Kaydet (Commit) e6cca48b authored tarafından Pranav Kant's avatar Pranav Kant Kaydeden (comit) pranavk

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/34950Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarpranavk <pranavk@collabora.co.uk>
üst 0531ffaf
......@@ -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;
......
......@@ -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
......
......@@ -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().
......
......@@ -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());
......
......@@ -303,8 +303,6 @@ public:
const OUString& rPropertyName) override;
};
OUString SwRedlineTypeToOUString(RedlineType_t eType);
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -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) ) );
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment