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/xmlimp.hxx>
25 #include <xmloff/xmlnamespace.hxx>
26 #include <xmloff/xmltoken.hxx>
27 #include <rtl/ustring.hxx>
30 using ::com::sun::star::beans::XPropertySet
;
31 using ::com::sun::star::uno::Reference
;
32 using ::com::sun::star::uno::Any
;
33 using namespace ::xmloff::token
;
35 XMLIndexUserSourceContext::XMLIndexUserSourceContext(
37 Reference
<XPropertySet
> & rPropSet
)
38 : XMLIndexSourceBaseContext(rImport
, rPropSet
, UseStyles::Level
),
44 bUseLevelFromSource(false),
45 bUseLevelParagraphStyles(false)
49 XMLIndexUserSourceContext::~XMLIndexUserSourceContext()
53 void XMLIndexUserSourceContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter
& aIter
)
57 switch (aIter
.getToken())
59 case XML_ELEMENT(TEXT
, XML_USE_INDEX_MARKS
):
60 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
66 case XML_ELEMENT(TEXT
, XML_USE_OBJECTS
):
67 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
73 case XML_ELEMENT(TEXT
, XML_USE_GRAPHICS
):
74 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
80 case XML_ELEMENT(TEXT
, XML_USE_TABLES
):
81 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
87 case XML_ELEMENT(TEXT
, XML_USE_FLOATING_FRAMES
):
88 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
94 case XML_ELEMENT(TEXT
, XML_COPY_OUTLINE_LEVELS
):
95 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
97 bUseLevelFromSource
= bTmp
;
101 case XML_ELEMENT(TEXT
, XML_USE_INDEX_SOURCE_STYLES
):
102 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
104 bUseLevelParagraphStyles
= bTmp
;
108 case XML_ELEMENT(TEXT
, XML_INDEX_NAME
):
109 sIndexName
= aIter
.toString();
113 XMLIndexSourceBaseContext::ProcessAttribute(aIter
);
118 void XMLIndexUserSourceContext::endFastElement(sal_Int32 nElement
)
120 rIndexPropertySet
->setPropertyValue(u
"CreateFromEmbeddedObjects"_ustr
, css::uno::Any(bUseObjects
));
121 rIndexPropertySet
->setPropertyValue(u
"CreateFromGraphicObjects"_ustr
, css::uno::Any(bUseGraphic
));
122 rIndexPropertySet
->setPropertyValue(u
"UseLevelFromSource"_ustr
, css::uno::Any(bUseLevelFromSource
));
123 rIndexPropertySet
->setPropertyValue(u
"CreateFromMarks"_ustr
, css::uno::Any(bUseMarks
));
124 rIndexPropertySet
->setPropertyValue(u
"CreateFromTables"_ustr
, css::uno::Any(bUseTables
));
125 rIndexPropertySet
->setPropertyValue(u
"CreateFromTextFrames"_ustr
, css::uno::Any(bUseFrames
));
126 rIndexPropertySet
->setPropertyValue(u
"CreateFromLevelParagraphStyles"_ustr
, css::uno::Any(bUseLevelParagraphStyles
));
128 if( !sIndexName
.isEmpty() )
130 rIndexPropertySet
->setPropertyValue(u
"UserIndexName"_ustr
, css::uno::Any(sIndexName
));
133 XMLIndexSourceBaseContext::endFastElement(nElement
);
136 css::uno::Reference
< css::xml::sax::XFastContextHandler
> XMLIndexUserSourceContext::createFastChildContext(
138 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
140 if ( nElement
== XML_ELEMENT(TEXT
, XML_USER_INDEX_ENTRY_TEMPLATE
) )
142 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet
,
145 aLevelStylePropNameTOCMap
,
146 aAllowedTokenTypesUser
);
150 return XMLIndexSourceBaseContext::createFastChildContext(nElement
,
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */