12ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
32ee96f1cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
42ee96f1cSAndrew Rist * or more contributor license agreements. See the NOTICE file
52ee96f1cSAndrew Rist * distributed with this work for additional information
62ee96f1cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
72ee96f1cSAndrew Rist * to you under the Apache License, Version 2.0 (the
82ee96f1cSAndrew Rist * "License"); you may not use this file except in compliance
92ee96f1cSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
112ee96f1cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
132ee96f1cSAndrew Rist * Unless required by applicable law or agreed to in writing,
142ee96f1cSAndrew Rist * software distributed under the License is distributed on an
152ee96f1cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162ee96f1cSAndrew Rist * KIND, either express or implied. See the License for the
172ee96f1cSAndrew Rist * specific language governing permissions and limitations
182ee96f1cSAndrew Rist * under the License.
19cdf0e10cSrcweir *
202ee96f1cSAndrew Rist *************************************************************/
212ee96f1cSAndrew Rist
222ee96f1cSAndrew 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
IconcDlgCmpUS_Impl(const void * p1,const void * p2)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
SetViewOptUserItem(SvtViewOptions & rOpt,const String & rData)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
GetViewOptUserItem(const SvtViewOptions & rOpt)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
IconChoicePage(Window * pParent,const ResId & rResId,const SfxItemSet & rAttrSet)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
~IconChoicePage()101cdf0e10cSrcweir IconChoicePage::~IconChoicePage()
102cdf0e10cSrcweir {
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
105cdf0e10cSrcweir /**********************************************************************
106cdf0e10cSrcweir |
107cdf0e10cSrcweir | Activate / Deaktivate
108cdf0e10cSrcweir |
109cdf0e10cSrcweir \**********************************************************************/
110cdf0e10cSrcweir
ActivatePage(const SfxItemSet &)111cdf0e10cSrcweir void IconChoicePage::ActivatePage( const SfxItemSet& )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
115cdf0e10cSrcweir // -----------------------------------------------------------------------
116cdf0e10cSrcweir
DeactivatePage(SfxItemSet *)117cdf0e10cSrcweir int IconChoicePage::DeactivatePage( SfxItemSet* )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir return LEAVE_PAGE;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
122cdf0e10cSrcweir /**********************************************************************
123cdf0e10cSrcweir |
124cdf0e10cSrcweir | ...
125cdf0e10cSrcweir |
126cdf0e10cSrcweir \**********************************************************************/
127cdf0e10cSrcweir
FillUserData()128cdf0e10cSrcweir void IconChoicePage::FillUserData()
129cdf0e10cSrcweir {
130cdf0e10cSrcweir }
131cdf0e10cSrcweir
132cdf0e10cSrcweir // -----------------------------------------------------------------------
133cdf0e10cSrcweir
IsReadOnly() const134cdf0e10cSrcweir sal_Bool IconChoicePage::IsReadOnly() const
135cdf0e10cSrcweir {
136cdf0e10cSrcweir return sal_False;
137cdf0e10cSrcweir }
138cdf0e10cSrcweir
139cdf0e10cSrcweir // -----------------------------------------------------------------------
140cdf0e10cSrcweir
QueryClose()141cdf0e10cSrcweir sal_Bool IconChoicePage::QueryClose()
142cdf0e10cSrcweir {
143cdf0e10cSrcweir return sal_True;
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
146cdf0e10cSrcweir /**********************************************************************
147cdf0e10cSrcweir |
148cdf0e10cSrcweir | window-methods
149cdf0e10cSrcweir |
150cdf0e10cSrcweir \**********************************************************************/
151cdf0e10cSrcweir
ImplInitSettings()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
StateChanged(StateChangedType nType)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
DataChanged(const DataChangedEvent & rDCEvt)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
IconChoiceDialog(Window * pParent,const ResId & rResId,const EIconChoicePos ePos,const SfxItemSet * pItemSet)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
~IconChoiceDialog()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
AddTabPage(sal_uInt16 nId,const String & rIconText,const Image & rChoiceIcon,const Image & rChoiceIconHC,CreatePage pCreateFunc,GetPageRanges pRangesFunc,sal_Bool bItemsOnDemand,sal_uLong)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
Paint(const Rectangle & rRect)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
SetCtrlPos(const EIconChoicePos & rPos)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
ShowPageImpl(IconChoicePageData * pData)436cdf0e10cSrcweir void IconChoiceDialog::ShowPageImpl ( IconChoicePageData* pData )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir if ( pData->pPage )
439cdf0e10cSrcweir pData->pPage->Show();
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
442cdf0e10cSrcweir // -----------------------------------------------------------------------
443cdf0e10cSrcweir
HidePageImpl(IconChoicePageData * pData)444cdf0e10cSrcweir void IconChoiceDialog::HidePageImpl ( IconChoicePageData* pData )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir if ( pData->pPage )
447cdf0e10cSrcweir pData->pPage->Hide();
448cdf0e10cSrcweir }
449cdf0e10cSrcweir
450cdf0e10cSrcweir // -----------------------------------------------------------------------
451cdf0e10cSrcweir
ShowPage(sal_uInt16 nId)452cdf0e10cSrcweir void IconChoiceDialog::ShowPage( sal_uInt16 nId )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir bool bInvalidate = GetCurPageId() != nId;
455cdf0e10cSrcweir SetCurPageId( nId );
456cdf0e10cSrcweir ActivatePageImpl( );
457cdf0e10cSrcweir if(bInvalidate)
458cdf0e10cSrcweir Invalidate();
459*9b8096d0SSteve Yin
460*9b8096d0SSteve Yin // IA2 CWS. MT: I guess we want the event now, and not in Paint()?
461*9b8096d0SSteve Yin IconChoicePageData* pData = GetPageData ( mnCurrentPageId );
462*9b8096d0SSteve Yin if(pData)
463*9b8096d0SSteve Yin ShowPageImpl ( pData );
464cdf0e10cSrcweir }
465cdf0e10cSrcweir
466cdf0e10cSrcweir /**********************************************************************
467cdf0e10cSrcweir |
468cdf0e10cSrcweir | Resize Dialog
469cdf0e10cSrcweir |
470cdf0e10cSrcweir \**********************************************************************/
471cdf0e10cSrcweir
472cdf0e10cSrcweir #define ICONCTRL_WIDTH_PIXEL 110
473cdf0e10cSrcweir #define ICONCTRL_HEIGHT_PIXEL 75
474cdf0e10cSrcweir #define MINSIZE_BUTTON_WIDTH 70
475cdf0e10cSrcweir #define MINSIZE_BUTTON_HEIGHT 22
476cdf0e10cSrcweir
Resize()477cdf0e10cSrcweir void IconChoiceDialog::Resize()
478cdf0e10cSrcweir {
479cdf0e10cSrcweir Dialog::Resize ();
480cdf0e10cSrcweir
481cdf0e10cSrcweir if ( IsReallyVisible() )
482cdf0e10cSrcweir {
483cdf0e10cSrcweir SetPosSizeCtrls ();
484cdf0e10cSrcweir }
485cdf0e10cSrcweir }
486cdf0e10cSrcweir
SetPosSizeCtrls(sal_Bool bInit)487cdf0e10cSrcweir void IconChoiceDialog::SetPosSizeCtrls ( sal_Bool bInit )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir const Point aCtrlOffset ( LogicToPixel( Point( CTRLS_OFFSET, CTRLS_OFFSET ), MAP_APPFONT ) );
490cdf0e10cSrcweir Size aOutSize ( GetOutputSizePixel() );
491cdf0e10cSrcweir
492cdf0e10cSrcweir ////////////////////////////////////////
493cdf0e10cSrcweir // Button-Defaults
494cdf0e10cSrcweir //
495cdf0e10cSrcweir Size aDefaultButtonSize = LogicToPixel( Size( 50, 14 ), MAP_APPFONT );
496cdf0e10cSrcweir
497cdf0e10cSrcweir // Reset-Button
498cdf0e10cSrcweir Size aResetButtonSize ( bInit ? aDefaultButtonSize :
499cdf0e10cSrcweir aResetBtn.GetSizePixel () );
500cdf0e10cSrcweir
501cdf0e10cSrcweir ////////////////////////////////////////
502cdf0e10cSrcweir // IconChoiceCtrl resizen & positionieren
503cdf0e10cSrcweir //
504cdf0e10cSrcweir SvtTabAppearanceCfg aCfg;
505cdf0e10cSrcweir const long nDefaultWidth = (aCfg.GetScaleFactor() * ICONCTRL_WIDTH_PIXEL) / 100;
506cdf0e10cSrcweir const long nDefaultHeight = (aCfg.GetScaleFactor() * ICONCTRL_HEIGHT_PIXEL) / 100;
507cdf0e10cSrcweir
508cdf0e10cSrcweir Size aNewIconCtrlSize ( nDefaultWidth,
509cdf0e10cSrcweir aOutSize.Height()-(2*aCtrlOffset.X()) );
510cdf0e10cSrcweir Point aIconCtrlPos;
511cdf0e10cSrcweir switch ( meChoicePos )
512cdf0e10cSrcweir {
513cdf0e10cSrcweir case PosLeft :
514cdf0e10cSrcweir aIconCtrlPos = aCtrlOffset;
515cdf0e10cSrcweir aNewIconCtrlSize = Size ( nDefaultWidth,
516cdf0e10cSrcweir aOutSize.Height()-(2*aCtrlOffset.X()) );
517cdf0e10cSrcweir break;
518cdf0e10cSrcweir case PosRight :
519cdf0e10cSrcweir aIconCtrlPos = Point ( aOutSize.Width() - nDefaultWidth -
520cdf0e10cSrcweir aCtrlOffset.X(), aCtrlOffset.X() );
521cdf0e10cSrcweir aNewIconCtrlSize = Size ( nDefaultWidth,
522cdf0e10cSrcweir aOutSize.Height()-(2*aCtrlOffset.X()) );
523cdf0e10cSrcweir break;
524cdf0e10cSrcweir case PosTop :
525cdf0e10cSrcweir aIconCtrlPos = aCtrlOffset;
526cdf0e10cSrcweir aNewIconCtrlSize = Size ( aOutSize.Width()-(2*aCtrlOffset.X()),
527cdf0e10cSrcweir nDefaultHeight );
528cdf0e10cSrcweir break;
529cdf0e10cSrcweir case PosBottom :
530cdf0e10cSrcweir aIconCtrlPos = Point ( aCtrlOffset.X(), aOutSize.Height() -
531cdf0e10cSrcweir aResetButtonSize.Height() - (2*aCtrlOffset.X()) -
532cdf0e10cSrcweir nDefaultHeight );
533cdf0e10cSrcweir aNewIconCtrlSize = Size ( aOutSize.Width()-(2*aCtrlOffset.X()),
534cdf0e10cSrcweir nDefaultHeight );
535cdf0e10cSrcweir break;
536cdf0e10cSrcweir };
537cdf0e10cSrcweir maIconCtrl.SetPosSizePixel ( aIconCtrlPos, aNewIconCtrlSize );
538cdf0e10cSrcweir maIconCtrl.ArrangeIcons();
539cdf0e10cSrcweir
540cdf0e10cSrcweir ////////////////////////////////////////
541cdf0e10cSrcweir // Pages resizen & positionieren
542cdf0e10cSrcweir //
543cdf0e10cSrcweir for ( sal_uLong i=0; i<maPageList.Count(); i++ )
544cdf0e10cSrcweir {
545cdf0e10cSrcweir IconChoicePageData* pData = (IconChoicePageData*)maPageList.GetObject ( i );
546cdf0e10cSrcweir
547cdf0e10cSrcweir Point aNewPagePos;
548cdf0e10cSrcweir Size aNewPageSize;
549cdf0e10cSrcweir switch ( meChoicePos )
550cdf0e10cSrcweir {
551cdf0e10cSrcweir case PosLeft :
552cdf0e10cSrcweir aNewPagePos = Point ( aNewIconCtrlSize.Width() + (2*CTRLS_OFFSET),
553cdf0e10cSrcweir CTRLS_OFFSET );
554cdf0e10cSrcweir aNewPageSize = Size ( aOutSize.Width() - aNewIconCtrlSize.Width() -
555cdf0e10cSrcweir (3*CTRLS_OFFSET),
556cdf0e10cSrcweir aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
557cdf0e10cSrcweir (3*CTRLS_OFFSET) );
558cdf0e10cSrcweir break;
559cdf0e10cSrcweir case PosRight :
560cdf0e10cSrcweir aNewPagePos = aCtrlOffset;
561cdf0e10cSrcweir aNewPageSize = Size ( aOutSize.Width() - aNewIconCtrlSize.Width() -
562cdf0e10cSrcweir (3*aCtrlOffset.X()),
563cdf0e10cSrcweir aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
564cdf0e10cSrcweir (3*aCtrlOffset.X()) );
565cdf0e10cSrcweir break;
566cdf0e10cSrcweir case PosTop :
567cdf0e10cSrcweir aNewPagePos = Point ( aCtrlOffset.X(), aNewIconCtrlSize.Height() +
568cdf0e10cSrcweir (2*aCtrlOffset.X()) );
569cdf0e10cSrcweir aNewPageSize = Size ( aOutSize.Width() - (2*aCtrlOffset.X()),
570cdf0e10cSrcweir aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
571cdf0e10cSrcweir aNewIconCtrlSize.Height() - (4*aCtrlOffset.X()) );
572cdf0e10cSrcweir break;
573cdf0e10cSrcweir case PosBottom :
574cdf0e10cSrcweir aNewPagePos = aCtrlOffset;
575cdf0e10cSrcweir aNewPageSize = Size ( aOutSize.Width() - (2*aCtrlOffset.X()),
576cdf0e10cSrcweir aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
577cdf0e10cSrcweir aNewIconCtrlSize.Height() - (4*aCtrlOffset.X()) );
578cdf0e10cSrcweir break;
579cdf0e10cSrcweir };
580cdf0e10cSrcweir
581cdf0e10cSrcweir if ( pData->pPage )
582cdf0e10cSrcweir pData->pPage->SetPosSizePixel ( aNewPagePos, aNewPageSize );
583cdf0e10cSrcweir }
584cdf0e10cSrcweir
585cdf0e10cSrcweir ////////////////////////////////////////
586cdf0e10cSrcweir // Buttons positionieren
587cdf0e10cSrcweir //
588cdf0e10cSrcweir sal_uLong nXOffset=0;
589cdf0e10cSrcweir if ( meChoicePos == PosRight )
590cdf0e10cSrcweir nXOffset = aNewIconCtrlSize.Width()+(2*aCtrlOffset.X());
591cdf0e10cSrcweir
592cdf0e10cSrcweir aResetBtn.SetPosSizePixel ( Point( aOutSize.Width() - nXOffset -
593cdf0e10cSrcweir aResetButtonSize.Width()-aCtrlOffset.X(),
594cdf0e10cSrcweir aOutSize.Height()-aResetButtonSize.Height()-
595cdf0e10cSrcweir aCtrlOffset.X() ),
596cdf0e10cSrcweir aResetButtonSize );
597cdf0e10cSrcweir // Help-Button
598cdf0e10cSrcweir Size aHelpButtonSize ( bInit ? aDefaultButtonSize :
599cdf0e10cSrcweir aHelpBtn.GetSizePixel () );
600cdf0e10cSrcweir aHelpBtn.SetPosSizePixel ( Point( aOutSize.Width()-aResetButtonSize.Width()-
601cdf0e10cSrcweir aHelpButtonSize.Width()- nXOffset -
602cdf0e10cSrcweir (2*aCtrlOffset.X()),
603cdf0e10cSrcweir aOutSize.Height()-aHelpButtonSize.Height()-
604cdf0e10cSrcweir aCtrlOffset.X() ),
605cdf0e10cSrcweir aHelpButtonSize );
606cdf0e10cSrcweir // Cancel-Button
607cdf0e10cSrcweir Size aCancelButtonSize ( bInit ? aDefaultButtonSize :
608cdf0e10cSrcweir aCancelBtn.GetSizePixel () );
609cdf0e10cSrcweir aCancelBtn.SetPosSizePixel ( Point( aOutSize.Width()-aCancelButtonSize.Width()-
610cdf0e10cSrcweir aResetButtonSize.Width()-aHelpButtonSize.Width()-
611cdf0e10cSrcweir (3*aCtrlOffset.X()) - nXOffset,
612cdf0e10cSrcweir aOutSize.Height()-aCancelButtonSize.Height()-
613cdf0e10cSrcweir aCtrlOffset.X() ),
614cdf0e10cSrcweir aCancelButtonSize );
615cdf0e10cSrcweir // OK-Button
616cdf0e10cSrcweir Size aOKButtonSize ( bInit ? aDefaultButtonSize : aOKBtn.GetSizePixel () );
617cdf0e10cSrcweir aOKBtn.SetPosSizePixel ( Point( aOutSize.Width()-aOKButtonSize.Width()-
618cdf0e10cSrcweir aCancelButtonSize.Width()-aResetButtonSize.Width()-
619cdf0e10cSrcweir aHelpButtonSize.Width()-(4*aCtrlOffset.X())- nXOffset,
620cdf0e10cSrcweir aOutSize.Height()-aOKButtonSize.Height()-aCtrlOffset.X() ),
621cdf0e10cSrcweir aOKButtonSize );
622cdf0e10cSrcweir
623cdf0e10cSrcweir Invalidate();
624cdf0e10cSrcweir }
625cdf0e10cSrcweir
SetPosSizePages(sal_uInt16 nId)626cdf0e10cSrcweir void IconChoiceDialog::SetPosSizePages ( sal_uInt16 nId )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir const Point aCtrlOffset ( LogicToPixel( Point( CTRLS_OFFSET, CTRLS_OFFSET ), MAP_APPFONT ) );
629cdf0e10cSrcweir IconChoicePageData* pData = GetPageData ( nId );
630cdf0e10cSrcweir
631cdf0e10cSrcweir if ( pData->pPage )
632cdf0e10cSrcweir {
633cdf0e10cSrcweir Size aOutSize ( GetOutputSizePixel() );
634cdf0e10cSrcweir Size aIconCtrlSize ( maIconCtrl.GetSizePixel() );
635cdf0e10cSrcweir
636cdf0e10cSrcweir Point aNewPagePos;
637cdf0e10cSrcweir Size aNewPageSize;
638cdf0e10cSrcweir switch ( meChoicePos )
639cdf0e10cSrcweir {
640cdf0e10cSrcweir case PosLeft :
641cdf0e10cSrcweir aNewPagePos = Point ( aIconCtrlSize.Width() + (2*aCtrlOffset.X()),
642cdf0e10cSrcweir aCtrlOffset.X() );
643cdf0e10cSrcweir aNewPageSize = Size ( aOutSize.Width() - maIconCtrl.GetSizePixel().Width() -
644cdf0e10cSrcweir (3*aCtrlOffset.X()),
645cdf0e10cSrcweir aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
646cdf0e10cSrcweir (3*aCtrlOffset.X()) );
647cdf0e10cSrcweir break;
648cdf0e10cSrcweir case PosRight :
649cdf0e10cSrcweir aNewPagePos = aCtrlOffset;
650cdf0e10cSrcweir aNewPageSize = Size ( aOutSize.Width() - maIconCtrl.GetSizePixel().Width() -
651cdf0e10cSrcweir (3*aCtrlOffset.X()),
652cdf0e10cSrcweir aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
653cdf0e10cSrcweir (3*aCtrlOffset.X()) );
654cdf0e10cSrcweir break;
655cdf0e10cSrcweir case PosTop :
656cdf0e10cSrcweir aNewPagePos = Point ( aCtrlOffset.X(), aIconCtrlSize.Height() +
657cdf0e10cSrcweir (2*aCtrlOffset.X()) );
658cdf0e10cSrcweir aNewPageSize = Size ( aOutSize.Width() - (2*aCtrlOffset.X()),
659cdf0e10cSrcweir aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
660cdf0e10cSrcweir maIconCtrl.GetSizePixel().Height() - (4*aCtrlOffset.X()) );
661cdf0e10cSrcweir break;
662cdf0e10cSrcweir case PosBottom :
663cdf0e10cSrcweir aNewPagePos = aCtrlOffset;
664cdf0e10cSrcweir aNewPageSize = Size ( aOutSize.Width() - (2*aCtrlOffset.X()),
665cdf0e10cSrcweir aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
666cdf0e10cSrcweir maIconCtrl.GetSizePixel().Height() - (4*aCtrlOffset.X()) );
667cdf0e10cSrcweir break;
668cdf0e10cSrcweir };
669cdf0e10cSrcweir
670cdf0e10cSrcweir pData->pPage->SetPosSizePixel ( aNewPagePos, aNewPageSize );
671cdf0e10cSrcweir }
672cdf0e10cSrcweir }
673cdf0e10cSrcweir
674cdf0e10cSrcweir /**********************************************************************
675cdf0e10cSrcweir |
676cdf0e10cSrcweir | select a page
677cdf0e10cSrcweir |
678cdf0e10cSrcweir \**********************************************************************/
679cdf0e10cSrcweir
IMPL_LINK(IconChoiceDialog,ChosePageHdl_Impl,void *,EMPTYARG)680cdf0e10cSrcweir IMPL_LINK ( IconChoiceDialog , ChosePageHdl_Impl, void *, EMPTYARG )
681cdf0e10cSrcweir {
682cdf0e10cSrcweir sal_uLong nPos;
683cdf0e10cSrcweir
684cdf0e10cSrcweir SvxIconChoiceCtrlEntry *pEntry = maIconCtrl.GetSelectedEntry ( nPos );
685cdf0e10cSrcweir if ( !pEntry )
686cdf0e10cSrcweir pEntry = maIconCtrl.GetCursor( );
687cdf0e10cSrcweir
688cdf0e10cSrcweir sal_uInt16 *pId = (sal_uInt16*)pEntry->GetUserData ();
689cdf0e10cSrcweir
690cdf0e10cSrcweir if( *pId != mnCurrentPageId )
691cdf0e10cSrcweir {
692cdf0e10cSrcweir IconChoicePageData* pData = GetPageData ( mnCurrentPageId );
693cdf0e10cSrcweir if ( pData->pPage )
694cdf0e10cSrcweir DeActivatePageImpl();
695cdf0e10cSrcweir
696cdf0e10cSrcweir SetCurPageId ( *pId );
697cdf0e10cSrcweir
698cdf0e10cSrcweir ActivatePageImpl();
699cdf0e10cSrcweir Invalidate();
700cdf0e10cSrcweir }
701cdf0e10cSrcweir
702cdf0e10cSrcweir return 0L;
703cdf0e10cSrcweir }
704cdf0e10cSrcweir
705cdf0e10cSrcweir /**********************************************************************
706cdf0e10cSrcweir |
707cdf0e10cSrcweir | Button-handler
708cdf0e10cSrcweir |
709cdf0e10cSrcweir \**********************************************************************/
710cdf0e10cSrcweir
IMPL_LINK(IconChoiceDialog,OkHdl,Button *,EMPTYARG)711cdf0e10cSrcweir IMPL_LINK( IconChoiceDialog, OkHdl, Button *, EMPTYARG )
712cdf0e10cSrcweir {
713cdf0e10cSrcweir bInOK = sal_True;
714cdf0e10cSrcweir
715cdf0e10cSrcweir if ( OK_Impl() )
716cdf0e10cSrcweir {
717cdf0e10cSrcweir if ( bModal )
718cdf0e10cSrcweir EndDialog( Ok() );
719cdf0e10cSrcweir else
720cdf0e10cSrcweir {
721cdf0e10cSrcweir Ok();
722cdf0e10cSrcweir Close();
723cdf0e10cSrcweir }
724cdf0e10cSrcweir }
725cdf0e10cSrcweir return 0;
726cdf0e10cSrcweir }
727cdf0e10cSrcweir
728cdf0e10cSrcweir // -----------------------------------------------------------------------
729cdf0e10cSrcweir
IMPL_LINK(IconChoiceDialog,ResetHdl,Button *,EMPTYARG)730cdf0e10cSrcweir IMPL_LINK( IconChoiceDialog, ResetHdl, Button *, EMPTYARG )
731cdf0e10cSrcweir {
732cdf0e10cSrcweir ResetPageImpl ();
733cdf0e10cSrcweir
734cdf0e10cSrcweir IconChoicePageData* pData = GetPageData ( mnCurrentPageId );
735cdf0e10cSrcweir DBG_ASSERT( pData, "Id nicht bekannt" );
736cdf0e10cSrcweir
737cdf0e10cSrcweir if ( pData->bOnDemand )
738cdf0e10cSrcweir {
739cdf0e10cSrcweir // CSet auf AIS hat hier Probleme, daher getrennt
740cdf0e10cSrcweir const SfxItemSet* _pSet = &( pData->pPage->GetItemSet() );
741cdf0e10cSrcweir pData->pPage->Reset( *(SfxItemSet*)_pSet );
742cdf0e10cSrcweir }
743cdf0e10cSrcweir else
744cdf0e10cSrcweir pData->pPage->Reset( *pSet );
745cdf0e10cSrcweir
746cdf0e10cSrcweir
747cdf0e10cSrcweir return 0;
748cdf0e10cSrcweir }
749cdf0e10cSrcweir
750cdf0e10cSrcweir // -----------------------------------------------------------------------
751cdf0e10cSrcweir
IMPL_LINK(IconChoiceDialog,CancelHdl,Button *,EMPTYARG)752cdf0e10cSrcweir IMPL_LINK( IconChoiceDialog, CancelHdl, Button*, EMPTYARG )
753cdf0e10cSrcweir {
754cdf0e10cSrcweir Close();
755cdf0e10cSrcweir
756cdf0e10cSrcweir return 0;
757cdf0e10cSrcweir }
758cdf0e10cSrcweir
759cdf0e10cSrcweir /**********************************************************************
760cdf0e10cSrcweir |
761cdf0e10cSrcweir | call page
762cdf0e10cSrcweir |
763cdf0e10cSrcweir \**********************************************************************/
764cdf0e10cSrcweir
ActivatePageImpl()765cdf0e10cSrcweir void IconChoiceDialog::ActivatePageImpl ()
766cdf0e10cSrcweir {
767cdf0e10cSrcweir DBG_ASSERT( maPageList.Count(), "keine Pages angemeldet" );
768cdf0e10cSrcweir IconChoicePageData* pData = GetPageData ( mnCurrentPageId );
769cdf0e10cSrcweir DBG_ASSERT( pData, "Id nicht bekannt" );
770cdf0e10cSrcweir if ( pData )
771cdf0e10cSrcweir {
772cdf0e10cSrcweir if ( !pData->pPage )
773cdf0e10cSrcweir {
774cdf0e10cSrcweir const SfxItemSet* pTmpSet = 0;
775cdf0e10cSrcweir
776cdf0e10cSrcweir if ( pSet )
777cdf0e10cSrcweir {
778cdf0e10cSrcweir if ( bItemsReset && pSet->GetParent() )
779cdf0e10cSrcweir pTmpSet = pSet->GetParent();
780cdf0e10cSrcweir else
781cdf0e10cSrcweir pTmpSet = pSet;
782cdf0e10cSrcweir }
783cdf0e10cSrcweir
784cdf0e10cSrcweir if ( pTmpSet && !pData->bOnDemand )
785cdf0e10cSrcweir pData->pPage = (pData->fnCreatePage)( this, *pTmpSet );
786cdf0e10cSrcweir else
787cdf0e10cSrcweir pData->pPage = (pData->fnCreatePage)( this, *CreateInputItemSet( mnCurrentPageId ) );
788cdf0e10cSrcweir
789cdf0e10cSrcweir SvtViewOptions aTabPageOpt( E_TABPAGE, String::CreateFromInt32( pData->nId ) );
790cdf0e10cSrcweir pData->pPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) );
791cdf0e10cSrcweir SetPosSizePages ( pData->nId );
792cdf0e10cSrcweir
793cdf0e10cSrcweir if ( pData->bOnDemand )
794cdf0e10cSrcweir pData->pPage->Reset( (SfxItemSet &)pData->pPage->GetItemSet() );
795cdf0e10cSrcweir else
796cdf0e10cSrcweir pData->pPage->Reset( *pSet );
797cdf0e10cSrcweir
798cdf0e10cSrcweir PageCreated( mnCurrentPageId, *pData->pPage );
799cdf0e10cSrcweir }
800cdf0e10cSrcweir else if ( pData->bRefresh )
801cdf0e10cSrcweir {
802cdf0e10cSrcweir pData->pPage->Reset( *pSet );
803cdf0e10cSrcweir }
804cdf0e10cSrcweir
805cdf0e10cSrcweir pData->bRefresh = sal_False;
806cdf0e10cSrcweir
807cdf0e10cSrcweir if ( pExampleSet )
808cdf0e10cSrcweir pData->pPage->ActivatePage( *pExampleSet );
809cdf0e10cSrcweir }
810cdf0e10cSrcweir
811cdf0e10cSrcweir SetHelpId( pData->pPage->GetHelpId() );
812cdf0e10cSrcweir
813cdf0e10cSrcweir sal_Bool bReadOnly = pData->pPage->IsReadOnly();
814cdf0e10cSrcweir if ( bReadOnly || bHideResetBtn )
815cdf0e10cSrcweir aResetBtn.Hide();
816cdf0e10cSrcweir else
817cdf0e10cSrcweir aResetBtn.Show();
818cdf0e10cSrcweir
819cdf0e10cSrcweir }
820cdf0e10cSrcweir
821cdf0e10cSrcweir // -----------------------------------------------------------------------
822cdf0e10cSrcweir
DeActivatePageImpl()823cdf0e10cSrcweir sal_Bool IconChoiceDialog::DeActivatePageImpl ()
824cdf0e10cSrcweir {
825cdf0e10cSrcweir IconChoicePageData *pData = GetPageData ( mnCurrentPageId );
826cdf0e10cSrcweir
827cdf0e10cSrcweir int nRet = IconChoicePage::LEAVE_PAGE;
828cdf0e10cSrcweir
829cdf0e10cSrcweir if ( pData )
830cdf0e10cSrcweir {
831cdf0e10cSrcweir IconChoicePage * pPage = pData->pPage;
832cdf0e10cSrcweir
833cdf0e10cSrcweir if ( !pExampleSet && pPage->HasExchangeSupport() && pSet )
834cdf0e10cSrcweir pExampleSet = new SfxItemSet( *pSet->GetPool(), pSet->GetRanges() );
835cdf0e10cSrcweir
836cdf0e10cSrcweir if ( pSet )
837cdf0e10cSrcweir {
838cdf0e10cSrcweir SfxItemSet aTmp( *pSet->GetPool(), pSet->GetRanges() );
839cdf0e10cSrcweir
840cdf0e10cSrcweir if ( pPage->HasExchangeSupport() )
841cdf0e10cSrcweir nRet = pPage->DeactivatePage( &aTmp );
842cdf0e10cSrcweir
843cdf0e10cSrcweir if ( ( IconChoicePage::LEAVE_PAGE & nRet ) == IconChoicePage::LEAVE_PAGE &&
844cdf0e10cSrcweir aTmp.Count() )
845cdf0e10cSrcweir {
846cdf0e10cSrcweir pExampleSet->Put( aTmp );
847cdf0e10cSrcweir pOutSet->Put( aTmp );
848cdf0e10cSrcweir }
849cdf0e10cSrcweir }
850cdf0e10cSrcweir else
851cdf0e10cSrcweir {
852cdf0e10cSrcweir if ( pPage->HasExchangeSupport() ) //!!!
853cdf0e10cSrcweir {
854cdf0e10cSrcweir if ( !pExampleSet )
855cdf0e10cSrcweir {
856cdf0e10cSrcweir SfxItemPool* pPool = pPage->GetItemSet().GetPool();
857cdf0e10cSrcweir pExampleSet =
858cdf0e10cSrcweir new SfxItemSet( *pPool, GetInputRanges( *pPool ) );
859cdf0e10cSrcweir }
860cdf0e10cSrcweir nRet = pPage->DeactivatePage( pExampleSet );
861cdf0e10cSrcweir }
862cdf0e10cSrcweir else
863cdf0e10cSrcweir nRet = pPage->DeactivatePage( NULL );
864cdf0e10cSrcweir }
865cdf0e10cSrcweir
866cdf0e10cSrcweir if ( nRet & IconChoicePage::REFRESH_SET )
867cdf0e10cSrcweir {
868cdf0e10cSrcweir pSet = GetRefreshedSet();
869cdf0e10cSrcweir DBG_ASSERT( pSet, "GetRefreshedSet() liefert NULL" );
870cdf0e10cSrcweir // alle Pages als neu zu initialsieren flaggen
871cdf0e10cSrcweir const sal_uLong nCount = maPageList.Count();
872cdf0e10cSrcweir
873cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; ++i )
874cdf0e10cSrcweir {
875cdf0e10cSrcweir IconChoicePageData* pObj = (IconChoicePageData*)maPageList.GetObject(i);
876cdf0e10cSrcweir
877cdf0e10cSrcweir if ( pObj->pPage != pPage ) // eigene Page nicht mehr refreshen
878cdf0e10cSrcweir pObj->bRefresh = sal_True;
879cdf0e10cSrcweir else
880cdf0e10cSrcweir pObj->bRefresh = sal_False;
881cdf0e10cSrcweir }
882cdf0e10cSrcweir }
883cdf0e10cSrcweir }
884cdf0e10cSrcweir
885cdf0e10cSrcweir if ( nRet & IconChoicePage::LEAVE_PAGE )
886cdf0e10cSrcweir return sal_True;
887cdf0e10cSrcweir else
888cdf0e10cSrcweir return sal_False;
889cdf0e10cSrcweir }
890cdf0e10cSrcweir
891cdf0e10cSrcweir // -----------------------------------------------------------------------
892cdf0e10cSrcweir
ResetPageImpl()893cdf0e10cSrcweir void IconChoiceDialog::ResetPageImpl ()
894cdf0e10cSrcweir {
895cdf0e10cSrcweir IconChoicePageData *pData = GetPageData ( mnCurrentPageId );
896cdf0e10cSrcweir
897cdf0e10cSrcweir DBG_ASSERT( pData, "Id nicht bekannt" );
898cdf0e10cSrcweir
899cdf0e10cSrcweir if ( pData->bOnDemand )
900cdf0e10cSrcweir {
901cdf0e10cSrcweir // CSet auf AIS hat hier Probleme, daher getrennt
902cdf0e10cSrcweir const SfxItemSet* _pSet = &pData->pPage->GetItemSet();
903cdf0e10cSrcweir pData->pPage->Reset( *(SfxItemSet*)_pSet );
904cdf0e10cSrcweir }
905cdf0e10cSrcweir else
906cdf0e10cSrcweir pData->pPage->Reset( *pSet );
907cdf0e10cSrcweir }
908cdf0e10cSrcweir
909cdf0e10cSrcweir /**********************************************************************
910cdf0e10cSrcweir |
911cdf0e10cSrcweir | handling itemsets
912cdf0e10cSrcweir |
913cdf0e10cSrcweir \**********************************************************************/
914cdf0e10cSrcweir
GetInputRanges(const SfxItemPool & rPool)915cdf0e10cSrcweir const sal_uInt16* IconChoiceDialog::GetInputRanges( const SfxItemPool& rPool )
916cdf0e10cSrcweir {
917cdf0e10cSrcweir if ( pSet )
918cdf0e10cSrcweir {
919cdf0e10cSrcweir DBG_ERRORFILE( "Set bereits vorhanden!" );
920cdf0e10cSrcweir return pSet->GetRanges();
921cdf0e10cSrcweir }
922cdf0e10cSrcweir
923cdf0e10cSrcweir if ( pRanges )
924cdf0e10cSrcweir return pRanges;
925cdf0e10cSrcweir SvUShorts aUS( 16, 16 );
926cdf0e10cSrcweir sal_uLong nCount = maPageList.Count();
927cdf0e10cSrcweir
928cdf0e10cSrcweir sal_uInt16 i;
929cdf0e10cSrcweir for ( i = 0; i < nCount; ++i )
930cdf0e10cSrcweir {
931cdf0e10cSrcweir IconChoicePageData* pData = maPageList.GetObject (i);
932cdf0e10cSrcweir
933cdf0e10cSrcweir if ( pData->fnGetRanges )
934cdf0e10cSrcweir {
935cdf0e10cSrcweir const sal_uInt16* pTmpRanges = (pData->fnGetRanges)();
936cdf0e10cSrcweir const sal_uInt16* pIter = pTmpRanges;
937cdf0e10cSrcweir
938cdf0e10cSrcweir sal_uInt16 nLen;
939cdf0e10cSrcweir for( nLen = 0; *pIter; ++nLen, ++pIter )
940cdf0e10cSrcweir ;
941cdf0e10cSrcweir aUS.Insert( pTmpRanges, nLen, aUS.Count() );
942cdf0e10cSrcweir }
943cdf0e10cSrcweir }
944cdf0e10cSrcweir
945cdf0e10cSrcweir // remove double Id's
946cdf0e10cSrcweir #ifndef TF_POOLABLE
947cdf0e10cSrcweir if ( rPool.HasMap() )
948cdf0e10cSrcweir #endif
949cdf0e10cSrcweir {
950cdf0e10cSrcweir nCount = aUS.Count();
951cdf0e10cSrcweir
952cdf0e10cSrcweir for ( i = 0; i < nCount; ++i )
953cdf0e10cSrcweir aUS[i] = rPool.GetWhich( aUS[i] );
954cdf0e10cSrcweir }
955cdf0e10cSrcweir
956cdf0e10cSrcweir // sortieren
957cdf0e10cSrcweir if ( aUS.Count() > 1 )
958cdf0e10cSrcweir {
959cdf0e10cSrcweir #if defined __SUNPRO_CC
960cdf0e10cSrcweir #pragma disable_warn
961cdf0e10cSrcweir #endif
962cdf0e10cSrcweir qsort( (void*)aUS.GetData(), aUS.Count(), sizeof(sal_uInt16), IconcDlgCmpUS_Impl );
963cdf0e10cSrcweir #if defined __SUNPRO_CC
964cdf0e10cSrcweir #pragma enable_warn
965cdf0e10cSrcweir #endif
966cdf0e10cSrcweir }
967cdf0e10cSrcweir
968cdf0e10cSrcweir pRanges = new sal_uInt16[aUS.Count() + 1];
969cdf0e10cSrcweir memcpy(pRanges, aUS.GetData(), sizeof(sal_uInt16) * aUS.Count());
970cdf0e10cSrcweir pRanges[aUS.Count()] = 0;
971cdf0e10cSrcweir
972cdf0e10cSrcweir return pRanges;
973cdf0e10cSrcweir }
974cdf0e10cSrcweir
975cdf0e10cSrcweir // -----------------------------------------------------------------------
976cdf0e10cSrcweir
SetInputSet(const SfxItemSet * pInSet)977cdf0e10cSrcweir void IconChoiceDialog::SetInputSet( const SfxItemSet* pInSet )
978cdf0e10cSrcweir {
979cdf0e10cSrcweir FASTBOOL bSet = ( pSet != NULL );
980cdf0e10cSrcweir
981cdf0e10cSrcweir pSet = pInSet;
982cdf0e10cSrcweir
983cdf0e10cSrcweir if ( !bSet && !pExampleSet && !pOutSet )
984cdf0e10cSrcweir {
985cdf0e10cSrcweir pExampleSet = new SfxItemSet( *pSet );
986cdf0e10cSrcweir pOutSet = new SfxItemSet( *pSet->GetPool(), pSet->GetRanges() );
987cdf0e10cSrcweir }
988cdf0e10cSrcweir }
989cdf0e10cSrcweir
990cdf0e10cSrcweir // -----------------------------------------------------------------------
991cdf0e10cSrcweir
PageCreated(sal_uInt16,IconChoicePage &)992cdf0e10cSrcweir void IconChoiceDialog::PageCreated( sal_uInt16 /*nId*/, IconChoicePage& /*rPage*/ )
993cdf0e10cSrcweir {
994cdf0e10cSrcweir // not interested in
995cdf0e10cSrcweir }
996cdf0e10cSrcweir
997cdf0e10cSrcweir // -----------------------------------------------------------------------
998cdf0e10cSrcweir
CreateInputItemSet(sal_uInt16)999cdf0e10cSrcweir SfxItemSet* IconChoiceDialog::CreateInputItemSet( sal_uInt16 )
1000cdf0e10cSrcweir {
1001cdf0e10cSrcweir DBG_WARNINGFILE( "CreateInputItemSet nicht implementiert" );
1002cdf0e10cSrcweir
1003cdf0e10cSrcweir return 0;
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir
1006cdf0e10cSrcweir /**********************************************************************
1007cdf0e10cSrcweir |
1008cdf0e10cSrcweir | start dialog
1009cdf0e10cSrcweir |
1010cdf0e10cSrcweir \**********************************************************************/
1011cdf0e10cSrcweir
Execute()1012cdf0e10cSrcweir short IconChoiceDialog::Execute()
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir if ( !maPageList.Count() )
1015cdf0e10cSrcweir return RET_CANCEL;
1016cdf0e10cSrcweir
1017cdf0e10cSrcweir Start_Impl();
1018cdf0e10cSrcweir
1019cdf0e10cSrcweir return Dialog::Execute();
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir // -----------------------------------------------------------------------
1023cdf0e10cSrcweir
Start(sal_Bool bShow)1024cdf0e10cSrcweir void IconChoiceDialog::Start( sal_Bool bShow )
1025cdf0e10cSrcweir {
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir aCancelBtn.SetClickHdl( LINK( this, IconChoiceDialog, CancelHdl ) );
1028cdf0e10cSrcweir bModal = sal_False;
1029cdf0e10cSrcweir
1030cdf0e10cSrcweir Start_Impl();
1031cdf0e10cSrcweir
1032cdf0e10cSrcweir if ( bShow )
1033cdf0e10cSrcweir Window::Show();
1034cdf0e10cSrcweir
1035cdf0e10cSrcweir }
1036cdf0e10cSrcweir
1037cdf0e10cSrcweir // -----------------------------------------------------------------------
1038cdf0e10cSrcweir
QueryClose()1039cdf0e10cSrcweir sal_Bool IconChoiceDialog::QueryClose()
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir sal_Bool bRet = sal_True;
1042cdf0e10cSrcweir const sal_uLong nCount = maPageList.Count();
1043cdf0e10cSrcweir for ( sal_uLong i = 0; i < nCount; ++i )
1044cdf0e10cSrcweir {
1045cdf0e10cSrcweir IconChoicePageData* pData = maPageList.GetObject(i);
1046cdf0e10cSrcweir if ( pData->pPage && !pData->pPage->QueryClose() )
1047cdf0e10cSrcweir {
1048cdf0e10cSrcweir bRet = sal_False;
1049cdf0e10cSrcweir break;
1050cdf0e10cSrcweir }
1051cdf0e10cSrcweir }
1052cdf0e10cSrcweir return bRet;
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir
1055cdf0e10cSrcweir // -----------------------------------------------------------------------
1056cdf0e10cSrcweir
Start_Impl()1057cdf0e10cSrcweir void IconChoiceDialog::Start_Impl()
1058cdf0e10cSrcweir {
1059cdf0e10cSrcweir Point aPos;
1060cdf0e10cSrcweir sal_uInt16 nActPage;
1061cdf0e10cSrcweir
1062cdf0e10cSrcweir if ( mnCurrentPageId == 0 || mnCurrentPageId == USHRT_MAX )
1063cdf0e10cSrcweir nActPage = maPageList.GetObject(0)->nId;//First()->nId;
1064cdf0e10cSrcweir else
1065cdf0e10cSrcweir nActPage = mnCurrentPageId;
1066cdf0e10cSrcweir
1067cdf0e10cSrcweir // Konfiguration vorhanden?
1068cdf0e10cSrcweir SvtViewOptions aTabDlgOpt( E_TABDIALOG, String::CreateFromInt32( nResId ) );
1069cdf0e10cSrcweir
1070cdf0e10cSrcweir if ( aTabDlgOpt.Exists() )
1071cdf0e10cSrcweir {
1072cdf0e10cSrcweir // ggf. Position aus Konfig
1073cdf0e10cSrcweir SetWindowState( ByteString( aTabDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) );
1074cdf0e10cSrcweir
1075cdf0e10cSrcweir // initiale TabPage aus Programm/Hilfe/Konfig
1076cdf0e10cSrcweir nActPage = (sal_uInt16)aTabDlgOpt.GetPageID();
1077cdf0e10cSrcweir
1078cdf0e10cSrcweir if ( USHRT_MAX != mnCurrentPageId )
1079cdf0e10cSrcweir nActPage = mnCurrentPageId;
1080cdf0e10cSrcweir
1081cdf0e10cSrcweir if ( GetPageData ( nActPage ) == NULL )
1082cdf0e10cSrcweir nActPage = ( (IconChoicePageData*)maPageList.GetObject(0) )->nId;
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir else if ( USHRT_MAX != mnCurrentPageId && GetPageData ( mnCurrentPageId ) != NULL )
1085cdf0e10cSrcweir nActPage = mnCurrentPageId;
1086cdf0e10cSrcweir
1087cdf0e10cSrcweir mnCurrentPageId = nActPage;
1088cdf0e10cSrcweir
1089cdf0e10cSrcweir FocusOnIcon( mnCurrentPageId );
1090cdf0e10cSrcweir
1091cdf0e10cSrcweir ActivatePageImpl();
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir
1094cdf0e10cSrcweir // -----------------------------------------------------------------------
1095cdf0e10cSrcweir
GetRefreshedSet()1096cdf0e10cSrcweir const SfxItemSet* IconChoiceDialog::GetRefreshedSet()
1097cdf0e10cSrcweir {
1098cdf0e10cSrcweir DBG_ERRORFILE( "GetRefreshedSet nicht implementiert" );
1099cdf0e10cSrcweir return 0;
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir
1102cdf0e10cSrcweir /**********************************************************************
1103cdf0e10cSrcweir |
1104cdf0e10cSrcweir | tool-methods
1105cdf0e10cSrcweir |
1106cdf0e10cSrcweir \**********************************************************************/
1107cdf0e10cSrcweir
GetPageData(sal_uInt16 nId)1108cdf0e10cSrcweir IconChoicePageData* IconChoiceDialog::GetPageData ( sal_uInt16 nId )
1109cdf0e10cSrcweir {
1110cdf0e10cSrcweir IconChoicePageData *pRet = NULL;
1111cdf0e10cSrcweir sal_Bool bFound = sal_False;
1112cdf0e10cSrcweir
1113cdf0e10cSrcweir for ( sal_uLong i=0; i<maPageList.Count() && !bFound; i++ )
1114cdf0e10cSrcweir {
1115cdf0e10cSrcweir IconChoicePageData* pData = (IconChoicePageData*)maPageList.GetObject ( i );
1116cdf0e10cSrcweir
1117cdf0e10cSrcweir if ( pData->nId == nId )
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir pRet = pData;
1120cdf0e10cSrcweir }
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir
1123cdf0e10cSrcweir return pRet;
1124cdf0e10cSrcweir }
1125cdf0e10cSrcweir
1126cdf0e10cSrcweir /**********************************************************************
1127cdf0e10cSrcweir |
1128cdf0e10cSrcweir | OK-Status
1129cdf0e10cSrcweir |
1130cdf0e10cSrcweir \**********************************************************************/
1131cdf0e10cSrcweir
OK_Impl()1132cdf0e10cSrcweir sal_Bool IconChoiceDialog::OK_Impl()
1133cdf0e10cSrcweir {
1134cdf0e10cSrcweir IconChoicePage* pPage = GetPageData ( mnCurrentPageId )->pPage;
1135cdf0e10cSrcweir
1136cdf0e10cSrcweir bool bEnd = !pPage;
1137cdf0e10cSrcweir if ( pPage )
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir int nRet = IconChoicePage::LEAVE_PAGE;
1140cdf0e10cSrcweir if ( pSet )
1141cdf0e10cSrcweir {
1142cdf0e10cSrcweir SfxItemSet aTmp( *pSet->GetPool(), pSet->GetRanges() );
1143cdf0e10cSrcweir sal_Bool bRet = sal_False;
1144cdf0e10cSrcweir
1145cdf0e10cSrcweir if ( pPage->HasExchangeSupport() )
1146cdf0e10cSrcweir nRet = pPage->DeactivatePage( &aTmp );
1147cdf0e10cSrcweir
1148cdf0e10cSrcweir if ( ( IconChoicePage::LEAVE_PAGE & nRet ) == IconChoicePage::LEAVE_PAGE
1149cdf0e10cSrcweir && aTmp.Count() )
1150cdf0e10cSrcweir {
1151cdf0e10cSrcweir pExampleSet->Put( aTmp );
1152cdf0e10cSrcweir pOutSet->Put( aTmp );
1153cdf0e10cSrcweir }
1154cdf0e10cSrcweir else if ( bRet )
1155cdf0e10cSrcweir bModified |= sal_True;
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir else
1158cdf0e10cSrcweir nRet = pPage->DeactivatePage( NULL );
1159cdf0e10cSrcweir bEnd = nRet;
1160cdf0e10cSrcweir }
1161cdf0e10cSrcweir
1162cdf0e10cSrcweir return bEnd;
1163cdf0e10cSrcweir }
1164cdf0e10cSrcweir
1165cdf0e10cSrcweir // -----------------------------------------------------------------------
1166cdf0e10cSrcweir
Ok()1167cdf0e10cSrcweir short IconChoiceDialog::Ok()
1168cdf0e10cSrcweir {
1169cdf0e10cSrcweir bInOK = sal_True;
1170cdf0e10cSrcweir
1171cdf0e10cSrcweir if ( !pOutSet )
1172cdf0e10cSrcweir {
1173cdf0e10cSrcweir if ( !pExampleSet && pSet )
1174cdf0e10cSrcweir pOutSet = pSet->Clone( sal_False ); // ohne Items
1175cdf0e10cSrcweir else if ( pExampleSet )
1176cdf0e10cSrcweir pOutSet = new SfxItemSet( *pExampleSet );
1177cdf0e10cSrcweir }
1178cdf0e10cSrcweir sal_Bool _bModified = sal_False;
1179cdf0e10cSrcweir
1180cdf0e10cSrcweir const sal_uLong nCount = maPageList.Count();
1181cdf0e10cSrcweir
1182cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; ++i )
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir IconChoicePageData* pData = GetPageData ( i );
1185cdf0e10cSrcweir
1186cdf0e10cSrcweir IconChoicePage* pPage = pData->pPage;
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir if ( pPage )
1189cdf0e10cSrcweir {
1190cdf0e10cSrcweir if ( pData->bOnDemand )
1191cdf0e10cSrcweir {
1192cdf0e10cSrcweir SfxItemSet& rSet = (SfxItemSet&)pPage->GetItemSet();
1193cdf0e10cSrcweir rSet.ClearItem();
1194cdf0e10cSrcweir _bModified |= pPage->FillItemSet( rSet );
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir else if ( pSet && !pPage->HasExchangeSupport() )
1197cdf0e10cSrcweir {
1198cdf0e10cSrcweir SfxItemSet aTmp( *pSet->GetPool(), pSet->GetRanges() );
1199cdf0e10cSrcweir
1200cdf0e10cSrcweir if ( pPage->FillItemSet( aTmp ) )
1201cdf0e10cSrcweir {
1202cdf0e10cSrcweir _bModified |= sal_True;
1203cdf0e10cSrcweir pExampleSet->Put( aTmp );
1204cdf0e10cSrcweir pOutSet->Put( aTmp );
1205cdf0e10cSrcweir }
1206cdf0e10cSrcweir }
1207cdf0e10cSrcweir }
1208cdf0e10cSrcweir }
1209cdf0e10cSrcweir
1210cdf0e10cSrcweir if ( _bModified || ( pOutSet && pOutSet->Count() > 0 ) )
1211cdf0e10cSrcweir _bModified |= sal_True;
1212cdf0e10cSrcweir
1213cdf0e10cSrcweir return _bModified ? RET_OK : RET_CANCEL;
1214cdf0e10cSrcweir }
1215cdf0e10cSrcweir
1216cdf0e10cSrcweir // -----------------------------------------------------------------------
1217cdf0e10cSrcweir
FocusOnIcon(sal_uInt16 nId)1218cdf0e10cSrcweir void IconChoiceDialog::FocusOnIcon( sal_uInt16 nId )
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir // set focus to icon for the current visible page
1221cdf0e10cSrcweir for ( sal_uInt16 i=0; i<maIconCtrl.GetEntryCount(); i++)
1222cdf0e10cSrcweir {
1223cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = maIconCtrl.GetEntry ( i );
1224cdf0e10cSrcweir sal_uInt16* pUserData = (sal_uInt16*) pEntry->GetUserData();
1225cdf0e10cSrcweir
1226cdf0e10cSrcweir if ( pUserData && *pUserData == nId )
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir maIconCtrl.SetCursor( pEntry );
1229cdf0e10cSrcweir break;
1230cdf0e10cSrcweir }
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir }
1233