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

Miklos Vajna vmiklos at kemper.freedesktop.org
Wed Apr 11 02:17:02 PDT 2012


 sw/qa/extras/rtftok/data/fdo44176.rtf       |   10 ++++++++++
 sw/qa/extras/rtftok/rtftok.cxx              |   18 ++++++++++++++++++
 writerfilter/source/dmapper/PropertyMap.cxx |   15 ++++++++++++---
 3 files changed, 40 insertions(+), 3 deletions(-)

New commits:
commit b0edaff7e2d885f80e96277967bfe29664c83df1
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Apr 11 09:45:53 2012 +0200

    fdo#44176 dmapper: fix import of titlepg top/bottom margin

diff --git a/sw/qa/extras/rtftok/data/fdo44176.rtf b/sw/qa/extras/rtftok/data/fdo44176.rtf
new file mode 100644
index 0000000..c1754af
--- /dev/null
+++ b/sw/qa/extras/rtftok/data/fdo44176.rtf
@@ -0,0 +1,10 @@
+{\rtf1
+{\header foo
+\par }
+\titlepg
+First page has no header.
+\par
+\pagebb
+Second page has a header.
+\par
+}
diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx
index a8908d5..e81fa3a 100644
--- a/sw/qa/extras/rtftok/rtftok.cxx
+++ b/sw/qa/extras/rtftok/rtftok.cxx
@@ -79,6 +79,7 @@ public:
     void testFdo48104();
     void testFdo47107();
     void testFdo45182();
+    void testFdo44176();
 
     CPPUNIT_TEST_SUITE(RtfModelTest);
 #if !defined(MACOSX) && !defined(WNT)
@@ -100,6 +101,7 @@ public:
     CPPUNIT_TEST(testFdo48104);
     CPPUNIT_TEST(testFdo47107);
     CPPUNIT_TEST(testFdo45182);
+    CPPUNIT_TEST(testFdo44176);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -515,6 +517,22 @@ void RtfModelTest::testFdo45182()
     CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
 }
 
+void RtfModelTest::testFdo44176()
+{
+    load("fdo44176.rtf");
+
+    uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XNameAccess> xStyles(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
+    uno::Reference<container::XNameAccess> xPageStyles(xStyles->getByName("PageStyles"), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xFirstPage(xPageStyles->getByName("First Page"), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xDefault(xPageStyles->getByName("Default"), uno::UNO_QUERY);
+    sal_Int32 nFirstTop = 0, nDefaultTop = 0, nDefaultHeader = 0;
+    xFirstPage->getPropertyValue("TopMargin") >>= nFirstTop;
+    xDefault->getPropertyValue("TopMargin") >>= nDefaultTop;
+    xDefault->getPropertyValue("HeaderHeight") >>= nDefaultHeader;
+    CPPUNIT_ASSERT_EQUAL(nFirstTop, nDefaultTop + nDefaultHeader);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index ee3ba7f..471f9b8 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -778,9 +778,18 @@ void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
         operator[]( PropertyDefinition( PROP_FOOTER_BODY_DISTANCE, false )) = uno::makeAny( m_nHeaderBottom );
     }
 
-    //now set the top/bottom margin for the follow page style
-    operator[]( PropertyDefinition( PROP_TOP_MARGIN, false )) = uno::makeAny( m_nTopMargin );
-    operator[]( PropertyDefinition( PROP_BOTTOM_MARGIN, false )) = uno::makeAny( m_nBottomMargin );
+    //now set the top/bottom margin
+    sal_Int32 nHeaderHeight = 0, nFooterHeight = 0;
+    if (bFirstPage)
+    {
+        // make sure the height of the header/footer is added to the top/bottom margin if necessary
+        if (m_aFollowPageStyle.is() && !HasHeader(true) && HasHeader(false))
+            m_aFollowPageStyle->getPropertyValue("HeaderHeight") >>= nHeaderHeight;
+        if (m_aFollowPageStyle.is() && !HasFooter(true) && HasFooter(false))
+            m_aFollowPageStyle->getPropertyValue("FooterHeight") >>= nFooterHeight;
+    }
+    operator[]( PropertyDefinition( PROP_TOP_MARGIN, false )) = uno::makeAny( m_nTopMargin + nHeaderHeight );
+    operator[]( PropertyDefinition( PROP_BOTTOM_MARGIN, false )) = uno::makeAny( m_nBottomMargin + nFooterHeight );
 }
 
 


More information about the Libreoffice-commits mailing list