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 {
54 uno::Reference< xml::sax::XFastContextHandler > xRet;
55 AttributeList aAttribs( xAttribs );
56 switch( aElementToken )
57 {
58 case A_TOKEN( tcBdr ): // CT_TableCellBorderStyle
59 break;
60 case A_TOKEN( left ): // CT_ThemeableLineStyle
61 case A_TOKEN( right ):
62 case A_TOKEN( top ):
63 case A_TOKEN( bottom ):
64 case A_TOKEN( insideH ):
65 case A_TOKEN( insideV ):
66 case A_TOKEN( tl2br ):
67 case A_TOKEN( tr2bl ):
68 mnLineType = getBaseToken( aElementToken );
69 break;
70
71 case A_TOKEN( ln ):
72 {
73 if ( mnLineType != XML_none )
74 {
75 std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr >& rLineBorders = mrTableStylePart.getLineBorders();
76 ::oox::drawingml::LinePropertiesPtr mpLineProperties( new oox::drawingml::LineProperties );
77 rLineBorders[ mnLineType ] = mpLineProperties;
78 xRet = new LinePropertiesContext( *this, xAttribs, *mpLineProperties );
79 }
80 }
81 break;
82 case A_TOKEN( lnRef ):
83 {
84 if ( mnLineType != XML_none )
85 {
86 ShapeStyleRef& rLineStyleRef = mrTableStylePart.getStyleRefs()[ mnLineType ];
87 rLineStyleRef.mnThemedIdx = aAttribs.getInteger( XML_idx, 0 );
88 xRet.set( new ColorContext( *this, rLineStyleRef.maPhClr ) );
89 }
90 }
91 break;
92
93 // EG_ThemeableFillStyle (choice)
94 case A_TOKEN( fill ): // CT_FillProperties
95 {
96 FillPropertiesPtr& rxFillProperties = mrTableStylePart.getFillProperties();
97 rxFillProperties.reset( new FillProperties );
98 xRet.set( new FillPropertiesContext( *this, *rxFillProperties ) );
99 }
100 break;
101 case A_TOKEN( fillRef ): // CT_StyleMatrixReference
102 {
103 ShapeStyleRef& rStyleRef = mrTableStylePart.getStyleRefs()[ XML_fillRef ];
104 rStyleRef.mnThemedIdx = aAttribs.getInteger( XML_idx, 0 );
105 xRet.set( new ColorContext( *this, rStyleRef.maPhClr ) );
106 }
107 break;
108
109 case A_TOKEN( cell3D ): // CT_Cell3D
110 break;
111 }
112 if( !xRet.is() )
113 {
114 uno::Reference<XFastContextHandler> xTmp(this);
115 xRet.set( xTmp );
116 }
117 return xRet;
118 }
119
120 } } }
121