LibreOffice Module filter (master) 1
elements.cxx
Go to the documentation of this file.
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#include <algorithm>
24
26{
27 Init();
28};
29
30
32{
33}
34
35
37{
38 if (this == &rSource)
39 return *this;
40
41 sal_uInt32 nIndex;
42
46 nRealSize = rSource.nRealSize;
50
52 eScalingMode = rSource.eScalingMode;
54 eVDCType = rSource.eVDCType;
56 nVDCRealSize = rSource.nVDCRealSize;
57 aVDCExtent = rSource.aVDCExtent;
65 nMitreLimit = rSource.nMitreLimit;
67 aClipRect = rSource.aClipRect;
71
72 for ( nIndex = 1; nIndex < 256; nIndex++ ) // do not overwrite the background color
73 {
75 aColorTable[ nIndex ] = rSource.aColorTable[ nIndex ];
77 }
78
79 for ( nIndex = 0; nIndex < 8; nIndex++ )
80 {
82 }
84
86 aLineBundle = rSource.aLineBundle;
87 pLineBundle = static_cast<LineBundle*>(GetBundle( aLineList, rSource.pLineBundle->GetIndex() ));
89 eLineCapType = rSource.eLineCapType;
91
96
98 aEdgeBundle = rSource.aEdgeBundle;
99 pEdgeBundle = static_cast<EdgeBundle*>(GetBundle( aEdgeList, rSource.pEdgeBundle->GetIndex() ));
102
104 aTextBundle = rSource.aTextBundle;
105 pTextBundle = static_cast<TextBundle*>(GetBundle( aTextList, rSource.pTextBundle->GetIndex() ));
113 eTextPath = rSource.eTextPath;
120 aFontList = rSource.aFontList;
122
124 aFillBundle = rSource.aFillBundle;
125 pFillBundle = static_cast<FillBundle*>(GetBundle( aFillList, rSource.pFillBundle->GetIndex() ));
129
130 maHatchMap = rSource.maHatchMap;
132 return *this;
133}
134
135
137{
138
142 nColorPrecision = 1;
145
150// aVDCExtent.Right = aVDCExtent.Top = 32767;
153// aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 32767;
155
165
166 nMitreLimit = 32767;
169
172 int i;
173 for ( i = 0; i < 256; aColorTableEntryIs[ i++ ] = 0 ) ;
174 aColorTable[ 0 ] = 0;
175 for ( i = 1; i < 256; aColorTable[ i++ ] = 0xffffff ) ;
177 aLatestColorTable[ 0 ] = 0;
178 for ( i = 1; i < 256; aLatestColorTable[ i++ ] = 0xffffff ) ;
181
182 nAspectSourceFlags = 0; // all flags are individual
183
184 eLineWidthSpecMode = SM_SCALED; // line parameter
187 pLineBundle = &aLineBundle; // line bundle parameter
191 aLineBundle.SetColor( 0xffffff );
193
194 eMarkerSizeSpecMode = SM_SCALED; // marker parameter
195 pMarkerBundle = &aMarkerBundle; // marker bundle parameter
199 aMarkerBundle.SetColor( 0xffffff );
201
202 eEdgeVisibility = EV_OFF; // edge parameter
204 pEdgeBundle = &aEdgeBundle; // edge bundle parameter
208 aEdgeBundle.SetColor( 0xffffff );
210
211 nCharacterHeight = 327; // text parameter
217 nUnderlineColor = 0xffffff;
223 pTextBundle = &aTextBundle; // text bundle parameter
229 aTextBundle.SetColor( 0xffffff );
231
232 pFillBundle = &aFillBundle; // fill bundle parameter
237 aFillBundle.SetColor( 0xffffff );
239
240 ImplInsertHatch( 0, 0, 0, 0 );
241 ImplInsertHatch( 1, 0, 125, 0 );
242 ImplInsertHatch( 2, 0, 125, 900 );
243 ImplInsertHatch( 3, 0, 125, 450 );
244 ImplInsertHatch( 4, 0, 125, 1350 );
245 ImplInsertHatch( 5, 1, 125, 0 );
246 ImplInsertHatch( 6, 1, 125, 450 );
247 ImplInsertHatch( -1, 0, 75, 0 );
248 ImplInsertHatch( -2, 0, 75, 900 );
249 ImplInsertHatch( -3, 0, 75, 450 );
250 ImplInsertHatch( -4, 0, 75, 1350 );
251 ImplInsertHatch( -5, 1, 75, 0 );
252 ImplInsertHatch( -6, 1, 75, 450 );
253 ImplInsertHatch( -7, 2, 125, 0 );
254 ImplInsertHatch( -8, 2, 125, 900 );
255 ImplInsertHatch( -9, 2, 125, 450 );
256 ImplInsertHatch( -10, 2, 125, 1350 );
257 ImplInsertHatch( -11, 0, 40, 0 );
258 ImplInsertHatch( -12, 0, 40, 900 );
259 ImplInsertHatch( -13, 0, 40, 450 );
260 ImplInsertHatch( -14, 0, 40, 1350 );
261 ImplInsertHatch( -15, 1, 40, 0 );
262 ImplInsertHatch( -16, 1, 40, 900 );
263 ImplInsertHatch( -21, 0, 250, 0 );
264 ImplInsertHatch( -22, 0, 250, 900 );
265 ImplInsertHatch( -23, 0, 250, 450 );
266 ImplInsertHatch( -24, 0, 250, 1350 );
267 ImplInsertHatch( -25, 1, 250, 0 );
268 ImplInsertHatch( -26, 1, 250, 450 );
269
271
273
274 bSegmentCount = false;
275
276 nScalingFactor = 1.0;
278}
279
280
281void CGMElements::ImplInsertHatch( sal_Int32 nKey, int nStyle, tools::Long nDistance, tools::Long nAngle )
282{
283 HatchEntry& rEntry = maHatchMap[nKey];
284 rEntry.HatchStyle = nStyle;
285 rEntry.HatchDistance = nDistance;
286 rEntry.HatchAngle = nAngle;
287}
288
289
291{
292 rDest.clear();
293
294 for (auto & pPtr : rSource)
295 {
296 rDest.push_back( pPtr->Clone() );
297 }
298};
299
300
302{
303 rBundle.SetIndex( nIndex );
304 Bundle* pBundle = GetBundle( rList, nIndex );
305 if ( !pBundle )
306 pBundle = InsertBundle( rList, rBundle );
307 return pBundle;
308}
309
310
312{
313 for (auto const & i : rList) {
314 if ( i->GetIndex() == nIndex ) {
315 return i.get();
316 }
317 }
318 return nullptr;
319}
320
321
323{
324 Bundle* pBundle = GetBundle( rList, rBundle.GetIndex() );
325 if ( pBundle )
326 {
327 auto it = std::find_if(rList.begin(), rList.end(),
328 [&pBundle](const std::unique_ptr<Bundle>& rxBundle) { return rxBundle.get() == pBundle; });
329 if (it != rList.end())
330 rList.erase( it );
331 }
332 rList.push_back( rBundle.Clone() );
333 return rList.back().get();
334};
335
336/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ SM_SCALED
Definition: cgmtypes.hxx:110
@ T_ON
Definition: cgmtypes.hxx:121
@ LCT_NONE
Definition: cgmtypes.hxx:111
@ DVPM_FRACTION
Definition: cgmtypes.hxx:90
@ TPR_STRING
Definition: cgmtypes.hxx:101
@ ET_SOLID
Definition: cgmtypes.hxx:115
@ EV_OFF
Definition: cgmtypes.hxx:117
@ DVPM_FORCED
Definition: cgmtypes.hxx:91
@ LJT_NONE
Definition: cgmtypes.hxx:112
@ CCA_BASIC_7
Definition: cgmtypes.hxx:100
@ TPR_RIGHT
Definition: cgmtypes.hxx:102
@ SM_ABSTRACT
Definition: cgmtypes.hxx:87
@ TAH_NORMAL
Definition: cgmtypes.hxx:103
@ TAV_NORMAL
Definition: cgmtypes.hxx:104
@ FIS_HOLLOW
Definition: cgmtypes.hxx:123
@ DVPMH_LEFT
Definition: cgmtypes.hxx:92
@ UM_OFF
Definition: cgmtypes.hxx:105
@ MT_STAR
Definition: cgmtypes.hxx:119
@ CSM_INDEXED
Definition: cgmtypes.hxx:97
@ DVPMV_BOTTOM
Definition: cgmtypes.hxx:93
@ VDC_INTEGER
Definition: cgmtypes.hxx:89
@ CI_ON
Definition: cgmtypes.hxx:95
@ LT_SOLID
Definition: cgmtypes.hxx:108
@ RP_FIXED
Definition: cgmtypes.hxx:85
virtual std::unique_ptr< Bundle > Clone()
Definition: bundles.hxx:45
tools::Long GetIndex() const
Definition: bundles.hxx:37
void SetIndex(tools::Long nBundleIndex)
Definition: bundles.hxx:38
void SetColor(sal_uInt32 nColor)
Definition: bundles.cxx:25
BundleList aFillList
Definition: elements.hxx:114
TextAlignmentV eTextAlignmentV
Definition: elements.hxx:104
sal_uInt32 nIntegerPrecision
Definition: elements.hxx:36
sal_uInt32 nColorIndexPrecision
Definition: elements.hxx:41
static Bundle * GetBundleIndex(tools::Long nIndex, BundleList &, Bundle &)
Definition: elements.cxx:301
SpecMode eLineWidthSpecMode
Definition: elements.hxx:80
RealPrecision eVDCRealPrecision
Definition: elements.hxx:48
DeviceViewPortMapV eDeviceViewPortMapV
Definition: elements.hxx:57
sal_uInt32 nAspectSourceFlags
Definition: elements.hxx:74
double nCharacterOrientation[4]
Definition: elements.hxx:99
void Init()
Definition: elements.cxx:136
tools::Long nCharacterSetIndex
Definition: elements.hxx:107
LineBundle aLineBundle
Definition: elements.hxx:78
::std::map< sal_uInt32, HatchEntry > maHatchMap
Definition: elements.hxx:117
TextAlignmentH eTextAlignmentH
Definition: elements.hxx:103
FillBundle aFillBundle
Definition: elements.hxx:113
EdgeBundle aEdgeBundle
Definition: elements.hxx:90
CGMFList aFontList
Definition: elements.hxx:110
MarkerBundle aMarkerBundle
Definition: elements.hxx:85
static Bundle * GetBundle(BundleList &rList, tools::Long nIndex)
Definition: elements.cxx:311
MarkerBundle * pMarkerBundle
Definition: elements.hxx:84
sal_uInt32 nColorMaximumIndex
Definition: elements.hxx:66
sal_uInt32 nRealSize
Definition: elements.hxx:39
BundleList aTextList
Definition: elements.hxx:97
DeviceViewPortMapH eDeviceViewPortMapH
Definition: elements.hxx:56
sal_uInt32 nIndexPrecision
Definition: elements.hxx:37
UnderlineMode eUnderlineMode
Definition: elements.hxx:100
sal_uInt32 nUnderlineColor
Definition: elements.hxx:101
FloatPoint aFillRefPoint
Definition: elements.hxx:115
BundleList aEdgeList
Definition: elements.hxx:91
FloatRect aVDCExtent
Definition: elements.hxx:50
LineJoinType eLineJoinType
Definition: elements.hxx:82
sal_uInt32 nVDCRealSize
Definition: elements.hxx:49
CharacterCodingA eCharacterCodingA
Definition: elements.hxx:109
BundleList aLineList
Definition: elements.hxx:79
sal_uInt32 nColorPrecision
Definition: elements.hxx:40
void ImplInsertHatch(sal_Int32 Key, int Style, tools::Long Distance, tools::Long Angle)
Definition: elements.cxx:281
sal_uInt32 nLatestColorMaximumIndex
Definition: elements.hxx:67
sal_uInt32 nAuxiliaryColor
Definition: elements.hxx:121
FloatRect aDeviceViewPort
Definition: elements.hxx:58
CGMElements & operator=(const CGMElements &)
Definition: elements.cxx:36
static Bundle * InsertBundle(BundleList &, Bundle &)
Definition: elements.cxx:322
BundleList aMarkerList
Definition: elements.hxx:86
FloatRect aVDCExtentMaximum
Definition: elements.hxx:51
double nScalingFactor
Definition: elements.hxx:44
EdgeVisibility eEdgeVisibility
Definition: elements.hxx:92
double nTextAlignmentHCont
Definition: elements.hxx:105
sal_uInt32 nVDCIntegerPrecision
Definition: elements.hxx:47
tools::Long nAlternateCharacterSetIndex
Definition: elements.hxx:108
LineCapType eLineCapType
Definition: elements.hxx:81
LineBundle * pLineBundle
Definition: elements.hxx:77
sal_Int8 aColorTableEntryIs[256]
Definition: elements.hxx:68
sal_uInt32 nColorValueExtent[8]
Definition: elements.hxx:71
FloatRect aClipRect
Definition: elements.hxx:63
bool bSegmentCount
Definition: elements.hxx:125
double nTextAlignmentVCont
Definition: elements.hxx:106
sal_uInt32 aLatestColorTable[256]
Definition: elements.hxx:70
VDCType eVDCType
Definition: elements.hxx:46
double nDeviceViewPortScale
Definition: elements.hxx:54
DeviceViewPortMap eDeviceViewPortMap
Definition: elements.hxx:55
Transparency eTransparency
Definition: elements.hxx:119
TextBundle aTextBundle
Definition: elements.hxx:96
FillBundle * pFillBundle
Definition: elements.hxx:112
SpecMode eEdgeWidthSpecMode
Definition: elements.hxx:93
DeviceViewPortMode eDeviceViewPortMode
Definition: elements.hxx:53
SpecMode eMarkerSizeSpecMode
Definition: elements.hxx:87
sal_uInt32 aColorTable[256]
Definition: elements.hxx:69
RealPrecision eRealPrecision
Definition: elements.hxx:38
TextBundle * pTextBundle
Definition: elements.hxx:95
EdgeBundle * pEdgeBundle
Definition: elements.hxx:89
double nMitreLimit
Definition: elements.hxx:60
static void CopyAllBundles(const BundleList &Source, BundleList &Dest)
Definition: elements.cxx:290
double nCharacterHeight
Definition: elements.hxx:98
TextPath eTextPath
Definition: elements.hxx:102
ScalingMode eScalingMode
Definition: elements.hxx:43
ColorSelectionMode eColorSelectionMode
Definition: elements.hxx:65
ClipIndicator eClipIndicator
Definition: elements.hxx:62
tools::Long nMetaFileVersion
Definition: elements.hxx:34
EdgeType eEdgeType
Definition: bundles.hxx:92
double nEdgeWidth
Definition: bundles.hxx:93
FillInteriorStyle eFillInteriorStyle
Definition: bundles.hxx:127
tools::Long nFillPatternIndex
Definition: bundles.hxx:128
tools::Long nFillHatchIndex
Definition: bundles.hxx:129
double nLineWidth
Definition: bundles.hxx:61
LineType eLineType
Definition: bundles.hxx:60
MarkerType eMarkerType
Definition: bundles.hxx:76
double nMarkerSize
Definition: bundles.hxx:77
double nCharacterExpansion
Definition: bundles.hxx:109
double nCharacterSpacing
Definition: bundles.hxx:110
sal_uInt32 nTextFontIndex
Definition: bundles.hxx:107
TextPrecision eTextPrecision
Definition: bundles.hxx:108
::std::vector< std::unique_ptr< Bundle > > BundleList
Definition: elements.hxx:28
#define nBackGroundColor
Definition: elements.hxx:26
sal_Int32 nIndex
int i
Definition: gentoken.py:48
long Long
double Left
Definition: cgmtypes.hxx:33
double Right
Definition: cgmtypes.hxx:35
double Bottom
Definition: cgmtypes.hxx:36
double Top
Definition: cgmtypes.hxx:34
tools::Long HatchAngle
Definition: cgmtypes.hxx:60
int HatchStyle
Definition: cgmtypes.hxx:58
tools::Long HatchDistance
Definition: cgmtypes.hxx:59