[Libreoffice-commits] core.git: sw/qa sw/source

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Mon Oct 14 10:13:53 UTC 2019


 sw/qa/extras/ooxmlimport/data/tdf128076.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx     |   16 ++++++++++++++++
 sw/source/core/unocore/unofield.cxx          |    6 +++---
 3 files changed, 19 insertions(+), 3 deletions(-)

New commits:
commit 802d034c55876c9a933206176a7882ac1ae7566e
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Fri Oct 11 19:00:05 2019 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Mon Oct 14 12:13:03 2019 +0200

    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 at cib.de>
    Tested-by: Michael Stahl <michael.stahl at cib.de>

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
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf128076.docx 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)


More information about the Libreoffice-commits mailing list