xref: /AOO41X/main/oox/source/drawingml/table/tablebackgroundstylecontext.cxx (revision ca5ec2004b000a7d9aaa8381be8ac2853e3b1dc7)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include <osl/diagnose.h>
25 
26 #include "oox/drawingml/table/tablebackgroundstylecontext.hxx"
27 #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
28 #include "oox/helper/attributelist.hxx"
29 
30 using namespace ::oox::core;
31 using namespace ::com::sun::star;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::xml::sax;
34 using ::rtl::OUString;
35 
36 namespace oox { namespace drawingml { namespace table {
37 
TableBackgroundStyleContext(ContextHandler & rParent,TableStyle & rTableStyle)38 TableBackgroundStyleContext::TableBackgroundStyleContext( ContextHandler& rParent, TableStyle& rTableStyle )
39 : ContextHandler( rParent )
40 , mrTableStyle( rTableStyle )
41 {
42 }
43 
~TableBackgroundStyleContext()44 TableBackgroundStyleContext::~TableBackgroundStyleContext()
45 {
46 }
47 
48 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
createFastChildContext(::sal_Int32 aElementToken,const uno::Reference<xml::sax::XFastAttributeList> & xAttribs)49 TableBackgroundStyleContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
50     throw ( xml::sax::SAXException, uno::RuntimeException)
51 {
52     uno::Reference< xml::sax::XFastContextHandler > xRet;
53 
54     AttributeList aAttribs( xAttribs );
55     switch( aElementToken )
56     {
57         // EG_ThemeableFillStyle (choice)
58         case A_TOKEN( fill ):       // CT_FillProperties
59             {
60                 boost::shared_ptr< FillProperties >& rxFillProperties = mrTableStyle.getBackgroundFillProperties();
61                 rxFillProperties.reset( new FillProperties );
62                 xRet.set( new FillPropertiesContext( *this, *rxFillProperties ) );
63             }
64             break;
65         case A_TOKEN( fillRef ):    // CT_StyleMatrixReference
66             {
67                 ShapeStyleRef& rStyleRef = mrTableStyle.getBackgroundFillStyleRef();
68                 rStyleRef.mnThemedIdx = aAttribs.getInteger( XML_idx, 0 );
69                 xRet.set( new ColorContext( *this, rStyleRef.maPhClr ) );
70             }
71             break;
72 
73         // EG_ThemeableEffectStyle (choice)
74         case A_TOKEN( effect ):     // CT_EffectProperties
75             break;
76         case A_TOKEN( effectRef ):  // CT_StyleMatrixReference
77             break;
78     }
79     if( !xRet.is() )
80     {
81         uno::Reference<XFastContextHandler> xTmp(this);
82         xRet.set( xTmp );
83     }
84     return xRet;
85 }
86 
87 } } }
88