RE: OO SDK

2013-05-09 Thread k.misha
Thanks a lot!<неиDo you have any examples in VS
C++?<неи<неи<неи-Original Message-<неиFrom: Ariel Constenla-Haile
[mailto:arie...@apache.org] <неиSent: Wednesday, May 08, 2013 6:58 PM<неиTo:
api@openoffice.apache.org<неиSubject: Re: OO SDK<неи<неиHi k.
misha,<неи<неиOn Wed, May 08, 2013 at 02:56:31PM +0300, k.misha wrote:<неи>
Hi!<неи> <неи>  <неи> <неи> How I can insert Image to a calc document using
oo sdk 3.4.1?<неи<неи(Side note: please use descriptive subjects in the
mails, something like "Inserting image in Calc")<неи<неиEach spreadsheet is
described
here:<неиhttp://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/Sp
readsheet.html<неи<неиAs you can see, it supports
::com::sun::star::drawing::XDrawPageSupplier<неиThen:<неи<неи- access a
spreadsheet<неи- get the draw page for this spreadsheet<неи- create a
com.sun.star.drawing.GraphicObjectShape at the document<неи  factory, set
its size, position and graphic URL/css.graphic.XGraphic<неи- add the shape
to the draw page.<неи<неиSample code in Basic:<неи<неиREM  *  BASIC
*<неи<неиSub Main<неиDim oDoc as Object<неиoDoc =
StarDesktop.loadComponentFromURL(_<неи"private:factory/scalc",_<неи
"_default",_<неи0,_<неиArray())<неи<неиDim oGraphic
as Object<неиDim oGraphicProvider as Object<неиoGraphicProvider =
CreateUnoService(_<неи"com.sun.star.graphic.GraphicProvider")<неи
Dim aArgs(0) as new com.sun.star.beans.PropertyValue<неиaArgs(0).Name =
"URL"<неиaArgs(0).Value =
"private:graphicrepository/framework/res/backing.png"<неиoGraphic =
oGraphicProvider.queryGraphic(aArgs)<неи<неиIf IsNull(oGraphic) OR
oGraphic.getType() = com.sun.star.graphic.GraphicType.EMPTY Then<неи
Exit Sub<неиEnd If<неиDim oSize100thMM as Object<неиoSize100thMM
= oGraphic.Size100thMM<неиIf oSize100thMM.Width = 0 OR
oSize100thMM.Height = 0 Then<неиDim oSizePixel as Object<неи
oSizePixel = oGraphic.SizePixel<неиIf oSizePixel.Width = 0 OR
oSizePixel.Height = 0 Then<неиExit Sub<неиEnd If<неи
Dim oUnitConversion as Object<неиoUnitConversion =
oDoc.getCurrentController().getFrame().getContainerWindow()<неи
oSize100thMM =
oUnitConversion.convertSizeToLogic(oSizePixel,com.sun.star.util.MeasureUnit.
MM_100TH)<неиEnd If<неи<неиDim oSheets as Object<неиDim
oSheet as Object<неиoSheets = oDoc.getSheets()<неиIf NOT
oSheets.hasElements() Then<неи'ToDo insert one<неиExit
Sub<неиEnd If<неиoSheet = oSheets.getByIndex(0)<неи<неиDim
oDrawPage as Object<неиoDrawPage = oSheet.getDrawPage()<неи<неи
Dim oGraphicShape as Object<неиoGraphicShape =
oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape")<неи<неи
Dim oPoint as new com.sun.star.awt.Point<неиoPoint.X = 5000<неи
oPoint.Y = 200<неи<неиWith oGraphicShape<неи
.setPosition(oPoint)<неи.setSize(oSize100thMM)<неи.Graphic =
oGraphic<неиEnd With<неиoDrawPage.add(oGraphicShape)<неиEnd
Sub<неи<неи<неиRegards<неи--<неиAriel Constenla-Haile<неиLa Plata,
Argentina<неи


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



Re: OO SDK

2013-05-08 Thread Ariel Constenla-Haile
Hi k. misha,

On Wed, May 08, 2013 at 02:56:31PM +0300, k.misha wrote:
> Hi!
> 
>  
> 
> How I can insert Image to a calc document using oo sdk 3.4.1?

(Side note: please use descriptive subjects in the mails, something like
"Inserting image in Calc")

Each spreadsheet is described here:
http://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/Spreadsheet.html

As you can see, it supports ::com::sun::star::drawing::XDrawPageSupplier
Then:

- access a spreadsheet
- get the draw page for this spreadsheet
- create a com.sun.star.drawing.GraphicObjectShape at the document
  factory, set its size, position and graphic URL/css.graphic.XGraphic
- add the shape to the draw page.

Sample code in Basic:

REM  *  BASIC  *

Sub Main
Dim oDoc as Object
oDoc = StarDesktop.loadComponentFromURL(_
"private:factory/scalc",_
"_default",_
0,_
Array())

Dim oGraphic as Object
Dim oGraphicProvider as Object
oGraphicProvider = CreateUnoService(_
"com.sun.star.graphic.GraphicProvider")
Dim aArgs(0) as new com.sun.star.beans.PropertyValue
aArgs(0).Name = "URL"
aArgs(0).Value = "private:graphicrepository/framework/res/backing.png"
oGraphic = oGraphicProvider.queryGraphic(aArgs)

If IsNull(oGraphic) OR oGraphic.getType() = 
com.sun.star.graphic.GraphicType.EMPTY Then
Exit Sub
End If
Dim oSize100thMM as Object
oSize100thMM = oGraphic.Size100thMM
If oSize100thMM.Width = 0 OR oSize100thMM.Height = 0 Then
Dim oSizePixel as Object
oSizePixel = oGraphic.SizePixel
If oSizePixel.Width = 0 OR oSizePixel.Height = 0 Then
Exit Sub
End If
Dim oUnitConversion as Object
oUnitConversion = 
oDoc.getCurrentController().getFrame().getContainerWindow()
oSize100thMM = 
oUnitConversion.convertSizeToLogic(oSizePixel,com.sun.star.util.MeasureUnit.MM_100TH)
End If

Dim oSheets as Object
Dim oSheet as Object
oSheets = oDoc.getSheets()
If NOT oSheets.hasElements() Then
'ToDo insert one
Exit Sub
End If
oSheet = oSheets.getByIndex(0)

Dim oDrawPage as Object
oDrawPage = oSheet.getDrawPage()

Dim oGraphicShape as Object
oGraphicShape = 
oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape")

Dim oPoint as new com.sun.star.awt.Point
oPoint.X = 5000
oPoint.Y = 200

With oGraphicShape
.setPosition(oPoint)
.setSize(oSize100thMM)
.Graphic = oGraphic
End With
oDrawPage.add(oGraphicShape)
End Sub


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


pgpgSsRF3rcmC.pgp
Description: PGP signature


OO SDK

2013-05-08 Thread k.misha
Hi!

 

How I can insert Image to a calc document using oo sdk 3.4.1?

 

Thanks.