diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-12-17 11:17:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-12-17 13:15:32 +0100 |
commit | 7d1b00c9924765624e0e3e5bdf947f3e30317ff8 (patch) | |
tree | 97178f0a6b1f8ade39ad33fbc39a2bae0875620e /sw/source | |
parent | 37edf62981acf8b73a70d645755e8cdbc9bbcd3f (diff) |
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.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/ui/dbui/mmlayoutpage.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/index/cntex.cxx | 21 | ||||
-rw-r--r-- | sw/source/uibase/inc/unotools.hxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 10 | ||||
-rw-r--r-- | sw/source/uibase/utlui/unotools.cxx | 9 |
6 files changed, 27 insertions, 28 deletions
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 @@ -1905,6 +1905,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; |