1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/text/ReferenceFieldPart.hpp>
26 #include <sax/tools/converter.hxx>
28 #include "XMLIndexTemplateContext.hxx"
29 #include <xmloff/xmlictxt.hxx>
30 #include <xmloff/xmlimp.hxx>
31 #include <xmloff/xmlnamespace.hxx>
32 #include <xmloff/xmltoken.hxx>
33 #include <xmloff/xmluconv.hxx>
34 #include <xmloff/xmlement.hxx>
35 #include <rtl/ustring.hxx>
38 using namespace ::com::sun::star::text
;
39 using namespace ::xmloff::token
;
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
;
46 XMLIndexTableSourceContext::XMLIndexTableSourceContext(
47 SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
48 const OUString
& rLocalName
, Reference
<XPropertySet
> & rPropSet
)
49 : XMLIndexSourceBaseContext(rImport
, nPrfx
, rLocalName
,
53 , bDisplayFormatOK(false)
58 XMLIndexTableSourceContext::~XMLIndexTableSourceContext()
62 SvXMLEnumMapEntry
<sal_uInt16
> const lcl_aReferenceTypeTokenMap
[] =
65 { XML_TEXT
, ReferenceFieldPart::TEXT
},
66 { XML_CATEGORY_AND_VALUE
, ReferenceFieldPart::CATEGORY_AND_NUMBER
},
67 { XML_CAPTION
, ReferenceFieldPart::ONLY_CAPTION
},
69 // wrong values that previous versions wrote:
70 { XML_CHAPTER
, ReferenceFieldPart::CATEGORY_AND_NUMBER
},
71 { XML_PAGE
, ReferenceFieldPart::ONLY_CAPTION
},
73 { XML_TOKEN_INVALID
, 0 }
76 void XMLIndexTableSourceContext::ProcessAttribute(
77 enum IndexSourceParamEnum eParam
,
78 const OUString
& rValue
)
84 case XML_TOK_INDEXSOURCE_USE_CAPTION
:
85 if (::sax::Converter::convertBool(bTmp
, rValue
))
91 case XML_TOK_INDEXSOURCE_SEQUENCE_NAME
:
96 case XML_TOK_INDEXSOURCE_SEQUENCE_FORMAT
:
99 if (SvXMLUnitConverter::convertEnum(nTmp
, rValue
,
100 lcl_aReferenceTypeTokenMap
))
102 nDisplayFormat
= nTmp
;
103 bDisplayFormatOK
= true;
109 XMLIndexSourceBaseContext::ProcessAttribute(eParam
, rValue
);
114 void XMLIndexTableSourceContext::endFastElement(sal_Int32 nElement
)
116 rIndexPropertySet
->setPropertyValue("CreateFromLabels", css::uno::Any(bUseCaption
));
120 rIndexPropertySet
->setPropertyValue("LabelCategory", css::uno::Any(sSequence
));
123 if (bDisplayFormatOK
)
125 rIndexPropertySet
->setPropertyValue("LabelDisplayType", css::uno::Any(nDisplayFormat
));
128 XMLIndexSourceBaseContext::endFastElement(nElement
);
131 SvXMLImportContextRef
XMLIndexTableSourceContext::CreateChildContext(
133 const OUString
& rLocalName
,
134 const Reference
<XAttributeList
> & xAttrList
)
136 if ( ( XML_NAMESPACE_TEXT
== nPrefix
) &&
137 ( IsXMLToken( rLocalName
, XML_TABLE_INDEX_ENTRY_TEMPLATE
) ) )
139 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet
,
142 XML_TOKEN_INVALID
, // no outline-level attr
143 aLevelStylePropNameTableMap
,
144 aAllowedTokenTypesTable
);
148 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix
,
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */