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.

(post deleted by author)