xref: /trunk/main/svx/source/dialog/rlrcitem.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 // INCLUDE ---------------------------------------------------------------
32 #include <svl/rectitem.hxx>
33 
34 
35 
36 
37 
38 
39 #include <svx/dialogs.hrc>
40 
41 #include <svx/ruler.hxx>
42 #include <editeng/lrspitem.hxx>
43 #include <editeng/ulspitem.hxx>
44 #include <editeng/tstpitem.hxx>
45 #include "editeng/protitem.hxx"
46 #include "rlrcitem.hxx"
47 #include "svx/rulritem.hxx"
48 #include <svl/eitem.hxx>
49 
50 // class SvxRulerItem ----------------------------------------------------
51 
52 SvxRulerItem::SvxRulerItem(sal_uInt16 _nId, SvxRuler &rRul, SfxBindings &rBindings)
53 : SfxControllerItem(_nId, rBindings),
54   rRuler(rRul)
55 {
56 }
57 
58 // -----------------------------------------------------------------------
59 
60 void SvxRulerItem::StateChanged( sal_uInt16 nSID, SfxItemState eState,
61                                  const SfxPoolItem* pState)
62 {
63     // SFX_ITEM_DONTCARE => pState == -1 => PTR_CAST buff
64     if ( eState != SFX_ITEM_AVAILABLE )
65         pState = 0;
66 
67     switch(nSID)
68     {
69         // Linker / rechter Seitenrand
70         case SID_RULER_LR_MIN_MAX:
71         {
72             const SfxRectangleItem *pItem = PTR_CAST(SfxRectangleItem, pState);
73             rRuler.UpdateFrameMinMax(pItem);
74             break;
75         }
76         case SID_ATTR_LONG_LRSPACE:
77         {
78             const SvxLongLRSpaceItem *pItem = PTR_CAST(SvxLongLRSpaceItem, pState);
79             DBG_ASSERT(pState? 0 != pItem: sal_True, "SvxLRSpaceItem erwartet");
80             rRuler.UpdateFrame(pItem);
81             break;
82         }
83         case SID_ATTR_LONG_ULSPACE:
84         {
85             const SvxLongULSpaceItem *pItem = PTR_CAST(SvxLongULSpaceItem, pState);
86             DBG_ASSERT(pState? 0 != pItem: sal_True, "SvxULSpaceItem erwartet");
87             rRuler.UpdateFrame(pItem);
88             break;
89         }
90         case SID_ATTR_TABSTOP_VERTICAL:
91         case SID_ATTR_TABSTOP:
92         {
93             const SvxTabStopItem *pItem = PTR_CAST(SvxTabStopItem, pState);
94             DBG_ASSERT(pState?  0 != pItem: sal_True, "SvxTabStopItem erwartet");
95             rRuler.Update(pItem);
96             break;
97         }
98         case SID_ATTR_PARA_LRSPACE_VERTICAL:
99         case SID_ATTR_PARA_LRSPACE:
100         {
101             const SvxLRSpaceItem *pItem = PTR_CAST(SvxLRSpaceItem, pState);
102             DBG_ASSERT(pState?  0 != pItem: sal_True, "SvxLRSpaceItem erwartet");
103             rRuler.UpdatePara(pItem);
104             break;
105         }
106         case SID_RULER_BORDERS_VERTICAL:
107         case SID_RULER_BORDERS:
108         case SID_RULER_ROWS:
109         case SID_RULER_ROWS_VERTICAL:
110         {
111             const SvxColumnItem *pItem = PTR_CAST(SvxColumnItem, pState);
112             DBG_ASSERT(pState?  0 != pItem: sal_True, "SvxColumnItem erwartet");
113 #ifdef DBG_UTIL
114             if(pItem)
115             {
116                 if(pItem->IsConsistent())
117                     rRuler.Update(pItem, nSID);
118                 else
119                     DBG_ERROR("Spaltenitem corrupted");
120             }
121             else
122                 rRuler.Update(pItem, nSID);
123 #else
124             rRuler.Update(pItem, nSID);
125 #endif
126             break;
127         }
128         case SID_RULER_PAGE_POS:
129         {   // Position Seite, Seitenbreite
130             const SvxPagePosSizeItem *pItem = PTR_CAST(SvxPagePosSizeItem, pState);
131             DBG_ASSERT(pState?  0 != pItem: sal_True, "SvxPagePosSizeItem erwartet");
132             rRuler.Update(pItem);
133             break;
134         }
135         case SID_RULER_OBJECT:
136         {   // Object-Selektion
137             const SvxObjectItem *pItem = PTR_CAST(SvxObjectItem, pState);
138             DBG_ASSERT(pState?  0 != pItem: sal_True, "SvxObjectItem erwartet");
139             rRuler.Update(pItem);
140             break;
141         }
142         case SID_RULER_PROTECT:
143         {
144             const SvxProtectItem *pItem = PTR_CAST(SvxProtectItem, pState);
145             DBG_ASSERT(pState?  0 != pItem: sal_True, "SvxProtectItem erwartet");
146             rRuler.Update(pItem);
147             break;
148         }
149         case SID_RULER_BORDER_DISTANCE:
150         {
151             const SvxLRSpaceItem *pItem = PTR_CAST(SvxLRSpaceItem, pState);
152             DBG_ASSERT(pState?  0 != pItem: sal_True, "SvxLRSpaceItem erwartet");
153             rRuler.UpdateParaBorder(pItem);
154         }
155         break;
156         case SID_RULER_TEXT_RIGHT_TO_LEFT :
157         {
158             const SfxBoolItem *pItem = PTR_CAST(SfxBoolItem, pState);
159             DBG_ASSERT(pState?  0 != pItem: sal_True, "SfxBoolItem erwartet");
160             rRuler.UpdateTextRTL(pItem);
161         }
162         break;
163     }
164 }
165 
166 
167