Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svl/source/items/rectitem.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
21
#include <svl/rectitem.hxx>
22
#include <com/sun/star/uno/Any.hxx>
23
#include <com/sun/star/awt/Rectangle.hpp>
24
#include <osl/diagnose.h>
25
26
#include <svl/poolitem.hxx>
27
#include <svl/memberid.h>
28
29
30
0
SfxPoolItem* SfxRectangleItem::CreateDefault() { return new SfxRectangleItem; }
31
32
33
SfxRectangleItem::SfxRectangleItem()
34
0
    : SfxPoolItem( 0 )
35
0
{
36
0
}
37
38
39
SfxRectangleItem::SfxRectangleItem( sal_uInt16 nW, const tools::Rectangle& rVal ) :
40
0
    SfxPoolItem( nW ),
41
0
    maVal( rVal )
42
0
{
43
0
}
44
45
46
bool SfxRectangleItem::GetPresentation
47
(
48
    SfxItemPresentation     /*ePresentation*/,
49
    MapUnit                 /*eCoreMetric*/,
50
    MapUnit                 /*ePresentationMetric*/,
51
    OUString&               rText,
52
    const IntlWrapper&
53
)   const
54
0
{
55
0
    rText = OUString::number(maVal.Top())    + ", " +
56
0
            OUString::number(maVal.Left())   + ", " +
57
0
            OUString::number(maVal.Bottom()) + ", " +
58
0
            OUString::number(maVal.Right());
59
0
    return true;
60
0
}
61
62
63
bool SfxRectangleItem::operator==( const SfxPoolItem& rItem ) const
64
0
{
65
0
    assert(SfxPoolItem::operator==(rItem));
66
0
    return static_cast<const SfxRectangleItem&>(rItem).maVal == maVal;
67
0
}
68
69
SfxRectangleItem* SfxRectangleItem::Clone(SfxItemPool *) const
70
0
{
71
0
    return new SfxRectangleItem( *this );
72
0
}
73
74
bool SfxRectangleItem::QueryValue( css::uno::Any& rVal,
75
                                   sal_uInt8 nMemberId) const
76
0
{
77
0
    nMemberId &= ~CONVERT_TWIPS;
78
0
    switch ( nMemberId )
79
0
    {
80
0
        case 0:
81
0
        {
82
0
            rVal <<= css::awt::Rectangle( maVal.Left(),
83
0
                                             maVal.Top(),
84
0
                                             maVal.getOpenWidth(),
85
0
                                             maVal.getOpenHeight() );
86
0
            break;
87
0
        }
88
0
        case MID_RECT_LEFT:  rVal <<= maVal.Left(); break;
89
0
        case MID_RECT_RIGHT: rVal <<= maVal.Top(); break;
90
0
        case MID_WIDTH: rVal <<= maVal.getOpenWidth(); break;
91
0
        case MID_HEIGHT: rVal <<= maVal.getOpenHeight(); break;
92
0
        default: OSL_FAIL("Wrong MemberID!"); return false;
93
0
    }
94
95
0
    return true;
96
0
}
97
98
99
bool SfxRectangleItem::PutValue( const css::uno::Any& rVal,
100
                                 sal_uInt8 nMemberId )
101
0
{
102
0
    bool bRet = false;
103
0
    nMemberId &= ~CONVERT_TWIPS;
104
0
    css::awt::Rectangle aValue;
105
0
    sal_Int32 nVal = 0;
106
0
    if ( !nMemberId )
107
0
        bRet = (rVal >>= aValue);
108
0
    else
109
0
        bRet = (rVal >>= nVal);
110
111
0
    if ( bRet )
112
0
    {
113
0
        switch ( nMemberId )
114
0
        {
115
0
            case 0:
116
0
                maVal.SetLeft( aValue.X );
117
0
                maVal.SetTop( aValue.Y );
118
0
                maVal.setWidth( aValue.Width );
119
0
                maVal.setHeight( aValue.Height );
120
0
                break;
121
0
            case MID_RECT_LEFT:  maVal.SetPosX( nVal ); break;
122
0
            case MID_RECT_RIGHT: maVal.SetPosY( nVal ); break;
123
0
            case MID_WIDTH: maVal.setWidth( nVal ); break;
124
0
            case MID_HEIGHT: maVal.setHeight( nVal ); break;
125
0
            default: OSL_FAIL("Wrong MemberID!"); return false;
126
0
        }
127
0
    }
128
129
0
    return bRet;
130
0
}
131
132
133
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */