[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 2 commits - desktop/source include/LibreOfficeKit include/vcl sc/inc sc/qa sc/source sd/inc sd/qa sd/source sw/inc sw/qa sw/source
Jan Holesovsky
kendy at collabora.com
Sat Apr 23 15:33:20 UTC 2016
desktop/source/lib/init.cxx | 22 +++++++++++++++++++++-
include/LibreOfficeKit/LibreOfficeKit.h | 4 ++++
include/LibreOfficeKit/LibreOfficeKit.hxx | 6 ++++++
include/vcl/ITiledRenderable.hxx | 6 ++++++
sc/inc/document.hxx | 1 +
sc/inc/docuno.hxx | 3 +++
sc/inc/table.hxx | 2 ++
sc/qa/unit/tiledrendering/tiledrendering.cxx | 18 ++++++++++++++++++
sc/source/core/data/document.cxx | 13 +++++++++++++
sc/source/core/data/table1.cxx | 5 +++++
sc/source/ui/unoobj/docuno.cxx | 7 +++++++
sd/inc/sdpage.hxx | 1 +
sd/qa/unit/tiledrendering/tiledrendering.cxx | 19 +++++++++++++++++++
sd/source/core/sdpage.cxx | 5 +++++
sd/source/ui/inc/unomodel.hxx | 2 ++
sd/source/ui/unoidl/unomodel.cxx | 12 ++++++++++++
sw/inc/unotxdoc.hxx | 2 ++
sw/qa/extras/tiledrendering/tiledrendering.cxx | 16 ++++++++++++++++
sw/source/uibase/uno/unotxdoc.cxx | 8 ++++++++
19 files changed, 151 insertions(+), 1 deletion(-)
New commits:
commit 41a5531afb740f7af01309ac061838c37c6c3fb1
Author: Jan Holesovsky <kendy at collabora.com>
Date: Thu Apr 21 19:04:58 2016 +0200
lok: getPartHash should be at the end, it is a new API call.
Also add it to the init.cxx so that it is actually used.
Change-Id: I255411158d0822718116ac05aad1ee925a9a7a9a
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index bada69f..f1cb9f0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -381,6 +381,7 @@ static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
const char *pFontName,
int* pFontWidth,
int* pFontHeight);
+static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart);
LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
: mxComponent(xComponent)
@@ -400,7 +401,6 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->setPart = doc_setPart;
m_pDocumentClass->getPartName = doc_getPartName;
m_pDocumentClass->setPartMode = doc_setPartMode;
- m_pDocumentClass->renderFont = doc_renderFont;
m_pDocumentClass->paintTile = doc_paintTile;
m_pDocumentClass->getTileMode = doc_getTileMode;
m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
@@ -424,6 +424,9 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->getView = doc_getView;
m_pDocumentClass->getViews = doc_getViews;
+ m_pDocumentClass->renderFont = doc_renderFont;
+ m_pDocumentClass->getPartHash = doc_getPartHash;
+
gDocumentClass = m_pDocumentClass;
}
pClass = m_pDocumentClass.get();
@@ -913,6 +916,23 @@ static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart)
}
+static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart)
+{
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return nullptr;
+ }
+
+ OUString sHash = pDoc->getPartHash(nPart);
+ OString aString = OUStringToOString(sHash, RTL_TEXTENCODING_UTF8);
+ char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
+ strcpy(pMemory, aString.getStr());
+ return pMemory;
+
+}
+
static void doc_setPartMode(LibreOfficeKitDocument* pThis,
int nPartMode)
{
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index d66028a..be833db 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -116,10 +116,6 @@ 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);
@@ -226,6 +222,10 @@ struct _LibreOfficeKitDocumentClass
const char* pFontName,
int* pFontWidth,
int* pFontHeight);
+
+ /// @see lok::Document::getPartHash().
+ char* (*getPartHash) (LibreOfficeKitDocument* pThis,
+ int nPart);
#endif // LOK_USE_UNSTABLE_API
};
commit 756e208be95b455d3d817610d931a742d1b04389
Author: Henry Castro <hcastro at collabora.com>
Date: Wed Apr 20 13:52:31 2016 -0400
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 at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 4feaaf7..d66028a 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 84741e0..5bd3e60 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 34f5315..6e5df25 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 69e6f5b..272d2eb 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 09fd69c..6eb3292 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 7454188..a912bea 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 52d6af1..4f33ffb 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 f207610..95c7ae5 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 d93d1f4..be738f9 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 cba78bd..f03768d 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 6e6a354..58f6fe6 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 7c63bf2..4fe421e 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 5a8de34..e6c550f 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 1fd9756..388bfc5 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 adb1fc7..19be0ad 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 1251f76..fc70cbb 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 240899c..00d8595 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 9a78c37..8392cfd 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;
More information about the Libreoffice-commits
mailing list