Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / unodraw / tableshape.cxx
blobb9220516411af818b47170bc0597201dc2a51d22
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include "UnoGraphicExporter.hxx"
23 #include "shapeimpl.hxx"
24 #include <svx/unodraw/SvxTableShape.hxx>
25 #include <svx/unoshprp.hxx>
26 #include <svx/svdotable.hxx>
27 #include <svx/svdpool.hxx>
30 using namespace ::osl;
31 using namespace ::cppu;
32 using namespace sdr::table;
33 using namespace ::com::sun::star;
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::container;
37 using namespace ::com::sun::star::beans;
39 SvxTableShape::SvxTableShape(SdrObject* pObj)
40 : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_TABLE), getSvxMapProvider().GetPropertySet(SVXMAP_TABLE, SdrObject::GetGlobalDrawObjectItemPool()) )
42 SetShapeType( "com.sun.star.drawing.TableShape" );
45 SvxTableShape::~SvxTableShape() noexcept
49 bool SvxTableShape::setPropertyValueImpl(
50 const OUString& rName,
51 const SfxItemPropertyMapEntry* pProperty,
52 const css::uno::Any& rValue )
54 switch( pProperty->nWID )
56 case OWN_ATTR_TABLETEMPLATE:
58 Reference< XIndexAccess > xTemplate;
60 if( !(rValue >>= xTemplate) )
61 throw IllegalArgumentException();
63 if( HasSdrObject() )
64 static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->setTableStyle(xTemplate);
66 return true;
68 case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
69 case OWN_ATTR_TABLETEMPLATE_LASTROW:
70 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
71 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
72 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
73 case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS:
75 if( HasSdrObject() )
77 TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyleSettings() );
79 switch( pProperty->nWID )
81 case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue >>= aSettings.mbUseFirstRow; break;
82 case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue >>= aSettings.mbUseLastRow; break;
83 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue >>= aSettings.mbUseFirstColumn; break;
84 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue >>= aSettings.mbUseLastColumn; break;
85 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue >>= aSettings.mbUseRowBanding; break;
86 case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS: rValue >>= aSettings.mbUseColumnBanding; break;
89 static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->setTableStyleSettings(aSettings);
92 return true;
94 default:
96 return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
101 bool SvxTableShape::getPropertyValueImpl(
102 const OUString& rName,
103 const SfxItemPropertyMapEntry* pProperty,
104 css::uno::Any& rValue )
106 switch( pProperty->nWID )
108 case OWN_ATTR_OLEMODEL:
110 if( HasSdrObject() )
112 rValue <<= static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTable();
114 return true;
116 case OWN_ATTR_TABLETEMPLATE:
118 if( HasSdrObject() )
120 rValue <<= static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyle();
122 return true;
124 case OWN_ATTR_REPLACEMENT_GRAPHIC:
126 if( HasSdrObject() )
128 Graphic aGraphic( SvxGetGraphicForShape( *GetSdrObject() ) );
129 rValue <<= aGraphic.GetXGraphic();
131 return true;
133 case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
134 case OWN_ATTR_TABLETEMPLATE_LASTROW:
135 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
136 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
137 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
138 case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS:
140 if( HasSdrObject() )
142 TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyleSettings() );
144 switch( pProperty->nWID )
146 case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue <<= aSettings.mbUseFirstRow; break;
147 case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue <<= aSettings.mbUseLastRow; break;
148 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue <<= aSettings.mbUseFirstColumn; break;
149 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue <<= aSettings.mbUseLastColumn; break;
150 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue <<= aSettings.mbUseRowBanding; break;
151 case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS: rValue <<= aSettings.mbUseColumnBanding; break;
155 return true;
157 default:
159 return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
164 void SvxTableShape::lock()
166 SvxShape::lock();
167 if( HasSdrObject() )
168 static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->uno_lock();
171 void SvxTableShape::unlock()
173 if( HasSdrObject() )
174 static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->uno_unlock();
175 SvxShape::unlock();
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */