LibreOffice Module writerfilter (master) 1
OOXMLFactory.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sax/fastattribs.hxx>
21#include "OOXMLFactory.hxx"
22
23namespace writerfilter::ooxml {
24
25using namespace com::sun::star;
26
27
29{
30}
31
32
35{
36 Id nDefine = pHandler->getDefine();
38
39 if (!pFactory)
40 return;
41
44
45 const AttributeInfo *pAttr = pFactory->getAttributeInfoArray(nDefine);
46 if (!pAttr)
47 return;
48
49 for (; pAttr->m_nToken != -1; ++pAttr)
50 {
51 sal_Int32 nToken = pAttr->m_nToken;
52 sal_Int32 nAttrIndex = rAttribs.getAttributeIndex(nToken);
53 if (nAttrIndex == -1)
54 continue;
55
56 Id nId = pFactory->getResourceId(nDefine, nToken);
57
59 switch (pAttr->m_nResource)
60 {
62 xValue = OOXMLBooleanValue::Create(rAttribs.getAsViewByIndex(nAttrIndex));
63 break;
65 xValue = new OOXMLStringValue(rAttribs.getValueByIndex(nAttrIndex));
66 break;
68 xValue = OOXMLIntegerValue::Create(rAttribs.getAsIntegerByIndex(nAttrIndex));
69 break;
71 xValue = new OOXMLHexValue(rAttribs.getAsViewByIndex(nAttrIndex));
72 break;
74 xValue = new OOXMLHexColorValue(rAttribs.getAsViewByIndex(nAttrIndex));
75 break;
78 xValue = new OOXMLTwipsMeasureValue(rAttribs.getAsViewByIndex(nAttrIndex));
79 if (xValue->getInt() < 0)
80 {
82 xValue = OOXMLIntegerValue::Create(0);
83 }
84 break;
86 xValue = new OOXMLHpsMeasureValue(rAttribs.getAsViewByIndex(nAttrIndex));
87 break;
89 xValue = new OOXMLMeasurementOrPercentValue(rAttribs.getAsViewByIndex(nAttrIndex));
90 break;
92 if (sal_uInt32 nValue;
93 pFactory->getListValue(pAttr->m_nRef, rAttribs.getAsViewByIndex(nAttrIndex), nValue))
94 {
96 }
97 break;
98 default:
99 break;
100 }
101
102 if (xValue)
103 {
104 pHandler->newProperty(nId, xValue);
105 pFactory->attributeAction(pHandler, nToken, xValue);
106 }
107 }
108}
109
112 Token_t Element)
113{
114 Id nDefine = pHandler->getDefine();
115
117
119
120 //Avoid handling unknown tokens and recursing to death
121 if ((Element & 0xffff) < oox::XML_TOKEN_COUNT)
122 ret = createFastChildContextFromFactory(pHandler, pFactory, Element);
123
124 return ret;
125}
126
128 const OUString & rString)
129{
130 Id nDefine = pHandler->getDefine();
132
133 if (pFactory)
134 {
135 pFactory->charactersAction(pHandler, rString);
136 }
137}
138
140{
141 Id nDefine = pHandler->getDefine();
143
144 if (pFactory)
145 {
146 pFactory->startAction(pHandler);
147 }
148}
149
151{
152 Id nDefine = pHandler->getDefine();
154
155 if (pFactory)
156 {
157 pFactory->endAction(pHandler);
158 }
159}
160
162{
163}
164
166{
167}
168
170{
171}
172
174{
175}
176
177}
178
179/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString getValueByIndex(sal_Int32 nTokenIndex) const
std::string_view getAsViewByIndex(sal_Int32 nTokenIndex) const
sal_Int32 getAttributeIndex(::sal_Int32 Token)
sal_Int32 getAsIntegerByIndex(sal_Int32 nTokenIndex) const
static OOXMLValue::Pointer_t const & Create(bool bValue)
virtual void charactersAction(OOXMLFastContextHandler *pHandler, const OUString &rString)
virtual void endAction(OOXMLFastContextHandler *pHandler)
virtual void startAction(OOXMLFastContextHandler *pHandler)
virtual void attributeAction(OOXMLFastContextHandler *pHandler, Token_t nToken, const OOXMLValue::Pointer_t &pValue)
static css::uno::Reference< css::xml::sax::XFastContextHandler > createFastChildContextFromFactory(OOXMLFastContextHandler *pHandler, OOXMLFactory_ns::Pointer_t pFactory, Token_t Element)
static void attributes(OOXMLFastContextHandler *pHandler, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs)
static void characters(OOXMLFastContextHandler *pHandler, const OUString &rString)
static void startAction(OOXMLFastContextHandler *pHandler)
static OOXMLFactory_ns::Pointer_t getFactoryForNamespace(Id id)
static void endAction(OOXMLFastContextHandler *pHandler)
static css::uno::Reference< css::xml::sax::XFastContextHandler > createFastChildContext(OOXMLFastContextHandler *pHandler, Token_t Element)
virtual void newProperty(Id aId, const OOXMLValue::Pointer_t &pVal)
static OOXMLValue::Pointer_t Create(sal_Int32 nValue)
sal_Int16 nValue
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
OOXMLNthPtMeasureValue< 2 > OOXMLHpsMeasureValue
Handles OOXML's ST_HpsMeasure value.
OOXMLNthPtMeasureValue< 20 > OOXMLTwipsMeasureValue
Handles OOXML's ST_TwipsMeasure value.
sal_Int32 Token_t
sal_Int16 nId
DefTokenId nToken
sal_uInt32 Id