summaryrefslogtreecommitdiff
path: root/sw/source/filter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-05-22 22:05:24 +0200
committerAndras Timar <andras.timar@collabora.com>2018-06-01 20:46:21 +0200
commitd8e63f23c28023cdd42860be354189bbe1e4efdc (patch)
tree11a0d8e2ed757f59805fa4a527c33497fcab08bb /sw/source/filter
parent60929b2a2dc41d0ce008d4faa9b12a5718acaad8 (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> (cherry picked from commit 8e4a9db1e62871878155207c2c4d252b3705c307)
Diffstat (limited to 'sw/source/filter')
-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
3 files changed, 15 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 07f57320db08..ca1097eccb12 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3084,7 +3084,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