xref: /aoo41x/main/xmloff/source/draw/ximplink.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmloff.hxx"
30 #include"xmloff/xmlnmspe.hxx"
31 #include "ximplink.hxx"
32 #include <xmloff/xmltoken.hxx>
33 
34 using ::rtl::OUString;
35 using ::rtl::OUStringBuffer;
36 
37 using namespace ::com::sun::star;
38 using namespace ::xmloff::token;
39 
40 //////////////////////////////////////////////////////////////////////////////
41 
42 TYPEINIT1( SdXMLShapeLinkContext, SvXMLImportContext );
43 
44 SdXMLShapeLinkContext::SdXMLShapeLinkContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList>& xAttrList, uno::Reference< drawing::XShapes >& rShapes)
45 : SvXMLShapeContext( rImport, nPrfx, rLocalName, false )
46 , mxParent( rShapes )
47 {
48 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
49 
50 	for(sal_Int16 i=0; i < nAttrCount; i++)
51 	{
52 		OUString sAttrName = xAttrList->getNameByIndex( i );
53 		OUString aLocalName;
54 		sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
55 		if( (nPrefix == XML_NAMESPACE_XLINK) && IsXMLToken( aLocalName, XML_HREF ) )
56 		{
57 			msHyperlink = xAttrList->getValueByIndex( i );
58 			break;
59 		}
60 	}
61 }
62 
63 //////////////////////////////////////////////////////////////////////////////
64 
65 SdXMLShapeLinkContext::~SdXMLShapeLinkContext()
66 {
67 }
68 
69 //////////////////////////////////////////////////////////////////////////////
70 
71 SvXMLImportContext* SdXMLShapeLinkContext::CreateChildContext( sal_uInt16 nPrefix,
72 	const OUString& rLocalName,
73 	const uno::Reference< xml::sax::XAttributeList>& xAttrList )
74 {
75 	SvXMLShapeContext* pContext = GetImport().GetShapeImport()->CreateGroupChildContext( GetImport(), nPrefix, rLocalName, xAttrList, mxParent);
76 
77 	if( pContext )
78 	{
79 		pContext->setHyperlink( msHyperlink );
80 		return pContext;
81 	}
82 
83 	// call parent when no own context was created
84 	return SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList);
85 
86 }
87 
88 //////////////////////////////////////////////////////////////////////////////
89 
90 void SdXMLShapeLinkContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttr )
91 {
92 	SvXMLImportContext::StartElement( xAttr );
93 }
94 
95 //////////////////////////////////////////////////////////////////////////////
96 
97 void SdXMLShapeLinkContext::EndElement()
98 {
99 	SvXMLImportContext::EndElement();
100 }
101 
102 
103