diff options
author | Attila Bakos (NISZ) <bakos.attilakaroly@nisz.hu> | 2021-03-12 14:33:08 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-03-31 14:44:27 +0200 |
commit | b802ab694a8a7357d4657f3e11b571144fa7c7bf (patch) | |
tree | 1c8aba77e9b6aed048d8b49f55ff006c5d099d5f /writerfilter | |
parent | 3c49a3be592eb515bba100b4a17617136fabbcba (diff) |
tdf#141158 DOCX: import discarded headers/footers
Before the inactive DOCX headers/footers lost during
import time. Now it can be restored by disabling
the options “Same content on left and right pages” and
“Same content on first page” on the Header and the
Footer panes of the Page style. This is for improving
the interoperability with other Office programs, e.g.
supporting DOCX text document templates better.
Follow-up of commit f5dc6b11d2218d94c9effe7a1ab418d0133da5e3
(tdf#140117 sw UI: keep headers/footers when inactive).
To start the py-UItest run:
$ make UITest_writer_tests7 UITEST_TEST_NAME="tdf141158.TestTdf141158.test_tdf141158"
Note: In spite of this patch implements the
left/first/first_left page header/footer stash
at import time, the left one works correctly at now.
This is because the first pages have different
page styles so changing the right page style will
restore the hidden header/footer content.
For this problem further improvements are planned,
exactly in the filter part. Number of unit tests
had to be modified, because before these headers
and footers were dropped.
Co-developed-with: Daniel Arato (NISZ)
Change-Id: I3dd452a648bc465710698707c083734dc762ed94
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112580
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index d83ed06526f8..44ab9fdf3b36 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2587,6 +2587,30 @@ void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::P : xText->createTextCursorByRange(xText->getStart()))); m_bDiscardHeaderFooter = false; // set only on success! } + // If we have *hidden* header footer + else if (bLeft && !GetSettingsTable()->GetEvenAndOddHeaders()) + { + bool bIsShared; + // Turn on the headers + xPageStyle->setPropertyValue(getPropertyName(ePropIsOn), uno::makeAny(true)); + // Store the state of the previous state of shared prop + xPageStyle->getPropertyValue(getPropertyName(ePropShared)) >>= bIsShared; + // Turn on the shared prop in order to save the headers/footers in time + 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; + + m_aTextAppendStack.push( + TextAppendContext(uno::Reference<text::XTextAppend>(xText, uno::UNO_QUERY_THROW), + m_bIsNewDoc ? uno::Reference<text::XTextCursor>() + : xText->createTextCursorByRange(xText->getStart()))); + m_bDiscardHeaderFooter = false; // set only on success! + // Restore the original state of the shared prop after we stored the neccessary values. + xPageStyle->setPropertyValue(getPropertyName(ePropShared), uno::makeAny(bIsShared)); + } + } catch( const uno::Exception& ) { |