summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
Diffstat (limited to 'sd')
-rw-r--r--sd/CppunitTest_sd_tiledrendering.mk63
-rw-r--r--sd/Module_sd.mk1
-rw-r--r--sd/qa/unit/tiledrendering/data/dummy.odpbin0 -> 10303 bytes
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx125
-rw-r--r--sd/source/ui/inc/unomodel.hxx3
5 files changed, 191 insertions, 1 deletions
diff --git a/sd/CppunitTest_sd_tiledrendering.mk b/sd/CppunitTest_sd_tiledrendering.mk
new file mode 100644
index 000000000000..2a3f29ce5957
--- /dev/null
+++ b/sd/CppunitTest_sd_tiledrendering.mk
@@ -0,0 +1,63 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sd_tiledrendering))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sd_tiledrendering, \
+ sd/qa/unit/tiledrendering/tiledrendering \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sd_tiledrendering, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ editeng \
+ sal \
+ sfx \
+ svl \
+ svt \
+ svxcore \
+ sd \
+ test \
+ unotest \
+ vcl \
+ tl \
+ utl \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sd_tiledrendering,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sd_tiledrendering,\
+ -I$(SRCDIR)/sd/inc \
+ -I$(SRCDIR)/sd/source/ui/inc \
+ -I$(SRCDIR)/sd/qa/unit \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sd_tiledrendering,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sd_tiledrendering))
+$(eval $(call gb_CppunitTest_use_vcl,sd_tiledrendering))
+
+$(eval $(call gb_CppunitTest_use_rdb,sd_tiledrendering,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,sd_tiledrendering))
+
+$(call gb_CppunitTest_get_target,sd_tiledrendering) : $(call gb_AllLangResTarget_get_target,sd)
+
+# vim: set noet sw=4 ts=4:
diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk
index 0c2d57733623..4bd26acb6feb 100644
--- a/sd/Module_sd.mk
+++ b/sd/Module_sd.mk
@@ -33,6 +33,7 @@ $(eval $(call gb_Module_add_check_targets,sd,\
CppunitTest_sd_export_tests \
CppunitTest_sd_filters_test \
CppunitTest_sd_html_export_tests \
+ CppunitTest_sd_tiledrendering \
))
endif
diff --git a/sd/qa/unit/tiledrendering/data/dummy.odp b/sd/qa/unit/tiledrendering/data/dummy.odp
new file mode 100644
index 000000000000..e559de627cec
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/data/dummy.odp
Binary files differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
new file mode 100644
index 000000000000..d1e924db3c39
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
+#include <test/bootstrapfixture.hxx>
+#include <test/xmltesttools.hxx>
+#include <unotest/macros_test.hxx>
+
+#include <DrawDocShell.hxx>
+#include <ViewShell.hxx>
+#include <unomodel.hxx>
+
+using namespace css;
+
+static const char* DATA_DIRECTORY = "/sd/qa/unit/tiledrendering/data/";
+
+class SdTiledRenderingTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
+{
+public:
+ virtual void setUp() SAL_OVERRIDE;
+ virtual void tearDown() SAL_OVERRIDE;
+
+ void testRegisterCallback();
+
+ CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
+#if !defined(WNT) && !defined(MACOSX)
+ CPPUNIT_TEST(testRegisterCallback);
+#endif
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ SdXImpressDocument* createDoc(const char* pName);
+ static void callback(int nType, const char* pPayload, void* pData);
+ void callbackImpl(int nType, const char* pPayload);
+
+ uno::Reference<lang::XComponent> mxComponent;
+ Rectangle m_aInvalidation;
+};
+
+void SdTiledRenderingTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
+}
+
+void SdTiledRenderingTest::tearDown()
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+
+ test::BootstrapFixture::tearDown();
+}
+
+SdXImpressDocument* SdTiledRenderingTest::createDoc(const char* pName)
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+ mxComponent = loadFromDesktop(getURLFromSrc(DATA_DIRECTORY) + OUString::createFromAscii(pName), "com.sun.star.presentation.PresentationDocument");
+ SdXImpressDocument* pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pImpressDocument);
+ pImpressDocument->initializeForTiledRendering();
+ return pImpressDocument;
+}
+
+void SdTiledRenderingTest::callback(int nType, const char* pPayload, void* pData)
+{
+ static_cast<SdTiledRenderingTest*>(pData)->callbackImpl(nType, pPayload);
+}
+
+void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
+{
+ switch (nType)
+ {
+ case LOK_CALLBACK_INVALIDATE_TILES:
+ {
+ OUString aPayload = OUString::createFromAscii(pPayload);
+ if (aPayload != "EMPTY" && m_aInvalidation.IsEmpty())
+ {
+ uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(aPayload);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength());
+ m_aInvalidation.setX(aSeq[0].toInt32());
+ m_aInvalidation.setY(aSeq[1].toInt32());
+ m_aInvalidation.setWidth(aSeq[2].toInt32());
+ m_aInvalidation.setHeight(aSeq[3].toInt32());
+ }
+ }
+ break;
+ }
+}
+
+void SdTiledRenderingTest::testRegisterCallback()
+{
+ // Tests sd::Window::LogicInvalidate().
+ SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+ pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this);
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+
+ // Append a character to the empty title shape.
+ vcl::KeyCode aKeyCode(0, 0);
+ KeyEvent aKeyEvent(static_cast<sal_Unicode>('x'), aKeyCode, 0);
+ pViewShell->KeyInput(aKeyEvent, 0);
+ mxComponent->dispose();
+
+ // Check that the top left 256x256px tile would be invalidated.
+ CPPUNIT_ASSERT(!m_aInvalidation.IsEmpty());
+ Rectangle aTopLeft(0, 0, 256*15, 256*15); // 1 px = 15 twips, assuming 96 DPI.
+ CPPUNIT_ASSERT(m_aInvalidation.IsOver(aTopLeft));
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 409b62021b3d..bb840f2b1983 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -50,6 +50,7 @@
#include <editeng/unoipset.hxx>
#include <comphelper/servicehelper.hxx>
+#include <sddllapi.h>
class SdDrawDocument;
class SdPage;
@@ -65,7 +66,7 @@ extern OUString getPageApiNameFromUiName( const OUString& rUIName );
/***********************************************************************
* *
***********************************************************************/
-class SdXImpressDocument : public SfxBaseModel, // implements SfxListener, OWEAKOBJECT & other
+class SD_DLLPUBLIC SdXImpressDocument : public SfxBaseModel, // implements SfxListener, OWEAKOBJECT & other
public SvxFmMSFactory,
public ::com::sun::star::drawing::XDrawPageDuplicator,
public ::com::sun::star::drawing::XLayerSupplier,