bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / unodraw / tableshape.cxx
blobfaa6d402144c9cf41cfd891448644990a7f2071a
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/unoshprp.hxx"
25 #include "svx/svdotable.hxx"
26 #include <svx/svdpool.hxx>
31 using namespace ::osl;
32 using namespace ::cppu;
33 using namespace sdr::table;
34 using namespace ::com::sun::star;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::lang;
37 using namespace ::com::sun::star::container;
38 using namespace ::com::sun::star::beans;
40 SvxTableShape::SvxTableShape( SdrObject* pObj ) throw()
41 : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_TABLE), getSvxMapProvider().GetPropertySet(SVXMAP_TABLE, SdrObject::GetGlobalDrawObjectItemPool()) )
43 SetShapeType( OUString( "com.sun.star.drawing.TableShape" ) );
47 SvxTableShape::~SvxTableShape() throw()
53 bool SvxTableShape::setPropertyValueImpl(
54 const OUString& rName,
55 const SfxItemPropertySimpleEntry* pProperty,
56 const ::com::sun::star::uno::Any& rValue )
57 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)
59 switch( pProperty->nWID )
61 case OWN_ATTR_TABLETEMPLATE:
63 Reference< XIndexAccess > xTemplate;
65 if( !(rValue >>= xTemplate) )
66 throw IllegalArgumentException();
68 if( mpObj.is() )
69 static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyle(xTemplate);
71 return true;
73 case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
74 case OWN_ATTR_TABLETEMPLATE_LASTROW:
75 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
76 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
77 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
78 case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
80 if( mpObj.is() )
82 TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
84 switch( pProperty->nWID )
86 case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue >>= aSettings.mbUseFirstRow; break;
87 case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue >>= aSettings.mbUseLastRow; break;
88 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue >>= aSettings.mbUseFirstColumn; break;
89 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue >>= aSettings.mbUseLastColumn; break;
90 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue >>= aSettings.mbUseRowBanding; break;
91 case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue >>= aSettings.mbUseColumnBanding; break;
94 static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyleSettings(aSettings);
97 return true;
99 default:
101 return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
106 bool SvxTableShape::getPropertyValueImpl(
107 const OUString& rName,
108 const SfxItemPropertySimpleEntry* pProperty,
109 ::com::sun::star::uno::Any& rValue )
110 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception)
112 switch( pProperty->nWID )
114 case OWN_ATTR_OLEMODEL:
116 if( mpObj.is() )
118 rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTable();
120 return true;
122 case OWN_ATTR_TABLETEMPLATE:
124 if( mpObj.is() )
126 rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyle();
128 return true;
130 case OWN_ATTR_BITMAP:
132 if( mpObj.is() )
134 Graphic aGraphic( SvxGetGraphicForShape( *mpObj.get(), true ) );
135 rValue <<= aGraphic.GetXGraphic();
137 return true;
139 case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
140 case OWN_ATTR_TABLETEMPLATE_LASTROW:
141 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
142 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
143 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
144 case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
146 if( mpObj.is() )
148 TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
150 switch( pProperty->nWID )
152 case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue <<= aSettings.mbUseFirstRow; break;
153 case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue <<= aSettings.mbUseLastRow; break;
154 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue <<= aSettings.mbUseFirstColumn; break;
155 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue <<= aSettings.mbUseLastColumn; break;
156 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue <<= aSettings.mbUseRowBanding; break;
157 case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue <<= aSettings.mbUseColumnBanding; break;
161 return true;
163 default:
165 return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
170 void SvxTableShape::lock()
172 SvxShape::lock();
173 if( mpObj.is() )
174 static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_lock();
177 void SvxTableShape::unlock()
179 if( mpObj.is() )
180 static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_unlock();
181 SvxShape::unlock();
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */