bump product version to 4.1.6.2
[LibreOffice.git] / oox / source / drawingml / table / tablecellcontext.cxx
blob0c9e9bb092a052b04ad6d18db3aad1a9f79fd8ea
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <osl/diagnose.h>
22 #include "oox/drawingml/table/tablecellcontext.hxx"
23 #include "oox/drawingml/textbodycontext.hxx"
24 #include "oox/drawingml/linepropertiescontext.hxx"
25 #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
26 #include "oox/helper/attributelist.hxx"
28 using namespace ::oox::core;
29 using namespace ::com::sun::star;
31 namespace oox { namespace drawingml { namespace table {
33 TableCellContext::TableCellContext( ContextHandler& rParent, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs, TableCell& rTableCell )
34 : ContextHandler( rParent )
35 , mrTableCell( rTableCell )
37 if ( xAttribs->hasAttribute( XML_rowSpan ) )
38 mrTableCell.setRowSpan( xAttribs->getOptionalValue( XML_rowSpan ).toInt32() );
39 if ( xAttribs->hasAttribute( XML_gridSpan ) )
40 mrTableCell.setGridSpan( xAttribs->getOptionalValue( XML_gridSpan ).toInt32() );
42 AttributeList aAttribs( xAttribs );
43 mrTableCell.sethMerge( aAttribs.getBool( XML_hMerge, sal_False ) );
44 mrTableCell.setvMerge( aAttribs.getBool( XML_vMerge, sal_False ) );
47 TableCellContext::~TableCellContext()
51 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
52 TableCellContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
53 throw ( xml::sax::SAXException, uno::RuntimeException)
55 uno::Reference< xml::sax::XFastContextHandler > xRet;
57 switch( aElementToken )
59 case A_TOKEN( txBody ): // CT_TextBody
61 oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody );
62 mrTableCell.setTextBody( xTextBody );
63 xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody );
65 break;
67 case A_TOKEN( tcPr ): // CT_TableCellProperties
69 AttributeList aAttribs( xAttribs );
70 mrTableCell.setLeftMargin( aAttribs.getInteger( XML_marL, 91440 ) );
71 mrTableCell.setRightMargin( aAttribs.getInteger( XML_marR, 91440 ) );
72 mrTableCell.setTopMargin( aAttribs.getInteger( XML_marT, 45720 ) );
73 mrTableCell.setBottomMargin( aAttribs.getInteger( XML_marB, 45720 ) );
74 mrTableCell.setVertToken( xAttribs->getOptionalValueToken( XML_vert, XML_horz ) ); // ST_TextVerticalType
75 mrTableCell.setAnchorToken( xAttribs->getOptionalValueToken( XML_anchor, XML_t ) ); // ST_TextAnchoringType
76 mrTableCell.setAnchorCtr( aAttribs.getBool( XML_anchorCtr, sal_False ) );
77 mrTableCell.setHorzOverflowToken( xAttribs->getOptionalValueToken( XML_horzOverflow, XML_clip ) ); // ST_TextHorzOverflowType
79 break;
80 case A_TOKEN( lnL ):
81 xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesLeft ) );
82 break;
83 case A_TOKEN( lnR ):
84 xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesRight ) );
85 break;
86 case A_TOKEN( lnT ):
87 xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesTop ) );
88 break;
89 case A_TOKEN( lnB ):
90 xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesBottom ) );
91 break;
92 case A_TOKEN( lnTlToBr ):
93 xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesTopLeftToBottomRight ) );
94 break;
95 case A_TOKEN( lnBlToTr ):
96 xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesBottomLeftToTopRight ) );
97 break;
98 case A_TOKEN( cell3D ): // CT_Cell3D
99 break;
101 case A_TOKEN( extLst ): // CT_OfficeArtExtensionList
102 break;
104 default:
105 xRet.set( FillPropertiesContext::createFillContext( *this, aElementToken, xAttribs, mrTableCell.maFillProperties ) );
106 break;
109 if ( !xRet.is() )
111 uno::Reference< XFastContextHandler > xTmp( this );
112 xRet.set( xTmp );
114 return xRet;
117 } } }
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */