lok: slideshow rework: check that requested slide is the expected one
Change-Id: I225dfea9981d43fb90888f5025792e9d24d9a789 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173061 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178129 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
This commit is contained in:
parent
810b895ec7
commit
7364b3a2d8
7 changed files with 46 additions and 5 deletions
|
@ -1331,6 +1331,7 @@ static char* doc_getPresentationInfo(LibreOfficeKitDocument* pThis);
|
|||
|
||||
static bool doc_createSlideRenderer(
|
||||
LibreOfficeKitDocument* pThis,
|
||||
const char* pSlideHash,
|
||||
int nSlideNumber, unsigned* nViewWidth, unsigned* nViewHeight,
|
||||
bool bRenderBackground, bool bRenderMasterPage);
|
||||
|
||||
|
@ -5724,6 +5725,7 @@ static char* doc_getPresentationInfo(LibreOfficeKitDocument* pThis)
|
|||
|
||||
static bool doc_createSlideRenderer(
|
||||
LibreOfficeKitDocument* pThis,
|
||||
const char* pSlideHash,
|
||||
int nSlideNumber, unsigned* pViewWidth, unsigned* pViewHeight,
|
||||
bool bRenderBackground, bool bRenderMasterPage)
|
||||
{
|
||||
|
@ -5737,9 +5739,11 @@ static bool doc_createSlideRenderer(
|
|||
return false;
|
||||
}
|
||||
|
||||
OString sSlideHash(pSlideHash);
|
||||
sal_Int32 nViewWidth = *pViewWidth;
|
||||
sal_Int32 nViewHeight = *pViewHeight;
|
||||
bool bReturn = pDoc->createSlideRenderer(
|
||||
sSlideHash,
|
||||
nSlideNumber, nViewWidth, nViewHeight,
|
||||
bRenderBackground, bRenderMasterPage);
|
||||
|
||||
|
|
|
@ -541,6 +541,7 @@ struct _LibreOfficeKitDocumentClass
|
|||
/// @see lok::Document::createSlideRenderer
|
||||
bool (*createSlideRenderer) (
|
||||
LibreOfficeKitDocument* pThis,
|
||||
const char* pSlideHash,
|
||||
int nSlideNumber, unsigned* nViewWidth, unsigned* nViewHeight,
|
||||
bool bRenderBackground, bool bRenderMasterPage);
|
||||
|
||||
|
|
|
@ -917,11 +917,12 @@ public:
|
|||
|
||||
/// Create a slide renderer in core for the input slide.
|
||||
bool createSlideRenderer(
|
||||
const char* pSlideHash,
|
||||
int nSlideNumber, unsigned* nViewWidth, unsigned* nViewHeight,
|
||||
bool bRenderBackground, bool bRenderMasterPage)
|
||||
{
|
||||
return mpDoc->pClass->createSlideRenderer(
|
||||
mpDoc, nSlideNumber, nViewWidth, nViewHeight, bRenderBackground, bRenderMasterPage);
|
||||
mpDoc, pSlideHash, nSlideNumber, nViewWidth, nViewHeight, bRenderBackground, bRenderMasterPage);
|
||||
}
|
||||
|
||||
/// Clean-up the slideshow (slide renderer)
|
||||
|
|
|
@ -392,6 +392,7 @@ public:
|
|||
}
|
||||
/** Creates a slide show renderer (Impress only function) */
|
||||
virtual bool createSlideRenderer(
|
||||
const OString& /*rSlideHash*/,
|
||||
sal_Int32 /*nSlideNumber*/, sal_Int32& /*nViewWidth*/, sal_Int32& /*nViewHeight*/,
|
||||
bool /*bRenderBackground*/, bool /*bRenderMasterPage*/)
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <sfx2/viewfrm.hxx>
|
||||
#include <svl/stritem.hxx>
|
||||
#include <svl/intitem.hxx>
|
||||
#include <svx/unoapi.hxx>
|
||||
#include <svx/svdotable.hxx>
|
||||
#include <svx/svdoutl.hxx>
|
||||
#include <unotools/datetime.hxx>
|
||||
|
@ -41,6 +42,7 @@
|
|||
#include <sdpage.hxx>
|
||||
#include <undo/undomanager.hxx>
|
||||
#include <sfx2/request.hxx>
|
||||
|
||||
#include <svx/svxids.hrc>
|
||||
#include <pres.hxx>
|
||||
#include <navigatr.hxx>
|
||||
|
@ -2791,9 +2793,10 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering)
|
|||
CPPUNIT_ASSERT(pViewShell);
|
||||
SdPage* pPage = pViewShell->GetActualPage();
|
||||
CPPUNIT_ASSERT(pPage);
|
||||
std::string sHash = GetInterfaceHash(GetXDrawPageForSdrPage(pPage));
|
||||
sal_Int32 nViewWidth = 2000;
|
||||
sal_Int32 nViewHeight = 2000;
|
||||
CPPUNIT_ASSERT(pXImpressDocument->createSlideRenderer(0, nViewWidth, nViewHeight, true, true));
|
||||
CPPUNIT_ASSERT(pXImpressDocument->createSlideRenderer(sHash.c_str(), 0, nViewWidth, nViewHeight, true, true));
|
||||
CPPUNIT_ASSERT_EQUAL(2000, nViewWidth);
|
||||
CPPUNIT_ASSERT_EQUAL(1125, nViewHeight);
|
||||
|
||||
|
@ -2869,10 +2872,12 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_WithFie
|
|||
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
|
||||
CPPUNIT_ASSERT(pViewShell);
|
||||
SdPage* pPage = pViewShell->GetActualPage();
|
||||
|
||||
CPPUNIT_ASSERT(pPage);
|
||||
std::string sHash = GetInterfaceHash(GetXDrawPageForSdrPage(pPage));
|
||||
sal_Int32 nViewWidth = 2000;
|
||||
sal_Int32 nViewHeight = 2000;
|
||||
CPPUNIT_ASSERT(pXImpressDocument->createSlideRenderer(0, nViewWidth, nViewHeight, true, true));
|
||||
CPPUNIT_ASSERT(pXImpressDocument->createSlideRenderer(sHash.c_str(), 0, nViewWidth, nViewHeight, true, true));
|
||||
CPPUNIT_ASSERT_EQUAL(2000, nViewWidth);
|
||||
CPPUNIT_ASSERT_EQUAL(1125, nViewHeight);
|
||||
|
||||
|
@ -2967,9 +2972,10 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati
|
|||
CPPUNIT_ASSERT(pViewShell);
|
||||
SdPage* pPage = pViewShell->GetActualPage();
|
||||
CPPUNIT_ASSERT(pPage);
|
||||
std::string sHash = GetInterfaceHash(GetXDrawPageForSdrPage(pPage));
|
||||
sal_Int32 nViewWidth = 2000;
|
||||
sal_Int32 nViewHeight = 2000;
|
||||
CPPUNIT_ASSERT(pXImpressDocument->createSlideRenderer(0, nViewWidth, nViewHeight, true, true));
|
||||
CPPUNIT_ASSERT(pXImpressDocument->createSlideRenderer(sHash.c_str(), 0, nViewWidth, nViewHeight, true, true));
|
||||
CPPUNIT_ASSERT_EQUAL(2000, nViewWidth);
|
||||
CPPUNIT_ASSERT_EQUAL(1125, nViewHeight);
|
||||
|
||||
|
@ -3078,7 +3084,8 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati
|
|||
CPPUNIT_ASSERT(pPage);
|
||||
sal_Int32 nViewWidth = 2000;
|
||||
sal_Int32 nViewHeight = 2000;
|
||||
CPPUNIT_ASSERT(pXImpressDocument->createSlideRenderer(0, nViewWidth, nViewHeight, true, true));
|
||||
std::string sHash = GetInterfaceHash(GetXDrawPageForSdrPage(pPage));
|
||||
CPPUNIT_ASSERT(pXImpressDocument->createSlideRenderer(sHash.c_str(), 0, nViewWidth, nViewHeight, true, true));
|
||||
CPPUNIT_ASSERT_EQUAL(2000, nViewWidth);
|
||||
CPPUNIT_ASSERT_EQUAL(1125, nViewHeight);
|
||||
|
||||
|
|
|
@ -302,6 +302,7 @@ public:
|
|||
SD_DLLPUBLIC OString getPresentationInfo() const override;
|
||||
/// @see vcl::ITiledRenderable::createSlideRenderer().
|
||||
SD_DLLPUBLIC bool createSlideRenderer(
|
||||
const OString& rSlideHash,
|
||||
sal_Int32 nSlideNumber, sal_Int32& nViewWidth, sal_Int32& nViewHeight,
|
||||
bool bRenderBackground, bool bRenderMasterPage) override;
|
||||
/// @see vcl::ITiledRenderable::postSlideshowCleanup().
|
||||
|
|
|
@ -4525,12 +4525,38 @@ namespace
|
|||
{
|
||||
// use VCL slideshow renderer or not - leave the old one in for now, so it is possible to compare output
|
||||
constexpr const bool bVCLSlideShowRenderer = true;
|
||||
|
||||
bool isRequestedSlideValid(SdDrawDocument* mpDoc, sal_Int32 nSlideNumber, const std::string& slideHash)
|
||||
{
|
||||
try
|
||||
{
|
||||
uno::Reference<drawing::XDrawPagesSupplier> xDrawPages(getXWeak(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);
|
||||
if (xSlide.is()) {
|
||||
return slideHash == GetInterfaceHash(xSlide);
|
||||
}
|
||||
}
|
||||
catch (uno::Exception&)
|
||||
{
|
||||
TOOLS_WARN_EXCEPTION( "sd", "SdXImpressDocument::createLOKSlideRenderer: failed" );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool SdXImpressDocument::createSlideRenderer(
|
||||
const OString& rSlideHash,
|
||||
sal_Int32 nSlideNumber, sal_Int32& nViewWidth, sal_Int32& nViewHeight,
|
||||
bool bRenderBackground, bool bRenderMasterPage)
|
||||
{
|
||||
std::string sSlideHash(rSlideHash);
|
||||
if (!isRequestedSlideValid(mpDoc, nSlideNumber, sSlideHash))
|
||||
return false;
|
||||
|
||||
if (bVCLSlideShowRenderer)
|
||||
{
|
||||
SdPage* pPage = mpDoc->GetSdPage(sal_uInt16(nSlideNumber), PageKind::Standard);
|
||||
|
|
Loading…
Reference in a new issue