summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2016-04-20 13:52:31 -0400
committerHenry Castro <hcastro@collabora.com>2016-04-23 11:33:23 -0400
commit756e208be95b455d3d817610d931a742d1b04389 (patch)
tree67436ea151fa579b61d18d41cc23111daf26fa72
parentbb52a54aa49cbb75820f8ddbfc8e9e94b63281cd (diff)
lokit: add getPartHash
In the tiled rendering case, the slides, no matter if it is inserted or deleted, the part names always return sequential names i.e. Slide 1, Slide 2, ..., Slide N. However the client side needs to know what slides had been deleted or inserted, so it is necessary to send the hash codes. Change-Id: I0e9caeec660c3e42dd9f751bdce7690f9ad365a1 Reviewed-on: https://gerrit.libreoffice.org/24267 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h4
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx6
-rw-r--r--include/vcl/ITiledRenderable.hxx6
-rw-r--r--sc/inc/document.hxx1
-rw-r--r--sc/inc/docuno.hxx3
-rw-r--r--sc/inc/table.hxx2
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx18
-rw-r--r--sc/source/core/data/document.cxx13
-rw-r--r--sc/source/core/data/table1.cxx5
-rw-r--r--sc/source/ui/unoobj/docuno.cxx7
-rw-r--r--sd/inc/sdpage.hxx1
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx19
-rw-r--r--sd/source/core/sdpage.cxx5
-rw-r--r--sd/source/ui/inc/unomodel.hxx2
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx12
-rw-r--r--sw/inc/unotxdoc.hxx2
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx16
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx8
18 files changed, 130 insertions, 0 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 4feaaf758cae..d66028a4b18d 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -116,6 +116,10 @@ struct _LibreOfficeKitDocumentClass
char* (*getPartName) (LibreOfficeKitDocument* pThis,
int nPart);
+ /// @see lok::Document::getPartHash().
+ char* (*getPartHash) (LibreOfficeKitDocument* pThis,
+ int nPart);
+
/// @see lok::Document::setPartMode().
void (*setPartMode) (LibreOfficeKitDocument* pThis,
int nMode);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 84741e0ee20b..5bd3e60b9286 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -113,6 +113,12 @@ public:
return mpDoc->pClass->getPartName(mpDoc, nPart);
}
+ /// Get the current part's hash.
+ inline char* getPartHash(int nPart)
+ {
+ return mpDoc->pClass->getPartHash(mpDoc, nPart);
+ }
+
inline void setPartMode(int nMode)
{
mpDoc->pClass->setPartMode(mpDoc, nMode);
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 34f53153b9cb..6e5df25d205b 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -83,6 +83,12 @@ public:
return OUString("");
}
+ /**
+ * Get the hash of the currently displayed part, i.e. sheet in a spreadsheet
+ * or slide in a presentation.
+ */
+ virtual OUString getPartHash(int nPart) = 0;
+
/// @see lok::Document::setPartMode().
virtual void setPartMode(int nPartMode)
{
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 69e6f5bd9586..272d2eb1b3a0 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -596,6 +596,7 @@ public:
SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab) { nVisibleTab = nTab; }
SC_DLLPUBLIC bool HasTable( SCTAB nTab ) const;
+ SC_DLLPUBLIC bool GetHashCode( SCTAB nTab, sal_Int64& rHashCode) const;
SC_DLLPUBLIC bool GetName( SCTAB nTab, OUString& rName ) const;
SC_DLLPUBLIC bool GetCodeName( SCTAB nTab, OUString& rName ) const;
SC_DLLPUBLIC bool SetCodeName( SCTAB nTab, const OUString& rName );
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 09fd69c670c0..6eb32920307c 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -392,6 +392,9 @@ public:
/// @see vcl::ITiledRenderable::getPartName().
virtual OUString getPartName(int nPart) SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::getPartHash().
+ virtual OUString getPartHash( int nPart ) SAL_OVERRIDE;
+
/// @see vcl::ITiledRenderable::initializeForTiledRendering().
virtual void initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) SAL_OVERRIDE;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 7454188f04a7..a912bea5db71 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -292,6 +292,8 @@ public:
void SetLink( sal_uInt8 nMode, const OUString& rDoc, const OUString& rFlt,
const OUString& rOpt, const OUString& rTab, sal_uLong nRefreshDelay );
+ sal_Int64 GetHashCode () const;
+
void GetName( OUString& rName ) const;
void SetName( const OUString& rNewName );
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 52d6af174c24..4f33ffb67ce0 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -54,12 +54,14 @@ public:
#if !defined(WNT) && !defined(MACOSX)
void testRowColumnSelections();
void testSortAscendingDescending();
+ void testPartHash();
#endif
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
#if !defined(WNT) && !defined(MACOSX)
CPPUNIT_TEST(testRowColumnSelections);
CPPUNIT_TEST(testSortAscendingDescending);
+ CPPUNIT_TEST(testPartHash);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -257,6 +259,22 @@ void ScTiledRenderingTest::testSortAscendingDescending()
comphelper::LibreOfficeKit::setActive(false);
}
+void ScTiledRenderingTest::testPartHash()
+{
+ comphelper::LibreOfficeKit::setActive();
+ ScModelObj* pModelObj = createDoc("sort-range.ods");
+
+ int nParts = pModelObj->getParts();
+ for (int it = 0; it < nParts; it++)
+ {
+ CPPUNIT_ASSERT(!pModelObj->getPartHash(it).isEmpty());
+ }
+
+ // check part that it does not exists
+ CPPUNIT_ASSERT(pModelObj->getPartHash(100).isEmpty());
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
#endif
CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index f207610d3013..95c7ae5dca12 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -192,6 +192,19 @@ bool ScDocument::HasTable( SCTAB nTab ) const
return false;
}
+bool ScDocument::GetHashCode( SCTAB nTab, sal_Int64& rHashCode ) const
+{
+ if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()))
+ {
+ if (maTabs[nTab])
+ {
+ rHashCode = maTabs[nTab]->GetHashCode();
+ return true;
+ }
+ }
+ return false;
+}
+
bool ScDocument::GetName( SCTAB nTab, OUString& rName ) const
{
if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()))
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index d93d1f4d7ed3..be738f9c5a6e 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -354,6 +354,11 @@ ScTable::~ScTable()
aCol[k].PrepareBroadcastersForDestruction();
}
+sal_Int64 ScTable::GetHashCode() const
+{
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+}
+
void ScTable::GetName( OUString& rName ) const
{
rName = aName;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index cba78bd63e70..f03768d1ec48 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -523,6 +523,13 @@ OUString ScModelObj::getPartName( int nPart )
return sTabName;
}
+OUString ScModelObj::getPartHash( int nPart )
+{
+ sal_Int64 nHashCode;
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ return (pViewData->GetDocument()->GetHashCode(nPart, nHashCode) ? OUString::number(nHashCode) : OUString());
+}
+
Size ScModelObj::getDocumentSize()
{
Size aSize(10, 10); // minimum size
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index 6e6a354408b1..58f6fe6651ff 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -186,6 +186,7 @@ public:
OUString GetPresObjText(PresObjKind eObjKind) const;
SfxStyleSheet* GetStyleSheetForMasterPageBackground() const;
SfxStyleSheet* GetStyleSheetForPresObj(PresObjKind eObjKind) const;
+ sal_Int64 GetHashCode() const;
bool RestoreDefaultText( SdrObject* pObj );
/** @return true if the given SdrObject is inside the presentation object list */
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 7c63bf275ac7..4fe421ede4a1 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -66,6 +66,7 @@ public:
void testSearchAllSelections();
void testSearchAllNotifications();
void testSearchAllFollowedBySearch();
+ void testPartHash();
#endif
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
@@ -83,6 +84,8 @@ public:
//CPPUNIT_TEST(testSearchAllSelections);
CPPUNIT_TEST(testSearchAllNotifications);
CPPUNIT_TEST(testSearchAllFollowedBySearch);
+ CPPUNIT_TEST(testInsertDeletePage);
+ CPPUNIT_TEST(testPartHash);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -622,6 +625,22 @@ void SdTiledRenderingTest::testInsertDeletePage()
comphelper::LibreOfficeKit::setActive(false);
}
+void SdTiledRenderingTest::testPartHash()
+{
+ comphelper::LibreOfficeKit::setActive();
+ SdXImpressDocument* pDoc = createDoc("dummy.odp");
+
+ int nParts = pDoc->getParts();
+ for (int it = 0; it < nParts; it++)
+ {
+ CPPUNIT_ASSERT(!pDoc->getPartHash(it).isEmpty());
+ }
+
+ // check part that it does not exists
+ CPPUNIT_ASSERT(pDoc->getPartHash(100).isEmpty());
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
#endif
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 5a8de34029fe..e6c550fa9ca7 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -2700,6 +2700,11 @@ SdPage* SdPage::getImplementation( const ::com::sun::star::uno::Reference< ::com
return 0;
}
+sal_Int64 SdPage::GetHashCode() const
+{
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+}
+
void SdPage::SetName (const OUString& rName)
{
OUString aOldName( GetName() );
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 1fd97568f363..388bfc5045eb 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -240,6 +240,8 @@ public:
virtual int getPart() SAL_OVERRIDE;
virtual int getParts() SAL_OVERRIDE;
virtual OUString getPartName( int nPart ) SAL_OVERRIDE;
+ virtual OUString getPartHash( int nPart ) SAL_OVERRIDE;
+
virtual void setPartMode( int nPartMode ) SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::initializeForTiledRendering().
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index adb1fc72586d..19be0ad85797 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2339,6 +2339,18 @@ OUString SdXImpressDocument::getPartName( int nPart )
return pPage->GetName();
}
+OUString SdXImpressDocument::getPartHash( int nPart )
+{
+ SdPage* pPage = mpDoc->GetSdPage( nPart, PK_STANDARD );
+ if (!pPage)
+ {
+ SAL_WARN("sd", "DrawViewShell not available!");
+ return OUString();
+ }
+
+ return OUString::number(pPage->GetHashCode());
+}
+
void SdXImpressDocument::setPartMode( int nPartMode )
{
DrawViewShell* pViewSh = GetViewShell();
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 1251f76b1e94..fc70cbbc3f85 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -416,6 +416,8 @@ public:
virtual int getPart() SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::getPartName().
virtual OUString getPartName(int nPart) SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::getPartHash().
+ virtual OUString getPartHash(int nPart) SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::initializeForTiledRendering().
virtual void initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::registerCallback().
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 240899c602c0..00d85951e7b8 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -55,6 +55,7 @@ public:
void testSearchAll();
void testSearchAllNotifications();
void testPageDownInvalidation();
+ void testPartHash();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -72,6 +73,7 @@ public:
CPPUNIT_TEST(testSearchAll);
CPPUNIT_TEST(testSearchAllNotifications);
CPPUNIT_TEST(testPageDownInvalidation);
+ CPPUNIT_TEST(testPartHash);
CPPUNIT_TEST_SUITE_END();
private:
@@ -518,6 +520,20 @@ void SwTiledRenderingTest::testPageDownInvalidation()
comphelper::LibreOfficeKit::setActive(false);
}
+void SwTiledRenderingTest::testPartHash()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ SwXTextDocument* pXTextDocument = createDoc("pagedown-invalidation.odt");
+ int nParts = pXTextDocument->getParts();
+ for (int it = 0; it < nParts; it++)
+ {
+ CPPUNIT_ASSERT(!pXTextDocument->getPartHash(it).isEmpty());
+ }
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 9a78c37b6ca2..8392cfd0ee72 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3262,6 +3262,14 @@ OUString SwXTextDocument::getPartName(int nPart)
return OUString(SW_RES(STR_PAGE)) + OUString::number(nPart + 1);
}
+OUString SwXTextDocument::getPartHash(int nPart)
+{
+ SolarMutexGuard aGuard;
+ OUString sPart(OUString(SW_RES(STR_PAGE)) + OUString::number(nPart + 1));
+
+ return OUString::number(sPart.hashCode());
+}
+
void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
{
SolarMutexGuard aGuard;