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 namespace ::xmloff::token
;
38 XMLIndexUserSourceContext::XMLIndexUserSourceContext(
40 Reference
<XPropertySet
> & rPropSet
) :
41 XMLIndexSourceBaseContext(rImport
,
48 bUseLevelFromSource(false),
49 bUseLevelParagraphStyles(false)
53 XMLIndexUserSourceContext::~XMLIndexUserSourceContext()
57 void XMLIndexUserSourceContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter
& aIter
)
61 switch (aIter
.getToken())
63 case XML_ELEMENT(TEXT
, XML_USE_INDEX_MARKS
):
64 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
70 case XML_ELEMENT(TEXT
, XML_USE_OBJECTS
):
71 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
77 case XML_ELEMENT(TEXT
, XML_USE_GRAPHICS
):
78 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
84 case XML_ELEMENT(TEXT
, XML_USE_TABLES
):
85 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
91 case XML_ELEMENT(TEXT
, XML_USE_FLOATING_FRAMES
):
92 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
98 case XML_ELEMENT(TEXT
, XML_COPY_OUTLINE_LEVELS
):
99 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
101 bUseLevelFromSource
= bTmp
;
105 case XML_ELEMENT(TEXT
, XML_USE_INDEX_SOURCE_STYLES
):
106 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
108 bUseLevelParagraphStyles
= bTmp
;
112 case XML_ELEMENT(TEXT
, XML_INDEX_NAME
):
113 sIndexName
= aIter
.toString();
117 XMLIndexSourceBaseContext::ProcessAttribute(aIter
);
122 void XMLIndexUserSourceContext::endFastElement(sal_Int32 nElement
)
124 rIndexPropertySet
->setPropertyValue("CreateFromEmbeddedObjects", css::uno::Any(bUseObjects
));
125 rIndexPropertySet
->setPropertyValue("CreateFromGraphicObjects", css::uno::Any(bUseGraphic
));
126 rIndexPropertySet
->setPropertyValue("UseLevelFromSource", css::uno::Any(bUseLevelFromSource
));
127 rIndexPropertySet
->setPropertyValue("CreateFromMarks", css::uno::Any(bUseMarks
));
128 rIndexPropertySet
->setPropertyValue("CreateFromTables", css::uno::Any(bUseTables
));
129 rIndexPropertySet
->setPropertyValue("CreateFromTextFrames", css::uno::Any(bUseFrames
));
130 rIndexPropertySet
->setPropertyValue("CreateFromLevelParagraphStyles", css::uno::Any(bUseLevelParagraphStyles
));
132 if( !sIndexName
.isEmpty() )
134 rIndexPropertySet
->setPropertyValue("UserIndexName", css::uno::Any(sIndexName
));
137 XMLIndexSourceBaseContext::endFastElement(nElement
);
140 css::uno::Reference
< css::xml::sax::XFastContextHandler
> XMLIndexUserSourceContext::createFastChildContext(
142 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
144 if ( nElement
== XML_ELEMENT(TEXT
, XML_USER_INDEX_ENTRY_TEMPLATE
) )
146 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet
,
149 aLevelStylePropNameTOCMap
,
150 aAllowedTokenTypesUser
);
154 return XMLIndexSourceBaseContext::createFastChildContext(nElement
,
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */