LibreOffice Module xmloff (master) 1
FillStyleContext.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 <com/sun/star/container/XNameContainer.hpp>
21#include <com/sun/star/graphic/XGraphic.hpp>
22#include <com/sun/star/awt/XBitmap.hpp>
23#include "FillStyleContext.hxx"
24#include <xmloff/xmlimp.hxx>
26#include <xmloff/HatchStyle.hxx>
27#include <xmloff/ImageStyle.hxx>
30#include <xmloff/DashStyle.hxx>
32#include <xmloff/xmltkmap.hxx>
34
35using namespace ::com::sun::star;
36
37
38XMLGradientStyleContext::XMLGradientStyleContext( SvXMLImport& rImport, sal_Int32 ,
39 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList)
40: SvXMLStyleContext(rImport)
41{
42 // start import
43 XMLGradientStyleImport aGradientStyle( GetImport() );
44 aGradientStyle.importXML( xAttrList, maAny, maStrName );
45}
46
48{
49}
50
52{
53 uno::Reference< container::XNameContainer > xGradient( GetImport().GetGradientHelper() );
54
55 try
56 {
57 if(xGradient.is())
58 {
59 if( xGradient->hasByName( maStrName ) )
60 {
61 xGradient->replaceByName( maStrName, maAny );
62 }
63 else
64 {
65 xGradient->insertByName( maStrName, maAny );
66 }
67 }
68 }
69 catch( container::ElementExistException& )
70 {}
71}
72
74{
75 return true;
76}
77
78
79XMLHatchStyleContext::XMLHatchStyleContext( SvXMLImport& rImport, sal_Int32 /*nElement*/,
80 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList)
81: SvXMLStyleContext(rImport)
82{
83 // start import
84 XMLHatchStyleImport aHatchStyle( GetImport() );
85 aHatchStyle.importXML( xAttrList, maAny, maStrName );
86}
87
89{
90}
91
93{
94 uno::Reference< container::XNameContainer > xHatch( GetImport().GetHatchHelper() );
95
96 try
97 {
98 if(xHatch.is())
99 {
100 if( xHatch->hasByName( maStrName ) )
101 {
102 xHatch->replaceByName( maStrName, maAny );
103 }
104 else
105 {
106 xHatch->insertByName( maStrName, maAny );
107 }
108 }
109 }
110 catch( container::ElementExistException& )
111 {}
112}
113
115{
116 return true;
117}
118
119
120XMLBitmapStyleContext::XMLBitmapStyleContext( SvXMLImport& rImport, sal_Int32 /*nElement*/,
121 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList)
122: SvXMLStyleContext(rImport)
123{
124 // start import
125 XMLImageStyle::importXML( xAttrList, maAny, maStrName, rImport );
126}
127
129{
130}
131
132css::uno::Reference< css::xml::sax::XFastContextHandler > XMLBitmapStyleContext::createFastChildContext(
133 sal_Int32 nElement,
134 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
135{
137 {
138 OUString sURL;
139 maAny >>= sURL;
140 if( sURL.isEmpty() && !mxBase64Stream.is() )
141 {
142 mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
143 if( mxBase64Stream.is() )
145 }
146 }
147
148 return nullptr;
149}
150
152{
153 if (!maAny.has<uno::Reference<graphic::XGraphic>>() && mxBase64Stream.is())
154 {
155 // No graphic so far? Then see if it's inline.
156 uno::Reference<graphic::XGraphic> xGraphic = GetImport().loadGraphicFromBase64(mxBase64Stream);
157 if (xGraphic.is())
158 {
159 maAny <<= xGraphic;
160 }
161 }
162
163 if (!maAny.has<uno::Reference<graphic::XGraphic>>())
164 return;
165
166 uno::Reference<container::XNameContainer> xBitmapContainer(GetImport().GetBitmapHelper());
167
168 uno::Reference<graphic::XGraphic> xGraphic = maAny.get<uno::Reference<graphic::XGraphic>>();
169 uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
170
171 try
172 {
173 if (xBitmapContainer.is())
174 {
175 if (xBitmapContainer->hasByName(maStrName))
176 {
177 xBitmapContainer->replaceByName(maStrName, uno::Any(xBitmap));
178 }
179 else
180 {
181 xBitmapContainer->insertByName(maStrName, uno::Any(xBitmap));
182 }
183 }
184 }
185 catch (container::ElementExistException&)
186 {}
187}
188
190{
191 return true;
192}
193
194
195XMLTransGradientStyleContext::XMLTransGradientStyleContext( SvXMLImport& rImport, sal_Int32 /*nElement*/,
196 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList)
197: SvXMLStyleContext(rImport)
198{
199 // start import
200 XMLTransGradientStyleImport aTransGradientStyle( GetImport() );
201 aTransGradientStyle.importXML( xAttrList, maAny, maStrName );
202}
203
205{
206}
207
209{
210 uno::Reference< container::XNameContainer > xTransGradient( GetImport().GetTransGradientHelper() );
211
212 try
213 {
214 if(xTransGradient.is())
215 {
216 if( xTransGradient->hasByName( maStrName ) )
217 {
218 xTransGradient->replaceByName( maStrName, maAny );
219 }
220 else
221 {
222 xTransGradient->insertByName( maStrName, maAny );
223 }
224 }
225 }
226 catch( container::ElementExistException& )
227 {}
228}
229
231{
232 return true;
233}
234
235
236XMLMarkerStyleContext::XMLMarkerStyleContext( SvXMLImport& rImport, sal_Int32 /*nElement*/,
237 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList)
238: SvXMLStyleContext(rImport)
239{
240 // start import
241 XMLMarkerStyleImport aMarkerStyle( GetImport() );
242 aMarkerStyle.importXML( xAttrList, maAny, maStrName );
243}
244
246{
247}
248
250{
251 uno::Reference< container::XNameContainer > xMarker( GetImport().GetMarkerHelper() );
252
253 try
254 {
255 if(xMarker.is())
256 {
257 if( xMarker->hasByName( maStrName ) )
258 {
259 xMarker->replaceByName( maStrName, maAny );
260 }
261 else
262 {
263 xMarker->insertByName( maStrName, maAny );
264 }
265 }
266 }
267 catch( container::ElementExistException& )
268 {}
269}
270
272{
273 return true;
274}
275
276
277XMLDashStyleContext::XMLDashStyleContext( SvXMLImport& rImport, sal_Int32 /*nElement*/,
278 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList)
279: SvXMLStyleContext(rImport)
280{
281 // start import
282 XMLDashStyleImport aDashStyle( GetImport() );
283 aDashStyle.importXML( xAttrList, maAny, maStrName );
284}
285
287{
288}
289
291{
292 uno::Reference< container::XNameContainer > xDashes( GetImport().GetDashHelper() );
293
294 try
295 {
296 if(xDashes.is())
297 {
298 if( xDashes->hasByName( maStrName ) )
299 {
300 xDashes->replaceByName( maStrName, maAny );
301 }
302 else
303 {
304 xDashes->insertByName( maStrName, maAny );
305 }
306 }
307 }
308 catch( container::ElementExistException& )
309 {}
310}
311
313{
314 return true;
315}
316
317/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
virtual ~XMLBitmapStyleContext() override
XMLBitmapStyleContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
css::uno::Reference< css::io::XOutputStream > mxBase64Stream
virtual bool IsTransient() const override
if this method returns true, its parent styles context should not add it to its container.
virtual bool IsTransient() const override
if this method returns true, its parent styles context should not add it to its container.
XMLDashStyleContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual ~XMLDashStyleContext() override
void importXML(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Any &rValue, OUString &rStrName)
Definition: DashStyle.cxx:57
virtual ~XMLGradientStyleContext() override
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
XMLGradientStyleContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
virtual bool IsTransient() const override
if this method returns true, its parent styles context should not add it to its container.
void importXML(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Any &rValue, OUString &rStrName)
virtual bool IsTransient() const override
if this method returns true, its parent styles context should not add it to its container.
virtual ~XMLHatchStyleContext() override
XMLHatchStyleContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
void importXML(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Any &rValue, OUString &rStrName)
Definition: HatchStyle.cxx:57
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual ~XMLMarkerStyleContext() override
XMLMarkerStyleContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
virtual bool IsTransient() const override
if this method returns true, its parent styles context should not add it to its container.
void importXML(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Any &rValue, OUString &rStrName)
Definition: MarkerStyle.cxx:47
virtual bool IsTransient() const override
if this method returns true, its parent styles context should not add it to its container.
virtual ~XMLTransGradientStyleContext() override
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
XMLTransGradientStyleContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
void importXML(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Any &rValue, OUString &rStrName)
XMLOFF_DLLPUBLIC bool importXML(css::uno::Reference< css::xml::sax::XFastAttributeList > const &xAttrList, css::uno::Any &rValue, OUString &rStrName, SvXMLImport &rImport)
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:98