Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "elements.hxx"
31 : :
32 : : // ---------------------------------------------------------------
33 : :
34 : :
35 : 0 : CGMElements::CGMElements( CGM& rCGM ) :
36 : 0 : mpCGM ( &rCGM )
37 : : {
38 : 0 : Init();
39 : 0 : };
40 : :
41 : : // ---------------------------------------------------------------
42 : :
43 : 0 : CGMElements::~CGMElements()
44 : : {
45 : 0 : DeleteAllBundles( aLineList );
46 : 0 : DeleteAllBundles( aMarkerList );
47 : 0 : DeleteAllBundles( aEdgeList );
48 : 0 : DeleteAllBundles( aTextList );
49 : 0 : DeleteAllBundles( aFillList );
50 : 0 : }
51 : :
52 : : // ---------------------------------------------------------------
53 : :
54 : 0 : CGMElements& CGMElements::operator=( CGMElements& rSource )
55 : : {
56 : : sal_uInt32 nIndex;
57 : :
58 : 0 : nVDCIntegerPrecision = rSource.nVDCIntegerPrecision;
59 : 0 : nIntegerPrecision = rSource.nIntegerPrecision;
60 : 0 : eRealPrecision = rSource.eRealPrecision;
61 : 0 : nRealSize = rSource.nRealSize;
62 : 0 : nIndexPrecision = rSource.nIndexPrecision;
63 : 0 : nColorPrecision = rSource.nColorPrecision;
64 : 0 : nColorIndexPrecision = rSource.nColorIndexPrecision;
65 : :
66 : 0 : nMetaFileVersion = rSource.nMetaFileVersion;
67 : 0 : eScalingMode = rSource.eScalingMode;
68 : 0 : nScalingFactor = rSource.nScalingFactor;
69 : 0 : eVDCType = rSource.eVDCType;
70 : 0 : eVDCRealPrecision = rSource.eVDCRealPrecision;
71 : 0 : nVDCRealSize = rSource.nVDCRealSize;
72 : 0 : aVDCExtent = rSource.aVDCExtent;
73 : 0 : aVDCExtentMaximum = rSource.aVDCExtentMaximum;
74 : 0 : eDeviceViewPortMode = rSource.eDeviceViewPortMode;
75 : 0 : nDeviceViewPortScale = rSource.nDeviceViewPortScale;
76 : 0 : eDeviceViewPortMap = rSource.eDeviceViewPortMap;
77 : 0 : eDeviceViewPortMapH = rSource.eDeviceViewPortMapH;
78 : 0 : eDeviceViewPortMapV = rSource.eDeviceViewPortMapV;
79 : 0 : aDeviceViewPort = rSource.aDeviceViewPort;
80 : 0 : nMitreLimit = rSource.nMitreLimit;
81 : 0 : eClipIndicator = rSource.eClipIndicator;
82 : 0 : aClipRect = rSource.aClipRect;
83 : 0 : eColorSelectionMode = rSource.eColorSelectionMode;
84 : 0 : eColorModel = rSource.eColorModel;
85 : 0 : nColorMaximumIndex = rSource.nColorMaximumIndex;
86 : 0 : nLatestColorMaximumIndex = rSource.nLatestColorMaximumIndex;
87 : :
88 : 0 : for ( nIndex = 1; nIndex < 256; nIndex++ ) // do not overwrite the background color
89 : : {
90 : 0 : aColorTableEntryIs[ nIndex ] = rSource.aColorTableEntryIs[ nIndex ];
91 : 0 : aColorTable[ nIndex ] = rSource.aColorTable[ nIndex ];
92 : 0 : aLatestColorTable[ nIndex ] = rSource.aColorTable[ nIndex ];
93 : : }
94 : :
95 : 0 : for ( nIndex = 0; nIndex < 8; nIndex++ )
96 : : {
97 : 0 : nColorValueExtent[ nIndex ] = rSource.nColorValueExtent[ nIndex ];
98 : : }
99 : 0 : nAspectSourceFlags = rSource.nAspectSourceFlags;
100 : :
101 : 0 : CopyAllBundles( rSource.aLineList, aLineList );
102 : 0 : aLineBundle = rSource.aLineBundle;
103 : 0 : pLineBundle = (LineBundle*)GetBundle( aLineList, rSource.pLineBundle->GetIndex() );
104 : 0 : eLineWidthSpecMode = rSource.eLineWidthSpecMode;
105 : 0 : eLineCapType = rSource.eLineCapType;
106 : 0 : eLineJoinType = rSource.eLineJoinType;
107 : :
108 : 0 : CopyAllBundles( rSource.aMarkerList, aMarkerList );
109 : 0 : aMarkerBundle = rSource.aMarkerBundle;
110 : 0 : pMarkerBundle = (MarkerBundle*)GetBundle( aMarkerList, rSource.pMarkerBundle->GetIndex() );
111 : 0 : eMarkerSizeSpecMode = rSource.eMarkerSizeSpecMode;
112 : :
113 : 0 : CopyAllBundles( rSource.aEdgeList, aEdgeList );
114 : 0 : aEdgeBundle = rSource.aEdgeBundle;
115 : 0 : pEdgeBundle = (EdgeBundle*)GetBundle( aEdgeList, rSource.pEdgeBundle->GetIndex() );
116 : 0 : eEdgeVisibility = rSource.eEdgeVisibility;
117 : 0 : eEdgeWidthSpecMode = rSource.eEdgeWidthSpecMode;
118 : :
119 : 0 : CopyAllBundles( rSource.aTextList, aTextList );
120 : 0 : aTextBundle = rSource.aTextBundle;
121 : 0 : pTextBundle = (TextBundle*)GetBundle( aTextList, rSource.pTextBundle->GetIndex() );
122 : 0 : nCharacterHeight = rSource.nCharacterHeight;
123 : 0 : nCharacterOrientation[ 0 ] = rSource.nCharacterOrientation[ 0 ];
124 : 0 : nCharacterOrientation[ 1 ] = rSource.nCharacterOrientation[ 1 ];
125 : 0 : nCharacterOrientation[ 2 ] = rSource.nCharacterOrientation[ 2 ];
126 : 0 : nCharacterOrientation[ 3 ] = rSource.nCharacterOrientation[ 3 ];
127 : 0 : eUnderlineMode = rSource.eUnderlineMode;
128 : 0 : nUnderlineColor = rSource.nUnderlineColor;
129 : 0 : eTextPath = rSource.eTextPath;
130 : 0 : eTextAlignmentH = rSource.eTextAlignmentH;
131 : 0 : eTextAlignmentV = rSource.eTextAlignmentV;
132 : 0 : nTextAlignmentHCont = rSource.nTextAlignmentHCont;
133 : 0 : nTextAlignmentVCont = rSource.nTextAlignmentVCont;
134 : 0 : nCharacterSetIndex = rSource.nCharacterSetIndex;
135 : 0 : nAlternateCharacterSetIndex = rSource.nAlternateCharacterSetIndex;
136 : 0 : aFontList = rSource.aFontList;
137 : 0 : eCharacterCodingA = rSource.eCharacterCodingA;
138 : :
139 : 0 : CopyAllBundles( rSource.aFillList, aFillList );
140 : 0 : aFillBundle = rSource.aFillBundle;
141 : 0 : pFillBundle = (FillBundle*)GetBundle( aFillList, rSource.pFillBundle->GetIndex() );
142 : 0 : aFillRefPoint = rSource.aFillRefPoint;
143 : 0 : eTransparency = rSource.eTransparency;
144 : 0 : nAuxiliaryColor = rSource.nAuxiliaryColor;
145 : :
146 : 0 : maHatchMap = rSource.maHatchMap;
147 : 0 : bSegmentCount = rSource.bSegmentCount;
148 : 0 : return (*this);
149 : : }
150 : :
151 : : // ---------------------------------------------------------------
152 : :
153 : 0 : void CGMElements::Init()
154 : : {
155 : :
156 : 0 : nIntegerPrecision = nIndexPrecision = 2;
157 : 0 : nRealSize = nVDCRealSize = 4;
158 : 0 : nColorIndexPrecision = 1;
159 : 0 : nColorPrecision = 1;
160 : 0 : nVDCIntegerPrecision = 2;
161 : 0 : eRealPrecision = eVDCRealPrecision = RP_FIXED; //RP_FLOAT;
162 : :
163 : 0 : nMetaFileVersion = 1;
164 : 0 : eScalingMode = SM_ABSTRACT;
165 : 0 : eVDCType = VDC_INTEGER;
166 : 0 : aVDCExtent.Left = aVDCExtent.Bottom = 0;
167 : : // aVDCExtent.Right = aVDCExtent.Top = 32767;
168 : 0 : aVDCExtent.Right = aVDCExtent.Top = 1.0;
169 : 0 : aVDCExtentMaximum.Left = aVDCExtentMaximum.Bottom = 0;
170 : : // aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 32767;
171 : 0 : aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 1.0;
172 : :
173 : 0 : eDeviceViewPortMode = DVPM_FRACTION;
174 : 0 : nDeviceViewPortScale = 1;
175 : 0 : eDeviceViewPortMap = DVPM_FORCED;
176 : 0 : eDeviceViewPortMapH = DVPMH_LEFT;
177 : 0 : eDeviceViewPortMapV = DVPMV_BOTTOM;
178 : 0 : aDeviceViewPort.Left = 0;
179 : 0 : aDeviceViewPort.Top = 1;
180 : 0 : aDeviceViewPort.Right = 0;
181 : 0 : aDeviceViewPort.Bottom = 1;
182 : :
183 : 0 : nMitreLimit = 32767;
184 : 0 : eClipIndicator = CI_ON;
185 : 0 : aClipRect = aVDCExtent;
186 : :
187 : 0 : eColorSelectionMode = CSM_INDEXED;
188 : 0 : eColorModel = CM_RGB;
189 : 0 : nColorMaximumIndex = 63;
190 : : int i;
191 : 0 : for ( i = 0; i < 256; aColorTableEntryIs[ i++ ] = 0 ) ;
192 : 0 : aColorTable[ 0 ] = 0;
193 : 0 : for ( i = 1; i < 256; aColorTable[ i++ ] = 0xffffff ) ;
194 : 0 : nLatestColorMaximumIndex = 63;
195 : 0 : aLatestColorTable[ 0 ] = 0;
196 : 0 : for ( i = 1; i < 256; aLatestColorTable[ i++ ] = 0xffffff ) ;
197 : 0 : nColorValueExtent[ 0 ] = nColorValueExtent[ 1 ] = nColorValueExtent[ 2 ] = 0;
198 : 0 : nColorValueExtent[ 3 ] = nColorValueExtent[ 4 ] = nColorValueExtent[ 5 ] = 255;
199 : :
200 : 0 : nAspectSourceFlags = 0; // all flags are individual
201 : :
202 : 0 : eLineWidthSpecMode = SM_SCALED; // line parameter
203 : 0 : eLineCapType = LCT_NONE;
204 : 0 : eLineJoinType = LJT_NONE;
205 : 0 : pLineBundle = &aLineBundle; // line bundle parameter
206 : 0 : aLineBundle.SetIndex( 1 );
207 : 0 : aLineBundle.eLineType = LT_SOLID;
208 : 0 : aLineBundle.nLineWidth = 1;
209 : 0 : aLineBundle.SetColor( 0xffffff );
210 : 0 : InsertBundle( aLineList, aLineBundle );
211 : :
212 : 0 : eMarkerSizeSpecMode = SM_SCALED; // marker parameter
213 : 0 : pMarkerBundle = &aMarkerBundle; // marker bundle parameter
214 : 0 : aMarkerBundle.SetIndex( 1 );
215 : 0 : aMarkerBundle.eMarkerType = MT_STAR;
216 : 0 : aMarkerBundle.nMarkerSize = 1;
217 : 0 : aMarkerBundle.SetColor( 0xffffff );
218 : 0 : InsertBundle( aMarkerList, aMarkerBundle );
219 : :
220 : 0 : eEdgeVisibility = EV_OFF; // edge parameter
221 : 0 : eEdgeWidthSpecMode = SM_SCALED;
222 : 0 : pEdgeBundle = &aEdgeBundle; // edge bundle parameter
223 : 0 : aEdgeBundle.SetIndex( 1 );
224 : 0 : aEdgeBundle.eEdgeType = ET_SOLID;
225 : 0 : aEdgeBundle.nEdgeWidth = 1;
226 : 0 : aEdgeBundle.SetColor( 0xffffff );
227 : 0 : InsertBundle( aEdgeList, aEdgeBundle );
228 : :
229 : 0 : nCharacterHeight = 327; // text parameter
230 : 0 : nCharacterOrientation[0] = 0;
231 : 0 : nCharacterOrientation[1] = 1;
232 : 0 : nCharacterOrientation[2] = 1;
233 : 0 : nCharacterOrientation[3] = 0;
234 : 0 : eUnderlineMode = UM_OFF;
235 : 0 : nUnderlineColor = 0xffffff;
236 : 0 : eTextPath = TPR_RIGHT;
237 : 0 : eTextAlignmentH = TAH_NORMAL;
238 : 0 : eTextAlignmentV = TAV_NORMAL;
239 : 0 : nCharacterSetIndex = nAlternateCharacterSetIndex = 1;
240 : 0 : eCharacterCodingA = CCA_BASIC_7;
241 : 0 : pTextBundle = &aTextBundle; // text bundle parameter
242 : 0 : aTextBundle.SetIndex( 1 );
243 : 0 : aTextBundle.nTextFontIndex = 1;
244 : 0 : aTextBundle.eTextPrecision = TPR_STRING;
245 : 0 : aTextBundle.nCharacterExpansion = 1;
246 : 0 : aTextBundle.nCharacterSpacing = 0;
247 : 0 : aTextBundle.SetColor( 0xffffff );
248 : 0 : InsertBundle( aTextList, aTextBundle );
249 : :
250 : 0 : pFillBundle = &aFillBundle; // fill bundle parameter
251 : 0 : aFillBundle.SetIndex( 1 );
252 : 0 : aFillBundle.eFillInteriorStyle = FIS_HOLLOW;
253 : 0 : aFillBundle.nFillHatchIndex = 1;
254 : 0 : aFillBundle.nFillPatternIndex = 1;
255 : 0 : aFillBundle.SetColor( 0xffffff );
256 : 0 : InsertBundle( aFillList, aFillBundle );
257 : :
258 : 0 : ImplInsertHatch( 0, 0, 0, 0 );
259 : 0 : ImplInsertHatch( 1, 0, 125, 0 );
260 : 0 : ImplInsertHatch( 2, 0, 125, 900 );
261 : 0 : ImplInsertHatch( 3, 0, 125, 450 );
262 : 0 : ImplInsertHatch( 4, 0, 125, 1350 );
263 : 0 : ImplInsertHatch( 5, 1, 125, 0 );
264 : 0 : ImplInsertHatch( 6, 1, 125, 450 );
265 : 0 : ImplInsertHatch( -1, 0, 75, 0 );
266 : 0 : ImplInsertHatch( -2, 0, 75, 900 );
267 : 0 : ImplInsertHatch( -3, 0, 75, 450 );
268 : 0 : ImplInsertHatch( -4, 0, 75, 1350 );
269 : 0 : ImplInsertHatch( -5, 1, 75, 0 );
270 : 0 : ImplInsertHatch( -6, 1, 75, 450 );
271 : 0 : ImplInsertHatch( -7, 2, 125, 0 );
272 : 0 : ImplInsertHatch( -8, 2, 125, 900 );
273 : 0 : ImplInsertHatch( -9, 2, 125, 450 );
274 : 0 : ImplInsertHatch( -10, 2, 125, 1350 );
275 : 0 : ImplInsertHatch( -11, 0, 40, 0 );
276 : 0 : ImplInsertHatch( -12, 0, 40, 900 );
277 : 0 : ImplInsertHatch( -13, 0, 40, 450 );
278 : 0 : ImplInsertHatch( -14, 0, 40, 1350 );
279 : 0 : ImplInsertHatch( -15, 1, 40, 0 );
280 : 0 : ImplInsertHatch( -16, 1, 40, 900 );
281 : 0 : ImplInsertHatch( -21, 0, 250, 0 );
282 : 0 : ImplInsertHatch( -22, 0, 250, 900 );
283 : 0 : ImplInsertHatch( -23, 0, 250, 450 );
284 : 0 : ImplInsertHatch( -24, 0, 250, 1350 );
285 : 0 : ImplInsertHatch( -25, 1, 250, 0 );
286 : 0 : ImplInsertHatch( -26, 1, 250, 450 );
287 : :
288 : 0 : eTransparency = T_ON;
289 : :
290 : 0 : nBackGroundColor = nAuxiliaryColor = 0;
291 : :
292 : 0 : bSegmentCount = sal_False;
293 : 0 : }
294 : :
295 : : // ---------------------------------------------------------------
296 : :
297 : 0 : void CGMElements::ImplInsertHatch( sal_Int32 nKey, int nStyle, long nDistance, long nAngle )
298 : : {
299 : 0 : HatchEntry& rEntry = maHatchMap[nKey];
300 : 0 : rEntry.HatchStyle = nStyle;
301 : 0 : rEntry.HatchDistance = nDistance;
302 : 0 : rEntry.HatchAngle = nAngle;
303 : 0 : }
304 : :
305 : : // ---------------------------------------------------------------
306 : :
307 : 0 : void CGMElements::DeleteAllBundles( BundleList& rList )
308 : : {
309 : 0 : for ( size_t i = 0, n = rList.size(); i < n; ++i ) {
310 : 0 : delete rList[ i ];
311 : : }
312 : 0 : rList.clear();
313 : 0 : };
314 : :
315 : :
316 : : // ---------------------------------------------------------------
317 : :
318 : 0 : void CGMElements::CopyAllBundles( BundleList& rSource, BundleList& rDest )
319 : : {
320 : 0 : DeleteAllBundles( rDest );
321 : :
322 : 0 : for ( size_t i = 0, n = rSource.size(); i < n; ++i )
323 : : {
324 : 0 : Bundle* pPtr = rSource[ i ];
325 : 0 : Bundle* pTempBundle = pPtr->Clone();
326 : 0 : rDest.push_back( pTempBundle );
327 : : }
328 : 0 : };
329 : :
330 : : // ---------------------------------------------------------------
331 : :
332 : 0 : Bundle* CGMElements::GetBundleIndex( long nIndex, BundleList& rList, Bundle& rBundle )
333 : : {
334 : 0 : rBundle.SetIndex( nIndex );
335 : 0 : Bundle* pBundle = GetBundle( rList, nIndex );
336 : 0 : if ( !pBundle )
337 : 0 : pBundle = InsertBundle( rList, rBundle );
338 : 0 : return pBundle;
339 : : }
340 : :
341 : : // ---------------------------------------------------------------
342 : :
343 : 0 : Bundle* CGMElements::GetBundle( BundleList& rList, long nIndex )
344 : : {
345 : 0 : for ( size_t i = 0, n = rList.size(); i < n; ++i ) {
346 : 0 : if ( rList[ i ]->GetIndex() == nIndex ) {
347 : 0 : return rList[ i ];
348 : : }
349 : : }
350 : 0 : return NULL;
351 : : }
352 : :
353 : : // ---------------------------------------------------------------
354 : :
355 : 0 : Bundle* CGMElements::InsertBundle( BundleList& rList, Bundle& rBundle )
356 : : {
357 : 0 : Bundle* pBundle = GetBundle( rList, rBundle.GetIndex() );
358 : 0 : if ( pBundle )
359 : : {
360 : 0 : for ( BundleList::iterator it = rList.begin(); it != rList.end(); ++it ) {
361 : 0 : if ( *it == pBundle ) {
362 : 0 : rList.erase( it );
363 : 0 : delete pBundle;
364 : 0 : break;
365 : : }
366 : : }
367 : : }
368 : 0 : pBundle = rBundle.Clone();
369 : 0 : rList.push_back( pBundle );
370 : 0 : return pBundle;
371 : : };
372 : :
373 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|