Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/unodraw/tableshape.cxx
Line
Count
Source
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/unodraw/SvxTableShape.hxx>
25
#include <svx/unoshprp.hxx>
26
#include <svx/svdotable.hxx>
27
#include <svx/svdpool.hxx>
28
29
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;
35
36
SvxTableShape::SvxTableShape(SdrObject* pObj)
37
230
:   SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_TABLE), getSvxMapProvider().GetPropertySet(SVXMAP_TABLE, SdrObject::GetGlobalDrawObjectItemPool()) )
38
230
{
39
230
    SetShapeType( u"com.sun.star.drawing.TableShape"_ustr );
40
230
}
41
42
SvxTableShape::~SvxTableShape() noexcept
43
230
{
44
230
}
45
46
bool SvxTableShape::setPropertyValueImpl(
47
    const OUString& rName,
48
    const SfxItemPropertyMapEntry* pProperty,
49
    const css::uno::Any& rValue )
50
119
{
51
119
    switch( pProperty->nWID )
52
119
    {
53
0
    case OWN_ATTR_TABLETEMPLATE:
54
0
    {
55
0
        Reference< XIndexAccess > xTemplate;
56
57
0
        if( !(rValue >>= xTemplate) )
58
0
            throw IllegalArgumentException();
59
60
0
        if( HasSdrObject() )
61
0
            static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->setTableStyle(xTemplate);
62
63
0
        return true;
64
0
    }
65
1
    case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
66
2
    case OWN_ATTR_TABLETEMPLATE_LASTROW:
67
3
    case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
68
4
    case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
69
5
    case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
70
6
    case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS:
71
6
    {
72
6
        if( HasSdrObject() )
73
6
        {
74
6
            TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyleSettings() );
75
76
6
            switch( pProperty->nWID )
77
6
            {
78
1
            case OWN_ATTR_TABLETEMPLATE_FIRSTROW:           rValue >>= aSettings.mbUseFirstRow; break;
79
1
            case OWN_ATTR_TABLETEMPLATE_LASTROW:            rValue >>= aSettings.mbUseLastRow; break;
80
1
            case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:        rValue >>= aSettings.mbUseFirstColumn; break;
81
1
            case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:         rValue >>= aSettings.mbUseLastColumn; break;
82
1
            case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:        rValue >>= aSettings.mbUseRowBanding; break;
83
1
            case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS:    rValue >>= aSettings.mbUseColumnBanding; break;
84
6
            }
85
86
6
            static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->setTableStyleSettings(aSettings);
87
6
        }
88
89
6
        return true;
90
6
    }
91
113
    default:
92
113
    {
93
113
        return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
94
6
    }
95
119
    }
96
119
}
97
98
bool SvxTableShape::getPropertyValueImpl(
99
    const OUString& rName,
100
    const SfxItemPropertyMapEntry* pProperty,
101
    css::uno::Any& rValue )
102
114
{
103
114
    switch( pProperty->nWID )
104
114
    {
105
114
    case OWN_ATTR_OLEMODEL:
106
114
    {
107
114
        if( HasSdrObject() )
108
114
        {
109
114
            rValue <<= static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTable();
110
114
        }
111
114
        return true;
112
0
    }
113
0
    case OWN_ATTR_TABLETEMPLATE:
114
0
    {
115
0
        if( HasSdrObject() )
116
0
        {
117
0
            rValue <<= static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyle();
118
0
        }
119
0
        return true;
120
0
    }
121
0
    case OWN_ATTR_REPLACEMENT_GRAPHIC:
122
0
    {
123
0
        if( HasSdrObject() )
124
0
        {
125
0
            Graphic aGraphic( SvxGetGraphicForShape( *GetSdrObject() ) );
126
0
            rValue <<= aGraphic.GetXGraphic();
127
0
        }
128
0
        return true;
129
0
    }
130
0
    case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
131
0
    case OWN_ATTR_TABLETEMPLATE_LASTROW:
132
0
    case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
133
0
    case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
134
0
    case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
135
0
    case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS:
136
0
    {
137
0
        if( HasSdrObject() )
138
0
        {
139
0
            TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyleSettings() );
140
141
0
            switch( pProperty->nWID )
142
0
            {
143
0
            case OWN_ATTR_TABLETEMPLATE_FIRSTROW:           rValue <<= aSettings.mbUseFirstRow; break;
144
0
            case OWN_ATTR_TABLETEMPLATE_LASTROW:            rValue <<= aSettings.mbUseLastRow; break;
145
0
            case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:        rValue <<= aSettings.mbUseFirstColumn; break;
146
0
            case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:         rValue <<= aSettings.mbUseLastColumn; break;
147
0
            case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:        rValue <<= aSettings.mbUseRowBanding; break;
148
0
            case OWN_ATTR_TABLETEMPLATE_BANDINGCOLUMNS:    rValue <<= aSettings.mbUseColumnBanding; break;
149
0
            }
150
0
        }
151
152
0
        return true;
153
0
    }
154
0
    default:
155
0
    {
156
0
        return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
157
0
    }
158
114
    }
159
114
}
160
161
void SvxTableShape::lock()
162
114
{
163
114
    SvxShape::lock();
164
114
    if( HasSdrObject() )
165
114
        static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->uno_lock();
166
114
}
167
168
void SvxTableShape::unlock()
169
113
{
170
113
    if( HasSdrObject() )
171
113
        static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->uno_unlock();
172
113
    SvxShape::unlock();
173
113
}
174
175
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */