Re: [udk-dev] PyUNO : Inserting a User field

2009-10-22 Thread Fernand Vanrie

Etienne
in basic its done like:
Dim Doc As Object
Dim DateTimeField As Object
Dim Cursor As Object
Doc = StarDesktop.CurrentComponent
Cursor = Doc.Text.createTextCursor()
DateTimeField = 
Doc.createInstance(com.sun.star.text.Tcom.sun.star.text.TextField.User)) 


Doc.Text.insertTextContent(Cursor, DateTimeField, False)

hope it helps
fernand

Dear list,

First I hope I am in the right place... Please forgive me and direct 
me to the appropriate mailing-list/forum/whatever if I'm off-topic...


I'm trying to develop an application that would interact with 
OpenOffice via PyUNO, and I am not able to create a User field. I 
started from the Java example here: 
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Text/Text_Fields, 
and tried to convert it in Python...


Dim Doc As Object
Dim DateTimeField As Object
Dim Cursor As Object
Doc = StarDesktop.CurrentComponent
Cursor = Doc.Text.createTextCursor()
DateTimeField = 
Doc.createInstance(com.sun.star.text.Tcom.sun.star.text.TextField.User)) 


Doc.Text.insertTextContent(Cursor, DateTimeField, False)
#-
import uno

localContext = uno.getComponentContext()
resolver = 
localContext.ServiceManager.createInstanceWithContext(com.sun.star.bridge.UnoUrlResolver, 
localContext )
ctx = resolver.resolve( 
uno:pipe,name=OOo_pipe;urp;StarOffice.ComponentContext )

smgr = ctx.ServiceManager

desktop = smgr.createInstanceWithContext( 
com.sun.star.frame.Desktop,ctx)

model   = desktop.getCurrentComponent()

if model.getImplementationName()=='SwXTextDocument':
   xUserField = model.createInstance(com.sun.star.text.TextField.User)
   xMasterPropSet = 
model.createInstance(com.sun.star.text.FieldMaster.User)

   xMasterPropSet.setPropertyValue(Name, UserEmperor)
 
ctx.ServiceManager

#-

I get an error __main__.IllegalArgumentException, on the 
xMasterPropSet.setPropertyValue(Name, UserEmperor) line.
If I run dir(xMasterPropSet), I get all the expected method and 
properties, so it just look like the setPropertyValue is either not 
the implementation I expected, or that the argument types are wrong?


Can anyone give me a hint on how to do that?

Thanks a lot!.
-Etienne



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



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



Re: [udk-dev] pyuno question

2009-10-08 Thread Fernand Vanrie

Martin ,
do not kwow pyuno but its similar to basic:

Note the landscape page MUST use a different page style then the 
portrait pages. Each page style contains a* IsLandscape* property. You 
want to insert a page break and change the page style name on the new page


the code must been like

Sub test()
   Dim oServiceManager As Object
   Dim oDesktop As Object
   Dim oDocument As Object
   Dim oText
   Dim oCursor
   Dim oNewStyle
   Dim Args()
   Dim s
   Dim oStyle
  

 
   Set oServiceManager = CreateObject(com.sun.star.ServiceManager)
   Set oDesktop = 
oServiceManager.createInstance(com.sun.star.frame.Desktop)
   Set oDocument = 
oDesktop.loadComponentFromURL(private:factory/swriter, _blank, 0, Args)

   Set oText = oDocument.GetText
   Set oCursor = oText.createTextCursor
  
   'Insert the page break

   oText.insertControlCharacter oCursor, 0, False
   oCursor.BreakType = 4
   oCursor.gotoEnd False
  
   'getting the old style

   s = oCursor.PageStyleName
   Set oStyle = 
oDocument.StyleFamilies.getByName(*PageStyles*).getByName(s)


   'creating the new style
   Set oNewStyle = 
oDocument.createInstance(com.sun.star.style.PageStyle)

   'Setting the lanscape property to true
   oNewStyle.setPropertyValue IsLandscape, True
   oNewStyle.setPropertyValue Width, oStyle.Height
   oNewStyle.setPropertyValue Height, oStyle.Width

   'Adding the new style to pagestyle family
   oDocument.StyleFamilies.getByName(*PageStyles*).insertByName 
LandscapeStyle, oNewStyle
  
   'setting the PageStyleName to the *landscape* pagestyle

   oCursor.setPropertyValue PageDescName, LandscapeStyle

end sub
hope it helps


Fernand
  








Hi,

I am a newbe in pyuno and like to modify the example 


http://udk.openoffice.org/python/samples/swritercomp.py

in such a way, that the page format is landscape (and not portrait).

Can anybody help me with that? I really feel a bit lost with the 
documentation...

Thanks a lot and best wishes,

Martin

 
  



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



Re: [udk-dev] Sorting reference marks by position in Writer document

2009-02-26 Thread Fernand Vanrie

Morten Omholt Alver wrote:

Hi,

I am working on a plugin for interfacing JabRef and OpenOffice. This
involves inserting citation markers in a Writer text (representing a
bibliography citation), and formatting a reference list based on which
citations appear in the text.

In order to sort the reference list by order of appearance in the
document, I use XTextRangeCompare to sort the reference marks.
However, if some reference marks are placed in table cells or
footnotes, this doesn't work, since XTextRangeCompare only compares
text ranges within the same Text, and this apparently doesn't hold in
this case (a reference mark in a normal paragraph is not within the
same Text as a reference mark in a table cell or footnote).

Is there another way of ordering reference marks by position 
The vertical position of a oridnary viewcursor can here been used. But 
tabel positions are a bit more triky, i supose you have to find the 
postion of a table cursor and then find the position of a cursor just 
under or on top of a table and then counting rows and rowheights... :-)

in the
text, or can I somehow access the position of a table / table cell or
footnote within the outer Text, so they can be compared?


Sincerely,
Morten Alver

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



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



Re: [udk-dev] Uneditable reference marks or bookmarks

2008-02-29 Thread Fernand Vanrie

Morten Omholt Alver wrote:

Hi,

I am working on a plugin for interfacing JabRef and OpenOffice. This
involves inserting citation markers in a Writer text (representing a
bibliography citation), and formatting a reference list based on which
citations appear in the text. This is not done using OO's built-in
bibliographic functions, but handled entirely by the plugin.

For reference, the current version of the plugin is available here:

http://www.itk.ntnu.no/ansatte/Alver_Omholt_Morten/jabref/OOPlugin.html

In the current implementation I insert a ReferenceMark for which I set
the text to appear in the document (the citation). The name of each
ReferenceMark is chosen so it indicates which bibliographic entries
(known to JabRef) it represents - therefore the actual text shown in
the document does not need to carry that information.

There are two problems with my approach:

* First, the text in the reference mark is editable, so the user can
accidentally add text to the marker instead of outside of it.
  
Maybe GraphicShapes could help, do not now if there is a property to 
make them readonly, but you can always glua a macro on them who prefends 
accitental acces to the text inside.

* Second, the reference marks are lost when saving to Word format.

I'm wondering if there is another mechanism I'm overlooking, which
would allow me to insert uneditable markers (gray like reference
marks), or if it is possible to make the reference marks uneditable?
It would be a bonus if the mechanism also could be conserved when
interchanging documents with MS Word.
  

Most of this shapes are pretty good tranfered

Hope it helps


Sincerely,
Morten O. Alver

-
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: [udk-dev] Mapping of UNO method pairs StarBasic pseudo Properties

2008-01-23 Thread Fernand Vanrie

Bernard Marcelly wrote:

Hi Paolo,

Message de Paolo Mantovani  date 2008-01-22 23:55 :
That said, I've just noticed that in my ooo 2.3.1 - Italian (Linux) , 
the following starbasic code gets an error of type mismatch (not 
sure of the translation):


  Dim bModified As Boolean
  bModified = ThisComponent.Modified



This code instead runs without errors:
  bModified = ThisComponent.isModified()


I'm quite sure that in previous versions I never observed this 
problem. can anyone confirm ?




I just tested again with OOo 1.1.5. It's the same. A method
isSomething() does _not_ produce a pseudo-property Something.
Uno language binding documentation for Basic (and for COM) say nothing 
for isSomething() methods.


You may have been fooled (like me) from the fact that pseudo-property
Modified does exist in OOoBasic.
But it is a write-only property!
Because there is a method setModified(boolean) but no getModified().

Other case: there is a method isReadOnly() but there is no method
setReadOnly(boolean). As a consequence there is no pseudo-property 
ReadOnly.


In a Calc cell you have a pseudo-property IsMerged which is read-only,
because there is a method getIsMerged(). And there is no method
setIsMerged(boolean),

As i am not a professional coder i see an bit of logic begint this :-)
merging can only be done by other methods ?

but only the method merge(boolean).
A cleaner naming would have been to define isMerged() instead of
getIsMerged(). And then there would be no pseudo-property.

In a Calc cell annotation you find the pseudo-property IsVisible because
there is getIsVisible() and setIsVisible(boolean).

setVisible is a action who can bedone with this method ?

Here again it is an awkward naming. It should have simply been named
getVisible() and setVisible(boolean), producing a pseudo-property
Visible. But what's done is done.

__
Bernard



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