1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: elements.cxx,v $
10 * $Revision: 1.6.38.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_goodies.hxx"
34 #include "elements.hxx"
36 // ---------------------------------------------------------------
39 CGMElements::CGMElements( CGM
& rCGM
) :
45 // ---------------------------------------------------------------
47 CGMElements::~CGMElements()
49 DeleteTable( aHatchTable
);
50 DeleteAllBundles( aLineList
);
51 DeleteAllBundles( aMarkerList
);
52 DeleteAllBundles( aEdgeList
);
53 DeleteAllBundles( aTextList
);
54 DeleteAllBundles( aFillList
);
57 // ---------------------------------------------------------------
59 CGMElements
& CGMElements::operator=( CGMElements
& rSource
)
63 nVDCIntegerPrecision
= rSource
.nVDCIntegerPrecision
;
64 nIntegerPrecision
= rSource
.nIntegerPrecision
;
65 eRealPrecision
= rSource
.eRealPrecision
;
66 nRealSize
= rSource
.nRealSize
;
67 nIndexPrecision
= rSource
.nIndexPrecision
;
68 nColorPrecision
= rSource
.nColorPrecision
;
69 nColorIndexPrecision
= rSource
.nColorIndexPrecision
;
71 nMetaFileVersion
= rSource
.nMetaFileVersion
;
72 eScalingMode
= rSource
.eScalingMode
;
73 nScalingFactor
= rSource
.nScalingFactor
;
74 eVDCType
= rSource
.eVDCType
;
75 eVDCRealPrecision
= rSource
.eVDCRealPrecision
;
76 nVDCRealSize
= rSource
.nVDCRealSize
;
77 aVDCExtent
= rSource
.aVDCExtent
;
78 aVDCExtentMaximum
= rSource
.aVDCExtentMaximum
;
79 eDeviceViewPortMode
= rSource
.eDeviceViewPortMode
;
80 nDeviceViewPortScale
= rSource
.nDeviceViewPortScale
;
81 eDeviceViewPortMap
= rSource
.eDeviceViewPortMap
;
82 eDeviceViewPortMapH
= rSource
.eDeviceViewPortMapH
;
83 eDeviceViewPortMapV
= rSource
.eDeviceViewPortMapV
;
84 aDeviceViewPort
= rSource
.aDeviceViewPort
;
85 nMitreLimit
= rSource
.nMitreLimit
;
86 eClipIndicator
= rSource
.eClipIndicator
;
87 aClipRect
= rSource
.aClipRect
;
88 eColorSelectionMode
= rSource
.eColorSelectionMode
;
89 eColorModel
= rSource
.eColorModel
;
90 nColorMaximumIndex
= rSource
.nColorMaximumIndex
;
91 nLatestColorMaximumIndex
= rSource
.nLatestColorMaximumIndex
;
93 for ( nIndex
= 1; nIndex
< 256; nIndex
++ ) // do not overwrite the background color
95 aColorTableEntryIs
[ nIndex
] = rSource
.aColorTableEntryIs
[ nIndex
];
96 aColorTable
[ nIndex
] = rSource
.aColorTable
[ nIndex
];
97 aLatestColorTable
[ nIndex
] = rSource
.aColorTable
[ nIndex
];
100 for ( nIndex
= 0; nIndex
< 8; nIndex
++ )
102 nColorValueExtent
[ nIndex
] = rSource
.nColorValueExtent
[ nIndex
];
104 nAspectSourceFlags
= rSource
.nAspectSourceFlags
;
106 CopyAllBundles( rSource
.aLineList
, aLineList
);
107 aLineBundle
= rSource
.aLineBundle
;
108 pLineBundle
= (LineBundle
*)GetBundle( aLineList
, rSource
.pLineBundle
->GetIndex() );
109 eLineWidthSpecMode
= rSource
.eLineWidthSpecMode
;
110 eLineCapType
= rSource
.eLineCapType
;
111 eLineJoinType
= rSource
.eLineJoinType
;
113 CopyAllBundles( rSource
.aMarkerList
, aMarkerList
);
114 aMarkerBundle
= rSource
.aMarkerBundle
;
115 pMarkerBundle
= (MarkerBundle
*)GetBundle( aMarkerList
, rSource
.pMarkerBundle
->GetIndex() );
116 eMarkerSizeSpecMode
= rSource
.eMarkerSizeSpecMode
;
118 CopyAllBundles( rSource
.aEdgeList
, aEdgeList
);
119 aEdgeBundle
= rSource
.aEdgeBundle
;
120 pEdgeBundle
= (EdgeBundle
*)GetBundle( aEdgeList
, rSource
.pEdgeBundle
->GetIndex() );
121 eEdgeVisibility
= rSource
.eEdgeVisibility
;
122 eEdgeWidthSpecMode
= rSource
.eEdgeWidthSpecMode
;
124 CopyAllBundles( rSource
.aTextList
, aTextList
);
125 aTextBundle
= rSource
.aTextBundle
;
126 pTextBundle
= (TextBundle
*)GetBundle( aTextList
, rSource
.pTextBundle
->GetIndex() );
127 nCharacterHeight
= rSource
.nCharacterHeight
;
128 nCharacterOrientation
[ 0 ] = rSource
.nCharacterOrientation
[ 0 ];
129 nCharacterOrientation
[ 1 ] = rSource
.nCharacterOrientation
[ 1 ];
130 nCharacterOrientation
[ 2 ] = rSource
.nCharacterOrientation
[ 2 ];
131 nCharacterOrientation
[ 3 ] = rSource
.nCharacterOrientation
[ 3 ];
132 eUnderlineMode
= rSource
.eUnderlineMode
;
133 nUnderlineColor
= rSource
.nUnderlineColor
;
134 eTextPath
= rSource
.eTextPath
;
135 eTextAlignmentH
= rSource
.eTextAlignmentH
;
136 eTextAlignmentV
= rSource
.eTextAlignmentV
;
137 nTextAlignmentHCont
= rSource
.nTextAlignmentHCont
;
138 nTextAlignmentVCont
= rSource
.nTextAlignmentVCont
;
139 nCharacterSetIndex
= rSource
.nCharacterSetIndex
;
140 nAlternateCharacterSetIndex
= rSource
.nAlternateCharacterSetIndex
;
141 aFontList
= rSource
.aFontList
;
142 eCharacterCodingA
= rSource
.eCharacterCodingA
;
144 CopyAllBundles( rSource
.aFillList
, aFillList
);
145 aFillBundle
= rSource
.aFillBundle
;
146 pFillBundle
= (FillBundle
*)GetBundle( aFillList
, rSource
.pFillBundle
->GetIndex() );
147 aFillRefPoint
= rSource
.aFillRefPoint
;
148 eTransparency
= rSource
.eTransparency
;
149 nAuxiliaryColor
= rSource
.nAuxiliaryColor
;
151 DeleteTable( aHatchTable
);
152 HatchEntry
* pSource
= (HatchEntry
*)rSource
.aHatchTable
.First();
155 sal_uInt32 nKey
= rSource
.aHatchTable
.GetKey( pSource
);
156 aHatchTable
.Insert( nKey
, new HatchEntry( *pSource
) );
157 pSource
= (HatchEntry
*)rSource
.aHatchTable
.Next();
159 bSegmentCount
= rSource
.bSegmentCount
;
163 // ---------------------------------------------------------------
165 void CGMElements::Init()
168 nIntegerPrecision
= nIndexPrecision
= 2;
169 nRealSize
= nVDCRealSize
= 4;
170 nColorIndexPrecision
= 1;
172 nVDCIntegerPrecision
= 2;
173 eRealPrecision
= eVDCRealPrecision
= RP_FIXED
; //RP_FLOAT;
175 nMetaFileVersion
= 1;
176 eScalingMode
= SM_ABSTRACT
;
177 eVDCType
= VDC_INTEGER
;
178 aVDCExtent
.Left
= aVDCExtent
.Bottom
= 0;
179 // aVDCExtent.Right = aVDCExtent.Top = 32767;
180 aVDCExtent
.Right
= aVDCExtent
.Top
= 1.0;
181 aVDCExtentMaximum
.Left
= aVDCExtentMaximum
.Bottom
= 0;
182 // aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 32767;
183 aVDCExtentMaximum
.Right
= aVDCExtentMaximum
.Top
= 1.0;
185 eDeviceViewPortMode
= DVPM_FRACTION
;
186 nDeviceViewPortScale
= 1;
187 eDeviceViewPortMap
= DVPM_FORCED
;
188 eDeviceViewPortMapH
= DVPMH_LEFT
;
189 eDeviceViewPortMapV
= DVPMV_BOTTOM
;
190 aDeviceViewPort
.Left
= 0;
191 aDeviceViewPort
.Top
= 1;
192 aDeviceViewPort
.Right
= 0;
193 aDeviceViewPort
.Bottom
= 1;
196 eClipIndicator
= CI_ON
;
197 aClipRect
= aVDCExtent
;
199 eColorSelectionMode
= CSM_INDEXED
;
200 eColorModel
= CM_RGB
;
201 nColorMaximumIndex
= 63;
203 for ( i
= 0; i
< 256; aColorTableEntryIs
[ i
++ ] = 0 ) ;
204 aColorTable
[ 0 ] = 0;
205 for ( i
= 1; i
< 256; aColorTable
[ i
++ ] = 0xffffff ) ;
206 nLatestColorMaximumIndex
= 63;
207 aLatestColorTable
[ 0 ] = 0;
208 for ( i
= 1; i
< 256; aLatestColorTable
[ i
++ ] = 0xffffff ) ;
209 nColorValueExtent
[ 0 ] = nColorValueExtent
[ 1 ] = nColorValueExtent
[ 2 ] = 0;
210 nColorValueExtent
[ 3 ] = nColorValueExtent
[ 4 ] = nColorValueExtent
[ 5 ] = 255;
212 nAspectSourceFlags
= 0; // all flags are individual
214 eLineWidthSpecMode
= SM_SCALED
; // line parameter
215 eLineCapType
= LCT_NONE
;
216 eLineJoinType
= LJT_NONE
;
217 pLineBundle
= &aLineBundle
; // line bundle parameter
218 aLineBundle
.SetIndex( 1 );
219 aLineBundle
.eLineType
= LT_SOLID
;
220 aLineBundle
.nLineWidth
= 1;
221 aLineBundle
.SetColor( 0xffffff );
222 InsertBundle( aLineList
, aLineBundle
);
224 eMarkerSizeSpecMode
= SM_SCALED
; // marker parameter
225 pMarkerBundle
= &aMarkerBundle
; // marker bundle parameter
226 aMarkerBundle
.SetIndex( 1 );
227 aMarkerBundle
.eMarkerType
= MT_STAR
;
228 aMarkerBundle
.nMarkerSize
= 1;
229 aMarkerBundle
.SetColor( 0xffffff );
230 InsertBundle( aMarkerList
, aMarkerBundle
);
232 eEdgeVisibility
= EV_OFF
; // edge parameter
233 eEdgeWidthSpecMode
= SM_SCALED
;
234 pEdgeBundle
= &aEdgeBundle
; // edge bundle parameter
235 aEdgeBundle
.SetIndex( 1 );
236 aEdgeBundle
.eEdgeType
= ET_SOLID
;
237 aEdgeBundle
.nEdgeWidth
= 1;
238 aEdgeBundle
.SetColor( 0xffffff );
239 InsertBundle( aEdgeList
, aEdgeBundle
);
241 nCharacterHeight
= 327; // text parameter
242 nCharacterOrientation
[0] = 0;
243 nCharacterOrientation
[1] = 1;
244 nCharacterOrientation
[2] = 1;
245 nCharacterOrientation
[3] = 0;
246 eUnderlineMode
= UM_OFF
;
247 nUnderlineColor
= 0xffffff;
248 eTextPath
= TPR_RIGHT
;
249 eTextAlignmentH
= TAH_NORMAL
;
250 eTextAlignmentV
= TAV_NORMAL
;
251 nCharacterSetIndex
= nAlternateCharacterSetIndex
= 1;
252 eCharacterCodingA
= CCA_BASIC_7
;
253 pTextBundle
= &aTextBundle
; // text bundle parameter
254 aTextBundle
.SetIndex( 1 );
255 aTextBundle
.nTextFontIndex
= 1;
256 aTextBundle
.eTextPrecision
= TPR_STRING
;
257 aTextBundle
.nCharacterExpansion
= 1;
258 aTextBundle
.nCharacterSpacing
= 0;
259 aTextBundle
.SetColor( 0xffffff );
260 InsertBundle( aTextList
, aTextBundle
);
262 pFillBundle
= &aFillBundle
; // fill bundle parameter
263 aFillBundle
.SetIndex( 1 );
264 aFillBundle
.eFillInteriorStyle
= FIS_HOLLOW
;
265 aFillBundle
.nFillHatchIndex
= 1;
266 aFillBundle
.nFillPatternIndex
= 1;
267 aFillBundle
.SetColor( 0xffffff );
268 InsertBundle( aFillList
, aFillBundle
);
270 ImplInsertHatch( 0, 0, 0, 0 );
271 ImplInsertHatch( 1, 0, 125, 0 );
272 ImplInsertHatch( 2, 0, 125, 900 );
273 ImplInsertHatch( 3, 0, 125, 450 );
274 ImplInsertHatch( 4, 0, 125, 1350 );
275 ImplInsertHatch( 5, 1, 125, 0 );
276 ImplInsertHatch( 6, 1, 125, 450 );
277 ImplInsertHatch( -1, 0, 75, 0 );
278 ImplInsertHatch( -2, 0, 75, 900 );
279 ImplInsertHatch( -3, 0, 75, 450 );
280 ImplInsertHatch( -4, 0, 75, 1350 );
281 ImplInsertHatch( -5, 1, 75, 0 );
282 ImplInsertHatch( -6, 1, 75, 450 );
283 ImplInsertHatch( -7, 2, 125, 0 );
284 ImplInsertHatch( -8, 2, 125, 900 );
285 ImplInsertHatch( -9, 2, 125, 450 );
286 ImplInsertHatch( -10, 2, 125, 1350 );
287 ImplInsertHatch( -11, 0, 40, 0 );
288 ImplInsertHatch( -12, 0, 40, 900 );
289 ImplInsertHatch( -13, 0, 40, 450 );
290 ImplInsertHatch( -14, 0, 40, 1350 );
291 ImplInsertHatch( -15, 1, 40, 0 );
292 ImplInsertHatch( -16, 1, 40, 900 );
293 ImplInsertHatch( -21, 0, 250, 0 );
294 ImplInsertHatch( -22, 0, 250, 900 );
295 ImplInsertHatch( -23, 0, 250, 450 );
296 ImplInsertHatch( -24, 0, 250, 1350 );
297 ImplInsertHatch( -25, 1, 250, 0 );
298 ImplInsertHatch( -26, 1, 250, 450 );
300 eTransparency
= T_ON
;
302 nBackGroundColor
= nAuxiliaryColor
= 0;
304 bSegmentCount
= sal_False
;
307 // ---------------------------------------------------------------
309 void CGMElements::ImplInsertHatch( sal_Int32 nKey
, int nStyle
, long nDistance
, long nAngle
)
311 HatchEntry
* pHatchEntry
;
312 pHatchEntry
= new HatchEntry
;
313 aHatchTable
.Insert( (sal_uInt32
)nKey
, pHatchEntry
);
314 pHatchEntry
->HatchStyle
= nStyle
;
315 pHatchEntry
->HatchDistance
= nDistance
;
316 pHatchEntry
->HatchAngle
= nAngle
;
319 // ---------------------------------------------------------------
321 void CGMElements::DeleteTable( Table
& rTable
)
323 HatchEntry
* pPtr
= (HatchEntry
*)rTable
.First();
327 pPtr
= (HatchEntry
*)rTable
.Next();
332 // ---------------------------------------------------------------
334 void CGMElements::DeleteAllBundles( List
& rList
)
336 void* pPtr
= rList
.First();
339 delete (Bundle
*)pPtr
;
345 // ---------------------------------------------------------------
347 void CGMElements::CopyAllBundles( List
& rSource
, List
& rDest
)
349 DeleteAllBundles( rDest
);
352 void* pPtr
= rSource
.First();
355 Bundle
* pTempBundle
= ( (Bundle
*)pPtr
)->Clone();
356 rDest
.Insert( pTempBundle
, LIST_APPEND
);
357 pPtr
= rSource
.Next();
361 // ---------------------------------------------------------------
363 Bundle
* CGMElements::GetBundleIndex( sal_uInt32 nIndex
, List
& rList
, Bundle
& rBundle
)
365 rBundle
.SetIndex( nIndex
);
366 Bundle
* pBundle
= GetBundle( rList
, nIndex
);
368 pBundle
= InsertBundle( rList
, rBundle
);
372 // ---------------------------------------------------------------
374 Bundle
* CGMElements::GetBundle( List
& rList
, long nIndex
)
376 Bundle
* pBundle
= (Bundle
*)rList
.First();
377 while( pBundle
&& ( pBundle
->GetIndex() != nIndex
) )
379 pBundle
= (Bundle
*)rList
.Next();
384 // ---------------------------------------------------------------
386 Bundle
* CGMElements::InsertBundle( List
& rList
, Bundle
& rBundle
)
388 Bundle
* pBundle
= GetBundle( rList
, rBundle
.GetIndex() );
391 rList
.Remove( pBundle
);
394 pBundle
= rBundle
.Clone();
395 rList
.Insert( pBundle
, LIST_APPEND
);