tdf#164420 Fix unselected Check/Radio buttons not following themes in GTK
[LibreOffice.git] / filter / source / graphicfilter / icgm / elements.cxx
blob9a0221066fec2151ba0092d2dac9ff9a4cfe58c6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #include <algorithm>
25 CGMElements::CGMElements()
27 Init();
31 CGMElements::~CGMElements()
36 CGMElements& CGMElements::operator=( const CGMElements& rSource )
38 if (this == &rSource)
39 return *this;
41 sal_uInt32 nIndex;
43 nVDCIntegerPrecision = rSource.nVDCIntegerPrecision;
44 nIntegerPrecision = rSource.nIntegerPrecision;
45 eRealPrecision = rSource.eRealPrecision;
46 nRealSize = rSource.nRealSize;
47 nIndexPrecision = rSource.nIndexPrecision;
48 nColorPrecision = rSource.nColorPrecision;
49 nColorIndexPrecision = rSource.nColorIndexPrecision;
51 nMetaFileVersion = rSource.nMetaFileVersion;
52 eScalingMode = rSource.eScalingMode;
53 nScalingFactor = rSource.nScalingFactor;
54 eVDCType = rSource.eVDCType;
55 eVDCRealPrecision = rSource.eVDCRealPrecision;
56 nVDCRealSize = rSource.nVDCRealSize;
57 aVDCExtent = rSource.aVDCExtent;
58 aVDCExtentMaximum = rSource.aVDCExtentMaximum;
59 eDeviceViewPortMode = rSource.eDeviceViewPortMode;
60 nDeviceViewPortScale = rSource.nDeviceViewPortScale;
61 eDeviceViewPortMap = rSource.eDeviceViewPortMap;
62 eDeviceViewPortMapH = rSource.eDeviceViewPortMapH;
63 eDeviceViewPortMapV = rSource.eDeviceViewPortMapV;
64 aDeviceViewPort = rSource.aDeviceViewPort;
65 nMitreLimit = rSource.nMitreLimit;
66 eClipIndicator = rSource.eClipIndicator;
67 aClipRect = rSource.aClipRect;
68 eColorSelectionMode = rSource.eColorSelectionMode;
69 nColorMaximumIndex = rSource.nColorMaximumIndex;
70 nLatestColorMaximumIndex = rSource.nLatestColorMaximumIndex;
72 for ( nIndex = 1; nIndex < 256; nIndex++ ) // do not overwrite the background color
74 aColorTableEntryIs[ nIndex ] = rSource.aColorTableEntryIs[ nIndex ];
75 aColorTable[ nIndex ] = rSource.aColorTable[ nIndex ];
76 aLatestColorTable[ nIndex ] = rSource.aColorTable[ nIndex ];
79 for ( nIndex = 0; nIndex < 8; nIndex++ )
81 nColorValueExtent[ nIndex ] = rSource.nColorValueExtent[ nIndex ];
83 nAspectSourceFlags = rSource.nAspectSourceFlags;
85 CopyAllBundles( rSource.aLineList, aLineList );
86 aLineBundle = rSource.aLineBundle;
87 pLineBundle = static_cast<LineBundle*>(GetBundle( aLineList, rSource.pLineBundle->GetIndex() ));
88 eLineWidthSpecMode = rSource.eLineWidthSpecMode;
89 eLineCapType = rSource.eLineCapType;
90 eLineJoinType = rSource.eLineJoinType;
92 CopyAllBundles( rSource.aMarkerList, aMarkerList );
93 aMarkerBundle = rSource.aMarkerBundle;
94 pMarkerBundle = static_cast<MarkerBundle*>(GetBundle( aMarkerList, rSource.pMarkerBundle->GetIndex() ));
95 eMarkerSizeSpecMode = rSource.eMarkerSizeSpecMode;
97 CopyAllBundles( rSource.aEdgeList, aEdgeList );
98 aEdgeBundle = rSource.aEdgeBundle;
99 pEdgeBundle = static_cast<EdgeBundle*>(GetBundle( aEdgeList, rSource.pEdgeBundle->GetIndex() ));
100 eEdgeVisibility = rSource.eEdgeVisibility;
101 eEdgeWidthSpecMode = rSource.eEdgeWidthSpecMode;
103 CopyAllBundles( rSource.aTextList, aTextList );
104 aTextBundle = rSource.aTextBundle;
105 pTextBundle = static_cast<TextBundle*>(GetBundle( aTextList, rSource.pTextBundle->GetIndex() ));
106 nCharacterHeight = rSource.nCharacterHeight;
107 nCharacterOrientation[ 0 ] = rSource.nCharacterOrientation[ 0 ];
108 nCharacterOrientation[ 1 ] = rSource.nCharacterOrientation[ 1 ];
109 nCharacterOrientation[ 2 ] = rSource.nCharacterOrientation[ 2 ];
110 nCharacterOrientation[ 3 ] = rSource.nCharacterOrientation[ 3 ];
111 eUnderlineMode = rSource.eUnderlineMode;
112 nUnderlineColor = rSource.nUnderlineColor;
113 eTextPath = rSource.eTextPath;
114 eTextAlignmentH = rSource.eTextAlignmentH;
115 eTextAlignmentV = rSource.eTextAlignmentV;
116 nTextAlignmentHCont = rSource.nTextAlignmentHCont;
117 nTextAlignmentVCont = rSource.nTextAlignmentVCont;
118 nCharacterSetIndex = rSource.nCharacterSetIndex;
119 nAlternateCharacterSetIndex = rSource.nAlternateCharacterSetIndex;
120 aFontList = rSource.aFontList;
121 eCharacterCodingA = rSource.eCharacterCodingA;
123 CopyAllBundles( rSource.aFillList, aFillList );
124 aFillBundle = rSource.aFillBundle;
125 pFillBundle = static_cast<FillBundle*>(GetBundle( aFillList, rSource.pFillBundle->GetIndex() ));
126 aFillRefPoint = rSource.aFillRefPoint;
127 eTransparency = rSource.eTransparency;
128 nAuxiliaryColor = rSource.nAuxiliaryColor;
130 maHatchMap = rSource.maHatchMap;
131 bSegmentCount = rSource.bSegmentCount;
132 return *this;
136 void CGMElements::Init()
139 nIntegerPrecision = nIndexPrecision = 2;
140 nRealSize = nVDCRealSize = 4;
141 nColorIndexPrecision = 1;
142 nColorPrecision = 1;
143 nVDCIntegerPrecision = 2;
144 eRealPrecision = eVDCRealPrecision = RP_FIXED; //RP_FLOAT;
146 nMetaFileVersion = 1;
147 eScalingMode = SM_ABSTRACT;
148 eVDCType = VDC_INTEGER;
149 aVDCExtent.Left = aVDCExtent.Bottom = 0;
150 // aVDCExtent.Right = aVDCExtent.Top = 32767;
151 aVDCExtent.Right = aVDCExtent.Top = 1.0;
152 aVDCExtentMaximum.Left = aVDCExtentMaximum.Bottom = 0;
153 // aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 32767;
154 aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 1.0;
156 eDeviceViewPortMode = DVPM_FRACTION;
157 nDeviceViewPortScale = 1;
158 eDeviceViewPortMap = DVPM_FORCED;
159 eDeviceViewPortMapH = DVPMH_LEFT;
160 eDeviceViewPortMapV = DVPMV_BOTTOM;
161 aDeviceViewPort.Left = 0;
162 aDeviceViewPort.Top = 1;
163 aDeviceViewPort.Right = 0;
164 aDeviceViewPort.Bottom = 1;
166 nMitreLimit = 32767;
167 eClipIndicator = CI_ON;
168 aClipRect = aVDCExtent;
170 eColorSelectionMode = CSM_INDEXED;
171 nColorMaximumIndex = 63;
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 ) ;
176 nLatestColorMaximumIndex = 63;
177 aLatestColorTable[ 0 ] = 0;
178 for ( i = 1; i < 256; aLatestColorTable[ i++ ] = 0xffffff ) ;
179 nColorValueExtent[ 0 ] = nColorValueExtent[ 1 ] = nColorValueExtent[ 2 ] = 0;
180 nColorValueExtent[ 3 ] = nColorValueExtent[ 4 ] = nColorValueExtent[ 5 ] = 255;
182 nAspectSourceFlags = 0; // all flags are individual
184 eLineWidthSpecMode = SM_SCALED; // line parameter
185 eLineCapType = LCT_NONE;
186 eLineJoinType = LJT_NONE;
187 pLineBundle = &aLineBundle; // line bundle parameter
188 aLineBundle.SetIndex( 1 );
189 aLineBundle.eLineType = LT_SOLID;
190 aLineBundle.nLineWidth = 1;
191 aLineBundle.SetColor( 0xffffff );
192 InsertBundle( aLineList, aLineBundle );
194 eMarkerSizeSpecMode = SM_SCALED; // marker parameter
195 pMarkerBundle = &aMarkerBundle; // marker bundle parameter
196 aMarkerBundle.SetIndex( 1 );
197 aMarkerBundle.eMarkerType = MT_STAR;
198 aMarkerBundle.nMarkerSize = 1;
199 aMarkerBundle.SetColor( 0xffffff );
200 InsertBundle( aMarkerList, aMarkerBundle );
202 eEdgeVisibility = EV_OFF; // edge parameter
203 eEdgeWidthSpecMode = SM_SCALED;
204 pEdgeBundle = &aEdgeBundle; // edge bundle parameter
205 aEdgeBundle.SetIndex( 1 );
206 aEdgeBundle.eEdgeType = ET_SOLID;
207 aEdgeBundle.nEdgeWidth = 1;
208 aEdgeBundle.SetColor( 0xffffff );
209 InsertBundle( aEdgeList, aEdgeBundle );
211 nCharacterHeight = 327; // text parameter
212 nCharacterOrientation[0] = 0;
213 nCharacterOrientation[1] = 1;
214 nCharacterOrientation[2] = 1;
215 nCharacterOrientation[3] = 0;
216 eUnderlineMode = UM_OFF;
217 nUnderlineColor = 0xffffff;
218 eTextPath = TPR_RIGHT;
219 eTextAlignmentH = TAH_NORMAL;
220 eTextAlignmentV = TAV_NORMAL;
221 nCharacterSetIndex = nAlternateCharacterSetIndex = 1;
222 eCharacterCodingA = CCA_BASIC_7;
223 pTextBundle = &aTextBundle; // text bundle parameter
224 aTextBundle.SetIndex( 1 );
225 aTextBundle.nTextFontIndex = 1;
226 aTextBundle.eTextPrecision = TPR_STRING;
227 aTextBundle.nCharacterExpansion = 1;
228 aTextBundle.nCharacterSpacing = 0;
229 aTextBundle.SetColor( 0xffffff );
230 InsertBundle( aTextList, aTextBundle );
232 pFillBundle = &aFillBundle; // fill bundle parameter
233 aFillBundle.SetIndex( 1 );
234 aFillBundle.eFillInteriorStyle = FIS_HOLLOW;
235 aFillBundle.nFillHatchIndex = 1;
236 aFillBundle.nFillPatternIndex = 1;
237 aFillBundle.SetColor( 0xffffff );
238 InsertBundle( aFillList, aFillBundle );
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 );
270 eTransparency = T_ON;
272 nBackGroundColor = nAuxiliaryColor = 0;
274 bSegmentCount = false;
276 nScalingFactor = 1.0;
277 nTextAlignmentVCont = nTextAlignmentHCont = 0.0;
281 void CGMElements::ImplInsertHatch( sal_Int32 nKey, int nStyle, tools::Long nDistance, tools::Long nAngle )
283 HatchEntry& rEntry = maHatchMap[nKey];
284 rEntry.HatchStyle = nStyle;
285 rEntry.HatchDistance = nDistance;
286 rEntry.HatchAngle = nAngle;
290 void CGMElements::CopyAllBundles( const BundleList& rSource, BundleList& rDest )
292 rDest.clear();
294 for (auto & pPtr : rSource)
296 rDest.push_back( pPtr->Clone() );
301 Bundle* CGMElements::GetBundleIndex( tools::Long nIndex, BundleList& rList, Bundle& rBundle )
303 rBundle.SetIndex( nIndex );
304 Bundle* pBundle = GetBundle( rList, nIndex );
305 if ( !pBundle )
306 pBundle = InsertBundle( rList, rBundle );
307 return pBundle;
311 Bundle* CGMElements::GetBundle( BundleList& rList, tools::Long nIndex )
313 for (auto const & i : rList) {
314 if ( i->GetIndex() == nIndex ) {
315 return i.get();
318 return nullptr;
322 Bundle* CGMElements::InsertBundle( BundleList& rList, Bundle& rBundle )
324 Bundle* pBundle = GetBundle( rList, rBundle.GetIndex() );
325 if ( pBundle )
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 );
332 rList.push_back( rBundle.Clone() );
333 return rList.back().get();
336 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */