1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: basedlgs.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
34 // include ---------------------------------------------------------------
37 #include <vcl/fixed.hxx>
38 #include <vcl/help.hxx>
39 #include <vcl/msgbox.hxx>
40 #include <svtools/eitem.hxx>
41 #include <svtools/viewoptions.hxx>
42 #include <svtools/fixedhyper.hxx>
43 #include <svtools/controldims.hrc>
45 #include <sfx2/basedlgs.hxx>
46 #include <sfx2/viewfrm.hxx>
47 #include <sfx2/tabdlg.hxx>
48 #include <sfx2/app.hxx>
49 #include <sfx2/bindings.hxx>
50 #include <sfx2/dispatch.hxx>
51 #include <sfx2/childwin.hxx>
52 #include <sfx2/viewsh.hxx>
53 #include "sfxhelp.hxx"
54 #include "workwin.hxx"
55 #include "sfxresid.hxx"
58 using namespace ::com::sun::star::uno
;
59 using namespace ::rtl
;
61 #define USERITEM_NAME OUString::createFromAscii( "UserItem" )
63 class SfxModelessDialog_Impl
: public SfxListener
69 void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
74 void SfxModelessDialog_Impl::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
76 if ( rHint
.IsA(TYPE(SfxSimpleHint
)) )
78 switch( ( (SfxSimpleHint
&) rHint
).GetId() )
87 class SfxFloatingWindow_Impl
: public SfxListener
95 void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
98 void SfxFloatingWindow_Impl::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
100 if ( rHint
.IsA(TYPE(SfxSimpleHint
)) )
102 switch( ( (SfxSimpleHint
&) rHint
).GetId() )
111 // class SfxModalDefParentHelper -----------------------------------------
113 SfxModalDefParentHelper::SfxModalDefParentHelper( Window
*pWindow
)
115 pOld
= Application::GetDefDialogParent();
116 Application::SetDefDialogParent( pWindow
);
119 // -----------------------------------------------------------------------
121 SfxModalDefParentHelper::~SfxModalDefParentHelper()
123 Application::SetDefDialogParent( pOld
);
126 // -----------------------------------------------------------------------
128 void SfxModalDialog::SetDialogData_Impl()
130 // save settings (position and user data)
131 SvtViewOptions
aDlgOpt( E_DIALOG
, String::CreateFromInt32( nUniqId
) );
132 aDlgOpt
.SetWindowState(
133 OUString::createFromAscii( GetWindowState( WINDOWSTATE_MASK_POS
).GetBuffer() ) );
134 if ( aExtraData
.Len() )
135 aDlgOpt
.SetUserItem( USERITEM_NAME
, makeAny( OUString( aExtraData
) ) );
138 // -----------------------------------------------------------------------
140 void SfxModalDialog::GetDialogData_Impl()
144 Hilfsfunktion; liest die Dialogposition aus der Ini-Datei
145 und setzt diese am "ubergebenen Window.
149 SvtViewOptions
aDlgOpt( E_DIALOG
, String::CreateFromInt32( nUniqId
) );
150 if ( aDlgOpt
.Exists() )
153 SetWindowState( ByteString( aDlgOpt
.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US
) );
154 Any aUserItem
= aDlgOpt
.GetUserItem( USERITEM_NAME
);
156 if ( aUserItem
>>= aTemp
)
157 aExtraData
= String( aTemp
);
161 // -----------------------------------------------------------------------
163 void SfxModalDialog::init()
165 GetDialogData_Impl();
166 aTimer
.SetTimeout( 100 );
167 aTimer
.SetTimeoutHdl( LINK( this, SfxModalDialog
, TimerHdl_Impl
) );
171 // -----------------------------------------------------------------------
173 SfxModalDialog::SfxModalDialog(Window
* pParent
, const ResId
&rResId
)
177 Konstruktor der allgemeinen Basisklasse f"ur modale Dialoge;
178 ResId wird als ID im ini-file verwendet.
179 Die dort gespeicherte Position wird gesetzt.
182 : ModalDialog(pParent
, rResId
),
183 nUniqId(rResId
.GetId()),
190 // -----------------------------------------------------------------------
192 SfxModalDialog::SfxModalDialog(Window
* pParent
,
193 sal_uInt32 nUniqueId
,
197 Konstruktor der allgemeinen Basisklasse f"ur modale Dialoge;
198 ID f"ur das ini-file wird explizit "ubergeben.
199 Die dort gespeicherte Position wird gesetzt.
202 ModalDialog(pParent
, nWinStyle
),
210 // -----------------------------------------------------------------------
212 SfxModalDialog::~SfxModalDialog()
216 Dtor; schreibt Dialogposition in das ini-file
221 SfxHelpPI *pHelpPI = SFX_APP()->GetHelpPI();
223 pHelpPI->ResetTopic();
225 SetDialogData_Impl();
230 void SfxModalDialog::CreateOutputItemSet( SfxItemPool
& rPool
)
232 DBG_ASSERT( !pOutputSet
, "Double creation of OutputSet!" );
234 pOutputSet
= new SfxAllItemSet( rPool
);
237 // -----------------------------------------------------------------------
239 IMPL_LINK( SfxModalDialog
, TimerHdl_Impl
, Timer
*, EMPTYARG
)
242 SfxHelpPI *pHelpPI = SFX_APP()->GetHelpPI();
244 pHelpPI->LoadTopic( GetHelpId() );
249 void SfxModalDialog::CreateOutputItemSet( const SfxItemSet
& rSet
)
251 DBG_ASSERT( !pOutputSet
, "Double creation of OutputSet!" );
254 pOutputSet
= new SfxItemSet( rSet
);
255 pOutputSet
->ClearItem();
259 //-------------------------------------------------------------------------
260 void SfxModelessDialog::StateChanged( StateChangedType nStateChange
)
262 if ( nStateChange
== STATE_CHANGE_INITSHOW
)
264 if ( pImp
->aWinState
.Len() )
266 SetWindowState( pImp
->aWinState
);
270 Point aPos
= GetPosPixel();
273 aSize
= GetSizePixel();
275 Size aParentSize
= GetParent()->GetOutputSizePixel();
276 Size aDlgSize
= GetSizePixel();
277 aPos
.X() += ( aParentSize
.Width() - aDlgSize
.Width() ) / 2;
278 aPos
.Y() += ( aParentSize
.Height() - aDlgSize
.Height() ) / 2;
281 Rectangle aRect
= GetDesktopRectPixel();
282 aPoint
.X() = aRect
.Right() - aDlgSize
.Width();
283 aPoint
.Y() = aRect
.Bottom() - aDlgSize
.Height();
285 aPoint
= OutputToScreenPixel( aPoint
);
287 if ( aPos
.X() > aPoint
.X() )
288 aPos
.X() = aPoint
.X() ;
289 if ( aPos
.Y() > aPoint
.Y() )
290 aPos
.Y() = aPoint
.Y();
292 if ( aPos
.X() < 0 ) aPos
.X() = 0;
293 if ( aPos
.Y() < 0 ) aPos
.Y() = 0;
299 pImp
->bConstructed
= TRUE
;
302 ModelessDialog::StateChanged( nStateChange
);
305 void SfxModelessDialog::Initialize(SfxChildWinInfo
*pInfo
)
309 Initialisierung der Klasse SfxModelessDialog "uber ein SfxChildWinInfo.
310 Die Initialisierung erfolgt erst in einem 2.Schritt
311 nach dem ctor und sollte vom ctor der abgeleiteten Klasse
312 oder von dem des SfxChildWindows aufgerufen werden.
316 pImp
->aWinState
= pInfo
->aWinState
;
319 void SfxModelessDialog::Resize()
323 Diese virtuelle Methode der Klasse FloatingWindow merkt sich ggf. eine
325 Wird diese Methode von einer abgeleiteten Klasse "uberschrieben, mu\s
326 auch SfxFloatingWindow::Resize() gerufen werden.
330 ModelessDialog::Resize();
331 if ( pImp
->bConstructed
&& pImp
->pMgr
)
333 // start timer for saving window status information
334 pImp
->aMoveTimer
.Start();
338 void SfxModelessDialog::Move()
340 ModelessDialog::Move();
341 if ( pImp
->bConstructed
&& pImp
->pMgr
&& IsReallyVisible() )
343 // start timer for saving window status information
344 pImp
->aMoveTimer
.Start();
349 Implements a timer event that is triggered by a move or resize of the window
350 This will save config information to Views.xcu with a small delay
352 IMPL_LINK( SfxModelessDialog
, TimerHdl
, Timer
*, EMPTYARG
)
354 pImp
->aMoveTimer
.Stop();
355 if ( pImp
->bConstructed
&& pImp
->pMgr
)
358 aSize
= GetSizePixel();
359 ULONG nMask
= WINDOWSTATE_MASK_POS
| WINDOWSTATE_MASK_STATE
;
360 if ( GetStyle() & WB_SIZEABLE
)
361 nMask
|= ( WINDOWSTATE_MASK_WIDTH
| WINDOWSTATE_MASK_HEIGHT
);
362 pImp
->aWinState
= GetWindowState( nMask
);
363 GetBindings().GetWorkWindow_Impl()->ConfigChild_Impl( SFX_CHILDWIN_DOCKINGWINDOW
, SFX_ALIGNDOCKINGWINDOW
, pImp
->pMgr
->GetType() );
368 // -----------------------------------------------------------------------
370 SfxModelessDialog::SfxModelessDialog( SfxBindings
*pBindinx
,
372 Window
* pParent
, WinBits nWinBits
) :
373 ModelessDialog (pParent
, nWinBits
),
375 pImp( new SfxModelessDialog_Impl
)
378 pImp
->bConstructed
= FALSE
;
379 sal_uInt32 nId
= GetHelpId();
383 pImp
->StartListening( *pBindinx
);
384 pImp
->aMoveTimer
.SetTimeout(50);
385 pImp
->aMoveTimer
.SetTimeoutHdl(LINK(this,SfxModelessDialog
,TimerHdl
));
388 // -----------------------------------------------------------------------
390 SfxModelessDialog::SfxModelessDialog( SfxBindings
*pBindinx
,
391 SfxChildWindow
*pCW
, Window
*pParent
,
392 const ResId
& rResId
) :
393 ModelessDialog(pParent
, rResId
),
395 pImp( new SfxModelessDialog_Impl
)
398 pImp
->bConstructed
= FALSE
;
399 sal_uInt32 nId
= GetHelpId();
403 pImp
->StartListening( *pBindinx
);
404 pImp
->aMoveTimer
.SetTimeout(50);
405 pImp
->aMoveTimer
.SetTimeoutHdl(LINK(this,SfxModelessDialog
,TimerHdl
));
408 // -----------------------------------------------------------------------
410 long SfxModelessDialog::Notify( NotifyEvent
& rEvt
)
414 Wenn ein ModelessDialog aktiviert wird, wird sein ViewFrame aktiviert.
415 Notwendig ist das bei PlugInFrames.
419 if ( rEvt
.GetType() == EVENT_GETFOCUS
)
421 pBindings
->SetActiveFrame( pImp
->pMgr
->GetFrame() );
422 pImp
->pMgr
->Activate_Impl();
423 Window
* pWindow
= rEvt
.GetWindow();
425 while ( !nHelpId
&& pWindow
)
427 nHelpId
= pWindow
->GetHelpId();
428 pWindow
= pWindow
->GetParent();
432 SfxHelp::OpenHelpAgent( pBindings
->GetDispatcher_Impl()->GetFrame()->GetFrame(), nHelpId
);
434 else if ( rEvt
.GetType() == EVENT_LOSEFOCUS
&& !HasChildPathFocus() )
436 pBindings
->SetActiveFrame( ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> () );
437 pImp
->pMgr
->Deactivate_Impl();
439 else if( rEvt
.GetType() == EVENT_KEYINPUT
)
441 // KeyInput zuerst f"ur Dialogfunktionen zulassen ( TAB etc. )
442 if ( !ModelessDialog::Notify( rEvt
) && SfxViewShell::Current() )
443 // dann auch global g"ultige Acceleratoren verwenden
444 return SfxViewShell::Current()->GlobalKeyInput_Impl( *rEvt
.GetKeyEvent() );
448 return ModelessDialog::Notify( rEvt
);
451 // -----------------------------------------------------------------------
453 SfxModelessDialog::~SfxModelessDialog()
461 if ( pImp
->pMgr
->GetFrame().is() && pImp
->pMgr
->GetFrame() == pBindings
->GetActiveFrame() )
462 pBindings
->SetActiveFrame( NULL
);
466 //-------------------------------------------------------------------------
468 sal_Bool
SfxModelessDialog::Close()
472 Das Fenster wird geschlossen, indem das ChildWindow durch Ausf"uhren des
473 ChildWindow-Slots zerst"ort wird.
474 Wird diese Methode von einer abgeleiteten Klasse "uberschrieben, mu\s
475 danach SfxModelessDialogWindow::Close() gerufen werden, wenn nicht das
476 Close() mit "return sal_False" abgebrochen wird.
481 // Execute mit Parametern, da Toggle von einigen ChildWindows ignoriert
483 SfxBoolItem
aValue( pImp
->pMgr
->GetType(), sal_False
);
484 pBindings
->GetDispatcher_Impl()->Execute(
485 pImp
->pMgr
->GetType(),
486 SFX_CALLMODE_RECORD
|SFX_CALLMODE_SYNCHRON
, &aValue
, 0L );
490 //-------------------------------------------------------------------------
492 void SfxModelessDialog::FillInfo(SfxChildWinInfo
& rInfo
) const
496 F"ullt ein SfxChildWinInfo mit f"ur SfxModelessDialof spezifischen Daten,
497 damit sie in die INI-Datei geschrieben werden koennen.
498 Es wird angenommen, da\s rInfo alle anderen evt. relevanten Daten in
499 der ChildWindow-Klasse erh"alt.
500 ModelessDialogs haben keine spezifischen Informationen, so dass die
501 Basisimplementierung nichts tut und daher nicht gerufen werden mu\s.
507 rInfo
.nFlags
|= SFX_CHILDWIN_ZOOMIN
;
510 // -----------------------------------------------------------------------
512 long SfxFloatingWindow::Notify( NotifyEvent
& rEvt
)
516 Wenn ein ModelessDialog aktiviert wird, wird sein ViewFrame aktiviert.
517 Notwendig ist das bei PlugInFrames.
521 if ( rEvt
.GetType() == EVENT_GETFOCUS
)
523 pBindings
->SetActiveFrame( pImp
->pMgr
->GetFrame() );
524 pImp
->pMgr
->Activate_Impl();
525 Window
* pWindow
= rEvt
.GetWindow();
527 while ( !nHelpId
&& pWindow
)
529 nHelpId
= pWindow
->GetHelpId();
530 pWindow
= pWindow
->GetParent();
534 SfxHelp::OpenHelpAgent( pBindings
->GetDispatcher_Impl()->GetFrame()->GetFrame(), nHelpId
);
536 else if ( rEvt
.GetType() == EVENT_LOSEFOCUS
)
538 if ( !HasChildPathFocus() )
540 pBindings
->SetActiveFrame( NULL
);
541 pImp
->pMgr
->Deactivate_Impl();
544 else if( rEvt
.GetType() == EVENT_KEYINPUT
)
546 // KeyInput zuerst f"ur Dialogfunktionen zulassen
547 if ( !FloatingWindow::Notify( rEvt
) && SfxViewShell::Current() )
548 // dann auch global g"ultige Acceleratoren verwenden
549 return SfxViewShell::Current()->GlobalKeyInput_Impl( *rEvt
.GetKeyEvent() );
553 return FloatingWindow::Notify( rEvt
);
556 // -----------------------------------------------------------------------
558 SfxFloatingWindow::SfxFloatingWindow( SfxBindings
*pBindinx
,
560 Window
* pParent
, WinBits nWinBits
) :
561 FloatingWindow (pParent
, nWinBits
),
563 pImp( new SfxFloatingWindow_Impl
)
566 pImp
->bConstructed
= FALSE
;
567 sal_uInt32 nId
= GetHelpId();
571 pImp
->StartListening( *pBindinx
);
572 pImp
->aMoveTimer
.SetTimeout(50);
573 pImp
->aMoveTimer
.SetTimeoutHdl(LINK(this,SfxFloatingWindow
,TimerHdl
));
576 // -----------------------------------------------------------------------
578 SfxFloatingWindow::SfxFloatingWindow( SfxBindings
*pBindinx
,
581 const ResId
& rResId
) :
582 FloatingWindow(pParent
, rResId
),
584 pImp( new SfxFloatingWindow_Impl
)
587 pImp
->bConstructed
= FALSE
;
588 sal_uInt32 nId
= GetHelpId();
592 pImp
->StartListening( *pBindinx
);
593 pImp
->aMoveTimer
.SetTimeout(50);
594 pImp
->aMoveTimer
.SetTimeoutHdl(LINK(this,SfxFloatingWindow
,TimerHdl
));
597 //-------------------------------------------------------------------------
599 sal_Bool
SfxFloatingWindow::Close()
603 Das Fenster wird geschlossen, indem das ChildWindow durch Ausf"uhren des
604 ChildWindow-Slots zerst"ort wird.
605 Wird diese Methode von einer abgeleiteten Klasse "uberschrieben, mu\s
606 danach SfxFloatingWindow::Close() gerufen werden, wenn nicht das Close()
607 mit "return sal_False" abgebrochen wird.
612 // Execute mit Parametern, da Toggle von einigen ChildWindows ignoriert
614 SfxBoolItem
aValue( pImp
->pMgr
->GetType(), sal_False
);
615 pBindings
->GetDispatcher_Impl()->Execute(
616 pImp
->pMgr
->GetType(),
617 SFX_CALLMODE_RECORD
|SFX_CALLMODE_SYNCHRON
, &aValue
, 0L );
621 // -----------------------------------------------------------------------
623 SfxFloatingWindow::~SfxFloatingWindow()
631 if ( pImp
->pMgr
->GetFrame() == pBindings
->GetActiveFrame() )
632 pBindings
->SetActiveFrame( NULL
);
636 //-------------------------------------------------------------------------
638 void SfxFloatingWindow::Resize()
642 Diese virtuelle Methode der Klasse FloatingWindow merkt sich ggf. eine
644 Wird diese Methode von einer abgeleiteten Klasse "uberschrieben, mu\s
645 auch SfxFloatingWindow::Resize() gerufen werden.
649 FloatingWindow::Resize();
650 if ( pImp
->bConstructed
&& pImp
->pMgr
)
652 // start timer for saving window status information
653 pImp
->aMoveTimer
.Start();
657 void SfxFloatingWindow::Move()
659 FloatingWindow::Move();
660 if ( pImp
->bConstructed
&& pImp
->pMgr
)
662 // start timer for saving window status information
663 pImp
->aMoveTimer
.Start();
668 Implements a timer event that is triggered by a move or resize of the window
669 This will save config information to Views.xcu with a small delay
671 IMPL_LINK( SfxFloatingWindow
, TimerHdl
, Timer
*, EMPTYARG
)
673 pImp
->aMoveTimer
.Stop();
674 if ( pImp
->bConstructed
&& pImp
->pMgr
)
677 aSize
= GetSizePixel();
678 ULONG nMask
= WINDOWSTATE_MASK_POS
| WINDOWSTATE_MASK_STATE
;
679 if ( GetStyle() & WB_SIZEABLE
)
680 nMask
|= ( WINDOWSTATE_MASK_WIDTH
| WINDOWSTATE_MASK_HEIGHT
);
681 pImp
->aWinState
= GetWindowState( nMask
);
682 GetBindings().GetWorkWindow_Impl()->ConfigChild_Impl( SFX_CHILDWIN_DOCKINGWINDOW
, SFX_ALIGNDOCKINGWINDOW
, pImp
->pMgr
->GetType() );
687 //-------------------------------------------------------------------------
688 void SfxFloatingWindow::StateChanged( StateChangedType nStateChange
)
690 if ( nStateChange
== STATE_CHANGE_INITSHOW
)
692 // FloatingWindows are not centered by default
693 if ( pImp
->aWinState
.Len() )
694 SetWindowState( pImp
->aWinState
);
695 pImp
->bConstructed
= TRUE
;
698 FloatingWindow::StateChanged( nStateChange
);
702 void SfxFloatingWindow::Initialize(SfxChildWinInfo
*pInfo
)
706 Initialisierung der Klasse SfxFloatingWindow "uber ein SfxChildWinInfo.
707 Die Initialisierung erfolgt erst in einem 2.Schritt
708 nach dem ctor und sollte vom ctor der abgeleiteten Klasse
709 oder von dem des SfxChildWindows aufgerufen werden.
712 pImp
->aWinState
= pInfo
->aWinState
;
715 //-------------------------------------------------------------------------
717 void SfxFloatingWindow::FillInfo(SfxChildWinInfo
& rInfo
) const
721 F"ullt ein SfxChildWinInfo mit f"ur SfxFloatingWindow spezifischen Daten,
722 damit sie in die INI-Datei geschrieben werden koennen.
723 Es wird angenommen, da\s rInfo alle anderen evt. relevanten Daten in
724 der ChildWindow-Klasse erh"alt.
725 Eingetragen werden hier gemerkte Gr"o\se und das ZoomIn-Flag.
726 Wird diese Methode "uberschrieben, mu\s zuerst die Basisimplementierung
733 rInfo
.nFlags
|= SFX_CHILDWIN_ZOOMIN
;
736 // SfxSingleTabDialog ----------------------------------------------------
738 IMPL_LINK( SfxSingleTabDialog
, OKHdl_Impl
, Button
*, EMPTYARG
)
742 Ok_Handler; f"ur die gesetzte Page wird FillItemSet() gerufen.
746 if ( !GetInputItemSet() )
748 // TabPage without ItemSet
753 if ( !GetOutputItemSet() )
755 CreateOutputItemSet( *GetInputItemSet() );
757 sal_Bool bModified
= sal_False
;
759 if ( pImpl
->m_pSfxPage
->HasExchangeSupport() )
761 int nRet
= pImpl
->m_pSfxPage
->DeactivatePage( GetOutputSetImpl() );
762 if ( nRet
!= SfxTabPage::LEAVE_PAGE
)
765 bModified
= ( GetOutputItemSet()->Count() > 0 );
768 bModified
= pImpl
->m_pSfxPage
->FillItemSet( *GetOutputSetImpl() );
772 // auch noch schnell User-Daten im IniManager abspeichern
773 pImpl
->m_pSfxPage
->FillUserData();
774 String
sData( pImpl
->m_pSfxPage
->GetUserData() );
775 SvtViewOptions
aPageOpt( E_TABPAGE
, String::CreateFromInt32( GetUniqId() ) );
776 aPageOpt
.SetUserItem( USERITEM_NAME
, makeAny( OUString( sData
) ) );
780 EndDialog( RET_CANCEL
);
784 // -----------------------------------------------------------------------
786 SfxSingleTabDialog::SfxSingleTabDialog
789 const SfxItemSet
& rSet
,
795 Konstruktor der allgemeinen Basisklasse f"ur SingleTab-Dialoge;
796 ID f"ur das ini-file wird "ubergeben.
799 SfxModalDialog( pParent
, nUniqueId
, WinBits( WB_STDMODAL
| WB_3DLOOK
) ),
804 pImpl ( new SingleTabDlgImpl
)
806 DBG_WARNING( "please use the ctor with ViewFrame" );
807 SetInputSet( &rSet
);
810 // -----------------------------------------------------------------------
812 SfxSingleTabDialog::SfxSingleTabDialog
815 sal_uInt16 nUniqueId
,
816 const SfxItemSet
* pInSet
821 Konstruktor der allgemeinen Basisklasse f"ur SingleTab-Dialoge;
822 ID f"ur das ini-file wird "ubergeben.
823 Sollte nicht mehr benutzt werden.
826 : SfxModalDialog( pParent
, nUniqueId
, WinBits( WB_STDMODAL
| WB_3DLOOK
) ),
831 pImpl ( new SingleTabDlgImpl
)
833 DBG_WARNING( "bitte den Ctor mit ViewFrame verwenden" );
834 SetInputSet( pInSet
);
837 // -----------------------------------------------------------------------
839 SfxSingleTabDialog::SfxSingleTabDialog
842 sal_uInt16 nUniqueId
,
843 const String
& rInfoURL
848 Konstruktor der allgemeinen Basisklasse f"ur SingleTab-Dialoge;
849 ID f"ur das ini-file wird "ubergeben.
852 : SfxModalDialog( pParent
, nUniqueId
, WinBits( WB_STDMODAL
| WB_3DLOOK
) ),
857 pImpl ( new SingleTabDlgImpl
)
859 pImpl
->m_sInfoURL
= rInfoURL
;
862 // -----------------------------------------------------------------------
864 SfxSingleTabDialog::~SfxSingleTabDialog()
869 delete pImpl
->m_pTabPage
;
870 delete pImpl
->m_pSfxPage
;
871 delete pImpl
->m_pLine
;
872 delete pImpl
->m_pInfoImage
;
876 // -----------------------------------------------------------------------
878 void SfxSingleTabDialog::SetPage( TabPage
* pNewPage
)
880 if ( !pImpl
->m_pLine
)
881 pImpl
->m_pLine
= new FixedLine( this );
885 pOKBtn
= new OKButton( this, WB_DEFBUTTON
);
886 pOKBtn
->SetClickHdl( LINK( this, SfxSingleTabDialog
, OKHdl_Impl
) );
889 if ( pImpl
->m_sInfoURL
.Len() > 0 && !pImpl
->m_pInfoImage
)
891 pImpl
->m_pInfoImage
= new ::svt::FixedHyperlinkImage( this );
892 Image aInfoImage
= Image( SfxResId( IMG_INFO
) );
893 Size aImageSize
= aInfoImage
.GetSizePixel();
894 aImageSize
.Width() += 4;
895 aImageSize
.Height() += 4;
896 pImpl
->m_pInfoImage
->SetSizePixel( aImageSize
);
897 pImpl
->m_pInfoImage
->SetImage( aInfoImage
);
898 pImpl
->m_pInfoImage
->SetURL( pImpl
->m_sInfoURL
);
899 pImpl
->m_pInfoImage
->SetClickHdl( pImpl
->m_aInfoLink
);
902 if ( pImpl
->m_pTabPage
)
903 delete pImpl
->m_pTabPage
;
904 if ( pImpl
->m_pSfxPage
)
905 delete pImpl
->m_pSfxPage
;
906 pImpl
->m_pTabPage
= pNewPage
;
908 if ( pImpl
->m_pTabPage
)
910 // Gr"ossen und Positionen anpassen
911 pImpl
->m_pTabPage
->SetPosPixel( Point() );
912 Size
aOutSz( pImpl
->m_pTabPage
->GetSizePixel() );
913 Size aOffSz
= LogicToPixel( Size( RSC_SP_CTRL_X
, RSC_SP_CTRL_Y
), MAP_APPFONT
);
914 Size aFLSz
= LogicToPixel( Size( aOutSz
.Width(), RSC_CD_FIXEDLINE_HEIGHT
) );
915 Size aBtnSz
= LogicToPixel( Size( RSC_CD_PUSHBUTTON_WIDTH
, RSC_CD_PUSHBUTTON_HEIGHT
), MAP_APPFONT
);
917 Point
aPnt( 0, aOutSz
.Height() );
918 pImpl
->m_pLine
->SetPosSizePixel( aPnt
, aFLSz
);
919 aPnt
.X() = aOutSz
.Width() - aOffSz
.Width() - aBtnSz
.Width();
920 aPnt
.Y() += aFLSz
.Height() + ( aOffSz
.Height() / 2 );
921 pOKBtn
->SetPosSizePixel( aPnt
, aBtnSz
);
923 if ( pImpl
->m_pInfoImage
)
925 aPnt
.X() = aOffSz
.Width();
926 long nDelta
= ( pImpl
->m_pInfoImage
->GetSizePixel().Height() - aBtnSz
.Height() ) / 2;
928 pImpl
->m_pInfoImage
->SetPosPixel( aPnt
);
929 pImpl
->m_pInfoImage
->Show();
932 aOutSz
.Height() += aFLSz
.Height() + ( aOffSz
.Height() / 2 ) + aBtnSz
.Height() + aOffSz
.Height();
933 SetOutputSizePixel( aOutSz
);
935 pImpl
->m_pLine
->Show();
937 pImpl
->m_pTabPage
->Show();
939 // Text der TabPage in den Dialog setzen
940 SetText( pImpl
->m_pTabPage
->GetText() );
942 // Dialog bekommt HelpId der TabPage
943 SetHelpId( pImpl
->m_pTabPage
->GetHelpId() );
944 SetUniqueId( pImpl
->m_pTabPage
->GetUniqueId() );
948 // -----------------------------------------------------------------------
950 void SfxSingleTabDialog::SetTabPage( SfxTabPage
* pTabPage
,
951 GetTabPageRanges pRangesFunc
)
954 Setzen einer (neuen) TabPage; eine bereits vorhandene Page
956 Die "ubergebene Page wird durch Aufruf von Reset() mit dem
957 initial "ubergebenen Itemset initialisiert.
963 pOKBtn
= new OKButton( this, WB_DEFBUTTON
);
964 pOKBtn
->SetClickHdl( LINK( this, SfxSingleTabDialog
, OKHdl_Impl
) );
967 pCancelBtn
= new CancelButton( this );
969 pHelpBtn
= new HelpButton( this );
971 if ( pImpl
->m_pTabPage
)
972 delete pImpl
->m_pTabPage
;
973 if ( pImpl
->m_pSfxPage
)
974 delete pImpl
->m_pSfxPage
;
975 pImpl
->m_pSfxPage
= pTabPage
;
976 fnGetRanges
= pRangesFunc
;
978 if ( pImpl
->m_pSfxPage
)
980 // erstmal die User-Daten besorgen, dann erst Reset()
981 SvtViewOptions
aPageOpt( E_TABPAGE
, String::CreateFromInt32( GetUniqId() ) );
983 Any aUserItem
= aPageOpt
.GetUserItem( USERITEM_NAME
);
985 if ( aUserItem
>>= aTemp
)
986 sUserData
= String( aTemp
);
987 pImpl
->m_pSfxPage
->SetUserData( sUserData
);
988 pImpl
->m_pSfxPage
->Reset( *GetInputItemSet() );
989 pImpl
->m_pSfxPage
->Show();
991 // Gr"ossen und Positionen anpassen
992 pImpl
->m_pSfxPage
->SetPosPixel( Point() );
993 Size
aOutSz( pImpl
->m_pSfxPage
->GetSizePixel() );
994 Size aBtnSiz
= LogicToPixel( Size( 50, 14 ), MAP_APPFONT
);
995 Point
aPnt( aOutSz
.Width(), LogicToPixel( Point( 0, 6 ), MAP_APPFONT
).Y() );
996 aOutSz
.Width() += aBtnSiz
.Width() + LogicToPixel( Size( 6, 0 ), MAP_APPFONT
).Width();
997 SetOutputSizePixel( aOutSz
);
998 pOKBtn
->SetPosSizePixel( aPnt
, aBtnSiz
);
1000 aPnt
.Y() = LogicToPixel( Point( 0, 23 ), MAP_APPFONT
).Y();
1001 pCancelBtn
->SetPosSizePixel( aPnt
, aBtnSiz
);
1003 aPnt
.Y() = LogicToPixel( Point( 0, 43 ), MAP_APPFONT
).Y();
1004 pHelpBtn
->SetPosSizePixel( aPnt
, aBtnSiz
);
1006 if ( Help::IsContextHelpEnabled() )
1009 // Text der TabPage in den Dialog setzen
1010 SetText( pImpl
->m_pSfxPage
->GetText() );
1012 // Dialog bekommt HelpId der TabPage
1013 SetHelpId( pImpl
->m_pSfxPage
->GetHelpId() );
1014 SetUniqueId( pImpl
->m_pSfxPage
->GetUniqueId() );
1018 // -----------------------------------------------------------------------
1020 void SfxSingleTabDialog::SetInfoLink( const Link
& rLink
)
1022 pImpl
->m_aInfoLink
= rLink
;
1025 //--------------------------------------------------------------------
1026 // Vergleichsfunktion fuer qsort
1029 int __cdecl
BaseDlgsCmpUS_Impl( const void* p1
, const void* p2
)
1031 #if defined(OS2) && defined(ICC)
1032 int _Optlink
BaseDlgsCmpUS_Impl( const void* p1
, const void* p2
)
1034 extern "C" int BaseDlgsCmpUS_Impl( const void* p1
, const void* p2
)
1038 return *(sal_uInt16
*)p1
- *(sal_uInt16
*)p2
;
1041 // -----------------------------------------------------------------------
1044 Bildet das Set "uber die Ranges der Page. Die Page muss die statische
1045 Methode f"ur das Erfragen ihrer Ranges bei SetTabPage angegeben haben,
1046 liefert also ihr Set onDemand.
1048 const sal_uInt16
* SfxSingleTabDialog::GetInputRanges( const SfxItemPool
& rPool
)
1050 if ( GetInputItemSet() )
1052 DBG_ERROR( "Set bereits vorhanden!" );
1053 return GetInputItemSet()->GetRanges();
1058 SvUShorts
aUS(16, 16);
1062 const sal_uInt16
*pTmpRanges
= (fnGetRanges
)();
1063 const sal_uInt16
*pIter
= pTmpRanges
;
1065 for ( nLen
= 0; *pIter
; ++nLen
, ++pIter
)
1067 aUS
.Insert( pTmpRanges
, nLen
, aUS
.Count() );
1070 //! Doppelte Ids entfernen?
1071 sal_uInt16 nCount
= aUS
.Count();
1073 for ( sal_uInt16 i
= 0; i
< nCount
; ++i
)
1074 aUS
[i
] = rPool
.GetWhich( aUS
[i
]) ;
1077 if ( aUS
.Count() > 1 )
1078 qsort( (void*)aUS
.GetData(), aUS
.Count(), sizeof(sal_uInt16
), BaseDlgsCmpUS_Impl
);
1080 pRanges
= new sal_uInt16
[aUS
.Count() + 1];
1081 memcpy( pRanges
, aUS
.GetData(), sizeof(sal_uInt16
) * aUS
.Count() );
1082 pRanges
[aUS
.Count()] = 0;