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 2 : CGMOutAct::CGMOutAct( CGM& rCGM )
27 : {
28 2 : mpCGM = &rCGM;
29 2 : mnCurrentPage = 0;
30 2 : mnGroupActCount = mnGroupLevel = 0;
31 2 : mpGroupLevel = new sal_uInt32[CGM_OUTACT_MAX_GROUP_LEVEL] ();
32 2 : mpPoints = reinterpret_cast<Point*>(new sal_Int8[ 0x2000 * sizeof( Point ) ]);
33 2 : mpFlags = new sal_uInt8[ 0x2000 ];
34 :
35 2 : mnIndex = 0;
36 2 : mpGradient = NULL;
37 2 : }
38 :
39 4 : CGMOutAct::~CGMOutAct()
40 : {
41 2 : delete[] reinterpret_cast<sal_Int8*>(mpPoints);
42 2 : delete[] mpFlags;
43 2 : delete[] mpGroupLevel;
44 2 : delete mpGradient;
45 2 : }
46 :
47 0 : void CGMOutAct::BeginFigure()
48 : {
49 0 : if ( mnIndex )
50 0 : EndFigure();
51 :
52 0 : BeginGroup();
53 0 : mnIndex = 0;
54 0 : }
55 :
56 0 : void CGMOutAct::CloseRegion()
57 : {
58 0 : if ( mnIndex > 2 )
59 : {
60 0 : NewRegion();
61 0 : DrawPolyPolygon( maPolyPolygon );
62 0 : maPolyPolygon.Clear();
63 : }
64 0 : }
65 :
66 14 : void CGMOutAct::NewRegion()
67 : {
68 14 : if ( mnIndex > 2 )
69 : {
70 0 : Polygon aPolygon( mnIndex, mpPoints, mpFlags );
71 0 : maPolyPolygon.Insert( aPolygon );
72 : }
73 14 : mnIndex = 0;
74 14 : }
75 :
76 14 : void CGMOutAct::EndFigure()
77 : {
78 14 : NewRegion();
79 14 : DrawPolyPolygon( maPolyPolygon );
80 14 : maPolyPolygon.Clear();
81 14 : EndGroup();
82 14 : mnIndex = 0;
83 14 : }
84 :
85 0 : void CGMOutAct::RegPolyLine( Polygon& rPolygon, bool bReverse )
86 : {
87 0 : sal_uInt16 nPoints = rPolygon.GetSize();
88 0 : if ( nPoints )
89 : {
90 0 : if ( bReverse )
91 : {
92 0 : for ( sal_uInt16 i = 0; i < nPoints; i++ )
93 : {
94 0 : mpPoints[ mnIndex + i ] = rPolygon.GetPoint( nPoints - i - 1 );
95 0 : mpFlags[ mnIndex + i ] = (sal_Int8)rPolygon.GetFlags( nPoints - i - 1 );
96 : }
97 : }
98 : else
99 : {
100 0 : for ( sal_uInt16 i = 0; i < nPoints; i++ )
101 : {
102 0 : mpPoints[ mnIndex + i ] = rPolygon.GetPoint( i );
103 0 : mpFlags[ mnIndex + i ] = (sal_Int8)rPolygon.GetFlags( i );
104 : }
105 : }
106 0 : mnIndex = mnIndex + nPoints;
107 : }
108 0 : }
109 :
110 0 : void CGMOutAct::SetGradientOffset( long nHorzOfs, long nVertOfs, sal_uInt32 /*nType*/ )
111 : {
112 0 : if ( !mpGradient )
113 0 : mpGradient = new awt::Gradient;
114 0 : mpGradient->XOffset = ( (sal_uInt16)nHorzOfs & 0x7f );
115 0 : mpGradient->YOffset = ( (sal_uInt16)nVertOfs & 0x7f );
116 0 : }
117 :
118 0 : void CGMOutAct::SetGradientAngle( long nAngle )
119 : {
120 0 : if ( !mpGradient )
121 0 : mpGradient = new awt::Gradient;
122 0 : mpGradient->Angle = sal::static_int_cast< sal_Int16 >(nAngle);
123 0 : }
124 :
125 0 : void CGMOutAct::SetGradientDescriptor( sal_uInt32 nColorFrom, sal_uInt32 nColorTo )
126 : {
127 0 : if ( !mpGradient )
128 0 : mpGradient = new awt::Gradient;
129 0 : mpGradient->StartColor = nColorFrom;
130 0 : mpGradient->EndColor = nColorTo;
131 0 : }
132 :
133 0 : void CGMOutAct::SetGradientStyle( sal_uInt32 nStyle, double /*fRatio*/ )
134 : {
135 0 : if ( !mpGradient )
136 0 : mpGradient = new awt::Gradient;
137 0 : switch ( nStyle )
138 : {
139 : case 0xff :
140 : {
141 0 : mpGradient->Style = awt::GradientStyle_AXIAL;
142 : }
143 0 : break;
144 : case 4 :
145 : {
146 0 : mpGradient->Style = awt::GradientStyle_RADIAL; // CONICAL
147 : }
148 0 : break;
149 : case 3 :
150 : {
151 0 : mpGradient->Style = awt::GradientStyle_RECT;
152 : }
153 0 : break;
154 : case 2 :
155 : {
156 0 : mpGradient->Style = awt::GradientStyle_ELLIPTICAL;
157 : }
158 0 : break;
159 : default :
160 : {
161 0 : mpGradient->Style = awt::GradientStyle_LINEAR;
162 : }
163 : }
164 0 : }
165 :
166 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|