diff options
author | Henry Castro <hcastro@collabora.com> | 2016-02-20 09:57:52 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2016-02-20 16:12:33 -0400 |
commit | c6fe577cc579cc0ae5f0a7d63bc86b1718eddeeb (patch) | |
tree | b61f847a394c08819d126db3efcaa1813d701b2d /sd | |
parent | 6eec9807349494c54decfdd22bc2d36e70dfea2f (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 | 72 | ||||
-rw-r--r-- | sd/source/core/drawdoc2.cxx | 26 | ||||
-rw-r--r-- | sd/source/ui/inc/SlideSorterViewShell.hxx | 3 | ||||
-rw-r--r-- | sd/source/ui/inc/ViewShell.hxx | 3 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx | 4 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/model/SlideSorterModel.cxx | 36 |
6 files changed, 56 insertions, 88 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 0c037f835340..8d19021ab2a0 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -31,9 +31,6 @@ #include <sfx2/viewfrm.hxx> #include <svl/srchitem.hxx> -#include <ImpressViewShellBase.hxx> -#include <SlideSorterViewShell.hxx> -#include <SlideSorter.hxx> #include <DrawDocShell.hxx> #include <ViewShell.hxx> #include <sdpage.hxx> @@ -55,7 +52,7 @@ public: virtual void tearDown() SAL_OVERRIDE; #if !defined(WNT) && !defined(MACOSX) - void testInsertPage(); + void testInsertDeletePage(); void testRegisterCallback(); void testPostKeyEvent(); void testPostMouseEvent(); @@ -72,7 +69,7 @@ public: CPPUNIT_TEST_SUITE(SdTiledRenderingTest); #if !defined(WNT) && !defined(MACOSX) - CPPUNIT_TEST(testInsertPage); + CPPUNIT_TEST(testInsertDeletePage); CPPUNIT_TEST(testRegisterCallback); CPPUNIT_TEST(testPostKeyEvent); CPPUNIT_TEST(testPostMouseEvent); @@ -518,95 +515,67 @@ 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) + OUString("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); - - Application::Reschedule(true); - Scheduler::ProcessTaskScheduling(true); - sd::slidesorter::SlideSorterViewShell* pSSVS = - sd::slidesorter::SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase()); - 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 - for(unsigned nIterator=0; nIterator < m_aPageList.size(); nIterator++) + for(auto i: m_aPageList) { - SdPage* pPage = pDoc->GetSdPage(m_aPageList[nIterator], PK_STANDARD); + SdPage* pPage = pDoc->GetSdPage(i, PK_STANDARD); CPPUNIT_ASSERT(pPage); } 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 - for(unsigned nIterator=0; nIterator < m_aPageList.size(); nIterator++) + for(auto i: m_aPageList) { - SdPage* pPage = pDoc->GetSdPage(m_aPageList[nIterator], PK_STANDARD); + SdPage* pPage = pDoc->GetSdPage(i, PK_STANDARD); CPPUNIT_ASSERT(pPage == nullptr); } 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 - for(unsigned nIterator=0; nIterator < m_aPageList.size(); nIterator++) + for(auto i: m_aPageList) { - SdPage* pPage = pDoc->GetSdPage(m_aPageList[nIterator], PK_STANDARD); + SdPage* pPage = pDoc->GetSdPage(i, PK_STANDARD); CPPUNIT_ASSERT(pPage); } 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 - for(unsigned nIterator=0; nIterator < m_aPageList.size(); nIterator++) + for(auto i: m_aPageList) { - SdPage* pPage = pDoc->GetSdPage(m_aPageList[nIterator], PK_STANDARD); + SdPage* pPage = pDoc->GetSdPage(i, PK_STANDARD); CPPUNIT_ASSERT(pPage == nullptr); } @@ -614,12 +583,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 eb83adecc860..ce0dec576415 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/inc/SlideSorterViewShell.hxx b/sd/source/ui/inc/SlideSorterViewShell.hxx index 92fd749688b4..fe039105d026 100644 --- a/sd/source/ui/inc/SlideSorterViewShell.hxx +++ b/sd/source/ui/inc/SlideSorterViewShell.hxx @@ -70,8 +70,7 @@ public: pane is returned. When no slidesorter is visible then NULL is returned. */ - // Exported for unit test - SD_DLLPUBLIC static SlideSorterViewShell* GetSlideSorter (ViewShellBase& rBase); + static SlideSorterViewShell* GetSlideSorter (ViewShellBase& rBase); virtual SdPage* GetActualPage() SAL_OVERRIDE; diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx index dce807869f5b..bc962ca59810 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -365,8 +365,7 @@ public: // virtual void OuterResizePixel(const Point &rPos, const Size &rSize); // virtual void InnerResizePixel(const Point &rPos, const Size &rSize); - // Exported for unit test - SD_DLLPUBLIC ViewShellBase& GetViewShellBase() const; + ViewShellBase& GetViewShellBase() const; /** Return <TRUE/> when the called view shell is the main sub shell of its ViewShellBase object, i.e. is display in the center pane. This diff --git a/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx b/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx index 3bd56cf793ab..c2f20cf781a4 100644 --- a/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx +++ b/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx @@ -223,8 +223,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 4d32f110bb92..9a02c8870196 100644 --- a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx +++ b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx @@ -33,7 +33,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" @@ -43,8 +42,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; @@ -527,7 +524,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 == NULL) @@ -541,42 +537,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( @@ -589,11 +573,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); @@ -620,13 +602,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) |