Coverage Report

Created: 2026-09-28 10:59

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
172k
: SfxControllerItem(_nId, rBindings),
36
172k
  rRuler(rRul)
37
172k
{
38
172k
}
39
40
41
void SvxRulerItem::StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState,
42
                                 const SfxPoolItem* pState)
43
828
{
44
    // SfxItemState::INVALID => pState == -1 => PTR_CAST buff
45
828
    if ( eState != SfxItemState::DEFAULT )
46
180
        pState = nullptr;
47
48
828
    switch(nSID)
49
828
    {
50
        // Left / right margin
51
72
        case SID_RULER_LR_MIN_MAX:
52
72
        {
53
72
            const SfxRectangleItem *pItem = dynamic_cast<const SfxRectangleItem*>( pState );
54
72
            rRuler.UpdateFrameMinMax(pItem);
55
72
            break;
56
0
        }
57
72
        case SID_ATTR_LONG_LRSPACE:
58
72
        {
59
72
            const SvxLongLRSpaceItem *pItem = dynamic_cast<const SvxLongLRSpaceItem*>( pState );
60
72
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxLRSpaceItem expected");
61
72
            rRuler.UpdateFrame(pItem);
62
72
            break;
63
72
        }
64
72
        case SID_ATTR_LONG_ULSPACE:
65
72
        {
66
72
            const SvxLongULSpaceItem *pItem = dynamic_cast<const SvxLongULSpaceItem*>( pState );
67
72
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxULSpaceItem expected");
68
72
            rRuler.UpdateFrame(pItem);
69
72
            break;
70
72
        }
71
36
        case SID_ATTR_TABSTOP_VERTICAL:
72
36
        case SID_ATTR_TABSTOP:
73
36
        {
74
36
            const SvxTabStopItem *pItem = dynamic_cast<const SvxTabStopItem*>( pState );
75
36
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxTabStopItem expected");
76
36
            rRuler.Update(pItem);
77
36
            break;
78
36
        }
79
36
        case SID_ATTR_PARA_LRSPACE_VERTICAL:
80
36
        case SID_ATTR_PARA_LRSPACE:
81
36
        {
82
36
            const SvxLRSpaceItem *pItem = dynamic_cast<const SvxLRSpaceItem*>( pState );
83
36
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxLRSpaceItem expected");
84
36
            rRuler.UpdatePara(pItem);
85
36
            break;
86
36
        }
87
36
        case SID_RULER_BORDERS_VERTICAL:
88
36
        case SID_RULER_BORDERS:
89
72
        case SID_RULER_ROWS:
90
108
        case SID_RULER_ROWS_VERTICAL:
91
108
        {
92
108
            const SvxColumnItem *pItem = dynamic_cast<const SvxColumnItem*>( pState );
93
108
            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
108
            rRuler.Update(pItem, nSID);
106
108
#endif
107
108
            break;
108
108
        }
109
144
        case SID_RULER_PAGE_POS:
110
144
        {   // Position page, page width
111
144
            const SvxPagePosSizeItem *pItem = dynamic_cast<const SvxPagePosSizeItem*>( pState );
112
144
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxPagePosSizeItem expected");
113
144
            rRuler.Update(pItem);
114
144
            break;
115
144
        }
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
144
        case SID_RULER_PROTECT:
124
144
        {
125
144
            const SvxProtectItem *pItem = dynamic_cast<const SvxProtectItem*>( pState );
126
144
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxProtectItem expected");
127
144
            rRuler.Update(pItem);
128
144
            break;
129
144
        }
130
72
        case SID_RULER_BORDER_DISTANCE:
131
72
        {
132
72
            const SvxLRSpaceItem *pItem = dynamic_cast<const SvxLRSpaceItem*>( pState );
133
72
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxLRSpaceItem expected");
134
72
            rRuler.UpdateBorder(pItem);
135
72
        }
136
0
        break;
137
72
        case SID_RULER_TEXT_RIGHT_TO_LEFT :
138
72
        {
139
72
            const SfxBoolItem *pItem = dynamic_cast<const SfxBoolItem*>( pState );
140
72
            SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SfxBoolItem expected");
141
72
            rRuler.UpdateTextRTL(pItem);
142
72
        }
143
0
        break;
144
828
    }
145
828
}
146
147
148
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */