tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / svx / source / unodraw / tableshape.cxx
blobebefa12fec3f39bedad44dfdbefc5f586ee33da2
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/unodraw/SvxTableShape.hxx>
25 #include <svx/unoshprp.hxx>
26 #include <svx/svdotable.hxx>
27 #include <svx/svdpool.hxx>
30 using namespace sdr::table;
31 using namespace ::com::sun::star;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::lang;
34 using namespace ::com::sun::star::container;
36 SvxTableShape::SvxTableShape(SdrObject* pObj)
37 : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_TABLE), getSvxMapProvider().GetPropertySet(SVXMAP_TABLE, SdrObject::GetGlobalDrawObjectItemPool()) )
39 SetShapeType( u"com.sun.star.drawing.TableShape"_ustr );
42 SvxTableShape::~SvxTableShape() noexcept
46 bool SvxTableShape::setPropertyValueImpl(
47 const OUString& rName,
48 const SfxItemPropertyMapEntry* pProperty,
49 const css::uno::Any& rValue )
51 switch( pProperty->nWID )
53 case OWN_ATTR_TABLETEMPLATE:
55 Reference< XIndexAccess > xTemplate;
57 if( !(rValue >>= xTemplate) )
58 throw IllegalArgumentException();
60 if( HasSdrObject() )
61 static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->setTableStyle(xTemplate);
63 return true;
65 case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
66 case OWN_ATTR_TABLETEMPLATE_LASTROW:
67 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
68 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
69 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
70 case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS:
72 if( HasSdrObject() )
74 TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyleSettings() );
76 switch( pProperty->nWID )
78 case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue >>= aSettings.mbUseFirstRow; break;
79 case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue >>= aSettings.mbUseLastRow; break;
80 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue >>= aSettings.mbUseFirstColumn; break;
81 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue >>= aSettings.mbUseLastColumn; break;
82 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue >>= aSettings.mbUseRowBanding; break;
83 case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS: rValue >>= aSettings.mbUseColumnBanding; break;
86 static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->setTableStyleSettings(aSettings);
89 return true;
91 default:
93 return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
98 bool SvxTableShape::getPropertyValueImpl(
99 const OUString& rName,
100 const SfxItemPropertyMapEntry* pProperty,
101 css::uno::Any& rValue )
103 switch( pProperty->nWID )
105 case OWN_ATTR_OLEMODEL:
107 if( HasSdrObject() )
109 rValue <<= static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTable();
111 return true;
113 case OWN_ATTR_TABLETEMPLATE:
115 if( HasSdrObject() )
117 rValue <<= static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyle();
119 return true;
121 case OWN_ATTR_REPLACEMENT_GRAPHIC:
123 if( HasSdrObject() )
125 Graphic aGraphic( SvxGetGraphicForShape( *GetSdrObject() ) );
126 rValue <<= aGraphic.GetXGraphic();
128 return true;
130 case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
131 case OWN_ATTR_TABLETEMPLATE_LASTROW:
132 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
133 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
134 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
135 case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS:
137 if( HasSdrObject() )
139 TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyleSettings() );
141 switch( pProperty->nWID )
143 case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue <<= aSettings.mbUseFirstRow; break;
144 case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue <<= aSettings.mbUseLastRow; break;
145 case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue <<= aSettings.mbUseFirstColumn; break;
146 case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue <<= aSettings.mbUseLastColumn; break;
147 case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue <<= aSettings.mbUseRowBanding; break;
148 case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS: rValue <<= aSettings.mbUseColumnBanding; break;
152 return true;
154 default:
156 return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
161 void SvxTableShape::lock()
163 SvxShape::lock();
164 if( HasSdrObject() )
165 static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->uno_lock();
168 void SvxTableShape::unlock()
170 if( HasSdrObject() )
171 static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->uno_unlock();
172 SvxShape::unlock();
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */