diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2019-10-11 19:00:05 +0200 |
---|---|---|
committer | Xisco Faulí <xiscofauli@libreoffice.org> | 2019-10-15 10:56:42 +0200 |
commit | 52485e1f3464ab69b38d2e240c8c364d6b78ceb8 (patch) | |
tree | 1840af2e52fcd17045b6f64dbf6df2eb2e277786 /sw | |
parent | 6f9407c0d872675dbcbd0dc52fd7a0fdb098804b (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>
(cherry picked from commit 802d034c55876c9a933206176a7882ac1ae7566e)
Reviewed-on: https://gerrit.libreoffice.org/80764
Tested-by: Jenkins
Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf128076.docx | bin | 0 -> 18928 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/unocore/unofield.cxx | 6 |
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 Binary files differnew file mode 100644 index 000000000000..69490a14554b --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf128076.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 4ee66606b7a6..94b6c66ac82d 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -211,6 +211,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 0cbf59a13931..c8363b9c01f9 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1186,11 +1186,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) |