bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / text / XMLAutoMarkFileContext.cxx
blobb2f3a36ce99881565114d795fe3f1e0808b5683e
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 .
20 #include "XMLAutoMarkFileContext.hxx"
21 #include <xmloff/xmlimp.hxx>
22 #include <rtl/ustring.hxx>
23 #include <xmloff/nmspmap.hxx>
24 #include <xmloff/xmlnmspe.hxx>
25 #include <xmloff/xmltoken.hxx>
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <com/sun/star/xml/sax/XAttributeList.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
31 using ::com::sun::star::uno::Any;
32 using ::com::sun::star::uno::Reference;
33 using ::com::sun::star::uno::UNO_QUERY;
34 using ::com::sun::star::xml::sax::XAttributeList;
35 using ::com::sun::star::beans::XPropertySet;
37 using ::xmloff::token::IsXMLToken;
38 using ::xmloff::token::XML_HREF;
41 TYPEINIT1( XMLAutoMarkFileContext, SvXMLImportContext );
43 XMLAutoMarkFileContext::XMLAutoMarkFileContext(
44 SvXMLImport& rImport,
45 sal_uInt16 nPrefix,
46 const OUString& rLocalName) :
47 SvXMLImportContext(rImport, nPrefix, rLocalName),
48 sIndexAutoMarkFileURL("IndexAutoMarkFileURL")
52 XMLAutoMarkFileContext::~XMLAutoMarkFileContext()
57 void XMLAutoMarkFileContext::StartElement(
58 const Reference<XAttributeList> & xAttrList)
60 // scan for text:alphabetical-index-auto-mark-file attribute, and if
61 // found set value with the document
63 sal_Int16 nLength = xAttrList->getLength();
64 for( sal_Int16 i = 0; i < nLength; i++ )
66 OUString sLocalName;
67 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
68 GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
70 if ( ( XML_NAMESPACE_XLINK == nPrefix ) &&
71 IsXMLToken(sLocalName, XML_HREF) )
73 Any aAny;
74 aAny <<= GetImport().GetAbsoluteReference( xAttrList->getValueByIndex(i) );
75 Reference<XPropertySet> xPropertySet(
76 GetImport().GetModel(), UNO_QUERY );
77 if (xPropertySet.is())
79 xPropertySet->setPropertyValue( sIndexAutoMarkFileURL, aAny );
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */