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/tablestylecellstylecontext.hxx"
27 #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
28 #include "oox/drawingml/linepropertiescontext.hxx"
29 #include "oox/helper/attributelist.hxx"
30
31 using namespace ::oox::core;
32 using namespace ::com::sun::star;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::xml::sax;
35 using ::rtl::OUString;
36
37 namespace oox { namespace drawingml { namespace table {
38
TableStyleCellStyleContext(ContextHandler & rParent,TableStylePart & rTableStylePart)39 TableStyleCellStyleContext::TableStyleCellStyleContext( ContextHandler& rParent, TableStylePart& rTableStylePart )
40 : ContextHandler( rParent )
41 , mrTableStylePart( rTableStylePart )
42 , mnLineType( XML_none )
43 {
44 }
45
~TableStyleCellStyleContext()46 TableStyleCellStyleContext::~TableStyleCellStyleContext()
47 {
48 }
49
50 // CT_TableStyleCellStyle
51 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
createFastChildContext(::sal_Int32 aElementToken,const uno::Reference<xml::sax::XFastAttributeList> & xAttribs)52 TableStyleCellStyleContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
53 throw ( xml::sax::SAXException, uno::RuntimeException)
54 {
55 uno::Reference< xml::sax::XFastContextHandler > xRet;
56 AttributeList aAttribs( xAttribs );
57 switch( aElementToken )
58 {
59 case A_TOKEN( tcBdr ): // CT_TableCellBorderStyle
60 break;
61 case A_TOKEN( left ): // CT_ThemeableLineStyle
62 case A_TOKEN( right ):
63 case A_TOKEN( top ):
64 case A_TOKEN( bottom ):
65 case A_TOKEN( insideH ):
66 case A_TOKEN( insideV ):
67 case A_TOKEN( tl2br ):
68 case A_TOKEN( tr2bl ):
69 mnLineType = getBaseToken( aElementToken );
70 break;
71
72 case A_TOKEN( ln ):
73 {
74 if ( mnLineType != XML_none )
75 {
76 std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr >& rLineBorders = mrTableStylePart.getLineBorders();
77 ::oox::drawingml::LinePropertiesPtr mpLineProperties( new oox::drawingml::LineProperties );
78 rLineBorders[ mnLineType ] = mpLineProperties;
79 xRet = new LinePropertiesContext( *this, xAttribs, *mpLineProperties );
80 }
81 }
82 break;
83 case A_TOKEN( lnRef ):
84 {
85 if ( mnLineType != XML_none )
86 {
87 ShapeStyleRef& rLineStyleRef = mrTableStylePart.getStyleRefs()[ mnLineType ];
88 rLineStyleRef.mnThemedIdx = aAttribs.getInteger( XML_idx, 0 );
89 xRet.set( new ColorContext( *this, rLineStyleRef.maPhClr ) );
90 }
91 }
92 break;
93
94 // EG_ThemeableFillStyle (choice)
95 case A_TOKEN( fill ): // CT_FillProperties
96 {
97 FillPropertiesPtr& rxFillProperties = mrTableStylePart.getFillProperties();
98 rxFillProperties.reset( new FillProperties );
99 xRet.set( new FillPropertiesContext( *this, *rxFillProperties ) );
100 }
101 break;
102 case A_TOKEN( fillRef ): // CT_StyleMatrixReference
103 {
104 ShapeStyleRef& rStyleRef = mrTableStylePart.getStyleRefs()[ XML_fillRef ];
105 rStyleRef.mnThemedIdx = aAttribs.getInteger( XML_idx, 0 );
106 xRet.set( new ColorContext( *this, rStyleRef.maPhClr ) );
107 }
108 break;
109
110 case A_TOKEN( cell3D ): // CT_Cell3D
111 break;
112 }
113 if( !xRet.is() )
114 {
115 uno::Reference<XFastContextHandler> xTmp(this);
116 xRet.set( xTmp );
117 }
118 return xRet;
119 }
120
121 } } }
122