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_CreateFromStarImage
[] = "CreateFromStarImage";
53 const sal_Char sAPI_CreateFromStarMath
[] = "CreateFromStarMath";
54 const sal_Char sAPI_CreateFromOtherEmbeddedObjects
[] = "CreateFromOtherEmbeddedObjects";
57 TYPEINIT1( XMLIndexObjectSourceContext
, XMLIndexSourceBaseContext
);
59 XMLIndexObjectSourceContext::XMLIndexObjectSourceContext(
62 const OUString
& rLocalName
,
63 Reference
<XPropertySet
> & rPropSet
) :
64 XMLIndexSourceBaseContext(rImport
, nPrfx
, rLocalName
,
66 sCreateFromStarCalc(sAPI_CreateFromStarCalc
),
67 sCreateFromStarChart(sAPI_CreateFromStarChart
),
68 sCreateFromStarDraw(sAPI_CreateFromStarDraw
),
69 sCreateFromStarMath(sAPI_CreateFromStarMath
),
70 sCreateFromOtherEmbeddedObjects(sAPI_CreateFromOtherEmbeddedObjects
),
75 bUseOtherObjects(sal_False
)
79 XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext()
83 void XMLIndexObjectSourceContext::ProcessAttribute(
84 enum IndexSourceParamEnum eParam
,
85 const OUString
& rValue
)
91 case XML_TOK_INDEXSOURCE_USE_OTHER_OBJECTS
:
92 if (::sax::Converter::convertBool(bTmp
, rValue
))
94 bUseOtherObjects
= bTmp
;
98 case XML_TOK_INDEXSOURCE_USE_SHEET
:
99 if (::sax::Converter::convertBool(bTmp
, rValue
))
105 case XML_TOK_INDEXSOURCE_USE_CHART
:
106 if (::sax::Converter::convertBool(bTmp
, rValue
))
112 case XML_TOK_INDEXSOURCE_USE_DRAW
:
113 if (::sax::Converter::convertBool(bTmp
, rValue
))
119 case XML_TOK_INDEXSOURCE_USE_MATH
:
120 if (::sax::Converter::convertBool(bTmp
, rValue
))
127 XMLIndexSourceBaseContext::ProcessAttribute(eParam
, rValue
);
132 void XMLIndexObjectSourceContext::EndElement()
136 aAny
.setValue(&bUseCalc
, ::getBooleanCppuType());
137 rIndexPropertySet
->setPropertyValue(sCreateFromStarCalc
, aAny
);
139 aAny
.setValue(&bUseChart
, ::getBooleanCppuType());
140 rIndexPropertySet
->setPropertyValue(sCreateFromStarChart
, aAny
);
142 aAny
.setValue(&bUseDraw
, ::getBooleanCppuType());
143 rIndexPropertySet
->setPropertyValue(sCreateFromStarDraw
, aAny
);
145 aAny
.setValue(&bUseMath
, ::getBooleanCppuType());
146 rIndexPropertySet
->setPropertyValue(sCreateFromStarMath
, aAny
);
148 aAny
.setValue(&bUseOtherObjects
, ::getBooleanCppuType());
149 rIndexPropertySet
->setPropertyValue(sCreateFromOtherEmbeddedObjects
, aAny
);
151 XMLIndexSourceBaseContext::EndElement();
154 SvXMLImportContext
* XMLIndexObjectSourceContext::CreateChildContext(
156 const OUString
& rLocalName
,
157 const Reference
<XAttributeList
> & xAttrList
)
159 if ( (XML_NAMESPACE_TEXT
== nPrefix
) &&
160 (IsXMLToken(rLocalName
, XML_OBJECT_INDEX_ENTRY_TEMPLATE
)) )
162 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet
,
165 XML_TOKEN_INVALID
, // no outline-level attr
166 aLevelStylePropNameTableMap
,
167 aAllowedTokenTypesTable
);
171 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix
,
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */