1*ca5ec200SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*ca5ec200SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*ca5ec200SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*ca5ec200SAndrew Rist * distributed with this work for additional information
6*ca5ec200SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*ca5ec200SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*ca5ec200SAndrew Rist * "License"); you may not use this file except in compliance
9*ca5ec200SAndrew Rist * with the License. You may obtain a copy of the License at
10*ca5ec200SAndrew Rist *
11*ca5ec200SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*ca5ec200SAndrew Rist *
13*ca5ec200SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*ca5ec200SAndrew Rist * software distributed under the License is distributed on an
15*ca5ec200SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ca5ec200SAndrew Rist * KIND, either express or implied. See the License for the
17*ca5ec200SAndrew Rist * specific language governing permissions and limitations
18*ca5ec200SAndrew Rist * under the License.
19*ca5ec200SAndrew Rist *
20*ca5ec200SAndrew Rist *************************************************************/
21*ca5ec200SAndrew Rist
22*ca5ec200SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include <osl/diagnose.h>
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include "oox/drawingml/table/tablecellcontext.hxx"
27cdf0e10cSrcweir #include "oox/drawingml/textbodycontext.hxx"
28cdf0e10cSrcweir #include "oox/drawingml/linepropertiescontext.hxx"
29cdf0e10cSrcweir #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
30cdf0e10cSrcweir #include "oox/helper/attributelist.hxx"
31cdf0e10cSrcweir
32cdf0e10cSrcweir using namespace ::oox::core;
33cdf0e10cSrcweir using namespace ::com::sun::star;
34cdf0e10cSrcweir using ::rtl::OUString;
35cdf0e10cSrcweir
36cdf0e10cSrcweir namespace oox { namespace drawingml { namespace table {
37cdf0e10cSrcweir
TableCellContext(ContextHandler & rParent,const uno::Reference<xml::sax::XFastAttributeList> & xAttribs,TableCell & rTableCell)38cdf0e10cSrcweir TableCellContext::TableCellContext( ContextHandler& rParent, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs, TableCell& rTableCell )
39cdf0e10cSrcweir : ContextHandler( rParent )
40cdf0e10cSrcweir , mrTableCell( rTableCell )
41cdf0e10cSrcweir {
42cdf0e10cSrcweir if ( xAttribs->hasAttribute( XML_rowSpan ) )
43cdf0e10cSrcweir mrTableCell.setRowSpan( xAttribs->getOptionalValue( XML_rowSpan ).toInt32() );
44cdf0e10cSrcweir if ( xAttribs->hasAttribute( XML_gridSpan ) )
45cdf0e10cSrcweir mrTableCell.setGridSpan( xAttribs->getOptionalValue( XML_gridSpan ).toInt32() );
46cdf0e10cSrcweir
47cdf0e10cSrcweir AttributeList aAttribs( xAttribs );
48cdf0e10cSrcweir mrTableCell.sethMerge( aAttribs.getBool( XML_hMerge, sal_False ) );
49cdf0e10cSrcweir mrTableCell.setvMerge( aAttribs.getBool( XML_vMerge, sal_False ) );
50cdf0e10cSrcweir }
51cdf0e10cSrcweir
~TableCellContext()52cdf0e10cSrcweir TableCellContext::~TableCellContext()
53cdf0e10cSrcweir {
54cdf0e10cSrcweir }
55cdf0e10cSrcweir
56cdf0e10cSrcweir uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
createFastChildContext(::sal_Int32 aElementToken,const uno::Reference<xml::sax::XFastAttributeList> & xAttribs)57cdf0e10cSrcweir TableCellContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
58cdf0e10cSrcweir throw ( xml::sax::SAXException, uno::RuntimeException)
59cdf0e10cSrcweir {
60cdf0e10cSrcweir uno::Reference< xml::sax::XFastContextHandler > xRet;
61cdf0e10cSrcweir
62cdf0e10cSrcweir switch( aElementToken )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir case A_TOKEN( txBody ): // CT_TextBody
65cdf0e10cSrcweir {
66cdf0e10cSrcweir oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody );
67cdf0e10cSrcweir mrTableCell.setTextBody( xTextBody );
68cdf0e10cSrcweir xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody );
69cdf0e10cSrcweir }
70cdf0e10cSrcweir break;
71cdf0e10cSrcweir
72cdf0e10cSrcweir case A_TOKEN( tcPr ): // CT_TableCellProperties
73cdf0e10cSrcweir {
74cdf0e10cSrcweir AttributeList aAttribs( xAttribs );
75cdf0e10cSrcweir mrTableCell.setLeftMargin( aAttribs.getInteger( XML_marL, 91440 ) );
76cdf0e10cSrcweir mrTableCell.setRightMargin( aAttribs.getInteger( XML_marR, 91440 ) );
77cdf0e10cSrcweir mrTableCell.setTopMargin( aAttribs.getInteger( XML_marT, 45720 ) );
78cdf0e10cSrcweir mrTableCell.setBottomMargin( aAttribs.getInteger( XML_marB, 45720 ) );
79cdf0e10cSrcweir mrTableCell.setVertToken( xAttribs->getOptionalValueToken( XML_vert, XML_horz ) ); // ST_TextVerticalType
80cdf0e10cSrcweir mrTableCell.setAnchorToken( xAttribs->getOptionalValueToken( XML_anchor, XML_t ) ); // ST_TextAnchoringType
81cdf0e10cSrcweir mrTableCell.setAnchorCtr( aAttribs.getBool( XML_anchorCtr, sal_False ) );
82cdf0e10cSrcweir mrTableCell.setHorzOverflowToken( xAttribs->getOptionalValueToken( XML_horzOverflow, XML_clip ) ); // ST_TextHorzOverflowType
83cdf0e10cSrcweir }
84cdf0e10cSrcweir break;
85cdf0e10cSrcweir case A_TOKEN( lnL ):
86cdf0e10cSrcweir xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesLeft ) );
87cdf0e10cSrcweir break;
88cdf0e10cSrcweir case A_TOKEN( lnR ):
89cdf0e10cSrcweir xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesRight ) );
90cdf0e10cSrcweir break;
91cdf0e10cSrcweir case A_TOKEN( lnT ):
92cdf0e10cSrcweir xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesTop ) );
93cdf0e10cSrcweir break;
94cdf0e10cSrcweir case A_TOKEN( lnB ):
95cdf0e10cSrcweir xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesBottom ) );
96cdf0e10cSrcweir break;
97cdf0e10cSrcweir case A_TOKEN( lnTlToBr ):
98cdf0e10cSrcweir xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesTopLeftToBottomRight ) );
99cdf0e10cSrcweir break;
100cdf0e10cSrcweir case A_TOKEN( lnBlToTr ):
101cdf0e10cSrcweir xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesBottomLeftToTopRight ) );
102cdf0e10cSrcweir break;
103cdf0e10cSrcweir case A_TOKEN( cell3D ): // CT_Cell3D
104cdf0e10cSrcweir break;
105cdf0e10cSrcweir
106cdf0e10cSrcweir case A_TOKEN( extLst ): // CT_OfficeArtExtensionList
107cdf0e10cSrcweir break;
108cdf0e10cSrcweir
109cdf0e10cSrcweir default:
110cdf0e10cSrcweir xRet.set( FillPropertiesContext::createFillContext( *this, aElementToken, xAttribs, mrTableCell.maFillProperties ) );
111cdf0e10cSrcweir break;
112cdf0e10cSrcweir
113cdf0e10cSrcweir }
114cdf0e10cSrcweir if ( !xRet.is() )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir uno::Reference< XFastContextHandler > xTmp( this );
117cdf0e10cSrcweir xRet.set( xTmp );
118cdf0e10cSrcweir }
119cdf0e10cSrcweir return xRet;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
122cdf0e10cSrcweir } } }
123