1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tablecellcontext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <osl/diagnose.h>
33 #include "oox/drawingml/table/tablecellcontext.hxx"
34 #include "oox/drawingml/textbodycontext.hxx"
35 #include "oox/drawingml/linepropertiescontext.hxx"
36 #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
37 #include "oox/core/namespaces.hxx"
38 #include "oox/helper/attributelist.hxx"
40 using namespace ::oox::core
;
41 using namespace ::com::sun::star
;
42 using ::rtl::OUString
;
44 namespace oox
{ namespace drawingml
{ namespace table
{
46 TableCellContext::TableCellContext( ContextHandler
& rParent
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttribs
, TableCell
& rTableCell
)
47 : ContextHandler( rParent
)
48 , mrTableCell( rTableCell
)
50 if ( xAttribs
->hasAttribute( XML_rowSpan
) )
51 mrTableCell
.setRowSpan( xAttribs
->getOptionalValue( XML_rowSpan
).toInt32() );
52 if ( xAttribs
->hasAttribute( XML_gridSpan
) )
53 mrTableCell
.setGridSpan( xAttribs
->getOptionalValue( XML_gridSpan
).toInt32() );
55 AttributeList
aAttribs( xAttribs
);
56 mrTableCell
.sethMerge( aAttribs
.getBool( XML_hMerge
, sal_False
) );
57 mrTableCell
.setvMerge( aAttribs
.getBool( XML_vMerge
, sal_False
) );
60 TableCellContext::~TableCellContext()
64 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
65 TableCellContext::createFastChildContext( ::sal_Int32 aElementToken
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttribs
)
66 throw ( xml::sax::SAXException
, uno::RuntimeException
)
68 uno::Reference
< xml::sax::XFastContextHandler
> xRet
;
70 switch( aElementToken
)
72 case NMSP_DRAWINGML
|XML_txBody
: // CT_TextBody
74 oox::drawingml::TextBodyPtr
xTextBody( new oox::drawingml::TextBody
);
75 mrTableCell
.setTextBody( xTextBody
);
76 xRet
= new oox::drawingml::TextBodyContext( *this, *xTextBody
);
80 case NMSP_DRAWINGML
|XML_tcPr
: // CT_TableCellProperties
82 AttributeList
aAttribs( xAttribs
);
83 mrTableCell
.setLeftMargin( aAttribs
.getInteger( XML_marL
, 91440 ) );
84 mrTableCell
.setRightMargin( aAttribs
.getInteger( XML_marR
, 91440 ) );
85 mrTableCell
.setTopMargin( aAttribs
.getInteger( XML_marT
, 45720 ) );
86 mrTableCell
.setBottomMargin( aAttribs
.getInteger( XML_marB
, 45720 ) );
87 mrTableCell
.setVertToken( xAttribs
->getOptionalValueToken( XML_vert
, XML_horz
) ); // ST_TextVerticalType
88 mrTableCell
.setAnchorToken( xAttribs
->getOptionalValueToken( XML_anchor
, XML_t
) ); // ST_TextAnchoringType
89 mrTableCell
.setAnchorCtr( aAttribs
.getBool( XML_anchorCtr
, sal_False
) );
90 mrTableCell
.setHorzOverflowToken( xAttribs
->getOptionalValueToken( XML_horzOverflow
, XML_clip
) ); // ST_TextHorzOverflowType
93 case NMSP_DRAWINGML
|XML_lnL
:
94 xRet
.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs
, mrTableCell
.maLinePropertiesLeft
) );
96 case NMSP_DRAWINGML
|XML_lnR
:
97 xRet
.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs
, mrTableCell
.maLinePropertiesRight
) );
99 case NMSP_DRAWINGML
|XML_lnT
:
100 xRet
.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs
, mrTableCell
.maLinePropertiesTop
) );
102 case NMSP_DRAWINGML
|XML_lnB
:
103 xRet
.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs
, mrTableCell
.maLinePropertiesBottom
) );
105 case NMSP_DRAWINGML
|XML_lnTlToBr
:
106 xRet
.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs
, mrTableCell
.maLinePropertiesTopLeftToBottomRight
) );
108 case NMSP_DRAWINGML
|XML_lnBlToTr
:
109 xRet
.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs
, mrTableCell
.maLinePropertiesBottomLeftToTopRight
) );
111 case NMSP_DRAWINGML
|XML_cell3D
: // CT_Cell3D
114 case NMSP_DRAWINGML
|XML_extLst
: // CT_OfficeArtExtensionList
118 xRet
.set( FillPropertiesContext::createFillContext( *this, aElementToken
, xAttribs
, mrTableCell
.maFillProperties
) );
124 uno::Reference
< XFastContextHandler
> xTmp( this );