[Libreoffice-bugs] [Bug 139991] New: Use user-defined default template when opening 0-byte files with OD* extensions

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Fri Jan 29 06:07:41 UTC 2021


https://bugs.documentfoundation.org/show_bug.cgi?id=139991

            Bug ID: 139991
           Summary: Use user-defined default template when opening 0-byte
                    files with OD* extensions
           Product: LibreOffice
           Version: unspecified
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: medium
         Component: LibreOffice
          Assignee: libreoffice-bugs at lists.freedesktop.org
          Reporter: mikekaganski at hotmail.com
                CC: vmiklos at collabora.com

After fixing tdf#133661, the documents created using Windows Explorer's
ShellNew command follow some LibreOffice settings (language, fonts). However,
they still do not honor user-defined default templates (as configured in
File->Templates->Manage Templates). This means that the two methods of creating
new LibreOffice documents (from within LibreOffice application, and from
Explorer's context menu), which from user's PoV should be interchangeable and
give identical results, in fact behave differently: the former method does what
user told to do, while the latter ignored user default template setting.

With the fix to tdf#123476, LibreOffice now opens 0-byte files with ODT/ODS/etc
extensions as empty documents in the corresponding component. This paves a way
to implement the missing functionality: process such files to make them use
default templates, and then create empty files in Windows ShellNew handler
(i.e., drop soffice.* files in C:\Program
Files\LibreOffice\share\template\shellnew, and replace "FileName" with
"NullFile" in ShellNew registry subkeys [1]).

We should detect that the opened file that uses our native filter is 0-byte
file (tools::isEmptyFileUrl) somewhere before the call to
SfxObjectShell::DoLoad, and use SfxObjectFactory::GetStandardTemplate to get
the default template for the component service. Then we must use the template
to initialize the document, but unlike the normal creation of a new document
from a template, we must make it have the name and location of the 0-byte file.

I don't have a specific proposal where should this happen, and how to implement
the substitution of temporary storage (that is used for newly created files)
with the 0-byte file, thus not marking this an easy hack.

[1]
https://docs.microsoft.com/en-us/windows/win32/shell/context#extending-the-new-submenu

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210129/4550fef0/attachment-0001.htm>


More information about the Libreoffice-bugs mailing list