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 .
19 #ifndef INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLFASTHELPER_HXX
20 #define INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLFASTHELPER_HXX
23 #include <resourcemodel/QNameToString.hxx>
24 #include "OOXMLFastContextHandler.hxx"
25 #include "ooxmlLoggers.hxx"
26 namespace writerfilter
{
35 static css::uno::Reference
<css::xml::sax::XFastContextHandler
> createAndSetParent
36 (OOXMLFastContextHandler
* pHandler
, sal_uInt32 nToken
, Id nId
);
38 static css::uno::Reference
<css::xml::sax::XFastContextHandler
> createAndSetParentAndDefine
39 (OOXMLFastContextHandler
* pHandler
, sal_uInt32 nToken
, Id nId
, Id nDefine
);
41 static css::uno::Reference
<css::xml::sax::XFastContextHandler
> createAndSetParentRef
42 (OOXMLFastContextHandler
* pHandler
, sal_uInt32 nToken
,
43 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
);
45 static void newProperty(OOXMLFastContextHandler
* pHandler
,
47 const OUString
& rValue
);
49 static void newProperty(OOXMLFastContextHandler
* pHandler
,
50 Id nId
, sal_Int32 nValue
);
52 static void attributes
53 (OOXMLFastContextHandler
* pContext
,
54 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
);
58 uno::Reference
<css::xml::sax::XFastContextHandler
>
59 OOXMLFastHelper
<T
>::createAndSetParent
60 (OOXMLFastContextHandler
* pHandler
, sal_uInt32 nToken
, Id nId
)
63 debug_logger
->startElement("helper.createAndSetParent");
64 debug_logger
->attribute("context", pHandler
->getType());
65 debug_logger
->attribute("id", (*QNameToString::Instance())(nId
));
68 OOXMLFastContextHandler
* pTmp
= new T(pHandler
);
70 pTmp
->setToken(nToken
);
74 debug_logger
->startElement("createAndSetParent");
75 debug_logger
->attribute("context", pHandler
->getType());
76 debug_logger
->attribute("token", fastTokenToId(pTmp
->getToken()));
77 debug_logger
->attribute("id", (*QNameToString::Instance())(nId
));
79 debug_logger
->startElement("created");
80 debug_logger
->addTag(pTmp
->toTag());
81 debug_logger
->endElement("created");
82 debug_logger
->endElement("helper.createAndSetParent");
85 css::uno::Reference
<css::xml::sax::XFastContextHandler
> aResult(pTmp
);
91 uno::Reference
<css::xml::sax::XFastContextHandler
>
92 OOXMLFastHelper
<T
>::createAndSetParentAndDefine
93 (OOXMLFastContextHandler
* pHandler
, sal_uInt32 nToken
, Id nId
, Id nDefine
)
96 debug_logger
->startElement("helper.createAndSetParentAndDefine");
97 debug_logger
->attribute("context", pHandler
->getType());
98 debug_logger
->attribute("id", (*QNameToString::Instance())(nId
));
100 static char buffer
[16];
101 snprintf(buffer
, sizeof(buffer
), "0x%08" SAL_PRIxUINT32
, nId
);
103 debug_logger
->attribute("idnum", buffer
);
106 OOXMLFastContextHandler
* pTmp
= new T(pHandler
);
108 pTmp
->setToken(nToken
);
110 pTmp
->setDefine(nDefine
);
114 debug_logger
->startElement("created");
115 debug_logger
->addTag(pTmp
->toTag());
116 debug_logger
->endElement("created");
117 debug_logger
->endElement("helper.createAndSetParentAndDefine");
120 css::uno::Reference
<css::xml::sax::XFastContextHandler
> aResult(pTmp
);
126 uno::Reference
<css::xml::sax::XFastContextHandler
>
127 OOXMLFastHelper
<T
>::createAndSetParentRef
128 (OOXMLFastContextHandler
* pHandler
, sal_uInt32 nToken
,
129 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
)
132 debug_logger
->startElement("helper.createAndSetParentRef");
133 debug_logger
->attribute("context", pHandler
->getType());
134 debug_logger
->attribute("type", fastTokenToId(nToken
));
137 boost::shared_ptr
<OOXMLFastContextHandler
> pTmp(new T(pHandler
));
139 css::uno::Reference
<css::xml::sax::XFastContextHandler
> xChild
=
140 pTmp
->createFastChildContext(nToken
, Attribs
);
144 OOXMLFastContextHandler
* pResult
= dynamic_cast<OOXMLFastContextHandler
*>(xChild
.get());
145 pResult
->setToken(nToken
);
146 pResult
->setParent(pHandler
);
151 debug_logger
->startElement("created");
152 debug_logger
->addTag(pTmp
->toTag());
153 debug_logger
->endElement("created");
154 debug_logger
->endElement("helper.createAndSetParentRef");
161 void OOXMLFastHelper
<T
>::newProperty(OOXMLFastContextHandler
* pHandler
,
163 const OUString
& rValue
)
165 OOXMLValue::Pointer_t
pVal(new T(rValue
));
168 string aStr
= (*QNameToString::Instance())(nId
);
170 debug_logger
->startElement("newProperty-from-string");
171 debug_logger
->attribute("name", aStr
);
172 debug_logger
->attribute
175 (rValue
, RTL_TEXTENCODING_ASCII_US
).getStr());
178 debug_logger
->element( "unknown-qname" );
181 pHandler
->newProperty(nId
, pVal
);
184 debug_logger
->endElement();
190 void OOXMLFastHelper
<T
>::newProperty(OOXMLFastContextHandler
* pHandler
,
194 OOXMLValue::Pointer_t
pVal(new T(nVal
));
197 string aStr
= (*QNameToString::Instance())(nId
);
199 debug_logger
->startElement("helper.newProperty-from-int");
200 debug_logger
->attribute("name", aStr
);
201 debug_logger
->attribute("value", pVal
->toString());
204 debug_logger
->element("unknown-qname");
206 debug_logger
->endElement();
209 pHandler
->newProperty(nId
, pVal
);
213 #endif // INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLFASTHELPER_HXX
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */