[Libreoffice-commits] core.git: include/LibreOfficeKit libreofficekit/source sw/inc sw/source
include/LibreOfficeKit/LibreOfficeKitEnums.h | 26 libreofficekit/source/gtk/lokdocview.cxx |4 sw/inc/PostItMgr.hxx |2 sw/source/uibase/docvw/PostItMgr.cxx | 158 +-- 4 files changed, 154 insertions(+), 36 deletions(-) New commits: commit 5f5073a84518e4a8660e0153c2e218fb75a85ec4 Author: Pranav KantDate: Tue Jan 24 14:07:45 2017 +0530 lok: Implement new callbacks for comment notifications Change-Id: I298183b295c68c4a39cb1f6fffe4b89b4eaee0f3 Reviewed-on: https://gerrit.libreoffice.org/33469 Reviewed-by: pranavk Tested-by: pranavk diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index f3dccd0..8a59b4c 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -467,6 +467,32 @@ typedef enum * - 'action' is 'Modify'. */ LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED = 31, + +/** + * There is some change in comments in the document + * + * The payload example: + * { + * "comment": { + * "action": "Add", + * "id": "11", + * "parent": "4", + * "author": "Unknown Author", + * "text": "", + * "dateTime": "2016-08-18T13:13:00", + * "anchorPos": "4529, 3906", + * "textRange": "1418, 3906, 3111, 919" + * } + * } + * + * The format is the same as an entry of + * lok::Document::getCommandValues('.uno:ViewAnnotations'), extra + * fields: + * + * - 'action' can be 'Add', 'Remove' or 'Modify' depending on whether + *comment has been added, removed or modified. + */ +LOK_CALLBACK_COMMENT = 32 } LibreOfficeKitCallbackType; diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index c9c32af..1cd2c05 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -426,6 +426,8 @@ callbackTypeToString (int nType) return "LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED"; case LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED: return "LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED"; +case LOK_CALLBACK_COMMENT: +return "LOK_CALLBACK_COMMENT"; } g_assert(false); return nullptr; @@ -1395,6 +1397,8 @@ callback (gpointer pData) { break; } +case LOK_CALLBACK_COMMENT: +break; default: g_assert(false); break; diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx index 68887aa..97448fd 100644 --- a/sw/inc/PostItMgr.hxx +++ b/sw/inc/PostItMgr.hxx @@ -186,7 +186,7 @@ class SwPostItMgr: public SfxListener sw::sidebarwindows::SwSidebarWin* GetSidebarWin(const SfxBroadcaster* pBroadcaster) const; -voidInsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus); +SwSidebarItem* InsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus); voidRemoveItem( SfxBroadcaster* pBroadcast ); public: diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index d169a89..43b1b55 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -17,11 +17,13 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + #include "PostItMgr.hxx" #include -#include #include +#include #include #include @@ -53,6 +55,7 @@ #include #include #include +#include #include #include @@ -75,6 +78,8 @@ #include #include #include +#include +#include #include "annotsh.hxx" #include "swabstdlg.hxx" @@ -94,37 +99,89 @@ using namespace sw::sidebarwindows; -bool comp_pos(const SwSidebarItem* a, const SwSidebarItem* b) -{ -// sort by anchor position -SwPosition aPosAnchorA = a->GetAnchorPosition(); -SwPosition aPosAnchorB = b->GetAnchorPosition(); +namespace { -bool aAnchorAInFooter = false; -bool aAnchorBInFooter = false; +enum class CommentNotificationType { Add, Remove, Modify }; -// is the anchor placed in Footnote or the Footer? -if( aPosAnchorA.nNode.GetNode().FindFootnoteStartNode() || aPosAnchorA.nNode.GetNode().FindFooterStartNode() ) -aAnchorAInFooter = true; -if( aPosAnchorB.nNode.GetNode().FindFootnoteStartNode() || aPosAnchorB.nNode.GetNode().FindFooterStartNode() ) -aAnchorBInFooter = true; +bool comp_pos(const SwSidebarItem* a, const SwSidebarItem* b) +{ +// sort by anchor position +SwPosition aPosAnchorA = a->GetAnchorPosition(); +SwPosition aPosAnchorB = b->GetAnchorPosition(); -// fdo#34800 -// if AnchorA is in footnote, and AnchorB isn't -// we do not want to change over the position
[Libreoffice-commits] core.git: include/LibreOfficeKit libreofficekit/source sw/inc sw/source
include/LibreOfficeKit/LibreOfficeKitEnums.h | 23 libreofficekit/source/gtk/lokdocview.cxx |6 +++ sw/inc/redline.hxx | 14 ++- sw/source/core/doc/docredln.cxx | 48 +++ 4 files changed, 75 insertions(+), 16 deletions(-) New commits: commit 8f96ab602a9e7cad1215abb693f33824a7b37679 Author: Tor LillqvistDate: Thu Aug 25 13:58:06 2016 +0300 Emit notification to a LibreOfficeKit client also when a redline is modified Work in progress, not all modifications to a redline record cause notifications yet. Change-Id: I01614cd6ede9576e9cc329889fef86342567325f diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index 0805e62..324318c 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -431,6 +431,29 @@ typedef enum */ LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED, +/** + * An entry in the change tracking table has been modified. + * + * The payload example: + * { + * "redline": { + * "action": "Modify", + * "index": "1", + * "author": "Unknown Author", + * "type": "Insert", + * "comment": "", + * "description": "Insert 'abcd'", + * "dateTime": "2016-08-18T13:13:00" + * } + * } + * + * The format is the same as an entry of + * lok::Document::getCommandValues('.uno:AcceptTrackedChanges'), extra + * fields: + * + * - 'action' is 'Modify'. + */ +LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED, } LibreOfficeKitCallbackType; diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 694ea62..fc8d3637 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -424,6 +424,8 @@ callbackTypeToString (int nType) return "LOK_CALLBACK_VIEW_LOCK"; case LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED: return "LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED"; +case LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED: +return "LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED"; } g_assert(false); return nullptr; @@ -1346,6 +1348,10 @@ callback (gpointer pData) { break; } +case LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED: +{ +break; +} default: g_assert(false); break; diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx index 0adc5c9..55d4076 100644 --- a/sw/inc/redline.hxx +++ b/sw/inc/redline.hxx @@ -190,6 +190,7 @@ class SW_DLLPUBLIC SwRangeRedline : public SwPaM void CopyToSection(); void DelCopyOfSection(size_t nMyPos); void MoveFromSection(size_t nMyPos); +void MaybeNotifyModification(); public: SwRangeRedline( RedlineType_t eType, const SwPaM& rPam ); @@ -211,16 +212,9 @@ public: bool IsVisible() const { return bIsVisible; } bool IsDelLastPara() const { return bDelLastPara; } -void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = nullptr ) -{ -if( !pSttPtr ) pSttPtr = Start(); -*pSttPtr = rPos; -} -void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = nullptr ) -{ -if( !pEndPtr ) pEndPtr = End(); -*pEndPtr = rPos; -} +void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = nullptr ); +void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = nullptr ); + /// Do we have a valid selection? bool HasValidRange() const; diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 602b736..8a2e2be 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -57,6 +57,8 @@ using namespace com::sun::star; +enum class RedlineNotification { Add, Remove, Modify }; + #ifdef DBG_UTIL void sw_DebugRedline( const SwDoc* pDoc ) @@ -299,13 +301,15 @@ bool SwExtraRedlineTable::DeleteTableCellRedline( SwDoc* pDoc, const SwTableBox& } /// Emits LOK notification about one addition / removal of a redline item. -static void lcl_RedlineNotification(bool bAdd, size_t nPos, SwRangeRedline* pRedline) +static void lcl_RedlineNotification(RedlineNotification nType, size_t nPos, SwRangeRedline* pRedline) { if (!comphelper::LibreOfficeKit::isActive()) return; boost::property_tree::ptree aRedline; -aRedline.put("action", (bAdd ? "Add" : "Remove")); +aRedline.put("action", (nType == RedlineNotification::Add ? "Add" : +(nType == RedlineNotification::Remove ? "Remove" : + (nType == RedlineNotification::Modify ? "Modify" : "???"; aRedline.put("index", nPos); aRedline.put("author", pRedline->GetAuthorString(1).toUtf8().getStr()); aRedline.put("type",