LibreOffice Module xmloff (master)  1
XMLAutoMarkFileContext.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 <xmloff/xmlimp.hxx>
22 #include <rtl/ustring.hxx>
23 #include <xmloff/namespacemap.hxx>
24 #include <xmloff/xmlnamespace.hxx>
25 #include <xmloff/xmltoken.hxx>
26 #include <com/sun/star/frame/XModel.hpp>
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/xml/sax/XAttributeList.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <sal/log.hxx>
31 
32 
33 using ::com::sun::star::uno::Any;
34 using ::com::sun::star::uno::Reference;
35 using ::com::sun::star::uno::UNO_QUERY;
36 using ::com::sun::star::xml::sax::XAttributeList;
37 using ::com::sun::star::beans::XPropertySet;
38 
41 
42 
44  SvXMLImport& rImport) :
45  SvXMLImportContext(rImport)
46 {
47 }
48 
50 {
51 }
52 
53 
55  sal_Int32 /*nElement*/,
56  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
57 {
58  // scan for text:alphabetical-index-auto-mark-file attribute, and if
59  // found set value with the document
60 
61  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
62  {
63  switch(aIter.getToken())
64  {
65  case XML_ELEMENT(XLINK, XML_HREF):
66  {
67  Any aAny;
68  aAny <<= GetImport().GetAbsoluteReference( aIter.toString() );
69  Reference<XPropertySet> xPropertySet(
70  GetImport().GetModel(), UNO_QUERY );
71  if (xPropertySet.is())
72  {
73  xPropertySet->setPropertyValue( "IndexAutoMarkFileURL", aAny );
74  }
75  break;
76  }
77  default:
78  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
79  }
80  }
81 }
82 
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:59
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3508
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:113
XMLAutoMarkFileContext(SvXMLImport &rImport)
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
virtual ~XMLAutoMarkFileContext() override
OUString GetAbsoluteReference(const OUString &rValue) const
Definition: xmlimp.cxx:1602
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97