merge the formfield patch from ooo-build
[ooovba.git] / svx / source / unodraw / tableshape.cxx
blobf8b5bceec9263b362c1ca0280a26f9cb15e3448d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tableshape.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include "shapeimpl.hxx"
35 #include "svx/unoshprp.hxx"
36 #include "svx/svdotable.hxx"
38 ///////////////////////////////////////////////////////////////////////
40 using ::rtl::OUString;
42 using namespace ::osl;
43 using namespace ::vos;
44 using namespace ::cppu;
45 using namespace ::sdr::table;
46 using namespace ::com::sun::star;
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::lang;
49 using namespace ::com::sun::star::container;
50 using namespace ::com::sun::star::beans;
52 SvxTableShape::SvxTableShape( SdrObject* pObj ) throw()
53 : SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_TABLE), aSvxMapProvider.GetPropertySet(SVXMAP_TABLE) )
55 SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TableShape" ) ) );
58 //----------------------------------------------------------------------
59 SvxTableShape::~SvxTableShape() throw()
63 //----------------------------------------------------------------------
65 bool SvxTableShape::setPropertyValueImpl(
66 const ::rtl::OUString& rName,
67 const SfxItemPropertySimpleEntry* pProperty,
68 const ::com::sun::star::uno::Any& rValue )
69 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)
71 switch( pProperty->nWID )
73 case OWN_ATTR_TABLETEMPLATE:
75 Reference< XIndexAccess > xTemplate;
77 if( !(rValue >>= xTemplate) )
78 throw IllegalArgumentException();
80 if( mpObj.is() )
81 static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyle(xTemplate);
83 return true;
85 case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
86 case OWN_ATTR_TABLETEMPLATE_LASTROW:
87 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
88 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
89 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
90 case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
92 if( mpObj.is() )
94 TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
96 switch( pProperty->nWID )
98 case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue >>= aSettings.mbUseFirstRow; break;
99 case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue >>= aSettings.mbUseLastRow; break;
100 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue >>= aSettings.mbUseFirstColumn; break;
101 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue >>= aSettings.mbUseLastColumn; break;
102 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue >>= aSettings.mbUseRowBanding; break;
103 case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue >>= aSettings.mbUseColumnBanding; break;
106 static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyleSettings(aSettings);
109 return true;
111 default:
113 return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
118 extern Graphic SvxGetGraphicForShape( SdrObject& rShape, bool bVector );
120 bool SvxTableShape::getPropertyValueImpl(
121 const ::rtl::OUString& rName,
122 const SfxItemPropertySimpleEntry* pProperty,
123 ::com::sun::star::uno::Any& rValue )
124 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
126 switch( pProperty->nWID )
128 case OWN_ATTR_OLEMODEL:
130 if( mpObj.is() )
132 rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTable();
134 return true;
136 case OWN_ATTR_TABLETEMPLATE:
138 if( mpObj.is() )
140 rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyle();
142 return true;
144 case OWN_ATTR_BITMAP:
146 if( mpObj.is() )
148 Graphic aGraphic( SvxGetGraphicForShape( *mpObj.get(), true ) );
149 rValue <<= aGraphic.GetXGraphic();
151 return true;
153 case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
154 case OWN_ATTR_TABLETEMPLATE_LASTROW:
155 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
156 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
157 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
158 case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
160 if( mpObj.is() )
162 TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
164 switch( pProperty->nWID )
166 case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue <<= aSettings.mbUseFirstRow; break;
167 case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue <<= aSettings.mbUseLastRow; break;
168 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue <<= aSettings.mbUseFirstColumn; break;
169 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue <<= aSettings.mbUseLastColumn; break;
170 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue <<= aSettings.mbUseRowBanding; break;
171 case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue <<= aSettings.mbUseColumnBanding; break;
175 return true;
177 default:
179 return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
184 void SvxTableShape::lock()
186 SvxShape::lock();
187 if( mpObj.is() )
188 static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_lock();
191 void SvxTableShape::unlock()
193 if( mpObj.is() )
194 static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_unlock();
195 SvxShape::unlock();