Version 7.1.7.1, tag libreoffice-7.1.7.1
[LibreOffice.git] / svx / source / dialog / rlrcitem.cxx
blobf5309e843f0bb5ce6d772612474d669fd20b0601
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 <svl/rectitem.hxx>
21 #include <sal/log.hxx>
22 #include <osl/diagnose.h>
24 #include <svx/svxids.hrc>
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>
34 SvxRulerItem::SvxRulerItem(sal_uInt16 _nId, SvxRuler &rRul, SfxBindings &rBindings)
35 : SfxControllerItem(_nId, rBindings),
36 rRuler(rRul)
41 void SvxRulerItem::StateChanged( sal_uInt16 nSID, SfxItemState eState,
42 const SfxPoolItem* pState)
44 // SfxItemState::DONTCARE => pState == -1 => PTR_CAST buff
45 if ( eState != SfxItemState::DEFAULT )
46 pState = nullptr;
48 switch(nSID)
50 // Left / right margin
51 case SID_RULER_LR_MIN_MAX:
53 const SfxRectangleItem *pItem = dynamic_cast<const SfxRectangleItem*>( pState );
54 rRuler.UpdateFrameMinMax(pItem);
55 break;
57 case SID_ATTR_LONG_LRSPACE:
59 const SvxLongLRSpaceItem *pItem = dynamic_cast<const SvxLongLRSpaceItem*>( pState );
60 SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxLRSpaceItem expected");
61 rRuler.UpdateFrame(pItem);
62 break;
64 case SID_ATTR_LONG_ULSPACE:
66 const SvxLongULSpaceItem *pItem = dynamic_cast<const SvxLongULSpaceItem*>( pState );
67 SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxULSpaceItem expected");
68 rRuler.UpdateFrame(pItem);
69 break;
71 case SID_ATTR_TABSTOP_VERTICAL:
72 case SID_ATTR_TABSTOP:
74 const SvxTabStopItem *pItem = dynamic_cast<const SvxTabStopItem*>( pState );
75 SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxTabStopItem expected");
76 rRuler.Update(pItem);
77 break;
79 case SID_ATTR_PARA_LRSPACE_VERTICAL:
80 case SID_ATTR_PARA_LRSPACE:
82 const SvxLRSpaceItem *pItem = dynamic_cast<const SvxLRSpaceItem*>( pState );
83 SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxLRSpaceItem expected");
84 rRuler.UpdatePara(pItem);
85 break;
87 case SID_RULER_BORDERS_VERTICAL:
88 case SID_RULER_BORDERS:
89 case SID_RULER_ROWS:
90 case SID_RULER_ROWS_VERTICAL:
92 const SvxColumnItem *pItem = dynamic_cast<const SvxColumnItem*>( pState );
93 SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxColumnItem expected");
94 #ifdef DBG_UTIL
95 if(pItem)
97 if(pItem->IsConsistent())
98 rRuler.Update(pItem, nSID);
99 else
100 OSL_FAIL("Column item corrupted");
102 else
103 rRuler.Update(pItem, nSID);
104 #else
105 rRuler.Update(pItem, nSID);
106 #endif
107 break;
109 case SID_RULER_PAGE_POS:
110 { // Position page, page width
111 const SvxPagePosSizeItem *pItem = dynamic_cast<const SvxPagePosSizeItem*>( pState );
112 SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxPagePosSizeItem expected");
113 rRuler.Update(pItem);
114 break;
116 case SID_RULER_OBJECT:
117 { // Object selection
118 const SvxObjectItem *pItem = dynamic_cast<const SvxObjectItem*>( pState );
119 SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxObjectItem expected");
120 rRuler.Update(pItem);
121 break;
123 case SID_RULER_PROTECT:
125 const SvxProtectItem *pItem = dynamic_cast<const SvxProtectItem*>( pState );
126 SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxProtectItem expected");
127 rRuler.Update(pItem);
128 break;
130 case SID_RULER_BORDER_DISTANCE:
132 const SvxLRSpaceItem *pItem = dynamic_cast<const SvxLRSpaceItem*>( pState );
133 SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SvxLRSpaceItem expected");
134 rRuler.UpdateParaBorder();
136 break;
137 case SID_RULER_TEXT_RIGHT_TO_LEFT :
139 const SfxBoolItem *pItem = dynamic_cast<const SfxBoolItem*>( pState );
140 SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", "SfxBoolItem expected");
141 rRuler.UpdateTextRTL(pItem);
143 break;
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */