diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-10-02 21:37:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-10-03 14:08:07 +0200 |
commit | 36d4938894a0c4ac3fecd2fe00991328560d4b8a (patch) | |
tree | f3292829e34f2115a44d7ee137c18cd53d7e4c6f /sd/source/ui | |
parent | 9b26255f03d6049bb9c7eeed4b63da070849d7be (diff) |
use more concrete UNO class in SdXImpressDocument
Change-Id: I61fb3e0c5f76fd6208255dc1f1bc403c25221ba6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174412
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/source/ui')
-rw-r--r-- | sd/source/ui/inc/unomodel.hxx | 5 | ||||
-rw-r--r-- | sd/source/ui/inc/unopage.hxx | 3 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 269 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.cxx | 11 |
4 files changed, 144 insertions, 144 deletions
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx index 02f1ee19ceb7..3141abd46bc9 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -59,6 +59,7 @@ class SdMasterPagesAccess; class SdLayerManager; class SdXCustomPresentationAccess; class SdDocLinkTargets; +class SdGenericDrawPage; namespace sd { class DrawDocShell; @@ -304,6 +305,8 @@ public: /// @see vcl::ITiledRenderable::renderNextSlideLayer(). bool renderNextSlideLayer(unsigned char* pBuffer, bool& bIsBitmapLayer, OUString& rJsonMsg) override; + rtl::Reference< SdDrawPagesAccess > getSdDrawPages(); + // XComponent /** This dispose implementation releases the resources held by the @@ -355,6 +358,8 @@ public: virtual void SAL_CALL dispose( ) override; virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + SdGenericDrawPage* getDrawPageByIndex( sal_Int32 Index ); }; /*********************************************************************** diff --git a/sd/source/ui/inc/unopage.hxx b/sd/source/ui/inc/unopage.hxx index 534aa8c1c6a4..f27b79ad4ce8 100644 --- a/sd/source/ui/inc/unopage.hxx +++ b/sd/source/ui/inc/unopage.hxx @@ -38,6 +38,7 @@ class SdrObject; class SdXImpressDocument; +class SdMasterPage; class SdGenericDrawPage : public SvxDrawPage, public SdUnoSearchReplaceShape, @@ -211,6 +212,8 @@ public: // XShapes virtual void SAL_CALL add( const css::uno::Reference< css::drawing::XShape >& xShape ) override; virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XShape >& xShape ) override; + + SdMasterPage* getSdMasterPage(); }; /*********************************************************************** diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 9a8b17c65cdb..b5e2bb9dbf0b 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -1561,6 +1561,11 @@ uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getDrawPages( { ::SolarMutexGuard aGuard; + return getSdDrawPages(); +} + +rtl::Reference< SdDrawPagesAccess > SdXImpressDocument::getSdDrawPages() +{ if( nullptr == mpDoc ) throw lang::DisposedException(); @@ -3759,157 +3764,142 @@ OString SdXImpressDocument::getPresentationInfo() const try { - uno::Reference<drawing::XDrawPages> xDrawPages = const_cast<SdXImpressDocument*>(this)->getDrawPages(); - uno::Reference<container::XIndexAccess> xSlides(xDrawPages, uno::UNO_QUERY_THROW); - if (xSlides.is()) + rtl::Reference<SdDrawPagesAccess> xDrawPages = const_cast<SdXImpressDocument*>(this)->getSdDrawPages(); + // size in twips + Size aDocSize = const_cast<SdXImpressDocument*>(this)->getDocumentSize(); + aJsonWriter.put("docWidth", aDocSize.getWidth()); + aJsonWriter.put("docHeight", aDocSize.getHeight()); + + auto aSlideList = aJsonWriter.startArray("slides"); + sal_Int32 nSlideCount = xDrawPages->getCount(); + for (sal_Int32 i = 0; i < nSlideCount; ++i) { - // size in twips - Size aDocSize = const_cast<SdXImpressDocument*>(this)->getDocumentSize(); - aJsonWriter.put("docWidth", aDocSize.getWidth()); - aJsonWriter.put("docHeight", aDocSize.getHeight()); - - auto aSlideList = aJsonWriter.startArray("slides"); - sal_Int32 nSlideCount = xSlides->getCount(); - for (sal_Int32 i = 0; i < nSlideCount; ++i) + SdGenericDrawPage* pSlide(xDrawPages->getDrawPageByIndex(i)); + bool bIsVisible = true; // default visible + pSlide->getPropertyValue("Visible") >>= bIsVisible; + if (bIsVisible) { - uno::Reference<drawing::XDrawPage> xSlide(xSlides->getByIndex(i), uno::UNO_QUERY_THROW); - if (xSlide.is()) - { - uno::Reference<XPropertySet> xPropSet(xSlide, uno::UNO_QUERY); - if (xPropSet.is()) - { - bool bIsVisible = true; // default visible - xPropSet->getPropertyValue("Visible") >>= bIsVisible; - if (bIsVisible) - { - SdrPage* pPage = SdPage::getImplementation(xSlide); - - auto aSlideNode = aJsonWriter.startStruct(); - std::string sSlideHash = GetInterfaceHash(xSlide); - aJsonWriter.put("hash", sSlideHash); - aJsonWriter.put("index", i); + SdrPage* pPage = pSlide->GetSdrPage(); - uno::Reference<drawing::XShapes> xSlideShapes(xSlide, uno::UNO_QUERY_THROW); - bool bIsDrawPageEmpty = true; - if (xSlideShapes.is()) { - bIsDrawPageEmpty = xSlideShapes->getCount() == 0; - } - aJsonWriter.put("empty", bIsDrawPageEmpty); + auto aSlideNode = aJsonWriter.startStruct(); + std::string sSlideHash = GetInterfaceHash(cppu::getXWeak(pSlide)); + aJsonWriter.put("hash", sSlideHash); + aJsonWriter.put("index", i); - uno::Reference<drawing::XDrawPage> xMasterPage; - uno::Reference<drawing::XMasterPageTarget> xMasterPageTarget(xSlide, uno::UNO_QUERY); - if (xMasterPageTarget.is()) - { - xMasterPage = xMasterPageTarget->getMasterPage(); - if (xMasterPage.is()) - { - std::string sMPHash = GetInterfaceHash(xMasterPage); - aJsonWriter.put("masterPage", sMPHash); + bool bIsDrawPageEmpty = pSlide->getCount() == 0; + aJsonWriter.put("empty", bIsDrawPageEmpty); - bool bBackgroundObjectsVisibility = true; // default visible - xPropSet->getPropertyValue("IsBackgroundObjectsVisible") >>= bBackgroundObjectsVisibility; - aJsonWriter.put("masterPageObjectsVisibility", bBackgroundObjectsVisibility); - } - } + SdMasterPage* pMasterPage = nullptr; + SdDrawPage* pMasterPageTarget(dynamic_cast<SdDrawPage*>(pSlide)); + if (pMasterPageTarget) + { + pMasterPage = pMasterPageTarget->getSdMasterPage(); + if (pMasterPage) + { + std::string sMPHash = GetInterfaceHash(cppu::getXWeak(pMasterPage)); + aJsonWriter.put("masterPage", sMPHash); - bool bBackgroundVisibility = true; // default visible - xPropSet->getPropertyValue("IsBackgroundVisible") >>= bBackgroundVisibility; - if (bBackgroundVisibility) - { - SlideBackgroundInfo aSlideBackgroundInfo(xSlide, xMasterPage); - if (aSlideBackgroundInfo.hasBackground()) - { - auto aBackgroundNode = aJsonWriter.startNode("background"); - aJsonWriter.put("isCustom", aSlideBackgroundInfo.slideHasOwnBackground()); - if (aSlideBackgroundInfo.isSolidColor()) - { - aJsonWriter.put("fillColor", aSlideBackgroundInfo.getFillColorAsRGBA()); - } - } - } + bool bBackgroundObjectsVisibility = true; // default visible + pSlide->getPropertyValue("IsBackgroundObjectsVisible") >>= bBackgroundObjectsVisibility; + aJsonWriter.put("masterPageObjectsVisibility", bBackgroundObjectsVisibility); + } + } - { - auto aVideoList = aJsonWriter.startArray("videos"); - SdrObjListIter aIterator(pPage, SdrIterMode::DeepWithGroups); - while (aIterator.IsMore()) - { - auto* pObject = aIterator.Next(); - if (pObject->GetObjIdentifier() == SdrObjKind::Media) - { - auto aVideosNode = aJsonWriter.startStruct(); - auto* pMediaObject = static_cast<SdrMediaObj*>(pObject); - auto const& rRectangle = pMediaObject->GetLogicRect(); - auto aRectangle = o3tl::convert(rRectangle, o3tl::Length::mm100, o3tl::Length::twip); - aJsonWriter.put("id", reinterpret_cast<sal_uInt64>(pMediaObject)); - aJsonWriter.put("url", pMediaObject->getTempURL()); - aJsonWriter.put("x", aRectangle.Left()); - aJsonWriter.put("y", aRectangle.Top()); - aJsonWriter.put("width", aRectangle.GetWidth()); - aJsonWriter.put("height", aRectangle.GetHeight()); - } - } - } + bool bBackgroundVisibility = true; // default visible + pSlide->getPropertyValue("IsBackgroundVisible") >>= bBackgroundVisibility; + if (bBackgroundVisibility) + { + SlideBackgroundInfo aSlideBackgroundInfo(pSlide, static_cast<SvxDrawPage*>(pMasterPage)); + if (aSlideBackgroundInfo.hasBackground()) + { + auto aBackgroundNode = aJsonWriter.startNode("background"); + aJsonWriter.put("isCustom", aSlideBackgroundInfo.slideHasOwnBackground()); + if (aSlideBackgroundInfo.isSolidColor()) + { + aJsonWriter.put("fillColor", aSlideBackgroundInfo.getFillColorAsRGBA()); + } + } + } - sal_Int32 nTransitionType = 0; - xPropSet->getPropertyValue("TransitionType") >>= nTransitionType; + { + auto aVideoList = aJsonWriter.startArray("videos"); + SdrObjListIter aIterator(pPage, SdrIterMode::DeepWithGroups); + while (aIterator.IsMore()) + { + auto* pObject = aIterator.Next(); + if (pObject->GetObjIdentifier() == SdrObjKind::Media) + { + auto aVideosNode = aJsonWriter.startStruct(); + auto* pMediaObject = static_cast<SdrMediaObj*>(pObject); + auto const& rRectangle = pMediaObject->GetLogicRect(); + auto aRectangle = o3tl::convert(rRectangle, o3tl::Length::mm100, o3tl::Length::twip); + aJsonWriter.put("id", reinterpret_cast<sal_uInt64>(pMediaObject)); + aJsonWriter.put("url", pMediaObject->getTempURL()); + aJsonWriter.put("x", aRectangle.Left()); + aJsonWriter.put("y", aRectangle.Top()); + aJsonWriter.put("width", aRectangle.GetWidth()); + aJsonWriter.put("height", aRectangle.GetHeight()); + } + } + } - if (nTransitionType != 0) - { - auto iterator = constTransitionTypeToString.find(nTransitionType); + sal_Int32 nTransitionType = 0; + pSlide->getPropertyValue("TransitionType") >>= nTransitionType; - if (iterator != constTransitionTypeToString.end()) - { - aJsonWriter.put("transitionType", iterator->second); + if (nTransitionType != 0) + { + auto iterator = constTransitionTypeToString.find(nTransitionType); - sal_Int32 nTransitionSubtype = 0; - xPropSet->getPropertyValue("TransitionSubtype") >>= nTransitionSubtype; + if (iterator != constTransitionTypeToString.end()) + { + aJsonWriter.put("transitionType", iterator->second); - auto iteratorSubType = constTransitionSubTypeToString.find(nTransitionSubtype); - if (iteratorSubType != constTransitionSubTypeToString.end()) - { - aJsonWriter.put("transitionSubtype", iteratorSubType->second); - } - else - { - SAL_WARN("sd", "Transition sub-type unknown: " << nTransitionSubtype); - } + sal_Int32 nTransitionSubtype = 0; + pSlide->getPropertyValue("TransitionSubtype") >>= nTransitionSubtype; - bool nTransitionDirection = false; - xPropSet->getPropertyValue("TransitionDirection") >>= nTransitionDirection; - aJsonWriter.put("transitionDirection", nTransitionDirection); - } + auto iteratorSubType = constTransitionSubTypeToString.find(nTransitionSubtype); + if (iteratorSubType != constTransitionSubTypeToString.end()) + { + aJsonWriter.put("transitionSubtype", iteratorSubType->second); + } + else + { + SAL_WARN("sd", "Transition sub-type unknown: " << nTransitionSubtype); + } - double nTransitionDuration(0.0); - if( xPropSet->getPropertySetInfo()->hasPropertyByName( "TransitionDuration" ) && - (xPropSet->getPropertyValue( "TransitionDuration" ) >>= nTransitionDuration ) && nTransitionDuration != 0.0 ) - { - // convert transitionDuration time to ms - aJsonWriter.put("transitionDuration", nTransitionDuration * 1000); - } + bool nTransitionDirection = false; + pSlide->getPropertyValue("TransitionDirection") >>= nTransitionDirection; + aJsonWriter.put("transitionDirection", nTransitionDirection); + } - sal_Int32 nChange(0); - if( xPropSet->getPropertySetInfo()->hasPropertyByName( "Change" ) && - (xPropSet->getPropertyValue( "Change" ) >>= nChange ) && nChange == 1 ) - { - double fSlideDuration(0); - if( xPropSet->getPropertySetInfo()->hasPropertyByName( "HighResDuration" ) && - (xPropSet->getPropertyValue( "HighResDuration" ) >>= fSlideDuration) ) - { - // convert slide duration time to ms - aJsonWriter.put("nextSlideDuration", fSlideDuration * 1000); - } - } - } + double nTransitionDuration(0.0); + if( pSlide->getPropertySetInfo()->hasPropertyByName( "TransitionDuration" ) && + (pSlide->getPropertyValue( "TransitionDuration" ) >>= nTransitionDuration ) && nTransitionDuration != 0.0 ) + { + // convert transitionDuration time to ms + aJsonWriter.put("transitionDuration", nTransitionDuration * 1000); + } - AnimationsExporter aAnimationExporter(aJsonWriter, xSlide); - if (aAnimationExporter.hasEffects()) - { - auto aAnimationsNode = aJsonWriter.startNode("animations"); - aAnimationExporter.exportAnimations(); - } + sal_Int32 nChange(0); + if( pSlide->getPropertySetInfo()->hasPropertyByName( "Change" ) && + (pSlide->getPropertyValue( "Change" ) >>= nChange ) && nChange == 1 ) + { + double fSlideDuration(0); + if( pSlide->getPropertySetInfo()->hasPropertyByName( "HighResDuration" ) && + (pSlide->getPropertyValue( "HighResDuration" ) >>= fSlideDuration) ) + { + // convert slide duration time to ms + aJsonWriter.put("nextSlideDuration", fSlideDuration * 1000); } } } + + AnimationsExporter aAnimationExporter(aJsonWriter, pSlide); + if (aAnimationExporter.hasEffects()) + { + auto aAnimationsNode = aJsonWriter.startNode("animations"); + aAnimationExporter.exportAnimations(); + } } } } @@ -4067,24 +4057,25 @@ sal_Int32 SAL_CALL SdDrawPagesAccess::getCount() uno::Any SAL_CALL SdDrawPagesAccess::getByIndex( sal_Int32 Index ) { + uno::Reference< drawing::XDrawPage > xDrawPage( getDrawPageByIndex(Index) ); + return uno::Any(xDrawPage); +} + +SdGenericDrawPage* SdDrawPagesAccess::getDrawPageByIndex( sal_Int32 Index ) +{ ::SolarMutexGuard aGuard; if( nullptr == mpModel ) throw lang::DisposedException(); - uno::Any aAny; - if( (Index < 0) || (Index >= mpModel->mpDoc->GetSdPageCount( PageKind::Standard ) ) ) throw lang::IndexOutOfBoundsException(); SdPage* pPage = mpModel->mpDoc->GetSdPage( static_cast<sal_uInt16>(Index), PageKind::Standard ); if( pPage ) - { - uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY ); - aAny <<= xDrawPage; - } + return dynamic_cast<SdGenericDrawPage*>( pPage->getUnoPage().get() ); - return aAny; + return nullptr; } // XNameAccess diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index d4878a84e4df..c3d60bd59daf 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -2344,21 +2344,22 @@ OUString SAL_CALL SdDrawPage::getName() // XMasterPageTarget Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getMasterPage( ) { + return static_cast<SdGenericDrawPage*>(getSdMasterPage()); +} + +SdMasterPage* SdDrawPage::getSdMasterPage() +{ ::SolarMutexGuard aGuard; throwIfDisposed(); if(GetPage()) { - Reference< drawing::XDrawPage > xPage; - if(SvxDrawPage::mpPage->TRG_HasMasterPage()) { SdrPage& rMasterPage = SvxDrawPage::mpPage->TRG_GetMasterPage(); - xPage.set( rMasterPage.getUnoPage(), uno::UNO_QUERY ); + return dynamic_cast<SdMasterPage*>(rMasterPage.getUnoPage().get()); } - - return xPage; } return nullptr; } |