summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-08-23 17:24:40 +0200
committerXisco Faulí <xiscofauli@libreoffice.org>2019-09-17 15:21:35 +0200
commitafe190f1545a159e67d48eeba5c6be133d262af0 (patch)
tree116042de5545908b7c65f9e4a9e583680c62d1cc
parent4436a29401beffd0893ecae70cd09c7a49f49f22 (diff)
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@collabora.com> (cherry picked from commit 3ceefe9abff98fc24ffb5e8e405f4999faddc351) Change-Id: I945098277d1ed34c65b43f0f6ad8eb361cf41b53 Reviewed-on: https://gerrit.libreoffice.org/78394 Tested-by: Jenkins Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf119809.docxbin0 -> 22211 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport13.cxx11
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx5
-rw-r--r--writerfilter/source/dmapper/SdtHelper.cxx3
-rw-r--r--writerfilter/source/dmapper/SdtHelper.hxx5
5 files changed, 22 insertions, 2 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf119809.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 4942409a78d5..825907b4a781 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -13,6 +13,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/text/XTextFrame.hpp>
#include <com/sun/star/text/XTextFramesSupplier.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
#include <sfx2/docfile.hxx>
#include <sfx2/docfilt.hxx>
@@ -131,6 +132,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 9d2cbd7bfe81..e421109ba396 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1016,7 +1016,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();
break;
case NS_ooxml::LN_CT_SdtListItem_displayText:
@@ -2394,6 +2394,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);
@@ -3193,7 +3194,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 cccebf1d260c..5f1f16c2c8aa 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -91,6 +91,7 @@ static awt::Size lcl_getOptimalWidth(const StyleSheetTablePtr& pStyleSheet, OUSt
SdtHelper::SdtHelper(DomainMapper_Impl& rDM_Impl)
: m_rDM_Impl(rDM_Impl)
+ , m_bInsideDropDownControl(false)
, m_bHasElements(false)
, m_bOutsideAParagraph(false)
{
@@ -100,6 +101,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);
@@ -110,6 +112,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()
diff --git a/writerfilter/source/dmapper/SdtHelper.hxx b/writerfilter/source/dmapper/SdtHelper.hxx
index 91f005f9d544..7a0760433d98 100644
--- a/writerfilter/source/dmapper/SdtHelper.hxx
+++ b/writerfilter/source/dmapper/SdtHelper.hxx
@@ -50,6 +50,8 @@ class SdtHelper final : public virtual SvRefBase
/// 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.
@@ -111,6 +113,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();
/// Create date control from w:sdt's w:date.