fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / xmloff / source / text / XMLIndexTableSourceContext.cxx
blob38bce6e3f88b7ccfc608a84f1dccbd9e3614d273
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "XMLIndexTableSourceContext.hxx"
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/container/XIndexReplace.hpp>
25 #include <com/sun/star/text/ReferenceFieldPart.hpp>
27 #include <sax/tools/converter.hxx>
29 #include "XMLIndexTemplateContext.hxx"
30 #include "XMLIndexTitleTemplateContext.hxx"
31 #include "XMLIndexTOCStylesContext.hxx"
32 #include <xmloff/xmlictxt.hxx>
33 #include <xmloff/xmlimp.hxx>
34 #include <xmloff/txtimp.hxx>
35 #include "xmloff/xmlnmspe.hxx"
36 #include <xmloff/nmspmap.hxx>
37 #include <xmloff/xmltoken.hxx>
38 #include <xmloff/xmluconv.hxx>
39 #include <rtl/ustring.hxx>
42 using namespace ::com::sun::star::text;
43 using namespace ::xmloff::token;
45 using ::com::sun::star::beans::XPropertySet;
46 using ::com::sun::star::uno::Reference;
47 using ::com::sun::star::uno::Any;
48 using ::com::sun::star::xml::sax::XAttributeList;
50 const sal_Char sAPI_CreateFromLabels[] = "CreateFromLabels";
51 const sal_Char sAPI_LabelCategory[] = "LabelCategory";
52 const sal_Char sAPI_LabelDisplayType[] = "LabelDisplayType";
55 TYPEINIT1(XMLIndexTableSourceContext, XMLIndexSourceBaseContext);
58 XMLIndexTableSourceContext::XMLIndexTableSourceContext(
59 SvXMLImport& rImport,
60 sal_uInt16 nPrfx,
61 const OUString& rLocalName,
62 Reference<XPropertySet> & rPropSet) :
63 XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
64 rPropSet, sal_False),
65 sCreateFromLabels(sAPI_CreateFromLabels),
66 sLabelCategory(sAPI_LabelCategory),
67 sLabelDisplayType(sAPI_LabelDisplayType),
68 bSequenceOK(sal_False),
69 bDisplayFormatOK(sal_False),
70 bUseCaption(sal_True)
74 XMLIndexTableSourceContext::~XMLIndexTableSourceContext()
78 static SvXMLEnumMapEntry const lcl_aReferenceTypeTokenMap[] =
81 { XML_TEXT, ReferenceFieldPart::TEXT },
82 { XML_CATEGORY_AND_VALUE, ReferenceFieldPart::CATEGORY_AND_NUMBER },
83 { XML_CAPTION, ReferenceFieldPart::ONLY_CAPTION },
85 // wrong values that previous versions wrote:
86 { XML_CHAPTER, ReferenceFieldPart::CATEGORY_AND_NUMBER },
87 { XML_PAGE, ReferenceFieldPart::ONLY_CAPTION },
89 { XML_TOKEN_INVALID, 0 }
92 void XMLIndexTableSourceContext::ProcessAttribute(
93 enum IndexSourceParamEnum eParam,
94 const OUString& rValue)
96 bool bTmp(false);
98 switch (eParam)
100 case XML_TOK_INDEXSOURCE_USE_CAPTION:
101 if (::sax::Converter::convertBool(bTmp, rValue))
103 bUseCaption = bTmp;
105 break;
107 case XML_TOK_INDEXSOURCE_SEQUENCE_NAME:
108 sSequence = rValue;
109 bSequenceOK = sal_True;
110 break;
112 case XML_TOK_INDEXSOURCE_SEQUENCE_FORMAT:
114 sal_uInt16 nTmp;
115 if (SvXMLUnitConverter::convertEnum(nTmp, rValue,
116 lcl_aReferenceTypeTokenMap))
118 nDisplayFormat = nTmp;
119 bDisplayFormatOK = sal_True;
121 break;
124 default:
125 XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
126 break;
131 void XMLIndexTableSourceContext::EndElement()
133 Any aAny;
135 aAny.setValue(&bUseCaption, ::getBooleanCppuType());
136 rIndexPropertySet->setPropertyValue(sCreateFromLabels, aAny);
138 if (bSequenceOK)
140 aAny <<= sSequence;
141 rIndexPropertySet->setPropertyValue(sLabelCategory, aAny);
144 if (bDisplayFormatOK)
146 aAny <<= nDisplayFormat;
147 rIndexPropertySet->setPropertyValue(sLabelDisplayType, aAny);
150 XMLIndexSourceBaseContext::EndElement();
154 SvXMLImportContext* XMLIndexTableSourceContext::CreateChildContext(
155 sal_uInt16 nPrefix,
156 const OUString& rLocalName,
157 const Reference<XAttributeList> & xAttrList )
159 if ( ( XML_NAMESPACE_TEXT == nPrefix ) &&
160 ( IsXMLToken( rLocalName, XML_TABLE_INDEX_ENTRY_TEMPLATE ) ) )
162 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
163 nPrefix, rLocalName,
164 aLevelNameTableMap,
165 XML_TOKEN_INVALID, // no outline-level attr
166 aLevelStylePropNameTableMap,
167 aAllowedTokenTypesTable);
169 else
171 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
172 rLocalName,
173 xAttrList);
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */