| View previous topic :: View next topic |
| Author |
Message |
asouxuning Power User

Joined: 20 Jan 2008 Posts: 79
|
Posted: Wed Jan 07, 2009 10:09 pm Post subject: How to insert a picture with no fill? |
|
|
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 |
|
 |
asouxuning Power User

Joined: 20 Jan 2008 Posts: 79
|
Posted: Wed Jan 07, 2009 11:32 pm Post subject: |
|
|
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 |
|
 |
asouxuning Power User

Joined: 20 Jan 2008 Posts: 79
|
Posted: Thu Jan 08, 2009 1:05 am Post subject: |
|
|
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 |
|
 |
asouxuning Power User

Joined: 20 Jan 2008 Posts: 79
|
Posted: Thu Jan 08, 2009 1:28 am Post subject: |
|
|
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.
Sharing the result with C++ programmer. Good luck. |
|
| Back to top |
|
 |
|