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 "XMLIndexUserSourceContext.hxx"
21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <sax/tools/converter.hxx>
23 #include "XMLIndexTemplateContext.hxx"
24 #include <xmloff/xmlictxt.hxx>
25 #include <xmloff/xmlimp.hxx>
26 #include <xmloff/xmlnamespace.hxx>
27 #include <xmloff/xmltoken.hxx>
28 #include <rtl/ustring.hxx>
31 using ::com::sun::star::beans::XPropertySet
;
32 using ::com::sun::star::uno::Reference
;
33 using ::com::sun::star::uno::Any
;
34 using ::com::sun::star::xml::sax::XAttributeList
;
35 using ::xmloff::token::IsXMLToken
;
36 using ::xmloff::token::XML_USER_INDEX_ENTRY_TEMPLATE
;
37 using ::xmloff::token::XML_OUTLINE_LEVEL
;
39 XMLIndexUserSourceContext::XMLIndexUserSourceContext(
42 const OUString
& rLocalName
,
43 Reference
<XPropertySet
> & rPropSet
) :
44 XMLIndexSourceBaseContext(rImport
, nPrfx
, rLocalName
,
51 bUseLevelFromSource(false),
52 bUseLevelParagraphStyles(false)
56 XMLIndexUserSourceContext::~XMLIndexUserSourceContext()
60 void XMLIndexUserSourceContext::ProcessAttribute(
61 enum IndexSourceParamEnum eParam
,
62 const OUString
& rValue
)
68 case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS
:
69 if (::sax::Converter::convertBool(bTmp
, rValue
))
75 case XML_TOK_INDEXSOURCE_USE_OBJECTS
:
76 if (::sax::Converter::convertBool(bTmp
, rValue
))
82 case XML_TOK_INDEXSOURCE_USE_GRAPHICS
:
83 if (::sax::Converter::convertBool(bTmp
, rValue
))
89 case XML_TOK_INDEXSOURCE_USE_TABLES
:
90 if (::sax::Converter::convertBool(bTmp
, rValue
))
96 case XML_TOK_INDEXSOURCE_USE_FRAMES
:
97 if (::sax::Converter::convertBool(bTmp
, rValue
))
103 case XML_TOK_INDEXSOURCE_COPY_OUTLINE_LEVELS
:
104 if (::sax::Converter::convertBool(bTmp
, rValue
))
106 bUseLevelFromSource
= bTmp
;
110 case XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES
:
111 if (::sax::Converter::convertBool(bTmp
, rValue
))
113 bUseLevelParagraphStyles
= bTmp
;
117 case XML_TOK_INDEXSOURCE_USER_INDEX_NAME
:
122 XMLIndexSourceBaseContext::ProcessAttribute(eParam
, rValue
);
127 void XMLIndexUserSourceContext::endFastElement(sal_Int32 nElement
)
129 rIndexPropertySet
->setPropertyValue("CreateFromEmbeddedObjects", css::uno::Any(bUseObjects
));
130 rIndexPropertySet
->setPropertyValue("CreateFromGraphicObjects", css::uno::Any(bUseGraphic
));
131 rIndexPropertySet
->setPropertyValue("UseLevelFromSource", css::uno::Any(bUseLevelFromSource
));
132 rIndexPropertySet
->setPropertyValue("CreateFromMarks", css::uno::Any(bUseMarks
));
133 rIndexPropertySet
->setPropertyValue("CreateFromTables", css::uno::Any(bUseTables
));
134 rIndexPropertySet
->setPropertyValue("CreateFromTextFrames", css::uno::Any(bUseFrames
));
135 rIndexPropertySet
->setPropertyValue("CreateFromLevelParagraphStyles", css::uno::Any(bUseLevelParagraphStyles
));
137 if( !sIndexName
.isEmpty() )
139 rIndexPropertySet
->setPropertyValue("UserIndexName", css::uno::Any(sIndexName
));
142 XMLIndexSourceBaseContext::endFastElement(nElement
);
145 SvXMLImportContextRef
XMLIndexUserSourceContext::CreateChildContext(
147 const OUString
& rLocalName
,
148 const Reference
<XAttributeList
> & xAttrList
)
150 if ( (XML_NAMESPACE_TEXT
== nPrefix
) &&
151 (IsXMLToken(rLocalName
, XML_USER_INDEX_ENTRY_TEMPLATE
)) )
153 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet
,
157 aLevelStylePropNameTOCMap
,
158 aAllowedTokenTypesUser
);
162 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix
,
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */