Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <osl/diagnose.h>
21 :
22 : #include "oox/drawingml/table/tablestyletextstylecontext.hxx"
23 : #include "oox/drawingml/colorchoicecontext.hxx"
24 : #include "oox/helper/attributelist.hxx"
25 :
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;
30 :
31 : namespace oox { namespace drawingml { namespace table {
32 :
33 0 : TableStyleTextStyleContext::TableStyleTextStyleContext( ContextHandler& rParent,
34 : const Reference< XFastAttributeList >& xAttribs, TableStylePart& rTableStylePart )
35 : : ContextHandler( rParent )
36 0 : , mrTableStylePart( rTableStylePart )
37 : {
38 0 : if( xAttribs->hasAttribute( XML_b ) ) {
39 0 : sal_Int32 nB = xAttribs->getOptionalValueToken( XML_b, XML_def );
40 0 : if ( nB == XML_on )
41 0 : mrTableStylePart.getTextBoldStyle() = ::boost::optional< sal_Bool >( sal_True );
42 0 : else if ( nB == XML_off )
43 0 : mrTableStylePart.getTextBoldStyle() = ::boost::optional< sal_Bool >( sal_False );
44 : }
45 :
46 0 : if( xAttribs->hasAttribute( XML_i ) ) {
47 0 : sal_Int32 nI = xAttribs->getOptionalValueToken( XML_i, XML_def );
48 0 : if ( nI == XML_on )
49 0 : mrTableStylePart.getTextItalicStyle() = ::boost::optional< sal_Bool >( sal_True );
50 0 : else if ( nI == XML_off )
51 0 : mrTableStylePart.getTextItalicStyle() = ::boost::optional< sal_Bool >( sal_False );
52 : }
53 0 : }
54 :
55 0 : TableStyleTextStyleContext::~TableStyleTextStyleContext()
56 : {
57 0 : }
58 :
59 : // CT_TableStyleTextStyle
60 : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
61 0 : TableStyleTextStyleContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
62 : throw ( xml::sax::SAXException, uno::RuntimeException)
63 : {
64 0 : uno::Reference< xml::sax::XFastContextHandler > xRet;
65 0 : AttributeList aAttribs( xAttribs );
66 :
67 0 : switch( aElementToken )
68 : {
69 : // EG_ThemeableFontStyles (choice)
70 : case A_TOKEN( font ): // CT_FontCollection
71 0 : xRet.set( this );
72 0 : break;
73 : case A_TOKEN( ea ): // CT_TextFont
74 0 : mrTableStylePart.getAsianFont().setAttributes( aAttribs );
75 0 : return 0;
76 : case A_TOKEN( cs ): // CT_TextFont
77 0 : mrTableStylePart.getComplexFont().setAttributes( aAttribs );
78 0 : return 0;
79 : case A_TOKEN( sym ): // CT_TextFont
80 0 : mrTableStylePart.getSymbolFont().setAttributes( aAttribs );
81 0 : return 0;
82 : case A_TOKEN( latin ): // CT_TextFont
83 0 : mrTableStylePart.getLatinFont().setAttributes( aAttribs );
84 0 : return 0;
85 :
86 : case A_TOKEN( fontRef ): // CT_FontReference
87 : {
88 0 : ShapeStyleRef& rFontStyle = mrTableStylePart.getStyleRefs()[ XML_fontRef ];
89 0 : rFontStyle.mnThemedIdx = aAttribs.getToken( XML_idx, XML_none );
90 0 : xRet.set( new ColorContext( *this, rFontStyle.maPhClr ) );
91 : }
92 0 : break;
93 :
94 : case A_TOKEN( extLst ): // CT_OfficeArtExtensionList
95 0 : break;
96 : }
97 0 : if( !xRet.is() )
98 0 : xRet.set( new ColorValueContext( *this, mrTableStylePart.getTextColor() ) );
99 :
100 0 : return xRet;
101 : }
102 :
103 51 : } } }
104 :
105 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|