1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include <sal/config.h>
21 #include <sal/log.hxx>
23 #include <o3tl/safeint.hxx>
25 #include "bundles.hxx"
27 #include "elements.hxx"
30 void CGM::ImplDoClass1()
32 tools::Long nInteger
, nI0
, nI1
;
35 switch ( mnElementID
)
37 case 0x01 : /*Metafile Version*/
38 pElement
->nMetaFileVersion
= ImplGetI( pElement
->nIntegerPrecision
);
40 case 0x02 : /*Metafile Description */break;
41 case 0x03 : /*VDC Type*/
43 nUInteger
= ImplGetUI16();
46 case 0 : pElement
->eVDCType
= VDC_INTEGER
; break;
47 case 1 : pElement
->eVDCType
= VDC_REAL
; break;
48 default: mbStatus
= false; break;
52 case 0x04 : /*Integer Precision*/
54 nInteger
= ImplGetI( pElement
->nIntegerPrecision
);
60 case 8 : pElement
->nIntegerPrecision
= nInteger
>> 3; break;
61 default : mbStatus
= false; break;
65 case 0x05 : /*Real Precision*/
67 nUInteger
= ImplGetUI16();
68 nI0
= ImplGetI( pElement
->nIntegerPrecision
); // exponent
69 nI1
= ImplGetI( pElement
->nIntegerPrecision
); // mantissa
73 pElement
->eRealPrecision
= RP_FLOAT
;
79 pElement
->nRealSize
= 4;
84 pElement
->nRealSize
= 8;
92 pElement
->eRealPrecision
= RP_FIXED
;
96 pElement
->nRealSize
= 4;
98 pElement
->nRealSize
= 8;
103 mbStatus
= false; break;
107 case 0x06 : /*Index Precision*/
109 nInteger
= ImplGetI( pElement
->nIntegerPrecision
);
115 case 8 : pElement
->nIndexPrecision
= nInteger
>> 3; break;
116 default : mbStatus
= false; break;
120 case 0x07 : /*Color Precision*/
122 nInteger
= ImplGetI( pElement
->nIntegerPrecision
);
128 case 8 : pElement
->nColorPrecision
= nInteger
>> 3; break;
129 default : mbStatus
= false; break;
133 case 0x08 : /*Color Index Precision*/
135 nInteger
= ImplGetI( pElement
->nIntegerPrecision
);
141 case 8 : pElement
->nColorIndexPrecision
= nInteger
>> 3; break;
142 default : mbStatus
= false; break;
146 case 0x09 : /*Maximum Colour Index*/
148 pElement
->nColorMaximumIndex
= ImplGetUI( pElement
->nColorIndexPrecision
);
149 if ( ( pElement
->nColorMaximumIndex
> 256 /*255*/ ) || ( pElement
->nColorMaximumIndex
== 0 ) )
153 case 0x0a : /*Color Value Extent*/
158 case 0x0b : /*MetaFile Element List */break;
159 case 0x0c : /*MetaFile Default Replacement*/
161 if ( mnElementSize
> 1 )
163 std::unique_ptr
<sal_uInt8
[]> pBuf(new sal_uInt8
[ mnElementSize
]);
164 memcpy( pBuf
.get(), mpSource
, mnElementSize
);
165 maDefRepList
.push_back( std::move(pBuf
) );
166 maDefRepSizeList
.push_back( mnElementSize
);
168 mnParaSize
= mnElementSize
;
171 case 0x0d : /*Font List*/
173 while ( mnParaSize
< mnElementSize
)
175 sal_uInt32 nSize
= ImplGetUI(1);
177 if (o3tl::make_unsigned(mpEndValidSource
- (mpSource
+ mnParaSize
)) < nSize
)
178 throw css::uno::Exception("attempt to read past end of input", nullptr);
180 pElement
->aFontList
.InsertName( mpSource
+ mnParaSize
, nSize
);
185 case 0x0e : /*Character Set List*/
187 while ( mnParaSize
< mnElementSize
)
189 ImplGetUI16(); // skip CharSetType
190 sal_uInt32 nSize
= ImplGetUI(1);
192 if (o3tl::make_unsigned(mpEndValidSource
- (mpSource
+ mnParaSize
)) < nSize
)
193 throw css::uno::Exception("attempt to read past end of input", nullptr);
195 pElement
->aFontList
.InsertCharSet( mpSource
+ mnParaSize
, nSize
);
200 case 0x0f : /*Character Coding Announcer*/
202 auto nCharacterCoding
= ImplGetUI16();
203 if (nCharacterCoding
<= CCA_EXT_8
)
204 pElement
->eCharacterCodingA
= static_cast<CharacterCodingA
>(nCharacterCoding
);
206 SAL_WARN("filter.icgm", "CharacterCoding " << nCharacterCoding
<< " requested, but legal max is " << CCA_EXT_8
);
209 case 0x10 : /*Name Precision */break; // NS
210 case 0x11 : /*Maximum VDC Extent */break; // NS
211 case 0x12 : /*Segment Priority Extent */break; // NS
212 case 0x13 : /*Color Model */break; // NS
213 case 0x14 : /*Color Calibration */break; // NS
214 case 0x15 : /*Font Properties */break; // NS
215 case 0x16 : /*Glyph Mapping */break; // NS
216 case 0x17 : /*Symbol Library List */break; // NS
217 case 0xfc : /*Inquire Function Support */break;
218 case 0xfa : /*End Metafile Defaults Replacement */break;
219 case 0xf8 : /*Set Color Value Desc Extent */break;
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */