Update ooo320-m1
[ooovba.git] / goodies / source / filter.vcl / icgm / outact.cxx
blob6fd9a81c380cf0e1a6d806a7606e8c5272ca810b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: outact.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_goodies.hxx"
34 #include <outact.hxx>
35 #include <vcl/gradient.hxx>
37 using namespace ::com::sun::star;
39 // ---------------------------------------------------------------
41 CGMOutAct::CGMOutAct( CGM& rCGM )
43 mpCGM = &rCGM;
44 mnCurrentPage = 0;
45 mnGroupActCount = mnGroupLevel = 0;
46 mpGroupLevel = new sal_uInt32[ CGM_OUTACT_MAX_GROUP_LEVEL ];
47 mpPoints = (Point*)new sal_Int8[ 0x2000 * sizeof( Point ) ];
48 mpFlags = new BYTE[ 0x2000 ];
50 mnIndex = 0;
51 mpGradient = NULL;
54 // ---------------------------------------------------------------
56 CGMOutAct::~CGMOutAct()
58 delete[] (sal_Int8*) mpPoints;
59 delete[] mpFlags;
60 delete[] mpGroupLevel;
62 if ( mpGradient )
63 delete mpGradient;
66 // ---------------------------------------------------------------
68 void CGMOutAct::BeginFigure()
70 if ( mnIndex )
71 EndFigure();
73 BeginGroup();
74 mnIndex = 0;
77 // ---------------------------------------------------------------
79 void CGMOutAct::CloseRegion()
81 if ( mnIndex > 2 )
83 NewRegion();
84 DrawPolyPolygon( maPolyPolygon );
85 maPolyPolygon.Clear();
89 // ---------------------------------------------------------------
91 void CGMOutAct::NewRegion()
93 if ( mnIndex > 2 )
95 Polygon aPolygon( mnIndex, mpPoints, mpFlags );
96 maPolyPolygon.Insert( aPolygon );
98 mnIndex = 0;
101 // ---------------------------------------------------------------
103 void CGMOutAct::EndFigure()
105 NewRegion();
106 DrawPolyPolygon( maPolyPolygon );
107 maPolyPolygon.Clear();
108 EndGroup();
109 mnIndex = 0;
112 // ---------------------------------------------------------------
114 void CGMOutAct::RegPolyLine( Polygon& rPolygon, sal_Bool bReverse )
116 USHORT nPoints = rPolygon.GetSize();
117 if ( nPoints )
119 if ( bReverse )
121 for ( USHORT i = 0; i < nPoints; i++ )
123 mpPoints[ mnIndex + i ] = rPolygon.GetPoint( nPoints - i - 1 );
124 mpFlags[ mnIndex + i ] = (sal_Int8)rPolygon.GetFlags( nPoints - i - 1 );
127 else
129 for ( USHORT i = 0; i < nPoints; i++ )
131 mpPoints[ mnIndex + i ] = rPolygon.GetPoint( i );
132 mpFlags[ mnIndex + i ] = (sal_Int8)rPolygon.GetFlags( i );
135 mnIndex = mnIndex + nPoints;
139 // ---------------------------------------------------------------
141 void CGMOutAct::SetGradientOffset( long nHorzOfs, long nVertOfs, sal_uInt32 /*nType*/ )
143 if ( !mpGradient )
144 mpGradient = new awt::Gradient;
145 mpGradient->XOffset = ( (sal_uInt16)nHorzOfs & 0x7f );
146 mpGradient->YOffset = ( (sal_uInt16)nVertOfs & 0x7f );
149 // ---------------------------------------------------------------
151 void CGMOutAct::SetGradientAngle( long nAngle )
153 if ( !mpGradient )
154 mpGradient = new awt::Gradient;
155 mpGradient->Angle = sal::static_int_cast< sal_Int16 >(nAngle);
158 // ---------------------------------------------------------------
160 void CGMOutAct::SetGradientDescriptor( sal_uInt32 nColorFrom, sal_uInt32 nColorTo )
162 if ( !mpGradient )
163 mpGradient = new awt::Gradient;
164 mpGradient->StartColor = nColorFrom;
165 mpGradient->EndColor = nColorTo;
168 // ---------------------------------------------------------------
170 void CGMOutAct::SetGradientStyle( sal_uInt32 nStyle, double /*fRatio*/ )
172 if ( !mpGradient )
173 mpGradient = new awt::Gradient;
174 switch ( nStyle )
176 case 0xff :
178 mpGradient->Style = awt::GradientStyle_AXIAL;
180 break;
181 case 4 :
183 mpGradient->Style = awt::GradientStyle_RADIAL; // CONICAL
185 break;
186 case 3 :
188 mpGradient->Style = awt::GradientStyle_RECT;
190 break;
191 case 2 :
193 mpGradient->Style = awt::GradientStyle_ELLIPTICAL;
195 break;
196 default :
198 mpGradient->Style = awt::GradientStyle_LINEAR;