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 .
21 #include <drawingml/table/tablecellcontext.hxx>
22 #include <drawingml/textbodycontext.hxx>
23 #include <drawingml/linepropertiescontext.hxx>
24 #include <drawingml/misccontexts.hxx>
25 #include <oox/helper/attributelist.hxx>
26 #include <oox/token/namespaces.hxx>
27 #include <oox/token/tokens.hxx>
29 using namespace ::oox::core
;
30 using namespace ::com::sun::star
;
32 namespace oox::drawingml::table
{
34 TableCellContext::TableCellContext( ContextHandler2Helper
const & rParent
, const AttributeList
& rAttribs
, TableCell
& rTableCell
)
35 : ContextHandler2( rParent
)
36 , mrTableCell( rTableCell
)
38 if ( rAttribs
.hasAttribute( XML_rowSpan
) )
39 mrTableCell
.setRowSpan( rAttribs
.getInteger( XML_rowSpan
, 0 ) );
40 if ( rAttribs
.hasAttribute( XML_gridSpan
) )
41 mrTableCell
.setGridSpan( rAttribs
.getInteger( XML_gridSpan
, 0 ) );
43 mrTableCell
.sethMerge( rAttribs
.getBool( XML_hMerge
, false ) );
44 mrTableCell
.setvMerge( rAttribs
.getBool( XML_vMerge
, false ) );
47 TableCellContext::~TableCellContext()
52 TableCellContext::onCreateContext( ::sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
54 switch( aElementToken
)
56 case A_TOKEN( txBody
): // CT_TextBody
58 oox::drawingml::TextBodyPtr xTextBody
= std::make_shared
<oox::drawingml::TextBody
>();
59 mrTableCell
.setTextBody( xTextBody
);
60 return new oox::drawingml::TextBodyContext( *this, *xTextBody
);
63 case A_TOKEN( tcPr
): // CT_TableCellProperties
65 mrTableCell
.setLeftMargin( rAttribs
.getInteger( XML_marL
, 91440 ) );
66 mrTableCell
.setRightMargin( rAttribs
.getInteger( XML_marR
, 91440 ) );
67 mrTableCell
.setTopMargin( rAttribs
.getInteger( XML_marT
, 45720 ) );
68 mrTableCell
.setBottomMargin( rAttribs
.getInteger( XML_marB
, 45720 ) );
69 mrTableCell
.setVertToken( rAttribs
.getToken( XML_vert
, XML_horz
) ); // ST_TextVerticalType
70 mrTableCell
.setAnchorToken( rAttribs
.getToken( XML_anchor
, XML_t
) ); // ST_TextAnchoringType
71 mrTableCell
.setAnchorCtr( rAttribs
.getBool( XML_anchorCtr
, false ) );
72 mrTableCell
.setHorzOverflowToken( rAttribs
.getToken( XML_horzOverflow
, XML_clip
) ); // ST_TextHorzOverflowType
76 return new oox::drawingml::LinePropertiesContext( *this, rAttribs
, mrTableCell
.maLinePropertiesLeft
);
78 return new oox::drawingml::LinePropertiesContext( *this, rAttribs
, mrTableCell
.maLinePropertiesRight
);
80 return new oox::drawingml::LinePropertiesContext( *this, rAttribs
, mrTableCell
.maLinePropertiesTop
);
82 return new oox::drawingml::LinePropertiesContext( *this, rAttribs
, mrTableCell
.maLinePropertiesBottom
);
83 case A_TOKEN( lnTlToBr
):
84 return new oox::drawingml::LinePropertiesContext( *this, rAttribs
, mrTableCell
.maLinePropertiesTopLeftToBottomRight
);
85 case A_TOKEN( lnBlToTr
):
86 return new oox::drawingml::LinePropertiesContext( *this, rAttribs
, mrTableCell
.maLinePropertiesBottomLeftToTopRight
);
87 case A_TOKEN( cell3D
): // CT_Cell3D
90 case A_TOKEN( extLst
): // CT_OfficeArtExtensionList
94 return FillPropertiesContext::createFillContext(*this, aElementToken
, rAttribs
, mrTableCell
.maFillProperties
, nullptr);
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */