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