1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
;
38 SvxTableShape::SvxTableShape(SdrObject
* pObj
)
39 : SvxShape( pObj
, getSvxMapProvider().GetMap(SVXMAP_TABLE
), getSvxMapProvider().GetPropertySet(SVXMAP_TABLE
, SdrObject::GetGlobalDrawObjectItemPool()) )
41 SetShapeType( "com.sun.star.drawing.TableShape" );
44 SvxTableShape::~SvxTableShape() noexcept
48 bool SvxTableShape::setPropertyValueImpl(
49 const OUString
& rName
,
50 const SfxItemPropertyMapEntry
* pProperty
,
51 const css::uno::Any
& rValue
)
53 switch( pProperty
->nWID
)
55 case OWN_ATTR_TABLETEMPLATE
:
57 Reference
< XIndexAccess
> xTemplate
;
59 if( !(rValue
>>= xTemplate
) )
60 throw IllegalArgumentException();
63 static_cast< sdr::table::SdrTableObj
* >( GetSdrObject() )->setTableStyle(xTemplate
);
67 case OWN_ATTR_TABLETEMPLATE_FIRSTROW
:
68 case OWN_ATTR_TABLETEMPLATE_LASTROW
:
69 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN
:
70 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN
:
71 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS
:
72 case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS
:
76 TableStyleSettings
aSettings( static_cast< sdr::table::SdrTableObj
* >( GetSdrObject() )->getTableStyleSettings() );
78 switch( pProperty
->nWID
)
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_BANDINGCOLUMNS
: rValue
>>= aSettings
.mbUseColumnBanding
; break;
88 static_cast< sdr::table::SdrTableObj
* >( GetSdrObject() )->setTableStyleSettings(aSettings
);
95 return SvxShape::setPropertyValueImpl( rName
, pProperty
, rValue
);
100 bool SvxTableShape::getPropertyValueImpl(
101 const OUString
& rName
,
102 const SfxItemPropertyMapEntry
* pProperty
,
103 css::uno::Any
& rValue
)
105 switch( pProperty
->nWID
)
107 case OWN_ATTR_OLEMODEL
:
111 rValue
<<= static_cast< sdr::table::SdrTableObj
* >( GetSdrObject() )->getTable();
115 case OWN_ATTR_TABLETEMPLATE
:
119 rValue
<<= static_cast< sdr::table::SdrTableObj
* >( GetSdrObject() )->getTableStyle();
123 case OWN_ATTR_REPLACEMENT_GRAPHIC
:
127 Graphic
aGraphic( SvxGetGraphicForShape( *GetSdrObject() ) );
128 rValue
<<= aGraphic
.GetXGraphic();
132 case OWN_ATTR_TABLETEMPLATE_FIRSTROW
:
133 case OWN_ATTR_TABLETEMPLATE_LASTROW
:
134 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN
:
135 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN
:
136 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS
:
137 case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS
:
141 TableStyleSettings
aSettings( static_cast< sdr::table::SdrTableObj
* >( GetSdrObject() )->getTableStyleSettings() );
143 switch( pProperty
->nWID
)
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_BANDINGCOLUMNS
: rValue
<<= aSettings
.mbUseColumnBanding
; break;
158 return SvxShape::getPropertyValueImpl( rName
, pProperty
, rValue
);
163 void SvxTableShape::lock()
167 static_cast< sdr::table::SdrTableObj
* >( GetSdrObject() )->uno_lock();
170 void SvxTableShape::unlock()
173 static_cast< sdr::table::SdrTableObj
* >( GetSdrObject() )->uno_unlock();
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */