summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2024-06-24 15:26:18 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-06-25 17:11:23 +0200
commit0d959d483555307c363f5bfa5b83eaf5bd98d357 (patch)
tree1d297d142efeaebb94a297f0f2d2873ac08a7ae7 /sd
parent649ecf83b7e2b9891b4545a58e7091db854d7870 (diff)
sd: slideshow render interface and implementation
Interface and implementation to expose the ability to render the slide's layers to a bitmap. Change-Id: I3da48585e498354592e163d84bd29659b233c255 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169450 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/inc/DrawViewShell.hxx7
-rw-r--r--sd/source/ui/inc/unomodel.hxx9
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx60
-rw-r--r--sd/source/ui/view/drviewsa.cxx2
-rw-r--r--sd/source/ui/view/drviewsk.cxx42
5 files changed, 119 insertions, 1 deletions
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index 3043ba007bf2..cdd2cc3a44fd 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -33,6 +33,7 @@
namespace svx::sidebar { class SelectionChangeHandler; }
namespace com::sun::star::lang { class XEventListener; }
namespace com::sun::star::scanner { class XScannerManager2; }
+namespace com::sun::star::presentation { class XSlideShow; }
class Outliner;
class SdPage;
@@ -376,6 +377,10 @@ public:
const SdViewOptions& GetViewOptions() const { return maViewOptions; }
//move this method to ViewShell.
//void NotifyAccUpdate();
+
+ css::uno::Reference<css::presentation::XSlideShow> getXSlideShowInstance();
+ void destroyXSlideShowInstance();
+
protected:
DECL_DLLPRIVATE_LINK( ClipboardChanged, TransferableDataHelper*, void );
DECL_DLLPRIVATE_LINK( TabSplitHdl, TabBar *, void );
@@ -495,6 +500,8 @@ private:
::std::unique_ptr< ViewOverlayManager > mpViewOverlayManager;
std::vector<std::unique_ptr<SdrExternalToolEdit>> m_ExternalEdits;
SdViewOptions maViewOptions;
+
+ css::uno::Reference<com::sun::star::presentation::XSlideShow> mxSlideShow;
};
/// Merge the background properties together and deposit the result in rMergeAttr
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 0cf13555ddfa..155d50e9ecce 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -283,12 +283,19 @@ public:
}
/// @see vcl::ITiledRenderable::setPaintTextEdit().
virtual void setPaintTextEdit(bool bPaint) override { mbPaintTextEdit = bPaint; }
-
/// @see vcl::ITiledRenderable::getViewRenderState().
OString getViewRenderState(SfxViewShell* pViewShell = nullptr) override;
/// @see vcl::ITiledRenderable::getPresentationInfo().
OString getPresentationInfo() const override;
+ /// @see vcl::ITiledRenderable::createSlideRenderer().
+ bool createSlideRenderer(
+ sal_Int32 nSlideNumber, sal_Int32& nViewWidth, sal_Int32& nViewHeight,
+ bool bRenderBackground, bool bRenderMasterPage) override;
+ /// @see vcl::ITiledRenderable::postSlideshowCleanup().
+ void postSlideshowCleanup() override;
+ /// @see vcl::ITiledRenderable::renderNextSlideLayer().
+ bool renderNextSlideLayer(unsigned char* pBuffer, bool& bIsBitmapLayer, OUString& rJsonMsg) override;
// XComponent
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index efda0612a3cc..1bb62e02c832 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -80,6 +80,7 @@
#include <editeng/eeitem.hxx>
#include <unotools/datetime.hxx>
#include <xmloff/autolayout.hxx>
+#include <tools/helpers.hxx>
#include <tools/json_writer.hxx>
#include <tools/helpers.hxx>
@@ -3081,6 +3082,65 @@ OString SdXImpressDocument::getPresentationInfo() const
return aJsonWriter.finishAndGetAsOString();
}
+bool SdXImpressDocument::createSlideRenderer(
+ sal_Int32 nSlideNumber, sal_Int32& nViewWidth, sal_Int32& nViewHeight,
+ bool bRenderBackground, bool bRenderMasterPage)
+{
+ DrawViewShell* pViewSh = GetViewShell();
+ if (!pViewSh)
+ return false;
+
+ uno::Reference<presentation::XSlideShow> xSlideShow = pViewSh->getXSlideShowInstance();
+ if (!xSlideShow.is())
+ return false;
+
+ bool bSuccess = false;
+ try
+ {
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPages(mpDoc->getUnoModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<container::XIndexAccess> xSlides(xDrawPages->getDrawPages(), uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xSlide(xSlides->getByIndex(nSlideNumber), uno::UNO_QUERY_THROW);
+ uno::Reference<animations::XAnimationNodeSupplier> xAnimNodeSupplier(xSlide, uno::UNO_QUERY_THROW);
+ uno::Reference<animations::XAnimationNode> xAnimNode = xAnimNodeSupplier->getAnimationNode();
+
+ bSuccess = xSlideShow->createLOKSlideRenderer(nViewWidth, nViewHeight,
+ bRenderMasterPage, bRenderBackground,
+ xSlide, xDrawPages, xAnimNode);
+ }
+ catch (uno::Exception&)
+ {
+ TOOLS_WARN_EXCEPTION( "sd", "SdXImpressDocument::createLOKSlideRenderer: failed" );
+ }
+ return bSuccess;
+}
+
+void SdXImpressDocument::postSlideshowCleanup()
+{
+ DrawViewShell* pViewSh = GetViewShell();
+ if (!pViewSh)
+ return;
+
+ pViewSh->destroyXSlideShowInstance();
+}
+
+bool SdXImpressDocument::renderNextSlideLayer(unsigned char* pBuffer, bool& bIsBitmapLayer, OUString& rJsonMsg)
+{
+ DrawViewShell* pViewSh = GetViewShell();
+ if (!pViewSh)
+ return true;
+
+ uno::Reference<presentation::XSlideShow> xSlideShow = pViewSh->getXSlideShowInstance();
+ if (!xSlideShow.is())
+ return true;
+
+ auto nBufferPointer = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(pBuffer));
+ sal_Bool bBitmapLayer = false;
+ bool bDone = xSlideShow->renderNextLOKSlideLayer(nBufferPointer, bBitmapLayer, rJsonMsg);
+ bIsBitmapLayer = bBitmapLayer;
+
+ return bDone;
+}
+
SdrModel& SdXImpressDocument::getSdrModelFromUnoModel() const
{
OSL_ENSURE(GetDoc(), "No SdrModel in draw/Impress, should not happen");
diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx
index 5d5cfe613245..9572561482f1 100644
--- a/sd/source/ui/view/drviewsa.cxx
+++ b/sd/source/ui/view/drviewsa.cxx
@@ -149,6 +149,8 @@ DrawViewShell::~DrawViewShell()
void DrawViewShell::ImplDestroy()
{
+ destroyXSlideShowInstance();
+
SD_MOD()->GetColorConfig().RemoveListener(this);
mpSelectionChangeHandler->Disconnect();
diff --git a/sd/source/ui/view/drviewsk.cxx b/sd/source/ui/view/drviewsk.cxx
index bdbb821e96b3..cb40d8398f04 100644
--- a/sd/source/ui/view/drviewsk.cxx
+++ b/sd/source/ui/view/drviewsk.cxx
@@ -11,12 +11,18 @@
#include <ViewShellBase.hxx>
#include <sdmod.hxx>
+#include <com/sun/star/presentation/SlideShow.hpp>
+
#include <comphelper/lok.hxx>
+#include <comphelper/diagnose_ex.hxx>
+#include <comphelper/processfactory.hxx>
#include <comphelper/servicehelper.hxx>
#include <sfx2/lokhelper.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <unomodel.hxx>
+using namespace css;
+
namespace sd {
void DrawViewShell::ConfigurationChanged( utl::ConfigurationBroadcaster* pCb, ConfigurationHints )
@@ -57,6 +63,42 @@ void DrawViewShell::ConfigureAppBackgroundColor( svtools::ColorConfig *pColorCon
maViewOptions.mnAppBackgroundColor = aFillColor;
}
+void DrawViewShell::destroyXSlideShowInstance()
+{
+ if (!mxSlideShow.is())
+ return;
+
+ try
+ {
+ uno::Reference<lang::XComponent> xComponent(mxSlideShow, uno::UNO_QUERY);
+ if (xComponent.is())
+ xComponent->dispose();
+ }
+ catch (uno::Exception&)
+ {
+ TOOLS_WARN_EXCEPTION( "sd", "DrawViewShell::destroyXSlideShowInstance dispose");
+ }
+
+ mxSlideShow.clear();
+}
+
+uno::Reference<presentation::XSlideShow> DrawViewShell::getXSlideShowInstance()
+{
+ if (!mxSlideShow.is())
+ {
+ try
+ {
+ auto xContext = ::comphelper::getProcessComponentContext();
+ mxSlideShow.set(presentation::SlideShow::create(xContext), uno::UNO_SET_THROW);
+ }
+ catch (uno::Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("sd", "DrawViewShell::createXSlideShowInstance()");
+ }
+ }
+ return mxSlideShow;
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */