[api-dev] Re: [users] Macro in 1.1.4 does not work in 2.0

2006-06-06 Thread Miguel Quirós
El lun, 05-06-2006 a las 21:35 -0400, Andrew Douglas Pitonyak escribió: 
> Miguel Quirós wrote:
> 
> >Hello. I am not sure if I am sending this message to the proper place.
> >In this case, I would be grateful for a reply telling me which this
> >proper place may be.
> >  
> >
> Anthony already indicated the best place to ask this question...
> 
> >I wrote a macro for OpenOffice 1.1.4 that used a sentence like the
> >following:
> >  encontrado = dispatcher.executeDispatch(document,
> >".uno:ExecuteSearch", "", 0, busqueda())
> >to perform a text search in a document and get a boolean value (stored
> >in the boolean variable encontrado) to check whether the search was
> >successful or not.
> >  
> >
> You are using the dispatcher, which works, but is more likely to change 
> than using regular API calls.
> >Could anyone tell me which kind of value (if any!) is returned by this
> >procedure in OpenOffice 2.0? How can I get now the boolean value I used
> >to get in Open Office 1.1?
> >  
> >
> I do not believe that this is really the best way to do this. When I 
> want to know what is returned, I usually end up looking at hte source 
> code, which is a very difficult thing to do (so I recommend against it). 
> If you obtained the macro using the macro recorder, perhaps you can 
> record the macro again. Otherwise, perhaps you can modify an existing 
> API example that is less likely to change. If all that you want to do is 
> to see if some text exists, then the following might work for you.
> 
>   Dim vDescriptor, vFound
>   ' Create a descriptor from a searchable document.
>   vDescriptor = ThisComponent.createSearchDescriptor()
>   ' Set the text for which to search and other
>   ' 
> http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchDescriptor.html
>  
> 
>   With vDescriptor
> .SearchString = "hello"
> ' These all default to false so you can comment them if you do
> ' not want them...
> .SearchWords = true
> .SearchCaseSensitive = False
>   End With
>   ' Find the first one
>   vFound = ThisComponent.findFirst(vDescriptor)
>   ' At this point, all you seemed to want to know was if it existed or not
>   ' Note, however, that the search as shown is from the START of the
>   ' document.
>   If IsNull(vFound) Then
> Print "The text did NOT exist"
>   Else
> Print "The text did exist and was found"
>   End If
> 
> If you set the variable "cursor" to something first, you should be able 
> to use "ThisComponent.findNext(cursor, vDescriptor)" to start from a 
> different location than the start.
> 

Thank you very much for your answer. As I told, I am not expert in
writing macros and I am just using the things that I can see are used by
the macro recorder (the dispatcher) and try to adapt them to my needs.
>From your answer, I deduce that there are methods easier to use than the
dispatcher (.searchString).

My needs are to search all occurrences of a determinate string in a
document and, in some cases just replace it by another simple string (in
which case I see that there is something called .replaceAll that may be
useful and easy to use) and in other cases by something more complicated
like putting a new string with special symbols, superindexes , etc in
it, in this case perhaps .replaceAll cannot do all the work.

As suggested, I am sending this message also to dev@api.openoffice.org

-- 
Miguel Quirós Olozábal
Departamento de Química Inorgánica. Facultad de Ciencias.
Universidad de Granada. 18071 Granada. SPAIN
email:mquirosugres
  mquirosugres

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[api-dev] Actual Size of com.sun.star.drawing.GraphicObjectShape

2006-06-06 Thread Kent Gibson
How does one get the ActualSize of a
GraphicObjectShape?

If I do this:

drawingTextShape = factory.createInstance( 
"com.sun.star.drawing.GraphicObjectShape"  );
XPropertySet xGraphicPropsGOS = ( XPropertySet )
UnoRuntime.queryInterface( XPropertySet.class,
drawingTextShape );
// the property GraphicObjectFillBitmap is actually
deprecated, however I no other choice
Object graphicObject =
xGraphicPropsGOS.getPropertyValue(
GRAPHIC_OBJECT_FILL_BITMAP );
XBitmap xGraphic = ( XBitmap ) AnyConverter.toObject(
XBitmap.class, graphicObject );
actualSize = xGraphic.getSize();

I get the number of pixels. But how do I get the
resolution so that I can find out how big the picture
would be in cm, or how do I get directly the picture
size?

I can get the XGraphic object but didn't seem to help
in getting the actual size.

If I use a com.sun.star.text.GraphicObject then I can
get the actualsize, but I am experiencing a strange
problem with whereby the first image after a page
break doesn't appear.

thanks.

kent

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] How to add a toolbar and its icons to a uno.pkg

2006-06-06 Thread Carsten Driesner

Jo wrote:

The mind boggles. I read:

http://api.openoffice.org/docs/DevelopersGuide/Components/Components.xhtml#1_9_1_UNO_Package_Installation_Using_unopkg, 


4.9.1

and

http://api.openoffice.org/docs/DevelopersGuide/Components/Components.xhtml,
4.7.3


several times. What I don't find in there is what names those files need to
have. OK, there is this:

example_addon.zip:
   Addons.xcu
   ProtocolHandler.xcu
   windows.plt/
   example_addon.dll


Hi Jo,




now what goes itno Addons.xcu and what goes into ProtocolHandler.xcu? There
is a lot of xml in the paragraphs preceding this example, from which I
distilled the following, since I only want to add a toolbar to my package:


The Developer's Guide has a whole chapter (4.7 Integrating Components 
into OpenOffice.org) explaining the ProtocolHandler.xcu and Addons.xcu.


The "Addons.xcu" contains the definition of the user interface of an 
add-on (e.g. which buttons are part of the add-on toolbar and which 
command URL should they execute).
The "ProtocolHandler.xcu" contains the association between the command 
URL schema and the implementation which executes the URL.





http://openoffice.org/2001/registry"; xmlns:xs="
http://www.w3.org/2001/XMLSchema"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";>
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   



http://openoffice.org/2001/registry";
xmlns:xs="http://www.w3.org/2001/XMLSchema"; oor:name="Addons" oor:package="
org.openoffice.Office">
   
   
   
   
   
   org.openoffice.Office.addon.example:Function1

   
   
   
   Function 1
   Funktion 1
   
   
   _self
   
   
   com.sun.star.text.TextDocument
   
   
   
   
   


Those are the examples, minus everything related to menus and help files.

I created a toolbar in OOo and I had hoped that I would be able to just 
grab

the code that I found in C:\Documents and Settings\MyUserName\Application
Data\OpenOffice.org2\user\config\soffice.cfg\modules\swriter\toolbar\custom_toolbar_1.xml


Add-ons uses a completely different mechanism to describe their user 
interface. Therefore you cannot use a plain toolbar xml file from that 
folder. Plain toolbar xml files just contain the command every button 
should execute. The Addons.xcu file contains more properties which makes 
sense for add-ons, e.g. Context, Title, UserDefinedImages, ...







http://openoffice.org/2001/toolbar";
xmlns:xlink="http://www.w3.org/1999/xlink"; toolbar:uiname="ETUC">
   

toolbar:text="Insert Logo" toolbar:helpid="
vnd.sun.star.script:ETUC.ETUC.InsertETUCLogo?language=Basic&
;location=application"/>
   

toolbar:text="Insert Footer" toolbar:helpid="
vnd.sun.star.script:ETUC.ETUC.InsertFooterFrame?language=Basic&
;location=application"/>
   

toolbar:text="Date Fr" toolbar:helpid="
vnd.sun.star.script:ETUC.ETUC.InsertEurDate?language=Basic&
;location=application"/>
   

toolbar:text="Date En" toolbar:helpid="
vnd.sun.star.script:ETUC.ETUC.InsertUSDate?language=Basic&
;location=application"/>
   

toolbar:text="Saut de page" toolbar:helpid="
vnd.sun.star.script:ETUC.ETUC.InsertPageBreak?language=Basic&
;location=application"/>
   

toolbar:text="concern." toolbar:helpid="
vnd.sun.star.script:ETUC.ETUC.InsertConcernTable?language=Basic&
;location=application"/>
   

toolbar:text="2 sign." toolbar:helpid="
vnd.sun.star.script:ETUC.ETUC.Insert2SignaturesTable?language=Basic&
;location=application"/>
   

toolbar:text="annex" toolbar:helpid="
vnd.sun.star.script:ETUC.ETUC.InsertAnnexes?language=Basic&
;location=application"/>
   

toolbar:text="Cc:" toolbar:helpid="
vnd.sun.star.script:ETUC.ETUC.InsertCc?language=Basic&
;location=application"/>


and here: C:\Documents and Settings\MyUserName\Application
Data\OpenOffice.org2\user\config\soffice.cfg\modules\swriter\images\sc_imagelist.xml 




OfficeDocument

1.0//EN" "image.dtd">
http://openoffice.org/2001/image";
xmlns:xlink="http://www.w3.org/1999/xlink";>
   
   
   
   
   
   
   
   


I even found this:

C:\Documents and Settings\MyUserName\Application
Data\OpenOffice.org2\user\config\soffice.cfg\modules\swriter\images\Bitmaps\sc_userimages.png 
The sc_userimages.png contains all user defined images. It's possible 
that this file contains more images than just your toolbar. The images 
are added horizontally to this single image file. You have to load the 
image file, cut every bitmap and store it (using the bitmap file 
format!) separately. Put your single image

[api-dev] "Spacing to Contents" in Tables

2006-06-06 Thread Kent Gibson
Is there any way to use the api to set the "Spacing to
Contents" parameter for a table?

If I use the dispatcher (see below) I can get no
spacing to contents with the mysterious flags=8, but I
am having a problem uno:InsertTable. Later when I call
getByName() it tells me the element does not exist.

thanks

#
Sub Main

rem
--
rem define variables
dim document   as object
dim dispatcher as object
rem
--
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher =
createUnoService("com.sun.star.frame.DispatchHelper")

rem
--
dim args1(3) as new com.sun.star.beans.PropertyValue
args1(0).Name = "TableName"
args1(0).Value = "Table1"
args1(1).Name = "Columns"
args1(1).Value = 1
args1(2).Name = "Rows"
args1(2).Value = 1
args1(3).Name = "Flags"
args1(3).Value = 8

dispatcher.executeDispatch(document,
".uno:InsertTable", "", 0, args1())
oTable =
ThisComponent.getTextTables().getByName("Table1")

end sub

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[api-dev] How to debug API usage

2006-06-06 Thread Bénigot Yves





I use open office 
developper release 2.0.3 on Linux with Java and UNO. Openoffice is started as a 
server under root
and accessed via jboss.
 
When I try to use 
storeToURL() to an RTF file I get 
"com.sun.star.task.ErrorCodeIOException", although the URL
seems 
correct (its a file url). Also running a test program under different conditions 
(eclipse client on Windows, to a
Linux server, instead of using the API as a jboss 
backend) works.
 
-> So I need to get more information about what goes 
wrong in my precise case.
 
Is there a way 
to get a trace of what happens on the openoffice side, to understand why the 
file write fails ? 
Is
there a journal file for errors ? or a debug switch 
?
 
Yves 
Benigot


Re: [api-dev] Actual Size of com.sun.star.drawing.GraphicObjectShape

2006-06-06 Thread Fernand Vanrie

do  a  archive search  for "graphicprovider"

Kent Gibson schreef:

How does one get the ActualSize of a
GraphicObjectShape?

If I do this:

drawingTextShape = factory.createInstance( 
"com.sun.star.drawing.GraphicObjectShape"  );

XPropertySet xGraphicPropsGOS = ( XPropertySet )
UnoRuntime.queryInterface( XPropertySet.class,
drawingTextShape );
// the property GraphicObjectFillBitmap is actually
deprecated, however I no other choice
Object graphicObject =
xGraphicPropsGOS.getPropertyValue(
GRAPHIC_OBJECT_FILL_BITMAP );
XBitmap xGraphic = ( XBitmap ) AnyConverter.toObject(
XBitmap.class, graphicObject );
actualSize = xGraphic.getSize();

I get the number of pixels. But how do I get the
resolution so that I can find out how big the picture
would be in cm, or how do I get directly the picture
size?

I can get the XGraphic object but didn't seem to help
in getting the actual size.

If I use a com.sun.star.text.GraphicObject then I can
get the actualsize, but I am experiencing a strange
problem with whereby the first image after a page
break doesn't appear.

thanks.

kent

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] How to add a toolbar and its icons to a uno.pkg

2006-06-06 Thread Jo

Mathias Bauer schreef:

Jo wrote:

  

The mind boggles. I read:

http://api.openoffice.org/docs/DevelopersGuide/Components/Components.xhtml#1_9_1_UNO_Package_Installation_Using_unopkg,
4.9.1

and

http://api.openoffice.org/docs/DevelopersGuide/Components/Components.xhtml,
4.7.3


several times. What I don't find in there is what names those files need to
have. OK, there is this:

example_addon.zip:
Addons.xcu
ProtocolHandler.xcu
windows.plt/
example_addon.dll


now what goes itno Addons.xcu and what goes into ProtocolHandler.xcu? There
is a lot of xml in the paragraphs preceding this example, from which I
distilled the following, since I only want to add a toolbar to my package:



The Addons.xcu file contains information about which buttons shall be in
the toolbar. The ProtocolHandler.xcu tells OOo which code it should load
to execute a certain command.

  

I'm starting to doubt that I'm smart enough for this stuff. It's great that
there is documentation, but I would be nice to find out what needs to be
saved in which files and it would be great to have an easy way to get from
what OOo generates to work with to what is expected for this uno.pkgstructure.



You are right, it would be nice to make things easier and we are working
on it. The plan is to have some tools that can generate the necessary
files and integrate these tools into NetBeans, Eclipse or our Basic IDE,
but this isn't done yet.

When these tools will be done all you will have to specify is which
commands shall be added to your toolbar or menu and which code shall be
bound to it. Until then you could study existing code to learn how the
things work together. Which programming language have you planned to use?

Best regards,
Mathias
  

Hi Mathias,

I'm working in OOo Basic. My personal preference goes to Python, since 
it's very clean and understandable, but since all the examples and 
available information exists in OOo Basic, I chose to use that. Where 
can I find examples of existing code? I'm sure that that would help a lot.


It's great to hear that you are working on an easier interface to 
accomplish the creation of .uno.pkgs. I'm afraid my customer won't be 
able until it's finished though. Is there any kind of ETA? Could it be 
that it might be finished in a month? Then I could ask for a delay. If 
it will most probably take more than a month, then I'll have to bite the 
sour apple and learn how to do it by hand. Any reference to an example 
will help tremendously in that case.


Kind regards,

Jo

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] how to make the macros available to all users of a Windows Terminal server

2006-06-06 Thread Jo

Mathias Bauer schreef:

Jo wrote:

  

Hi Carsten,

Many thanks for your answer. The next problem is that when logged on as 
a different user the library containing the macros is not available. I 
tried to also copy the basic code as follows:


C:\Documents and Settings\My Username\Application Data\OpenOffice.org2\user\basic\ETUC\*.* 


to C:\Program Files\OpenOffice.org 2.0\share\basic\ETUC\


But the module is not recognized any more. When I try to do it properly, 
then the Add... button becomes grey when I select Macros and Dialog 
boxes of OpenOffice.org.


Can you help me out on this one too?



I'm not Carsten but I hope I can help too. :-)

Basic has an administration file for all of its libraries and just
copying libraries won't help without updating this file. Unfortunately
this file is part of each user profile so it needs manual operations in
all user installations. Not recommended. Deploying libraries for all
users admittedly is a little bit awkward in OOo.

The best way is to create a UNO package from the libs and install it
with unopkg --shared.

Creating packages will be supported by the BasicIDE in OOo2.0.3. The
created packages of course will work in any OOo2 version.
  

Hi Mathias,

Of course you're welcome to help too. Did I read correctly that the next 
release of OOo will have an easy way to create these packages? Then I'll 
postpone trying to create them by hand. It's simply taking too much 
time. The estimate I made hardly even covered the creation of the macros 
themselves, let alone packaging them, but it's the best way to deliver 
them. That I'm convinced of by now.


Many thanks!

Jo

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] Re: [users] Macro in 1.1.4 does not work in 2.0

2006-06-06 Thread Andrew Douglas Pitonyak

Miguel Quirós wrote:


Thank you very much for your answer. As I told, I am not expert in
writing macros and I am just using the things that I can see are used by
the macro recorder (the dispatcher) and try to adapt them to my needs.

From your answer, I deduce that there are methods easier to use than the

dispatcher (.searchString).
 

Unfortunately, they are not easier, because you need to learn how things 
work inside of OOo.
Many examples are available that can be adapted to the problems that you 
want to solve. Also, sometimes the macro recorder works for what you 
want, and sometimes it does not.
I have a free macro document that contains many examples (this is 
different than my book):


http://www.pitonyak.org/AndrewMacro.odt

There are so many resources that I can not easily list them all. There 
are code snippets with examples:


http://codesnippets.services.openoffice.org/

There is a forum that you can search:

http://www.oooforum.org/


My needs are to search all occurrences of a determinate string in a
document 

You did not say why you wanted to search for every occurrence of the 
string. Ignoring the "replace it" part, here is an example that finds 
all occurrences:


Take a look at my macro document in section 7.14 titled  "Search And 
Replace". Does this help at all?



and, in some cases just replace it by another simple string (in
which case I see that there is something called .replaceAll that may be
useful and easy to use) and in other cases by something more complicated
like putting a new string with special symbols, superindexes , etc in
it, in this case perhaps .replaceAll cannot do all the work.

As suggested, I am sending this message also to dev@api.openoffice.org

 



--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]