26#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
27#include <com/sun/star/drawing/LineStyle.hpp>
28#include <com/sun/star/drawing/LineDash.hpp>
29#include <com/sun/star/drawing/FillStyle.hpp>
30#include <com/sun/star/drawing/Hatch.hpp>
31#include <com/sun/star/awt/FontDescriptor.hpp>
32#include <com/sun/star/awt/FontWeight.hpp>
33#include <com/sun/star/awt/FontUnderline.hpp>
34#include <com/sun/star/drawing/XShapeGrouper.hpp>
35#include <com/sun/star/drawing/CircleKind.hpp>
36#include <com/sun/star/awt/XBitmap.hpp>
37#include <com/sun/star/drawing/PointSequenceSequence.hpp>
38#include <com/sun/star/drawing/PointSequence.hpp>
39#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
40#include <com/sun/star/drawing/FlagSequence.hpp>
41#include <com/sun/star/drawing/ShapeCollection.hpp>
42#include <com/sun/star/drawing/TextAdjust.hpp>
43#include <com/sun/star/text/XText.hpp>
44#include <com/sun/star/text/XTextRange.hpp>
45#include <com/sun/star/style/HorizontalAlignment.hpp>
56#define MAX_PAGES_FOR_FUZZING 2048
71 bool bStatRet =
false;
73 uno::Reference< drawing::XDrawPagesSupplier > aDrawPageSup( rModel, uno::UNO_QUERY );
74 if( aDrawPageSup.is() )
94 a->removeActionLock();
99 bool bStatRet =
false;
116 maXShape.set( xNewShape, uno::UNO_QUERY );
121 uno::Reference<document::XActionLockable> xLockable(
maXShape, uno::UNO_QUERY);
124 xLockable->addActionLock();
134 maXPropSet->setPropertyValue(
"RotationPointX",
uno::Any(
static_cast<sal_Int32
>(rRefPoint.
X)) );
135 maXPropSet->setPropertyValue(
"RotationPointY",
uno::Any(
static_cast<sal_Int32
>(rRefPoint.
Y)) );
136 maXPropSet->setPropertyValue(
"RotateAngle",
uno::Any(
static_cast<sal_Int32
>( rOrientation * 100.0 )) );
142 drawing::LineStyle eLS;
144 sal_uInt32 nLineColor;
161 maXPropSet->setPropertyValue(
"LineColor",
uno::Any(
static_cast<sal_Int32
>(nLineColor)) );
163 maXPropSet->setPropertyValue(
"LineWidth",
uno::Any(
static_cast<sal_Int32
>(fLineWidth)) );
168 eLS = drawing::LineStyle_NONE;
176 eLS = drawing::LineStyle_DASH;
180 eLS = drawing::LineStyle_SOLID;
184 if ( eLS == drawing::LineStyle_DASH )
186 drawing::LineDash aLineDash( drawing::DashStyle_RECTRELATIVE, 1, 50, 3, 33, 100 );
193 drawing::LineStyle eLS;
194 drawing::FillStyle eFS;
196 sal_uInt32 nEdgeColor = 0;
198 double fEdgeWidth = 0;
200 sal_uInt32 nFillColor;
202 sal_uInt32 nHatchIndex;
223 eFillStyle =
mpCGM->
pElement->pFillBundle->eFillInteriorStyle;
225 eFillStyle =
mpCGM->
pElement->aFillBundle.eFillInteriorStyle;
231 nHatchIndex =
static_cast<sal_uInt32
>(
mpCGM->
pElement->pFillBundle->nFillHatchIndex);
233 nHatchIndex =
static_cast<sal_uInt32
>(
mpCGM->
pElement->aFillBundle.nFillHatchIndex);
235 maXPropSet->setPropertyValue(
"FillColor",
uno::Any(
static_cast<sal_Int32
>(nFillColor)) );
237 switch ( eFillStyle )
241 if ( nHatchIndex == 0 )
242 eFS = drawing::FillStyle_NONE;
244 eFS = drawing::FillStyle_HATCH;
250 eFS = drawing::FillStyle_SOLID;
258 eFS = drawing::FillStyle_NONE;
265 eFS = drawing::FillStyle_GRADIENT;
273 eFS = drawing::FillStyle_NONE;
278 eFS = drawing::FillStyle_GRADIENT;
280 if ( eFS == drawing::FillStyle_GRADIENT )
286 eLS = drawing::LineStyle_NONE;
289 eLS = drawing::LineStyle_SOLID;
290 maXPropSet->setPropertyValue(
"LineColor",
uno::Any(
static_cast<sal_Int32
>(nFillColor)) );
293 else if ( eEdgeType !=
ET_NONE )
295 maXPropSet->setPropertyValue(
"LineColor",
uno::Any(
static_cast<sal_Int32
>(nEdgeColor)) );
297 maXPropSet->setPropertyValue(
"LineWidth",
uno::Any(
static_cast<sal_Int32
>(fEdgeWidth)) );
310 eLS = drawing::LineStyle_SOLID;
318 if ( eFS != drawing::FillStyle_HATCH )
321 drawing::Hatch aHatch;
323 aHatch.Color = nFillColor;
329 case 0 : aHatch.Style = drawing::HatchStyle_SINGLE;
break;
330 case 1 : aHatch.Style = drawing::HatchStyle_DOUBLE;
break;
331 case 2 : aHatch.Style = drawing::HatchStyle_TRIPLE;
break;
338 aHatch.Style = drawing::HatchStyle_TRIPLE;
339 aHatch.Distance = 10 * ( nHatchIndex & 0x1f ) | 100;
340 aHatch.Angle = 15 * ( ( nHatchIndex & 0x1f ) - 5 );
347 sal_uInt32 nTextFontIndex;
348 sal_uInt32 nTextColor;
351 nTextFontIndex =
mpCGM->
pElement->pTextBundle->nTextFontIndex;
353 nTextFontIndex =
mpCGM->
pElement->aTextBundle.nTextFontIndex;
359 rProperty->setPropertyValue(
"CharColor",
uno::Any(
static_cast<sal_Int32
>(nTextColor)) );
361 sal_uInt32 nFontType = 0;
362 awt::FontDescriptor aFontDescriptor;
367 aFontDescriptor.Name = OUString(
reinterpret_cast<char*
>(pFontEntry->
aFontName.data()),
369 RTL_TEXTENCODING_ASCII_US);
371 aFontDescriptor.Height = sal_Int16(
mpCGM->
pElement->nCharacterHeight * 1.50 );
373 aFontDescriptor.Slant = awt::FontSlant_ITALIC;
375 aFontDescriptor.Weight = awt::FontWeight::BOLD;
377 aFontDescriptor.Weight = awt::FontWeight::NORMAL;
381 aFontDescriptor.Underline = awt::FontUnderline::SINGLE;
383 rProperty->setPropertyValue(
"FontDescriptor",
uno::Any(aFontDescriptor) );
390 uno::Reference< drawing::XDrawPage > xPage =
maXDrawPages->insertNewByIndex( 0xffff );
422 if ( nFirstIndex == 0xffffffff )
424 sal_uInt32 nCurrentCount =
maXShapes->getCount();
425 if ( ( nCurrentCount - nFirstIndex ) <= 1 )
428 uno::Reference< drawing::XShapeGrouper > aXShapeGrouper;
430 if( !aXShapeGrouper.is() )
434 for ( sal_uInt32
i = nFirstIndex;
i < nCurrentCount;
i++ )
436 uno::Reference< drawing::XShape > aXShape = *o3tl::doAccess<uno::Reference<drawing::XShape>>(
maXShapes->getByIndex(
i ));
439 aXShapes->add( aXShape );
442 aXShapeGrouper->group( aXShapes );
459 SAL_WARN(
"filter.icgm",
"bad left: " << rFloatRect.
Left);
464 SAL_WARN(
"filter.icgm",
"bad top: " << rFloatRect.
Top);
467 double fWidth = rFloatRect.
Right - rFloatRect.
Left;
470 SAL_WARN(
"filter.icgm",
"bad width: " << fWidth);
473 double fHeight = rFloatRect.
Bottom - rFloatRect.
Top;
476 SAL_WARN(
"filter.icgm",
"bad height: " << fHeight);
481 maXShape->setSize(awt::Size(fWidth, fHeight));
491 drawing::CircleKind eCircleKind = drawing::CircleKind_FULL;
493 maXPropSet->setPropertyValue(
"CircleKind", aAny );
501 maXShape->setSize( awt::Size( nXSize, nYSize ) );
504 if ( rOrientation != 0 )
512 sal_uInt32 nType,
double& fStartAngle,
double& fEndAngle )
518 drawing::CircleKind eCircleKind;
528 maXShape->setSize( awt::Size ( nXSize, nYSize ) );
530 if ( rOrientation != 0 )
537 case 0 : eCircleKind = drawing::CircleKind_SECTION;
break;
538 case 1 : eCircleKind = drawing::CircleKind_CUT;
break;
539 case 2 : eCircleKind = drawing::CircleKind_ARC;
break;
540 default : eCircleKind = drawing::CircleKind_FULL;
break;
544 eCircleKind = drawing::CircleKind_FULL;
550 maXPropSet->setPropertyValue(
"CircleStartAngle",
uno::Any(
static_cast<sal_Int32
>( fStartAngle * 100 )) );
551 maXPropSet->setPropertyValue(
"CircleEndAngle",
uno::Any(
static_cast<sal_Int32
>( fEndAngle * 100 )) );
554 if ( rOrientation != 0 )
558 if ( eCircleKind == drawing::CircleKind_ARC )
568 aAny <<= drawing::FillStyle_NONE;
569 maXPropSet->setPropertyValue(
"FillStyle", aAny );
580 double fdx = pBmpDesc->
mndx;
581 double fdy = pBmpDesc->
mndy;
585 nMirr |= BmpMirrorFlags::Vertical;
586 if ( nMirr != BmpMirrorFlags::NONE )
610 sal_uInt16 nPoints = rPoly.
GetSize();
612 if ( !(( nPoints > 1 ) &&
ImplCreateShape(
"com.sun.star.drawing.PolyPolygonShape" )) )
615 drawing::PointSequenceSequence aRetval;
618 aRetval.realloc( 1 );
621 drawing::PointSequence* pOuterSequence = aRetval.getArray();
624 pOuterSequence->realloc(
static_cast<sal_Int32
>(nPoints));
627 awt::Point* pInnerSequence = pOuterSequence->getArray();
629 for( sal_uInt16
n = 0;
n < nPoints;
n++ )
630 *pInnerSequence++ = awt::Point( rPoly[
n ].
X(), rPoly[
n].
Y() );
634 maXPropSet->setPropertyValue(
"PolyPolygon", aParam );
640 sal_uInt16 nPoints = rPoly.
GetSize();
642 if ( !(( nPoints > 1 ) &&
ImplCreateShape(
"com.sun.star.drawing.PolyLineShape" )) )
645 drawing::PointSequenceSequence aRetval;
648 aRetval.realloc( 1 );
651 drawing::PointSequence* pOuterSequence = aRetval.getArray();
654 pOuterSequence->realloc(
static_cast<sal_Int32
>(nPoints));
657 awt::Point* pInnerSequence = pOuterSequence->getArray();
659 for( sal_uInt16
n = 0;
n < nPoints;
n++ )
660 *pInnerSequence++ = awt::Point( rPoly[
n ].
X(), rPoly[
n].
Y() );
664 maXPropSet->setPropertyValue(
"PolyPolygon", aParam );
670 sal_uInt16 nPoints = rPolygon.
GetSize();
671 if ( !(( nPoints > 1 ) &&
ImplCreateShape(
"com.sun.star.drawing.OpenBezierShape" )) )
674 drawing::PolyPolygonBezierCoords aRetval;
676 aRetval.Coordinates.realloc( 1 );
677 aRetval.Flags.realloc( 1 );
680 drawing::PointSequence* pOuterSequence = aRetval.Coordinates.getArray();
681 drawing::FlagSequence* pOuterFlags = aRetval.Flags.getArray();
684 pOuterSequence->realloc( nPoints );
685 pOuterFlags->realloc( nPoints );
687 awt::Point* pInnerSequence = pOuterSequence->getArray();
688 drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray();
690 for( sal_uInt16
i = 0;
i < nPoints;
i++ )
692 *pInnerSequence++ = awt::Point( rPolygon[
i ].
X(), rPolygon[
i ].
Y() );
693 *pInnerFlags++ =
static_cast<drawing::PolygonFlags
>(rPolygon.
GetFlags(
i ));
697 maXPropSet->setPropertyValue(
"PolyPolygonBezier", aParam );
703 sal_uInt32 nNumPolys = rPolyPolygon.
Count();
704 if ( !(nNumPolys &&
ImplCreateShape(
"com.sun.star.drawing.ClosedBezierShape" )) )
707 drawing::PolyPolygonBezierCoords aRetval;
710 aRetval.Coordinates.realloc(
static_cast<sal_Int32
>(nNumPolys));
711 aRetval.Flags.realloc(
static_cast<sal_Int32
>(nNumPolys));
714 drawing::PointSequence* pOuterSequence = aRetval.Coordinates.getArray();
715 drawing::FlagSequence* pOuterFlags = aRetval.Flags.getArray();
717 for( sal_uInt32
a = 0;
a < nNumPolys;
a++ )
720 sal_uInt32 nNumPoints = aPolygon.
GetSize();
723 pOuterSequence->realloc(
static_cast<sal_Int32
>(nNumPoints));
724 pOuterFlags->realloc(
static_cast<sal_Int32
>(nNumPoints));
727 awt::Point* pInnerSequence = pOuterSequence->getArray();
728 drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray();
730 for( sal_uInt32 b = 0; b < nNumPoints; b++ )
732 *pInnerSequence++ = awt::Point( aPolygon.
GetPoint( b ).
X(), aPolygon.
GetPoint( b ).
Y() ) ;
733 *pInnerFlags++ =
static_cast<drawing::PolygonFlags
>(aPolygon.
GetFlags( b ));
740 maXPropSet->setPropertyValue(
"PolyPolygonBezier", aParam);
753 awt::Point aTextPos( rTextPos );
778 else if ( nWidth == 0 )
786 else if ( nHeight == 0 )
791 maXShape->setSize( awt::Size( nWidth, nHeight ) );
794 double fSqrt = std::hypot(nX, nY);
795 double nOrientation = fSqrt != 0.0 ?
basegfx::rad2deg(acos(nX / fSqrt)) : 0.0;
797 nOrientation = 360 - nOrientation;
802 maXPropSet->setPropertyValue(
"RotationPointY",
uno::Any(
static_cast<sal_Int32
>( aTextPos.Y + nHeight )) );
803 maXPropSet->setPropertyValue(
"RotateAngle",
uno::Any(
static_cast<sal_Int32
>( nOrientation * 100 )) );
808 maXPropSet->setPropertyValue(
"TextAutoGrowWidth", aAny );
810 drawing::TextAdjust eTextAdjust;
814 eTextAdjust = drawing::TextAdjust_RIGHT;
819 eTextAdjust = drawing::TextAdjust_LEFT;
822 eTextAdjust = drawing::TextAdjust_CENTER;
831 uno::Reference< text::XText > xText;
833 if( aFirstQuery >>= xText )
835 uno::Reference< text::XTextCursor > aXTextCursor( xText->createTextCursor() );
837 aXTextCursor->gotoEnd(
false );
838 uno::Reference< text::XTextRange > aCursorText;
840 if ( aSecondQuery >>= aCursorText )
842 uno::Reference< beans::XPropertySet > aCursorPropSet;
845 if( aQuery >>= aCursorPropSet )
852 aAny <<= sal_Int16(style::HorizontalAlignment_RIGHT);
857 aAny <<= sal_Int16(style::HorizontalAlignment_LEFT);
860 aAny <<= sal_Int16(style::HorizontalAlignment_CENTER);
863 aCursorPropSet->setPropertyValue(
"ParaAdjust", aAny );
865 if ( nWidth > 0 && nHeight > 0 )
868 maXPropSet->setPropertyValue(
"TextFitToSize", aAny );
870 aCursorText->setString(rString);
871 aXTextCursor->gotoEnd(
true );
888 uno::Reference< drawing::XShape > aShape = *o3tl::doAccess<uno::Reference<drawing::XShape>>(
maXShapes->getByIndex(
nFinalTextCount - 1 ));
892 uno::Reference< text::XText > xText;
894 if( !(aFirstQuery >>= xText) )
897 OUString
aStr(pString, strlen(pString), RTL_TEXTENCODING_ASCII_US);
899 uno::Reference< text::XTextCursor > aXTextCursor( xText->createTextCursor() );
900 if ( !aXTextCursor.is() )
903 aXTextCursor->gotoEnd(
false );
904 uno::Reference< text::XTextRange > aCursorText;
906 if ( aSecondQuery >>= aCursorText )
908 uno::Reference< beans::XPropertySet > aPropSet;
910 if( aQuery >>= aPropSet )
912 aCursorText->setString(
aStr );
913 aXTextCursor->gotoEnd(
true );
963 sal_uInt16 nPoints = rPolygon.
GetSize();
969 for ( sal_uInt16
i = 0;
i < nPoints;
i++ )
977 for ( sal_uInt16
i = 0;
i < nPoints;
i++ )
989 mpGradient->XOffset = (
static_cast<sal_uInt16
>(nHorzOfs) & 0x7f );
990 mpGradient->YOffset = (
static_cast<sal_uInt16
>(nVertOfs) & 0x7f );
997 mpGradient->Angle = sal::static_int_cast< sal_Int16 >(nAngle);
1016 mpGradient->Style = awt::GradientStyle_AXIAL;
1021 mpGradient->Style = awt::GradientStyle_RADIAL;
1031 mpGradient->Style = awt::GradientStyle_ELLIPTICAL;
1036 mpGradient->Style = awt::GradientStyle_LINEAR;
#define MAX_PAGES_FOR_FUZZING
bool useless(double value)
#define ASF_FILLINTERIORSTYLE
#define ACT4_GRADIENT_ACTION
#define ASF_TEXTFONTINDEX
bool Mirror(BmpMirrorFlags nMirrorFlags)
CGMImpressOutAct(CGM &, const css::uno::Reference< css::frame::XModel > &)
void DrawRectangle(FloatRect const &)
void ImplSetTextBundle(const css::uno::Reference< css::beans::XPropertySet > &)
css::uno::Reference< css::drawing::XDrawPages > maXDrawPages
void DrawText(css::awt::Point const &TextRectPos, css::awt::Size const &TextRectSize, const OUString &rString, FinalFlag)
void ImplSetOrientation(FloatPoint const &RefPoint, double Orientation)
bool ImplCreateShape(const OUString &rType)
sal_uInt32 nFinalTextCount
std::vector< css::uno::Reference< css::document::XActionLockable > > maLockedNewXShapes
void DrawEllipse(FloatPoint const ¢er, FloatPoint const &, double &Orientation)
css::uno::Reference< css::drawing::XShape > maXShape
std::vector< PolyFlags > maFlags
void SetGradientDescriptor(sal_uInt32 nColorFrom, sal_uInt32 nColorTo)
void SetGradientAngle(tools::Long nAngle)
std::vector< Point > maPoints
css::uno::Reference< css::lang::XMultiServiceFactory > maXMultiServiceFactory
void SetGradientOffset(tools::Long nHorzOfs, tools::Long nVertOfs)
void DrawPolybezier(tools::Polygon &)
void DrawPolygon(tools::Polygon &)
css::uno::Reference< css::beans::XPropertySet > maXPropSet
css::uno::Reference< css::drawing::XDrawPage > maXDrawPage
css::uno::Reference< css::drawing::XShapes > maXShapes
void RegPolyLine(tools::Polygon const &, bool bReverse=false)
void DrawBitmap(CGMBitmapDescriptor *)
std::array< sal_uInt32, CGM_OUTACT_MAX_GROUP_LEVEL > maGroupLevel
sal_uInt32 mnGroupActCount
tools::PolyPolygon maPolyPolygon
void DrawPolyPolygon(tools::PolyPolygon const &)
void SetGradientStyle(sal_uInt32 nStyle)
void DrawEllipticalArc(FloatPoint const ¢er, FloatPoint const &size, double &orientation, sal_uInt32 etype, double &startangle, double &endangle)
void AppendText(const char *String)
void DrawPolyLine(tools::Polygon &)
std::unique_ptr< css::awt::Gradient > mpGradient
void ImplMapPoint(FloatPoint &)
std::unique_ptr< CGMElements > pElement
sal_uInt32 mnAct4PostReset
constexpr tools::Long Y() const
constexpr tools::Long X() const
static css::uno::Reference< css::awt::XBitmap > CreateBitmap(const BitmapEx &rBitmap)
#define SAL_WARN(area, stream)
constexpr double rad2deg(double v)
Shape IDs per cluster in DGG atom.
Reference< XComponentContext > getProcessComponentContext()
constexpr T saturating_add(T a, T b)
#define CGM_OUTACT_MAX_GROUP_LEVEL
std::vector< sal_Int8 > aFontName
tools::Long HatchDistance