1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <com/sun/star/container/XNameContainer.hpp>
21 #include "FillStyleContext.hxx"
22 #include <xmloff/xmlimp.hxx>
23 #include "xmloff/GradientStyle.hxx"
24 #include "xmloff/HatchStyle.hxx"
25 #include "xmloff/ImageStyle.hxx"
26 #include "TransGradientStyle.hxx"
27 #include "xmloff/MarkerStyle.hxx"
28 #include "xmloff/DashStyle.hxx"
29 #include <xmloff/families.hxx>
30 #include <xmloff/nmspmap.hxx>
31 #include "xmloff/xmlnmspe.hxx"
32 #include <xmloff/XMLBase64ImportContext.hxx>
34 using namespace ::com::sun::star
;
37 //////////////////////////////////////////////////////////////////////////////
38 //////////////////////////////////////////////////////////////////////////////
40 TYPEINIT1( XMLGradientStyleContext
, SvXMLStyleContext
);
42 XMLGradientStyleContext::XMLGradientStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
43 const OUString
& rLName
,
44 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
45 : SvXMLStyleContext(rImport
, nPrfx
, rLName
, xAttrList
)
49 XMLGradientStyleImport
aGradientStyle( GetImport() );
50 aGradientStyle
.importXML( xAttrList
, maAny
, maStrName
);
53 XMLGradientStyleContext::~XMLGradientStyleContext()
57 void XMLGradientStyleContext::EndElement()
59 uno::Reference
< container::XNameContainer
> xGradient( GetImport().GetGradientHelper() );
65 if( xGradient
->hasByName( maStrName
) )
67 xGradient
->replaceByName( maStrName
, maAny
);
71 xGradient
->insertByName( maStrName
, maAny
);
75 catch( container::ElementExistException
& )
79 sal_Bool
XMLGradientStyleContext::IsTransient() const
84 //////////////////////////////////////////////////////////////////////////////
85 //////////////////////////////////////////////////////////////////////////////
87 TYPEINIT1( XMLHatchStyleContext
, SvXMLStyleContext
);
89 XMLHatchStyleContext::XMLHatchStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
90 const OUString
& rLName
,
91 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
92 : SvXMLStyleContext(rImport
, nPrfx
, rLName
, xAttrList
)
95 XMLHatchStyleImport
aHatchStyle( GetImport() );
96 aHatchStyle
.importXML( xAttrList
, maAny
, maStrName
);
99 XMLHatchStyleContext::~XMLHatchStyleContext()
103 void XMLHatchStyleContext::EndElement()
105 uno::Reference
< container::XNameContainer
> xHatch( GetImport().GetHatchHelper() );
111 if( xHatch
->hasByName( maStrName
) )
113 xHatch
->replaceByName( maStrName
, maAny
);
117 xHatch
->insertByName( maStrName
, maAny
);
121 catch( container::ElementExistException
& )
125 sal_Bool
XMLHatchStyleContext::IsTransient() const
130 //////////////////////////////////////////////////////////////////////////////
131 //////////////////////////////////////////////////////////////////////////////
133 TYPEINIT1( XMLBitmapStyleContext
, SvXMLStyleContext
);
135 XMLBitmapStyleContext::XMLBitmapStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
136 const OUString
& rLName
,
137 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
138 : SvXMLStyleContext(rImport
, nPrfx
, rLName
, xAttrList
)
141 XMLImageStyle aBitmapStyle
;
142 aBitmapStyle
.importXML( xAttrList
, maAny
, maStrName
, rImport
);
145 XMLBitmapStyleContext::~XMLBitmapStyleContext()
149 SvXMLImportContext
* XMLBitmapStyleContext::CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> & xAttrList
)
151 SvXMLImportContext
*pContext
= 0;
152 if( (XML_NAMESPACE_OFFICE
== nPrefix
) && xmloff::token::IsXMLToken( rLocalName
, xmloff::token::XML_BINARY_DATA
) )
156 if( sURL
.isEmpty() && !mxBase64Stream
.is() )
158 mxBase64Stream
= GetImport().GetStreamForGraphicObjectURLFromBase64();
159 if( mxBase64Stream
.is() )
160 pContext
= new XMLBase64ImportContext( GetImport(), nPrefix
,
161 rLocalName
, xAttrList
,
167 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
173 void XMLBitmapStyleContext::EndElement()
178 if( sURL
.isEmpty() && mxBase64Stream
.is() )
180 sURL
= GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream
);
185 uno::Reference
< container::XNameContainer
> xBitmap( GetImport().GetBitmapHelper() );
191 if( xBitmap
->hasByName( maStrName
) )
193 xBitmap
->replaceByName( maStrName
, maAny
);
197 xBitmap
->insertByName( maStrName
, maAny
);
201 catch( container::ElementExistException
& )
205 sal_Bool
XMLBitmapStyleContext::IsTransient() const
211 //////////////////////////////////////////////////////////////////////////////
212 //////////////////////////////////////////////////////////////////////////////
214 TYPEINIT1( XMLTransGradientStyleContext
, SvXMLStyleContext
);
216 XMLTransGradientStyleContext::XMLTransGradientStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
217 const OUString
& rLName
,
218 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
219 : SvXMLStyleContext(rImport
, nPrfx
, rLName
, xAttrList
)
222 XMLTransGradientStyleImport
aTransGradientStyle( GetImport() );
223 aTransGradientStyle
.importXML( xAttrList
, maAny
, maStrName
);
226 XMLTransGradientStyleContext::~XMLTransGradientStyleContext()
230 void XMLTransGradientStyleContext::EndElement()
232 uno::Reference
< container::XNameContainer
> xTransGradient( GetImport().GetTransGradientHelper() );
236 if(xTransGradient
.is())
238 if( xTransGradient
->hasByName( maStrName
) )
240 xTransGradient
->replaceByName( maStrName
, maAny
);
244 xTransGradient
->insertByName( maStrName
, maAny
);
248 catch( container::ElementExistException
& )
252 sal_Bool
XMLTransGradientStyleContext::IsTransient() const
257 //////////////////////////////////////////////////////////////////////////////
258 //////////////////////////////////////////////////////////////////////////////
260 TYPEINIT1( XMLMarkerStyleContext
, SvXMLStyleContext
);
262 XMLMarkerStyleContext::XMLMarkerStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
263 const OUString
& rLName
,
264 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
265 : SvXMLStyleContext(rImport
, nPrfx
, rLName
, xAttrList
)
268 XMLMarkerStyleImport
aMarkerStyle( GetImport() );
269 aMarkerStyle
.importXML( xAttrList
, maAny
, maStrName
);
272 XMLMarkerStyleContext::~XMLMarkerStyleContext()
276 void XMLMarkerStyleContext::EndElement()
278 uno::Reference
< container::XNameContainer
> xMarker( GetImport().GetMarkerHelper() );
284 if( xMarker
->hasByName( maStrName
) )
286 xMarker
->replaceByName( maStrName
, maAny
);
290 xMarker
->insertByName( maStrName
, maAny
);
294 catch( container::ElementExistException
& )
298 sal_Bool
XMLMarkerStyleContext::IsTransient() const
303 //////////////////////////////////////////////////////////////////////////////
304 //////////////////////////////////////////////////////////////////////////////
306 TYPEINIT1( XMLDashStyleContext
, SvXMLStyleContext
);
308 XMLDashStyleContext::XMLDashStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
309 const OUString
& rLName
,
310 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
311 : SvXMLStyleContext(rImport
, nPrfx
, rLName
, xAttrList
)
314 XMLDashStyleImport
aDashStyle( GetImport() );
315 aDashStyle
.importXML( xAttrList
, maAny
, maStrName
);
318 XMLDashStyleContext::~XMLDashStyleContext()
322 void XMLDashStyleContext::EndElement()
324 uno::Reference
< container::XNameContainer
> xDashes( GetImport().GetDashHelper() );
330 if( xDashes
->hasByName( maStrName
) )
332 xDashes
->replaceByName( maStrName
, maAny
);
336 xDashes
->insertByName( maStrName
, maAny
);
340 catch( container::ElementExistException
& )
344 sal_Bool
XMLDashStyleContext::IsTransient() const
349 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */