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