Template not refreshing after moving documents to a new folder

I have an ordinary template saved in the root of the template manager. The template contains custom styles that I use within a master document and the subdocuments. In the past, I’ve had no problems making changes to the template and the documents prompting for a refresh when opened. Now, however, none of my documents are prompting for a refresh.

All that has changed is that I moved the master document and its subdocuments to a new folder. I initially created everything in a test folder in My Documents, and I have since moved them to a new folder, also within My Documents (same computer). Moving the documents back to the test folder fixed the problem. Before that, I tried restarting in safe mode and refreshing from the template manager, but neither worked. The path for the templates is correct.

I’m going to change the template assigned to a document, but I’d like to know why this broke the link.

I’m running LO 7.0.2.4 64-bit on Windows 10.

In the XML representation of your document, path to the template is recorded as a relative path rooted at the directory where you store the document. Consequently, when you move your document to another location from which the path to the template master directory is different in its relative form than the previous one, you are faced with what you describe.

The convenient way to deal with it is to download the Template Changer extension from the LO site. You can then change the template (in fact reapply the same) to fix the issue.

The problem comes from a limitation in ODF format and I don’t see how it could be remedied (maybe needs a modification to ODF and this case is consequently very long because there needs to be an agreement on changing the standard, with all the implications on existing documents which could break).

2 Likes

@ajlittoz Thank you for explaining. I was wondering why they used a relative path. Too bad they can’t fix it.

So to be sure, the template-document link breaks every time the document location moves? Can you confirm if this correct?

And the most convenient way of fixing this is by using the template changer to re-link the document and template? I wonder if there is any other solution, particularly when dealing with many documents which move location. I.e., can the templates of several documents be updated/changed at once?

Furthermore, does the same problem occur if a document is renamed?

Not exactly. This happens when the relative path to the template is not the same. Many moves will keep this path valid, e.g. when template is located in a sibling directory:

outer --+-- template_dir --- template
        |
        +-- sub_dir_a --- d.odt
        |
        +-- sub_dir_b

you can move d.odt from outer/sub_dir_a/ to outer/sub_dir_b/ safely because the relative path …/template_dir/template still points on the template.

This is the simplest case; you can build more complex ones. But as soon as the relative path starting from the new location of the document no longer designates the template, you must rebase with TemplateChanger.

This is possible b fiddling directly inside the document with a macro-generator. My preference is to store the documents as .fodt. The transformation .odt → .fodt can be “en masse” with a shell script. It is also possible to do it on .odt but it is more complicated (you must extract the XML description of the contents from the zipped .odt, do the modification and reinsert into the zip). I don’t recommend it as it is too easy too work directly on the original instead of a copy. And mistakes happen so fast …

No. The relative path does not take the document name into account.

But if you rename the template, the relative path breaks and you must rebase anew with TemplateChanger.