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