Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <sal/config.h>
21 :
22 : #include "UnoGraphicExporter.hxx"
23 : #include "shapeimpl.hxx"
24 : #include "svx/unoshprp.hxx"
25 : #include "svx/svdotable.hxx"
26 : #include <svx/svdpool.hxx>
27 :
28 :
29 :
30 :
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;
39 :
40 38 : SvxTableShape::SvxTableShape( SdrObject* pObj ) throw()
41 38 : : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_TABLE), getSvxMapProvider().GetPropertySet(SVXMAP_TABLE, SdrObject::GetGlobalDrawObjectItemPool()) )
42 : {
43 38 : SetShapeType( OUString( "com.sun.star.drawing.TableShape" ) );
44 38 : }
45 :
46 :
47 76 : SvxTableShape::~SvxTableShape() throw()
48 : {
49 76 : }
50 :
51 :
52 :
53 88 : 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)
58 : {
59 88 : switch( pProperty->nWID )
60 : {
61 : case OWN_ATTR_TABLETEMPLATE:
62 : {
63 4 : Reference< XIndexAccess > xTemplate;
64 :
65 4 : if( !(rValue >>= xTemplate) )
66 0 : throw IllegalArgumentException();
67 :
68 4 : if( mpObj.is() )
69 4 : static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyle(xTemplate);
70 :
71 4 : return true;
72 : }
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:
79 : {
80 54 : if( mpObj.is() )
81 : {
82 54 : TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
83 :
84 54 : switch( pProperty->nWID )
85 : {
86 9 : case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue >>= aSettings.mbUseFirstRow; break;
87 9 : case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue >>= aSettings.mbUseLastRow; break;
88 9 : case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue >>= aSettings.mbUseFirstColumn; break;
89 9 : case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue >>= aSettings.mbUseLastColumn; break;
90 9 : case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue >>= aSettings.mbUseRowBanding; break;
91 9 : case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue >>= aSettings.mbUseColumnBanding; break;
92 : }
93 :
94 54 : static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyleSettings(aSettings);
95 : }
96 :
97 54 : return true;
98 : }
99 : default:
100 : {
101 30 : return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
102 : }
103 : }
104 : }
105 :
106 28 : 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)
111 : {
112 28 : switch( pProperty->nWID )
113 : {
114 : case OWN_ATTR_OLEMODEL:
115 : {
116 25 : if( mpObj.is() )
117 : {
118 25 : rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTable();
119 : }
120 25 : return true;
121 : }
122 : case OWN_ATTR_TABLETEMPLATE:
123 : {
124 0 : if( mpObj.is() )
125 : {
126 0 : rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyle();
127 : }
128 0 : return true;
129 : }
130 : case OWN_ATTR_BITMAP:
131 : {
132 0 : if( mpObj.is() )
133 : {
134 0 : Graphic aGraphic( SvxGetGraphicForShape( *mpObj.get(), true ) );
135 0 : rValue <<= aGraphic.GetXGraphic();
136 : }
137 0 : return true;
138 : }
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:
145 : {
146 0 : if( mpObj.is() )
147 : {
148 0 : TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
149 :
150 0 : switch( pProperty->nWID )
151 : {
152 0 : case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue <<= aSettings.mbUseFirstRow; break;
153 0 : case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue <<= aSettings.mbUseLastRow; break;
154 0 : case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue <<= aSettings.mbUseFirstColumn; break;
155 0 : case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue <<= aSettings.mbUseLastColumn; break;
156 0 : case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue <<= aSettings.mbUseRowBanding; break;
157 0 : case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue <<= aSettings.mbUseColumnBanding; break;
158 : }
159 : }
160 :
161 0 : return true;
162 : }
163 : default:
164 : {
165 3 : return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
166 : }
167 : }
168 : }
169 :
170 21 : void SvxTableShape::lock()
171 : {
172 21 : SvxShape::lock();
173 21 : if( mpObj.is() )
174 21 : static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_lock();
175 21 : }
176 :
177 21 : void SvxTableShape::unlock()
178 : {
179 21 : if( mpObj.is() )
180 21 : static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_unlock();
181 21 : SvxShape::unlock();
182 456 : }
183 :
184 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|