summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-03-03 14:57:39 +0530
committerpranavk <pranavk@collabora.co.uk>2017-03-08 06:44:57 +0000
commite6cca48bc9deb1049f8d501406269b71f91511ca (patch)
treeff2aec2ec271497c0b0f1c844a411f3cd42c0372
parent0531ffaf99941ad1d1a1c79b368c086cd9e64516 (diff)
lok: Do not use UNO for fetching tracked changes
See inline comment for reasons. Also, move the SwRedlineTypeToOUString function as inline to same header file containing redline types. Change-Id: I9b4be4f104c095b2ccd8287d935347c81fd25974 Reviewed-on: https://gerrit.libreoffice.org/34950 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: pranavk <pranavk@collabora.co.uk>
-rw-r--r--desktop/source/lib/init.cxx5
-rw-r--r--sw/inc/IDocumentRedlineAccess.hxx15
-rw-r--r--sw/inc/unotxdoc.hxx2
-rw-r--r--sw/source/core/doc/docredln.cxx2
-rw-r--r--sw/source/core/inc/unoport.hxx2
-rw-r--r--sw/source/core/unocore/unoredline.cxx21
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx47
7 files changed, 72 insertions, 22 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5ba852efccb4..5d0dfc28d688 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2484,7 +2484,10 @@ static char* getTrackedChanges(LibreOfficeKitDocument* pThis)
uno::Reference<document::XRedlinesSupplier> xRedlinesSupplier(pDocument->mxComponent, uno::UNO_QUERY);
std::stringstream aStream;
- if (xRedlinesSupplier.is())
+ // We want positions of the track changes also which is not possible from
+ // UNO. Enable positioning information for text documents only for now, so
+ // construct the tracked changes JSON from inside the sw/, not here using UNO
+ if (doc_getDocumentType(pThis) != LOK_DOCTYPE_TEXT && xRedlinesSupplier.is())
{
uno::Reference<container::XEnumeration> xRedlines = xRedlinesSupplier->getRedlines()->createEnumeration();
boost::property_tree::ptree aRedlines;
diff --git a/sw/inc/IDocumentRedlineAccess.hxx b/sw/inc/IDocumentRedlineAccess.hxx
index 71650325042b..47fab8559d8d 100644
--- a/sw/inc/IDocumentRedlineAccess.hxx
+++ b/sw/inc/IDocumentRedlineAccess.hxx
@@ -82,6 +82,21 @@ namespace nsRedlineType_t
// When larger than 128, flags can be inserted.
const RedlineType_t REDLINE_NO_FLAG_MASK = 0x7F;
const RedlineType_t REDLINE_FORM_AUTOFMT = 0x80;// Can be a flag in RedlineType.
+
+ inline OUString SwRedlineTypeToOUString(RedlineType_t eType)
+ {
+ OUString sRet;
+ switch(eType & nsRedlineType_t::REDLINE_NO_FLAG_MASK)
+ {
+ case nsRedlineType_t::REDLINE_INSERT: sRet = "Insert"; break;
+ case nsRedlineType_t::REDLINE_DELETE: sRet = "Delete"; break;
+ case nsRedlineType_t::REDLINE_FORMAT: sRet = "Format"; break;
+ case nsRedlineType_t::REDLINE_PARAGRAPH_FORMAT: sRet = "ParagraphFormat"; break;
+ case nsRedlineType_t::REDLINE_TABLE: sRet = "TextTable"; break;
+ case nsRedlineType_t::REDLINE_FMTCOLL:sRet = "Style"; break;
+ }
+ return sRet;
+ }
}
class IDocumentRedlineAccess
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index aeb55619e716..8e9e22096596 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -417,6 +417,8 @@ public:
virtual void setClientVisibleArea(const Rectangle& rRectangle) override;
/// @see vcl::ITiledRenderable::getPointer().
virtual Pointer getPointer() override;
+ /// @see vcl::ITiledRenderable::getTrackedChanges().
+ OUString getTrackedChanges() override;
/// @see vcl::ITiledRenderable::getTrackedChangeAuthors().
OUString getTrackedChangeAuthors() override;
/// @see vcl::ITiledRenderable::getPostIts().
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index c9f329bfe721..d6cf1c9584f6 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -315,7 +315,7 @@ static void lcl_RedlineNotification(RedlineNotification nType, SwRedlineTable::s
(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());
+ aRedline.put("type", nsRedlineType_t::SwRedlineTypeToOUString(pRedline->GetRedlineData().GetType()).toUtf8().getStr());
aRedline.put("comment", pRedline->GetRedlineData().GetComment().toUtf8().getStr());
aRedline.put("description", pRedline->GetDescr().toUtf8().getStr());
OUString sDateTime = utl::toISO8601(pRedline->GetRedlineData().GetTimeStamp().GetUNODateTime());
diff --git a/sw/source/core/inc/unoport.hxx b/sw/source/core/inc/unoport.hxx
index 5eed3898698b..539d6b9a5e7e 100644
--- a/sw/source/core/inc/unoport.hxx
+++ b/sw/source/core/inc/unoport.hxx
@@ -303,8 +303,6 @@ public:
const OUString& rPropertyName) override;
};
-OUString SwRedlineTypeToOUString(RedlineType_t eType);
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx
index d1b5b08f1a78..eb153b67b5cc 100644
--- a/sw/source/core/unocore/unoredline.cxx
+++ b/sw/source/core/unocore/unoredline.cxx
@@ -183,21 +183,6 @@ SwXRedlinePortion::~SwXRedlinePortion()
{
}
-OUString SwRedlineTypeToOUString(RedlineType_t eType)
-{
- OUString sRet;
- switch(eType & nsRedlineType_t::REDLINE_NO_FLAG_MASK)
- {
- case nsRedlineType_t::REDLINE_INSERT: sRet = "Insert"; break;
- case nsRedlineType_t::REDLINE_DELETE: sRet = "Delete"; break;
- case nsRedlineType_t::REDLINE_FORMAT: sRet = "Format"; break;
- case nsRedlineType_t::REDLINE_PARAGRAPH_FORMAT: sRet = "ParagraphFormat"; break;
- case nsRedlineType_t::REDLINE_TABLE: sRet = "TextTable"; break;
- case nsRedlineType_t::REDLINE_FMTCOLL:sRet = "Style"; break;
- }
- return sRet;
-}
-
static uno::Sequence<beans::PropertyValue> lcl_GetSuccessorProperties(const SwRangeRedline& rRedline)
{
uno::Sequence<beans::PropertyValue> aValues(4);
@@ -215,7 +200,7 @@ static uno::Sequence<beans::PropertyValue> lcl_GetSuccessorProperties(const SwRa
pValues[2].Name = UNO_NAME_REDLINE_COMMENT;
pValues[2].Value <<= pNext->GetComment();
pValues[3].Name = UNO_NAME_REDLINE_TYPE;
- pValues[3].Value <<= SwRedlineTypeToOUString(pNext->GetType());
+ pValues[3].Value <<= nsRedlineType_t::SwRedlineTypeToOUString(pNext->GetType());
}
return aValues;
}
@@ -284,7 +269,7 @@ uno::Any SwXRedlinePortion::GetPropertyValue( const OUString& rPropertyName, co
aRet <<= const_cast<SwRangeRedline&>(rRedline).GetDescr();
else if(rPropertyName == UNO_NAME_REDLINE_TYPE)
{
- aRet <<= SwRedlineTypeToOUString(rRedline.GetType());
+ aRet <<= nsRedlineType_t::SwRedlineTypeToOUString(rRedline.GetType());
}
else if(rPropertyName == UNO_NAME_REDLINE_SUCCESSOR_DATA)
{
@@ -324,7 +309,7 @@ uno::Sequence< beans::PropertyValue > SwXRedlinePortion::CreateRedlineProperties
pRet[nPropIdx].Name = UNO_NAME_REDLINE_DESCRIPTION;
pRet[nPropIdx++].Value <<= const_cast<SwRangeRedline&>(rRedline).GetDescr();
pRet[nPropIdx].Name = UNO_NAME_REDLINE_TYPE;
- pRet[nPropIdx++].Value <<= SwRedlineTypeToOUString(rRedline.GetType());
+ pRet[nPropIdx++].Value <<= nsRedlineType_t::SwRedlineTypeToOUString(rRedline.GetType());
pRet[nPropIdx].Name = UNO_NAME_REDLINE_IDENTIFIER;
pRet[nPropIdx++].Value <<= OUString::number(
sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(&rRedline) ) );
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 6c7647464d55..66e26a137810 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -144,6 +144,7 @@
#include <svl/stylepool.hxx>
#include <swatrset.hxx>
#include <view.hxx>
+#include <viscrs.hxx>
#include <srcview.hxx>
#include <edtwin.hxx>
#include <swdtflvr.hxx>
@@ -3179,6 +3180,52 @@ Pointer SwXTextDocument::getPointer()
return pWrtShell->GetView().GetEditWin().GetPointer();
}
+OUString SwXTextDocument::getTrackedChanges()
+{
+ const SwRedlineTable& rRedlineTable = pDocShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
+ boost::property_tree::ptree aTrackedChanges;
+ for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i)
+ {
+ boost::property_tree::ptree aTrackedChange;
+ aTrackedChange.put("index", i);
+ aTrackedChange.put("author", rRedlineTable[i]->GetAuthorString(1).toUtf8().getStr());
+ aTrackedChange.put("type", nsRedlineType_t::SwRedlineTypeToOUString(rRedlineTable[i]->GetRedlineData().GetType()).toUtf8().getStr());
+ aTrackedChange.put("comment", rRedlineTable[i]->GetRedlineData().GetComment().toUtf8().getStr());
+ aTrackedChange.put("description", rRedlineTable[i]->GetDescr().toUtf8().getStr());
+ OUString sDateTime = utl::toISO8601(rRedlineTable[i]->GetRedlineData().GetTimeStamp().GetUNODateTime());
+ aTrackedChange.put("dateTime", sDateTime.toUtf8().getStr());
+
+ SwContentNode* pContentNd = rRedlineTable[i]->GetContentNode();
+ SwView* pView = dynamic_cast<SwView*>(SfxViewShell::Current());
+ if (pView && pContentNd)
+ {
+ std::unique_ptr<SwShellCursor> pCursor(new SwShellCursor(pView->GetWrtShell(), *(rRedlineTable[i]->Start()) ));
+ pCursor->SetMark();
+ pCursor->GetMark()->nNode = *pContentNd;
+ pCursor->GetMark()->nContent.Assign(pContentNd, rRedlineTable[i]->End()->nContent.GetIndex());
+
+ pCursor->FillRects();
+
+ SwRects* pRects(pCursor.get());
+ std::vector<OString> aRects;
+ for(SwRect& rNextRect : *pRects)
+ aRects.push_back(rNextRect.SVRect().toString());
+
+ const OString sRects = comphelper::string::join("; ", aRects);
+ aTrackedChange.put("textRange", sRects.getStr());
+ }
+
+ aTrackedChanges.push_back(std::make_pair("", aTrackedChange));
+ }
+
+ boost::property_tree::ptree aTree;
+ aTree.add_child("redlines", aTrackedChanges);
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+
+ return OUString::fromUtf8(aStream.str().c_str());
+}
+
OUString SwXTextDocument::getTrackedChangeAuthors()
{
return SW_MOD()->GetRedlineAuthorInfo();