fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / xmloff / source / chart / XMLSymbolImageContext.cxx
blobd57534fb2f954f1b13a47fc35e16055c87041334
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 "XMLSymbolImageContext.hxx"
21 #include <xmloff/xmltoken.hxx>
22 #include <xmloff/xmltkmap.hxx>
23 #include "xmloff/xmlnmspe.hxx"
24 #include <xmloff/xmlimp.hxx>
25 #include <xmloff/nmspmap.hxx>
26 #include <xmloff/XMLBase64ImportContext.hxx>
27 #include <com/sun/star/io/XOutputStream.hpp>
29 TYPEINIT1( XMLSymbolImageContext, XMLElementPropertyContext );
31 using namespace ::com::sun::star;
33 enum SvXMLTokenMapAttrs
35 XML_TOK_SYMBOL_IMAGE_HREF,
36 XML_TOK_SYMBOL_IMAGE_TYPE,
37 XML_TOK_SYMBOL_IMAGE_ACTUATE,
38 XML_TOK_SYMBOL_IMAGE_SHOW,
39 XML_TOK_SYMBOL_IMAGE_END = XML_TOK_UNKNOWN
42 static SvXMLTokenMapEntry aSymbolImageAttrTokenMap[] =
44 { XML_NAMESPACE_XLINK, ::xmloff::token::XML_HREF, XML_TOK_SYMBOL_IMAGE_HREF },
45 { XML_NAMESPACE_XLINK, ::xmloff::token::XML_TYPE, XML_TOK_SYMBOL_IMAGE_TYPE },
46 { XML_NAMESPACE_XLINK, ::xmloff::token::XML_ACTUATE, XML_TOK_SYMBOL_IMAGE_ACTUATE },
47 { XML_NAMESPACE_XLINK, ::xmloff::token::XML_SHOW, XML_TOK_SYMBOL_IMAGE_SHOW },
48 XML_TOKEN_MAP_END
51 XMLSymbolImageContext::XMLSymbolImageContext(
52 SvXMLImport& rImport, sal_uInt16 nPrfx,
53 const OUString& rLName,
54 const XMLPropertyState& rProp,
55 ::std::vector< XMLPropertyState > &rProps ) :
56 XMLElementPropertyContext(
57 rImport, nPrfx, rLName, rProp, rProps )
61 XMLSymbolImageContext::~XMLSymbolImageContext()
64 void XMLSymbolImageContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
66 SvXMLTokenMap aTokenMap( aSymbolImageAttrTokenMap );
67 OUString aLocalName;
69 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
70 for( sal_Int16 i = 0; i < nAttrCount; i++ )
72 const OUString& rAttrName = xAttrList->getNameByIndex( i );
73 sal_uInt16 nPrefix =
74 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
75 &aLocalName );
76 const OUString& rValue = xAttrList->getValueByIndex( i );
78 switch( aTokenMap.Get( nPrefix, aLocalName ) )
80 case XML_TOK_SYMBOL_IMAGE_HREF:
81 msURL = rValue;
82 break;
83 case XML_TOK_SYMBOL_IMAGE_ACTUATE:
84 case XML_TOK_SYMBOL_IMAGE_TYPE:
85 case XML_TOK_SYMBOL_IMAGE_SHOW:
86 // these values are currently not interpreted
87 // it is always assumed 'actuate=onLoad', 'type=simple', 'show=embed'
88 break;
93 SvXMLImportContext* XMLSymbolImageContext::CreateChildContext(
94 sal_uInt16 nPrefix, const OUString& rLocalName,
95 const uno::Reference< xml::sax::XAttributeList > & xAttrList )
97 SvXMLImportContext* pContext = NULL;
98 if( xmloff::token::IsXMLToken( rLocalName,
99 xmloff::token::XML_BINARY_DATA ) )
101 if( msURL.isEmpty() && ! mxBase64Stream.is() )
103 mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
104 if( mxBase64Stream.is() )
105 pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
106 rLocalName, xAttrList,
107 mxBase64Stream );
110 if( ! pContext )
112 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
115 return pContext;
118 void XMLSymbolImageContext::EndElement()
120 OUString sResolvedURL;
122 if( !msURL.isEmpty() )
124 sResolvedURL = GetImport().ResolveGraphicObjectURL( msURL, sal_False );
126 else if( mxBase64Stream.is() )
128 sResolvedURL = GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream );
129 mxBase64Stream = 0;
132 if( !sResolvedURL.isEmpty())
134 // aProp is a member of XMLElementPropertyContext
135 aProp.maValue <<= sResolvedURL;
136 SetInsert( sal_True );
139 XMLElementPropertyContext::EndElement();
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */