Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <outact.hxx>
22 : #include <vcl/gradient.hxx>
23 :
24 : using namespace ::com::sun::star;
25 :
26 : // ---------------------------------------------------------------
27 :
28 0 : CGMOutAct::CGMOutAct( CGM& rCGM )
29 : {
30 0 : mpCGM = &rCGM;
31 0 : mnCurrentPage = 0;
32 0 : mnGroupActCount = mnGroupLevel = 0;
33 0 : mpGroupLevel = new sal_uInt32[ CGM_OUTACT_MAX_GROUP_LEVEL ];
34 0 : mpPoints = (Point*)new sal_Int8[ 0x2000 * sizeof( Point ) ];
35 0 : mpFlags = new sal_uInt8[ 0x2000 ];
36 :
37 0 : mnIndex = 0;
38 0 : mpGradient = NULL;
39 0 : };
40 :
41 : // ---------------------------------------------------------------
42 :
43 0 : CGMOutAct::~CGMOutAct()
44 : {
45 0 : delete[] (sal_Int8*) mpPoints;
46 0 : delete[] mpFlags;
47 0 : delete[] mpGroupLevel;
48 :
49 0 : if ( mpGradient )
50 0 : delete mpGradient;
51 0 : };
52 :
53 : // ---------------------------------------------------------------
54 :
55 0 : void CGMOutAct::BeginFigure()
56 : {
57 0 : if ( mnIndex )
58 0 : EndFigure();
59 :
60 0 : BeginGroup();
61 0 : mnIndex = 0;
62 0 : }
63 :
64 : // ---------------------------------------------------------------
65 :
66 0 : void CGMOutAct::CloseRegion()
67 : {
68 0 : if ( mnIndex > 2 )
69 : {
70 0 : NewRegion();
71 0 : DrawPolyPolygon( maPolyPolygon );
72 0 : maPolyPolygon.Clear();
73 : }
74 0 : }
75 :
76 : // ---------------------------------------------------------------
77 :
78 0 : void CGMOutAct::NewRegion()
79 : {
80 0 : if ( mnIndex > 2 )
81 : {
82 0 : Polygon aPolygon( mnIndex, mpPoints, mpFlags );
83 0 : maPolyPolygon.Insert( aPolygon );
84 : }
85 0 : mnIndex = 0;
86 0 : }
87 :
88 : // ---------------------------------------------------------------
89 :
90 0 : void CGMOutAct::EndFigure()
91 : {
92 0 : NewRegion();
93 0 : DrawPolyPolygon( maPolyPolygon );
94 0 : maPolyPolygon.Clear();
95 0 : EndGroup();
96 0 : mnIndex = 0;
97 0 : }
98 :
99 : // ---------------------------------------------------------------
100 :
101 0 : void CGMOutAct::RegPolyLine( Polygon& rPolygon, sal_Bool bReverse )
102 : {
103 0 : sal_uInt16 nPoints = rPolygon.GetSize();
104 0 : if ( nPoints )
105 : {
106 0 : if ( bReverse )
107 : {
108 0 : for ( sal_uInt16 i = 0; i < nPoints; i++ )
109 : {
110 0 : mpPoints[ mnIndex + i ] = rPolygon.GetPoint( nPoints - i - 1 );
111 0 : mpFlags[ mnIndex + i ] = (sal_Int8)rPolygon.GetFlags( nPoints - i - 1 );
112 : }
113 : }
114 : else
115 : {
116 0 : for ( sal_uInt16 i = 0; i < nPoints; i++ )
117 : {
118 0 : mpPoints[ mnIndex + i ] = rPolygon.GetPoint( i );
119 0 : mpFlags[ mnIndex + i ] = (sal_Int8)rPolygon.GetFlags( i );
120 : }
121 : }
122 0 : mnIndex = mnIndex + nPoints;
123 : }
124 0 : }
125 :
126 : // ---------------------------------------------------------------
127 :
128 0 : void CGMOutAct::SetGradientOffset( long nHorzOfs, long nVertOfs, sal_uInt32 /*nType*/ )
129 : {
130 0 : if ( !mpGradient )
131 0 : mpGradient = new awt::Gradient;
132 0 : mpGradient->XOffset = ( (sal_uInt16)nHorzOfs & 0x7f );
133 0 : mpGradient->YOffset = ( (sal_uInt16)nVertOfs & 0x7f );
134 0 : }
135 :
136 : // ---------------------------------------------------------------
137 :
138 0 : void CGMOutAct::SetGradientAngle( long nAngle )
139 : {
140 0 : if ( !mpGradient )
141 0 : mpGradient = new awt::Gradient;
142 0 : mpGradient->Angle = sal::static_int_cast< sal_Int16 >(nAngle);
143 0 : }
144 :
145 : // ---------------------------------------------------------------
146 :
147 0 : void CGMOutAct::SetGradientDescriptor( sal_uInt32 nColorFrom, sal_uInt32 nColorTo )
148 : {
149 0 : if ( !mpGradient )
150 0 : mpGradient = new awt::Gradient;
151 0 : mpGradient->StartColor = nColorFrom;
152 0 : mpGradient->EndColor = nColorTo;
153 0 : }
154 :
155 : // ---------------------------------------------------------------
156 :
157 0 : void CGMOutAct::SetGradientStyle( sal_uInt32 nStyle, double /*fRatio*/ )
158 : {
159 0 : if ( !mpGradient )
160 0 : mpGradient = new awt::Gradient;
161 0 : switch ( nStyle )
162 : {
163 : case 0xff :
164 : {
165 0 : mpGradient->Style = awt::GradientStyle_AXIAL;
166 : }
167 0 : break;
168 : case 4 :
169 : {
170 0 : mpGradient->Style = awt::GradientStyle_RADIAL; // CONICAL
171 : }
172 0 : break;
173 : case 3 :
174 : {
175 0 : mpGradient->Style = awt::GradientStyle_RECT;
176 : }
177 0 : break;
178 : case 2 :
179 : {
180 0 : mpGradient->Style = awt::GradientStyle_ELLIPTICAL;
181 : }
182 0 : break;
183 : default :
184 : {
185 0 : mpGradient->Style = awt::GradientStyle_LINEAR;
186 : }
187 : }
188 0 : }
189 :
190 :
191 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|