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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Oct 11 01:53:03 PDT 2012


 sw/qa/extras/ooxmlimport/data/n783638.docx    |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx      |   13 ++++++++++++
 writerfilter/source/dmapper/GraphicImport.cxx |   28 +++++++++++++++++---------
 3 files changed, 32 insertions(+), 9 deletions(-)

New commits:
commit e2c481db7b905305128e733bb1fc8d0ad8cadbf5
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Oct 11 10:48:16 2012 +0200

    n#783638 testcase
    
    Change-Id: I6b6093ba1e6961e421ac9754fdbdea9ba63eeda0

diff --git a/sw/qa/extras/ooxmlimport/data/n783638.docx b/sw/qa/extras/ooxmlimport/data/n783638.docx
new file mode 100644
index 0000000..93b587b
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/n783638.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index acc2097..c3a0bc5 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -104,6 +104,7 @@ public:
     void testShadow();
     void testN782061();
     void testN782345();
+    void testN783638();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -150,6 +151,7 @@ public:
     CPPUNIT_TEST(testShadow);
     CPPUNIT_TEST(testN782061);
     CPPUNIT_TEST(testN782345);
+    CPPUNIT_TEST(testN783638);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -1077,6 +1079,17 @@ void Test::testN779957()
     }
 }
 
+void Test::testN783638()
+{
+    // The problem was that the margins of inline images were not zero.
+    load("n783638.docx");
+
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPropertySet, "LeftMargin"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 3d7e168a2a43c2414b0633379102ddb29437e75b
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Oct 11 10:21:57 2012 +0200

    n#783638 DOCX import of wp:inline's distT/B/L/R attributes
    
    Change-Id: I181fcae021eed07608b06744b469628e4d78ccba

diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 9042f80..5709a17 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -339,6 +339,15 @@ public:
     {
         return bYSizeValid;
     }
+
+    void applyMargins(uno::Reference< beans::XPropertySet > xGraphicObjectProperties) const
+    {
+        PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
+        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_LEFT_MARGIN ), uno::makeAny(nLeftMargin));
+        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_RIGHT_MARGIN ), uno::makeAny(nRightMargin));
+        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_TOP_MARGIN ), uno::makeAny(nTopMargin));
+        xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_BOTTOM_MARGIN ), uno::makeAny(nBottomMargin));
+    }
 };
 
 
@@ -969,10 +978,17 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
             }
         break;
         case NS_ooxml::LN_CT_Inline_distT:
+            m_pImpl->nTopMargin = ConversionHelper::convertTwipToMM100(nIntValue);
+        break;
         case NS_ooxml::LN_CT_Inline_distB:
+            m_pImpl->nBottomMargin = ConversionHelper::convertTwipToMM100(nIntValue);
+        break;
         case NS_ooxml::LN_CT_Inline_distL:
+            m_pImpl->nLeftMargin = ConversionHelper::convertTwipToMM100(nIntValue);
+        break;
         case NS_ooxml::LN_CT_Inline_distR:
-            //TODO: need to be handled
+            m_pImpl->nRightMargin = ConversionHelper::convertTwipToMM100(nIntValue);
+        break;
         break;
         case NS_ooxml::LN_CT_GraphicalObjectData_uri:
             val.getString();
@@ -1453,14 +1469,7 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b
                     uno::makeAny(m_pImpl->bContour));
                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_CONTOUR_OUTSIDE ),
                     uno::makeAny(m_pImpl->bContourOutside));
-                xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_LEFT_MARGIN ),
-                    uno::makeAny(m_pImpl->nLeftMargin));
-                xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_RIGHT_MARGIN ),
-                    uno::makeAny(m_pImpl->nRightMargin));
-                xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_TOP_MARGIN ),
-                    uno::makeAny(m_pImpl->nTopMargin));
-                xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_BOTTOM_MARGIN ),
-                    uno::makeAny(m_pImpl->nBottomMargin));
+                m_pImpl->applyMargins(xGraphicObjectProperties);
 
                 if( m_pImpl->eColorMode == drawing::ColorMode_STANDARD &&
                     m_pImpl->nContrast == -70 &&
@@ -1550,6 +1559,7 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b
                 if( m_pImpl->getXSize() && m_pImpl->getYSize() )
                     xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_SIZE),
                         uno::makeAny( awt::Size( m_pImpl->getXSize(), m_pImpl->getYSize() )));
+                m_pImpl->applyMargins(xGraphicObjectProperties);
                 try
                 {
                     if( !m_pImpl->sName.isEmpty() )


More information about the Libreoffice-commits mailing list