Bug 43532 - Renaming and deleting of inserted template categories broken, inserted templates land in wrong category (indexing issue in code)
Summary: Renaming and deleting of inserted template categories broken, inserted templa...
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
(earliest affected)
Master old -3.6
Hardware: Other All
: high normal
Assignee: Stephan Bergmann
Keywords: regression
Depends on:
Blocks: mab3.5
  Show dependency treegraph
Reported: 2011-12-05 05:16 UTC by Cor Nouws
Modified: 2012-01-11 05:14 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:

screen short with error given when trying to rename (35.33 KB, image/png)
2011-12-05 05:17 UTC, Cor Nouws

Note You need to log in before you can comment on or make changes to this bug.
Description Cor Nouws 2011-12-05 05:16:12 UTC
File > Templates > Organise
Select one of the categories in the left list
Type Insert key 
  'Untitled' appears
Immediately Type foo as new name and Enter to confirm
  > error message Catageory cannot be renamed.

Try to remove > is disabled.

Insert two more categories.
From the 3rd on, renaming does work.

With more personal catagories deleting is possible too. Only the first that is inserted, cannot be deleted.

Looks as an indexing issue.
Feels rather buggy.
Comment 1 Cor Nouws 2011-12-05 05:17:55 UTC
Created attachment 54120 [details]
screen short with error given when trying to rename
Comment 2 Cor Nouws 2011-12-05 05:27:16 UTC
indeed there is some indexing issue.
When loading a template in a category folder, and trying to find them via Ctrl-Shft-N, I find them in a different category
Comment 3 Rainer Bielefeld Retired 2011-12-05 05:50:00 UTC
[Reproducible] with Server installation of MSVC Master "LibO-dev 3.5.0 – WIN7 Home Premium (64bit) ENGLISH UI [(Build ID:  4f11d0a-adcf6d5-c4bb9bd)]" Windows_2008R8 - 111118) - so this is not a particular 3.5.0Beta bug, it appeared more early.

Works fine with Server installation of Master "LibO-dev 3.5.0 – WIN7 Home Premium (64bit) English UI [(Build ID:  3b32204-7f92fce-2ba0a9f)]" (110903)
[Reproducible] with Server installation of Master 110829 "LibO-dev 3.5.0 – WIN7 Home Premium (64bit) English UI [(Build ID: a6adae1-4eb4f62-09af278)]"

Works fine with 3.4.4
Comment 4 Rainer Bielefeld Retired 2011-12-05 05:54:01 UTC
I'm sorry, I did NOT test Master 110829 "LibO-dev 3.5.0 – WIN7
Home Premium (64bit) English UI [(Build ID: a6adae1-4eb4f62-09af278)] and I doubt that it shows the roblem!
Comment 5 Cor Nouws 2011-12-15 14:14:20 UTC
Still problem in 350 beta1
Comment 6 Cor Nouws 2011-12-15 14:18:03 UTC
annyong, regression, bla bla > so higher importance
Comment 7 Stephan Bergmann 2012-01-09 06:28:32 UTC
Regression apparently caused by <http://cgit.freedesktop.org/libreoffice/core/commit/?id=df59068902b294b7b344af0c20da196cc64aaced> "Fix of localized template name problems in Impress part 2".  Having a look.
Comment 8 Cor Nouws 2012-01-09 11:15:27 UTC
While working on that, you might want to change "regions" to "categories" at the same time?
(code is bit more complex then I'm used to, so I won't try that)
Comment 9 Stephan Bergmann 2012-01-09 23:35:07 UTC
@cor:  I would prefer to keep any UI changes out of the bug fix.  I can do that in a follow up (on master), though.
Comment 10 Cor Nouws 2012-01-10 02:00:18 UTC
(In reply to comment #9)
> @cor:  I would prefer to keep any UI changes out of the bug fix.  

I ment the words that are used as comment in the code ;-)

Is the next bug related ?
Bug 37593 - "File > New > Template" no longer remembers my last open folder
Comment 11 Stephan Bergmann 2012-01-10 05:34:15 UTC

- ah, but "region" does also appear in the UI (at least in some error box message)

- I guess bug 37593 is unrelated; that bug reportedly already appears in 3.4, while this issue is apparently a regression new to 3.5
Comment 12 Korrawit Pruegsanusak 2012-01-11 03:47:33 UTC
Stephan, I see that you have commit a fix to this bug, but just asking to be sure.



IOW, shall we mark this bug as fixed?
Comment 13 Stephan Bergmann 2012-01-11 05:14:26 UTC
What <http://cgit.freedesktop.org/libreoffice/core/commit/?id=50b7733fa41879a62d35cab64da59b109e1a8502> "Make template names appear in the correct word order," <http://cgit.freedesktop.org/libreoffice/core/commit/?id=0c113d825da98a8038cb4359cd86e765eef0b915> "Fix of localised template name problems in Impress part 1," and <http://cgit.freedesktop.org/libreoffice/core/commit/?id=df59068902b294b7b344af0c20da196cc64aaced> "Fix of localized template name problems in Impress part 2" were apparently intended to achieve is the following:

Some dialogs display lists of templates organized into categories, and those lists are not properly sorted for non-en-US locales.  The relevant dialogs are

* "File - Wizards - Presentation..." (AssistentDlgImpl in sd/source/ui/dlg/dlgass.cxx)

* In Writer, Calc, etc.: "File - Templates - Save..." (SfxDocumentTemplateDlg in sfx2/source/doc/doctdlg.cxx)

* In Impress: "Format - Slide Design... - Load..." (SfxNewFileDialog_Impl in sfx2/source/doc/new.cxx; probably also accessible in some way in Writer)

* "File - Templates - Organize..." (SfxOrganizeDlg_Impl in sfx2/source/doc/docvor.cxx)

For the first dialog, the commits seem to work as intended.  For the other three, however, the problem is that the code uses two separate data models, one is the list box, the other is SfxDocumentTemplates.  The models are synchronized via indices into the list, so the two must be sorted exactly the same for this to work.  But while the list box uses a locale-specific collation order (e.g., sorting upper and lower case letters together), SfxDocumentTemplates sorts on Unicode code points, thus sorts all lower case letters after all upper case letters, thus sorts the "en-US" category after all the other three categories.  This causes all those three dialogs to display wrong content for a given category.

And the problem is extremely severe for the last dialog (see this issue's original description), where the ability to add and remove categories only increases the confusion between the two data models.

The correct fix would probably be to unite the models, having the list boxes use UserData pointers to the items within SfxDocumentTemplates.  However, the relevant code is so badly structured that this is not an easy task, esp. not at this stage of libreoffice-3-5.

I thus just reverted the attempt to sort the last three dialogs for now (<http://cgit.freedesktop.org/libreoffice/core/commit/?h=libreoffice-3-5&id=6b5969cee2495b760e27b896ec4f0bbd61239e23> "fdo#43532 Partial revert of '...template names appear... correct word order'"), postponing a proper fix for that to future work on master.