OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Problem with applying text attributes to text shape

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
ivan_zderadicka
Newbie
Newbie


Joined: 27 Sep 2004
Posts: 2

PostPosted: Mon Sep 27, 2004 12:41 am    Post subject: Problem with applying text attributes to text shape Reply with quote

Hi,

I have a problem with apllining multiple text attribute changes to the text shape (in Impress), which is being actually edited in the application.
Everything works fine when object is just "selected", but when text editing is going on all changes to text attributes done in macro are ignored ( more correctly except last change done in macro, which become visible when text shape is deselected and thus editing is ended).
It looks like the component is not listening to changes done in macro, while it is opened for editing.
My question now is - how to make it listen to the changes? Or other solution would b how programatically change mode of selected text shape from text editing to "normal" selection" and then back to editing (with cursor on the same place as it was before).
Thanks in advance for any ideas.

Kind regards
Ivan
Back to top
View user's profile Send private message
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Mon Sep 27, 2004 5:55 am    Post subject: Reply with quote

Hi Ivan, I cannot imagine why the format you change via the API should not be staying after the textshape has lost the current focus.
Can you please give some code?

Christian
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
ivan_zderadicka
Newbie
Newbie


Joined: 27 Sep 2004
Posts: 2

PostPosted: Wed Sep 29, 2004 3:38 am    Post subject: Reply with quote

Here is the code:
Sub changeFont(delta)
doc= ThisComponent
cnt = doc.getCurrentController()
sel= cnt.getSelection()
if isNull(sel) or isEmpty(sel) then
MsgBox "No text shape sellected"
end
endif
pg = cnt.getCurrentPage()
shape = sel.getByIndex(0)

if not hasUnoInterfaces(shape, "com.sun.star.text.XText") then
MsgBox "selected object is not text shape"
end
endif
cur = shape.createTextCursor()
cur.gotoStart(false)


while cur.goRight(1, true)

size= cur.getPropertyValue("CharHeight")
cur.setPropertyValue("CharHeight",(size + delta))
cur.collapseToEnd()

wend
End Sub

But the same afect was when I was trying something more simple - like set CharWeight and CharHeight - only last chage appers if selecdtion is in "text editing" mode, if "normal" object selection is active then everything works fine.
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Wed Sep 29, 2004 7:26 am    Post subject: Re: Problem with applying text attributes to text shape Reply with quote

ivan_zderadicka wrote:
works fine when object is just "selected", but when text editing is going on all changes to text attributes done in macro are ignored ( more correctly except last change done in macro, which become visible when text shape is deselected and thus editing is ended).

That is the behavior I get.

ivan_zderadicka wrote:
how programatically change mode of selected text shape from text editing to "normal" selection" and then back to editing (with cursor on the same place as it was before).

I tried this, but no success.....
Code:
Sub Main
   changeFont( 20 )
End Sub

Sub changeFont(delta)
   doc= ThisComponent
   cnt = doc.getCurrentController()
   sel= cnt.getSelection()
   
   if isNull(sel) or isEmpty(sel) then
      MsgBox "No text shape sellected"
      end
   endif
   
   pg = cnt.getCurrentPage()
   shape = sel.getByIndex(0)
   
   if not hasUnoInterfaces(shape, "com.sun.star.text.XText") then
      MsgBox "selected object is not text shape"
      end
   endif
   
   '-----Danny's Changes ------
   ' Just create an empty shape collection of no shapes.
   ' Thus, nothing will be selected on the drawing.
   oShapeCollection = createUnoService( "com.sun.star.drawing.ShapeCollection" )
   cnt.select( oShapeCollection )
   'exit sub
   cnt.select( sel )
   '-----Danny's Changes ------
   
   cur = shape.createTextCursor()
   cur.gotoStart(false)
   
   while cur.goRight(1, true)   
      size= cur.getPropertyValue("CharHeight")
      cur.setPropertyValue("CharHeight",(size + delta))
      cur.collapseToEnd()
   wend
End Sub

_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
gpiroux
General User
General User


Joined: 05 Jan 2005
Posts: 36
Location: Belgium

PostPosted: Mon Apr 18, 2005 12:34 pm    Post subject: Reply with quote

Hello...

no new idea ? I have the same problem with OOo1.1.4
Is there the same problem with 2.0 ?

regards, geoffroy
Back to top
View user's profile Send private message AIM Address MSN Messenger
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Tue Apr 19, 2005 5:01 am    Post subject: Reply with quote

I can only guess as to the problem, but I suspect that it is because the user interface is holding a copy of the properties, which are applied back into the object when the user interface stops editing the object. If nothing else works, I recommend that you try using a dispatch to remove the focus (no, I do not know how to do that) and then try to make your changes. Anything that will cause the UI to refresh AND to remove the focus will probably suffice.
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group