summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-05-30 14:56:40 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-05-31 08:39:35 +0200
commit7f1940b1c8667538e2892a9bc3b898d0944b544b (patch)
treea5b73c8dde3af16ee7fbe997a5a43a3634e8ea8b
parent4a504709498628378bcdf576a7e2da85d33e20a3 (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. (cherry picked from commit 6f179ce5c5469d1c53e4bb7736384b2d9ce51926) Conflicts: sw/inc/unoframe.hxx sw/source/core/unocore/unomapproperties.hxx Change-Id: I6e8006fbd666802070cfeb88ca4528c66cc6d559 Reviewed-on: https://gerrit.libreoffice.org/73205 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--offapi/com/sun/star/text/TextFrame.idl8
-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
6 files changed, 31 insertions, 0 deletions
diff --git a/offapi/com/sun/star/text/TextFrame.idl b/offapi/com/sun/star/text/TextFrame.idl
index 68a73141b1fd..44f4139d92f7 100644
--- a/offapi/com/sun/star/text/TextFrame.idl
+++ b/offapi/com/sun/star/text/TextFrame.idl
@@ -142,6 +142,14 @@ published service TextFrame
@since LibreOffice 4.3
*/
[optional, property] com::sun::star::drawing::TextVerticalAdjust TextVerticalAdjust;
+
+ /** Parent text of this text frame.
+
+ This might be a header text, body text, etc.
+
+ @since LibreOffice 6.3
+ */
+ [optional, readonly, property] com::sun::star::text::XText ParentText;
};
diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx
index 4bf9e3aa0647..3396d00b1d92 100644
--- a/sw/inc/unoframe.hxx
+++ b/sw/inc/unoframe.hxx
@@ -70,6 +70,7 @@ private:
OUString m_sName;
SwPaM* m_pCopySource;
+ 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 e6dc81d274e0..94c04287c0bb 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -159,6 +159,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 64c0a7c443ca..549b2b75d415 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -2268,6 +2268,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 633fd3db3e2e..fb3154246fe0 100644
--- a/sw/source/core/unocore/unomapproperties.hxx
+++ b/sw/source/core/unocore/unomapproperties.hxx
@@ -317,6 +317,7 @@
{ OUString(UNO_NAME_USER_DEFINED_ATTRIBUTES), RES_UNKNOWNATR_CONTAINER, cppu::UnoType<css::container::XNameContainer>::get(), PropertyAttribute::MAYBEVOID, 0 },\
{ 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, 0}, \
+ { 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}, \