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
;
36 TYPEINIT1( XMLGradientStyleContext
, SvXMLStyleContext
);
38 XMLGradientStyleContext::XMLGradientStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
39 const OUString
& rLName
,
40 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
41 : SvXMLStyleContext(rImport
, nPrfx
, rLName
, xAttrList
)
45 XMLGradientStyleImport
aGradientStyle( GetImport() );
46 aGradientStyle
.importXML( xAttrList
, maAny
, maStrName
);
49 XMLGradientStyleContext::~XMLGradientStyleContext()
53 void XMLGradientStyleContext::EndElement()
55 uno::Reference
< container::XNameContainer
> xGradient( GetImport().GetGradientHelper() );
61 if( xGradient
->hasByName( maStrName
) )
63 xGradient
->replaceByName( maStrName
, maAny
);
67 xGradient
->insertByName( maStrName
, maAny
);
71 catch( container::ElementExistException
& )
75 bool XMLGradientStyleContext::IsTransient() const
80 TYPEINIT1( XMLHatchStyleContext
, SvXMLStyleContext
);
82 XMLHatchStyleContext::XMLHatchStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
83 const OUString
& rLName
,
84 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
85 : SvXMLStyleContext(rImport
, nPrfx
, rLName
, xAttrList
)
88 XMLHatchStyleImport
aHatchStyle( GetImport() );
89 aHatchStyle
.importXML( xAttrList
, maAny
, maStrName
);
92 XMLHatchStyleContext::~XMLHatchStyleContext()
96 void XMLHatchStyleContext::EndElement()
98 uno::Reference
< container::XNameContainer
> xHatch( GetImport().GetHatchHelper() );
104 if( xHatch
->hasByName( maStrName
) )
106 xHatch
->replaceByName( maStrName
, maAny
);
110 xHatch
->insertByName( maStrName
, maAny
);
114 catch( container::ElementExistException
& )
118 bool XMLHatchStyleContext::IsTransient() const
123 TYPEINIT1( XMLBitmapStyleContext
, SvXMLStyleContext
);
125 XMLBitmapStyleContext::XMLBitmapStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
126 const OUString
& rLName
,
127 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
128 : SvXMLStyleContext(rImport
, nPrfx
, rLName
, xAttrList
)
131 XMLImageStyle aBitmapStyle
;
132 aBitmapStyle
.importXML( xAttrList
, maAny
, maStrName
, rImport
);
135 XMLBitmapStyleContext::~XMLBitmapStyleContext()
139 SvXMLImportContext
* XMLBitmapStyleContext::CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> & xAttrList
)
141 SvXMLImportContext
*pContext
= 0;
142 if( (XML_NAMESPACE_OFFICE
== nPrefix
) && xmloff::token::IsXMLToken( rLocalName
, xmloff::token::XML_BINARY_DATA
) )
146 if( sURL
.isEmpty() && !mxBase64Stream
.is() )
148 mxBase64Stream
= GetImport().GetStreamForGraphicObjectURLFromBase64();
149 if( mxBase64Stream
.is() )
150 pContext
= new XMLBase64ImportContext( GetImport(), nPrefix
,
151 rLocalName
, xAttrList
,
157 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
163 void XMLBitmapStyleContext::EndElement()
168 if( sURL
.isEmpty() && mxBase64Stream
.is() )
170 sURL
= GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream
);
175 uno::Reference
< container::XNameContainer
> xBitmap( GetImport().GetBitmapHelper() );
181 if( xBitmap
->hasByName( maStrName
) )
183 xBitmap
->replaceByName( maStrName
, maAny
);
187 xBitmap
->insertByName( maStrName
, maAny
);
191 catch( container::ElementExistException
& )
195 bool XMLBitmapStyleContext::IsTransient() const
200 TYPEINIT1( XMLTransGradientStyleContext
, SvXMLStyleContext
);
202 XMLTransGradientStyleContext::XMLTransGradientStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
203 const OUString
& rLName
,
204 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
205 : SvXMLStyleContext(rImport
, nPrfx
, rLName
, xAttrList
)
208 XMLTransGradientStyleImport
aTransGradientStyle( GetImport() );
209 aTransGradientStyle
.importXML( xAttrList
, maAny
, maStrName
);
212 XMLTransGradientStyleContext::~XMLTransGradientStyleContext()
216 void XMLTransGradientStyleContext::EndElement()
218 uno::Reference
< container::XNameContainer
> xTransGradient( GetImport().GetTransGradientHelper() );
222 if(xTransGradient
.is())
224 if( xTransGradient
->hasByName( maStrName
) )
226 xTransGradient
->replaceByName( maStrName
, maAny
);
230 xTransGradient
->insertByName( maStrName
, maAny
);
234 catch( container::ElementExistException
& )
238 bool XMLTransGradientStyleContext::IsTransient() const
243 TYPEINIT1( XMLMarkerStyleContext
, SvXMLStyleContext
);
245 XMLMarkerStyleContext::XMLMarkerStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
246 const OUString
& rLName
,
247 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
248 : SvXMLStyleContext(rImport
, nPrfx
, rLName
, xAttrList
)
251 XMLMarkerStyleImport
aMarkerStyle( GetImport() );
252 aMarkerStyle
.importXML( xAttrList
, maAny
, maStrName
);
255 XMLMarkerStyleContext::~XMLMarkerStyleContext()
259 void XMLMarkerStyleContext::EndElement()
261 uno::Reference
< container::XNameContainer
> xMarker( GetImport().GetMarkerHelper() );
267 if( xMarker
->hasByName( maStrName
) )
269 xMarker
->replaceByName( maStrName
, maAny
);
273 xMarker
->insertByName( maStrName
, maAny
);
277 catch( container::ElementExistException
& )
281 bool XMLMarkerStyleContext::IsTransient() const
286 TYPEINIT1( XMLDashStyleContext
, SvXMLStyleContext
);
288 XMLDashStyleContext::XMLDashStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
289 const OUString
& rLName
,
290 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
291 : SvXMLStyleContext(rImport
, nPrfx
, rLName
, xAttrList
)
294 XMLDashStyleImport
aDashStyle( GetImport() );
295 aDashStyle
.importXML( xAttrList
, maAny
, maStrName
);
298 XMLDashStyleContext::~XMLDashStyleContext()
302 void XMLDashStyleContext::EndElement()
304 uno::Reference
< container::XNameContainer
> xDashes( GetImport().GetDashHelper() );
310 if( xDashes
->hasByName( maStrName
) )
312 xDashes
->replaceByName( maStrName
, maAny
);
316 xDashes
->insertByName( maStrName
, maAny
);
320 catch( container::ElementExistException
& )
324 bool XMLDashStyleContext::IsTransient() const
329 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */