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 <ooxml/resourceids.hxx>
21 #include <resourcemodel/QNameToString.hxx>
22 #include "Handler.hxx"
24 namespace writerfilter
{
29 class OOXMLFootnoteHandler
31 OOXMLFootnoteHandler::OOXMLFootnoteHandler(OOXMLFastContextHandler
* pContext
)
32 : mpFastContext(pContext
)
36 OOXMLFootnoteHandler::~OOXMLFootnoteHandler()
40 void OOXMLFootnoteHandler::attribute(Id name
, Value
& val
)
44 case NS_ooxml::LN_CT_FtnEdnRef_id
:
45 mpFastContext
->resolveFootnote(sal_Int32(val
.getInt()));
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
)
72 case NS_ooxml::LN_CT_FtnEdnRef_id
:
73 mpFastContext
->resolveEndnote(sal_Int32(val
.getInt()));
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
)
100 case NS_ooxml::LN_CT_Markup_id
:
101 mpFastContext
->resolveComment(val
.getInt());
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
)
128 case NS_ooxml::LN_CT_OLEObject_r_id
:
129 mpFastContext
->resolveData(val
.getString());
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
)
153 case NS_ooxml::LN_CT_Rel_id
:
154 mpFastContext
->resolveData(val
.getString());
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
)
182 case NS_ooxml::LN_CT_HdrFtrRef_id
:
183 msStreamId
= val
.getString();
185 case NS_ooxml::LN_CT_HdrFtrRef_type
:
186 mnType
= val
.getInt();
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
)
214 case NS_ooxml::LN_CT_HdrFtrRef_id
:
215 msStreamId
= val
.getString();
217 case NS_ooxml::LN_CT_HdrFtrRef_type
:
218 mnType
= val
.getInt();
225 void OOXMLHeaderHandler::sprm(Sprm
& /*sprm*/)
230 class OOXMLBreakHandler
232 OOXMLBreakHandler::OOXMLBreakHandler(Stream
&rStream
)
233 : mnType(0), mnClear(0),
238 OOXMLBreakHandler::~OOXMLBreakHandler()
240 sal_uInt8 tmpBreak
[1];
243 case NS_ooxml::LN_Value_ST_BrType_column
:
246 case NS_ooxml::LN_Value_ST_BrType_page
:
249 case NS_ooxml::LN_Value_ST_BrType_textWrapping
:
250 default: // when no attribute type is present, the spec assume textWrapping
254 mrStream
.text(&tmpBreak
[0], 1);
257 void OOXMLBreakHandler::attribute(Id name
, Value
& val
)
261 case NS_ooxml::LN_CT_Br_type
:
262 mnType
= val
.getInt();
264 case NS_ooxml::LN_CT_Br_clear
:
265 mnClear
= val
.getInt();
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());
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
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 \"");
325 sReturn
+= mFieldCode
;
327 mpFastContext
->text(sReturn
);
330 void OOXMLHyperlinkHandler::attribute(Id name
, Value
& val
)
334 case NS_ooxml::LN_CT_Hyperlink_tgtFrame
:
335 mFieldCode
+= " \\t \"";
336 mFieldCode
+= val
.getString();
339 case NS_ooxml::LN_CT_Hyperlink_tooltip
:
340 mFieldCode
+= " \\o \"";
341 mFieldCode
+= val
.getString();
344 case NS_ooxml::LN_CT_Hyperlink_docLocation
:
346 case NS_ooxml::LN_CT_Hyperlink_history
:
348 case NS_ooxml::LN_CT_Hyperlink_anchor
:
349 mFieldCode
+= " \\l \"";
350 mFieldCode
+= val
.getString();
353 case NS_ooxml::LN_CT_Hyperlink_r_id
:
354 mURL
= mpFastContext
->getTargetForId(val
.getString());
361 void OOXMLHyperlinkHandler::sprm(Sprm
& /*rSprm*/)
367 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */