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( ContextHandler& rParent, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs, TableCell& rTableCell )
34 : : ContextHandler( rParent )
35 0 : , mrTableCell( rTableCell )
36 : {
37 0 : if ( xAttribs->hasAttribute( XML_rowSpan ) )
38 0 : mrTableCell.setRowSpan( xAttribs->getOptionalValue( XML_rowSpan ).toInt32() );
39 0 : if ( xAttribs->hasAttribute( XML_gridSpan ) )
40 0 : mrTableCell.setGridSpan( xAttribs->getOptionalValue( XML_gridSpan ).toInt32() );
41 :
42 0 : AttributeList aAttribs( xAttribs );
43 0 : mrTableCell.sethMerge( aAttribs.getBool( XML_hMerge, sal_False ) );
44 0 : mrTableCell.setvMerge( aAttribs.getBool( XML_vMerge, sal_False ) );
45 0 : }
46 :
47 0 : TableCellContext::~TableCellContext()
48 : {
49 0 : }
50 :
51 : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
52 0 : TableCellContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
53 : throw ( xml::sax::SAXException, uno::RuntimeException)
54 : {
55 0 : uno::Reference< xml::sax::XFastContextHandler > xRet;
56 :
57 0 : switch( aElementToken )
58 : {
59 : case A_TOKEN( txBody ): // CT_TextBody
60 : {
61 0 : oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody );
62 0 : mrTableCell.setTextBody( xTextBody );
63 0 : xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody );
64 : }
65 0 : break;
66 :
67 : case A_TOKEN( tcPr ): // CT_TableCellProperties
68 : {
69 0 : AttributeList aAttribs( xAttribs );
70 0 : mrTableCell.setLeftMargin( aAttribs.getInteger( XML_marL, 91440 ) );
71 0 : mrTableCell.setRightMargin( aAttribs.getInteger( XML_marR, 91440 ) );
72 0 : mrTableCell.setTopMargin( aAttribs.getInteger( XML_marT, 45720 ) );
73 0 : mrTableCell.setBottomMargin( aAttribs.getInteger( XML_marB, 45720 ) );
74 0 : mrTableCell.setVertToken( xAttribs->getOptionalValueToken( XML_vert, XML_horz ) ); // ST_TextVerticalType
75 0 : mrTableCell.setAnchorToken( xAttribs->getOptionalValueToken( XML_anchor, XML_t ) ); // ST_TextAnchoringType
76 0 : mrTableCell.setAnchorCtr( aAttribs.getBool( XML_anchorCtr, sal_False ) );
77 0 : mrTableCell.setHorzOverflowToken( xAttribs->getOptionalValueToken( XML_horzOverflow, XML_clip ) ); // ST_TextHorzOverflowType
78 : }
79 0 : break;
80 : case A_TOKEN( lnL ):
81 0 : xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesLeft ) );
82 0 : break;
83 : case A_TOKEN( lnR ):
84 0 : xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesRight ) );
85 0 : break;
86 : case A_TOKEN( lnT ):
87 0 : xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesTop ) );
88 0 : break;
89 : case A_TOKEN( lnB ):
90 0 : xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesBottom ) );
91 0 : break;
92 : case A_TOKEN( lnTlToBr ):
93 0 : xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesTopLeftToBottomRight ) );
94 0 : break;
95 : case A_TOKEN( lnBlToTr ):
96 0 : xRet.set( new oox::drawingml::LinePropertiesContext( *this, xAttribs, mrTableCell.maLinePropertiesBottomLeftToTopRight ) );
97 0 : break;
98 : case A_TOKEN( cell3D ): // CT_Cell3D
99 0 : break;
100 :
101 : case A_TOKEN( extLst ): // CT_OfficeArtExtensionList
102 0 : break;
103 :
104 : default:
105 0 : xRet.set( FillPropertiesContext::createFillContext( *this, aElementToken, xAttribs, mrTableCell.maFillProperties ) );
106 0 : break;
107 :
108 : }
109 0 : if ( !xRet.is() )
110 : {
111 0 : uno::Reference< XFastContextHandler > xTmp( this );
112 0 : xRet.set( xTmp );
113 : }
114 0 : return xRet;
115 : }
116 :
117 51 : } } }
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|