1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sfx2.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // include --------------------------------------------------------------- 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <stdlib.h> 34*cdf0e10cSrcweir #include <vcl/fixed.hxx> 35*cdf0e10cSrcweir #include <vcl/help.hxx> 36*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 37*cdf0e10cSrcweir #include <svl/eitem.hxx> 38*cdf0e10cSrcweir #include <unotools/viewoptions.hxx> 39*cdf0e10cSrcweir #include <svtools/fixedhyper.hxx> 40*cdf0e10cSrcweir #include <svtools/controldims.hrc> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <sfx2/basedlgs.hxx> 43*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 44*cdf0e10cSrcweir #include <sfx2/tabdlg.hxx> 45*cdf0e10cSrcweir #include <sfx2/app.hxx> 46*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 47*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 48*cdf0e10cSrcweir #include <sfx2/childwin.hxx> 49*cdf0e10cSrcweir #include <sfx2/viewsh.hxx> 50*cdf0e10cSrcweir #include "sfx2/sfxhelp.hxx" 51*cdf0e10cSrcweir #include "workwin.hxx" 52*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx" 53*cdf0e10cSrcweir #include "dialog.hrc" 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 56*cdf0e10cSrcweir using namespace ::rtl; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir #define USERITEM_NAME OUString::createFromAscii( "UserItem" ) 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir class SfxModelessDialog_Impl : public SfxListener 61*cdf0e10cSrcweir { 62*cdf0e10cSrcweir public: 63*cdf0e10cSrcweir ByteString aWinState; 64*cdf0e10cSrcweir SfxChildWindow* pMgr; 65*cdf0e10cSrcweir sal_Bool bConstructed; 66*cdf0e10cSrcweir void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir Timer aMoveTimer; 69*cdf0e10cSrcweir }; 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir void SfxModelessDialog_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint ) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir if ( rHint.IsA(TYPE(SfxSimpleHint)) ) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir switch( ( (SfxSimpleHint&) rHint ).GetId() ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir case SFX_HINT_DYING: 78*cdf0e10cSrcweir pMgr->Destroy(); 79*cdf0e10cSrcweir break; 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir class SfxFloatingWindow_Impl : public SfxListener 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir public: 87*cdf0e10cSrcweir ByteString aWinState; 88*cdf0e10cSrcweir SfxChildWindow* pMgr; 89*cdf0e10cSrcweir sal_Bool bConstructed; 90*cdf0e10cSrcweir Timer aMoveTimer; 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 93*cdf0e10cSrcweir }; 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir void SfxFloatingWindow_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint ) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir if ( rHint.IsA(TYPE(SfxSimpleHint)) ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir switch( ( (SfxSimpleHint&) rHint ).GetId() ) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir case SFX_HINT_DYING: 102*cdf0e10cSrcweir pMgr->Destroy(); 103*cdf0e10cSrcweir break; 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir // class SfxModalDefParentHelper ----------------------------------------- 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir SfxModalDefParentHelper::SfxModalDefParentHelper( Window *pWindow) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir pOld = Application::GetDefDialogParent(); 113*cdf0e10cSrcweir Application::SetDefDialogParent( pWindow ); 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir // ----------------------------------------------------------------------- 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir SfxModalDefParentHelper::~SfxModalDefParentHelper() 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir Application::SetDefDialogParent( pOld ); 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir // ----------------------------------------------------------------------- 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir void SfxModalDialog::SetDialogData_Impl() 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir // save settings (position and user data) 128*cdf0e10cSrcweir SvtViewOptions aDlgOpt( E_DIALOG, String::CreateFromInt32( nUniqId ) ); 129*cdf0e10cSrcweir aDlgOpt.SetWindowState( 130*cdf0e10cSrcweir OUString::createFromAscii( GetWindowState( WINDOWSTATE_MASK_POS ).GetBuffer() ) ); 131*cdf0e10cSrcweir if ( aExtraData.Len() ) 132*cdf0e10cSrcweir aDlgOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( aExtraData ) ) ); 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir // ----------------------------------------------------------------------- 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir void SfxModalDialog::GetDialogData_Impl() 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir /* [Beschreibung] 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir Hilfsfunktion; liest die Dialogposition aus der Ini-Datei 142*cdf0e10cSrcweir und setzt diese am "ubergebenen Window. 143*cdf0e10cSrcweir */ 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir SvtViewOptions aDlgOpt( E_DIALOG, String::CreateFromInt32( nUniqId ) ); 147*cdf0e10cSrcweir if ( aDlgOpt.Exists() ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir // load settings 150*cdf0e10cSrcweir SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) ); 151*cdf0e10cSrcweir Any aUserItem = aDlgOpt.GetUserItem( USERITEM_NAME ); 152*cdf0e10cSrcweir OUString aTemp; 153*cdf0e10cSrcweir if ( aUserItem >>= aTemp ) 154*cdf0e10cSrcweir aExtraData = String( aTemp ); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir // ----------------------------------------------------------------------- 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir void SfxModalDialog::init() 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir GetDialogData_Impl(); 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir // ----------------------------------------------------------------------- 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir SfxModalDialog::SfxModalDialog(Window* pParent, const ResId &rResId ) 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir /* [Beschreibung] 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir Konstruktor der allgemeinen Basisklasse f"ur modale Dialoge; 172*cdf0e10cSrcweir ResId wird als ID im ini-file verwendet. 173*cdf0e10cSrcweir Die dort gespeicherte Position wird gesetzt. 174*cdf0e10cSrcweir */ 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir : ModalDialog(pParent, rResId), 177*cdf0e10cSrcweir nUniqId(rResId.GetId()), 178*cdf0e10cSrcweir pInputSet(0), 179*cdf0e10cSrcweir pOutputSet(0) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir init(); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir // ----------------------------------------------------------------------- 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir SfxModalDialog::SfxModalDialog(Window* pParent, 187*cdf0e10cSrcweir sal_uInt32 nUniqueId, 188*cdf0e10cSrcweir WinBits nWinStyle) : 189*cdf0e10cSrcweir /* [Beschreibung] 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir Konstruktor der allgemeinen Basisklasse f"ur modale Dialoge; 192*cdf0e10cSrcweir ID f"ur das ini-file wird explizit "ubergeben. 193*cdf0e10cSrcweir Die dort gespeicherte Position wird gesetzt. 194*cdf0e10cSrcweir */ 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir ModalDialog(pParent, nWinStyle), 197*cdf0e10cSrcweir nUniqId(nUniqueId), 198*cdf0e10cSrcweir pInputSet(0), 199*cdf0e10cSrcweir pOutputSet(0) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir init(); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir // ----------------------------------------------------------------------- 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir SfxModalDialog::~SfxModalDialog() 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir /* [Beschreibung] 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir Dtor; schreibt Dialogposition in das ini-file 211*cdf0e10cSrcweir */ 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir SetDialogData_Impl(); 215*cdf0e10cSrcweir delete pOutputSet; 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir void SfxModalDialog::CreateOutputItemSet( SfxItemPool& rPool ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir DBG_ASSERT( !pOutputSet, "Double creation of OutputSet!" ); 221*cdf0e10cSrcweir if (!pOutputSet) 222*cdf0e10cSrcweir pOutputSet = new SfxAllItemSet( rPool ); 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir // ----------------------------------------------------------------------- 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir void SfxModalDialog::CreateOutputItemSet( const SfxItemSet& rSet ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir DBG_ASSERT( !pOutputSet, "Double creation of OutputSet!" ); 230*cdf0e10cSrcweir if (!pOutputSet) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir pOutputSet = new SfxItemSet( rSet ); 233*cdf0e10cSrcweir pOutputSet->ClearItem(); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir //------------------------------------------------------------------------- 238*cdf0e10cSrcweir void SfxModelessDialog::StateChanged( StateChangedType nStateChange ) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir if ( nStateChange == STATE_CHANGE_INITSHOW ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir if ( pImp->aWinState.Len() ) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir SetWindowState( pImp->aWinState ); 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir else 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir Point aPos = GetPosPixel(); 249*cdf0e10cSrcweir if ( !aPos.X() ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir aSize = GetSizePixel(); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir Size aParentSize = GetParent()->GetOutputSizePixel(); 254*cdf0e10cSrcweir Size aDlgSize = GetSizePixel(); 255*cdf0e10cSrcweir aPos.X() += ( aParentSize.Width() - aDlgSize.Width() ) / 2; 256*cdf0e10cSrcweir aPos.Y() += ( aParentSize.Height() - aDlgSize.Height() ) / 2; 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir Point aPoint; 259*cdf0e10cSrcweir Rectangle aRect = GetDesktopRectPixel(); 260*cdf0e10cSrcweir aPoint.X() = aRect.Right() - aDlgSize.Width(); 261*cdf0e10cSrcweir aPoint.Y() = aRect.Bottom() - aDlgSize.Height(); 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir aPoint = OutputToScreenPixel( aPoint ); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir if ( aPos.X() > aPoint.X() ) 266*cdf0e10cSrcweir aPos.X() = aPoint.X() ; 267*cdf0e10cSrcweir if ( aPos.Y() > aPoint.Y() ) 268*cdf0e10cSrcweir aPos.Y() = aPoint.Y(); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir if ( aPos.X() < 0 ) aPos.X() = 0; 271*cdf0e10cSrcweir if ( aPos.Y() < 0 ) aPos.Y() = 0; 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir SetPosPixel( aPos ); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir pImp->bConstructed = sal_True; 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir ModelessDialog::StateChanged( nStateChange ); 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir void SfxModelessDialog::Initialize(SfxChildWinInfo *pInfo) 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir /* [Beschreibung] 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir Initialisierung der Klasse SfxModelessDialog "uber ein SfxChildWinInfo. 288*cdf0e10cSrcweir Die Initialisierung erfolgt erst in einem 2.Schritt 289*cdf0e10cSrcweir nach dem ctor und sollte vom ctor der abgeleiteten Klasse 290*cdf0e10cSrcweir oder von dem des SfxChildWindows aufgerufen werden. 291*cdf0e10cSrcweir */ 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir pImp->aWinState = pInfo->aWinState; 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir void SfxModelessDialog::Resize() 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir /* [Beschreibung] 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir Diese virtuelle Methode der Klasse FloatingWindow merkt sich ggf. eine 302*cdf0e10cSrcweir ver"anderte Gr"o\se. 303*cdf0e10cSrcweir Wird diese Methode von einer abgeleiteten Klasse "uberschrieben, mu\s 304*cdf0e10cSrcweir auch SfxFloatingWindow::Resize() gerufen werden. 305*cdf0e10cSrcweir */ 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir ModelessDialog::Resize(); 309*cdf0e10cSrcweir if ( pImp->bConstructed && pImp->pMgr ) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir // start timer for saving window status information 312*cdf0e10cSrcweir pImp->aMoveTimer.Start(); 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir void SfxModelessDialog::Move() 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir ModelessDialog::Move(); 319*cdf0e10cSrcweir if ( pImp->bConstructed && pImp->pMgr && IsReallyVisible() ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir // start timer for saving window status information 322*cdf0e10cSrcweir pImp->aMoveTimer.Start(); 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir /* 327*cdf0e10cSrcweir Implements a timer event that is triggered by a move or resize of the window 328*cdf0e10cSrcweir This will save config information to Views.xcu with a small delay 329*cdf0e10cSrcweir */ 330*cdf0e10cSrcweir IMPL_LINK( SfxModelessDialog, TimerHdl, Timer*, EMPTYARG) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir pImp->aMoveTimer.Stop(); 333*cdf0e10cSrcweir if ( pImp->bConstructed && pImp->pMgr ) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir if ( !IsRollUp() ) 336*cdf0e10cSrcweir aSize = GetSizePixel(); 337*cdf0e10cSrcweir sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE; 338*cdf0e10cSrcweir if ( GetStyle() & WB_SIZEABLE ) 339*cdf0e10cSrcweir nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT ); 340*cdf0e10cSrcweir pImp->aWinState = GetWindowState( nMask ); 341*cdf0e10cSrcweir GetBindings().GetWorkWindow_Impl()->ConfigChild_Impl( SFX_CHILDWIN_DOCKINGWINDOW, SFX_ALIGNDOCKINGWINDOW, pImp->pMgr->GetType() ); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir return 0; 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir // ----------------------------------------------------------------------- 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir SfxModelessDialog::SfxModelessDialog( SfxBindings *pBindinx, 349*cdf0e10cSrcweir SfxChildWindow *pCW, 350*cdf0e10cSrcweir Window* pParent, WinBits nWinBits ) : 351*cdf0e10cSrcweir ModelessDialog (pParent, nWinBits), 352*cdf0e10cSrcweir pBindings(pBindinx), 353*cdf0e10cSrcweir pImp( new SfxModelessDialog_Impl ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir pImp->pMgr = pCW; 356*cdf0e10cSrcweir pImp->bConstructed = sal_False; 357*cdf0e10cSrcweir SetUniqueId( GetHelpId() ); 358*cdf0e10cSrcweir SetHelpId(""); 359*cdf0e10cSrcweir if ( pBindinx ) 360*cdf0e10cSrcweir pImp->StartListening( *pBindinx ); 361*cdf0e10cSrcweir pImp->aMoveTimer.SetTimeout(50); 362*cdf0e10cSrcweir pImp->aMoveTimer.SetTimeoutHdl(LINK(this,SfxModelessDialog,TimerHdl)); 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir // ----------------------------------------------------------------------- 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir SfxModelessDialog::SfxModelessDialog( SfxBindings *pBindinx, 368*cdf0e10cSrcweir SfxChildWindow *pCW, Window *pParent, 369*cdf0e10cSrcweir const ResId& rResId ) : 370*cdf0e10cSrcweir ModelessDialog(pParent, rResId), 371*cdf0e10cSrcweir pBindings(pBindinx), 372*cdf0e10cSrcweir pImp( new SfxModelessDialog_Impl ) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir pImp->pMgr = pCW; 375*cdf0e10cSrcweir pImp->bConstructed = sal_False; 376*cdf0e10cSrcweir SetUniqueId( GetHelpId() ); 377*cdf0e10cSrcweir SetHelpId(""); 378*cdf0e10cSrcweir if ( pBindinx ) 379*cdf0e10cSrcweir pImp->StartListening( *pBindinx ); 380*cdf0e10cSrcweir pImp->aMoveTimer.SetTimeout(50); 381*cdf0e10cSrcweir pImp->aMoveTimer.SetTimeoutHdl(LINK(this,SfxModelessDialog,TimerHdl)); 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir // ----------------------------------------------------------------------- 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir long SfxModelessDialog::Notify( NotifyEvent& rEvt ) 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir /* [Beschreibung] 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir Wenn ein ModelessDialog aktiviert wird, wird sein ViewFrame aktiviert. 391*cdf0e10cSrcweir Notwendig ist das bei PlugInFrames. 392*cdf0e10cSrcweir */ 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir if ( rEvt.GetType() == EVENT_GETFOCUS ) 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir pBindings->SetActiveFrame( pImp->pMgr->GetFrame() ); 398*cdf0e10cSrcweir pImp->pMgr->Activate_Impl(); 399*cdf0e10cSrcweir Window* pWindow = rEvt.GetWindow(); 400*cdf0e10cSrcweir rtl::OString sHelpId; 401*cdf0e10cSrcweir while ( !sHelpId.getLength() && pWindow ) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir sHelpId = pWindow->GetHelpId(); 404*cdf0e10cSrcweir pWindow = pWindow->GetParent(); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir if ( sHelpId.getLength() ) 408*cdf0e10cSrcweir SfxHelp::OpenHelpAgent( &pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(), sHelpId ); 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir else if ( rEvt.GetType() == EVENT_LOSEFOCUS && !HasChildPathFocus() ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir pBindings->SetActiveFrame( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > () ); 413*cdf0e10cSrcweir pImp->pMgr->Deactivate_Impl(); 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir else if( rEvt.GetType() == EVENT_KEYINPUT ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir // KeyInput zuerst f"ur Dialogfunktionen zulassen ( TAB etc. ) 418*cdf0e10cSrcweir if ( !ModelessDialog::Notify( rEvt ) && SfxViewShell::Current() ) 419*cdf0e10cSrcweir // dann auch global g"ultige Acceleratoren verwenden 420*cdf0e10cSrcweir return SfxViewShell::Current()->GlobalKeyInput_Impl( *rEvt.GetKeyEvent() ); 421*cdf0e10cSrcweir return sal_True; 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir return ModelessDialog::Notify( rEvt ); 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir // ----------------------------------------------------------------------- 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir SfxModelessDialog::~SfxModelessDialog() 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir /* [Beschreibung] 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir Dtor 434*cdf0e10cSrcweir */ 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir if ( pImp->pMgr->GetFrame().is() && pImp->pMgr->GetFrame() == pBindings->GetActiveFrame() ) 438*cdf0e10cSrcweir pBindings->SetActiveFrame( NULL ); 439*cdf0e10cSrcweir delete pImp; 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir //------------------------------------------------------------------------- 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir sal_Bool SfxModelessDialog::Close() 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir /* [Beschreibung] 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir Das Fenster wird geschlossen, indem das ChildWindow durch Ausf"uhren des 449*cdf0e10cSrcweir ChildWindow-Slots zerst"ort wird. 450*cdf0e10cSrcweir Wird diese Methode von einer abgeleiteten Klasse "uberschrieben, mu\s 451*cdf0e10cSrcweir danach SfxModelessDialogWindow::Close() gerufen werden, wenn nicht das 452*cdf0e10cSrcweir Close() mit "return sal_False" abgebrochen wird. 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir */ 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir // Execute mit Parametern, da Toggle von einigen ChildWindows ignoriert 458*cdf0e10cSrcweir // werden kann 459*cdf0e10cSrcweir SfxBoolItem aValue( pImp->pMgr->GetType(), sal_False); 460*cdf0e10cSrcweir pBindings->GetDispatcher_Impl()->Execute( 461*cdf0e10cSrcweir pImp->pMgr->GetType(), 462*cdf0e10cSrcweir SFX_CALLMODE_RECORD|SFX_CALLMODE_SYNCHRON, &aValue, 0L ); 463*cdf0e10cSrcweir return sal_True; 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir //------------------------------------------------------------------------- 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir void SfxModelessDialog::FillInfo(SfxChildWinInfo& rInfo) const 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir /* [Beschreibung] 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir F"ullt ein SfxChildWinInfo mit f"ur SfxModelessDialof spezifischen Daten, 473*cdf0e10cSrcweir damit sie in die INI-Datei geschrieben werden koennen. 474*cdf0e10cSrcweir Es wird angenommen, da\s rInfo alle anderen evt. relevanten Daten in 475*cdf0e10cSrcweir der ChildWindow-Klasse erh"alt. 476*cdf0e10cSrcweir ModelessDialogs haben keine spezifischen Informationen, so dass die 477*cdf0e10cSrcweir Basisimplementierung nichts tut und daher nicht gerufen werden mu\s. 478*cdf0e10cSrcweir */ 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir rInfo.aSize = aSize; 482*cdf0e10cSrcweir if ( IsRollUp() ) 483*cdf0e10cSrcweir rInfo.nFlags |= SFX_CHILDWIN_ZOOMIN; 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir // ----------------------------------------------------------------------- 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir long SfxFloatingWindow::Notify( NotifyEvent& rEvt ) 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir /* [Beschreibung] 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir Wenn ein ModelessDialog aktiviert wird, wird sein ViewFrame aktiviert. 493*cdf0e10cSrcweir Notwendig ist das bei PlugInFrames. 494*cdf0e10cSrcweir */ 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir if ( rEvt.GetType() == EVENT_GETFOCUS ) 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir pBindings->SetActiveFrame( pImp->pMgr->GetFrame() ); 500*cdf0e10cSrcweir pImp->pMgr->Activate_Impl(); 501*cdf0e10cSrcweir Window* pWindow = rEvt.GetWindow(); 502*cdf0e10cSrcweir rtl::OString sHelpId; 503*cdf0e10cSrcweir while ( !sHelpId.getLength() && pWindow ) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir sHelpId = pWindow->GetHelpId(); 506*cdf0e10cSrcweir pWindow = pWindow->GetParent(); 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir if ( sHelpId.getLength() ) 510*cdf0e10cSrcweir SfxHelp::OpenHelpAgent( &pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(), sHelpId ); 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir else if ( rEvt.GetType() == EVENT_LOSEFOCUS ) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir if ( !HasChildPathFocus() ) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir pBindings->SetActiveFrame( NULL ); 517*cdf0e10cSrcweir pImp->pMgr->Deactivate_Impl(); 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir else if( rEvt.GetType() == EVENT_KEYINPUT ) 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir // KeyInput zuerst f"ur Dialogfunktionen zulassen 523*cdf0e10cSrcweir if ( !FloatingWindow::Notify( rEvt ) && SfxViewShell::Current() ) 524*cdf0e10cSrcweir // dann auch global g"ultige Acceleratoren verwenden 525*cdf0e10cSrcweir return SfxViewShell::Current()->GlobalKeyInput_Impl( *rEvt.GetKeyEvent() ); 526*cdf0e10cSrcweir return sal_True; 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir return FloatingWindow::Notify( rEvt ); 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir // ----------------------------------------------------------------------- 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir SfxFloatingWindow::SfxFloatingWindow( SfxBindings *pBindinx, 535*cdf0e10cSrcweir SfxChildWindow *pCW, 536*cdf0e10cSrcweir Window* pParent, WinBits nWinBits) : 537*cdf0e10cSrcweir FloatingWindow (pParent, nWinBits), 538*cdf0e10cSrcweir pBindings(pBindinx), 539*cdf0e10cSrcweir pImp( new SfxFloatingWindow_Impl ) 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir pImp->pMgr = pCW; 542*cdf0e10cSrcweir pImp->bConstructed = sal_False; 543*cdf0e10cSrcweir SetUniqueId( GetHelpId() ); 544*cdf0e10cSrcweir SetHelpId(""); 545*cdf0e10cSrcweir if ( pBindinx ) 546*cdf0e10cSrcweir pImp->StartListening( *pBindinx ); 547*cdf0e10cSrcweir pImp->aMoveTimer.SetTimeout(50); 548*cdf0e10cSrcweir pImp->aMoveTimer.SetTimeoutHdl(LINK(this,SfxFloatingWindow,TimerHdl)); 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir // ----------------------------------------------------------------------- 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir SfxFloatingWindow::SfxFloatingWindow( SfxBindings *pBindinx, 554*cdf0e10cSrcweir SfxChildWindow *pCW, 555*cdf0e10cSrcweir Window* pParent, 556*cdf0e10cSrcweir const ResId& rResId) : 557*cdf0e10cSrcweir FloatingWindow(pParent, rResId), 558*cdf0e10cSrcweir pBindings(pBindinx), 559*cdf0e10cSrcweir pImp( new SfxFloatingWindow_Impl ) 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir pImp->pMgr = pCW; 562*cdf0e10cSrcweir pImp->bConstructed = sal_False; 563*cdf0e10cSrcweir SetUniqueId( GetHelpId() ); 564*cdf0e10cSrcweir SetHelpId(""); 565*cdf0e10cSrcweir if ( pBindinx ) 566*cdf0e10cSrcweir pImp->StartListening( *pBindinx ); 567*cdf0e10cSrcweir pImp->aMoveTimer.SetTimeout(50); 568*cdf0e10cSrcweir pImp->aMoveTimer.SetTimeoutHdl(LINK(this,SfxFloatingWindow,TimerHdl)); 569*cdf0e10cSrcweir } 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir //------------------------------------------------------------------------- 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir sal_Bool SfxFloatingWindow::Close() 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir /* [Beschreibung] 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir Das Fenster wird geschlossen, indem das ChildWindow durch Ausf"uhren des 578*cdf0e10cSrcweir ChildWindow-Slots zerst"ort wird. 579*cdf0e10cSrcweir Wird diese Methode von einer abgeleiteten Klasse "uberschrieben, mu\s 580*cdf0e10cSrcweir danach SfxFloatingWindow::Close() gerufen werden, wenn nicht das Close() 581*cdf0e10cSrcweir mit "return sal_False" abgebrochen wird. 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir */ 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir // Execute mit Parametern, da Toggle von einigen ChildWindows ignoriert 587*cdf0e10cSrcweir // werden kann 588*cdf0e10cSrcweir SfxBoolItem aValue( pImp->pMgr->GetType(), sal_False); 589*cdf0e10cSrcweir pBindings->GetDispatcher_Impl()->Execute( 590*cdf0e10cSrcweir pImp->pMgr->GetType(), 591*cdf0e10cSrcweir SFX_CALLMODE_RECORD|SFX_CALLMODE_SYNCHRON, &aValue, 0L ); 592*cdf0e10cSrcweir return sal_True; 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir // ----------------------------------------------------------------------- 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir SfxFloatingWindow::~SfxFloatingWindow() 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir /* [Beschreibung] 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir Dtor 602*cdf0e10cSrcweir */ 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir { 605*cdf0e10cSrcweir if ( pImp->pMgr->GetFrame() == pBindings->GetActiveFrame() ) 606*cdf0e10cSrcweir pBindings->SetActiveFrame( NULL ); 607*cdf0e10cSrcweir delete pImp; 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir //------------------------------------------------------------------------- 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir void SfxFloatingWindow::Resize() 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir /* [Beschreibung] 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir Diese virtuelle Methode der Klasse FloatingWindow merkt sich ggf. eine 617*cdf0e10cSrcweir ver"anderte Gr"o\se. 618*cdf0e10cSrcweir Wird diese Methode von einer abgeleiteten Klasse "uberschrieben, mu\s 619*cdf0e10cSrcweir auch SfxFloatingWindow::Resize() gerufen werden. 620*cdf0e10cSrcweir */ 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir FloatingWindow::Resize(); 624*cdf0e10cSrcweir if ( pImp->bConstructed && pImp->pMgr ) 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir // start timer for saving window status information 627*cdf0e10cSrcweir pImp->aMoveTimer.Start(); 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir void SfxFloatingWindow::Move() 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir FloatingWindow::Move(); 634*cdf0e10cSrcweir if ( pImp->bConstructed && pImp->pMgr ) 635*cdf0e10cSrcweir { 636*cdf0e10cSrcweir // start timer for saving window status information 637*cdf0e10cSrcweir pImp->aMoveTimer.Start(); 638*cdf0e10cSrcweir } 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir 641*cdf0e10cSrcweir /* 642*cdf0e10cSrcweir Implements a timer event that is triggered by a move or resize of the window 643*cdf0e10cSrcweir This will save config information to Views.xcu with a small delay 644*cdf0e10cSrcweir */ 645*cdf0e10cSrcweir IMPL_LINK( SfxFloatingWindow, TimerHdl, Timer*, EMPTYARG) 646*cdf0e10cSrcweir { 647*cdf0e10cSrcweir pImp->aMoveTimer.Stop(); 648*cdf0e10cSrcweir if ( pImp->bConstructed && pImp->pMgr ) 649*cdf0e10cSrcweir { 650*cdf0e10cSrcweir if ( !IsRollUp() ) 651*cdf0e10cSrcweir aSize = GetSizePixel(); 652*cdf0e10cSrcweir sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE; 653*cdf0e10cSrcweir if ( GetStyle() & WB_SIZEABLE ) 654*cdf0e10cSrcweir nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT ); 655*cdf0e10cSrcweir pImp->aWinState = GetWindowState( nMask ); 656*cdf0e10cSrcweir GetBindings().GetWorkWindow_Impl()->ConfigChild_Impl( SFX_CHILDWIN_DOCKINGWINDOW, SFX_ALIGNDOCKINGWINDOW, pImp->pMgr->GetType() ); 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir return 0; 659*cdf0e10cSrcweir } 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir //------------------------------------------------------------------------- 662*cdf0e10cSrcweir void SfxFloatingWindow::StateChanged( StateChangedType nStateChange ) 663*cdf0e10cSrcweir { 664*cdf0e10cSrcweir if ( nStateChange == STATE_CHANGE_INITSHOW ) 665*cdf0e10cSrcweir { 666*cdf0e10cSrcweir // FloatingWindows are not centered by default 667*cdf0e10cSrcweir if ( pImp->aWinState.Len() ) 668*cdf0e10cSrcweir SetWindowState( pImp->aWinState ); 669*cdf0e10cSrcweir pImp->bConstructed = sal_True; 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir FloatingWindow::StateChanged( nStateChange ); 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir void SfxFloatingWindow::Initialize(SfxChildWinInfo *pInfo) 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir /* [Beschreibung] 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir Initialisierung der Klasse SfxFloatingWindow "uber ein SfxChildWinInfo. 681*cdf0e10cSrcweir Die Initialisierung erfolgt erst in einem 2.Schritt 682*cdf0e10cSrcweir nach dem ctor und sollte vom ctor der abgeleiteten Klasse 683*cdf0e10cSrcweir oder von dem des SfxChildWindows aufgerufen werden. 684*cdf0e10cSrcweir */ 685*cdf0e10cSrcweir { 686*cdf0e10cSrcweir pImp->aWinState = pInfo->aWinState; 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir //------------------------------------------------------------------------- 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir void SfxFloatingWindow::FillInfo(SfxChildWinInfo& rInfo) const 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir /* [Beschreibung] 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir F"ullt ein SfxChildWinInfo mit f"ur SfxFloatingWindow spezifischen Daten, 696*cdf0e10cSrcweir damit sie in die INI-Datei geschrieben werden koennen. 697*cdf0e10cSrcweir Es wird angenommen, da\s rInfo alle anderen evt. relevanten Daten in 698*cdf0e10cSrcweir der ChildWindow-Klasse erh"alt. 699*cdf0e10cSrcweir Eingetragen werden hier gemerkte Gr"o\se und das ZoomIn-Flag. 700*cdf0e10cSrcweir Wird diese Methode "uberschrieben, mu\s zuerst die Basisimplementierung 701*cdf0e10cSrcweir gerufen werden. 702*cdf0e10cSrcweir */ 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir { 705*cdf0e10cSrcweir rInfo.aSize = aSize; 706*cdf0e10cSrcweir if ( IsRollUp() ) 707*cdf0e10cSrcweir rInfo.nFlags |= SFX_CHILDWIN_ZOOMIN; 708*cdf0e10cSrcweir } 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir // SfxSingleTabDialog ---------------------------------------------------- 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir IMPL_LINK( SfxSingleTabDialog, OKHdl_Impl, Button *, EMPTYARG ) 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir /* [Beschreibung] 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir Ok_Handler; f"ur die gesetzte Page wird FillItemSet() gerufen. 717*cdf0e10cSrcweir */ 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir { 720*cdf0e10cSrcweir if ( !GetInputItemSet() ) 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir // TabPage without ItemSet 723*cdf0e10cSrcweir EndDialog( RET_OK ); 724*cdf0e10cSrcweir return 1; 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir 727*cdf0e10cSrcweir if ( !GetOutputItemSet() ) 728*cdf0e10cSrcweir { 729*cdf0e10cSrcweir CreateOutputItemSet( *GetInputItemSet() ); 730*cdf0e10cSrcweir } 731*cdf0e10cSrcweir sal_Bool bModified = sal_False; 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir if ( pImpl->m_pSfxPage->HasExchangeSupport() ) 734*cdf0e10cSrcweir { 735*cdf0e10cSrcweir int nRet = pImpl->m_pSfxPage->DeactivatePage( GetOutputSetImpl() ); 736*cdf0e10cSrcweir if ( nRet != SfxTabPage::LEAVE_PAGE ) 737*cdf0e10cSrcweir return 0; 738*cdf0e10cSrcweir else 739*cdf0e10cSrcweir bModified = ( GetOutputItemSet()->Count() > 0 ); 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir else 742*cdf0e10cSrcweir bModified = pImpl->m_pSfxPage->FillItemSet( *GetOutputSetImpl() ); 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir if ( bModified ) 745*cdf0e10cSrcweir { 746*cdf0e10cSrcweir // auch noch schnell User-Daten im IniManager abspeichern 747*cdf0e10cSrcweir pImpl->m_pSfxPage->FillUserData(); 748*cdf0e10cSrcweir String sData( pImpl->m_pSfxPage->GetUserData() ); 749*cdf0e10cSrcweir SvtViewOptions aPageOpt( E_TABPAGE, String::CreateFromInt32( GetUniqId() ) ); 750*cdf0e10cSrcweir aPageOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( sData ) ) ); 751*cdf0e10cSrcweir EndDialog( RET_OK ); 752*cdf0e10cSrcweir } 753*cdf0e10cSrcweir else 754*cdf0e10cSrcweir EndDialog( RET_CANCEL ); 755*cdf0e10cSrcweir return 0; 756*cdf0e10cSrcweir } 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir // ----------------------------------------------------------------------- 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir SfxSingleTabDialog::SfxSingleTabDialog 761*cdf0e10cSrcweir ( 762*cdf0e10cSrcweir Window *pParent, 763*cdf0e10cSrcweir const SfxItemSet& rSet, 764*cdf0e10cSrcweir sal_uInt16 nUniqueId 765*cdf0e10cSrcweir ) : 766*cdf0e10cSrcweir 767*cdf0e10cSrcweir /* [Beschreibung] 768*cdf0e10cSrcweir 769*cdf0e10cSrcweir Konstruktor der allgemeinen Basisklasse f"ur SingleTab-Dialoge; 770*cdf0e10cSrcweir ID f"ur das ini-file wird "ubergeben. 771*cdf0e10cSrcweir */ 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir SfxModalDialog( pParent, nUniqueId, WinBits( WB_STDMODAL | WB_3DLOOK ) ), 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir pOKBtn ( 0 ), 776*cdf0e10cSrcweir pCancelBtn ( 0 ), 777*cdf0e10cSrcweir pHelpBtn ( 0 ), 778*cdf0e10cSrcweir pImpl ( new SingleTabDlgImpl ) 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir DBG_WARNING( "please use the ctor with ViewFrame" ); 781*cdf0e10cSrcweir SetInputSet( &rSet ); 782*cdf0e10cSrcweir } 783*cdf0e10cSrcweir 784*cdf0e10cSrcweir // ----------------------------------------------------------------------- 785*cdf0e10cSrcweir 786*cdf0e10cSrcweir SfxSingleTabDialog::SfxSingleTabDialog 787*cdf0e10cSrcweir ( 788*cdf0e10cSrcweir Window* pParent, 789*cdf0e10cSrcweir sal_uInt16 nUniqueId, 790*cdf0e10cSrcweir const SfxItemSet* pInSet 791*cdf0e10cSrcweir ) 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir /* [Beschreibung] 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir Konstruktor der allgemeinen Basisklasse f"ur SingleTab-Dialoge; 796*cdf0e10cSrcweir ID f"ur das ini-file wird "ubergeben. 797*cdf0e10cSrcweir Sollte nicht mehr benutzt werden. 798*cdf0e10cSrcweir */ 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir : SfxModalDialog( pParent, nUniqueId, WinBits( WB_STDMODAL | WB_3DLOOK ) ), 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir pOKBtn ( 0 ), 803*cdf0e10cSrcweir pCancelBtn ( 0 ), 804*cdf0e10cSrcweir pHelpBtn ( 0 ), 805*cdf0e10cSrcweir pImpl ( new SingleTabDlgImpl ) 806*cdf0e10cSrcweir { 807*cdf0e10cSrcweir DBG_WARNING( "bitte den Ctor mit ViewFrame verwenden" ); 808*cdf0e10cSrcweir SetInputSet( pInSet ); 809*cdf0e10cSrcweir } 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir // ----------------------------------------------------------------------- 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir SfxSingleTabDialog::SfxSingleTabDialog 814*cdf0e10cSrcweir ( 815*cdf0e10cSrcweir Window* pParent, 816*cdf0e10cSrcweir sal_uInt16 nUniqueId, 817*cdf0e10cSrcweir const String& rInfoURL 818*cdf0e10cSrcweir ) 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir /* [Beschreibung] 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir Konstruktor der allgemeinen Basisklasse f"ur SingleTab-Dialoge; 823*cdf0e10cSrcweir ID f"ur das ini-file wird "ubergeben. 824*cdf0e10cSrcweir */ 825*cdf0e10cSrcweir 826*cdf0e10cSrcweir : SfxModalDialog( pParent, nUniqueId, WinBits( WB_STDMODAL | WB_3DLOOK ) ), 827*cdf0e10cSrcweir 828*cdf0e10cSrcweir pOKBtn ( NULL ), 829*cdf0e10cSrcweir pCancelBtn ( NULL ), 830*cdf0e10cSrcweir pHelpBtn ( NULL ), 831*cdf0e10cSrcweir pImpl ( new SingleTabDlgImpl ) 832*cdf0e10cSrcweir { 833*cdf0e10cSrcweir pImpl->m_sInfoURL = rInfoURL; 834*cdf0e10cSrcweir } 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir // ----------------------------------------------------------------------- 837*cdf0e10cSrcweir 838*cdf0e10cSrcweir SfxSingleTabDialog::~SfxSingleTabDialog() 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir delete pOKBtn; 841*cdf0e10cSrcweir delete pCancelBtn; 842*cdf0e10cSrcweir delete pHelpBtn; 843*cdf0e10cSrcweir delete pImpl->m_pTabPage; 844*cdf0e10cSrcweir delete pImpl->m_pSfxPage; 845*cdf0e10cSrcweir delete pImpl->m_pLine; 846*cdf0e10cSrcweir delete pImpl->m_pInfoImage; 847*cdf0e10cSrcweir delete pImpl; 848*cdf0e10cSrcweir } 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir // ----------------------------------------------------------------------- 851*cdf0e10cSrcweir 852*cdf0e10cSrcweir void SfxSingleTabDialog::SetPage( TabPage* pNewPage ) 853*cdf0e10cSrcweir { 854*cdf0e10cSrcweir if ( !pImpl->m_pLine ) 855*cdf0e10cSrcweir pImpl->m_pLine = new FixedLine( this ); 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir if ( !pOKBtn ) 858*cdf0e10cSrcweir { 859*cdf0e10cSrcweir pOKBtn = new OKButton( this, WB_DEFBUTTON ); 860*cdf0e10cSrcweir pOKBtn->SetClickHdl( LINK( this, SfxSingleTabDialog, OKHdl_Impl ) ); 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir if ( pImpl->m_sInfoURL.Len() > 0 && !pImpl->m_pInfoImage ) 864*cdf0e10cSrcweir { 865*cdf0e10cSrcweir pImpl->m_pInfoImage = new ::svt::FixedHyperlinkImage( this ); 866*cdf0e10cSrcweir Image aInfoImage = Image( SfxResId( IMG_INFO ) ); 867*cdf0e10cSrcweir Size aImageSize = aInfoImage.GetSizePixel(); 868*cdf0e10cSrcweir aImageSize.Width() += 4; 869*cdf0e10cSrcweir aImageSize.Height() += 4; 870*cdf0e10cSrcweir pImpl->m_pInfoImage->SetSizePixel( aImageSize ); 871*cdf0e10cSrcweir pImpl->m_pInfoImage->SetImage( aInfoImage ); 872*cdf0e10cSrcweir pImpl->m_pInfoImage->SetURL( pImpl->m_sInfoURL ); 873*cdf0e10cSrcweir pImpl->m_pInfoImage->SetClickHdl( pImpl->m_aInfoLink ); 874*cdf0e10cSrcweir } 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir if ( pImpl->m_pTabPage ) 877*cdf0e10cSrcweir delete pImpl->m_pTabPage; 878*cdf0e10cSrcweir if ( pImpl->m_pSfxPage ) 879*cdf0e10cSrcweir delete pImpl->m_pSfxPage; 880*cdf0e10cSrcweir pImpl->m_pTabPage = pNewPage; 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir if ( pImpl->m_pTabPage ) 883*cdf0e10cSrcweir { 884*cdf0e10cSrcweir // Gr"ossen und Positionen anpassen 885*cdf0e10cSrcweir pImpl->m_pTabPage->SetPosPixel( Point() ); 886*cdf0e10cSrcweir Size aOutSz( pImpl->m_pTabPage->GetSizePixel() ); 887*cdf0e10cSrcweir Size aOffSz = LogicToPixel( Size( RSC_SP_CTRL_X, RSC_SP_CTRL_Y ), MAP_APPFONT ); 888*cdf0e10cSrcweir Size aFLSz = LogicToPixel( Size( aOutSz.Width(), RSC_CD_FIXEDLINE_HEIGHT ) ); 889*cdf0e10cSrcweir Size aBtnSz = LogicToPixel( Size( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ), MAP_APPFONT ); 890*cdf0e10cSrcweir 891*cdf0e10cSrcweir Point aPnt( 0, aOutSz.Height() ); 892*cdf0e10cSrcweir pImpl->m_pLine->SetPosSizePixel( aPnt, aFLSz ); 893*cdf0e10cSrcweir aPnt.X() = aOutSz.Width() - aOffSz.Width() - aBtnSz.Width(); 894*cdf0e10cSrcweir aPnt.Y() += aFLSz.Height() + ( aOffSz.Height() / 2 ); 895*cdf0e10cSrcweir pOKBtn->SetPosSizePixel( aPnt, aBtnSz ); 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir if ( pImpl->m_pInfoImage ) 898*cdf0e10cSrcweir { 899*cdf0e10cSrcweir aPnt.X() = aOffSz.Width(); 900*cdf0e10cSrcweir long nDelta = ( pImpl->m_pInfoImage->GetSizePixel().Height() - aBtnSz.Height() ) / 2; 901*cdf0e10cSrcweir aPnt.Y() -= nDelta; 902*cdf0e10cSrcweir pImpl->m_pInfoImage->SetPosPixel( aPnt ); 903*cdf0e10cSrcweir pImpl->m_pInfoImage->Show(); 904*cdf0e10cSrcweir } 905*cdf0e10cSrcweir 906*cdf0e10cSrcweir aOutSz.Height() += aFLSz.Height() + ( aOffSz.Height() / 2 ) + aBtnSz.Height() + aOffSz.Height(); 907*cdf0e10cSrcweir SetOutputSizePixel( aOutSz ); 908*cdf0e10cSrcweir 909*cdf0e10cSrcweir pImpl->m_pLine->Show(); 910*cdf0e10cSrcweir pOKBtn->Show(); 911*cdf0e10cSrcweir pImpl->m_pTabPage->Show(); 912*cdf0e10cSrcweir 913*cdf0e10cSrcweir // Text der TabPage in den Dialog setzen 914*cdf0e10cSrcweir SetText( pImpl->m_pTabPage->GetText() ); 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir // Dialog bekommt HelpId der TabPage 917*cdf0e10cSrcweir SetHelpId( pImpl->m_pTabPage->GetHelpId() ); 918*cdf0e10cSrcweir SetUniqueId( pImpl->m_pTabPage->GetUniqueId() ); 919*cdf0e10cSrcweir } 920*cdf0e10cSrcweir } 921*cdf0e10cSrcweir 922*cdf0e10cSrcweir // ----------------------------------------------------------------------- 923*cdf0e10cSrcweir 924*cdf0e10cSrcweir void SfxSingleTabDialog::SetTabPage( SfxTabPage* pTabPage, 925*cdf0e10cSrcweir GetTabPageRanges pRangesFunc ) 926*cdf0e10cSrcweir /* [Beschreibung] 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir Setzen einer (neuen) TabPage; eine bereits vorhandene Page 929*cdf0e10cSrcweir wird gel"oscht. 930*cdf0e10cSrcweir Die "ubergebene Page wird durch Aufruf von Reset() mit dem 931*cdf0e10cSrcweir initial "ubergebenen Itemset initialisiert. 932*cdf0e10cSrcweir */ 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir { 935*cdf0e10cSrcweir if ( !pOKBtn ) 936*cdf0e10cSrcweir { 937*cdf0e10cSrcweir pOKBtn = new OKButton( this, WB_DEFBUTTON ); 938*cdf0e10cSrcweir pOKBtn->SetClickHdl( LINK( this, SfxSingleTabDialog, OKHdl_Impl ) ); 939*cdf0e10cSrcweir } 940*cdf0e10cSrcweir if ( !pCancelBtn ) 941*cdf0e10cSrcweir pCancelBtn = new CancelButton( this ); 942*cdf0e10cSrcweir if ( !pHelpBtn ) 943*cdf0e10cSrcweir pHelpBtn = new HelpButton( this ); 944*cdf0e10cSrcweir 945*cdf0e10cSrcweir if ( pImpl->m_pTabPage ) 946*cdf0e10cSrcweir delete pImpl->m_pTabPage; 947*cdf0e10cSrcweir if ( pImpl->m_pSfxPage ) 948*cdf0e10cSrcweir delete pImpl->m_pSfxPage; 949*cdf0e10cSrcweir pImpl->m_pSfxPage = pTabPage; 950*cdf0e10cSrcweir fnGetRanges = pRangesFunc; 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir if ( pImpl->m_pSfxPage ) 953*cdf0e10cSrcweir { 954*cdf0e10cSrcweir // erstmal die User-Daten besorgen, dann erst Reset() 955*cdf0e10cSrcweir SvtViewOptions aPageOpt( E_TABPAGE, String::CreateFromInt32( GetUniqId() ) ); 956*cdf0e10cSrcweir String sUserData; 957*cdf0e10cSrcweir Any aUserItem = aPageOpt.GetUserItem( USERITEM_NAME ); 958*cdf0e10cSrcweir OUString aTemp; 959*cdf0e10cSrcweir if ( aUserItem >>= aTemp ) 960*cdf0e10cSrcweir sUserData = String( aTemp ); 961*cdf0e10cSrcweir pImpl->m_pSfxPage->SetUserData( sUserData ); 962*cdf0e10cSrcweir pImpl->m_pSfxPage->Reset( *GetInputItemSet() ); 963*cdf0e10cSrcweir pImpl->m_pSfxPage->Show(); 964*cdf0e10cSrcweir 965*cdf0e10cSrcweir // Gr"ossen und Positionen anpassen 966*cdf0e10cSrcweir pImpl->m_pSfxPage->SetPosPixel( Point() ); 967*cdf0e10cSrcweir Size aOutSz( pImpl->m_pSfxPage->GetSizePixel() ); 968*cdf0e10cSrcweir Size aBtnSiz = LogicToPixel( Size( 50, 14 ), MAP_APPFONT ); 969*cdf0e10cSrcweir Point aPnt( aOutSz.Width(), LogicToPixel( Point( 0, 6 ), MAP_APPFONT ).Y() ); 970*cdf0e10cSrcweir aOutSz.Width() += aBtnSiz.Width() + LogicToPixel( Size( 6, 0 ), MAP_APPFONT ).Width(); 971*cdf0e10cSrcweir SetOutputSizePixel( aOutSz ); 972*cdf0e10cSrcweir pOKBtn->SetPosSizePixel( aPnt, aBtnSiz ); 973*cdf0e10cSrcweir pOKBtn->Show(); 974*cdf0e10cSrcweir aPnt.Y() = LogicToPixel( Point( 0, 23 ), MAP_APPFONT ).Y(); 975*cdf0e10cSrcweir pCancelBtn->SetPosSizePixel( aPnt, aBtnSiz ); 976*cdf0e10cSrcweir pCancelBtn->Show(); 977*cdf0e10cSrcweir aPnt.Y() = LogicToPixel( Point( 0, 43 ), MAP_APPFONT ).Y(); 978*cdf0e10cSrcweir pHelpBtn->SetPosSizePixel( aPnt, aBtnSiz ); 979*cdf0e10cSrcweir 980*cdf0e10cSrcweir if ( Help::IsContextHelpEnabled() ) 981*cdf0e10cSrcweir pHelpBtn->Show(); 982*cdf0e10cSrcweir 983*cdf0e10cSrcweir // Text der TabPage in den Dialog setzen 984*cdf0e10cSrcweir SetText( pImpl->m_pSfxPage->GetText() ); 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir // Dialog bekommt HelpId der TabPage 987*cdf0e10cSrcweir SetHelpId( pImpl->m_pSfxPage->GetHelpId() ); 988*cdf0e10cSrcweir SetUniqueId( pImpl->m_pSfxPage->GetUniqueId() ); 989*cdf0e10cSrcweir } 990*cdf0e10cSrcweir } 991*cdf0e10cSrcweir 992*cdf0e10cSrcweir // ----------------------------------------------------------------------- 993*cdf0e10cSrcweir 994*cdf0e10cSrcweir void SfxSingleTabDialog::SetInfoLink( const Link& rLink ) 995*cdf0e10cSrcweir { 996*cdf0e10cSrcweir pImpl->m_aInfoLink = rLink; 997*cdf0e10cSrcweir } 998*cdf0e10cSrcweir 999*cdf0e10cSrcweir //-------------------------------------------------------------------- 1000*cdf0e10cSrcweir // Vergleichsfunktion fuer qsort 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir #ifdef WNT 1003*cdf0e10cSrcweir int __cdecl BaseDlgsCmpUS_Impl( const void* p1, const void* p2 ) 1004*cdf0e10cSrcweir #else 1005*cdf0e10cSrcweir #if defined(OS2) && defined(ICC) 1006*cdf0e10cSrcweir int _Optlink BaseDlgsCmpUS_Impl( const void* p1, const void* p2 ) 1007*cdf0e10cSrcweir #else 1008*cdf0e10cSrcweir extern "C" int BaseDlgsCmpUS_Impl( const void* p1, const void* p2 ) 1009*cdf0e10cSrcweir #endif 1010*cdf0e10cSrcweir #endif 1011*cdf0e10cSrcweir { 1012*cdf0e10cSrcweir return *(sal_uInt16*)p1 - *(sal_uInt16*)p2; 1013*cdf0e10cSrcweir } 1014*cdf0e10cSrcweir 1015*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1016*cdf0e10cSrcweir 1017*cdf0e10cSrcweir /* 1018*cdf0e10cSrcweir Bildet das Set "uber die Ranges der Page. Die Page muss die statische 1019*cdf0e10cSrcweir Methode f"ur das Erfragen ihrer Ranges bei SetTabPage angegeben haben, 1020*cdf0e10cSrcweir liefert also ihr Set onDemand. 1021*cdf0e10cSrcweir */ 1022*cdf0e10cSrcweir const sal_uInt16* SfxSingleTabDialog::GetInputRanges( const SfxItemPool& rPool ) 1023*cdf0e10cSrcweir { 1024*cdf0e10cSrcweir if ( GetInputItemSet() ) 1025*cdf0e10cSrcweir { 1026*cdf0e10cSrcweir DBG_ERROR( "Set bereits vorhanden!" ); 1027*cdf0e10cSrcweir return GetInputItemSet()->GetRanges(); 1028*cdf0e10cSrcweir } 1029*cdf0e10cSrcweir 1030*cdf0e10cSrcweir if ( pRanges ) 1031*cdf0e10cSrcweir return pRanges; 1032*cdf0e10cSrcweir SvUShorts aUS(16, 16); 1033*cdf0e10cSrcweir 1034*cdf0e10cSrcweir if ( fnGetRanges) 1035*cdf0e10cSrcweir { 1036*cdf0e10cSrcweir const sal_uInt16 *pTmpRanges = (fnGetRanges)(); 1037*cdf0e10cSrcweir const sal_uInt16 *pIter = pTmpRanges; 1038*cdf0e10cSrcweir sal_uInt16 nLen; 1039*cdf0e10cSrcweir for ( nLen = 0; *pIter; ++nLen, ++pIter ) 1040*cdf0e10cSrcweir ; 1041*cdf0e10cSrcweir aUS.Insert( pTmpRanges, nLen, aUS.Count() ); 1042*cdf0e10cSrcweir } 1043*cdf0e10cSrcweir 1044*cdf0e10cSrcweir //! Doppelte Ids entfernen? 1045*cdf0e10cSrcweir sal_uInt16 nCount = aUS.Count(); 1046*cdf0e10cSrcweir 1047*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; ++i ) 1048*cdf0e10cSrcweir aUS[i] = rPool.GetWhich( aUS[i]) ; 1049*cdf0e10cSrcweir 1050*cdf0e10cSrcweir // sortieren 1051*cdf0e10cSrcweir if ( aUS.Count() > 1 ) 1052*cdf0e10cSrcweir qsort( (void*)aUS.GetData(), aUS.Count(), sizeof(sal_uInt16), BaseDlgsCmpUS_Impl ); 1053*cdf0e10cSrcweir 1054*cdf0e10cSrcweir pRanges = new sal_uInt16[aUS.Count() + 1]; 1055*cdf0e10cSrcweir memcpy( pRanges, aUS.GetData(), sizeof(sal_uInt16) * aUS.Count() ); 1056*cdf0e10cSrcweir pRanges[aUS.Count()] = 0; 1057*cdf0e10cSrcweir return pRanges; 1058*cdf0e10cSrcweir } 1059*cdf0e10cSrcweir 1060