1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "elements.hxx"
#include <algorithm>
CGMElements::CGMElements()
{
Init();
};
CGMElements::~CGMElements()
{
}
CGMElements& CGMElements::operator=( const CGMElements& rSource )
{
if (this == &rSource)
return *this;
sal_uInt32 nIndex;
nVDCIntegerPrecision = rSource.nVDCIntegerPrecision;
nIntegerPrecision = rSource.nIntegerPrecision;
eRealPrecision = rSource.eRealPrecision;
nRealSize = rSource.nRealSize;
nIndexPrecision = rSource.nIndexPrecision;
nColorPrecision = rSource.nColorPrecision;
nColorIndexPrecision = rSource.nColorIndexPrecision;
nMetaFileVersion = rSource.nMetaFileVersion;
eScalingMode = rSource.eScalingMode;
nScalingFactor = rSource.nScalingFactor;
eVDCType = rSource.eVDCType;
eVDCRealPrecision = rSource.eVDCRealPrecision;
nVDCRealSize = rSource.nVDCRealSize;
aVDCExtent = rSource.aVDCExtent;
aVDCExtentMaximum = rSource.aVDCExtentMaximum;
eDeviceViewPortMode = rSource.eDeviceViewPortMode;
nDeviceViewPortScale = rSource.nDeviceViewPortScale;
eDeviceViewPortMap = rSource.eDeviceViewPortMap;
eDeviceViewPortMapH = rSource.eDeviceViewPortMapH;
eDeviceViewPortMapV = rSource.eDeviceViewPortMapV;
aDeviceViewPort = rSource.aDeviceViewPort;
nMitreLimit = rSource.nMitreLimit;
eClipIndicator = rSource.eClipIndicator;
aClipRect = rSource.aClipRect;
eColorSelectionMode = rSource.eColorSelectionMode;
nColorMaximumIndex = rSource.nColorMaximumIndex;
nLatestColorMaximumIndex = rSource.nLatestColorMaximumIndex;
for ( nIndex = 1; nIndex < 256; nIndex++ ) // do not overwrite the background color
{
aColorTableEntryIs[ nIndex ] = rSource.aColorTableEntryIs[ nIndex ];
aColorTable[ nIndex ] = rSource.aColorTable[ nIndex ];
aLatestColorTable[ nIndex ] = rSource.aColorTable[ nIndex ];
}
for ( nIndex = 0; nIndex < 8; nIndex++ )
{
nColorValueExtent[ nIndex ] = rSource.nColorValueExtent[ nIndex ];
}
nAspectSourceFlags = rSource.nAspectSourceFlags;
CopyAllBundles( rSource.aLineList, aLineList );
aLineBundle = rSource.aLineBundle;
pLineBundle = static_cast<LineBundle*>(GetBundle( aLineList, rSource.pLineBundle->GetIndex() ));
eLineWidthSpecMode = rSource.eLineWidthSpecMode;
eLineCapType = rSource.eLineCapType;
eLineJoinType = rSource.eLineJoinType;
CopyAllBundles( rSource.aMarkerList, aMarkerList );
aMarkerBundle = rSource.aMarkerBundle;
pMarkerBundle = static_cast<MarkerBundle*>(GetBundle( aMarkerList, rSource.pMarkerBundle->GetIndex() ));
eMarkerSizeSpecMode = rSource.eMarkerSizeSpecMode;
CopyAllBundles( rSource.aEdgeList, aEdgeList );
aEdgeBundle = rSource.aEdgeBundle;
pEdgeBundle = static_cast<EdgeBundle*>(GetBundle( aEdgeList, rSource.pEdgeBundle->GetIndex() ));
eEdgeVisibility = rSource.eEdgeVisibility;
eEdgeWidthSpecMode = rSource.eEdgeWidthSpecMode;
CopyAllBundles( rSource.aTextList, aTextList );
aTextBundle = rSource.aTextBundle;
pTextBundle = static_cast<TextBundle*>(GetBundle( aTextList, rSource.pTextBundle->GetIndex() ));
nCharacterHeight = rSource.nCharacterHeight;
nCharacterOrientation[ 0 ] = rSource.nCharacterOrientation[ 0 ];
nCharacterOrientation[ 1 ] = rSource.nCharacterOrientation[ 1 ];
nCharacterOrientation[ 2 ] = rSource.nCharacterOrientation[ 2 ];
nCharacterOrientation[ 3 ] = rSource.nCharacterOrientation[ 3 ];
eUnderlineMode = rSource.eUnderlineMode;
nUnderlineColor = rSource.nUnderlineColor;
eTextPath = rSource.eTextPath;
eTextAlignmentH = rSource.eTextAlignmentH;
eTextAlignmentV = rSource.eTextAlignmentV;
nTextAlignmentHCont = rSource.nTextAlignmentHCont;
nTextAlignmentVCont = rSource.nTextAlignmentVCont;
nCharacterSetIndex = rSource.nCharacterSetIndex;
nAlternateCharacterSetIndex = rSource.nAlternateCharacterSetIndex;
aFontList = rSource.aFontList;
eCharacterCodingA = rSource.eCharacterCodingA;
CopyAllBundles( rSource.aFillList, aFillList );
aFillBundle = rSource.aFillBundle;
pFillBundle = static_cast<FillBundle*>(GetBundle( aFillList, rSource.pFillBundle->GetIndex() ));
aFillRefPoint = rSource.aFillRefPoint;
eTransparency = rSource.eTransparency;
nAuxiliaryColor = rSource.nAuxiliaryColor;
maHatchMap = rSource.maHatchMap;
bSegmentCount = rSource.bSegmentCount;
return *this;
}
void CGMElements::Init()
{
nIntegerPrecision = nIndexPrecision = 2;
nRealSize = nVDCRealSize = 4;
nColorIndexPrecision = 1;
nColorPrecision = 1;
nVDCIntegerPrecision = 2;
eRealPrecision = eVDCRealPrecision = RP_FIXED; //RP_FLOAT;
nMetaFileVersion = 1;
eScalingMode = SM_ABSTRACT;
eVDCType = VDC_INTEGER;
aVDCExtent.Left = aVDCExtent.Bottom = 0;
// aVDCExtent.Right = aVDCExtent.Top = 32767;
aVDCExtent.Right = aVDCExtent.Top = 1.0;
aVDCExtentMaximum.Left = aVDCExtentMaximum.Bottom = 0;
// aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 32767;
aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 1.0;
eDeviceViewPortMode = DVPM_FRACTION;
nDeviceViewPortScale = 1;
eDeviceViewPortMap = DVPM_FORCED;
eDeviceViewPortMapH = DVPMH_LEFT;
eDeviceViewPortMapV = DVPMV_BOTTOM;
aDeviceViewPort.Left = 0;
aDeviceViewPort.Top = 1;
aDeviceViewPort.Right = 0;
aDeviceViewPort.Bottom = 1;
nMitreLimit = 32767;
eClipIndicator = CI_ON;
aClipRect = aVDCExtent;
eColorSelectionMode = CSM_INDEXED;
nColorMaximumIndex = 63;
int i;
for ( i = 0; i < 256; aColorTableEntryIs[ i++ ] = 0 ) ;
aColorTable[ 0 ] = 0;
for ( i = 1; i < 256; aColorTable[ i++ ] = 0xffffff ) ;
nLatestColorMaximumIndex = 63;
aLatestColorTable[ 0 ] = 0;
for ( i = 1; i < 256; aLatestColorTable[ i++ ] = 0xffffff ) ;
nColorValueExtent[ 0 ] = nColorValueExtent[ 1 ] = nColorValueExtent[ 2 ] = 0;
nColorValueExtent[ 3 ] = nColorValueExtent[ 4 ] = nColorValueExtent[ 5 ] = 255;
nAspectSourceFlags = 0; // all flags are individual
eLineWidthSpecMode = SM_SCALED; // line parameter
eLineCapType = LCT_NONE;
eLineJoinType = LJT_NONE;
pLineBundle = &aLineBundle; // line bundle parameter
aLineBundle.SetIndex( 1 );
aLineBundle.eLineType = LT_SOLID;
aLineBundle.nLineWidth = 1;
aLineBundle.SetColor( 0xffffff );
InsertBundle( aLineList, aLineBundle );
eMarkerSizeSpecMode = SM_SCALED; // marker parameter
pMarkerBundle = &aMarkerBundle; // marker bundle parameter
aMarkerBundle.SetIndex( 1 );
aMarkerBundle.eMarkerType = MT_STAR;
aMarkerBundle.nMarkerSize = 1;
aMarkerBundle.SetColor( 0xffffff );
InsertBundle( aMarkerList, aMarkerBundle );
eEdgeVisibility = EV_OFF; // edge parameter
eEdgeWidthSpecMode = SM_SCALED;
pEdgeBundle = &aEdgeBundle; // edge bundle parameter
aEdgeBundle.SetIndex( 1 );
aEdgeBundle.eEdgeType = ET_SOLID;
aEdgeBundle.nEdgeWidth = 1;
aEdgeBundle.SetColor( 0xffffff );
InsertBundle( aEdgeList, aEdgeBundle );
nCharacterHeight = 327; // text parameter
nCharacterOrientation[0] = 0;
nCharacterOrientation[1] = 1;
nCharacterOrientation[2] = 1;
nCharacterOrientation[3] = 0;
eUnderlineMode = UM_OFF;
nUnderlineColor = 0xffffff;
eTextPath = TPR_RIGHT;
eTextAlignmentH = TAH_NORMAL;
eTextAlignmentV = TAV_NORMAL;
nCharacterSetIndex = nAlternateCharacterSetIndex = 1;
eCharacterCodingA = CCA_BASIC_7;
pTextBundle = &aTextBundle; // text bundle parameter
aTextBundle.SetIndex( 1 );
aTextBundle.nTextFontIndex = 1;
aTextBundle.eTextPrecision = TPR_STRING;
aTextBundle.nCharacterExpansion = 1;
aTextBundle.nCharacterSpacing = 0;
aTextBundle.SetColor( 0xffffff );
InsertBundle( aTextList, aTextBundle );
pFillBundle = &aFillBundle; // fill bundle parameter
aFillBundle.SetIndex( 1 );
aFillBundle.eFillInteriorStyle = FIS_HOLLOW;
aFillBundle.nFillHatchIndex = 1;
aFillBundle.nFillPatternIndex = 1;
aFillBundle.SetColor( 0xffffff );
InsertBundle( aFillList, aFillBundle );
ImplInsertHatch( 0, 0, 0, 0 );
ImplInsertHatch( 1, 0, 125, 0 );
ImplInsertHatch( 2, 0, 125, 900 );
ImplInsertHatch( 3, 0, 125, 450 );
ImplInsertHatch( 4, 0, 125, 1350 );
ImplInsertHatch( 5, 1, 125, 0 );
ImplInsertHatch( 6, 1, 125, 450 );
ImplInsertHatch( -1, 0, 75, 0 );
ImplInsertHatch( -2, 0, 75, 900 );
ImplInsertHatch( -3, 0, 75, 450 );
ImplInsertHatch( -4, 0, 75, 1350 );
ImplInsertHatch( -5, 1, 75, 0 );
ImplInsertHatch( -6, 1, 75, 450 );
ImplInsertHatch( -7, 2, 125, 0 );
ImplInsertHatch( -8, 2, 125, 900 );
ImplInsertHatch( -9, 2, 125, 450 );
ImplInsertHatch( -10, 2, 125, 1350 );
ImplInsertHatch( -11, 0, 40, 0 );
ImplInsertHatch( -12, 0, 40, 900 );
ImplInsertHatch( -13, 0, 40, 450 );
ImplInsertHatch( -14, 0, 40, 1350 );
ImplInsertHatch( -15, 1, 40, 0 );
ImplInsertHatch( -16, 1, 40, 900 );
ImplInsertHatch( -21, 0, 250, 0 );
ImplInsertHatch( -22, 0, 250, 900 );
ImplInsertHatch( -23, 0, 250, 450 );
ImplInsertHatch( -24, 0, 250, 1350 );
ImplInsertHatch( -25, 1, 250, 0 );
ImplInsertHatch( -26, 1, 250, 450 );
eTransparency = T_ON;
nBackGroundColor = nAuxiliaryColor = 0;
bSegmentCount = false;
nScalingFactor = 1.0;
nTextAlignmentVCont = nTextAlignmentHCont = 0.0;
}
void CGMElements::ImplInsertHatch( sal_Int32 nKey, int nStyle, tools::Long nDistance, tools::Long nAngle )
{
HatchEntry& rEntry = maHatchMap[nKey];
rEntry.HatchStyle = nStyle;
rEntry.HatchDistance = nDistance;
rEntry.HatchAngle = nAngle;
}
void CGMElements::CopyAllBundles( const BundleList& rSource, BundleList& rDest )
{
rDest.clear();
for (auto & pPtr : rSource)
{
rDest.push_back( pPtr->Clone() );
}
};
Bundle* CGMElements::GetBundleIndex( tools::Long nIndex, BundleList& rList, Bundle& rBundle )
{
rBundle.SetIndex( nIndex );
Bundle* pBundle = GetBundle( rList, nIndex );
if ( !pBundle )
pBundle = InsertBundle( rList, rBundle );
return pBundle;
}
Bundle* CGMElements::GetBundle( BundleList& rList, tools::Long nIndex )
{
for (auto const & i : rList) {
if ( i->GetIndex() == nIndex ) {
return i.get();
}
}
return nullptr;
}
Bundle* CGMElements::InsertBundle( BundleList& rList, Bundle& rBundle )
{
Bundle* pBundle = GetBundle( rList, rBundle.GetIndex() );
if ( pBundle )
{
auto it = std::find_if(rList.begin(), rList.end(),
[&pBundle](const std::unique_ptr<Bundle>& rxBundle) { return rxBundle.get() == pBundle; });
if (it != rList.end())
rList.erase( it );
}
rList.push_back( rBundle.Clone() );
return rList.back().get();
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|