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