diff options
author | Henry Castro <hcastro@collabora.com> | 2016-02-20 09:57:52 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2016-02-20 18:53:48 +0000 |
commit | 286adeb032df8ab30930b6f76f75b342a3fa314b (patch) | |
tree | 26e7853a75267bfd571499ca500ed1f04796dd60 /sd | |
parent | 4bb148e74495b02f65483bd460cab762114177ea (diff) |
sd lok: re-work LOK_CALLBACK_PARTS_COUNT_CHANGED callback
In the tiled rendering case, slide sorted view is not created.
This revert some portion commit 80d7c5859b9e7a834a915d7e8bbbe9bc2130108a
Change-Id: Ifc2b7535f36ca69268de3e462bdd50ade9ec3853
Reviewed-on: https://gerrit.libreoffice.org/22542
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 62 | ||||
-rw-r--r-- | sd/source/core/drawdoc2.cxx | 26 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx | 4 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/model/SlideSorterModel.cxx | 36 |
4 files changed, 46 insertions, 82 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 955425101b2e..baeb36bc360d 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -25,9 +25,6 @@ #include <svl/srchitem.hxx> #include <comphelper/lok.hxx> -#include <ImpressViewShellBase.hxx> -#include <SlideSorterViewShell.hxx> -#include <SlideSorter.hxx> #include <DrawDocShell.hxx> #include <ViewShell.hxx> #include <sdpage.hxx> @@ -48,7 +45,7 @@ public: virtual void tearDown() override; #if !defined(_WIN32) && !defined(MACOSX) - void testInsertPage(); + void testInsertDeletePage(); void testRegisterCallback(); void testPostKeyEvent(); void testPostMouseEvent(); @@ -65,7 +62,7 @@ public: CPPUNIT_TEST_SUITE(SdTiledRenderingTest); #if !defined(_WIN32) && !defined(MACOSX) - CPPUNIT_TEST(testInsertPage); + CPPUNIT_TEST(testInsertDeletePage); CPPUNIT_TEST(testRegisterCallback); CPPUNIT_TEST(testPostKeyEvent); CPPUNIT_TEST(testPostMouseEvent); @@ -519,56 +516,22 @@ void SdTiledRenderingTest::testSearchAllFollowedBySearch() CPPUNIT_ASSERT_EQUAL(OString("match"), pXImpressDocument->getTextSelection("text/plain;charset=utf-8", aUsedFormat)); } -void SdTiledRenderingTest::testInsertPage() +void SdTiledRenderingTest::testInsertDeletePage() { - uno::Sequence<beans::PropertyValue> aFilterOptions; - uno::Reference<frame::XDesktop2> xLoader(mxDesktop, uno::UNO_QUERY); - CPPUNIT_ASSERT(xLoader.is()); - - uno::Reference<lang::XComponent> xComponent; - xComponent = xLoader->loadComponentFromURL( - getURLFromSrc(DATA_DIRECTORY) + "insert-delete.odp", - "_blank", - 0, - aFilterOptions); - CPPUNIT_ASSERT(xComponent.is()); - - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent); - CPPUNIT_ASSERT(pFoundShell); - - ::sd::DrawDocShell* xDocSh = dynamic_cast<sd::DrawDocShell*>(pFoundShell); - CPPUNIT_ASSERT(xDocSh); - - sd::ViewShell* pViewShell = xDocSh->GetViewShell(); - CPPUNIT_ASSERT(pViewShell); - - sd::slidesorter::SlideSorterViewShell* pSSVS = nullptr; - for (int i = 0; i < 1000; i++) - { - // Process all Tasks - slide sorter is created here - while (Scheduler::ProcessTaskScheduling(true)); - if ((pSSVS = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase())) != nullptr) - break; - TimeValue aSleep(0, 100 * 1000000); // 100 msec - osl::Thread::wait(aSleep); - } - CPPUNIT_ASSERT(pSSVS); - comphelper::LibreOfficeKit::setActive(); - SdXImpressDocument* pXImpressDocument = SdXImpressDocument::getImplementation(xDocSh->GetModel()); - CPPUNIT_ASSERT(pXImpressDocument); + SdXImpressDocument* pXImpressDocument = createDoc("insert-delete.odp"); + pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this); + SdDrawDocument *pDoc = pXImpressDocument->GetDocShell()->GetDoc(); CPPUNIT_ASSERT(pDoc); // the document has 1 slide CPPUNIT_ASSERT(pDoc->GetSdPageCount(PK_STANDARD) == 1); - pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this); - uno::Sequence<beans::PropertyValue> aArgs; // Insert slides - for(unsigned nIterator=1; nIterator <= 10; nIterator++) + for(unsigned it = 1; it <= 10; it++) comphelper::dispatchCommand(".uno:InsertPage", aArgs); // Verify inserted slides @@ -581,7 +544,7 @@ void SdTiledRenderingTest::testInsertPage() m_aPageList.clear(); // Delete slides - for(unsigned nIterator=1; nIterator <= 10; nIterator++) + for(unsigned it = 1; it <= 10; it++) comphelper::dispatchCommand(".uno:DeletePage", aArgs); // Verify deleted slides @@ -594,7 +557,7 @@ void SdTiledRenderingTest::testInsertPage() m_aPageList.clear(); // Undo deleted slides - for(unsigned nIterator=1; nIterator <= 10; nIterator++) + for(unsigned it = 1; it <= 10; it++) comphelper::dispatchCommand(".uno:Undo", aArgs); // Verify inserted slides @@ -607,7 +570,7 @@ void SdTiledRenderingTest::testInsertPage() m_aPageList.clear(); // Redo deleted slides - for(unsigned nIterator=1; nIterator <= 10; nIterator++) + for(unsigned it = 1; it <= 10; it++) comphelper::dispatchCommand(".uno:Redo", aArgs); // Verify deleted slides @@ -621,12 +584,7 @@ void SdTiledRenderingTest::testInsertPage() CPPUNIT_ASSERT(pDoc->GetSdPageCount(PK_STANDARD) == 1); comphelper::LibreOfficeKit::setActive(false); - - uno::Reference<util::XCloseable> xClose(xComponent, uno::UNO_QUERY); - CPPUNIT_ASSERT(xClose.is()); - xClose->close(false); } - #endif CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx index a5406d2a1a75..f153285946dc 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -46,6 +46,9 @@ #include <editeng/outliner.hxx> #include <svx/svditer.hxx> #include <svtools/imapobj.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <boost/property_tree/json_parser.hpp> +#include <comphelper/lok.hxx> #include "sdresid.hxx" #include "drawdoc.hxx" @@ -374,6 +377,17 @@ void SdDrawDocument::InsertPage(SdrPage* pPage, sal_uInt16 nPos) if (!bLast) UpdatePageRelativeURLs(static_cast<SdPage*>( pPage ), nPos, 1); + if (comphelper::LibreOfficeKit::isActive() && + static_cast<SdPage*>(pPage)->GetPageKind() == PK_STANDARD) + { + boost::property_tree::ptree aTree; + std::stringstream aStream; + aTree.put("action", "PartInserted"); + aTree.put("part", OUString::number(nPos / 2).toUtf8().getStr()); + boost::property_tree::write_json(aStream, aTree); + const OString aPayload = aStream.str().c_str(); + libreOfficeKitCallback(LOK_CALLBACK_PARTS_COUNT_CHANGED, aPayload.getStr()); + } } // Delete page @@ -398,6 +412,18 @@ SdrPage* SdDrawDocument::RemovePage(sal_uInt16 nPgNum) if (!bLast) UpdatePageRelativeURLs(static_cast<SdPage*>(pPage), nPgNum, -1); + if (comphelper::LibreOfficeKit::isActive() && + static_cast<SdPage*>(pPage)->GetPageKind() == PK_STANDARD) + { + boost::property_tree::ptree aTree; + std::stringstream aStream; + aTree.put("action", "PartDeleted"); + aTree.put("part", OUString::number(nPgNum / 2).toUtf8().getStr()); + boost::property_tree::write_json(aStream, aTree); + const OString aPayload = aStream.str().c_str(); + libreOfficeKitCallback(LOK_CALLBACK_PARTS_COUNT_CHANGED, aPayload.getStr()); + } + return pPage; } diff --git a/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx b/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx index 64b2a232d9af..8f22b6ba4d3d 100644 --- a/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx +++ b/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx @@ -219,8 +219,8 @@ private: void AdaptSize(); SdPage* GetPage (const sal_Int32 nCoreIndex) const; - sal_Int32 InsertSlide (SdPage* pPage); - sal_Int32 DeleteSlide (const SdPage* pPage); + void InsertSlide (SdPage* pPage); + void DeleteSlide (const SdPage* pPage); void UpdateIndices (const sal_Int32 nFirstIndex); }; diff --git a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx index 8912d523c1ba..4d9ddfaf5e4c 100644 --- a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx +++ b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx @@ -32,7 +32,6 @@ #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/UnknownPropertyException.hpp> -#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include "ViewShellBase.hxx" #include "DrawViewShell.hxx" @@ -42,8 +41,6 @@ #include "FrameView.hxx" #include <tools/diagnose_ex.h> -#include <boost/property_tree/json_parser.hpp> -#include <comphelper/lok.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -524,7 +521,6 @@ vcl::Region SlideSorterModel::RestoreSelection() bool SlideSorterModel::NotifyPageEvent (const SdrPage* pSdrPage) { ::osl::MutexGuard aGuard (maMutex); - sal_Int32 nIndex = -1; SdPage* pPage = const_cast<SdPage*>(dynamic_cast<const SdPage*>(pSdrPage)); if (pPage == nullptr) @@ -538,42 +534,30 @@ bool SlideSorterModel::NotifyPageEvent (const SdrPage* pSdrPage) return false; if (pPage->IsInserted()) - nIndex = InsertSlide(pPage); + InsertSlide(pPage); else - nIndex = DeleteSlide(pPage); + DeleteSlide(pPage); CheckModel(*this); - if (comphelper::LibreOfficeKit::isActive() && - nIndex != -1) - { - boost::property_tree::ptree aTree; - std::stringstream aStream; - aTree.put("action", pPage->IsInserted() ? "PartInserted" : "PartDeleted"); - aTree.put("part", OUString::number(nIndex).toUtf8().getStr()); - boost::property_tree::write_json(aStream, aTree); - const OString aPayload = aStream.str().c_str(); - GetDocument()->libreOfficeKitCallback(LOK_CALLBACK_PARTS_COUNT_CHANGED, aPayload.getStr()); - } - return true; } -sal_Int32 SlideSorterModel::InsertSlide (SdPage* pPage) +void SlideSorterModel::InsertSlide (SdPage* pPage) { // Find the index at which to insert the given page. sal_uInt16 nCoreIndex (pPage->GetPageNum()); sal_Int32 nIndex (FromCoreIndex(nCoreIndex)); if (pPage != GetPage(nIndex)) - return -1; + return; // Check that the pages in the document before and after the given page // are present in this model. if (nIndex>0) if (GetPage(nIndex-1) != GetPageDescriptor(nIndex-1)->GetPage()) - return -1; + return; if (size_t(nIndex)<maPageDescriptors.size()-1) if (GetPage(nIndex+1) != GetPageDescriptor(nIndex)->GetPage()) - return -1; + return; // Insert the given page at index nIndex maPageDescriptors.insert( @@ -586,11 +570,9 @@ sal_Int32 SlideSorterModel::InsertSlide (SdPage* pPage) // Update page indices. UpdateIndices(nIndex+1); - - return nIndex; } -sal_Int32 SlideSorterModel::DeleteSlide (const SdPage* pPage) +void SlideSorterModel::DeleteSlide (const SdPage* pPage) { sal_Int32 nIndex(0); @@ -617,13 +599,11 @@ sal_Int32 SlideSorterModel::DeleteSlide (const SdPage* pPage) { if (maPageDescriptors[nIndex]) if (maPageDescriptors[nIndex]->GetPage() != pPage) - return -1; + return; maPageDescriptors.erase(maPageDescriptors.begin()+nIndex); UpdateIndices(nIndex); } - - return nIndex; } void SlideSorterModel::UpdateIndices (const sal_Int32 nFirstIndex) |