LibreOffice Module svx (master)  1
tableshape.cxx
Go to the documentation of this file.
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 using namespace ::osl;
30 using namespace ::cppu;
31 using namespace sdr::table;
32 using namespace ::com::sun::star;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::lang;
35 using namespace ::com::sun::star::container;
36 using namespace ::com::sun::star::beans;
37 
39 : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_TABLE), getSvxMapProvider().GetPropertySet(SVXMAP_TABLE, SdrObject::GetGlobalDrawObjectItemPool()) )
40 {
41  SetShapeType( "com.sun.star.drawing.TableShape" );
42 }
43 
45 {
46 }
47 
49  const OUString& rName,
50  const SfxItemPropertySimpleEntry* pProperty,
51  const css::uno::Any& rValue )
52 {
53  switch( pProperty->nWID )
54  {
56  {
57  Reference< XIndexAccess > xTemplate;
58 
59  if( !(rValue >>= xTemplate) )
60  throw IllegalArgumentException();
61 
62  if( HasSdrObject() )
63  static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->setTableStyle(xTemplate);
64 
65  return true;
66  }
73  {
74  if( HasSdrObject() )
75  {
76  TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyleSettings() );
77 
78  switch( pProperty->nWID )
79  {
80  case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue >>= aSettings.mbUseFirstRow; break;
81  case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue >>= aSettings.mbUseLastRow; break;
82  case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue >>= aSettings.mbUseFirstColumn; break;
83  case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue >>= aSettings.mbUseLastColumn; break;
84  case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue >>= aSettings.mbUseRowBanding; break;
85  case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue >>= aSettings.mbUseColumnBanding; break;
86  }
87 
88  static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->setTableStyleSettings(aSettings);
89  }
90 
91  return true;
92  }
93  default:
94  {
95  return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
96  }
97  }
98 }
99 
101  const OUString& rName,
102  const SfxItemPropertySimpleEntry* pProperty,
103  css::uno::Any& rValue )
104 {
105  switch( pProperty->nWID )
106  {
107  case OWN_ATTR_OLEMODEL:
108  {
109  if( HasSdrObject() )
110  {
111  rValue <<= static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTable();
112  }
113  return true;
114  }
116  {
117  if( HasSdrObject() )
118  {
119  rValue <<= static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyle();
120  }
121  return true;
122  }
124  {
125  if( HasSdrObject() )
126  {
127  Graphic aGraphic( SvxGetGraphicForShape( *GetSdrObject() ) );
128  rValue <<= aGraphic.GetXGraphic();
129  }
130  return true;
131  }
138  {
139  if( HasSdrObject() )
140  {
141  TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyleSettings() );
142 
143  switch( pProperty->nWID )
144  {
145  case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue <<= aSettings.mbUseFirstRow; break;
146  case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue <<= aSettings.mbUseLastRow; break;
147  case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue <<= aSettings.mbUseFirstColumn; break;
148  case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue <<= aSettings.mbUseLastColumn; break;
149  case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue <<= aSettings.mbUseRowBanding; break;
150  case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue <<= aSettings.mbUseColumnBanding; break;
151  }
152  }
153 
154  return true;
155  }
156  default:
157  {
158  return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
159  }
160  }
161 }
162 
164 {
165  SvxShape::lock();
166  if( HasSdrObject() )
167  static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->uno_lock();
168 }
169 
171 {
172  if( HasSdrObject() )
173  static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->uno_unlock();
175 }
176 
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void unlock()
called from the XActionLockable interface methods on final unlock
Definition: unoshape.cxx:3607
virtual bool setPropertyValueImpl(const OUString &rName, const SfxItemPropertySimpleEntry *pProperty, const css::uno::Any &rValue) override
Definition: tableshape.cxx:48
#define OWN_ATTR_TABLETEMPLATE_LASTCOLUMN
Definition: unoshprp.hxx:141
#define OWN_ATTR_REPLACEMENT_GRAPHIC
reuse attr slots for GraphicObject which will never be used together with graphic object ...
Definition: unoshprp.hxx:118
virtual void lock()
called from the XActionLockable interface methods on initial locking
Definition: unoshape.cxx:3601
Graphic SvxGetGraphicForShape(SdrObject &rShape)
#define OWN_ATTR_TABLETEMPLATE
Definition: unoshprp.hxx:137
virtual void unlock() override
called from the XActionLockable interface methods on final unlock
Definition: tableshape.cxx:170
virtual bool getPropertyValueImpl(const OUString &rName, const SfxItemPropertySimpleEntry *pProperty, css::uno::Any &rValue)
Definition: unoshape.cxx:2500
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
#define OWN_ATTR_TABLETEMPLATE_LASTROW
Definition: unoshprp.hxx:139
#define OWN_ATTR_TABLETEMPLATE_FIRSTROW
Definition: unoshprp.hxx:138
virtual bool getPropertyValueImpl(const OUString &rName, const SfxItemPropertySimpleEntry *pProperty, css::uno::Any &rValue) override
Definition: tableshape.cxx:100
bool HasSdrObject() const
Definition: unoshape.hxx:211
void SetShapeType(const OUString &ShapeType)
Definition: unoshape.hxx:213
#define OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS
Definition: unoshprp.hxx:143
virtual void lock() override
called from the XActionLockable interface methods on initial locking
Definition: tableshape.cxx:163
#define SVXMAP_TABLE
Definition: unoprov.hxx:76
Abstract DrawObject.
Definition: svdobj.hxx:312
SvxTableShape(SdrObject *pObj)
Definition: tableshape.cxx:38
virtual ~SvxTableShape() override
Definition: tableshape.cxx:44
SdrObject * GetSdrObject() const
Definition: unoshape.hxx:210
#define OWN_ATTR_TABLETEMPLATE_BANDINGROWS
Definition: unoshprp.hxx:142
#define OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN
Definition: unoshprp.hxx:140
TableStyleSettings.
Definition: svdotable.hxx:75
virtual bool setPropertyValueImpl(const OUString &rName, const SfxItemPropertySimpleEntry *pProperty, const css::uno::Any &rValue)
Definition: unoshape.cxx:2049
SvxUnoPropertyMapProvider & getSvxMapProvider()
Definition: unoprov.cxx:877
#define OWN_ATTR_OLEMODEL
Definition: unoshprp.hxx:102