diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-05-22 22:05:24 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-05-23 09:12:06 +0200 |
commit | 5956828c88501ef1366e60010b05053a8e1e642e (patch) | |
tree | 28b6389baca36b8ced4199934cff55a3790510f7 | |
parent | 4552096794c408110630ab2eaf47bebaa6c403f2 (diff) |
tdf#117505 RTF export: fix incorrect header distance for first/follow pages
In case the first and the follow page format has different header
distances, the DOC and DOCX import work with the distance from the first
page format when they take the last item from the MSWordSections
container at the end of the export.
RTF writes section info before the document content, and in case there
are separate first and follow page formats, then we work with the follow
format since commit 20a53cb9e9c7b797c091fe6ac6a34dfb28c61304
(INTEGRATION: CWS limerickfilterteam08 (1.16.32); FILE MERGED,
2003-09-01) as a fix for i#13107.
There is no perfect solution here, the sw doc model can store different
header distances for first and follow pages, while Word works with a
single distance. But RTF/DOCX/DOC import puts the relevant header
distance to the first page format and DOCX/DOC export reads the distance
from there, so be consistent and do the same in the RTF export as well.
This means the DOCX import -> RTF export -> RTF import sequence from the
bugreport will result in a correct header distance.
Change-Id: I3f1fe3080360702c41d680b8785cc3602e74685e
Reviewed-on: https://gerrit.libreoffice.org/54680
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/qa/extras/rtfexport/data/tdf117505.odt | bin | 0 -> 19263 bytes | |||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport3.cxx | 11 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.hxx | 4 |
5 files changed, 26 insertions, 1 deletions
diff --git a/sw/qa/extras/rtfexport/data/tdf117505.odt b/sw/qa/extras/rtfexport/data/tdf117505.odt Binary files differnew file mode 100644 index 000000000000..91bde8f92393 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/tdf117505.odt diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx index 142c7f6c8381..d27eec82fea9 100644 --- a/sw/qa/extras/rtfexport/rtfexport3.cxx +++ b/sw/qa/extras/rtfexport/rtfexport3.cxx @@ -145,6 +145,17 @@ DECLARE_RTFEXPORT_TEST(testTdf117268, "tdf117268.rtf") CPPUNIT_ASSERT_EQUAL(xCell, xAnchorCell); } +DECLARE_RTFEXPORT_TEST(testTdf117505, "tdf117505.odt") +{ + uno::Reference<container::XNameAccess> xPageStyles(getStyles("PageStyles")); + uno::Reference<beans::XPropertySet> xFirstPage(xPageStyles->getByName("First Page"), + uno::UNO_QUERY); + // This was 499, small header height resulted in visible whitespace from + // remaining top margin -> header content moved down. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1499), + getProperty<sal_Int32>(xFirstPage, "HeaderHeight")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 56c0d2f9d293..42199d4770b6 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -3017,7 +3017,14 @@ void RtfAttributeOutput::FormatULSpace(const SvxULSpaceItem& rULSpace) if (!m_rExport.GetCurItemSet()) return; - sw::util::HdFtDistanceGlue aDistances(*m_rExport.GetCurItemSet()); + // If we export a follow page format, then our doc model has + // separate header/footer distances for the first page and the + // follow pages, but Word can have only a single distance. In case + // the two values differ, work with the value from the first page + // format to be in sync with the import. + sw::util::HdFtDistanceGlue aDistances(m_rExport.GetFirstPageItemSet() + ? *m_rExport.GetFirstPageItemSet() + : *m_rExport.GetCurItemSet()); if (aDistances.dyaTop) { diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index 0b206edcf693..7c5e096ea5b3 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -1348,7 +1348,10 @@ void RtfExport::OutPageDescription(const SwPageDesc& rPgDsc, bool bCheckForFirst const SwFormat* pFormat = &m_pCurrentPageDesc->GetMaster(); //GetLeft(); m_bOutPageDescs = true; + if (m_pCurrentPageDesc != &rPgDsc) + m_pFirstPageItemSet = &rPgDsc.GetMaster().GetAttrSet(); OutputFormat(*pFormat, true, false); + m_pFirstPageItemSet = nullptr; m_bOutPageDescs = false; // normal header / footer (without a style) diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx index 03f06d5e22b1..fd2c7a285e7b 100644 --- a/sw/source/filter/ww8/rtfexport.hxx +++ b/sw/source/filter/ww8/rtfexport.hxx @@ -189,6 +189,8 @@ public: void InsStyle(sal_uInt16 nId, const OString& rStyle); OString* GetStyle(sal_uInt16 nId); + const SfxItemSet* GetFirstPageItemSet() { return m_pFirstPageItemSet; } + private: void WriteFonts(); void WriteStyles(); @@ -214,6 +216,8 @@ private: std::map<OUString, sal_uInt16> m_aRedlineTable; /// If set, then Strm() returns this tream, instead of m_pWriter's stream. std::unique_ptr<SvMemoryStream> m_pStream; + /// Item set of the first page during export of a follow page format. + const SfxItemSet* m_pFirstPageItemSet = nullptr; }; #endif // INCLUDED_SW_SOURCE_FILTER_WW8_RTFEXPORT_HXX |