Bug 139962 - Creating a new .odt file from Win Explorer does not use default template
Summary: Creating a new .odt file from Win Explorer does not use default template
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyBeginner, easyHack, skillCpp
: 148067 (view as bug list)
Depends on:
Blocks: Desktop-Integration Templates
  Show dependency treegraph
 
Reported: 2021-01-28 09:39 UTC by Orwel
Modified: 2022-04-16 03:50 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Orwel 2021-01-28 09:39:34 UTC
Description:
If your create your own template in Writer, creating a new text document from Win Explorer (Right click - New - Text document) creates a document which is not based on your new default template, but on a default empty soffice.odt file stored in 

Steps to Reproduce:
1. create your own template (with some Numbering etc., or use my test_template, attached)
2. put it in some folder, make it default by LO-Writer.
3. try opening a new file from Windows Explorer (mouse right click - New - Text document Opendocument).

Actual Results:
The new created empty file is NOT based on default template.

Expected Results:
The new created empty file SHOULD BE based on default template.


Reproducible: Always


User Profile Reset: Yes


OpenGL enabled: Yes

Additional Info:
Windows registry stores the default soffice.odt for ShellNew in the registry key: Computer\HKEY_CLASSES_ROOT\.odt\LibreOffice.WriterDocument.1\ShellNew

You can create a new ODT file in Writer in 2 different ways:
1. LO - File - New
2. Win Explorer - right mouse click - New - Text document

For me as an user both possibilities of creating a new document should bring the same result (new document based on own default template).

A possible solution could be:
By each create/re-save of own default template (LO-File-Templates-Manage) LO should automatically rewrite the default file C:\Program Files\LibreOffice\share\template\shellnew\soffice.odt (as it is pointed by Win Shallnew registry key).

Important - the C:\Program Files\LibreOffice\share\template\shellnew\soffice.odt file should not be (in possible solution above) rewritten by an update of LO.

I do know know if it is possible to make it working on Win environment with more users as I do not know, if each user can use own (different) default template... If the proposed solution is not possible, another solution could be proposed:
- Each time LO opens a document based on the default C:\Program Files\LibreOffice\share\template\shellnew\soffice.odt a proposal for importing settings from the default template should appear and user could with one click import all settings from the default template.
Comment 1 Dieter 2021-02-13 09:24:42 UTC
I confirm it with

Version: 7.1.0.3 (x64) / LibreOffice Community
Build ID: f6099ecf3d29644b5008cc8f48f42f4a40986e4c
CPU threads: 4; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: threaded

I'm pretty sure, that a similar bug has been reported before, but I couldn't find it
Comment 2 Dieter 2021-02-13 09:28:29 UTC
At least related to bug 133661, that should be fixed in LO 7.1

Mike, I think, you might be interested in this
Comment 3 Dieter 2022-04-12 06:04:43 UTC
*** Bug 148067 has been marked as a duplicate of this bug. ***
Comment 4 Mike Kaganski 2022-04-15 13:39:14 UTC
So now, after tdf#139991 is implemented, it allows to fix this trivially: make the shell's New command to create an *empty* (0-byte) file. LibreOffice would open such a file as a new document of type detected from extension only, using default template (if any) set for respective component.

For Windows, it implies:
1. Search for all occurrences of "shellnew" in the codebase;
2. In the SCP files found, replace respective "Name" from "FileName" to "NullFile", and "Value" from "<progpath>\share\template\shellnew\soffice.*" to "" (empty string);
3. Drop extras/source/shellnew/*.

There should be some similar way for Linux integrations (or, if unavailable, we would need to still provide 0-byte files under extras/source/shellnew/, instead of dropping them at #3 above).

As maybe simple solution, just making all those files under extras/source/shellnew/ 0-byte would be enough, without a need to modify anything else. That would automatically work for any Linux integration making use of the files, too.

The caveat is that the new way relies on special-processing the 0-based files, which are *not* proper ODF packages. MS Office uses the same technique; but if you open those files using a different application before editing and saving in LibreOffice, the results would be unexpected (just the same way as they were in LibreOffice before implementation of tdf#123476).
Comment 5 Mike Kaganski 2022-04-15 14:24:04 UTC
FTR: This is *not* "skillCpp"; I do not see a matching "skillAny" in the possible values ;) - so I'll keep what is set now :-D