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: tablestyletextstylecontext.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 <osl/diagnose.h>
33 #include "oox/drawingml/table/tablestyletextstylecontext.hxx"
34 #include "oox/drawingml/colorchoicecontext.hxx"
35 #include "oox/core/namespaces.hxx"
36 #include "oox/helper/attributelist.hxx"
38 using namespace ::oox::core
;
39 using namespace ::com::sun::star
;
40 using namespace ::com::sun::star::uno
;
41 using namespace ::com::sun::star::xml::sax
;
42 using ::rtl::OUString
;
44 namespace oox
{ namespace drawingml
{ namespace table
{
46 TableStyleTextStyleContext::TableStyleTextStyleContext( ContextHandler
& rParent
,
47 const Reference
< XFastAttributeList
>& xAttribs
, TableStylePart
& rTableStylePart
)
48 : ContextHandler( rParent
)
49 , mrTableStylePart( rTableStylePart
)
51 sal_Int32 nB
= xAttribs
->getOptionalValueToken( XML_b
, XML_def
);
53 mrTableStylePart
.getTextBoldStyle() = ::boost::optional
< sal_Bool
>( sal_True
);
54 else if ( nB
== XML_off
)
55 mrTableStylePart
.getTextBoldStyle() = ::boost::optional
< sal_Bool
>( sal_False
);
57 sal_Int32 nI
= xAttribs
->getOptionalValueToken( XML_i
, XML_def
);
59 mrTableStylePart
.getTextItalicStyle() = ::boost::optional
< sal_Bool
>( sal_True
);
60 else if ( nI
== XML_off
)
61 mrTableStylePart
.getTextItalicStyle() = ::boost::optional
< sal_Bool
>( sal_False
);
64 TableStyleTextStyleContext::~TableStyleTextStyleContext()
68 // CT_TableStyleTextStyle
69 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
70 TableStyleTextStyleContext::createFastChildContext( ::sal_Int32 aElementToken
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttribs
)
71 throw ( xml::sax::SAXException
, uno::RuntimeException
)
73 uno::Reference
< xml::sax::XFastContextHandler
> xRet
;
74 AttributeList
aAttribs( xAttribs
);
76 switch( aElementToken
)
78 // EG_ThemeableFontStyles (choice)
79 case NMSP_DRAWINGML
|XML_font
: // CT_FontCollection
82 case NMSP_DRAWINGML
|XML_ea
: // CT_TextFont
83 mrTableStylePart
.getAsianFont().setAttributes( aAttribs
);
85 case NMSP_DRAWINGML
|XML_cs
: // CT_TextFont
86 mrTableStylePart
.getComplexFont().setAttributes( aAttribs
);
88 case NMSP_DRAWINGML
|XML_sym
: // CT_TextFont
89 mrTableStylePart
.getSymbolFont().setAttributes( aAttribs
);
91 case NMSP_DRAWINGML
|XML_latin
: // CT_TextFont
92 mrTableStylePart
.getLatinFont().setAttributes( aAttribs
);
95 case NMSP_DRAWINGML
|XML_fontRef
: // CT_FontReference
97 ShapeStyleRef
& rFontStyle
= mrTableStylePart
.getStyleRefs()[ XML_fontRef
];
98 rFontStyle
.mnThemedIdx
= aAttribs
.getToken( XML_idx
, XML_none
);
99 xRet
.set( new ColorContext( *this, rFontStyle
.maPhClr
) );
103 case NMSP_DRAWINGML
|XML_extLst
: // CT_OfficeArtExtensionList
107 xRet
.set( new ColorValueContext( *this, mrTableStylePart
.getTextColor() ) );