1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "elements.hxx"
23 // ---------------------------------------------------------------
26 CGMElements::CGMElements( CGM
& rCGM
) :
32 // ---------------------------------------------------------------
34 CGMElements::~CGMElements()
36 DeleteAllBundles( aLineList
);
37 DeleteAllBundles( aMarkerList
);
38 DeleteAllBundles( aEdgeList
);
39 DeleteAllBundles( aTextList
);
40 DeleteAllBundles( aFillList
);
43 // ---------------------------------------------------------------
45 CGMElements
& CGMElements::operator=( CGMElements
& rSource
)
49 nVDCIntegerPrecision
= rSource
.nVDCIntegerPrecision
;
50 nIntegerPrecision
= rSource
.nIntegerPrecision
;
51 eRealPrecision
= rSource
.eRealPrecision
;
52 nRealSize
= rSource
.nRealSize
;
53 nIndexPrecision
= rSource
.nIndexPrecision
;
54 nColorPrecision
= rSource
.nColorPrecision
;
55 nColorIndexPrecision
= rSource
.nColorIndexPrecision
;
57 nMetaFileVersion
= rSource
.nMetaFileVersion
;
58 eScalingMode
= rSource
.eScalingMode
;
59 nScalingFactor
= rSource
.nScalingFactor
;
60 eVDCType
= rSource
.eVDCType
;
61 eVDCRealPrecision
= rSource
.eVDCRealPrecision
;
62 nVDCRealSize
= rSource
.nVDCRealSize
;
63 aVDCExtent
= rSource
.aVDCExtent
;
64 aVDCExtentMaximum
= rSource
.aVDCExtentMaximum
;
65 eDeviceViewPortMode
= rSource
.eDeviceViewPortMode
;
66 nDeviceViewPortScale
= rSource
.nDeviceViewPortScale
;
67 eDeviceViewPortMap
= rSource
.eDeviceViewPortMap
;
68 eDeviceViewPortMapH
= rSource
.eDeviceViewPortMapH
;
69 eDeviceViewPortMapV
= rSource
.eDeviceViewPortMapV
;
70 aDeviceViewPort
= rSource
.aDeviceViewPort
;
71 nMitreLimit
= rSource
.nMitreLimit
;
72 eClipIndicator
= rSource
.eClipIndicator
;
73 aClipRect
= rSource
.aClipRect
;
74 eColorSelectionMode
= rSource
.eColorSelectionMode
;
75 eColorModel
= rSource
.eColorModel
;
76 nColorMaximumIndex
= rSource
.nColorMaximumIndex
;
77 nLatestColorMaximumIndex
= rSource
.nLatestColorMaximumIndex
;
79 for ( nIndex
= 1; nIndex
< 256; nIndex
++ ) // do not overwrite the background color
81 aColorTableEntryIs
[ nIndex
] = rSource
.aColorTableEntryIs
[ nIndex
];
82 aColorTable
[ nIndex
] = rSource
.aColorTable
[ nIndex
];
83 aLatestColorTable
[ nIndex
] = rSource
.aColorTable
[ nIndex
];
86 for ( nIndex
= 0; nIndex
< 8; nIndex
++ )
88 nColorValueExtent
[ nIndex
] = rSource
.nColorValueExtent
[ nIndex
];
90 nAspectSourceFlags
= rSource
.nAspectSourceFlags
;
92 CopyAllBundles( rSource
.aLineList
, aLineList
);
93 aLineBundle
= rSource
.aLineBundle
;
94 pLineBundle
= (LineBundle
*)GetBundle( aLineList
, rSource
.pLineBundle
->GetIndex() );
95 eLineWidthSpecMode
= rSource
.eLineWidthSpecMode
;
96 eLineCapType
= rSource
.eLineCapType
;
97 eLineJoinType
= rSource
.eLineJoinType
;
99 CopyAllBundles( rSource
.aMarkerList
, aMarkerList
);
100 aMarkerBundle
= rSource
.aMarkerBundle
;
101 pMarkerBundle
= (MarkerBundle
*)GetBundle( aMarkerList
, rSource
.pMarkerBundle
->GetIndex() );
102 eMarkerSizeSpecMode
= rSource
.eMarkerSizeSpecMode
;
104 CopyAllBundles( rSource
.aEdgeList
, aEdgeList
);
105 aEdgeBundle
= rSource
.aEdgeBundle
;
106 pEdgeBundle
= (EdgeBundle
*)GetBundle( aEdgeList
, rSource
.pEdgeBundle
->GetIndex() );
107 eEdgeVisibility
= rSource
.eEdgeVisibility
;
108 eEdgeWidthSpecMode
= rSource
.eEdgeWidthSpecMode
;
110 CopyAllBundles( rSource
.aTextList
, aTextList
);
111 aTextBundle
= rSource
.aTextBundle
;
112 pTextBundle
= (TextBundle
*)GetBundle( aTextList
, rSource
.pTextBundle
->GetIndex() );
113 nCharacterHeight
= rSource
.nCharacterHeight
;
114 nCharacterOrientation
[ 0 ] = rSource
.nCharacterOrientation
[ 0 ];
115 nCharacterOrientation
[ 1 ] = rSource
.nCharacterOrientation
[ 1 ];
116 nCharacterOrientation
[ 2 ] = rSource
.nCharacterOrientation
[ 2 ];
117 nCharacterOrientation
[ 3 ] = rSource
.nCharacterOrientation
[ 3 ];
118 eUnderlineMode
= rSource
.eUnderlineMode
;
119 nUnderlineColor
= rSource
.nUnderlineColor
;
120 eTextPath
= rSource
.eTextPath
;
121 eTextAlignmentH
= rSource
.eTextAlignmentH
;
122 eTextAlignmentV
= rSource
.eTextAlignmentV
;
123 nTextAlignmentHCont
= rSource
.nTextAlignmentHCont
;
124 nTextAlignmentVCont
= rSource
.nTextAlignmentVCont
;
125 nCharacterSetIndex
= rSource
.nCharacterSetIndex
;
126 nAlternateCharacterSetIndex
= rSource
.nAlternateCharacterSetIndex
;
127 aFontList
= rSource
.aFontList
;
128 eCharacterCodingA
= rSource
.eCharacterCodingA
;
130 CopyAllBundles( rSource
.aFillList
, aFillList
);
131 aFillBundle
= rSource
.aFillBundle
;
132 pFillBundle
= (FillBundle
*)GetBundle( aFillList
, rSource
.pFillBundle
->GetIndex() );
133 aFillRefPoint
= rSource
.aFillRefPoint
;
134 eTransparency
= rSource
.eTransparency
;
135 nAuxiliaryColor
= rSource
.nAuxiliaryColor
;
137 maHatchMap
= rSource
.maHatchMap
;
138 bSegmentCount
= rSource
.bSegmentCount
;
142 // ---------------------------------------------------------------
144 void CGMElements::Init()
147 nIntegerPrecision
= nIndexPrecision
= 2;
148 nRealSize
= nVDCRealSize
= 4;
149 nColorIndexPrecision
= 1;
151 nVDCIntegerPrecision
= 2;
152 eRealPrecision
= eVDCRealPrecision
= RP_FIXED
; //RP_FLOAT;
154 nMetaFileVersion
= 1;
155 eScalingMode
= SM_ABSTRACT
;
156 eVDCType
= VDC_INTEGER
;
157 aVDCExtent
.Left
= aVDCExtent
.Bottom
= 0;
158 // aVDCExtent.Right = aVDCExtent.Top = 32767;
159 aVDCExtent
.Right
= aVDCExtent
.Top
= 1.0;
160 aVDCExtentMaximum
.Left
= aVDCExtentMaximum
.Bottom
= 0;
161 // aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 32767;
162 aVDCExtentMaximum
.Right
= aVDCExtentMaximum
.Top
= 1.0;
164 eDeviceViewPortMode
= DVPM_FRACTION
;
165 nDeviceViewPortScale
= 1;
166 eDeviceViewPortMap
= DVPM_FORCED
;
167 eDeviceViewPortMapH
= DVPMH_LEFT
;
168 eDeviceViewPortMapV
= DVPMV_BOTTOM
;
169 aDeviceViewPort
.Left
= 0;
170 aDeviceViewPort
.Top
= 1;
171 aDeviceViewPort
.Right
= 0;
172 aDeviceViewPort
.Bottom
= 1;
175 eClipIndicator
= CI_ON
;
176 aClipRect
= aVDCExtent
;
178 eColorSelectionMode
= CSM_INDEXED
;
179 eColorModel
= CM_RGB
;
180 nColorMaximumIndex
= 63;
182 for ( i
= 0; i
< 256; aColorTableEntryIs
[ i
++ ] = 0 ) ;
183 aColorTable
[ 0 ] = 0;
184 for ( i
= 1; i
< 256; aColorTable
[ i
++ ] = 0xffffff ) ;
185 nLatestColorMaximumIndex
= 63;
186 aLatestColorTable
[ 0 ] = 0;
187 for ( i
= 1; i
< 256; aLatestColorTable
[ i
++ ] = 0xffffff ) ;
188 nColorValueExtent
[ 0 ] = nColorValueExtent
[ 1 ] = nColorValueExtent
[ 2 ] = 0;
189 nColorValueExtent
[ 3 ] = nColorValueExtent
[ 4 ] = nColorValueExtent
[ 5 ] = 255;
191 nAspectSourceFlags
= 0; // all flags are individual
193 eLineWidthSpecMode
= SM_SCALED
; // line parameter
194 eLineCapType
= LCT_NONE
;
195 eLineJoinType
= LJT_NONE
;
196 pLineBundle
= &aLineBundle
; // line bundle parameter
197 aLineBundle
.SetIndex( 1 );
198 aLineBundle
.eLineType
= LT_SOLID
;
199 aLineBundle
.nLineWidth
= 1;
200 aLineBundle
.SetColor( 0xffffff );
201 InsertBundle( aLineList
, aLineBundle
);
203 eMarkerSizeSpecMode
= SM_SCALED
; // marker parameter
204 pMarkerBundle
= &aMarkerBundle
; // marker bundle parameter
205 aMarkerBundle
.SetIndex( 1 );
206 aMarkerBundle
.eMarkerType
= MT_STAR
;
207 aMarkerBundle
.nMarkerSize
= 1;
208 aMarkerBundle
.SetColor( 0xffffff );
209 InsertBundle( aMarkerList
, aMarkerBundle
);
211 eEdgeVisibility
= EV_OFF
; // edge parameter
212 eEdgeWidthSpecMode
= SM_SCALED
;
213 pEdgeBundle
= &aEdgeBundle
; // edge bundle parameter
214 aEdgeBundle
.SetIndex( 1 );
215 aEdgeBundle
.eEdgeType
= ET_SOLID
;
216 aEdgeBundle
.nEdgeWidth
= 1;
217 aEdgeBundle
.SetColor( 0xffffff );
218 InsertBundle( aEdgeList
, aEdgeBundle
);
220 nCharacterHeight
= 327; // text parameter
221 nCharacterOrientation
[0] = 0;
222 nCharacterOrientation
[1] = 1;
223 nCharacterOrientation
[2] = 1;
224 nCharacterOrientation
[3] = 0;
225 eUnderlineMode
= UM_OFF
;
226 nUnderlineColor
= 0xffffff;
227 eTextPath
= TPR_RIGHT
;
228 eTextAlignmentH
= TAH_NORMAL
;
229 eTextAlignmentV
= TAV_NORMAL
;
230 nCharacterSetIndex
= nAlternateCharacterSetIndex
= 1;
231 eCharacterCodingA
= CCA_BASIC_7
;
232 pTextBundle
= &aTextBundle
; // text bundle parameter
233 aTextBundle
.SetIndex( 1 );
234 aTextBundle
.nTextFontIndex
= 1;
235 aTextBundle
.eTextPrecision
= TPR_STRING
;
236 aTextBundle
.nCharacterExpansion
= 1;
237 aTextBundle
.nCharacterSpacing
= 0;
238 aTextBundle
.SetColor( 0xffffff );
239 InsertBundle( aTextList
, aTextBundle
);
241 pFillBundle
= &aFillBundle
; // fill bundle parameter
242 aFillBundle
.SetIndex( 1 );
243 aFillBundle
.eFillInteriorStyle
= FIS_HOLLOW
;
244 aFillBundle
.nFillHatchIndex
= 1;
245 aFillBundle
.nFillPatternIndex
= 1;
246 aFillBundle
.SetColor( 0xffffff );
247 InsertBundle( aFillList
, aFillBundle
);
249 ImplInsertHatch( 0, 0, 0, 0 );
250 ImplInsertHatch( 1, 0, 125, 0 );
251 ImplInsertHatch( 2, 0, 125, 900 );
252 ImplInsertHatch( 3, 0, 125, 450 );
253 ImplInsertHatch( 4, 0, 125, 1350 );
254 ImplInsertHatch( 5, 1, 125, 0 );
255 ImplInsertHatch( 6, 1, 125, 450 );
256 ImplInsertHatch( -1, 0, 75, 0 );
257 ImplInsertHatch( -2, 0, 75, 900 );
258 ImplInsertHatch( -3, 0, 75, 450 );
259 ImplInsertHatch( -4, 0, 75, 1350 );
260 ImplInsertHatch( -5, 1, 75, 0 );
261 ImplInsertHatch( -6, 1, 75, 450 );
262 ImplInsertHatch( -7, 2, 125, 0 );
263 ImplInsertHatch( -8, 2, 125, 900 );
264 ImplInsertHatch( -9, 2, 125, 450 );
265 ImplInsertHatch( -10, 2, 125, 1350 );
266 ImplInsertHatch( -11, 0, 40, 0 );
267 ImplInsertHatch( -12, 0, 40, 900 );
268 ImplInsertHatch( -13, 0, 40, 450 );
269 ImplInsertHatch( -14, 0, 40, 1350 );
270 ImplInsertHatch( -15, 1, 40, 0 );
271 ImplInsertHatch( -16, 1, 40, 900 );
272 ImplInsertHatch( -21, 0, 250, 0 );
273 ImplInsertHatch( -22, 0, 250, 900 );
274 ImplInsertHatch( -23, 0, 250, 450 );
275 ImplInsertHatch( -24, 0, 250, 1350 );
276 ImplInsertHatch( -25, 1, 250, 0 );
277 ImplInsertHatch( -26, 1, 250, 450 );
279 eTransparency
= T_ON
;
281 nBackGroundColor
= nAuxiliaryColor
= 0;
283 bSegmentCount
= sal_False
;
286 // ---------------------------------------------------------------
288 void CGMElements::ImplInsertHatch( sal_Int32 nKey
, int nStyle
, long nDistance
, long nAngle
)
290 HatchEntry
& rEntry
= maHatchMap
[nKey
];
291 rEntry
.HatchStyle
= nStyle
;
292 rEntry
.HatchDistance
= nDistance
;
293 rEntry
.HatchAngle
= nAngle
;
296 // ---------------------------------------------------------------
298 void CGMElements::DeleteAllBundles( BundleList
& rList
)
300 for ( size_t i
= 0, n
= rList
.size(); i
< n
; ++i
) {
307 // ---------------------------------------------------------------
309 void CGMElements::CopyAllBundles( BundleList
& rSource
, BundleList
& rDest
)
311 DeleteAllBundles( rDest
);
313 for ( size_t i
= 0, n
= rSource
.size(); i
< n
; ++i
)
315 Bundle
* pPtr
= rSource
[ i
];
316 Bundle
* pTempBundle
= pPtr
->Clone();
317 rDest
.push_back( pTempBundle
);
321 // ---------------------------------------------------------------
323 Bundle
* CGMElements::GetBundleIndex( long nIndex
, BundleList
& rList
, Bundle
& rBundle
)
325 rBundle
.SetIndex( nIndex
);
326 Bundle
* pBundle
= GetBundle( rList
, nIndex
);
328 pBundle
= InsertBundle( rList
, rBundle
);
332 // ---------------------------------------------------------------
334 Bundle
* CGMElements::GetBundle( BundleList
& rList
, long nIndex
)
336 for ( size_t i
= 0, n
= rList
.size(); i
< n
; ++i
) {
337 if ( rList
[ i
]->GetIndex() == nIndex
) {
344 // ---------------------------------------------------------------
346 Bundle
* CGMElements::InsertBundle( BundleList
& rList
, Bundle
& rBundle
)
348 Bundle
* pBundle
= GetBundle( rList
, rBundle
.GetIndex() );
351 for ( BundleList::iterator it
= rList
.begin(); it
!= rList
.end(); ++it
) {
352 if ( *it
== pBundle
) {
359 pBundle
= rBundle
.Clone();
360 rList
.push_back( pBundle
);
364 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */