Bug 150497 - FORMATTING: Templates in nested folders are not displayed, allow nested categories in the Template Manager
Summary: FORMATTING: Templates in nested folders are not displayed, allow nested categ...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.3.4.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Template-Manager
  Show dependency treegraph
 
Reported: 2022-08-19 10:46 UTC by Emanuele Gissi
Modified: 2023-04-22 11:14 UTC (History)
3 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 Emanuele Gissi 2022-08-19 10:46:29 UTC
Description:
The document templates are currently organized in categories by the Template Manager (`File > Templates > Manage templates`). The categories are taken from the folders contained in the template paths specified in `Tools > Options > Libreoffice > Paths > Templates`.

Currently only one level of template categories is displayed. Sub-categories are not displayed.

For example: if the template path is set to `TemplateTest/`, the `TemplateTest/categoryA/letter.ott` template is displayed inside the `categoryA`, but the `templatepath/categoryA/subcategoryA/subletter.ott` template is not shown at all, not even in the `categoryA`.

Complex organisations have lots of templates. So it would be **very useful** to have nested categories in the Template Manager, to better classify them (eg. by office and by process).

This is why I suggest:
 * allowing nested template categories, from nested folders in the selected template paths;
 * using a directory-like visualization for categories and sub-categories, instead of the `Category` pop down in the Template Manager, because it seems more friendly to basic office users.

For comparison, this seems already possible in the many Microsoft Office versions, see how it works there: http://www.addbalance.com/usersguide/templates.htm


Steps to Reproduce:
1. Create a new folder `TemplateTest` and add it in `Tools > Options > Libreoffice > Paths > Templates`
2. Create and put a `letter.ott` template into the `TemplateTest` folder.
3. Create a nested folder called `categoryA` inside the `TemplateTest` folder
4. Create and put a `letter2.ott` template into the `categoryA` folder.
5. Create a nested folder called `subcategoryA` inside the `categoryA` folder
6. Create and put a `letter3.ott` template into the `subcategoryA` folder.
7. Open the Template Manager with `File > Templates > Manage templates`
8. The templates `letter.ott` and `letter2.ott` are displayed, `letter2.ott` is not. No sub category is shown as well.


Actual Results:
The templates `letter.ott` and `letter2.ott` are displayed, `letter3.ott` is not. No sub category is shown as well.

Expected Results:
The templates `letter.ott`, `letter2.ott`, and `letter3.ott` should be displayed.
The nested sub category `subcategoryA` should be displayed as a folder of `categoryA`.


Reproducible: Always


User Profile Reset: No



Additional Info:
Thank you!
Comment 1 Andreas Heinisch 2022-08-22 15:40:52 UTC
Valid enhancement. Should we allow an infinte depth of folders or limit them to a certain depth?
Comment 2 Emanuele Gissi 2022-08-23 07:48:47 UTC
Well, I do not imagine using more than 3 or 4 levels.
But, as it happens for nested directories, I neither see a reason to limit nesting.
Comment 3 Andreas Heinisch 2022-08-30 19:55:27 UTC
I tried to understand the logic behind the creation of the template list and it is quite overwhelming.

I think that in SfxDocTplService_Impl::createFromContent no sub folders are included, and I have to check if there is a possibility to read the entire directories including their sub folders to create the correct list by adding a new  entry in the ResultSetInclude enum.
Comment 4 Andreas Heinisch 2022-09-07 12:26:13 UTC
Proposed patch:  https://gerrit.libreoffice.org/c/core/+/139593

However, after opening a folder, LO somehow destroys the entire folder hierarchy and the files cannot be read again. I will try to speak to some people at the LiboCon and try to solve this, but at the moment after countless debugging houers I can't really help here :(
Comment 5 Emanuele Gissi 2022-09-07 14:09:32 UTC
Good job! A first step in the right direction. Thank you!
Comment 6 Emanuele Gissi 2022-11-11 06:17:34 UTC
May I help in any way? Testing?
Comment 7 Andreas Heinisch 2022-11-11 07:05:16 UTC
Atm, I hope to get the enhancement complete, but I am in cheerful spirits 😊
Comment 8 Andreas Heinisch 2022-11-24 10:08:55 UTC
Could not figure it out how the HierarchyManager rertrieves its names and where it calls the file system, for instance, with FindFileW on Windows. It never calls them, somehow magically it has all the names of the files without any subdirectory.

Sometimes all the subdiretories show up ,sometimes not, and I have no idea how to resolve this issue.
Comment 9 Emanuele Gissi 2023-01-01 16:59:14 UTC
So no hope to solve this bug?
Anyway, happy new year
Comment 10 Andreas Heinisch 2023-01-01 22:12:49 UTC
Unfortunately, I have no idea how to solve this issue. Lots of calls to subclasses and delegations, even some kind of cache that checks if all the folders AND subfolders are in place. 

Then it even gets stranger. SOMETIMES all the folders including subfolders work, sometimes they disappear event on the file system itself. Imho, this section needs a rework or someone with a deeper understanding of the code base that left untouched for 22 years according to github.