Save As of a template damaged document linking?

Status major update
Template link in document is back to its being-functional if to enable the attribute
“Apply user data” in template properties.
I believe to had modified this setting as well as “save preview image with this document” once past document creation from template.
Is it a mistake in Writer usage rather than a Writer bug for template-linking to stop be functional when “Apply user data” is disabled in template properties? No idea on my side if it is the fact of carrying out modification this kind past document creation, or the fact of this attribute disablement the root-cause of problem addressed this discussion.
End of status update

Working with template and a number of .odt files, Writer 24.2.7.2.
Template is used only to carry styles; except for one blank paragraph, one field in footer (page number) it transports no content. All actual purposes of this template are placed in styles.

Recently I did Save As… of template (an open one yet active in document linking) to new .ott file. The intention was to have one further template for other purposes however not starting from scratch.
Eventually it was the operation which destroyed the link template to derived document - I make this statement because style modifications in template no more trigger take-over changes prompt on document reload.
Possibly I should had used Save a Copy … instead.

Can anyone confirm the above cause-result relation? If relation is true, any simple means exist to repair?
I remember from past that Templatechanger was not effective under certain but unknown conditions to make the link template-document working again.

EDIT
Templatechanger didn’t unfortunately restored the link template-document to working state.

Do you work strictly with document template management or via the file manager?
You should describe these individual steps in detail?
Do you have a backup of your user profile?
Please also state your operating system. Thank you.

Template Management of Writer only. Former Template is still registered to Writer template management. Also the new template created using Save As… is registered to Writer template management.

Version: 24.2.7.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 2; OS: Linux 6.6; UI render: default; VCL: gtk3
Locale: de-DE (en_US.utf8); UI: en-US
24.2.7-2
Calc: threaded

Proceeded in following sequence
Have a template and a number of derived documents.
Custom templates path is registered with Writer Tools > Options > LibreOffice > Paths
Template used is stored to path as above.
This is custom template.
Work on documents.
Have all of them open in Writer.
Do Save As of open template; before storing create a subfolder of custom templates path: complete Save As by saving to this sub-folder
Continue working on documents - this step eventually didn’t took place (don’t remember any more)
Do a modification of template file as original (the template created by Save As is not intended for use in this context)
Save template modification to disk.
Reload document > style changes prompt doesn’t happen.

1 Like

(Probably relevant)
The file you saved as a template (.ott) somewhere: did you also import it with the template manager into your profile?

Depending on how you opened your template leads to a new template or standard text document.

If you want a template, you must open it with File>Templates>Edit Template. Then File>Save updates the template. File>Save as creates a new template but does not register it. File>Templates>Save as Template gives the opportunity to change the name (creating a new template) and simultaneously to register it.

Double-clicking on a template icon create a new document from the template but does not keep the link to the template.

File>New>Template creates a new document from the template and keeps the link with it. File>Save xxx saves a standard text document.

Anytime, you can create a new template from the current contents of the active document with File>Templates>Save as Template.


===


The template upon which the document is based is reported by File>Properties. Unfortunately, only the filename is given, not the directory.

I am not aware of cases where TemplateChanger did not complete its job. You may meet temporary difficulties. Then, assign a completely irrelevant template, quit TemplateChanger, reenter it and assign the correct template.

1 Like

The DocumnetProperties know the URL of the template (if it is a managed template). It just isn’t shown in the respective dialog.
The following user code will show it:

Sub templateURL_show(Optional pDoc As Object)
If IsMissing(pDoc) Then pDoc = ThisComponent
theProps = pDoc.DocumentProperties
MsgBox(theProps.TemplateURL)
End Sub

A document created from a not managed template in any directory (by DblClick) will neither know the full URL nor the name of that template.

1 Like

Thank you to you and @ajlittoz for all tips so far. Regarding user code proposed, is it to be placed in a macro to run and try?

Proceeded that time in following sequence.
Create new document based on Writer’s default/stock template, File > New > Text Document
Save to disk as template, .ott
Create a low number of documents using this template
Work on documents, work on template - a session of duration of a number of days
If my understanding is only correct, the import of template in template manager should in this case be not needed; maybe, in contrary, interfering with present template.

In this particular case the link template to document worked a number of days pretty well. It became broken recently.

Latest attempt to fix doesn’t help as well:
Disconnect document from template using TemplateChanger
Make backup of the critical template at file system location the Writer was not informed about.
Unregister template the former one and the newer one.
Unregister the custom template category.
Make sure template files are not present on custom templates path.
In Writer let’s open template backup then store as template at custom templates path - for this to work the backup needed first to be placed manually on custom templates path, otherwise no visibility
in template manager.
Use TemplateChanger to connected document again with template recreated.
Do the test of style modification in template then the test of prompt for changes take-over when document gets reloaded.

One further derived document is affected as well, possibly all of those remaining are.

What myself tried before was the simple disconnect from template and connect again.
What I will try as next is @ajlittoz’s proposal to connect document temporarily to some irrelevant template.

I afraid this will not suffice when multiple derived documents are affected.

EDIT
Proposed user code helped to verify that in document the path of template is as expected - leads to intended template file and its intended location.

EDIT 2
It seems to be something at template management level. I dare to do this statement because if to create now a new document from this template the style modification doesn’t propagate to document too.
Would it be some dirt thing the document level while the remaining levels/areas being clean (I mean mainly template management right now) I would expect the link template-document to work properly for document created right now.

EDIT 3
For the prompt “caution, styles in template have been modified. do you want to take over modifications?” - is it expected to pop-up unconditionally on document reopening, reloading? I mean it in the sense how should my test look like. Can I test with paragraph style used in no paragraph of derived document? I mean unused however visible in Styles manager/viewer side bar. Writer Guide seems to be silent regarding this question.

EDIT 4
I encountered one document derived from same template but generating the prompt on document reload. That means that problem is not reproducible in this case. No more true. Became broken after repeated test.

EDIT 5
Is it eventually a bad idea to use in template Writer’s function document Versions? Two were created recent (up to) 32 hours.

EDIT 6
How are handled those modifications of paragraph style conducted by mistake in document instead of template? Will modification template level overwrite it when style name is identical and user gives agreement when the prompt pops up on document reopen/reload?

EDIT 7
There must be something dirty at template management/registration level. Why my conclusion? Answer: Last minutes following was conducted. Menu Styles > Load Styles from Template > Load from registered template (From File … not using) > select template the document is considered to be linked to > checked are
Paragraph and Character
Lists
Page
Overwrite
a click on OK > Save to disk > check that paragraph style I use to test > document and template are not in sync regarding that attribute of paragraph style in that one paragraph style I use to test. Should the use of Load Styles from Template complete with some sort of execution summary pop-up? None happens here.

Eventually the problem nature is that Load Styles and template linking are not effective when document got once a style modification document-locally. No idea how wrong this understanding is.

EDIT 8
Custom templates path (registered one in LO Options, Paths) has a whitespace in path string. How bad may it be? User code presented by @Lupp is coding whitspace to “%20” in output message.

EDIT 9
Fortunately, the conduction of mere “update of document from changed template” results in no permanent changes in document file. A subsequent yet explicit/manual save to disk is necessary to make this update permanent. It raised the Aha!-effect on my side some day in the past because, as far as Writer documentation is concerned, the behaviour is not presented to have this form. Eventually it can help in further troubleshooting here as one of derived documents has the link to template still in functional state. My current feeling is, that in case of that one document the save of document update due to modifications in template will render its linking to template non-functional.

Template change detection relies on a implicit assumption: organisation of your documents/directories in your computer does not change over the life of your work with the document and template. The link from the document to the template is recorded as a relative path. If you change the relative position on one to the other, such as e.g. moving the document from one directory to another one in the system file browser, you break the link. TemplateChanger must be used to restore it.

Don’t mix “Load styles from files” with template management. This feature is offered as a simplified function (without all the automatic updates) for people not wanting to use templates. Though it should be harmless, you may get confused (you, the user, not Writer but Writer could take unexpected decisions) or pollute your style dictionary with useless styles.

As always, using an advanced feature requires some thinking and task preparation. If you run blind into it, you’ll inevitably bump into incorrectly configured settings and things will go awry. So, sit down, stop using the computer and scribble notes about what you want to do. Once your ideas are sorted out and made minimal and consistent, read available documentation (even it is not perfect, it exists) and see how your ideas integrate with the features. Experiment on small cases and scratch documents.

1 Like

I do use documentation - primarily the Writer Guide. There is a number a questions I find no answers for, nor details*. It happens also to be hard to find the location in documentation where I should search for needed information. Usually I use documentation internal structure to navigate through tree of topics.

The set of used styles and custom styles is minimal - for writing’s current state of maturity this set can’t be less.

For one of documents affected the styles spotlight (by the way: a great tool) reports a picture of clear and reasonable style usage - I see in spotlight’s presentation no spot I should research further for troubleshooting; remaining documents affected still not inspected with styles spotlight.

Among all those handlings undertaken I see only Save As… to have the potential of destroying relative path to document template. No files were moved in file system, unless the clean-up in course of the attempt of recovery.
I see also that no later than on the use of TemplateChanger for the connection to template establishment this linking should be recovered and back to be-functional state. Recovering the link document-template using Templatechanger didn’t help in this case so far. Furthermore, if the template relative path stored in document meta-data is only the decisive factor the chaos in styles should not harm the link - I mean it in the sense to prompt should come. Dirt style maintenance can only the process of syncing style attributes, the change detection layer has a good chance to not depend on how well styles are maintained.

EDIT
Sure, that a session of planning and reading docs was preliminarily conducted. At that point of time the decision to start writing no open points were visible.

*) E.g. no luck on finding elaborations in docs regarding LO-specific behaviour of Save button and Undo-History of Undo-button (both on Writer’s toolbar). Save button not going shadowed when nothing to save; while clipboard buttons can go shadowed when nothing in clipboard the Save-button can’t. Saving to disk doesn’t reset Undo history. These are designs I encountered never before.

EDIT
Template link doesn’t work also in case of document created from template few seconds ago. Document-content wise the document is identical with template - it means no content were added to document past doing File > New > Templates > select desired template. How can, in this case, it be a matter you refer to? The template has been registered with Writer few minutes earlier. Template linking stopped to work. It isn’t working also in the very simple situation.

@mikekaganski If possible please check if Writer 24.2.7.2 source code provides any confirmation for the behavior to be true as in the finding? The latest yet a major update at the top of OP.

Is there a bug report with clear 1-2-3 reproduction steps not requiring to read a wall of text to understand the issue?

Thanks for you coming to my concern so quickly.
Actually, the message to you is put in top text passage of OP, so myself didn’t expect you to need to deal with the wall of text. Please see the text over there wrapped in “status major update”. I will try to find time window today to open a ticket.
Expressed shortly, the template-to-document linking correlates unexpectedly yet regarding the effects in destructive way with option “Apply user data” in template document properties. Reproducing

  • Create a template
  • Template major purpose is to carry styles, one blank paragraph on one single page in template should suffice
  • Derive a document (or a number of) from template
  • Work on template, work on document in the interchangeable way
  • Following almost every style modification in template do document reload/reopen to sync up
  • Disable “Apply user data” in template properties
  • Have one more cycle of style modification in template followed by syncing document to template
  • The point in sequence got achieved where document reload/reopening is not accompanied by the prompt “linked template has been modified, do you like to take over made modifications?” - this is my prompt message paraphrasing
  • Enable “Apply user data”
  • Have one more cycle of style modification and document sync-up
  • This time the prompt should again be popping up

Thanks. One note: in all your steps, please never give things like “work on document in the interchangeable way” or “Following almost every style modification in template do document reload/reopen to sync up”. Only write specific steps, like “select style X, open dialog A, do change B, click button C”. Of course, then it’s OK to comment on that step, like “the problem would also happen on other changes, but this is what should be enough to see the problem”. A reader should never guess, what a generic phrase might mean in reality.

1 Like

I still can’t see if the file you stored it to is just acting like a template based on its name extension (.ott) when clicked or if it is imported into your user profile with the help of the template manager (then used via the panel of the start center or via >File>New>Templates...).

  • Was the way you used the templates when creating the ordinary documents always the same? This may be relevant.
  • Do all the documents under discussion show the same information under >File>Properties...>>General>Template? What does it tell?
1 Like

was communicated:

Be more specific please. Why the term “ordinary” plays a role here?

Prior to troubleshooting session - yes.

template file name, without extension, no file path

What is shown under document Properties... behind Template: isn’t necessarily the name of the used template file. In fact it is the name of the link which is shown by the template manager. You can change this name without touching the file the link points to.

Also: An “ordinary file” in this context is one not saved as a template with the respective name extension (.ott here).

This thread got extremely bloated, and I now even don’t know if the starting post (question) still contains what there was in the beginning. Surely I have missed one or another statement by some participant.

I will therefore no longer post here.

1 Like

So, @eighty2, let’s restart from the beginning. Note that communication is difficult because none of the present participants are native English speakers and our backgrounds are different.

A. Creating a document from the template

How do you create a new document?

  1. double-cliking on a template icon
  2. File>New>Text Document and selecting a template
  3. File>New>Templates

B. Updating styles in “the” template

B1. How do you open the template?

  1. double-clicking on the template icon
  2. File>Open and selecting the template
  3. File>Templates>Edit Template

B2. How do you save template changes?

  1. File>Save
  2. File>Save As and where?
  3. File>Templates>Save as Template

C. Updating document styles
After modifying your templates, how do you update your document to latest template state?

  1. close document and reopen
  2. File>Save, then File>Reload
  3. only File>Reload

D. "User Data"

  1. Why do you play with User Data? This should have no impact on document behaviour regarding templates.

E. Others

  1. Have you enabled track changes?
  2. Have you customised settings in Tools>Options? Which ones?

Please answer by mentioning question ids. For A, B and C, the answer id is sufficient.

A.3, only custom template is used in current writing, but it is not set to default template
B1.3
B2.1, actually toolbar, the button Save (toolbar layout: Writer default)
sometimes C.2 (if last document edition was not saved to disk prior to modifying template, then syncing document), other times C.3
D in order to not to take over the data from Writer Options
Change was conducted long before the problem presence was realized
E.1 No, however Document versions are created
E.2 as below
LO custom template path added
Writer View customization
Writer Formatting aids customization
Writer Basic Fonts, all fields to Noto Sans
LO, JRE version selected
LO, General extended tips
LO, macro security, no customization before troubleshooting started, right now very high, during past troubleshooting low level in order to run user code found in this discussion

I see nothing unusual or wrong in your answers.

I am presently working on a very sophisticated and complex templated document requiring styles modification (in the template). I stumbled on the non-update issue on File>Reload. I suspect my last update was too close (in time) to the previous one and the delta with the recorded timestamp was below the threshold Writer can detect. I had to use TemplateChanger to cut link to template, save, close document, reopen it and recreate the link to the template. It worked fine afterwards.

tdf#164939