LibreOffice Module xmloff (master)  1
XMLIndexUserSourceContext.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 <sax/tools/converter.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>
29 
30 
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;
36 using namespace ::xmloff::token;
37 
39  SvXMLImport& rImport,
40  Reference<XPropertySet> & rPropSet) :
42  rPropSet, true),
43  bUseObjects(false),
44  bUseGraphic(false),
45  bUseMarks(false),
46  bUseTables(false),
47  bUseFrames(false),
48  bUseLevelFromSource(false),
49  bUseLevelParagraphStyles(false)
50 {
51 }
52 
54 {
55 }
56 
58 {
59  bool bTmp(false);
60 
61  switch (aIter.getToken())
62  {
64  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
65  {
66  bUseMarks = bTmp;
67  }
68  break;
69 
71  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
72  {
73  bUseObjects = bTmp;
74  }
75  break;
76 
78  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
79  {
80  bUseGraphic = bTmp;
81  }
82  break;
83 
85  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
86  {
87  bUseTables = bTmp;
88  }
89  break;
90 
92  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
93  {
94  bUseFrames = bTmp;
95  }
96  break;
97 
99  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
100  {
101  bUseLevelFromSource = bTmp;
102  }
103  break;
104 
106  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
107  {
109  }
110  break;
111 
113  sIndexName = aIter.toString();
114  break;
115 
116  default:
118  break;
119  }
120 }
121 
123 {
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));
131 
132  if( !sIndexName.isEmpty() )
133  {
134  rIndexPropertySet->setPropertyValue("UserIndexName", css::uno::Any(sIndexName));
135  }
136 
138 }
139 
140 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexUserSourceContext::createFastChildContext(
141  sal_Int32 nElement,
142  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
143 {
144  if ( nElement == XML_ELEMENT(TEXT, XML_USER_INDEX_ENTRY_TEMPLATE) )
145  {
151  }
152  else
153  {
155  xAttrList);
156  }
157 
158 }
159 
160 /* 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
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3508
virtual ~XMLIndexUserSourceContext() 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 ...
const bool aAllowedTokenTypesUser[]
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)
XMLIndexUserSourceContext(SvXMLImport &rImport, css::uno::Reference< css::beans::XPropertySet > &rPropSet)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
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 ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter) override
const SvXMLEnumMapEntry< sal_uInt16 > aSvLevelNameTOCMap[]
TEXT