Re: [api-dev] EMF converson API

2008-06-07 Thread Stephan Wunderlich
Hi Andreas,

in openoffice it is possible to import EMF images.
 Can anyone please tell me if API functions are available to load a EMF
 file and convert it to a bitmap format ( BMP, TIF ).

 This should possibly work on linux too.


the following Basic sample should do what you want ...

--
rem to be adjusted
source = fileurl to your emf file
aURL.complete = fileurl for the tiff file

emffile = StarDesktop.loadComponentFromURL(source,0,_blank,dimArray())

xExporter = createUnoService( com.sun.star.drawing.GraphicExportFilter )
xExporter.SetSourceDocument( emffile.currentController.currentPage )

Dim aArgs (1) as new com.sun.star.beans.PropertyValue
Dim aURL as new com.sun.star.util.URL

aArgs(0).Name  = MediaType
aArgs(0).Value = image/tiff
aArgs(1).Name  = URL
aArgs(1).Value = aURL
xExporter.filter( aArgs() )
emffile.close(true)
--

Hope that helps

Cheers

Stephan


Re: [api-dev] Using API remotely

2008-06-07 Thread Stephan Wunderlich
Hi Andy,

you are not by any chance the wildlife photographer, are you ?

I am trying to use the API from my portal on one Linux server to access
 OpenOffice running on a separate Linux server.  I took all the jars from
 OpenOffice and made them part my portal but I could only get the API to
 work
 after I installed OpenOffice.org on the portal server as well.  And I see
 that when I use the API for the first time on the portal server, OpenOffice
 is started up on the portal server.

 Do you have to have the complete OpenOffice.org application installed on
 the
 API client server and why does it start OpenOffice automatically on the
 client server?

 BTW I am using OpenOffice.org 2.4.

 Thanks for any info on this.


if you use something along the lines

xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();

and then get the MultiComponentFactory from this context the API will
attempt to connect a local running office and in case it can't find one
start an Office instance.

To connect a running office on another machine you will have to start it on
that machine with command line parameters like

soffice -accept=socket,host=0,port=PORT;urp;

and in your java program on the client you will have to use something like

--
public static void main(String args[]) {


String sConnectionString =
uno:socket,host=HOST,port=PORT;urp;StarOffice.NamingService;

XMultiServiceFactory xMSF = null;

// create connection(s) and get multiservicefactory
System.out.println( getting MultiServiceFactory );

try {
xMSF = connect( sConnectionString );
} catch( Exception Ex ) {
System.out.println( Couldn't get MSF+ Ex );
return;
}
System.out.println(Opening an empty Writer document);
myDoc = openWriter(xMSF);

}

public static XTextDocument openWriter(XMultiServiceFactory oMSF) {


//define variables
XInterface oInterface;
XDesktop oDesktop;
XComponentLoader oCLoader;
XTextDocument oDoc = null;
XComponent aDoc = null;

try {

oInterface = (XInterface) oMSF.createInstance(
com.sun.star.frame.Desktop );
oDesktop = ( XDesktop ) UnoRuntime.queryInterface(
XDesktop.class, oInterface );
oCLoader = ( XComponentLoader ) UnoRuntime.queryInterface(
XComponentLoader.class, oDesktop );
PropertyValue [] szEmptyArgs = new PropertyValue [0];
String doc = private:factory/swriter;
aDoc = oCLoader.loadComponentFromURL(doc, _blank, 0,
szEmptyArgs );
oDoc = (XTextDocument)
UnoRuntime.queryInterface(XTextDocument.class, aDoc);

} // end of try

catch(Exception e){

System.out.println( Exception  + e);

} // end of catch


return oDoc;
}//end of openWriter

public static XMultiServiceFactory connect( String connectStr )
throws com.sun.star.uno.Exception,
com.sun.star.uno.RuntimeException, Exception {
// Get component context
XComponentContext xcomponentcontext =
com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(
null );

// initial serviceManager
XMultiComponentFactory xLocalServiceManager =
xcomponentcontext.getServiceManager();

// create a connector, so that it can contact the office
Object  xUrlResolver  =
xLocalServiceManager.createInstanceWithContext(
com.sun.star.bridge.UnoUrlResolver, xcomponentcontext );
XUnoUrlResolver urlResolver =
(XUnoUrlResolver)UnoRuntime.queryInterface(
XUnoUrlResolver.class, xUrlResolver );

Object rInitialObject = urlResolver.resolve( connectStr );

XNamingService rName = (XNamingService)UnoRuntime.queryInterface(
XNamingService.class, rInitialObject );

XMultiServiceFactory xMSF = null;
if( rName != null ) {
System.err.println( got the remote naming service ! );
Object rXsmgr =
rName.getRegisteredObject(StarOffice.ServiceManager );

xMSF = (XMultiServiceFactory)
UnoRuntime.queryInterface( XMultiServiceFactory.class, rXsmgr );
}

return ( xMSF );
}
--

which should open a writer document on your remote machine.

Hope that helps

Regards

Stephan


Re: [api-dev] UserDefinedAttributes for TextSection....

2007-09-05 Thread Stephan Wunderlich
mmm ...
http://api.openoffice.org/docs/common/ref/com/sun/star/text/TextSection.html...
doesn't state that such a property exist.
Are you sure that it is a textsection we are talking about ?

2007/9/5, ashok _ [EMAIL PROTECTED]:

 I found that a TextSection in writer has a UserDefinedAttributes
 property.

 It seems to be a AttributeContainer type, and so I was able to set XML
 AttributeData values to it.  I did not receive any errors, but the
 values are never saved to the document.
 (i scanned both content.xml and meta.xml...)

 Is this property supported by the API or is it a bug ?

 ashok

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




Re: [api-dev] API - java

2007-04-02 Thread Stephan Wunderlich

Hi Michael,

if I remember correctly you can create an instance of
com.sun.star.document.FilterFactory which implements a
com.sun.star.container.XNameAccess to give you the information you look for.

Hope that helps

Regards

Stephan

2007/3/31, M. Niedermair [EMAIL PROTECTED]:


Hi,

how can i get all the installed filters (name and file-extenson, which
is also shown in the dialog) with the java-api?

By
Michael

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




Re: [api-dev] Macro writer to get filename document

2007-01-29 Thread Stephan Wunderlich

Hi Jurgen,

I'm looking for code to get the filename of the current document in  
writer.

In MS word is it like Activedocument.name but in Openoffice?


you can query the XModel from your document, which has a method getURL 
() that should do what you want.


Regards

Stephan

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



Re: [api-dev] Compare document

2007-01-22 Thread Stephan Wunderlich

Hi Sarath,

is there any possibility to perform Edit-Compare Document within  
the

API


the following macro should compare the current document with one of  
your choice and open the Accept or Reject changes dialog ...

---
dim xFrame   as object
dim xDispatchHelper as object

xFrame   = ThisComponent.CurrentController.Frame
xDispatchHelper = createUnoService(com.sun.star.frame.DispatchHelper)

dim args(0) as new com.sun.star.beans.PropertyValue
args(0).Name = URL
args(0).Value = file:///whereever the file is you want to compare  
the current document with
xDispatchHelper.executeDispatch(xFrame, .uno:CompareDocuments, ,  
0, args())

---

Hope that helps

Regards

Stephan

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



Re: [api-dev] get the currently selected shaoe from impress

2007-01-08 Thread Stephan Wunderlich

Hi there,


yes, I queryed with xshapes and used getbyindex method its working
fine...now the problem is on click of the shape iam calling macro  
which
should find which shape is clicked..for this getting the selected  
shape is
not working correctly...so is there any other(interfaces) way to  
find which

shape is clicked?


what do you mean with not working correctly ?
If only one shape is selected the getSelection() method will be a  
collection of shapes that consists of only one shape.
If you mean by clicking on it that you have a cursor inside the  
shape afterwards, than the selection is indeed the ShapeText ... is  
that what you meant by not working ?


Regards

Stephan

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



Re: [api-dev] get the currently selected shaoe from impress

2007-01-08 Thread Stephan Wunderlich

whether the getselection works when the shape is clicked during slide
show..i.e) when the shape is linked to macro and working fine in  
normal
impress document..when the slideshow is started is that possible to  
get

current  documents and shape selected.


in presentation view nothing is selected and so the selection changed  
event will most likely not be fired.
I suppose the easiest way to handle this would be to create one  
method for each shape where the shape's name is handed over to a  
method that does what has to be done with all shapes.


Somethings like

sub shape1_click
doShapeStuff(Shape1)
end sub

sub doShapeStuff(ShapeName as String)
xShape=ThisComponent.DrawPages(0).getByName(ShapeName)
'...
' do something brilliant :-)
'...
end sub

Hope that helps

Regards

Stephan

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



Re: [api-dev] document.Settings: how to set PrinterIndependentLayout?

2007-01-08 Thread Stephan Wunderlich

Hi Arthur,

I seem to have gone temporarily blind, but I can't figure out how  
to set the PrinterIndependentLayout property as described under
http://api.openoffice.org/docs/common/ref/com/sun/star/document/ 
Settings.html#PrinterIndependentLayout


you can query the interface css.lang.XMultiServiceFactory.
With this MultiServicefactory you can create an instance of  
com.sun.star.text.DocumentSettings.
The object you get with that you can query to an  
css.beans.XPropertySet which should contain the property you are  
looking for.


Hope that helps

Regards

Stephan

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



Re: [api-dev] Getting the XComponent out of a XFrame in a UNO Component

2006-12-18 Thread Stephan Wunderlich

Hi Tobias,


after testing, I wrote this little test method:
-%-
public void test() {
XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class,
this.xComponent);
com.sun.star.frame.XController xController =
xModel.getCurrentController();

System.out.println(this.xComponent);

System.out.println(xController);

XComponent myComp = (XComponent)
UnoRuntime.queryInterface(XComponent.class,
xController);

System.out.println(myComp.equals(this.xComponent));
}
-%-

In my Opinion the last line should return true. Am I right? But for  
me,

it prints false...


Nope ... the java method equals won't work properly with UNO-Objects  
and as far as I remember always return false.


Beside this you seem to compare the XComponent gained from the  
document with the one gained from the document view which are  
unlikely to be equal anyway.


Regards

Stephan

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



Re: [api-dev] Getting the XComponent out of a XFrame in a UNO Component

2006-12-18 Thread Stephan Wunderlich

Hi Tobias,

That is interesting. Thank you. But if I continue the code the  
following

way, I run into troubles (xPrintable will be null):
-%-
// Querying for the interface XPrintable on the loaded document
XPrintable xPrintable = (XPrintable)
UnoRuntime.queryInterface(XPrintable.class, myComp);
-%-

How to solve this?


even though I'm not the Stephan you addressed ;-)
I'd try to query the XPrintable at you xModel instead of myComp.

Regards

Stephan

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



Re: [api-dev] listener in Calc

2006-12-17 Thread Stephan Wunderlich

Hi Jörg,


when i go to the print preview and i leave the print preview, then OOo
is crashed in this moment. crashed means that the complete
OOo-Applikation goes down, all open windows/dokuments are closed,  
in my

words: 'OOo is dead'.


Just a wild guess ... but when you switch to the print preview the  
original view is disposed and since the listener you added to the  
view isn't removed the office might crash.


It might be helpful if you add an event listener to the XComponent  
you should be able to query from the view and when it is called to  
remove all listeners you previously added.


Just an idea ... hope it helps

Regards

Stephan


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



Re: [api-dev] how to find Properties Available

2006-12-06 Thread Stephan Wunderlich

Hi Mikael,


I wonder where I can find a list of all property available for a
XCellRange object.

Actually I want to get the number of columns and the number of rows  
of a
cell range. I've tried with the Size properties but that don't give  
the

number of rows and columns, it gives the height and width of the cell
range.

Here's what I would :

--
Reference XCellRange  aCellRange =
pCalc-getCellRangebyString(A1:B4);
Reference beans::XPropertySet  xPropSet (aCellRange,UNO_QUERY);

uno::Any nRow =
xPropSet-getPropertyValue(rtl::OUString::createFromAscii(NRow));
sal_Int32 n;
nRow = n;



You could query the interface css.table.XColumnRowRange of your  
CellRange.
This interface has the methods getColumns() and getRows(), which  
return css.table.XTableColumns and css.table.XTableRows respectively.
Both these Interfaces can be queried to an css.container.XIndexAccess  
which has the method getCount().


Hope that helps

Regards

Stephan

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



Re: [api-dev] Open document in same window (OOBean)

2006-12-01 Thread Stephan Wunderlich

Hi Joan,


Sorry, maybe I didn't explain properly...

I load a document, and when a load another one the first one  
disappears

and it's not under the Window menu label. I'd like to be able to load
different documents and make them accessible through that label.


 ... you only have one window and so the window menu will only  
show this one ... I can't see how to get not really existing windows  
in there :-)


If you opened your documents in a sequence they might be in File- 
Recent Documents though.


Regards

Stephan

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



Re: [api-dev] XDispatchHelper / XModel in XEnumeration

2006-11-17 Thread Stephan Wunderlich

Hi there,


I want to parser a document and trigger a XDispatchHelper at certain
points. I need the XModel object for doing it but when I get to this
line:

XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class,field);

xModel is null What am I doing wrong??


well textfields don't implement the Interface XModel as far as I  
know. You will have to get it from the document your field is in.


Hope that helps

Regards

Stephan

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



Re: [api-dev] XDispatchHelper / XModel in XEnumeration

2006-11-17 Thread Stephan Wunderlich

Hi Joan,


Thanks Stephan, that was really helpful!


you are very welcome.


The problem is that I don't really get (maybe because of my English)
what is every class... What's a model, a controller, a component, a
frame, etc


it is not that easy to understand methinks :-)

From http://api.openoffice.org/docs/DevelopersGuide/OfficeDev/ 
OfficeDev.xhtml ...


The Frame-Controller-Model (FCM) paradigm in OpenOffice.org separates  
three application areas: document object (model), screen interaction  
with the model (controller) and controller-window linkage (frame).


 -  The model holds the document data and has methods to change  
these data without using a controller object. Text, drawings, and  
spreadsheet cells are accessed directly at the model.


 -  The controller has knowledge about the current view status of  
the document and manipulates the screen presentation of the document,  
but not the document data. It observes changes made to the model, and  
can be duplicated to have multiple controllers for the same model.


 -  The frame contains the controller for a model and knows the  
windows that are used with it, but does not have window functionality.


The purpose of FCM is to have three exchangeable parts that are used  
with an exchangeable window system.


Hope that clarifies things a bit.

Regards

Stephan

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



Re: [api-dev] How to get the XStyleFamiliesSupplier from a Presentation and Drawing?

2006-11-16 Thread Stephan Wunderlich

Hi Tobias,


I try to set the printer tray for documents an need the
XStyleFamiliesSupplier for a presentation and a drawing document.  
With a

XTextDocument I do it this way:
-%-
// Get the StyleFamiliesSupplier interface of the document
XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)
UnoRuntime.queryInterface(XStyleFamiliesSupplier.class,
xTextDocument);
-%-

Can you tell my, how to retrieve it for a presentation and a drawing?


Both Draw and Impress documents implement the interface  
XStyleFamiliesSupplier ( see for example http://api.openoffice.org/ 
docs/common/ref/com/sun/star/drawing/ 
GenericDrawingDocument.html ) ... so you should be able to gather it  
in the same way you do it for the Writer document.


Regards

Stephan

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



Re: [api-dev] Search PageStyle Property Name for Presentation and Draw Documents

2006-11-16 Thread Stephan Wunderlich

Hi Tobias,


For both, the Presentains and the Drawings, a UnknownPropertyException
is thrown. Can you tell me the PropertyNames?


I'm not aware of PageStyles in Draw or Impress so there might well be  
no such Property :-)


Regards

Stephan

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



Re: [api-dev] how to copy textsection from a writer document to another ?

2006-11-07 Thread Stephan Wunderlich

Hi Oliver,


thanks for the code snippet, i can use it as a workaround:

- - first copy  paste the section
- - second copy the properties of the paragraph styles


why do you need the first step ? The code snippet copies the content  
of the textsection already.
Copy  Paste is a wee bit tricky as it is asynchronly done by  
dispatch and you so never know when it is really done :-)


but what i am really looking for is to store a textsection as url,  
or serialize it ...


The only way I can think of is extend the given snippet, so that all  
children of the textsection are copied including text tables and  
text frames.


Nicer would be if a text section would implement the  
com.sun.star.util.XCloneable interface so that you could create a  
clone and insert this as text content in a new document ... but that  
it doesn't as far as I know.


Somethings I haven't considered yet is to use the ContentExporter and  
the parse the xml-stream ... not sure if that is any easier than  
travelling through the structure of the text section and rebuild it  
that way in a second document which you then save.


Not sure if that helps.

Regards

Stephan

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



Re: [api-dev] how to copy textsection from a writer document to another ?

2006-11-06 Thread Stephan Wunderlich

Hi Oliver,

is there a possibility to copy a textsection from a source document  
to a

destination document using the api ?

At the moment i am using copy  paste but this has the disadvantage
of loosing the paragraph format ...

any hints ?


the following macro will copy the first section of the current  
document into a new document.
It doesn't handle TextTables, TextFrames of TextSections that might  
be in the given section.


Hope that helps

Regards

Stephan

-- The Macro --
Sub Main
xSection = ThisComponent.TextSections(0)

xDoc = StarDesktop.loadComponentFromURL(private:factory/ 
swriter,_blank,0,dimarray())

xText = xDoc.getText()
xTextCursor = xText.createTextCursor
xSecondSection = xDoc.createInstance(com.sun.star.text.TextSection)
xText.insertTextContent(xTextCursor, xSecondSection, false)
cloneProperties(xSection, xSecondSection)

xorgCursor = xSection.getAnchor
xnewCursor = xSecondSection.getAnchor
xnewText = xnewCursor.getText()

xDoc.lockControllers
On Error resume next
xEnum = xorgCursor.createEnumeration
while xEnum.hasMoreElements
xPara = xEnum.nextElement
xPortions = xPara.createEnumeration
while xPortions.hasMoreElements
xPortion = xPortions.nextElement()
xnewText.insertString(xnewCursor,xPortion.getString(),true)
cloneProperties(xPortion,xnewCursor)
xnewCursor = xnewCursor.getEnd()
wend

wend

xDoc.unlockControllers

End Sub

function cloneProperties(original, clone)
On Error resume next
properties = original.getPropertySetInfo.getProperties
for i=0 to UBound(properties)
aName = properties(i).Name
aValue = original.getPropertyValue(aName)
if (NOT isNull(aValue)) AND (NOT isEmpty(aValue)) then
clone.setPropertyValue(aName,aValue)
endif
next
end function


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



Re: [api-dev] Changing menus of a document in background

2006-11-06 Thread Stephan Wunderlich

Hi Tobias,
I have one more question. I would like to change the menus in a  
document
in the background. Up to now I can change menus for loaded  
documents in

the foreground. Here is the code:
-%-
XPropertySet xps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class,
xDesktop.getCurrentFrame());

XLayoutManager xLayoutManager = (XLayoutManager)
UnoRuntime.queryInterface(XLayoutManager.class,
xps.getPropertyValue(LayoutManager));
-%-

With this code (getCurrentFrame) I can only get the XLayoutManager of
the foreground Window.

Background info: I wrote a java application that opens a document.
Shortly after loading the document I start changing the menus. It can
happen that meanwhile an other OO Document comes in foreground and I
change the menus of this foreground window.

How can I get the XLayoutManager of the XComponent I am working on  
with

my application?


You could query the Interface com.sun.star.frame.XModel from you  
document.
This has a method getCurrentController() which returns a  
com.sun.star.frame.XController.
Now you could use the method getFrame() of this interface and so  
get the XFrame your document resides in.


Hope that helps

Regards

Stephan

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



Re: [api-dev] Name of merged file.

2006-09-28 Thread Stephan Wunderlich

Hi Knut,


Is there any way to find the name of the file generated from
MailMerge.execute( args() )?
I don't like guessing :)


guessing can be fun at times ;-)

I think for your problem the  
com.sun.star.frame.GlobalEventBroadcaster comes in handy. It can be  
created at the XMultiServiceFactory you gained after connecting the  
office or if you are in Basic with the help of the method


createUnoService(com.sun.star.frame.GlobalEventBroadcaster )

This broadcaster has the method addEventListener, where you can add  
a com.sun.star.document.XEventListener


The call-back function notifyEvent of this listener has the argument  
Event, which is an com.sun.star.document.EventObject
If it's EventName is OnUnload you can ask the Event for it's Source  
and call the method getURL() at it.

With the last step you should have the URL of the document.

Hope that helps

Regards

Stephan

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



Re: [api-dev] Obscure documentation (Was: [api-dev] insertnewbookmark)

2006-09-26 Thread Stephan Wunderlich

Hi Knut,

Ok, thanx. I'll make shure to file issues. There is a lot of them..  
Starting
with:  69861 http://www.openoffice.org/issues/show_bug.cgi? 
id=69861 and

69863 http://www.openoffice.org/issues/show_bug.cgi?id=69863


That is great :-) ... As you already pointed out a good documentation  
is crucial if external developers should be attracted to program for  
OOo.

So every step to make it better is one in the right direction :-)


Two euro is quite alot, I could eat lunch for that :)


Bon appetit :-)

Kind Regards

Stephan



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



Re: [api-dev] insertnewbookmark

2006-09-25 Thread Stephan Wunderlich

Hi Knut,


I can't get insertnewbookmark to work.
http://api.openoffice.org/docs/common/ref/com/sun/star/text/ 
XBookmarkInsertTool.html


From the documentation it looks to me that I sould be able to do:
ThisComponent.Text.InsertNewDocument(Cursor, TheBookMark)

What am I doing wrong?


I couldn't find any service that pretends to implement the Interface  
XBookmarkInsertTool, so I suppose it has never been implemented.


So the following seems to be the way to go when you want to insert a  
bookmark


xText = ThisComponent.getText()
xTextCursor = xText.createTextCursor()
aBookmark = ThisComponent.createInstance(com.sun.star.text.Bookmark)
aBookmark.Name=myBookmark   
xText.insertTextContent(xTextCursor, aBookmark, false)

Hope that helps

Regards

Stephan

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



Re: [api-dev] Listening to TextRange string

2006-09-20 Thread Stephan Wunderlich

Hi Julien,

Is there a way to be notified when the content (the string, I mean)  
of a TextRange is changed ?


I feel that the answer is negative, from some mails I've read in  
this list, but in case there is a miracle...


As far as I know there is no way to be notified when a specific  
XTextRange is changed.


TextRange publishes XPropertySet, which enables registration of a  
property listener, but there is no such thing as a 'string'  
property (at least, documented).


The PropertyChanged event is called for bound properties and the  
PropertyVeto event is called for constrained properties. The  
XPropertySet has as far as I know neither of them and so the  
Listeners will never be called anyway.



Thank you if you know a trick on this,


If you are just after changes via UI you could add a ModifyListener  
to your document and in case it is called you could get the  
ViewCursor and so have the currently changed TextRange.


Hope that helps

Regards

Stephan

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



Re: [api-dev] GraphicProvider and export of graphics

2006-09-04 Thread Stephan Wunderlich

Hi Jimmy,

I'm trying to get hold of the GraphicProvider to store images of a  
Writer document.


the code snippet ... http://codesnippets.services.openoffice.org/ 
Writer/Writer.ExtractGfx.snip ... seems to do what you want.


Regards

Stephan

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



Re: [api-dev] How can I concatenate a stream word collection

2006-09-02 Thread Stephan Wunderlich

Hi there,

Now I am merging the documents using URL and then store the merged  
document
on disk. I have some HTML files that are converted on WORD files  
(stream)
after they are merged on only one WORD document. You can see the  
result by
the attached files. The final document looses the text format and  
the others

documents only appear their code. Why?


Not sure why you use the way via HTML to merge the documents, but  
there might be some problems with formatting when using this filter.


The codesnipped ... http://codesnippets.services.openoffice.org/ 
Writer/Writer.MergeDocs.snip ... might give you an idea how to merge  
several documents into one.


http://api.openoffice.org/docs/DevelopersGuide/OfficeDev/ 
OfficeDev.xhtml#1_1_5_1_Loading_Documents ... should give you some  
general information on the ways to load documents.


Hope that helps

Regards

Stephan

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



Re: [api-dev] How can I concatenate a stream word collection

2006-09-01 Thread Stephan Wunderlich

Hi there,


I need to merge some Word files that are streams. I receive it as a
InputStream collection and I must generate a OutputStream.

I am already able to load them as XInputStream into OpenOffice I  
but How can

I write a new word document that contains the previous merged?


After merging your documents into one you should have an  
XTextDocument which supports the Interface XStorable.
So you should be able to store the Document with code like the  
following in MS Word format.


Dim args(0) as new com.sun.star.beans.PropertyValue
args(0).Name = FilterName
args(0).Value = MS Word 97
destination = file:///myhome/documents/output.doc
xStorable.storeAsURL(destination,args())

Hope that helps

Regards

Stephan

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



Re: [api-dev] setting url for the string

2006-09-01 Thread Stephan Wunderlich

Hi there,

I need to assign a url to a string and then the string should be  
shown in
the text document..for example if i set a string in the way  
given below


String test
xTextRanget.setString(test);

the String test should be linked to url say www.gmail.com...this is  
what i

need can any one help me...


the following macro should do what you want

  xText = ThisComponent.getText()
  xTextCursor = xText.createTextCursor()
  xTextCursor.setString(www.openoffice.org)
  xTextCursor.HyperLinkTarget = http://www.openoffice.org;
  xTextCursor.HyperLinkURL = http://www.openoffice.org;

Hope that helps

Regards

Stephan

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



Re: [api-dev] setting url for the string

2006-09-01 Thread Stephan Wunderlich

Hi,

Thanx for the reply. i think the code u sent is a basic code. is  
there any
examples in java since i saw that there is no method named  
HypeLinkUrl in

XTextCursor and XTextRange interfaces...


If you query the XPropertySet from your XTextRange/XTextCursor you'll  
be able to set the property HyperLinkURL and HyperLinkTarget.
These are listed in com.sun.star.style.CharacterProperties ( http:// 
api.openoffice.org/docs/common/ref/com/sun/star/style/ 
CharacterProperties.html ).


Hope that helps

Regards

Stephan

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



Re: [api-dev] How can I concatenate a stream word collection

2006-09-01 Thread Stephan Wunderlich

Hi there,


I am newer in OpenOffice. Could you give me some example that use
XTextDocument?
Because I am understanding. Below theres is a pience of code that I  
am using

but it doesn't work.


 public OutputStream comporDocumentosDocParaDoc(List colecao)
  throws java.io.IOException, DocumentException, IOException,
IllegalArgumentException, BootstrapException
  {
ConversorDeDocumento conversor = new ConversorDeDocumento();
//prepare base document
//move the document to byteArray
InputStream docBase = (InputStream)colecao.get(0);
ByteArrayOutputStream arrayByteDocBase = new  
ByteArrayOutputStream();

docBase.toString();
IOUtils.copy(docBase,arrayByteDocBase);
//via URL
File arqBase = new File(M:\\Aloizio_SS\\SINF2\\DOCS\\arq0.doc);
FileOutputStream fout = new FileOutputStream(arqBase,true);
fout.write(arrayByteDocBase.toByteArray());
fout.close();

//upload the base document into open office
XComponent docFinal =
  carregarDocumentoOpenOffice(arqBase, DOC);

//iterator over document list
for(int i = 1; i  colecao.size(); i++)
{
  InputStream arqDoc = (InputStream)colecao.get(i);
  //move the document to byte array
  ByteArrayOutputStream arrayByteDoc = new ByteArrayOutputStream 
();

  IOUtils.copy(arqDoc,arrayByteDoc);

  //via URL
  File arqDocAux = new
File(M:\\Aloizio_SS\\SINF2\\DOCS\\arq+i+.doc);
  FileOutputStream foutAux = new FileOutputStream(arqDocAux);
  foutAux.write(arrayByteDoc.toByteArray());
  foutAux.close();


  //consulta a interface XTextDocument para obter o texto
  XTextDocument mxDoc =
(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,  
docFinal);

  XText mxDocText = mxDoc.getText();
  // create a cursor
  XTextCursor mxDocCursor = mxDocText.createTextCursor();
  mxDocCursor.gotoEnd(false);

  XDocumentInsertable lXDocInsertable = (XDocumentInsertable) 
UnoRuntime.

  queryInterface(XDocumentInsertable.class, mxDocCursor);

  PropertyValue[] loadProps = new PropertyValue[0];
  String url = createUNOFileURL(arqDocAux.getAbsolutePath());
  OOInputStream oois = new OOInputStream 
(arrayByteDoc.toByteArray());

  PropertyValue[] loadProps = new PropertyValue[3];
  loadProps[0] = new PropertyValue();
  loadProps[0].Name = Hidden;
  loadProps[0].Value = new Boolean(true);
  loadProps[1] = new PropertyValue();
  loadProps[1].Name = FilterName;
  loadProps[1].Value = new Boolean(true);
  loadProps[2] = new PropertyValue();
  loadProps[2].Name = InputStream;
  loadProps[2].Value = oois;
  lXDocInsertable.insertDocumentFromURL(private:stream,  
loadProps);

}

XStorable xstorable = ( XStorable ) UnoRuntime.queryInterface(
XStorable.class,
docFinal );



here you query XStorable, which should work properly, but you don't  
use it to actually store the document.



XComponent xComponent = ( XComponent ) UnoRuntime.queryInterface(
XComponent.class, xstorable );
xComponent.dispose();


Here you dispose the document and with that destroy it ... generally  
XCloseable.close() should work smoother :-)



byte[] docFundido = obterDocumentoComposto(docFinal);
InputStream fim = new ByteArrayInputStream(docFundido);
OutputStream out = new ByteArrayOutputStream();
IOUtils.copy(fim,out);
return out;


mmm ... some lines above you dispose docFinal and now you try to  
write something related to it to a java  output stream ?


Is the goal to have a Microsoft word document on disk after merging  
several document in one ?


I'm a bit lost here.

Regards

Stephan

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



Re: [api-dev] how to remove final paragraph?

2006-08-25 Thread Stephan Wunderlich

Hi Jimmy,

Well you're right, there must be something spooky about my  
bookmarks, that's why I went looking a little further. You were  
right this works just fine, BUT (who would have expected that) I do  
have a section around the paragraph at first which I remove either by


currSect.dispose();or
xText.removeTextContent(currSect);

Both work fine, afterwards I'm left with the same xml as if there  
has never been any section. So I'm executing the code you  
proposed AND it doesn't remove the silly bookmark.


So can you beat that? :)


I'll try my best ;-)

Ok now I put my last paragraph into a TextSection and execute

xSection = ThisComponent.TextSections(0)
xText = ThisComponent.getText()
xPCursor = ThisComponent.Text.CreateTextCursor

xText.removeTextContent(xSection)

while xPCursor.gotoNextParagraph(false)
wend
msgbox last Paragraph
xPCursor.gotoEndOfParagraph(false)
xPCursor.gotoStartOfParagraph(true)
xPCursor.setString()

Afterwards the section and the bookmark are gone.
Are you sure that there isn't an empty paragraph behind your section ?

Regards

Stephan

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



Re: [api-dev] how to remove final paragraph?

2006-08-24 Thread Stephan Wunderlich

Hi Jimmy,

The following problem only occurs, if I'm trying to remove the very  
last paragraph of my Writer document with my Java Addon.

I'm left with the following structure at the end of the document:

.
text:p text:style-name=ElmlGoals
text:bookmark-start text:name=goals/
text:bookmark-end text:name=goals/
/text:p

Alright now I can't seem to be able to remove the paragraph  
including it's bookmark with the following code:


xParaCursor.gotoNextParagraph(false);
xParaCursor.gotoPreviousParagraph(true);
xParaCursor.setString();

The code works fine if there's another paragraph following. This  
makes even a little sense to me, since I can't go on to the next  
paragraph if there's no more, but how am I supposed to remove the  
paragraph with it's content? Do I have to do this with enumeration  
although it works everywhere else? How can I enumerate a paragraph  
if all I've got is the XParaCursor


xPCursor = ThisComponent.Text.CreateTextCursor
while xPCursor.gotoNextParagraph(false)
wend
msgbox last Paragraph
xPCursor.gotoEndOfParagraph(false)
xPCursor.gotoStartOfParagraph(true)
xPCursor.setString()

removes the content of the last paragraph for me.

Hope that helps

Regards

Stephan

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



Re: [api-dev] create bookmark at current location

2006-08-23 Thread Stephan Wunderlich

Hi Max,
in java I try to write a add-on that creates a bookmark at the  
current cursor location in a swriter document.

The following code works well for usual texts passages in swriter.
When I run the add-ons with the current cursor location in a table  
(pure openoffice tabel, no shreadsheet) it does not work.

How do I handle this case?


You'll have to treat the case that you are in a texttable seperately.
For this you first need to know if you are in a texttable or not :-)
Fortunately the ViewCursor has a property called TextTable and if  
this isn't empty you know that you are in a texttable.
If that is the case methinks there was a property Cell at the Cursor  
that shouldn't be empty now.

Let's say you got that and called it xCell, then something like

xCell.getText().insertTextContent(xCell,xTextContent,false);

should work.

Hope that helps

Regards

Stephan

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



Re: [api-dev] Modifiable styled mutliline fields

2006-08-23 Thread Stephan Wunderlich

Hi Jan,


I need some special kind of field which
- can consist of multiple lines of styled text (for example, the  
second word in the second line is bold)

- knows whether the user has modified portions of it
- does not regard itself as modified if text is inserted  
immediately before or after it

- has a unique identifier which can be read and set through the api
- is displayed in oowriter as styled text (for example, the second  
word in the second line is bold),

 perhaps with a grey background like other fields

Does anyone can give me a clue how this is possible at all without  
rewriting half of openoffice?


Have you considered using a TextSection for this purpose ... seems to  
me that it fulfils what you need. The only tricky thing could be the  
modified stage this I don't think that sections implement a  
XModifyListener or something comparable.


Hope that helps

Regards

Stephan

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



Re: [api-dev] BorderDistance or Spacing to Contents in a Frame

2006-06-23 Thread Stephan Wunderlich

Hi Kent,


If you do not have a border in a frame you are not
allowed to set what is referred to in the UI as
Spacing to Contents. I observe that without a border
LeftBorderDistance, RightBorderDistance, etc are
ignored.

Is there no way to get around this? The only success I
have had is with transparent colors, but then you can
sometimes see them in pdf outputs. I just want a frame
with an internal margin and no borders.

I am thinking of submitting a feature request. The
code below creates a frame with a border and a large
spacing to contents. If you leave out the borders it
puts them in. Zero for the line widths doesn't work
either.


instead of trying to set the distance to a non existing border you could 
try to set the margins of the text inside the frame.


Something like the following seems to do what you want

--
 oFrame = ThisComponent.createInstance(com.sun.star.text.TextFrame )
 oFrame.Width = 16000

 aBorder = createUnoStruct(com.sun.star.table.BorderLine )

 oFrame.TopBorder = aBorder
 oFrame.BottomBorder = aBorder
 oFrame.LeftBorder = aBorder
 oFrame.RightBorder = aBorder

 ThisComponent.Text.insertTextContent(ThisComponent.Text.Start, oFrame, 
false )

 oFrame.Text.String = Hello, this text is within the frame.+chr(13)
 xFrameText = oFrame.Text
 xFirstParagraph = xFrameText.createEnumeration.nextElement
 xFirstParagraph.ParaLeftMargin=5000
 xFirstParagraph.ParaRightMargin=5000
 xFirstParagraph.ParaBottomMargin=5000
 xFirstParagraph.ParaTopMargin=5000
--

Hope that helps

Regards

Stephan

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



Re: [api-dev] not deleting bookmarks

2006-06-19 Thread Stephan Wunderlich

Hi Knut,


These are all good workarounds or hacks, and I can use them temporary,
but wouldn't it be best to look at the design and find a good solution
that would make OpenOffice.org a usable platform? What would it take
to go for a real solution. Would anyone care?  Who would I talk to and
would they listen, or would they say use the source, Luke, and point
me to the cvs?


These are indeed workarounds for temporary use ... to get the real 
problem fixed you'll have to write a issuzilla task.


Regards

Stephan

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



Re: [api-dev] not deleting bookmarks

2006-06-16 Thread Stephan Wunderlich

Hi Knut,


Unfortunately I did not cut and paste the code from the actual code,
but here is some code copied and pasted from the actual program. And
the bookmark comes _after_ the inserted text.

dispatcher.executeDispatch(Dok.CurrentController.Frame,
.uno:InsertPagebreak, , 0, Array())

Cursor.gotoEnd( false )
Bookmark = Dok.createInstance(com.sun.star.text.Bookmark)
Bookmark.Name = NyttDok
Dok.Text.insertTextContent( Cursor, Bookmark, False )

Cursor.gotoEnd( false )
Cursor.collapseToEnd()
Cursor.goRight(1, false)

Cursor.insertDocumentFromURL( ConvertToURL(KSMal3$), Array() )


looks indeed like an issue to me ... it doesn't seem to be possible to 
position the cursor behing the bookmark when the bookmark is the last 
element in that line ... something like


Dok=ThisComponent
Cursor=Dok.Text.createTextCursor
Cursor.gotoEnd( false )
Bookmark = Dok.createInstance(com.sun.star.text.Bookmark)
Bookmark.Name = NyttDok
Dok.Text.insertTextContent( Cursor, Bookmark, False )
Cursor.String=.
Cursor.insertDocumentFromURL( ConvertToURL(KSMal3$), Array() )

works tho and places the dokument behind the bookmark.

Regards

Stephan

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



Re: [api-dev] not deleting bookmarks

2006-06-16 Thread Stephan Wunderlich

Hi Knut,

and if you want to keep the bookmark after insertion ...

Dok=ThisComponent
Cursor=Dok.Text.createTextCursor
Cursor.gotoEnd( false )
Bookmark = Dok.createInstance(com.sun.star.text.Bookmark)
Bookmark.Name = NyttDok
Dok.Text.insertTextContent( Cursor, Bookmark, False )
Cursor.String=.
Cursor.collapseToEnd()
Cursor.insertDocumentFromURL( ConvertToURL(KSMal3$), Array() )

Regards

Stephan

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



Re: [api-dev] not deleting bookmarks

2006-06-14 Thread Stephan Wunderlich

Hi Knut,


Then Later I do:
Cursor.gotoRange(
ThisComponent.bookmarks.getByName(START).getAnchor(), False)
Cursor.gotoRange( ThisComponent.bookmarks.getByName(END).getAnchor(),
True)
Cursor.setString() ' Here goes my bookmarks! How can I keep them?


your cursor spans from the beginning of the bookmark Start to the 
beginning of the bookmark End ... so I'd expect your code to delete 
the first bookmark and keep the second untouched.


To circumvent this you could move the cursor one to the right after 
moving it to bookmarks.getByName(START).getAnchor() by adding the line


Cursor.goRight(1,false)

This way the cursor spans from one character behind the first bookmark 
to the beginning of the second and so both bookmarks should be preserved.



Cursor.gotoRange(
ThisComponent.bookmarks.getByName(START).getAnchor(), False)
Cursor.insertDocumentFromURL(SomeURL, Array())

REM then the bookmark is moved to the end, and I'm not able to track
where I started.


Here you place the cursor at the beginning of the bookmark Start and 
insert your document there ... this way the document is inserted 
_before_ the bookmark Start ... again the line above should enable you 
to move the cursor behind the bookmark Start and so solve your problem.


Hope that helps

Regards

Stephan

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



Re: [api-dev] Problem with insertTextContent() , cant insert textfield.

2006-05-30 Thread Stephan Wunderlich

HI James,


Hi all, I have being trying to implement the code below (from developers
guide p.548) and I constantly run into problems, could anyone suggest a
solution or point me in the right direction to fixing the problem?

The exception I get varies but is always one of the following:

1. java.lang.NullPointerException
2. com.sun.star.lang.IllegalArgumentException: second parameter invalid




   XTextDocument td =
(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,xDesktop.getCurrentComponent()); 



   XTextCursor tc = td.getText().createTextCursor();
  Object bookmark =
oobean.getMultiServiceFactory().createInstance (
com.sun.star.text.Bookmark );
   XNamed xNamed = (XNamed)
UnoRuntime.queryInterface ( XNamed.class, bookmark );
   xNamed.setName(MyUniqueBookmarkName);
   XTextContent xTextContent = (XTextContent)
UnoRuntime.queryInterface (XTextContent.class, bookmark );
   td.getText().insertTextContent (
td.getText().getEnd(), xTextContent, false );


The exception occurs on the line:

   td.getText().insertTextContent (
td.getText().getEnd(), xTextContent, false );

Thanks in advance for your help,


css.text.Bookmark has to be created at the MultiServiceFactory that you 
can query from your TextDocument ... then all should work just fine.


Hope that helps

Regards

Stephan

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



Re: [api-dev] Backgroung conversion crashes when closing last foreground document

2006-05-24 Thread Stephan Wunderlich

Hi Tobias,


I have following problem. I wrote a little program that converts
documents in background, without showing a user interface. If I have an
active OO screen and close this, my conversion utility crashes.

My questing: how can I stop OO closing my conversion tool?

Please give me a hint.


when you close the visible Office the soffice process ends, so I 
suppose your conversion tool will run into a DisposedException.


You could catch this exception and reconnect when it is throws.

For the reconnect ... if you use the SimpleBootstrap mechanism as used 
in the SDK-samples then this will start the office and connect ... if 
you use a self written socket or pipe connection you'll have to restart 
the office.


Hope that helps

Regards

Stephan

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



Re: [api-dev] Multiple cells in macros

2006-05-19 Thread Stephan Wunderlich

Hi Moisés,



sub Main
ThisComponent.currentController.select(ThisComponent.Sheets(3))
printSelection
ThisComponent.currentController.select(ThisComponent.Sheets(4))
printSelection   end sub


sub printSelection
xFrame   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(com.sun.star.frame.DispatchHelper)
dim args(0) as new com.sun.star.beans.PropertyValue
args(0).Name = Selection
args(0).Value = true
dispatcher.executeDispatch(xFrame, .uno:Print, , 0, args())
end sub



I tried this, but it prints all the pages not the selection :(


That is strange, since it worked for me ... well I removed some args 
that I though would be superfluous ... you could give the following a try


-
sub printSelection
xFrame   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(com.sun.star.frame.DispatchHelper)
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = Copies
args1(0).Value = 1
args1(1).Name = Selection
args1(1).Value = true
args1(2).Name = Collate
args1(2).Value = false

dispatcher.executeDispatch(xFrame, .uno:Print, , 0, args1())
end sub
-

Hope that helps

Regards

Stephan

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



Re: [api-dev] Larger Documents Failing

2006-05-19 Thread Stephan Wunderlich

Hi Thomas,

I’m using the following code snippet to get contents of word documents 
as strings:


 

XTextDocument xTextDocument = (XTextDocument) 
UnoRuntime.queryInterface(


XTextDocument.class, xComp);

   


String s = xTextDocument.getText().getString();

 

 

This seems to work fine for documents up to around 5MB in size and just 
return “” for larger documents. Anybody have an idea of why I get this 
problem? Maybe you need to set available memory somewhere, I tried 
–Xmx1024m as a jvm argument but still fails with no exception.


Could it be that the text you get is just to large for a 
java.lang.String ? ... As far as I know this holds a maximum of 
2147483646 characters.


To ensure that you get it in smaller portions you could enumerate over 
what you get from xTextDocument.getText and then get the Strings of 
these portions.


Hope that helps

Regards

Stephan

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



Re: [api-dev] Multiple cells in macros

2006-05-18 Thread Stephan Wunderlich

Hi,


sub borrarSeleccionMultiple
dim document   as object
dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(com.sun.star.frame.DispatchHelper)
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = ToPoint
args1(0).Value = $B$5
dispatcher.executeDispatch(document, .uno:GoToCell, , 0, args1())
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = Flags
args2(0).Value = SVDFN
dispatcher.executeDispatch(document, .uno:Delete, , 0, args2())
end sub

This is the generated code. The problem is that I say to do the same 
operation in cells B5, B7  B11. Need I to write the code each time I 
need something similar ?


well the given code snippet wanders to Cell B5 and then deletes the 
contents ... something similar and for all your three Cells does


'all is the sum of all css.sheet.CellFlags
all = 895
xSheet = ThisComponent.Sheets(0)
xCellRange = xSheet.getCellRangeByName(B5)
xCellRange.clearContents(all)
xCellRange = xSheet.getCellRangeByName(B7)
xCellRange.clearContents(all)   
xCellRange = xSheet.getCellRangeByName(B11) 
xCellRange.clearContents(all)   

Hope that helps

Regards

Stephan

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



Re: [api-dev] Multiple cells in macros

2006-05-18 Thread Stephan Wunderlich

Hi Moisés

Hi, this is correct. But I want to say ... print sheets 4,5. Only these 
sheets.


if those sheets each fit on a page you could use the Property Pages to 
pass it to the XPrintable.print() call.


E.g.

Dim printProps(0) as new com.sun.star.beans.PropertyValue
printProps(0).Name=Pages
printProps(0).Value=4;5

ThisComponent.print(printProps())

Hope that helps

Regards

Stephan

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



Re: [api-dev] Multiple cells in macros

2006-05-17 Thread Stephan Wunderlich

Hi,

When I record a macro that do an operation in several cells this only 
work when I'm recording it. Later, when I execute this only work for the 
first cell.


what exactly did you try to record ? Maybe the code the recorder 
produced could give an insight too.


The same thing when I want to print two or more sheets. It only print 
the first one.


m 

ThisComponent.print(dimArray())

prints all sheets that contain contents for me, when attached to the 
document.


Regards

Stephan

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



Re: [api-dev] Programmatic To Foreground

2006-05-09 Thread Stephan Wunderlich

Hi Kent,


I render some objects - textframes, graphic frames and
lines.

For all of these I explicitly set the zOrder.

Somehow though my lines get put onto a different layer
(I presume).

What looks like a solution is when I press the button
To Foreground on the line then zOrdering looks ok,
the problem is that To Foreground is no where
documented. How do I set this property with a macro or
from java? 


I know through the dispatcher I could issue the
SetObjectToForeground, but I can't figure out how to
pass the dispatcher a line for example so that it
knows what to set to the foreground.

does anyone have any ideas?


generally setting the z-order should work ... but well it doesn't seem 
to in your case, but I'd have to look into the used code to see if it is 
an issue or something in your code.


For the dispatch ... the one you want to use reacts to the currently 
selected shape as far as I know, so the following macro should bring the 
first shape in your document to the foreground


xShape = ThisComponent.drawpage(0)
thiscomponent.currentController.select(xShape)

'ensure that the shape is selected
xSel = thisComponent.currentController.getSelection
wasSelected = EqualUnoObjects(xShape,xSel(0))

while not wasSelected
 'wait for selection
wend

dim document   as object
dim dispatcher as object

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(com.sun.star.frame.DispatchHelper)
dispatcher.executeDispatch(document, .uno:SetObjectToForeground, , 
0, Array())


Hope that helps

Regards

Stephan

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



Re: [api-dev] Copy Page_Style from a document to another doc

2006-05-09 Thread Stephan Wunderlich

Hi Bart

I need to copy a page_style from a document, and write it to another 
(new) document.


No problem for copy...


 snip -


But write the page style on new document seems impossible...


 snip -


what is wrong ?


as far as I know it is not possible to insert a style that is bound to 
one document into another in the way you tried.


What you could do is create a new style with the same name if you like 
in the new document and then loop over all properties in your original 
style and set them accordingly in your new style.


Hope that helps

Regards

Stephan

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



Re: [api-dev] .uno:PrintDefault Works but .uno:PrinterSetup does not

2006-05-03 Thread Stephan Wunderlich

Hi Kent,


any ideas?


that is strange indeed ... does my sample work on your machine ?

Regards

Stephan

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



Re: [api-dev] .uno:PrintDefault Works but .uno:PrinterSetup does not

2006-05-03 Thread Stephan Wunderlich

Hi Kent,


that is what I meant, your sample hangs my machine
with .uno:PrintDefault and I see no difference with
.uno:PrinterSetup (result.State is 0)


oh ok, I misunderstood you then thought you'd have integrated my code in 
your program ... since I can't recall to have included any DispatchEvents.


Well ... since the method I posted works like a charm for me with 
OOo2.0.2 ... which version do you use and on which platform does it run ?


Regards

Stephan

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



Re: [api-dev] Unanswered question: Is there ANY way to get the Current Values of the Scrollbar of A Doc?

2006-05-03 Thread Stephan Wunderlich

Hi Kent,


Is there any way to get the current values of the
scrollbar for a given document?


there is always a way ;-) ... The question is do you want to step along 
it :-)


Ok ... as far as I know the XScrollbar Interface is only implemented by 
css.awt.UnoControlScrollBar ... but not anywhere where it would be 
helpful to get the Scrollbar of a document.


So the only way I see to gain the information you want is using the 
Accessibility API ... a working sample for that would look like follows




public static void main(String[] args) {


try {
XComponentContext xContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();

// get the servie manager rom the office
XMultiComponentFactory xMCF = xContext.getServiceManager();

// create a new instance of the the desktop
Object oDesktop = xMCF.createInstanceWithContext(
com.sun.star.frame.Desktop, xContext );

// query the desktop object for the XComponentLoader
XComponentLoader xCLoader = ( XComponentLoader )
UnoRuntime.queryInterface(
XComponentLoader.class, oDesktop );

PropertyValue LoadArgs[]  = new PropertyValue []{};

XComponent xComp = xCLoader.loadComponentFromURL(
private:factory/swriter, _blank, 0, LoadArgs );

XModel xModel = (XModel)
UnoRuntime.queryInterface(XModel.class, xComp);

XAccessible xRoot = (XAccessible) UnoRuntime.queryInterface(
XAccessible.class, 
xModel.getCurrentController().getFrame().getContainerWindow());


getAccessibleObjectForRole(xRoot, AccessibleRole.SCROLL_BAR);

XAccessibleValue aValue = (XAccessibleValue) 
UnoRuntime.queryInterface(

XAccessibleValue.class, SearchedContext);

System.out.println(Scrollbar Value: +aValue.getCurrentValue());

} catch(Exception e){
System.err.println( Exception  + e);
e.printStackTrace(System.err);
}
System.out.println(... done);

}

public static XAccessibleContext SearchedContext = null;
public static XAccessible SearchedAccessible = null;

public static void getAccessibleObjectForRole(XAccessible xacc,
   short role) {
XAccessibleContext ac = xacc.getAccessibleContext();
boolean isShowing = ac.getAccessibleStateSet()
  .contains(
com.sun.star.accessibility.AccessibleStateType.SHOWING);

if ((ac.getAccessibleRole() == role)  isShowing) {
SearchedContext = ac;
SearchedAccessible = xacc;
} else {
int k = ac.getAccessibleChildCount();

if (ac.getAccessibleChildCount()  100) {
k = 50;
}

for (int i = 0; i  k; i++) {
try {
getAccessibleObjectForRole(
ac.getAccessibleChild(i), role);

if (SearchedContext != null) {
return;
}
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
System.out.println(Couldn't get Child);
}
}
}
}



For sure not overly elegant and you are in trouble when there are two 
Scrollbars ;-)


So the question is, can you circumvent the need for the ScrollbarValue 
by gaining something else ... and this depends on what you are trying to 
achieve.


Hope that helps

Regards

Stephan

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



Re: [api-dev] UnknownPropertyException when trying to set HyperLinkURL

2006-05-02 Thread Stephan Wunderlich

Hi Ann,


I've added that property but am still not seeing the link. I also tried
fiddling with the other properties (I tried setting TargetFrame to
_blank), but am not getting any link OR text to appear. And I tried
saving the file as an .sxi file rather than a PowerPoint file (as I
usually do), but that also did not make a difference.

Do you have any other ideas? Could this be a bug in the OpenOffice.org
code?


That is strange ... something like the following works like a charm for 
me ...




xDrawDoc = ThisComponent
xDrawPage = xDrawDoc.getDrawPages.getByIndex(0)

xShape = xDrawDoc.createInstance(com.sun.star.drawing.TextShape)

dim aSize as new com.sun.star.awt.Size
dim aPosition as new com.sun.star.awt.Point

aPosition.X = 2000
aPosition.Y = 2000
aSize.Width = 8000
aSize.Height = 1500

xShape.setPosition(aPosition)
xShape.setSize(aSize)   

xDrawPage.add(xShape)

xText = xShape.getText()
xTextCursor = xText.createTextCursor()

aField = xDrawDoc.createInstance(com.sun.star.text.TextField.URL)   
aField.setPropertyValue(URL, www.openoffice.org)
aField.setPropertyValue(Representation,www.openoffice.org
xText.insertTextContent(xTextCursor, aField, false)



Hope that helps

Regards

Stephan

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



Re: [api-dev] XTextViewCursor Listener

2006-05-02 Thread Stephan Wunderlich

Hi Tuomas,


I haven't found a suitable listener from API for listening events which
occur when position of XTextViewCursor changes.
Is there a way to catch those events?


when the view cursor moves a selectionChanged event should be fired, so 
I'd give the SelectionListener at the documents view a try.


Hope that helps

Regards

Stephan

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



Re: [api-dev] .uno:PrintDefault Works but .uno:PrinterSetup does not

2006-05-02 Thread Stephan Wunderlich

Hi Kent,


This one is really weird. PrintDefault works perfect,
a little window pops up and it ticks down the pages
and prints, but PrinterSetup, even though it is issued
exactly the same was as PrintDefualt never works. I
even tried to create a macro and called it, and it
doesn't work. The only guess I have is that somehow
the window is being swallowed somewhere. Does anyone
else have any ideas? Or any work arounds, ie is there
no other way to get the PrinterSetup window to appear?


Strange ...

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(com.sun.star.frame.DispatchHelper)
dispatcher.executeDispatch(document, .uno:PrinterSetup, , 0, DimArray())

opens the PrinterSetup dialog on my machine ... what do I do different 
than you ?


Regards

Stephan

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



Re: [api-dev] UnknownPropertyException when trying to set HyperLinkURL

2006-04-28 Thread Stephan Wunderlich

Hi Ann,


Thanks for all the pointers. I am no longer getting any errors in running
the code. However, I am not seeing any links in the resulting document.
Could it be because I am using OpenOffice.org 1.1, or that I am trying
also to output it as a PowerPoint file?

Here is a code snippet:

// xPresentation is an impress presentation
XDrawPage xDrawPage = PageHelper.getDrawPageByIndex(xPresentation, 0);
XMultiServiceFactory xFactory =

(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class,
xPresentation);
Object xObj = xFactory.createInstance(com.sun.star.drawing.TextShape);

XShape xShape = (XShape)UnoRuntime.queryInterface(XShape.class, xObj);
xShape.setPosition(aPos);
xShape.setSize(aSize);

XText xText = (XText)UnoRuntime.queryInterface(XText.class, xShape);
XTextCursor xTextCursor = xText.createTextCursor();

Object o = xFactory.createInstance(com.sun.star.text.TextField.URL);
XTextContent xTC = (XTextContent)
UnoRuntime.queryInterface(XTextContent.class, o);
XPropertySet xPS = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xTC);
xPS.setPropertyValue(URL,http://www.openoffice.org;);

xText.insertTextContent(xTextCursor, xTC, true);
xDrawPage.add(xShape);


looks good so far ... additionally you should set the property 
Representation which doesn't seem to be set automatically in 
Draw/Impress ... e.g.


xPS.setPropertyValue(Representation,http://www.openoffice.org;);

Hope that helps

Regards

Stephan

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



Re: [api-dev] How to minimize whole OpenOffice window

2006-04-04 Thread Stephan Wunderlich

Hi Tobias,


due to your help my project is close to be finished.

I have one last question: how can I minimize my whole OpenOffice window
to the taskbar of my OS?

I did not find a thing for this, only how to terminate my OO.


as far as I know there is no UNO-API for this purpose, but you could try 
your luck with system dependend calls ... on Windows something like the 
following should do what your want


Declare Function ShowWindow Lib user32 _
(ByVal lHwnd As Long, _
ByVal lCmdShow As Long) As Boolean

sub MinWindow
dim frame
dim window
dim handle
frame  = StarDesktop.getActiveFrame()
window = frame.getContainerWindow()
handle = window.getWindowHandle(dimarray(), 1) ' 1=WIN32
ShowWindow( handle, 2 )
end sub

Hope that helps

Regards

Stephan

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



Re: [api-dev] TextFrame Transparency Not Working

2006-03-29 Thread Stephan Wunderlich

Hi Kent,


In the ui you can set a 100% transparent color. That
is what I am trying to do with the backcolor, but
nothing I try seems to work.


If I set BackTransparent to true and avoid setting a BackColor 
afterwards it looks transparent to me :-)


Anyway, to set the percentage as in the dialog you can set the property 
BackColorTransparency to the wanted value, e.g. 100 for 100%


Hope that helps

Regards

Stephan

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



Re: [api-dev] detecting unrecoverable error event

2006-03-23 Thread Stephan Wunderlich

Hi John,

1.) Most important: is there any way to suppress the dialog so that OO 
just goes away quietly without user intervention.


you could start the office with the parameters -nocrashreport and 
-norestore ... e.g.


soffice.exe -accept=... -norestore -nocrashreport

2.) Convenient: Is there any way to observe the ‘unrecoverable error’ 
event within our UNO library, so our driver would know to retry the text 
block.


as soon as the office is gone this way your library should run into a 
com.sun.star.lang.DisposedException as soon as the next UNO-call is 
send ... this way you know when the office died prematurely.


Hope that helps

Regards

Stephan

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



Re: AW: [api-dev] url for new base document

2006-03-17 Thread Stephan Wunderlich

Hi Andreas,


thank you for your snippet - the document will be created. But i can not open 
the connection. I will always get the error 'No storage property was set'.

After restarting OpenOffice.org the connection is available.

Any idea ?


not sure if I understand you correctly ... I can work with this newly 
opened db-document ... create tables for example worked like a charm.


So what means i can not open the connection ?

Regards

Stephan

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



Re: [api-dev] UnknownPropertyException when trying to set HyperLinkURL

2006-03-16 Thread Stephan Wunderlich

Hi Ann,


I am trying to set the hyperlink for a particular part of text using the
following code and OpenOffice 1.1:

XText xText = (XText)UnoRuntime.queryInterface(XText.class, xShape);
XTextCursor xTextCursor = xText.createTextCursor();
XPropertySet propCursor = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
propCursor.setPropertyValue(HyperLinkURL, http://www.openoffice.org;);

When I try to run it, I get an UnknownPropertyException. Does anyone
know what I am doing wrong, or alternately, have a code example that will
do the right thing?


As far as I know it isn't possible to set a hyperlink for a text inside 
a shape.
This doesn't seem to work via UI so it is unlikely that it would work 
via API :-)


Hope that helps

Regards

Stephan

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



Re: [api-dev] url for new base document

2006-03-16 Thread Stephan Wunderlich

Hi Andreas,

which url must i use in order to construct a new OpenOffice.org base 
document with the java api.


Database Documents differ from other documents ... you need to define a 
datasource for them and they have to exist on your hard disk ... the 
following code should do what you want ...


--
XComponentContext xContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();

XMultiComponentFactory xMCF = xContext.getServiceManager();

// create a new instance of the the desktop
Object oDesktop = xMCF.createInstanceWithContext(
com.sun.star.frame.Desktop, xContext );

// query the desktop object for the XComponentLoader
XComponentLoader xCLoader = ( XComponentLoader )
UnoRuntime.queryInterface(
XComponentLoader.class, oDesktop );

//create a new datasource

Object dataSource = xMCF.createInstanceWithContext(
com.sun.star.sdb.DataSource, xContext);

XPropertySet xSrcProp = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, dataSource);

xSrcProp.setPropertyValue(URL, sdbc:embedded:hsqldb);

XDocumentDataSource xDDS = (XDocumentDataSource)
UnoRuntime.queryInterface(XDocumentDataSource.class, dataSource);

XStorable store = (XStorable) UnoRuntime.queryInterface(
XStorable.class,xDDS.getDatabaseDocument());

String aFile = file:///wherever you want it/testdb.odb;


//store it
store.storeAsURL(aFile, new PropertyValue[] {  });

//load it again
xCLoader.loadComponentFromURL(
aFile, _blank, 0,  new PropertyValue[]{});
--

Hope that helps

Regards

Stephan

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



Re: [api-dev] Create an index in a writer document with the link

2006-03-08 Thread Stephan Wunderlich

Hi Cristian,

I see in the developer's guide how create an index in a writer document 
with the JAVA API.
i would add at every page number in the index (or eventually in the 
title) a hyperlink to the right section..

Someone know how can i do it (in JAVA)??
Thanks to all...


given that you have a textdocument with some nice headings inside the 
following macro should insert a TableOfContents with the first Level 
HyperLinked ...


--
xDoc = ThisComponent
xText = xDoc.getText()
xTextCursor = xText.createTextCursor
xIndex = xDoc.createInstance(com.sun.star.text.ContentIndex)
xIndex.createFromOutline=True
xText.insertTextContent(xTextCursor, xIndex, false)
LFormat = xIndex.LevelFormat.getByIndex(1)
elementcount = ubound(LFormat)
dim newFormat(elementcount+1) as Variant

dim cont(0) as Variant
dim aProp as new com.sun.star.beans.PropertyValue
aProp.Name=TokenType
aProp.Value=TokenHyperlinkStart
cont(0) = aProp
newFormat(0) = cont()

for i=0 to ubound(LFormat)
newFormat(i+1)=LFormat(i)
next

dim cont2(0) as Variant
dim aProp2 as new com.sun.star.beans.PropertyValue
aProp2.Name=TokenType
aProp2.Value=TokenHyperlinkEnd
cont2(0) = aProp2
newFormat(ubound(LFormat)+1) = cont2()

xIndex.LevelFormat.replaceByIndex(1,newFormat())

xIndex.update
xText.removeTextContent(xIndex)

--

Hope that helps

Regards

Stephan

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



Re: [api-dev] Unanswered Request - Fw: [api-dev] HTML and Spreadsheet - BASIC

2006-02-20 Thread Stephan Wunderlich

Hi Rudolf,


thank you for your prompt message.


you are most welcome :-)


I tried VISIBLE = TRUE also. It shows the the link LINK, but I do not see
the contents. The problem seems to be to get
the contents into a defined cell.  Apparently, I have to enlarge the size of
the cell. Is there a method to  transfer the contents of the web-page of the
cess  from my spreadsheet table to CSV-format file. Once I  can achieve
this I can solve the problem.


The following macro should get the webpage into calc

sName=SUNW
oSheet = ThisComponent.Sheets(0)
sUrl = http://finance.yahoo.com/q?s=; + sName
AreaLinks = ThisComponent.Arealinks
xCell = oSheet.getCellByPosition(0,0).CellAddress
Arealinks.insertAtPosition(xCell, sUrl,	html_all, 
calc_HTML_WebQuery,  )


You could choose an additional invisible sheet as in your sample to 
place the data there, then link the essential part of this data to lets 
say your first sheet and save the document using XStorable.storeToURL, 
thereby using the csv-filter.


Hope that helps

Regards

Stephan

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



Re: [api-dev] Page Style with Right and Left Pages

2006-02-17 Thread Stephan Wunderlich

Hi Kent,


Does anyone have an example of this in Java?

I cannot seem to be able to create a document where
one side uses a left sided style and the next page
uses the right sided style.

It ends up using for the whole document the last style
loaded with CursorProps.setPropertyValue(
PageDescName, style ).

Then if I create a page break the editor generates
Blank Pages  which can only be seen in print preview
and say blank page over them.


the problem here might be the FollowStyle ... beu default this is 
default for FirstPage, Left Page for Left Page and Right Page 
for Right Page


Something like

try {
XStyleFamiliesSupplier xSFS = (XStyleFamiliesSupplier)
UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xModel);

XNameAccess xFamilies = xSFS.getStyleFamilies();

XNameContainer xFamily = (XNameContainer)
UnoRuntime.queryInterface(
XNameContainer.class, 
xFamilies.getByName(PageStyles));

XStyle firstPageStyle = (XStyle)
UnoRuntime.queryInterface(
XStyle.class, xFamily.getByName(First Page)); 
  
XPropertySet xFirstStyleProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, firstPageStyle);  

xFirstStyleProps.setPropertyValue(FollowStyle, Right Page);

XStyle leftPageStyle = (XStyle)
UnoRuntime.queryInterface(
XStyle.class, xFamily.getByName(Left Page));
XPropertySet xLeftStyleProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, 
leftPageStyle);
xLeftStyleProps.setPropertyValue(FollowStyle, Right Page);

XStyle rightPageStyle = (XStyle)
UnoRuntime.queryInterface(
XStyle.class, xFamily.getByName(Right Page));
XPropertySet xRightStyleProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, rightPageStyle);
xRightStyleProps.setPropertyValue(FollowStyle, Left Page);
} catch (Exception e) {

}

should do that.

If you then set the property PageDescName of the Cursor gained by

XTextDocument.getText().createTextCursor()

to First Page you should have what you wanted.

Hope that helps

Regards

Stephan

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



Re: [api-dev] Unanswered Request - Fw: [api-dev] HTML and Spreadsheet - BASIC

2006-02-17 Thread Stephan Wunderlich

Hi Rudolf,

your basic code inserts an invisible sheet to host your weblink ... 
changing the line


oSheet.IsVisible = FALSE

to

oSheet.IsVisible = TRUE

should show you the sheet Link with the data inside.

Hope that helps

Regards

Stephan



Hello,

since I did not get a response to my question below I try again. Also I
tested numerous variations to handle
the LINK in connection with various filters to store the contents of a
web-page in a file of CSV format,
I was not successful up-to-now. Maybe somebody can help me.
Have a nice week-end.

Rudi


- Original Message -
From: Rudolf Huber [EMAIL PROTECTED]
To: dev@api.openoffice.org
Sent: Wednesday, November 16, 2005 9:15 AM
Subject: [api-dev] HTML and Spreadsheet




Hello,

I am trying to get the following routine with the functions HTTP and
Spreadsheet to run under OOo 1.1.4. Neither the HTML- nor the
CSV-filter-options function.  When I look at the spreadsheet I see no


link;


however, when I check the menue Edit-Sheet-Select the sheet names show the
LINK for the HTML-page. Although the following lines show the entire
routine,
only the last ten lines are really important:


=
REM * BASIC *
Option Explicit
 Const STOCK_COLUMN = 2
 Const STOCK_ROW = 7

Sub Main
 GetHyperllinkT
End Sub
Sub GetHyperlinkT
Dim Desktop As Object
Dim sName As String
Dim oDoc As Object
Dim NoParm()
Dim oSheets As Object
Dim oSheet As Object
Dim oRanges As Object
Dim oCells As Object
oDoc = ThisComponent
oDoc.addActionLock
oSheets = oDoc.Sheets(0)
Desktop = CreateUnoService(com.sun.star.frame.Desktop)
oSheets = oDoc.getSheets()
If oDoc.Sheets.hasByName(Link) Then
 oDoc.Sheets.removeByName(Link)
End If
sName = AMD
Dim sUrl As String, sFilter As String
Dim sOptions As String
oSheets = oDoc.Sheets
If oSheets.hasByName(Link) Then
   oSheet = oSheets.getByName(Link)
 Else
oSheet =

oDoc.createInstance(com.sun.star.sheet.Spreadsheet)
oDoc.Sheets.insertByName(Link, oSheet)
   oSheet.IsVisible = FALSE
End If
sUrl = http://finance.yahoo.com/q?s=; + sName   rem +


.html


sFilter = HTML (StarCalc)
sOptions = 
rem sFilter = Text - txt - csv (StarCalc)
rem sOptions =
44,34,SYSTEM,1,1/10/2/10/3/10/4/10/5/10/6/10/7/10/8/10/9/10
oSheet.link(sURL, Link, , ,
com.sun.star.sheet.SheetLinkMode.NONE)
oDoc = Desktop.loadComponentFromURL(sUrl, _blank, 0, NoParm())
oSheet = oSheets.getByIndex(0)
If oSheets.hasByName(Link) Then
  oSheet = oSheets.getByName(Link)
  MsgBox sheet o.k.
   else
  MsgBox no sheet
  oSheet =
oDoc.createInstance(com.sun.star.sheet.Spreadsheet )
  oDoc.Sheets.insertByName( Link, osheet )
  End If
End Sub






==

I have no problem to store the HTML-page as a normal text-file under IE
6.0.

Maybe, I have the incorrect parameter settings for OOo 1.1.4, which


prevent


the display of the web-page in the sheet.

Thanks.

Rudi







-
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]



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



Re: [api-dev] How to apply a paragraph style to a XTextTableCursor?

2005-12-22 Thread Stephan Wunderlich

Hi Peter,


(made my first UNO-steps with StarOffice 5.2..., no comment please ;) )


I liked that office version ... eventhough not many seemed to be 
convinced of the Do Everything in one place  ... but that is a totally 
different topic now ;-)



Only wondered, why all the other paragraph and char properties work.
Imo it makes no sense to allow e.g. the property NumberingStyleName
(which is optional too) and the ParaStyleName not.

oTableCursor.CharColor = 128 and
oTableCursor.NumberingStyleName = List 1 work fine for example.


Might be worth a request for enhancement. If it would be implemented at 
the TableCursor then you could change the ParaStyleName for all Cells at 
once instead of traversing through the table cells :-)


Regards

Stephan

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



Re: [api-dev] getData() and getDataArray() do not work on text tables.

2005-12-21 Thread Stephan Wunderlich

Hi Andrew,


Should getData() and getDataArray() work on a text table?

I tested this on windows and linux using 2.01 release candidates.

Create a text document and add a single text table.

Add some data to the text table. Use at least two rows and two columns.

Now, run this macro

Dim oTable

oTable = Thiscomponent.getTextTables().getbyIndex(0)

Dim oData() : oData() = oTable.getDataArray()

Dim a() : a() = oData(1)

Print a(1)

MsgBox Join(a(), CHR$(10))

Print oTable.getCellByPosition(1, 1).getString()


The returned data is ALWAYS 0. Now, change getDataArray() to getData(). 
The returned values are still zero. What am I missing?


did you ensure that the cells are formatted as numbers ?

Regards

Stephan

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



Re: [api-dev] How to apply a paragraph style to a XTextTableCursor?

2005-12-21 Thread Stephan Wunderlich

Hi Peter,


in a former StarOffice version the following worked properly:

oTableCursor = oTable.createCursorByCellName(oTable.CellNames(0))
oTableCursor.ParaStyleName = MyStyle

Contrary to a normal XTextCursor this does not work in 2.0 anymore.

According to the api the service css.text.TextTableCursor includes the 
service css.style.ParagraphProperties with the missing property 
ParaStyleName.


I wonder that this worked ... the property ParaStyleName is optional and 
only makes sense for the text inside a cell, not for the cursor that 
enables you to move through the table ... but well ... changing your 
macro by


oTableCursor = oTable.getCellbyName(oTable.CellNames(0)).createTextCursor

should ensure that the paragraph style of the first cell is changed.

Hope that helps

Regards

Stephan

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



Re: [api-dev] getData() and getDataArray() do not work on text tables.

2005-12-21 Thread Stephan Wunderlich

Hi Andrew,


Interesting
Formatting the out AS a number allows non-zero numbers to be returned; I 
had not tried that before. Thanks for that information.

So getData() and getDataArray() both ONLY return numbers!

I thought that getData() should return numbers.
I thought that getDataArray() should return numbers AND strings.

I thought that the documentation stated this anyway. It does work this 
way in Calc. In my quick test, It generated an error if I tried to use 
setDataArray() with a string. Am I not correct in the difference between 
getData() and getDataArray().


now that you say it I took a look at the idl-documentation and 
getDataArray() should indeed also return the strings.


I wrote issue 59645 for it.

Regards

Stephan


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



Re: [api-dev] Integer Division?

2005-12-14 Thread Stephan Wunderlich - Sun Germany - ham02 - Hamburg

Hi Felix,


http://www.richhillsoftware.com/blog/archives/2005/06/xnumbers_011_no.html



Do I really need an extra package just to do integer division?  This operation 
is built into almost every programming language!


does

   print cint(11/3)

do what you want ?

Regards

Stephan

--
Everything should be made as simple as possible, but
not one bit simpler. Albert Einstein (1879 - 1955)

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



Re: [api-dev] IsFieldDisplayed property

2005-11-01 Thread Stephan Wunderlich - Sun Germany - ham02 - Hamburg

Hi Fabricio,


Ok then. I just got lost because I saw the property at the api
specification, that doesn´t mention the 2.0.1 version;


seems the since-tag isn't evaluated when creating the documentation
yet ... I wrote issue 57136 for that.


Thank you a lot Stephan :)


you are welcome :-)

Regards

Stephan




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



Re: [api-dev] macro doesn't run

2005-11-01 Thread Stephan Wunderlich - Sun Germany - ham02 - Hamburg

Hi Douglas,


I have a macro that calls a dialog. The dialog calls a 2nd macro. The 2nd macro 
doesn't run unless the macro editor is open. Is this the right place to seek 
guidance on this issue? If not, where should I look?


works for me with OOo 2.0, well I changed your macro slightly, so that
no error will appear from

  oGraph.setposition(oPos)
  ThisComponent.getDrawpage().add(oGraph)
  oGraph.GraphicURL = ...

to

  oGraph.setposition(oPos)
  ThisComponent.Drawpages(0).add(oGraph)
  oGraph.GraphicURL = ...

Hope that helps

Regards

Stephan


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



Re: [api-dev] Insert Image in a TextTable

2005-08-31 Thread Stephan Wunderlich - Sun Germany - ham02 - Hamburg

Hi Giorgio,


The problem is the following:
i have inserted a graphic object in a Bookmark  into a TextTable, but
now i have a reference to a Cell but don't have a bookmark...

I have utilised this code:

 // oWriter is my document
 


objCell=oWriter.getTextTables().getByName(MyTableName).getCellByName(MyCellName)
//reference to my TextCell

Now i have a problem to insert the graphic object with the method
insertTextContent because i do not know like putting in relation the
object objCell with the method and with the his parameters.


you can query your objCell to an XText, lets call it cellText and then 
call something like


cellText.insertTextContent(cellText.createTextCursor,objGraph,Boolean.TRUE)

Hope that helps

Regards

Stephan

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



Re: [api-dev] Hiding a textField throught the API

2005-08-30 Thread Stephan Wunderlich - Sun Germany - ham02 - Hamburg

Hi Fabricio,


Worked just fine.
Thank you, Stephan.

But, in my application, I need to hide a textfield that has a given
name. How would be the code for that?


When you have a Enumeration of your TextFields you can query each of 
them for an XDependentTextField. UserFields are those and then you can 
call the method getTextFieldMaster() at this and get the property name 
from the returned PropertySet.
If the TextFieldMaster has the name you search you can set the property 
 IsVisible at the corresponding TexField.


Hope that helps

Regards

Stephan

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



Re: [api-dev] Hiding a textField throught the API

2005-08-29 Thread Stephan Wunderlich - Sun Germany - ham02 - Hamburg

Hi Fabricio,


How can I hide a document text field using the API (without macros)?
Here´s the code that I use for accessing the textfield:

XTextFieldsSupplier xTextFieldsSupplier = (XTextFieldsSupplier)
UnoRuntime.queryInterface(
XTextFieldsSupplier.class, component);

XNameAccess xNamedFieldMasters = xTextFieldsSupplier.getTextFieldMasters();

XEnumerationAccess xEnumeratedFields = xTextFieldsSupplier.getTextFields();

String completeName = com.sun.star.text.FieldMaster.User. + textFieldName;

Object fieldMaster = xNamedFieldMasters.getByName(completeName);


the TextFields has a property called IsVisible ... setting this to 
false will hide your User-TextFields.


Somethings like

XPropertySet FieldProperties = (XPropertySet) 
UnoRuntime.queryInterface(XPropertySet.class, 
xEnumeratedFields.nextElement())


FieldProperties.setPropertyValue(IsVisible,Boolean.FALSE)

should hide the first textfield in your enumeration ... that is if it is 
a User-Field ;-)


Hope that helps

Regards

Stephan


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



Re: [api-dev] 2.0 and changing JAVA-Settings

2005-08-29 Thread Stephan Wunderlich - Sun Germany - ham02 - Hamburg

Hi Peter,


asking on dev-dba, Frank redirected me to this list.

I want to automate the Java-Settings during and after the installation.
So, if a JDBC-Driver is required, the users have to add a classpath via 
GUI and restart the application. Is there a way to automate this via 
scripting?


There's no jvmsetup in 2.0 anymore, I think.

Alternatively a API-solution (Basic) would be appreciated (if no 
restarting is required).


May be, the installation- or the dev-list are the better addresses for 
this kind of question, but I want to avoid X-postings, so lets start here.


in case of jdbc-drivers you could try to pack your jdbc-driver in a zip 
file and then add it calling unopkg add yourzipfile ... unopkg might 
complain that the zip doesn't contain a uno-package, but as far as I 
know will copy the jar-file and adjust the classpath, so that the driver 
should work.


Hope that helps

Regards

Stephan

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



Re: [api-dev] Having a FilePicker: how to bring it to front ?

2005-08-22 Thread Stephan Wunderlich

Hi Rony,

*WOW*, *that* made it work, thank you *very* much!! (Did try it on OOo 
1.1.4 and 1.9.122.)


great :-)

Now a lest (little?) request: how can one set the properties for OOo 
altogether (would just need a hint where - which class - or code-samples 
to start researching this corner of OOo, including the ability to learn 
about the version one is using). This way one can read, set and re-set 
the setting in the case one wishes to use the FilePicker.


I suppose you mean the things you can adjust via Tools-Options ... these 
are stored in the Configuration and how to access this can be found in 
the appropriate Developers Guide Chapter ... 
http://api.openoffice.org/docs/DevelopersGuide/Config/Config.htm


Hope that helps

Regards

Stephan

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



Re: [api-dev] Text Table Column properties

2005-08-19 Thread Stephan Wunderlich

Hi Przemek

   Is there an easy way to change properties of text table column, i.e 
the back color of the column.


   When i read this mailing list posts i found a post that suggests to 
use text table rows, but for large tables this is not efficient.


The macro

sub Main
atable = ThisComponent.TextTables(0)
acolumn = getColumn(1,atable)
acolumn.BackColor=rgb(0,255,0)
end sub

function getColumn(col as Integer, table as Object) as Object
tablerows = table.rows.count-1
getColumn = table.getCellRangeByPosition(col,0,col,tablerows)
end function

will change the backgroundcolor of the second column in your first table.

Hope that helps

Regards

Stephan

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



Re: [api-dev] Having a FilePicker: how to bring it to front ?

2005-08-19 Thread Stephan Wunderlich

Hi Rony,

What would be a starting point to research to get the FilePicker to the 
front programmatically (without having a document object yet)?


Now I'm curious ... the filepicker is a modal dialog that is always on 
top and can't be moved to the back ... just to be sure I opened it via 
Basic, Java and UI and in all three cases the dialog persists in the 
front of the application.


Which platform are you working on ? Do you get the OOo-FilePicker or the 
System-FilePicker ? In the second case, have you tried to switch to the 
OOo-Filepicker by setting Tools-Options-General-Use OOo Dialogs ?


Regards

Stephan

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



Re: [api-dev] macro to add a new curve in a Calc diagram

2005-08-16 Thread Stephan Wunderlich

Hi ch'prof,


A Calc sheet contains myDiagram which refers to A1:B31 cells.

myDiagram.ChartRangeAddress sends the following string :
'mySheet'.$A$1:.$B$31
 
I want my macro to add a new curve in it, with datas located in A32:C33.
 
I used myDiagram.ChartRangeAddress= 'mySheet'.$A$1:.$C$33 and multiple 
variations on this string.


myDiagram.ChartRangeAddress is correctly changed but the diagram itself 
refers to the lone A1 cell or various ref errors.


If ChartRangeAddress is the right property to use, how should its 
argument be set ?


The following macro adds two rows to the existing Range of the first 
chart in a CalcDocument


theRanges = ThisComponent.Sheets(0).Charts(0).getRanges()
theRanges(0).EndRow = theRanges(0).EndRow+2
ThisComponent.Sheets(0).Charts(0).setRanges(theRanges)

Hope that helps

Regards

Stephan

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



Re: [api-dev] Problem to identify the name of a chart

2005-08-12 Thread Stephan Wunderlich

Hi Sacha


I'm working on an OpenOffice-based Report-Framework and have a problem
with the identification of a chart by its name. The methods
XTableCharts.getElementNames() and XTableCharts.getByName(String)
refer to the internal name of the chart, i.e. Object 1. What I need
is the name, which the user can set via the function Set name ... of
the context menu of a chart. In the XML-Source it is the value of the
attribute draw:name of the draw:frame-Element, what I need. How can I
access this name by the API? Can anyone help me?


what you get as name there is the persistant name, which doesn't change 
by changing the UI name.


What you could do is getting the shape-collection from the document. The 
shapes implement a XNamed interface and this returns the displayed name.
Beside this the shape also has the property PersistName which contains 
the appropriate Name to get the right TableChart.


Hope that helps

Regards

Stephan

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



Re: [api-dev] Updating formulas (JAVA)

2005-08-01 Thread Stephan Wunderlich

Hi Andreas,


we have a text document with a text table which contains several formulas. This 
text table will be filled with data in hidden mode. After the filling process 
we export the document to pdf. In most cases the fields with the formulas 
contains the message **expression faulty**. But the formula does not contain 
any error. If we store the document to odt and open it, the formula fields 
contains also the message **expression faulty**. But if we click into the text 
table the formula will be calculated and the correct result appears. What can 
we do do avoid this behaviour ?


the SwXTextDocument supports an interface call XTextFieldsSupplier, 
where you can call the method getTextFields(). The methods returns the 
implementation object SwXTextFieldTypes, which implments the interface 
XRefreshable where you can call the method refresh(). This should update 
all TextFields in your document.


Hope that helps.

Regards

Stephan

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



Re: [api-dev] Updating formulas (JAVA)

2005-08-01 Thread Stephan Wunderlich

Hi Andreas,

we have tested the reformat of the text document. But this does not solve the problem. 


What can we do else ?


can you send me a running sample that demonstrates the behaviour ?

Regards

Stephan

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



Re: [api-dev] How to remove a specific annotation?

2005-06-16 Thread Stephan Wunderlich
Hi Yu,

 Thus the annotition will gone with the text. Can we do the 
 same( only without remove the text) with OOo API? I've 
 tried with quering XEnumerationAccess interface from 
 XModel.getCurrentSelection(), as shown in the following 
 code, but failed at the first place: the selection doesn't 
 seem to support XEnumerationAccess.Here's the code:

the returned selection a SwXTextRanges object, from this you can get the
first one using the XIndexAccess and this will give you a SwXTextRange.
You can then create an enumeration for this Range and you will get the
ParagraphEnumeration. For each element therein you can create another
Enumeration and you will get the TextPortionEnumeration.
In the second enumeration you can ask the element if it supports a
css.text.TextField and if so you can get the property TextField from
this element and ask if it supports a css.text.TextField.Annotation.

Hope that helps

Regards

Stephan

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



Re: [api-dev] Table width

2005-03-18 Thread Stephan Wunderlich
Hi Cristian,
This is my Java code:
 Object table = 
xWriterFactory.createInstance(com.sun.star.text.TextTable);
XTextContent xTextContentTable = 
(XTextContent)UnoRuntime.queryInterface(XTextContent.class, table);
   XPropertySet 
xTableProps=(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,table);  

   xTableProps.setPropertyValue(HoriOrient,new 
Integer(com.sun.star.text.HoriOrientation.LEFT_AND_WIDTH));
 xTableProps.setPropertyValue(LeftMargin,new Integer(-1000));
 xTableProps.setPropertyValue(Width,new Integer(18000));

Thanks to all
mmm ... strange ... the macro
aTable = thisComponent.TextTables(0)
aTable.HoriOrient = com.sun.star.text.HoriOrientation.LEFT_AND_WIDTH
aTable.LeftMargin=-1000
aTable.Width=18000
works like a charm for me.
Do you change the properties before you insert the table or after you 
insert the table ?

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


Re: [api-dev] setting OOo options

2005-03-11 Thread Stephan Wunderlich
Hi Jorge,
I'd like to write a macro setting some of OOo's options (Menu Tools-Options)
programatically. Can this be done?
So far, by means of recording a macro, I've just got to:
   dispatcher = createUnoService(com.sun.star.frame.DispatchHelper)
   dispatcher.executeDispatch(document, .uno:OptionsTreeDialog, , 0,
Array())
which displays the options dialog. I guess using the right command URLs might do
it, but I cannot find this sort of info in the docs.
most of the settings in this dialogue should be accessible through the 
configuration api, you might want to take a look at the corresponding 
developers guide chapter 
http://api.openoffice.org/docs/DevelopersGuide/Config/Config.htm

Hope that helps
Regards
Stephan
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [api-dev] SDB query

2005-03-07 Thread Stephan Wunderlich
Hi Indukamar,
I am new to the OOo UNO APIs. I was trying to connect
to the SDB from OOo using Java. But I could not find
the com.sun.star.sdb.RowSet class in any JARs supplied
with the standard installation of OOo. Can anyone
please point  me to the place where I can find it? I
downloaded the SDK, the documentation and all, but
could not find a reference which points to where I can
find it.
css.sdb.RowSet is a Service and the jar files only contain types, so you 
won't find a class file, corresponding to this service anywhere.

To get an idea how database access works using the OOo-UNO-API you might 
want to have a look at the corresponding developers guide chapter

http://api.openoffice.org/docs/DevelopersGuide/Database/Database.htm
Hope that helps
Regards
Stephan
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [api-dev] Number of line of a paragraph

2005-03-07 Thread Stephan Wunderlich
Hi Laurent,
using macros (but any language welcomed)
I retreive a paragraph containing text. Is there a way to know how many 
lines it represents displayed in the document ? (so, depending on the 
formats,  font, font size aso)

I know i can count characters with
num = Len(myParagraph.string)
but need know that this number is displayed on N lines
I suppose you have an XTextRange as base for your calculation.
The following macro should count the lines of a selected text, but by 
replacing the first line with your text range it should work for you too :-)

textRange = thiscomponent.currentcontroller.Selection.getByIndex(0) 
textCursor = thisComponent.getText.createTextCursorByRange(textRange)
viewCursor = thisComponent.currentcontroller.ViewCursor()
viewCursor.gotoRange(textRange,false)
viewCursor.collapseToStart()
counter = 0
while thiscomponent.getText.compareRegionEnds(textCursor,viewCursor)0
viewCursor.goDown(1,false)
counter = counter +1
wend
msgbox lines in selected paragraph +counter
Hope that helps
Regards
Stephan
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [api-dev] Number of line of a paragraph

2005-03-07 Thread Stephan Wunderlich
Hi Laurent,
The trick with a view cursor will work
I didn't try this as i was searching for Non-view methods
No View no lines I'd say :-)
The XTextRange doesn't know in how many lines it will be displayed and 
so can't tell you how many lines it contains.

Nevertheless, i'll save the current selection before and restore it at 
the end. But his will flicker for the user ...
using
thiscomponent.lockControllers
at the beginning of the macro and
thiscomponent.unlockControllers
at the end should avoid the flicker.
Regards
Stephan
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [api-dev] OOo Basic Specification

2005-01-21 Thread Stephan Wunderlich
Hi Curtis,
Is there a complete specification for the OOo Basic language?
For OOo Basic you can just press F1 when you are in the Basic-IDE.
For the OOo-API take a look at http://api.openoffice.org/ where you will 
find the

idl-reference:
http://api.openoffice.org/docs/common/ref/com/sun/star/module-ix.html
and the Developers Guide:
http://api.openoffice.org/DevelopersGuide/DevelopersGuide.html
Hope that helps
Regards
Stephan
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]