LibreOffice Module xmloff (master)  1
XMLIndexTOCSourceContext.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <com/sun/star/container/XIndexReplace.hpp>
23 #include <sax/tools/converter.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>
31 
32 
33 using namespace ::xmloff::token;
34 
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;
39 
41  SvXMLImport& rImport,
42  Reference<XPropertySet> & rPropSet)
43 : XMLIndexSourceBaseContext(rImport, rPropSet, true)
44  // use all chapters by default
45 , nOutlineLevel(rImport.GetTextImport()->GetChapterNumbering()->getCount())
46 , bUseOutline(true)
47 , bUseMarks(true)
48 , bUseParagraphStyles(false)
49 {
50 }
51 
53 {
54 }
55 
57 {
58  switch (aIter.getToken())
59  {
61  if ( IsXMLToken( aIter, XML_NONE ) )
62  {
63  // #104651# use OUTLINE_LEVEL and USE_OUTLINE_LEVEL instead of
64  // OUTLINE_LEVEL with values none|1..10. For backwards
65  // compatibility, 'none' must still be read.
66  bUseOutline = false;
67  }
68  else
69  {
70  sal_Int32 nTmp;
72  nTmp, aIter.toView(), 1, GetImport().GetTextImport()->
73  GetChapterNumbering()->getCount()))
74  {
75  bUseOutline = true;
76  nOutlineLevel = nTmp;
77  }
78  }
79  break;
80 
82  {
83  bool bTmp(false);
84  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
85  {
86  bUseOutline = bTmp;
87  }
88  break;
89  }
90 
91 
93  {
94  bool bTmp(false);
95  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
96  {
97  bUseMarks = bTmp;
98  }
99  break;
100  }
101 
103  {
104  bool bTmp(false);
105  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
106  {
107  bUseParagraphStyles = bTmp;
108  }
109  break;
110  }
111 
112  default:
113  // default: ask superclass
115  break;
116  }
117 }
118 
120 {
121  rIndexPropertySet->setPropertyValue("CreateFromMarks", css::uno::Any(bUseMarks));
122  rIndexPropertySet->setPropertyValue("CreateFromOutline", css::uno::Any(bUseOutline));
123  rIndexPropertySet->setPropertyValue("CreateFromLevelParagraphStyles", css::uno::Any(bUseParagraphStyles));
124 
125  rIndexPropertySet->setPropertyValue("Level", css::uno::Any(static_cast<sal_Int16>(nOutlineLevel)));
126 
127  // process common attributes
129 }
130 
131 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexTOCSourceContext::createFastChildContext(
132  sal_Int32 nElement,
133  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
134 {
136  {
141  aAllowedTokenTypesTOC, true );
142  }
143  else
144  {
146  xAttrList);
147  }
148 }
149 
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const char * aLevelStylePropNameTOCMap[]
Superclass for index source elements.
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:59
const bool aAllowedTokenTypesTOC[]
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3508
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:600
virtual ~XMLIndexTOCSourceContext() override
XMLIndexTOCSourceContext(SvXMLImport &rImport, css::uno::Reference< css::beans::XPropertySet > &rPropSet)
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter)
static bool convertBool(bool &rBool, std::u16string_view rString)
Import index entry templates.
css::uno::Reference< css::beans::XPropertySet > & rIndexPropertySet
tab stops relative to margin or indent?
Handling of tokens in XML:
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter) override
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
const SvXMLEnumMapEntry< sal_uInt16 > aSvLevelNameTOCMap[]
TEXT
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)