[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - 4 commits - include/LibreOfficeKit include/svl sc/qa sc/source svl/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Aug 5 12:56:31 UTC 2016
include/LibreOfficeKit/LibreOfficeKitInit.h | 10 ++++-----
include/svl/undo.hxx | 5 ++++
sc/qa/unit/tiledrendering/tiledrendering.cxx | 22 +++++++++++++++++++++
sc/source/ui/inc/undobase.hxx | 6 +++++
sc/source/ui/inc/undodraw.hxx | 3 ++
sc/source/ui/undo/undobase.cxx | 20 +++++++++++++++++--
sc/source/ui/undo/undodraw.cxx | 10 ++++++++-
svl/source/undo/undo.cxx | 28 +++++++++++++++++++++++++--
8 files changed, 94 insertions(+), 10 deletions(-)
New commits:
commit 1dd03826d3c17af500731550e14acd4b694b1bd9
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Aug 4 18:08:34 2016 +0200
LOK init: avoid non-inline function definition in header file
To prevent possible ODR violations.
Change-Id: Ic9538244a0bf3760808904d2bcf608151c53f899
Reviewed-on: https://gerrit.libreoffice.org/27883
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit 3f02b2aa51e32c46d5b6610480bc1ba22156a3ec)
diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h
index 2ab7d18..6190d72 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -42,7 +42,7 @@ extern "C"
#endif
#define SEPARATOR '/'
- void *lok_loadlib(const char *pFN)
+ inline void *lok_loadlib(const char *pFN)
{
return dlopen(pFN, RTLD_LAZY
#if defined __clang__ && defined __linux__ \
@@ -54,22 +54,22 @@ extern "C"
);
}
- char *lok_dlerror(void)
+ inline char *lok_dlerror(void)
{
return dlerror();
}
- void *lok_dlsym(void *Hnd, const char *pName)
+ inline void *lok_dlsym(void *Hnd, const char *pName)
{
return dlsym(Hnd, pName);
}
- int lok_dlclose(void *Hnd)
+ inline int lok_dlclose(void *Hnd)
{
return dlclose(Hnd);
}
- void extendUnoPath(const char *pPath)
+ inline void extendUnoPath(const char *pPath)
{
(void)pPath;
}
commit e3d57b2c8219fff9653120558eb363ebc5672e3e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Aug 4 15:55:45 2016 +0200
svl: track creation time of SfxUndoAction instances
It's not yet clear how to expose this on the UI, though.
Reviewed-on: https://gerrit.libreoffice.org/27878
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit 33a5ab1eb74d140265b471fb33ca98aca7cfb1a6)
Conflicts:
svl/source/undo/undo.cxx
Change-Id: Iee6737922d36e896653b4fae557442747dda1b8b
diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx
index 2012df9..95684f5 100644
--- a/include/svl/undo.hxx
+++ b/include/svl/undo.hxx
@@ -21,6 +21,7 @@
#include <svl/svldllapi.h>
#include <rtl/ustring.hxx>
+#include <tools/datetime.hxx>
#include <limits>
#include <memory>
@@ -68,11 +69,15 @@ public:
virtual sal_uInt16 GetId() const;
/// ID of the view shell that created this undo action.
virtual sal_Int32 GetViewShellId() const;
+ /// Timestamp when this undo item was created.
+ const DateTime& GetDateTime() const;
virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
private:
SfxUndoAction( const SfxUndoAction& ) = delete;
SfxUndoAction& operator=( const SfxUndoAction& ) = delete;
+
+ DateTime m_aDateTime;
};
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index 8481ed3..0fa3867 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -26,6 +26,7 @@
#include <comphelper/flagguard.hxx>
#include <tools/diagnose_ex.h>
#include <libxml/xmlwriter.h>
+#include <unotools/datetime.hxx>
#include <vector>
#include <list>
@@ -62,7 +63,8 @@ SfxUndoAction::~SfxUndoAction()
SfxUndoAction::SfxUndoAction()
-: mpSfxLinkUndoAction(nullptr)
+: mpSfxLinkUndoAction(nullptr),
+ m_aDateTime(DateTime::SYSTEM)
{
}
@@ -89,6 +91,11 @@ sal_Int32 SfxUndoAction::GetViewShellId() const
return -1;
}
+const DateTime& SfxUndoAction::GetDateTime() const
+{
+ return m_aDateTime;
+}
+
OUString SfxUndoAction::GetRepeatComment(SfxRepeatTarget&) const
{
return GetComment();
@@ -142,6 +149,7 @@ void SfxUndoAction::dumpAsXml(xmlTextWriterPtr pWriter) const
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("symbol"), BAD_CAST(typeid(*this).name()));
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("comment"), BAD_CAST(GetComment().toUtf8().getStr()));
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("viewShellId"), BAD_CAST(OString::number(GetViewShellId()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("dateTime"), BAD_CAST(utl::toISO8601(m_aDateTime.GetUNODateTime()).toUtf8().getStr()));
xmlTextWriterEndElement(pWriter);
}
commit 8094a21526cd46074d529509c00a03d0839fc28e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Aug 4 12:39:18 2016 +0200
svl: expose redo actions in SfxUndoManager::dumpAsXml()
To see if an undo action is actually deleted or just moved to the redo
stack.
Change-Id: I40632ea29353e50b643b8b1831d5ffdf443ca75a
Reviewed-on: https://gerrit.libreoffice.org/27871
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit ba8fc726ebae7b1ebaf65ae462d56ee0b4af14a3)
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index def0089..8481ed3 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -1285,6 +1285,8 @@ void SfxUndoManager::RemoveOldestUndoActions( size_t const i_count )
void SfxUndoManager::dumpAsXml(xmlTextWriterPtr pWriter) const
{
+ UndoManagerGuard aGuard(*m_xData);
+
bool bOwns = false;
if (!pWriter)
{
@@ -1295,9 +1297,23 @@ void SfxUndoManager::dumpAsXml(xmlTextWriterPtr pWriter) const
xmlTextWriterStartElement(pWriter, BAD_CAST("sfxUndoManager"));
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nUndoActionCount"), BAD_CAST(OString::number(GetUndoActionCount()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nRedoActionCount"), BAD_CAST(OString::number(GetRedoActionCount()).getStr()));
+ xmlTextWriterStartElement(pWriter, BAD_CAST("undoActions"));
for (size_t i = 0; i < GetUndoActionCount(); ++i)
- GetUndoAction(i)->dumpAsXml(pWriter);
+ {
+ const SfxUndoArray* pUndoArray = m_xData->pActUndoArray;
+ pUndoArray->aUndoActions[pUndoArray->nCurUndoAction - 1 - i].pAction->dumpAsXml(pWriter);
+ }
+ xmlTextWriterEndElement(pWriter);
+
+ xmlTextWriterStartElement(pWriter, BAD_CAST("redoActions"));
+ for (size_t i = 0; i < GetRedoActionCount(); ++i)
+ {
+ const SfxUndoArray* pUndoArray = m_xData->pActUndoArray;
+ pUndoArray->aUndoActions[pUndoArray->nCurUndoAction + i].pAction->dumpAsXml(pWriter);
+ }
+ xmlTextWriterEndElement(pWriter);
xmlTextWriterEndElement(pWriter);
if (bOwns)
commit 392635220aad1c361897fedeff1c4e7ca5c8476d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Aug 4 09:13:33 2016 +0200
sc: implement SfxUndoAction::GetViewShellId() interface ...
... in SfxUndoAction subclasses
Change-Id: I1504e2cfb0f58ff97e2de7a641d72e4867238164
Reviewed-on: https://gerrit.libreoffice.org/27861
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit 7cbb0664b94bb9f4587098c1940de98e4f7aae16)
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index f049f4e..8b088ba 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -60,6 +60,7 @@ public:
void testDocumentSizeChanged();
void testViewLock();
void testColRowResize();
+ void testUndoShells();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnSelections);
@@ -71,6 +72,7 @@ public:
CPPUNIT_TEST(testDocumentSizeChanged);
CPPUNIT_TEST(testViewLock);
CPPUNIT_TEST(testColRowResize);
+ CPPUNIT_TEST(testUndoShells);
CPPUNIT_TEST_SUITE_END();
private:
@@ -560,6 +562,26 @@ void ScTiledRenderingTest::testColRowResize()
comphelper::LibreOfficeKit::setActive(false);
}
+void ScTiledRenderingTest::testUndoShells()
+{
+ comphelper::LibreOfficeKit::setActive();
+ ScModelObj* pModelObj = createDoc("small.ods");
+ // Clear the currently selected cell.
+ comphelper::dispatchCommand(".uno:ClearContents", {});
+
+ auto pDocShell = dynamic_cast<ScDocShell*>(pModelObj->GetEmbeddedObject());
+ CPPUNIT_ASSERT(pDocShell);
+ ScDocument& rDoc = pDocShell->GetDocument();
+ SfxUndoManager* pUndoManager = rDoc.GetUndoManager();
+ CPPUNIT_ASSERT(pUndoManager);
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pUndoManager->GetUndoActionCount());
+ sal_Int32 nView1 = SfxLokHelper::getView();
+ // This was -1: ScSimpleUndo did not remember what view shell created it.
+ CPPUNIT_ASSERT_EQUAL(nView1, pUndoManager->GetUndoAction()->GetViewShellId());
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
diff --git a/sc/source/ui/inc/undobase.hxx b/sc/source/ui/inc/undobase.hxx
index f501f5b..a9a3ba2 100644
--- a/sc/source/ui/inc/undobase.hxx
+++ b/sc/source/ui/inc/undobase.hxx
@@ -45,10 +45,13 @@ public:
virtual ~ScSimpleUndo();
virtual bool Merge( SfxUndoAction *pNextAction ) override;
+ /// See SfxUndoAction::GetViewShellId().
+ sal_Int32 GetViewShellId() const override;
protected:
ScDocShell* pDocShell;
SfxUndoAction* pDetectiveUndo;
+ sal_Int32 mnViewShellId;
bool IsPaintLocked() const { return pDocShell->IsPaintLocked(); }
@@ -164,6 +167,7 @@ private:
class ScUndoWrapper: public SfxUndoAction // for manual merging of actions
{
SfxUndoAction* pWrappedUndo;
+ sal_Int32 mnViewShellId;
public:
ScUndoWrapper( SfxUndoAction* pUndo );
@@ -182,6 +186,8 @@ public:
virtual OUString GetComment() const override;
virtual OUString GetRepeatComment(SfxRepeatTarget&) const override;
virtual sal_uInt16 GetId() const override;
+ /// See SfxUndoAction::GetViewShellId().
+ sal_Int32 GetViewShellId() const override;
};
#endif
diff --git a/sc/source/ui/inc/undodraw.hxx b/sc/source/ui/inc/undodraw.hxx
index 103b015..bbebad8 100644
--- a/sc/source/ui/inc/undodraw.hxx
+++ b/sc/source/ui/inc/undodraw.hxx
@@ -28,6 +28,7 @@ class ScUndoDraw: public SfxUndoAction
{
SfxUndoAction* pDrawUndo;
ScDocShell* pDocShell;
+ sal_Int32 mnViewShellId;
void UpdateSubShell();
@@ -48,6 +49,8 @@ public:
virtual OUString GetComment() const override;
virtual OUString GetRepeatComment(SfxRepeatTarget&) const override;
virtual sal_uInt16 GetId() const override;
+ /// See SfxUndoAction::GetViewShellId().
+ sal_Int32 GetViewShellId() const override;
};
#endif
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index 64ce53a..1859b58 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -38,8 +38,16 @@
ScSimpleUndo::ScSimpleUndo( ScDocShell* pDocSh ) :
pDocShell( pDocSh ),
- pDetectiveUndo( nullptr )
+ pDetectiveUndo( nullptr ),
+ mnViewShellId(-1)
{
+ if (ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell())
+ mnViewShellId = pViewShell->GetViewShellId();
+}
+
+sal_Int32 ScSimpleUndo::GetViewShellId() const
+{
+ return mnViewShellId;
}
ScSimpleUndo::~ScSimpleUndo()
@@ -562,8 +570,11 @@ void ScDBFuncUndo::EndRedo()
}
ScUndoWrapper::ScUndoWrapper( SfxUndoAction* pUndo ) :
- pWrappedUndo( pUndo )
+ pWrappedUndo( pUndo ),
+ mnViewShellId( -1 )
{
+ if (pWrappedUndo)
+ mnViewShellId = pWrappedUndo->GetViewShellId();
}
ScUndoWrapper::~ScUndoWrapper()
@@ -583,6 +594,11 @@ OUString ScUndoWrapper::GetComment() const
return OUString();
}
+sal_Int32 ScUndoWrapper::GetViewShellId() const
+{
+ return mnViewShellId;
+}
+
OUString ScUndoWrapper::GetRepeatComment(SfxRepeatTarget& rTarget) const
{
if (pWrappedUndo)
diff --git a/sc/source/ui/undo/undodraw.cxx b/sc/source/ui/undo/undodraw.cxx
index 5645afb..5b9c0d5 100644
--- a/sc/source/ui/undo/undodraw.cxx
+++ b/sc/source/ui/undo/undodraw.cxx
@@ -26,8 +26,11 @@
ScUndoDraw::ScUndoDraw( SfxUndoAction* pUndo, ScDocShell* pDocSh ) :
pDrawUndo( pUndo ),
- pDocShell( pDocSh )
+ pDocShell( pDocSh ),
+ mnViewShellId( -1 )
{
+ if (ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell())
+ mnViewShellId = pViewShell->GetViewShellId();
}
ScUndoDraw::~ScUndoDraw()
@@ -47,6 +50,11 @@ OUString ScUndoDraw::GetComment() const
return OUString();
}
+sal_Int32 ScUndoDraw::GetViewShellId() const
+{
+ return mnViewShellId;
+}
+
OUString ScUndoDraw::GetRepeatComment(SfxRepeatTarget& rTarget) const
{
if (pDrawUndo)
More information about the Libreoffice-commits
mailing list