sw/inc/unotext.hxx                                   |    5 ++--
 sw/inc/unotxdoc.hxx                                  |    3 ++
 sw/source/core/inc/unofootnote.hxx                   |    3 +-
 sw/source/uibase/uno/unotxdoc.cxx                    |   14 +++++++++++++
 sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx |   20 ++++++++++---------
 5 files changed, 33 insertions(+), 12 deletions(-)

New commits:
commit efc8ce2c4e840cc68dbfc73da014434a3ddd0cda
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Apr 25 10:09:01 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Apr 30 09:34:29 2024 +0200

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

diff --git a/sw/inc/unotext.hxx b/sw/inc/unotext.hxx
index 5dbb7e993fc9..67a3c60bddb1 100644
--- a/sw/inc/unotext.hxx
+++ b/sw/inc/unotext.hxx
@@ -20,6 +20,7 @@
 #ifndef INCLUDED_SW_INC_UNOTEXT_HXX
 #define INCLUDED_SW_INC_UNOTEXT_HXX
 
+#include "swdllapi.h"
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/text/XTextCopy.hpp>
 #include <com/sun/star/text/XTextRangeCompare.hpp>
@@ -120,7 +121,7 @@ public:
     // XTextRange
     virtual css::uno::Reference< css::text::XText >
         SAL_CALL getText() override;
-    virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() 
override;
+    SW_DLLPUBLIC virtual css::uno::Reference< css::text::XTextRange > SAL_CALL 
getStart() override;
     virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() 
override;
     virtual OUString SAL_CALL getString() override;
     virtual void SAL_CALL setString(const OUString& rString) override;
@@ -132,7 +133,7 @@ public:
     virtual void SAL_CALL insertControlCharacter(
             const css::uno::Reference< css::text::XTextRange > & xRange,
             sal_Int16 nControlCharacter, sal_Bool bAbsorb) override;
-    virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL 
createTextCursorByRange(
+    SW_DLLPUBLIC virtual css::uno::Reference< css::text::XTextCursor > 
SAL_CALL createTextCursorByRange(
             const ::css::uno::Reference< ::css::text::XTextRange >& 
aTextPosition ) override final;
     virtual rtl::Reference< SwXTextCursor > createXTextCursorByRange(
             const ::css::uno::Reference< ::css::text::XTextRange >& 
aTextPosition ) = 0;
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index e35a17d284b2..bd6903b14882 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -92,6 +92,7 @@ class SwXTextFieldTypes;
 class SwXTextFieldMasters;
 class SwXTextSections;
 class SwXNumberingRulesCollection;
+class SwXFootnote;
 class SwXFootnotes;
 class SwXContentControls;
 class SwXDocumentIndexes;
@@ -530,6 +531,8 @@ public:
     SW_DLLPUBLIC rtl::Reference<SwXStyle> createNumberingStyle();
     SW_DLLPUBLIC rtl::Reference<SwXPageStyle> createPageStyle();
     SW_DLLPUBLIC rtl::Reference<SwXContentControl> createContentControl();
+    SW_DLLPUBLIC rtl::Reference<SwXFootnote> createFootnote();
+    SW_DLLPUBLIC rtl::Reference<SwXFootnote> createEndnote();
 };
 
 class SwXLinkTargetSupplier final : public cppu::WeakImplHelper
diff --git a/sw/source/core/inc/unofootnote.hxx 
b/sw/source/core/inc/unofootnote.hxx
index a7498a730749..c1fb2b5b1eb6 100644
--- a/sw/source/core/inc/unofootnote.hxx
+++ b/sw/source/core/inc/unofootnote.hxx
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include <swdllapi.h>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/container/XEnumerationAccess.hpp>
@@ -38,7 +39,7 @@ typedef ::cppu::WeakImplHelper
 ,   css::text::XFootnote
 > SwXFootnote_Base;
 
-class SwXFootnote final
+class SW_DLLPUBLIC SwXFootnote final
     : public SwXFootnote_Base
     , public SwXText
 {
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 90cae4b3324e..5532c67c05a6 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -1743,6 +1743,20 @@ rtl::Reference< SwXContentControl > 
SwXTextDocument::createContentControl()
     return SwXContentControl::CreateXContentControl(GetDocOrThrow());
 }
 
+rtl::Reference< SwXFootnote > SwXTextDocument::createFootnote()
+{
+    SolarMutexGuard aGuard;
+    ThrowIfInvalid();
+    return SwXFootnote::CreateXFootnote(GetDocOrThrow(), nullptr);
+}
+
+rtl::Reference< SwXFootnote > SwXTextDocument::createEndnote()
+{
+    SolarMutexGuard aGuard;
+    ThrowIfInvalid();
+    return SwXFootnote::CreateXFootnote(GetDocOrThrow(), nullptr, true);
+}
+
 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 5ea4f174537c..14c9ebae3946 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
@@ -141,6 +141,7 @@
 #include <unoframe.hxx>
 #include <unoxstyle.hxx>
 #include <unocontentcontrol.hxx>
+#include <unofootnote.hxx>
 #include <unoport.hxx>
 
 #define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100
@@ -4001,20 +4002,21 @@ void DomainMapper_Impl::PushFootOrEndnote( bool 
bIsFootnote )
         // for footnotes/endnotes to restore original LO behavior here.
         pTopContext->Erase(PROP_CHAR_STYLE_NAME);
 
-        uno::Reference< text::XText > xFootnoteText;
+        rtl::Reference< SwXFootnote > xFootnote;
         if (m_xTextDocument)
-            xFootnoteText.set( m_xTextDocument->createInstance(
-            bIsFootnote ?
-                OUString( "com.sun.star.text.Footnote" ) : OUString( 
"com.sun.star.text.Endnote" )),
-            uno::UNO_QUERY_THROW );
-        uno::Reference< text::XFootnote > xFootnote( xFootnoteText, 
uno::UNO_QUERY_THROW );
+        {
+            if (bIsFootnote)
+                xFootnote = m_xTextDocument->createFootnote();
+            else
+                xFootnote = m_xTextDocument->createEndnote();
+        }
         pTopContext->SetFootnote(xFootnote, sFootnoteCharStyleName);
         uno::Sequence< beans::PropertyValue > aFontProperties;
         if (GetTopContextOfType(CONTEXT_CHARACTER))
             aFontProperties = 
GetTopContextOfType(CONTEXT_CHARACTER)->GetPropertyValues();
-        appendTextContent( uno::Reference< text::XTextContent >( 
xFootnoteText, uno::UNO_QUERY_THROW ), aFontProperties );
-        m_aTextAppendStack.push(TextAppendContext(uno::Reference< 
text::XTextAppend >( xFootnoteText, uno::UNO_QUERY_THROW ),
-                    
xFootnoteText->createTextCursorByRange(xFootnoteText->getStart())));
+        appendTextContent( xFootnote, aFontProperties );
+        m_aTextAppendStack.push(TextAppendContext(xFootnote,
+                    
xFootnote->createTextCursorByRange(xFootnote->getStart())));
 
         // Redlines for the footnote anchor in the main text content
         std::vector< RedlineParamsPtr > aFootnoteRedline = 
std::move(m_aRedlines.top());

Reply via email to