[Patch] OpenDocument requires " around file on OSX, not on Windows
Original Reporter info from Mantis: BigChimp
-
Reporter name: Reinier Olislagers
Original Reporter info from Mantis: BigChimp
- Reporter name: Reinier Olislagers
Description:
If you run lclintf.Opendocument with file names with spaces in the paths, you will need to double quote them on OSX. Not quoting them won't work and apparently won't even return failure.
On Windows, you don't need to quote the file/path.
Code inspection of lcl/include/sysenvapis_unix.inc suggests you don't need to quote on other Unix either.
Steps to reproduce:
Run attached program.
Navigate to a pdf file with e.g. spaces in the path.
Click OpenDocument.
FileExistsUTF8 will properly recognize the file is there.
The call to OpenDocument will do nothing though (apparently not even return a failure)
Additional information:
Inconsistent behaviour:
- Windows version does not require quoting
- Inconsistent with other functions like FileExistsUTF8 that also don't require quoting (and won't work with it)
Compared recent Lazarus Windows x86 SVN with OSX version.
Attached (untested) patch will presumably fix it, but break earlier code.
Note that the Unix version also quotes the path for you, so OSX is the only one that is different:
if (APath<>'') and (APath[1]<>'"') then
APath:=QuotedStr(APath);
... perhaps using QuotedStr instead of the patch will also work
Below is a grep -i --recursive OpenDocument * from the Lazarus root directory; at first glance, seems changing this won't have consequences for Lazarus (only perhaps improvements in the Delphi converter on OSX):
Binary file components/lazreport/doc/.svn/text-base/firststeps.odt.svn-base matches
Binary file components/lazreport/doc/firststeps.odt matches
Binary file components/lazreport/doc/tutorials/stringgrid/en/.svn/text-base/Tutorial_en.odt.svn-base matches
Binary file components/lazreport/doc/tutorials/stringgrid/en/Tutorial_en.odt matches
Binary file components/lazreport/doc/tutorials/stringgrid/es/.svn/text-base/Tutorial_es.odt.svn-base matches
Binary file components/lazreport/doc/tutorials/stringgrid/es/Tutorial_es.odt matches
converter/.svn/text-base/convertsettings.pas.svn-base: 'if $3 match ":/" then OpenURL($3); OpenDocument($3)', 'LCL', 'LCLIntf');
converter/.svn/text-base/replacefuncsunit.pas.svn-base:// Example: 'if $3 match ":/" then OpenURL($3); OpenDocument($3)'
converter/convertsettings.pas: 'if $3 match ":/" then OpenURL($3); OpenDocument($3)', 'LCL', 'LCLIntf');
converter/replacefuncsunit.pas:// Example: 'if $3 match ":/" then OpenURL($3); OpenDocument($3)'
Binary file docs/booth/.svn/text-base/ProdProgEntwMitOpenSourceSystems2007.odp.svn-base matches
Binary file docs/booth/ProdProgEntwMitOpenSourceSystems2007.odp matches
Binary file docs/diagrams/.svn/text-base/customdrawn_diagram.odg.svn-base matches
Binary file docs/diagrams/customdrawn_diagram.odg matches
docs/xml/lcl/.svn/text-base/lclintf.xml.svn-base: &LtPos;element name="OpenDocument">
docs/xml/lcl/.svn/text-base/lclintf.xml.svn-base: &LtPos;element name="OpenDocument.Result">
docs/xml/lcl/.svn/text-base/lclintf.xml.svn-base: &LtPos;element name="OpenDocument.APath">
docs/xml/lcl/lclintf.xml: &LtPos;element name="OpenDocument">
docs/xml/lcl/lclintf.xml: &LtPos;element name="OpenDocument.Result">
docs/xml/lcl/lclintf.xml: &LtPos;element name="OpenDocument.APath">
Binary file lazarus.exe matches
Binary file lazarus.new.exe matches
Binary file lazarus.old.exe matches
lcl/.svn/text-base/lclintf.pas.svn-base:function OpenDocument(APath: String): Boolean;
lcl/include/.svn/text-base/sysenvapis_mac.inc.svn-base:function OpenDocument(APath: String): Boolean;
lcl/include/.svn/text-base/sysenvapis_unix.inc.svn-base:function OpenDocument(APath: String): Boolean;
lcl/include/.svn/text-base/sysenvapis_win.inc.svn-base:function OpenDocument(APath: String): Boolean;
lcl/include/sysenvapis_mac.inc:function OpenDocument(APath: String): Boolean;
lcl/include/sysenvapis_unix.inc:function OpenDocument(APath: String): Boolean;
lcl/include/sysenvapis_win.inc:function OpenDocument(APath: String): Boolean;
lcl/interfaces/carbon/.svn/text-base/carbonobject.inc.svn-base: AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, FOpenEventHandlerUPP, 0, False),
lcl/interfaces/carbon/carbonobject.inc: AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, FOpenEventHandlerUPP, 0, False),
lcl/interfaces/carbon/pascocoa/appkit/.svn/text-base/NSResponder.inc.svn-base:You can invoke this method to present error alert dialog boxes. For example, Cocoa's own [NSDocumentController openDocument:] invokes this method when it's just invoked -openDocumentWithContentsOfURL:display:error: and that method has returned nil.
lcl/interfaces/carbon/pascocoa/appkit/NSResponder.inc:You can invoke this method to present error alert dialog boxes. For example, Cocoa's own [NSDocumentController openDocument:] invokes this method when it's just invoked -openDocumentWithContentsOfURL:display:error: and that method has returned nil.
lcl/lclintf.pas:function OpenDocument(APath: String): Boolean;
Binary file lcl/units/i386-win32/lclintf.o matches
Binary file lcl/units/i386-win32/lclintf.ppu matches
Binary file lcl/units/x86_64-win64/lclintf.o matches
Binary file lcl/units/x86_64-win64/lclintf.ppu matches
Binary file tools/lazdatadesktop/lazdatadesktop.exe matches
Binary file units/i386-win32/win32/convertsettings.o matches
Mantis conversion info:
- Mantis ID: 21651
- OS: OSX/Windows
- OS Build: Lion/Vista
- Build: 35900/36173
- Platform: Mac Intel+PC x64
- Version: 0.9.31 (SVN)
- Fixed in version: 1.1 (SVN)
- Fixed in revision: 37286 (#e7dd80db)