xref: /trunk/main/cui/source/dialogs/iconcdlg.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_cui.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <sfx2/app.hxx>
32*cdf0e10cSrcweir #include <tools/rc.h>
33*cdf0e10cSrcweir #include <tools/shl.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #define _SVSTDARR_USHORTS
36*cdf0e10cSrcweir #include <svl/svstdarr.hxx>
37*cdf0e10cSrcweir #include <dialmgr.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include "iconcdlg.hxx"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include "helpid.hrc"
42*cdf0e10cSrcweir #include <cuires.hrc>
43*cdf0e10cSrcweir #include <unotools/viewoptions.hxx>
44*cdf0e10cSrcweir #include <svtools/apearcfg.hxx>
45*cdf0e10cSrcweir #include <vcl/mnemonic.hxx>
46*cdf0e10cSrcweir #include <vcl/i18nhelp.hxx>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #ifdef WNT
49*cdf0e10cSrcweir int __cdecl IconcDlgCmpUS_Impl( const void* p1, const void* p2 )
50*cdf0e10cSrcweir #else
51*cdf0e10cSrcweir #if defined(OS2) && defined(ICC)
52*cdf0e10cSrcweir int _Optlink IconcDlgCmpUS_Impl( const void* p1, const void* p2 )
53*cdf0e10cSrcweir #else
54*cdf0e10cSrcweir int IconcDlgCmpUS_Impl( const void* p1, const void* p2 )
55*cdf0e10cSrcweir #endif
56*cdf0e10cSrcweir #endif
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir     return *(sal_uInt16*)p1 - *(sal_uInt16*)p2;
59*cdf0e10cSrcweir }
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir // some stuff for easier changes for SvtViewOptions
62*cdf0e10cSrcweir static const sal_Char*      pViewOptDataName = "dialog data";
63*cdf0e10cSrcweir #define VIEWOPT_DATANAME    ::rtl::OUString::createFromAscii( pViewOptDataName )
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir static inline void SetViewOptUserItem( SvtViewOptions& rOpt, const String& rData )
66*cdf0e10cSrcweir {
67*cdf0e10cSrcweir     rOpt.SetUserItem( VIEWOPT_DATANAME, ::com::sun::star::uno::makeAny( ::rtl::OUString( rData ) ) );
68*cdf0e10cSrcweir }
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir static inline String GetViewOptUserItem( const SvtViewOptions& rOpt )
71*cdf0e10cSrcweir {
72*cdf0e10cSrcweir     ::com::sun::star::uno::Any aAny( rOpt.GetUserItem( VIEWOPT_DATANAME ) );
73*cdf0e10cSrcweir     ::rtl::OUString aUserData;
74*cdf0e10cSrcweir     aAny >>= aUserData;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     return String( aUserData );
77*cdf0e10cSrcweir }
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir //#####################################################################
81*cdf0e10cSrcweir //
82*cdf0e10cSrcweir // Class IconChoicePage
83*cdf0e10cSrcweir //
84*cdf0e10cSrcweir //#####################################################################
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir /**********************************************************************
87*cdf0e10cSrcweir |
88*cdf0e10cSrcweir | Ctor / Dtor
89*cdf0e10cSrcweir |
90*cdf0e10cSrcweir \**********************************************************************/
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir IconChoicePage::IconChoicePage( Window *pParent, const ResId &rResId,
93*cdf0e10cSrcweir                                 const SfxItemSet &rAttrSet )
94*cdf0e10cSrcweir :   TabPage                   ( pParent, rResId ),
95*cdf0e10cSrcweir     pSet                      ( &rAttrSet ),
96*cdf0e10cSrcweir     bHasExchangeSupport       ( sal_False ),
97*cdf0e10cSrcweir     pDialog                   ( NULL ),
98*cdf0e10cSrcweir     bStandard                 ( sal_False )
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir     SetStyle ( GetStyle()  | WB_DIALOGCONTROL | WB_HIDE );
101*cdf0e10cSrcweir }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir // -----------------------------------------------------------------------
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir IconChoicePage::~IconChoicePage()
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir /**********************************************************************
110*cdf0e10cSrcweir |
111*cdf0e10cSrcweir | Activate / Deaktivate
112*cdf0e10cSrcweir |
113*cdf0e10cSrcweir \**********************************************************************/
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir void IconChoicePage::ActivatePage( const SfxItemSet& )
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir }
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir // -----------------------------------------------------------------------
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir int IconChoicePage::DeactivatePage( SfxItemSet* )
122*cdf0e10cSrcweir {
123*cdf0e10cSrcweir     return LEAVE_PAGE;
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir /**********************************************************************
127*cdf0e10cSrcweir |
128*cdf0e10cSrcweir | ...
129*cdf0e10cSrcweir |
130*cdf0e10cSrcweir \**********************************************************************/
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir void IconChoicePage::FillUserData()
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir // -----------------------------------------------------------------------
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir sal_Bool IconChoicePage::IsReadOnly() const
139*cdf0e10cSrcweir {
140*cdf0e10cSrcweir     return sal_False;
141*cdf0e10cSrcweir }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir // -----------------------------------------------------------------------
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir sal_Bool IconChoicePage::QueryClose()
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir     return sal_True;
148*cdf0e10cSrcweir }
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir /**********************************************************************
151*cdf0e10cSrcweir |
152*cdf0e10cSrcweir | window-methods
153*cdf0e10cSrcweir |
154*cdf0e10cSrcweir \**********************************************************************/
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir void IconChoicePage::ImplInitSettings()
157*cdf0e10cSrcweir {
158*cdf0e10cSrcweir     Window* pParent = GetParent();
159*cdf0e10cSrcweir     if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
160*cdf0e10cSrcweir     {
161*cdf0e10cSrcweir         EnableChildTransparentMode( sal_True );
162*cdf0e10cSrcweir         SetParentClipMode( PARENTCLIPMODE_NOCLIP );
163*cdf0e10cSrcweir         SetPaintTransparent( sal_True );
164*cdf0e10cSrcweir         SetBackground();
165*cdf0e10cSrcweir     }
166*cdf0e10cSrcweir     else
167*cdf0e10cSrcweir     {
168*cdf0e10cSrcweir         EnableChildTransparentMode( sal_False );
169*cdf0e10cSrcweir         SetParentClipMode( 0 );
170*cdf0e10cSrcweir         SetPaintTransparent( sal_False );
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir         if ( IsControlBackground() )
173*cdf0e10cSrcweir             SetBackground( GetControlBackground() );
174*cdf0e10cSrcweir         else
175*cdf0e10cSrcweir             SetBackground( pParent->GetBackground() );
176*cdf0e10cSrcweir     }
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir // -----------------------------------------------------------------------
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir void IconChoicePage::StateChanged( StateChangedType nType )
182*cdf0e10cSrcweir {
183*cdf0e10cSrcweir     Window::StateChanged( nType );
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
186*cdf0e10cSrcweir     {
187*cdf0e10cSrcweir         ImplInitSettings();
188*cdf0e10cSrcweir         Invalidate();
189*cdf0e10cSrcweir     }
190*cdf0e10cSrcweir }
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir // -----------------------------------------------------------------------
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir void IconChoicePage::DataChanged( const DataChangedEvent& rDCEvt )
195*cdf0e10cSrcweir {
196*cdf0e10cSrcweir     Window::DataChanged( rDCEvt );
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
199*cdf0e10cSrcweir          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
200*cdf0e10cSrcweir     {
201*cdf0e10cSrcweir         ImplInitSettings();
202*cdf0e10cSrcweir         Invalidate();
203*cdf0e10cSrcweir     }
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir //#####################################################################
207*cdf0e10cSrcweir //
208*cdf0e10cSrcweir // Class IconChoiceDialog
209*cdf0e10cSrcweir //
210*cdf0e10cSrcweir //#####################################################################
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir /**********************************************************************
213*cdf0e10cSrcweir |
214*cdf0e10cSrcweir | Ctor / Dtor
215*cdf0e10cSrcweir |
216*cdf0e10cSrcweir \**********************************************************************/
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir IconChoiceDialog::IconChoiceDialog ( Window* pParent, const ResId &rResId,
219*cdf0e10cSrcweir                                      const EIconChoicePos ePos,
220*cdf0e10cSrcweir                                      const SfxItemSet *pItemSet )//, sal_Bool bEditFmt, const String *pUserButtonText = 0 )
221*cdf0e10cSrcweir :   ModalDialog         ( pParent, rResId ),
222*cdf0e10cSrcweir     meChoicePos     ( ePos ),
223*cdf0e10cSrcweir     maIconCtrl      ( this, WB_3DLOOK | WB_ICON | WB_BORDER |
224*cdf0e10cSrcweir                             WB_NOCOLUMNHEADER | WB_HIGHLIGHTFRAME |
225*cdf0e10cSrcweir                             /* WB_NOSELECTION | */ WB_NODRAGSELECTION | WB_TABSTOP ),
226*cdf0e10cSrcweir     mnCurrentPageId ( USHRT_MAX ),
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir     aOKBtn          ( this, WB_DEFBUTTON ),
229*cdf0e10cSrcweir     aCancelBtn      ( this, WB_DEFBUTTON ),
230*cdf0e10cSrcweir     aHelpBtn        ( this ),
231*cdf0e10cSrcweir     aResetBtn       ( this ),
232*cdf0e10cSrcweir     pSet            ( pItemSet ),
233*cdf0e10cSrcweir     pOutSet         ( NULL ),
234*cdf0e10cSrcweir     pExampleSet     ( NULL ),
235*cdf0e10cSrcweir     pRanges         ( NULL ),
236*cdf0e10cSrcweir     nResId          ( rResId.GetId() ),
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir     bHideResetBtn   ( sal_False ),
239*cdf0e10cSrcweir     bModal          ( sal_False ),
240*cdf0e10cSrcweir     bInOK           ( sal_False ),
241*cdf0e10cSrcweir     bModified       ( sal_False ),
242*cdf0e10cSrcweir     bItemsReset     ( sal_False )
243*cdf0e10cSrcweir {
244*cdf0e10cSrcweir     // IconChoiceCtrl-Settings
245*cdf0e10cSrcweir     //maIconCtrl.SetBackground ( Wallpaper( Color (146, 146, 186) ) );
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir     maIconCtrl.SetStyle (WB_3DLOOK | WB_ICON | WB_BORDER | WB_NOCOLUMNHEADER | WB_HIGHLIGHTFRAME | /* WB_NOSELECTION | */ WB_NODRAGSELECTION | WB_TABSTOP | WB_CLIPCHILDREN );
248*cdf0e10cSrcweir     SetCtrlPos ( meChoicePos );
249*cdf0e10cSrcweir     maIconCtrl.SetClickHdl ( LINK ( this, IconChoiceDialog , ChosePageHdl_Impl ) );
250*cdf0e10cSrcweir     maIconCtrl.Show();
251*cdf0e10cSrcweir     maIconCtrl.SetChoiceWithCursor ( sal_True );
252*cdf0e10cSrcweir     maIconCtrl.SetSelectionMode( SINGLE_SELECTION );
253*cdf0e10cSrcweir     maIconCtrl.SetHelpId( HID_ICCDIALOG_CHOICECTRL );
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     // ItemSet
256*cdf0e10cSrcweir     if ( pSet )
257*cdf0e10cSrcweir     {
258*cdf0e10cSrcweir         pExampleSet = new SfxItemSet( *pSet );
259*cdf0e10cSrcweir         pOutSet = new SfxItemSet( *pSet->GetPool(), pSet->GetRanges() );
260*cdf0e10cSrcweir     }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir     // Buttons
263*cdf0e10cSrcweir     aOKBtn.SetClickHdl   ( LINK( this, IconChoiceDialog, OkHdl ) );
264*cdf0e10cSrcweir     aOKBtn.SetHelpId( HID_ICCDIALOG_OK_BTN );
265*cdf0e10cSrcweir     aCancelBtn.SetHelpId( HID_ICCDIALOG_CANCEL_BTN );
266*cdf0e10cSrcweir     aResetBtn.SetClickHdl( LINK( this, IconChoiceDialog, ResetHdl ) );
267*cdf0e10cSrcweir     aResetBtn.SetText( CUI_RESSTR(RID_SVXSTR_ICONCHOICEDLG_RESETBUT) );
268*cdf0e10cSrcweir     aResetBtn.SetHelpId( HID_ICCDIALOG_RESET_BTN );
269*cdf0e10cSrcweir     aOKBtn.Show();
270*cdf0e10cSrcweir     aCancelBtn.Show();
271*cdf0e10cSrcweir     aHelpBtn.Show();
272*cdf0e10cSrcweir     aResetBtn.Show();
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir     SetPosSizeCtrls ( sal_True );
275*cdf0e10cSrcweir }
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir // -----------------------------------------------------------------------
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir /*
280*cdf0e10cSrcweir IconChoiceDialog ::IconChoiceDialog ( SfxViewFrame *pViewFrame, Window* pParent, const ResId &rResId,
281*cdf0e10cSrcweir                    const SfxItemSet * = 0, sal_Bool bEditFmt = sal_False,
282*cdf0e10cSrcweir                    const String *pUserButtonText = 0 )
283*cdf0e10cSrcweir :   meChoicePos     ( PosLeft ),    // Default erst ma Links
284*cdf0e10cSrcweir     maIconCtrl      ( this, Die_Winbits ),
285*cdf0e10cSrcweir     aOKBtn          ( this ),
286*cdf0e10cSrcweir     pUserBtn        ( pUserButtonText? new PushButton(this): 0 ),
287*cdf0e10cSrcweir     aCancelBtn      ( this ),
288*cdf0e10cSrcweir     aHelpBtn        ( this ),
289*cdf0e10cSrcweir     aResetBtn       ( this ),
290*cdf0e10cSrcweir     aBaseFmtBtn     ( this ),
291*cdf0e10cSrcweir     mnCurrentPageId ( 0 )
292*cdf0e10cSrcweir {
293*cdf0e10cSrcweir     FreeResource();
294*cdf0e10cSrcweir }
295*cdf0e10cSrcweir */
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir // -----------------------------------------------------------------------
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir IconChoiceDialog ::~IconChoiceDialog ()
300*cdf0e10cSrcweir {
301*cdf0e10cSrcweir     sal_uLong i;
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir     // save configuration at INI-Manager
304*cdf0e10cSrcweir     // and remove pages
305*cdf0e10cSrcweir     SvtViewOptions aTabDlgOpt( E_TABDIALOG, String::CreateFromInt32( nResId ) );
306*cdf0e10cSrcweir     aTabDlgOpt.SetWindowState( ::rtl::OUString::createFromAscii( GetWindowState((WINDOWSTATE_MASK_X | WINDOWSTATE_MASK_Y | WINDOWSTATE_MASK_STATE | WINDOWSTATE_MASK_MINIMIZED)).GetBuffer() ) );
307*cdf0e10cSrcweir     aTabDlgOpt.SetPageID( mnCurrentPageId );
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir     const sal_uLong nCount = maPageList.Count();
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir     for ( i = 0; i < nCount; ++i )
312*cdf0e10cSrcweir     {
313*cdf0e10cSrcweir         IconChoicePageData* pData = maPageList.GetObject(i);
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir         if ( pData->pPage )
316*cdf0e10cSrcweir         {
317*cdf0e10cSrcweir             pData->pPage->FillUserData();
318*cdf0e10cSrcweir             String aPageData(pData->pPage->GetUserData());
319*cdf0e10cSrcweir             if ( aPageData.Len() )
320*cdf0e10cSrcweir             {
321*cdf0e10cSrcweir                 SvtViewOptions aTabPageOpt( E_TABPAGE, String::CreateFromInt32( pData->nId ) );
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir                 SetViewOptUserItem( aTabPageOpt, aPageData );
324*cdf0e10cSrcweir             }
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir             if ( pData->bOnDemand )
327*cdf0e10cSrcweir                 delete (SfxItemSet*)&pData->pPage->GetItemSet();
328*cdf0e10cSrcweir             delete pData->pPage;
329*cdf0e10cSrcweir         }
330*cdf0e10cSrcweir         delete pData;
331*cdf0e10cSrcweir     }
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir     // remove Userdata from Icons
334*cdf0e10cSrcweir     for ( i=0; i<maIconCtrl.GetEntryCount(); i++)
335*cdf0e10cSrcweir     {
336*cdf0e10cSrcweir         SvxIconChoiceCtrlEntry* pEntry = maIconCtrl.GetEntry ( i );
337*cdf0e10cSrcweir         sal_uInt16* pUserData = (sal_uInt16*) pEntry->GetUserData();
338*cdf0e10cSrcweir         delete pUserData;
339*cdf0e10cSrcweir     }
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir     //
342*cdf0e10cSrcweir     if ( pRanges )
343*cdf0e10cSrcweir         delete pRanges;
344*cdf0e10cSrcweir     if ( pOutSet )
345*cdf0e10cSrcweir         delete pOutSet;
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir /**********************************************************************
349*cdf0e10cSrcweir |
350*cdf0e10cSrcweir | add new page
351*cdf0e10cSrcweir |
352*cdf0e10cSrcweir \**********************************************************************/
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* IconChoiceDialog::AddTabPage( sal_uInt16 nId, const String& rIconText,
355*cdf0e10cSrcweir                                    const Image& rChoiceIcon,
356*cdf0e10cSrcweir                                    const Image& rChoiceIconHC,
357*cdf0e10cSrcweir                                    CreatePage pCreateFunc /* != 0 */,
358*cdf0e10cSrcweir                                    GetPageRanges pRangesFunc /* darf 0 sein */,
359*cdf0e10cSrcweir                                    sal_Bool bItemsOnDemand, sal_uLong /*nPos*/ )
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir     IconChoicePageData* pData = new IconChoicePageData ( nId, pCreateFunc,
362*cdf0e10cSrcweir                                                          pRangesFunc,
363*cdf0e10cSrcweir                                                          bItemsOnDemand );
364*cdf0e10cSrcweir     maPageList.Insert ( pData, LIST_APPEND );
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir     pData->fnGetRanges = pRangesFunc;
367*cdf0e10cSrcweir     pData->bOnDemand = bItemsOnDemand;
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir     sal_uInt16 *pId = new sal_uInt16 ( nId );
370*cdf0e10cSrcweir     SvxIconChoiceCtrlEntry* pEntry = maIconCtrl.InsertEntry( rIconText, rChoiceIcon, rChoiceIconHC );
371*cdf0e10cSrcweir     pEntry->SetUserData ( (void*) pId );
372*cdf0e10cSrcweir     return pEntry;
373*cdf0e10cSrcweir }
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir /**********************************************************************
376*cdf0e10cSrcweir |
377*cdf0e10cSrcweir | Paint-method
378*cdf0e10cSrcweir |
379*cdf0e10cSrcweir \**********************************************************************/
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir void IconChoiceDialog::Paint( const Rectangle& rRect )
382*cdf0e10cSrcweir {
383*cdf0e10cSrcweir     Dialog::Paint ( rRect );
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir     for ( sal_uLong i=0; i<maPageList.Count(); i++ )
386*cdf0e10cSrcweir     {
387*cdf0e10cSrcweir         IconChoicePageData* pData = (IconChoicePageData*)maPageList.GetObject ( i );
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir         if ( pData->nId == mnCurrentPageId )
390*cdf0e10cSrcweir         {
391*cdf0e10cSrcweir             ShowPageImpl ( pData );
392*cdf0e10cSrcweir         }
393*cdf0e10cSrcweir         else
394*cdf0e10cSrcweir         {
395*cdf0e10cSrcweir             HidePageImpl ( pData );
396*cdf0e10cSrcweir         }
397*cdf0e10cSrcweir     }
398*cdf0e10cSrcweir }
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir EIconChoicePos IconChoiceDialog::SetCtrlPos( const EIconChoicePos& rPos )
401*cdf0e10cSrcweir {
402*cdf0e10cSrcweir     WinBits aWinBits = maIconCtrl.GetStyle ();
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir     switch ( meChoicePos )
405*cdf0e10cSrcweir     {
406*cdf0e10cSrcweir         case PosLeft :
407*cdf0e10cSrcweir             aWinBits &= ~WB_ALIGN_TOP & ~WB_NOVSCROLL;
408*cdf0e10cSrcweir             aWinBits |= WB_ALIGN_LEFT | WB_NOHSCROLL;
409*cdf0e10cSrcweir             break;
410*cdf0e10cSrcweir         case PosRight :
411*cdf0e10cSrcweir             aWinBits &= ~WB_ALIGN_TOP & ~WB_NOVSCROLL;
412*cdf0e10cSrcweir             aWinBits |= WB_ALIGN_LEFT | WB_NOHSCROLL;
413*cdf0e10cSrcweir             break;
414*cdf0e10cSrcweir         case PosTop :
415*cdf0e10cSrcweir             aWinBits &= ~WB_ALIGN_LEFT & ~WB_NOHSCROLL;
416*cdf0e10cSrcweir             aWinBits |= WB_ALIGN_TOP | WB_NOVSCROLL;
417*cdf0e10cSrcweir             break;
418*cdf0e10cSrcweir         case PosBottom :
419*cdf0e10cSrcweir             aWinBits &= ~WB_ALIGN_LEFT & ~WB_NOHSCROLL;
420*cdf0e10cSrcweir             aWinBits |= WB_ALIGN_TOP | WB_NOVSCROLL;
421*cdf0e10cSrcweir             break;
422*cdf0e10cSrcweir     };
423*cdf0e10cSrcweir     maIconCtrl.SetStyle ( aWinBits );
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir     SetPosSizeCtrls();
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir     EIconChoicePos eOldPos = meChoicePos;
429*cdf0e10cSrcweir     meChoicePos = rPos;
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir     return eOldPos;
432*cdf0e10cSrcweir }
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir /**********************************************************************
435*cdf0e10cSrcweir |
436*cdf0e10cSrcweir | Show / Hide page or button
437*cdf0e10cSrcweir |
438*cdf0e10cSrcweir \**********************************************************************/
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir void IconChoiceDialog::ShowPageImpl ( IconChoicePageData* pData )
441*cdf0e10cSrcweir {
442*cdf0e10cSrcweir     if ( pData->pPage )
443*cdf0e10cSrcweir         pData->pPage->Show();
444*cdf0e10cSrcweir }
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir // -----------------------------------------------------------------------
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir void IconChoiceDialog::HidePageImpl ( IconChoicePageData* pData )
449*cdf0e10cSrcweir {
450*cdf0e10cSrcweir     if ( pData->pPage )
451*cdf0e10cSrcweir         pData->pPage->Hide();
452*cdf0e10cSrcweir }
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir // -----------------------------------------------------------------------
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir void IconChoiceDialog::ShowPage( sal_uInt16 nId )
457*cdf0e10cSrcweir {
458*cdf0e10cSrcweir     bool bInvalidate = GetCurPageId() != nId;
459*cdf0e10cSrcweir     SetCurPageId( nId );
460*cdf0e10cSrcweir     ActivatePageImpl( );
461*cdf0e10cSrcweir     if(bInvalidate)
462*cdf0e10cSrcweir         Invalidate();
463*cdf0e10cSrcweir }
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir /**********************************************************************
466*cdf0e10cSrcweir |
467*cdf0e10cSrcweir | Resize Dialog
468*cdf0e10cSrcweir |
469*cdf0e10cSrcweir \**********************************************************************/
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir #define ICONCTRL_WIDTH_PIXEL       110
472*cdf0e10cSrcweir #define ICONCTRL_HEIGHT_PIXEL       75
473*cdf0e10cSrcweir #define MINSIZE_BUTTON_WIDTH        70
474*cdf0e10cSrcweir #define MINSIZE_BUTTON_HEIGHT       22
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir void IconChoiceDialog::Resize()
477*cdf0e10cSrcweir {
478*cdf0e10cSrcweir     Dialog::Resize ();
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir     if ( IsReallyVisible() )
481*cdf0e10cSrcweir     {
482*cdf0e10cSrcweir         SetPosSizeCtrls ();
483*cdf0e10cSrcweir     }
484*cdf0e10cSrcweir }
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir void IconChoiceDialog::SetPosSizeCtrls ( sal_Bool bInit )
487*cdf0e10cSrcweir {
488*cdf0e10cSrcweir     const Point aCtrlOffset ( LogicToPixel( Point( CTRLS_OFFSET, CTRLS_OFFSET ), MAP_APPFONT ) );
489*cdf0e10cSrcweir     Size aOutSize ( GetOutputSizePixel() );
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir     ////////////////////////////////////////
492*cdf0e10cSrcweir     // Button-Defaults
493*cdf0e10cSrcweir     //
494*cdf0e10cSrcweir     Size aDefaultButtonSize = LogicToPixel( Size( 50, 14 ), MAP_APPFONT );
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir     // Reset-Button
497*cdf0e10cSrcweir     Size aResetButtonSize ( bInit ? aDefaultButtonSize :
498*cdf0e10cSrcweir                                     aResetBtn.GetSizePixel () );
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir     ////////////////////////////////////////
501*cdf0e10cSrcweir     // IconChoiceCtrl resizen & positionieren
502*cdf0e10cSrcweir     //
503*cdf0e10cSrcweir     SvtTabAppearanceCfg aCfg;
504*cdf0e10cSrcweir     const long nDefaultWidth = (aCfg.GetScaleFactor() * ICONCTRL_WIDTH_PIXEL) / 100;
505*cdf0e10cSrcweir     const long nDefaultHeight = (aCfg.GetScaleFactor() * ICONCTRL_HEIGHT_PIXEL) / 100;
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir     Size aNewIconCtrlSize  ( nDefaultWidth,
508*cdf0e10cSrcweir                              aOutSize.Height()-(2*aCtrlOffset.X()) );
509*cdf0e10cSrcweir     Point aIconCtrlPos;
510*cdf0e10cSrcweir     switch ( meChoicePos )
511*cdf0e10cSrcweir     {
512*cdf0e10cSrcweir         case PosLeft :
513*cdf0e10cSrcweir             aIconCtrlPos = aCtrlOffset;
514*cdf0e10cSrcweir             aNewIconCtrlSize = Size ( nDefaultWidth,
515*cdf0e10cSrcweir                                       aOutSize.Height()-(2*aCtrlOffset.X()) );
516*cdf0e10cSrcweir             break;
517*cdf0e10cSrcweir         case PosRight :
518*cdf0e10cSrcweir             aIconCtrlPos = Point ( aOutSize.Width() - nDefaultWidth -
519*cdf0e10cSrcweir                                    aCtrlOffset.X(), aCtrlOffset.X() );
520*cdf0e10cSrcweir             aNewIconCtrlSize = Size ( nDefaultWidth,
521*cdf0e10cSrcweir                                       aOutSize.Height()-(2*aCtrlOffset.X()) );
522*cdf0e10cSrcweir             break;
523*cdf0e10cSrcweir         case PosTop :
524*cdf0e10cSrcweir             aIconCtrlPos = aCtrlOffset;
525*cdf0e10cSrcweir             aNewIconCtrlSize = Size ( aOutSize.Width()-(2*aCtrlOffset.X()),
526*cdf0e10cSrcweir                                       nDefaultHeight );
527*cdf0e10cSrcweir             break;
528*cdf0e10cSrcweir         case PosBottom :
529*cdf0e10cSrcweir             aIconCtrlPos = Point ( aCtrlOffset.X(), aOutSize.Height() -
530*cdf0e10cSrcweir                                    aResetButtonSize.Height() - (2*aCtrlOffset.X()) -
531*cdf0e10cSrcweir                                    nDefaultHeight );
532*cdf0e10cSrcweir             aNewIconCtrlSize = Size ( aOutSize.Width()-(2*aCtrlOffset.X()),
533*cdf0e10cSrcweir                                       nDefaultHeight );
534*cdf0e10cSrcweir             break;
535*cdf0e10cSrcweir     };
536*cdf0e10cSrcweir     maIconCtrl.SetPosSizePixel ( aIconCtrlPos, aNewIconCtrlSize );
537*cdf0e10cSrcweir     maIconCtrl.ArrangeIcons();
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir     ////////////////////////////////////////
540*cdf0e10cSrcweir     // Pages resizen & positionieren
541*cdf0e10cSrcweir     //
542*cdf0e10cSrcweir     for ( sal_uLong i=0; i<maPageList.Count(); i++ )
543*cdf0e10cSrcweir     {
544*cdf0e10cSrcweir         IconChoicePageData* pData = (IconChoicePageData*)maPageList.GetObject ( i );
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir         Point aNewPagePos;
547*cdf0e10cSrcweir         Size aNewPageSize;
548*cdf0e10cSrcweir         switch ( meChoicePos )
549*cdf0e10cSrcweir         {
550*cdf0e10cSrcweir             case PosLeft :
551*cdf0e10cSrcweir                 aNewPagePos = Point ( aNewIconCtrlSize.Width() + (2*CTRLS_OFFSET),
552*cdf0e10cSrcweir                                       CTRLS_OFFSET );
553*cdf0e10cSrcweir                 aNewPageSize = Size ( aOutSize.Width() - aNewIconCtrlSize.Width() -
554*cdf0e10cSrcweir                                       (3*CTRLS_OFFSET),
555*cdf0e10cSrcweir                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
556*cdf0e10cSrcweir                                       (3*CTRLS_OFFSET) );
557*cdf0e10cSrcweir                 break;
558*cdf0e10cSrcweir             case PosRight :
559*cdf0e10cSrcweir                 aNewPagePos = aCtrlOffset;
560*cdf0e10cSrcweir                 aNewPageSize = Size ( aOutSize.Width() - aNewIconCtrlSize.Width() -
561*cdf0e10cSrcweir                                       (3*aCtrlOffset.X()),
562*cdf0e10cSrcweir                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
563*cdf0e10cSrcweir                                       (3*aCtrlOffset.X()) );
564*cdf0e10cSrcweir                 break;
565*cdf0e10cSrcweir             case PosTop :
566*cdf0e10cSrcweir                 aNewPagePos = Point ( aCtrlOffset.X(), aNewIconCtrlSize.Height() +
567*cdf0e10cSrcweir                                       (2*aCtrlOffset.X()) );
568*cdf0e10cSrcweir                 aNewPageSize = Size ( aOutSize.Width() - (2*aCtrlOffset.X()),
569*cdf0e10cSrcweir                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
570*cdf0e10cSrcweir                                       aNewIconCtrlSize.Height() - (4*aCtrlOffset.X()) );
571*cdf0e10cSrcweir                 break;
572*cdf0e10cSrcweir             case PosBottom :
573*cdf0e10cSrcweir                 aNewPagePos = aCtrlOffset;
574*cdf0e10cSrcweir                 aNewPageSize = Size ( aOutSize.Width() - (2*aCtrlOffset.X()),
575*cdf0e10cSrcweir                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
576*cdf0e10cSrcweir                                       aNewIconCtrlSize.Height() - (4*aCtrlOffset.X()) );
577*cdf0e10cSrcweir                 break;
578*cdf0e10cSrcweir         };
579*cdf0e10cSrcweir 
580*cdf0e10cSrcweir         if ( pData->pPage )
581*cdf0e10cSrcweir             pData->pPage->SetPosSizePixel ( aNewPagePos, aNewPageSize );
582*cdf0e10cSrcweir     }
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir     ////////////////////////////////////////
585*cdf0e10cSrcweir     // Buttons positionieren
586*cdf0e10cSrcweir     //
587*cdf0e10cSrcweir     sal_uLong nXOffset=0;
588*cdf0e10cSrcweir     if ( meChoicePos == PosRight )
589*cdf0e10cSrcweir         nXOffset = aNewIconCtrlSize.Width()+(2*aCtrlOffset.X());
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir     aResetBtn.SetPosSizePixel ( Point( aOutSize.Width() - nXOffset -
592*cdf0e10cSrcweir                                        aResetButtonSize.Width()-aCtrlOffset.X(),
593*cdf0e10cSrcweir                                        aOutSize.Height()-aResetButtonSize.Height()-
594*cdf0e10cSrcweir                                        aCtrlOffset.X() ),
595*cdf0e10cSrcweir                                aResetButtonSize );
596*cdf0e10cSrcweir     // Help-Button
597*cdf0e10cSrcweir     Size aHelpButtonSize ( bInit ? aDefaultButtonSize :
598*cdf0e10cSrcweir                                    aHelpBtn.GetSizePixel () );
599*cdf0e10cSrcweir     aHelpBtn.SetPosSizePixel ( Point( aOutSize.Width()-aResetButtonSize.Width()-
600*cdf0e10cSrcweir                                       aHelpButtonSize.Width()- nXOffset -
601*cdf0e10cSrcweir                                       (2*aCtrlOffset.X()),
602*cdf0e10cSrcweir                                       aOutSize.Height()-aHelpButtonSize.Height()-
603*cdf0e10cSrcweir                                       aCtrlOffset.X() ),
604*cdf0e10cSrcweir                                aHelpButtonSize );
605*cdf0e10cSrcweir     // Cancel-Button
606*cdf0e10cSrcweir     Size aCancelButtonSize ( bInit ? aDefaultButtonSize :
607*cdf0e10cSrcweir                                      aCancelBtn.GetSizePixel () );
608*cdf0e10cSrcweir     aCancelBtn.SetPosSizePixel ( Point( aOutSize.Width()-aCancelButtonSize.Width()-
609*cdf0e10cSrcweir                                         aResetButtonSize.Width()-aHelpButtonSize.Width()-
610*cdf0e10cSrcweir                                         (3*aCtrlOffset.X()) -  nXOffset,
611*cdf0e10cSrcweir                                         aOutSize.Height()-aCancelButtonSize.Height()-
612*cdf0e10cSrcweir                                         aCtrlOffset.X() ),
613*cdf0e10cSrcweir                                 aCancelButtonSize );
614*cdf0e10cSrcweir     // OK-Button
615*cdf0e10cSrcweir     Size aOKButtonSize ( bInit ? aDefaultButtonSize : aOKBtn.GetSizePixel () );
616*cdf0e10cSrcweir     aOKBtn.SetPosSizePixel ( Point( aOutSize.Width()-aOKButtonSize.Width()-
617*cdf0e10cSrcweir                                     aCancelButtonSize.Width()-aResetButtonSize.Width()-
618*cdf0e10cSrcweir                                     aHelpButtonSize.Width()-(4*aCtrlOffset.X())-  nXOffset,
619*cdf0e10cSrcweir                                     aOutSize.Height()-aOKButtonSize.Height()-aCtrlOffset.X() ),
620*cdf0e10cSrcweir                             aOKButtonSize );
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir     Invalidate();
623*cdf0e10cSrcweir }
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir void IconChoiceDialog::SetPosSizePages ( sal_uInt16 nId )
626*cdf0e10cSrcweir {
627*cdf0e10cSrcweir     const Point aCtrlOffset ( LogicToPixel( Point( CTRLS_OFFSET, CTRLS_OFFSET ), MAP_APPFONT ) );
628*cdf0e10cSrcweir     IconChoicePageData* pData = GetPageData ( nId );
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir     if ( pData->pPage )
631*cdf0e10cSrcweir     {
632*cdf0e10cSrcweir         Size aOutSize ( GetOutputSizePixel() );
633*cdf0e10cSrcweir         Size aIconCtrlSize ( maIconCtrl.GetSizePixel() );
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir         Point aNewPagePos;
636*cdf0e10cSrcweir         Size aNewPageSize;
637*cdf0e10cSrcweir         switch ( meChoicePos )
638*cdf0e10cSrcweir         {
639*cdf0e10cSrcweir             case PosLeft :
640*cdf0e10cSrcweir                 aNewPagePos = Point ( aIconCtrlSize.Width() + (2*aCtrlOffset.X()),
641*cdf0e10cSrcweir                                       aCtrlOffset.X() );
642*cdf0e10cSrcweir                 aNewPageSize = Size ( aOutSize.Width() - maIconCtrl.GetSizePixel().Width() -
643*cdf0e10cSrcweir                                       (3*aCtrlOffset.X()),
644*cdf0e10cSrcweir                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
645*cdf0e10cSrcweir                                       (3*aCtrlOffset.X()) );
646*cdf0e10cSrcweir                 break;
647*cdf0e10cSrcweir             case PosRight :
648*cdf0e10cSrcweir                 aNewPagePos = aCtrlOffset;
649*cdf0e10cSrcweir                 aNewPageSize = Size ( aOutSize.Width() - maIconCtrl.GetSizePixel().Width() -
650*cdf0e10cSrcweir                                       (3*aCtrlOffset.X()),
651*cdf0e10cSrcweir                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
652*cdf0e10cSrcweir                                       (3*aCtrlOffset.X()) );
653*cdf0e10cSrcweir                 break;
654*cdf0e10cSrcweir             case PosTop :
655*cdf0e10cSrcweir                 aNewPagePos = Point ( aCtrlOffset.X(), aIconCtrlSize.Height() +
656*cdf0e10cSrcweir                                       (2*aCtrlOffset.X()) );
657*cdf0e10cSrcweir                 aNewPageSize = Size ( aOutSize.Width() - (2*aCtrlOffset.X()),
658*cdf0e10cSrcweir                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
659*cdf0e10cSrcweir                                       maIconCtrl.GetSizePixel().Height() - (4*aCtrlOffset.X()) );
660*cdf0e10cSrcweir                 break;
661*cdf0e10cSrcweir             case PosBottom :
662*cdf0e10cSrcweir                 aNewPagePos = aCtrlOffset;
663*cdf0e10cSrcweir                 aNewPageSize = Size ( aOutSize.Width() - (2*aCtrlOffset.X()),
664*cdf0e10cSrcweir                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
665*cdf0e10cSrcweir                                       maIconCtrl.GetSizePixel().Height() - (4*aCtrlOffset.X()) );
666*cdf0e10cSrcweir                 break;
667*cdf0e10cSrcweir         };
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir         pData->pPage->SetPosSizePixel ( aNewPagePos, aNewPageSize );
670*cdf0e10cSrcweir     }
671*cdf0e10cSrcweir }
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir /**********************************************************************
674*cdf0e10cSrcweir |
675*cdf0e10cSrcweir | select a page
676*cdf0e10cSrcweir |
677*cdf0e10cSrcweir \**********************************************************************/
678*cdf0e10cSrcweir 
679*cdf0e10cSrcweir IMPL_LINK ( IconChoiceDialog , ChosePageHdl_Impl, void *, EMPTYARG )
680*cdf0e10cSrcweir {
681*cdf0e10cSrcweir     sal_uLong nPos;
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir     SvxIconChoiceCtrlEntry *pEntry = maIconCtrl.GetSelectedEntry ( nPos );
684*cdf0e10cSrcweir     if ( !pEntry )
685*cdf0e10cSrcweir         pEntry = maIconCtrl.GetCursor( );
686*cdf0e10cSrcweir 
687*cdf0e10cSrcweir     sal_uInt16 *pId = (sal_uInt16*)pEntry->GetUserData ();
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir     if( *pId != mnCurrentPageId )
690*cdf0e10cSrcweir     {
691*cdf0e10cSrcweir         IconChoicePageData* pData = GetPageData ( mnCurrentPageId );
692*cdf0e10cSrcweir         if ( pData->pPage )
693*cdf0e10cSrcweir             DeActivatePageImpl();
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir         SetCurPageId ( *pId );
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir         ActivatePageImpl();
698*cdf0e10cSrcweir         Invalidate();
699*cdf0e10cSrcweir     }
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir     return 0L;
702*cdf0e10cSrcweir }
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir /**********************************************************************
705*cdf0e10cSrcweir |
706*cdf0e10cSrcweir | Button-handler
707*cdf0e10cSrcweir |
708*cdf0e10cSrcweir \**********************************************************************/
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir IMPL_LINK( IconChoiceDialog, OkHdl, Button *, EMPTYARG )
711*cdf0e10cSrcweir {
712*cdf0e10cSrcweir     bInOK = sal_True;
713*cdf0e10cSrcweir 
714*cdf0e10cSrcweir     if ( OK_Impl() )
715*cdf0e10cSrcweir     {
716*cdf0e10cSrcweir         if ( bModal )
717*cdf0e10cSrcweir             EndDialog( Ok() );
718*cdf0e10cSrcweir         else
719*cdf0e10cSrcweir         {
720*cdf0e10cSrcweir             Ok();
721*cdf0e10cSrcweir             Close();
722*cdf0e10cSrcweir         }
723*cdf0e10cSrcweir     }
724*cdf0e10cSrcweir     return 0;
725*cdf0e10cSrcweir }
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir // -----------------------------------------------------------------------
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir IMPL_LINK( IconChoiceDialog, ResetHdl, Button *, EMPTYARG )
730*cdf0e10cSrcweir {
731*cdf0e10cSrcweir     ResetPageImpl ();
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir     IconChoicePageData* pData = GetPageData ( mnCurrentPageId );
734*cdf0e10cSrcweir     DBG_ASSERT( pData, "Id nicht bekannt" );
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir     if ( pData->bOnDemand )
737*cdf0e10cSrcweir     {
738*cdf0e10cSrcweir         // CSet auf AIS hat hier Probleme, daher getrennt
739*cdf0e10cSrcweir         const SfxItemSet* _pSet = &( pData->pPage->GetItemSet() );
740*cdf0e10cSrcweir         pData->pPage->Reset( *(SfxItemSet*)_pSet );
741*cdf0e10cSrcweir     }
742*cdf0e10cSrcweir     else
743*cdf0e10cSrcweir         pData->pPage->Reset( *pSet );
744*cdf0e10cSrcweir 
745*cdf0e10cSrcweir 
746*cdf0e10cSrcweir     return 0;
747*cdf0e10cSrcweir }
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir // -----------------------------------------------------------------------
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir IMPL_LINK( IconChoiceDialog, CancelHdl, Button*, EMPTYARG )
752*cdf0e10cSrcweir {
753*cdf0e10cSrcweir     Close();
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir     return 0;
756*cdf0e10cSrcweir }
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir /**********************************************************************
759*cdf0e10cSrcweir |
760*cdf0e10cSrcweir | call page
761*cdf0e10cSrcweir |
762*cdf0e10cSrcweir \**********************************************************************/
763*cdf0e10cSrcweir 
764*cdf0e10cSrcweir void IconChoiceDialog::ActivatePageImpl ()
765*cdf0e10cSrcweir {
766*cdf0e10cSrcweir     DBG_ASSERT( maPageList.Count(), "keine Pages angemeldet" );
767*cdf0e10cSrcweir     IconChoicePageData* pData = GetPageData ( mnCurrentPageId );
768*cdf0e10cSrcweir     DBG_ASSERT( pData, "Id nicht bekannt" );
769*cdf0e10cSrcweir     if ( pData )
770*cdf0e10cSrcweir     {
771*cdf0e10cSrcweir         if ( !pData->pPage )
772*cdf0e10cSrcweir         {
773*cdf0e10cSrcweir             const SfxItemSet* pTmpSet = 0;
774*cdf0e10cSrcweir 
775*cdf0e10cSrcweir             if ( pSet )
776*cdf0e10cSrcweir             {
777*cdf0e10cSrcweir                 if ( bItemsReset && pSet->GetParent() )
778*cdf0e10cSrcweir                     pTmpSet = pSet->GetParent();
779*cdf0e10cSrcweir                 else
780*cdf0e10cSrcweir                     pTmpSet = pSet;
781*cdf0e10cSrcweir             }
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir             if ( pTmpSet && !pData->bOnDemand )
784*cdf0e10cSrcweir                 pData->pPage = (pData->fnCreatePage)( this, *pTmpSet );
785*cdf0e10cSrcweir             else
786*cdf0e10cSrcweir                 pData->pPage = (pData->fnCreatePage)( this, *CreateInputItemSet( mnCurrentPageId ) );
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir             SvtViewOptions aTabPageOpt( E_TABPAGE, String::CreateFromInt32( pData->nId ) );
789*cdf0e10cSrcweir             pData->pPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) );
790*cdf0e10cSrcweir             SetPosSizePages ( pData->nId );
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir             if ( pData->bOnDemand )
793*cdf0e10cSrcweir                 pData->pPage->Reset( (SfxItemSet &)pData->pPage->GetItemSet() );
794*cdf0e10cSrcweir             else
795*cdf0e10cSrcweir                 pData->pPage->Reset( *pSet );
796*cdf0e10cSrcweir 
797*cdf0e10cSrcweir             PageCreated( mnCurrentPageId, *pData->pPage );
798*cdf0e10cSrcweir         }
799*cdf0e10cSrcweir         else if ( pData->bRefresh )
800*cdf0e10cSrcweir         {
801*cdf0e10cSrcweir             pData->pPage->Reset( *pSet );
802*cdf0e10cSrcweir         }
803*cdf0e10cSrcweir 
804*cdf0e10cSrcweir         pData->bRefresh = sal_False;
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir         if ( pExampleSet )
807*cdf0e10cSrcweir             pData->pPage->ActivatePage( *pExampleSet );
808*cdf0e10cSrcweir     }
809*cdf0e10cSrcweir 
810*cdf0e10cSrcweir     SetHelpId( pData->pPage->GetHelpId() );
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir     sal_Bool bReadOnly = pData->pPage->IsReadOnly();
813*cdf0e10cSrcweir     if ( bReadOnly || bHideResetBtn )
814*cdf0e10cSrcweir         aResetBtn.Hide();
815*cdf0e10cSrcweir     else
816*cdf0e10cSrcweir         aResetBtn.Show();
817*cdf0e10cSrcweir 
818*cdf0e10cSrcweir }
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir // -----------------------------------------------------------------------
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir sal_Bool IconChoiceDialog::DeActivatePageImpl ()
823*cdf0e10cSrcweir {
824*cdf0e10cSrcweir     IconChoicePageData *pData = GetPageData ( mnCurrentPageId );
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir     int nRet = IconChoicePage::LEAVE_PAGE;
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir     if ( pData )
829*cdf0e10cSrcweir     {
830*cdf0e10cSrcweir         IconChoicePage * pPage = pData->pPage;
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir         if ( !pExampleSet && pPage->HasExchangeSupport() && pSet )
833*cdf0e10cSrcweir             pExampleSet = new SfxItemSet( *pSet->GetPool(), pSet->GetRanges() );
834*cdf0e10cSrcweir 
835*cdf0e10cSrcweir         if ( pSet )
836*cdf0e10cSrcweir         {
837*cdf0e10cSrcweir             SfxItemSet aTmp( *pSet->GetPool(), pSet->GetRanges() );
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir             if ( pPage->HasExchangeSupport() )
840*cdf0e10cSrcweir                 nRet = pPage->DeactivatePage( &aTmp );
841*cdf0e10cSrcweir 
842*cdf0e10cSrcweir             if ( ( IconChoicePage::LEAVE_PAGE & nRet ) == IconChoicePage::LEAVE_PAGE &&
843*cdf0e10cSrcweir                  aTmp.Count() )
844*cdf0e10cSrcweir             {
845*cdf0e10cSrcweir                 pExampleSet->Put( aTmp );
846*cdf0e10cSrcweir                 pOutSet->Put( aTmp );
847*cdf0e10cSrcweir             }
848*cdf0e10cSrcweir         }
849*cdf0e10cSrcweir         else
850*cdf0e10cSrcweir         {
851*cdf0e10cSrcweir             if ( pPage->HasExchangeSupport() ) //!!!
852*cdf0e10cSrcweir             {
853*cdf0e10cSrcweir                 if ( !pExampleSet )
854*cdf0e10cSrcweir                 {
855*cdf0e10cSrcweir                     SfxItemPool* pPool = pPage->GetItemSet().GetPool();
856*cdf0e10cSrcweir                     pExampleSet =
857*cdf0e10cSrcweir                         new SfxItemSet( *pPool, GetInputRanges( *pPool ) );
858*cdf0e10cSrcweir                 }
859*cdf0e10cSrcweir                 nRet = pPage->DeactivatePage( pExampleSet );
860*cdf0e10cSrcweir             }
861*cdf0e10cSrcweir             else
862*cdf0e10cSrcweir                 nRet = pPage->DeactivatePage( NULL );
863*cdf0e10cSrcweir         }
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir         if ( nRet & IconChoicePage::REFRESH_SET )
866*cdf0e10cSrcweir         {
867*cdf0e10cSrcweir             pSet = GetRefreshedSet();
868*cdf0e10cSrcweir             DBG_ASSERT( pSet, "GetRefreshedSet() liefert NULL" );
869*cdf0e10cSrcweir             // alle Pages als neu zu initialsieren flaggen
870*cdf0e10cSrcweir             const sal_uLong nCount = maPageList.Count();
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < nCount; ++i )
873*cdf0e10cSrcweir             {
874*cdf0e10cSrcweir                 IconChoicePageData* pObj = (IconChoicePageData*)maPageList.GetObject(i);
875*cdf0e10cSrcweir 
876*cdf0e10cSrcweir                 if ( pObj->pPage != pPage ) // eigene Page nicht mehr refreshen
877*cdf0e10cSrcweir                     pObj->bRefresh = sal_True;
878*cdf0e10cSrcweir                 else
879*cdf0e10cSrcweir                     pObj->bRefresh = sal_False;
880*cdf0e10cSrcweir             }
881*cdf0e10cSrcweir         }
882*cdf0e10cSrcweir     }
883*cdf0e10cSrcweir 
884*cdf0e10cSrcweir     if ( nRet & IconChoicePage::LEAVE_PAGE )
885*cdf0e10cSrcweir         return sal_True;
886*cdf0e10cSrcweir     else
887*cdf0e10cSrcweir         return sal_False;
888*cdf0e10cSrcweir }
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir // -----------------------------------------------------------------------
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir void IconChoiceDialog::ResetPageImpl ()
893*cdf0e10cSrcweir {
894*cdf0e10cSrcweir     IconChoicePageData *pData = GetPageData ( mnCurrentPageId );
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir     DBG_ASSERT( pData, "Id nicht bekannt" );
897*cdf0e10cSrcweir 
898*cdf0e10cSrcweir     if ( pData->bOnDemand )
899*cdf0e10cSrcweir     {
900*cdf0e10cSrcweir         // CSet auf AIS hat hier Probleme, daher getrennt
901*cdf0e10cSrcweir         const SfxItemSet* _pSet = &pData->pPage->GetItemSet();
902*cdf0e10cSrcweir         pData->pPage->Reset( *(SfxItemSet*)_pSet );
903*cdf0e10cSrcweir     }
904*cdf0e10cSrcweir     else
905*cdf0e10cSrcweir         pData->pPage->Reset( *pSet );
906*cdf0e10cSrcweir }
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir /**********************************************************************
909*cdf0e10cSrcweir |
910*cdf0e10cSrcweir | handling itemsets
911*cdf0e10cSrcweir |
912*cdf0e10cSrcweir \**********************************************************************/
913*cdf0e10cSrcweir 
914*cdf0e10cSrcweir const sal_uInt16* IconChoiceDialog::GetInputRanges( const SfxItemPool& rPool )
915*cdf0e10cSrcweir {
916*cdf0e10cSrcweir     if ( pSet )
917*cdf0e10cSrcweir     {
918*cdf0e10cSrcweir         DBG_ERRORFILE( "Set bereits vorhanden!" );
919*cdf0e10cSrcweir         return pSet->GetRanges();
920*cdf0e10cSrcweir     }
921*cdf0e10cSrcweir 
922*cdf0e10cSrcweir     if ( pRanges )
923*cdf0e10cSrcweir         return pRanges;
924*cdf0e10cSrcweir     SvUShorts aUS( 16, 16 );
925*cdf0e10cSrcweir     sal_uLong nCount = maPageList.Count();
926*cdf0e10cSrcweir 
927*cdf0e10cSrcweir     sal_uInt16 i;
928*cdf0e10cSrcweir     for ( i = 0; i < nCount; ++i )
929*cdf0e10cSrcweir     {
930*cdf0e10cSrcweir         IconChoicePageData* pData = maPageList.GetObject (i);
931*cdf0e10cSrcweir 
932*cdf0e10cSrcweir         if ( pData->fnGetRanges )
933*cdf0e10cSrcweir         {
934*cdf0e10cSrcweir             const sal_uInt16* pTmpRanges = (pData->fnGetRanges)();
935*cdf0e10cSrcweir             const sal_uInt16* pIter = pTmpRanges;
936*cdf0e10cSrcweir 
937*cdf0e10cSrcweir             sal_uInt16 nLen;
938*cdf0e10cSrcweir             for( nLen = 0; *pIter; ++nLen, ++pIter )
939*cdf0e10cSrcweir                 ;
940*cdf0e10cSrcweir             aUS.Insert( pTmpRanges, nLen, aUS.Count() );
941*cdf0e10cSrcweir         }
942*cdf0e10cSrcweir     }
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir     // remove double Id's
945*cdf0e10cSrcweir #ifndef TF_POOLABLE
946*cdf0e10cSrcweir     if ( rPool.HasMap() )
947*cdf0e10cSrcweir #endif
948*cdf0e10cSrcweir     {
949*cdf0e10cSrcweir         nCount = aUS.Count();
950*cdf0e10cSrcweir 
951*cdf0e10cSrcweir         for ( i = 0; i < nCount; ++i )
952*cdf0e10cSrcweir             aUS[i] = rPool.GetWhich( aUS[i] );
953*cdf0e10cSrcweir     }
954*cdf0e10cSrcweir 
955*cdf0e10cSrcweir     // sortieren
956*cdf0e10cSrcweir     if ( aUS.Count() > 1 )
957*cdf0e10cSrcweir     {
958*cdf0e10cSrcweir #if defined __SUNPRO_CC
959*cdf0e10cSrcweir #pragma disable_warn
960*cdf0e10cSrcweir #endif
961*cdf0e10cSrcweir         qsort( (void*)aUS.GetData(), aUS.Count(), sizeof(sal_uInt16), IconcDlgCmpUS_Impl );
962*cdf0e10cSrcweir #if defined __SUNPRO_CC
963*cdf0e10cSrcweir #pragma enable_warn
964*cdf0e10cSrcweir #endif
965*cdf0e10cSrcweir     }
966*cdf0e10cSrcweir 
967*cdf0e10cSrcweir     pRanges = new sal_uInt16[aUS.Count() + 1];
968*cdf0e10cSrcweir     memcpy(pRanges, aUS.GetData(), sizeof(sal_uInt16) * aUS.Count());
969*cdf0e10cSrcweir     pRanges[aUS.Count()] = 0;
970*cdf0e10cSrcweir 
971*cdf0e10cSrcweir     return pRanges;
972*cdf0e10cSrcweir }
973*cdf0e10cSrcweir 
974*cdf0e10cSrcweir // -----------------------------------------------------------------------
975*cdf0e10cSrcweir 
976*cdf0e10cSrcweir void IconChoiceDialog::SetInputSet( const SfxItemSet* pInSet )
977*cdf0e10cSrcweir {
978*cdf0e10cSrcweir     FASTBOOL bSet = ( pSet != NULL );
979*cdf0e10cSrcweir 
980*cdf0e10cSrcweir     pSet = pInSet;
981*cdf0e10cSrcweir 
982*cdf0e10cSrcweir     if ( !bSet && !pExampleSet && !pOutSet )
983*cdf0e10cSrcweir     {
984*cdf0e10cSrcweir         pExampleSet = new SfxItemSet( *pSet );
985*cdf0e10cSrcweir         pOutSet = new SfxItemSet( *pSet->GetPool(), pSet->GetRanges() );
986*cdf0e10cSrcweir     }
987*cdf0e10cSrcweir }
988*cdf0e10cSrcweir 
989*cdf0e10cSrcweir // -----------------------------------------------------------------------
990*cdf0e10cSrcweir 
991*cdf0e10cSrcweir void IconChoiceDialog::PageCreated( sal_uInt16 /*nId*/, IconChoicePage& /*rPage*/ )
992*cdf0e10cSrcweir {
993*cdf0e10cSrcweir     // not interested in
994*cdf0e10cSrcweir }
995*cdf0e10cSrcweir 
996*cdf0e10cSrcweir // -----------------------------------------------------------------------
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir SfxItemSet* IconChoiceDialog::CreateInputItemSet( sal_uInt16 )
999*cdf0e10cSrcweir {
1000*cdf0e10cSrcweir     DBG_WARNINGFILE( "CreateInputItemSet nicht implementiert" );
1001*cdf0e10cSrcweir 
1002*cdf0e10cSrcweir     return 0;
1003*cdf0e10cSrcweir }
1004*cdf0e10cSrcweir 
1005*cdf0e10cSrcweir /**********************************************************************
1006*cdf0e10cSrcweir |
1007*cdf0e10cSrcweir | start dialog
1008*cdf0e10cSrcweir |
1009*cdf0e10cSrcweir \**********************************************************************/
1010*cdf0e10cSrcweir 
1011*cdf0e10cSrcweir short IconChoiceDialog::Execute()
1012*cdf0e10cSrcweir {
1013*cdf0e10cSrcweir     if ( !maPageList.Count() )
1014*cdf0e10cSrcweir         return RET_CANCEL;
1015*cdf0e10cSrcweir 
1016*cdf0e10cSrcweir     Start_Impl();
1017*cdf0e10cSrcweir 
1018*cdf0e10cSrcweir     return Dialog::Execute();
1019*cdf0e10cSrcweir }
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir // -----------------------------------------------------------------------
1022*cdf0e10cSrcweir 
1023*cdf0e10cSrcweir void IconChoiceDialog::Start( sal_Bool bShow )
1024*cdf0e10cSrcweir {
1025*cdf0e10cSrcweir 
1026*cdf0e10cSrcweir     aCancelBtn.SetClickHdl( LINK( this, IconChoiceDialog, CancelHdl ) );
1027*cdf0e10cSrcweir     bModal = sal_False;
1028*cdf0e10cSrcweir 
1029*cdf0e10cSrcweir     Start_Impl();
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir     if ( bShow )
1032*cdf0e10cSrcweir         Window::Show();
1033*cdf0e10cSrcweir 
1034*cdf0e10cSrcweir }
1035*cdf0e10cSrcweir 
1036*cdf0e10cSrcweir // -----------------------------------------------------------------------
1037*cdf0e10cSrcweir 
1038*cdf0e10cSrcweir sal_Bool IconChoiceDialog::QueryClose()
1039*cdf0e10cSrcweir {
1040*cdf0e10cSrcweir     sal_Bool bRet = sal_True;
1041*cdf0e10cSrcweir     const sal_uLong nCount = maPageList.Count();
1042*cdf0e10cSrcweir     for ( sal_uLong i = 0; i < nCount; ++i )
1043*cdf0e10cSrcweir     {
1044*cdf0e10cSrcweir         IconChoicePageData* pData = maPageList.GetObject(i);
1045*cdf0e10cSrcweir         if ( pData->pPage && !pData->pPage->QueryClose() )
1046*cdf0e10cSrcweir         {
1047*cdf0e10cSrcweir             bRet = sal_False;
1048*cdf0e10cSrcweir             break;
1049*cdf0e10cSrcweir         }
1050*cdf0e10cSrcweir     }
1051*cdf0e10cSrcweir     return bRet;
1052*cdf0e10cSrcweir }
1053*cdf0e10cSrcweir 
1054*cdf0e10cSrcweir // -----------------------------------------------------------------------
1055*cdf0e10cSrcweir 
1056*cdf0e10cSrcweir void IconChoiceDialog::Start_Impl()
1057*cdf0e10cSrcweir {
1058*cdf0e10cSrcweir     Point aPos;
1059*cdf0e10cSrcweir     sal_uInt16 nActPage;
1060*cdf0e10cSrcweir 
1061*cdf0e10cSrcweir     if ( mnCurrentPageId == 0 || mnCurrentPageId == USHRT_MAX )
1062*cdf0e10cSrcweir         nActPage = maPageList.GetObject(0)->nId;//First()->nId;
1063*cdf0e10cSrcweir     else
1064*cdf0e10cSrcweir         nActPage = mnCurrentPageId;
1065*cdf0e10cSrcweir 
1066*cdf0e10cSrcweir     // Konfiguration vorhanden?
1067*cdf0e10cSrcweir     SvtViewOptions aTabDlgOpt( E_TABDIALOG, String::CreateFromInt32( nResId ) );
1068*cdf0e10cSrcweir 
1069*cdf0e10cSrcweir     if ( aTabDlgOpt.Exists() )
1070*cdf0e10cSrcweir     {
1071*cdf0e10cSrcweir         // ggf. Position aus Konfig
1072*cdf0e10cSrcweir         SetWindowState( ByteString( aTabDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) );
1073*cdf0e10cSrcweir 
1074*cdf0e10cSrcweir         // initiale TabPage aus Programm/Hilfe/Konfig
1075*cdf0e10cSrcweir         nActPage = (sal_uInt16)aTabDlgOpt.GetPageID();
1076*cdf0e10cSrcweir 
1077*cdf0e10cSrcweir         if ( USHRT_MAX != mnCurrentPageId )
1078*cdf0e10cSrcweir             nActPage = mnCurrentPageId;
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir         if ( GetPageData ( nActPage ) == NULL )
1081*cdf0e10cSrcweir             nActPage = ( (IconChoicePageData*)maPageList.GetObject(0) )->nId;
1082*cdf0e10cSrcweir     }
1083*cdf0e10cSrcweir     else if ( USHRT_MAX != mnCurrentPageId && GetPageData ( mnCurrentPageId ) != NULL )
1084*cdf0e10cSrcweir         nActPage = mnCurrentPageId;
1085*cdf0e10cSrcweir 
1086*cdf0e10cSrcweir     mnCurrentPageId = nActPage;
1087*cdf0e10cSrcweir 
1088*cdf0e10cSrcweir     FocusOnIcon( mnCurrentPageId );
1089*cdf0e10cSrcweir 
1090*cdf0e10cSrcweir     ActivatePageImpl();
1091*cdf0e10cSrcweir }
1092*cdf0e10cSrcweir 
1093*cdf0e10cSrcweir // -----------------------------------------------------------------------
1094*cdf0e10cSrcweir 
1095*cdf0e10cSrcweir const SfxItemSet* IconChoiceDialog::GetRefreshedSet()
1096*cdf0e10cSrcweir {
1097*cdf0e10cSrcweir     DBG_ERRORFILE( "GetRefreshedSet nicht implementiert" );
1098*cdf0e10cSrcweir     return 0;
1099*cdf0e10cSrcweir }
1100*cdf0e10cSrcweir 
1101*cdf0e10cSrcweir /**********************************************************************
1102*cdf0e10cSrcweir |
1103*cdf0e10cSrcweir | tool-methods
1104*cdf0e10cSrcweir |
1105*cdf0e10cSrcweir \**********************************************************************/
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir IconChoicePageData* IconChoiceDialog::GetPageData ( sal_uInt16 nId )
1108*cdf0e10cSrcweir {
1109*cdf0e10cSrcweir     IconChoicePageData *pRet = NULL;
1110*cdf0e10cSrcweir     sal_Bool bFound = sal_False;
1111*cdf0e10cSrcweir 
1112*cdf0e10cSrcweir     for ( sal_uLong i=0; i<maPageList.Count() && !bFound; i++ )
1113*cdf0e10cSrcweir     {
1114*cdf0e10cSrcweir         IconChoicePageData* pData = (IconChoicePageData*)maPageList.GetObject ( i );
1115*cdf0e10cSrcweir 
1116*cdf0e10cSrcweir         if ( pData->nId == nId )
1117*cdf0e10cSrcweir         {
1118*cdf0e10cSrcweir             pRet = pData;
1119*cdf0e10cSrcweir         }
1120*cdf0e10cSrcweir     }
1121*cdf0e10cSrcweir 
1122*cdf0e10cSrcweir     return pRet;
1123*cdf0e10cSrcweir }
1124*cdf0e10cSrcweir 
1125*cdf0e10cSrcweir /**********************************************************************
1126*cdf0e10cSrcweir |
1127*cdf0e10cSrcweir | OK-Status
1128*cdf0e10cSrcweir |
1129*cdf0e10cSrcweir \**********************************************************************/
1130*cdf0e10cSrcweir 
1131*cdf0e10cSrcweir sal_Bool IconChoiceDialog::OK_Impl()
1132*cdf0e10cSrcweir {
1133*cdf0e10cSrcweir     IconChoicePage* pPage = GetPageData ( mnCurrentPageId )->pPage;
1134*cdf0e10cSrcweir 
1135*cdf0e10cSrcweir     bool bEnd = !pPage;
1136*cdf0e10cSrcweir     if ( pPage )
1137*cdf0e10cSrcweir     {
1138*cdf0e10cSrcweir         int nRet = IconChoicePage::LEAVE_PAGE;
1139*cdf0e10cSrcweir         if ( pSet )
1140*cdf0e10cSrcweir         {
1141*cdf0e10cSrcweir             SfxItemSet aTmp( *pSet->GetPool(), pSet->GetRanges() );
1142*cdf0e10cSrcweir             sal_Bool bRet = sal_False;
1143*cdf0e10cSrcweir 
1144*cdf0e10cSrcweir             if ( pPage->HasExchangeSupport() )
1145*cdf0e10cSrcweir                 nRet = pPage->DeactivatePage( &aTmp );
1146*cdf0e10cSrcweir 
1147*cdf0e10cSrcweir             if ( ( IconChoicePage::LEAVE_PAGE & nRet ) == IconChoicePage::LEAVE_PAGE
1148*cdf0e10cSrcweir                  && aTmp.Count() )
1149*cdf0e10cSrcweir             {
1150*cdf0e10cSrcweir                 pExampleSet->Put( aTmp );
1151*cdf0e10cSrcweir                 pOutSet->Put( aTmp );
1152*cdf0e10cSrcweir             }
1153*cdf0e10cSrcweir             else if ( bRet )
1154*cdf0e10cSrcweir                 bModified |= sal_True;
1155*cdf0e10cSrcweir         }
1156*cdf0e10cSrcweir         else
1157*cdf0e10cSrcweir             nRet = pPage->DeactivatePage( NULL );
1158*cdf0e10cSrcweir         bEnd = nRet;
1159*cdf0e10cSrcweir     }
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir     return bEnd;
1162*cdf0e10cSrcweir }
1163*cdf0e10cSrcweir 
1164*cdf0e10cSrcweir // -----------------------------------------------------------------------
1165*cdf0e10cSrcweir 
1166*cdf0e10cSrcweir short IconChoiceDialog::Ok()
1167*cdf0e10cSrcweir {
1168*cdf0e10cSrcweir     bInOK = sal_True;
1169*cdf0e10cSrcweir 
1170*cdf0e10cSrcweir     if ( !pOutSet )
1171*cdf0e10cSrcweir     {
1172*cdf0e10cSrcweir         if ( !pExampleSet && pSet )
1173*cdf0e10cSrcweir             pOutSet = pSet->Clone( sal_False ); // ohne Items
1174*cdf0e10cSrcweir         else if ( pExampleSet )
1175*cdf0e10cSrcweir             pOutSet = new SfxItemSet( *pExampleSet );
1176*cdf0e10cSrcweir     }
1177*cdf0e10cSrcweir     sal_Bool _bModified = sal_False;
1178*cdf0e10cSrcweir 
1179*cdf0e10cSrcweir     const sal_uLong nCount = maPageList.Count();
1180*cdf0e10cSrcweir 
1181*cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < nCount; ++i )
1182*cdf0e10cSrcweir     {
1183*cdf0e10cSrcweir         IconChoicePageData* pData = GetPageData ( i );
1184*cdf0e10cSrcweir 
1185*cdf0e10cSrcweir         IconChoicePage* pPage = pData->pPage;
1186*cdf0e10cSrcweir 
1187*cdf0e10cSrcweir         if ( pPage )
1188*cdf0e10cSrcweir         {
1189*cdf0e10cSrcweir             if ( pData->bOnDemand )
1190*cdf0e10cSrcweir             {
1191*cdf0e10cSrcweir                 SfxItemSet& rSet = (SfxItemSet&)pPage->GetItemSet();
1192*cdf0e10cSrcweir                 rSet.ClearItem();
1193*cdf0e10cSrcweir                 _bModified |= pPage->FillItemSet( rSet );
1194*cdf0e10cSrcweir             }
1195*cdf0e10cSrcweir             else if ( pSet && !pPage->HasExchangeSupport() )
1196*cdf0e10cSrcweir             {
1197*cdf0e10cSrcweir                 SfxItemSet aTmp( *pSet->GetPool(), pSet->GetRanges() );
1198*cdf0e10cSrcweir 
1199*cdf0e10cSrcweir                 if ( pPage->FillItemSet( aTmp ) )
1200*cdf0e10cSrcweir                 {
1201*cdf0e10cSrcweir                     _bModified |= sal_True;
1202*cdf0e10cSrcweir                     pExampleSet->Put( aTmp );
1203*cdf0e10cSrcweir                     pOutSet->Put( aTmp );
1204*cdf0e10cSrcweir                 }
1205*cdf0e10cSrcweir             }
1206*cdf0e10cSrcweir         }
1207*cdf0e10cSrcweir     }
1208*cdf0e10cSrcweir 
1209*cdf0e10cSrcweir     if ( _bModified || ( pOutSet && pOutSet->Count() > 0 ) )
1210*cdf0e10cSrcweir         _bModified |= sal_True;
1211*cdf0e10cSrcweir 
1212*cdf0e10cSrcweir     return _bModified ? RET_OK : RET_CANCEL;
1213*cdf0e10cSrcweir }
1214*cdf0e10cSrcweir 
1215*cdf0e10cSrcweir // -----------------------------------------------------------------------
1216*cdf0e10cSrcweir 
1217*cdf0e10cSrcweir void IconChoiceDialog::FocusOnIcon( sal_uInt16 nId )
1218*cdf0e10cSrcweir {
1219*cdf0e10cSrcweir     // set focus to icon for the current visible page
1220*cdf0e10cSrcweir     for ( sal_uInt16 i=0; i<maIconCtrl.GetEntryCount(); i++)
1221*cdf0e10cSrcweir     {
1222*cdf0e10cSrcweir         SvxIconChoiceCtrlEntry* pEntry = maIconCtrl.GetEntry ( i );
1223*cdf0e10cSrcweir         sal_uInt16* pUserData = (sal_uInt16*) pEntry->GetUserData();
1224*cdf0e10cSrcweir 
1225*cdf0e10cSrcweir         if ( pUserData && *pUserData == nId )
1226*cdf0e10cSrcweir         {
1227*cdf0e10cSrcweir             maIconCtrl.SetCursor( pEntry );
1228*cdf0e10cSrcweir             break;
1229*cdf0e10cSrcweir         }
1230*cdf0e10cSrcweir     }
1231*cdf0e10cSrcweir }
1232