1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 // INCLUDE ---------------------------------------------------------------
32 #include <svl/intitem.hxx>
33 #include <vcl/svapp.hxx>
35 #include <sfx2/templdlg.hxx>
36 #include <sfx2/bindings.hxx>
37 #include "sfx2/tplpitem.hxx"
38 #include "tplcitem.hxx"
39 #include "templdgi.hxx"
41 #include <sfx2/sfx.hrc>
44 // STATIC DATA -----------------------------------------------------------
48 SfxTemplateControllerItem::SfxTemplateControllerItem(
49 sal_uInt16 nSlotId
, // ID
50 SfxCommonTemplateDialog_Impl
&rDlg
, // Controller-Instance,
51 // which is assigned to this item.
52 SfxBindings
&rBindings
):
53 SfxControllerItem(nSlotId
, rBindings
),
59 // -----------------------------------------------------------------------
60 SfxTemplateControllerItem::~SfxTemplateControllerItem()
63 Application::RemoveUserEvent(nUserEventId
);
66 // -----------------------------------------------------------------------
67 // Notice about change of status, is propagated through the Controller
68 // passed on by the constructor
70 void SfxTemplateControllerItem::StateChanged( sal_uInt16 nSID
, SfxItemState eState
,
71 const SfxPoolItem
* pItem
)
75 case SID_STYLE_FAMILY1
:
76 case SID_STYLE_FAMILY2
:
77 case SID_STYLE_FAMILY3
:
78 case SID_STYLE_FAMILY4
:
79 case SID_STYLE_FAMILY5
:
81 bool bAvailable
= SFX_ITEM_AVAILABLE
== eState
;
83 rTemplateDlg
.SetFamilyState(GetId(), 0);
85 const SfxTemplateItem
*pStateItem
= PTR_CAST(
86 SfxTemplateItem
, pItem
);
87 DBG_ASSERT(pStateItem
!= 0, "SfxTemplateItem expected");
88 rTemplateDlg
.SetFamilyState( GetId(), pStateItem
);
90 sal_Bool bDisable
= eState
== SFX_ITEM_DISABLED
;
92 sal_uInt16 nFamily
= 0;
95 case SID_STYLE_FAMILY1
:
97 case SID_STYLE_FAMILY2
:
99 case SID_STYLE_FAMILY3
:
101 case SID_STYLE_FAMILY4
:
103 case SID_STYLE_FAMILY5
:
106 default: OSL_FAIL("unknown StyleFamily"); break;
108 rTemplateDlg
.EnableFamilyItem( nFamily
, !bDisable
);
111 case SID_STYLE_WATERCAN
:
113 if ( eState
== SFX_ITEM_DISABLED
)
114 nWaterCanState
= 0xff;
115 else if( eState
== SFX_ITEM_AVAILABLE
)
117 const SfxBoolItem
*pStateItem
= PTR_CAST(SfxBoolItem
, pItem
);
118 DBG_ASSERT(pStateItem
!= 0, "BoolItem expected");
119 nWaterCanState
= pStateItem
->GetValue() ? 1 : 0;
121 //not necessary if the last event is still on the way
123 nUserEventId
= Application::PostUserEvent( STATIC_LINK(
124 this, SfxTemplateControllerItem
, SetWaterCanStateHdl_Impl
) );
128 rTemplateDlg
.EnableEdit( SFX_ITEM_DISABLED
!= eState
);
130 case SID_STYLE_DELETE
:
131 rTemplateDlg
.EnableDel( SFX_ITEM_DISABLED
!= eState
);
133 case SID_STYLE_NEW_BY_EXAMPLE
:
135 rTemplateDlg
.EnableExample_Impl(
136 GetId(), SFX_ITEM_DISABLED
!= eState
);
138 case SID_STYLE_UPDATE_BY_EXAMPLE
:
140 rTemplateDlg
.EnableExample_Impl(
141 GetId(), eState
!= SFX_ITEM_DISABLED
);
146 rTemplateDlg
.EnableNew( SFX_ITEM_DISABLED
!= eState
);
149 case SID_STYLE_DRAGHIERARCHIE
:
151 rTemplateDlg
.EnableTreeDrag( SFX_ITEM_DISABLED
!= eState
);
154 case SID_STYLE_FAMILY
:
156 const SfxUInt16Item
*pStateItem
= PTR_CAST( SfxUInt16Item
, pItem
);
158 rTemplateDlg
.SetFamily( pStateItem
->GetValue() );
164 IMPL_STATIC_LINK(SfxTemplateControllerItem
, SetWaterCanStateHdl_Impl
,
165 SfxTemplateControllerItem
*, EMPTYARG
)
167 pThis
->nUserEventId
= 0;
168 SfxBoolItem
* pState
= 0;
169 switch(pThis
->nWaterCanState
)
173 pState
= new SfxBoolItem(SID_STYLE_WATERCAN
, pThis
->nWaterCanState
? sal_True
: sal_False
);
176 pThis
->rTemplateDlg
.SetWaterCanState(pState
);
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */