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 
29 using namespace ::oox::core;
30 using namespace ::com::sun::star;
31 
32 namespace oox::drawingml::table {
33 
34 TableCellContext::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.getString( XML_rowSpan ).get().toInt32() );
40  if ( rAttribs.hasAttribute( XML_gridSpan ) )
41  mrTableCell.setGridSpan( rAttribs.getString( XML_gridSpan ).get().toInt32() );
42 
43  mrTableCell.sethMerge( rAttribs.getBool( XML_hMerge, false ) );
44  mrTableCell.setvMerge( rAttribs.getBool( XML_vMerge, false ) );
45 }
46 
48 {
49 }
50 
52 TableCellContext::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: */
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
void setHorzOverflowToken(sal_Int32 nToken)
Definition: tablecell.hxx:65
OptValue< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
OptValue< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
oox::drawingml::LineProperties maLinePropertiesTopLeftToBottomRight
Definition: tablecell.hxx:85
oox::drawingml::LineProperties maLinePropertiesTop
Definition: tablecell.hxx:83
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
const Type & get() const
Definition: helper.hxx:185
oox::drawingml::LineProperties maLinePropertiesBottomLeftToTopRight
Definition: tablecell.hxx:86
void setBottomMargin(sal_Int32 nMargin)
Definition: tablecell.hxx:59
void setTextBody(const oox::drawingml::TextBodyPtr &pTextBody)
Definition: tablecell.hxx:67
oox::drawingml::LineProperties maLinePropertiesRight
Definition: tablecell.hxx:82
void setRowSpan(sal_Int32 nRowSpan)
Definition: tablecell.hxx:45
oox::drawingml::LineProperties maLinePropertiesBottom
Definition: tablecell.hxx:84
void setRightMargin(sal_Int32 nMargin)
Definition: tablecell.hxx:55
void sethMerge(bool bhMerge)
Definition: tablecell.hxx:49
void setLeftMargin(sal_Int32 nMargin)
Definition: tablecell.hxx:53
std::shared_ptr< TextBody > TextBodyPtr
Provides access to attribute values of an element.
oox::drawingml::LineProperties maLinePropertiesLeft
Definition: tablecell.hxx:81
TableCellContext(::oox::core::ContextHandler2Helper const &rParent, const ::oox::AttributeList &rAttribs, TableCell &rTableCell)
void setVertToken(sal_Int32 nToken)
Definition: tablecell.hxx:61
void setAnchorCtr(bool bAnchorCtr)
Definition: tablecell.hxx:64
void setGridSpan(sal_Int32 nGridSpan)
Definition: tablecell.hxx:47
::oox::core::ContextHandlerRef createFillContext(::oox::core::ContextHandler2Helper const &rParent, sal_Int32 nElement, const ::oox::AttributeList &rAttribs, FillProperties &rFillProps)
oox::drawingml::FillProperties maFillProperties
Definition: tablecell.hxx:88
Helper class that provides a context stack.
void setvMerge(bool bvMerge)
Definition: tablecell.hxx:51
OptValue< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
void setTopMargin(sal_Int32 nMargin)
Definition: tablecell.hxx:57
void setAnchorToken(sal_Int32 nToken)
Definition: tablecell.hxx:63