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 <osl/diagnose.h>
22 #include "drawingml/table/tablestyletextstylecontext.hxx"
23 #include "drawingml/colorchoicecontext.hxx"
24 #include "oox/helper/attributelist.hxx"
26 using namespace ::oox::core
;
27 using namespace ::com::sun::star
;
28 using namespace ::com::sun::star::uno
;
29 using namespace ::com::sun::star::xml::sax
;
31 namespace oox
{ namespace drawingml
{ namespace table
{
33 TableStyleTextStyleContext::TableStyleTextStyleContext( ContextHandler2Helper
& rParent
,
34 const AttributeList
& rAttribs
, TableStylePart
& rTableStylePart
)
35 : ContextHandler2( rParent
)
36 , mrTableStylePart( rTableStylePart
)
38 if( rAttribs
.hasAttribute( XML_b
) ) {
39 sal_Int32 nB
= rAttribs
.getToken( XML_b
, XML_def
);
41 mrTableStylePart
.getTextBoldStyle() = ::boost::optional
< sal_Bool
>( sal_True
);
42 else if ( nB
== XML_off
)
43 mrTableStylePart
.getTextBoldStyle() = ::boost::optional
< sal_Bool
>( sal_False
);
46 if( rAttribs
.hasAttribute( XML_i
) ) {
47 sal_Int32 nI
= rAttribs
.getToken( XML_i
, XML_def
);
49 mrTableStylePart
.getTextItalicStyle() = ::boost::optional
< sal_Bool
>( sal_True
);
50 else if ( nI
== XML_off
)
51 mrTableStylePart
.getTextItalicStyle() = ::boost::optional
< sal_Bool
>( sal_False
);
55 TableStyleTextStyleContext::~TableStyleTextStyleContext()
59 // CT_TableStyleTextStyle
61 TableStyleTextStyleContext::onCreateContext( ::sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
63 switch( aElementToken
)
65 // EG_ThemeableFontStyles (choice)
66 case A_TOKEN( font
): // CT_FontCollection
68 case A_TOKEN( ea
): // CT_TextFont
69 mrTableStylePart
.getAsianFont().setAttributes( rAttribs
);
71 case A_TOKEN( cs
): // CT_TextFont
72 mrTableStylePart
.getComplexFont().setAttributes( rAttribs
);
74 case A_TOKEN( sym
): // CT_TextFont
75 mrTableStylePart
.getSymbolFont().setAttributes( rAttribs
);
77 case A_TOKEN( latin
): // CT_TextFont
78 mrTableStylePart
.getLatinFont().setAttributes( rAttribs
);
81 case A_TOKEN( fontRef
): // CT_FontReference
83 ShapeStyleRef
& rFontStyle
= mrTableStylePart
.getStyleRefs()[ XML_fontRef
];
84 rFontStyle
.mnThemedIdx
= rAttribs
.getToken( XML_idx
, XML_none
);
85 return new ColorContext( *this, rFontStyle
.maPhClr
);
88 case A_TOKEN( extLst
): // CT_OfficeArtExtensionList
92 return new ColorValueContext( *this, mrTableStylePart
.getTextColor() );
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */