LibreOffice Module oox (master) 1
tablecellcontext.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
26#include <oox/token/namespaces.hxx>
27#include <oox/token/tokens.hxx>
28
29using namespace ::oox::core;
30using namespace ::com::sun::star;
31
32namespace oox::drawingml::table {
33
34TableCellContext::TableCellContext( ContextHandler2Helper const & rParent, const AttributeList& rAttribs, TableCell& rTableCell )
35: ContextHandler2( rParent )
36, mrTableCell( rTableCell )
37{
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 ) );
42
43 mrTableCell.sethMerge( rAttribs.getBool( XML_hMerge, false ) );
44 mrTableCell.setvMerge( rAttribs.getBool( XML_vMerge, false ) );
45}
46
48{
49}
50
52TableCellContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs )
53{
54 switch( aElementToken )
55 {
56 case A_TOKEN( txBody ): // CT_TextBody
57 {
58 oox::drawingml::TextBodyPtr xTextBody = std::make_shared<oox::drawingml::TextBody>();
59 mrTableCell.setTextBody( xTextBody );
60 return new oox::drawingml::TextBodyContext( *this, *xTextBody );
61 }
62
63 case A_TOKEN( tcPr ): // CT_TableCellProperties
64 {
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
73 }
74 break;
75 case A_TOKEN( lnL ):
77 case A_TOKEN( lnR ):
79 case A_TOKEN( lnT ):
81 case A_TOKEN( lnB ):
83 case A_TOKEN( lnTlToBr ):
85 case A_TOKEN( lnBlToTr ):
87 case A_TOKEN( cell3D ): // CT_Cell3D
88 break;
89
90 case A_TOKEN( extLst ): // CT_OfficeArtExtensionList
91 break;
92
93 default:
94 return FillPropertiesContext::createFillContext( *this, aElementToken, rAttribs, mrTableCell.maFillProperties );
95
96 }
97
98 return this;
99}
100
101}
102
103/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to attribute values of an element.
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
std::optional< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
::oox::core::ContextHandlerRef createFillContext(::oox::core::ContextHandler2Helper const &rParent, sal_Int32 nElement, const ::oox::AttributeList &rAttribs, FillProperties &rFillProps)
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
TableCellContext(::oox::core::ContextHandler2Helper const &rParent, const ::oox::AttributeList &rAttribs, TableCell &rTableCell)
oox::drawingml::FillProperties maFillProperties
Definition: tablecell.hxx:90
oox::drawingml::LineProperties maLinePropertiesTopLeftToBottomRight
Definition: tablecell.hxx:87
void setLeftMargin(sal_Int32 nMargin)
Definition: tablecell.hxx:53
void setRightMargin(sal_Int32 nMargin)
Definition: tablecell.hxx:55
void setAnchorToken(sal_Int32 nToken)
Definition: tablecell.hxx:63
oox::drawingml::LineProperties maLinePropertiesBottomLeftToTopRight
Definition: tablecell.hxx:88
void setTopMargin(sal_Int32 nMargin)
Definition: tablecell.hxx:57
void setTextBody(const oox::drawingml::TextBodyPtr &pTextBody)
Definition: tablecell.hxx:67
void setBottomMargin(sal_Int32 nMargin)
Definition: tablecell.hxx:59
void setGridSpan(sal_Int32 nGridSpan)
Definition: tablecell.hxx:47
void sethMerge(bool bhMerge)
Definition: tablecell.hxx:49
void setHorzOverflowToken(sal_Int32 nToken)
Definition: tablecell.hxx:65
oox::drawingml::LineProperties maLinePropertiesLeft
Definition: tablecell.hxx:81
oox::drawingml::LineProperties maLinePropertiesTop
Definition: tablecell.hxx:83
oox::drawingml::LineProperties maLinePropertiesRight
Definition: tablecell.hxx:82
void setvMerge(bool bvMerge)
Definition: tablecell.hxx:51
void setAnchorCtr(bool bAnchorCtr)
Definition: tablecell.hxx:64
oox::drawingml::LineProperties maLinePropertiesBottom
Definition: tablecell.hxx:84
void setVertToken(sal_Int32 nToken)
Definition: tablecell.hxx:61
void setRowSpan(sal_Int32 nRowSpan)
Definition: tablecell.hxx:45
std::shared_ptr< TextBody > TextBodyPtr