1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
);
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
81 xRet
.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs
, mrTableCell
.maLinePropertiesLeft
) );
84 xRet
.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs
, mrTableCell
.maLinePropertiesRight
) );
87 xRet
.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs
, mrTableCell
.maLinePropertiesTop
) );
90 xRet
.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs
, mrTableCell
.maLinePropertiesBottom
) );
92 case A_TOKEN( lnTlToBr
):
93 xRet
.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs
, mrTableCell
.maLinePropertiesTopLeftToBottomRight
) );
95 case A_TOKEN( lnBlToTr
):
96 xRet
.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs
, mrTableCell
.maLinePropertiesBottomLeftToTopRight
) );
98 case A_TOKEN( cell3D
): // CT_Cell3D
101 case A_TOKEN( extLst
): // CT_OfficeArtExtensionList
105 xRet
.set( FillPropertiesContext::createFillContext( *this, aElementToken
, xAttribs
, mrTableCell
.maFillProperties
) );
111 uno::Reference
< XFastContextHandler
> xTmp( this );
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */