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