summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/unotxdoc.hxx2
-rw-r--r--sw/source/core/inc/unocontentcontrol.hxx3
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx8
-rw-r--r--sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx58
-rw-r--r--sw/source/writerfilter/dmapper/SdtHelper.cxx14
5 files changed, 48 insertions, 37 deletions
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 4651ccaee190..e35a17d284b2 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -115,6 +115,7 @@ class SwXLineBreak;
class SwXTextFrame;
class SwXTextGraphicObject;
class SwXPageStyle;
+class SwXContentControl;
namespace com::sun::star::container { class XNameContainer; }
namespace com::sun::star::frame { class XController; }
namespace com::sun::star::lang { struct Locale; }
@@ -528,6 +529,7 @@ public:
SW_DLLPUBLIC rtl::Reference<SwXTextGraphicObject> createTextGraphicObject();
SW_DLLPUBLIC rtl::Reference<SwXStyle> createNumberingStyle();
SW_DLLPUBLIC rtl::Reference<SwXPageStyle> createPageStyle();
+ SW_DLLPUBLIC rtl::Reference<SwXContentControl> createContentControl();
};
class SwXLinkTargetSupplier final : public cppu::WeakImplHelper
diff --git a/sw/source/core/inc/unocontentcontrol.hxx b/sw/source/core/inc/unocontentcontrol.hxx
index 08e32afd7f54..3781512377cb 100644
--- a/sw/source/core/inc/unocontentcontrol.hxx
+++ b/sw/source/core/inc/unocontentcontrol.hxx
@@ -19,6 +19,7 @@
#pragma once
+#include <swdllapi.h>
#include <memory>
#include <deque>
@@ -48,7 +49,7 @@ typedef std::deque<rtl::Reference<SwXTextPortion>> TextRangeList_t;
* UNO API wrapper around an SwContentControl, exposed as the com.sun.star.text.ContentControl
* service.
*/
-class SwXContentControl final
+class SW_DLLPUBLIC SwXContentControl final
: public cppu::WeakImplHelper<css::lang::XServiceInfo, css::container::XEnumerationAccess,
css::text::XTextContent, css::text::XText,
css::beans::XPropertySet>
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 1107072b7c2a..90cae4b3324e 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -180,6 +180,7 @@
#include <unofield.hxx>
#include <unoframe.hxx>
#include <unoxstyle.hxx>
+#include <unocontentcontrol.hxx>
#include <SwXTextDefaults.hxx>
using namespace ::com::sun::star;
@@ -1735,6 +1736,13 @@ rtl::Reference< SwXPageStyle > SwXTextDocument::createPageStyle()
return SwXStyleFamilies::CreateStylePage(GetDocOrThrow());
}
+rtl::Reference< SwXContentControl > SwXTextDocument::createContentControl()
+{
+ SolarMutexGuard aGuard;
+ ThrowIfInvalid();
+ return SwXContentControl::CreateXContentControl(GetDocOrThrow());
+}
+
Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName)
{
return create(rServiceName, nullptr);
diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
index 2fe1cde929a4..5ea4f174537c 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
@@ -140,6 +140,8 @@
#include <unolinebreak.hxx>
#include <unoframe.hxx>
#include <unoxstyle.hxx>
+#include <unocontentcontrol.hxx>
+#include <unoport.hxx>
#define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100
#define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL 0xc200
@@ -1084,86 +1086,84 @@ void DomainMapper_Impl::PopSdt()
}
}
- uno::Reference<text::XTextContent> xContentControl(
- m_xTextDocument->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY);
+ rtl::Reference<SwXContentControl> xContentControl( m_xTextDocument->createContentControl());
if (m_pSdtHelper->GetShowingPlcHdr())
{
- xContentControlProps->setPropertyValue("ShowingPlaceHolder",
+ xContentControl->setPropertyValue("ShowingPlaceHolder",
uno::Any(m_pSdtHelper->GetShowingPlcHdr()));
}
if (!m_pSdtHelper->GetPlaceholderDocPart().isEmpty())
{
- xContentControlProps->setPropertyValue("PlaceholderDocPart",
+ xContentControl->setPropertyValue("PlaceholderDocPart",
uno::Any(m_pSdtHelper->GetPlaceholderDocPart()));
}
if (!m_pSdtHelper->GetDataBindingPrefixMapping().isEmpty())
{
- xContentControlProps->setPropertyValue("DataBindingPrefixMappings",
+ xContentControl->setPropertyValue("DataBindingPrefixMappings",
uno::Any(m_pSdtHelper->GetDataBindingPrefixMapping()));
}
if (!m_pSdtHelper->GetDataBindingXPath().isEmpty())
{
- xContentControlProps->setPropertyValue("DataBindingXpath",
+ xContentControl->setPropertyValue("DataBindingXpath",
uno::Any(m_pSdtHelper->GetDataBindingXPath()));
}
if (!m_pSdtHelper->GetDataBindingStoreItemID().isEmpty())
{
- xContentControlProps->setPropertyValue("DataBindingStoreItemID",
+ xContentControl->setPropertyValue("DataBindingStoreItemID",
uno::Any(m_pSdtHelper->GetDataBindingStoreItemID()));
}
if (!m_pSdtHelper->GetColor().isEmpty())
{
- xContentControlProps->setPropertyValue("Color",
+ xContentControl->setPropertyValue("Color",
uno::Any(m_pSdtHelper->GetColor()));
}
if (!m_pSdtHelper->GetAppearance().isEmpty())
{
- xContentControlProps->setPropertyValue("Appearance",
+ xContentControl->setPropertyValue("Appearance",
uno::Any(m_pSdtHelper->GetAppearance()));
}
if (!m_pSdtHelper->GetAlias().isEmpty())
{
- xContentControlProps->setPropertyValue("Alias",
+ xContentControl->setPropertyValue("Alias",
uno::Any(m_pSdtHelper->GetAlias()));
}
if (!m_pSdtHelper->GetTag().isEmpty())
{
- xContentControlProps->setPropertyValue("Tag",
+ xContentControl->setPropertyValue("Tag",
uno::Any(m_pSdtHelper->GetTag()));
}
if (m_pSdtHelper->GetId())
{
- xContentControlProps->setPropertyValue("Id", uno::Any(m_pSdtHelper->GetId()));
+ xContentControl->setPropertyValue("Id", uno::Any(m_pSdtHelper->GetId()));
}
if (m_pSdtHelper->GetTabIndex())
{
- xContentControlProps->setPropertyValue("TabIndex", uno::Any(m_pSdtHelper->GetTabIndex()));
+ xContentControl->setPropertyValue("TabIndex", uno::Any(m_pSdtHelper->GetTabIndex()));
}
if (!m_pSdtHelper->GetLock().isEmpty())
{
- xContentControlProps->setPropertyValue("Lock", uno::Any(m_pSdtHelper->GetLock()));
+ xContentControl->setPropertyValue("Lock", uno::Any(m_pSdtHelper->GetLock()));
}
if (m_pSdtHelper->getControlType() == SdtControlType::checkBox)
{
- xContentControlProps->setPropertyValue("Checkbox", uno::Any(true));
+ xContentControl->setPropertyValue("Checkbox", uno::Any(true));
- xContentControlProps->setPropertyValue("Checked", uno::Any(m_pSdtHelper->GetChecked()));
+ xContentControl->setPropertyValue("Checked", uno::Any(m_pSdtHelper->GetChecked()));
- xContentControlProps->setPropertyValue("CheckedState",
+ xContentControl->setPropertyValue("CheckedState",
uno::Any(m_pSdtHelper->GetCheckedState()));
- xContentControlProps->setPropertyValue("UncheckedState",
+ xContentControl->setPropertyValue("UncheckedState",
uno::Any(m_pSdtHelper->GetUncheckedState()));
}
@@ -1183,31 +1183,31 @@ void DomainMapper_Impl::PopSdt()
comphelper::makePropertyValue("Value", rValues[i])
};
}
- xContentControlProps->setPropertyValue("ListItems", uno::Any(aItems));
+ xContentControl->setPropertyValue("ListItems", uno::Any(aItems));
if (m_pSdtHelper->getControlType() == SdtControlType::dropDown)
{
- xContentControlProps->setPropertyValue("DropDown", uno::Any(true));
+ xContentControl->setPropertyValue("DropDown", uno::Any(true));
}
else
{
- xContentControlProps->setPropertyValue("ComboBox", uno::Any(true));
+ xContentControl->setPropertyValue("ComboBox", uno::Any(true));
}
}
}
if (m_pSdtHelper->getControlType() == SdtControlType::picture)
{
- xContentControlProps->setPropertyValue("Picture", uno::Any(true));
+ xContentControl->setPropertyValue("Picture", uno::Any(true));
}
bool bDateFromDataBinding = false;
if (m_pSdtHelper->getControlType() == SdtControlType::datePicker)
{
- xContentControlProps->setPropertyValue("Date", uno::Any(true));
+ xContentControl->setPropertyValue("Date", uno::Any(true));
OUString aDateFormat = m_pSdtHelper->getDateFormat().makeStringAndClear();
- xContentControlProps->setPropertyValue("DateFormat",
+ xContentControl->setPropertyValue("DateFormat",
uno::Any(aDateFormat.replaceAll("'", "\"")));
- xContentControlProps->setPropertyValue("DateLanguage",
+ xContentControl->setPropertyValue("DateLanguage",
uno::Any(m_pSdtHelper->getLocale().makeStringAndClear()));
OUString aCurrentDate = m_pSdtHelper->getDate().makeStringAndClear();
if (oData.has_value())
@@ -1215,13 +1215,13 @@ void DomainMapper_Impl::PopSdt()
aCurrentDate = *oData;
bDateFromDataBinding = true;
}
- xContentControlProps->setPropertyValue("CurrentDate",
+ xContentControl->setPropertyValue("CurrentDate",
uno::Any(aCurrentDate));
}
if (m_pSdtHelper->getControlType() == SdtControlType::plainText)
{
- xContentControlProps->setPropertyValue("PlainText", uno::Any(true));
+ xContentControl->setPropertyValue("PlainText", uno::Any(true));
}
xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true);
@@ -1229,7 +1229,7 @@ void DomainMapper_Impl::PopSdt()
if (bDateFromDataBinding)
{
OUString aDateString;
- xContentControlProps->getPropertyValue("DateString") >>= aDateString;
+ xContentControl->getPropertyValue("DateString") >>= aDateString;
xCursor->setString(aDateString);
}
diff --git a/sw/source/writerfilter/dmapper/SdtHelper.cxx b/sw/source/writerfilter/dmapper/SdtHelper.cxx
index db00c79461c0..5505d698150f 100644
--- a/sw/source/writerfilter/dmapper/SdtHelper.cxx
+++ b/sw/source/writerfilter/dmapper/SdtHelper.cxx
@@ -33,6 +33,8 @@
#include <com/sun/star/xml/dom/DocumentBuilder.hpp>
#include <unotxdoc.hxx>
#include <unobookmark.hxx>
+#include <unocontentcontrol.hxx>
+#include <unoport.hxx>
namespace writerfilter::dmapper
{
@@ -374,10 +376,8 @@ void SdtHelper::createPlainTextControl()
if (oData.has_value())
xCrsr->setString(*oData);
- uno::Reference<text::XTextContent> xContentControl(
- m_rDM_Impl.GetTextDocument()->createInstance("com.sun.star.text.ContentControl"),
- uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY);
+ rtl::Reference<SwXContentControl> xContentControl(
+ m_rDM_Impl.GetTextDocument()->createContentControl());
for (const beans::PropertyValue& prop : getInteropGrabBagAndClear())
{
@@ -418,7 +418,7 @@ void SdtHelper::createPlainTextControl()
sPropertyName = "MultiLine";
if (!sPropertyName.isEmpty())
{
- xContentControlProps->setPropertyValue(sPropertyName, internalProp.Value);
+ xContentControl->setPropertyValue(sPropertyName, internalProp.Value);
}
sPropertyName.clear();
}
@@ -426,11 +426,11 @@ void SdtHelper::createPlainTextControl()
if (!sPropertyName.isEmpty())
{
- xContentControlProps->setPropertyValue(sPropertyName, prop.Value);
+ xContentControl->setPropertyValue(sPropertyName, prop.Value);
}
}
- xContentControlProps->setPropertyValue("PlainText", uno::Any(true));
+ xContentControl->setPropertyValue("PlainText", uno::Any(true));
xText->insertTextContent(xCrsr, xContentControl, /*bAbsorb=*/true);