bump product version to 4.1.6.2
[LibreOffice.git] / filter / source / graphicfilter / icgm / class5.cxx
blobeb537886fbb6cdff67889561ca1a7edad19b96c7
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 .
20 //#define VCL_NEED_BASETSD
22 #include <main.hxx>
23 #include <outact.hxx>
26 // ---------------------------------------------------------------
28 void CGM::ImplDoClass5()
30 switch ( mnElementID )
32 case 0x01 : /*Line Bundle Index*/
33 pElement->pLineBundle = (LineBundle*)pElement->GetBundleIndex( ImplGetI( pElement->nIndexPrecision ), pElement->aLineList, pElement->aLineBundle );
34 break;
35 case 0x02 : /*Line Type*/
37 if ( pElement->nAspectSourceFlags & ASF_LINETYPE )
38 pElement->pLineBundle->eLineType = (LineType)ImplGetI( pElement->nIndexPrecision );
39 else
40 pElement->aLineBundle.eLineType = (LineType)ImplGetI( pElement->nIndexPrecision );
42 break;
43 case 0x03 : /*Line Width*/
45 double nWidth;
46 if ( pElement->eLineWidthSpecMode == SM_ABSOLUTE )
48 if ( pElement->eVDCType == VDC_REAL )
49 nWidth = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
50 else
51 nWidth = (double)ImplGetI( pElement->nVDCIntegerPrecision );
53 ImplMapDouble( nWidth );
55 else
56 nWidth = (sal_uInt32)ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize ) * 25; // scaling in 1/4 mm
58 ( pElement->nAspectSourceFlags & ASF_LINEWIDTH )
59 ? pElement->aLineBundle.nLineWidth = nWidth
60 : pElement->aLineBundle.nLineWidth = nWidth;
62 break;
63 case 0x04 : /*Line Color*/
65 if ( pElement->nAspectSourceFlags & ASF_LINECOLOR )
66 pElement->pLineBundle->SetColor( ImplGetBitmapColor() );
67 else
68 pElement->aLineBundle.SetColor( ImplGetBitmapColor() );
70 break;
71 case 0x05 : /*Marker Bundle Index*/
72 pElement->pMarkerBundle = (MarkerBundle*)pElement->GetBundleIndex( ImplGetI( pElement->nIndexPrecision ), pElement->aMarkerList, pElement->aMarkerBundle );
73 break;
74 case 0x06 : /*Marker Type*/
76 if ( pElement->nAspectSourceFlags & ASF_MARKERTYPE )
77 pElement->pMarkerBundle->eMarkerType = (MarkerType)ImplGetI( pElement->nIndexPrecision );
78 else
79 pElement->aMarkerBundle.eMarkerType = (MarkerType)ImplGetI( pElement->nIndexPrecision );
81 break;
82 case 0x07 : /*Marker Size*/
84 double nWidth;
85 if ( pElement->eMarkerSizeSpecMode == SM_ABSOLUTE )
87 if ( pElement->eVDCType == VDC_REAL )
88 nWidth = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
89 else
90 nWidth = (double)ImplGetI( pElement->nVDCIntegerPrecision );
91 ImplMapDouble( nWidth );
93 else
94 nWidth = (sal_uInt32)ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize ) * 25;
95 ( pElement->nAspectSourceFlags & ASF_MARKERSIZE )
96 ? pElement->aMarkerBundle.nMarkerSize = nWidth
97 : pElement->aMarkerBundle.nMarkerSize = nWidth;
99 break;
100 case 0x08 : /*Marker Color*/
102 if ( pElement->nAspectSourceFlags & ASF_MARKERCOLOR )
103 pElement->pMarkerBundle->SetColor( ImplGetBitmapColor() );
104 else
105 pElement->aMarkerBundle.SetColor( ImplGetBitmapColor() );
107 break;
108 case 0x09 : /*Text Bundle Index*/
109 pElement->pTextBundle = (TextBundle*)pElement->GetBundleIndex( ImplGetI( pElement->nIndexPrecision ), pElement->aTextList, pElement->aTextBundle );
110 break;
111 case 0x0a : /*Text Font Index*/
113 if ( pElement->nAspectSourceFlags & ASF_TEXTFONTINDEX )
114 pElement->pTextBundle->nTextFontIndex = ImplGetI( pElement->nIndexPrecision );
115 else
116 pElement->aTextBundle.nTextFontIndex = ImplGetI( pElement->nIndexPrecision );
118 break;
119 case 0x0b : /*Text Precision*/
121 TextBundle* pBundle;
122 if ( pElement->nAspectSourceFlags & ASF_TEXTPRECISION )
123 pBundle = pElement->pTextBundle;
124 else
125 pBundle = &pElement->aTextBundle;
126 switch( ImplGetUI16() )
128 case 0 : pBundle->eTextPrecision = TPR_STRING; break;
129 case 1 : pBundle->eTextPrecision = TPR_CHARACTER; break;
130 case 2 : pBundle->eTextPrecision = TPR_STROKE; break;
131 default : pBundle->eTextPrecision = TPR_UNDEFINED; break;
134 break;
135 case 0x0c : /*Character Expansion Factor*/
137 if ( pElement->nAspectSourceFlags & ASF_CHARACTEREXPANSION )
138 pElement->pTextBundle->nCharacterExpansion = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
139 else
140 pElement->aTextBundle.nCharacterExpansion = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
142 break;
143 case 0x0d : /*Character Spacing*/
145 if ( pElement->nAspectSourceFlags & ASF_CHARACTERSPACING )
146 pElement->pTextBundle->nCharacterSpacing = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
147 else
148 pElement->aTextBundle.nCharacterSpacing = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
150 break;
151 case 0x0e : /*Text Color*/
153 if ( pElement->nAspectSourceFlags & ASF_TEXTCOLOR )
154 pElement->pTextBundle->SetColor( ImplGetBitmapColor() );
155 else
156 pElement->aTextBundle.SetColor( ImplGetBitmapColor() );
158 break;
159 case 0x0f : /*Character Height*/
161 if ( pElement->eVDCType == VDC_INTEGER )
162 pElement->nCharacterHeight = ImplGetI( pElement->nVDCIntegerPrecision );
163 else // ->floating points
164 pElement->nCharacterHeight = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
165 ImplMapDouble( pElement->nCharacterHeight );
166 pElement->nCharacterHeight /= 18.0;
168 break;
169 case 0x10 : /*Character Orientation*/
171 if ( pElement->eVDCType == VDC_INTEGER )
173 pElement->nCharacterOrientation[0] = ImplGetI( pElement->nVDCIntegerPrecision );
174 pElement->nCharacterOrientation[1] = ImplGetI( pElement->nVDCIntegerPrecision );
175 pElement->nCharacterOrientation[2] = ImplGetI( pElement->nVDCIntegerPrecision );
176 pElement->nCharacterOrientation[3] = ImplGetI( pElement->nVDCIntegerPrecision );
178 else // ->floating points
180 pElement->nCharacterOrientation[0] = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
181 pElement->nCharacterOrientation[1] = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
182 pElement->nCharacterOrientation[2] = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
183 pElement->nCharacterOrientation[3] = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
186 break;
187 case 0x11 : /*Text Path*/
189 switch( ImplGetUI16() )
191 case 0 : pElement->eTextPath = TPR_RIGHT; break;
192 case 1 : pElement->eTextPath = TPR_LEFT; break;
193 case 2 : pElement->eTextPath = TPR_UP; break;
194 case 3 : pElement->eTextPath = TPR_DOWN; break;
195 default : mbStatus = sal_False; break;
198 break;
199 case 0x12 : /*Text Alignment*/
201 pElement->eTextAlignmentH = (TextAlignmentH)ImplGetUI16();
202 pElement->eTextAlignmentV = (TextAlignmentV)ImplGetUI16( 8 );
203 pElement->nTextAlignmentHCont = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
204 pElement->nTextAlignmentVCont = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
206 break;
207 case 0x13 : /*Character Set Index*/
208 pElement->nCharacterSetIndex = ImplGetI( pElement->nIndexPrecision );
209 break;
210 case 0x14 : /*Alternate Character Set Index*/
211 pElement->nAlternateCharacterSetIndex = ImplGetI( pElement->nIndexPrecision );
212 break;
213 case 0x15 : /*Fill Bundle Index*/
214 pElement->pFillBundle = (FillBundle*)pElement->GetBundleIndex( ImplGetI( pElement->nIndexPrecision ), pElement->aFillList, pElement->aFillBundle );
215 break;
216 case 0x16 : /*Fill Interior Style*/
218 if ( pElement->nAspectSourceFlags & ASF_FILLINTERIORSTYLE )
219 pElement->pFillBundle->eFillInteriorStyle = (FillInteriorStyle)ImplGetUI16();
220 else
221 pElement->aFillBundle.eFillInteriorStyle = (FillInteriorStyle)ImplGetUI16();
223 break;
224 case 0x17 : /*Fill Color*/
226 if ( pElement->nAspectSourceFlags & ASF_FILLCOLOR )
227 pElement->pFillBundle->SetColor( ImplGetBitmapColor() );
228 else
229 pElement->aFillBundle.SetColor( ImplGetBitmapColor() );
231 break;
232 case 0x18 : /*Fill Hatch Index*/
234 if ( pElement->nAspectSourceFlags & ASF_HATCHINDEX )
235 pElement->pFillBundle->nFillHatchIndex = ImplGetI( pElement->nIndexPrecision );
236 else
237 pElement->aFillBundle.nFillHatchIndex = ImplGetI( pElement->nIndexPrecision );
239 break;
240 case 0x19 : /*Fill Pattern Index*/
242 if ( pElement->nAspectSourceFlags & ASF_PATTERNINDEX )
243 pElement->pFillBundle->nFillPatternIndex = ImplGetI( pElement->nIndexPrecision );
244 else
245 pElement->aFillBundle.nFillPatternIndex = ImplGetI( pElement->nIndexPrecision );
247 break;
248 case 0x1a : /*Edge Bundle Index*/
249 pElement->pEdgeBundle = (EdgeBundle*)pElement->GetBundleIndex( ImplGetI( pElement->nIndexPrecision ), pElement->aEdgeList, pElement->aEdgeBundle );
250 break;
251 case 0x1b : /*Edge Type*/
253 if ( pElement->nAspectSourceFlags & ASF_EDGETYPE )
254 pElement->pEdgeBundle->eEdgeType = (EdgeType)ImplGetI( pElement->nIndexPrecision );
255 else
256 pElement->aEdgeBundle.eEdgeType = (EdgeType)ImplGetI( pElement->nIndexPrecision );
258 break;
259 case 0x1c : /*Edge Width*/
261 double nWidth;
262 if ( pElement->eEdgeWidthSpecMode == SM_ABSOLUTE )
264 if ( pElement->eVDCType == VDC_REAL )
265 nWidth = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
266 else
267 nWidth = (double)ImplGetI( pElement->nVDCIntegerPrecision );
269 ImplMapDouble( nWidth );
271 else
272 nWidth = (sal_uInt32)ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize ) * 25;
273 ( pElement->nAspectSourceFlags & ASF_EDGEWIDTH )
274 ? pElement->aEdgeBundle.nEdgeWidth = nWidth
275 : pElement->aEdgeBundle.nEdgeWidth = nWidth;
277 break;
278 case 0x1d : /*Edge Color*/
280 if ( pElement->nAspectSourceFlags & ASF_EDGECOLOR )
281 pElement->pEdgeBundle->SetColor( ImplGetBitmapColor() );
282 else
283 pElement->aEdgeBundle.SetColor( ImplGetBitmapColor() );
285 break;
286 case 0x1e : /*Edge Visibility*/
288 switch( ImplGetUI16() )
290 case 0 : pElement->eEdgeVisibility = EV_OFF; break;
291 case 1 : pElement->eEdgeVisibility = EV_ON; break;
292 default : mbStatus = sal_False;
295 break;
296 case 0x1f : /*Fill Reference Point*/
297 ImplGetPoint( pElement->aFillRefPoint );
298 break;
299 case 0x20 : /*Pattern Table" )*/ break;
300 case 0x21 : /*Pattern Size" )*/ break;
301 case 0x22 : /*Color Table*/
303 sal_uInt32 nColorStartIndex = ImplGetUI( pElement->nColorIndexPrecision );
304 if ( ( nColorStartIndex > 255 ) ||
305 ( ( ( mnElementSize - pElement->nColorIndexPrecision ) % ( pElement->nColorPrecision * 3 ) ) != 0 ) )
307 mbStatus = sal_False;
309 else
311 sal_uInt32 nColors = ( mnElementSize - pElement->nColorIndexPrecision ) / ( 3 * pElement->nColorPrecision );
312 if ( nColors )
314 sal_uInt32 nMaxColorIndex = nColorStartIndex + nColors - 1;
315 sal_uInt32 nIndex;
316 if ( nMaxColorIndex > 255 )
318 mbStatus = sal_False;
319 break;
321 if ( pElement->nLatestColorMaximumIndex < nMaxColorIndex )
322 pElement->nLatestColorMaximumIndex = nMaxColorIndex;
324 for ( nIndex = nColorStartIndex; nIndex <= nMaxColorIndex; nIndex++ )
326 pElement->aLatestColorTable[ nIndex ] = ImplGetBitmapColor( sal_True );
329 pElement->nColorMaximumIndex = pElement->nLatestColorMaximumIndex;
330 for ( nIndex = nColorStartIndex; nIndex <= nMaxColorIndex; nIndex++ )
332 if ( !pElement->aColorTableEntryIs[ nIndex ] )
334 pElement->aColorTableEntryIs[ nIndex ] = 1;
335 pElement->aColorTable[ nIndex ] = pElement->aLatestColorTable[ nIndex ];
341 break;
342 case 0x23 : /*Aspect Source Flags*/
344 int nFlags = mnElementSize >> 2;
345 while ( nFlags-- > 0 )
347 sal_uInt32 nFlag = 0;
348 switch( ImplGetUI16() )
350 case 0 : nFlag = ASF_LINETYPE; break;
351 case 1 : nFlag = ASF_LINEWIDTH; break;
352 case 2 : nFlag = ASF_LINECOLOR; break;
353 case 3 : nFlag = ASF_MARKERTYPE; break;
354 case 4 : nFlag = ASF_MARKERSIZE; break;
355 case 5 : nFlag = ASF_MARKERCOLOR; break;
356 case 6 : nFlag = ASF_FILLINTERIORSTYLE; break;
357 case 7 : nFlag = ASF_HATCHINDEX; break;
358 case 8 : nFlag = ASF_PATTERNINDEX; break;
359 case 9 : nFlag = ASF_BITMAPINDEX; break;
360 case 10 : nFlag = ASF_FILLCOLOR; break;
361 case 11 : nFlag = ASF_EDGETYPE; break;
362 case 12 : nFlag = ASF_EDGEWIDTH; break;
363 case 13 : nFlag = ASF_EDGECOLOR; break;
364 case 14 : nFlag = ASF_TEXTFONTINDEX; break;
365 case 15 : nFlag = ASF_TEXTPRECISION; break;
366 case 16 : nFlag = ASF_CHARACTEREXPANSION; break;
367 case 17 : nFlag = ASF_CHARACTERSPACING; break;
368 case 18 : nFlag = ASF_TEXTCOLOR; break;
369 default : mbStatus = sal_False; break;
371 sal_uInt32 nASF = ImplGetUI16();
372 switch ( nASF )
374 case 0 : pElement->nAspectSourceFlags &= ~nFlag; break; // INDIVIDUAL
375 case 1 : pElement->nAspectSourceFlags |= nFlag; break; // BUNDLED
376 default : mbStatus = sal_False; break;
380 break;
381 case 0x24 : /*Pick Identifier" ) bre*/
382 case 0x25 : /*Line Cap*/
384 switch( ImplGetUI16() )
386 case 0 : pElement->eLineCapType = LCT_BUTT; break;
387 case 1 : pElement->eLineCapType = LCT_ROUND; break;
388 case 2 : pElement->eLineCapType = LCT_SQUARE; break;
389 case 3 : pElement->eLineCapType = LCT_TRIANGLE; break;
390 case 4 : pElement->eLineCapType = LCT_ARROW; break;
391 default : pElement->eLineCapType = LCT_NONE; break;
394 break;
395 case 0x26 : /*Line Join*/
397 switch( ImplGetUI16() )
399 case 0 : pElement->eLineJoinType = LJT_MITER; break;
400 case 1 : pElement->eLineJoinType = LJT_ROUND; break;
401 case 2 : pElement->eLineJoinType = LJT_BEVEL; break;
402 default : pElement->eLineJoinType = LJT_NONE; break;
405 break;
406 case 0x27 : /*Line Type Continuation*/ break; // NS
407 case 0x28 : /*Line Type Initial Offset*/ break; // NS
408 case 0x29 : /*Text Score Type*/ break;
409 case 0x2a : /*Restricted Text Type*/ break;
410 case 0x2b : /*Interpolated interior*/ break;
411 case 0x2c : /*Edge Cap*/ break; // NS
412 case 0x2d : /*Edge Join*/ break;
413 case 0x2e : /*Edge Type Continuation*/ break; // NS
414 case 0x2f : /*Edge Type Initial Offset*/ break; // NS
415 case 0x30 : /*Symbol Library Index*/ break; // NS
416 case 0x31 : /*Symbol Color*/ break; // NS
417 case 0x32 : /*Symbol Size*/ break; // NS
418 case 0x33 : /*Symbol Orientation*/ break; // NS
419 case 0x50 : /*Block Text Region Margins*/ break;
420 case 0x51 : /*Block Text Region Expansion*/ break;
421 case 0x52 : /*Block Text Region Anchor*/ break;
422 case 0x53 : /*Block Text Paragraph Horizontal Alignment*/ break;
423 case 0x54 : /*Block Text Paragraph Vertical Alignment*/ break;
424 case 0x55 : /*Block Text Line Flow*/ break;
425 case 0x60 : /*Block Text Paragraph Spacing*/ break;
426 case 0x61 : /*Block Text Paragraph Indent*/ break;
427 case 0x62 : /*Block Text Paragraph Tabs*/ break;
428 case 0x63 : /*Block Text Paragraph Bullets*/ break;
429 case 0x64 : /*Block Text Paragraph Bullet Level*/ break;
430 case 0x65 : /*Block Text Paragraph Line Horizontal Alignment*/ break;
431 case 0x66 : /*Block Text Paragraph Line Vertical Alignment*/ break;
432 case 0x67 : /*Block Text Paragragh Line Spacing*/ break;
433 case 0x68 : /*Block Text Paragraph Word Wrap*/ break;
434 case 0x70 : /*Block Text Forward Advance Distance*/ break;
435 case 0x71 : /*Word Spacing*/ break;
436 case 0x72 : /*External Leading*/ break;
437 case 0x7a : /*set Gradient Offset*/
439 long nHorzOffset = ImplGetI( pElement->nIndexPrecision );
440 long nVertOffset = ImplGetI( pElement->nIndexPrecision );
441 sal_uInt32 nType = ImplGetUI16();
442 mpOutAct->SetGradientOffset( nHorzOffset, nVertOffset, nType );
443 mnAct4PostReset |= ACT4_GRADIENT_ACTION;
445 break;
446 case 0x7b : /*set Gradient Edge*/
448 mnAct4PostReset |= ACT4_GRADIENT_ACTION;
450 break;
451 case 0x7c : /*set Gradient Angle*/
453 mpOutAct->SetGradientAngle( ImplGetI( pElement->nIndexPrecision ) );
454 mnAct4PostReset |= ACT4_GRADIENT_ACTION;
456 break;
457 case 0x7d : /*set Gradient Description*/
459 ImplGetI( pElement->nIndexPrecision ); // -Wall is this needed?
460 sal_uInt32 nNumberOfStages = ImplGetI( pElement->nIndexPrecision );
461 sal_uInt32 i, nColorFrom = 0;
462 sal_uInt32 nColorTo = 0xffffff;
464 //FIXME, does this loop actually do anything?
465 for ( i = 0; i < nNumberOfStages; i++ )
467 ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize ); // -Wall is this needed
470 for ( i = 0; i <= nNumberOfStages; i++ )
472 sal_uInt32 nPara = mnParaSize + 24;
473 if ( i == 0 )
475 nColorTo = ImplGetBitmapColor();
476 nColorFrom = nColorTo ^ 0xffffff;
478 else if ( i == 1 )
479 nColorFrom = ImplGetBitmapColor();
480 mnParaSize = nPara;
482 if ( nNumberOfStages > 1 )
483 mpOutAct->SetGradientStyle( 0xff, 1 );
485 mpOutAct->SetGradientDescriptor( nColorFrom, nColorTo );
486 mnAct4PostReset |= ACT4_GRADIENT_ACTION;
488 break;
489 case 0x7e : /*set Gradient Style*/
491 sal_uInt32 nStyle = ImplGetUI16( 8 );
492 double fRatio = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
493 mpOutAct->SetGradientStyle( nStyle, fRatio );
494 mnAct4PostReset |= ACT4_GRADIENT_ACTION;
496 break;
497 case 0xff : /*inquire Font metrics*/ break;
498 case 0xfe : /*inquire character widths*/ break;
499 case 0xfd : /*set Text Font*/ break;
500 case 0xfc : /*set current position*/ break;
501 case 0xfb : /*set current position mode*/ break;
502 case 0xfa : /*set character height mode*/ break;
503 case 0xf9 : /*set Transform matrix 2D*/ break;
504 case 0xf8 : /*set Transform matrix 3D*/ break;
505 case 0xf7 : /*pop transformation state*/ break;
506 case 0xf6 : /*clear transformation state*/ break;
507 case 0xf5 : /*set character widths*/ break;
508 case 0xf4 : /*set color name - for Pantone support*/ break;
509 default: break;
514 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */