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 .
21 #include "XMLIndexObjectSourceContext.hxx"
23 #include <rtl/ustring.hxx>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/container/XIndexReplace.hpp>
28 #include <sax/tools/converter.hxx>
30 #include "XMLIndexTemplateContext.hxx"
31 #include "XMLIndexTitleTemplateContext.hxx"
32 #include "XMLIndexTOCStylesContext.hxx"
33 #include <xmloff/xmlictxt.hxx>
34 #include <xmloff/xmlimp.hxx>
35 #include <xmloff/txtimp.hxx>
36 #include <xmloff/xmlnmspe.hxx>
37 #include <xmloff/nmspmap.hxx>
38 #include <xmloff/xmltoken.hxx>
41 using ::com::sun::star::beans::XPropertySet
;
42 using ::com::sun::star::uno::Reference
;
43 using ::com::sun::star::uno::Any
;
44 using ::com::sun::star::xml::sax::XAttributeList
;
45 using ::xmloff::token::IsXMLToken
;
46 using ::xmloff::token::XML_OBJECT_INDEX_ENTRY_TEMPLATE
;
47 using ::xmloff::token::XML_TOKEN_INVALID
;
49 const sal_Char sAPI_CreateFromStarCalc
[] = "CreateFromStarCalc";
50 const sal_Char sAPI_CreateFromStarChart
[] = "CreateFromStarChart";
51 const sal_Char sAPI_CreateFromStarDraw
[] = "CreateFromStarDraw";
52 const sal_Char sAPI_CreateFromStarMath
[] = "CreateFromStarMath";
53 const sal_Char sAPI_CreateFromOtherEmbeddedObjects
[] = "CreateFromOtherEmbeddedObjects";
56 TYPEINIT1( XMLIndexObjectSourceContext
, XMLIndexSourceBaseContext
);
58 XMLIndexObjectSourceContext::XMLIndexObjectSourceContext(
61 const OUString
& rLocalName
,
62 Reference
<XPropertySet
> & rPropSet
) :
63 XMLIndexSourceBaseContext(rImport
, nPrfx
, rLocalName
,
65 sCreateFromStarCalc(sAPI_CreateFromStarCalc
),
66 sCreateFromStarChart(sAPI_CreateFromStarChart
),
67 sCreateFromStarDraw(sAPI_CreateFromStarDraw
),
68 sCreateFromStarMath(sAPI_CreateFromStarMath
),
69 sCreateFromOtherEmbeddedObjects(sAPI_CreateFromOtherEmbeddedObjects
),
74 bUseOtherObjects(false)
78 XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext()
82 void XMLIndexObjectSourceContext::ProcessAttribute(
83 enum IndexSourceParamEnum eParam
,
84 const OUString
& rValue
)
90 case XML_TOK_INDEXSOURCE_USE_OTHER_OBJECTS
:
91 if (::sax::Converter::convertBool(bTmp
, rValue
))
93 bUseOtherObjects
= bTmp
;
97 case XML_TOK_INDEXSOURCE_USE_SHEET
:
98 if (::sax::Converter::convertBool(bTmp
, rValue
))
104 case XML_TOK_INDEXSOURCE_USE_CHART
:
105 if (::sax::Converter::convertBool(bTmp
, rValue
))
111 case XML_TOK_INDEXSOURCE_USE_DRAW
:
112 if (::sax::Converter::convertBool(bTmp
, rValue
))
118 case XML_TOK_INDEXSOURCE_USE_MATH
:
119 if (::sax::Converter::convertBool(bTmp
, rValue
))
126 XMLIndexSourceBaseContext::ProcessAttribute(eParam
, rValue
);
131 void XMLIndexObjectSourceContext::EndElement()
135 aAny
.setValue(&bUseCalc
, cppu::UnoType
<bool>::get());
136 rIndexPropertySet
->setPropertyValue(sCreateFromStarCalc
, aAny
);
138 aAny
.setValue(&bUseChart
, cppu::UnoType
<bool>::get());
139 rIndexPropertySet
->setPropertyValue(sCreateFromStarChart
, aAny
);
141 aAny
.setValue(&bUseDraw
, cppu::UnoType
<bool>::get());
142 rIndexPropertySet
->setPropertyValue(sCreateFromStarDraw
, aAny
);
144 aAny
.setValue(&bUseMath
, cppu::UnoType
<bool>::get());
145 rIndexPropertySet
->setPropertyValue(sCreateFromStarMath
, aAny
);
147 aAny
.setValue(&bUseOtherObjects
, cppu::UnoType
<bool>::get());
148 rIndexPropertySet
->setPropertyValue(sCreateFromOtherEmbeddedObjects
, aAny
);
150 XMLIndexSourceBaseContext::EndElement();
153 SvXMLImportContext
* XMLIndexObjectSourceContext::CreateChildContext(
155 const OUString
& rLocalName
,
156 const Reference
<XAttributeList
> & xAttrList
)
158 if ( (XML_NAMESPACE_TEXT
== nPrefix
) &&
159 (IsXMLToken(rLocalName
, XML_OBJECT_INDEX_ENTRY_TEMPLATE
)) )
161 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet
,
164 XML_TOKEN_INVALID
, // no outline-level attr
165 aLevelStylePropNameTableMap
,
166 aAllowedTokenTypesTable
);
170 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix
,
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */