Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <stdlib.h>
21 : #include <comphelper/processfactory.hxx>
22 : #include <osl/file.hxx>
23 : #include <vcl/fixed.hxx>
24 : #include <vcl/help.hxx>
25 : #include <vcl/msgbox.hxx>
26 : #include <svl/eitem.hxx>
27 : #include <unotools/viewoptions.hxx>
28 : #include <svtools/controldims.hrc>
29 : #include <vcl/idle.hxx>
30 :
31 : #include <sfx2/basedlgs.hxx>
32 : #include <sfx2/viewfrm.hxx>
33 : #include <sfx2/tabdlg.hxx>
34 : #include <sfx2/app.hxx>
35 : #include <sfx2/bindings.hxx>
36 : #include <sfx2/dispatch.hxx>
37 : #include <sfx2/childwin.hxx>
38 : #include <sfx2/viewsh.hxx>
39 : #include <sfx2/sfxhelp.hxx>
40 : #include "workwin.hxx"
41 : #include <sfx2/sfxresid.hxx>
42 : #include "dialog.hrc"
43 :
44 : using namespace ::com::sun::star::uno;
45 :
46 : #define USERITEM_NAME OUString("UserItem")
47 :
48 0 : SingleTabDlgImpl::SingleTabDlgImpl()
49 : : m_pSfxPage(NULL)
50 0 : , m_pLine(NULL)
51 : {
52 0 : }
53 :
54 0 : class SfxModelessDialog_Impl : public SfxListener
55 : {
56 : public:
57 : OString aWinState;
58 : SfxChildWindow* pMgr;
59 : bool bConstructed;
60 : void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
61 :
62 : Idle aMoveIdle;
63 : };
64 :
65 0 : void SfxModelessDialog_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint )
66 : {
67 0 : const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
68 0 : if ( pSimpleHint )
69 : {
70 0 : switch( pSimpleHint->GetId() )
71 : {
72 : case SFX_HINT_DYING:
73 0 : pMgr->Destroy();
74 0 : break;
75 : }
76 : }
77 0 : }
78 :
79 0 : class SfxFloatingWindow_Impl : public SfxListener
80 : {
81 : public:
82 : OString aWinState;
83 : SfxChildWindow* pMgr;
84 : bool bConstructed;
85 : Idle aMoveIdle;
86 :
87 : void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
88 : };
89 :
90 0 : void SfxFloatingWindow_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint )
91 : {
92 0 : const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
93 0 : if ( pSimpleHint )
94 : {
95 0 : switch( pSimpleHint->GetId() )
96 : {
97 : case SFX_HINT_DYING:
98 0 : pMgr->Destroy();
99 0 : break;
100 : }
101 : }
102 0 : }
103 :
104 :
105 :
106 0 : void SfxModalDialog::SetDialogData_Impl()
107 : {
108 : // save settings (position and user data)
109 0 : OUString sConfigId;
110 0 : if (isLayoutEnabled())
111 0 : sConfigId = OStringToOUString(GetHelpId(),RTL_TEXTENCODING_UTF8);
112 : else
113 : {
114 : SAL_WARN("sfx.config", "Dialog needs to be converted to .ui format");
115 0 : sConfigId = OUString::number(nUniqId);
116 : }
117 :
118 0 : SvtViewOptions aDlgOpt(E_DIALOG, sConfigId);
119 : aDlgOpt.SetWindowState(OStringToOUString(
120 0 : GetWindowState(WINDOWSTATE_MASK_POS), RTL_TEXTENCODING_ASCII_US));
121 0 : if ( !aExtraData.isEmpty() )
122 0 : aDlgOpt.SetUserItem( USERITEM_NAME, makeAny( aExtraData ) );
123 0 : }
124 :
125 :
126 :
127 0 : void SfxModalDialog::GetDialogData_Impl()
128 :
129 : /* [Description]
130 :
131 : Helper function, reads the dialogue position from the ini file and
132 : puts them on the transferred window.
133 : */
134 :
135 : {
136 0 : OUString sConfigId;
137 0 : if (isLayoutEnabled())
138 0 : sConfigId = OStringToOUString(GetHelpId(),RTL_TEXTENCODING_UTF8);
139 : else
140 : {
141 : SAL_WARN("sfx.config", "Dialog needs to be converted to .ui format");
142 0 : sConfigId = OUString::number(nUniqId);
143 : }
144 :
145 0 : SvtViewOptions aDlgOpt(E_DIALOG, sConfigId);
146 0 : if ( aDlgOpt.Exists() )
147 : {
148 : // load settings
149 0 : SetWindowState( OUStringToOString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) );
150 0 : Any aUserItem = aDlgOpt.GetUserItem( USERITEM_NAME );
151 0 : OUString aTemp;
152 0 : if ( aUserItem >>= aTemp )
153 0 : aExtraData = aTemp;
154 0 : }
155 0 : }
156 :
157 0 : void SfxModalDialog::init()
158 : {
159 0 : GetDialogData_Impl();
160 0 : }
161 :
162 0 : SfxModalDialog::SfxModalDialog(vcl::Window *pParent, const OUString& rID, const OUString& rUIXMLDescription )
163 : : ModalDialog(pParent, rID, rUIXMLDescription),
164 : nUniqId(0), //todo: remove this member when the ResId using ctor is removed
165 : pInputSet(0),
166 0 : pOutputSet(0)
167 : {
168 0 : init();
169 0 : }
170 :
171 0 : SfxModalDialog::~SfxModalDialog()
172 : {
173 0 : disposeOnce();
174 0 : }
175 :
176 0 : void SfxModalDialog::dispose()
177 : {
178 0 : SetDialogData_Impl();
179 0 : delete pOutputSet;
180 0 : ModalDialog::dispose();
181 0 : }
182 :
183 0 : void SfxModalDialog::CreateOutputItemSet( SfxItemPool& rPool )
184 : {
185 : DBG_ASSERT( !pOutputSet, "Double creation of OutputSet!" );
186 0 : if (!pOutputSet)
187 0 : pOutputSet = new SfxAllItemSet( rPool );
188 0 : }
189 :
190 :
191 :
192 0 : void SfxModalDialog::CreateOutputItemSet( const SfxItemSet& rSet )
193 : {
194 : DBG_ASSERT( !pOutputSet, "Double creation of OutputSet!" );
195 0 : if (!pOutputSet)
196 : {
197 0 : pOutputSet = new SfxItemSet( rSet );
198 0 : pOutputSet->ClearItem();
199 : }
200 0 : }
201 :
202 :
203 0 : void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
204 : {
205 0 : if ( nStateChange == StateChangedType::InitShow )
206 : {
207 0 : if ( !pImp->aWinState.isEmpty() )
208 : {
209 0 : SetWindowState( pImp->aWinState );
210 : }
211 : else
212 : {
213 0 : Point aPos = GetPosPixel();
214 0 : if ( !aPos.X() )
215 : {
216 0 : aSize = GetSizePixel();
217 :
218 0 : Size aParentSize = GetParent()->GetOutputSizePixel();
219 0 : Size aDlgSize = GetSizePixel();
220 0 : aPos.X() += ( aParentSize.Width() - aDlgSize.Width() ) / 2;
221 0 : aPos.Y() += ( aParentSize.Height() - aDlgSize.Height() ) / 2;
222 :
223 0 : Point aPoint;
224 0 : Rectangle aRect = GetDesktopRectPixel();
225 0 : aPoint.X() = aRect.Right() - aDlgSize.Width();
226 0 : aPoint.Y() = aRect.Bottom() - aDlgSize.Height();
227 :
228 0 : aPoint = OutputToScreenPixel( aPoint );
229 :
230 0 : if ( aPos.X() > aPoint.X() )
231 0 : aPos.X() = aPoint.X() ;
232 0 : if ( aPos.Y() > aPoint.Y() )
233 0 : aPos.Y() = aPoint.Y();
234 :
235 0 : if ( aPos.X() < 0 ) aPos.X() = 0;
236 0 : if ( aPos.Y() < 0 ) aPos.Y() = 0;
237 :
238 0 : SetPosPixel( aPos );
239 : }
240 : }
241 :
242 0 : pImp->bConstructed = true;
243 : }
244 :
245 0 : ModelessDialog::StateChanged( nStateChange );
246 0 : }
247 :
248 0 : void SfxModelessDialog::Initialize(SfxChildWinInfo *pInfo)
249 :
250 : /* [Description]
251 :
252 : Initialization of the class SfxModelessDialog via a SfxChildWinInfo.
253 : The initialization is done only in a 2nd step after the constructor, this
254 : constructor should be called from the derived class or from the
255 : SfxChildWindows.
256 : */
257 :
258 : {
259 0 : if (pInfo)
260 0 : pImp->aWinState = pInfo->aWinState;
261 0 : }
262 :
263 0 : void SfxModelessDialog::Resize()
264 :
265 : /* [Description]
266 :
267 : This virtual method of the class FloatingWindow keeps track if a change
268 : in size has been made. When this method is overridden by a derived class,
269 : then the SfxFloatingWindow: Resize() must also be called.
270 : */
271 :
272 : {
273 0 : ModelessDialog::Resize();
274 0 : if ( pImp->bConstructed && pImp->pMgr )
275 : {
276 : // start timer for saving window status information
277 0 : pImp->aMoveIdle.Start();
278 : }
279 0 : }
280 :
281 0 : void SfxModelessDialog::Move()
282 : {
283 0 : ModelessDialog::Move();
284 0 : if ( pImp->bConstructed && pImp->pMgr && IsReallyVisible() )
285 : {
286 : // start timer for saving window status information
287 0 : pImp->aMoveIdle.Start();
288 : }
289 0 : }
290 :
291 : /*
292 : Implements a timer event that is triggered by a move or resize of the window
293 : This will save config information to Views.xcu with a small delay
294 : */
295 0 : IMPL_LINK_NOARG_TYPED(SfxModelessDialog, TimerHdl, Idle *, void)
296 : {
297 0 : pImp->aMoveIdle.Stop();
298 0 : if ( pImp->bConstructed && pImp->pMgr )
299 : {
300 0 : if ( !IsRollUp() )
301 0 : aSize = GetSizePixel();
302 0 : sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE;
303 0 : if ( GetStyle() & WB_SIZEABLE )
304 0 : nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT );
305 0 : pImp->aWinState = GetWindowState( nMask );
306 0 : GetBindings().GetWorkWindow_Impl()->ConfigChild_Impl( SfxChildIdentifier::DOCKINGWINDOW, SfxDockingConfig::ALIGNDOCKINGWINDOW, pImp->pMgr->GetType() );
307 : }
308 0 : }
309 :
310 0 : SfxModelessDialog::SfxModelessDialog(SfxBindings* pBindinx,
311 : SfxChildWindow *pCW, vcl::Window *pParent, const OUString& rID,
312 : const OUString& rUIXMLDescription)
313 0 : : ModelessDialog(pParent, rID, rUIXMLDescription)
314 : {
315 0 : Init(pBindinx, pCW);
316 0 : }
317 :
318 0 : void SfxModelessDialog::Init(SfxBindings *pBindinx, SfxChildWindow *pCW)
319 : {
320 0 : pBindings = pBindinx;
321 0 : pImp = new SfxModelessDialog_Impl;
322 0 : pImp->pMgr = pCW;
323 0 : pImp->bConstructed = false;
324 0 : SetUniqueId( GetHelpId() );
325 0 : if ( pBindinx )
326 0 : pImp->StartListening( *pBindinx );
327 0 : pImp->aMoveIdle.SetPriority(SchedulerPriority::RESIZE);
328 0 : pImp->aMoveIdle.SetIdleHdl(LINK(this,SfxModelessDialog,TimerHdl));
329 0 : }
330 :
331 : /* [Description]
332 :
333 : If a ModelessDialog is enabled its ViewFrame wil be activated.
334 : This is necessary by PluginInFrames.
335 : */
336 0 : bool SfxModelessDialog::Notify( NotifyEvent& rEvt )
337 : {
338 0 : if ( pImp )
339 : {
340 0 : if ( rEvt.GetType() == MouseNotifyEvent::GETFOCUS )
341 : {
342 0 : pBindings->SetActiveFrame( pImp->pMgr->GetFrame() );
343 0 : pImp->pMgr->Activate_Impl();
344 : }
345 0 : else if ( rEvt.GetType() == MouseNotifyEvent::LOSEFOCUS && !HasChildPathFocus() )
346 : {
347 0 : pBindings->SetActiveFrame( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > () );
348 0 : pImp->pMgr->Deactivate_Impl();
349 : }
350 0 : else if( rEvt.GetType() == MouseNotifyEvent::KEYINPUT )
351 : {
352 : // First, allow KeyInput for Dialog functions ( TAB etc. )
353 0 : if ( !ModelessDialog::Notify( rEvt ) && SfxViewShell::Current() )
354 : // then also for valid global accelerators.
355 0 : return SfxViewShell::Current()->GlobalKeyInput_Impl( *rEvt.GetKeyEvent() );
356 0 : return true;
357 : }
358 : }
359 :
360 0 : return ModelessDialog::Notify( rEvt );
361 : }
362 :
363 0 : SfxModelessDialog::~SfxModelessDialog()
364 : {
365 0 : disposeOnce();
366 0 : }
367 :
368 0 : void SfxModelessDialog::dispose()
369 : {
370 0 : if ( pImp->pMgr->GetFrame().is() && pImp->pMgr->GetFrame() == pBindings->GetActiveFrame() )
371 0 : pBindings->SetActiveFrame( NULL );
372 0 : delete pImp;
373 0 : pImp = NULL;
374 0 : ModelessDialog::dispose();
375 0 : }
376 :
377 :
378 :
379 0 : bool SfxModelessDialog::Close()
380 :
381 : /* [Description]
382 :
383 : The window is closed when the ChildWindow is destroyed by running the
384 : ChildWindow-slots. If this is method is overridden by a derived class
385 : method, then the SfxModelessDialogWindow: Close() must be called afterwards
386 : if the Close() was not cancelled with "return sal_False".
387 : */
388 :
389 : {
390 : // Execute with Parameters, since Toggle is ignored by some ChildWindows.
391 0 : SfxBoolItem aValue( pImp->pMgr->GetType(), false);
392 : pBindings->GetDispatcher_Impl()->Execute(
393 0 : pImp->pMgr->GetType(),
394 0 : SfxCallMode::RECORD|SfxCallMode::SYNCHRON, &aValue, 0L );
395 0 : return true;
396 : }
397 :
398 :
399 :
400 0 : void SfxModelessDialog::FillInfo(SfxChildWinInfo& rInfo) const
401 :
402 : /* [Description]
403 :
404 : Fills a SfxChildWinInfo with specific data from SfxModelessDialog,
405 : so that it can be written in the INI file. It is assumed that rinfo
406 : receives all other possible relevant data in the ChildWindow class.
407 : ModelessDialogs have no specific information, so that the base
408 : implementation does nothing and therefore must not be called.
409 : */
410 :
411 : {
412 0 : rInfo.aSize = aSize;
413 0 : if ( IsRollUp() )
414 0 : rInfo.nFlags |= SfxChildWindowFlags::ZOOMIN;
415 0 : }
416 :
417 :
418 :
419 0 : bool SfxFloatingWindow::Notify( NotifyEvent& rEvt )
420 :
421 : /* [Description]
422 :
423 : If a ModelessDialog is enabled, its ViewFrame will be activated.
424 : This necessary for the PluginInFrames.
425 : */
426 :
427 : {
428 0 : if ( pImp )
429 : {
430 0 : if ( rEvt.GetType() == MouseNotifyEvent::GETFOCUS )
431 : {
432 0 : pBindings->SetActiveFrame( pImp->pMgr->GetFrame() );
433 0 : pImp->pMgr->Activate_Impl();
434 : }
435 0 : else if ( rEvt.GetType() == MouseNotifyEvent::LOSEFOCUS )
436 : {
437 0 : if ( !HasChildPathFocus() )
438 : {
439 0 : pBindings->SetActiveFrame( NULL );
440 0 : pImp->pMgr->Deactivate_Impl();
441 : }
442 : }
443 0 : else if( rEvt.GetType() == MouseNotifyEvent::KEYINPUT )
444 : {
445 : // First, allow KeyInput for Dialog functions
446 0 : if ( !FloatingWindow::Notify( rEvt ) && SfxViewShell::Current() )
447 : // then also for valid global accelerators.
448 0 : return SfxViewShell::Current()->GlobalKeyInput_Impl( *rEvt.GetKeyEvent() );
449 0 : return true;
450 : }
451 : }
452 :
453 0 : return FloatingWindow::Notify( rEvt );
454 : }
455 :
456 0 : SfxFloatingWindow::SfxFloatingWindow( SfxBindings *pBindinx,
457 : SfxChildWindow *pCW,
458 : vcl::Window* pParent, WinBits nWinBits) :
459 : FloatingWindow (pParent, nWinBits),
460 : pBindings(pBindinx),
461 0 : pImp( new SfxFloatingWindow_Impl )
462 : {
463 0 : pImp->pMgr = pCW;
464 0 : pImp->bConstructed = false;
465 0 : SetUniqueId( GetHelpId() );
466 0 : SetHelpId("");
467 0 : if ( pBindinx )
468 0 : pImp->StartListening( *pBindinx );
469 0 : pImp->aMoveIdle.SetPriority(SchedulerPriority::RESIZE);
470 0 : pImp->aMoveIdle.SetIdleHdl(LINK(this,SfxFloatingWindow,TimerHdl));
471 0 : }
472 :
473 0 : SfxFloatingWindow::SfxFloatingWindow( SfxBindings *pBindinx,
474 : SfxChildWindow *pCW,
475 : vcl::Window* pParent,
476 : const OString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame> &rFrame) :
477 : FloatingWindow(pParent, rID, rUIXMLDescription, rFrame),
478 : pBindings(pBindinx),
479 0 : pImp( new SfxFloatingWindow_Impl )
480 : {
481 0 : pImp->pMgr = pCW;
482 0 : pImp->bConstructed = false;
483 :
484 : //do we really need this odd helpid/uniqueid dance ?
485 0 : SetUniqueId( GetHelpId() );
486 0 : SetHelpId("");
487 :
488 0 : if ( pBindinx )
489 0 : pImp->StartListening( *pBindinx );
490 0 : pImp->aMoveIdle.SetPriority(SchedulerPriority::RESIZE);
491 0 : pImp->aMoveIdle.SetIdleHdl(LINK(this,SfxFloatingWindow,TimerHdl));
492 0 : }
493 :
494 0 : bool SfxFloatingWindow::Close()
495 :
496 : /* [Description]
497 :
498 : The window is closed when the ChildWindow is destroyed by running the
499 : ChildWindow-slots. If this is method is overridden by a derived class
500 : method, then the SfxModelessDialogWindow: Close) must be called afterwards
501 : if the Close() was not cancelled with "return sal_False".
502 : */
503 :
504 : {
505 : // Execute with Parameters, since Toggle is ignored by some ChildWindows.
506 0 : SfxBoolItem aValue( pImp->pMgr->GetType(), false);
507 : pBindings->GetDispatcher_Impl()->Execute(
508 0 : pImp->pMgr->GetType(),
509 0 : SfxCallMode::RECORD|SfxCallMode::SYNCHRON, &aValue, 0L );
510 0 : return true;
511 : }
512 :
513 :
514 :
515 0 : SfxFloatingWindow::~SfxFloatingWindow()
516 : {
517 0 : disposeOnce();
518 0 : }
519 :
520 0 : void SfxFloatingWindow::dispose()
521 : {
522 0 : if ( pImp && pImp->pMgr->GetFrame() == pBindings->GetActiveFrame() )
523 0 : pBindings->SetActiveFrame( NULL );
524 0 : delete pImp;
525 0 : pImp = NULL;
526 0 : FloatingWindow::dispose();
527 0 : }
528 :
529 0 : void SfxFloatingWindow::Resize()
530 :
531 : /* [Description]
532 :
533 : This virtual method of the class FloatingWindow keeps track if a change
534 : in size has been made. When this method is overridden by a derived class,
535 : then the SfxFloatingWindow: Resize() must also be called.
536 : */
537 :
538 : {
539 0 : FloatingWindow::Resize();
540 0 : if ( pImp->bConstructed && pImp->pMgr )
541 : {
542 : // start timer for saving window status information
543 0 : pImp->aMoveIdle.Start();
544 : }
545 0 : }
546 :
547 0 : void SfxFloatingWindow::Move()
548 : {
549 0 : FloatingWindow::Move();
550 0 : if ( pImp->bConstructed && pImp->pMgr )
551 : {
552 : // start timer for saving window status information
553 0 : pImp->aMoveIdle.Start();
554 : }
555 0 : }
556 :
557 : /*
558 : Implements a timer event that is triggered by a move or resize of the window
559 : This will save config information to Views.xcu with a small delay
560 : */
561 0 : IMPL_LINK_NOARG_TYPED(SfxFloatingWindow, TimerHdl, Idle *, void)
562 : {
563 0 : pImp->aMoveIdle.Stop();
564 0 : if ( pImp->bConstructed && pImp->pMgr )
565 : {
566 0 : if ( !IsRollUp() )
567 0 : aSize = GetSizePixel();
568 0 : sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE;
569 0 : if ( GetStyle() & WB_SIZEABLE )
570 0 : nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT );
571 0 : pImp->aWinState = GetWindowState( nMask );
572 0 : GetBindings().GetWorkWindow_Impl()->ConfigChild_Impl( SfxChildIdentifier::DOCKINGWINDOW, SfxDockingConfig::ALIGNDOCKINGWINDOW, pImp->pMgr->GetType() );
573 : }
574 0 : }
575 :
576 :
577 0 : void SfxFloatingWindow::StateChanged( StateChangedType nStateChange )
578 : {
579 0 : if ( nStateChange == StateChangedType::InitShow )
580 : {
581 : // FloatingWindows are not centered by default
582 0 : if ( !pImp->aWinState.isEmpty() )
583 0 : SetWindowState( pImp->aWinState );
584 0 : pImp->bConstructed = true;
585 : }
586 :
587 0 : FloatingWindow::StateChanged( nStateChange );
588 0 : }
589 :
590 :
591 0 : void SfxFloatingWindow::Initialize(SfxChildWinInfo *pInfo)
592 :
593 : /* [Description]
594 :
595 : Initialization of a class SfxFloatingWindow through a SfxChildWinInfo.
596 : The initialization is done only in a 2nd step after the constructor and
597 : should be called by the constructor of the derived class or from the
598 : SfxChildWindows.
599 : */
600 : {
601 0 : if (pInfo)
602 0 : pImp->aWinState = pInfo->aWinState;
603 0 : }
604 :
605 :
606 :
607 0 : void SfxFloatingWindow::FillInfo(SfxChildWinInfo& rInfo) const
608 :
609 : /* [Description]
610 :
611 : Fills a SfxChildWinInfo with specific data from SfxFloatingWindow,
612 : so that it can be written in the INI file. It is assumed that rinfo
613 : receives all other possible relevant data in the ChildWindow class.
614 : Insertions are marked with size and the ZoomIn flag.
615 : If this method is overridden, the base implementation must be called first.
616 : */
617 :
618 : {
619 0 : rInfo.aSize = aSize;
620 0 : if ( IsRollUp() )
621 0 : rInfo.nFlags |= SfxChildWindowFlags::ZOOMIN;
622 0 : }
623 :
624 : // SfxSingleTabDialog ----------------------------------------------------
625 :
626 0 : IMPL_LINK_NOARG(SfxSingleTabDialog, OKHdl_Impl)
627 :
628 : /* [Description]
629 :
630 : Ok_Handler; FillItemSet() is called for setting of Page.
631 : */
632 :
633 : {
634 0 : if ( !GetInputItemSet() )
635 : {
636 : // TabPage without ItemSet
637 0 : EndDialog( RET_OK );
638 0 : return 1;
639 : }
640 :
641 0 : if ( !GetOutputItemSet() )
642 : {
643 0 : CreateOutputItemSet( *GetInputItemSet() );
644 : }
645 0 : bool bModified = false;
646 :
647 0 : if ( pImpl->m_pSfxPage->HasExchangeSupport() )
648 : {
649 0 : int nRet = pImpl->m_pSfxPage->DeactivatePage( GetOutputSetImpl() );
650 0 : if ( nRet != SfxTabPage::LEAVE_PAGE )
651 0 : return 0;
652 : else
653 0 : bModified = ( GetOutputItemSet()->Count() > 0 );
654 : }
655 : else
656 0 : bModified = pImpl->m_pSfxPage->FillItemSet( GetOutputSetImpl() );
657 :
658 0 : if ( bModified )
659 : {
660 : // Save user data in IniManager.
661 0 : pImpl->m_pSfxPage->FillUserData();
662 0 : OUString sData( pImpl->m_pSfxPage->GetUserData() );
663 :
664 0 : OUString sConfigId = OStringToOUString(pImpl->m_pSfxPage->GetConfigId(),
665 0 : RTL_TEXTENCODING_UTF8);
666 0 : if (sConfigId.isEmpty())
667 : {
668 : SAL_WARN("sfx.config", "Tabpage needs to be converted to .ui format");
669 0 : sConfigId = OUString::number(GetUniqId());
670 : }
671 :
672 0 : SvtViewOptions aPageOpt(E_TABPAGE, sConfigId);
673 0 : aPageOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( sData ) ) );
674 0 : EndDialog( RET_OK );
675 : }
676 : else
677 0 : EndDialog( RET_CANCEL );
678 0 : return 0;
679 : }
680 :
681 :
682 :
683 0 : SfxSingleTabDialog::SfxSingleTabDialog(vcl::Window *pParent, const SfxItemSet& rSet,
684 : const OUString& rID, const OUString& rUIXMLDescription)
685 : : SfxModalDialog(pParent, rID, rUIXMLDescription)
686 : , fnGetRanges(NULL)
687 0 : , pImpl(new SingleTabDlgImpl)
688 : {
689 0 : get(pOKBtn, "ok");
690 0 : pOKBtn->SetClickHdl( LINK( this, SfxSingleTabDialog, OKHdl_Impl ) );
691 0 : get(pCancelBtn, "cancel");
692 0 : get(pHelpBtn, "help");
693 0 : SetInputSet( &rSet );
694 0 : }
695 :
696 0 : SfxSingleTabDialog::SfxSingleTabDialog(vcl::Window* pParent, const SfxItemSet* pInSet,
697 : const OUString& rID, const OUString& rUIXMLDescription)
698 : : SfxModalDialog(pParent, rID, rUIXMLDescription)
699 : , fnGetRanges(NULL)
700 0 : , pImpl(new SingleTabDlgImpl)
701 : {
702 0 : get(pOKBtn, "ok");
703 0 : pOKBtn->SetClickHdl( LINK( this, SfxSingleTabDialog, OKHdl_Impl ) );
704 0 : get(pCancelBtn, "cancel");
705 0 : get(pHelpBtn, "help");
706 0 : SetInputSet( pInSet );
707 0 : }
708 :
709 0 : SfxSingleTabDialog::~SfxSingleTabDialog()
710 : {
711 0 : disposeOnce();
712 0 : }
713 :
714 0 : void SfxSingleTabDialog::dispose()
715 : {
716 0 : pImpl->m_pSfxPage.disposeAndClear();
717 0 : pImpl->m_pLine.disposeAndClear();
718 0 : delete pImpl;
719 0 : pOKBtn.clear();
720 0 : pCancelBtn.clear();
721 0 : pHelpBtn.clear();
722 0 : SfxModalDialog::dispose();
723 0 : }
724 :
725 0 : void SfxSingleTabDialog::SetTabPage(SfxTabPage* pTabPage,
726 : GetTabPageRanges pRangesFunc, sal_uInt32 nSettingsId)
727 : /* [Description]
728 :
729 : Insert a (new) TabPage; an existing page is deleted.
730 : The passed on page is initialized with the initially given Itemset
731 : through calling Reset().
732 : */
733 :
734 : {
735 0 : SetUniqId(nSettingsId);
736 0 : pImpl->m_pSfxPage.disposeAndClear();
737 0 : pImpl->m_pSfxPage = pTabPage;
738 0 : fnGetRanges = pRangesFunc;
739 :
740 0 : if ( pImpl->m_pSfxPage )
741 : {
742 : // First obtain the user data, only then Reset()
743 0 : OUString sConfigId = OStringToOUString(pImpl->m_pSfxPage->GetConfigId(),
744 0 : RTL_TEXTENCODING_UTF8);
745 0 : if (sConfigId.isEmpty())
746 : {
747 : SAL_WARN("sfx.config", "Tabpage needs to be converted to .ui format");
748 0 : sConfigId = OUString::number(GetUniqId());
749 : }
750 :
751 0 : SvtViewOptions aPageOpt(E_TABPAGE, sConfigId);
752 0 : Any aUserItem = aPageOpt.GetUserItem( USERITEM_NAME );
753 0 : OUString sUserData;
754 0 : aUserItem >>= sUserData;
755 0 : pImpl->m_pSfxPage->SetUserData(sUserData);
756 0 : pImpl->m_pSfxPage->Reset( GetInputItemSet() );
757 0 : pImpl->m_pSfxPage->Show();
758 :
759 0 : pHelpBtn->Show(Help::IsContextHelpEnabled());
760 :
761 : // Set TabPage text in the Dialog if there is any
762 0 : OUString sTitle(pImpl->m_pSfxPage->GetText());
763 0 : if (!sTitle.isEmpty())
764 0 : SetText(sTitle);
765 :
766 : // Dialog receives the HelpId of TabPage if there is any
767 0 : OString sHelpId(pImpl->m_pSfxPage->GetHelpId());
768 0 : if (!sHelpId.isEmpty())
769 0 : SetHelpId(sHelpId);
770 0 : OString sUniqueId(pImpl->m_pSfxPage->GetUniqueId());
771 0 : if (!sUniqueId.isEmpty())
772 0 : SetUniqueId(sUniqueId);
773 : }
774 648 : }
775 :
776 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|