1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tplcitem.cxx,v $
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>
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>
51 // STATIC DATA -----------------------------------------------------------
55 SfxTemplateControllerItem::SfxTemplateControllerItem(
57 SfxCommonTemplateDialog_Impl
&rDlg
, // Controller-Instanz, dem dieses Item zugeordnet ist.
58 SfxBindings
&rBindings
):
59 SfxControllerItem(nSlotId
, rBindings
),
65 // -----------------------------------------------------------------------
66 SfxTemplateControllerItem::~SfxTemplateControllerItem()
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
)
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
;
90 rTemplateDlg
.SetFamilyState(GetId(), 0);
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
;
102 case SID_STYLE_FAMILY1
:
104 case SID_STYLE_FAMILY2
:
106 case SID_STYLE_FAMILY3
:
108 case SID_STYLE_FAMILY4
:
110 case SID_STYLE_FAMILY5
:
112 default: DBG_ERROR("unbekannte StyleFamily"); break;
114 rTemplateDlg
.EnableFamilyItem( nFamily
, !bDisable
);
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
129 nUserEventId
= Application::PostUserEvent( STATIC_LINK(
130 this, SfxTemplateControllerItem
, SetWaterCanStateHdl_Impl
) );
134 rTemplateDlg
.EnableEdit( SFX_ITEM_DISABLED
!= eState
);
136 case SID_STYLE_DELETE
:
137 rTemplateDlg
.EnableDel( SFX_ITEM_DISABLED
!= eState
);
139 case SID_STYLE_NEW_BY_EXAMPLE
:
141 rTemplateDlg
.EnableExample_Impl(
142 GetId(), SFX_ITEM_DISABLED
!= eState
);
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 ); */
155 rTemplateDlg
.EnableNew( SFX_ITEM_DISABLED
!= eState
);
158 case SID_STYLE_DRAGHIERARCHIE
:
160 rTemplateDlg
.EnableTreeDrag( SFX_ITEM_DISABLED
!= eState
);
163 case SID_STYLE_FAMILY
:
165 const SfxUInt16Item
*pStateItem
= PTR_CAST( SfxUInt16Item
, pItem
);
167 rTemplateDlg
.SetFamily( pStateItem
->GetValue() );
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
)
184 pState
= new SfxBoolItem(SID_STYLE_WATERCAN
, pThis
->nWaterCanState
? TRUE
: FALSE
);
187 pThis
->rTemplateDlg
.SetWaterCanState(pState
);