LibreOffice Module xmloff (master) 1
XMLIndexSourceBaseContext.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>
24#include <xmloff/xmlictxt.hxx>
25#include <xmloff/xmlimp.hxx>
28#include <xmloff/xmltoken.hxx>
30#include <rtl/ustring.hxx>
31#include <sal/log.hxx>
32
33
34using namespace ::xmloff::token;
35
36using ::com::sun::star::beans::XPropertySet;
37using ::com::sun::star::uno::Reference;
38using ::com::sun::star::uno::Any;
39using ::com::sun::star::xml::sax::XAttributeList;
40
41
43 SvXMLImport& rImport,
44 Reference<XPropertySet> & rPropSet,
45 bool bLevelFormats)
46: SvXMLImportContext(rImport)
47, bUseLevelFormats(bLevelFormats)
48, bChapterIndex(false)
49, bRelativeTabs(true)
50, rIndexPropertySet(rPropSet)
51{
52}
53
55{
56}
57
59 sal_Int32 /*nElement*/,
60 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
61{
62 // process attributes
63 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
64 ProcessAttribute(aIter);
65}
66
68{
69 switch (aIter.getToken())
70 {
72 if ( IsXMLToken( aIter, XML_CHAPTER ) )
73 {
74 bChapterIndex = true;
75 }
76 break;
77
79 {
80 bool bTmp(false);
81 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
82 {
83 bRelativeTabs = bTmp;
84 }
85 break;
86 }
87
88 default:
89 // unknown attribute -> ignore
90 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
91 break;
92 }
93}
94
96{
97 rIndexPropertySet->setPropertyValue("IsRelativeTabstops", css::uno::Any(bRelativeTabs));
98 rIndexPropertySet->setPropertyValue("CreateFromChapter", css::uno::Any(bChapterIndex));
99}
100
101css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexSourceBaseContext::createFastChildContext(
102 sal_Int32 nElement,
103 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
104{
105 SvXMLImportContextRef xContext;
106
107 if (nElement == XML_ELEMENT(TEXT, XML_INDEX_TITLE_TEMPLATE) )
108 {
111 }
112 else if ( bUseLevelFormats &&
114 {
115 xContext = new XMLIndexTOCStylesContext(GetImport(),
117 }
118 // else: unknown namespace -> ignore
119
120 return xContext;
121}
122
123/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
XMLIndexSourceBaseContext(SvXMLImport &rImport, css::uno::Reference< css::beans::XPropertySet > &rPropSet, bool bLevelFormats)
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?
bool bRelativeTabs
chapter-wise or document index?
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
virtual ~XMLIndexSourceBaseContext() override
virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter)
Import <test:index-source-styles> elements and their children.
static bool convertBool(bool &rBool, std::u16string_view rString)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
@ XML_RELATIVE_TAB_STOP_POSITION
Definition: xmltoken.hxx:1617
@ XML_INDEX_SOURCE_STYLES
Definition: xmltoken.hxx:1098
@ XML_INDEX_TITLE_TEMPLATE
Definition: xmltoken.hxx:1100
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3581
TEXT
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:98