summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2023-01-17 12:23:44 +0530
committerMiklos Vajna <vmiklos@collabora.com>2023-01-17 14:26:29 +0000
commit5b1f5319fc065eac71267b29472111d81e0dc14e (patch)
treeccad9fef01c67928de6dd4ec16d9503e84ce551a
parentb09b29073f0802cc7e30c9455e2c8d6ac1ea6c63 (diff)
sw: lok: use redline author for saved author fields(2)
Without the fix author fields will expand to "Unknown author" when loading files which have author fields in them. But only update the fields when the first view joins and not for later view joins. online.git does not expect document to be modified just after load, so to avoid this situation clear the document modified flag just after field update. Change-Id: I19253f4c871e2c023d206d2d83b6d694ed5933d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145654 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sw/qa/extras/tiledrendering/data/savedauthorfield.odtbin0 -> 9373 bytes
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx16
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx19
3 files changed, 34 insertions, 1 deletions
diff --git a/sw/qa/extras/tiledrendering/data/savedauthorfield.odt b/sw/qa/extras/tiledrendering/data/savedauthorfield.odt
new file mode 100644
index 000000000000..e4b41d28b92a
--- /dev/null
+++ b/sw/qa/extras/tiledrendering/data/savedauthorfield.odt
Binary files differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 88b4dcc95d7f..3330e419dc8b 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -3791,6 +3791,22 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testAuthorField)
assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", sAuthor);
}
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSavedAuthorField)
+{
+ SwXTextDocument* pXTextDocument = createDoc("savedauthorfield.odt");
+ const OUString sAuthor("XYZ ABCD");
+ uno::Sequence<beans::PropertyValue> aPropertyValues1(comphelper::InitPropertySequence(
+ {
+ {".uno:Author", uno::makeAny(sAuthor)},
+ }));
+ pXTextDocument->initializeForTiledRendering(aPropertyValues1);
+
+ Scheduler::ProcessEventsToIdle();
+
+ xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", sAuthor);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index f91fe5626f1b..78af58de3184 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3570,6 +3570,9 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::
// Disable field shadings: the result would depend on the cursor position.
SwViewOption::SetAppearanceFlag(ViewOptFlags::FieldShadings, false);
+ OUString sOrigAuthor = SW_MOD()->GetRedlineAuthor(SW_MOD()->GetRedlineAuthor());
+ OUString sAuthor;
+
for (const beans::PropertyValue& rValue : rArguments)
{
if (rValue.Name == ".uno:HideWhitespace" && rValue.Value.has<bool>())
@@ -3578,8 +3581,9 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::
SwViewOption::SetAppearanceFlag(ViewOptFlags::Shadow , rValue.Value.get<bool>());
else if (rValue.Name == ".uno:Author" && rValue.Value.has<OUString>())
{
+ sAuthor = rValue.Value.get<OUString>();
// Store the author name in the view.
- pView->SetRedlineAuthor(rValue.Value.get<OUString>());
+ pView->SetRedlineAuthor(sAuthor);
// Let the actual author name pick up the value from the current
// view, which would normally happen only during the next view
// switch.
@@ -3589,6 +3593,19 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::
aViewOption.SetOnlineSpell(rValue.Value.get<bool>());
}
+ if (!sAuthor.isEmpty() && sAuthor != sOrigAuthor)
+ {
+ SwView* pFirstView = static_cast<SwView*>(SfxViewShell::GetFirst());
+ if (pFirstView && SfxViewShell::GetNext(*pFirstView) == nullptr)
+ {
+ if (SwEditShell* pShell = &pFirstView->GetWrtShell())
+ {
+ pShell->SwViewShell::UpdateFields(true);
+ pShell->ResetModified();
+ }
+ }
+ }
+
// Set the initial zoom value to 1; usually it is set in setClientZoom and
// SwViewShell::PaintTile; zoom value is used for chart in place
// editing, see postMouseEvent and setGraphicSelection methods.