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