sw: lok: use redline author for saved author fields
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. Change-Id: I4ac3b25349b8057812c45dc8148f8b3fc3b7ca1e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145317 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
parent
6c5c33a827
commit
d4760b5d4b
3 changed files with 31 additions and 1 deletions
BIN
sw/qa/extras/tiledrendering/data/savedauthorfield.odt
Normal file
BIN
sw/qa/extras/tiledrendering/data/savedauthorfield.odt
Normal file
Binary file not shown.
|
@ -3831,6 +3831,22 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testAuthorField)
|
|||
assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion[1]/SwLineLayout[1]/SwFieldPortion[1]", "expand", 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::Any(sAuthor)},
|
||||
}));
|
||||
pXTextDocument->initializeForTiledRendering(aPropertyValues1);
|
||||
|
||||
Scheduler::ProcessEventsToIdle();
|
||||
|
||||
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
|
||||
assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion[1]/SwLineLayout[1]/SwFieldPortion[1]", "expand", sAuthor);
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -3568,6 +3568,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>())
|
||||
|
@ -3576,8 +3579,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.
|
||||
|
@ -3587,6 +3591,16 @@ 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 (SwViewShell* pShell = &pFirstView->GetWrtShell())
|
||||
pShell->UpdateFields(true);
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
|
Loading…
Reference in a new issue