diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-04-11 09:45:53 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-04-11 11:17:35 +0200 |
commit | b0edaff7e2d885f80e96277967bfe29664c83df1 (patch) | |
tree | 1ad26820e942d801cb7512b0e314306eaf7b6ef8 | |
parent | dd9bbad2b19d7c8bbe68dd2cdcf3d90d763d747d (diff) |
fdo#44176 dmapper: fix import of titlepg top/bottom margin
-rw-r--r-- | sw/qa/extras/rtftok/data/fdo44176.rtf | 10 | ||||
-rw-r--r-- | sw/qa/extras/rtftok/rtftok.cxx | 18 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 15 |
3 files changed, 40 insertions, 3 deletions
diff --git a/sw/qa/extras/rtftok/data/fdo44176.rtf b/sw/qa/extras/rtftok/data/fdo44176.rtf new file mode 100644 index 000000000000..c1754afced77 --- /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 a8908d5ad001..e81fa3a02440 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 ee3ba7f5e6eb..471f9b8cfa79 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 ); } |