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/intitem.hxx>
21 #include <vcl/svapp.hxx>
23 #include <sfx2/templdlg.hxx>
24 #include <sfx2/bindings.hxx>
25 #include "sfx2/tplpitem.hxx"
26 #include "tplcitem.hxx"
27 #include "templdgi.hxx"
29 #include <sfx2/sfx.hrc>
32 // STATIC DATA -----------------------------------------------------------
36 SfxTemplateControllerItem::SfxTemplateControllerItem(
37 sal_uInt16 nSlotId
, // ID
38 SfxCommonTemplateDialog_Impl
&rDlg
, // Controller-Instance,
39 // which is assigned to this item.
40 SfxBindings
&rBindings
):
41 SfxControllerItem(nSlotId
, rBindings
),
47 // -----------------------------------------------------------------------
48 SfxTemplateControllerItem::~SfxTemplateControllerItem()
51 Application::RemoveUserEvent(nUserEventId
);
54 // -----------------------------------------------------------------------
55 // Notice about change of status, is propagated through the Controller
56 // passed on by the constructor
58 void SfxTemplateControllerItem::StateChanged( sal_uInt16 nSID
, SfxItemState eState
,
59 const SfxPoolItem
* pItem
)
63 case SID_STYLE_FAMILY1
:
64 case SID_STYLE_FAMILY2
:
65 case SID_STYLE_FAMILY3
:
66 case SID_STYLE_FAMILY4
:
67 case SID_STYLE_FAMILY5
:
69 bool bAvailable
= SFX_ITEM_AVAILABLE
== eState
;
71 rTemplateDlg
.SetFamilyState(GetId(), 0);
73 const SfxTemplateItem
*pStateItem
= PTR_CAST(
74 SfxTemplateItem
, pItem
);
75 DBG_ASSERT(pStateItem
!= 0, "SfxTemplateItem expected");
76 rTemplateDlg
.SetFamilyState( GetId(), pStateItem
);
78 sal_Bool bDisable
= eState
== SFX_ITEM_DISABLED
;
80 sal_uInt16 nFamily
= 0;
83 case SID_STYLE_FAMILY1
:
85 case SID_STYLE_FAMILY2
:
87 case SID_STYLE_FAMILY3
:
89 case SID_STYLE_FAMILY4
:
91 case SID_STYLE_FAMILY5
:
94 default: OSL_FAIL("unknown StyleFamily"); break;
96 rTemplateDlg
.EnableFamilyItem( nFamily
, !bDisable
);
99 case SID_STYLE_WATERCAN
:
101 if ( eState
== SFX_ITEM_DISABLED
)
102 nWaterCanState
= 0xff;
103 else if( eState
== SFX_ITEM_AVAILABLE
)
105 const SfxBoolItem
*pStateItem
= PTR_CAST(SfxBoolItem
, pItem
);
106 DBG_ASSERT(pStateItem
!= 0, "BoolItem expected");
107 nWaterCanState
= pStateItem
->GetValue() ? 1 : 0;
109 //not necessary if the last event is still on the way
111 nUserEventId
= Application::PostUserEvent( STATIC_LINK(
112 this, SfxTemplateControllerItem
, SetWaterCanStateHdl_Impl
) );
116 rTemplateDlg
.EnableEdit( SFX_ITEM_DISABLED
!= eState
);
118 case SID_STYLE_DELETE
:
119 rTemplateDlg
.EnableDel( SFX_ITEM_DISABLED
!= eState
);
122 rTemplateDlg
.EnableHide( SFX_ITEM_DISABLED
!= eState
);
125 rTemplateDlg
.EnableShow( SFX_ITEM_DISABLED
!= eState
);
127 case SID_STYLE_NEW_BY_EXAMPLE
:
129 rTemplateDlg
.EnableExample_Impl(
130 GetId(), SFX_ITEM_DISABLED
!= eState
);
132 case SID_STYLE_UPDATE_BY_EXAMPLE
:
134 rTemplateDlg
.EnableExample_Impl(
135 GetId(), eState
!= SFX_ITEM_DISABLED
);
140 rTemplateDlg
.EnableNew( SFX_ITEM_DISABLED
!= eState
);
143 case SID_STYLE_DRAGHIERARCHIE
:
145 rTemplateDlg
.EnableTreeDrag( SFX_ITEM_DISABLED
!= eState
);
148 case SID_STYLE_FAMILY
:
150 const SfxUInt16Item
*pStateItem
= PTR_CAST( SfxUInt16Item
, pItem
);
152 rTemplateDlg
.SetFamily( pStateItem
->GetValue() );
158 IMPL_STATIC_LINK(SfxTemplateControllerItem
, SetWaterCanStateHdl_Impl
,
159 SfxTemplateControllerItem
*, EMPTYARG
)
161 pThis
->nUserEventId
= 0;
162 SfxBoolItem
* pState
= 0;
163 switch(pThis
->nWaterCanState
)
167 pState
= new SfxBoolItem(SID_STYLE_WATERCAN
, pThis
->nWaterCanState
? sal_True
: sal_False
);
170 pThis
->rTemplateDlg
.SetWaterCanState(pState
);
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */