summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-03-03 14:57:39 +0530
committerPranav Kant <pranavk@collabora.co.uk>2017-03-23 20:29:39 +0530
commitaaffd4536c359c67da201e507264bf78636e66ad (patch)
tree1b20a75867ed95b4fe232018f809bc5c74e30195 /sw
parent98de85d176fe2a8d77ea55e1f972d92722c5c471 (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> (cherry picked from commit e6cca48bc9deb1049f8d501406269b71f91511ca)
Diffstat (limited to 'sw')
-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
6 files changed, 68 insertions, 21 deletions
diff --git a/sw/inc/IDocumentRedlineAccess.hxx b/sw/inc/IDocumentRedlineAccess.hxx
index 757394ded765..5488f7fcd66d 100644
--- a/sw/inc/IDocumentRedlineAccess.hxx
+++ b/sw/inc/IDocumentRedlineAccess.hxx
@@ -80,6 +80,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 03a338e4ed37..0560b41a04c9 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -438,6 +438,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 868fd19e595a..abadabe28084 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, size_t nPos, SwRa
(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 fa82c830c06c..a01a73c902d6 100644
--- a/sw/source/core/inc/unoport.hxx
+++ b/sw/source/core/inc/unoport.hxx
@@ -306,8 +306,6 @@ public:
css::uno::RuntimeException, std::exception) 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 3e38c6b9e8f4..42497ef799e7 100644
--- a/sw/source/core/unocore/unoredline.cxx
+++ b/sw/source/core/unocore/unoredline.cxx
@@ -189,21 +189,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);
@@ -221,7 +206,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;
}
@@ -291,7 +276,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)
{
@@ -331,7 +316,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 b89e6e8bcfda..add15faaf543 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>
@@ -3232,6 +3233,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();