Difference between revisions of "Working with Shapes"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (See also)
 
(46 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{NeedsRework|EN}}
 
==Introduction==
 
==Introduction==
We describe first our new starting code. Any procedures are added to simplify the listings given [http://www.oooforum.org/forum/viewtopic.phtml?t=11128 here] (from Christian Junker).
+
We describe first our new starting code. Any procedures are added to simplify the listings given [http://www.oooforum.org/forum/viewtopic.phtml?t=11128 here] (from Christian Junker). We are using in this code <idl>com.sun.star.drawing.XShapes</idl>, <idl>com.sun.star.drawing.XShape</idl>, <idl>com.sun.star.drawing.XDrawPage</idl> and <idl>com.sun.star.beans.XPropertySet</idl> interfaces and <idl>com.sun.star.awt.Point</idl>, <idl>com.sun.star.awt.Size</idl> structures.
<code>[cpp]
+
 
 +
<source lang="cpp">
 
//Listing 1 New sub to simplify Shape Management
 
//Listing 1 New sub to simplify Shape Management
 
// C++
 
// C++
Line 33: Line 35:
 
makeAny(OUString::createFromAscii(shapename)));  
 
makeAny(OUString::createFromAscii(shapename)));  
 
}  
 
}  
</code>
+
</source>
With these procedures we start now from a rectangle shape : our new starting main code is then :
+
 
<code>[cpp]
+
With these procedures we start now from a rectangle shape. Our new starting main code is then using a lot of interfaces <idl>com.sun.star.drawing.XDrawPagesSupplier</idl>, <idl>com.sun.star.drawing.XDrawPages</idl>, <idl>com.sun.star.beans.XIndexAccess</idl>, <idl>com.sun.star.drawing.XDrawPage</idl>, <idl>com.sun.star.drawing.XShape</idl>, <idl>com.sun.star.container.XNamed</idl> and  <idl>com.sun.star.drawing.RectangleShape</idl> service:
 +
 
 +
<source lang="cpp">
 
//Listing 2 Our new starting Code
 
//Listing 2 Our new starting Code
 
int main( ) {
 
int main( ) {
Line 97: Line 101:
 
     return 0;
 
     return 0;
 
}
 
}
</code>
+
</source>
 +
 
 
This code draws a blue colored rectangle.
 
This code draws a blue colored rectangle.
 +
 +
You can find the [[OOConnect|ooConnect() function here]].
  
 
=Shape's Properties=
 
=Shape's Properties=
 +
 
==Background Colors and Shape Colors==
 
==Background Colors and Shape Colors==
The shape is usually created with a default background color and and a uniform (solid) color. It is possible to change this. We search how,  and then begin with  a look to <OpenOffice.org1.1_SDK>/idl/com/sun/star/drawing/fillstyle.idl file :
+
 
<pre>
+
The shape is usually created with a default background color and and a uniform (solid) color. It is possible to change this. We search how,  and then begin with  a look to <OpenOffice.org1.1_SDK>/idl/com/sun/star/drawing/fillstyle.idl file (available also here :<idl>com.sun.star.drawing.fillstyle</idl>):
 +
 
 +
<source lang="idl">
 
//Listing 3 Fillstyle IDL File  
 
//Listing 3 Fillstyle IDL File  
 
// IDL
 
// IDL
Line 116: Line 126:
 
};  
 
};  
 
}; }; }; };
 
}; }; }; };
</pre>
+
</source>
 +
 
 
This problem has been already tackled in [[SDKCppLanguage#To_go_further_:_the_Enumeration_Type_Problem | To go further : the Enumeration values Problem]]  : we can deduce from this IDL file that our constants in C++ are : FillStyle_NONE, FillStyle_SOLID, ... and FillStyle_BITMAP and we have to construct the corresponding hpp and hxx files.
 
This problem has been already tackled in [[SDKCppLanguage#To_go_further_:_the_Enumeration_Type_Problem | To go further : the Enumeration values Problem]]  : we can deduce from this IDL file that our constants in C++ are : FillStyle_NONE, FillStyle_SOLID, ... and FillStyle_BITMAP and we have to construct the corresponding hpp and hxx files.
 
The second problem is how to translate this OOoBasic piece of code :
 
The second problem is how to translate this OOoBasic piece of code :
<code>[oobas]
+
 
 +
<source lang="vb">
 
'Listing 4 How to translate this OOoBasic Code ?
 
'Listing 4 How to translate this OOoBasic Code ?
 
REM  *****  BASIC  *****
 
REM  *****  BASIC  *****
 
MaForme.FillColor = RGB(255,200,255)
 
MaForme.FillColor = RGB(255,200,255)
 
MaForme.FillStyle = com.sun.star.drawing.FillStyle.NONE
 
MaForme.FillStyle = com.sun.star.drawing.FillStyle.NONE
</code>
+
</source>
To put it differently, is the FillStyle a property and what about FillColor ? To search an answer we return to IDL file with FillProperties.idl :  
+
 
<pre>
+
To put it differently, is the FillStyle a property and what about FillColor ? To search an answer we return to IDL file with FillProperties.idl (available also here <idl>com.sun.star.drawing.FillProperties</idl>) :  
 +
 
 +
<source lang="idl">
 
//Listing 5 Fillproperties IDL File  
 
//Listing 5 Fillproperties IDL File  
 
// IDL
 
// IDL
Line 156: Line 170:
 
};
 
};
 
}; }; }; };  
 
}; }; }; };  
</pre>
+
</source>
The both first properties seem interesting for us. We begin with FillColor. If we add this code we obtain a rectangle with an other color.
+
 
<code>[cpp]
+
The both first properties seem interesting for us. We begin with FillColor. Adding the code below, we obtain a rectangle with an other color (green here) using <idl>com.sun.star.beans.XPropertySet</idl> interface
 +
 
 +
<source lang="cpp">
 
//Listing 6 Coloring the Shape Background
 
//Listing 6 Coloring the Shape Background
 
// C++
 
// C++
Line 170: Line 186:
 
color<<=(long)0xFF00;  //green
 
color<<=(long)0xFF00;  //green
 
rShapeProps->setPropertyValue(OUString::createFromAscii("FillColor"),color);
 
rShapeProps->setPropertyValue(OUString::createFromAscii("FillColor"),color);
</code>
+
</source>
 +
 
 
The color is defined in RGB : one octet for each : 0xff0000 is red, 0x00ff00 is green and 0x0000ff is blue.
 
The color is defined in RGB : one octet for each : 0xff0000 is red, 0x00ff00 is green and 0x0000ff is blue.
 
It's time to remove the background color with the FillStyle_NONE constant. Simply add this code :
 
It's time to remove the background color with the FillStyle_NONE constant. Simply add this code :
<code>[cpp]
+
 
 +
<source lang="cpp">
 
//Listing 7 Removing the Shape Background
 
//Listing 7 Removing the Shape Background
 
// C++
 
// C++
Line 182: Line 200:
 
FillStyle <<= FillStyle_NONE;
 
FillStyle <<= FillStyle_NONE;
 
rShapeProps->setPropertyValue(OUString::createFromAscii("FillStyle"),FillStyle);
 
rShapeProps->setPropertyValue(OUString::createFromAscii("FillStyle"),FillStyle);
</code>
+
</source>
 +
 
 
We stop here but there is a lot to do with other FillStyle constants.
 
We stop here but there is a lot to do with other FillStyle constants.
 +
 +
See also <idl>com.sun.star.drawing.FillStyle</idl>, <idl>com.sun.star.beans.XPropertySet</idl>, <idl>com.sun.star.drawing.FillProperties</idl> and <idl>com.sun.star.beans.XPropertySet</idl>.
  
 
==Shape and Shadow==
 
==Shape and Shadow==
Shadow is described by ShadowProperties.idl file :
+
 
<pre>
+
Shadow is described by <idl>com.sun.star.drawing.ShadowProperties</idl> interface presented below :
 +
 
 +
<source lang="idl">
 
// IDL
 
// IDL
 
module com {  module sun {  module star {  module drawing {
 
module com {  module sun {  module star {  module drawing {
Line 199: Line 222:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</pre>
+
</source>
 +
 
 
Then the corresponding C++ code to manipulate these properties could be :
 
Then the corresponding C++ code to manipulate these properties could be :
<code>[cpp]
+
 
 +
<source lang="cpp">
 
//Listing 8 Shadowing a Shape
 
//Listing 8 Shadowing a Shape
 
// C++
 
// C++
Line 211: Line 236:
 
ShadowProperties[3] <<= (long) 300;
 
ShadowProperties[3] <<= (long) 300;
 
rShapeProps->setPropertyValue(OUString::createFromAscii("Shadow"),ShadowProperties[0]);
 
rShapeProps->setPropertyValue(OUString::createFromAscii("Shadow"),ShadowProperties[0]);
rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowColor"),
+
rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowColor"),ShadowProperties[1]);
ShadowProperties[1]);
+
rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowXDistance"),ShadowProperties[2]);
rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowXDistance"),
+
rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowYDistance"),ShadowProperties[3]);
ShadowProperties[2]);
+
</source>
rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowYDistance"),
+
 
ShadowProperties[3]);
+
</code>
+
 
This code adds a red shadow at the rectangle shape.
 
This code adds a red shadow at the rectangle shape.
  
 
==Shape's Rotation and sharing==
 
==Shape's Rotation and sharing==
 +
 
The corresponding IDL file is  
 
The corresponding IDL file is  
<pre>
+
 
 +
<source lang="idl">
 
// IDL
 
// IDL
 
module com {  module sun {  module star {  module drawing {
 
module com {  module sun {  module star {  module drawing {
Line 234: Line 259:
 
};
 
};
 
}; }; }; };
 
}; }; }; };
</pre>
+
</source>
 +
 
 
The angle is given in 1/100° starting from an horizontal line.
 
The angle is given in 1/100° starting from an horizontal line.
<code>[cpp]
+
 
 +
<source lang="cpp">
 
//Listing 9 Rotating a Shape
 
//Listing 9 Rotating a Shape
 
// C++
 
// C++
Line 242: Line 269:
 
Angle <<= (long)3000; // 30 degres
 
Angle <<= (long)3000; // 30 degres
 
rShapeProps->setPropertyValue(OUString::createFromAscii("RotateAngle"),Angle);
 
rShapeProps->setPropertyValue(OUString::createFromAscii("RotateAngle"),Angle);
</code>
+
</source>
which gives a 30° rotation.
+
 
 +
which gives a 30° rotation. We have already defined in previous code, the variable rShapeProps as a <idl>com.sun.star.beans.XPropertySet</idl> interface.
 +
 
 +
See also <idl>com.sun.star.drawing.RotationDescriptor</idl>.
  
 
==Line Style==
 
==Line Style==
The corresponding IDL files are :
+
 
<pre>
+
The corresponding IDL files are (<idl>com.sun.star.drawing.LineProperties</idl>, <idl>com.sun.star.drawing.LineStyle</idl> and <idl>com.sun.star.drawing.LineDash</idl>):
 +
 
 +
<source lang="idl">
 
//Listing 10 Lineproperties IDL file  
 
//Listing 10 Lineproperties IDL file  
 
// IDL
 
// IDL
Line 268: Line 300:
 
};  
 
};  
 
}; }; }; };  
 
}; }; }; };  
</pre>
+
</source>
 +
 
 
completed with :
 
completed with :
<pre>
+
 
 +
<source lang="idl">
 
//Listing 11 LineStyle Enumeration
 
//Listing 11 LineStyle Enumeration
 
// IDL
 
// IDL
Line 281: Line 315:
 
};
 
};
 
}; }; }; };
 
}; }; }; };
</pre>
+
</source>
 +
 
 
We give the significance of these constants :
 
We give the significance of these constants :
 
; line styles
 
; line styles
Line 296: Line 331:
  
 
We give now the LineDash properties with an IDL file   
 
We give now the LineDash properties with an IDL file   
<pre>
+
 
 +
<source lang="idl">
 
//Listing 12 IDL File : Linedash
 
//Listing 12 IDL File : Linedash
 
// IDL
 
// IDL
Line 310: Line 346:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</pre>
+
</source>
 +
 
 
and their meaning :
 
and their meaning :
 
; lineDash properties
 
; lineDash properties
Line 330: Line 367:
 
|}
 
|}
  
The dash styles are given  
+
The dash styles are given now (<idl>com.sun.star.drawing.DashStyle</idl>)
<pre>
+
 
 +
<source lang="idl">
 
//Listing 13 DashStyle IDL File  
 
//Listing 13 DashStyle IDL File  
 
// IDL
 
// IDL
Line 343: Line 381:
 
};
 
};
 
}; }; }; };
 
}; }; }; };
</pre>
+
</source>
 +
 
 
Here is an example in C++ which uses a line style :
 
Here is an example in C++ which uses a line style :
<code>[cpp]
+
 
 +
<source lang="cpp">
 
//Listing 14 Modifying a Line Style : en Example
 
//Listing 14 Modifying a Line Style : en Example
 
// C++
 
// C++
Line 369: Line 409:
 
LineWidth <<= (long) 50;
 
LineWidth <<= (long) 50;
 
rShapeProps->setPropertyValue(OUString::createFromAscii("LineWidth"),LineWidth);
 
rShapeProps->setPropertyValue(OUString::createFromAscii("LineWidth"),LineWidth);
</code>
+
</source>
 +
 
 
Adding this code to the previous one,  gives this figure :
 
Adding this code to the previous one,  gives this figure :
  
 
[[Image:shape1.png|center]]
 
[[Image:shape1.png|center]]
 +
 +
See also <idl>com.sun.star.drawing.LineDash</idl> and <idl>com.sun.star.drawing.LineStyle</idl>.
  
 
We can go further with shapes now.
 
We can go further with shapes now.
  
 
=Drawing Shapes=
 
=Drawing Shapes=
 +
 
==Polyline Shape==
 
==Polyline Shape==
 +
 
When working with polyline the first question we have to answer is what is a  
 
When working with polyline the first question we have to answer is what is a  
Sequence < Sequence < Point >> ? We give the IDL description :
+
Sequence < Sequence < Point >> ? We give the IDL description (<idl>com.sun.star.drawing.PointSequenceSequence</idl>) :
<pre>
+
 
 +
<source lang="idl">
 
//Listing 15 PointSequenceSequence IDL File
 
//Listing 15 PointSequenceSequence IDL File
 
// IDL
 
// IDL
Line 386: Line 432:
 
typedef sequence<PointSequence> PointSequenceSequence;
 
typedef sequence<PointSequence> PointSequenceSequence;
 
}; }; }; };  
 
}; }; }; };  
</pre>
+
</source>
What is a PointSequence ?
+
 
<pre>
+
What is a PointSequence ? The answer is given by (<idl>com.sun.star.drawing.PointSequence</idl>):
 +
 
 +
<source lang="idl">
 
//Listing 16 PointSequence IDL File
 
//Listing 16 PointSequence IDL File
 
// IDL
 
// IDL
Line 394: Line 442:
 
typedef sequence<com::sun::star::awt::Point> PointSequence;
 
typedef sequence<com::sun::star::awt::Point> PointSequence;
 
}; }; }; };  
 
}; }; }; };  
</pre>
+
</source>
We can have a look at PolyLineShape now :
+
 
<pre>
+
We can have a look at <idl>com.sun.star.drawing.PolyLineShape</idl> now :
 +
 
 +
<source lang="idl">
 
//Listing 17 PolyLineShape IDL File  
 
//Listing 17 PolyLineShape IDL File  
 
// IDL
 
// IDL
Line 410: Line 460:
 
};
 
};
 
}; }; }; };
 
}; }; }; };
</pre>
+
</source>
The last IDL file we have to inspect is the PolyPolygonDescriptor service :
+
 
<pre>
+
The last IDL file we have to inspect is the <idl>com.sun.star.drawing.PolyPolygonDescriptor</idl> service :
 +
 
 +
<source lang="idl">
 
//Listing 18 PolyPolygonDescriptor IDL File
 
//Listing 18 PolyPolygonDescriptor IDL File
 
// IDL
 
// IDL
Line 423: Line 475:
 
};
 
};
 
}; }; }; };
 
}; }; }; };
</pre>
+
</source>
 +
 
 
where we see the PolyPolygon is a property. These files allow us to draw any tips :
 
where we see the PolyPolygon is a property. These files allow us to draw any tips :
first construct a Sequence< Sequence< Point >> and put values in it
+
*first construct a Sequence< Sequence< Point >> and put values in it
second transform it in an Any variable
+
*second transform it in an Any variable
third, use the  XPropertySet to gives a value to the property "PolyPolygon"
+
*third, use the  <idl>com.sun.star.beans.XPropertySet</idl> interface to gives a value to the property "PolyPolygon".
 +
 
 
This conduct us to the following example
 
This conduct us to the following example
<code>[cpp]
+
 
 +
<source lang="cpp">
 
//Listing 19 Using a Polyline Shape
 
//Listing 19 Using a Polyline Shape
 
// C++
 
// C++
Line 460: Line 515:
 
Reference< XPropertySet > rPolyShapeProps(rPolyLineShape,UNO_QUERY);
 
Reference< XPropertySet > rPolyShapeProps(rPolyLineShape,UNO_QUERY);
 
rPolyShapeProps->setPropertyValue(OUString::createFromAscii("PolyPolygon"),PropspolyPoly);
 
rPolyShapeProps->setPropertyValue(OUString::createFromAscii("PolyPolygon"),PropspolyPoly);
</code>
+
</source>
 +
 
 
When running, this example gives a figure presented below :
 
When running, this example gives a figure presented below :
  
 
[[Image:Shape2.png|center|Polyline Example]]
 
[[Image:Shape2.png|center|Polyline Example]]
  
If you replace “PolyLineShape” with “PolyPolygonShape” in the previous code, you obtain the same shape but closed  (and by default filled).
+
If you replace <idl>com.sun.star.drawing.PolyLineShape</idl> with <idl>com.sun.star.drawing.PolyPolygonShape</idl> in the previous code, you obtain the same shape but closed  (and by default filled).
 +
 
 +
See also <idl>com.sun.star.drawing.PolyLineShape</idl>, <idl>com.sun.star.drawing.PolyPolygonDescriptor</idl> and <idl>com.sun.star.drawing.PolyPolygonShape</idl>.
  
 
==Bezier Shape==
 
==Bezier Shape==
Let us begin describing the Bezier's struct :  PolyPolygonBezierCoords is presented now :
+
Let us begin describing the Bezier's struct :  <idl>com.sun.star.drawing.PolyPolygonBezierCoords</idl> is presented now :
<pre>
+
 
 +
<source lang="idl">
 
//Listing 20 PolyPolygonBezierCoords IDL File
 
//Listing 20 PolyPolygonBezierCoords IDL File
 
// IDL
 
// IDL
Line 484: Line 543:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</pre>
+
</source>
PointSequenceSequence has been already encountered in the previous chapter. More precision on flags is expected. Again the IDL file will give us this information :
+
 
<pre>
+
<idl>com.sun.star.drawing.PointSequenceSequence</idl>has been already encountered in the previous chapter. More precision on flags is expected. Again the IDL file will give us this information (<idl>com.sun.star.drawing.PolygonFlags</idl>) :
 +
 
 +
<source lang="idl">
 
//Listing 21 PolygonFlags enumeration : IDL File  
 
//Listing 21 PolygonFlags enumeration : IDL File  
 
// IDL
 
// IDL
Line 498: Line 559:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</pre>
+
</source>
The service ClosedBezierShape is interesting :
+
 
<pre>
+
The service <idl>com.sun.star.drawing.ClosedBezierShape</idl> is interesting :
 +
 
 +
<source lang="idl">
 
//Listing 22 ClosedBezierShape Service : IDL File  
 
//Listing 22 ClosedBezierShape Service : IDL File  
 
// IDL
 
// IDL
Line 515: Line 578:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</pre>
+
</source>
and also the PolyPolygonDescriptor :
+
 
<pre>
+
and also the <idl>com.sun.star.drawing.PolyPolygonDescriptor</idl> service :
 +
 
 +
<source lang="idl">
 
//Listing 23 PolyPolygonBezierDescriptor Service : IDL File  
 
//Listing 23 PolyPolygonBezierDescriptor Service : IDL File  
 
// IDL
 
// IDL
Line 528: Line 593:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</pre>
+
</source>
Again as in previous chapter, what we see are properties. We have never encounter the first (PolygonKind) and then give the corresponding IDL file :
+
 
<pre>
+
Again as in previous chapter, what we see are properties. We have never encounter the first (<idl>com.sun.star.drawing.PolygonKind</idl>) and then give the corresponding IDL file :
 +
 
 +
<source lang="idl">
 
//Listing 24 PolygonKind Enumeration : IDL File  
 
//Listing 24 PolygonKind Enumeration : IDL File  
 
// IDL
 
// IDL
Line 556: Line 623:
 
};  
 
};  
 
}; }; }; };   
 
}; }; }; };   
</pre>
+
</source>
 +
 
 
Note this property is read only. We have left comments to understand the values'  significance, difficult to guess with only their name.
 
Note this property is read only. We have left comments to understand the values'  significance, difficult to guess with only their name.
 
The following code draw a Bezier closed shape :
 
The following code draw a Bezier closed shape :
<code>[cpp]
+
 
 +
<source lang="cpp">
 
//Listing 25 Bezier Shape : an Example
 
//Listing 25 Bezier Shape : an Example
 
// C++
 
// C++
Line 609: Line 678:
 
rClosedBezierShapeProps->setPropertyValue(OUString::createFromAscii
 
rClosedBezierShapeProps->setPropertyValue(OUString::createFromAscii
 
                               ("PolyPolygonBezier"), ClosedBezierProperty);
 
                               ("PolyPolygonBezier"), ClosedBezierProperty);
</code>
+
</source>
 +
 
 
It is possible to replace “ClosedBezierShape” with “OpenBezierShape” and obtain an open shape.
 
It is possible to replace “ClosedBezierShape” with “OpenBezierShape” and obtain an open shape.
When reading the PolyPolygonBezierShape.idl file I deduce I have only to replace “ClosedBezierShape” with “PolyPolygonBezierShape to have an open Bezier Shape. But it doesn't work and I don't know why for the moment. Andrew Pitonyak writes in his book : “Not all combinations of points and flags are valid” and I suppose I have a false combination.  
+
When reading the <idl>com.sun.star.drawing.PolyPolygonBezierShape</idl> file I deduce I have only to replace “<idl>com.sun.star.drawing.ClosedBezierShape</idl>” with “<idl>com.sun.star.drawing.PolyPolygonBezierShape</idl> to obtain an open Bezier Shape. But it doesn't work and I don't know why for the moment. Andrew Pitonyak writes in his book : “Not all combinations of points and flags are valid” and I suppose I have a false combination.
 +
 
 +
See also <idl>com.sun.star.drawing.PolyPolygonBezierCoords</idl>, <idl>com.sun.star.drawing.FlagSequenceSequence</idl>, <idl>com.sun.star.drawing.FlagSequence</idl>, <idl>com.sun.star.drawing.PolygonFlags</idl> and <idl>com.sun.star.drawing.ClosedBezierShape</idl>
 +
 
 
==Connectors and glues points==
 
==Connectors and glues points==
<pre>
+
 
 +
<source lang="idl">
 
//Listing 26  XGluePointsSupplier IDL File  
 
//Listing 26  XGluePointsSupplier IDL File  
 
// IDL
 
// IDL
Line 623: Line 697:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</pre>
+
</source>
 +
 
 
To do : to continue
 
To do : to continue
  
  
 
+
{{Template:Home_Page}}
[[Image:HomePageCpp.png]] [[Using_Cpp_with_the_OOo_SDK|Return to Document Home page]]
+
  
 
= See also=
 
= See also=
 
+
* [[FR/Documentation/Les_formes_%28shapes%29|French version of this chapter]].
 +
* Drawing Documents and Presentation Documents [[Documentation/DevGuide/Drawings/Drawing_Documents_and_Presentation_Documents|in Developer's Guide]]
 +
* [[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno|C++ and UNO tutorial]]
 
* [http://perso.wanadoo.fr/moutou/MyUNODoc_HTML/UNOCppAPI7.html Shapes] (Chapter 7 from UNO/C++ document)  
 
* [http://perso.wanadoo.fr/moutou/MyUNODoc_HTML/UNOCppAPI7.html Shapes] (Chapter 7 from UNO/C++ document)  
 
* Writing a Program to Control OpenOffice.org, by Franco Pingiori — [http://www.linuxjournal.com/article/8550 Part 1] and [http://www.linuxjournal.com/article/8608 Part 2], Linux Journal
 
* Writing a Program to Control OpenOffice.org, by Franco Pingiori — [http://www.linuxjournal.com/article/8550 Part 1] and [http://www.linuxjournal.com/article/8608 Part 2], Linux Journal
Line 637: Line 713:
 
[[Category:OOoDraw]]
 
[[Category:OOoDraw]]
 
[[Category:OOoImpress]]
 
[[Category:OOoImpress]]
[[Category:Development]]
+
[[Category:Cpp]]
[[Category:Uno:Cpp]]
+
[[Category:Uno]]

Latest revision as of 14:00, 30 June 2018


Edit-find-replace.png This article should be checked for accuracy and conformity to style.

Introduction

We describe first our new starting code. Any procedures are added to simplify the listings given here (from Christian Junker). We are using in this code com.sun.star.drawing.XShapes, com.sun.star.drawing.XShape, com.sun.star.drawing.XDrawPage and com.sun.star.beans.XPropertySet interfaces and com.sun.star.awt.Point, com.sun.star.awt.Size structures.

//Listing 1 New sub to simplify Shape Management
// C++
// Don't forget to add : #include <com/sun/star/drawing/XShapes.hpp>
// Don't forget to add "com.sun.star.drawing.XShapes \" in the makefile
 
// Don't forget to add : using namespace com::sun::star::beans;
// Don't forget to add : #include <com/sun/star/beans/XPropertySet.hpp>
// Don't forget to add "com.sun.star.beans.XPropertySet \" in the makefile
 
// Christian Junker code
void MakePosition(sal_Int32 x, sal_Int32 y, ::com::sun::star::awt::Point *Pos) 
{ 
 
	Pos->X = x; 
	Pos->Y = y; 
} 
 
void MakeSize(sal_Int32 width, sal_Int32 height, ::com::sun::star::awt::Size *Size) 
{ 
	Size->Width = width; 
	Size->Height = height; 
} 
 
void DrawMe(Reference< XShape > &Shape, Reference< XDrawPage > &page, const char *shapename) 
{ 
	Reference< XShapes > Shapes(page, UNO_QUERY); 
	Shapes->add(Shape); 
	Reference< XPropertySet > shapeprops(Shape, UNO_QUERY); 
	shapeprops->setPropertyValue(OUString::createFromAscii("Name"),
					makeAny(OUString::createFromAscii(shapename))); 
}

With these procedures we start now from a rectangle shape. Our new starting main code is then using a lot of interfaces com.sun.star.drawing.XDrawPagesSupplier, com.sun.star.drawing.XDrawPages, com.sun.star.beans.XIndexAccess, com.sun.star.drawing.XDrawPage, com.sun.star.drawing.XShape, com.sun.star.container.XNamed and com.sun.star.drawing.RectangleShape service:

//Listing 2 Our new starting Code
int main( ) {
//retrieve an instance of the remote service manager
    Reference< XMultiServiceFactory > rOfficeServiceManager;
    rOfficeServiceManager = ooConnect();
    if( rOfficeServiceManager.is() ){
        printf( "Connected sucessfully to the office\n" );
    }
 
//get the desktop service using createInstance returns an XInterface type
    Reference< XInterface  > Desktop = rOfficeServiceManager->createInstance(
    OUString::createFromAscii( "com.sun.star.frame.Desktop" ));
 
//query for the XComponentLoader interface
    Reference< XComponentLoader > rComponentLoader (Desktop, UNO_QUERY);
    if( rComponentLoader.is() ){
        	printf( "XComponentloader successfully instanciated\n" );
    	}
 
//get an instance of the OOowriter document
    Reference< XComponent > xcomponent = rComponentLoader->loadComponentFromURL(
	OUString::createFromAscii("private:factory/sdraw"),
        OUString::createFromAscii("_blank"),
        0,
        Sequence < ::com::sun::star::beans::PropertyValue >());
 
// added code here
	Reference< XDrawPagesSupplier > rDrawDoc(xcomponent, UNO_QUERY);
 
// query the XDrawPages Interface
	Reference< XDrawPages > rDrawPages = rDrawDoc->getDrawPages();
 
// query the XIndexAccess Interface
	Reference< XIndexAccess > rPageIndexAccess(rDrawPages, UNO_QUERY);
 
	Any DrawPage = rPageIndexAccess->getByIndex(0);
 
// Query the XDrawPage Interface
	Reference< XDrawPage > rDrawPage(DrawPage, UNO_QUERY);
// query for the XNamed Interface
	Reference< XNamed > rNamed(DrawPage, UNO_QUERY);
	rNamed->setName(OUString::createFromAscii("My first page"));
 
	Reference< XMultiServiceFactory > DocFactory(xcomponent, UNO_QUERY);
 
	Point *Pos = new (Point);
	Size *TheSize = new ( Size );
 
	Reference< XInterface > RectangleShape = DocFactory->createInstance(
	               OUString::createFromAscii("com.sun.star.drawing.RectangleShape") );
	Reference< XShape > rRectShape(RectangleShape, UNO_QUERY);
	MakePosition(2000, 6000, Pos);
	MakeSize(7000, 2000, TheSize);
	rRectShape->setPosition(*Pos);
	rRectShape->setSize(*TheSize);
	DrawMe(rRectShape, rDrawPage, "My TextShape");
 
// add code here 
 
    return 0;
}

This code draws a blue colored rectangle.

You can find the ooConnect() function here.

Shape's Properties

Background Colors and Shape Colors

The shape is usually created with a default background color and and a uniform (solid) color. It is possible to change this. We search how, and then begin with a look to <OpenOffice.org1.1_SDK>/idl/com/sun/star/drawing/fillstyle.idl file (available also here :com.sun.star.drawing.fillstyle):

//Listing 3 Fillstyle IDL File 
// IDL
module com {  module sun {  module star {  module drawing {
enum FillStyle
{
	NONE,
	SOLID,
	GRADIENT, 
	HATCH, 
	BITMAP  
}; 
}; }; }; };

This problem has been already tackled in To go further : the Enumeration values Problem  : we can deduce from this IDL file that our constants in C++ are : FillStyle_NONE, FillStyle_SOLID, ... and FillStyle_BITMAP and we have to construct the corresponding hpp and hxx files. The second problem is how to translate this OOoBasic piece of code :

'Listing 4 How to translate this OOoBasic Code ?
REM  *****  BASIC  *****
MaForme.FillColor = RGB(255,200,255)
MaForme.FillStyle = com.sun.star.drawing.FillStyle.NONE

To put it differently, is the FillStyle a property and what about FillColor ? To search an answer we return to IDL file with FillProperties.idl (available also here com.sun.star.drawing.FillProperties) :

//Listing 5 Fillproperties IDL File 
// IDL
module com { module sun { module star { module drawing {
service FillProperties
{
	[property] com::sun::star::drawing::FillStyle FillStyle;
	[property] long FillColor;
	[property] short FillTransparence;
	[property] string FillTransparenceGradientName;
	[optional, property] com::sun::star::awt::Gradient FillTransparenceGradient;
	[property] string FillGradientName;
	[optional, property] com::sun::star::awt::Gradient FillGradient;
	[property] string FillHatchName;
	[optional, property] com::sun::star::drawing::Hatch FillHatch;
	[property] string FillBitmapName;
	[optional, property] com::sun::star::awt::XBitmap FillBitmap;
	[optional, property] string FillBitmapURL;
	[property] short FillBitmapOffsetX;
	[property] short FillBitmapOffsetY;
	[property] short FillBitmapPositionOffsetX;
	[property] short FillBitmapPositionOffsetY;
	[property] com::sun::star::drawing::RectanglePoint FillBitmapRectanglePoint;
	[property] boolean FillBitmapLogicalSize;
	[property] long FillBitmapSizeX;
	[property] long FillBitmapSizeY;
	[property] com::sun::star::drawing::BitmapMode FillBitmapMode;
	[property] boolean FillBackground;
};
}; }; }; };

The both first properties seem interesting for us. We begin with FillColor. Adding the code below, we obtain a rectangle with an other color (green here) using com.sun.star.beans.XPropertySet interface

//Listing 6 Coloring the Shape Background
// C++
// Don't forget to add : using namespace com::sun::star::beans;
// Don't forget to add : #include <com/sun/star/beans/XPropertySet.hpp>
// Don't forget to add "com.sun.star.beans.XPropertySet \" in the makefile
 
// Get the property set of the rRectShape 
	Reference< XPropertySet > rShapeProps(rRectShape,UNO_QUERY);
	Any color;
	color<<=(long)0xFF00;  //green
	rShapeProps->setPropertyValue(OUString::createFromAscii("FillColor"),color);

The color is defined in RGB : one octet for each : 0xff0000 is red, 0x00ff00 is green and 0x0000ff is blue. It's time to remove the background color with the FillStyle_NONE constant. Simply add this code :

//Listing 7 Removing the Shape Background
// C++
// Don't forget to add : #include <com/sun/star/drawing/FillStyle.hpp>
// Don't forget to add "com.sun.star.drawing.FillStyle \" in the makefile
 
	Any FillStyle;
	FillStyle <<= FillStyle_NONE;
	rShapeProps->setPropertyValue(OUString::createFromAscii("FillStyle"),FillStyle);

We stop here but there is a lot to do with other FillStyle constants.

See also com.sun.star.drawing.FillStyle, com.sun.star.beans.XPropertySet, com.sun.star.drawing.FillProperties and com.sun.star.beans.XPropertySet.

Shape and Shadow

Shadow is described by com.sun.star.drawing.ShadowProperties interface presented below :

// IDL
module com {  module sun {  module star {  module drawing {
service ShadowProperties
{
	[property] boolean Shadow;
	[property] long ShadowColor;
	[property] short ShadowTransparence;
	[property] long ShadowXDistance;
	[property] long ShadowYDistance;
};
}; }; }; };

Then the corresponding C++ code to manipulate these properties could be :

//Listing 8 Shadowing a Shape
// C++
// Shadow
	Any ShadowProperties[4];
	ShadowProperties[0] <<= (sal_Bool)true;
	ShadowProperties[1] <<= (long) 0xFF0000; // red
	ShadowProperties[2] <<= (long) 300;
	ShadowProperties[3] <<= (long) 300;
	rShapeProps->setPropertyValue(OUString::createFromAscii("Shadow"),ShadowProperties[0]);
	rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowColor"),ShadowProperties[1]);
	rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowXDistance"),ShadowProperties[2]);
	rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowYDistance"),ShadowProperties[3]);

This code adds a red shadow at the rectangle shape.

Shape's Rotation and sharing

The corresponding IDL file is

// IDL
module com {  module sun {  module star {  module drawing {
service RotationDescriptor
{
/** This is the angle for rotation of this Shape.
	The shape is rotated counter-clockwise around the center of the bounding box. */
 
	[property] long RotateAngle;
	[optional, property] long ShearAngle;
};
}; }; }; };

The angle is given in 1/100° starting from an horizontal line.

//Listing 9 Rotating a Shape
// C++
	Any Angle;
	Angle <<= (long)3000; // 30 degres
	rShapeProps->setPropertyValue(OUString::createFromAscii("RotateAngle"),Angle);

which gives a 30° rotation. We have already defined in previous code, the variable rShapeProps as a com.sun.star.beans.XPropertySet interface.

See also com.sun.star.drawing.RotationDescriptor.

Line Style

The corresponding IDL files are (com.sun.star.drawing.LineProperties, com.sun.star.drawing.LineStyle and com.sun.star.drawing.LineDash):

//Listing 10 Lineproperties IDL file 
// IDL
module com {  module sun {  module star {  module drawing {
service LineProperties
{
	[property] com::sun::star::drawing::LineStyle LineStyle;
	[property] com::sun::star::drawing::LineDash LineDash;
	[property] long LineColor;
	[property] short LineTransparence;
	[property] long LineWidth; 
	[property] com::sun::star::drawing::LineJoint LineJoint; 
	[optional, property] string LineStartName;
	[optional, property] com::sun::star::drawing::PolyPolygonBezierCoords LineStart; 
	[optional, property] com::sun::star::drawing::PolyPolygonBezierCoords LineEnd; 
	[optional, property] boolean LineStartCenter; 
	[optional, property] long LineStartWidth; 
	[optional, property] boolean LineEndCenter; 
	[optional, property] long LineEndWidth; 
}; 
}; }; }; };

completed with :

//Listing 11 LineStyle Enumeration
// IDL
module com {  module sun {  module star {  module drawing {
enum LineStyle
{
	NONE,
	SOLID, 
	DASH
};
}; }; }; };

We give the significance of these constants :

line styles
Constant Signification
NONE Line is not visible
SOLID continuous line (default value)
DASH Dash line; LineDash property is controling the dash's shape

We give now the LineDash properties with an IDL file

//Listing 12 IDL File : Linedash
// IDL
module com {  module sun {  module star {  module drawing {
struct LineDash
{
	com::sun::star::drawing::DashStyle Style;
	short Dots; 
	long DotLen; 
	short Dashes; 
	long DashLen; 
	long Distance; 
};
}; }; }; };

and their meaning :

lineDash properties
Proprerty Signification
Style A constant ( com.sun.star.drawing.DashStyle.xxx) gives the dash style
Dots How many dots
DotLen Dot length in 1/100 mm
Dashes How many dashes
DashLen Dash length in 1/100 mm
Distance distance between dots in 1/100 mm

The dash styles are given now (com.sun.star.drawing.DashStyle)

//Listing 13 DashStyle IDL File 
// IDL
module com {  module sun {  module star {  module drawing {
enum DashStyle
{
	RECT,
	ROUND,
	RECTRELATIVE,
	ROUNDRELATIVE 
};
}; }; }; };

Here is an example in C++ which uses a line style :

//Listing 14 Modifying a Line Style : en Example
// C++
// Line dash
// Don't forget to add : #include <com/sun/star/drawing/LineDash.hpp>
// Don't forget to add "com.sun.star.drawing.LineDash \" in the makefile
// Don't forget to add : #include <com/sun/star/drawing/LineStyle.hpp>
// Don't forget to add "com.sun.star.drawing.LineStyle \" in the makefile
	LineDash *Tirets = new (LineDash);
	Tirets->Style = DashStyle_RECT;
  	Tirets->Dots = 3;
  	Tirets->DotLen = 50;
  	Tirets->Dashes = 2;
  	Tirets->DashLen = 200;
  	Tirets->Distance = 150;
	Any LineStyle,LineDash,LineWidth;
	LineStyle <<= LineStyle_DASH;
	rShapeProps->setPropertyValue(OUString::createFromAscii("LineStyle"),LineStyle);
	LineDash <<= *Tirets;
	rShapeProps->setPropertyValue(OUString::createFromAscii("LineDash"),LineDash);
	color <<= (long)0xFF00;
	rShapeProps->setPropertyValue(OUString::createFromAscii("LineColor"),color);
	LineWidth <<= (long) 50;
	rShapeProps->setPropertyValue(OUString::createFromAscii("LineWidth"),LineWidth);

Adding this code to the previous one, gives this figure :

Shape1.png

See also com.sun.star.drawing.LineDash and com.sun.star.drawing.LineStyle.

We can go further with shapes now.

Drawing Shapes

Polyline Shape

When working with polyline the first question we have to answer is what is a Sequence < Sequence < Point >> ? We give the IDL description (com.sun.star.drawing.PointSequenceSequence) :

//Listing 15 PointSequenceSequence IDL File
// IDL
module com { module sun { module star { module drawing {
	typedef sequence<PointSequence> PointSequenceSequence;
}; }; }; };

What is a PointSequence ? The answer is given by (com.sun.star.drawing.PointSequence):

//Listing 16 PointSequence IDL File
// IDL
module com { module sun { module star { module drawing {
	typedef sequence<com::sun::star::awt::Point> PointSequence;
}; }; }; };

We can have a look at com.sun.star.drawing.PolyLineShape now :

//Listing 17 PolyLineShape IDL File 
// IDL
 module com {  module sun {  module star {  module drawing {
service PolyLineShape
{
	service com::sun::star::drawing::Shape;
	service com::sun::star::drawing::LineProperties;
	service com::sun::star::drawing::PolyPolygonDescriptor;
	service com::sun::star::drawing::Text;
	service com::sun::star::drawing::ShadowProperties;
	service com::sun::star::drawing::RotationDescriptor;
};
}; }; }; };

The last IDL file we have to inspect is the com.sun.star.drawing.PolyPolygonDescriptor service :

//Listing 18 PolyPolygonDescriptor IDL File
// IDL
module com {  module sun {  module star {  module drawing {
service PolyPolygonDescriptor
{
	[readonly, property] com::sun::star::drawing::PolygonKind PolygonKind;
	[property] com::sun::star::drawing::PointSequenceSequence PolyPolygon;
	[property] com::sun::star::drawing::PointSequenceSequence Geometry;
};
}; }; }; };

where we see the PolyPolygon is a property. These files allow us to draw any tips :

  • first construct a Sequence< Sequence< Point >> and put values in it
  • second transform it in an Any variable
  • third, use the com.sun.star.beans.XPropertySet interface to gives a value to the property "PolyPolygon".

This conduct us to the following example

//Listing 19 Using a Polyline Shape
// C++
	Sequence< Sequence< Point > > PointsSeqSeq(2);
	Sequence< Point > PointsArray(4);
	//Size *TheSize = new ( Size );
 
	Reference< XInterface > PolyLineShape = DocFactory->createInstance(
	               OUString::createFromAscii("com.sun.star.drawing.PolyLineShape") );
	Reference< XShape > rPolyLineShape(PolyLineShape, UNO_QUERY);
	MakePosition(1100, 8000, &PointsArray[0]);
	MakePosition(1500, 6000, &PointsArray[1]);
	MakePosition(1900, 8000, &PointsArray[2]);
	MakePosition(2300, 6000, &PointsArray[3]);
 
	PointsSeqSeq[0]=PointsArray;
 
	PointsArray.realloc(5);
	MakePosition(1100, 9000, &PointsArray[0]);
	MakePosition(1500, 7000, &PointsArray[1]);
	MakePosition(1900, 9000, &PointsArray[2]);
	MakePosition(2300, 7000, &PointsArray[3]);
	MakePosition(2700, 9000, &PointsArray[4]);
	PointsSeqSeq[1]=PointsArray;
 
	DrawMe(rPolyLineShape, rDrawPage, "");
 
	Any PropspolyPoly;
	PropspolyPoly <<= PointsSeqSeq;
	Reference< XPropertySet > rPolyShapeProps(rPolyLineShape,UNO_QUERY);
	rPolyShapeProps->setPropertyValue(OUString::createFromAscii("PolyPolygon"),PropspolyPoly);

When running, this example gives a figure presented below :

Polyline Example

If you replace com.sun.star.drawing.PolyLineShape with com.sun.star.drawing.PolyPolygonShape in the previous code, you obtain the same shape but closed (and by default filled).

See also com.sun.star.drawing.PolyLineShape, com.sun.star.drawing.PolyPolygonDescriptor and com.sun.star.drawing.PolyPolygonShape.

Bezier Shape

Let us begin describing the Bezier's struct : com.sun.star.drawing.PolyPolygonBezierCoords is presented now :

//Listing 20 PolyPolygonBezierCoords IDL File
// IDL
module com {  module sun {  module star {  module drawing {
 
struct PolyPolygonBezierCoords
{
	// DocMerge: empty anyway
	com::sun::star::drawing::PointSequenceSequence Coordinates; 
 
	// DocMerge: empty anyway
	com::sun::star::drawing::FlagSequenceSequence Flags;
 
};
}; }; }; };

com.sun.star.drawing.PointSequenceSequencehas been already encountered in the previous chapter. More precision on flags is expected. Again the IDL file will give us this information (com.sun.star.drawing.PolygonFlags) :

//Listing 21 PolygonFlags enumeration : IDL File 
// IDL
 module com {  module sun {  module star {  module drawing {
enum PolygonFlags
{
	NORMAL,
	SMOOTH, 
	CONTROL, 
	SYMMETRIC  
};
}; }; }; };

The service com.sun.star.drawing.ClosedBezierShape is interesting :

//Listing 22 ClosedBezierShape Service : IDL File 
// IDL
 module com {  module sun {  module star {  module drawing {
service ClosedBezierShape
{
	service com::sun::star::drawing::Shape;
	service com::sun::star::drawing::LineProperties;
	service com::sun::star::drawing::FillProperties;
	service com::sun::star::drawing::PolyPolygonBezierDescriptor;
	service com::sun::star::drawing::Text;
	service com::sun::star::drawing::ShadowProperties;
	service com::sun::star::drawing::RotationDescriptor;
};
}; }; }; };

and also the com.sun.star.drawing.PolyPolygonDescriptor service :

//Listing 23 PolyPolygonBezierDescriptor Service : IDL File 
// IDL
module com {  module sun {  module star {  module drawing {
service PolyPolygonBezierDescriptor
{
	[readonly, property] com::sun::star::drawing::PolygonKind PolygonKind;
	[property] com::sun::star::drawing::PolyPolygonBezierCoords PolyPolygonBezier;
	[property] com::sun::star::drawing::PolyPolygonBezierCoords Geometry;
};
}; }; }; };

Again as in previous chapter, what we see are properties. We have never encounter the first (com.sun.star.drawing.PolygonKind) and then give the corresponding IDL file :

//Listing 24 PolygonKind Enumeration : IDL File 
// IDL
module com {  module sun {  module star {  module drawing {
enum PolygonKind
{
	/** This is the PolygonKind for a LineShape.	 */
	LINE,
	/** This is the PolygonKind for a PolyPolygonShape.	 */
	POLY,
	/** This is the PolygonKind for a PolyLineShape.	 */
	PLIN, 
	/** This is the PolygonKind for an OpenBezierShape.	 */
	PATHLINE, 
	/** This is the PolygonKind for a ClosedBezierShape.	 */
	PATHFILL, 
	/** This is the PolygonKind for an OpenFreeHandShape.	 */
	FREELINE, 
	/** This is the PolygonKind for a ClosedFreeHandShape.	 */
	FREEFILL, 
	/** This is the PolygonKind for a PolyPolygonPathShape.	 */
	PATHPOLY, 
	/** This is the PolygonKind for a PolyLinePathShape.	 */
	PATHPLIN 
}; 
}; }; }; };

Note this property is read only. We have left comments to understand the values' significance, difficult to guess with only their name. The following code draw a Bezier closed shape :

//Listing 25 Bezier Shape : an Example
// C++
// Bezier
// Don't forget to add : #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
// Don't forget to add "com.sun.star.drawing.PolyPolygonBezierCoords \" in the makefile
 
	struct PolyPolygonBezierCoords BezierCords;
 
// we suppose we use the previous declarations of PointsSeqSeq and PointsArray 
// (previous chapter on PolyPolygonShape) : we then only realloc
 
	PointsSeqSeq.realloc(1);
	PointsArray.realloc(4);
 
	MakePosition(1000, 1000, &PointsArray[0]);
	MakePosition(3000, 4000, &PointsArray[1]);
	MakePosition(3000, 4000, &PointsArray[2]);
	MakePosition(5000, 1000, &PointsArray[3]);
	PointsSeqSeq[0]=PointsArray;
	BezierCords.Coordinates = PointsSeqSeq;
 
// Don't forget to add : #include <com/sun/star/drawing/FlagSequenceSequence.hpp>
// Don't forget to add "com.sun.star.drawing.FlagSequenceSequence \" in the makefile
// Don't forget to add : #include <com/sun/star/drawing/FlagSequence.hpp>
// Don't forget to add "com.sun.star.drawing.FlagSequence \" in the makefile
	FlagSequenceSequence flagsSeqSeq(1);
	FlagSequence flagsSeq(4);
 
// Don't forget to add : #include <com/sun/star/drawing/PolygonFlags.hpp>
// Don't forget to add "com.sun.star.drawing.PolygonFlags \" in the makefile
	flagsSeq[0] = PolygonFlags_NORMAL;
	flagsSeq[1] = PolygonFlags_CONTROL;
	flagsSeq[2] = PolygonFlags_CONTROL;
	flagsSeq[3] = PolygonFlags_NORMAL;
	flagsSeqSeq[0] = flagsSeq;
	BezierCords.Flags = flagsSeqSeq;
// PolyPolygonBezier is a property => construct a Any type;
	Any ClosedBezierProperty;
	ClosedBezierProperty <<= BezierCords;
// create the PolyPolygonBezierShape Service
	Reference< XInterface > closedBezierShape = DocFactory->createInstance(
	               OUString::createFromAscii("com.sun.star.drawing.ClosedBezierShape") );
	Reference< XShape > rClosedBezierShape(closedBezierShape, UNO_QUERY);
	if (! rClosedBezierShape.is()) printf("****Pb with Bezier\n");
	DrawMe(rClosedBezierShape, rDrawPage, "");
// Adjust the properties :
	Reference< XPropertySet > rClosedBezierShapeProps(rClosedBezierShape,UNO_QUERY);
	rClosedBezierShapeProps->setPropertyValue(OUString::createFromAscii
                               ("PolyPolygonBezier"),	ClosedBezierProperty);

It is possible to replace “ClosedBezierShape” with “OpenBezierShape” and obtain an open shape. When reading the com.sun.star.drawing.PolyPolygonBezierShape file I deduce I have only to replace “com.sun.star.drawing.ClosedBezierShape” with “com.sun.star.drawing.PolyPolygonBezierShape to obtain an open Bezier Shape. But it doesn't work and I don't know why for the moment. Andrew Pitonyak writes in his book : “Not all combinations of points and flags are valid” and I suppose I have a false combination.

See also com.sun.star.drawing.PolyPolygonBezierCoords, com.sun.star.drawing.FlagSequenceSequence, com.sun.star.drawing.FlagSequence, com.sun.star.drawing.PolygonFlags and com.sun.star.drawing.ClosedBezierShape

Connectors and glues points

//Listing 26  XGluePointsSupplier IDL File 
// IDL
module com {  module sun {  module star {  module drawing {
interface XGluePointsSupplier: com::sun::star::uno::XInterface
{
	com::sun::star::container::XIndexContainer getGluePoints();
 
};
}; }; }; };

To do : to continue


See also

Personal tools