|
List Info
Thread: insert graphic into Writer, anchored to page, can't set position
|
|
| insert graphic into Writer, anchored to
page, can't set position |

|
2006-05-19 09:45:33 |
Hi,
What I'm trying to achieve is to insert a picture into
writer and have
it anchored to the page. I don't understand why I can't
set the position
in a straightforward way. I found oGraph has a method
getPosition(), but
it doesn't want to work. I had hoped to use
setPostion(oPos), but I'm
not having much luck there either.
Then I tried with HoriOrientPosition, since I found
somebody's code
where he was doing that with a frame. Do I have to embed my
picture in a
frame if I want to position it anchored to the page?
Sub Main
InsertGraphicObject(ThisComponent,
"file:///E:/headlinetype01.gif")
End Sub
Sub InsertGraphicObject(oDoc, sURL$)
REM Author: Andrew Pitonyak
Dim oCursor
Dim oGraph
Dim oText
Dim oPos As New com.sun.star.awt.Point
oText = oDoc.getText()
oCursor = oText.createTextCursor()
oCursor.goToStart(FALSE)
oGraph =
oDoc.createInstance("com.sun.star.text.GraphicObject&
quot;)
With oGraph
.GraphicURL = sURL
.AnchorType =
com.sun.star.text.TextContentAnchorType.AT_PAGE
.HoriOrientPosition=1000 ' This doesn't seem to
have any effect.
.VertOrientPosition=1000 ' The graphic is simply
inserted
centered horizontally across the page
' glued
against the top.
End With
' Xray OGraph
'now insert the image into the text document
oText.insertTextContent( oCursor, oGraph, False )
' print oGraph.getPosition() ' Found this method with
Xray
' BASIC runtime error
' An exception occurred
' Type: com.sun.star.uno.RuntimeException
' Message: position cannot be determined with this
method.
With oPos
.X = 1000
.Y = 1000
End With
oGraph.setPosition(oPos) ' Found this method with Xray
' Message: position cannot be changed with this method.
End Sub
Yours ever more in despair,
Jo
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| insert graphic into Writer, anchored to
page, can't set position |

|
2006-05-19 10:00:28 |
Hi Jo,
you have to set the Property AnchorPageNo for the inserted
graphic after
setting anchor type, for example
oGraph.AnchorPageNo = 2
Hope that helped...
Mathias
Jo schrieb:
> Hi,
>
> What I'm trying to achieve is to insert a picture into
writer and have
> it anchored to the page. I don't understand why I
can't set the
> position in a straightforward way. I found oGraph has a
method
> getPosition(), but it doesn't want to work. I had
hoped to use
> setPostion(oPos), but I'm not having much luck there
either.
>
> Then I tried with HoriOrientPosition, since I found
somebody's code
> where he was doing that with a frame. Do I have to
embed my picture in
> a frame if I want to position it anchored to the page?
>
> Sub Main
> InsertGraphicObject(ThisComponent,
> "file:///E:/headlinetype01.gif") End Sub
>
> Sub InsertGraphicObject(oDoc, sURL$)
> REM Author: Andrew Pitonyak
> Dim oCursor
> Dim oGraph
> Dim oText
> Dim oPos As New com.sun.star.awt.Point
>
> oText = oDoc.getText()
> oCursor = oText.createTextCursor()
> oCursor.goToStart(FALSE)
> oGraph =
oDoc.createInstance("com.sun.star.text.GraphicObject&
quot;)
>
> With oGraph
> .GraphicURL = sURL
> .AnchorType =
com.sun.star.text.TextContentAnchorType.AT_PAGE
> .HoriOrientPosition=1000 ' This doesn't seem to
have any effect.
> .VertOrientPosition=1000 ' The graphic is simply
inserted
> centered horizontally across the page
> ' glued
against the top.
> End With
>
> ' Xray OGraph
>
> 'now insert the image into the text document
> oText.insertTextContent( oCursor, oGraph, False )
>
> ' print oGraph.getPosition() ' Found this method
with Xray
> ' BASIC runtime error
> ' An exception occurred
> ' Type: com.sun.star.uno.RuntimeException
> ' Message: position cannot be determined with this
method.
>
> With oPos
> .X = 1000
> .Y = 1000
> End With
>
> oGraph.setPosition(oPos) ' Found this method with
Xray
> ' Message: position cannot be changed with this
method.
>
> End Sub
>
>
> Yours ever more in despair,
>
> Jo
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
> For additional commands, e-mail: dev-help api.openoffice.org
>
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| insert graphic into Writer, anchored to
page, can't set position |

|
2006-05-19 10:14:31 |
Mathias Supp wrote:
> Hi Jo,
>
> you have to set the Property AnchorPageNo for the
inserted graphic
> after setting anchor type, for example
> oGraph.AnchorPageNo = 2
>
> Hope that helped...
Hi Mathias,
Thanks for your answer. When I do that, nothing happens
anymore. I did
discover the following though:
.HoriOrient = com.sun.star.text.HoriOrientation.NONE '
This is
necessary to override the default settings for the
positioning
.VertOrient = com.sun.star.text.VertOrientation.NONE
When I add those lines, the graphic does get positioned
where I want it.
Very odd, if you ask me, but I'm glad I found something
that seems to
work now.
Jo
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| insert graphic into Writer, anchored to
page, can't set position |

|
2006-05-19 11:07:18 |
Hi Jo,
it seems (to me) somehow logical that orientation and
absolute
positioning conflict with each other.
But what exactly did you mean with "nothing happens
anymore"?
bye
Mathias
Jo schrieb:
> Mathias Supp wrote:
>> Hi Jo,
>>
>> you have to set the Property AnchorPageNo for the
inserted graphic
>> after setting anchor type, for example
>> oGraph.AnchorPageNo = 2
>>
>> Hope that helped...
> Hi Mathias,
>
> Thanks for your answer. When I do that, nothing happens
anymore. I did
> discover the following though:
>
> .HoriOrient = com.sun.star.text.HoriOrientation.NONE
' This is
> necessary to override the default settings for the
positioning
> .VertOrient = com.sun.star.text.VertOrientation.NONE
>
> When I add those lines, the graphic does get positioned
where I want it.
>
> Very odd, if you ask me, but I'm glad I found
something that seems to
> work now.
>
> Jo
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
> For additional commands, e-mail: dev-help api.openoffice.org
>
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| insert graphic into Writer, anchored to
page, can't set position |

|
2006-05-19 12:10:56 |
Jo,
I did in the paste a lot of work in this area and used
always
"VertOrient = com.sun.star.text.VertOrientation.NONE
" plus in my old
notyes i found
"'for unkwon reasons the only way to get the values
of the "Actualsize"
of the graphic we needed to get all the GrapicElements and
ther name
and ther total ' and then been publiched in a messageBox
????? "
What means that i now always "place" the
Graphics at an non-defined
postion, then enumerate al the graphics, need some
"^pause" (msgbox)
and then do the positioning, sizing achoring....
A dev-gui explaned in a recent thread that this ellements
are
"layout-based" and therefore only can be found
after the grahic is
actual placen in the WriterDoc
Hope it helps to understand
Btw. did you read my Insert Graphic quenstions ?
Fernand
the
Mathias Supp schreef:
> Hi Jo,
>
> it seems (to me) somehow logical that orientation and
absolute
> positioning conflict with each other.
>
> But what exactly did you mean with "nothing
happens anymore"?
>
> bye
>
> Mathias
>
> Jo schrieb:
>> Mathias Supp wrote:
>>> Hi Jo,
>>>
>>> you have to set the Property AnchorPageNo for
the inserted graphic
>>> after setting anchor type, for example
>>> oGraph.AnchorPageNo = 2
>>>
>>> Hope that helped...
>> Hi Mathias,
>>
>> Thanks for your answer. When I do that, nothing
happens anymore. I
>> did discover the following though:
>>
>> .HoriOrient =
com.sun.star.text.HoriOrientation.NONE ' This is
>> necessary to override the default settings for the
positioning
>> .VertOrient =
com.sun.star.text.VertOrientation.NONE
>>
>> When I add those lines, the graphic does get
positioned where I want it.
>>
>> Very odd, if you ask me, but I'm glad I found
something that seems to
>> work now.
>>
>> Jo
>>
>>
------------------------------------------------------------
---------
>> To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
>> For additional commands, e-mail: dev-help api.openoffice.org
>>
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
> For additional commands, e-mail: dev-help api.openoffice.org
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| insert graphic into Writer, anchored to
page, can't set position |

|
2006-05-19 12:33:22 |
Mathias Supp schreef:
> Hi Jo,
>
> it seems (to me) somehow logical that orientation and
absolute
> positioning conflict with each other.
>
> But what exactly did you mean with "nothing
happens anymore"?
As soon as I added that and I executed the macro the picture
was not
inserted at all anymore.
You are right, it's logical. The problem is that when those
directives
are not there, one doesn't know their default values have
an influence...
I found those directives in an article about frames and had
to try and
find out whether they would work for graphics.
I really appreciate your help and want to say a big thank
you.
Cheers,
Jo
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| insert graphic into Writer, anchored to
page, can't set position |

|
2006-05-19 12:34:09 |
Fernand Vanrie schreef:
> Jo,
>
> I did in the paste a lot of work in this area and used
always
> "VertOrient =
com.sun.star.text.VertOrientation.NONE " plus in my
old
> notyes i found
> "'for unkwon reasons the only way to get the
values of the
> "Actualsize" of the graphic we needed to
get all the GrapicElements
> and ther name and ther total ' and then been
publiched in a
> messageBox ????? "
>
> What means that i now always "place" the
Graphics at an non-defined
> postion, then enumerate al the graphics, need some
"^pause" (msgbox)
> and then do the positioning, sizing achoring....
> A dev-gui explaned in a recent thread that this
ellements are
> "layout-based" and therefore only can be
found after the grahic is
> actual placen in the WriterDoc
>
> Hope it helps to understand
> Btw. did you read my Insert Graphic quenstions ?
Hi Fernand,
Where can I find these questions?
Jo
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| insert graphic into Writer, anchored to
page, can't set position |

|
2006-05-19 13:33:48 |
Please look at
http://api.openoffice.org/servlets/ReadMsg?
list=dev&msgId=2622846
http://api.openoffice.org/servlets/ReadMsg?
list=dev&msgId=2623946
Fernand
Jo schreef:
> Fernand Vanrie schreef:
>> Jo,
>>
>> I did in the paste a lot of work in this area and
used always
>> "VertOrient =
com.sun.star.text.VertOrientation.NONE " plus in my
old
>> notyes i found
>> "'for unkwon reasons the only way to get the
values of the
>> "Actualsize" of the graphic we needed
to get all the GrapicElements
>> and ther name and ther total ' and then been
publiched in a
>> messageBox ????? "
>>
>> What means that i now always "place"
the Graphics at an non-defined
>> postion, then enumerate al the graphics, need some
"^pause" (msgbox)
>> and then do the positioning, sizing achoring....
>> A dev-gui explaned in a recent thread that this
ellements are
>> "layout-based" and therefore only can
be found after the grahic is
>> actual placen in the WriterDoc
>>
>> Hope it helps to understand
>> Btw. did you read my Insert Graphic quenstions ?
>
> Hi Fernand,
>
> Where can I find these questions?
>
> Jo
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
> For additional commands, e-mail: dev-help api.openoffice.org
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
[1-8]
|
|