summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorLuke Deller <luke@deller.id.au>2014-07-12 21:49:50 +1000
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-09-11 15:59:01 +0200
commit79bd799f0571a7213faa9b81709d0b4084a21c57 (patch)
tree757d2a72a465372eed9fd7cb97f17e4781d91a03 /writerfilter
parent416546ee8ef21d8ea33c1aa2c17dd6a9a0ac6189 (diff)
Related: fdo#82114 Copy first-header-footer test from ww8 to ooxml
The test document was converted from doc to docx using MS Word 2010. Several fixes were required to make this test pass: - Do not clear the "FirstIsShared" property on page styles, as the code instead uses the old fashioned method of translating a Word section with "different first page header/footer": two page styles linked together, the first page style and the follow page style. (Also remove a wrong test case which checks the FirstIsShared property) - Do not clear the "HeaderIsShared"/"FooterIsShared" properties on the first page style, only on the follow page style. - Actually set the "FollowStyle" property on the first page style to link it to the follow page style. This didn't matter for the very first Word section because it was mapped to the default page styles "First Page" and "Standard" which are already linked, but it does matter for subsequent Word sections. - For some reason setting a new page style at a section break was excluded in the case where the following section had a title page. Remove this exclusion. - The exclusion mentioned in the last point was masking that bnc#751077 was not entirely fixed. To resolve that issue: When checking if the last paragraph of the section is empty, consider not just text content but also shapes. - Remove a workaround for bnc#780843 involving copying of headers and footers from the "Standard" (first section) page style in the case where the following section had a title page. This workaround is no longer needed as the test case passes without it. (cherry picked from commit b4ccde72b8e2e45e7276d5b08b182495a1b1a617) Change-Id: Iacc9bba0720c11414da3e852892cff301ebbc4fe
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx4
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx52
2 files changed, 15 insertions, 41 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index b4e7e42a71a9..37152f647974 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1532,6 +1532,7 @@ void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::P
try
{
bool bLeft = eType == SectionPropertyMap::PAGE_LEFT;
+ bool bFirst = eType == SectionPropertyMap::PAGE_FIRST;
if ((!bLeft && !GetSettingsTable()->GetEvenAndOddHeaders()) || (GetSettingsTable()->GetEvenAndOddHeaders()))
{
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
@@ -1543,7 +1544,7 @@ void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::P
// If the 'Different Even & Odd Pages' flag is turned on - do not ignore it
// Even if the 'Even' header/footer is blank - the flag should be imported (so it would look in LO like in Word)
- if (GetSettingsTable()->GetEvenAndOddHeaders())
+ if (!bFirst && GetSettingsTable()->GetEvenAndOddHeaders())
xPageStyle->setPropertyValue(rPropNameSupplier.GetName(ePropShared), uno::makeAny(false));
//set the interface
@@ -1930,6 +1931,7 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
xProps->setPropertyValue( rPropNameSupplier.GetName( PROP_BOTTOM_MARGIN ), (*pos).second.getValue() );
}
}
+ m_bParaChanged = true;
}
catch ( const uno::Exception& e )
{
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 055916b0f73c..4434bdc75aaf 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -396,6 +396,12 @@ uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle(
m_aFirstPageStyle = uno::Reference< beans::XPropertySet > (
xTextFactory->createInstance("com.sun.star.style.PageStyle"),
uno::UNO_QUERY);
+ // Ensure that m_aFollowPageStyle has been created
+ GetPageStyle( xPageStyles, xTextFactory, false );
+ // Chain m_aFollowPageStyle to be after m_aFirstPageStyle
+ m_aFirstPageStyle->setPropertyValue("FollowStyle",
+ uno::makeAny(m_sFollowPageStyleName));
+
if (xPageStyles.is())
xPageStyles->insertByName( m_sFirstPageStyleName, uno::makeAny(m_aFirstPageStyle) );
}
@@ -1083,11 +1089,6 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
if( xColumns.is() )
xFirstPageStyle->setPropertyValue(
rPropNameSupplier.GetName( PROP_TEXT_COLUMNS ), uno::makeAny( xColumns ));
-
- // If the 'Different First Page' flag is turned on - do not ignore it
- // If the 'Diffferent First Page' is non-checked, it must be checked - the flag should be imported (so it would look in LO like in Word)
- xFirstPageStyle->setPropertyValue(rPropNameSupplier.GetName( PROP_FIRST_IS_SHARED ), uno::makeAny( false ));
- xFollowPageStyle->setPropertyValue(rPropNameSupplier.GetName( PROP_FIRST_IS_SHARED ), uno::makeAny( false ));
}
ApplyBorderToPageStyles( rDM_Impl.GetPageStyles( ), rDM_Impl.GetTextFactory( ), m_nBorderParams );
@@ -1099,41 +1100,12 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
uno::Reference<beans::XPropertySet> xRangeProperties(lcl_GetRangeProperties(m_bIsFirstSection, rDM_Impl, m_xStartingRange));
/* break type
0 - No break 1 - New Column 2 - New page 3 - Even page 4 - odd page */
- if ((m_bTitlePage && m_bIsFirstSection) || !m_bTitlePage)
- {
- if (xRangeProperties.is() && rDM_Impl.IsNewDoc())
- xRangeProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_PAGE_DESC_NAME ),
- uno::makeAny( m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName ));
- }
- else
- {
- // In this miserable situation (second or later section on a title page), make sure that the header / footer is not lost.
- uno::Reference< container::XNameAccess > xPageStyles(rDM_Impl.GetPageStyles(), uno::UNO_QUERY);
- if (xPageStyles->hasByName(m_sFollowPageStyleName))
- {
- uno::Reference<beans::XPropertySet> xCurrent(xPageStyles->getByName(rPropNameSupplier.GetName(PROP_STANDARD)), uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xFollow(xPageStyles->getByName(m_sFollowPageStyleName), uno::UNO_QUERY);
-
- if (xFollow->getPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_IS_ON)).get<sal_Bool>())
- {
- xCurrent->setPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_IS_ON), uno::makeAny(sal_True));
- uno::Reference<text::XTextRange> xCurrentRange(xCurrent->getPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_TEXT)), uno::UNO_QUERY_THROW);
- xCurrentRange->setString("");
- uno::Reference<text::XTextCopy> xCurrentTxt(xCurrentRange, uno::UNO_QUERY_THROW);
- uno::Reference<text::XTextCopy> xFollowTxt(xFollow->getPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_TEXT)), uno::UNO_QUERY_THROW);
- xCurrentTxt->copyText(xFollowTxt);
- }
- if (xFollow->getPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_IS_ON)).get<sal_Bool>())
- {
- xCurrent->setPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_IS_ON), uno::makeAny(sal_True));
- uno::Reference<text::XTextRange> xCurrentRange(xCurrent->getPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_TEXT)), uno::UNO_QUERY_THROW);
- xCurrentRange->setString("");
- uno::Reference<text::XTextCopy> xCurrentTxt(xCurrentRange, uno::UNO_QUERY_THROW);
- uno::Reference<text::XTextCopy> xFollowTxt(xFollow->getPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_TEXT)), uno::UNO_QUERY_THROW);
- xCurrentTxt->copyText(xFollowTxt);
- }
- }
- }
+ if (xRangeProperties.is() && rDM_Impl.IsNewDoc())
+ xRangeProperties->setPropertyValue(
+ rPropNameSupplier.GetName( PROP_PAGE_DESC_NAME ),
+ uno::makeAny( m_bTitlePage ? m_sFirstPageStyleName
+ : m_sFollowPageStyleName ));
+
// handle page breaks with odd/even page numbering
style::PageStyleLayout nPageStyleLayout(style::PageStyleLayout_ALL);
if (m_nBreakType == 3)