1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Handler.cxx,v $
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
{
40 class OOXMLFootnoteHandler
42 OOXMLFootnoteHandler::OOXMLFootnoteHandler(OOXMLFastContextHandler
* pContext
)
43 : mpFastContext(pContext
)
47 OOXMLFootnoteHandler::~OOXMLFootnoteHandler()
51 void OOXMLFootnoteHandler::attribute(Id name
, Value
& val
)
55 case NS_ooxml::LN_CT_FtnEdnRef_id
:
56 mpFastContext
->resolveFootnote(val
.getString());
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
)
83 case NS_ooxml::LN_CT_FtnEdnRef_id
:
84 mpFastContext
->resolveEndnote(val
.getString());
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
)
111 case NS_ooxml::LN_CT_Markup_id
:
112 mpFastContext
->resolveComment(val
.getString());
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
)
139 case NS_ooxml::LN_CT_OLEObject_r_id
:
140 mpFastContext
->resolveOLE(val
.getString());
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
)
168 case NS_ooxml::LN_CT_HdrFtrRef_id
:
169 msStreamId
= val
.getString();
171 case NS_ooxml::LN_CT_HdrFtrRef_type
:
172 mnType
= val
.getInt();
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
)
200 case NS_ooxml::LN_CT_HdrFtrRef_id
:
201 msStreamId
= val
.getString();
203 case NS_ooxml::LN_CT_HdrFtrRef_type
:
204 mnType
= val
.getInt();
211 void OOXMLHeaderHandler::sprm(Sprm
& /*sprm*/)
216 class OOXMLBreakHandler
218 OOXMLBreakHandler::OOXMLBreakHandler(Stream
&rStream
,
219 OOXMLFastContextHandler
* pContext
)
220 : mpFastContext(pContext
), mnType(0), mnClear(0),
225 OOXMLBreakHandler::~OOXMLBreakHandler()
227 sal_uInt8 tmpBreak
[1];
230 case NS_ooxml::LN_Value_ST_BrType_column
:
233 case NS_ooxml::LN_Value_ST_BrType_page
:
236 case NS_ooxml::LN_Value_ST_BrType_textWrapping
:
237 default: // when no attribute type is present, the spec assume textWrapping
241 mrStream
.text(&tmpBreak
[0], 1);
244 void OOXMLBreakHandler::attribute(Id name
, Value
& val
)
248 case NS_ooxml::LN_CT_Br_type
:
249 mnType
= val
.getInt();
251 case NS_ooxml::LN_CT_Br_clear
:
252 mnClear
= val
.getInt();
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());
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
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 \""));
311 sReturn
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\""));
312 sReturn
+= mFieldCode
;
314 mpFastContext
->characters(sReturn
);
317 void OOXMLHyperlinkHandler::attribute(Id name
, Value
& val
)
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("\""));
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("\""));
331 case NS_ooxml::LN_CT_Hyperlink_docLocation
:
333 case NS_ooxml::LN_CT_Hyperlink_history
:
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("\""));
340 case NS_ooxml::LN_CT_Hyperlink_r_id
:
341 mURL
= mpFastContext
->getTargetForId(val
.getString());
348 void OOXMLHyperlinkHandler::sprm(Sprm
& /*rSprm*/)