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>
25#include <xmloff/xmlictxt.hxx>
26#include <xmloff/xmlimp.hxx>
27#include <xmloff/txtimp.hxx>
29#include <xmloff/xmltoken.hxx>
30#include <rtl/ustring.hxx>
31
32
33using namespace ::xmloff::token;
34
35using ::com::sun::star::beans::XPropertySet;
36using ::com::sun::star::uno::Reference;
37using ::com::sun::star::uno::Any;
38
40 SvXMLImport& rImport,
41 Reference<XPropertySet> & rPropSet)
42: XMLIndexSourceBaseContext(rImport, rPropSet, UseStyles::Level)
43 // use all chapters by default
44, nOutlineLevel(rImport.GetTextImport()->GetChapterNumbering()->getCount())
45, bUseOutline(true)
46, bUseMarks(true)
47, bUseParagraphStyles(false)
48{
49}
50
52{
53}
54
56{
57 switch (aIter.getToken())
58 {
60 if ( IsXMLToken( aIter, XML_NONE ) )
61 {
62 // #104651# use OUTLINE_LEVEL and USE_OUTLINE_LEVEL instead of
63 // OUTLINE_LEVEL with values none|1..10. For backwards
64 // compatibility, 'none' must still be read.
65 bUseOutline = false;
66 }
67 else
68 {
69 sal_Int32 nTmp;
71 nTmp, aIter.toView(), 1, GetImport().GetTextImport()->
72 GetChapterNumbering()->getCount()))
73 {
74 bUseOutline = true;
75 nOutlineLevel = nTmp;
76 }
77 }
78 break;
79
81 {
82 bool bTmp(false);
83 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
84 {
85 bUseOutline = bTmp;
86 }
87 break;
88 }
89
90
92 {
93 bool bTmp(false);
94 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
95 {
96 bUseMarks = bTmp;
97 }
98 break;
99 }
100
102 {
103 bool bTmp(false);
104 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
105 {
106 bUseParagraphStyles = bTmp;
107 }
108 break;
109 }
110
111 default:
112 // default: ask superclass
114 break;
115 }
116}
117
119{
120 rIndexPropertySet->setPropertyValue("CreateFromMarks", css::uno::Any(bUseMarks));
121 rIndexPropertySet->setPropertyValue("CreateFromOutline", css::uno::Any(bUseOutline));
122 rIndexPropertySet->setPropertyValue("CreateFromLevelParagraphStyles", css::uno::Any(bUseParagraphStyles));
123
124 rIndexPropertySet->setPropertyValue("Level", css::uno::Any(static_cast<sal_Int16>(nOutlineLevel)));
125
126 // process common attributes
128}
129
130css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexTOCSourceContext::createFastChildContext(
131 sal_Int32 nElement,
132 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
133{
135 {
140 aAllowedTokenTypesTOC, true );
141 }
142 else
143 {
145 xAttrList);
146 }
147}
148
149/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const char * aLevelStylePropNameTOCMap[]
const bool aAllowedTokenTypesTOC[]
const SvXMLEnumMapEntry< sal_uInt16 > aSvLevelNameTOCMap[]
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
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
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 ...
css::uno::Reference< css::beans::XPropertySet > & rIndexPropertySet
tab stops relative to margin or indent?
virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter)
XMLIndexTOCSourceContext(SvXMLImport &rImport, css::uno::Reference< css::beans::XPropertySet > &rPropSet)
virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter) override
virtual ~XMLIndexTOCSourceContext() override
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 css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Import index entry templates.
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
static bool convertBool(bool &rBool, std::u16string_view rString)
Handling of tokens in XML:
@ XML_TABLE_OF_CONTENT_ENTRY_TEMPLATE
Definition: xmltoken.hxx:1927
@ XML_USE_INDEX_SOURCE_STYLES
Definition: xmltoken.hxx:2074
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3597
TEXT
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97