Bump version to 4.1-6
[LibreOffice.git] / writerfilter / source / ooxml / Handler.cxx
blob1c795256e92cea927ba14cf806f119710d452f5d
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 #include <ooxml/resourceids.hxx>
21 #include <resourcemodel/QNameToString.hxx>
22 #include "Handler.hxx"
24 namespace writerfilter {
25 namespace ooxml
29 class OOXMLFootnoteHandler
31 OOXMLFootnoteHandler::OOXMLFootnoteHandler(OOXMLFastContextHandler * pContext)
32 : mpFastContext(pContext)
36 OOXMLFootnoteHandler::~OOXMLFootnoteHandler()
40 void OOXMLFootnoteHandler::attribute(Id name, Value & val)
42 switch (name)
44 case NS_ooxml::LN_CT_FtnEdnRef_id:
45 mpFastContext->resolveFootnote(sal_Int32(val.getInt()));
46 break;
47 default:
48 break;
52 void OOXMLFootnoteHandler::sprm(Sprm & /*sprm*/)
57 class OOXMLEndnoteHandler
59 OOXMLEndnoteHandler::OOXMLEndnoteHandler(OOXMLFastContextHandler * pContext)
60 : mpFastContext(pContext)
64 OOXMLEndnoteHandler::~OOXMLEndnoteHandler()
68 void OOXMLEndnoteHandler::attribute(Id name, Value & val)
70 switch (name)
72 case NS_ooxml::LN_CT_FtnEdnRef_id:
73 mpFastContext->resolveEndnote(sal_Int32(val.getInt()));
74 break;
75 default:
76 break;
80 void OOXMLEndnoteHandler::sprm(Sprm & /*sprm*/)
85 class OOXMLCommentHandler
87 OOXMLCommentHandler::OOXMLCommentHandler(OOXMLFastContextHandler * pContext)
88 : mpFastContext(pContext)
92 OOXMLCommentHandler::~OOXMLCommentHandler()
96 void OOXMLCommentHandler::attribute(Id name, Value & val)
98 switch (name)
100 case NS_ooxml::LN_CT_Markup_id:
101 mpFastContext->resolveComment(val.getInt());
102 break;
103 default:
108 void OOXMLCommentHandler::sprm(Sprm & /*sprm*/)
113 class OOXMLOLEHandler
115 OOXMLOLEHandler::OOXMLOLEHandler(OOXMLFastContextHandler * pContext)
116 : mpFastContext(pContext)
120 OOXMLOLEHandler::~OOXMLOLEHandler()
124 void OOXMLOLEHandler::attribute(Id name, Value & val)
126 switch (name)
128 case NS_ooxml::LN_CT_OLEObject_r_id:
129 mpFastContext->resolveData(val.getString());
130 break;
131 default:
136 void OOXMLOLEHandler::sprm(Sprm & /*sprm*/)
140 OOXMLEmbeddedFontHandler::OOXMLEmbeddedFontHandler(OOXMLFastContextHandler * pContext)
141 : mpFastContext(pContext)
145 OOXMLEmbeddedFontHandler::~OOXMLEmbeddedFontHandler()
149 void OOXMLEmbeddedFontHandler::attribute(Id name, Value & val)
151 switch (name)
153 case NS_ooxml::LN_CT_Rel_id:
154 mpFastContext->resolveData(val.getString());
155 break;
156 default:
157 break;
161 void OOXMLEmbeddedFontHandler::sprm(Sprm & /*sprm*/)
166 class OOXMLFooterHandler
168 OOXMLFooterHandler::OOXMLFooterHandler(OOXMLFastContextHandler * pContext)
169 : mpFastContext(pContext), msStreamId(), mnType(0)
173 OOXMLFooterHandler::~OOXMLFooterHandler()
175 mpFastContext->resolveFooter(mnType, msStreamId);
178 void OOXMLFooterHandler::attribute(Id name, Value & val)
180 switch (name)
182 case NS_ooxml::LN_CT_HdrFtrRef_id:
183 msStreamId = val.getString();
184 break;
185 case NS_ooxml::LN_CT_HdrFtrRef_type:
186 mnType = val.getInt();
187 break;
188 default:
189 break;
193 void OOXMLFooterHandler::sprm(Sprm & /*sprm*/)
198 class OOXMLHeaderHandler
200 OOXMLHeaderHandler::OOXMLHeaderHandler(OOXMLFastContextHandler * pContext)
201 : mpFastContext(pContext), msStreamId(), mnType(0)
205 OOXMLHeaderHandler::~OOXMLHeaderHandler()
207 mpFastContext->resolveHeader(mnType, msStreamId);
210 void OOXMLHeaderHandler::attribute(Id name, Value & val)
212 switch (name)
214 case NS_ooxml::LN_CT_HdrFtrRef_id:
215 msStreamId = val.getString();
216 break;
217 case NS_ooxml::LN_CT_HdrFtrRef_type:
218 mnType = val.getInt();
219 break;
220 default:
221 break;
225 void OOXMLHeaderHandler::sprm(Sprm & /*sprm*/)
230 class OOXMLBreakHandler
232 OOXMLBreakHandler::OOXMLBreakHandler(Stream &rStream)
233 : mnType(0), mnClear(0),
234 mrStream(rStream)
238 OOXMLBreakHandler::~OOXMLBreakHandler()
240 sal_uInt8 tmpBreak[1];
241 switch (mnType)
243 case NS_ooxml::LN_Value_ST_BrType_column:
244 tmpBreak[0] = 0x0E;
245 break;
246 case NS_ooxml::LN_Value_ST_BrType_page:
247 tmpBreak[0] = 0x0C;
248 break;
249 case NS_ooxml::LN_Value_ST_BrType_textWrapping:
250 default: // when no attribute type is present, the spec assume textWrapping
251 tmpBreak[0] = 0x0A;
252 break;
254 mrStream.text(&tmpBreak[0], 1);
257 void OOXMLBreakHandler::attribute(Id name, Value & val)
259 switch (name)
261 case NS_ooxml::LN_CT_Br_type:
262 mnType = val.getInt();
263 break;
264 case NS_ooxml::LN_CT_Br_clear:
265 mnClear = val.getInt();
266 break;
267 default:
268 break;
272 void OOXMLBreakHandler::sprm(Sprm & /*sprm*/)
277 class OOXMLPictureHandler
279 OOXMLPictureHandler::OOXMLPictureHandler(OOXMLFastContextHandler * pContext)
280 : mpFastContext(pContext)
284 OOXMLPictureHandler::~OOXMLPictureHandler()
288 void OOXMLPictureHandler::attribute(Id name, Value & val)
290 if (name == NS_ooxml::LN_AG_Blob_r_embed)
291 mpFastContext->resolvePicture(val.getString());
292 else
294 writerfilter::Reference<Properties>::Pointer_t pProps
295 (val.getProperties());
296 if (pProps.get() != NULL)
297 pProps->resolve(*this);
301 void OOXMLPictureHandler::sprm(Sprm & rSprm)
303 writerfilter::Reference<Properties>::Pointer_t pProps
304 (rSprm.getProps());
306 if (pProps.get() != NULL)
307 pProps->resolve(*this);
311 class OOXMLHyperlinkHandler
314 OOXMLHyperlinkHandler::OOXMLHyperlinkHandler(OOXMLFastContextHandler * pContext)
315 : mpFastContext(pContext)
319 OOXMLHyperlinkHandler::~OOXMLHyperlinkHandler()
321 OUString sReturn(" HYPERLINK \"");
323 sReturn += mURL;
324 sReturn += "\"";
325 sReturn += mFieldCode;
327 mpFastContext->text(sReturn);
330 void OOXMLHyperlinkHandler::attribute(Id name, Value & val)
332 switch (name)
334 case NS_ooxml::LN_CT_Hyperlink_tgtFrame:
335 mFieldCode += " \\t \"";
336 mFieldCode += val.getString();
337 mFieldCode += "\"";
338 break;
339 case NS_ooxml::LN_CT_Hyperlink_tooltip:
340 mFieldCode += " \\o \"";
341 mFieldCode += val.getString();
342 mFieldCode += "\"";
343 break;
344 case NS_ooxml::LN_CT_Hyperlink_docLocation:
345 break;
346 case NS_ooxml::LN_CT_Hyperlink_history:
347 break;
348 case NS_ooxml::LN_CT_Hyperlink_anchor:
349 mFieldCode += " \\l \"";
350 mFieldCode += val.getString();
351 mFieldCode += "\"";
352 break;
353 case NS_ooxml::LN_CT_Hyperlink_r_id:
354 mURL = mpFastContext->getTargetForId(val.getString());
355 break;
356 default:
357 break;
361 void OOXMLHyperlinkHandler::sprm(Sprm & /*rSprm*/)
367 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */