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

Zolnai Tamás tamas.zolnai at collabora.com
Tue Jun 10 10:13:03 PDT 2014


 dev/null                                    |binary
 oox/source/drawingml/textbodyproperties.cxx |    6 +--
 oox/source/drawingml/transform2dcontext.cxx |   56 +++++++++++++++-------------
 sd/qa/unit/data/pptx/bnc862510_5.pptx       |binary
 sd/qa/unit/import-tests.cxx                 |   44 +++++++++++-----------
 5 files changed, 57 insertions(+), 49 deletions(-)

New commits:
commit 98dd0f2bb5801f974374ef341037e094e4275cbb
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Tue Jun 10 18:19:30 2014 +0200

    Related bnc#862510: extend handling of txXfrm
    
    We don't actually need to check mbAnchorCtr to change
    text spacing. This txXfrm workaround works only with rectangles,
    because other shapes' text area can be smaller then the shape
    size. So add some condition to avoid using it for
    other shapes.
    
    Plus fix typos cause regression introduced in:
    53c376d35b7223d53e8c9403390afe53d1f69089
    
    Change-Id: I87917b8e0b2bb97ae1bba773e7dda7f81682736f

diff --git a/oox/source/drawingml/textbodyproperties.cxx b/oox/source/drawingml/textbodyproperties.cxx
index 9899fbb..dfa3d60 100644
--- a/oox/source/drawingml/textbodyproperties.cxx
+++ b/oox/source/drawingml/textbodyproperties.cxx
@@ -81,9 +81,9 @@ void TextBodyProperties::pushRotationAdjustments( sal_Int32 nRotation )
         // Hack for n#760986
         // TODO: Preferred method would be to have a textbox on top
         // of the shape and the place it according to the (off,ext)
-        if( nOff == 0 && moTextOffLeft && mbAnchorCtr ) nVal = *moTextOffLeft;
-        if( nOff == 1 && moTextOffUpper ) nVal = *moTextOffLeft;
-        if( nOff == 2 && moTextOffRight && mbAnchorCtr ) nVal = *moTextOffRight;
+        if( nOff == 0 && moTextOffLeft  ) nVal = *moTextOffLeft;
+        if( nOff == 1 && moTextOffUpper ) nVal = *moTextOffUpper;
+        if( nOff == 2 && moTextOffRight ) nVal = *moTextOffRight;
         if( nOff == 3 && moTextOffLower ) nVal = *moTextOffLower;
         if( nVal < 0 ) nVal = 0;
 
diff --git a/oox/source/drawingml/transform2dcontext.cxx b/oox/source/drawingml/transform2dcontext.cxx
index c036b50..d3f7f5e 100644
--- a/oox/source/drawingml/transform2dcontext.cxx
+++ b/oox/source/drawingml/transform2dcontext.cxx
@@ -55,37 +55,43 @@ ContextHandlerRef Transform2DContext::onCreateContext( sal_Int32 aElementToken,
 {
     if( mbtxXfrm )
     {
-        switch( aElementToken )
+        // Workaround: only for rectangles
+        const sal_Int32 nType = mrShape.getCustomShapeProperties()->getShapePresetType();
+        if( nType == XML_rect || nType == XML_roundRect )
         {
-            case A_TOKEN( off ):
-                {
-                    OUString sXValue = rAttribs.getString( XML_x ).get();
-                    OUString sYValue = rAttribs.getString( XML_y ).get();
-                    if( !sXValue.isEmpty() )
-                        mrShape.getTextBody()->getTextProperties().moTextOffUpper = GetCoordinate( sXValue.toInt32() - mrShape.getPosition().X );
-                    if( !sYValue.isEmpty() )
-                        mrShape.getTextBody()->getTextProperties().moTextOffLeft = GetCoordinate( sYValue.toInt32() - mrShape.getPosition().Y );
-                }
-                break;
-            case A_TOKEN( ext ):
-                {
-                    const OUString sXValue = rAttribs.getString( XML_cx ).get();
-                    const OUString sYValue = rAttribs.getString( XML_cy ).get();
-                    if( !sXValue.isEmpty() )
+            switch( aElementToken )
+            {
+                case A_TOKEN( off ):
                     {
-                        mrShape.getTextBody()->getTextProperties().moTextOffRight = GetCoordinate(mrShape.getSize().Width - sXValue.toInt32());
-                        if( mrShape.getTextBody()->getTextProperties().moTextOffLeft )
-                           *mrShape.getTextBody()->getTextProperties().moTextOffRight -=  *mrShape.getTextBody()->getTextProperties().moTextOffLeft;
+                        const OUString sXValue = rAttribs.getString( XML_x ).get();
+                        const OUString sYValue = rAttribs.getString( XML_y ).get();
+                        if( !sXValue.isEmpty() && nType == XML_rect )
+                            mrShape.getTextBody()->getTextProperties().moTextOffLeft = GetCoordinate( sXValue.toInt32() - mrShape.getPosition().X );
+                        if( !sYValue.isEmpty() )
+                            mrShape.getTextBody()->getTextProperties().moTextOffUpper = GetCoordinate( sYValue.toInt32() - mrShape.getPosition().Y );
                     }
-                    if( !sYValue.isEmpty() )
+                    break;
+                case A_TOKEN( ext ):
                     {
-                        mrShape.getTextBody()->getTextProperties().moTextOffLower = GetCoordinate(mrShape.getSize().Height - sYValue.toInt32());
-                        if( mrShape.getTextBody()->getTextProperties().moTextOffUpper )
-                           *mrShape.getTextBody()->getTextProperties().moTextOffLower -=  *mrShape.getTextBody()->getTextProperties().moTextOffUpper;
+                        const OUString sXValue = rAttribs.getString( XML_cx ).get();
+                        const OUString sYValue = rAttribs.getString( XML_cy ).get();
 
+                        if( !sXValue.isEmpty() && nType == XML_rect )
+                        {
+                            mrShape.getTextBody()->getTextProperties().moTextOffRight = GetCoordinate(mrShape.getSize().Width - sXValue.toInt32());
+                            if( mrShape.getTextBody()->getTextProperties().moTextOffLeft )
+                               *mrShape.getTextBody()->getTextProperties().moTextOffRight -=  *mrShape.getTextBody()->getTextProperties().moTextOffLeft;
+                        }
+                        if( !sYValue.isEmpty() )
+                        {
+                            mrShape.getTextBody()->getTextProperties().moTextOffLower = GetCoordinate(mrShape.getSize().Height - sYValue.toInt32());
+                            if( mrShape.getTextBody()->getTextProperties().moTextOffUpper )
+                               *mrShape.getTextBody()->getTextProperties().moTextOffLower -=  *mrShape.getTextBody()->getTextProperties().moTextOffUpper;
+
+                        }
                     }
-                }
-                break;
+                    break;
+            }
         }
         return 0;
     }
diff --git a/sd/qa/unit/data/pptx/bnc862510_5.pptx b/sd/qa/unit/data/pptx/bnc862510_5.pptx
new file mode 100644
index 0000000..ed145e4
Binary files /dev/null and b/sd/qa/unit/data/pptx/bnc862510_5.pptx differ
diff --git a/sd/qa/unit/data/pptx/n862510_3.pptx b/sd/qa/unit/data/pptx/n862510_3.pptx
deleted file mode 100644
index cf0b7b5..0000000
Binary files a/sd/qa/unit/data/pptx/n862510_3.pptx and /dev/null differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 1c36673..cc9339a 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -70,7 +70,6 @@ public:
     void testStrictOOXML();
     void testN862510_1();
     void testN862510_2();
-    void testN862510_3();
     void testN862510_4();
     void testFdo71961();
     void testMediaEmbedding();
@@ -78,6 +77,7 @@ public:
     void testBnc870233_1();
     void testBnc870233_2();
     void testBnc880763();
+    void testBnc862510_5();
 
     CPPUNIT_TEST_SUITE(SdFiltersTest);
     CPPUNIT_TEST(testDocumentLayout);
@@ -98,7 +98,6 @@ public:
     CPPUNIT_TEST(testStrictOOXML);
     CPPUNIT_TEST(testN862510_1);
     CPPUNIT_TEST(testN862510_2);
-    CPPUNIT_TEST(testN862510_3);
     CPPUNIT_TEST(testN862510_4);
     CPPUNIT_TEST(testFdo71961);
     CPPUNIT_TEST(testMediaEmbedding);
@@ -106,6 +105,7 @@ public:
     CPPUNIT_TEST(testBnc870233_1);
     CPPUNIT_TEST(testBnc870233_2);
     CPPUNIT_TEST(testBnc880763);
+    CPPUNIT_TEST(testBnc862510_5);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -305,25 +305,6 @@ void SdFiltersTest::testN862510_2()
     xDocShRef->DoClose();
 }
 
-void SdFiltersTest::testN862510_3()
-{
-    ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_3.pptx") );
-
-    SdDrawDocument *pDoc = xDocShRef->GetDoc();
-    CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
-    const SdrPage *pPage = pDoc->GetPage( 1 );
-    CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
-    {
-        SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 0 ) );
-        CPPUNIT_ASSERT( pGrpObj );
-        SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>( pGrpObj->GetSubList()->GetObj( 0 ) );
-        CPPUNIT_ASSERT( pObj );
-        CPPUNIT_ASSERT_MESSAGE( "Left Spacing is wrong! check attribute anchorCtr", pObj->GetTextLeftDistance() < 30);
-    }
-
-    xDocShRef->DoClose();
-}
-
 void SdFiltersTest::testN862510_4()
 {
     ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_4.pptx") );
@@ -927,6 +908,27 @@ void SdFiltersTest::testBnc880763()
     xDocShRef->DoClose();
 }
 
+void SdFiltersTest::testBnc862510_5()
+{
+    ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_5.pptx"));
+    xDocShRef = saveAndReload( xDocShRef, PPTX );
+
+    SdDrawDocument *pDoc = xDocShRef->GetDoc();
+    CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+    const SdrPage *pPage = pDoc->GetPage (1);
+    CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+
+    // Same as testBnc870237, but here we check the horizontal spacing
+    const SdrObject* pObj = dynamic_cast<SdrObject*>( pPage->GetObj( 1 ) );
+    CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL);
+    CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrTextUpperDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST))).GetValue());
+    CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrTextLowerDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST))).GetValue());
+    CPPUNIT_ASSERT_EQUAL( sal_Int32(7510), (static_cast< const SdrTextRightDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_RIGHTDIST))).GetValue());
+    CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrTextLeftDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_LEFTDIST))).GetValue());
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list