LibreOffice Module writerfilter (master) 1
Handler.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 <ooxml/resourceids.hxx>
21#include "Handler.hxx"
22
23#include <sal/log.hxx>
24
25namespace writerfilter::ooxml
26{
27
28/*
29 class OOXMLFootnoteHandler
30 */
32: mpFastContext(pContext)
33{
34}
35
37{
38}
39
41{
42 switch (name)
43 {
44 case NS_ooxml::LN_CT_FtnEdnRef_id:
45 mpFastContext->resolveFootnote(sal_Int32(val.getInt()));
46 break;
47 default:
48 break;
49 }
50}
51
53{
54}
55
56/*
57 class OOXMLEndnoteHandler
58 */
60: mpFastContext(pContext)
61{
62}
63
65{
66}
67
69{
70 switch (name)
71 {
72 case NS_ooxml::LN_CT_FtnEdnRef_id:
73 mpFastContext->resolveEndnote(sal_Int32(val.getInt()));
74 break;
75 default:
76 break;
77 }
78}
79
81{
82}
83
84/*
85 class OOXMLCommentHandler
86*/
88: mpFastContext(pContext)
89{
90}
91
93{
94}
95
97{
98 switch (name)
99 {
100 case NS_ooxml::LN_CT_Markup_id:
102 break;
103 default:
104 ;
105 }
106}
107
109{
110}
111
112/*
113 class OOXMLOLEHandler
114*/
116: mpFastContext(pContext)
117{
118}
119
121{
122}
123
125{
126 switch (name)
127 {
128 case NS_ooxml::LN_CT_OLEObject_r_id:
129 try {
131 }
132 catch (const ::css::uno::Exception&)
133 {
134 // Can't resolve OLE stream
135 SAL_WARN("writerfilter.ooxml", "Failed to open OLE stream!");
136 }
137 break;
138 default:
139 ;
140 }
141}
142
144{
145}
146
148: mpFastContext(pContext)
149{
150}
151
153{
154}
155
157{
158 switch (name)
159 {
160 case NS_ooxml::LN_CT_Rel_id:
162 break;
163 default:
164 break;
165 }
166}
167
169{
170}
171
172/*
173 class OOXMLFooterHandler
174 */
176 : mpFastContext(pContext), mnType(0)
177{
178}
179
181{
183}
184
186{
187 switch (name)
188 {
189 case NS_ooxml::LN_CT_HdrFtrRef_id:
190 msStreamId = val.getString();
191 break;
192 case NS_ooxml::LN_CT_HdrFtrRef_type:
193 mnType = val.getInt();
194 break;
195 default:
196 break;
197 }
198}
199
201{
202}
203
204/*
205 class OOXMLHeaderHandler
206 */
208 : mpFastContext(pContext), mnType(0)
209{
210}
211
213{
215}
216
218{
219 switch (name)
220 {
221 case NS_ooxml::LN_CT_HdrFtrRef_id:
222 msStreamId = val.getString();
223 break;
224 case NS_ooxml::LN_CT_HdrFtrRef_type:
225 mnType = val.getInt();
226 break;
227 default:
228 break;
229 }
230}
231
233{
234}
235
236/*
237 class OOXMLBreakHandler
238 */
240: mnType(0),
241 mpFastContext(pContext),
242 mrStream(rStream)
243{
244}
245
247{
248 if (mpFastContext)
249 {
252 }
253
254 sal_uInt8 tmpBreak[1];
255 switch (mnType)
256 {
257 case NS_ooxml::LN_Value_ST_BrType_column:
258 tmpBreak[0] = 0x0E;
259 break;
260 case NS_ooxml::LN_Value_ST_BrType_page:
261 tmpBreak[0] = 0x0C;
262 break;
263 case NS_ooxml::LN_Value_ST_BrType_textWrapping:
264 default: // when no attribute type is present, the spec assume textWrapping
265 tmpBreak[0] = 0x0A;
266 break;
267 }
268 mrStream.text(&tmpBreak[0], 1);
269}
270
272{
273 switch (name)
274 {
275 case NS_ooxml::LN_CT_Br_type:
276 mnType = val.getInt();
277 break;
278 case NS_ooxml::LN_CT_Br_clear:
279 break;
280 default:
281 break;
282 }
283}
284
286{
287}
288
289/*
290 class OOXMLPictureHandler
291 */
293: mpFastContext(pContext)
294{
295}
296
298{
299}
300
302{
303 if (name == NS_ooxml::LN_AG_Blob_r_embed)
305 else
306 {
308 (val.getProperties());
309 if (pProps)
310 pProps->resolve(*this);
311 }
312}
313
315{
317 (rSprm.getProps());
318
319 if (pProps)
320 pProps->resolve(*this);
321}
322
328: mpFastContext(pContext)
329{
330}
331
333{
334}
335
337{
338 OUString sReturn = " HYPERLINK \"" + mURL + "\"" + mFieldCode;
339 mpFastContext->text(sReturn);
340}
341
343{
344 switch (name)
345 {
346 case NS_ooxml::LN_CT_Hyperlink_tgtFrame:
347 mFieldCode += " \\t \"";
348 mFieldCode += val.getString();
349 mFieldCode += "\"";
350 break;
351 case NS_ooxml::LN_CT_Hyperlink_tooltip:
352 mFieldCode += " \\o \"";
353 mFieldCode += val.getString();
354 mFieldCode += "\"";
355 break;
356 case NS_ooxml::LN_CT_Hyperlink_docLocation:
357 break;
358 case NS_ooxml::LN_CT_Hyperlink_history:
359 break;
360 case NS_ooxml::LN_CT_Hyperlink_anchor:
361 mFieldCode += " \\l \"";
362 mFieldCode += val.getString();
363 mFieldCode += "\"";
364 break;
365 case NS_ooxml::LN_CT_Hyperlink_r_id:
367 break;
368 default:
369 break;
370 }
371}
372
374{
375}
376
382: mpFastContext(pContext)
383{
384}
385
387{
389 mpFastContext->newProperty(NS_ooxml::LN_CT_Hyperlink_URL, OOXMLValue::Pointer_t(new OOXMLStringValue(mURL)));
390}
391
393{
394 switch (name)
395 {
396 case NS_ooxml::LN_CT_Hyperlink_URL:
398 break;
399 default:
400 break;
401 }
402}
403
405{
406}
407
409 : mpFastContext(pContext)
410{
411}
412
414{
416 mpFastContext->newProperty(NS_ooxml::LN_CT_AltChunk,
418}
419
421{
422 switch (nName)
423 {
424 case NS_ooxml::LN_CT_AltChunk:
426 break;
427 default:
428 break;
429 }
430}
431
433}
434
435/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
T * get() const
An SPRM: Section, Paragraph and Run Modifier.
virtual writerfilter::Reference< Properties >::Pointer_t getProps()=0
Returns reference to properties contained in the SPRM.
Handler for a stream.
virtual void props(writerfilter::Reference< Properties >::Pointer_t ref)=0
Receives properties of the current run of text.
virtual void text(const sal_uInt8 *data, size_t len)=0
Receives 8-bit per character text.
virtual writerfilter::Reference< Properties >::Pointer_t getProperties()=0
Returns properties of this value.
virtual int getInt() const =0
Returns integer representation of the value.
virtual OUString getString() const =0
Returns string representation of the value.
virtual void attribute(Id name, Value &val) override
Receives an attribute.
Definition: Handler.cxx:420
OOXMLFastContextHandler * mpFastContext
Definition: Handler.hxx:167
OOXMLAltChunkHandler(OOXMLFastContextHandler *pContext)
Definition: Handler.cxx:408
virtual void sprm(Sprm &sprm) override
Receives a SPRM.
Definition: Handler.cxx:432
OOXMLFastContextHandler * mpFastContext
Definition: Handler.hxx:114
OOXMLBreakHandler(OOXMLFastContextHandler *pContext, Stream &rStream)
Definition: Handler.cxx:239
virtual ~OOXMLBreakHandler() override
Definition: Handler.cxx:246
virtual void sprm(Sprm &sprm) override
Receives a SPRM.
Definition: Handler.cxx:285
virtual void attribute(Id name, Value &val) override
Receives an attribute.
Definition: Handler.cxx:271
virtual ~OOXMLCommentHandler() override
Definition: Handler.cxx:92
virtual void sprm(Sprm &sprm) override
Receives a SPRM.
Definition: Handler.cxx:108
OOXMLFastContextHandler * mpFastContext
Definition: Handler.hxx:78
virtual void attribute(Id name, Value &val) override
Receives an attribute.
Definition: Handler.cxx:96
OOXMLCommentHandler(OOXMLFastContextHandler *pContext)
Definition: Handler.cxx:87
OOXMLEmbeddedFontHandler(OOXMLFastContextHandler *pContext)
Definition: Handler.cxx:147
virtual void sprm(Sprm &sprm) override
Receives a SPRM.
Definition: Handler.cxx:168
OOXMLFastContextHandler * mpFastContext
Definition: Handler.hxx:101
virtual void attribute(Id name, Value &val) override
Receives an attribute.
Definition: Handler.cxx:156
OOXMLFastContextHandler * mpFastContext
Definition: Handler.hxx:40
OOXMLEndnoteHandler(OOXMLFastContextHandler *pContext)
Definition: Handler.cxx:59
virtual void sprm(Sprm &sprm) override
Receives a SPRM.
Definition: Handler.cxx:80
virtual void attribute(Id name, Value &val) override
Receives an attribute.
Definition: Handler.cxx:68
virtual ~OOXMLEndnoteHandler() override
Definition: Handler.cxx:64
void resolveHeader(const sal_Int32 type, const OUString &rId)
virtual void newProperty(Id aId, const OOXMLValue::Pointer_t &pVal)
void resolveFooter(const sal_Int32 type, const OUString &rId)
virtual OOXMLPropertySet::Pointer_t getPropertySet() const
virtual void sprm(Sprm &sprm) override
Receives a SPRM.
Definition: Handler.cxx:200
OOXMLFooterHandler(OOXMLFastContextHandler *pContext)
Definition: Handler.cxx:175
OOXMLFastContextHandler * mpFastContext
Definition: Handler.hxx:52
virtual void attribute(Id name, Value &val) override
Receives an attribute.
Definition: Handler.cxx:185
OOXMLFootnoteHandler(OOXMLFastContextHandler *pContext)
Definition: Handler.cxx:31
virtual ~OOXMLFootnoteHandler() override
Definition: Handler.cxx:36
virtual void attribute(Id name, Value &val) override
Receives an attribute.
Definition: Handler.cxx:40
OOXMLFastContextHandler * mpFastContext
Definition: Handler.hxx:28
virtual void sprm(Sprm &sprm) override
Receives a SPRM.
Definition: Handler.cxx:52
OOXMLHeaderHandler(OOXMLFastContextHandler *pContext)
Definition: Handler.cxx:207
virtual void attribute(Id name, Value &val) override
Receives an attribute.
Definition: Handler.cxx:217
virtual void sprm(Sprm &sprm) override
Receives a SPRM.
Definition: Handler.cxx:232
OOXMLFastContextHandler * mpFastContext
Definition: Handler.hxx:65
virtual void sprm(Sprm &sprm) override
Receives a SPRM.
Definition: Handler.cxx:373
OOXMLHyperlinkHandler(OOXMLFastContextHandler *pContext)
class OOXMLHyperlinkHandler
Definition: Handler.cxx:327
OOXMLFastContextHandler * mpFastContext
Definition: Handler.hxx:138
virtual void attribute(Id name, Value &val) override
Receives an attribute.
Definition: Handler.cxx:342
virtual void attribute(Id name, Value &val) override
Receives an attribute.
Definition: Handler.cxx:392
OOXMLHyperlinkURLHandler(OOXMLFastContextHandler *pContext)
class OOXMLHyperlinkURLHandler
Definition: Handler.cxx:381
OOXMLFastContextHandler * mpFastContext
Definition: Handler.hxx:153
virtual void sprm(Sprm &sprm) override
Receives a SPRM.
Definition: Handler.cxx:404
virtual void sprm(Sprm &sprm) override
Receives a SPRM.
Definition: Handler.cxx:143
virtual void attribute(Id name, Value &val) override
Receives an attribute.
Definition: Handler.cxx:124
virtual ~OOXMLOLEHandler() override
Definition: Handler.cxx:120
OOXMLFastContextHandler * mpFastContext
Definition: Handler.hxx:89
OOXMLOLEHandler(OOXMLFastContextHandler *pContext)
Definition: Handler.cxx:115
OOXMLFastContextHandler * mpFastContext
Definition: Handler.hxx:126
virtual void sprm(Sprm &sprm) override
Receives a SPRM.
Definition: Handler.cxx:314
virtual void attribute(Id name, Value &val) override
Receives an attribute.
Definition: Handler.cxx:301
OOXMLPictureHandler(OOXMLFastContextHandler *pContext)
Definition: Handler.cxx:292
const char * name
#define SAL_WARN(area, stream)
sal_uInt32 Id
sal_Int32 mnType
unsigned char sal_uInt8