Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/dialog/rlrcitem.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 <svl/rectitem.hxx>
21
#include <sal/log.hxx>
22
#include <osl/diagnose.h>
23
24
#include <svx/svxids.hrc>
25
26
#include <svx/ruler.hxx>
27
#include <editeng/lrspitem.hxx>
28
#include <editeng/tstpitem.hxx>
29
#include <editeng/protitem.hxx>
30
#include "rlrcitem.hxx"
31
#include <svx/rulritem.hxx>
32
#include <svl/eitem.hxx>
33
34
SvxRulerItem::SvxRulerItem(sal_uInt16 _nId, SvxRuler &rRul, SfxBindings &rBindings)
35
124k
: SfxControllerItem(_nId, rBindings),
36
124k
  rRuler(rRul)
37
124k
{
38
124k
}
39
40
41
void SvxRulerItem::StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState,
42
                                 const SfxPoolItem* pState)
43
1.01k
{
44
    // SfxItemState::INVALID => pState == -1 => PTR_CAST buff
45
1.01k
    if ( eState != SfxItemState::DEFAULT )
46
220
        pState = nullptr;
47
48
1.01k
    switch(nSID)
49
1.01k
    {
50
        // Left / right margin
51
88
        case SID_RULER_LR_MIN_MAX:
52
88
        {
53
88
            const SfxRectangleItem *pItem = dynamic_cast<const SfxRectangleItem*>( pState );
54
88
            rRuler.UpdateFrameMinMax(pItem);
55
88
            break;
56
0
        }
57
88
        case SID_ATTR_LONG_LRSPACE:
58
88
        {
59
88
            const SvxLongLRSpaceItem *pItem = dynamic_cast<const SvxLongLRSpaceItem*>( pState );
60
88
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxLRSpaceItem expected");
61
88
            rRuler.UpdateFrame(pItem);
62
88
            break;
63
88
        }
64
88
        case SID_ATTR_LONG_ULSPACE:
65
88
        {
66
88
            const SvxLongULSpaceItem *pItem = dynamic_cast<const SvxLongULSpaceItem*>( pState );
67
88
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxULSpaceItem expected");
68
88
            rRuler.UpdateFrame(pItem);
69
88
            break;
70
88
        }
71
44
        case SID_ATTR_TABSTOP_VERTICAL:
72
44
        case SID_ATTR_TABSTOP:
73
44
        {
74
44
            const SvxTabStopItem *pItem = dynamic_cast<const SvxTabStopItem*>( pState );
75
44
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxTabStopItem expected");
76
44
            rRuler.Update(pItem);
77
44
            break;
78
44
        }
79
44
        case SID_ATTR_PARA_LRSPACE_VERTICAL:
80
44
        case SID_ATTR_PARA_LRSPACE:
81
44
        {
82
44
            const SvxLRSpaceItem *pItem = dynamic_cast<const SvxLRSpaceItem*>( pState );
83
44
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxLRSpaceItem expected");
84
44
            rRuler.UpdatePara(pItem);
85
44
            break;
86
44
        }
87
44
        case SID_RULER_BORDERS_VERTICAL:
88
44
        case SID_RULER_BORDERS:
89
88
        case SID_RULER_ROWS:
90
132
        case SID_RULER_ROWS_VERTICAL:
91
132
        {
92
132
            const SvxColumnItem *pItem = dynamic_cast<const SvxColumnItem*>( pState );
93
132
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxColumnItem expected");
94
#ifdef DBG_UTIL
95
            if(pItem)
96
            {
97
                if(pItem->IsConsistent())
98
                    rRuler.Update(pItem, nSID);
99
                else
100
                    OSL_FAIL("Column item corrupted");
101
            }
102
            else
103
                rRuler.Update(pItem, nSID);
104
#else
105
132
            rRuler.Update(pItem, nSID);
106
132
#endif
107
132
            break;
108
132
        }
109
176
        case SID_RULER_PAGE_POS:
110
176
        {   // Position page, page width
111
176
            const SvxPagePosSizeItem *pItem = dynamic_cast<const SvxPagePosSizeItem*>( pState );
112
176
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxPagePosSizeItem expected");
113
176
            rRuler.Update(pItem);
114
176
            break;
115
176
        }
116
0
        case SID_RULER_OBJECT:
117
0
        {   // Object selection
118
0
            const SvxObjectItem *pItem = dynamic_cast<const SvxObjectItem*>( pState );
119
0
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxObjectItem expected");
120
0
            rRuler.Update(pItem);
121
0
            break;
122
0
        }
123
176
        case SID_RULER_PROTECT:
124
176
        {
125
176
            const SvxProtectItem *pItem = dynamic_cast<const SvxProtectItem*>( pState );
126
176
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxProtectItem expected");
127
176
            rRuler.Update(pItem);
128
176
            break;
129
176
        }
130
88
        case SID_RULER_BORDER_DISTANCE:
131
88
        {
132
88
            const SvxLRSpaceItem *pItem = dynamic_cast<const SvxLRSpaceItem*>( pState );
133
88
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxLRSpaceItem expected");
134
88
            rRuler.UpdateBorder(pItem);
135
88
        }
136
0
        break;
137
88
        case SID_RULER_TEXT_RIGHT_TO_LEFT :
138
88
        {
139
88
            const SfxBoolItem *pItem = dynamic_cast<const SfxBoolItem*>( pState );
140
88
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SfxBoolItem expected");
141
88
            rRuler.UpdateTextRTL(pItem);
142
88
        }
143
0
        break;
144
1.01k
    }
145
1.01k
}
146
147
148
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */