update dev300-m57
[ooovba.git] / sfx2 / source / dialog / tplcitem.cxx
blob03103837b2e03cd8804f1f6eb9c852bff6cb4beb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tplcitem.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
34 // INCLUDE ---------------------------------------------------------------
36 #include <svtools/intitem.hxx>
37 #include <vcl/svapp.hxx>
39 #ifndef GCC
40 #endif
42 #include <sfx2/templdlg.hxx>
43 #include <sfx2/bindings.hxx>
44 #include "tplpitem.hxx"
45 #include "tplcitem.hxx"
46 #include "templdgi.hxx"
48 #include <sfx2/sfx.hrc>
49 #include "dialog.hrc"
51 // STATIC DATA -----------------------------------------------------------
53 // Konstruktor
55 SfxTemplateControllerItem::SfxTemplateControllerItem(
56 USHORT nSlotId, // ID
57 SfxCommonTemplateDialog_Impl &rDlg, // Controller-Instanz, dem dieses Item zugeordnet ist.
58 SfxBindings &rBindings):
59 SfxControllerItem(nSlotId, rBindings),
60 rTemplateDlg(rDlg),
61 nWaterCanState(0xff),
62 nUserEventId(0)
65 // -----------------------------------------------------------------------
66 SfxTemplateControllerItem::~SfxTemplateControllerItem()
68 if(nUserEventId)
69 Application::RemoveUserEvent(nUserEventId);
72 // -----------------------------------------------------------------------
74 // Benachrichtigung "uber Status"anderung; wird an den
75 // im Konstruktor "ubergebenen Controller propagiert
77 void SfxTemplateControllerItem::StateChanged( USHORT nSID, SfxItemState eState,
78 const SfxPoolItem* pItem )
80 switch(nSID)
82 case SID_STYLE_FAMILY1:
83 case SID_STYLE_FAMILY2:
84 case SID_STYLE_FAMILY3:
85 case SID_STYLE_FAMILY4:
86 case SID_STYLE_FAMILY5:
88 FASTBOOL bAvailable = SFX_ITEM_AVAILABLE == eState;
89 if ( !bAvailable )
90 rTemplateDlg.SetFamilyState(GetId(), 0);
91 else {
92 const SfxTemplateItem *pStateItem = PTR_CAST(
93 SfxTemplateItem, pItem);
94 DBG_ASSERT(pStateItem != 0, "SfxTemplateItem erwartet");
95 rTemplateDlg.SetFamilyState( GetId(), pStateItem );
97 BOOL bDisable = eState == SFX_ITEM_DISABLED;
98 // Familie Disablen
99 USHORT nFamily = 0;
100 switch( GetId())
102 case SID_STYLE_FAMILY1:
103 nFamily = 1; break;
104 case SID_STYLE_FAMILY2:
105 nFamily = 2; break;
106 case SID_STYLE_FAMILY3:
107 nFamily = 3; break;
108 case SID_STYLE_FAMILY4:
109 nFamily = 4; break;
110 case SID_STYLE_FAMILY5:
111 nFamily = 5; break;
112 default: DBG_ERROR("unbekannte StyleFamily"); break;
114 rTemplateDlg.EnableFamilyItem( nFamily, !bDisable );
115 break;
117 case SID_STYLE_WATERCAN:
119 if ( eState == SFX_ITEM_DISABLED )
120 nWaterCanState = 0xff;
121 else if( eState == SFX_ITEM_AVAILABLE )
123 const SfxBoolItem *pStateItem = PTR_CAST(SfxBoolItem, pItem);
124 DBG_ASSERT(pStateItem != 0, "BoolItem erwartet");
125 nWaterCanState = pStateItem->GetValue() ? 1 : 0;
127 //not necessary if the last event is still on the way
128 if(!nUserEventId)
129 nUserEventId = Application::PostUserEvent( STATIC_LINK(
130 this, SfxTemplateControllerItem, SetWaterCanStateHdl_Impl ) );
131 break;
133 case SID_STYLE_EDIT:
134 rTemplateDlg.EnableEdit( SFX_ITEM_DISABLED != eState );
135 break;
136 case SID_STYLE_DELETE:
137 rTemplateDlg.EnableDel( SFX_ITEM_DISABLED != eState );
138 break;
139 case SID_STYLE_NEW_BY_EXAMPLE:
141 rTemplateDlg.EnableExample_Impl(
142 GetId(), SFX_ITEM_DISABLED != eState );
143 break;
144 case SID_STYLE_UPDATE_BY_EXAMPLE:
146 rTemplateDlg.EnableExample_Impl(
147 GetId(), eState != SFX_ITEM_DISABLED );
148 // Das Select Disabled dann, falls enabled und Style Readonly
149 /* String aStr = rTemplateDlg.GetSelectedEntry();
150 if( aStr.Len() ) rTemplateDlg.SelectStyle( aStr ); */
151 break;
153 case SID_STYLE_NEW:
155 rTemplateDlg.EnableNew( SFX_ITEM_DISABLED != eState );
156 break;
158 case SID_STYLE_DRAGHIERARCHIE:
160 rTemplateDlg.EnableTreeDrag( SFX_ITEM_DISABLED != eState );
161 break;
163 case SID_STYLE_FAMILY :
165 const SfxUInt16Item *pStateItem = PTR_CAST( SfxUInt16Item, pItem);
166 if (pStateItem)
167 rTemplateDlg.SetFamily( pStateItem->GetValue() );
168 break;
172 /* -----------------------------05.09.2001 10:48------------------------------
174 ---------------------------------------------------------------------------*/
175 IMPL_STATIC_LINK(SfxTemplateControllerItem, SetWaterCanStateHdl_Impl,
176 SfxTemplateControllerItem*, EMPTYARG)
178 pThis->nUserEventId = 0;
179 SfxBoolItem* pState = 0;
180 switch(pThis->nWaterCanState)
182 case 0 :
183 case 1 :
184 pState = new SfxBoolItem(SID_STYLE_WATERCAN, pThis->nWaterCanState ? TRUE : FALSE);
185 break;
187 pThis->rTemplateDlg.SetWaterCanState(pState);
188 delete pState;
189 return 0;