summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2019-10-11 19:00:05 +0200
committerMichael Stahl <michael.stahl@cib.de>2019-10-14 12:13:03 +0200
commit802d034c55876c9a933206176a7882ac1ae7566e (patch)
treea147d997019e363ee22f6847cdc140123d0cd2d2
parentb4be66f14abce2e817fd636f53433a8dc6c031fd (diff)
tdf#128076: throw exception only if it's not alive and it's not a description
According to a comment from https://gerrit.libreoffice.org/#/c/74533/ okay... then i guess there are different kinds of callers: those who actually want to check if its a descriptor, and those who want to check that it isn't "live" so check if it's a description even if it's not alive Change-Id: I1526fdbcb006506cc67d29cbe3f65138f90843dc Reviewed-on: https://gerrit.libreoffice.org/80677 Reviewed-by: Michael Stahl <michael.stahl@cib.de> Tested-by: Michael Stahl <michael.stahl@cib.de>
-rw-r--r--sw/qa/extras/ooxmlimport/data/tdf128076.docxbin0 -> 18928 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx16
-rw-r--r--sw/source/core/unocore/unofield.cxx6
3 files changed, 19 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf128076.docx b/sw/qa/extras/ooxmlimport/data/tdf128076.docx
new file mode 100644
index 000000000000..69490a14554b
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf128076.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index f5c85890e3b2..1f151b363002 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -209,6 +209,22 @@ xray ThisComponent.DrawPage(1).getByIndex(0).Anchor.PageStyleName
CPPUNIT_ASSERT_EQUAL(OUString("First Page"), getProperty<OUString>(xTextContent->getAnchor(), "PageStyleName"));
}
+DECLARE_OOXMLIMPORT_TEST(testTdf128076, "tdf128076.docx")
+{
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+
+ if( !xFields->hasMoreElements() ) {
+ CPPUNIT_ASSERT(false);
+ return;
+ }
+
+ uno::Reference<text::XTextField> xEnumerationAccess(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("User Field adres = Test"), xEnumerationAccess->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("Test"), xEnumerationAccess->getPresentation(false).trim());
+}
+
DECLARE_OOXMLIMPORT_TEST(testfdo90720, "testfdo90720.docx")
{
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index cbf34d1ffb5d..51ea73498e46 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1182,11 +1182,11 @@ public:
SwFieldType* GetFieldType() const
{
- if(!m_pDoc)
+ if(!m_pDoc && !IsDescriptor())
throw uno::RuntimeException();
-
- if (IsDescriptor())
+ else if (IsDescriptor())
return m_pFieldType;
+
return m_pFormatField->GetField()->GetTyp();
}
void SetFieldType(SwFieldType& rType)