bump product version to 4.1.6.2
[LibreOffice.git] / filter / source / graphicfilter / icgm / outact.cxx
blobfe1d09ffd46ba1d60d74beeb651d9da497b38dce
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <outact.hxx>
22 #include <vcl/gradient.hxx>
24 using namespace ::com::sun::star;
26 // ---------------------------------------------------------------
28 CGMOutAct::CGMOutAct( CGM& rCGM )
30 mpCGM = &rCGM;
31 mnCurrentPage = 0;
32 mnGroupActCount = mnGroupLevel = 0;
33 mpGroupLevel = new sal_uInt32[ CGM_OUTACT_MAX_GROUP_LEVEL ];
34 mpPoints = (Point*)new sal_Int8[ 0x2000 * sizeof( Point ) ];
35 mpFlags = new sal_uInt8[ 0x2000 ];
37 mnIndex = 0;
38 mpGradient = NULL;
41 // ---------------------------------------------------------------
43 CGMOutAct::~CGMOutAct()
45 delete[] (sal_Int8*) mpPoints;
46 delete[] mpFlags;
47 delete[] mpGroupLevel;
49 if ( mpGradient )
50 delete mpGradient;
53 // ---------------------------------------------------------------
55 void CGMOutAct::BeginFigure()
57 if ( mnIndex )
58 EndFigure();
60 BeginGroup();
61 mnIndex = 0;
64 // ---------------------------------------------------------------
66 void CGMOutAct::CloseRegion()
68 if ( mnIndex > 2 )
70 NewRegion();
71 DrawPolyPolygon( maPolyPolygon );
72 maPolyPolygon.Clear();
76 // ---------------------------------------------------------------
78 void CGMOutAct::NewRegion()
80 if ( mnIndex > 2 )
82 Polygon aPolygon( mnIndex, mpPoints, mpFlags );
83 maPolyPolygon.Insert( aPolygon );
85 mnIndex = 0;
88 // ---------------------------------------------------------------
90 void CGMOutAct::EndFigure()
92 NewRegion();
93 DrawPolyPolygon( maPolyPolygon );
94 maPolyPolygon.Clear();
95 EndGroup();
96 mnIndex = 0;
99 // ---------------------------------------------------------------
101 void CGMOutAct::RegPolyLine( Polygon& rPolygon, sal_Bool bReverse )
103 sal_uInt16 nPoints = rPolygon.GetSize();
104 if ( nPoints )
106 if ( bReverse )
108 for ( sal_uInt16 i = 0; i < nPoints; i++ )
110 mpPoints[ mnIndex + i ] = rPolygon.GetPoint( nPoints - i - 1 );
111 mpFlags[ mnIndex + i ] = (sal_Int8)rPolygon.GetFlags( nPoints - i - 1 );
114 else
116 for ( sal_uInt16 i = 0; i < nPoints; i++ )
118 mpPoints[ mnIndex + i ] = rPolygon.GetPoint( i );
119 mpFlags[ mnIndex + i ] = (sal_Int8)rPolygon.GetFlags( i );
122 mnIndex = mnIndex + nPoints;
126 // ---------------------------------------------------------------
128 void CGMOutAct::SetGradientOffset( long nHorzOfs, long nVertOfs, sal_uInt32 /*nType*/ )
130 if ( !mpGradient )
131 mpGradient = new awt::Gradient;
132 mpGradient->XOffset = ( (sal_uInt16)nHorzOfs & 0x7f );
133 mpGradient->YOffset = ( (sal_uInt16)nVertOfs & 0x7f );
136 // ---------------------------------------------------------------
138 void CGMOutAct::SetGradientAngle( long nAngle )
140 if ( !mpGradient )
141 mpGradient = new awt::Gradient;
142 mpGradient->Angle = sal::static_int_cast< sal_Int16 >(nAngle);
145 // ---------------------------------------------------------------
147 void CGMOutAct::SetGradientDescriptor( sal_uInt32 nColorFrom, sal_uInt32 nColorTo )
149 if ( !mpGradient )
150 mpGradient = new awt::Gradient;
151 mpGradient->StartColor = nColorFrom;
152 mpGradient->EndColor = nColorTo;
155 // ---------------------------------------------------------------
157 void CGMOutAct::SetGradientStyle( sal_uInt32 nStyle, double /*fRatio*/ )
159 if ( !mpGradient )
160 mpGradient = new awt::Gradient;
161 switch ( nStyle )
163 case 0xff :
165 mpGradient->Style = awt::GradientStyle_AXIAL;
167 break;
168 case 4 :
170 mpGradient->Style = awt::GradientStyle_RADIAL; // CONICAL
172 break;
173 case 3 :
175 mpGradient->Style = awt::GradientStyle_RECT;
177 break;
178 case 2 :
180 mpGradient->Style = awt::GradientStyle_ELLIPTICAL;
182 break;
183 default :
185 mpGradient->Style = awt::GradientStyle_LINEAR;
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */