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