summaryrefslogtreecommitdiff
path: root/sd/source/ui
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2024-06-24 15:26:18 +0900
committerMiklos Vajna <vmiklos@collabora.com>2024-07-10 08:05:56 +0200
commit1f0fd06bc0cfe5036661ce2c23911f34eccf678a (patch)
treee18e8ec47b4b788c9cf3e5eb62021e5df6d6c3ed /sd/source/ui
parent6f96e7720f765d4e5e8fdef6a2a2b8cbb75c81ef (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/+/170214 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sd/source/ui')
-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 f6da30194224..ce1e7c74cea3 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;
@@ -383,6 +384,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 );
@@ -502,6 +507,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 28bd323dd8d4..3b5532759cc4 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().
SD_DLLPUBLIC 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 4241a7537a25..e46884e1c88a 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>
@@ -3090,6 +3091,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 a3587ab7490b..f057488e591d 100644
--- a/sd/source/ui/view/drviewsa.cxx
+++ b/sd/source/ui/view/drviewsa.cxx
@@ -160,6 +160,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: */