LibreOffice Module filter (master) 1
class2.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#include "cgm.hxx"
21#include "bundles.hxx"
22#include "elements.hxx"
23
24
26{
27 sal_uInt32 nUInteger;
28 switch ( mnElementID )
29 {
30 case 0x01 : /*Scaling Mode*/
31 {
32 if ( mnElementSize ) // HACK (NASA.CGM)
33 {
34 switch( ImplGetUI16() )
35 {
36 case 0 : pElement->eScalingMode = SM_ABSTRACT; break;
37 case 1 : pElement->eScalingMode = SM_METRIC; break;
38 default : mbStatus = false; break;
39 }
40 pElement->nScalingFactor = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
42 }
43 }
44 break;
45 case 0x02 : /*Color Selection Mode*/
46 {
47 nUInteger = ImplGetUI16();
48 switch( nUInteger )
49 {
50 case 0 : pElement->eColorSelectionMode = CSM_INDEXED; break;
51 case 1 : pElement->eColorSelectionMode = CSM_DIRECT; break;
52 default : mbStatus = false; break;
53 }
54 }
55 break;
56 case 0x03 : /*Line Width Specification Mode*/
57 {
58 nUInteger = ImplGetUI16();
59 switch( nUInteger )
60 {
61 case 0 : pElement->eLineWidthSpecMode = SM_ABSOLUTE; break;
62 case 1 : pElement->eLineWidthSpecMode = SM_SCALED; break;
63 default : mbStatus = false; break;
64 }
65 }
66 break;
67 case 0x04 : /*Marker Size Specification Mode*/
68 {
69 nUInteger = ImplGetUI16();
70 switch( nUInteger )
71 {
72 case 0 : pElement->eMarkerSizeSpecMode = SM_ABSOLUTE; break;
73 case 1 : pElement->eMarkerSizeSpecMode = SM_SCALED; break;
74 default : mbStatus = false; break;
75 }
76 }
77 break;
78 case 0x05 : /*Edge Width Specification Mode*/
79 {
80 nUInteger = ImplGetUI16();
81 switch( nUInteger )
82 {
83 case 0 : pElement->eEdgeWidthSpecMode = SM_ABSOLUTE; break;
84 case 1 : pElement->eEdgeWidthSpecMode = SM_SCALED; break;
85 default : mbStatus = false; break;
86 }
87 }
88 break;
89 case 0x06 : /*VDC Extent*/
90 {
91 ImplGetRectangleNS( pElement->aVDCExtent );
93 }
94 break;
95 case 0x07 : /*Background Color*/
96 pElement->nBackGroundColor = ImplGetBitmapColor( true );
97 break;
98 case 0x08 : /*Device Viewport*/
99 {
100 if ( pElement->eVDCType == VDC_INTEGER )
101 ImplGetRectangle( pElement->aDeviceViewPort );
103 }
104 break;
105 case 0x09 : /*Device Viewport Specification Mode*/
106 {
107 nUInteger = ImplGetUI16();
108 switch( nUInteger )
109 {
110 case 0 : pElement->eDeviceViewPortMode = DVPM_FRACTION; break;
111 case 1 : pElement->eDeviceViewPortMode = DVPM_METRIC; break;
112 case 2 : pElement->eDeviceViewPortMode = DVPM_DEVICE; break;
113 default : mbStatus = false; break;
114 }
115 pElement->nDeviceViewPortScale = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
117 }
118 break;
119 case 0x0a : /*Device Viewport Mapping*/
120 {
121 switch( ImplGetUI16() )
122 {
123 case 0 : pElement->eDeviceViewPortMap = DVPM_NOT_FORCED; break;
124 case 1 : pElement->eDeviceViewPortMap = DVPM_FORCED; break;
125 default : mbStatus = false; break;
126 }
127 switch( ImplGetUI16() )
128 {
129 case 0 : pElement->eDeviceViewPortMapH = DVPMH_LEFT; break;
130 case 1 : pElement->eDeviceViewPortMapH = DVPMH_CENTER; break;
131 case 2 : pElement->eDeviceViewPortMapH = CVPMH_RIGHT; break;
132 default : mbStatus = false; break;
133 }
134 switch( ImplGetUI16() )
135 {
136 case 0 : pElement->eDeviceViewPortMapV = DVPMV_BOTTOM; break;
137 case 1 : pElement->eDeviceViewPortMapV = DVPMV_CENTER; break;
138 case 2 : pElement->eDeviceViewPortMapV = DVPMV_TOP; break;
139 default : mbStatus = false; break;
140 }
142 }
143 break;
144 case 0x0b : /*Line Representation*/
145 {
146 LineBundle aTempLineBundle;
147 aTempLineBundle.SetIndex( ImplGetI( pElement->nIndexPrecision ) );
148 aTempLineBundle.eLineType = static_cast<LineType>(ImplGetI( pElement->nIndexPrecision ));
149 aTempLineBundle.nLineWidth = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
150 aTempLineBundle.SetColor( ImplGetBitmapColor() );
151 const bool bUpdateLineBundle = aTempLineBundle.GetIndex() == pElement->pLineBundle->GetIndex();
152 CGMElements::InsertBundle( pElement->aLineList, aTempLineBundle );
153 if (bUpdateLineBundle)
154 pElement->pLineBundle = static_cast<LineBundle*>(CGMElements::GetBundleIndex(aTempLineBundle.GetIndex(), pElement->aLineList, pElement->aLineBundle));
155 }
156 break;
157 case 0x0c : /*Marker Representation*/
158 {
159 MarkerBundle aTempMarkerBundle;
160 aTempMarkerBundle.SetIndex( ImplGetI( pElement->nIndexPrecision ) );
161 aTempMarkerBundle.eMarkerType = static_cast<MarkerType>(ImplGetI( pElement->nIndexPrecision ));
162 aTempMarkerBundle.nMarkerSize = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
163 aTempMarkerBundle.SetColor( ImplGetBitmapColor() );
164 const bool bUpdateMarkerBundle = aTempMarkerBundle.GetIndex() == pElement->pMarkerBundle->GetIndex();
165 CGMElements::InsertBundle( pElement->aMarkerList, aTempMarkerBundle );
166 if (bUpdateMarkerBundle)
167 pElement->pMarkerBundle = static_cast<MarkerBundle*>(CGMElements::GetBundleIndex(aTempMarkerBundle.GetIndex(), pElement->aMarkerList, pElement->aMarkerBundle));
168 }
169 break;
170 case 0x0d : /*Text Representation*/
171 {
172 TextBundle aTempTextBundle;
173 aTempTextBundle.SetIndex( ImplGetI( pElement->nIndexPrecision ) );
174 aTempTextBundle.nTextFontIndex = ImplGetI( pElement->nIndexPrecision );
175 aTempTextBundle.eTextPrecision = static_cast<TextPrecision>(ImplGetI( pElement->nIndexPrecision ));
176 aTempTextBundle.nCharacterSpacing = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
177 aTempTextBundle.nCharacterExpansion = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
178 aTempTextBundle.SetColor( ImplGetBitmapColor() );
179 const bool bUpdateTextBundle = aTempTextBundle.GetIndex() == pElement->pTextBundle->GetIndex();
180 CGMElements::InsertBundle( pElement->aTextList, aTempTextBundle );
181 if (bUpdateTextBundle)
182 pElement->pTextBundle = static_cast<TextBundle*>(CGMElements::GetBundleIndex(aTempTextBundle.GetIndex(), pElement->aTextList, pElement->aTextBundle));
183 }
184 break;
185 case 0x0e : /*Fill Representation*/
186 {
187 FillBundle aTempFillBundle;
188 aTempFillBundle.SetIndex( ImplGetI( pElement->nIndexPrecision ) );
189 aTempFillBundle.eFillInteriorStyle = static_cast<FillInteriorStyle>(ImplGetI( pElement->nIndexPrecision ));
190 aTempFillBundle.SetColor( ImplGetBitmapColor() );
191 aTempFillBundle.nFillPatternIndex = ImplGetI( pElement->nIndexPrecision );
192 aTempFillBundle.nFillHatchIndex = ImplGetI( pElement->nIndexPrecision );
193 const bool bUpdateFillBundle = aTempFillBundle.GetIndex() == pElement->pFillBundle->GetIndex();
194 CGMElements::InsertBundle( pElement->aFillList, aTempFillBundle );
195 if (bUpdateFillBundle)
196 pElement->pFillBundle = static_cast<FillBundle*>(CGMElements::GetBundleIndex(aTempFillBundle.GetIndex(), pElement->aFillList, pElement->aFillBundle));
197 }
198 break;
199 case 0x0f : /*Edge Representation*/
200 {
201 EdgeBundle aTempEdgeBundle;
202 aTempEdgeBundle.SetIndex( ImplGetI( pElement->nIndexPrecision ) );
203 aTempEdgeBundle.eEdgeType = static_cast<EdgeType>(ImplGetI( pElement->nIndexPrecision ));
204 aTempEdgeBundle.nEdgeWidth = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
205 aTempEdgeBundle.SetColor( ImplGetBitmapColor() );
206 const bool bUpdateEdgeBundle = aTempEdgeBundle.GetIndex() == pElement->pEdgeBundle->GetIndex();
207 CGMElements::InsertBundle( pElement->aEdgeList, aTempEdgeBundle );
208 if (bUpdateEdgeBundle)
209 pElement->pEdgeBundle = static_cast<EdgeBundle*>(CGMElements::GetBundleIndex(aTempEdgeBundle.GetIndex(), pElement->aEdgeList, pElement->aEdgeBundle));
210 }
211 break;
212 case 0x10 : /*Interior Style Specification Mode */break; // NS
213 case 0x11 : /*Line and Edge Type Definition */break;
214 case 0x12 : /*Hatch Style Definition */break; // NS
215 case 0x13 : /*Geometric Pattern Definition */break; // NS
216 case 0xff : /*inquire VDC EXTENT */break;
217 case 0xfe : /*inquire Background Color */break;
218 case 0xfd : /*inquire Device Viewport */break;
219 case 0xfc : /*set Font Selection Mode */break;
220 case 0xfb : /*inquire Color Selection Mode */break;
221 case 0xfa : /*inquire Font Selection Mode */break;
222 case 0xf9 : /*set Char Height Spec Mode*/
223 {
224 ImplGetUI16(); // -Wall is this really needed?
225 }
226 break;
227 case 0xf8 : /*set Background Style */break;
228 default: break;
229 }
230};
231
232
233/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ SM_SCALED
Definition: cgmtypes.hxx:110
@ SM_ABSOLUTE
Definition: cgmtypes.hxx:110
@ DVPM_DEVICE
Definition: cgmtypes.hxx:90
@ DVPM_FRACTION
Definition: cgmtypes.hxx:90
@ DVPM_METRIC
Definition: cgmtypes.hxx:90
TextPrecision
Definition: cgmtypes.hxx:101
EdgeType
Definition: cgmtypes.hxx:115
@ DVPM_NOT_FORCED
Definition: cgmtypes.hxx:91
@ DVPM_FORCED
Definition: cgmtypes.hxx:91
@ SM_ABSTRACT
Definition: cgmtypes.hxx:87
@ SM_METRIC
Definition: cgmtypes.hxx:87
FillInteriorStyle
Definition: cgmtypes.hxx:123
@ DVPMH_LEFT
Definition: cgmtypes.hxx:92
@ CVPMH_RIGHT
Definition: cgmtypes.hxx:92
@ DVPMH_CENTER
Definition: cgmtypes.hxx:92
MarkerType
Definition: cgmtypes.hxx:119
@ CSM_INDEXED
Definition: cgmtypes.hxx:97
@ CSM_DIRECT
Definition: cgmtypes.hxx:97
@ DVPMV_TOP
Definition: cgmtypes.hxx:93
@ DVPMV_BOTTOM
Definition: cgmtypes.hxx:93
@ DVPMV_CENTER
Definition: cgmtypes.hxx:93
@ VDC_INTEGER
Definition: cgmtypes.hxx:89
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
static Bundle * GetBundleIndex(tools::Long nIndex, BundleList &, Bundle &)
Definition: elements.cxx:301
static Bundle * InsertBundle(BundleList &, Bundle &)
Definition: elements.cxx:322
void ImplSetMapMode()
Definition: cgm.cxx:372
void ImplGetRectangleNS(FloatRect &)
Definition: cgm.cxx:316
double ImplGetFloat(RealPrecision, sal_uInt32 nRealSize)
Definition: cgm.cxx:172
bool mbStatus
Definition: cgm.hxx:55
sal_Int32 ImplGetI(sal_uInt32 nPrecision)
Definition: cgm.cxx:96
sal_uInt32 mnElementID
Definition: cgm.hxx:86
sal_uInt32 ImplGetBitmapColor(bool bDirectColor=false)
Definition: cgm.cxx:334
sal_uInt32 ImplGetUI16()
Definition: cgm.cxx:82
void ImplGetRectangle(FloatRect &, bool bMap=false)
Definition: cgm.cxx:290
sal_uInt32 mnElementSize
Definition: cgm.hxx:87
std::unique_ptr< CGMElements > pElement
Definition: cgm.hxx:69
void ImplDoClass2()
Definition: class2.cxx:25
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
LineType