summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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.cxx18
-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, 129 insertions, 0 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index c98dd1fed6a8..863e377d6784 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -118,6 +118,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 44e321f25419..3e3a0e1d501a 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -116,6 +116,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 d9cd34720512..9c82ba84cce4 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 c0eeb188c76e..958ffc46f842 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -638,6 +638,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 f0ac91e6dffa..80ab14d95950 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -375,6 +375,9 @@ public:
/// @see vcl::ITiledRenderable::getPartName().
virtual OUString getPartName(int nPart) override;
+ /// @see vcl::ITiledRenderable::getPartHash().
+ virtual OUString getPartHash( int nPart ) override;
+
/// @see vcl::ITiledRenderable::initializeForTiledRendering().
virtual void initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 57075d8a5d7f..f9fff87de97a 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -295,6 +295,8 @@ public:
void SetLink( ScLinkMode 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 574723e6a9a3..9007e0f42ac5 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -48,12 +48,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();
@@ -281,6 +283,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 faed5470cf2e..1483aea0e00e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -193,6 +193,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 1a8887a87e21..277f6c139519 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -352,6 +352,11 @@ ScTable::~ScTable()
DestroySortCollator();
}
+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 7449898b757c..7f1e02f12ebb 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 b893e6a5dff8..d7da289b6392 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -179,6 +179,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 d50d01e8994d..88b437f3286b 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -60,6 +60,7 @@ public:
void testSearchAllFollowedBySearch();
void testInsertDeletePage();
void testInsertTable();
+ void testPartHash();
#endif
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
@@ -78,6 +79,7 @@ public:
CPPUNIT_TEST(testSearchAllFollowedBySearch);
CPPUNIT_TEST(testInsertDeletePage);
CPPUNIT_TEST(testInsertTable);
+ CPPUNIT_TEST(testPartHash);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -660,6 +662,22 @@ void SdTiledRenderingTest::testInsertTable()
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 55c779c41ff9..c903177a267c 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -2699,6 +2699,11 @@ SdPage* SdPage::getImplementation( const css::uno::Reference< css::drawing::XDra
return nullptr;
}
+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 7b2c9d31e51d..c1097d15efec 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -241,6 +241,8 @@ public:
virtual int getPart() override;
virtual int getParts() override;
virtual OUString getPartName( int nPart ) override;
+ virtual OUString getPartHash( int nPart ) override;
+
virtual void setPartMode( int nPartMode ) override;
/// @see vcl::ITiledRenderable::initializeForTiledRendering().
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 594c157d3d73..674ae3de4c4e 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2328,6 +2328,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 0e1009ce42c9..381a3566bb2d 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -412,6 +412,8 @@ public:
virtual int getPart() override;
/// @see vcl::ITiledRenderable::getPartName().
virtual OUString getPartName(int nPart) override;
+ /// @see vcl::ITiledRenderable::getPartHash().
+ virtual OUString getPartHash(int nPart) override;
/// @see vcl::ITiledRenderable::initializeForTiledRendering().
virtual void initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
/// @see vcl::ITiledRenderable::registerCallback().
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 37e5cf50dfc2..d0203afde5b9 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -48,6 +48,7 @@ public:
void testSearchAll();
void testSearchAllNotifications();
void testPageDownInvalidation();
+ void testPartHash();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -65,6 +66,7 @@ public:
CPPUNIT_TEST(testSearchAll);
CPPUNIT_TEST(testSearchAllNotifications);
CPPUNIT_TEST(testPageDownInvalidation);
+ CPPUNIT_TEST(testPartHash);
CPPUNIT_TEST_SUITE_END();
private:
@@ -516,6 +518,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 b975697853d6..a4e7b2af702e 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3229,6 +3229,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;