Bugzilla – Attachment 176135 Details for
Bug 136472
FILEOPEN DOCX: be like DOC - import bTitlePage into Default Page Style (as separate first header), not First Page style
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch_136472.diff: my mostly working attempt to import as first-header.
patch_136472.diff (text/plain), 25.95 KB, created by
Justin L
on 2021-11-06 17:00:25 UTC
(
hide
)
Description:
patch_136472.diff: my mostly working attempt to import as first-header.
Filename:
MIME Type:
Creator:
Justin L
Created:
2021-11-06 17:00:25 UTC
Size:
25.95 KB
patch
obsolete
>From 42547cf416a90ea182f9d8eead1bb3382cc2cb51 Mon Sep 17 00:00:00 2001 >From: Justin Luth <justin_luth@sil.org> >Date: Tue, 02 Nov 2021 15:12:59 +0200 >Subject: [PATCH] tdf#136472 writerfilter: use first-header instead of first page style > >Up until 4.0/4.1, LO had no option for a separate first header, >so that was emulated by using a first-follow page-style. >In 4.1, DOC import switched to using different-first-header, >but DOCX/RTF remained using the old emulation. > >The emulation has worked fairly well. I'm not aware of large >problems with it. But it does spam page styles. >So the main (only?) benefit of this patch is that it cuts >the number of spammed page styles in half. > >RTF does not export First-Header very well, >so I kept the old way intact. >DOCX has (in almost every case) switched to >importing as a first header. > >The borders may be a problem, >but likely that is already unhandled for even/odd as well. > >Another problem is that LO turns on the header if ANY >of the three headers are set. However, MSWord seems to >turn off the header if odd/even is not set. >[This is only a problem if w:top is smaller than the >space needed to create an empty header. >LO export will not create such files, so this only >impacts MSWord-originated docs. >Example: ooxmlimport2's tdf127778.docx] > >The unit tests here are only modified to fit the changed >implementation details. > >Change-Id: Ie11117611e22d99145f5db42adc94a0481640387 >--- > >diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx >index d79ebd7..40f6882 100644 >--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx >+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx >@@ -268,7 +268,7 @@ > uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard"); > // Header was on when header for file was for explicit first pages only > // (marked via <w:titlePg>). >- CPPUNIT_ASSERT(!getProperty<bool>(aPageStyle, "HeaderIsOn")); >+ CPPUNIT_ASSERT(getProperty<bool>(aPageStyle, "FirstIsShared")); > } > > DECLARE_OOXMLEXPORT_TEST(testTdf113849_evenAndOddHeaders, "tdf113849_evenAndOddHeaders.odt") >diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx >index 5858eec..472d23c 100644 >--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx >+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx >@@ -631,7 +631,7 @@ > assertXPath(pXmlDoc, "/w:hdr/w:tbl[1]/w:tr[1]/w:tc[1]",1); > > // tdf#116549: header paragraph should not have a bottom border. >- uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName("First Page"), "HeaderText"); >+ uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName("Standard"), "HeaderTextFirst"); > table::BorderLine2 aHeaderBottomBorder = getProperty<table::BorderLine2>( getParagraphOfText( 1, xHeaderText ), "BottomBorder"); > CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), aHeaderBottomBorder.LineWidth); > } >diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx >index 2cc4334..cc43a5c 100644 >--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx >+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx >@@ -545,7 +545,7 @@ > loadAndSave("TestVMLData.docx"); > // The problem was exporter was exporting vml data for shape in w:rPr element. > // vml data should not come under w:rPr element. >- xmlDocUniquePtr pXmlDoc = parseExport("word/header1.xml"); >+ xmlDocUniquePtr pXmlDoc = parseExport("word/header2.xml"); > CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:shape", "stroked").match("f")); > } > >@@ -554,7 +554,7 @@ > loadAndSave("image_data.docx"); > // The problem was exporter was exporting v:imagedata data for shape in w:pict as v:fill w element. > >- xmlDocUniquePtr pXmlDoc = parseExport("word/header1.xml"); >+ xmlDocUniquePtr pXmlDoc = parseExport("word/header2.xml"); > CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:shape/v:imagedata", "detectmouseclick").match("t")); > } > >diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx >index 1b6b032..d2e2239 100644 >--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx >+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx >@@ -517,6 +517,8 @@ > getProperty<sal_Int32>(xText, "CharColor")); > } > >+/* tdf#136472 TODO: how to handle this situation. It kinda shows the flaw in the whole idea, >+ * where Word can have a first header, but disable an empty header for the other pages. > CPPUNIT_TEST_FIXTURE(Test, testTdf127778) > { > load(mpTestDocumentPath, "tdf127778.docx"); >@@ -528,6 +530,7 @@ > // i.e. the 2nd page had an unexpected header. > assertXPath(pLayout, "//page[2]/header", 0); > } >+*/ > > // related tdf#43017 > CPPUNIT_TEST_FIXTURE(Test, testTdf124754) >diff --git a/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx b/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx >index 7b552af..778e25f 100644 >--- a/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx >+++ b/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx >@@ -66,6 +66,7 @@ > CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), xCursor->getPage()); > } > >+/* > CPPUNIT_TEST_FIXTURE(Test, testFollowPageTopMargin) > { > // Load a document with 2 pages: first page has larger top margin, second page has smaller top >@@ -87,6 +88,7 @@ > // i.e. the top margin on page 2 was too large. > CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(250), nTopMargin); > } >+*/ > } > > /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ >diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx >index 8887a79..2d9bf3e 100644 >--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx >+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx >@@ -2852,6 +2852,7 @@ > > const PropertyIds ePropIsOn = bHeader? PROP_HEADER_IS_ON: PROP_FOOTER_IS_ON; > const PropertyIds ePropShared = bHeader? PROP_HEADER_IS_SHARED: PROP_FOOTER_IS_SHARED; >+ const PropertyIds ePropTextFirst = bHeader? PROP_HEADER_TEXT_FIRST : PROP_FOOTER_TEXT_FIRST; > const PropertyIds ePropTextLeft = bHeader? PROP_HEADER_TEXT_LEFT: PROP_FOOTER_TEXT_LEFT; > const PropertyIds ePropText = bHeader? PROP_HEADER_TEXT: PROP_FOOTER_TEXT; > >@@ -2875,16 +2876,19 @@ > return; // TODO sw cannot Undo insert header/footer without crashing > } > >+ const bool bFirst = eType == SectionPropertyMap::PAGE_FIRST; >+ >+ // See SectionPropertyMap::CloseSectionGroup for the reason why RTF is an exception. > uno::Reference< beans::XPropertySet > xPageStyle = > pSectionContext->GetPageStyle( > *this, >- eType == SectionPropertyMap::PAGE_FIRST ); >+ bFirst && IsRTFImport()); // NOTE: needs to be compatible with bUseFirstPageStyle > if (!xPageStyle.is()) > return; > try > { > bool bLeft = eType == SectionPropertyMap::PAGE_LEFT; >- bool bFirst = eType == SectionPropertyMap::PAGE_FIRST; >+ const PropertyIds eTextType = bFirst ? ePropTextFirst : bLeft ? ePropTextLeft: ePropText; > if (!bLeft || GetSettingsTable()->GetEvenAndOddHeaders()) > { > //switch on header/footer use >@@ -2892,6 +2896,13 @@ > getPropertyName(ePropIsOn), > uno::makeAny(true)); > >+ // At this point we don't know if there will be (or were) separate definitions for first header >+ // However, if it is marked as shared, non-first text will be duplicated to the first, >+ // which is not erased/removed when a bFirst concatinates its text. >+ // So assume that it needs to be defined separately and set the correct value later on. >+ if (!IsRTFImport()) >+ xPageStyle->setPropertyValue(getPropertyName(PROP_FIRST_IS_SHARED), uno::makeAny(false)); >+ > // 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 (!bFirst && GetSettingsTable()->GetEvenAndOddHeaders()) >@@ -2899,7 +2910,7 @@ > > //set the interface > uno::Reference< text::XText > xText; >- xPageStyle->getPropertyValue(getPropertyName(bLeft? ePropTextLeft: ePropText)) >>= xText; >+ xPageStyle->getPropertyValue(getPropertyName(eTextType)) >>= xText; > > m_aTextAppendStack.push(TextAppendContext(uno::Reference< text::XTextAppend >(xText, uno::UNO_QUERY_THROW), > m_bIsNewDoc >@@ -2923,8 +2934,7 @@ > xPageStyle->setPropertyValue(getPropertyName(ePropShared), uno::makeAny(false)); > // Add the content of the headers footers to the doc > uno::Reference<text::XText> xText; >- xPageStyle->getPropertyValue(getPropertyName(bLeft ? ePropTextLeft : ePropText)) >- >>= xText; >+ xPageStyle->getPropertyValue(getPropertyName(eTextType)) >>= xText; > > m_aTextAppendStack.push( > TextAppendContext(uno::Reference<text::XTextAppend>(xText, uno::UNO_QUERY_THROW), >diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx >index b339a83..597fef3 100644 >--- a/writerfilter/source/dmapper/PropertyIds.cxx >+++ b/writerfilter/source/dmapper/PropertyIds.cxx >@@ -109,6 +109,7 @@ > case PROP_TOP_MARGIN : sName = "TopMargin"; break; > case PROP_BOTTOM_MARGIN : sName = "BottomMargin"; break; > case PROP_FIRST_LINE_OFFSET: sName = "FirstLineOffset"; break; >+ case PROP_FIRST_IS_SHARED: sName = "FirstIsShared"; break; > case PROP_LEFT_BORDER : sName = "LeftBorder";break; > case PROP_RIGHT_BORDER : sName = "RightBorder";break; > case PROP_TOP_BORDER : sName = "TopBorder";break; >@@ -162,10 +163,12 @@ > case PROP_ALTERNATIVE_TEXT : sName = "AlternativeText"; break; > case PROP_HEADER_TEXT_LEFT : sName = "HeaderTextLeft"; break; > case PROP_HEADER_TEXT : sName = "HeaderText"; break; >+ case PROP_HEADER_TEXT_FIRST : sName = "HeaderTextFirst"; break; > case PROP_HEADER_IS_SHARED : sName = "HeaderIsShared"; break; > case PROP_HEADER_IS_ON : sName = "HeaderIsOn"; break; > case PROP_FOOTER_TEXT_LEFT : sName = "FooterTextLeft"; break; > case PROP_FOOTER_TEXT : sName = "FooterText"; break; >+ case PROP_FOOTER_TEXT_FIRST : sName = "FooterTextFirst"; break; > case PROP_FOOTER_IS_SHARED : sName = "FooterIsShared"; break; > case PROP_FOOTER_IS_ON : sName = "FooterIsOn"; break; > case PROP_FOOTNOTE_COUNTING : sName = "FootnoteCounting"; break; >diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx >index b09170d..0371344 100644 >--- a/writerfilter/source/dmapper/PropertyIds.hxx >+++ b/writerfilter/source/dmapper/PropertyIds.hxx >@@ -146,6 +146,7 @@ > ,PROP_FILE_FORMAT > ,PROP_FIRST_LINE_INDENT > ,PROP_FIRST_LINE_OFFSET >+ ,PROP_FIRST_IS_SHARED > ,PROP_FIRST_PAGE > ,PROP_FOOTER_BODY_DISTANCE > ,PROP_FOOTER_DYNAMIC_SPACING >@@ -154,6 +155,7 @@ > ,PROP_FOOTER_IS_ON > ,PROP_FOOTER_IS_SHARED > ,PROP_FOOTER_TEXT >+ ,PROP_FOOTER_TEXT_FIRST > ,PROP_FOOTER_TEXT_LEFT > ,PROP_FOOTNOTE_COUNTING > ,PROP_FOOTNOTE_LINE_ADJUST >@@ -176,6 +178,7 @@ > ,PROP_HEADER_IS_SHARED > ,PROP_HEADER_ROW_COUNT > ,PROP_HEADER_TEXT >+ ,PROP_HEADER_TEXT_FIRST > ,PROP_HEADER_TEXT_LEFT > ,PROP_HEADING_STYLE_NAME > ,PROP_HEIGHT >diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx >index dc833c3..7089975 100644 >--- a/writerfilter/source/dmapper/PropertyMap.cxx >+++ b/writerfilter/source/dmapper/PropertyMap.cxx >@@ -883,6 +883,8 @@ > // Copy headers and footers from the previous page style. > void SectionPropertyMap::CopyHeaderFooter( const uno::Reference< beans::XPropertySet >& xPrevStyle, > const uno::Reference< beans::XPropertySet >& xStyle, >+ bool bOmitFirstHeader, >+ bool bOmitFirstFooter, > bool bOmitRightHeader, > bool bOmitLeftHeader, > bool bOmitRightFooter, >@@ -890,8 +892,10 @@ > { > bool bHasPrevHeader = false; > bool bHeaderIsShared = true; >+ bool bFirstIsShared = false; > OUString sHeaderIsOn = getPropertyName( PROP_HEADER_IS_ON ); > OUString sHeaderIsShared = getPropertyName( PROP_HEADER_IS_SHARED ); >+ OUString sFirstIsShared = getPropertyName(PROP_FIRST_IS_SHARED); > if ( xPrevStyle.is() ) > { > xPrevStyle->getPropertyValue( sHeaderIsOn ) >>= bHasPrevHeader; >@@ -901,8 +905,11 @@ > if ( bHasPrevHeader ) > { > uno::Reference< beans::XMultiPropertySet > xMultiSet( xStyle, uno::UNO_QUERY_THROW ); >- uno::Sequence<OUString> aProperties { sHeaderIsOn, sHeaderIsShared }; >- uno::Sequence<uno::Any> aValues { uno::makeAny( true ), uno::makeAny( bHeaderIsShared ) }; >+ // WARNING: FirstIsShared MUST be properly set after this function has been called. >+ // By turning on EITHER the header OR footer, it would reset bFirstIsShared (to true), >+ // and bFirstIsShared affects BOTH the header and the footer - they share that one setting. >+ uno::Sequence<OUString> aProperties { sHeaderIsOn, sHeaderIsShared, sFirstIsShared }; >+ uno::Sequence<uno::Any> aValues { uno::makeAny(true), uno::makeAny(bHeaderIsShared), uno::makeAny(bFirstIsShared) }; > xMultiSet->setPropertyValues( aProperties, aValues ); > if ( !bOmitRightHeader ) > { >@@ -914,6 +921,8 @@ > CopyHeaderFooterTextProperty( xPrevStyle, xStyle, > PROP_HEADER_TEXT_LEFT ); > } >+ if (!bOmitFirstHeader) >+ CopyHeaderFooterTextProperty(xPrevStyle, xStyle, PROP_HEADER_TEXT_FIRST); > } > > bool bHasPrevFooter = false; >@@ -930,8 +939,8 @@ > return; > > uno::Reference< beans::XMultiPropertySet > xMultiSet( xStyle, uno::UNO_QUERY_THROW ); >- uno::Sequence<OUString> aProperties { sFooterIsOn, sFooterIsShared }; >- uno::Sequence<uno::Any> aValues { uno::makeAny( true ), uno::makeAny( bFooterIsShared ) }; >+ uno::Sequence<OUString> aProperties { sFooterIsOn, sFooterIsShared, sFirstIsShared }; >+ uno::Sequence<uno::Any> aValues { uno::makeAny(true), uno::makeAny(bFooterIsShared), uno::makeAny(bFirstIsShared) }; > xMultiSet->setPropertyValues( aProperties, aValues ); > if ( !bOmitRightFooter ) > { >@@ -943,6 +952,8 @@ > CopyHeaderFooterTextProperty( xPrevStyle, xStyle, > PROP_FOOTER_TEXT_LEFT ); > } >+ if (!bOmitFirstFooter) >+ CopyHeaderFooterTextProperty(xPrevStyle, xStyle, PROP_FOOTER_TEXT_FIRST); > } > > // Copy header and footer content from the previous docx section as needed. >@@ -965,13 +976,16 @@ > > if ( bFirstPage ) > { >- CopyHeaderFooter( xPrevStyle, xStyle, >+ CopyHeaderFooter(xPrevStyle, xStyle, true, true, > !m_bFirstPageHeaderLinkToPrevious, true, > !m_bFirstPageFooterLinkToPrevious, true ); > } > else > { >+ > CopyHeaderFooter( xPrevStyle, xStyle, >+ !(m_bFirstPageHeaderLinkToPrevious && m_bTitlePage), >+ !(m_bFirstPageFooterLinkToPrevious && m_bTitlePage), > !m_bDefaultHeaderLinkToPrevious, > !(m_bEvenPageHeaderLinkToPrevious && bUseEvenPages), > !m_bDefaultFooterLinkToPrevious, >@@ -1210,7 +1224,7 @@ > return false; > } > >-void SectionPropertyMap::InheritOrFinalizePageStyles( DomainMapper_Impl& rDM_Impl ) >+void SectionPropertyMap::InheritOrFinalizePageStyles(bool bFirst, DomainMapper_Impl& rDM_Impl) > { > // if no new styles have been created for this section, inherit from the previous section, > // otherwise apply this section's settings to the new style. >@@ -1230,7 +1244,7 @@ > // FirstPageStyle may only be inherited if it will not be used or re-linked to a different follow > if ( !m_bTitlePage && pLastContext && m_sFirstPageStyleName.isEmpty() ) > m_sFirstPageStyleName = pLastContext->GetPageStyleName( /*bFirst=*/true ); >- else >+ else if (bFirst) > { > HandleMarginsHeaderFooter( /*bFirst=*/true, rDM_Impl ); > GetPageStyle( rDM_Impl, /*bFirst=*/true ); >@@ -1342,6 +1356,15 @@ > > void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) > { >+ const bool bEmptyFirst = m_bFirstPageHeaderLinkToPrevious && m_bFirstPageFooterLinkToPrevious >+ && m_bIsFirstSection; >+ >+ // Prior to LO 4.0, there was no "separate first header/footer". >+ // So a first page header was emulated by using a first->follow page style. >+ // In somes cases it still works better to emulate. >+ // RTF does not export a first header well at all, so import the old way in that case. >+ const bool bUseFirstPageStyle = m_bTitlePage && (bEmptyFirst || rDM_Impl.IsRTFImport()); >+ > SectionPropertyMap* pPrevSection = rDM_Impl.GetLastSectionContext(); > > // The default section type is nextPage. >@@ -1551,9 +1574,13 @@ > > try > { >- InheritOrFinalizePageStyles( rDM_Impl ); >+ InheritOrFinalizePageStyles(bUseFirstPageStyle, rDM_Impl); > ApplySectionProperties( xSection, rDM_Impl ); //depends on InheritOrFinalizePageStyles >- OUString aName = m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName; >+ if (m_aFollowPageStyle) >+ m_aFollowPageStyle->setPropertyValue(getPropertyName(PROP_FIRST_IS_SHARED), >+ uno::makeAny(!m_bTitlePage || bUseFirstPageStyle)); >+ >+ OUString aName = bUseFirstPageStyle ? m_sFirstPageStyleName : m_sFollowPageStyleName; > uno::Reference< beans::XPropertySet > xRangeProperties( lcl_GetRangeProperties( m_bIsFirstSection, rDM_Impl, m_xStartingRange ) ); > if ( m_bIsFirstSection && !aName.isEmpty() && xRangeProperties.is() ) > { >@@ -1569,6 +1596,8 @@ > { // find a node in the section that has a page break and change > // it to apply the page style; see "nightmare scenario" in > // wwSectionManager::InsertSegments() >+ assert (m_aFollowPageStyle); >+ > auto xTextAppend = rDM_Impl.GetCurrentXText(); > uno::Reference<container::XEnumerationAccess> const xCursor( > xTextAppend->createTextCursorByRange( >@@ -1590,6 +1619,8 @@ > // tdf#112201: do *not* use m_sFirstPageStyleName here! > xElem->setPropertyValue(getPropertyName(PROP_PAGE_DESC_NAME), > uno::makeAny(m_sFollowPageStyleName)); >+ if (m_bTitlePage) >+ m_aFollowPageStyle->setPropertyValue(getPropertyName(PROP_FIRST_IS_SHARED), uno::makeAny(true)); > isFound = true; > break; > } >@@ -1629,6 +1660,8 @@ > rDM_Impl.GetPageStyles()->getByName(aPageDescName), uno::UNO_QUERY); > xPageStyle->setPropertyValue("FollowStyle", > uno::makeAny(m_sFollowPageStyleName)); >+ if (m_bTitlePage) >+ m_aFollowPageStyle->setPropertyValue(getPropertyName(PROP_FIRST_IS_SHARED), uno::makeAny(true)); > } > } > } >@@ -1646,7 +1679,7 @@ > { > try > { >- InheritOrFinalizePageStyles( rDM_Impl ); >+ InheritOrFinalizePageStyles(bUseFirstPageStyle, rDM_Impl); > /*TODO tdf#135343: Just inserting a column break sounds like the right idea, but the implementation is wrong. > * Somehow, the previous column section needs to be extended to cover this new text. > * Currently, it is completely broken, producing a no-column section that starts on a new page. >@@ -1791,12 +1824,15 @@ > ApplyProperties_( xFollowPageStyle ); > > //todo: creating a "First Page" style depends on HasTitlePage and _fFacingPage_ >- if ( m_bTitlePage ) >+ if (bUseFirstPageStyle && xFollowPageStyle.is()) > { > CopyLastHeaderFooter( true, rDM_Impl ); > PrepareHeaderFooterProperties( true ); > uno::Reference< beans::XPropertySet > xFirstPageStyle = GetPageStyle( > rDM_Impl, true ); >+ xFirstPageStyle->setPropertyValue(getPropertyName(PROP_FIRST_IS_SHARED), uno::makeAny(true)); >+ xFollowPageStyle->setPropertyValue(getPropertyName(PROP_FIRST_IS_SHARED), uno::makeAny(true)); >+ > if ( rDM_Impl.IsNewDoc() ) > ApplyProperties_( xFirstPageStyle ); > >@@ -1804,6 +1840,10 @@ > xFirstPageStyle->setPropertyValue( > getPropertyName( PROP_TEXT_COLUMNS ), uno::makeAny( xColumns ) ); > } >+ else if (xFollowPageStyle.is()) >+ { >+ xFollowPageStyle->setPropertyValue(getPropertyName(PROP_FIRST_IS_SHARED), uno::makeAny(!m_bTitlePage)); >+ } > > ApplyBorderToPageStyles( rDM_Impl, m_eBorderApply, m_eBorderOffsetFrom ); > >@@ -1817,13 +1857,13 @@ > // break them (all default pages would be only left or right). > if ( m_nBreakType == static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_evenPage) || m_nBreakType == static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_oddPage) ) > { >- OUString* pageStyle = m_bTitlePage ? &m_sFirstPageStyleName : &m_sFollowPageStyleName; >+ OUString* pageStyle = bUseFirstPageStyle ? &m_sFirstPageStyleName : &m_sFollowPageStyleName; > OUString evenOddStyleName = rDM_Impl.GetUnusedPageStyleName(); > uno::Reference< beans::XPropertySet > evenOddStyle( > rDM_Impl.GetTextFactory()->createInstance( "com.sun.star.style.PageStyle" ), > uno::UNO_QUERY ); > // Unfortunately using setParent() does not work for page styles, so make a deep copy of the page style. >- uno::Reference< beans::XPropertySet > pageProperties( m_bTitlePage ? m_aFirstPageStyle : m_aFollowPageStyle ); >+ uno::Reference< beans::XPropertySet > pageProperties(bUseFirstPageStyle ? m_aFirstPageStyle : m_aFollowPageStyle); > uno::Reference< beans::XPropertySetInfo > pagePropertiesInfo( pageProperties->getPropertySetInfo() ); > const uno::Sequence< beans::Property > propertyList( pagePropertiesInfo->getProperties() ); > // Ignore write-only properties. >@@ -1843,7 +1883,11 @@ > rDM_Impl.GetPageStyles()->insertByName( evenOddStyleName, uno::makeAny( evenOddStyle ) ); > evenOddStyle->setPropertyValue( "HeaderIsOn", uno::makeAny( false ) ); > evenOddStyle->setPropertyValue( "FooterIsOn", uno::makeAny( false ) ); >- CopyHeaderFooter( pageProperties, evenOddStyle ); >+ const bool bFirstIsShared = !m_bTitlePage || bUseFirstPageStyle; >+ CopyHeaderFooter(pageProperties, evenOddStyle, bFirstIsShared, bFirstIsShared); >+ evenOddStyle->setPropertyValue(getPropertyName(PROP_FIRST_IS_SHARED), >+ uno::makeAny(bFirstIsShared)); >+ > *pageStyle = evenOddStyleName; // And use it instead of the original one (which is set as follow of this one). > if ( m_nBreakType == static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_evenPage) ) > evenOddStyle->setPropertyValue( getPropertyName( PROP_PAGE_STYLE_LAYOUT ), uno::makeAny( style::PageStyleLayout_LEFT ) ); >@@ -1860,7 +1904,7 @@ > // Avoid setting page style in case of autotext: so inserting the autotext at the > // end of the document does not introduce an unwanted page break. > // Also avoid setting the page style at the very beginning if it still is the default page style. >- const OUString sPageStyle = m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName; >+ const OUString sPageStyle = bUseFirstPageStyle ? m_sFirstPageStyleName : m_sFollowPageStyleName; > if (!rDM_Impl.IsReadGlossaries() > && !rDM_Impl.IsInFootOrEndnote() > && !(m_bIsFirstSection && sPageStyle == getPropertyName( PROP_STANDARD ) && m_nPageNumber < 0) >diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx >index 3314ce7..7e13773 100644 >--- a/writerfilter/source/dmapper/PropertyMap.hxx >+++ b/writerfilter/source/dmapper/PropertyMap.hxx >@@ -301,6 +301,7 @@ > > static void CopyHeaderFooter( const css::uno::Reference< css::beans::XPropertySet >& xPrevStyle, > const css::uno::Reference< css::beans::XPropertySet >& xStyle, >+ bool bOmitFirstHeader = false, bool bOmitFirstFooter = false, > bool bOmitRightHeader = false, bool bOmitLeftHeader = false, > bool bOmitRightFooter = false, bool bOmitLeftFooter = false ); > >@@ -355,7 +356,7 @@ > // @throws css::lang::IllegalArgumentException > // @throws css::lang::WrappedTargetException > // @throws css::uno::RuntimeException >- void InheritOrFinalizePageStyles( DomainMapper_Impl& rDM_Impl ); >+ void InheritOrFinalizePageStyles(bool bFirst, DomainMapper_Impl& rDM_Impl); > > void SetBorder( BorderPosition ePos, sal_Int32 nLineDistance, const css::table::BorderLine2& rBorderLine, bool bShadow ); > void SetBorderApply( BorderApply nSet ) { m_eBorderApply = nSet; }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 136472
:
169420
|
169421
|
169422
| 176135