summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-08-19 16:46:15 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-19 16:51:36 +0200
commit9e310a4705ce956551059040696166aefb2388cb (patch)
tree55ed66cdf30ddcfa03ea44ce7f3555d63b859aa6
parente774d798f6734f3bcc10e74bf641efcce0dedc40 (diff)
sw redlines: expose description as part of the UNO/LOK API
A redline can have a manual comment and also an autogenerated description, like "Insert 'abc'". Expose this later property as well, as it provides useful additional information, especially when the comment property is empty. Change-Id: Id0f0ff62aef58d96b9b6071706c6f5b4a0d74800
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx4
-rw-r--r--desktop/source/lib/init.cxx4
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitEnums.h1
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx7
-rw-r--r--sw/inc/unoprnms.hxx1
-rw-r--r--sw/source/core/doc/docredln.cxx2
-rw-r--r--sw/source/core/unocore/unomapproperties.hxx1
-rw-r--r--sw/source/core/unocore/unoredline.cxx10
8 files changed, 26 insertions, 4 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index b356535e1a4d..d3888ff94021 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1434,6 +1434,10 @@ void DesktopLOKTest::testRedlineWriter()
// Make sure that pressing a key creates exactly one redline.
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aTree.get_child("redlines").size());
+ for (boost::property_tree::ptree::value_type& rRedline : aTree.get_child("redlines"))
+ // This failed with boost::property_tree::ptree_bad_path, as there were no description field.
+ CPPUNIT_ASSERT_EQUAL(std::string("Insert 't'"), rRedline.second.get<std::string>("description"));
+
comphelper::LibreOfficeKit::setActive(false);
}
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index dfad9b293739..79129d74a6b2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1843,6 +1843,10 @@ static char* getTrackedChanges(LibreOfficeKitDocument* pThis)
xRedline->getPropertyValue("RedlineComment") >>= sComment;
aRedline.put("comment", sComment.toUtf8().getStr());
+ OUString sDescription;
+ xRedline->getPropertyValue("RedlineDescription") >>= sDescription;
+ aRedline.put("description", sDescription.toUtf8().getStr());
+
util::DateTime aDateTime;
xRedline->getPropertyValue("RedlineDateTime") >>= aDateTime;
OUString sDateTime = utl::toISO8601(aDateTime);
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 2c3bcabc496c..0805e62145cd 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -417,6 +417,7 @@ typedef enum
* "author": "Unknown Author",
* "type": "Delete",
* "comment": "",
+ * "description": "Delete 'abc'",
* "dateTime": "2016-08-18T12:14:00"
* }
* }
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 5a134d02a599..9bfaa85a8002 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -485,7 +485,7 @@ static void documentRedline(GtkWidget* pButton, gpointer /*pItem*/)
GtkWidget* pContentArea = gtk_dialog_get_content_area(GTK_DIALOG (pDialog));
// Build the table.
- GtkTreeStore* pTreeStore = gtk_tree_store_new(5, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+ GtkTreeStore* pTreeStore = gtk_tree_store_new(6, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
for (const auto& rValue : aTree.get_child("redlines"))
{
GtkTreeIter aTreeIter;
@@ -495,11 +495,12 @@ static void documentRedline(GtkWidget* pButton, gpointer /*pItem*/)
1, rValue.second.get<std::string>("author").c_str(),
2, rValue.second.get<std::string>("type").c_str(),
3, rValue.second.get<std::string>("comment").c_str(),
- 4, rValue.second.get<std::string>("dateTime").c_str(),
+ 4, rValue.second.get<std::string>("description").c_str(),
+ 5, rValue.second.get<std::string>("dateTime").c_str(),
-1);
}
GtkWidget* pTreeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pTreeStore));
- std::vector<std::string> aColumns = {"Index", "Author", "Type", "Comment", "Timestamp"};
+ std::vector<std::string> aColumns = {"Index", "Author", "Type", "Comment", "Description", "Timestamp"};
for (size_t nColumn = 0; nColumn < aColumns.size(); ++nColumn)
{
GtkCellRenderer* pRenderer = gtk_cell_renderer_text_new();
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 0d1322d4be45..c4020c53acf8 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -537,6 +537,7 @@
#define UNO_NAME_REDLINE_AUTHOR "RedlineAuthor"
#define UNO_NAME_REDLINE_DATE_TIME "RedlineDateTime"
#define UNO_NAME_REDLINE_COMMENT "RedlineComment"
+#define UNO_NAME_REDLINE_DESCRIPTION "RedlineDescription"
#define UNO_NAME_REDLINE_TYPE "RedlineType"
#define UNO_NAME_REDLINE_SUCCESSOR_DATA "RedlineSuccessorData"
#define UNO_NAME_REDLINE_IDENTIFIER "RedlineIdentifier"
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index b93a39be749a..602b736a632b 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -310,6 +310,7 @@ static void lcl_RedlineNotification(bool bAdd, size_t nPos, SwRangeRedline* pRed
aRedline.put("author", pRedline->GetAuthorString(1).toUtf8().getStr());
aRedline.put("type", 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());
aRedline.put("dateTime", sDateTime.toUtf8().getStr());
boost::property_tree::ptree aTree;
@@ -1654,6 +1655,7 @@ void SwRangeRedline::dumpAsXml(xmlTextWriterPtr pWriter) const
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("id"), BAD_CAST(OString::number(GetSeqNo()).getStr()));
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("author"), BAD_CAST(SW_MOD()->GetRedlineAuthor(GetAuthor()).toUtf8().getStr()));
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("date"), BAD_CAST(DateTimeToOString(GetTimeStamp()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("descr"), BAD_CAST(const_cast<SwRangeRedline*>(this)->GetDescr().toUtf8().getStr()));
OString sRedlineType;
switch (GetType())
diff --git a/sw/source/core/unocore/unomapproperties.hxx b/sw/source/core/unocore/unomapproperties.hxx
index 1f528f0ba596..c0c6ed936aec 100644
--- a/sw/source/core/unocore/unomapproperties.hxx
+++ b/sw/source/core/unocore/unomapproperties.hxx
@@ -68,6 +68,7 @@
{OUString(UNO_NAME_REDLINE_AUTHOR), 0, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},\
{OUString(UNO_NAME_REDLINE_DATE_TIME), 0, cppu::UnoType<css::util::DateTime>::get(), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},\
{OUString(UNO_NAME_REDLINE_COMMENT), 0, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},\
+ {OUString(UNO_NAME_REDLINE_DESCRIPTION), 0, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID | PropertyAttribute::READONLY, 0}, \
{OUString(UNO_NAME_REDLINE_TYPE), 0, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},\
{OUString(UNO_NAME_REDLINE_SUCCESSOR_DATA), 0, cppu::UnoType< cppu::UnoSequenceType<css::beans::PropertyValue> >::get(), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},\
{OUString(UNO_NAME_REDLINE_IDENTIFIER), 0, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},\
diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx
index dc99aaf2bd91..c6b4fdb24de1 100644
--- a/sw/source/core/unocore/unoredline.cxx
+++ b/sw/source/core/unocore/unoredline.cxx
@@ -287,6 +287,8 @@ uno::Any SwXRedlinePortion::GetPropertyValue( const OUString& rPropertyName, co
}
else if(rPropertyName == UNO_NAME_REDLINE_COMMENT)
aRet <<= rRedline.GetComment();
+ else if(rPropertyName == UNO_NAME_REDLINE_DESCRIPTION)
+ aRet <<= const_cast<SwRangeRedline&>(rRedline).GetDescr();
else if(rPropertyName == UNO_NAME_REDLINE_TYPE)
{
aRet <<= SwRedlineTypeToOUString(rRedline.GetType());
@@ -315,7 +317,7 @@ uno::Any SwXRedlinePortion::GetPropertyValue( const OUString& rPropertyName, co
uno::Sequence< beans::PropertyValue > SwXRedlinePortion::CreateRedlineProperties(
const SwRangeRedline& rRedline, bool bIsStart ) throw()
{
- uno::Sequence< beans::PropertyValue > aRet(11);
+ uno::Sequence< beans::PropertyValue > aRet(12);
const SwRedlineData* pNext = rRedline.GetRedlineData().Next();
beans::PropertyValue* pRet = aRet.getArray();
@@ -326,6 +328,8 @@ uno::Sequence< beans::PropertyValue > SwXRedlinePortion::CreateRedlineProperties
pRet[nPropIdx++].Value <<= rRedline.GetTimeStamp().GetUNODateTime();
pRet[nPropIdx].Name = UNO_NAME_REDLINE_COMMENT;
pRet[nPropIdx++].Value <<= rRedline.GetComment();
+ 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].Name = UNO_NAME_REDLINE_IDENTIFIER;
@@ -401,6 +405,10 @@ void SwXRedline::setPropertyValue( const OUString& rPropertyName, const uno::Any
OUString sTmp; aValue >>= sTmp;
pRedline->SetComment(sTmp);
}
+ else if(rPropertyName == UNO_NAME_REDLINE_DESCRIPTION)
+ {
+ SAL_WARN("sw.uno", "SwXRedline::setPropertyValue: can't set Description");
+ }
else if(rPropertyName == UNO_NAME_REDLINE_TYPE)
{
OSL_FAIL("currently not available");