Bug 148979 - Field context menu should have "Update Field" item
Summary: Field context menu should have "Update Field" item
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: TokieSan
URL:
Whiteboard: target:7.6.0
Keywords: difficultyInteresting, easyHack, skillCpp, topicUI
: 152060 (view as bug list)
Depends on:
Blocks: Fields
  Show dependency treegraph
 
Reported: 2022-05-07 20:40 UTC by Eyal Rozenberg
Modified: 2023-06-04 23:08 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eyal Rozenberg 2022-05-07 20:40:57 UTC
When I right-click a field in LO writer, e.g. a cross-reference, there should be a menu item on the context menu for "Update Field" (not all fields, just the right-clicked field).
Comment 1 Eyal Rozenberg 2022-05-07 20:42:18 UTC
I don't think Writer ever used to have that item, but just in case: It's missing with 

Version: 7.4.0.0.alpha0+ / LibreOffice Community
Build ID: d9b33ed6644203141fdb0776c291425c2bc9f5ac
CPU threads: 4; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: en-IL (en_IL); UI: en-US
Comment 2 Heiko Tietze 2022-05-09 09:24:35 UTC
Why do you expect a field not to be up-to-date?
Comment 3 Eyal Rozenberg 2022-05-09 10:09:11 UTC
(In reply to Heiko Tietze from comment #2)
> Why do you expect a field not to be up-to-date?

Because a field isn't necessarily automatically up-to-date. Or - are you saying if that happens, then it's a bug?
Comment 4 Heiko Tietze 2022-05-09 14:36:23 UTC
(In reply to Eyal Rozenberg from comment #3)
> are you saying if that happens, then it's a bug?

I don't see a reason why fields cannot show the most recent content. Miklos, what do you think?
Comment 5 Miklos Vajna 2022-05-10 07:18:42 UTC
Not updating all fields automatically has a few benefits:

1) updating all these fields can take a bit of time for large documents, so doing it on every keypress would be seen as a problem by some users (Writer could be too slow to be usable)

2) we could also have code to track the dependencies of all fields (similar to e.g. what Calc does), not having that code makes the codebase simpler

3) there is not much pressure on us to do such auto-updates in all cases, e.g. Word doesn't update fields even on file load

So given that users learned to live with not auto-updating fields, this allows a bit simpler and faster code. That being said, we do auto-update a few fields, e.g. moving a page number field to a next page auto-updates it.

On the other hand, users learned that hand-editing a generated ToC is possible, and if we take that away, they can see that as a regression.

With these in mind, completely eliminating the explicit field update doesn't sound good.

Adding a possibly to explicitly update an individual field makes sense to me.
Comment 6 Heiko Tietze 2022-05-10 07:49:51 UTC
So let's make it an interesting easyhack, guess the prototype would be ImpEditEngine::UpdateFields().
Comment 7 Heiko Tietze 2022-11-16 07:52:01 UTC
*** Bug 152060 has been marked as a duplicate of this bug. ***
Comment 8 TokieSan 2023-04-13 13:11:12 UTC
I have been working on this bug with the appraoch of adding the option to update fields in a selected range and currently wrote a possible implementation for  a ImpEditEngine::UpdateSelectedField() function that does so. However, adding a new element to the context menu looks like much work. I believe it will need updating numerous files? If someone can help regarding how to actually add the element to the context menu & relevant files (even relevant docs) I would appreciate it.
Comment 9 Buovjaga 2023-04-13 15:03:05 UTC
(In reply to TokieSan from comment #8)
> I have been working on this bug with the appraoch of adding the option to
> update fields in a selected range and currently wrote a possible
> implementation for  a ImpEditEngine::UpdateSelectedField() function that
> does so. However, adding a new element to the context menu looks like much
> work. I believe it will need updating numerous files? If someone can help
> regarding how to actually add the element to the context menu & relevant
> files (even relevant docs) I would appreciate it.

Did you try grepping through the commit history for changes that add stuff to a context menu?
Comment 10 Heiko Tietze 2023-04-13 15:06:05 UTC
(In reply to TokieSan from comment #8)
> However, adding a new element to the context menu looks like much work.

It isn't. AT least if you have a UNO command it's just adding this to the XML defintion. A UNO command is not rocket science but involves some files. Check this blog post https://dev.blog.documentfoundation.org/2022/02/23/adding-a-new-uno-command/
Comment 11 Commit Notification 2023-05-15 06:57:35 UTC
TokieSan committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/627a601d1fcea0b3198654756d351b0b81600b49

tdf#148979 Added option to update selected field

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.