summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2016-08-25 13:58:06 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-30 09:46:57 +0200
commitdea74fbbe14e04968a215ffcf2acb54ec24b708e (patch)
treef978470627e423ffc980072c5f8f5589fc8f57a7
parent756c4ae5dcb948d6e675287e322720ab890c3e6b (diff)
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. (cherry picked from commit 8f96ab602a9e7cad1215abb693f33824a7b37679) Conflicts: sw/source/core/doc/docredln.cxx Change-Id: I01614cd6ede9576e9cc329889fef86342567325f
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitEnums.h23
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx6
-rw-r--r--sw/inc/redline.hxx14
-rw-r--r--sw/source/core/doc/docredln.cxx48
4 files changed, 75 insertions, 16 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 0805e62145cd..324318c357d8 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 3c8640f19ea5..2e5431c2bd5e 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -419,6 +419,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;
@@ -1330,6 +1332,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 72d590928201..b30e631a0c09 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -192,6 +192,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 );
@@ -213,16 +214,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 90c68750362a..99cd56658160 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", SwRedlineTypeToOUString(pRedline->GetRedlineData().GetType()).toUtf8().getStr());
@@ -322,7 +326,7 @@ static void lcl_RedlineNotification(bool bAdd, size_t nPos, SwRangeRedline* pRed
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED, aPayload.c_str());
+ pViewShell->libreOfficeKitViewCallback(nType == RedlineNotification::Modify ? LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED : LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED, aPayload.c_str());
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
@@ -334,7 +338,7 @@ bool SwRedlineTable::Insert( SwRangeRedline* p, bool bIns )
{
std::pair<vector_type::const_iterator, bool> rv = maVector.insert( p );
size_t nP = rv.first - begin();
- lcl_RedlineNotification(/*bAdd=*/true, nP, p);
+ lcl_RedlineNotification(RedlineNotification::Add, nP, p);
p->CallDisplayFunc(0, nP);
return rv.second;
}
@@ -502,7 +506,7 @@ bool SwRedlineTable::Remove( const SwRangeRedline* p )
void SwRedlineTable::Remove( sal_uInt16 nP )
{
- lcl_RedlineNotification(/*bAdd=*/false, nP, maVector[nP]);
+ lcl_RedlineNotification(RedlineNotification::Remove, nP, maVector[nP]);
SwDoc* pDoc = nullptr;
if( !nP && 1 == size() )
pDoc = maVector.front()->GetDoc();
@@ -529,7 +533,7 @@ void SwRedlineTable::DeleteAndDestroy( sal_uInt16 nP, sal_uInt16 nL )
size_t nCount = 0;
for( vector_type::const_iterator it = maVector.begin() + nP; it != maVector.begin() + nP + nL; ++it )
{
- lcl_RedlineNotification(/*bAdd=*/false, nP + nCount, *it);
+ lcl_RedlineNotification(RedlineNotification::Remove, nP + nCount, *it);
delete *it;
++nCount;
}
@@ -952,6 +956,38 @@ SwRangeRedline::~SwRangeRedline()
delete pRedlineData;
}
+void SwRangeRedline::MaybeNotifyModification()
+{
+ if (!comphelper::LibreOfficeKit::isActive())
+ return;
+
+ const SwRedlineTable& rRedTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
+ for (SwRedlineTable::size_type i = 0; i < rRedTable.size(); ++i)
+ {
+ if (rRedTable[i] == this)
+ {
+ lcl_RedlineNotification(RedlineNotification::Modify, i, this);
+ break;
+ }
+ }
+}
+
+void SwRangeRedline::SetStart( const SwPosition& rPos, SwPosition* pSttPtr )
+{
+ if( !pSttPtr ) pSttPtr = Start();
+ *pSttPtr = rPos;
+
+ MaybeNotifyModification();
+}
+
+void SwRangeRedline::SetEnd( const SwPosition& rPos, SwPosition* pEndPtr )
+{
+ if( !pEndPtr ) pEndPtr = End();
+ *pEndPtr = rPos;
+
+ MaybeNotifyModification();
+}
+
/// Do we have a valid Selection?
bool SwRangeRedline::HasValidRange() const
{