Re: [api-dev] Possible bug with MySQL and OOo ResultSet

2009-10-29 Thread Frank Schoenheit, Sun Microsystems Germany
Hi Sergio,

 oStmt = oConn.createStatement()
 oStmt.setPropertyValue(ResultSetType, 
 com.sun.star.sdbc.ResultSetType.SCROLL_INSENSITIVE)
 oStmt.setPropertyValue(ResultSetConcurrency, 
 com.sun.star.sdbc.ResultSetConcurrency.READ_ONLY)
 oRs = oStmt.executeQuery(sql_string)
 oRs.next
 c = oRs.getRow
 print c '= 1
 oRs.next
 print oRs.getRow '= 2
 oRs.absolute(c) 'give False with MySQL only
 print oRs.getRow '= 2 ***error*** with MySQL only
 
 If I connect to HSQL, it works giving 1 at the end, while if I connect 
 to MySQL, it return 2 at the end.
 Do I make an error?
 
 MySQL 5.1.40 - Connector 3.51.27 - OOo 3.1.1

In general, the result set type you specify (SCROLL_INSENSITIVE, in your
example) is a request which might not necessarily be fulfilled by the
database driver. That is, the driver is free to downgrade it, if it
doesn't support a particular type. Whether this downgrade happens
silently, or with a warning (or not at all, but execution would fail),
is at the discretion of the driver.

That said, it might be (do not know this out of my head) that the MySQL
Connector decided to downgrade your result set type to FORWARD_ONLY. In
this case, absolute is not expected to work, only next can be used then.

Provided that the driver provides proper information, you can check this
with
  Print oRs.ResultSetType ' should be 1004 [1]
, or, if you need the information before actually executing the statement:
  Print oConn.MetaData.supportsResultSetConcurrency( _
com.sun.star.sdbc.ResultSetType.SCROLL_INSENSITIVE, _
com.sun.star.sdbc.ResultSetConcurrency.READ_ONLY )
(However, the latter method is known to be improperly implemented by
some drivers, though I think the MySQL Connector is not amongst those.)


If you find that indeed the SCROLL_INSENSITIVE type is not supported by
the driver, then you might consider upgrading the Connector/ODBC -
finally, the 3.51 series is *really* old meanwhile.

Ciao
Frank

[1]http://api.openoffice.org/docs/common/ref/com/sun/star/sdbc/ResultSetType.html

 
 p.s. If I connect with extension native driver for OOo, it works, so 
 I'll use it, but it would be however a bug. And in Ubuntu, wich use 
 MySQL 5.0.75, native connector is not available.
 
 -
 To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
 For additional commands, e-mail: dev-h...@api.openoffice.org
 


-- 
- Frank Schönheit, Software Engineer frank.schoenh...@sun.com -
- Sun Microsystems  http://www.sun.com/staroffice -
- OpenOffice.org Base   http://dba.openoffice.org -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org



Re: [api-dev] Possible bug with MySQL and OOo ResultSet

2009-10-29 Thread Alex Thurgood
Hi Frank, Sergio,

It would appear that the 3.51 ODBC driver only supports dynamic cursors in 
FORWARD_ONLY and STATIC modes if this page is correct :


http://www.verbose.fr/mysql_5.0/mysql-connectors.html

25.1.14.2. Est-ce que MyODBC accepte les curseurs dynamiques?

Oui. MyODBC 3.51 supporte les curseurs dynamiques avec les modes Forward-only 
et static.

A cause des problèmes de performances, le pilote ne supporte pas cette 
fonctionnalité par défaut. Vous pouvez l'activer en spécifiant l'option de 
connexion OPTION=32 ou en cliquant dans l'option Enable Dynamic Cursor dans le 
panneau de configuration DSN. 

For those who don't speak French :
Does MyODBC accept dynamic cursors?
Yes. MyODBC 3.51 supports dynamic cursors in Forward-Only and Static modes
For performance reasons, the driver does not enable this functionality by 
default. It can be activated by specifying the connection option OPTION=32 or 
by clicking on the Enable Dynamic Cursor tickbox in the DSN configuration 
panel. 


Alex



- Frank Schoenheit, Sun Microsystems Germany frank.schoenh...@sun.com a 
écrit :

 Hi Sergio,
 
  oStmt = oConn.createStatement()
  oStmt.setPropertyValue(ResultSetType, 
  com.sun.star.sdbc.ResultSetType.SCROLL_INSENSITIVE)
  oStmt.setPropertyValue(ResultSetConcurrency, 
  com.sun.star.sdbc.ResultSetConcurrency.READ_ONLY)
  oRs = oStmt.executeQuery(sql_string)
  oRs.next
  c = oRs.getRow
  print c '= 1
  oRs.next
  print oRs.getRow '= 2
  oRs.absolute(c) 'give False with MySQL only
  print oRs.getRow '= 2 ***error*** with MySQL only
  
  If I connect to HSQL, it works giving 1 at the end, while if I
 connect 
  to MySQL, it return 2 at the end.
  Do I make an error?
  
  MySQL 5.1.40 - Connector 3.51.27 - OOo 3.1.1
 
 In general, the result set type you specify (SCROLL_INSENSITIVE, in
 your
 example) is a request which might not necessarily be fulfilled by the
 database driver. That is, the driver is free to downgrade it, if it
 doesn't support a particular type. Whether this downgrade happens
 silently, or with a warning (or not at all, but execution would
 fail),
 is at the discretion of the driver.
 
 That said, it might be (do not know this out of my head) that the
 MySQL
 Connector decided to downgrade your result set type to FORWARD_ONLY.
 In
 this case, absolute is not expected to work, only next can be used
 then.
 
 Provided that the driver provides proper information, you can check
 this
 with
   Print oRs.ResultSetType ' should be 1004 [1]
 , or, if you need the information before actually executing the
 statement:
   Print oConn.MetaData.supportsResultSetConcurrency( _
 com.sun.star.sdbc.ResultSetType.SCROLL_INSENSITIVE, _
 com.sun.star.sdbc.ResultSetConcurrency.READ_ONLY )
 (However, the latter method is known to be improperly implemented by
 some drivers, though I think the MySQL Connector is not amongst
 those.)
 
 
 If you find that indeed the SCROLL_INSENSITIVE type is not supported
 by
 the driver, then you might consider upgrading the Connector/ODBC -
 finally, the 3.51 series is *really* old meanwhile.
 
 Ciao
 Frank
 
 [1]http://api.openoffice.org/docs/common/ref/com/sun/star/sdbc/ResultSetType.html
 
  
  p.s. If I connect with extension native driver for OOo, it works, so
 
  I'll use it, but it would be however a bug. And in Ubuntu, wich use
 
  MySQL 5.0.75, native connector is not available.
  
 
 -
  To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
  For additional commands, e-mail: dev-h...@api.openoffice.org
  
 
 
 -- 
 - Frank Schönheit, Software Engineer frank.schoenh...@sun.com
 -
 - Sun Microsystems  http://www.sun.com/staroffice
 -
 - OpenOffice.org Base   http://dba.openoffice.org
 -
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -
 
 -
 To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
 For additional commands, e-mail: dev-h...@api.openoffice.org

-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org



Re: [api-dev] BASIC: Change toolbar button icon ?

2009-10-29 Thread Carsten Driesner

Jan Holst Jensen wrote:

Hi all.

I am trying to emulate a togglebutton/checkbox in a custom toolbar. 
Right now I have settled for having two toolbar buttons with different 
icons. Only one of them is visible and when it's pressed it toggles the 
visibility of both buttons using the code below (which sets visibility 
of a single button with a given label).


It works OK but only as long as the user doesn't fiddle with button 
visibility :-). Is there a way of changing a toolbar button's icon 
directly from Basic code ? I could not figure out how to do it.

Hi Jan,

Your solution looks it a little bit strange. You can set the image of a 
toolbar button with the help of an image manager. Look at the following 
Basic code which uses the image manager to set an image for a button 
that references a Basic macro. I am sure you can adapt the code to your 
needs.


Regards,
Carsten

REM  *  BASIC  *

REM *** This example creates a new basic macro toolbar button on
REM *** the Writer standard bar. It doesn't add the button twice.
REM *** It uses the Writer image manager to set an external image
REM *** for the macro toolbar button.

Sub Main
REM *** String to reference toolbar
sToolbar = private:resource/toolbar/standardbar
REM *** Macro command to add
sMyToolbarCmdId = macro:///Standard.Module1.Test()

	REM *** Retrieve the module configuration manager from central module 
configuration manager supplier
	oModuleCfgMgrSupplier = 
createUnoService(com.sun.star.ui.ModuleUIConfigurationManagerSupplier)


REM *** Retrieve the module configuration manager with module identifier
REM *** See com.sun.star.frame.ModuleManager for more information
	oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager( 
com.sun.star.text.TextDocument )

oImageMgr = oModuleCfgMgr.getImageManager()

oToolbarSettings = oModuleCfgMgr.getSettings( sToolbar, true )

REM *** Look for our button. Can be identified by the CommandURL 
property.
bHasAlreadyButton = false
nCount = oToolbarSettings.getCount()
for i = 0 to nCount-1
oToolbarButton() = oToolbarSettings.getByIndex( i )
nToolbarButtonCount = ubound(oToolbarButton())
for j = 0 to nToolbarButtonCount
if oToolbarButton(j).Name = CommandURL then
if oToolbarButton(j).Value = sMyToolbarCmdId 
then
bHasAlreadyButton = true
end if
endif
next j
next i

Dim oImageCmds(0)
Dim oImages(0)
REM *** Check if image has already been added
if not oImageMgr.hasImage( 0, sMyToolbarCmdId ) then

REM *** Try to load the image from the file URL
oImage = GetImageFromURL( file:///c:/test.bmp )
if not isNull( oImage ) then

REM *** Insert new image into the Writer image manager
oImageCmds(0) = sMyToolbarCmdId
oImages(0) = oImage
oImageMgr.insertImages( 0, oImageCmds(), oImages() )
end if
end if

if not bHasAlreadyButton then
sString = My Macro's
		oToolbarItem = CreateToolbarItem( sMyToolbarCmdId, 
Standard.Module1.Test )

oToolbarSettings.insertByIndex( nCount, oToolbarItem )
oModuleCfgMgr.replaceSettings( sToolbar, oToolbarSettings )
end if
End Sub

Function GetImageFromURL( URL as String ) as Variant
Dim oMediaProperties(0) as new com.sun.star.beans.PropertyValue

REM *** Create graphic provider instance to load images from external 
files
	oGraphicProvider = createUnoService( 
com.sun.star.graphic.GraphicProvider )


REM *** Set URL property so graphic provider is able to load the image
oMediaProperties(0).Name  = URL
oMediaProperties(0).Value = URL

REM *** Retrieve the com.sun.star.graphic.XGraphic instance
GetImageFromURL = oGraphicProvider.queryGraphic( oMediaProperties() )
End Function

Function CreateToolbarItem( Command as String, Label as String ) as Variant
Dim aToolbarItem(3) as new com.sun.star.beans.PropertyValue

aToolbarItem(0).Name = CommandURL
aToolbarItem(0).Value = Command
aToolbarItem(1).Name = Label
aToolbarItem(1).Value = Label
aToolbarItem(2).Name = Type
aToolbarItem(2).Value = 0
aToolbarItem(3).Name = Visible
aToolbarItem(3).Value = true

CreateToolbarItem = aToolbarItem()
End Function

Sub Test
MsgBox Test
End Sub

-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org



Re: [api-dev] BASIC: Change toolbar button icon ?

2009-10-29 Thread Paolo Mantovani
Hello Carsten,
Just for let you know that almost all your posts in d...@api are labeled
as important in my local archive :-)
Thanks for sharing.
Keep it up!!

ciao
Paolo M


Carsten Driesner ha scritto:
 Jan Holst Jensen wrote:
 Hi all.

 I am trying to emulate a togglebutton/checkbox in a custom toolbar.
 Right now I have settled for having two toolbar buttons with different
 icons. Only one of them is visible and when it's pressed it toggles
 the visibility of both buttons using the code below (which sets
 visibility of a single button with a given label).

 It works OK but only as long as the user doesn't fiddle with button
 visibility :-). Is there a way of changing a toolbar button's icon
 directly from Basic code ? I could not figure out how to do it.
 Hi Jan,
 
 Your solution looks it a little bit strange. You can set the image of a
 toolbar button with the help of an image manager. Look at the following
 Basic code which uses the image manager to set an image for a button
 that references a Basic macro. I am sure you can adapt the code to your
 needs.
 
 Regards,
 Carsten
 
 REM  *  BASIC  *
 
 REM *** This example creates a new basic macro toolbar button on
 REM *** the Writer standard bar. It doesn't add the button twice.
 REM *** It uses the Writer image manager to set an external image
 REM *** for the macro toolbar button.
 
 Sub Main
 REM *** String to reference toolbar
 sToolbar = private:resource/toolbar/standardbar
 REM *** Macro command to add
 sMyToolbarCmdId = macro:///Standard.Module1.Test()
 
 REM *** Retrieve the module configuration manager from central
 module configuration manager supplier
 oModuleCfgMgrSupplier =
 createUnoService(com.sun.star.ui.ModuleUIConfigurationManagerSupplier)
 
 REM *** Retrieve the module configuration manager with module
 identifier
 REM *** See com.sun.star.frame.ModuleManager for more information
 oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager(
 com.sun.star.text.TextDocument )
 oImageMgr = oModuleCfgMgr.getImageManager()
 
 oToolbarSettings = oModuleCfgMgr.getSettings( sToolbar, true )
 
 REM *** Look for our button. Can be identified by the CommandURL
 property.
 bHasAlreadyButton = false
 nCount = oToolbarSettings.getCount()
 for i = 0 to nCount-1
 oToolbarButton() = oToolbarSettings.getByIndex( i )
 nToolbarButtonCount = ubound(oToolbarButton())
 for j = 0 to nToolbarButtonCount
 if oToolbarButton(j).Name = CommandURL then
 if oToolbarButton(j).Value = sMyToolbarCmdId then
 bHasAlreadyButton = true
 end if
 endif
 next j
 next i
 
 Dim oImageCmds(0)
 Dim oImages(0)
 REM *** Check if image has already been added
 if not oImageMgr.hasImage( 0, sMyToolbarCmdId ) then

 REM *** Try to load the image from the file URL
 oImage = GetImageFromURL( file:///c:/test.bmp )
 if not isNull( oImage ) then

 REM *** Insert new image into the Writer image manager
 oImageCmds(0) = sMyToolbarCmdId
 oImages(0) = oImage
 oImageMgr.insertImages( 0, oImageCmds(), oImages() )
 end if
 end if
 
 if not bHasAlreadyButton then
 sString = My Macro's
 oToolbarItem = CreateToolbarItem( sMyToolbarCmdId,
 Standard.Module1.Test )
 oToolbarSettings.insertByIndex( nCount, oToolbarItem )
 oModuleCfgMgr.replaceSettings( sToolbar, oToolbarSettings )
 end if
 End Sub
 
 Function GetImageFromURL( URL as String ) as Variant
 Dim oMediaProperties(0) as new com.sun.star.beans.PropertyValue
 
 REM *** Create graphic provider instance to load images from
 external files
 oGraphicProvider = createUnoService(
 com.sun.star.graphic.GraphicProvider )
 
 REM *** Set URL property so graphic provider is able to load the image
 oMediaProperties(0).Name  = URL
 oMediaProperties(0).Value = URL
 
 REM *** Retrieve the com.sun.star.graphic.XGraphic instance
 GetImageFromURL = oGraphicProvider.queryGraphic( oMediaProperties() )
 End Function
 
 Function CreateToolbarItem( Command as String, Label as String ) as Variant
 Dim aToolbarItem(3) as new com.sun.star.beans.PropertyValue
 
 aToolbarItem(0).Name = CommandURL
 aToolbarItem(0).Value = Command
 aToolbarItem(1).Name = Label
 aToolbarItem(1).Value = Label
 aToolbarItem(2).Name = Type
 aToolbarItem(2).Value = 0
 aToolbarItem(3).Name = Visible
 aToolbarItem(3).Value = true
 
   CreateToolbarItem = aToolbarItem()
 End Function
 
 Sub Test
 MsgBox Test
 End Sub
 
 -
 To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
 For additional commands, e-mail: dev-h...@api.openoffice.org
 
 .
 



Re: [api-dev] Optional Parameters in NetBeans

2009-10-29 Thread Irné Barnard

Juergen Schmidt wrote:
i tried it with a OOo 3.1.1 and a development build dev300m61. Both 
works as expected.


Have you used the NB plugin wizard to create your project? How does 
your  CalcAddins.xcu looks like?


Well i have no real idea what's going wrong in your case.

Juergen



Thanks, I've just decided to start from scratch again. I must've 
modified something and just couldn't find what. After doing it all 
again, it seems to work fine this time!


--
Regards Irné Barnard


[api-dev] Bootstrap OpenOffice on a Mac

2009-10-29 Thread Daniel Käfer

Hello,

I am trying to bootstrap OpenOffice on a Mac (with Java). On Linux it 
works perfect. On the Mac appear the Error no office executable found!


I looked at the Source from InstallationFinder.java (from the Netbeans 
Plugin) and found no special code for Mac.


Should this work on a Mac or should i patch the InstallationFinder.java 
to find the soffice?


Kind regards
Daniel Käfer


-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org



Re: [api-dev] Bootstrap OpenOffice on a Mac

2009-10-29 Thread Juergen Schmidt

Hi Daniel,

it is a known problem on the Mac and the InstallationFinder have to be 
extended for some Mac specific code. But we simply forgot it.-( Feel 
free to submit an issue for this problem.


Juergen


Daniel Käfer wrote:

Hello,

I am trying to bootstrap OpenOffice on a Mac (with Java). On Linux it 
works perfect. On the Mac appear the Error no office executable found!


I looked at the Source from InstallationFinder.java (from the Netbeans 
Plugin) and found no special code for Mac.


Should this work on a Mac or should i patch the InstallationFinder.java 
to find the soffice?


Kind regards
Daniel Käfer


-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org




-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org



Re: [api-dev] BASIC: Change toolbar button icon ?

2009-10-29 Thread Fernand Vanrie

Carsten,

Thanks for this cool peace of code, very usefull !

But :-)

My button installs fine but the macro behind the button (located in a 
document) is not working, i supose there is something wrong with the 
commandUIRL


The test() macro is located in a document in a Toolbarlib Library, in 
a ToolbarButtonsMod module


is use sMyToolbarCmdId = macro:///Toolbarlib.ToolbarButtonsMod.Test() 


any idea ?

Thanks

Fernand



Hello Carsten,
Just for let you know that almost all your posts in d...@api are labeled
as important in my local archive :-)
Thanks for sharing.
Keep it up!!

ciao
Paolo M


Carsten Driesner ha scritto:
  

Jan Holst Jensen wrote:


Hi all.

I am trying to emulate a togglebutton/checkbox in a custom toolbar.
Right now I have settled for having two toolbar buttons with different
icons. Only one of them is visible and when it's pressed it toggles
the visibility of both buttons using the code below (which sets
visibility of a single button with a given label).

It works OK but only as long as the user doesn't fiddle with button
visibility :-). Is there a way of changing a toolbar button's icon
directly from Basic code ? I could not figure out how to do it.
  

Hi Jan,

Your solution looks it a little bit strange. You can set the image of a
toolbar button with the help of an image manager. Look at the following
Basic code which uses the image manager to set an image for a button
that references a Basic macro. I am sure you can adapt the code to your
needs.

Regards,
Carsten

REM  *  BASIC  *

REM *** This example creates a new basic macro toolbar button on
REM *** the Writer standard bar. It doesn't add the button twice.
REM *** It uses the Writer image manager to set an external image
REM *** for the macro toolbar button.

Sub Main
REM *** String to reference toolbar
sToolbar = private:resource/toolbar/standardbar
REM *** Macro command to add
sMyToolbarCmdId = macro:///Standard.Module1.Test()

REM *** Retrieve the module configuration manager from central

module configuration manager supplier
oModuleCfgMgrSupplier =
createUnoService(com.sun.star.ui.ModuleUIConfigurationManagerSupplier)

REM *** Retrieve the module configuration manager with module
identifier
REM *** See com.sun.star.frame.ModuleManager for more information
oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager(
com.sun.star.text.TextDocument )
oImageMgr = oModuleCfgMgr.getImageManager()

oToolbarSettings = oModuleCfgMgr.getSettings( sToolbar, true )

REM *** Look for our button. Can be identified by the CommandURL

property.
bHasAlreadyButton = false
nCount = oToolbarSettings.getCount()
for i = 0 to nCount-1
oToolbarButton() = oToolbarSettings.getByIndex( i )
nToolbarButtonCount = ubound(oToolbarButton())
for j = 0 to nToolbarButtonCount
if oToolbarButton(j).Name = CommandURL then
if oToolbarButton(j).Value = sMyToolbarCmdId then
bHasAlreadyButton = true
end if
endif
next j
next i

Dim oImageCmds(0)

Dim oImages(0)
REM *** Check if image has already been added
if not oImageMgr.hasImage( 0, sMyToolbarCmdId ) then
   
REM *** Try to load the image from the file URL

oImage = GetImageFromURL( file:///c:/test.bmp )
if not isNull( oImage ) then
   
REM *** Insert new image into the Writer image manager

oImageCmds(0) = sMyToolbarCmdId
oImages(0) = oImage
oImageMgr.insertImages( 0, oImageCmds(), oImages() )
end if
end if

if not bHasAlreadyButton then

sString = My Macro's
oToolbarItem = CreateToolbarItem( sMyToolbarCmdId,
Standard.Module1.Test )
oToolbarSettings.insertByIndex( nCount, oToolbarItem )
oModuleCfgMgr.replaceSettings( sToolbar, oToolbarSettings )
end if
End Sub

Function GetImageFromURL( URL as String ) as Variant
Dim oMediaProperties(0) as new com.sun.star.beans.PropertyValue

REM *** Create graphic provider instance to load images from
external files
oGraphicProvider = createUnoService(
com.sun.star.graphic.GraphicProvider )

REM *** Set URL property so graphic provider is able to load the image
oMediaProperties(0).Name  = URL
oMediaProperties(0).Value = URL

REM *** Retrieve the com.sun.star.graphic.XGraphic instance
GetImageFromURL = oGraphicProvider.queryGraphic( oMediaProperties() )
End Function

Function CreateToolbarItem( Command as String, Label as String ) as Variant
Dim aToolbarItem(3) as new com.sun.star.beans.PropertyValue

aToolbarItem(0).Name = CommandURL
aToolbarItem(0).Value = Command
aToolbarItem(1).Name = Label
aToolbarItem(1).Value = Label
aToolbarItem(2).Name = Type
aToolbarItem(2).Value = 0
aToolbarItem(3).Name = Visible
aToolbarItem(3).Value = true

  

[api-dev] OOoBean: possible Bug with OOoBean.loadFromURL()

2009-10-29 Thread Steffen Boersig

Hey guys,

OOoBean.loadFromURL() is acting strange for different URL formats.

   //fileURL = E:\Test.ods
   String fileURL = file.getAbsolutePath();
   URL = Tools.convertToFileURL(fileURL);
   try
   {
   PropertyValue[] loadProperties = new PropertyValue[1];
   loadProperties[0] = new PropertyValue(ReadOnly, 0, new 
Boolean(false), PropertyState.DIRECT_VALUE);

   aBean.loadFromURL(URL, loadProperties);

In this snippet, a valid fileURL is created by a method of mine to 
ensure there are no backslashes in the file URL. ( E:\Test.ods == 
E:/Test.ods )

If I'm exectuing the code, all works fine and i can work with the document.
If I'm changing the code to

   //fileURL = E:\Test.ods
   String fileURL = file.getAbsolutePath();
   URL = file:/// + fileURL;
   try
   {
   PropertyValue[] loadProperties = new PropertyValue[1];
   loadProperties[0] = new PropertyValue(ReadOnly, 0, new 
Boolean(false), PropertyState.DIRECT_VALUE);

   aBean.loadFromURL(URL, loadProperties);

the document will be loaded as well. That's some nice feature of the 
loadFromURL() function to not enforce converting backslashes. BUT it is 
then opened in read only mode. Which in my opinion is strange and not 
intuitive for users of the api.
At first I had the second snippet implemented and everything was fine, 
because I worked with templates only, but after opening normal documents 
that read-only error occured. After some rewriting I found the problem, 
but I think this should be documented at least. If not fixed.
Except someone can explain me, why OOoBean should open fileUrls which 
aren't correct but prevent modifiying.


Regards,

Steffen Börsig

-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org



Re: [api-dev] OOoBean: possible Bug with OOoBean.loadFromURL()

2009-10-29 Thread Juergen Schmidt

Hi Steffen,

it is no specific problem of the bean. The bean calls internally 
loadComponentFromURL(...) and there is no difference. The behaviour 
sounds indeed strange and maybe somebody can comment it.


Anyway using a valid and correct Url is always a good idea.

Juergen


Steffen Boersig wrote:

Hey guys,

OOoBean.loadFromURL() is acting strange for different URL formats.

   //fileURL = E:\Test.ods
   String fileURL = file.getAbsolutePath();
   URL = Tools.convertToFileURL(fileURL);
   try
   {
   PropertyValue[] loadProperties = new PropertyValue[1];
   loadProperties[0] = new PropertyValue(ReadOnly, 0, new 
Boolean(false), PropertyState.DIRECT_VALUE);

   aBean.loadFromURL(URL, loadProperties);

In this snippet, a valid fileURL is created by a method of mine to 
ensure there are no backslashes in the file URL. ( E:\Test.ods == 
E:/Test.ods )

If I'm exectuing the code, all works fine and i can work with the document.
If I'm changing the code to

   //fileURL = E:\Test.ods
   String fileURL = file.getAbsolutePath();
   URL = file:/// + fileURL;
   try
   {
   PropertyValue[] loadProperties = new PropertyValue[1];
   loadProperties[0] = new PropertyValue(ReadOnly, 0, new 
Boolean(false), PropertyState.DIRECT_VALUE);

   aBean.loadFromURL(URL, loadProperties);

the document will be loaded as well. That's some nice feature of the 
loadFromURL() function to not enforce converting backslashes. BUT it is 
then opened in read only mode. Which in my opinion is strange and not 
intuitive for users of the api.
At first I had the second snippet implemented and everything was fine, 
because I worked with templates only, but after opening normal documents 
that read-only error occured. After some rewriting I found the problem, 
but I think this should be documented at least. If not fixed.
Except someone can explain me, why OOoBean should open fileUrls which 
aren't correct but prevent modifiying.


Regards,

Steffen Börsig

-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org




-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org



Re: [api-dev] OOoBean: possible Bug with OOoBean.loadFromURL()

2009-10-29 Thread Stephan Bergmann

On 10/29/09 13:14, Steffen Boersig wrote:

If I'm changing the code to

   //fileURL = E:\Test.ods
   String fileURL = file.getAbsolutePath();
   URL = file:/// + fileURL;
   try
   {
   PropertyValue[] loadProperties = new PropertyValue[1];
   loadProperties[0] = new PropertyValue(ReadOnly, 0, new 
Boolean(false), PropertyState.DIRECT_VALUE);

   aBean.loadFromURL(URL, loadProperties);

the document will be loaded as well. That's some nice feature of the 
loadFromURL() function to not enforce converting backslashes. BUT it is 
then opened in read only mode. Which in my opinion is strange and not 
intuitive for users of the api.


file:///E:\Test.ods is not a valid URL to denote Windows pathname 
E:\Test.ods (file:///E:/Test.ods would be correct).  I vaguely 
remember that the implementation of loadComponentFromURL indeed does 
somewhat strange things upon such invalid input (which would explain the 
read-only status; maybe there is already an issue for this?).


(By the way, E:/Test.ods is also not a valid URL to denote Windows 
pathname E:\Test.ods; it is an URL of the---unknown---schema e.  That 
loadFromURL happens to work as expected for such invalid input is a 
sad consequence of try to guess what the client wants software.)


-Stephan

-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org



Re: [api-dev] OOoBean: possible Bug with OOoBean.loadFromURL()

2009-10-29 Thread Steffen Boersig

Stephan Bergmann schrieb:
file:///E:\Test.ods is not a valid URL to denote Windows pathname 
E:\Test.ods (file:///E:/Test.ods would be correct).  I vaguely 
remember that the implementation of loadComponentFromURL indeed does 
somewhat strange things upon such invalid input (which would explain 
the read-only status; maybe there is already an issue for this?).


(By the way, E:/Test.ods is also not a valid URL to denote Windows 
pathname E:\Test.ods; it is an URL of the---unknown---schema e.  
That loadFromURL happens to work as expected for such invalid input 
is a sad consequence of try to guess what the client wants software.)


-Stephan

-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

I didn't know if loadFromURL can handle E:/Test.ods as well since my 
converting function adds file:/// and gets rid of backslashes to get a 
valid file URL ( file:///E:/Test.ods ). But tested it and at least there 
it throws an error and does not open in read only mode or sth. like that.
An error on ALL kinds of invalid urls would be great. Would make 
debugging easier.


Steffen Börsig

-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org



Re: [api-dev] OOoBean: possible Bug with OOoBean.loadFromURL()

2009-10-29 Thread Stephan Bergmann

On 10/29/09 14:59, Steffen Boersig wrote:
I didn't know if loadFromURL can handle E:/Test.ods as well since my 
converting function adds file:/// and gets rid of backslashes to get a 
valid file URL ( file:///E:/Test.ods ). But tested it and at least there 
it throws an error and does not open in read only mode or sth. like that.


I see.

An error on ALL kinds of invalid urls would be great. Would make 
debugging easier.


Yes, I agree.  The problem, however, is probably along the lines that 
loadComponentFromURL is also used to load whatever the user types on the 
command line or in the file open dialog etc., where the smart logic to 
understand that E:\Test.ods is a Windows pathname while 
file:///E:/Test.ods is a URL is called for.  (Not that all this could 
not probably be disentangled in a sane way, but just to give some 
context why things are the way they are...)


-Stephan


-
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org