/src/libreoffice/xmloff/source/chart/XMLSymbolImageContext.cxx
Line | Count | Source (jump to first uncovered line) |
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 "XMLSymbolImageContext.hxx" |
21 | | #include <xmloff/xmltoken.hxx> |
22 | | #include <xmloff/xmlnamespace.hxx> |
23 | | #include <xmloff/xmlimp.hxx> |
24 | | #include <xmloff/XMLBase64ImportContext.hxx> |
25 | | #include <com/sun/star/graphic/XGraphic.hpp> |
26 | | #include <sal/log.hxx> |
27 | | |
28 | | using namespace css; |
29 | | using namespace xmloff::token; |
30 | | |
31 | | XMLSymbolImageContext::XMLSymbolImageContext( |
32 | | SvXMLImport& rImport, sal_Int32 nElement, |
33 | | const XMLPropertyState& rProp, |
34 | | ::std::vector< XMLPropertyState > &rProps ) : |
35 | 0 | XMLElementPropertyContext( |
36 | 0 | rImport, nElement, rProp, rProps ) |
37 | 0 | { |
38 | 0 | } |
39 | | |
40 | | XMLSymbolImageContext::~XMLSymbolImageContext() |
41 | 0 | {} |
42 | | |
43 | | void XMLSymbolImageContext::startFastElement( |
44 | | sal_Int32 /*nElement*/, |
45 | | const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) |
46 | 0 | { |
47 | 0 | for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) |
48 | 0 | { |
49 | 0 | const OUString sValue = aIter.toString(); |
50 | |
|
51 | 0 | switch( aIter.getToken() ) |
52 | 0 | { |
53 | 0 | case XML_ELEMENT(XLINK, XML_HREF): |
54 | 0 | msURL = sValue; |
55 | 0 | break; |
56 | 0 | case XML_ELEMENT(XLINK, XML_ACTUATE): |
57 | 0 | case XML_ELEMENT(XLINK, XML_TYPE): |
58 | 0 | case XML_ELEMENT(XLINK, XML_SHOW): |
59 | | // these values are currently not interpreted |
60 | | // it is always assumed 'actuate=onLoad', 'type=simple', 'show=embed' |
61 | 0 | break; |
62 | 0 | default: |
63 | 0 | XMLOFF_WARN_UNKNOWN("xmloff", aIter); |
64 | 0 | } |
65 | 0 | } |
66 | 0 | } |
67 | | |
68 | | css::uno::Reference< css::xml::sax::XFastContextHandler > XMLSymbolImageContext::createFastChildContext( |
69 | | sal_Int32 nElement, |
70 | | const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) |
71 | 0 | { |
72 | 0 | if( (nElement & TOKEN_MASK) == xmloff::token::XML_BINARY_DATA ) |
73 | 0 | { |
74 | 0 | if( msURL.isEmpty() && ! mxBase64Stream.is() ) |
75 | 0 | { |
76 | 0 | mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64(); |
77 | 0 | if( mxBase64Stream.is() ) |
78 | 0 | return new XMLBase64ImportContext( GetImport(), mxBase64Stream ); |
79 | 0 | } |
80 | 0 | } |
81 | 0 | XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); |
82 | 0 | return nullptr; |
83 | 0 | } |
84 | | |
85 | | void XMLSymbolImageContext::endFastElement(sal_Int32 nElement) |
86 | 0 | { |
87 | 0 | uno::Reference<graphic::XGraphic> xGraphic; |
88 | |
|
89 | 0 | if (!msURL.isEmpty()) |
90 | 0 | { |
91 | 0 | xGraphic = GetImport().loadGraphicByURL(msURL); |
92 | 0 | } |
93 | 0 | else if (mxBase64Stream.is()) |
94 | 0 | { |
95 | 0 | xGraphic = GetImport().loadGraphicFromBase64(mxBase64Stream); |
96 | 0 | mxBase64Stream = nullptr; |
97 | 0 | } |
98 | |
|
99 | 0 | if (xGraphic.is()) |
100 | 0 | { |
101 | | // aProp is a member of XMLElementPropertyContext |
102 | 0 | aProp.maValue <<= xGraphic; |
103 | 0 | SetInsert( true ); |
104 | 0 | } |
105 | |
|
106 | 0 | XMLElementPropertyContext::endFastElement(nElement); |
107 | 0 | } |
108 | | |
109 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |