Mercurial > forge
changeset 12266:aaa69cc3fe13 octave-forge
Fixed proper writing of other file types than .ods
author | prnienhuis |
---|---|
date | Wed, 01 Jan 2014 21:28:50 +0000 |
parents | 0eff975477c3 |
children | 67035503ba3b |
files | main/io/inst/private/__UNO_spsh_close__.m main/io/inst/private/__UNO_spsh_open__.m |
diffstat | 2 files changed, 42 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/main/io/inst/private/__UNO_spsh_close__.m Wed Jan 01 21:22:03 2014 +0000 +++ b/main/io/inst/private/__UNO_spsh_close__.m Wed Jan 01 21:28:50 2014 +0000 @@ -21,14 +21,18 @@ ## Updates: ## 2012-10-23 Style fixes ## 2013-01-20 Adapted to ML-compatible Java calls -## 2013-12-06 Updated copyright strings; +## 2013-12-06 Updated copyright strings +## 2014-01-01 Fixed bug ignoring xls.nfilename +## '' Simplified filename/nfilename code +## '' First throw at output file type filters function [ xls ] = __UNO_spsh_close__ (xls, force) if (isfield (xls, "nfilename")) ## New filename specified if (strcmp (xls.xtype, 'UNO')) - ## For UNO, turn filename into URL + ## For UNO, turn filename into URL + nfilename = xls.nfilename; if (! isempty (strmatch ("file:///", nfilename))... || ! isempty (strmatch ("http://", nfilename))... || ! isempty (strmatch ("ftp://", nfilename))... @@ -47,14 +51,16 @@ flen = numel (tmp); tmp(2:2:2*flen) = tmp; tmp(1:2:2*flen) = "/"; - nfilename = [ "file://" tmp{:} ]; + filename = [ "file://" tmp{:} ]; endif endif - endif + endif + else + filename = xls.filename; endif try - if (xls.changed && xls.changed < 3) + if (xls.changed > 0 && xls.changed < 3) ## Workaround: unotmp = javaObject ("com.sun.star.uno.Type", "com.sun.star.frame.XModel"); xModel = xls.workbook.queryInterface (unotmp); @@ -66,18 +72,28 @@ xStore = xls.app.xComp.queryInterface (unotmp); if (xls.changed == 2) ## Some trickery as Octave Java cannot create non-numeric arrays - lProps = javaArray ("com.sun.star.beans.PropertyValue", 1); + lProps = javaArray ("com.sun.star.beans.PropertyValue", 2); + ## Set file type property + [ftype, filtnam] = __get_ftype__ (filename) + if (isempty (filtnam)) + filtnam = "calc8"; + endif + lProp = javaObject ... + ("com.sun.star.beans.PropertyValue", "FilterName", 0, filtnam, []); + lProps(1) = lProp; + ## Set "Overwrite" property lProp = ... javaObject ("com.sun.star.beans.PropertyValue", "Overwrite", 0, true, []); - lProps(1) = lProp; + lProps(2) = lProp; ## OK, store file - if (isfield (xls, "nfilename")) + # if (isfield (xls, "nfilename")) ## Store in another file ## FIXME check if we need to close the old file - xStore.storeAsURL (xls.nfilename, lProps); - else - xStore.storeAsURL (xls.filename, lProps); - endif + # xStore.storeAsURL (xls.nfilename, lProps); + # else + # xStore.storeAsURL (xls.filename, lProps); + xStore.storeAsURL (filename, lProps); + # endif else xStore.store (); endif
--- a/main/io/inst/private/__UNO_spsh_open__.m Wed Jan 01 21:22:03 2014 +0000 +++ b/main/io/inst/private/__UNO_spsh_open__.m Wed Jan 01 21:28:50 2014 +0000 @@ -25,7 +25,8 @@ ## make_absolute_filename (see bug #36677) ## 2012-10-24 Style fixes ## 2013-01-20 Adapted to ML-compatible Java calls -## 2013-12-06 Updated copyright strings +## 2013-12-06 Updated copyright strings +## 2014-01-01 First throw at input/output type filters function [ xls, xlssupport, lastintf ] = __UNO_spsh_open__ (xls, xwrite, filename, xlssupport) @@ -60,9 +61,18 @@ unotmp = javaObject ("com.sun.star.uno.Type", "com.sun.star.frame.XComponentLoader"); aLoader = oDesktop.queryInterface (unotmp); ## Some trickery as Octave Java cannot create initialized arrays - lProps = javaArray ("com.sun.star.beans.PropertyValue", 1); - lProp = javaObject ("com.sun.star.beans.PropertyValue", "Hidden", 0, true, []); - lProps(1) = lProp; + lProps = javaArray ("com.sun.star.beans.PropertyValue", 2); + ## Set file type property + [ftype, filtnam] = __get_ftype__ (filename); + if (isempty (filtnam)) + filtnam = "calc8"; + endif + lProp = javaObject ... + ("com.sun.star.beans.PropertyValue", "FilterName", 0, filtnam, []); + lProps(1) = lProp; + ## Set hidden property + lProp = javaObject ("com.sun.star.beans.PropertyValue", "Hidden", 0, true, []); + lProps(2) = lProp; flags = 0; if (xwrite > 2) xComp = aLoader.loadComponentFromURL ("private:factory/scalc", "_blank", flags, lProps);