summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-05-30 14:56:40 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-05-30 15:59:03 +0200
commit6f179ce5c5469d1c53e4bb7736384b2d9ce51926 (patch)
tree9aa262bb78e6066ec298d03fb8241ca5aca9f2ad /sw
parent831de14f660ba4faf4cac716e30246c8dc0386f1 (diff)
ODT export: fix lost <text:user-field-decl> for fields in frames in headers
This is similar to commit 6bb241ccc61c6904efec95978fa17e33c0eb1df3 (ODT export: fix lost <text:user-field-decl> 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 <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/unoframe.hxx1
-rw-r--r--sw/qa/extras/odfexport/data/user-field-decl-fly.odtbin0 -> 9167 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx9
-rw-r--r--sw/source/core/unocore/unoframe.cxx12
-rw-r--r--sw/source/core/unocore/unomapproperties.hxx1
5 files changed, 23 insertions, 0 deletions
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<css::text::XText> 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
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/user-field-decl-fly.odt
Binary files 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<sal_Int32>::get(), PROPERTY_NONE, 0}, \
{ OUString(UNO_NAME_IS_FOLLOWING_TEXT_FLOW), RES_FOLLOW_TEXT_FLOW, cppu::UnoType<bool>::get(), PROPERTY_NONE, MID_FOLLOW_TEXT_FLOW}, \
{ OUString(UNO_NAME_IS_LAYOUT_IN_CELL), RES_FOLLOW_TEXT_FLOW, cppu::UnoType<bool>::get(), PROPERTY_NONE, MID_FTF_LAYOUT_IN_CELL}, \
+ { OUString(UNO_NAME_PARENT_TEXT), FN_UNO_PARENT_TEXT, cppu::UnoType<text::XText>::get(), PropertyAttribute::MAYBEVOID | PropertyAttribute::READONLY, 0 }, \
{ OUString(UNO_NAME_WRAP_INFLUENCE_ON_POSITION), RES_WRAP_INFLUENCE_ON_OBJPOS, cppu::UnoType<sal_Int8>::get(), PROPERTY_NONE, MID_WRAP_INFLUENCE}, \
{ OUString(UNO_NAME_TITLE), FN_UNO_TITLE, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, \
{ OUString(UNO_NAME_DESCRIPTION), FN_UNO_DESCRIPTION, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, \