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 "oox/drawingml/table/tablecellcontext.hxx"
23 : #include "oox/drawingml/textbodycontext.hxx"
24 : #include "oox/drawingml/linepropertiescontext.hxx"
25 : #include "oox/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 0 : TableCellContext::TableCellContext( ContextHandler2Helper& rParent, const AttributeList& rAttribs, TableCell& rTableCell )
34 : : ContextHandler2( rParent )
35 0 : , mrTableCell( rTableCell )
36 : {
37 0 : if ( rAttribs.hasAttribute( XML_rowSpan ) )
38 0 : mrTableCell.setRowSpan( rAttribs.getString( XML_rowSpan ).get().toInt32() );
39 0 : if ( rAttribs.hasAttribute( XML_gridSpan ) )
40 0 : mrTableCell.setGridSpan( rAttribs.getString( XML_gridSpan ).get().toInt32() );
41 :
42 0 : mrTableCell.sethMerge( rAttribs.getBool( XML_hMerge, false ) );
43 0 : mrTableCell.setvMerge( rAttribs.getBool( XML_vMerge, false ) );
44 0 : }
45 :
46 0 : TableCellContext::~TableCellContext()
47 : {
48 0 : }
49 :
50 : ContextHandlerRef
51 0 : TableCellContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs )
52 : {
53 0 : switch( aElementToken )
54 : {
55 : case A_TOKEN( txBody ): // CT_TextBody
56 : {
57 0 : oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody );
58 0 : mrTableCell.setTextBody( xTextBody );
59 0 : return new oox::drawingml::TextBodyContext( *this, *xTextBody );
60 : }
61 :
62 : case A_TOKEN( tcPr ): // CT_TableCellProperties
63 : {
64 0 : mrTableCell.setLeftMargin( rAttribs.getInteger( XML_marL, 91440 ) );
65 0 : mrTableCell.setRightMargin( rAttribs.getInteger( XML_marR, 91440 ) );
66 0 : mrTableCell.setTopMargin( rAttribs.getInteger( XML_marT, 45720 ) );
67 0 : mrTableCell.setBottomMargin( rAttribs.getInteger( XML_marB, 45720 ) );
68 0 : mrTableCell.setVertToken( rAttribs.getToken( XML_vert, XML_horz ) ); // ST_TextVerticalType
69 0 : mrTableCell.setAnchorToken( rAttribs.getToken( XML_anchor, XML_t ) ); // ST_TextAnchoringType
70 0 : mrTableCell.setAnchorCtr( rAttribs.getBool( XML_anchorCtr, false ) );
71 0 : mrTableCell.setHorzOverflowToken( rAttribs.getToken( XML_horzOverflow, XML_clip ) ); // ST_TextHorzOverflowType
72 : }
73 0 : 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 0 : return this;
98 : }
99 :
100 0 : } } }
101 :
102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|