[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sw/qa writerfilter/source

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 23 19:09:11 UTC 2019


 sw/qa/extras/ooxmlexport/data/tdf119809.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx   |   11 +++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx |    5 +++--
 writerfilter/source/dmapper/SdtHelper.cxx    |    3 +++
 writerfilter/source/dmapper/SdtHelper.hxx    |    5 +++++
 5 files changed, 22 insertions(+), 2 deletions(-)

New commits:
commit 0c7b24745bad049ce57ec13afb6f6c4e7210c2a3
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Aug 23 17:24:40 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Fri Aug 23 21:04:18 2019 +0200

    tdf#119809: FILESAVE DOCX The combo box ActiveX control is lost
    
    The problem was with the empty combobox. The implemenation before this
    commit imported a combobox only when the combobox had any item.
    
    Reviewed-on: https://gerrit.libreoffice.org/78024
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 3ceefe9abff98fc24ffb5e8e405f4999faddc351)
    
    Change-Id: I945098277d1ed34c65b43f0f6ad8eb361cf41b53

diff --git a/sw/qa/extras/ooxmlexport/data/tdf119809.docx b/sw/qa/extras/ooxmlexport/data/tdf119809.docx
new file mode 100644
index 000000000000..977938253108
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf119809.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 04e8442cac40..506d17729e01 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -29,6 +29,7 @@
 #include <xmloff/odffields.hxx>
 #include <IDocumentMarkAccess.hxx>
 #include <IMark.hxx>
+#include <com/sun/star/drawing/XControlShape.hpp>
 
 class Test : public SwModelTestBase
 {
@@ -555,6 +556,16 @@ DECLARE_OOXMLEXPORT_TEST(tdf127085, "tdf127085.docx")
     CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty<sal_Int16>(xShape, "FillTransparence"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(tdf119809, "tdf119809.docx")
+{
+    // Combobox without an item list lost during import
+    uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
+    uno::Reference<lang::XServiceInfo> xServiceInfo(xPropertySet, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService("com.sun.star.form.component.ComboBox")));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty< uno::Sequence<OUString> >(xPropertySet, "StringItemList").getLength());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 673037ee884e..f2e7270b5597 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1037,7 +1037,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
             else
                 m_pImpl->setSdtEndDeferred(true);
 
-            if (!m_pImpl->m_pSdtHelper->getDropDownItems().empty())
+            if (m_pImpl->m_pSdtHelper->isInsideDropDownControl())
                 m_pImpl->m_pSdtHelper->createDropDownControl();
             else if (m_pImpl->m_pSdtHelper->validateDateFormat())
                 m_pImpl->m_pSdtHelper->createDateContentControl();
@@ -2553,6 +2553,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
     case NS_ooxml::LN_CT_SdtPr_dropDownList:
     case NS_ooxml::LN_CT_SdtPr_comboBox:
     {
+        m_pImpl->m_pSdtHelper->setInsideDropDownControl(true);
         writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
         if (pProperties.get() != nullptr)
             pProperties->resolve(*this);
@@ -3326,7 +3327,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
     }
 
     bool bNewLine = len == 1 && (sText[0] == 0x0d || sText[0] == 0x07);
-    if (!m_pImpl->m_pSdtHelper->getDropDownItems().empty())
+    if (m_pImpl->m_pSdtHelper->isInsideDropDownControl())
     {
         if (bNewLine)
             // Dropdown control has single-line texts, so in case of newline, create the control.
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx
index eec3438fa2a4..80ac2e6eb650 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -65,6 +65,7 @@ awt::Size lcl_getOptimalWidth(const StyleSheetTablePtr& pStyleSheet, OUString co
 
 SdtHelper::SdtHelper(DomainMapper_Impl& rDM_Impl)
     : m_rDM_Impl(rDM_Impl)
+    , m_bInsideDropDownControl(false)
     , m_bHasElements(false)
     , m_bOutsideAParagraph(false)
 {
@@ -74,6 +75,7 @@ SdtHelper::~SdtHelper() = default;
 
 void SdtHelper::createDropDownControl()
 {
+    assert(m_bInsideDropDownControl);
     OUString aDefaultText = m_aSdtTexts.makeStringAndClear();
     uno::Reference<awt::XControlModel> xControlModel(m_rDM_Impl.GetTextFactory()->createInstance("com.sun.star.form.component.ComboBox"), uno::UNO_QUERY);
     uno::Reference<beans::XPropertySet> xPropertySet(xControlModel, uno::UNO_QUERY);
@@ -84,6 +86,7 @@ void SdtHelper::createDropDownControl()
     createControlShape(lcl_getOptimalWidth(m_rDM_Impl.GetStyleSheetTable(), aDefaultText, m_aDropDownItems),
                        xControlModel, uno::Sequence<beans::PropertyValue>());
     m_aDropDownItems.clear();
+    m_bInsideDropDownControl = false;
 }
 
 bool SdtHelper::validateDateFormat() const
diff --git a/writerfilter/source/dmapper/SdtHelper.hxx b/writerfilter/source/dmapper/SdtHelper.hxx
index 737021daae66..896d4a9ca5cf 100644
--- a/writerfilter/source/dmapper/SdtHelper.hxx
+++ b/writerfilter/source/dmapper/SdtHelper.hxx
@@ -53,6 +53,8 @@ class SdtHelper final
 
     /// Items of the drop-down control.
     std::vector<OUString> m_aDropDownItems;
+    /// Indicator of a drop-down control
+    bool m_bInsideDropDownControl;
     /// Pieces of the default text -- currently used only by the dropdown control.
     OUStringBuffer m_aSdtTexts;
     /// Date ISO string contained in the w:date element, used by the date control.
@@ -123,6 +125,9 @@ public:
         return m_bOutsideAParagraph;
     }
 
+    bool isInsideDropDownControl() const { return m_bInsideDropDownControl; }
+    void setInsideDropDownControl(bool bInside) { m_bInsideDropDownControl = bInside; }
+
     /// Create drop-down control from w:sdt's w:dropDownList.
     void createDropDownControl();
 


More information about the Libreoffice-commits mailing list