sw/inc/unoframe.hxx                                  |    2 -
 sw/inc/unotxdoc.hxx                                  |    6 +++
 sw/source/core/inc/unofield.hxx                      |    3 +
 sw/source/core/inc/unolinebreak.hxx                  |    3 +
 sw/source/uibase/uno/unotxdoc.cxx                    |   23 +++++++++++++++
 sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx |   29 ++++++++-----------
 sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx |    3 +
 7 files changed, 49 insertions(+), 20 deletions(-)

New commits:
commit 24ac1b2eea24c6aab04ecde88e692f352fda2b62
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Apr 24 14:49:26 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Apr 28 22:26:24 2024 +0200

    use more concrete UNO classes in writerfilter (SwXTextFrame)
    
    Change-Id: Ic00730c49c0feb7ab7e649c7d6e5d3ff1cb79b27
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166801
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx
index 9bd1c03b8b7f..705e52e40440 100644
--- a/sw/inc/unoframe.hxx
+++ b/sw/inc/unoframe.hxx
@@ -99,7 +99,7 @@ public:
 
     //XNamed
     virtual OUString SAL_CALL getName() override;
-    virtual void SAL_CALL setName(const OUString& Name_) override;
+    SW_DLLPUBLIC virtual void SAL_CALL setName(const OUString& Name_) override;
 
     //XPropertySet
     virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL 
getPropertySetInfo(  ) override;
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index b0057d2f8049..59fab6827acb 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -110,6 +110,8 @@ class SwXTextDefaults;
 class SwXBookmark;
 class SwXTextSection;
 class SwXTextField;
+class SwXLineBreak;
+class SwXTextFrame;
 namespace com::sun::star::container { class XNameContainer; }
 namespace com::sun::star::frame { class XController; }
 namespace com::sun::star::lang { struct Locale; }
@@ -518,6 +520,8 @@ public:
     SW_DLLPUBLIC rtl::Reference<SwXBookmark> createFieldmark();
     SW_DLLPUBLIC rtl::Reference<SwXTextSection> createTextSection();
     SW_DLLPUBLIC rtl::Reference<SwXTextField> createFieldAnnotation();
+    SW_DLLPUBLIC rtl::Reference<SwXLineBreak> createLineBreak();
+    SW_DLLPUBLIC rtl::Reference<SwXTextFrame> createTextFrame();
 };
 
 class SwXLinkTargetSupplier final : public cppu::WeakImplHelper
diff --git a/sw/source/core/inc/unolinebreak.hxx 
b/sw/source/core/inc/unolinebreak.hxx
index 46794f96b393..914a95322bcd 100644
--- a/sw/source/core/inc/unolinebreak.hxx
+++ b/sw/source/core/inc/unolinebreak.hxx
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include <swdllapi.h>
 #include <cppuhelper/implbase.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -30,7 +31,7 @@ class SwDoc;
 class SwFormatLineBreak;
 
 /// UNO API wrapper around an SwFormatLineBreak, exposed as the 
com.sun.star.text.LineBreak service.
-class SwXLineBreak final
+class SW_DLLPUBLIC SwXLineBreak final
     : public cppu::WeakImplHelper<css::beans::XPropertySet, 
css::lang::XServiceInfo,
                                   css::text::XTextContent>
 {
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 1e105391ff39..3d36312afecc 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -178,6 +178,7 @@
 #include <unobookmark.hxx>
 #include <unosection.hxx>
 #include <unofield.hxx>
+#include <unoframe.hxx>
 #include <SwXTextDefaults.hxx>
 
 using namespace ::com::sun::star;
@@ -1698,6 +1699,20 @@ rtl::Reference< SwXTextField > 
SwXTextDocument::createFieldAnnotation()
     return SwXTextField::CreateXTextField(&GetDocOrThrow(), nullptr, 
SwServiceType::FieldTypeAnnotation);
 }
 
+rtl::Reference< SwXLineBreak > SwXTextDocument::createLineBreak()
+{
+    SolarMutexGuard aGuard;
+    ThrowIfInvalid();
+    return SwXLineBreak::CreateXLineBreak(nullptr);
+}
+
+rtl::Reference< SwXTextFrame > SwXTextDocument::createTextFrame()
+{
+    SolarMutexGuard aGuard;
+    ThrowIfInvalid();
+    return SwXTextFrame::CreateXTextFrame(GetDocOrThrow(), nullptr);
+}
+
 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 8d8b63dfa7a0..879e9a38f8ce 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
@@ -137,6 +137,8 @@
 #include <unobookmark.hxx>
 #include <unosection.hxx>
 #include <unofield.hxx>
+#include <unolinebreak.hxx>
+#include <unoframe.hxx>
 
 #define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100
 #define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL 0xc200
@@ -5154,10 +5156,8 @@ void DomainMapper_Impl::HandleLineBreak(const 
PropertyMapPtr& pPropertyMap)
 
     if (m_xTextDocument)
     {
-        uno::Reference<text::XTextContent> xLineBreak(
-            m_xTextDocument->createInstance("com.sun.star.text.LineBreak"), 
uno::UNO_QUERY);
-        uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, 
uno::UNO_QUERY);
-        xLineBreakProps->setPropertyValue("Clear", 
uno::Any(*m_StreamStateStack.top().oLineBreakClear));
+        rtl::Reference<SwXLineBreak> xLineBreak = 
m_xTextDocument->createLineBreak();
+        xLineBreak->setPropertyValue("Clear", 
uno::Any(*m_StreamStateStack.top().oLineBreakClear));
         appendTextContent(xLineBreak, pPropertyMap->GetPropertyValues());
     }
     m_StreamStateStack.top().oLineBreakClear.reset();
@@ -5764,16 +5764,14 @@ void DomainMapper_Impl::PushTextBoxContent()
 
     try
     {
-        uno::Reference<text::XTextFrame> xTBoxFrame(
-            m_xTextDocument->createInstance("com.sun.star.text.TextFrame"), 
uno::UNO_QUERY_THROW);
-        uno::Reference<container::XNamed>(xTBoxFrame, uno::UNO_QUERY_THROW)
-            ->setName("textbox" + 
OUString::number(m_xPendingTextBoxFrames.size() + 1));
+        rtl::Reference<SwXTextFrame> 
xTBoxFrame(m_xTextDocument->createTextFrame());
+        xTBoxFrame->setName("textbox" + 
OUString::number(m_xPendingTextBoxFrames.size() + 1));
         
uno::Reference<text::XTextAppendAndConvert>(m_aTextAppendStack.top().xTextAppend,
             uno::UNO_QUERY_THROW)
-            ->appendTextContent(xTBoxFrame, beans::PropertyValues());
+            ->appendTextContent(static_cast<SwXFrame*>(xTBoxFrame.get()), 
beans::PropertyValues());
         m_xPendingTextBoxFrames.push(xTBoxFrame);
 
-        
m_aTextAppendStack.push(TextAppendContext(uno::Reference<text::XTextAppend>(xTBoxFrame,
 uno::UNO_QUERY_THROW), {}));
+        m_aTextAppendStack.push(TextAppendContext(xTBoxFrame, {}));
         m_StreamStateStack.top().bIsInTextBox = true;
 
         appendTableManager();
commit 94122cb7513a277b21f21611bba36505176f53b6
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Apr 24 14:26:46 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Apr 28 22:26:14 2024 +0200

    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.gran...@collabora.co.uk>

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;

Reply via email to