Difference between revisions of "Working with Shapes"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Drawing Shapes)
 
(27 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.
  
<source lang="cpp">
+
<syntaxhighlight lang="cpp">
 
//Listing 1 New sub to simplify Shape Management
 
//Listing 1 New sub to simplify Shape Management
 
// C++
 
// C++
Line 34: Line 35:
 
makeAny(OUString::createFromAscii(shapename)));  
 
makeAny(OUString::createFromAscii(shapename)));  
 
}  
 
}  
</source>
+
</syntaxhighlight>
  
With these procedures we start now from a rectangle shape : our new starting main code is then :
+
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">
+
<syntaxhighlight lang="cpp">
 
//Listing 2 Our new starting Code
 
//Listing 2 Our new starting Code
 
int main( ) {
 
int main( ) {
Line 100: Line 101:
 
     return 0;
 
     return 0;
 
}
 
}
</source>
+
</syntaxhighlight>
  
 
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=
Line 108: Line 111:
 
==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 :
+
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">
+
<syntaxhighlight lang="idl">
 
//Listing 3 Fillstyle IDL File  
 
//Listing 3 Fillstyle IDL File  
 
// IDL
 
// IDL
Line 123: Line 126:
 
};  
 
};  
 
}; }; }; };
 
}; }; }; };
</source>
+
</syntaxhighlight>
  
 
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 :
  
<source lang="vb">
+
<syntaxhighlight 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
</source>
+
</syntaxhighlight>
  
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 :  
+
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">
+
<syntaxhighlight lang="idl">
 
//Listing 5 Fillproperties IDL File  
 
//Listing 5 Fillproperties IDL File  
 
// IDL
 
// IDL
Line 167: Line 170:
 
};
 
};
 
}; }; }; };  
 
}; }; }; };  
</source>
+
</syntaxhighlight>
  
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.
+
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">
+
<syntaxhighlight lang="cpp">
 
//Listing 6 Coloring the Shape Background
 
//Listing 6 Coloring the Shape Background
 
// C++
 
// C++
Line 183: Line 186:
 
color<<=(long)0xFF00;  //green
 
color<<=(long)0xFF00;  //green
 
rShapeProps->setPropertyValue(OUString::createFromAscii("FillColor"),color);
 
rShapeProps->setPropertyValue(OUString::createFromAscii("FillColor"),color);
</source>
+
</syntaxhighlight>
  
 
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 :
  
<source lang="cpp">
+
<syntaxhighlight lang="cpp">
 
//Listing 7 Removing the Shape Background
 
//Listing 7 Removing the Shape Background
 
// C++
 
// C++
Line 197: Line 200:
 
FillStyle <<= FillStyle_NONE;
 
FillStyle <<= FillStyle_NONE;
 
rShapeProps->setPropertyValue(OUString::createFromAscii("FillStyle"),FillStyle);
 
rShapeProps->setPropertyValue(OUString::createFromAscii("FillStyle"),FillStyle);
</source>
+
</syntaxhighlight>
  
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>.
 
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>.
Line 205: Line 208:
 
==Shape and Shadow==
 
==Shape and Shadow==
  
Shadow is described by ShadowProperties.idl file :
+
Shadow is described by <idl>com.sun.star.drawing.ShadowProperties</idl> interface presented below :
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
// IDL
 
// IDL
 
module com {  module sun {  module star {  module drawing {
 
module com {  module sun {  module star {  module drawing {
Line 219: Line 222:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</source>
+
</syntaxhighlight>
  
 
Then the corresponding C++ code to manipulate these properties could be :
 
Then the corresponding C++ code to manipulate these properties could be :
  
<source lang="cpp">
+
<syntaxhighlight lang="cpp">
 
//Listing 8 Shadowing a Shape
 
//Listing 8 Shadowing a Shape
 
// C++
 
// C++
Line 236: Line 239:
 
rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowXDistance"),ShadowProperties[2]);
 
rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowXDistance"),ShadowProperties[2]);
 
rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowYDistance"),ShadowProperties[3]);
 
rShapeProps->setPropertyValue(OUString::createFromAscii("ShadowYDistance"),ShadowProperties[3]);
</source>
+
</syntaxhighlight>
  
 
This code adds a red shadow at the rectangle shape.
 
This code adds a red shadow at the rectangle shape.
 
See also <idl>com.sun.star.drawing.ShadowProperties</idl>.
 
  
 
==Shape's Rotation and sharing==
 
==Shape's Rotation and sharing==
Line 246: Line 247:
 
The corresponding IDL file is  
 
The corresponding IDL file is  
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
// IDL
 
// IDL
 
module com {  module sun {  module star {  module drawing {
 
module com {  module sun {  module star {  module drawing {
Line 258: Line 259:
 
};
 
};
 
}; }; }; };
 
}; }; }; };
</source>
+
</syntaxhighlight>
  
 
The angle is given in 1/100° starting from an horizontal line.
 
The angle is given in 1/100° starting from an horizontal line.
  
<source lang="cpp">
+
<syntaxhighlight lang="cpp">
 
//Listing 9 Rotating a Shape
 
//Listing 9 Rotating a Shape
 
// C++
 
// C++
Line 268: Line 269:
 
Angle <<= (long)3000; // 30 degres
 
Angle <<= (long)3000; // 30 degres
 
rShapeProps->setPropertyValue(OUString::createFromAscii("RotateAngle"),Angle);
 
rShapeProps->setPropertyValue(OUString::createFromAscii("RotateAngle"),Angle);
</source>
+
</syntaxhighlight>
  
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>.
 
See also <idl>com.sun.star.drawing.RotationDescriptor</idl>.
Line 276: Line 277:
 
==Line Style==
 
==Line Style==
  
The corresponding IDL files are :
+
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">
+
<syntaxhighlight lang="idl">
 
//Listing 10 Lineproperties IDL file  
 
//Listing 10 Lineproperties IDL file  
 
// IDL
 
// IDL
Line 299: Line 300:
 
};  
 
};  
 
}; }; }; };  
 
}; }; }; };  
</source>
+
</syntaxhighlight>
  
 
completed with :
 
completed with :
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
//Listing 11 LineStyle Enumeration
 
//Listing 11 LineStyle Enumeration
 
// IDL
 
// IDL
Line 314: Line 315:
 
};
 
};
 
}; }; }; };
 
}; }; }; };
</source>
+
</syntaxhighlight>
  
 
We give the significance of these constants :
 
We give the significance of these constants :
Line 331: Line 332:
 
We give now the LineDash properties with an IDL file   
 
We give now the LineDash properties with an IDL file   
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
//Listing 12 IDL File : Linedash
 
//Listing 12 IDL File : Linedash
 
// IDL
 
// IDL
Line 345: Line 346:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</source>
+
</syntaxhighlight>
  
 
and their meaning :
 
and their meaning :
Line 366: Line 367:
 
|}
 
|}
  
The dash styles are given  
+
The dash styles are given now (<idl>com.sun.star.drawing.DashStyle</idl>)
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
//Listing 13 DashStyle IDL File  
 
//Listing 13 DashStyle IDL File  
 
// IDL
 
// IDL
Line 380: Line 381:
 
};
 
};
 
}; }; }; };
 
}; }; }; };
</source>
+
</syntaxhighlight>
  
 
Here is an example in C++ which uses a line style :
 
Here is an example in C++ which uses a line style :
  
<source lang="cpp">
+
<syntaxhighlight lang="cpp">
 
//Listing 14 Modifying a Line Style : en Example
 
//Listing 14 Modifying a Line Style : en Example
 
// C++
 
// C++
Line 408: Line 409:
 
LineWidth <<= (long) 50;
 
LineWidth <<= (long) 50;
 
rShapeProps->setPropertyValue(OUString::createFromAscii("LineWidth"),LineWidth);
 
rShapeProps->setPropertyValue(OUString::createFromAscii("LineWidth"),LineWidth);
</source>
+
</syntaxhighlight>
  
 
Adding this code to the previous one,  gives this figure :
 
Adding this code to the previous one,  gives this figure :
Line 423: Line 424:
  
 
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>) :
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
//Listing 15 PointSequenceSequence IDL File
 
//Listing 15 PointSequenceSequence IDL File
 
// IDL
 
// IDL
Line 431: Line 432:
 
typedef sequence<PointSequence> PointSequenceSequence;
 
typedef sequence<PointSequence> PointSequenceSequence;
 
}; }; }; };  
 
}; }; }; };  
</source>
+
</syntaxhighlight>
  
What is a PointSequence ?
+
What is a PointSequence ? The answer is given by (<idl>com.sun.star.drawing.PointSequence</idl>):
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
//Listing 16 PointSequence IDL File
 
//Listing 16 PointSequence IDL File
 
// IDL
 
// IDL
Line 441: Line 442:
 
typedef sequence<com::sun::star::awt::Point> PointSequence;
 
typedef sequence<com::sun::star::awt::Point> PointSequence;
 
}; }; }; };  
 
}; }; }; };  
</source>
+
</syntaxhighlight>
  
We can have a look at PolyLineShape now :
+
We can have a look at <idl>com.sun.star.drawing.PolyLineShape</idl> now :
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
//Listing 17 PolyLineShape IDL File  
 
//Listing 17 PolyLineShape IDL File  
 
// IDL
 
// IDL
Line 459: Line 460:
 
};
 
};
 
}; }; }; };
 
}; }; }; };
</source>
+
</syntaxhighlight>
  
The last IDL file we have to inspect is the PolyPolygonDescriptor service :
+
The last IDL file we have to inspect is the <idl>com.sun.star.drawing.PolyPolygonDescriptor</idl> service :
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
//Listing 18 PolyPolygonDescriptor IDL File
 
//Listing 18 PolyPolygonDescriptor IDL File
 
// IDL
 
// IDL
Line 474: Line 475:
 
};
 
};
 
}; }; }; };
 
}; }; }; };
</source>
+
</syntaxhighlight>
  
 
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
  
<source lang="cpp">
+
<syntaxhighlight lang="cpp">
 
//Listing 19 Using a Polyline Shape
 
//Listing 19 Using a Polyline Shape
 
// C++
 
// C++
Line 513: 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);
</source>
+
</syntaxhighlight>
  
 
When running, this example gives a figure presented below :
 
When running, this example gives a figure presented below :
Line 519: Line 521:
 
[[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.PointSequenceSequence</idl>, <idl>com.sun.star.drawing.PolyLineShape</idl>, <idl>com.sun.star.drawing.PolyPolygonDescriptor</idl> and <idl>com.sun.star.drawing.PolyPolygonShape</idl>.
+
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 :
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
//Listing 20 PolyPolygonBezierCoords IDL File
 
//Listing 20 PolyPolygonBezierCoords IDL File
 
// IDL
 
// IDL
Line 541: Line 543:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</source>
+
</syntaxhighlight>
  
PointSequenceSequence 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.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">
+
<syntaxhighlight lang="idl">
 
//Listing 21 PolygonFlags enumeration : IDL File  
 
//Listing 21 PolygonFlags enumeration : IDL File  
 
// IDL
 
// IDL
Line 557: Line 559:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</source>
+
</syntaxhighlight>
  
The service ClosedBezierShape is interesting :
+
The service <idl>com.sun.star.drawing.ClosedBezierShape</idl> is interesting :
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
//Listing 22 ClosedBezierShape Service : IDL File  
 
//Listing 22 ClosedBezierShape Service : IDL File  
 
// IDL
 
// IDL
Line 576: Line 578:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</source>
+
</syntaxhighlight>
  
and also the PolyPolygonDescriptor :
+
and also the <idl>com.sun.star.drawing.PolyPolygonDescriptor</idl> service :
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
//Listing 23 PolyPolygonBezierDescriptor Service : IDL File  
 
//Listing 23 PolyPolygonBezierDescriptor Service : IDL File  
 
// IDL
 
// IDL
Line 591: Line 593:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</source>
+
</syntaxhighlight>
  
Again as in previous chapter, what we see are properties. We have never encounter the first (PolygonKind) and then give the corresponding IDL file :
+
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">
+
<syntaxhighlight lang="idl">
 
//Listing 24 PolygonKind Enumeration : IDL File  
 
//Listing 24 PolygonKind Enumeration : IDL File  
 
// IDL
 
// IDL
Line 621: Line 623:
 
};  
 
};  
 
}; }; }; };   
 
}; }; }; };   
</source>
+
</syntaxhighlight>
  
 
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 :
  
<source lang="cpp">
+
<syntaxhighlight lang="cpp">
 
//Listing 25 Bezier Shape : an Example
 
//Listing 25 Bezier Shape : an Example
 
// C++
 
// C++
Line 676: Line 678:
 
rClosedBezierShapeProps->setPropertyValue(OUString::createFromAscii
 
rClosedBezierShapeProps->setPropertyValue(OUString::createFromAscii
 
                               ("PolyPolygonBezier"), ClosedBezierProperty);
 
                               ("PolyPolygonBezier"), ClosedBezierProperty);
</source>
+
</syntaxhighlight>
  
 
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>
 
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>
Line 685: Line 687:
 
==Connectors and glues points==
 
==Connectors and glues points==
  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
//Listing 26  XGluePointsSupplier IDL File  
 
//Listing 26  XGluePointsSupplier IDL File  
 
// IDL
 
// IDL
Line 695: Line 697:
 
};
 
};
 
}; }; }; };   
 
}; }; }; };   
</source>
+
</syntaxhighlight>
  
 
To do : to continue
 
To do : to continue
Line 703: Line 705:
  
 
= 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]]
 
* 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]]
 
* [[Uno/Cpp/Tutorials/Introduction_to_Cpp_Uno|C++ and UNO tutorial]]
Line 710: Line 713:
 
[[Category:OOoDraw]]
 
[[Category:OOoDraw]]
 
[[Category:OOoImpress]]
 
[[Category:OOoImpress]]
[[Category:Development]]
 
 
[[Category:Cpp]]
 
[[Category:Cpp]]
 
[[Category:Uno]]
 
[[Category:Uno]]

Latest revision as of 12:00, 11 September 2022


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