summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-05-22 22:05:24 +0200
committerCaolán McNamara <caolanm@redhat.com>2018-05-27 17:50:17 +0200
commit8e4a9db1e62871878155207c2c4d252b3705c307 (patch)
tree8f8e7f6e981f798f2bd99a8b5177a7058d96f105
parent694e18cffd8cadc70e76c2b18b614b5ccceafefd (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. (cherry picked from commit 5956828c88501ef1366e60010b05053a8e1e642e) Change-Id: I3f1fe3080360702c41d680b8785cc3602e74685e Reviewed-on: https://gerrit.libreoffice.org/54697 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/qa/extras/rtfexport/data/tdf117505.odtbin0 -> 19263 bytes
-rw-r--r--sw/qa/extras/rtfexport/rtfexport3.cxx11
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx9
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx3
-rw-r--r--sw/source/filter/ww8/rtfexport.hxx4
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
new file mode 100644
index 000000000000..91bde8f92393
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf117505.odt
Binary files differ
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx
index 9f59e19a470a..c2399d561764 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -114,6 +114,17 @@ DECLARE_RTFEXPORT_TEST(testTdf117268, "tdf117268.rtf")
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextRangeCompare->compareRegionStarts(xAnchorCell, xCell));
}
+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 6c8bb3390979..400e4049f298 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3101,7 +3101,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 779719756a85..586dd01f23bd 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -1336,7 +1336,10 @@ void RtfExport::OutPageDescription(const SwPageDesc& rPgDsc, bool bCheckForFirst
const SwFormat* pFormat = &m_pAktPageDesc->GetMaster(); //GetLeft();
m_bOutPageDescs = true;
+ if (m_pAktPageDesc != &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 50ba510f4a7d..869a888e9b25 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -188,6 +188,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();
@@ -213,6 +215,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