[Libreoffice-commits] core.git: include/svx oox/source sd/qa svx/source

2023-04-17 Thread Sarper Akdemir (via logerrit)
 include/svx/svddef.hxx|4 ++
 oox/source/drawingml/table/tablecell.cxx  |   38 ++
 oox/source/export/shapes.cxx  |   14 +
 sd/qa/unit/data/pptx/tcPr-vert-roundtrip.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx|   12 
 svx/source/inc/cell.hxx   |3 ++
 svx/source/svdraw/svdattr.cxx |3 ++
 svx/source/table/cell.cxx |   21 ++
 8 files changed, 89 insertions(+), 6 deletions(-)

New commits:
commit 178832ef7139b9279a3ae0056eb11be9c476800e
Author: Sarper Akdemir 
AuthorDate: Wed Mar 29 19:44:18 2023 +0300
Commit: Sarper Akdemir 
CommitDate: Mon Apr 17 16:21:06 2023 +0200

oox: tcPr vert roundtrip, introduce interopability grab bag for table cell

To properly roundtrip all possible values of 

+ Introduce grab bag for table cell
+ on import: Store the unsupported values in the grab bag:
  + (e.g. wordArtVert, mongolianVert, wordArtVertRtl)
+ on export: if nothing is being exported from the doc
  model, export the value from the grabbag

Also adds a unit test covering this behavior.

Change-Id: I791ed2d992b0a554ef6da37200f027cffd8c5f2f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149737
Tested-by: Jenkins
Reviewed-by: Sarper Akdemir 

diff --git a/include/svx/svddef.hxx b/include/svx/svddef.hxx
index 85a72e5b713d..84db8c4d0aa4 100644
--- a/include/svx/svddef.hxx
+++ b/include/svx/svddef.hxx
@@ -138,6 +138,7 @@ class SdrVertShearAllItem;
 class SdrVertShearOneItem;
 class SdrYesNoItem;
 class SfxBoolItem;
+class SfxGrabBagItem;
 class SfxInt16Item;
 class SfxUInt16Item;
 class SfxUInt32Item;
@@ -417,7 +418,8 @@ constexpr TypedWhichId
SDRATTR_TABLE_BORDER_INNER  (SDRATTR_T
 constexpr TypedWhichId   SDRATTR_TABLE_BORDER_TLBR   
(SDRATTR_TABLE_FIRST+2);
 constexpr TypedWhichId   SDRATTR_TABLE_BORDER_BLTR   
(SDRATTR_TABLE_FIRST+3);
 constexpr TypedWhichId SDRATTR_TABLE_TEXT_ROTATION 
(SDRATTR_TABLE_FIRST+4);
-constexpr sal_uInt16  SDRATTR_TABLE_LAST  
(SDRATTR_TABLE_TEXT_ROTATION);
+constexpr TypedWhichIdSDRATTR_TABLE_GRABBAG   
(SDRATTR_TABLE_FIRST+5);
+constexpr sal_uInt16  SDRATTR_TABLE_LAST  
(SDRATTR_TABLE_GRABBAG);
 
 constexpr sal_uInt16  SDRATTR_GLOW_FIRST 
(SDRATTR_TABLE_LAST+1);
 constexpr TypedWhichId SDRATTR_GLOW_RADIUS   
(SDRATTR_GLOW_FIRST+0);
diff --git a/oox/source/drawingml/table/tablecell.cxx 
b/oox/source/drawingml/table/tablecell.cxx
index 17b13526084d..b0849b7002f3 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -29,12 +29,15 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
 
 using namespace ::oox::core;
 using namespace ::com::sun::star;
@@ -566,6 +569,36 @@ void TableCell::pushToXCell( const 
::oox::core::XmlFilterBase& rFilterBase, cons
 {
 xPropSet->setPropertyValue("TextWritingMode", 
Any(css::text::WritingMode_TB_RL));
 }
+else if ( getVertToken() == XML_vert )
+{
+xPropSet->setPropertyValue("RotateAngle", Any(short(27000)));
+}
+else if ( getVertToken() == XML_vert270 )
+{
+xPropSet->setPropertyValue("RotateAngle", Any(short(9000)));
+}
+else if ( getVertToken() != XML_horz )
+{
+// put the vert value in the grab bag for roundtrip
+const Sequence& aTokenNameSeq = 
StaticTokenMap().getUtf8TokenName(getVertToken());
+const OUString aTokenName{ reinterpret_cast(aTokenNameSeq.getConstArray()),
+   aTokenNameSeq.getLength(), 
RTL_TEXTENCODING_UTF8 };
+
+Sequence aGrabBag;
+xPropSet->getPropertyValue("CellInteropGrabBag") >>= aGrabBag;
+PropertyValue aPropertyValue = 
comphelper::makePropertyValue("mso-tcPr-vert-value", aTokenName);
+if (aGrabBag.hasElements())
+{
+sal_Int32 nLength = aGrabBag.getLength();
+aGrabBag.realloc(nLength + 1);
+aGrabBag.getArray()[nLength] = aPropertyValue;
+}
+else
+{
+aGrabBag = { aPropertyValue };
+}
+xPropSet->setPropertyValue("CellInteropGrabBag", Any(aGrabBag));
+}
 
 getTextBody()->insertAt( rFilterBase, xText, xAt, aTextStyleProps, 
pMasterTextListStyle );
 
@@ -582,11 +615,6 @@ void TableCell::pushToXCell( const 
::oox::core::XmlFilterBase& rFilterBase, cons
 aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase);
 }
 }
-
-if (getVertToken() == XML_vert)
-xPropSet->setPropertyValue("RotateAngle", Any(short(27000)));
-else if (getVertToken() == XML_vert270)
-xPropSet->setPropertyValue("RotateAngle", Any(short(9000)));
 }
 
 }
diff --git a/oox/source/export/shapes.cxx 

[Libreoffice-commits] core.git: include/svx oox/source sd/qa svx/source

2022-08-31 Thread Sarper Akdemir (via logerrit)
 include/svx/svdotable.hxx   |7 ++
 oox/source/drawingml/shape.cxx  |   25 
 sd/qa/unit/data/pptx/tdf144092-tableHeight.pptx |binary
 sd/qa/unit/export-tests-ooxml2.cxx  |2 -
 sd/qa/unit/import-tests2.cxx|   17 
 svx/source/table/svdotable.cxx  |   12 +++
 svx/source/table/tablelayouter.hxx  |6 ++---
 7 files changed, 65 insertions(+), 4 deletions(-)

New commits:
commit a5126a21351c87138ff86a6636326eb6cd6a0f8c
Author: Sarper Akdemir 
AuthorDate: Wed Aug 17 16:23:29 2022 +0300
Commit: Miklos Vajna 
CommitDate: Wed Aug 31 08:05:21 2022 +0200

tdf#144092 pptx import: correct table height during import

It appears PowerPoint can export rows of a table with row heights that
is less than the minimum height (for that row). And also export the
total table height wrong with it.

If PowerPoint imports such a table, those rows are individually
expanded to the minimum height. (Also increasing the table's total
height)

In Impress import we calculate table height by adding up individual
row heights. Table layouting code depends on the table height being
correct. This is why rows with less than minimum height lead to
layouting problems.

To compensate for this, while importing tables, layouting is skipped
until the table height is updated with the corrected height.

The correct height is calculated by layouting the table without
fitting to an area (i.e with bFit = false).

Change-Id: I79187882470a4e285b45bca1eabb469a084067f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138652
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx
index c12d7af6857c..64996cce2717 100644
--- a/include/svx/svdotable.hxx
+++ b/include/svx/svdotable.hxx
@@ -258,6 +258,13 @@ public:
 /// Next time layouting would be done, skip it (to layout at the end of 
multiple actions).
 void SetSkipChangeLayout(bool bSkipChangeLayout);
 
+/** Tries to get table height if rows with sizes less then the minimum 
size were expanded
+
+(i.e. Table height layouted without fitting to an area)
+Helper for OOXML import
+ */
+sal_Int32 getHeightWithoutFitting();
+
 virtual void onEditOutlinerStatusEvent( EditStatus* pEditStatus ) override;
 
 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 3e81a1b95a27..1e7a702b25e6 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -94,6 +94,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -834,6 +835,8 @@ Reference< XShape > const & Shape::createAndInsert(
 maSize.Height = 0;
 for (auto const& elem : mpTablePropertiesPtr->getTableRows())
 {
+// WARN: When less then minimum sized rows exist, calculated 
height here
+// is corrected before layouting takes place
 maSize.Height = o3tl::saturating_add(maSize.Height, 
elem.getHeight());
 }
 }
@@ -1256,7 +1259,14 @@ Reference< XShape > const & Shape::createAndInsert(
 mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, 
rGraphicHelper, mbFlipH, mbFlipV );
 }
 if ( mpTablePropertiesPtr && aServiceName == 
"com.sun.star.drawing.TableShape" )
+{
 mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, 
mpMasterTextListStyle );
+if ( auto* pTableShape = 
dynamic_cast(SdrObject::getSdrObjectFromXShape(mxShape))
 )
+{
+// Disable layouting until an attempt at correcting faulty 
table height is made
+pTableShape->SetSkipChangeLayout(true);
+}
+}
 
 FillProperties aFillProperties = getActualFillProperties(pTheme, 
);
 if (getFillProperties().moFillType.has_value() && 
getFillProperties().moFillType.value() == XML_grpFill)
@@ -1488,6 +1498,21 @@ Reference< XShape > const & Shape::createAndInsert(
 }
 
 PropertySet( xSet ).setProperties( aShapeProps );
+
+if (mpTablePropertiesPtr && aServiceName == 
"com.sun.star.drawing.TableShape")
+{
+// Powerpoint sometimes export row heights less than the 
minimum size,
+// which during import expanded to the minimum
+if (auto* pTableShape = 
dynamic_cast(SdrObject::getSdrObjectFromXShape(mxShape)))
+{
+sal_Int32 nCorrectedHeight = 
pTableShape->getHeightWithoutFitting();
+const auto& aShapeSize = mxShape->getSize();
+if( nCorrectedHeight > aShapeSize.Height )
+mxShape->setSize( {aShapeSize.Width, nCorrectedHeight} 

[Libreoffice-commits] core.git: include/svx oox/source sd/qa svx/source

2021-06-06 Thread Mike Kaganski (via logerrit)
 include/svx/svdotext.hxx   |2 -
 oox/source/export/drawingml.cxx|5 --
 sd/qa/unit/export-tests-ooxml2.cxx |5 +-
 svx/source/svdraw/svdotext.cxx |   65 +++--
 svx/source/unodraw/unoshape.cxx|9 -
 5 files changed, 12 insertions(+), 74 deletions(-)

New commits:
commit a1ae30166e92a0a40dff06740f0bb8e9ee63f70a
Author: Mike Kaganski 
AuthorDate: Sun Jun 6 21:50:53 2021 +0300
Commit: Mike Kaganski 
CommitDate: Sun Jun 6 21:58:09 2021 +0200

Fix and unify the two methods that get scaled text size

GetTextFitToSizeScale and SdrTextObj::GetFontScaleY both didn't
initialize outliners properly, and thus returned wrong results.

Change-Id: I6fe63c51ed838a0d0fafdfa03597cac97ce29831
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116765
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 61a63f660950..a3ff2e1fda50 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -392,7 +392,7 @@ public:
 // FitToSize and Fontwork are not taken into account in GetTextSize()!
 virtual const Size& GetTextSize() const;
 void FitFrameToTextSize();
-double GetFontScaleY() const;
+sal_uInt16 GetFontScaleY() const;
 
 // Simultaneously sets the text into the Outliner (possibly
 // the one of the EditOutliner) and sets the PaperSize.
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 6805c1bd3a49..684623a41813 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3302,10 +3302,7 @@ void DrawingML::WriteText(const Reference& 
rXIface, bool bBodyPr, bo
 {
 SdrTextObj* pTextObject = 
dynamic_cast(pTextShape->GetSdrObject());
 if (pTextObject)
-{
-double fScaleY = pTextObject->GetFontScaleY();
-nFontScale = static_cast(fScaleY * 100) * 
1000;
-}
+nFontScale = pTextObject->GetFontScaleY() * 1000;
 }
 
 mpFS->singleElementNS(XML_a, XML_normAutofit, XML_fontScale,
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index af1fb0e7d99a..abf469788695 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -1899,10 +1899,9 @@ void SdOOXMLExportTest2::testFontScale()
 xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
 xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, 
"ppt/slides/slide1.xml");
 
-// Rounding errors possible, approximate value
+// Rounding errors possible, approximate value (+/- 1%)
 OUString sScale = getXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:bodyPr/a:normAutofit", "fontScale");
-if (sScale != "73000" && sScale != "72000" && sScale != "74000")
-CPPUNIT_ASSERT_EQUAL(OUString("73000"), sScale);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(76000), sScale.toInt32(), 1000);
 
 xDocShRef->DoClose();
 }
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index ef9cedaeedb5..090ffc901dfe 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace com::sun::star;
 
@@ -1186,67 +1187,15 @@ void SdrTextObj::ImpSetupDrawOutlinerForPaint( bool 
bContourFrame,
 }
 }
 
-double SdrTextObj::GetFontScaleY() const
+sal_uInt16 SdrTextObj::GetFontScaleY() const
 {
-SdrText* pText = getActiveText();
-if (pText == nullptr || !pText->GetOutlinerParaObject())
-return 1.0;
-
 SdrOutliner& rOutliner = ImpGetDrawOutliner();
-const Size aShapeSize = GetSnapRect().GetSize();
-const Size aSize(aShapeSize.Width() - GetTextLeftDistance() - 
GetTextRightDistance(),
-aShapeSize.Height() - GetTextUpperDistance() - GetTextLowerDistance());
-
-rOutliner.SetPaperSize(aSize);
-rOutliner.SetUpdateMode(true);
-rOutliner.SetText(*pText->GetOutlinerParaObject());
-bool bIsVerticalWriting = IsVerticalWriting();
-
-// Algorithm from SdrTextObj::ImpAutoFitText
-
-sal_uInt16 nMinStretchX = 0, nMinStretchY = 0;
-sal_uInt16 nCurrStretchX = 100, nCurrStretchY = 100;
-sal_uInt16 aOldStretchXVals[] = { 0,0,0 };
-const size_t aStretchArySize = SAL_N_ELEMENTS(aOldStretchXVals);
-for (unsigned int i = 0; i= 1.0)
-{
-nMinStretchX = std::max(nMinStretchX, nCurrStretchX);
-nMinStretchY = std::max(nMinStretchY, nCurrStretchY);
-}
-
-aOldStretchXVals[i] = nCurrStretchX;
-if (std::find(aOldStretchXVals, aOldStretchXVals + i, nCurrStretchX) 
!= aOldStretchXVals + i)
-break; // same value already attained once; algo is looping, exit
-
-if (fFactor < 1.0 || nCurrStretchX != 100)
- 

[Libreoffice-commits] core.git: include/svx oox/source sd/qa svx/source

2018-02-16 Thread Szymon Kłos
 include/svx/svdotext.hxx |2 +
 oox/source/export/drawingml.cxx  |   19 ++
 sd/qa/unit/data/pptx/font-scale.pptx |binary
 sd/qa/unit/export-tests-ooxml2.cxx   |   14 +++
 svx/source/svdraw/svdotext.cxx   |   63 +++
 5 files changed, 97 insertions(+), 1 deletion(-)

New commits:
commit 2c2919cb591d88b11bb2e25e45d6f75923821457
Author: Szymon Kłos 
Date:   Tue Feb 13 17:47:23 2018 +0100

PPTX export scale for TextFitToSize

MSO requires to save fontScale attribute to have
all the text shown properly (with FitToSize property)

Values are approximated, after any modification in MSO
scale is recalculated.

Change-Id: I73657fdd663b540b436747cfeeef3c76e8fe388c
Reviewed-on: https://gerrit.libreoffice.org/49742
Tested-by: Jenkins 
Reviewed-by: Szymon Kłos 

diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 4f862638ce8b..dd9972b3ce56 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -213,6 +213,7 @@ protected:
 
 virtual SdrObject* getFullDragClone() const override;
 
+
 public:
 const Point& GetTextEditOffset() const { return maTextEditOffset; }
 void SetTextEditOffset(const Point& rNew) { maTextEditOffset = rNew; }
@@ -385,6 +386,7 @@ public:
 // FitToSize and Fontwork are not taken into account in GetTextSize()!
 virtual const Size& GetTextSize() const;
 void FitFrameToTextSize();
+double GetFontScaleY() const;
 
 // Simultaneously sets the text into the Outliner (possibly
 // the one of the EditOutliner) and sets the PaperSize.
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 0503a088faf7..52807f28be3d 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2553,8 +2553,25 @@ void DrawingML::WriteText( const Reference< XInterface 
>& rXIface, const OUStrin
 TextFitToSizeType eFit = TextFitToSizeType_NONE;
 if (GETA(TextFitToSize))
 mAny >>= eFit;
+
 if (eFit == TextFitToSizeType_AUTOFIT)
-mpFS->singleElementNS(XML_a, XML_normAutofit, FSEND);
+{
+const sal_Int32 MAX_SCALE_VAL = 10;
+sal_Int32 nFontScale = MAX_SCALE_VAL;
+SvxShapeText* pTextShape = 
dynamic_cast(rXIface.get());
+if (pTextShape)
+{
+SdrTextObj* pTextObject = 
dynamic_cast(pTextShape->GetSdrObject());
+if (pTextObject)
+{
+double fScaleY = pTextObject->GetFontScaleY();
+nFontScale = static_cast(fScaleY * 100) * 
1000;
+}
+}
+
+mpFS->singleElementNS(XML_a, XML_normAutofit, XML_fontScale,
+( nFontScale < MAX_SCALE_VAL && nFontScale > 0 ) ? 
I32S(nFontScale) : nullptr, FSEND);
+}
 }
 mpFS->endElementNS((nXmlNamespace ? nXmlNamespace : XML_a), 
XML_bodyPr);
 }
diff --git a/sd/qa/unit/data/pptx/font-scale.pptx 
b/sd/qa/unit/data/pptx/font-scale.pptx
new file mode 100644
index ..df33b20cebca
Binary files /dev/null and b/sd/qa/unit/data/pptx/font-scale.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index 062dab0c4cd0..51e13eb80a5e 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -128,6 +128,7 @@ public:
 void testTdf90626();
 void testTdf107608();
 void testTdf111786();
+void testFontScale();
 void testTdf115394();
 void testTdf115394Zero();
 
@@ -183,6 +184,7 @@ public:
 CPPUNIT_TEST(testTdf90626);
 CPPUNIT_TEST(testTdf107608);
 CPPUNIT_TEST(testTdf111786);
+CPPUNIT_TEST(testFontScale);
 CPPUNIT_TEST(testTdf115394);
 CPPUNIT_TEST(testTdf115394Zero);
 
@@ -1406,6 +1408,18 @@ void SdOOXMLExportTest2::testTdf111786()
 xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest2::testFontScale()
+{
+sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/font-scale.pptx"), 
PPTX);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
+
+assertXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:bodyPr/a:normAutofit", "fontScale", 
"73000");
+
+xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest2::testTdf115394()
 {
 sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf115394.pptx"), 
PPTX);
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index a0cf962a7671..4a9f69d1afe3 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ 

[Libreoffice-commits] core.git: include/svx oox/source sd/qa svx/source

2017-08-10 Thread Paul Trojahn
 include/svx/svdoashp.hxx  |1 
 oox/source/drawingml/customshapeproperties.cxx|1 
 oox/source/drawingml/shape.cxx|   15 
 oox/source/export/drawingml.cxx   |6 
 oox/source/token/properties.txt   |1 
 sd/qa/unit/data/tdf109317.pptx|binary
 sd/qa/unit/data/xml/fdo47434_0.xml|4 
 sd/qa/unit/data/xml/n593612_0.xml |1 
 sd/qa/unit/data/xml/n762695_0.xml |8 
 sd/qa/unit/data/xml/n762695_1.xml |3 
 sd/qa/unit/data/xml/n819614_0.xml |   56 --
 sd/qa/unit/data/xml/n820786_0.xml |   51 -
 sd/qa/unit/data/xml/n902652_0.xml |3 
 sd/qa/unit/data/xml/tdf109317_0.xml   |  492 ++
 sd/qa/unit/import-tests.cxx   |1 
 svx/source/customshapes/EnhancedCustomShape2d.cxx |5 
 svx/source/customshapes/EnhancedCustomShapeEngine.cxx |9 
 svx/source/svdraw/svdoashp.cxx|   12 
 18 files changed, 517 insertions(+), 152 deletions(-)

New commits:
commit 3e33a2551532806b99f6c8ca415136cd3f2f9256
Author: Paul Trojahn 
Date:   Tue Aug 1 15:56:48 2017 +0200

tdf#109317 Fix incorrect rotation of flipped custom OOXML shapes

The shape wasn't imported correctly because IsPostRotateAngle wasn't
set. As a result the shape was flipped after it was rotated instead
of before. This commit removes 1c44b263 and converts the rotation to
the internal format instead. This also fixes that ooxml preset shapes
can't be exported to odf correctly and that ooxml preset shapes rotate
in the wrong direction when rotated in LO.

Change-Id: I9691902fdfb2cfecc8fe50d6eb66ac3880ddd4e8
Reviewed-on: https://gerrit.libreoffice.org/40789
Reviewed-by: Tamás Zolnai 
Tested-by: Tamás Zolnai 

diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx
index dd4d03789c51..ea222ed578de 100644
--- a/include/svx/svdoashp.hxx
+++ b/include/svx/svdoashp.hxx
@@ -140,7 +140,6 @@ public:
 
 bool IsMirroredX() const;
 bool IsMirroredY() const;
-bool IsPostRotate() const;
 void SetMirroredX( const bool bMirroredX );
 void SetMirroredY( const bool bMirroredY );
 
diff --git a/oox/source/drawingml/customshapeproperties.cxx 
b/oox/source/drawingml/customshapeproperties.cxx
index 57aedfcd022a..303d24ee4ac9 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -149,7 +149,6 @@ void CustomShapeProperties::pushToPropSet(
 aPropertyMap.setProperty( PROP_MirroredX, mbMirroredX );
 aPropertyMap.setProperty( PROP_MirroredY, mbMirroredY );
 aPropertyMap.setProperty( PROP_TextPreRotateAngle, mnTextRotateAngle );
-aPropertyMap.setProperty( PROP_IsPostRotateAngle, true); // For 
OpenXML Imports
 Sequence< PropertyValue > aSeq = 
aPropertyMap.makePropertyValueSequence();
 aPropSet.setProperty( PROP_CustomShapeGeometry, aSeq );
 
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 021178a9a8e4..77730ecd2aff 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -498,8 +498,21 @@ Reference< XShape > const & Shape::createAndInsert(
 
 if( bUseRotationTransform && mnRotation != 0 )
 {
+// OOXML flips shapes before rotating them.
+sal_Int32 nRotation = mnRotation;
+if(bIsCustomShape)
+{
+if(mbFlipH)
+{
+nRotation = nRotation * -1 + 6*360;
+}
+if(mbFlipV)
+{
+nRotation = nRotation * -1 + 6*360;
+}
+}
 // rotate around object's center
-aTransformation.rotate( F_PI180 * ( (double)mnRotation / 6.0 ) 
);
+aTransformation.rotate( F_PI180 * ( (double)nRotation / 6.0 ) 
);
 }
 
 // move object back from center
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index f04c0f3273d8..0110f4c24875 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1157,6 +1157,12 @@ void DrawingML::WriteStretch( const css::uno::Reference< 
css::beans::XPropertySe
 void DrawingML::WriteTransformation( const tools::Rectangle& rRect,
 sal_Int32 nXmlNamespace, bool bFlipH, bool bFlipV, sal_Int32 nRotation 
)
 {
+//OOXML flips shapes before rotating them.
+if(bFlipH)
+nRotation = nRotation * -1 + 6*360;
+if(bFlipV)
+nRotation = nRotation * -1 + 6*360;
+
 mpFS->startElementNS( nXmlNamespace, XML_xfrm,
   XML_flipH, bFlipH