merge the formfield patch from ooo-build
[ooovba.git] / writerfilter / source / ooxml / Handler.cxx
blobc0647d3e0b3df47bcaf10bf4fe755d26de31a912
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Handler.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <ooxml/resourceids.hxx>
32 #include <resourcemodel/QNameToString.hxx>
33 #include "Handler.hxx"
35 namespace writerfilter {
36 namespace ooxml
40 class OOXMLFootnoteHandler
42 OOXMLFootnoteHandler::OOXMLFootnoteHandler(OOXMLFastContextHandler * pContext)
43 : mpFastContext(pContext)
47 OOXMLFootnoteHandler::~OOXMLFootnoteHandler()
51 void OOXMLFootnoteHandler::attribute(Id name, Value & val)
53 switch (name)
55 case NS_ooxml::LN_CT_FtnEdnRef_id:
56 mpFastContext->resolveFootnote(val.getString());
57 break;
58 default:
59 break;
63 void OOXMLFootnoteHandler::sprm(Sprm & /*sprm*/)
68 class OOXMLEndnoteHandler
70 OOXMLEndnoteHandler::OOXMLEndnoteHandler(OOXMLFastContextHandler * pContext)
71 : mpFastContext(pContext)
75 OOXMLEndnoteHandler::~OOXMLEndnoteHandler()
79 void OOXMLEndnoteHandler::attribute(Id name, Value & val)
81 switch (name)
83 case NS_ooxml::LN_CT_FtnEdnRef_id:
84 mpFastContext->resolveEndnote(val.getString());
85 break;
86 default:
87 break;
91 void OOXMLEndnoteHandler::sprm(Sprm & /*sprm*/)
96 class OOXMLCommentHandler
98 OOXMLCommentHandler::OOXMLCommentHandler(OOXMLFastContextHandler * pContext)
99 : mpFastContext(pContext)
103 OOXMLCommentHandler::~OOXMLCommentHandler()
107 void OOXMLCommentHandler::attribute(Id name, Value & val)
109 switch (name)
111 case NS_ooxml::LN_CT_Markup_id:
112 mpFastContext->resolveComment(val.getString());
113 break;
114 default:
119 void OOXMLCommentHandler::sprm(Sprm & /*sprm*/)
124 class OOXMLOLEHandler
126 OOXMLOLEHandler::OOXMLOLEHandler(OOXMLFastContextHandler * pContext)
127 : mpFastContext(pContext)
131 OOXMLOLEHandler::~OOXMLOLEHandler()
135 void OOXMLOLEHandler::attribute(Id name, Value & val)
137 switch (name)
139 case NS_ooxml::LN_CT_OLEObject_r_id:
140 mpFastContext->resolveOLE(val.getString());
141 break;
142 default:
147 void OOXMLOLEHandler::sprm(Sprm & /*sprm*/)
152 class OOXMLFooterHandler
154 OOXMLFooterHandler::OOXMLFooterHandler(OOXMLFastContextHandler * pContext)
155 : mpFastContext(pContext), msStreamId(), mnType(0)
159 OOXMLFooterHandler::~OOXMLFooterHandler()
161 mpFastContext->resolveFooter(mnType, msStreamId);
164 void OOXMLFooterHandler::attribute(Id name, Value & val)
166 switch (name)
168 case NS_ooxml::LN_CT_HdrFtrRef_id:
169 msStreamId = val.getString();
170 break;
171 case NS_ooxml::LN_CT_HdrFtrRef_type:
172 mnType = val.getInt();
173 break;
174 default:
175 break;
179 void OOXMLFooterHandler::sprm(Sprm & /*sprm*/)
184 class OOXMLHeaderHandler
186 OOXMLHeaderHandler::OOXMLHeaderHandler(OOXMLFastContextHandler * pContext)
187 : mpFastContext(pContext), msStreamId(), mnType(0)
191 OOXMLHeaderHandler::~OOXMLHeaderHandler()
193 mpFastContext->resolveHeader(mnType, msStreamId);
196 void OOXMLHeaderHandler::attribute(Id name, Value & val)
198 switch (name)
200 case NS_ooxml::LN_CT_HdrFtrRef_id:
201 msStreamId = val.getString();
202 break;
203 case NS_ooxml::LN_CT_HdrFtrRef_type:
204 mnType = val.getInt();
205 break;
206 default:
207 break;
211 void OOXMLHeaderHandler::sprm(Sprm & /*sprm*/)
216 class OOXMLBreakHandler
218 OOXMLBreakHandler::OOXMLBreakHandler(Stream &rStream,
219 OOXMLFastContextHandler * pContext)
220 : mpFastContext(pContext), mnType(0), mnClear(0),
221 mrStream(rStream)
225 OOXMLBreakHandler::~OOXMLBreakHandler()
227 sal_uInt8 tmpBreak[1];
228 switch (mnType)
230 case NS_ooxml::LN_Value_ST_BrType_column:
231 tmpBreak[0] = 0x0E;
232 break;
233 case NS_ooxml::LN_Value_ST_BrType_page:
234 tmpBreak[0] = 0x0C;
235 break;
236 case NS_ooxml::LN_Value_ST_BrType_textWrapping:
237 default: // when no attribute type is present, the spec assume textWrapping
238 tmpBreak[0] = 0x0A;
239 break;
241 mrStream.text(&tmpBreak[0], 1);
244 void OOXMLBreakHandler::attribute(Id name, Value & val)
246 switch (name)
248 case NS_ooxml::LN_CT_Br_type:
249 mnType = val.getInt();
250 break;
251 case NS_ooxml::LN_CT_Br_clear:
252 mnClear = val.getInt();
253 break;
254 default:
255 break;
259 void OOXMLBreakHandler::sprm(Sprm & /*sprm*/)
264 class OOXMLPictureHandler
266 OOXMLPictureHandler::OOXMLPictureHandler(OOXMLFastContextHandler * pContext)
267 : mpFastContext(pContext)
271 OOXMLPictureHandler::~OOXMLPictureHandler()
275 void OOXMLPictureHandler::attribute(Id name, Value & val)
277 if (name == NS_ooxml::LN_AG_Blob_r_embed)
278 mpFastContext->resolvePicture(val.getString());
279 else
281 writerfilter::Reference<Properties>::Pointer_t pProps
282 (val.getProperties());
283 if (pProps.get() != NULL)
284 pProps->resolve(*this);
288 void OOXMLPictureHandler::sprm(Sprm & rSprm)
290 writerfilter::Reference<Properties>::Pointer_t pProps
291 (rSprm.getProps());
293 if (pProps.get() != NULL)
294 pProps->resolve(*this);
298 class OOXMLHyperlinkHandler
301 OOXMLHyperlinkHandler::OOXMLHyperlinkHandler(OOXMLFastContextHandler * pContext)
302 : mpFastContext(pContext)
306 OOXMLHyperlinkHandler::~OOXMLHyperlinkHandler()
308 ::rtl::OUString sReturn(RTL_CONSTASCII_USTRINGPARAM(" HYPERLINK \""));
310 sReturn += mURL;
311 sReturn += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\""));
312 sReturn += mFieldCode;
314 mpFastContext->characters(sReturn);
317 void OOXMLHyperlinkHandler::attribute(Id name, Value & val)
319 switch (name)
321 case NS_ooxml::LN_CT_Hyperlink_tgtFrame:
322 mFieldCode += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" \\t \""));
323 mFieldCode += val.getString();
324 mFieldCode += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\""));
325 break;
326 case NS_ooxml::LN_CT_Hyperlink_tooltip:
327 mFieldCode += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" \\o \""));
328 mFieldCode += val.getString();
329 mFieldCode += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\""));
330 break;
331 case NS_ooxml::LN_CT_Hyperlink_docLocation:
332 break;
333 case NS_ooxml::LN_CT_Hyperlink_history:
334 break;
335 case NS_ooxml::LN_CT_Hyperlink_anchor:
336 mFieldCode += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" \\l \""));
337 mFieldCode += val.getString();
338 mFieldCode += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\""));
339 break;
340 case NS_ooxml::LN_CT_Hyperlink_r_id:
341 mURL = mpFastContext->getTargetForId(val.getString());
342 break;
343 default:
344 break;
348 void OOXMLHyperlinkHandler::sprm(Sprm & /*rSprm*/)