1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #include "shapeimpl.hxx" 32 #include "svx/unoshprp.hxx" 33 #include "svx/svdotable.hxx" 34 #include <svx/svdpool.hxx> 35 36 /////////////////////////////////////////////////////////////////////// 37 38 using ::rtl::OUString; 39 40 using namespace ::osl; 41 using namespace ::cppu; 42 using namespace ::sdr::table; 43 using namespace ::com::sun::star; 44 using namespace ::com::sun::star::uno; 45 using namespace ::com::sun::star::lang; 46 using namespace ::com::sun::star::container; 47 using namespace ::com::sun::star::beans; 48 49 SvxTableShape::SvxTableShape( SdrObject* pObj ) throw() 50 : SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_TABLE), aSvxMapProvider.GetPropertySet(SVXMAP_TABLE, SdrObject::GetGlobalDrawObjectItemPool()) ) 51 { 52 SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TableShape" ) ) ); 53 } 54 55 //---------------------------------------------------------------------- 56 SvxTableShape::~SvxTableShape() throw() 57 { 58 } 59 60 //---------------------------------------------------------------------- 61 62 bool SvxTableShape::setPropertyValueImpl( 63 const ::rtl::OUString& rName, 64 const SfxItemPropertySimpleEntry* pProperty, 65 const ::com::sun::star::uno::Any& rValue ) 66 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) 67 { 68 switch( pProperty->nWID ) 69 { 70 case OWN_ATTR_TABLETEMPLATE: 71 { 72 Reference< XIndexAccess > xTemplate; 73 74 if( !(rValue >>= xTemplate) ) 75 throw IllegalArgumentException(); 76 77 if( mpObj.is() ) 78 static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyle(xTemplate); 79 80 return true; 81 } 82 case OWN_ATTR_TABLETEMPLATE_FIRSTROW: 83 case OWN_ATTR_TABLETEMPLATE_LASTROW: 84 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: 85 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: 86 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: 87 case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: 88 { 89 if( mpObj.is() ) 90 { 91 TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() ); 92 93 switch( pProperty->nWID ) 94 { 95 case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue >>= aSettings.mbUseFirstRow; break; 96 case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue >>= aSettings.mbUseLastRow; break; 97 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue >>= aSettings.mbUseFirstColumn; break; 98 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue >>= aSettings.mbUseLastColumn; break; 99 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue >>= aSettings.mbUseRowBanding; break; 100 case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue >>= aSettings.mbUseColumnBanding; break; 101 } 102 103 static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyleSettings(aSettings); 104 } 105 106 return true; 107 } 108 default: 109 { 110 return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); 111 } 112 } 113 } 114 115 extern Graphic SvxGetGraphicForShape( SdrObject& rShape, bool bVector ); 116 117 bool SvxTableShape::getPropertyValueImpl( 118 const ::rtl::OUString& rName, 119 const SfxItemPropertySimpleEntry* pProperty, 120 ::com::sun::star::uno::Any& rValue ) 121 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) 122 { 123 switch( pProperty->nWID ) 124 { 125 case OWN_ATTR_OLEMODEL: 126 { 127 if( mpObj.is() ) 128 { 129 rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTable(); 130 } 131 return true; 132 } 133 case OWN_ATTR_TABLETEMPLATE: 134 { 135 if( mpObj.is() ) 136 { 137 rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyle(); 138 } 139 return true; 140 } 141 case OWN_ATTR_BITMAP: 142 { 143 if( mpObj.is() ) 144 { 145 Graphic aGraphic( SvxGetGraphicForShape( *mpObj.get(), true ) ); 146 rValue <<= aGraphic.GetXGraphic(); 147 } 148 return true; 149 } 150 case OWN_ATTR_TABLETEMPLATE_FIRSTROW: 151 case OWN_ATTR_TABLETEMPLATE_LASTROW: 152 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: 153 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: 154 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: 155 case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: 156 { 157 if( mpObj.is() ) 158 { 159 TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() ); 160 161 switch( pProperty->nWID ) 162 { 163 case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue <<= aSettings.mbUseFirstRow; break; 164 case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue <<= aSettings.mbUseLastRow; break; 165 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue <<= aSettings.mbUseFirstColumn; break; 166 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue <<= aSettings.mbUseLastColumn; break; 167 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue <<= aSettings.mbUseRowBanding; break; 168 case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue <<= aSettings.mbUseColumnBanding; break; 169 } 170 } 171 172 return true; 173 } 174 default: 175 { 176 return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); 177 } 178 } 179 } 180 181 void SvxTableShape::lock() 182 { 183 SvxShape::lock(); 184 if( mpObj.is() ) 185 static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_lock(); 186 } 187 188 void SvxTableShape::unlock() 189 { 190 if( mpObj.is() ) 191 static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_unlock(); 192 SvxShape::unlock(); 193 } 194 195