Repository.mk | 1 sd/CppunitTest_sd_lokit_search.mk | 2 sd/CppunitTest_sd_tiledrendering.mk | 2 sd/CppunitTest_sd_tiledrendering2.mk | 2 sd/Library_sdqahelper.mk | 59 ++++ sd/Module_sd.mk | 1 sd/qa/inc/sdqahelperdllapi.h | 20 + sd/qa/inc/sdtiledrenderingtest.hxx | 56 +++ sd/qa/unit/sdtiledrenderingtest.cxx | 202 +++++++++++++ sd/qa/unit/tiledrendering/LOKitSearchTest.cxx | 1 sd/qa/unit/tiledrendering/tiledrendering.cxx | 1 sd/qa/unit/tiledrendering/tiledrendering2.cxx | 1 sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx | 205 -------------- 13 files changed, 348 insertions(+), 205 deletions(-)
New commits: commit b320ade8f9d5205d552fb6fa7de9072eccb867d8 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Mar 12 14:37:02 2025 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Mar 12 15:44:32 2025 +0100 sd: move SdTiledRenderingTest to a new Library_sdqahelper Towards not including .cxx files in Impress tests. Change-Id: I8b50bd79ff36856f878529205d98d4b3299855de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182805 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/Repository.mk b/Repository.mk index 277a1fb99b8b..9240fda70a99 100644 --- a/Repository.mk +++ b/Repository.mk @@ -593,6 +593,7 @@ $(eval $(call gb_Helper_register_libraries,PLAINLIBS_NONE, \ vclbootstrapprotector \ scqahelper \ swqahelper \ + sdqahelper \ wpftqahelper \ precompiled_system \ $(if $(ENABLE_CLI),$(if $(filter MSC,$(COM)),cli_cppuhelper)) \ diff --git a/sd/CppunitTest_sd_lokit_search.mk b/sd/CppunitTest_sd_lokit_search.mk index 9e1652705628..05a94f8a70d0 100644 --- a/sd/CppunitTest_sd_lokit_search.mk +++ b/sd/CppunitTest_sd_lokit_search.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_lokit_search, \ svt \ svxcore \ sd \ + sdqahelper \ test \ unotest \ vcl \ @@ -46,6 +47,7 @@ $(eval $(call gb_CppunitTest_set_include,sd_lokit_search,\ -I$(SRCDIR)/sd/inc \ -I$(SRCDIR)/sd/source/ui/inc \ -I$(SRCDIR)/sd/qa/unit \ + -I$(SRCDIR)/sd/qa/inc \ $$(INCLUDE) \ )) diff --git a/sd/CppunitTest_sd_tiledrendering.mk b/sd/CppunitTest_sd_tiledrendering.mk index d5b44028ff05..f1a0ad96f146 100644 --- a/sd/CppunitTest_sd_tiledrendering.mk +++ b/sd/CppunitTest_sd_tiledrendering.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_tiledrendering, \ svt \ svxcore \ sd \ + sdqahelper \ test \ unotest \ vcl \ @@ -46,6 +47,7 @@ $(eval $(call gb_CppunitTest_set_include,sd_tiledrendering,\ -I$(SRCDIR)/sd/inc \ -I$(SRCDIR)/sd/source/ui/inc \ -I$(SRCDIR)/sd/qa/unit \ + -I$(SRCDIR)/sd/qa/inc \ $$(INCLUDE) \ )) diff --git a/sd/CppunitTest_sd_tiledrendering2.mk b/sd/CppunitTest_sd_tiledrendering2.mk index 07b867cc1309..ca4690e67823 100644 --- a/sd/CppunitTest_sd_tiledrendering2.mk +++ b/sd/CppunitTest_sd_tiledrendering2.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_tiledrendering2, \ svt \ svxcore \ sd \ + sdqahelper \ test \ unotest \ vcl \ @@ -46,6 +47,7 @@ $(eval $(call gb_CppunitTest_set_include,sd_tiledrendering2,\ -I$(SRCDIR)/sd/inc \ -I$(SRCDIR)/sd/source/ui/inc \ -I$(SRCDIR)/sd/qa/unit \ + -I$(SRCDIR)/sd/qa/inc \ $$(INCLUDE) \ )) diff --git a/sd/Library_sdqahelper.mk b/sd/Library_sdqahelper.mk new file mode 100644 index 000000000000..df072e6890ae --- /dev/null +++ b/sd/Library_sdqahelper.mk @@ -0,0 +1,59 @@ +# -*- 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_Library_Library,sdqahelper)) + +$(eval $(call gb_Library_set_include,sdqahelper,\ + -I$(SRCDIR)/sd/inc \ + -I$(SRCDIR)/sd/source/ui/inc \ + -I$(SRCDIR)/sd/qa/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_Library_use_custom_headers,sdqahelper,\ + officecfg/registry \ +)) + +$(eval $(call gb_Library_use_externals,sdqahelper, \ + boost_headers \ + cppunit \ + libxml2 \ +)) + +$(eval $(call gb_Library_add_defs,sdqahelper,\ + -DSDQAHELPER_DLLIMPLEMENTATION \ +)) + +$(eval $(call gb_Library_use_api,sdqahelper,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_Library_use_libraries,sdqahelper,\ + comphelper \ + cppu \ + cppuhelper \ + sal \ + subsequenttest \ + svxcore \ + sd \ + sfx \ + tl \ + utl \ + vcl \ + test \ + unotest \ +)) + +$(eval $(call gb_Library_add_exception_objects,sdqahelper,\ + sd/qa/unit/sdtiledrenderingtest \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk index 1e442265c4cc..827e5f51ea92 100644 --- a/sd/Module_sd.mk +++ b/sd/Module_sd.mk @@ -28,6 +28,7 @@ $(eval $(call gb_Module_add_l10n_targets,sd,\ ifeq ($(filter DRAGONFLY FREEBSD,$(OS)),) $(eval $(call gb_Module_add_slowcheck_targets,sd,\ + Library_sdqahelper \ $(if $(and $(filter $(COM),MSC),$(MERGELIBS)),, \ CppunitTest_sd_uimpress) \ CppunitTest_sd_import_tests \ diff --git a/sd/qa/inc/sdqahelperdllapi.h b/sd/qa/inc/sdqahelperdllapi.h new file mode 100644 index 000000000000..0eb8981a9202 --- /dev/null +++ b/sd/qa/inc/sdqahelperdllapi.h @@ -0,0 +1,20 @@ +/* -*- 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/. + */ + +#pragma once + +#include <sal/types.h> + +#if defined(SDQAHELPER_DLLIMPLEMENTATION) +#define SDQAHELPER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define SDQAHELPER_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/inc/sdtiledrenderingtest.hxx b/sd/qa/inc/sdtiledrenderingtest.hxx new file mode 100644 index 000000000000..e4504a3a657d --- /dev/null +++ b/sd/qa/inc/sdtiledrenderingtest.hxx @@ -0,0 +1,56 @@ +/* + * 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/. + */ + +#ifndef INCLUDED_SD_QA_INC_SDTILEDRENDERINGTEST_HXX +#define INCLUDED_SD_QA_INC_SDTILEDRENDERINGTEST_HXX + +#include <test/unoapixml_test.hxx> + +#include <osl/conditn.hxx> +#include <test/lokcallback.hxx> + +#include "sdqahelperdllapi.h" + +class SdXImpressDocument; +class SfxViewShell; + +class SDQAHELPER_DLLPUBLIC SdTiledRenderingTest : public UnoApiXmlTest +{ +public: + SdTiledRenderingTest(); + virtual void setUp() override; + virtual void tearDown() override; + +protected: + SdXImpressDocument* createDoc(const char* pName, + const css::uno::Sequence<css::beans::PropertyValue>& rArguments + = css::uno::Sequence<css::beans::PropertyValue>()); + void setupLibreOfficeKitViewCallback(SfxViewShell& pViewShell); + static void callback(int nType, const char* pPayload, void* pData); + void callbackImpl(int nType, const char* pPayload); + xmlDocUniquePtr parseXmlDump(); + + ::tools::Rectangle m_aInvalidation; + std::vector<::tools::Rectangle> m_aSelection; + bool m_bFound; + sal_Int32 m_nPart; + std::vector<OString> m_aSearchResultSelection; + std::vector<int> m_aSearchResultPart; + int m_nSelectionBeforeSearchResult; + int m_nSelectionAfterSearchResult; + int m_nSearchResultCount; + + /// For document size changed callback. + osl::Condition m_aDocumentSizeCondition; + xmlBufferPtr m_pXmlBuffer; + TestLokCallbackWrapper m_callbackWrapper; +}; + +#endif // INCLUDED_SD_QA_INC_SDTILEDRENDERINGTEST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/sdtiledrenderingtest.cxx b/sd/qa/unit/sdtiledrenderingtest.cxx new file mode 100644 index 000000000000..cf8eba78bf65 --- /dev/null +++ b/sd/qa/unit/sdtiledrenderingtest.cxx @@ -0,0 +1,202 @@ +/* -*- 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/. + */ + +#include <sdtiledrenderingtest.hxx> + +#include <boost/property_tree/json_parser.hpp> + +#include <comphelper/lok.hxx> +#include <comphelper/string.hxx> +#include <sfx2/lokhelper.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <o3tl/string_view.hxx> +#include <osl/process.h> + +#include <drawdoc.hxx> +#include <unomodel.hxx> + +using namespace css; + +SdTiledRenderingTest::SdTiledRenderingTest() + : UnoApiXmlTest(u"/sd/qa/unit/tiledrendering/data/"_ustr) + , m_bFound(true) + , m_nPart(0) + , m_nSelectionBeforeSearchResult(0) + , m_nSelectionAfterSearchResult(0) + , m_nSearchResultCount(0) + , m_pXmlBuffer(nullptr) + , m_callbackWrapper(&callback, this) +{ +} + +void SdTiledRenderingTest::setUp() +{ + UnoApiXmlTest::setUp(); + + // prevent showing warning message box + osl_setEnvironment(u"OOX_NO_SMARTART_WARNING"_ustr.pData, u"1"_ustr.pData); + comphelper::LibreOfficeKit::setActive(true); +} + +void SdTiledRenderingTest::tearDown() +{ + if (mxComponent.is()) + { + mxComponent->dispose(); + mxComponent.clear(); + } + + if (m_pXmlBuffer) + xmlBufferFree(m_pXmlBuffer); + + m_callbackWrapper.clear(); + comphelper::LibreOfficeKit::setActive(false); + + UnoApiXmlTest::tearDown(); +} + +SdXImpressDocument* +SdTiledRenderingTest::createDoc(const char* pName, + const uno::Sequence<beans::PropertyValue>& rArguments) +{ + loadFromFile(OUString::createFromAscii(pName)); + SdXImpressDocument* pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pImpressDocument); + pImpressDocument->initializeForTiledRendering(rArguments); + return pImpressDocument; +} + +void SdTiledRenderingTest::setupLibreOfficeKitViewCallback(SfxViewShell& pViewShell) +{ + pViewShell.setLibreOfficeKitViewCallback(&m_callbackWrapper); + m_callbackWrapper.setLOKViewId(SfxLokHelper::getView(&pViewShell)); +} + +void SdTiledRenderingTest::callback(int nType, const char* pPayload, void* pData) +{ + static_cast<SdTiledRenderingTest*>(pData)->callbackImpl(nType, pPayload); +} + +namespace +{ +std::vector<OUString> lcl_convertSeparated(std::u16string_view rString, sal_Unicode nSeparator) +{ + std::vector<OUString> aRet; + + sal_Int32 nIndex = 0; + do + { + OUString aToken(o3tl::trim(o3tl::getToken(rString, 0, nSeparator, nIndex))); + if (!aToken.isEmpty()) + aRet.push_back(aToken); + } while (nIndex >= 0); + + return aRet; +} + +void lcl_convertRectangle(std::u16string_view rString, ::tools::Rectangle& rRectangle) +{ + uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(rString); + CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5); + rRectangle.SetLeft(aSeq[0].toInt32()); + rRectangle.SetTop(aSeq[1].toInt32()); + rRectangle.setWidth(aSeq[2].toInt32()); + rRectangle.setHeight(aSeq[3].toInt32()); +} +} + +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()) + lcl_convertRectangle(aPayload, m_aInvalidation); + } + break; + case LOK_CALLBACK_TEXT_SELECTION: + { + OUString aPayload = OUString::createFromAscii(pPayload); + m_aSelection.clear(); + for (const OUString& rString : lcl_convertSeparated(aPayload, u';')) + { + ::tools::Rectangle aRectangle; + lcl_convertRectangle(rString, aRectangle); + m_aSelection.push_back(aRectangle); + } + if (m_aSearchResultSelection.empty()) + ++m_nSelectionBeforeSearchResult; + else + ++m_nSelectionAfterSearchResult; + } + break; + case LOK_CALLBACK_SEARCH_NOT_FOUND: + { + m_bFound = false; + } + break; + case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: + { + m_aDocumentSizeCondition.set(); + } + break; + case LOK_CALLBACK_SET_PART: + { + OUString aPayload = OUString::createFromAscii(pPayload); + m_nPart = aPayload.toInt32(); + } + break; + case LOK_CALLBACK_SEARCH_RESULT_SELECTION: + { + m_nSearchResultCount++; + m_aSearchResultSelection.clear(); + m_aSearchResultPart.clear(); + boost::property_tree::ptree aTree; + std::stringstream aStream(pPayload); + boost::property_tree::read_json(aStream, aTree); + for (const boost::property_tree::ptree::value_type& rValue : + aTree.get_child("searchResultSelection")) + { + m_aSearchResultSelection.emplace_back( + rValue.second.get<std::string>("rectangles").c_str()); + m_aSearchResultPart.push_back( + std::atoi(rValue.second.get<std::string>("part").c_str())); + } + } + break; + } +} + +xmlDocUniquePtr SdTiledRenderingTest::parseXmlDump() +{ + if (m_pXmlBuffer) + xmlBufferFree(m_pXmlBuffer); + + // Create the xml writer. + m_pXmlBuffer = xmlBufferCreate(); + xmlTextWriterPtr pXmlWriter = xmlNewTextWriterMemory(m_pXmlBuffer, 0); + (void)xmlTextWriterStartDocument(pXmlWriter, nullptr, nullptr, nullptr); + + // Create the dump. + SdXImpressDocument* pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pImpressDocument); + pImpressDocument->GetDoc()->dumpAsXml(pXmlWriter); + + // Delete the xml writer. + (void)xmlTextWriterEndDocument(pXmlWriter); + xmlFreeTextWriter(pXmlWriter); + + auto pCharBuffer = xmlBufferContent(m_pXmlBuffer); + SAL_INFO("test", "SdTiledRenderingTest::parseXmlDump: pCharBuffer is '" << pCharBuffer << "'"); + return xmlDocUniquePtr(xmlParseDoc(pCharBuffer)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx index aff3deafc5be..f801354221d6 100644 --- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx +++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx @@ -7,6 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <sdtiledrenderingtest.hxx> #include "tiledrenderingmodeltestbase.cxx" #include <test/helper/transferable.hxx> diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 0860126b6367..01d987433404 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -7,6 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <sdtiledrenderingtest.hxx> #include "tiledrenderingmodeltestbase.cxx" #include <app.hrc> diff --git a/sd/qa/unit/tiledrendering/tiledrendering2.cxx b/sd/qa/unit/tiledrendering/tiledrendering2.cxx index 02962989d5a5..935d21f07324 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering2.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering2.cxx @@ -7,6 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <sdtiledrenderingtest.hxx> #include "tiledrenderingmodeltestbase.cxx" #include <sfx2/sidebar/Sidebar.hxx> diff --git a/sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx b/sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx index dec211944cf9..45e4f1bf080e 100644 --- a/sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx +++ b/sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx @@ -22,211 +22,6 @@ using namespace css; -class SdTiledRenderingTest : public UnoApiXmlTest -{ -public: - SdTiledRenderingTest(); - virtual void setUp() override; - virtual void tearDown() override; - -protected: - SdXImpressDocument* createDoc(const char* pName, - const uno::Sequence<beans::PropertyValue>& rArguments - = uno::Sequence<beans::PropertyValue>()); - void setupLibreOfficeKitViewCallback(SfxViewShell& pViewShell); - static void callback(int nType, const char* pPayload, void* pData); - void callbackImpl(int nType, const char* pPayload); - xmlDocUniquePtr parseXmlDump(); - - ::tools::Rectangle m_aInvalidation; - std::vector<::tools::Rectangle> m_aSelection; - bool m_bFound; - sal_Int32 m_nPart; - std::vector<OString> m_aSearchResultSelection; - std::vector<int> m_aSearchResultPart; - int m_nSelectionBeforeSearchResult; - int m_nSelectionAfterSearchResult; - int m_nSearchResultCount; - - /// For document size changed callback. - osl::Condition m_aDocumentSizeCondition; - xmlBufferPtr m_pXmlBuffer; - TestLokCallbackWrapper m_callbackWrapper; -}; - -SdTiledRenderingTest::SdTiledRenderingTest() - : UnoApiXmlTest(u"/sd/qa/unit/tiledrendering/data/"_ustr) - , m_bFound(true) - , m_nPart(0) - , m_nSelectionBeforeSearchResult(0) - , m_nSelectionAfterSearchResult(0) - , m_nSearchResultCount(0) - , m_pXmlBuffer(nullptr) - , m_callbackWrapper(&callback, this) -{ -} - -void SdTiledRenderingTest::setUp() -{ - UnoApiXmlTest::setUp(); - - // prevent showing warning message box - setenv("OOX_NO_SMARTART_WARNING", "1", 1); - comphelper::LibreOfficeKit::setActive(true); -} - -void SdTiledRenderingTest::tearDown() -{ - if (mxComponent.is()) - { - mxComponent->dispose(); - mxComponent.clear(); - } - - if (m_pXmlBuffer) - xmlBufferFree(m_pXmlBuffer); - - m_callbackWrapper.clear(); - comphelper::LibreOfficeKit::setActive(false); - - UnoApiXmlTest::tearDown(); -} - -SdXImpressDocument* -SdTiledRenderingTest::createDoc(const char* pName, - const uno::Sequence<beans::PropertyValue>& rArguments) -{ - loadFromFile(OUString::createFromAscii(pName)); - SdXImpressDocument* pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pImpressDocument); - pImpressDocument->initializeForTiledRendering(rArguments); - return pImpressDocument; -} - -void SdTiledRenderingTest::setupLibreOfficeKitViewCallback(SfxViewShell& pViewShell) -{ - pViewShell.setLibreOfficeKitViewCallback(&m_callbackWrapper); - m_callbackWrapper.setLOKViewId(SfxLokHelper::getView(&pViewShell)); -} - -void SdTiledRenderingTest::callback(int nType, const char* pPayload, void* pData) -{ - static_cast<SdTiledRenderingTest*>(pData)->callbackImpl(nType, pPayload); -} - -std::vector<OUString> lcl_convertSeparated(std::u16string_view rString, sal_Unicode nSeparator) -{ - std::vector<OUString> aRet; - - sal_Int32 nIndex = 0; - do - { - OUString aToken(o3tl::trim(o3tl::getToken(rString, 0, nSeparator, nIndex))); - if (!aToken.isEmpty()) - aRet.push_back(aToken); - } while (nIndex >= 0); - - return aRet; -} - -void lcl_convertRectangle(std::u16string_view rString, ::tools::Rectangle& rRectangle) -{ - uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(rString); - CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5); - rRectangle.SetLeft(aSeq[0].toInt32()); - rRectangle.SetTop(aSeq[1].toInt32()); - rRectangle.setWidth(aSeq[2].toInt32()); - rRectangle.setHeight(aSeq[3].toInt32()); -} - -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()) - lcl_convertRectangle(aPayload, m_aInvalidation); - } - break; - case LOK_CALLBACK_TEXT_SELECTION: - { - OUString aPayload = OUString::createFromAscii(pPayload); - m_aSelection.clear(); - for (const OUString& rString : lcl_convertSeparated(aPayload, u';')) - { - ::tools::Rectangle aRectangle; - lcl_convertRectangle(rString, aRectangle); - m_aSelection.push_back(aRectangle); - } - if (m_aSearchResultSelection.empty()) - ++m_nSelectionBeforeSearchResult; - else - ++m_nSelectionAfterSearchResult; - } - break; - case LOK_CALLBACK_SEARCH_NOT_FOUND: - { - m_bFound = false; - } - break; - case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: - { - m_aDocumentSizeCondition.set(); - } - break; - case LOK_CALLBACK_SET_PART: - { - OUString aPayload = OUString::createFromAscii(pPayload); - m_nPart = aPayload.toInt32(); - } - break; - case LOK_CALLBACK_SEARCH_RESULT_SELECTION: - { - m_nSearchResultCount++; - m_aSearchResultSelection.clear(); - m_aSearchResultPart.clear(); - boost::property_tree::ptree aTree; - std::stringstream aStream(pPayload); - boost::property_tree::read_json(aStream, aTree); - for (const boost::property_tree::ptree::value_type& rValue : - aTree.get_child("searchResultSelection")) - { - m_aSearchResultSelection.emplace_back( - rValue.second.get<std::string>("rectangles").c_str()); - m_aSearchResultPart.push_back( - std::atoi(rValue.second.get<std::string>("part").c_str())); - } - } - break; - } -} - -xmlDocUniquePtr SdTiledRenderingTest::parseXmlDump() -{ - if (m_pXmlBuffer) - xmlBufferFree(m_pXmlBuffer); - - // Create the xml writer. - m_pXmlBuffer = xmlBufferCreate(); - xmlTextWriterPtr pXmlWriter = xmlNewTextWriterMemory(m_pXmlBuffer, 0); - (void)xmlTextWriterStartDocument(pXmlWriter, nullptr, nullptr, nullptr); - - // Create the dump. - SdXImpressDocument* pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pImpressDocument); - pImpressDocument->GetDoc()->dumpAsXml(pXmlWriter); - - // Delete the xml writer. - (void)xmlTextWriterEndDocument(pXmlWriter); - xmlFreeTextWriter(pXmlWriter); - - auto pCharBuffer = xmlBufferContent(m_pXmlBuffer); - SAL_INFO("test", "SdTiledRenderingTest::parseXmlDump: pCharBuffer is '" << pCharBuffer << "'"); - return xmlDocUniquePtr(xmlParseDoc(pCharBuffer)); -} - /// A view callback tracks callbacks invoked on one specific view. class ViewCallback final {