summaryrefslogtreecommitdiff
path: root/sd/source/ui/slidesorter/model
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2016-02-12 07:12:07 -0400
committerHenry Castro <hcastro@collabora.com>2016-02-16 11:14:37 +0000
commit80d7c5859b9e7a834a915d7e8bbbe9bc2130108a (patch)
tree4cdc3cd73c1f8ed9d9523621e4594ecdc94caceb /sd/source/ui/slidesorter/model
parent3f7a0f7dba759ed3763c900112b5eeb7ccfdd84d (diff)
sd lok: add LOK_CALLBACK_PARTS_COUNT_CHANGED callback
In the tiled rendering case, when a slide is deleted or inserted the sorted slides are updated on client side. However, when .uno:Undo and .uno:Redo actions are requested on client side the sorted slides are required to update all sorted slides. So every time when .uno:InsertPage, .uno:DeletePage, .uno:Undo, .uno:Redo actions are requested, it will notify verbose action (PageInserted, PageDeleted) with index on client side to update the sorted slide index. Change-Id: Iebda2aa11be13aea8fbb6d0cc50442805d7485e9 Reviewed-on: https://gerrit.libreoffice.org/22309 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'sd/source/ui/slidesorter/model')
-rw-r--r--sd/source/ui/slidesorter/model/SlideSorterModel.cxx36
1 files changed, 28 insertions, 8 deletions
diff --git a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
index 4d9ddfaf5e4c..8912d523c1ba 100644
--- a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
+++ b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
@@ -32,6 +32,7 @@
#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"
@@ -41,6 +42,8 @@
#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;
@@ -521,6 +524,7 @@ 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)
@@ -534,30 +538,42 @@ bool SlideSorterModel::NotifyPageEvent (const SdrPage* pSdrPage)
return false;
if (pPage->IsInserted())
- InsertSlide(pPage);
+ nIndex = InsertSlide(pPage);
else
- DeleteSlide(pPage);
+ nIndex = 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;
}
-void SlideSorterModel::InsertSlide (SdPage* pPage)
+sal_Int32 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;
+ return -1;
// 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;
+ return -1;
if (size_t(nIndex)<maPageDescriptors.size()-1)
if (GetPage(nIndex+1) != GetPageDescriptor(nIndex)->GetPage())
- return;
+ return -1;
// Insert the given page at index nIndex
maPageDescriptors.insert(
@@ -570,9 +586,11 @@ void SlideSorterModel::InsertSlide (SdPage* pPage)
// Update page indices.
UpdateIndices(nIndex+1);
+
+ return nIndex;
}
-void SlideSorterModel::DeleteSlide (const SdPage* pPage)
+sal_Int32 SlideSorterModel::DeleteSlide (const SdPage* pPage)
{
sal_Int32 nIndex(0);
@@ -599,11 +617,13 @@ void SlideSorterModel::DeleteSlide (const SdPage* pPage)
{
if (maPageDescriptors[nIndex])
if (maPageDescriptors[nIndex]->GetPage() != pPage)
- return;
+ return -1;
maPageDescriptors.erase(maPageDescriptors.begin()+nIndex);
UpdateIndices(nIndex);
}
+
+ return nIndex;
}
void SlideSorterModel::UpdateIndices (const sal_Int32 nFirstIndex)