Kaydet (Commit) b0edaff7 authored tarafından Miklos Vajna's avatar Miklos Vajna

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

üst dd9bbad2
{\rtf1
{\header foo
\par }
\titlepg
First page has no header.
\par
\pagebb
Second page has a header.
\par
}
......@@ -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();
......
......@@ -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 );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment