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: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All Windows (All)
: medium normal
Assignee: Laurent Balland
URL:
Whiteboard: target:7.5.0
Keywords: difficultyBeginner, easyHack, skillCpp
: 120141 148067 150226 (view as bug list)
Depends on:
Blocks: Desktop-Integration Templates
  Show dependency treegraph
 
Reported: 2021-01-28 09:39 UTC by Orwel
Modified: 2022-12-26 18:48 UTC (History)
9 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 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
Comment 6 Mike Kaganski 2022-08-01 20:36:07 UTC
*** Bug 150226 has been marked as a duplicate of this bug. ***
Comment 7 Dieter 2022-08-12 06:48:13 UTC
*** Bug 120141 has been marked as a duplicate of this bug. ***
Comment 8 Commit Notification 2022-09-25 14:22:02 UTC
Laurent Balland committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/567b4281b96f56ce48d3feb57522255b06816f9b

tdf#139962 make shellnew files 0-bytes

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Dieter 2022-10-09 09:34:10 UTC
(In reply to Commit Notification from comment #8)
> Affected users are encouraged to test the fix and report feedback.

Don't know a way how to create a LODev file from desktop. So I think,  have to wait for a RC of LO 7.5.
Comment 10 Mike Kaganski 2022-10-09 09:42:15 UTC
(In reply to Dieter from comment #9)

By default, dev (non-release) builds differ by WRITE_REGISTRY property value (they have it 0, while releases use value of 1). That means that installation doesn't write anything to registry, including the New shell registration.

You *could* use a command like

> msiexec.exe /i LODevDailySomething.msi WRITE_REGISTRY=1

to install it with all the registry data, but note that that would also conflict with the installed release version, which is why it isn't done by default.
Comment 11 Dieter 2022-10-09 09:49:15 UTC
Thank you for quick reply, but since I'm not familiar with registry entries, I don't want to change anything here.
Comment 12 Dieter 2022-12-26 18:48:27 UTC
VERIFIED with

Version: 7.5.0.1 (X86_64) / LibreOffice Community
Build ID: 77cd3d7ad4445740a0c6cf977992dafd8ebad8df
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: CL threaded

Laurent, thank you for fixing it!