[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/source

Tamás Zolnai tamas.zolnai at collabora.com
Sat Oct 29 16:43:56 UTC 2016


 sw/qa/extras/ooxmlexport/data/tdf103573.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx      |   19 +++++++++++++++++++
 sw/source/filter/ww8/docxsdrexport.cxx         |    6 ++++--
 writerfilter/source/dmapper/GraphicHelpers.cxx |    8 ++++++--
 4 files changed, 29 insertions(+), 4 deletions(-)

New commits:
commit 24e522f723569b53d9a830166b3825292bcd7527
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Sat Oct 29 15:49:18 2016 +0000

    tdf#103753: DOCX: Handle relative positions to left or right margin
    
    Positioning relative to left or right margin in MS Word
    works the same as the positioning relative to left or right
    page border in LO Writer.
    
    Change-Id: I476a5e9e76f766b7fb7f1c7f4a068af8bb3c8813
    Reviewed-on: https://gerrit.libreoffice.org/30376
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf103573.docx b/sw/qa/extras/ooxmlexport/data/tdf103573.docx
new file mode 100644
index 0000000..34d7e33
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf103573.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 5ee0ff4..a580bc9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -18,6 +18,8 @@
 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 #include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/RelOrientation.hpp>
 
 class Test : public SwModelTestBase
 {
@@ -85,6 +87,23 @@ DECLARE_OOXMLEXPORT_TEST(testTdf103544, "tdf103544.docx")
     CPPUNIT_ASSERT(xGraphic.is());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf103573, "tdf103573.docx")
+{
+    // Relative positions to the left or right margin (MS Word naming) was not handled.
+    uno::Reference<beans::XPropertySet> xShapeProperties( getShape(1), uno::UNO_QUERY );
+    sal_Int16 nValue;
+    xShapeProperties->getPropertyValue("HoriOrient") >>= nValue;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally", text::HoriOrientation::CENTER, nValue);
+    xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally relatively to left page border", text::RelOrientation::PAGE_LEFT, nValue);
+
+    xShapeProperties.set( getShape(2), uno::UNO_QUERY );
+    xShapeProperties->getPropertyValue("HoriOrient") >>= nValue;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally", text::HoriOrientation::CENTER, nValue);
+    xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally relatively to right page border", text::RelOrientation::PAGE_RIGHT, nValue);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 163f45c..0fe507f 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -444,8 +444,10 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
             relativeFromH = "character";
             break;
         case text::RelOrientation::PAGE_RIGHT:
-            relativeFromH = "page";
-            alignH = "right";
+            relativeFromH = "rightMargin";
+            break;
+        case text::RelOrientation::PAGE_LEFT:
+            relativeFromH = "leftMargin";
             break;
         case text::RelOrientation::FRAME:
         default:
diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx
index 0dccda7..8c4dd9c 100644
--- a/writerfilter/source/dmapper/GraphicHelpers.cxx
+++ b/writerfilter/source/dmapper/GraphicHelpers.cxx
@@ -94,7 +94,9 @@ void PositionHandler::lcl_attribute( Id aName, Value& rVal )
                     NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_margin,
                     NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page,
                     NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_column,
-                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_character
+                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_character,
+                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_leftMargin,
+                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_rightMargin
                 };
 
                 static const sal_Int16 pHoriRelations[] =
@@ -103,9 +105,11 @@ void PositionHandler::lcl_attribute( Id aName, Value& rVal )
                     text::RelOrientation::PAGE_FRAME,
                     text::RelOrientation::FRAME,
                     text::RelOrientation::CHAR,
+                    text::RelOrientation::PAGE_LEFT,
+                    text::RelOrientation::PAGE_RIGHT,
                 };
 
-                for ( int i = 0; i < 4; i++ )
+                for ( int i = 0; i < 6; i++ )
                 {
                     if ( pHoriRelValues[i] == sal_uInt32( nIntValue ) )
                         m_nRelation = pHoriRelations[i];


More information about the Libreoffice-commits mailing list