sd/IwyuFilter_sd.yaml | 8 - sd/source/console/PresenterViewFactory.cxx | 19 +--- sd/source/filter/grf/sdgrffilter.cxx | 8 - sd/source/ui/framework/factories/BasicPaneFactory.cxx | 80 ++++++++---------- sd/source/ui/framework/factories/BasicViewFactory.cxx | 33 +++---- sd/source/ui/inc/SdUnoDrawView.hxx | 4 sd/source/ui/unoidl/SdUnoDrawView.cxx | 50 ++++------- sd/source/ui/unoidl/unolayer.cxx | 25 ++--- sd/source/ui/unoidl/unomodel.cxx | 2 sd/source/ui/unoidl/unosrch.cxx | 36 +++----- sd/source/ui/unoidl/unowcntr.cxx | 2 sd/source/ui/view/drviews5.cxx | 5 - solenv/clang-format/excludelist | 2 13 files changed, 127 insertions(+), 147 deletions(-)
New commits: commit 934c0769ed78ae6f503d869c9cdcaf3e744f3316 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Mar 6 15:12:55 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Mar 6 17:21:18 2025 +0100 use more concrete UNO classes in sd Change-Id: I8727b67fbafa2a7baf89589ee2c85ce4637659ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182584 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sd/IwyuFilter_sd.yaml b/sd/IwyuFilter_sd.yaml index 334cd7c7267d..4d4b6081ba4b 100644 --- a/sd/IwyuFilter_sd.yaml +++ b/sd/IwyuFilter_sd.yaml @@ -84,6 +84,10 @@ excludelist: sd/inc/undo/undoobjects.hxx: # base class has to be a complete type - tools/weakbase.hxx + sd/inc/unolayer.hxx: + # base class has to be a complete type + - com/sun/star/drawing/XLayer.hpp + - com/sun/star/drawing/XLayerManager.hpp sd/source/filter/eppt/eppt.hxx: # base class has to be a complete type - escherex.hxx @@ -313,10 +317,6 @@ excludelist: # base class has to be a complete type - com/sun/star/document/XExtendedFilterDetection.hpp - com/sun/star/lang/XServiceInfo.hpp - sd/source/ui/unoidl/unolayer.hxx: - # base class has to be a complete type - - com/sun/star/drawing/XLayer.hpp - - com/sun/star/drawing/XLayerManager.hpp sd/source/ui/unoidl/unocpres.hxx: # base class has to be a complete type - com/sun/star/container/XIndexContainer.hpp diff --git a/sd/source/ui/unoidl/unolayer.hxx b/sd/inc/unolayer.hxx similarity index 100% rename from sd/source/ui/unoidl/unolayer.hxx rename to sd/inc/unolayer.hxx diff --git a/sd/source/console/PresenterViewFactory.cxx b/sd/source/console/PresenterViewFactory.cxx index 9f11a13bdfb9..4b85a1a8eb43 100644 --- a/sd/source/console/PresenterViewFactory.cxx +++ b/sd/source/console/PresenterViewFactory.cxx @@ -336,30 +336,27 @@ Reference<XResource> PresenterViewFactory::CreateView( Reference<XView> PresenterViewFactory::CreateSlideShowView( const Reference<XResourceId>& rxViewId) const { - Reference<XView> xView; - if ( ! mxConfigurationController.is()) - return xView; + return nullptr; if ( ! mxComponentContext.is()) - return xView; + return nullptr; try { - rtl::Reference<PresenterSlideShowView> pShowView ( + rtl::Reference<PresenterSlideShowView> xView; + xView = new PresenterSlideShowView( mxComponentContext, rxViewId, mxControllerWeak.get(), - mpPresenterController)); - pShowView->LateInit(); - xView = pShowView; + mpPresenterController); + xView->LateInit(); + return xView; } catch (RuntimeException&) { - xView = nullptr; + return nullptr; } - - return xView; } Reference<XView> PresenterViewFactory::CreateSlidePreviewView( diff --git a/sd/source/filter/grf/sdgrffilter.cxx b/sd/source/filter/grf/sdgrffilter.cxx index ea437dfb2ee0..ad544150da93 100644 --- a/sd/source/filter/grf/sdgrffilter.cxx +++ b/sd/source/filter/grf/sdgrffilter.cxx @@ -258,7 +258,7 @@ bool SdGRFFilter::Export() const sal_uInt16 nFilter = rGraphicFilter.GetExportFormatNumberForTypeName( aTypeName ); if ( nFilter != GRFILTER_FORMAT_NOTFOUND ) { - uno::Reference< task::XInteractionHandler > xInteractionHandler; + rtl::Reference< SdGRFFilter_ImplInteractionHdl > xInteractionHandler; beans::PropertyValues aArgs; TransformItems( SID_SAVEASDOC, rSet, aArgs ); @@ -281,7 +281,7 @@ bool SdGRFFilter::Export() if ( rArg.Value >>= xHdl ) { xInteractionHandler = new SdGRFFilter_ImplInteractionHdl( xHdl ); - rArg.Value <<= xInteractionHandler; + rArg.Value <<= uno::Reference< task::XInteractionHandler >(xInteractionHandler); } } } @@ -313,8 +313,8 @@ bool SdGRFFilter::Export() bRet = xExporter->filter( aArgs ); if ( !bRet && xInteractionHandler.is() ) SdGRFFilter::HandleGraphicFilterError( - static_cast< SdGRFFilter_ImplInteractionHdl* >( xInteractionHandler.get() )->GetErrorCode(), - rGraphicFilter.GetLastError() ); + xInteractionHandler->GetErrorCode(), + rGraphicFilter.GetLastError() ); } } } diff --git a/sd/source/ui/framework/factories/BasicPaneFactory.cxx b/sd/source/ui/framework/factories/BasicPaneFactory.cxx index 62a42f2ec2b0..3eb22471dbdf 100644 --- a/sd/source/ui/framework/factories/BasicPaneFactory.cxx +++ b/sd/source/ui/framework/factories/BasicPaneFactory.cxx @@ -335,14 +335,10 @@ void SAL_CALL BasicPaneFactory::disposing ( Reference<XResource> BasicPaneFactory::CreateFrameWindowPane ( const Reference<XResourceId>& rxPaneId) { - Reference<XResource> xPane; - - if (mpViewShellBase != nullptr) - { - xPane = new FrameWindowPane(rxPaneId, mpViewShellBase->GetViewWindow()); - } + if (!mpViewShellBase) + return nullptr; - return xPane; + return new FrameWindowPane(rxPaneId, mpViewShellBase->GetViewWindow()); } Reference<XResource> BasicPaneFactory::CreateFullScreenPane ( @@ -363,47 +359,43 @@ Reference<XResource> BasicPaneFactory::CreateChildWindowPane ( const Reference<XResourceId>& rxPaneId, const PaneDescriptor& rDescriptor) { - Reference<XResource> xPane; + if (!mpViewShellBase) + return nullptr; - if (mpViewShellBase != nullptr) + // Create the corresponding shell and determine the id of the child window. + sal_uInt16 nChildWindowId = 0; + ::std::unique_ptr<SfxShell> pShell; + switch (rDescriptor.mePaneId) { - // Create the corresponding shell and determine the id of the child window. - sal_uInt16 nChildWindowId = 0; - ::std::unique_ptr<SfxShell> pShell; - switch (rDescriptor.mePaneId) - { - case LeftImpressPaneId: - pShell.reset(new LeftImpressPaneShell()); - nChildWindowId = ::sd::LeftPaneImpressChildWindow::GetChildWindowId(); - break; - - case BottomImpressPaneId: - pShell.reset(new BottomImpressPaneShell()); - nChildWindowId = ::sd::BottomPaneImpressChildWindow::GetChildWindowId(); - break; - - case LeftDrawPaneId: - pShell.reset(new LeftDrawPaneShell()); - nChildWindowId = ::sd::LeftPaneDrawChildWindow::GetChildWindowId(); - break; - - default: - break; - } - - // With shell and child window id create the ChildWindowPane - // wrapper. - if (pShell != nullptr) - { - xPane = new ChildWindowPane( - rxPaneId, - nChildWindowId, - *mpViewShellBase, - std::move(pShell)); - } + case LeftImpressPaneId: + pShell.reset(new LeftImpressPaneShell()); + nChildWindowId = ::sd::LeftPaneImpressChildWindow::GetChildWindowId(); + break; + + case BottomImpressPaneId: + pShell.reset(new BottomImpressPaneShell()); + nChildWindowId = ::sd::BottomPaneImpressChildWindow::GetChildWindowId(); + break; + + case LeftDrawPaneId: + pShell.reset(new LeftDrawPaneShell()); + nChildWindowId = ::sd::LeftPaneDrawChildWindow::GetChildWindowId(); + break; + + default: + break; } - return xPane; + // With shell and child window id create the ChildWindowPane + // wrapper. + if (!pShell) + return nullptr; + + return new ChildWindowPane( + rxPaneId, + nChildWindowId, + *mpViewShellBase, + std::move(pShell)); } void BasicPaneFactory::ThrowIfDisposed() const diff --git a/sd/source/ui/framework/factories/BasicViewFactory.cxx b/sd/source/ui/framework/factories/BasicViewFactory.cxx index f94cf08a498a..8ad96a655f01 100644 --- a/sd/source/ui/framework/factories/BasicViewFactory.cxx +++ b/sd/source/ui/framework/factories/BasicViewFactory.cxx @@ -152,7 +152,6 @@ void BasicViewFactory::disposing(std::unique_lock<std::mutex>&) Reference<XResource> SAL_CALL BasicViewFactory::createResource ( const Reference<XResourceId>& rxViewId) { - Reference<XResource> xView; const bool bIsCenterPane ( rxViewId->isBoundToURL(FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT)); @@ -178,26 +177,26 @@ Reference<XResource> SAL_CALL BasicViewFactory::createResource ( if (mpBase != nullptr) pFrame = &mpBase->GetViewFrame(); - if (pFrame != nullptr && mpBase!=nullptr && pWindow!=nullptr) - { - // Try to get the view from the cache. - std::shared_ptr<ViewDescriptor> pDescriptor (GetViewFromCache(rxViewId, xPane)); + if (!pFrame || !mpBase || !pWindow) + return nullptr; - // When the requested view is not in the cache then create a new view. - if (pDescriptor == nullptr) - { - pDescriptor = CreateView(rxViewId, *pFrame, *pWindow, xPane, pFrameView, bIsCenterPane); - } + // Try to get the view from the cache. + std::shared_ptr<ViewDescriptor> pDescriptor (GetViewFromCache(rxViewId, xPane)); + + // When the requested view is not in the cache then create a new view. + if (pDescriptor == nullptr) + { + pDescriptor = CreateView(rxViewId, *pFrame, *pWindow, xPane, pFrameView, bIsCenterPane); + } - xView = pDescriptor->mxView; + rtl::Reference<ViewShellWrapper> xView = pDescriptor->mxView; - mpViewShellContainer->push_back(pDescriptor); + mpViewShellContainer->push_back(pDescriptor); - if (bIsCenterPane) - ActivateCenterView(pDescriptor); - else - pWindow->Resize(); - } + if (bIsCenterPane) + ActivateCenterView(pDescriptor); + else + pWindow->Resize(); return xView; } diff --git a/sd/source/ui/inc/SdUnoDrawView.hxx b/sd/source/ui/inc/SdUnoDrawView.hxx index ad14dabe52ab..1af4d8b3c4ce 100644 --- a/sd/source/ui/inc/SdUnoDrawView.hxx +++ b/sd/source/ui/inc/SdUnoDrawView.hxx @@ -20,9 +20,11 @@ #pragma once #include "DrawSubController.hxx" +#include <rtl/ref.hxx> class SdXImpressDocument; namespace com::sun::star::drawing { class XLayer; } +class SdLayer; namespace sd { @@ -78,7 +80,7 @@ public: The returned value may be empty when the internal state of this view is not valid (like during destruction.) */ - css::uno::Reference< css::drawing::XLayer> getActiveLayer() const; + rtl::Reference<SdLayer> getActiveLayer() const; private: bool getMasterPageMode() const noexcept; diff --git a/sd/source/ui/unoidl/SdUnoDrawView.cxx b/sd/source/ui/unoidl/SdUnoDrawView.cxx index edab1fabb0e4..3cb45c7b5202 100644 --- a/sd/source/ui/unoidl/SdUnoDrawView.cxx +++ b/sd/source/ui/unoidl/SdUnoDrawView.cxx @@ -23,7 +23,7 @@ #include <DrawDocShell.hxx> #include <DrawViewShell.hxx> #include <drawdoc.hxx> -#include "unolayer.hxx" +#include <unolayer.hxx> #include <unomodel.hxx> #include <Window.hxx> #include <pres.hxx> @@ -90,37 +90,31 @@ void SdUnoDrawView::setLayerMode (bool bLayerMode) noexcept } } -Reference<drawing::XLayer> SdUnoDrawView::getActiveLayer() const +rtl::Reference<SdLayer> SdUnoDrawView::getActiveLayer() const { - Reference<drawing::XLayer> xCurrentLayer; - - do - { - // Retrieve the layer manager from the model. - SdXImpressDocument* pModel = GetModel(); - if (pModel == nullptr) - break; + // Retrieve the layer manager from the model. + SdXImpressDocument* pModel = GetModel(); + if (pModel == nullptr) + return nullptr; - SdDrawDocument* pSdModel = pModel->GetDoc(); - if (pSdModel == nullptr) - break; + SdDrawDocument* pSdModel = pModel->GetDoc(); + if (pSdModel == nullptr) + return nullptr; - // From the model get the current SdrLayer object via the layer admin. - SdrLayerAdmin& rLayerAdmin = pSdModel->GetLayerAdmin (); - SdrLayer* pLayer = rLayerAdmin.GetLayer (mrView.GetActiveLayer()); - if (pLayer == nullptr) - break; + // From the model get the current SdrLayer object via the layer admin. + SdrLayerAdmin& rLayerAdmin = pSdModel->GetLayerAdmin (); + SdrLayer* pLayer = rLayerAdmin.GetLayer (mrView.GetActiveLayer()); + if (pLayer == nullptr) + return nullptr; - // Get the corresponding XLayer object from the implementation - // object of the layer manager. - Reference<drawing::XLayerManager> xManager (pModel->getLayerManager(), uno::UNO_QUERY); - SdLayerManager* pManager = dynamic_cast<SdLayerManager*> (xManager.get()); - if (pManager != nullptr) - xCurrentLayer = pManager->GetLayer (pLayer); - } - while (false); + // Get the corresponding XLayer object from the implementation + // object of the layer manager. + Reference<drawing::XLayerManager> xManager (pModel->getLayerManager(), uno::UNO_QUERY); + SdLayerManager* pManager = dynamic_cast<SdLayerManager*> (xManager.get()); + if (!pManager) + return nullptr; - return xCurrentLayer; + return pManager->GetLayer (pLayer); } void SdUnoDrawView::setActiveLayer (const Reference<drawing::XLayer>& rxLayer) @@ -369,7 +363,7 @@ Any SAL_CALL SdUnoDrawView::getFastPropertyValue ( break; case DrawController::PROPERTY_ACTIVE_LAYER: - aValue <<= getActiveLayer(); + aValue <<= Reference<XLayer>(getActiveLayer()); break; case DrawController::PROPERTY_ZOOMVALUE: diff --git a/sd/source/ui/unoidl/unolayer.cxx b/sd/source/ui/unoidl/unolayer.cxx index 5638f973b74a..4de31e6ad841 100644 --- a/sd/source/ui/unoidl/unolayer.cxx +++ b/sd/source/ui/unoidl/unolayer.cxx @@ -20,7 +20,7 @@ #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> -#include "unolayer.hxx" +#include <unolayer.hxx> #include <comphelper/extract.hxx> #include <editeng/unoipset.hxx> @@ -421,7 +421,7 @@ uno::Reference< drawing::XLayer > SAL_CALL SdLayerManager::insertNewByIndex( sal if( mpModel == nullptr ) throw lang::DisposedException(); - uno::Reference< drawing::XLayer > xLayer; + rtl::Reference< SdLayer > xLayer; if( mpModel->mpDoc ) { @@ -495,18 +495,17 @@ uno::Reference< drawing::XLayer > SAL_CALL SdLayerManager::getLayerForShape( con if( mpModel == nullptr ) throw lang::DisposedException(); - uno::Reference< drawing::XLayer > xLayer; + if(!mpModel->mpDoc) + return nullptr; - if(mpModel->mpDoc) - { - SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShape ); - if(pObj) - { - SdrLayerID aId = pObj->GetLayer(); - SdrLayerAdmin& rLayerAdmin = mpModel->mpDoc->GetLayerAdmin(); - xLayer = GetLayer (rLayerAdmin.GetLayerPerID(aId)); - } - } + SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShape ); + if(!pObj) + return nullptr; + + SdrLayerID aId = pObj->GetLayer(); + SdrLayerAdmin& rLayerAdmin = mpModel->mpDoc->GetLayerAdmin(); + + rtl::Reference< SdLayer > xLayer = GetLayer (rLayerAdmin.GetLayerPerID(aId)); return xLayer; } diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 4c1eefa3cd23..22f1d7229b4a 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -134,7 +134,7 @@ #include <strings.hrc> #include <strings.hxx> -#include "unolayer.hxx" +#include <unolayer.hxx> #include <unopage.hxx> #include "unocpres.hxx" #include "unoobj.hxx" diff --git a/sd/source/ui/unoidl/unosrch.cxx b/sd/source/ui/unoidl/unosrch.cxx index 8ed2ece29d7c..1cb5019e9098 100644 --- a/sd/source/ui/unoidl/unosrch.cxx +++ b/sd/source/ui/unoidl/unosrch.cxx @@ -519,7 +519,6 @@ uno::Reference< text::XTextRange > SdUnoSearchReplaceShape::Search( const uno:: } } - uno::Reference< text::XTextRange > xFound; ESelection aSel; if( xText.is() ) @@ -533,29 +532,26 @@ uno::Reference< text::XTextRange > SdUnoSearchReplaceShape::Search( const uno:: break; } - if( Search( aText, nStartPos, nEndPos, pDescr ) ) + if( !Search( aText, nStartPos, nEndPos, pDescr ) ) + return nullptr; + + if( nStartPos > nTextLen || nEndPos > nTextLen ) { - if( nStartPos <= nTextLen && nEndPos <= nTextLen ) - { - ESelection aSelection( pConvertPara[nStartPos], pConvertPos[nStartPos], - pConvertPara[nEndPos], pConvertPos[nEndPos] ); + OSL_FAIL("Array overflow while searching!"); + return nullptr; + } - SvxUnoTextBase* pParent = comphelper::getFromUnoTunnel<SvxUnoTextBase>( xParent ); + ESelection aSelection( pConvertPara[nStartPos], pConvertPos[nStartPos], + pConvertPara[nEndPos], pConvertPos[nEndPos] ); - if(pParent) - { - rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *pParent ); - xFound = pRange; - pRange->SetSelection(aSelection); - } - } - else - { - OSL_FAIL("Array overflow while searching!"); - } - } + SvxUnoTextBase* pParent = comphelper::getFromUnoTunnel<SvxUnoTextBase>( xParent ); + if(!pParent) + return nullptr; - return xFound; + rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *pParent ); + pRange->SetSelection(aSelection); + + return pRange; } bool SdUnoSearchReplaceShape::Search( const OUString& rText, sal_Int32& nStartPos, sal_Int32& nEndPos, SdUnoSearchReplaceDescriptor* pDescr ) noexcept diff --git a/sd/source/ui/unoidl/unowcntr.cxx b/sd/source/ui/unoidl/unowcntr.cxx index 7cc43c906c9d..e7886acb27ae 100644 --- a/sd/source/ui/unoidl/unowcntr.cxx +++ b/sd/source/ui/unoidl/unowcntr.cxx @@ -20,7 +20,7 @@ #include <com/sun/star/lang/XComponent.hpp> #include "unowcntr.hxx" -#include "unolayer.hxx" +#include <unolayer.hxx> using namespace ::com::sun::star; diff --git a/sd/source/ui/view/drviews5.cxx b/sd/source/ui/view/drviews5.cxx index e8e38674eebd..ad4fb46a08bb 100644 --- a/sd/source/ui/view/drviews5.cxx +++ b/sd/source/ui/view/drviews5.cxx @@ -54,6 +54,7 @@ #include <ViewShellBase.hxx> #include <FormShellManager.hxx> #include <DrawController.hxx> +#include <unolayer.hxx> #include <memory> #include <comphelper/lok.hxx> @@ -630,8 +631,8 @@ void DrawViewShell::SetActiveTabLayerIndex (int nIndex) rtl::Reference<SdUnoDrawView> pUnoDrawView(new SdUnoDrawView ( *this, *GetView())); - css::uno::Reference< css::drawing::XLayer> rLayer = pUnoDrawView->getActiveLayer(); - GetViewShellBase().GetDrawController()->fireChangeLayer( rLayer ); + rtl::Reference<SdLayer> xLayer = pUnoDrawView->getActiveLayer(); + GetViewShellBase().GetDrawController()->fireChangeLayer( xLayer ); } } diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index fe2cf0f085d7..cf89c561d6ca 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -9247,6 +9247,7 @@ sd/inc/stlsheet.hxx sd/inc/strings.hxx sd/inc/undo/undofactory.hxx sd/inc/undo/undomanager.hxx +sd/inc/unolayer.hxx sd/qa/unit/SVGExportTests.cxx sd/qa/unit/activex-controls-tests.cxx sd/qa/unit/dialogs-test.cxx @@ -9874,7 +9875,6 @@ sd/source/ui/unoidl/unocpres.cxx sd/source/ui/unoidl/unocpres.hxx sd/source/ui/unoidl/unodoc.cxx sd/source/ui/unoidl/unolayer.cxx -sd/source/ui/unoidl/unolayer.hxx sd/source/ui/unoidl/unomodel.cxx sd/source/ui/unoidl/unomodule.cxx sd/source/ui/unoidl/unomodule.hxx