LibreOffice Module xmloff (master)  1
XMLIndexTableSourceContext.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 
20 
22 
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/text/ReferenceFieldPart.hpp>
25 
26 #include <sax/tools/converter.hxx>
27 
29 #include <xmloff/xmlictxt.hxx>
30 #include <xmloff/xmlimp.hxx>
31 #include <xmloff/xmlnmspe.hxx>
32 #include <xmloff/xmltoken.hxx>
33 #include <xmloff/xmluconv.hxx>
34 #include <xmloff/xmlement.hxx>
35 #include <rtl/ustring.hxx>
36 
37 
38 using namespace ::com::sun::star::text;
39 using namespace ::xmloff::token;
40 
41 using ::com::sun::star::beans::XPropertySet;
42 using ::com::sun::star::uno::Reference;
43 using ::com::sun::star::uno::Any;
44 using ::com::sun::star::xml::sax::XAttributeList;
45 
47  SvXMLImport& rImport, sal_uInt16 nPrfx,
48  const OUString& rLocalName, Reference<XPropertySet> & rPropSet)
49  : XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
50  rPropSet, false)
51  , nDisplayFormat(0)
52  , bSequenceOK(false)
53  , bDisplayFormatOK(false)
54  , bUseCaption(true)
55 {
56 }
57 
59 {
60 }
61 
63 {
64 
65  { XML_TEXT, ReferenceFieldPart::TEXT },
66  { XML_CATEGORY_AND_VALUE, ReferenceFieldPart::CATEGORY_AND_NUMBER },
67  { XML_CAPTION, ReferenceFieldPart::ONLY_CAPTION },
68 
69  // wrong values that previous versions wrote:
70  { XML_CHAPTER, ReferenceFieldPart::CATEGORY_AND_NUMBER },
71  { XML_PAGE, ReferenceFieldPart::ONLY_CAPTION },
72 
73  { XML_TOKEN_INVALID, 0 }
74 };
75 
77  enum IndexSourceParamEnum eParam,
78  const OUString& rValue)
79 {
80  bool bTmp(false);
81 
82  switch (eParam)
83  {
85  if (::sax::Converter::convertBool(bTmp, rValue))
86  {
87  bUseCaption = bTmp;
88  }
89  break;
90 
92  sSequence = rValue;
93  bSequenceOK = true;
94  break;
95 
97  {
98  sal_uInt16 nTmp;
99  if (SvXMLUnitConverter::convertEnum(nTmp, rValue,
100  lcl_aReferenceTypeTokenMap))
101  {
102  nDisplayFormat = nTmp;
103  bDisplayFormatOK = true;
104  }
105  break;
106  }
107 
108  default:
110  break;
111  }
112 }
113 
115 {
116  rIndexPropertySet->setPropertyValue("CreateFromLabels", css::uno::Any(bUseCaption));
117 
118  if (bSequenceOK)
119  {
120  rIndexPropertySet->setPropertyValue("LabelCategory", css::uno::Any(sSequence));
121  }
122 
123  if (bDisplayFormatOK)
124  {
125  rIndexPropertySet->setPropertyValue("LabelDisplayType", css::uno::Any(nDisplayFormat));
126  }
127 
129 }
130 
132  sal_uInt16 nPrefix,
133  const OUString& rLocalName,
134  const Reference<XAttributeList> & xAttrList )
135 {
136  if ( ( XML_NAMESPACE_TEXT == nPrefix ) &&
137  ( IsXMLToken( rLocalName, XML_TABLE_INDEX_ENTRY_TEMPLATE ) ) )
138  {
140  nPrefix, rLocalName,
142  XML_TOKEN_INVALID, // no outline-level attr
145  }
146  else
147  {
149  rLocalName,
150  xAttrList);
151  }
152 
153 }
154 
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const char * aLevelStylePropNameTableMap[]
virtual void ProcessAttribute(enum IndexSourceParamEnum eParam, const OUString &rValue) override
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3422
static bool convertEnum(EnumT &rEnum, const OUString &rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
Definition: xmluconv.hxx:128
static bool convertBool(bool &rBool, const OUString &rString)
Superclass for index source elements.
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
constexpr sal_uInt16 XML_NAMESPACE_TEXT
Definition: xmlnmspe.hxx:31
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
virtual void ProcessAttribute(enum IndexSourceParamEnum eParam, const OUString &rValue)
static SvXMLEnumMapEntry< sal_uInt16 > const lcl_aReferenceTypeTokenMap[]
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
const SvXMLEnumMapEntry< sal_uInt16 > * aLevelNameTableMap
Import index entry templates.
css::uno::Reference< css::beans::XPropertySet > & rIndexPropertySet
tab stops relative to margin or indent?
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
Handling of tokens in XML:
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
XMLIndexTableSourceContext(SvXMLImport &rImport, sal_uInt16 nPrfx, const OUString &rLocalName, css::uno::Reference< css::beans::XPropertySet > &rPropSet)
const bool aAllowedTokenTypesTable[]