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>
22 #include <o3tl/safeint.hxx>
29 void CGM::ImplDoClass7()
31 switch ( mnElementID
)
33 case 0x01 : /*Message */break;
36 if (mpEndValidSource
- mpSource
< 12)
37 throw css::uno::Exception(u
"attempt to read past end of input"_ustr
, nullptr);
39 sal_uInt16
* pTemp
= reinterpret_cast<sal_uInt16
*>(mpSource
);
40 sal_uInt16 nOpcode
= pTemp
[ 4 ];
42 sal_uInt8
* pAppData
= mpSource
+ 12;
44 if ( mpChart
|| ( nOpcode
== 0 ) )
48 case 0x000 : /*AppData - Beginning of File Opcodes*/
50 if (mpEndValidSource
- pAppData
< 4)
51 throw css::uno::Exception(u
"attempt to read past end of input"_ustr
, nullptr);
53 if ( mpChart
== nullptr )
54 mpChart
.reset( new CGMChart
);
55 mpChart
->mnCurrentFileType
= pAppData
[ 3 ];
58 case 0x001 : /*AppData - End of File Opcodes */break;
59 case 0x190 : /*AppData - FDESC */break;
60 case 0x192 : /*AppData - FNOTES */break;
61 case 0x1F4 : /*AppData - BOGENFILE */break;
62 case 0x1F5 : /*AppData - EOGENFILE */break;
63 case 0x1F8 : /*AppData - BOCHTGROUP */break;
64 case 0x1F9 : /*AppData - EOCHTGROUP */break;
65 case 0x1FC : /*AppData - BOCHTDATA */break;
66 case 0x1FD : /*AppData - EOCHTDATA*/
68 // mpOutAct->DrawChart();
71 case 0x200 : /*AppData - BOSYMGROUP */break;
72 case 0x201 : /*AppData - EOSYMGROUP */break;
73 case 0x204 : /*AppData - BEGSYMBOL */break;
74 case 0x205 : /*AppData - ENDSYMBOL */break;
75 case 0x208 : /*AppData - BOSHWGROUP */break;
76 case 0x209 : /*AppData - EOSHWGROUP */break;
77 case 0x260 : /*AppData - BEGGROUP */break;
78 case 0x262 : /*AppData - ENDGROUP */break;
79 case 0x264 : /*AppData - DATANODE*/
81 if (o3tl::make_unsigned(mpEndValidSource
- pAppData
) < sizeof(DataNode
))
82 throw css::uno::Exception(u
"attempt to read past end of input"_ustr
, nullptr);
84 mpChart
->mDataNode
[ 0 ] = *reinterpret_cast<DataNode
*>( pAppData
);
85 sal_Int8 nZoneEnum
= mpChart
->mDataNode
[ 0 ].nZoneEnum
;
86 if (nZoneEnum
> 0 && nZoneEnum
<= 6)
87 mpChart
->mDataNode
[ nZoneEnum
] = *reinterpret_cast<DataNode
*>( pAppData
);
90 case 0x2BE : /*AppData - SHWSLIDEREC*/
92 if (mpEndValidSource
- pAppData
< 17)
93 throw css::uno::Exception(u
"attempt to read past end of input"_ustr
, nullptr);
95 if ( pAppData
[ 16 ] == 0 ) // a blank template ?
97 if ( pAppData
[ 2 ] == 46 )
99 // this starts the document -> maybe we could insert a new document
101 else if ( pAppData
[ 2 ] & 0x80 )
103 // this is a template
107 mpOutAct
->InsertPage();
110 mpChart
->ResetAnnotation();
113 case 0x2C0 : /*AppData - SHWKEYTABLE */break;
114 case 0x2C2 : /*AppData - SHWBUTTONTAB */break;
115 case 0x2C4 : /*AppData - SHWGLOBAL */break;
116 case 0x2C6 : /*AppData - SHWTITLE */break;
117 case 0x2CA : /*AppData - SHWAPP */break;
118 case 0x320 : /*AppData - TEXT*/
120 if (mpEndValidSource
- pAppData
< 9)
121 throw css::uno::Exception(u
"attempt to read past end of input"_ustr
, nullptr);
123 std::unique_ptr
<TextEntry
> pTextEntry(new TextEntry
);
124 pTextEntry
->nTypeOfText
= *reinterpret_cast<sal_uInt16
*>( pAppData
);
125 pTextEntry
->nRowOrLineNum
= *reinterpret_cast<sal_uInt16
*>( pAppData
+ 2 );
126 pTextEntry
->nColumnNum
= *reinterpret_cast<sal_uInt16
*>( pAppData
+ 4 );
127 sal_uInt16 nAttributes
= *reinterpret_cast<sal_uInt16
*>( pAppData
+ 6 );
128 pTextEntry
->nZoneSize
= nAttributes
& 0xff;
129 pTextEntry
->nLineType
= ( nAttributes
>> 8 ) & 0xf;
131 pTextEntry
->nAttributes
= nAttributes
;
133 auto nMaxLen
= mpEndValidSource
- pAppData
;
134 sal_uInt32 nLen
= strnlen(reinterpret_cast<char*>(pAppData
), nMaxLen
);
135 pTextEntry
->pText
= new char[nLen
+ 1];
136 memcpy( pTextEntry
->pText
, pAppData
, nLen
);
137 pTextEntry
->pText
[nLen
] = 0;
140 mpChart
->InsertTextEntry( std::move(pTextEntry
) );
143 case 0x321 : /*AppData - IOC_TABS */break;
144 case 0x322 : /*AppData - CHARTZONE*/
146 case 0x324 : /*AppData - TITLEZONE */break;
147 case 0x328 : /*AppData - FOOTNOTEZONE */break;
148 case 0x32A : /*AppData - LEGENDZONE */break;
149 case 0x330 : /*AppData - PAGEORIENTDIM*/
151 case 0x334 : /*AppData - CHTZONEOPTN*/
153 case 0x336 : /*AppData - CHTINTL*/
155 case 0x338 : /*AppData - CHTLINESPC */break;
156 case 0x384 : /*AppData - ORGGRIDSTATE */break;
157 case 0x386 : /*AppData - ORGSCRSTATE */break;
158 case 0x388 : /*AppData - ORGTREESTATE */break;
159 case 0x38A : /*AppData - ORGTEXTOPTN */break;
160 case 0x38E : /*AppData - ORGBOXOPTN */break;
161 case 0x390 : /*AppData - ORGBOXDIM */break;
162 case 0x392 : /*AppData - ORGBOX */break;
163 case 0x3EA : /*AppData - TTLTEXTOPTN */break;
164 case 0x3EE : /*AppData - TTLAUTOBUILD */break;
165 case 0x44E : /*AppData - BULTEXTOPTN */break;
166 case 0x452 : /*AppData - BULLETOPTN*/
168 case 0x454 : /*AppData - BULLETLINES*/break;
169 case 0x456 : /*AppData - BULAUTOBUILD */break;
170 case 0x4B2 : /*AppData - TBLTEXTOPTN */break;
171 case 0x4B6 : /*AppData - TBLOPTN */break;
172 case 0x4B8 : /*AppData - TBLCOLOPTN */break;
173 case 0x4BA : /*AppData - TBLLEGENDOPTN */break;
174 case 0x4BC : /*AppData - TBLRANGEOPTN */break;
175 case 0x4BE : /*AppData - TBLROWOPTN */break;
176 case 0x4C0 : /*AppData - TBLAUTOBUILD */break;
177 case 0x518 : /*AppData - PIECHARTOPTN */break;
178 case 0x51A : /*AppData - PIELEGENDOPTN */break;
179 case 0x51C : /*AppData - PIETEXTOPTN */break;
180 case 0x51E : /*AppData - PIEOPTN */break;
181 case 0x520 : /*AppData - PIEPCTLABOPTN */break;
182 case 0x522 : /*AppData - PIEVALLABOPTN */break;
183 case 0x524 : /*AppData - PIESLICE */break;
184 case 0x57A : /*AppData - XYAXISOPTN */break;
185 case 0x57C : /*AppData - XYGRIDOPTN */break;
186 case 0x57D : /*AppData - XYGRIDSHOWFILL */break;
187 case 0x57E : /*AppData - XYSERIESOPTN */break;
188 case 0x580 : /*AppData - XYSTYLEOPTN */break;
189 case 0x582 : /*AppData - XYTABLEOPTN */break;
190 case 0x584 : /*AppData - XYTEXTOPTN */break;
191 case 0x586 : /*AppData - XYDATAOPTN */break;
192 case 0x58A : /*AppData - XYLEGENDOPN */break;
193 case 0x58C : /*AppData - XYCALCULATION */break;
194 case 0x58E : /*AppData - XYXVALUE */break;
195 case 0x590 : /*AppData - XYYVALUE */break;
196 case 0x592 : /*AppData - XYXEXTVALUE */break;
197 case 0x618 : /*AppData - IOC_CHTCOLRTAB */break;
198 case 0x619 : /*AppData - IOC_CHTFONTTAB */break;
199 case 0x1fff : /*AppData - 0x1fff */break;
200 default : /*UNKNOWN Application Data */break;
203 mnParaSize
= mnElementSize
;
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */