sw/inc/unoidxcoll.hxx               |    2 +-
 sw/inc/unotxdoc.hxx                 |    1 +
 sw/source/ui/dbui/mmlayoutpage.cxx  |    5 ++---
 sw/source/ui/index/cntex.cxx        |   21 ++++++++-------------
 sw/source/uibase/inc/unotools.hxx   |    5 +++--
 sw/source/uibase/uno/unotxdoc.cxx   |    5 +++++
 sw/source/uibase/utlui/content.cxx  |   10 +++++-----
 sw/source/uibase/utlui/unotools.cxx |    9 ++++-----
 8 files changed, 29 insertions(+), 29 deletions(-)

New commits:
commit 7d1b00c9924765624e0e3e5bdf947f3e30317ff8
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Dec 17 11:17:13 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Dec 17 13:15:32 2024 +0100

    use more concrete UNO in sw
    
    Change-Id: I664c7eff512625f988a2a278062719d3084845dd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178645
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/unoidxcoll.hxx b/sw/inc/unoidxcoll.hxx
index b1bbe17248dc..92d275ca9a79 100644
--- a/sw/inc/unoidxcoll.hxx
+++ b/sw/inc/unoidxcoll.hxx
@@ -21,7 +21,7 @@
 
 #include "unocoll.hxx"
 
-class SwXDocumentIndexes final
+class SW_DLLPUBLIC SwXDocumentIndexes final
     : public SwCollectionBaseClass
     , public SwUnoCollection
 {
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 68ce93ff4875..28241df41d82 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -524,6 +524,7 @@ public:
 
     SwDocShell*                 GetDocShell() {return m_pDocShell;}
 
+    rtl::Reference<SwXDocumentIndexes> getSwDocumentIndexes();
     rtl::Reference<SwXTextTables> getSwTextTables();
     rtl::Reference<SwFmDrawPage> getSwDrawPage();
     rtl::Reference<SwXFootnotes> getSwXFootnotes();
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx 
b/sw/source/ui/dbui/mmlayoutpage.cxx
index e4fc8b02b1fd..4948cdfe5c59 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -591,12 +591,11 @@ IMPL_LINK_NOARG(SwMailMergeLayoutPage, 
PreviewLoadedHdl_Impl, SwOneExampleFrame&
 {
     m_xExampleContainerWIN->show();
 
-    Reference< XModel > & xModel = m_xExampleFrame->GetModel();
+    rtl::Reference< SwXTextDocument > & xModel = m_xExampleFrame->GetModel();
     //now the ViewOptions should be set properly
     Reference< XViewSettingsSupplier >  
xSettings(xModel->getCurrentController(), UNO_QUERY);
     m_xViewProperties = xSettings->getViewSettings();
-    auto pXDoc = comphelper::getFromUnoTunnel<SwXTextDocument>(xModel);
-    SwDocShell* pDocShell = pXDoc->GetDocShell();
+    SwDocShell* pDocShell = xModel->GetDocShell();
     m_pExampleWrtShell = pDocShell->GetWrtShell();
     OSL_ENSURE(m_pExampleWrtShell, "No SwWrtShell found!");
     if(!m_pExampleWrtShell)
diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx
index 663926af3fe9..b83d453c3844 100644
--- a/sw/source/ui/index/cntex.cxx
+++ b/sw/source/ui/index/cntex.cxx
@@ -39,6 +39,7 @@
 
 #include <SwStyleNameMapper.hxx>
 #include <swuicnttab.hxx>
+#include <unoidxcoll.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::text;
@@ -86,16 +87,13 @@ IMPL_LINK_NOARG(SwMultiTOXTabDialog, CreateExample_Hdl, 
SwOneExampleFrame&, void
 {
     try
     {
-        uno::Reference< frame::XModel > & xModel = m_xExampleFrame->GetModel();
-        auto pDoc = comphelper::getFromUnoTunnel<SwXTextDocument>(xModel);
+        rtl::Reference< SwXTextDocument > & xDoc = m_xExampleFrame->GetModel();
 
-        if( pDoc )
-            pDoc->GetDocShell()->LoadStyles_( 
*m_rWrtShell.GetView().GetDocShell(), true );
+        if( xDoc )
+            xDoc->GetDocShell()->LoadStyles_( 
*m_rWrtShell.GetView().GetDocShell(), true );
 
-        uno::Reference< text::XTextSectionsSupplier >  xSectionSupplier(
-                                                 xModel, uno::UNO_QUERY);
         uno::Reference< container::XNameAccess >  xSections =
-                                        xSectionSupplier->getTextSections();
+                                        xDoc->getTextSections();
 
         for(int i = 0; i < 7; ++i )
         {
@@ -103,8 +101,7 @@ IMPL_LINK_NOARG(SwMultiTOXTabDialog, CreateExample_Hdl, 
SwOneExampleFrame&, void
             uno::Any aSection = xSections->getByName( sTmp );
             aSection >>= m_vTypeData[i].m_oIndexSections->xContainerSection;
         }
-        uno::Reference< text::XDocumentIndexesSupplier >  xIdxSupp(xModel, 
uno::UNO_QUERY);
-        uno::Reference< container::XIndexAccess >  xIdxs = 
xIdxSupp->getDocumentIndexes();
+        rtl::Reference< SwXDocumentIndexes >  xIdxs = 
xDoc->getSwDocumentIndexes();
         int n = xIdxs->getCount();
         while(n)
         {
@@ -144,7 +141,7 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample(
         OSL_ENSURE(m_vTypeData[nTOXIndex].m_oIndexSections &&
                         
m_vTypeData[nTOXIndex].m_oIndexSections->xContainerSection.is(),
                             "Section not created");
-        uno::Reference< frame::XModel > & xModel = m_xExampleFrame->GetModel();
+        rtl::Reference< SwXTextDocument > & xModel = 
m_xExampleFrame->GetModel();
         bool bInitialCreate = true;
         if(!m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex.is())
         {
@@ -155,11 +152,9 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample(
              xAnchor = xAnchor->getStart();
              uno::Reference< text::XTextCursor >  xCursor = 
xAnchor->getText()->createTextCursorByRange(xAnchor);
 
-             uno::Reference< lang::XMultiServiceFactory >  xFact(xModel, 
uno::UNO_QUERY);
-
              OUString sIndexTypeName(OUString::createFromAscii( 
IndexServiceNames[
                     nTOXIndex <= TOX_AUTHORITIES ? nTOXIndex : TOX_USER] ));
-             
m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex.set(xFact->createInstance(sIndexTypeName),
 uno::UNO_QUERY);
+             
m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex.set(xModel->createInstance(sIndexTypeName),
 uno::UNO_QUERY);
              uno::Reference< text::XTextContent >  xContent = 
m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex;
              xCursor->getText()->insertTextContent(xCursor, xContent, false);
         }
diff --git a/sw/source/uibase/inc/unotools.hxx 
b/sw/source/uibase/inc/unotools.hxx
index e472a2f92706..6bc64fb1adc7 100644
--- a/sw/source/uibase/inc/unotools.hxx
+++ b/sw/source/uibase/inc/unotools.hxx
@@ -41,11 +41,12 @@
 
 class SwView;
 class SwXTextCursor;
+class SwXTextDocument;
 
 class SW_DLLPUBLIC SwOneExampleFrame final : public 
weld::CustomWidgetController
 {
     ScopedVclPtr<VirtualDevice> m_xVirDev;
-    css::uno::Reference< css::frame::XModel >         m_xModel;
+    rtl::Reference< SwXTextDocument >         m_xModel;
     css::uno::Reference< css::frame::XController >    m_xController;
     rtl::Reference< SwXTextCursor >                   m_xCursor;
 
@@ -75,7 +76,7 @@ public:
     virtual bool Command(const CommandEvent& rCEvt) override;
     virtual ~SwOneExampleFrame() override;
 
-    css::uno::Reference< css::frame::XModel > &       GetModel()      {return 
m_xModel;}
+    rtl::Reference< SwXTextDocument > &               GetModel()      {return 
m_xModel;}
     rtl::Reference< SwXTextCursor > &                 GetTextCursor() {return 
m_xCursor;}
 
     void ClearDocument();
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 7bfa033584e1..a878670e9489 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -1904,6 +1904,11 @@ Sequence< OUString > 
SwXTextDocument::getSupportedServiceNames()
 }
 
 Reference< XIndexAccess >  SwXTextDocument::getDocumentIndexes()
+{
+    return getSwDocumentIndexes();
+}
+
+rtl::Reference< SwXDocumentIndexes >  SwXTextDocument::getSwDocumentIndexes()
 {
     SolarMutexGuard aGuard;
     ThrowIfInvalid();
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 72cb5c3c0931..5e50407b7b9b 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -125,6 +125,7 @@
 
 #include <expfld.hxx>
 #include <unotxdoc.hxx>
+#include <unoidxcoll.hxx>
 
 #define CTYPE_CNT   0
 #define CTYPE_CTT   1
@@ -6247,13 +6248,12 @@ void SwContentTree::EditEntry(const weld::TreeIter& 
rEntry, EditEntryMode nMode)
                 case EditEntryMode::RENAME:
                 {
                     rtl::Reference< SwXTextDocument > xModel = 
m_pActiveShell->GetView().GetDocShell()->GetBaseModel();
-                    Reference< XIndexAccess> 
xIdxAcc(xModel->getDocumentIndexes());
-                    Reference< XNameAccess >xLocalNameAccess(xIdxAcc, 
UNO_QUERY);
+                    rtl::Reference< SwXDocumentIndexes> xIdxAcc = 
xModel->getSwDocumentIndexes();
                     if(EditEntryMode::RENAME == nMode)
-                        xNameAccess = std::move(xLocalNameAccess);
-                    else if(xLocalNameAccess.is() && 
xLocalNameAccess->hasByName(pBase->GetTOXName()))
+                        xNameAccess = xIdxAcc;
+                    else if(xIdxAcc.is() && 
xIdxAcc->hasByName(pBase->GetTOXName()))
                     {
-                        Any aIdx = 
xLocalNameAccess->getByName(pBase->GetTOXName());
+                        Any aIdx = xIdxAcc->getByName(pBase->GetTOXName());
                         Reference< XDocumentIndex> xIdx;
                         if(aIdx >>= xIdx)
                             xIdx->update();
diff --git a/sw/source/uibase/utlui/unotools.cxx 
b/sw/source/uibase/utlui/unotools.cxx
index 7029b6f29e68..94c8853b642c 100644
--- a/sw/source/uibase/utlui/unotools.cxx
+++ b/sw/source/uibase/utlui/unotools.cxx
@@ -27,6 +27,7 @@
 #include <unotools.hxx>
 #include <unoprnms.hxx>
 #include <unotextcursor.hxx>
+#include <unotxdoc.hxx>
 #include <i18nutil/unicode.hxx>
 #include <o3tl/string_view.hxx>
 #include <rtl/string.h>
@@ -189,7 +190,7 @@ void SwOneExampleFrame::CreateControl()
             { "Hidden", uno::Any(true) }
         }));
 
-    m_xModel.set(xDesktop->loadComponentFromURL(sTempURL, u"_blank"_ustr, 0, 
args), uno::UNO_QUERY);
+    m_xModel = 
dynamic_cast<SwXTextDocument*>(xDesktop->loadComponentFromURL(sTempURL, 
u"_blank"_ustr, 0, args).get());
 
     m_aLoadedIdle.Start();
 }
@@ -283,8 +284,7 @@ IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer, 
void )
             m_bIsInitialized = true;
         }
 
-        uno::Reference< text::XTextDocument >  xDoc(m_xModel, uno::UNO_QUERY);
-        uno::Reference< text::XText >  xText = xDoc->getText();
+        uno::Reference< text::XText >  xText = m_xModel->getText();
         uno::Reference< text::XTextCursor > xTextCursor = 
xText->createTextCursor();
         m_xCursor = dynamic_cast<SwXTextCursor*>(xTextCursor.get());
         assert(bool(xTextCursor) == bool(m_xCursor) && "expect to get 
SwXTextCursor type here");
@@ -366,8 +366,7 @@ IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer, 
void )
         OUString sPageStyle;
         aPageStyle >>= sPageStyle;
 
-        uno::Reference< style::XStyleFamiliesSupplier >  xSSupp( xDoc, 
uno::UNO_QUERY);
-        uno::Reference< container::XNameAccess >  xStyles = 
xSSupp->getStyleFamilies();
+        uno::Reference< container::XNameAccess >  xStyles = 
m_xModel->getStyleFamilies();
         uno::Any aPFamily = xStyles->getByName( u"PageStyles"_ustr );
         uno::Reference< container::XNameContainer >  xPFamily;
 

Reply via email to