nss: upgrade to release 3.73
[LibreOffice.git] / xmloff / source / text / XMLIndexTOCSourceContext.cxx
blobafc7481bc6636c200e64af9aed6f4190ab58349f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "XMLIndexTOCSourceContext.hxx"
21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <com/sun/star/container/XIndexReplace.hpp>
23 #include <sax/tools/converter.hxx>
24 #include "XMLIndexTemplateContext.hxx"
25 #include <xmloff/xmlictxt.hxx>
26 #include <xmloff/xmlimp.hxx>
27 #include <xmloff/txtimp.hxx>
28 #include <xmloff/xmlnamespace.hxx>
29 #include <xmloff/xmltoken.hxx>
30 #include <rtl/ustring.hxx>
33 using namespace ::xmloff::token;
35 using ::com::sun::star::beans::XPropertySet;
36 using ::com::sun::star::uno::Reference;
37 using ::com::sun::star::uno::Any;
38 using ::com::sun::star::xml::sax::XAttributeList;
40 XMLIndexTOCSourceContext::XMLIndexTOCSourceContext(
41 SvXMLImport& rImport,
42 sal_uInt16 nPrfx,
43 const OUString& rLocalName,
44 Reference<XPropertySet> & rPropSet)
45 : XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName, rPropSet, true)
46 // use all chapters by default
47 , nOutlineLevel(rImport.GetTextImport()->GetChapterNumbering()->getCount())
48 , bUseOutline(true)
49 , bUseMarks(true)
50 , bUseParagraphStyles(false)
54 XMLIndexTOCSourceContext::~XMLIndexTOCSourceContext()
58 void XMLIndexTOCSourceContext::ProcessAttribute(
59 enum IndexSourceParamEnum eParam,
60 const OUString& rValue)
62 switch (eParam)
64 case XML_TOK_INDEXSOURCE_OUTLINE_LEVEL:
65 if ( IsXMLToken( rValue, XML_NONE ) )
67 // #104651# use OUTLINE_LEVEL and USE_OUTLINE_LEVEL instead of
68 // OUTLINE_LEVEL with values none|1..10. For backwards
69 // compatibility, 'none' must still be read.
70 bUseOutline = false;
72 else
74 sal_Int32 nTmp;
75 if (::sax::Converter::convertNumber(
76 nTmp, rValue, 1, GetImport().GetTextImport()->
77 GetChapterNumbering()->getCount()))
79 bUseOutline = true;
80 nOutlineLevel = nTmp;
83 break;
85 case XML_TOK_INDEXSOURCE_USE_OUTLINE_LEVEL:
87 bool bTmp(false);
88 if (::sax::Converter::convertBool(bTmp, rValue))
90 bUseOutline = bTmp;
92 break;
96 case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS:
98 bool bTmp(false);
99 if (::sax::Converter::convertBool(bTmp, rValue))
101 bUseMarks = bTmp;
103 break;
106 case XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES:
108 bool bTmp(false);
109 if (::sax::Converter::convertBool(bTmp, rValue))
111 bUseParagraphStyles = bTmp;
113 break;
116 default:
117 // default: ask superclass
118 XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
119 break;
123 void XMLIndexTOCSourceContext::endFastElement(sal_Int32 nElement)
125 rIndexPropertySet->setPropertyValue("CreateFromMarks", css::uno::Any(bUseMarks));
126 rIndexPropertySet->setPropertyValue("CreateFromOutline", css::uno::Any(bUseOutline));
127 rIndexPropertySet->setPropertyValue("CreateFromLevelParagraphStyles", css::uno::Any(bUseParagraphStyles));
129 rIndexPropertySet->setPropertyValue("Level", css::uno::Any(static_cast<sal_Int16>(nOutlineLevel)));
131 // process common attributes
132 XMLIndexSourceBaseContext::endFastElement(nElement);
135 SvXMLImportContextRef XMLIndexTOCSourceContext::CreateChildContext(
136 sal_uInt16 nPrefix,
137 const OUString& rLocalName,
138 const Reference<XAttributeList> & xAttrList )
140 if ( (XML_NAMESPACE_TEXT == nPrefix) &&
141 IsXMLToken(rLocalName, XML_TABLE_OF_CONTENT_ENTRY_TEMPLATE) )
143 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
144 nPrefix, rLocalName,
145 aSvLevelNameTOCMap,
146 XML_OUTLINE_LEVEL,
147 aLevelStylePropNameTOCMap,
148 aAllowedTokenTypesTOC, true );
150 else
152 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
153 rLocalName,
154 xAttrList);
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */