From 6f179ce5c5469d1c53e4bb7736384b2d9ce51926 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 30 May 2019 14:56:40 +0200 Subject: ODT export: fix lost for fields in frames in headers This is similar to commit 6bb241ccc61c6904efec95978fa17e33c0eb1df3 (ODT export: fix lost for fields in tables in headers, 2019-05-29), but here the container we want to ignore (between the header and the field) is a text frame, not a table cell. Change-Id: I6e8006fbd666802070cfeb88ca4528c66cc6d559 Reviewed-on: https://gerrit.libreoffice.org/73205 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/inc/unoframe.hxx | 1 + sw/qa/extras/odfexport/data/user-field-decl-fly.odt | Bin 0 -> 9167 bytes sw/qa/extras/odfexport/odfexport.cxx | 9 +++++++++ sw/source/core/unocore/unoframe.cxx | 12 ++++++++++++ sw/source/core/unocore/unomapproperties.hxx | 1 + 5 files changed, 23 insertions(+) create mode 100644 sw/qa/extras/odfexport/data/user-field-decl-fly.odt (limited to 'sw') diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index 8751e7806480..207fbaac7414 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -75,6 +75,7 @@ private: sal_Int64 m_nDrawAspect; sal_Int64 m_nVisibleAreaWidth; sal_Int64 m_nVisibleAreaHeight; + css::uno::Reference m_xParentText; protected: css::uno::Reference< css::beans::XPropertySet > mxStyleData; diff --git a/sw/qa/extras/odfexport/data/user-field-decl-fly.odt b/sw/qa/extras/odfexport/data/user-field-decl-fly.odt new file mode 100644 index 000000000000..2ffe3ae55532 Binary files /dev/null and b/sw/qa/extras/odfexport/data/user-field-decl-fly.odt differ diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 8725efcc500b..4c17893e2310 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -260,6 +260,15 @@ DECLARE_ODFEXPORT_TEST(testUserFieldDecl, "user-field-decl.odt") assertXPath(pXmlDoc, "//style:header/text:user-field-decls/text:user-field-decl", 2); } +DECLARE_ODFEXPORT_TEST(testUserFieldDeclFly, "user-field-decl-fly.odt") +{ + if (xmlDocPtr pXmlDoc = parseExport("styles.xml")) + // Without the accompanying fix in place, this test would have failed with 'Expected: 2; + // Actual: 1', i.e. the in-textframe field had no declaration (in the header), while the + // outside-textframe one had the declaration. + assertXPath(pXmlDoc, "//style:header/text:user-field-decls/text:user-field-decl", 2); +} + DECLARE_ODFEXPORT_TEST(testFramebackgrounds, "framebackgrounds.odt") { //Counting the Number of Frames and checking with the expected count diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index b9806727394e..ea377f2e058e 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2239,6 +2239,18 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName) aAny <<= awt::Size( aMM100Size.Width(), aMM100Size.Height() ); } } + else if(pEntry->nWID == FN_UNO_PARENT_TEXT) + { + if (!m_xParentText.is()) + { + const SwPosition* pContentAnchor = pFormat->GetAnchor().GetContentAnchor(); + if (pContentAnchor) + { + m_xParentText = sw::CreateParentXText(*pFormat->GetDoc(), *pContentAnchor); + } + } + aAny <<= m_xParentText; + } else { // standard UNO API read attributes diff --git a/sw/source/core/unocore/unomapproperties.hxx b/sw/source/core/unocore/unomapproperties.hxx index 2c95e73326b3..549f97cbee70 100644 --- a/sw/source/core/unocore/unomapproperties.hxx +++ b/sw/source/core/unocore/unomapproperties.hxx @@ -322,6 +322,7 @@ { OUString(UNO_NAME_Z_ORDER), FN_UNO_Z_ORDER, cppu::UnoType::get(), PROPERTY_NONE, 0}, \ { OUString(UNO_NAME_IS_FOLLOWING_TEXT_FLOW), RES_FOLLOW_TEXT_FLOW, cppu::UnoType::get(), PROPERTY_NONE, MID_FOLLOW_TEXT_FLOW}, \ { OUString(UNO_NAME_IS_LAYOUT_IN_CELL), RES_FOLLOW_TEXT_FLOW, cppu::UnoType::get(), PROPERTY_NONE, MID_FTF_LAYOUT_IN_CELL}, \ + { OUString(UNO_NAME_PARENT_TEXT), FN_UNO_PARENT_TEXT, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID | PropertyAttribute::READONLY, 0 }, \ { OUString(UNO_NAME_WRAP_INFLUENCE_ON_POSITION), RES_WRAP_INFLUENCE_ON_OBJPOS, cppu::UnoType::get(), PROPERTY_NONE, MID_WRAP_INFLUENCE}, \ { OUString(UNO_NAME_TITLE), FN_UNO_TITLE, cppu::UnoType::get(), PROPERTY_NONE, 0}, \ { OUString(UNO_NAME_DESCRIPTION), FN_UNO_DESCRIPTION, cppu::UnoType::get(), PROPERTY_NONE, 0}, \ -- cgit v1.2.3