1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include <osl/diagnose.h>
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "oox/drawingml/table/tablecellcontext.hxx"
31*cdf0e10cSrcweir #include "oox/drawingml/textbodycontext.hxx"
32*cdf0e10cSrcweir #include "oox/drawingml/linepropertiescontext.hxx"
33*cdf0e10cSrcweir #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
34*cdf0e10cSrcweir #include "oox/helper/attributelist.hxx"
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir using namespace ::oox::core;
37*cdf0e10cSrcweir using namespace ::com::sun::star;
38*cdf0e10cSrcweir using ::rtl::OUString;
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir namespace oox { namespace drawingml { namespace table {
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir TableCellContext::TableCellContext( ContextHandler& rParent, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs, TableCell& rTableCell )
43*cdf0e10cSrcweir : ContextHandler( rParent )
44*cdf0e10cSrcweir , mrTableCell( rTableCell )
45*cdf0e10cSrcweir {
46*cdf0e10cSrcweir 	if ( xAttribs->hasAttribute( XML_rowSpan ) )
47*cdf0e10cSrcweir 		mrTableCell.setRowSpan( xAttribs->getOptionalValue( XML_rowSpan ).toInt32() );
48*cdf0e10cSrcweir 	if ( xAttribs->hasAttribute( XML_gridSpan ) )
49*cdf0e10cSrcweir 		mrTableCell.setGridSpan( xAttribs->getOptionalValue( XML_gridSpan ).toInt32() );
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir 	AttributeList aAttribs( xAttribs );
52*cdf0e10cSrcweir 	mrTableCell.sethMerge( aAttribs.getBool( XML_hMerge, sal_False ) );
53*cdf0e10cSrcweir 	mrTableCell.setvMerge( aAttribs.getBool( XML_vMerge, sal_False ) );
54*cdf0e10cSrcweir }
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir TableCellContext::~TableCellContext()
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir }
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
61*cdf0e10cSrcweir TableCellContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
62*cdf0e10cSrcweir 	throw ( xml::sax::SAXException, uno::RuntimeException)
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir 	uno::Reference< xml::sax::XFastContextHandler > xRet;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir 	switch( aElementToken )
67*cdf0e10cSrcweir 	{
68*cdf0e10cSrcweir 	case A_TOKEN( txBody ):		// CT_TextBody
69*cdf0e10cSrcweir 		{
70*cdf0e10cSrcweir 	        oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody );
71*cdf0e10cSrcweir 		    mrTableCell.setTextBody( xTextBody );
72*cdf0e10cSrcweir 			xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody );
73*cdf0e10cSrcweir 		}
74*cdf0e10cSrcweir 		break;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	case A_TOKEN( tcPr ):		// CT_TableCellProperties
77*cdf0e10cSrcweir 		{
78*cdf0e10cSrcweir 			AttributeList aAttribs( xAttribs );
79*cdf0e10cSrcweir 			mrTableCell.setLeftMargin( aAttribs.getInteger( XML_marL, 91440 ) );
80*cdf0e10cSrcweir 			mrTableCell.setRightMargin( aAttribs.getInteger( XML_marR, 91440 ) );
81*cdf0e10cSrcweir 			mrTableCell.setTopMargin( aAttribs.getInteger( XML_marT, 45720 ) );
82*cdf0e10cSrcweir 			mrTableCell.setBottomMargin( aAttribs.getInteger( XML_marB, 45720 ) );
83*cdf0e10cSrcweir 			mrTableCell.setVertToken( xAttribs->getOptionalValueToken( XML_vert, XML_horz ) );					// ST_TextVerticalType
84*cdf0e10cSrcweir 			mrTableCell.setAnchorToken( xAttribs->getOptionalValueToken( XML_anchor, XML_t ) );					// ST_TextAnchoringType
85*cdf0e10cSrcweir 			mrTableCell.setAnchorCtr( aAttribs.getBool( XML_anchorCtr, sal_False ) );
86*cdf0e10cSrcweir 			mrTableCell.setHorzOverflowToken( xAttribs->getOptionalValueToken( XML_horzOverflow, XML_clip ) );	// ST_TextHorzOverflowType
87*cdf0e10cSrcweir 		}
88*cdf0e10cSrcweir 		break;
89*cdf0e10cSrcweir 		case A_TOKEN( lnL ):
90*cdf0e10cSrcweir 				xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesLeft ) );
91*cdf0e10cSrcweir 			break;
92*cdf0e10cSrcweir 		case A_TOKEN( lnR ):
93*cdf0e10cSrcweir 				xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesRight ) );
94*cdf0e10cSrcweir 			break;
95*cdf0e10cSrcweir 		case A_TOKEN( lnT ):
96*cdf0e10cSrcweir 				xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesTop ) );
97*cdf0e10cSrcweir 			break;
98*cdf0e10cSrcweir 		case A_TOKEN( lnB ):
99*cdf0e10cSrcweir 				xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesBottom ) );
100*cdf0e10cSrcweir 			break;
101*cdf0e10cSrcweir 		case A_TOKEN( lnTlToBr ):
102*cdf0e10cSrcweir 				xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesTopLeftToBottomRight ) );
103*cdf0e10cSrcweir 			break;
104*cdf0e10cSrcweir 		case A_TOKEN( lnBlToTr ):
105*cdf0e10cSrcweir 				xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesBottomLeftToTopRight ) );
106*cdf0e10cSrcweir 			break;
107*cdf0e10cSrcweir 		case A_TOKEN( cell3D ):	// CT_Cell3D
108*cdf0e10cSrcweir 		break;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 	case A_TOKEN( extLst ):		// CT_OfficeArtExtensionList
111*cdf0e10cSrcweir 	break;
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	default:
114*cdf0e10cSrcweir         xRet.set( FillPropertiesContext::createFillContext( *this, aElementToken, xAttribs, mrTableCell.maFillProperties ) );
115*cdf0e10cSrcweir 	break;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	}
118*cdf0e10cSrcweir 	if ( !xRet.is() )
119*cdf0e10cSrcweir 	{
120*cdf0e10cSrcweir         uno::Reference< XFastContextHandler > xTmp( this );
121*cdf0e10cSrcweir 		xRet.set( xTmp );
122*cdf0e10cSrcweir 	}
123*cdf0e10cSrcweir 	return xRet;
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir } } }
127