diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-06-18 21:06:30 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-06-19 09:02:59 +0200 |
commit | 853350787df9a8d92c269ef1b6e764863e74ec2a (patch) | |
tree | e6a25de0428e94b7ea4fa46d7c202d65e947b92f /sw | |
parent | 3a8375eb974eb8ba36ac616478acd881b70f8e19 (diff) |
tdf#117805 DOCX export: fix lost header with at-page anchored frames
The bug has two parts: on one hand, the header was not completely lost,
just was written inside a shape. This is not valid, but at least our own
import understood that. This commit restores that old behavior, focusing
on just the regression part of the bugreport.
On the other hand the exported header is still referenced at an
incorrect location: the correct location would be the end of the
document. But that is follow-up work, it seems that never worked.
Change-Id: I468df9013c65ec581e3a474a5bf2f773fcb4f990
Reviewed-on: https://gerrit.libreoffice.org/56058
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf117805.odt | bin | 0 -> 14897 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 11 |
3 files changed, 22 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf117805.odt b/sw/qa/extras/ooxmlexport/data/tdf117805.odt Binary files differnew file mode 100644 index 000000000000..828384b3613d --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf117805.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 87d35f8a300c..730765a8c9ff 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -191,6 +191,19 @@ DECLARE_OOXMLEXPORT_TEST(testSignatureLineShape, "signature-line-all-props-set.d CPPUNIT_ASSERT_EQUAL(OUString("Check the machines!"), aSigningInstructions); } +DECLARE_OOXMLEXPORT_TEST(testTdf117805, "tdf117805.odt") +{ + if (!mbExported) + return; + + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess + = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), + maTempFile.GetURL()); + // This failed, the header was lost. It's still referenced at an incorrect + // location in document.xml, though. + CPPUNIT_ASSERT(xNameAccess->hasByName("word/header1.xml")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf113183, "tdf113183.docx") { // The horizontal positioning of the star shape affected the positioning of diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 8acb92e3e9ac..b714481d0043 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -117,6 +117,13 @@ void lclMovePositionWithRotation(awt::Point& aPos, const Size& rSize, sal_Int64 aPos.X += nXDiff; aPos.Y += nYDiff; } + +/// Determines if the anchor is inside a paragraph. +bool IsAnchorTypeInsideParagraph(const ww8::Frame* pFrame) +{ + const SwFormatAnchor& rAnchor = pFrame->GetFrameFormat().GetAttrSet().GetAnchor(); + return rAnchor.GetAnchorId() != RndStdIds::FLY_AT_PAGE; +} } ExportDataSaveRestore::ExportDataSaveRestore(DocxExport& rExport, sal_uLong nStt, sal_uLong nEnd, @@ -1395,7 +1402,7 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho bool bTextBoxOnly) { bool bDMLAndVMLDrawingOpen = m_pImpl->m_bDMLAndVMLDrawingOpen; - m_pImpl->m_bDMLAndVMLDrawingOpen = true; + m_pImpl->m_bDMLAndVMLDrawingOpen = IsAnchorTypeInsideParagraph(pParentFrame); sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer; const SwFrameFormat& rFrameFormat = pParentFrame->GetFrameFormat(); @@ -1690,7 +1697,7 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bTextBoxOnly) { bool bDMLAndVMLDrawingOpen = m_pImpl->m_bDMLAndVMLDrawingOpen; - m_pImpl->m_bDMLAndVMLDrawingOpen = true; + m_pImpl->m_bDMLAndVMLDrawingOpen = IsAnchorTypeInsideParagraph(pParentFrame); sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer; const SwFrameFormat& rFrameFormat = pParentFrame->GetFrameFormat(); |