1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
),
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
)
50 // Left / right margin
51 case SID_RULER_LR_MIN_MAX
:
53 const SfxRectangleItem
*pItem
= dynamic_cast<const SfxRectangleItem
*>( pState
);
54 rRuler
.UpdateFrameMinMax(pItem
);
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
);
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
);
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");
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
);
87 case SID_RULER_BORDERS_VERTICAL
:
88 case SID_RULER_BORDERS
:
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");
97 if(pItem
->IsConsistent())
98 rRuler
.Update(pItem
, nSID
);
100 OSL_FAIL("Column item corrupted");
103 rRuler
.Update(pItem
, nSID
);
105 rRuler
.Update(pItem
, nSID
);
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
);
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
);
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
);
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();
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
);
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */