LibreOffice Module xmloff (master)  1
ximplink.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 #include <xmloff/xmlimp.hxx>
21 #include <xmloff/xmlnmspe.hxx>
22 #include "ximplink.hxx"
23 #include <xmloff/xmltoken.hxx>
24 
25 using namespace ::com::sun::star;
26 using namespace ::xmloff::token;
27 
28 
29 SdXMLShapeLinkContext::SdXMLShapeLinkContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes)
30 : SvXMLShapeContext( rImport, nPrfx, rLocalName, false )
31 , mxParent( rShapes )
32 {
33  sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
34 
35  for(sal_Int16 i=0; i < nAttrCount; i++)
36  {
37  OUString sAttrName = xAttrList->getNameByIndex( i );
38  OUString aLocalName;
39  sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
40  if( (nPrefix == XML_NAMESPACE_XLINK) && IsXMLToken( aLocalName, XML_HREF ) )
41  {
42  assert(msHyperlink.pData);
43  msHyperlink = xAttrList->getValueByIndex( i );
44  break;
45  }
46  }
47 }
48 
50 {
51 }
52 
54  const OUString& rLocalName,
55  const uno::Reference< xml::sax::XAttributeList>& xAttrList )
56 {
57  SvXMLShapeContext* pContext = GetImport().GetShapeImport()->CreateGroupChildContext( GetImport(), nPrefix, rLocalName, xAttrList, mxParent);
58 
59  if( pContext )
60  {
61  pContext->setHyperlink( msHyperlink );
62  return pContext;
63  }
64 
65  return nullptr;
66 
67 }
68 
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3422
WeakReference< XInterface > mxParent
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
css::uno::Reference< css::drawing::XShapes > mxParent
Definition: ximplink.hxx:35
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:397
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
Definition: nmspmap.cxx:437
void setHyperlink(const OUString &rHyperlink)
int i
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
Definition: ximplink.cxx:53
constexpr sal_uInt16 XML_NAMESPACE_XLINK
Definition: xmlnmspe.hxx:35
SdXMLShapeLinkContext(SvXMLImport &rImport, sal_uInt16 nPrfx, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes)
Definition: ximplink.cxx:29
Handling of tokens in XML:
virtual ~SdXMLShapeLinkContext() override
Definition: ximplink.cxx:49
rtl::Reference< XMLShapeImportHelper > const & GetShapeImport()
Definition: xmlimp.hxx:602