diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-04-24 13:57:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-04-28 18:57:52 +0200 |
commit | 192f76cbb2718b9d83f4b674a71ddf8d1c467184 (patch) | |
tree | 34d6055ece77aeef6015315996889beb1116b7cd /sw/source | |
parent | a83b7cd01cb804d6138b4ca7de0e1d7a8abfe31d (diff) |
use more concrete UNO classes in writerfilter (SwXFieldmark)
Change-Id: Ifa90331eadc08e0949c28d09be92d5aed4c8a70f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166787
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 7 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 7 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/SdtHelper.cxx | 12 |
3 files changed, 16 insertions, 10 deletions
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index e72cf2a59ec5..400d9db8b805 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -175,6 +175,7 @@ #include <textcontentcontrol.hxx> #include <unocontentcontrol.hxx> #include <unoport.hxx> +#include <unobookmark.hxx> #include <SwXTextDefaults.hxx> using namespace ::com::sun::star; @@ -1674,6 +1675,12 @@ rtl::Reference< SwXBookmark > SwXTextDocument::createBookmark() return SwXBookmark::CreateXBookmark(GetDocOrThrow(), nullptr); } +rtl::Reference< SwXBookmark > SwXTextDocument::createFieldmark() +{ + SolarMutexGuard aGuard; + ThrowIfInvalid(); + return SwXFieldmark::CreateXFieldmark(GetDocOrThrow(), nullptr); +} Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName) { diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 103a836536bc..7f0b57ab483a 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -7461,8 +7461,6 @@ void DomainMapper_Impl::CloseFieldCommand() try { - uno::Reference< uno::XInterface > xFieldInterface; - const auto& [sType, vArguments, vSwitches]{ splitFieldCommand(pContext->GetCommand()) }; (void)vSwitches; OUString const sFirstParam(vArguments.empty() ? OUString() : vArguments.front()); @@ -7558,6 +7556,7 @@ void DomainMapper_Impl::CloseFieldCommand() bCreateField = false; } + uno::Reference< uno::XInterface > xFieldInterface; if( bCreateField || bCreateEnhancedField ) { //add the service prefix @@ -8347,9 +8346,9 @@ void DomainMapper_Impl::CloseFieldCommand() // Don't waste resources on wrapping shapes inside a fieldmark. if (sType != "SHAPE" && m_xTextDocument && !m_aTextAppendStack.empty()) { - xFieldInterface = m_xTextDocument->createInstance("com.sun.star.text.Fieldmark"); + rtl::Reference<SwXBookmark> xFieldInterface = m_xTextDocument->createFieldmark(); - uno::Reference<text::XFormField> const xFormField(xFieldInterface, uno::UNO_QUERY); + uno::Reference<text::XFormField> const xFormField(static_cast<cppu::OWeakObject*>(xFieldInterface.get()), uno::UNO_QUERY); InsertFieldmark(m_aTextAppendStack, xFormField, pContext->GetStartRange(), pContext->GetFieldId()); xFormField->setFieldType(ODF_UNHANDLED); diff --git a/sw/source/writerfilter/dmapper/SdtHelper.cxx b/sw/source/writerfilter/dmapper/SdtHelper.cxx index 06f3262b767e..db00c79461c0 100644 --- a/sw/source/writerfilter/dmapper/SdtHelper.cxx +++ b/sw/source/writerfilter/dmapper/SdtHelper.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/xml/xpath/XPathException.hpp> #include <com/sun/star/xml/dom/DocumentBuilder.hpp> #include <unotxdoc.hxx> +#include <unobookmark.hxx> namespace writerfilter::dmapper { @@ -473,14 +474,13 @@ void SdtHelper::createDateContentControl() return; } - uno::Reference<uno::XInterface> xFieldInterface - = m_rDM_Impl.GetTextDocument()->createInstance("com.sun.star.text.Fieldmark"); - uno::Reference<text::XFormField> xFormField(xFieldInterface, uno::UNO_QUERY); - uno::Reference<text::XTextContent> xToInsert(xFormField, uno::UNO_QUERY); - if (!(xFormField.is() && xToInsert.is())) + rtl::Reference<SwXBookmark> xFieldmark = m_rDM_Impl.GetTextDocument()->createFieldmark(); + uno::Reference<text::XFormField> xFormField(static_cast<cppu::OWeakObject*>(xFieldmark.get()), + uno::UNO_QUERY); + if (!xFormField) return; - xToInsert->attach(uno::Reference<text::XTextRange>(xCrsr, uno::UNO_QUERY_THROW)); + xFieldmark->attach(uno::Reference<text::XTextRange>(xCrsr, uno::UNO_QUERY_THROW)); xFormField->setFieldType(ODF_FORMDATE); uno::Reference<container::XNameContainer> xNameCont = xFormField->getParameters(); if (xNameCont.is()) |