summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-04-24 14:26:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-04-28 22:26:14 +0200
commit94122cb7513a277b21f21611bba36505176f53b6 (patch)
tree66358b5928fa77faa4c15fc8d1a1d54326692a9d
parent45d2d90d2354a6a32297cde52c0041915499b19b (diff)
use more concrete UNO classes in writerfilter (field annotation)
Change-Id: I39e2c1d7d3c49017795d1365895ef8bd8d1e0e87 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166800 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/inc/unotxdoc.hxx2
-rw-r--r--sw/source/core/inc/unofield.hxx3
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx8
-rw-r--r--sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx11
-rw-r--r--sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx3
5 files changed, 19 insertions, 8 deletions
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 9c1e5e39b29c..b0057d2f8049 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -109,6 +109,7 @@ class SwXDocumentSettings;
class SwXTextDefaults;
class SwXBookmark;
class SwXTextSection;
+class SwXTextField;
namespace com::sun::star::container { class XNameContainer; }
namespace com::sun::star::frame { class XController; }
namespace com::sun::star::lang { struct Locale; }
@@ -516,6 +517,7 @@ public:
SW_DLLPUBLIC rtl::Reference<SwXBookmark> createBookmark();
SW_DLLPUBLIC rtl::Reference<SwXBookmark> createFieldmark();
SW_DLLPUBLIC rtl::Reference<SwXTextSection> createTextSection();
+ SW_DLLPUBLIC rtl::Reference<SwXTextField> createFieldAnnotation();
};
class SwXLinkTargetSupplier final : public cppu::WeakImplHelper
diff --git a/sw/source/core/inc/unofield.hxx b/sw/source/core/inc/unofield.hxx
index 3224db126fca..924ff0ec358c 100644
--- a/sw/source/core/inc/unofield.hxx
+++ b/sw/source/core/inc/unofield.hxx
@@ -19,6 +19,7 @@
#pragma once
+#include <swdllapi.h>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/util/XUpdatable.hpp>
@@ -114,7 +115,7 @@ typedef ::cppu::WeakImplHelper
* UNO wrapper around an SwFormatField, i.e. a Writer field that the user creates via Insert ->
* Field.
*/
-class SwXTextField final
+class SW_DLLPUBLIC SwXTextField final
: public SwXTextField_Base
{
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 0d5a46f692ef..1e105391ff39 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -177,6 +177,7 @@
#include <unoport.hxx>
#include <unobookmark.hxx>
#include <unosection.hxx>
+#include <unofield.hxx>
#include <SwXTextDefaults.hxx>
using namespace ::com::sun::star;
@@ -1690,6 +1691,13 @@ rtl::Reference< SwXTextSection > SwXTextDocument::createTextSection()
return SwXTextSection::CreateXTextSection(nullptr, false);
}
+rtl::Reference< SwXTextField > SwXTextDocument::createFieldAnnotation()
+{
+ SolarMutexGuard aGuard;
+ ThrowIfInvalid();
+ return SwXTextField::CreateXTextField(&GetDocOrThrow(), nullptr, SwServiceType::FieldTypeAnnotation);
+}
+
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 241783ab848c..8d8b63dfa7a0 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
@@ -136,6 +136,7 @@
#include <SwXTextDefaults.hxx>
#include <unobookmark.hxx>
#include <unosection.hxx>
+#include <unofield.hxx>
#define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100
#define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL 0xc200
@@ -4247,8 +4248,7 @@ void DomainMapper_Impl::PushAnnotation()
m_StreamStateStack.top().eSubstreamType = SubstreamType::Annotation;
if (!m_xTextDocument)
return;
- m_xAnnotationField.set( m_xTextDocument->createInstance( "com.sun.star.text.TextField.Annotation" ),
- uno::UNO_QUERY_THROW );
+ m_xAnnotationField = m_xTextDocument->createFieldAnnotation();
uno::Reference< text::XText > xAnnotationText;
m_xAnnotationField->getPropertyValue("TextRange") >>= xAnnotationText;
m_aTextAppendStack.push(TextAppendContext(uno::Reference< text::XTextAppend >( xAnnotationText, uno::UNO_QUERY_THROW ),
@@ -4521,9 +4521,8 @@ void DomainMapper_Impl::PopAnnotation()
if (m_nAnnotationId == -1 || !m_aAnnotationPositions[m_nAnnotationId].m_xStart.is() || !m_aAnnotationPositions[m_nAnnotationId].m_xEnd.is())
{
uno::Sequence< beans::PropertyValue > aEmptyProperties;
- uno::Reference< text::XTextContent > xContent( m_xAnnotationField, uno::UNO_QUERY_THROW );
- appendTextContent( xContent, aEmptyProperties );
- CheckRedline( xContent->getAnchor( ) );
+ appendTextContent( m_xAnnotationField, aEmptyProperties );
+ CheckRedline( m_xAnnotationField->getAnchor( ) );
}
else
{
@@ -4547,7 +4546,7 @@ void DomainMapper_Impl::PopAnnotation()
// Attach the annotation to the range.
uno::Reference<text::XTextAppend> const xTextAppend = m_aTextAppendStack.top().xTextAppend;
- xTextAppend->insertTextContent(xTextRange, uno::Reference<text::XTextContent>(m_xAnnotationField, uno::UNO_QUERY_THROW), !xCursor->isCollapsed());
+ xTextAppend->insertTextContent(xTextRange, m_xAnnotationField, !xCursor->isCollapsed());
if (bMarker)
{
diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx
index 19f4d2cf0d23..7cd24bf51821 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx
@@ -58,6 +58,7 @@
class SwXTextDocument;
class SwXDocumentSettings;
class SwXTextSection;
+class SwXTextField;
namespace com::sun::star{
namespace awt{
struct Size;
@@ -661,7 +662,7 @@ private:
::std::set<::std::pair<PagePartType, PageType>> m_HeaderFooterSeen;
//annotation import
- css::uno::Reference< css::beans::XPropertySet > m_xAnnotationField;
+ rtl::Reference< SwXTextField > m_xAnnotationField;
sal_Int32 m_nAnnotationId;
bool m_bAnnotationResolved = false;
OUString m_sAnnotationParent;