/src/libreoffice/oox/source/drawingml/table/tablecellcontext.cxx
Line | Count | Source |
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 | | |
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/properties.hxx> |
28 | | #include <oox/token/tokens.hxx> |
29 | | |
30 | | using namespace ::oox::core; |
31 | | using namespace ::com::sun::star; |
32 | | |
33 | | namespace oox::drawingml::table { |
34 | | |
35 | | TableCellContext::TableCellContext( ContextHandler2Helper const & rParent, const AttributeList& rAttribs, TableCell& rTableCell ) |
36 | 2.61k | : ContextHandler2( rParent ) |
37 | 2.61k | , mrTableCell( rTableCell ) |
38 | 2.61k | { |
39 | 2.61k | if ( rAttribs.hasAttribute( XML_rowSpan ) ) |
40 | 0 | mrTableCell.setRowSpan( rAttribs.getInteger( XML_rowSpan, 0 ) ); |
41 | 2.61k | if ( rAttribs.hasAttribute( XML_gridSpan ) ) |
42 | 0 | mrTableCell.setGridSpan( rAttribs.getInteger( XML_gridSpan, 0 ) ); |
43 | | |
44 | 2.61k | mrTableCell.sethMerge( rAttribs.getBool( XML_hMerge, false ) ); |
45 | 2.61k | mrTableCell.setvMerge( rAttribs.getBool( XML_vMerge, false ) ); |
46 | 2.61k | } |
47 | | |
48 | | TableCellContext::~TableCellContext() |
49 | 2.61k | { |
50 | 2.61k | } |
51 | | |
52 | | ContextHandlerRef |
53 | | TableCellContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs ) |
54 | 8.09k | { |
55 | 8.09k | switch( aElementToken ) |
56 | 8.09k | { |
57 | 1.46k | case A_TOKEN( txBody ): // CT_TextBody |
58 | 1.46k | { |
59 | 1.46k | oox::drawingml::TextBodyPtr xTextBody = std::make_shared<oox::drawingml::TextBody>(); |
60 | 1.46k | xTextBody->getTextProperties().maPropertyMap.setProperty( |
61 | 1.46k | PROP_FontIndependentLineSpacing, true); |
62 | 1.46k | mrTableCell.setTextBody( xTextBody ); |
63 | 1.46k | return new oox::drawingml::TextBodyContext( *this, *xTextBody ); |
64 | 0 | } |
65 | | |
66 | 2.61k | case A_TOKEN( tcPr ): // CT_TableCellProperties |
67 | 2.61k | { |
68 | 2.61k | mrTableCell.setLeftMargin( rAttribs.getInteger( XML_marL, 91440 ) ); |
69 | 2.61k | mrTableCell.setRightMargin( rAttribs.getInteger( XML_marR, 91440 ) ); |
70 | 2.61k | mrTableCell.setTopMargin( rAttribs.getInteger( XML_marT, 45720 ) ); |
71 | 2.61k | mrTableCell.setBottomMargin( rAttribs.getInteger( XML_marB, 45720 ) ); |
72 | 2.61k | mrTableCell.setVertToken( rAttribs.getToken( XML_vert, XML_horz ) ); // ST_TextVerticalType |
73 | 2.61k | mrTableCell.setAnchorToken( rAttribs.getToken( XML_anchor, XML_t ) ); // ST_TextAnchoringType |
74 | 2.61k | mrTableCell.setAnchorCtr( rAttribs.getBool( XML_anchorCtr, false ) ); |
75 | 2.61k | mrTableCell.setHorzOverflowToken( rAttribs.getToken( XML_horzOverflow, XML_clip ) ); // ST_TextHorzOverflowType |
76 | 2.61k | } |
77 | 2.61k | break; |
78 | 672 | case A_TOKEN( lnL ): |
79 | 672 | return new oox::drawingml::LinePropertiesContext( *this, rAttribs, mrTableCell.maLinePropertiesLeft ); |
80 | 672 | case A_TOKEN( lnR ): |
81 | 672 | return new oox::drawingml::LinePropertiesContext( *this, rAttribs, mrTableCell.maLinePropertiesRight ); |
82 | 672 | case A_TOKEN( lnT ): |
83 | 672 | return new oox::drawingml::LinePropertiesContext( *this, rAttribs, mrTableCell.maLinePropertiesTop ); |
84 | 672 | case A_TOKEN( lnB ): |
85 | 672 | return new oox::drawingml::LinePropertiesContext( *this, rAttribs, mrTableCell.maLinePropertiesBottom ); |
86 | 666 | case A_TOKEN( lnTlToBr ): |
87 | 666 | return new oox::drawingml::LinePropertiesContext( *this, rAttribs, mrTableCell.maLinePropertiesTopLeftToBottomRight ); |
88 | 666 | case A_TOKEN( lnBlToTr ): |
89 | 666 | return new oox::drawingml::LinePropertiesContext( *this, rAttribs, mrTableCell.maLinePropertiesBottomLeftToTopRight ); |
90 | 0 | case A_TOKEN( cell3D ): // CT_Cell3D |
91 | 0 | break; |
92 | | |
93 | 0 | case A_TOKEN( extLst ): // CT_OfficeArtExtensionList |
94 | 0 | break; |
95 | | |
96 | 0 | default: |
97 | 0 | return FillPropertiesContext::createFillContext(*this, aElementToken, rAttribs, mrTableCell.maFillProperties, nullptr); |
98 | 8.09k | } |
99 | | |
100 | 2.61k | return this; |
101 | 8.09k | } |
102 | | |
103 | | } |
104 | | |
105 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |