diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-03-03 14:57:39 +0530 |
---|---|---|
committer | pranavk <pranavk@collabora.co.uk> | 2017-03-08 06:44:57 +0000 |
commit | e6cca48bc9deb1049f8d501406269b71f91511ca (patch) | |
tree | ff2aec2ec271497c0b0f1c844a411f3cd42c0372 /sw/source/uibase | |
parent | 0531ffaf99941ad1d1a1c79b368c086cd9e64516 (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>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 47 |
1 files changed, 47 insertions, 0 deletions
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(); |