1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*f6e50924SAndrew Rist * distributed with this work for additional information
6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at
10*f6e50924SAndrew Rist *
11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist *
13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the
17*f6e50924SAndrew Rist * specific language governing permissions and limitations
18*f6e50924SAndrew Rist * under the License.
19*f6e50924SAndrew Rist *
20*f6e50924SAndrew Rist *************************************************************/
21*f6e50924SAndrew Rist
22*f6e50924SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "shapeimpl.hxx"
28cdf0e10cSrcweir #include "svx/unoshprp.hxx"
29cdf0e10cSrcweir #include "svx/svdotable.hxx"
30cdf0e10cSrcweir #include <svx/svdpool.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
33cdf0e10cSrcweir
34cdf0e10cSrcweir using ::rtl::OUString;
35cdf0e10cSrcweir
36cdf0e10cSrcweir using namespace ::osl;
37cdf0e10cSrcweir using namespace ::cppu;
38cdf0e10cSrcweir using namespace ::sdr::table;
39cdf0e10cSrcweir using namespace ::com::sun::star;
40cdf0e10cSrcweir using namespace ::com::sun::star::uno;
41cdf0e10cSrcweir using namespace ::com::sun::star::lang;
42cdf0e10cSrcweir using namespace ::com::sun::star::container;
43cdf0e10cSrcweir using namespace ::com::sun::star::beans;
44cdf0e10cSrcweir
SvxTableShape(SdrObject * pObj)45cdf0e10cSrcweir SvxTableShape::SvxTableShape( SdrObject* pObj ) throw()
46cdf0e10cSrcweir : SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_TABLE), aSvxMapProvider.GetPropertySet(SVXMAP_TABLE, SdrObject::GetGlobalDrawObjectItemPool()) )
47cdf0e10cSrcweir {
48cdf0e10cSrcweir SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TableShape" ) ) );
49cdf0e10cSrcweir }
50cdf0e10cSrcweir
51cdf0e10cSrcweir //----------------------------------------------------------------------
~SvxTableShape()52cdf0e10cSrcweir SvxTableShape::~SvxTableShape() throw()
53cdf0e10cSrcweir {
54cdf0e10cSrcweir }
55cdf0e10cSrcweir
56cdf0e10cSrcweir //----------------------------------------------------------------------
57cdf0e10cSrcweir
setPropertyValueImpl(const::rtl::OUString & rName,const SfxItemPropertySimpleEntry * pProperty,const::com::sun::star::uno::Any & rValue)58cdf0e10cSrcweir bool SvxTableShape::setPropertyValueImpl(
59cdf0e10cSrcweir const ::rtl::OUString& rName,
60cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pProperty,
61cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue )
62cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
63cdf0e10cSrcweir {
64cdf0e10cSrcweir switch( pProperty->nWID )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE:
67cdf0e10cSrcweir {
68cdf0e10cSrcweir Reference< XIndexAccess > xTemplate;
69cdf0e10cSrcweir
70cdf0e10cSrcweir if( !(rValue >>= xTemplate) )
71cdf0e10cSrcweir throw IllegalArgumentException();
72cdf0e10cSrcweir
73cdf0e10cSrcweir if( mpObj.is() )
74cdf0e10cSrcweir static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyle(xTemplate);
75cdf0e10cSrcweir
76cdf0e10cSrcweir return true;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
79cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_LASTROW:
80cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
81cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
82cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
83cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
84cdf0e10cSrcweir {
85cdf0e10cSrcweir if( mpObj.is() )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
88cdf0e10cSrcweir
89cdf0e10cSrcweir switch( pProperty->nWID )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue >>= aSettings.mbUseFirstRow; break;
92cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue >>= aSettings.mbUseLastRow; break;
93cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue >>= aSettings.mbUseFirstColumn; break;
94cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue >>= aSettings.mbUseLastColumn; break;
95cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue >>= aSettings.mbUseRowBanding; break;
96cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue >>= aSettings.mbUseColumnBanding; break;
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
99cdf0e10cSrcweir static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyleSettings(aSettings);
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir return true;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir default:
105cdf0e10cSrcweir {
106cdf0e10cSrcweir return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
107cdf0e10cSrcweir }
108cdf0e10cSrcweir }
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir extern Graphic SvxGetGraphicForShape( SdrObject& rShape, bool bVector );
112cdf0e10cSrcweir
getPropertyValueImpl(const::rtl::OUString & rName,const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::uno::Any & rValue)113cdf0e10cSrcweir bool SvxTableShape::getPropertyValueImpl(
114cdf0e10cSrcweir const ::rtl::OUString& rName,
115cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pProperty,
116cdf0e10cSrcweir ::com::sun::star::uno::Any& rValue )
117cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir switch( pProperty->nWID )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir case OWN_ATTR_OLEMODEL:
122cdf0e10cSrcweir {
123cdf0e10cSrcweir if( mpObj.is() )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTable();
126cdf0e10cSrcweir }
127cdf0e10cSrcweir return true;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE:
130cdf0e10cSrcweir {
131cdf0e10cSrcweir if( mpObj.is() )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyle();
134cdf0e10cSrcweir }
135cdf0e10cSrcweir return true;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir case OWN_ATTR_BITMAP:
138cdf0e10cSrcweir {
139cdf0e10cSrcweir if( mpObj.is() )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir Graphic aGraphic( SvxGetGraphicForShape( *mpObj.get(), true ) );
142cdf0e10cSrcweir rValue <<= aGraphic.GetXGraphic();
143cdf0e10cSrcweir }
144cdf0e10cSrcweir return true;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
147cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_LASTROW:
148cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
149cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
150cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
151cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
152cdf0e10cSrcweir {
153cdf0e10cSrcweir if( mpObj.is() )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
156cdf0e10cSrcweir
157cdf0e10cSrcweir switch( pProperty->nWID )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue <<= aSettings.mbUseFirstRow; break;
160cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue <<= aSettings.mbUseLastRow; break;
161cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue <<= aSettings.mbUseFirstColumn; break;
162cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue <<= aSettings.mbUseLastColumn; break;
163cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue <<= aSettings.mbUseRowBanding; break;
164cdf0e10cSrcweir case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue <<= aSettings.mbUseColumnBanding; break;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir }
167cdf0e10cSrcweir
168cdf0e10cSrcweir return true;
169cdf0e10cSrcweir }
170cdf0e10cSrcweir default:
171cdf0e10cSrcweir {
172cdf0e10cSrcweir return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
173cdf0e10cSrcweir }
174cdf0e10cSrcweir }
175cdf0e10cSrcweir }
176cdf0e10cSrcweir
lock()177cdf0e10cSrcweir void SvxTableShape::lock()
178cdf0e10cSrcweir {
179cdf0e10cSrcweir SvxShape::lock();
180cdf0e10cSrcweir if( mpObj.is() )
181cdf0e10cSrcweir static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_lock();
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
unlock()184cdf0e10cSrcweir void SvxTableShape::unlock()
185cdf0e10cSrcweir {
186cdf0e10cSrcweir if( mpObj.is() )
187cdf0e10cSrcweir static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_unlock();
188cdf0e10cSrcweir SvxShape::unlock();
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
191