1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: clrschemecontext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/drawingml/clrschemecontext.hxx"
32 #include "oox/core/namespaces.hxx"
33 #include "oox/core/xmlfilterbase.hxx"
36 using namespace ::oox::core
;
37 using namespace ::com::sun::star::uno
;
38 using namespace ::com::sun::star::xml::sax
;
40 namespace oox
{ namespace drawingml
{
42 static void setClrMap( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttributes
,
43 ClrMap
& rClrMap
, sal_Int32 nToken
)
45 if ( xAttributes
->hasAttribute( nToken
) )
47 sal_Int32 nMappedToken
= xAttributes
->getOptionalValueToken( nToken
, 0 );
48 rClrMap
.setColorMap( nToken
, nMappedToken
);
52 clrMapContext::clrMapContext( ContextHandler
& rParent
,
53 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& xAttributes
, ClrMap
& rClrMap
)
54 : ContextHandler( rParent
)
56 setClrMap( xAttributes
, rClrMap
, XML_bg1
);
57 setClrMap( xAttributes
, rClrMap
, XML_tx1
);
58 setClrMap( xAttributes
, rClrMap
, XML_bg2
);
59 setClrMap( xAttributes
, rClrMap
, XML_tx2
);
60 setClrMap( xAttributes
, rClrMap
, XML_accent1
);
61 setClrMap( xAttributes
, rClrMap
, XML_accent2
);
62 setClrMap( xAttributes
, rClrMap
, XML_accent3
);
63 setClrMap( xAttributes
, rClrMap
, XML_accent4
);
64 setClrMap( xAttributes
, rClrMap
, XML_accent5
);
65 setClrMap( xAttributes
, rClrMap
, XML_accent6
);
66 setClrMap( xAttributes
, rClrMap
, XML_hlink
);
67 setClrMap( xAttributes
, rClrMap
, XML_folHlink
);
70 clrSchemeColorContext::clrSchemeColorContext( ContextHandler
& rParent
, ClrScheme
& rClrScheme
, sal_Int32 nColorToken
) :
71 ColorContext( rParent
, *this ),
72 mrClrScheme( rClrScheme
),
73 mnColorToken( nColorToken
)
77 clrSchemeColorContext::~clrSchemeColorContext()
79 mrClrScheme
.setColor( mnColorToken
, getColor( getFilter() ) );
82 clrSchemeContext::clrSchemeContext( ContextHandler
& rParent
, ClrScheme
& rClrScheme
) :
83 ContextHandler( rParent
),
84 mrClrScheme( rClrScheme
)
88 Reference
< XFastContextHandler
> clrSchemeContext::createFastChildContext(
89 sal_Int32 nElement
, const Reference
< XFastAttributeList
>& ) throw (SAXException
, RuntimeException
)
97 case A_TOKEN( accent1
):
98 case A_TOKEN( accent2
):
99 case A_TOKEN( accent3
):
100 case A_TOKEN( accent4
):
101 case A_TOKEN( accent5
):
102 case A_TOKEN( accent6
):
103 case A_TOKEN( hlink
):
104 case A_TOKEN( folHlink
):
105 return new clrSchemeColorContext( *this, mrClrScheme
, getToken( nElement
) );