[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - 4 commits - include/LibreOfficeKit libreofficekit/qa libreofficekit/source svl/source sw/inc sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Aug 19 09:03:42 UTC 2016
include/LibreOfficeKit/LibreOfficeKitGtk.h | 4 +-
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 34 +++++++++++++++++---
libreofficekit/source/gtk/lokdocview.cxx | 5 +-
svl/source/undo/undo.cxx | 6 ++-
sw/inc/view.hxx | 2 +
sw/qa/extras/tiledrendering/tiledrendering.cxx | 32 ++++++++++++++++++
sw/qa/extras/uiwriter/uiwriter.cxx | 30 +++++++++++++++++
sw/source/uibase/app/docsh.cxx | 7 ++++
sw/source/uibase/inc/uivwimp.hxx | 3 +
sw/source/uibase/uiview/viewprt.cxx | 11 ++++++
sw/source/uibase/uiview/viewstat.cxx | 9 +++--
sw/source/uibase/uno/unotxdoc.cxx | 9 +++++
12 files changed, 140 insertions(+), 12 deletions(-)
New commits:
commit 787c1a5e777f891bc0ffade69560fad09d0e8677
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Aug 18 13:37:42 2016 +0200
sw: fix accepting/rejecting a change by index when cursor is not at a redline
When there is no index, then the cursor position is used to find out
which redline to accept/reject. LOK uses the index parameter instead, so
there never disable the command.
Change-Id: Icbe0905e4ebd170c6f33fe383cd3042d812a2eb0
(cherry picked from commit b6011f07254f8003929320ad842d8d09daca0e09)
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 0111948..8cc2977 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -68,6 +68,7 @@ public:
void testUndoRepairDispatch();
void testShapeTextUndoShells();
void testShapeTextUndoGroupShells();
+ void testTrackChanges();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -100,6 +101,7 @@ public:
CPPUNIT_TEST(testUndoRepairDispatch);
CPPUNIT_TEST(testShapeTextUndoShells);
CPPUNIT_TEST(testShapeTextUndoGroupShells);
+ CPPUNIT_TEST(testTrackChanges);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1138,6 +1140,36 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
comphelper::LibreOfficeKit::setActive(false);
}
+void SwTiledRenderingTest::testTrackChanges()
+{
+ // Load a document.
+ comphelper::LibreOfficeKit::setActive();
+ SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+
+ // Turn on trak changes, type "zzz" at the end, and move to the start.
+ uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
+ xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true));
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ pWrtShell->EndDoc();
+ pWrtShell->Insert("zzz");
+ pWrtShell->SttDoc();
+
+ // Reject the change by index, while the cursor does not cover the tracked change.
+ uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+ {
+ {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(0))}
+ }));
+ comphelper::dispatchCommand(".uno:RejectTrackedChange", aPropertyValues);
+ Scheduler::ProcessEventsToIdle();
+
+ // Assert that the reject was performed.
+ SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
+ // This was 'Aaa bbb.zzz', the change wasn't rejected.
+ CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb."), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx
index c37b8d7..5ca0ffc 100644
--- a/sw/source/uibase/uiview/viewstat.cxx
+++ b/sw/source/uibase/uiview/viewstat.cxx
@@ -52,6 +52,7 @@
#include <globdoc.hxx>
#include <svl/stritem.hxx>
#include <unotools/moduleoptions.hxx>
+#include <comphelper/lok.hxx>
#include <svl/visitem.hxx>
#include <redline.hxx>
#include <docary.hxx>
@@ -275,8 +276,10 @@ void SwView::GetState(SfxItemSet &rSet)
SwPaM *pCursor = m_pWrtShell->GetCursor();
if (GetDocShell()->HasChangeRecordProtection())
rSet.DisableItem(nWhich);
- else if (pCursor->HasMark())
- { // If the selection does not contain redlines, disable accepting/rejecting changes.
+ else if (pCursor->HasMark() && !comphelper::LibreOfficeKit::isActive())
+ {
+ // If the selection does not contain redlines, disable accepting/rejecting changes.
+ // Though LibreOfficeKit wants to handle changes by index, so always allow there.
sal_uInt16 index = 0;
const SwRedlineTable& table = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
const SwRangeRedline* redline = table.FindAtPosition( *pCursor->Start(), index );
@@ -299,7 +302,7 @@ void SwView::GetState(SfxItemSet &rSet)
if( redline == nullptr )
rSet.DisableItem(nWhich);
}
- else
+ else if (!comphelper::LibreOfficeKit::isActive())
{
// If the cursor position isn't on a redline, disable
// accepting/rejecting changes.
commit 1be71c6e6aa4bb6506674220652163fbf0172935
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Aug 18 10:07:51 2016 +0200
gtktiledviewer: specify author name when calling initializeForRendering()
Open two views, and type into both of them when a Writer doc with
redlining enabled is open: the manage changes dialog now shows how the
correct author is used when creating the redline items.
Change-Id: I48fb90301bfcc04b06d5be5544324ca76fe7b3d7
(cherry picked from commit f2afe318ce800c1b301f7e1aef769194aa676b12)
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index fc7cec1..cb96f20 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -75,10 +75,12 @@ GtkWidget* lok_doc_view_new_from_user_profile (const gchar*
/**
* lok_doc_view_new_from_widget:
* @pDocView: The #LOKDocView instance
+ * @pRenderingArguments: (nullable): lok::Document::initializeForRendering() arguments.
*
* Returns: (transfer none): The #LOKDocView widget instance.
*/
-GtkWidget* lok_doc_view_new_from_widget (LOKDocView* pDocView);
+GtkWidget* lok_doc_view_new_from_widget (LOKDocView* pDocView,
+ const gchar* pRenderingArguments);
/**
* lok_doc_view_open_document:
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 2b3090e..9e369f4 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -136,7 +136,10 @@ public:
std::shared_ptr<TiledRowColumnBar> m_pRowBar;
std::shared_ptr<TiledRowColumnBar> m_pColumnBar;
std::shared_ptr<TiledCornerButton> m_pCornerButton;
+ /// Author string, used for comment insertion.
std::string m_aAuthor;
+ /// Rendering arguments, which are the same for all views.
+ boost::property_tree::ptree m_aRenderingArguments;
TiledWindow()
: m_pDocView(nullptr),
@@ -174,8 +177,6 @@ public:
m_pFindbarLabel(nullptr),
m_bFindAll(false)
{
- struct passwd* pPasswd = getpwuid(getuid());
- m_aAuthor = std::string(pPasswd->pw_gecos);
}
};
@@ -198,6 +199,14 @@ static TiledWindow& lcl_getTiledWindow(GtkWidget* pWidget)
return g_aWindows[pToplevel];
}
+/// Generate an author string for multiple views.
+static std::string getNextAuthor()
+{
+ static int nCounter = 0;
+ struct passwd* pPasswd = getpwuid(getuid());
+ return std::string(pPasswd->pw_gecos) + " #" + std::to_string(++nCounter);
+}
+
TiledRowColumnBar::TiledRowColumnBar(TiledBarType eType)
: m_pDrawingArea(gtk_drawing_area_new()),
m_nSizePixel(0),
@@ -841,9 +850,19 @@ static void registerSelectorHandlers(TiledWindow& rWindow)
static void createView(GtkWidget* pButton, gpointer /*pItem*/)
{
TiledWindow& rWindow = lcl_getTiledWindow(pButton);
- GtkWidget* pDocView = lok_doc_view_new_from_widget(LOK_DOC_VIEW(rWindow.m_pDocView));
+
+ boost::property_tree::ptree aTree = rWindow.m_aRenderingArguments;
+ std::string aAuthor = getNextAuthor();
+ aTree.put(boost::property_tree::ptree::path_type(".uno:Author/type", '/'), "string");
+ aTree.put(boost::property_tree::ptree::path_type(".uno:Author/value", '/'), aAuthor);
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+ std::string aArguments = aStream.str();
+
+ GtkWidget* pDocView = lok_doc_view_new_from_widget(LOK_DOC_VIEW(rWindow.m_pDocView), aArguments.c_str());
TiledWindow& rNewWindow = setupWidgetAndCreateWindow(pDocView);
+ rNewWindow.m_aAuthor = aAuthor;
// Hide the unused progress bar.
gtk_widget_show_all(rNewWindow.m_pStatusBar);
gtk_widget_hide(rNewWindow.m_pProgressBar);
@@ -866,7 +885,7 @@ static void createModelAndView(const char* pLOPath, const char* pDocPath, const
const gchar* pUserProfile = aUserProfile.empty() ? nullptr : aUserProfile.c_str();
GtkWidget* pDocView = lok_doc_view_new_from_user_profile(pLOPath, pUserProfile, nullptr, nullptr);
- setupWidgetAndCreateWindow(pDocView);
+ TiledWindow& rWindow = setupWidgetAndCreateWindow(pDocView);
boost::property_tree::ptree aTree;
for (size_t i = 0; i < rArguments.size(); ++i)
@@ -892,6 +911,13 @@ static void createModelAndView(const char* pLOPath, const char* pDocPath, const
}
}
+ // Save rendering arguments for views which are created later.
+ rWindow.m_aRenderingArguments = aTree;
+
+ rWindow.m_aAuthor = getNextAuthor();
+ aTree.put(boost::property_tree::ptree::path_type(".uno:Author/type", '/'), "string");
+ aTree.put(boost::property_tree::ptree::path_type(".uno:Author/value", '/'), rWindow.m_aAuthor);
+
std::stringstream aStream;
boost::property_tree::write_json(aStream, aTree);
std::string aArguments = aStream.str();
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index e5ac6c4..f3dbc6a 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -3001,7 +3001,8 @@ lok_doc_view_new_from_user_profile (const gchar* pPath, const gchar* pUserProfil
nullptr));
}
-SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new_from_widget(LOKDocView* pOldLOKDocView)
+SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new_from_widget(LOKDocView* pOldLOKDocView,
+ const gchar* pRenderingArguments)
{
LOKDocViewPrivate& pOldPriv = getPrivate(pOldLOKDocView);
GtkWidget* pNewDocView = GTK_WIDGET(g_initable_new(LOK_TYPE_DOC_VIEW, /*cancellable=*/nullptr, /*error=*/nullptr,
@@ -3019,7 +3020,7 @@ SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new_from_widget(LOKDocView* pOldLOK
// Store the view id only later in postDocumentLoad(), as
// initializeForRendering() changes the id in Impress.
pDocument->pClass->createView(pDocument);
- pNewPriv->m_aRenderingArguments = pOldPriv->m_aRenderingArguments;
+ pNewPriv->m_aRenderingArguments = pRenderingArguments;
postDocumentLoad(pNewDocView);
return pNewDocView;
commit fd590397606e944e9a2974a2c62759436a5a5b20
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Aug 18 10:01:32 2016 +0200
sw redlining: support per-view authors
In case there are multiple SwView instances and SetRedlineAuthor() is
called with a non-empty string on them, switching views will keep the
SwModule redline author string up to date as expected.
(cherry picked from commit cb9362faad9fe702031c5e657a31b1963ad4d374)
Conflicts:
sw/source/uibase/uno/unotxdoc.cxx
Change-Id: I363221049dbacd67d7c8f4ff3e778f8032a3bc43
diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index ff40f2c..acaff3e 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -653,6 +653,8 @@ public:
int getPart() const override;
/// See SfxViewShell::dumpAsXml().
void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
+ void SetRedlineAuthor(const OUString& rAuthor);
+ const OUString& GetRedlineAuthor();
};
inline long SwView::GetXScroll() const
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index b6838bd..edc8e6b 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -189,6 +189,7 @@ public:
void testTdf84695();
void testClassificationPaste();
void testRedlineParam();
+ void testRedlineViewAuthor();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -283,6 +284,7 @@ public:
CPPUNIT_TEST(testTdf84695);
CPPUNIT_TEST(testClassificationPaste);
CPPUNIT_TEST(testRedlineParam);
+ CPPUNIT_TEST(testRedlineViewAuthor);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3294,6 +3296,34 @@ void SwUiWriterTest::testRedlineParam()
CPPUNIT_ASSERT_EQUAL(OUString("aaamiddle"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
}
+void SwUiWriterTest::testRedlineViewAuthor()
+{
+ // Test that setting an author at an SwView level has effect.
+
+ // Create a document with minimal content.
+ SwDoc* pDoc = createDoc();
+ SwDocShell* pDocShell = pDoc->GetDocShell();
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ pWrtShell->Insert("middle");
+ SwView* pView = pDocShell->GetView();
+ const OUString aAuthor("A U. Thor");
+ pView->SetRedlineAuthor(aAuthor);
+ pDocShell->SetView(pView);
+
+ // Turn on track changes, and add changes to the start of the document.
+ uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
+ xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true));
+ pWrtShell->SttDoc();
+ pWrtShell->Insert("aaa");
+
+ // Now assert that SwView::SetRedlineAuthor() had an effect.
+ const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rTable.size());
+ SwRangeRedline* pRedline = rTable[0];
+ // This was 'Unknown Author' instead of 'A U. Thor'.
+ CPPUNIT_ASSERT_EQUAL(aAuthor, pRedline->GetAuthorString());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index e112b71..14d8cd8 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -1101,7 +1101,14 @@ void SwDocShell::SetView(SwView* pVw)
SetViewShell_Impl(pVw);
m_pView = pVw;
if (m_pView)
+ {
m_pWrtShell = &m_pView->GetWrtShell();
+
+ // Set view-specific redline author.
+ const OUString& rRedlineAuthor = m_pView->GetRedlineAuthor();
+ if (!rRedlineAuthor.isEmpty())
+ SW_MOD()->SetRedlineAuthor(m_pView->GetRedlineAuthor());
+ }
else
m_pWrtShell = nullptr;
}
diff --git a/sw/source/uibase/inc/uivwimp.hxx b/sw/source/uibase/inc/uivwimp.hxx
index 7713246..6fe798b 100644
--- a/sw/source/uibase/inc/uivwimp.hxx
+++ b/sw/source/uibase/inc/uivwimp.hxx
@@ -120,6 +120,9 @@ class SwView_Impl
bool m_bEditingPositionSet;
public:
+ /// Redline author that's specific to this view.
+ OUString m_sRedlineAuthor;
+
SwView_Impl(SwView* pShell);
~SwView_Impl();
diff --git a/sw/source/uibase/uiview/viewprt.cxx b/sw/source/uibase/uiview/viewprt.cxx
index ddcefec..00f0f5b 100644
--- a/sw/source/uibase/uiview/viewprt.cxx
+++ b/sw/source/uibase/uiview/viewprt.cxx
@@ -65,6 +65,7 @@
#include <svl/slstitm.hxx>
#include <unomid.h>
+#include <uivwimp.hxx>
using namespace ::com::sun::star;
@@ -268,6 +269,16 @@ void SwView::dumpAsXml(xmlTextWriterPtr pWriter) const
xmlTextWriterEndElement(pWriter);
}
+void SwView::SetRedlineAuthor(const OUString& rAuthor)
+{
+ m_pViewImpl->m_sRedlineAuthor = rAuthor;
+}
+
+const OUString& SwView::GetRedlineAuthor()
+{
+ return m_pViewImpl->m_sRedlineAuthor;
+}
+
// Create page printer/additions for SwView and SwPagePreview
VclPtr<SfxTabPage> CreatePrintOptionsPage( vcl::Window *pParent,
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index a37764a..1e10d09 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3250,6 +3250,15 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::
aViewOption.SetHideWhitespaceMode(rValue.Value.get<bool>());
else if (rValue.Name == ".uno:ShowBorderShadow" && rValue.Value.has<bool>())
SwViewOption::SetAppearanceFlag(VIEWOPT_SHADOW , rValue.Value.get<bool>());
+ else if (rValue.Name == ".uno:Author" && rValue.Value.has<OUString>())
+ {
+ // Store the author name in the view.
+ pView->SetRedlineAuthor(rValue.Value.get<OUString>());
+ // Let the actual author name pick up the value from the current
+ // view, which would normally happen only during the next view
+ // switch.
+ pDocShell->SetView(pView);
+ }
}
pViewShell->ApplyViewOptions(aViewOption);
commit c57b7875b4f725187faf113da6d563a9ea43164c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Aug 18 08:19:20 2016 +0200
svl: no need to iterate in reverse order in GetRedoActionsInfo()
We have random access to the array after all, so the non-reverse order
is OK as well, and it's more readable.
Change-Id: I966a56ae2e161d95f56927be1b2a9f9162d0f7bb
Reviewed-on: https://gerrit.libreoffice.org/28204
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit 19eab7b79c13edc657f4e3f380889ed0206357bd)
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index a9c50b6..f9ed3a9 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -1364,9 +1364,11 @@ OUString SfxUndoManager::GetRedoActionsInfo() const
{
boost::property_tree::ptree aActions;
const SfxUndoArray* pUndoArray = m_xData->pActUndoArray;
- for (size_t i = GetRedoActionCount(); i > 0; --i)
+ size_t nCount = GetRedoActionCount();
+ for (size_t i = 0; i < nCount; ++i)
{
- boost::property_tree::ptree aAction = lcl_ActionToJson(i - 1, pUndoArray->aUndoActions[pUndoArray->nCurUndoAction - 1 + i].pAction);
+ size_t nIndex = nCount - i - 1;
+ boost::property_tree::ptree aAction = lcl_ActionToJson(nIndex, pUndoArray->aUndoActions[pUndoArray->nCurUndoAction + nIndex].pAction);
aActions.push_back(std::make_pair("", aAction));
}
More information about the Libreoffice-commits
mailing list