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

How to insert a picture with no fill?

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


Joined: 20 Jan 2008
Posts: 79

PostPosted: Wed Jan 07, 2009 10:09 pm    Post subject: How to insert a picture with no fill? Reply with quote

I have a picture with transparent area inserted in a document. and I set the transparency property and so on. but these doesn't work.
this is my code.
Code:

Reference<uno::XInterface> rTextGraphicObject = m_dsmgr->createInstance(OUSTR("com.sun.star.text.TextGraphicObject"));
      xTextContent = Reference<text::XTextContent>(rTextGraphicObject, UNO_QUERY);
      Reference<beans::XPropertySet> xTextContentProps(xTextContent, UNO_QUERY);
      xTextContentProps->setPropertyValue(OUSTR("GraphicURL"), Any(OUSTR(iPath)));
      xTextContentProps->setPropertyValue(OUSTR("Width"), Any((short)width));
      xTextContentProps->setPropertyValue(OUSTR("Height"), Any((short)height));

      xTextContentProps->setPropertyValue(OUSTR("ContentProtected"), Any(sal_False));
      xTextContentProps->setPropertyValue(OUSTR("BackTransparent"), Any(sal_True));
      xTextContentProps->setPropertyValue(OUSTR("Opaque"), Any(sal_False));
      xTextContentProps->setPropertyValue(OUSTR("GraphicColorMode"), Any(drawing::ColorMode_STANDARD));
      std::cout << "TextGraphicObject.\n";
   Reference<text::XTextCursor> xTextCursor = xText->createTextCursor();
   xTextCursor->gotoStart(sal_False);
   xText->insertTextContent(xTextCursor->getStart(), xTextContent, sal_False);
Back to top
View user's profile Send private message
asouxuning
Power User
Power User


Joined: 20 Jan 2008
Posts: 79

PostPosted: Wed Jan 07, 2009 11:32 pm    Post subject: Reply with quote

and I get the property BackTransparent, the value is true.

I did the same thing in OOoBasic and set BackTransparent true. It works well with no fill color(white).
Back to top
View user's profile Send private message
asouxuning
Power User
Power User


Joined: 20 Jan 2008
Posts: 79

PostPosted: Thu Jan 08, 2009 1:05 am    Post subject: Reply with quote

Ok, I got it.

I set BackTransparent false first. Then set it true back. after the two steps, BackTransparent works.

Is this a bug?Why it can't take effect the first time I set the property value?
Back to top
View user's profile Send private message
asouxuning
Power User
Power User


Joined: 20 Jan 2008
Posts: 79

PostPosted: Thu Jan 08, 2009 1:28 am    Post subject: Reply with quote

Seemingly the default back color which the C++ api set is white. White color has no Transparency. So you must set a non-white back color first. Setting a back color needs to set BackTransparent false first.So the code seems redundent:

Code:

xTextGraphicObjectProps->setPropertyValue(OUSTR("BackTransparent"), Any(sal_False));
       xTextGraphicObjectProps->setPropertyValue(OUSTR("BackColor"), Any((util::Color)0xCCCCCC));
   xTextGraphicObjectProps->setPropertyValue(OUSTR("BackTransparent"), Any(sal_True));


this took me two days to solve. Crying or Very sad
Sharing the result with C++ programmer. Good luck.
Back to top
View user's profile Send private message
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