Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / sfx2 / source / dialog / basedlgs.cxx
blob3379d8f04c7360e34c29d314dd2c9950bbd21ff8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
30 // include ---------------------------------------------------------------
32 #include <stdlib.h>
33 #include <vcl/fixed.hxx>
34 #include <vcl/help.hxx>
35 #include <vcl/msgbox.hxx>
36 #include <svl/eitem.hxx>
37 #include <unotools/viewoptions.hxx>
38 #include <svtools/fixedhyper.hxx>
39 #include <svtools/controldims.hrc>
41 #include <sfx2/basedlgs.hxx>
42 #include <sfx2/viewfrm.hxx>
43 #include <sfx2/tabdlg.hxx>
44 #include <sfx2/app.hxx>
45 #include <sfx2/bindings.hxx>
46 #include <sfx2/dispatch.hxx>
47 #include <sfx2/childwin.hxx>
48 #include <sfx2/viewsh.hxx>
49 #include "sfx2/sfxhelp.hxx"
50 #include "workwin.hxx"
51 #include "sfx2/sfxresid.hxx"
52 #include "dialog.hrc"
54 using namespace ::com::sun::star::uno;
55 using namespace ::rtl;
57 #define USERITEM_NAME OUString("UserItem")
59 class SfxModelessDialog_Impl : public SfxListener
61 public:
62 rtl::OString aWinState;
63 SfxChildWindow* pMgr;
64 sal_Bool bConstructed;
65 void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
67 Timer aMoveTimer;
70 void SfxModelessDialog_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint )
72 if ( rHint.IsA(TYPE(SfxSimpleHint)) )
74 switch( ( (SfxSimpleHint&) rHint ).GetId() )
76 case SFX_HINT_DYING:
77 pMgr->Destroy();
78 break;
83 class SfxFloatingWindow_Impl : public SfxListener
85 public:
86 rtl::OString aWinState;
87 SfxChildWindow* pMgr;
88 sal_Bool bConstructed;
89 Timer aMoveTimer;
91 void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
94 void SfxFloatingWindow_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint )
96 if ( rHint.IsA(TYPE(SfxSimpleHint)) )
98 switch( ( (SfxSimpleHint&) rHint ).GetId() )
100 case SFX_HINT_DYING:
101 pMgr->Destroy();
102 break;
107 // class SfxModalDefParentHelper -----------------------------------------
109 SfxModalDefParentHelper::SfxModalDefParentHelper( Window *pWindow)
111 pOld = Application::GetDefDialogParent();
112 Application::SetDefDialogParent( pWindow );
115 // -----------------------------------------------------------------------
117 SfxModalDefParentHelper::~SfxModalDefParentHelper()
119 Application::SetDefDialogParent( pOld );
122 // -----------------------------------------------------------------------
124 void SfxModalDialog::SetDialogData_Impl()
126 // save settings (position and user data)
127 SvtViewOptions aDlgOpt( E_DIALOG, String::CreateFromInt32( nUniqId ) );
128 aDlgOpt.SetWindowState(OStringToOUString(
129 GetWindowState(WINDOWSTATE_MASK_POS), RTL_TEXTENCODING_ASCII_US));
130 if ( aExtraData.Len() )
131 aDlgOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( aExtraData ) ) );
134 // -----------------------------------------------------------------------
136 void SfxModalDialog::GetDialogData_Impl()
138 /* [Description]
140 Helper function, reads the dialogue position from the ini file and
141 puts them on the transfered window.
145 SvtViewOptions aDlgOpt( E_DIALOG, String::CreateFromInt32( nUniqId ) );
146 if ( aDlgOpt.Exists() )
148 // load settings
149 SetWindowState( rtl::OUStringToOString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) );
150 Any aUserItem = aDlgOpt.GetUserItem( USERITEM_NAME );
151 OUString aTemp;
152 if ( aUserItem >>= aTemp )
153 aExtraData = String( aTemp );
157 // -----------------------------------------------------------------------
159 void SfxModalDialog::init()
161 GetDialogData_Impl();
164 // -----------------------------------------------------------------------
166 SfxModalDialog::SfxModalDialog(Window* pParent, const ResId &rResId )
168 /* [Description]
170 Constructor of the general base class for modal Dialoge;
171 ResId is used as ID in ini-file. The saved position from there is set.
174 : ModalDialog(pParent, rResId),
175 nUniqId(rResId.GetId()),
176 pInputSet(0),
177 pOutputSet(0)
179 init();
182 // -----------------------------------------------------------------------
184 SfxModalDialog::SfxModalDialog(Window* pParent,
185 sal_uInt32 nUniqueId,
186 WinBits nWinStyle) :
187 /* [Description]
189 Constructor of the general base class for modal Dialoge;
190 The ID for the ini-file wird explicilty handed over.
191 The saved position from there is set.
194 ModalDialog(pParent, nWinStyle),
195 nUniqId(nUniqueId),
196 pInputSet(0),
197 pOutputSet(0)
199 init();
202 // -----------------------------------------------------------------------
204 SfxModalDialog::~SfxModalDialog()
206 /* [Description]
208 Destructor; writes the Dialog position in the ini-file.
212 SetDialogData_Impl();
213 delete pOutputSet;
216 void SfxModalDialog::CreateOutputItemSet( SfxItemPool& rPool )
218 DBG_ASSERT( !pOutputSet, "Double creation of OutputSet!" );
219 if (!pOutputSet)
220 pOutputSet = new SfxAllItemSet( rPool );
223 // -----------------------------------------------------------------------
225 void SfxModalDialog::CreateOutputItemSet( const SfxItemSet& rSet )
227 DBG_ASSERT( !pOutputSet, "Double creation of OutputSet!" );
228 if (!pOutputSet)
230 pOutputSet = new SfxItemSet( rSet );
231 pOutputSet->ClearItem();
235 //-------------------------------------------------------------------------
236 void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
238 if ( nStateChange == STATE_CHANGE_INITSHOW )
240 if ( !pImp->aWinState.isEmpty() )
242 SetWindowState( pImp->aWinState );
244 else
246 Point aPos = GetPosPixel();
247 if ( !aPos.X() )
249 aSize = GetSizePixel();
251 Size aParentSize = GetParent()->GetOutputSizePixel();
252 Size aDlgSize = GetSizePixel();
253 aPos.X() += ( aParentSize.Width() - aDlgSize.Width() ) / 2;
254 aPos.Y() += ( aParentSize.Height() - aDlgSize.Height() ) / 2;
256 Point aPoint;
257 Rectangle aRect = GetDesktopRectPixel();
258 aPoint.X() = aRect.Right() - aDlgSize.Width();
259 aPoint.Y() = aRect.Bottom() - aDlgSize.Height();
261 aPoint = OutputToScreenPixel( aPoint );
263 if ( aPos.X() > aPoint.X() )
264 aPos.X() = aPoint.X() ;
265 if ( aPos.Y() > aPoint.Y() )
266 aPos.Y() = aPoint.Y();
268 if ( aPos.X() < 0 ) aPos.X() = 0;
269 if ( aPos.Y() < 0 ) aPos.Y() = 0;
271 SetPosPixel( aPos );
275 pImp->bConstructed = sal_True;
278 ModelessDialog::StateChanged( nStateChange );
281 void SfxModelessDialog::Initialize(SfxChildWinInfo *pInfo)
283 /* [Description]
285 Initialization of the class SfxModelessDialog via a SfxChildWinInfo.
286 The initialization is done only in a 2nd step after the constructor, this
287 constructor should be called from the derived class or from the
288 SfxChildWindows.
292 pImp->aWinState = pInfo->aWinState;
295 void SfxModelessDialog::Resize()
297 /* [Description]
299 This virtual method of the class FloatingWindow keeps track if a change
300 in size has been made. When this method is overridden by a derived class,
301 then the SfxFloatingWindow: Resize() must also be called.
305 ModelessDialog::Resize();
306 if ( pImp->bConstructed && pImp->pMgr )
308 // start timer for saving window status information
309 pImp->aMoveTimer.Start();
313 void SfxModelessDialog::Move()
315 ModelessDialog::Move();
316 if ( pImp->bConstructed && pImp->pMgr && IsReallyVisible() )
318 // start timer for saving window status information
319 pImp->aMoveTimer.Start();
324 Implements a timer event that is triggered by a move or resize of the window
325 This will save config information to Views.xcu with a small delay
327 IMPL_LINK_NOARG(SfxModelessDialog, TimerHdl)
329 pImp->aMoveTimer.Stop();
330 if ( pImp->bConstructed && pImp->pMgr )
332 if ( !IsRollUp() )
333 aSize = GetSizePixel();
334 sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE;
335 if ( GetStyle() & WB_SIZEABLE )
336 nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT );
337 pImp->aWinState = GetWindowState( nMask );
338 GetBindings().GetWorkWindow_Impl()->ConfigChild_Impl( SFX_CHILDWIN_DOCKINGWINDOW, SFX_ALIGNDOCKINGWINDOW, pImp->pMgr->GetType() );
340 return 0;
343 // -----------------------------------------------------------------------
345 SfxModelessDialog::SfxModelessDialog( SfxBindings *pBindinx,
346 SfxChildWindow *pCW, Window *pParent,
347 const ResId& rResId ) :
348 ModelessDialog(pParent, rResId),
349 pBindings(pBindinx),
350 pImp( new SfxModelessDialog_Impl )
352 pImp->pMgr = pCW;
353 pImp->bConstructed = sal_False;
354 SetUniqueId( GetHelpId() );
355 SetHelpId("");
356 if ( pBindinx )
357 pImp->StartListening( *pBindinx );
358 pImp->aMoveTimer.SetTimeout(50);
359 pImp->aMoveTimer.SetTimeoutHdl(LINK(this,SfxModelessDialog,TimerHdl));
362 // -----------------------------------------------------------------------
364 long SfxModelessDialog::Notify( NotifyEvent& rEvt )
366 /* [Description]
368 If a ModelessDialog is enabled its ViewFrame wil be activated.
369 This is necessary by PluginInFrames.
373 if ( rEvt.GetType() == EVENT_GETFOCUS )
375 pBindings->SetActiveFrame( pImp->pMgr->GetFrame() );
376 pImp->pMgr->Activate_Impl();
377 Window* pWindow = rEvt.GetWindow();
378 rtl::OString sHelpId;
379 while ( sHelpId.isEmpty() && pWindow )
381 sHelpId = pWindow->GetHelpId();
382 pWindow = pWindow->GetParent();
385 if ( !sHelpId.isEmpty() )
386 SfxHelp::OpenHelpAgent( &pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(), sHelpId );
388 else if ( rEvt.GetType() == EVENT_LOSEFOCUS && !HasChildPathFocus() )
390 pBindings->SetActiveFrame( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > () );
391 pImp->pMgr->Deactivate_Impl();
393 else if( rEvt.GetType() == EVENT_KEYINPUT )
395 // First, allow KeyInput for Dialog functions ( TAB etc. )
396 if ( !ModelessDialog::Notify( rEvt ) && SfxViewShell::Current() )
397 // then also for valid global accelerators.
398 return SfxViewShell::Current()->GlobalKeyInput_Impl( *rEvt.GetKeyEvent() );
399 return sal_True;
402 return ModelessDialog::Notify( rEvt );
405 // -----------------------------------------------------------------------
407 SfxModelessDialog::~SfxModelessDialog()
409 /* [Description]
411 Destructor
415 if ( pImp->pMgr->GetFrame().is() && pImp->pMgr->GetFrame() == pBindings->GetActiveFrame() )
416 pBindings->SetActiveFrame( NULL );
417 delete pImp;
420 //-------------------------------------------------------------------------
422 sal_Bool SfxModelessDialog::Close()
424 /* [Description]
426 The window is closed when the ChildWindow is destroyed by running the
427 ChildWindow-slots. If this is method is overridden by a derived class
428 method, then the SfxModelessDialogWindow: Close() must be called afterwards
429 if the Close() was not cancelled with "return sal_False".
433 // Execute with Parameters, since Toggle is ignored by some ChildWindows.
434 SfxBoolItem aValue( pImp->pMgr->GetType(), sal_False);
435 pBindings->GetDispatcher_Impl()->Execute(
436 pImp->pMgr->GetType(),
437 SFX_CALLMODE_RECORD|SFX_CALLMODE_SYNCHRON, &aValue, 0L );
438 return sal_True;
441 //-------------------------------------------------------------------------
443 void SfxModelessDialog::FillInfo(SfxChildWinInfo& rInfo) const
445 /* [Description]
447 Fills a SfxChildWinInfo with specific data from SfxModelessDialog,
448 so that it can be written in the INI file. It is assumed that rinfo
449 receives all other possible relevant data in the ChildWindow class.
450 ModelessDialogs have no specific information, so that the base
451 implementation does nothing and therefore must not be called.
455 rInfo.aSize = aSize;
456 if ( IsRollUp() )
457 rInfo.nFlags |= SFX_CHILDWIN_ZOOMIN;
460 // -----------------------------------------------------------------------
462 long SfxFloatingWindow::Notify( NotifyEvent& rEvt )
464 /* [Description]
466 If a ModelessDialog is enabled, its ViewFrame will be activated.
467 This necessary for the PluginInFrames.
471 if ( rEvt.GetType() == EVENT_GETFOCUS )
473 pBindings->SetActiveFrame( pImp->pMgr->GetFrame() );
474 pImp->pMgr->Activate_Impl();
475 Window* pWindow = rEvt.GetWindow();
476 rtl::OString sHelpId;
477 while ( sHelpId.isEmpty() && pWindow )
479 sHelpId = pWindow->GetHelpId();
480 pWindow = pWindow->GetParent();
483 if ( !sHelpId.isEmpty() )
484 SfxHelp::OpenHelpAgent( &pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(), sHelpId );
486 else if ( rEvt.GetType() == EVENT_LOSEFOCUS )
488 if ( !HasChildPathFocus() )
490 pBindings->SetActiveFrame( NULL );
491 pImp->pMgr->Deactivate_Impl();
494 else if( rEvt.GetType() == EVENT_KEYINPUT )
496 // First, allow KeyInput for Dialog functions
497 if ( !FloatingWindow::Notify( rEvt ) && SfxViewShell::Current() )
498 // then also for valid global accelerators.
499 return SfxViewShell::Current()->GlobalKeyInput_Impl( *rEvt.GetKeyEvent() );
500 return sal_True;
503 return FloatingWindow::Notify( rEvt );
506 // -----------------------------------------------------------------------
508 SfxFloatingWindow::SfxFloatingWindow( SfxBindings *pBindinx,
509 SfxChildWindow *pCW,
510 Window* pParent, WinBits nWinBits) :
511 FloatingWindow (pParent, nWinBits),
512 pBindings(pBindinx),
513 pImp( new SfxFloatingWindow_Impl )
515 pImp->pMgr = pCW;
516 pImp->bConstructed = sal_False;
517 SetUniqueId( GetHelpId() );
518 SetHelpId("");
519 if ( pBindinx )
520 pImp->StartListening( *pBindinx );
521 pImp->aMoveTimer.SetTimeout(50);
522 pImp->aMoveTimer.SetTimeoutHdl(LINK(this,SfxFloatingWindow,TimerHdl));
525 // -----------------------------------------------------------------------
527 SfxFloatingWindow::SfxFloatingWindow( SfxBindings *pBindinx,
528 SfxChildWindow *pCW,
529 Window* pParent,
530 const ResId& rResId) :
531 FloatingWindow(pParent, rResId),
532 pBindings(pBindinx),
533 pImp( new SfxFloatingWindow_Impl )
535 pImp->pMgr = pCW;
536 pImp->bConstructed = sal_False;
537 SetUniqueId( GetHelpId() );
538 SetHelpId("");
539 if ( pBindinx )
540 pImp->StartListening( *pBindinx );
541 pImp->aMoveTimer.SetTimeout(50);
542 pImp->aMoveTimer.SetTimeoutHdl(LINK(this,SfxFloatingWindow,TimerHdl));
545 //-------------------------------------------------------------------------
547 sal_Bool SfxFloatingWindow::Close()
549 /* [Description]
551 The window is closed when the ChildWindow is destroyed by running the
552 ChildWindow-slots. If this is method is overridden by a derived class
553 method, then the SfxModelessDialogWindow: Close) must be called afterwards
554 if the Close() was not cancelled with "return sal_False".
558 // Execute with Parameters, since Toggle is ignored by some ChildWindows.
559 SfxBoolItem aValue( pImp->pMgr->GetType(), sal_False);
560 pBindings->GetDispatcher_Impl()->Execute(
561 pImp->pMgr->GetType(),
562 SFX_CALLMODE_RECORD|SFX_CALLMODE_SYNCHRON, &aValue, 0L );
563 return sal_True;
566 // -----------------------------------------------------------------------
568 SfxFloatingWindow::~SfxFloatingWindow()
570 /* [Description]
572 Destructor
576 if ( pImp->pMgr->GetFrame() == pBindings->GetActiveFrame() )
577 pBindings->SetActiveFrame( NULL );
578 delete pImp;
581 //-------------------------------------------------------------------------
583 void SfxFloatingWindow::Resize()
585 /* [Description]
587 This virtual method of the class FloatingWindow keeps track if a change
588 in size has been made. When this method is overridden by a derived class,
589 then the SfxFloatingWindow: Resize() must also be called.
593 FloatingWindow::Resize();
594 if ( pImp->bConstructed && pImp->pMgr )
596 // start timer for saving window status information
597 pImp->aMoveTimer.Start();
601 void SfxFloatingWindow::Move()
603 FloatingWindow::Move();
604 if ( pImp->bConstructed && pImp->pMgr )
606 // start timer for saving window status information
607 pImp->aMoveTimer.Start();
612 Implements a timer event that is triggered by a move or resize of the window
613 This will save config information to Views.xcu with a small delay
615 IMPL_LINK_NOARG(SfxFloatingWindow, TimerHdl)
617 pImp->aMoveTimer.Stop();
618 if ( pImp->bConstructed && pImp->pMgr )
620 if ( !IsRollUp() )
621 aSize = GetSizePixel();
622 sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE;
623 if ( GetStyle() & WB_SIZEABLE )
624 nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT );
625 pImp->aWinState = GetWindowState( nMask );
626 GetBindings().GetWorkWindow_Impl()->ConfigChild_Impl( SFX_CHILDWIN_DOCKINGWINDOW, SFX_ALIGNDOCKINGWINDOW, pImp->pMgr->GetType() );
628 return 0;
631 //-------------------------------------------------------------------------
632 void SfxFloatingWindow::StateChanged( StateChangedType nStateChange )
634 if ( nStateChange == STATE_CHANGE_INITSHOW )
636 // FloatingWindows are not centered by default
637 if ( !pImp->aWinState.isEmpty() )
638 SetWindowState( pImp->aWinState );
639 pImp->bConstructed = sal_True;
642 FloatingWindow::StateChanged( nStateChange );
646 void SfxFloatingWindow::Initialize(SfxChildWinInfo *pInfo)
648 /* [Description]
650 Initialization of a class SfxFloatingWindow through a SfxChildWinInfo.
651 The initialization is done only in a 2nd step after the constructor and
652 should be called by the constructor of the derived class or from the
653 SfxChildWindows.
656 pImp->aWinState = pInfo->aWinState;
659 //-------------------------------------------------------------------------
661 void SfxFloatingWindow::FillInfo(SfxChildWinInfo& rInfo) const
663 /* [Description]
665 Fills a SfxChildWinInfo with specific data from SfxFloatingWindow,
666 so that it can be written in the INI file. It is assumed that rinfo
667 receives all other possible relevant data in the ChildWindow class.
668 Insertions are marked with size and the ZoomIn flag.
669 If this method is overridden, the base implementation must be called first.
673 rInfo.aSize = aSize;
674 if ( IsRollUp() )
675 rInfo.nFlags |= SFX_CHILDWIN_ZOOMIN;
678 // SfxSingleTabDialog ----------------------------------------------------
680 IMPL_LINK_NOARG(SfxSingleTabDialog, OKHdl_Impl)
682 /* [Description]
684 Ok_Handler; FillItemSet() is called for setting of Page.
688 if ( !GetInputItemSet() )
690 // TabPage without ItemSet
691 EndDialog( RET_OK );
692 return 1;
695 if ( !GetOutputItemSet() )
697 CreateOutputItemSet( *GetInputItemSet() );
699 sal_Bool bModified = sal_False;
701 if ( pImpl->m_pSfxPage->HasExchangeSupport() )
703 int nRet = pImpl->m_pSfxPage->DeactivatePage( GetOutputSetImpl() );
704 if ( nRet != SfxTabPage::LEAVE_PAGE )
705 return 0;
706 else
707 bModified = ( GetOutputItemSet()->Count() > 0 );
709 else
710 bModified = pImpl->m_pSfxPage->FillItemSet( *GetOutputSetImpl() );
712 if ( bModified )
714 // Save user data in IniManager.
715 pImpl->m_pSfxPage->FillUserData();
716 String sData( pImpl->m_pSfxPage->GetUserData() );
717 SvtViewOptions aPageOpt( E_TABPAGE, String::CreateFromInt32( GetUniqId() ) );
718 aPageOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( sData ) ) );
719 EndDialog( RET_OK );
721 else
722 EndDialog( RET_CANCEL );
723 return 0;
726 // -----------------------------------------------------------------------
728 SfxSingleTabDialog::SfxSingleTabDialog
730 Window *pParent,
731 const SfxItemSet& rSet,
732 sal_uInt16 nUniqueId
735 /* [Description]
737 Constructor of the general base class for SingleTab-Dialoge;
738 ID for the ini-file is handed over.
741 SfxModalDialog( pParent, nUniqueId, WinBits( WB_STDMODAL | WB_3DLOOK ) ),
743 pOKBtn ( 0 ),
744 pCancelBtn ( 0 ),
745 pHelpBtn ( 0 ),
746 pImpl ( new SingleTabDlgImpl )
748 DBG_WARNING( "please use the constructor with ViewFrame" );
749 SetInputSet( &rSet );
752 // -----------------------------------------------------------------------
754 SfxSingleTabDialog::SfxSingleTabDialog
756 Window* pParent,
757 sal_uInt16 nUniqueId,
758 const SfxItemSet* pInSet
761 /* [Description]
763 Constructor of the general base class for SingleTab-Dialoge;
764 ID for the ini-file is handed over.
765 Deprecated.
768 : SfxModalDialog( pParent, nUniqueId, WinBits( WB_STDMODAL | WB_3DLOOK ) ),
770 pOKBtn ( 0 ),
771 pCancelBtn ( 0 ),
772 pHelpBtn ( 0 ),
773 pImpl ( new SingleTabDlgImpl )
775 DBG_WARNING( "please use the constructor with ViewFrame" );
776 SetInputSet( pInSet );
779 // -----------------------------------------------------------------------
781 SfxSingleTabDialog::~SfxSingleTabDialog()
783 delete pOKBtn;
784 delete pCancelBtn;
785 delete pHelpBtn;
786 delete pImpl->m_pTabPage;
787 delete pImpl->m_pSfxPage;
788 delete pImpl->m_pLine;
789 delete pImpl;
792 // -----------------------------------------------------------------------
794 void SfxSingleTabDialog::SetTabPage( SfxTabPage* pTabPage,
795 GetTabPageRanges pRangesFunc )
796 /* [Description]
798 Insert a (new) TabPage; an existing page is deleted.
799 The passed on page is initialized with the initially given Itemset
800 through calling Reset().
804 if ( !pOKBtn )
806 pOKBtn = new OKButton( this, WB_DEFBUTTON );
807 pOKBtn->SetClickHdl( LINK( this, SfxSingleTabDialog, OKHdl_Impl ) );
809 if ( !pCancelBtn )
810 pCancelBtn = new CancelButton( this );
811 if ( !pHelpBtn )
812 pHelpBtn = new HelpButton( this );
814 if ( pImpl->m_pTabPage )
815 delete pImpl->m_pTabPage;
816 if ( pImpl->m_pSfxPage )
817 delete pImpl->m_pSfxPage;
818 pImpl->m_pSfxPage = pTabPage;
819 fnGetRanges = pRangesFunc;
821 if ( pImpl->m_pSfxPage )
823 // First obtain the user data, only then Reset()
824 SvtViewOptions aPageOpt( E_TABPAGE, String::CreateFromInt32( GetUniqId() ) );
825 String sUserData;
826 Any aUserItem = aPageOpt.GetUserItem( USERITEM_NAME );
827 OUString aTemp;
828 if ( aUserItem >>= aTemp )
829 sUserData = String( aTemp );
830 pImpl->m_pSfxPage->SetUserData( sUserData );
831 pImpl->m_pSfxPage->Reset( *GetInputItemSet() );
832 pImpl->m_pSfxPage->Show();
834 // Adjust size and position
835 pImpl->m_pSfxPage->SetPosPixel( Point() );
836 Size aOutSz( pImpl->m_pSfxPage->GetSizePixel() );
837 Size aBtnSiz = LogicToPixel( Size( 50, 14 ), MAP_APPFONT );
838 Point aPnt( aOutSz.Width(), LogicToPixel( Point( 0, 6 ), MAP_APPFONT ).Y() );
839 aOutSz.Width() += aBtnSiz.Width() + LogicToPixel( Size( 6, 0 ), MAP_APPFONT ).Width();
840 SetOutputSizePixel( aOutSz );
841 pOKBtn->SetPosSizePixel( aPnt, aBtnSiz );
842 pOKBtn->Show();
843 aPnt.Y() = LogicToPixel( Point( 0, 23 ), MAP_APPFONT ).Y();
844 pCancelBtn->SetPosSizePixel( aPnt, aBtnSiz );
845 pCancelBtn->Show();
846 aPnt.Y() = LogicToPixel( Point( 0, 43 ), MAP_APPFONT ).Y();
847 pHelpBtn->SetPosSizePixel( aPnt, aBtnSiz );
849 if ( Help::IsContextHelpEnabled() )
850 pHelpBtn->Show();
852 // Set TabPage text in the Dialog
853 SetText( pImpl->m_pSfxPage->GetText() );
855 // Dialog recieves the HelpId of TabPage
856 SetHelpId( pImpl->m_pSfxPage->GetHelpId() );
857 SetUniqueId( pImpl->m_pSfxPage->GetUniqueId() );
861 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */