Kaydet (Commit) 5956828c authored tarafından Miklos Vajna's avatar Miklos Vajna

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 20a53cb9
(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/54680Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 45520967
......@@ -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: */
......@@ -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)
{
......
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment