LibreOffice Module sfx2 (master) 1
dockwin.cxx
Go to the documentation of this file.
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 <svl/eitem.hxx>
21#include <svl/solar.hrc>
22#include <vcl/event.hxx>
23#include <vcl/settings.hxx>
24
25#include <vcl/svapp.hxx>
26#include <vcl/timer.hxx>
27#include <vcl/idle.hxx>
28#include <o3tl/safeint.hxx>
29#include <o3tl/string_view.hxx>
30#include <osl/diagnose.h>
32#include <tools/debug.hxx>
35
36#include <sfx2/dockwin.hxx>
37#include <sfx2/bindings.hxx>
38#include <sfx2/viewfrm.hxx>
39#include <sfx2/dispatch.hxx>
40#include <workwin.hxx>
41#include <splitwin.hxx>
42#include <sfx2/viewsh.hxx>
43
44#include <com/sun/star/beans/UnknownPropertyException.hpp>
45#include <com/sun/star/lang/XSingleComponentFactory.hpp>
46#include <com/sun/star/awt/XWindow.hpp>
47#include <com/sun/star/uno/XComponentContext.hpp>
48#include <com/sun/star/frame/ModuleManager.hpp>
49#include <com/sun/star/container/XNameAccess.hpp>
50#include <com/sun/star/ui/theWindowStateConfiguration.hpp>
51#include <com/sun/star/ui/theWindowContentFactoryManager.hpp>
52
53#define MAX_TOGGLEAREA_WIDTH 20
54#define MAX_TOGGLEAREA_HEIGHT 20
55
56using namespace ::com::sun::star;
57
58// If you want to change the number you also have to:
59// - Add new slot ids to sfxsids.hrc
60// - Add new slots to frmslots.sdi
61// - Add new slot definitions to sfx.sdi
62const int NUM_OF_DOCKINGWINDOWS = 10;
63
64namespace {
65
66class SfxTitleDockingWindow : public SfxDockingWindow
67{
68 VclPtr<vcl::Window> m_pWrappedWindow;
69
70public:
71 SfxTitleDockingWindow(
72 SfxBindings* pBindings ,
73 SfxChildWindow* pChildWin ,
74 vcl::Window* pParent ,
75 WinBits nBits);
76 virtual ~SfxTitleDockingWindow() override;
77 virtual void dispose() override;
78
79 vcl::Window* GetWrappedWindow() const { return m_pWrappedWindow; }
80 void SetWrappedWindow(vcl::Window* const pWindow);
81
82 virtual void StateChanged( StateChangedType nType ) override;
83 virtual void Resize() override;
84 virtual void Resizing( Size& rSize ) override;
85};
86
87 struct WindowState
88 {
89 OUString sTitle;
90 };
91}
92
93static bool lcl_getWindowState( const uno::Reference< container::XNameAccess >& xWindowStateMgr, const OUString& rResourceURL, WindowState& rWindowState )
94{
95 bool bResult = false;
96
97 try
98 {
99 uno::Any a;
100 uno::Sequence< beans::PropertyValue > aWindowState;
101 a = xWindowStateMgr->getByName( rResourceURL );
102 if ( a >>= aWindowState )
103 {
104 for ( const auto& rProp : std::as_const(aWindowState) )
105 {
106 if ( rProp.Name == "UIName" )
107 {
108 rProp.Value >>= rWindowState.sTitle;
109 }
110 }
111 }
112
113 bResult = true;
114 }
115 catch ( container::NoSuchElementException& )
116 {
117 bResult = false;
118 }
119
120 return bResult;
121}
122
124 sal_uInt16 nId ,
125 SfxBindings* pBindings ,
126 SfxChildWinInfo* pInfo )
127 : SfxChildWindow( pParentWnd , nId )
128{
129 uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
130
131 VclPtr<SfxTitleDockingWindow> pTitleDockWindow = VclPtr<SfxTitleDockingWindow>::Create( pBindings, this, pParentWnd,
133 SetWindow( pTitleDockWindow );
134
135 // Use factory manager to retrieve XWindow factory. That can be used to instantiate
136 // the real window factory.
137 uno::Reference< lang::XSingleComponentFactory > xFactoryMgr = ui::theWindowContentFactoryManager::get(xContext);
138
139 SfxDispatcher* pDispatcher = pBindings->GetDispatcher();
140 uno::Reference< frame::XFrame > xFrame = pDispatcher->GetFrame()->GetFrame().GetFrameInterface();
141 // create a resource URL from the nId provided by the sfx2
142 OUString aResourceURL = "private:resource/dockingwindow/" + OUString::number(nId);
143 uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence(
144 {
145 {"Frame", uno::Any(xFrame)},
146 {"ResourceURL", uno::Any(aResourceURL)},
147 }));
148
149 uno::Reference< awt::XWindow > xWindow;
150 try
151 {
152 xWindow.set(
153 xFactoryMgr->createInstanceWithArgumentsAndContext( aArgs, xContext ),
154 uno::UNO_QUERY );
155
156 static uno::WeakReference< frame::XModuleManager2 > s_xModuleManager;
157
158 uno::Reference< frame::XModuleManager2 > xModuleManager( s_xModuleManager );
159 if ( !xModuleManager.is() )
160 {
161 xModuleManager = frame::ModuleManager::create(xContext);
162 s_xModuleManager = xModuleManager;
163 }
164
165 static uno::WeakReference< container::XNameAccess > s_xWindowStateConfiguration;
166
167 uno::Reference< container::XNameAccess > xWindowStateConfiguration( s_xWindowStateConfiguration );
168 if ( !xWindowStateConfiguration.is() )
169 {
170 xWindowStateConfiguration = ui::theWindowStateConfiguration::get( xContext );
171 s_xWindowStateConfiguration = xWindowStateConfiguration;
172 }
173
174 OUString sModuleIdentifier = xModuleManager->identify( xFrame );
175
176 uno::Reference< container::XNameAccess > xModuleWindowState(
177 xWindowStateConfiguration->getByName( sModuleIdentifier ),
178 uno::UNO_QUERY );
179 if ( xModuleWindowState.is() )
180 {
181 WindowState aDockWinState;
182 if ( lcl_getWindowState( xModuleWindowState, aResourceURL, aDockWinState ))
183 pTitleDockWindow->SetText( aDockWinState.sTitle );
184 }
185 }
186 catch ( beans::UnknownPropertyException& )
187 {
188 }
189 catch ( uno::RuntimeException& )
190 {
191 }
192 catch ( uno::Exception& )
193 {
194 }
195
196 VclPtr<vcl::Window> pContentWindow = VCLUnoHelper::GetWindow(xWindow);
197 if ( pContentWindow )
198 pContentWindow->SetStyle( pContentWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
199 pTitleDockWindow->SetWrappedWindow(pContentWindow);
200
201 GetWindow()->SetOutputSizePixel( Size( 270, 240 ) );
202
203 static_cast<SfxDockingWindow*>( GetWindow() )->Initialize( pInfo );
204 SetHideNotDelete( true );
205}
206
207std::unique_ptr<SfxChildWindow> SfxDockingWrapper::CreateImpl(vcl::Window *pParent, sal_uInt16 nId,
208 SfxBindings *pBindings, SfxChildWinInfo* pInfo)
209{
210 return std::make_unique<SfxDockingWrapper>(pParent, nId, pBindings, pInfo);
211}
212
214{
215 // pre-register a couple of docking windows
216 for (int i=0; i < NUM_OF_DOCKINGWINDOWS; i++ )
217 {
218 sal_uInt16 nID = sal_uInt16(SID_DOCKWIN_START+i);
219 SfxChildWinFactory aFact( SfxDockingWrapper::CreateImpl, nID, 0xffff );
220 aFact.aInfo.nFlags |= nFlags;
221 aFact.aInfo.bVisible = bVis;
223 }
224}
225
227{
229 static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo );
230 return aInfo;
231};
232
233SfxTitleDockingWindow::SfxTitleDockingWindow(SfxBindings* pBind, SfxChildWindow* pChildWin,
234 vcl::Window* pParent, WinBits nBits)
235 : SfxDockingWindow(pBind, pChildWin, pParent, nBits)
236 , m_pWrappedWindow(nullptr)
237{
238}
239
240SfxTitleDockingWindow::~SfxTitleDockingWindow()
241{
242 disposeOnce();
243}
244
245void SfxTitleDockingWindow::dispose()
246{
247 m_pWrappedWindow.disposeAndClear();
249}
250
251void SfxTitleDockingWindow::SetWrappedWindow( vcl::Window* const pWindow )
252{
253 m_pWrappedWindow = pWindow;
254 if (m_pWrappedWindow)
255 {
256 m_pWrappedWindow->SetParent(this);
257 m_pWrappedWindow->SetSizePixel( GetOutputSizePixel() );
258 m_pWrappedWindow->Show();
259 }
260}
261
262void SfxTitleDockingWindow::StateChanged( StateChangedType nType )
263{
264 if ( nType == StateChangedType::InitShow )
265 {
266 vcl::Window* pWindow = GetWrappedWindow();
267 if ( pWindow )
268 {
269 pWindow->SetSizePixel( GetOutputSizePixel() );
270 pWindow->Show();
271 }
272 }
273
275}
276
277void SfxTitleDockingWindow::Resize()
278{
280 if (m_pWrappedWindow)
281 m_pWrappedWindow->SetSizePixel( GetOutputSizePixel() );
282}
283
284void SfxTitleDockingWindow::Resizing( Size &rSize )
285{
287 if (m_pWrappedWindow)
288 m_pWrappedWindow->SetSizePixel( GetOutputSizePixel() );
289}
290
291static bool lcl_checkDockingWindowID( sal_uInt16 nID )
292{
293 return nID >= SID_DOCKWIN_START && nID < o3tl::make_unsigned(SID_DOCKWIN_START+NUM_OF_DOCKINGWINDOWS);
294}
295
296static SfxWorkWindow* lcl_getWorkWindowFromXFrame( const uno::Reference< frame::XFrame >& rFrame )
297{
298 // We need to find the corresponding SfxFrame of our XFrame
299 SfxFrame* pFrame = SfxFrame::GetFirst();
300 SfxFrame* pXFrame = nullptr;
301 while ( pFrame )
302 {
303 uno::Reference< frame::XFrame > xViewShellFrame( pFrame->GetFrameInterface() );
304 if ( xViewShellFrame == rFrame )
305 {
306 pXFrame = pFrame;
307 break;
308 }
309 else
310 pFrame = SfxFrame::GetNext( *pFrame );
311 }
312
313 // If we have a SfxFrame we can retrieve the work window (Sfx layout manager for docking windows)
314 if ( pXFrame )
315 return pXFrame->GetWorkWindow_Impl();
316 else
317 return nullptr;
318}
319
324void SfxDockingWindowFactory( const uno::Reference< frame::XFrame >& rFrame, std::u16string_view rDockingWindowName )
325{
326 SolarMutexGuard aGuard;
327 sal_uInt16 nID = sal_uInt16(o3tl::toInt32(rDockingWindowName));
328
329 // Check the range of the provided ID otherwise nothing will happen
330 if ( !lcl_checkDockingWindowID( nID ))
331 return;
332
333 SfxWorkWindow* pWorkWindow = lcl_getWorkWindowFromXFrame( rFrame );
334 if ( pWorkWindow )
335 {
336 SfxChildWindow* pChildWindow = pWorkWindow->GetChildWindow_Impl(nID);
337 if ( !pChildWindow )
338 {
339 // Register window at the workwindow child window list
340 pWorkWindow->SetChildWindow_Impl( nID, true, false );
341 }
342 }
343}
344
349bool IsDockingWindowVisible( const uno::Reference< frame::XFrame >& rFrame, std::u16string_view rDockingWindowName )
350{
351 SolarMutexGuard aGuard;
352
353 sal_uInt16 nID = sal_uInt16(o3tl::toInt32(rDockingWindowName));
354
355 // Check the range of the provided ID otherwise nothing will happen
356 if ( lcl_checkDockingWindowID( nID ))
357 {
358 SfxWorkWindow* pWorkWindow = lcl_getWorkWindowFromXFrame( rFrame );
359 if ( pWorkWindow )
360 {
361 SfxChildWindow* pChildWindow = pWorkWindow->GetChildWindow_Impl(nID);
362 if ( pChildWindow )
363 return true;
364 }
365 }
366
367 return false;
368}
369
371{
372friend class SfxDockingWindow;
373
380
381 // The following members are only valid in the time from startDocking to
382 // EndDocking:
386 sal_uInt16 nLine;
387 sal_uInt16 nPos;
388 sal_uInt16 nDockLine;
389 sal_uInt16 nDockPos;
392 OUString aWinState;
393
396 { return eLastAlignment; }
398 { eLastAlignment = eAlign; }
400 { return eDockAlignment; }
402 { eDockAlignment = eAlign; }
403};
404
406 :eLastAlignment(SfxChildAlignment::NOALIGNMENT)
407 ,eDockAlignment(SfxChildAlignment::NOALIGNMENT)
408 ,bConstructed(false)
409 ,pSplitWin(nullptr)
410 ,aMoveIdle( "sfx::SfxDockingWindow_Impl aMoveIdle" )
411 ,nHorizontalSize(0)
412 ,nVerticalSize(0)
413 ,nLine(0)
414 ,nPos(0)
415 ,nDockLine(0)
416 ,nDockPos(0)
417 ,bNewLine(false)
418 ,bDockingPrevented(false)
419{
420 aMoveIdle.SetPriority(TaskPriority::RESIZE);
422}
423
424/* [Description]
425
426 This virtual method of the class FloatingWindow keeps track of changes in
427 FloatingSize. If this method is overridden by a derived class,
428 then the FloatingWindow: Resize() must also be called.
429*/
431{
433 Invalidate();
434 if ( !pImpl || !pImpl->bConstructed || !pMgr )
435 return;
436
437 if ( IsFloatingMode() )
438 {
439 // start timer for saving window status information
440 pImpl->aMoveIdle.Start();
441 }
442 else
443 {
444 Size aSize( GetSizePixel() );
445 switch ( pImpl->GetDockAlignment() )
446 {
453 pImpl->nHorizontalSize = aSize.Width();
454 pImpl->aSplitSize = aSize;
455 break;
462 pImpl->nVerticalSize = aSize.Height();
463 pImpl->aSplitSize = aSize;
464 break;
465 default:
466 break;
467 }
468 }
469}
470
471/* [Description]
472
473 This virtual method of the class DockingWindow makes it possible to
474 intervene in the switching of the floating mode.
475 If this method is overridden by a derived class,
476 then the SfxDockingWindow::PrepareToggleFloatingMode() must be called
477 afterwards, if not FALSE is returned.
478*/
480{
481 if (!pImpl || !pImpl->bConstructed)
482 return true;
483
485 return false;
486
487 if ( pImpl->bDockingPrevented )
488 return false;
489
490 if (!IsFloatingMode())
491 {
492 // Test, if FloatingMode is permitted.
494 return false;
495
496 if ( pImpl->pSplitWin )
497 {
498 // The DockingWindow is inside a SplitWindow and will be teared of.
499 pImpl->pSplitWin->RemoveWindow(this/*, sal_False*/);
500 pImpl->pSplitWin = nullptr;
501 }
502 }
503 else if ( pMgr )
504 {
505 pImpl->aWinState = GetFloatingWindow()->GetWindowState();
506
507 // Test if it is allowed to dock,
509 return false;
510
511 // Test, if the Workwindow allows for docking at the moment.
513 if ( !pWorkWin->IsDockingAllowed() || !pWorkWin->IsInternalDockingAllowed() )
514 return false;
515 }
516
517 return true;
518}
519
520/* [Description]
521
522 This virtual method of the DockingWindow class sets the internal data of
523 the SfxDockingWindow and ensures the correct alignment on the parent window.
524 Through PrepareToggleFloatMode and Initialize it is ensured that
525 pImpl-> GetLastAlignment() always delivers an allowed alignment. If this
526 method is overridden by a derived class, then first the
527 SfxDockingWindow::ToggleFloatingMode() must be called.
528*/
530{
531 if ( !pImpl || !pImpl->bConstructed || !pMgr )
532 return; // No Handler call
533
534 // Remember old alignment and then switch.
535 // SV has already switched, but the alignment SfxDockingWindow is still
536 // the old one. What I was before?
537 SfxChildAlignment eLastAlign = GetAlignment();
538
540
541 if (IsFloatingMode())
542 {
544 if ( !pImpl->aWinState.isEmpty() )
545 GetFloatingWindow()->SetWindowState( pImpl->aWinState );
546 else
548 }
549 else
550 {
551 if (pImpl->GetDockAlignment() == eLastAlign)
552 {
553 // If ToggleFloatingMode was called, but the DockAlignment still
554 // is unchanged, then this means that it must have been a toggling
555 // through DClick, so use last alignment
556 SetAlignment (pImpl->GetLastAlignment());
557 }
558 else
559 {
560
561 // Toggling was triggered by dragging
562 pImpl->nLine = pImpl->nDockLine;
563 pImpl->nPos = pImpl->nDockPos;
564 SetAlignment (pImpl->GetDockAlignment());
565 }
566
567 // The DockingWindow is now in a SplitWindow
568 pImpl->pSplitWin = pWorkWin->GetSplitWindow_Impl(GetAlignment());
569
570 // The LastAlignment is still the last docked
571 SfxSplitWindow *pSplit = pWorkWin->GetSplitWindow_Impl(pImpl->GetLastAlignment());
572
573 DBG_ASSERT( pSplit, "LastAlignment is not correct!" );
574 if ( pSplit && pSplit != pImpl->pSplitWin )
575 pSplit->ReleaseWindow_Impl(this);
576 if ( pImpl->GetDockAlignment() == eLastAlign )
577 pImpl->pSplitWin->InsertWindow( this, pImpl->aSplitSize );
578 else
579 pImpl->pSplitWin->InsertWindow( this, pImpl->aSplitSize, pImpl->nLine, pImpl->nPos, pImpl->bNewLine );
580 if ( !pImpl->pSplitWin->IsFadeIn() )
581 pImpl->pSplitWin->FadeIn();
582 }
583
584 // Keep the old alignment for the next toggle; set it only now due to the
585 // unregister SplitWindow!
586 pImpl->SetLastAlignment(eLastAlign);
587
588 // Reset DockAlignment, if EndDocking is still called
589 pImpl->SetDockAlignment(GetAlignment());
590
591 // Dock or undock SfxChildWindow correctly.
593}
594
595/* [Description]
596
597 This virtual method of the DockingWindow class takes the inner and outer
598 docking rectangle from the parent window. If this method is overridden by
599 a derived class, then SfxDockingWindow:StartDocking() has to be called at
600 the end.
601*/
603{
604 if ( !pImpl || !pImpl->bConstructed || !pMgr )
605 return;
608 pImpl->SetDockAlignment(GetAlignment());
609
610 if ( pImpl->pSplitWin )
611 {
612 // Get the current docking data
613 pImpl->pSplitWin->GetWindowPos(this, pImpl->nLine, pImpl->nPos);
614 pImpl->nDockLine = pImpl->nLine;
615 pImpl->nDockPos = pImpl->nPos;
616 pImpl->bNewLine = false;
617 }
618}
619
620/* [Description]
621
622 This virtual method of the DockingWindow class calculates the current
623 tracking rectangle. For this purpose the method CalcAlignment(RPOs, rRect)
624 is used, the behavior can be influenced by the derived classes (see below).
625 This method should if possible not be overwritten.
626*/
628{
630 return true;
631
632 if ( !pImpl || !pImpl->bConstructed || !pMgr )
633 {
634 rRect.SetSize( Size() );
635 return IsFloatingMode();
636 }
637
639 if ( pImpl->bDockingPrevented || !pWorkWin->IsInternalDockingAllowed() )
640 return false;
641
642 bool bFloatMode = false;
643
644 if ( GetOuterRect().Contains( rPos ) )
645 {
646 // Mouse within OuterRect: calculate Alignment and Rectangle
647 SfxChildAlignment eAlign = CalcAlignment(rPos, rRect);
648 if (eAlign == SfxChildAlignment::NOALIGNMENT)
649 bFloatMode = true;
650 pImpl->SetDockAlignment(eAlign);
651 }
652 else
653 {
654 // Mouse is not within OuterRect: must be FloatingWindow
655 // Is this allowed?
657 return false;
658 bFloatMode = true;
659 if ( SfxChildAlignment::NOALIGNMENT != pImpl->GetDockAlignment() )
660 {
661 // Due to a bug the rRect may only be changed when the
662 // alignment is changed!
663 pImpl->SetDockAlignment(SfxChildAlignment::NOALIGNMENT);
665 }
666 }
667
668 return bFloatMode;
669}
670
675void SfxDockingWindow::EndDocking( const tools::Rectangle& rRect, bool bFloatMode )
676{
677 if ( !pImpl || !pImpl->bConstructed || IsDockingCanceled() || !pMgr )
678 return;
679
681
682 // If the alignment changes and the window is in a docked state in a
683 // SplitWindow, then it must be re-registered. If it is docked again,
684 // PrepareToggleFloatingMode() and ToggleFloatingMode() perform the
685 // re-registered
686 bool bReArrange = !bFloatMode;
687
688 if ( bReArrange )
689 {
690 if ( GetAlignment() != pImpl->GetDockAlignment() )
691 {
692 // before Show() is called must the reassignment have been made,
693 // therefore the base class can not be called
694 if ( IsFloatingMode() )
695 Show( false, ShowFlags::NoFocusChange );
696
697 // Set the size for toggling.
698 pImpl->aSplitSize = rRect.GetSize();
699 if ( IsFloatingMode() )
700 {
701 SetFloatingMode( bFloatMode );
702 if ( IsFloatingMode() )
703 Show( true, ShowFlags::NoFocusChange );
704 }
705 else
706 {
707 pImpl->pSplitWin->RemoveWindow(this,false);
708 pImpl->nLine = pImpl->nDockLine;
709 pImpl->nPos = pImpl->nDockPos;
710 pImpl->pSplitWin->ReleaseWindow_Impl(this);
711 pImpl->pSplitWin = pWorkWin->GetSplitWindow_Impl(pImpl->GetDockAlignment());
712 pImpl->pSplitWin->InsertWindow( this, pImpl->aSplitSize, pImpl->nDockLine, pImpl->nDockPos, pImpl->bNewLine );
713 if ( !pImpl->pSplitWin->IsFadeIn() )
714 pImpl->pSplitWin->FadeIn();
715 }
716 }
717 else if ( pImpl->nLine != pImpl->nDockLine || pImpl->nPos != pImpl->nDockPos || pImpl->bNewLine )
718 {
719 // Moved within Splitwindows
720 if ( pImpl->nLine != pImpl->nDockLine )
721 pImpl->aSplitSize = rRect.GetSize();
722 pImpl->pSplitWin->MoveWindow( this, pImpl->aSplitSize, pImpl->nDockLine, pImpl->nDockPos, pImpl->bNewLine );
723 }
724 }
725 else
726 {
727 ResizableDockingWindow::EndDocking(rRect, bFloatMode);
728 }
729
731}
732
733/* [Description]
734
735 Virtual method of the DockingWindow class. Here, the interactive resize in
736 FloatingMode can be influenced, for example by only allowing for discrete
737 values for width and / or height. The base implementation prevents that the
738 output size is smaller than one set with SetMinOutputSizePixel().
739*/
741{
742
743}
744
745/* [Description]
746
747 Constructor for the SfxDockingWindow class. A SfxChildWindow will be
748 required because the docking is implemented in Sfx through SfxChildWindows.
749*/
751 vcl::Window* pParent, WinBits nWinBits)
752 : ResizableDockingWindow(pParent, nWinBits)
753 , pBindings(pBindinx)
754 , pMgr(pCW)
755{
756 pImpl.reset(new SfxDockingWindow_Impl(this));
757}
758
763 vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription)
764 : ResizableDockingWindow(pParent)
765 , pBindings(pBindinx)
766 , pMgr(pCW)
767{
768 m_xBuilder = Application::CreateInterimBuilder(m_xBox, rUIXMLDescription, true);
769 m_xContainer = m_xBuilder->weld_box(rID);
770
771 pImpl.reset(new SfxDockingWindow_Impl(this));
772}
773
780{
781 if ( !pMgr )
782 {
783 pImpl->SetDockAlignment( SfxChildAlignment::NOALIGNMENT );
784 pImpl->bConstructed = true;
785 return;
786 }
787
788 if (pInfo && (pInfo->nFlags & SfxChildWindowFlags::FORCEDOCK))
789 pImpl->bDockingPrevented = true;
790
791 pImpl->aSplitSize = GetOutputSizePixel();
792 if ( !GetFloatingSize().Width() )
793 {
794 Size aMinSize( GetMinOutputSizePixel() );
795 SetFloatingSize( pImpl->aSplitSize );
796 if ( pImpl->aSplitSize.Width() < aMinSize.Width() )
797 pImpl->aSplitSize.setWidth( aMinSize.Width() );
798 if ( pImpl->aSplitSize.Height() < aMinSize.Height() )
799 pImpl->aSplitSize.setHeight( aMinSize.Height() );
800 }
801
802 bool bVertHorzRead( false );
803 if (pInfo && !pInfo->aExtraString.isEmpty())
804 {
805 // get information about alignment, split size and position in SplitWindow
806 OUString aStr;
807 sal_Int32 nPos = pInfo->aExtraString.indexOf("AL:");
808 if ( nPos != -1 )
809 {
810 // alignment information
811 sal_Int32 n1 = pInfo->aExtraString.indexOf('(', nPos);
812 if ( n1 != -1 )
813 {
814 sal_Int32 n2 = pInfo->aExtraString.indexOf(')', n1);
815 if ( n2 != -1 )
816 {
817 // extract alignment information from extrastring
818 aStr = pInfo->aExtraString.copy(nPos, n2 - nPos + 1);
819 pInfo->aExtraString = pInfo->aExtraString.replaceAt(nPos, n2 - nPos + 1, u"");
820 aStr = aStr.replaceAt(nPos, n1-nPos+1, u"");
821 }
822 }
823 }
824
825 if ( !aStr.isEmpty() )
826 {
827 // accept window state only if alignment is also set
828 pImpl->aWinState = pInfo->aWinState;
829
830 // check for valid alignment
831 SfxChildAlignment eLocalAlignment = static_cast<SfxChildAlignment>(static_cast<sal_uInt16>(aStr.toInt32()));
832 bool bIgnoreFloatConfig = (eLocalAlignment == SfxChildAlignment::NOALIGNMENT &&
834 if (pImpl->bDockingPrevented || bIgnoreFloatConfig)
835 // docking prevented, ignore old configuration and take alignment from default
836 aStr.clear();
837 else
838 SetAlignment( eLocalAlignment );
839
841 if ( eAlign != GetAlignment() )
842 {
843 OSL_FAIL("Invalid Alignment!");
844 SetAlignment( eAlign );
845 aStr.clear();
846 }
847
848 // get last alignment (for toggling)
849 nPos = aStr.indexOf(',');
850 if ( nPos != -1 )
851 {
852 aStr = aStr.copy(nPos+1);
853 pImpl->SetLastAlignment( static_cast<SfxChildAlignment>(static_cast<sal_uInt16>(aStr.toInt32())) );
854 }
855
856 nPos = aStr.indexOf(',');
857 if ( nPos != -1 )
858 {
859 // get split size and position in SplitWindow
860 Point aPos;
861 aStr = aStr.copy(nPos+1);
862 if ( GetPosSizeFromString( aStr, aPos, pImpl->aSplitSize ) )
863 {
864 pImpl->nLine = pImpl->nDockLine = static_cast<sal_uInt16>(aPos.X());
865 pImpl->nPos = pImpl->nDockPos = static_cast<sal_uInt16>(aPos.Y());
866 pImpl->nVerticalSize = pImpl->aSplitSize.Height();
867 pImpl->nHorizontalSize = pImpl->aSplitSize.Width();
868 if ( GetSplitSizeFromString( aStr, pImpl->aSplitSize ))
869 bVertHorzRead = true;
870 }
871 }
872 }
873 else {
874 OSL_FAIL( "Information is missing!" );
875 }
876 }
877
878 if ( !bVertHorzRead )
879 {
880 pImpl->nVerticalSize = pImpl->aSplitSize.Height();
881 pImpl->nHorizontalSize = pImpl->aSplitSize.Width();
882 }
883
886 {
887 // check if SfxWorkWindow is able to allow docking at its border
888 if (
889 !pWorkWin->IsDockingAllowed() ||
890 !pWorkWin->IsInternalDockingAllowed() ||
892 {
894 }
895 }
896
897 // detect floating mode
898 // toggling mode will not execute code in handlers, because pImpl->bConstructed is not set yet
899 bool bFloatMode = IsFloatingMode();
900 if ( bFloatMode != (GetAlignment() == SfxChildAlignment::NOALIGNMENT) )
901 {
902 bFloatMode = !bFloatMode;
903 SetFloatingMode( bFloatMode );
904 if ( bFloatMode )
905 {
906 if ( !pImpl->aWinState.isEmpty() )
907 GetFloatingWindow()->SetWindowState( pImpl->aWinState );
908 else
910 }
911 }
912
913 if ( IsFloatingMode() )
914 {
915 // validate last alignment
916 SfxChildAlignment eLastAlign = pImpl->GetLastAlignment();
917 if ( eLastAlign == SfxChildAlignment::NOALIGNMENT)
918 eLastAlign = CheckAlignment(eLastAlign, SfxChildAlignment::LEFT);
919 if ( eLastAlign == SfxChildAlignment::NOALIGNMENT)
920 eLastAlign = CheckAlignment(eLastAlign, SfxChildAlignment::RIGHT);
921 if ( eLastAlign == SfxChildAlignment::NOALIGNMENT)
922 eLastAlign = CheckAlignment(eLastAlign, SfxChildAlignment::TOP);
923 if ( eLastAlign == SfxChildAlignment::NOALIGNMENT)
924 eLastAlign = CheckAlignment(eLastAlign, SfxChildAlignment::BOTTOM);
925 pImpl->SetLastAlignment(eLastAlign);
926 }
927 else
928 {
929 // docked window must have NOALIGNMENT as last alignment
930 pImpl->SetLastAlignment(SfxChildAlignment::NOALIGNMENT);
931
932 pImpl->pSplitWin = pWorkWin->GetSplitWindow_Impl(GetAlignment());
933 pImpl->pSplitWin->InsertWindow(this, pImpl->aSplitSize);
934 }
935
936 // save alignment
937 pImpl->SetDockAlignment( GetAlignment() );
938}
939
941{
942 if ( !pMgr )
943 {
944 pImpl->bConstructed = true;
945 return;
946 }
947
948 SystemWindow* pFloatWin = GetFloatingWindow();
949 bool bSet = false;
950 if ( pFloatWin )
951 {
952 bSet = !pFloatWin->IsDefaultPos();
953 }
954 else
955 {
956 Point aPos = GetFloatingPos();
957 if ( aPos != Point() )
958 bSet = true;
959 }
960
961 if ( !bSet)
962 {
964 vcl::Window* pEditWin = pFrame->GetViewShell()->GetWindow();
965 Point aPos = pEditWin->OutputToScreenPixel( pEditWin->GetPosPixel() );
966 aPos = GetParent()->ScreenToOutputPixel( aPos );
967 SetFloatingPos( aPos );
968 }
969
970 if ( pFloatWin )
971 {
972 // initialize floating window
973 if ( pImpl->aWinState.isEmpty() )
974 // window state never set before, get if from defaults
975 pImpl->aWinState = pFloatWin->GetWindowState();
976
977 // trick: use VCL method SetWindowState to adjust position and size
978 pFloatWin->SetWindowState( pImpl->aWinState );
979 Size aSize(pFloatWin->GetSizePixel());
980
981 // remember floating size for calculating alignment and tracking rectangle
982 SetFloatingSize(aSize);
983
984 }
985
986 // allow calling of docking handlers
987 pImpl->bConstructed = true;
988}
989
997{
998 if (!pMgr || !pImpl)
999 return;
1000
1001 if (GetFloatingWindow() && pImpl->bConstructed)
1002 pImpl->aWinState = GetFloatingWindow()->GetWindowState();
1003
1004 rInfo.aWinState = pImpl->aWinState;
1005 rInfo.aExtraString = "AL:(";
1006 rInfo.aExtraString += OUString::number(static_cast<sal_uInt16>(GetAlignment()));
1007 rInfo.aExtraString += ",";
1008 rInfo.aExtraString += OUString::number (static_cast<sal_uInt16>(pImpl->GetLastAlignment()));
1009
1010 Point aPos(pImpl->nLine, pImpl->nPos);
1011 rInfo.aExtraString += ",";
1012 rInfo.aExtraString += OUString::number( aPos.X() );
1013 rInfo.aExtraString += "/";
1014 rInfo.aExtraString += OUString::number( aPos.Y() );
1015 rInfo.aExtraString += "/";
1016 rInfo.aExtraString += OUString::number( pImpl->nHorizontalSize );
1017 rInfo.aExtraString += "/";
1018 rInfo.aExtraString += OUString::number( pImpl->nVerticalSize );
1019 rInfo.aExtraString += ",";
1020 rInfo.aExtraString += OUString::number( pImpl->aSplitSize.Width() );
1021 rInfo.aExtraString += ";";
1022 rInfo.aExtraString += OUString::number( pImpl->aSplitSize.Height() );
1023
1024 rInfo.aExtraString += ")";
1025}
1026
1028{
1029 disposeOnce();
1030}
1031
1033{
1035 pImpl.reset();
1036 m_xContainer.reset();
1037 m_xBuilder.reset();
1039}
1040
1042{
1043 if ( pMgr && pMgr->GetFrame() == pBindings->GetActiveFrame() )
1044 pBindings->SetActiveFrame( nullptr );
1045
1046 if ( pMgr && pImpl->pSplitWin && pImpl->pSplitWin->IsItemValid( GetType() ) )
1047 pImpl->pSplitWin->RemoveWindow(this);
1048
1049 pMgr=nullptr;
1050}
1051
1064{
1065 // calculate hypothetical sizes for different modes
1067
1068 // check if docking is permitted
1070 if ( !pWorkWin->IsDockingAllowed() )
1071 {
1072 rRect.SetSize( aFloatingSize );
1073 return pImpl->GetDockAlignment();
1074 }
1075
1076 // calculate borders to shrink inner area before checking for intersection with tracking rectangle
1077 tools::Long nLRBorder, nTBBorder;
1078
1079 // take the smaller size of docked and floating mode
1080 Size aBorderTmp = pImpl->aSplitSize;
1081 if ( GetFloatingSize().Height() < aBorderTmp.Height() )
1082 aBorderTmp.setHeight( GetFloatingSize().Height() );
1083 if ( GetFloatingSize().Width() < aBorderTmp.Width() )
1084 aBorderTmp.setWidth( GetFloatingSize().Width() );
1085
1086 nLRBorder = aBorderTmp.Width();
1087 nTBBorder = aBorderTmp.Height();
1088
1089 // limit border to predefined constant values
1090 if ( nLRBorder > MAX_TOGGLEAREA_WIDTH )
1091 nLRBorder = MAX_TOGGLEAREA_WIDTH;
1092 if ( nTBBorder > MAX_TOGGLEAREA_WIDTH )
1093 nTBBorder = MAX_TOGGLEAREA_WIDTH;
1094
1095 // shrink area for floating mode if possible
1096 tools::Rectangle aInRect = GetInnerRect();
1097 if ( aInRect.GetWidth() > nLRBorder )
1098 aInRect.AdjustLeft(nLRBorder/2 );
1099 if ( aInRect.GetWidth() > nLRBorder )
1100 aInRect.AdjustRight( -(nLRBorder/2) );
1101 if ( aInRect.GetHeight() > nTBBorder )
1102 aInRect.AdjustTop(nTBBorder/2 );
1103 if ( aInRect.GetHeight() > nTBBorder )
1104 aInRect.AdjustBottom( -(nTBBorder/2) );
1105
1106 // calculate alignment resulting from docking rectangle
1107 bool bBecomesFloating = false;
1108 SfxChildAlignment eDockAlign = pImpl->GetDockAlignment();
1109 tools::Rectangle aDockingRect( rRect );
1110 if ( !IsFloatingMode() )
1111 {
1112 // don't use tracking rectangle for alignment check, because it will be too large
1113 // to get a floating mode as result - switch to floating size
1114 // so the calculation only depends on the position of the rectangle, not the current
1115 // docking state of the window
1116 aDockingRect.SetSize( GetFloatingSize() );
1117
1118 // in this mode docking is never done by keyboard, so it's OK to use the mouse position
1119 aDockingRect.SetPos( pWorkWin->GetWindow()->OutputToScreenPixel( pWorkWin->GetWindow()->GetPointerPosPixel() ) );
1120 }
1121
1122 Point aPos = aDockingRect.TopLeft();
1123 tools::Rectangle aIntersect = GetOuterRect().GetIntersection( aDockingRect );
1124 if ( aIntersect.IsEmpty() )
1125 // docking rectangle completely outside docking area -> floating mode
1126 bBecomesFloating = true;
1127 else
1128 {
1129 // create a small test rect around the mouse position and use this one
1130 // instead of the passed rRect to not dock too easily or by accident
1131 tools::Rectangle aSmallDockingRect;
1132 aSmallDockingRect.SetSize( Size( MAX_TOGGLEAREA_WIDTH, MAX_TOGGLEAREA_HEIGHT ) );
1133 Point aNewPos(rPos);
1134 aNewPos.AdjustX( -(aSmallDockingRect.GetWidth()/2) );
1135 aNewPos.AdjustY( -(aSmallDockingRect.GetHeight()/2) );
1136 aSmallDockingRect.SetPos(aNewPos);
1137 tools::Rectangle aIntersectRect = aInRect.GetIntersection( aSmallDockingRect );
1138 if ( aIntersectRect == aSmallDockingRect )
1139 // docking rectangle completely inside (shrunk) inner area -> floating mode
1140 bBecomesFloating = true;
1141 }
1142
1143 if ( bBecomesFloating )
1144 {
1145 eDockAlign = CheckAlignment(pImpl->GetDockAlignment(),SfxChildAlignment::NOALIGNMENT);
1146 }
1147 else
1148 {
1149 // docking rectangle is in the "sensible area"
1150 Point aInPosTL( aPos.X()-aInRect.Left(), aPos.Y()-aInRect.Top() );
1151 Point aInPosBR( aPos.X()-aInRect.Left() + aDockingRect.GetWidth(), aPos.Y()-aInRect.Top() + aDockingRect.GetHeight() );
1152 Size aInSize = aInRect.GetSize();
1153 bool bNoChange = false;
1154
1155 // check if alignment is still unchanged
1156 switch ( GetAlignment() )
1157 {
1161 if (aInPosTL.X() <= 0)
1162 {
1163 eDockAlign = GetAlignment();
1164 bNoChange = true;
1165 }
1166 break;
1170 if ( aInPosTL.Y() <= 0)
1171 {
1172 eDockAlign = GetAlignment();
1173 bNoChange = true;
1174 }
1175 break;
1179 if ( aInPosBR.X() >= aInSize.Width())
1180 {
1181 eDockAlign = GetAlignment();
1182 bNoChange = true;
1183 }
1184 break;
1188 if ( aInPosBR.Y() >= aInSize.Height())
1189 {
1190 eDockAlign = GetAlignment();
1191 bNoChange = true;
1192 }
1193 break;
1194 default:
1195 break;
1196 }
1197
1198 if ( !bNoChange )
1199 {
1200 // alignment will change, test alignment according to distance of the docking rectangles edges
1201 bool bForbidden = true;
1202 if ( aInPosTL.X() <= 0)
1203 {
1204 eDockAlign = CheckAlignment(pImpl->GetDockAlignment(),SfxChildAlignment::LEFT);
1205 bForbidden = ( eDockAlign != SfxChildAlignment::LEFT &&
1206 eDockAlign != SfxChildAlignment::FIRSTLEFT &&
1207 eDockAlign != SfxChildAlignment::LASTLEFT );
1208 }
1209
1210 if ( bForbidden && aInPosTL.Y() <= 0)
1211 {
1212 eDockAlign = CheckAlignment(pImpl->GetDockAlignment(),SfxChildAlignment::TOP);
1213 bForbidden = ( eDockAlign != SfxChildAlignment::TOP &&
1214 eDockAlign != SfxChildAlignment::HIGHESTTOP &&
1215 eDockAlign != SfxChildAlignment::LOWESTTOP );
1216 }
1217
1218 if ( bForbidden && aInPosBR.X() >= aInSize.Width())
1219 {
1220 eDockAlign = CheckAlignment(pImpl->GetDockAlignment(),SfxChildAlignment::RIGHT);
1221 bForbidden = ( eDockAlign != SfxChildAlignment::RIGHT &&
1222 eDockAlign != SfxChildAlignment::FIRSTRIGHT &&
1223 eDockAlign != SfxChildAlignment::LASTRIGHT );
1224 }
1225
1226 if ( bForbidden && aInPosBR.Y() >= aInSize.Height())
1227 {
1228 eDockAlign = CheckAlignment(pImpl->GetDockAlignment(),SfxChildAlignment::BOTTOM);
1229 bForbidden = ( eDockAlign != SfxChildAlignment::BOTTOM &&
1230 eDockAlign != SfxChildAlignment::HIGHESTBOTTOM &&
1231 eDockAlign != SfxChildAlignment::LOWESTBOTTOM );
1232 }
1233
1234 // the calculated alignment was rejected by the window -> take floating mode
1235 if ( bForbidden )
1236 eDockAlign = CheckAlignment(pImpl->GetDockAlignment(),SfxChildAlignment::NOALIGNMENT);
1237 }
1238 }
1239
1240 if ( eDockAlign == SfxChildAlignment::NOALIGNMENT )
1241 {
1242 // In the FloatingMode the tracking rectangle will get the floating
1243 // size. Due to a bug the rRect may only be changed when the
1244 // alignment is changed!
1245 if ( eDockAlign != pImpl->GetDockAlignment() )
1246 aDockingRect.SetSize( aFloatingSize );
1247 }
1248 else
1249 {
1250 sal_uInt16 nLine, nPos;
1251 SfxSplitWindow *pSplitWin = pWorkWin->GetSplitWindow_Impl(eDockAlign);
1252 aPos = pSplitWin->ScreenToOutputPixel( aPos );
1253 if ( pSplitWin->GetWindowPos( aPos, nLine, nPos ) )
1254 {
1255 // mouse over splitwindow, get line and position
1256 pImpl->nDockLine = nLine;
1257 pImpl->nDockPos = nPos;
1258 pImpl->bNewLine = false;
1259 }
1260 else
1261 {
1262 // mouse touches inner border -> create new line
1263 if ( eDockAlign == GetAlignment() && pImpl->pSplitWin &&
1264 pImpl->nLine == pImpl->pSplitWin->GetLineCount()-1 && pImpl->pSplitWin->GetWindowCount(pImpl->nLine) == 1 )
1265 {
1266 // if this window is the only one in the last line, it can't be docked as new line in the same splitwindow
1267 pImpl->nDockLine = pImpl->nLine;
1268 pImpl->nDockPos = pImpl->nPos;
1269 pImpl->bNewLine = false;
1270 }
1271 else
1272 {
1273 // create new line
1274 pImpl->nDockLine = pSplitWin->GetLineCount();
1275 pImpl->nDockPos = 0;
1276 pImpl->bNewLine = true;
1277 }
1278 }
1279
1280 bool bChanged = pImpl->nLine != pImpl->nDockLine || pImpl->nPos != pImpl->nDockPos || eDockAlign != GetAlignment();
1281 if ( !bChanged && !IsFloatingMode() )
1282 {
1283 // window only slightly moved, no change of any property
1284 rRect.SetSize( pImpl->aSplitSize );
1285 rRect.SetPos( aDockingRect.TopLeft() );
1286 return eDockAlign;
1287 }
1288
1289 // calculate new size and position
1290 Size aSize;
1291 Point aPoint = aDockingRect.TopLeft();
1292 Size aInnerSize = GetInnerRect().GetSize();
1293 if ( eDockAlign == SfxChildAlignment::LEFT || eDockAlign == SfxChildAlignment::RIGHT )
1294 {
1295 if ( pImpl->bNewLine )
1296 {
1297 // set height to height of free area
1298 aSize.setHeight( aInnerSize.Height() );
1299 aSize.setWidth( pImpl->nHorizontalSize );
1300 if ( eDockAlign == SfxChildAlignment::LEFT )
1301 {
1302 aPoint = aInnerRect.TopLeft();
1303 }
1304 else
1305 {
1306 aPoint = aInnerRect.TopRight();
1307 aPoint.AdjustX( -(aSize.Width()) );
1308 }
1309 }
1310 else
1311 {
1312 // get width from splitwindow
1313 aSize.setWidth( pSplitWin->GetLineSize(nLine) );
1314 aSize.setHeight( pImpl->aSplitSize.Height() );
1315 }
1316 }
1317 else
1318 {
1319 if ( pImpl->bNewLine )
1320 {
1321 // set width to width of free area
1322 aSize.setWidth( aInnerSize.Width() );
1323 aSize.setHeight( pImpl->nVerticalSize );
1324 if ( eDockAlign == SfxChildAlignment::TOP )
1325 {
1326 aPoint = aInnerRect.TopLeft();
1327 }
1328 else
1329 {
1330 aPoint = aInnerRect.BottomLeft();
1331 aPoint.AdjustY( -(aSize.Height()) );
1332 }
1333 }
1334 else
1335 {
1336 // get height from splitwindow
1337 aSize.setHeight( pSplitWin->GetLineSize(nLine) );
1338 aSize.setWidth( pImpl->aSplitSize.Width() );
1339 }
1340 }
1341
1342 aDockingRect.SetSize( aSize );
1343 aDockingRect.SetPos( aPoint );
1344 }
1345
1346 rRect = aDockingRect;
1347 return eDockAlign;
1348}
1349
1361{
1362 // Note: if the resizing is also possible in the docked state, then the
1363 // Floating-size does also have to be adjusted?
1364
1365 Size aSize = GetFloatingSize();
1366 switch (eAlign)
1367 {
1374 aSize.setWidth( aOuterRect.Right() - aOuterRect.Left() );
1375 break;
1382 aSize.setHeight( aInnerRect.Bottom() - aInnerRect.Top() );
1383 break;
1385 break;
1386 default:
1387 break;
1388 }
1389
1390 return aSize;
1391}
1392
1398 SfxChildAlignment eAlign)
1399{
1400 return eAlign;
1401}
1402
1409{
1410 // Execute with Parameters, since Toggle is ignored by some ChildWindows.
1411 if ( !pMgr )
1412 return true;
1413
1414 SfxBoolItem aValue( pMgr->GetType(), false);
1417 { &aValue });
1418 return true;
1419}
1420
1422{
1423}
1424
1429{
1430 pImpl->aMinSize = rSize;
1432}
1433
1436{
1437 return pImpl->aMinSize;
1438}
1439
1441{
1442 if ( !pImpl )
1444
1445 if ( rEvt.GetType() == NotifyEventType::GETFOCUS )
1446 {
1447 if (pMgr != nullptr)
1449
1450 if ( pImpl->pSplitWin )
1451 pImpl->pSplitWin->SetActiveWindow_Impl( this );
1452 else if (pMgr != nullptr)
1454
1455 // In VCL EventNotify goes first to the window itself, also call the
1456 // base class, otherwise the parent learns nothing
1457 // if ( rEvt.GetWindow() == this ) PB: #i74693# not necessary any longer
1459 // tdf#151112 move focus into container widget hierarchy if not already there
1460 if (m_xContainer && !m_xContainer->has_child_focus())
1461 m_xContainer->child_grab_focus();
1462 return true;
1463 }
1464 else if( rEvt.GetType() == NotifyEventType::KEYINPUT )
1465 {
1466 // First, allow KeyInput for Dialog functions
1468 {
1469 // then also for valid global accelerators.
1471 }
1472 return true;
1473 }
1474 else if ( rEvt.GetType() == NotifyEventType::LOSEFOCUS && !HasChildPathFocus() )
1475 {
1476 pBindings->SetActiveFrame( nullptr );
1477 }
1478
1480}
1481
1483{
1484 pImpl->aSplitSize = rSize;
1485
1488}
1489
1491{
1492 if ( pImpl->pSplitWin && pImpl->pSplitWin->IsItemValid( GetType() ) )
1493 pImpl->pSplitWin->RemoveWindow(this);
1494}
1495
1497{
1498 if ( pImpl->pSplitWin && !pImpl->pSplitWin->IsItemValid( GetType() ) )
1499 {
1500 pImpl->pSplitWin->InsertWindow( this, pImpl->aSplitSize );
1501 }
1502}
1503
1505{
1506 if ( pImpl->pSplitWin )
1507 return !pImpl->pSplitWin->IsFadeIn();
1508 else
1509 return false;
1510}
1511
1513{
1514 if ( pImpl->pSplitWin )
1515 {
1516 pImpl->pSplitWin->FadeIn();
1517 }
1518}
1519
1521{
1522 if ( nStateChange == StateChangedType::InitShow )
1524
1526}
1527
1529{
1530 if ( pImpl )
1531 pImpl->aMoveIdle.Start();
1532}
1533
1535{
1536 pImpl->aMoveIdle.Stop();
1537 if ( IsReallyVisible() && IsFloatingMode() )
1538 {
1540 pImpl->aWinState = GetFloatingWindow()->GetWindowState();
1543 }
1544}
1545
1546/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxChildAlignment
Definition: chalign.hxx:27
bool GetSplitSizeFromString(std::u16string_view rStr, Size &rSize)
Definition: childwin.cxx:124
bool GetPosSizeFromString(std::u16string_view rStr, Point &rPos, Size &rSize)
Definition: childwin.cxx:109
SfxChildWindowFlags
Definition: childwin.hxx:42
static bool IsInModalMode()
static std::unique_ptr< weld::Builder > CreateInterimBuilder(vcl::Window *pParent, const OUString &rUIFile, bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId=0)
Point GetFloatingPos() const
void SetMinOutputSizePixel(const Size &rSize)
bool IsFloatingMode() const
void SetFloatingMode(bool bFloatMode)
virtual void StateChanged(StateChangedType nType) override
Size GetSizePixel() const override
virtual bool EventNotify(NotifyEvent &rNEvt) override
Size GetOutputSizePixel() const
virtual void EndDocking(const tools::Rectangle &rRect, bool bFloatMode)
SystemWindow * GetFloatingWindow() const
void SetFloatingPos(const Point &rNewPos)
WinBits GetFloatStyle() const
bool IsDockingCanceled() const
const KeyEvent * GetKeyEvent() const
NotifyEventType GetType() const
constexpr tools::Long Y() const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
VclPtr< vcl::Window > m_xBox
virtual void dispose() override
SAL_DLLPRIVATE SfxWorkWindow * GetWorkWindow_Impl() const
Definition: bindings.cxx:1683
SAL_DLLPRIVATE SfxDispatcher * GetDispatcher_Impl()
Definition: bindings.hxx:180
SfxDispatcher * GetDispatcher() const
Definition: bindings.hxx:172
css::uno::Reference< css::frame::XFrame > GetActiveFrame() const
Definition: bindings.cxx:1712
void SetActiveFrame(const css::uno::Reference< css::frame::XFrame > &rFrame)
Definition: bindings.cxx:1703
const css::uno::Reference< css::frame::XFrame > & GetFrame() const
Definition: childwin.cxx:590
sal_uInt16 GetType() const
Definition: childwin.hxx:131
static void RegisterChildWindow(SfxModule *, const SfxChildWinFactory &)
Definition: childwin.cxx:618
vcl::Window * GetWindow() const
Definition: childwin.hxx:117
VclPtr< vcl::Window > pParent
Definition: childwin.hxx:101
virtual SfxChildWinInfo GetInfo() const
Definition: childwin.cxx:304
void SetWindow(const VclPtr< vcl::Window > &p)
Definition: childwin.hxx:111
void SetHideNotDelete(bool bOn)
Definition: childwin.cxx:431
SAL_DLLPRIVATE void Activate_Impl()
Definition: childwin.cxx:559
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
Method to execute a <SfxSlot>s over the Slot-Id.
Definition: dispatch.cxx:931
SfxViewFrame * GetFrame() const
Returns a pointer to the <SfxViewFrame> instance, which belongs to this SfxDispatcher.
Definition: dispatch.cxx:557
tools::Long nVerticalSize
Definition: dockwin.cxx:385
SfxChildAlignment eDockAlignment
Definition: dockwin.cxx:375
sal_uInt16 nDockLine
Definition: dockwin.cxx:388
SfxChildAlignment GetLastAlignment() const
Definition: dockwin.cxx:395
SfxDockingWindow_Impl(SfxDockingWindow *pBase)
Definition: dockwin.cxx:405
sal_uInt16 nDockPos
Definition: dockwin.cxx:389
void SetLastAlignment(SfxChildAlignment eAlign)
Definition: dockwin.cxx:397
SfxChildAlignment GetDockAlignment() const
Definition: dockwin.cxx:399
void SetDockAlignment(SfxChildAlignment eAlign)
Definition: dockwin.cxx:401
VclPtr< SfxSplitWindow > pSplitWin
Definition: dockwin.cxx:378
tools::Long nHorizontalSize
Definition: dockwin.cxx:384
SfxChildAlignment eLastAlignment
Definition: dockwin.cxx:374
std::unique_ptr< weld::Box > m_xContainer
Definition: dockwin.hxx:44
SAL_DLLPRIVATE void AutoShow_Impl()
Definition: dockwin.cxx:1512
SfxDockingWindow(SfxDockingWindow const &)=delete
SAL_DLLPRIVATE bool IsAutoHide_Impl() const
Definition: dockwin.cxx:1504
const Size & GetMinOutputSizePixel() const
Set the minimum size which is returned.
Definition: dockwin.cxx:1435
void Initialize(SfxChildWinInfo *pInfo)
Initialization of the SfxDockingDialog class via a SfxChildWinInfo.
Definition: dockwin.cxx:779
virtual void Resize() override
Definition: dockwin.cxx:430
SAL_DLLPRIVATE void ReleaseChildWindow_Impl()
Definition: dockwin.cxx:1041
tools::Rectangle aInnerRect
Definition: dockwin.hxx:47
SAL_DLLPRIVATE void Reappear_Impl()
Definition: dockwin.cxx:1496
virtual void FillInfo(SfxChildWinInfo &) const
Fills a SfxChildWinInfo with specific data from SfxDockingWindow, so that it can be written in the IN...
Definition: dockwin.cxx:996
virtual bool Docking(const Point &rPos, tools::Rectangle &rRect) override
Definition: dockwin.cxx:627
tools::Rectangle aOuterRect
Definition: dockwin.hxx:48
std::unique_ptr< weld::Builder > m_xBuilder
Definition: dockwin.hxx:43
SfxBindings * pBindings
Definition: dockwin.hxx:49
const tools::Rectangle & GetOuterRect() const
Definition: dockwin.hxx:95
SfxChildAlignment GetAlignment() const
Definition: dockwin.hxx:98
virtual void Move() override
Definition: dockwin.cxx:1528
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: dockwin.cxx:1440
void SetAlignment(SfxChildAlignment eAlign)
Definition: dockwin.hxx:99
virtual void StartDocking() override
Definition: dockwin.cxx:602
virtual bool Close() override
The window is closed when the ChildWindow is destroyed by running the ChildWindow-slots.
Definition: dockwin.cxx:1408
void SetFloatingSize(const Size &rSize)
Definition: dockwin.hxx:101
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: dockwin.cxx:1421
virtual void Resizing(Size &rSize) override
Definition: dockwin.cxx:740
virtual void StateChanged(StateChangedType nStateChange) override
Definition: dockwin.cxx:1520
SfxChildAlignment CalcAlignment(const Point &rPos, tools::Rectangle &rRect)
This method calculates a resulting alignment for the given mouse position and tracking rectangle.
Definition: dockwin.cxx:1063
const Size & GetFloatingSize() const
Definition: dockwin.hxx:100
virtual Size CalcDockingSize(SfxChildAlignment)
Virtual method of the SfxDockingWindow class.
Definition: dockwin.cxx:1360
virtual SfxChildAlignment CheckAlignment(SfxChildAlignment, SfxChildAlignment)
Virtual method of the SfxDockingWindow class.
Definition: dockwin.cxx:1397
virtual ~SfxDockingWindow() override
Definition: dockwin.cxx:1027
SAL_DLLPRIVATE void Initialize_Impl()
Definition: dockwin.cxx:940
virtual bool PrepareToggleFloatingMode() override
Definition: dockwin.cxx:479
virtual void ToggleFloatingMode() override
Definition: dockwin.cxx:529
SAL_DLLPRIVATE void SetItemSize_Impl(const Size &rSize)
Definition: dockwin.cxx:1482
virtual void dispose() override
Definition: dockwin.cxx:1032
std::unique_ptr< SfxDockingWindow_Impl > pImpl
Definition: dockwin.hxx:52
sal_uInt16 GetType() const
Definition: dockwin.hxx:97
const tools::Rectangle & GetInnerRect() const
Definition: dockwin.hxx:94
SAL_DLLPRIVATE void Disappear_Impl()
Definition: dockwin.cxx:1490
SfxChildWindow * pMgr
Definition: dockwin.hxx:51
virtual void EndDocking(const tools::Rectangle &rRect, bool bFloatMode) override
Virtual method of the DockingWindow class ensures the correct alignment on the parent window.
Definition: dockwin.cxx:675
void SetMinOutputSizePixel(const Size &rSize)
With this method, a minimal OutputSize be can set, that is queried in the Resizing()-Handler.
Definition: dockwin.cxx:1428
SfxDockingWrapper(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo)
Definition: dockwin.cxx:123
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
Definition: frame.cxx:515
SAL_DLLPRIVATE SfxWorkWindow * GetWorkWindow_Impl() const
Definition: frame.cxx:588
static SAL_WARN_UNUSED_RESULT SfxFrame * GetNext(SfxFrame &)
Definition: frame.cxx:711
static SAL_WARN_UNUSED_RESULT SfxFrame * GetFirst()
Definition: frame.cxx:706
SfxViewShell * GetViewShell() const
Returns the SfxViewShell in which they are located in the subshells.
Definition: shell.cxx:129
sal_uInt16 GetLineCount() const
Definition: splitwin.cxx:857
bool GetWindowPos(const SfxDockingWindow *pWindow, sal_uInt16 &rLine, sal_uInt16 &rPos) const
Definition: splitwin.cxx:818
void ReleaseWindow_Impl(SfxDockingWindow const *pWin, bool bSaveConfig=true)
Definition: splitwin.cxx:514
tools::Long GetLineSize(sal_uInt16) const
Definition: splitwin.cxx:868
SfxFrame & GetFrame() const
Definition: viewfrm.cxx:2782
SAL_DLLPRIVATE bool GlobalKeyInput_Impl(const KeyEvent &rKeyEvent)
Definition: viewsh.cxx:2495
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
Definition: viewsh.cxx:1848
vcl::Window * GetWindow() const
Definition: viewsh.hxx:272
vcl::Window * GetWindow() const
Definition: workwin.hxx:232
SfxSplitWindow * GetSplitWindow_Impl(SfxChildAlignment)
Definition: workwin.cxx:2193
void ConfigChild_Impl(SfxChildIdentifier, SfxDockingConfig, sal_uInt16)
Definition: workwin.cxx:1533
bool IsDockingAllowed() const
Definition: workwin.hxx:239
void SetChildWindow_Impl(sal_uInt16, bool bOn, bool bSetFocus)
Definition: workwin.cxx:1960
bool IsInternalDockingAllowed() const
Definition: workwin.hxx:241
SfxChildWindow * GetChildWindow_Impl(sal_uInt16)
Definition: workwin.cxx:2075
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
static bool GetDockingFloatsSupported()
OUString GetWindowState(vcl::WindowDataMask nMask=vcl::WindowDataMask::All) const
void SetWindowState(std::u16string_view rStr)
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
static VclPtr< reference_type > Create(Arg &&... arg)
constexpr tools::Long GetWidth() const
tools::Rectangle GetIntersection(const tools::Rectangle &rRect) const
constexpr tools::Long Top() const
void SetSize(const Size &)
constexpr Point TopLeft() const
void SetPos(const Point &rPoint)
constexpr Size GetSize() const
constexpr tools::Long Right() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr Point TopRight() const
constexpr tools::Long GetHeight() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
constexpr bool IsEmpty() const
constexpr Point BottomLeft() const
Point OutputToScreenPixel(const Point &rPos) const
bool IsReallyVisible() const
vcl::Window * GetParent() const
bool HasChildPathFocus(bool bSystemWindow=false) const
virtual void SetSizePixel(const Size &rNewSize)
virtual void Resize()
virtual Point GetPosPixel() const
void SetParent(vcl::Window *pNewParent)
virtual void SetOutputSizePixel(const Size &rNewSize)
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
virtual Size GetSizePixel() const
Point GetPointerPosPixel()
bool IsDefaultPos() const
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Point ScreenToOutputPixel(const Point &rPos) const
#define DBG_ASSERT(sCon, aError)
#define MAX_TOGGLEAREA_HEIGHT
Definition: dockwin.cxx:54
bool IsDockingWindowVisible(const uno::Reference< frame::XFrame > &rFrame, std::u16string_view rDockingWindowName)
Function used by the framework layout manager to determine the visibility state of a docking window w...
Definition: dockwin.cxx:349
static bool lcl_getWindowState(const uno::Reference< container::XNameAccess > &xWindowStateMgr, const OUString &rResourceURL, WindowState &rWindowState)
Definition: dockwin.cxx:93
const int NUM_OF_DOCKINGWINDOWS
Definition: dockwin.cxx:62
void SfxDockingWindowFactory(const uno::Reference< frame::XFrame > &rFrame, std::u16string_view rDockingWindowName)
Factory function used by the framework layout manager to "create" a docking window with a special nam...
Definition: dockwin.cxx:324
#define MAX_TOGGLEAREA_WIDTH
Definition: dockwin.cxx:53
IMPL_LINK_NOARG(SfxDockingWindow, TimerHdl, Timer *, void)
Definition: dockwin.cxx:1534
static SfxWorkWindow * lcl_getWorkWindowFromXFrame(const uno::Reference< frame::XFrame > &rFrame)
Definition: dockwin.cxx:296
static bool lcl_checkDockingWindowID(sal_uInt16 nID)
Definition: dockwin.cxx:291
float u
uno_Any a
sal_uInt16 nPos
Definition: linksrc.cxx:118
aStr
Definition: mgetempl.cxx:407
int n2
int n1
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
long Long
WindowState
sal_Int16 nId
SfxChildWindowFlags nFlags
Definition: childwin.hxx:68
OUString aWinState
Definition: childwin.hxx:65
OUString aExtraString
Definition: childwin.hxx:63
Reference< XFrame > xFrame
StateChangedType
sal_Int64 WinBits
WinBits const WB_DIALOGCONTROL
WinBits const WB_SIZEABLE
WinBits const WB_3DLOOK
WinBits const WB_CHILDDLGCTRL
WinBits const WB_STDDOCKWIN
WinBits const WB_STANDALONE
WinBits const WB_CLIPCHILDREN