LibreOffice Module sfx2 (master) 1
workwin.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 <config_features.h>
21#include <config_feature_desktop.h>
22#include <comphelper/lok.hxx>
24#include <osl/diagnose.h>
25#include <sal/log.hxx>
26#include <sfx2/docfile.hxx>
27#include <sfx2/objface.hxx>
28#include <sfx2/objsh.hxx>
29#include <sfx2/app.hxx>
30#include <workwin.hxx>
31#include <sfx2/viewfrm.hxx>
32#include <sfx2/module.hxx>
33#include <sfx2/dispatch.hxx>
34#include <sfx2/dockwin.hxx>
35#include <sfx2/viewsh.hxx>
36#include <splitwin.hxx>
37#include <sfx2/sfxsids.hrc>
38#include <sfx2/toolbarids.hxx>
39#include <vcl/taskpanelist.hxx>
40#include <vcl/svapp.hxx>
41#include <svl/eitem.hxx>
42#include <tools/svborder.hxx>
43#include <tools/debug.hxx>
46#include <com/sun/star/ui/XUIElement.hpp>
47#include <com/sun/star/frame/LayoutManagerEvents.hpp>
48#include <com/sun/star/frame/ModuleManager.hpp>
49#include <com/sun/star/frame/XLayoutManager.hpp>
50#include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp>
51#include <com/sun/star/beans/XPropertySet.hpp>
52#include <com/sun/star/lang/DisposedException.hpp>
53#include <type_traits>
54#include <unordered_map>
56
57using namespace ::com::sun::star;
58using namespace ::com::sun::star::uno;
59
60namespace {
61
62struct ResIdToResName
63{
64 ToolbarId eId;
65 const char* pName;
66};
67
68}
69
70const ResIdToResName pToolBarResToName[] =
71{
72 { ToolbarId::FullScreenToolbox, "fullscreenbar" },
73 { ToolbarId::EnvToolbox, "standardbar", },
74 { ToolbarId::SvxTbx_Form_Navigation, "formsnavigationbar" },
75 { ToolbarId::SvxTbx_Form_Filter, "formsfilterbar" },
76 { ToolbarId::SvxTbx_Text_Control_Attributes, "formtextobjectbar" },
77 { ToolbarId::SvxTbx_Controls, "formcontrols" },
78 { ToolbarId::SvxTbx_FormDesign, "formdesign" },
79 { ToolbarId::Math_Toolbox, "toolbar" }, //math
80 { ToolbarId::Text_Toolbox_Sc, "textobjectbar" }, //calc
81 { ToolbarId::Draw_Objectbar, "drawobjectbar" },
82 { ToolbarId::Graphic_Objectbar, "graphicobjectbar" },
83 { ToolbarId::Objectbar_Format, "formatobjectbar" },
84 { ToolbarId::Objectbar_Preview, "previewbar" },
85 { ToolbarId::Objectbar_Tools, "toolbar" }, //calc
86 { ToolbarId::Bezier_Toolbox_Sd, "bezierobjectbar" }, //draw/impress
87 { ToolbarId::Gluepoints_Toolbox, "gluepointsobjectbar" },
88 { ToolbarId::Draw_Graf_Toolbox, "graphicobjectbar" },
89 { ToolbarId::Draw_Obj_Toolbox, "drawingobjectbar" }, //impress
90 { ToolbarId::Draw_Text_Toolbox_Sd, "textobjectbar" }, //impress
91 { ToolbarId::Draw_Toolbox_Sd, "toolbar" }, //impress
92 { ToolbarId::Draw_Options_Toolbox, "optionsbar" },
93 { ToolbarId::Draw_CommonTask_Toolbox, "commontaskbar" },
94 { ToolbarId::Graphic_Obj_Toolbox, "drawingobjectbar" }, //draw
95 { ToolbarId::Outline_Toolbox, "outlinetoolbar" }, //impress
96 { ToolbarId::Slide_Toolbox, "slideviewtoolbar" },
97 { ToolbarId::Slide_Obj_Toolbox, "slideviewobjectbar" },
98 { ToolbarId::Bezier_Toolbox_Sw, "bezierobjectbar" },
99 { ToolbarId::Draw_Toolbox_Sw, "drawingobjectbar" },
100 { ToolbarId::Draw_Text_Toolbox_Sw, "drawtextobjectbar" },
101 { ToolbarId::Frame_Toolbox, "frameobjectbar" },
102 { ToolbarId::Grafik_Toolbox, "graphicobjectbar" },
103 { ToolbarId::Num_Toolbox, "numobjectbar" },
104 { ToolbarId::Ole_Toolbox, "oleobjectbar" },
105 { ToolbarId::Table_Toolbox, "tableobjectbar" },
106 { ToolbarId::Text_Toolbox_Sw, "textobjectbar" },
107 { ToolbarId::PView_Toolbox, "previewobjectbar" }, //writer
108 { ToolbarId::Webtools_Toolbox, "toolbar" }, //web
109 { ToolbarId::Webtext_Toolbox, "textobjectbar" },
110 { ToolbarId::Tools_Toolbox, "toolbar" }, //writer
111 { ToolbarId::Webframe_Toolbox, "frameobjectbar" }, //web
112 { ToolbarId::Webgraphic_Toolbox, "graphicobjectbar" },
113 { ToolbarId::Webole_Toolbox, "oleobjectbar" },
114 { ToolbarId::Basicide_Objectbar, "macrobar" },
115 { ToolbarId::Svx_Fontwork_Bar, "fontworkobjectbar" }, //global
116 { ToolbarId::Svx_Extrusion_Bar, "extrusionobjectbar" },
117 { ToolbarId::FormLayer_Toolbox, "formsobjectbar" },
118 { ToolbarId::Module_Toolbox, "viewerbar" }, //writer (plugin)
119 { ToolbarId::Objectbar_App, "viewerbar" }, //calc (plugin)
120 { ToolbarId::Draw_Viewer_Toolbox, "viewerbar" }, //impress(plugin)
121 { ToolbarId::Draw_Media_Toolbox, "mediaobjectbar" }, //draw/impress
122 { ToolbarId::Media_Objectbar, "mediaobjectbar" }, //calc
123 { ToolbarId::Media_Toolbox, "mediaobjectbar" }, //writer
124 { ToolbarId::None, "" }
125};
126
127// Sort the Children according their alignment
128// The order corresponds to the enum SfxChildAlignment (->CHILDWIN.HXX).
129
130constexpr OUStringLiteral g_aLayoutManagerPropName = u"LayoutManager";
131
132// Help to make changes to the alignment compatible!
134 SfxWorkWindow* pWrkWin ) :
135 m_bHasFrame( false ),
136 m_pWrkWin( pWrkWin )
137{
138}
139
141{
142}
143
144void LayoutManagerListener::setFrame( const css::uno::Reference< css::frame::XFrame >& xFrame )
145{
146 SolarMutexGuard aGuard;
147 if ( !m_pWrkWin || m_bHasFrame )
148 return;
149
151 m_bHasFrame = true;
152
153 if ( !xFrame.is() )
154 return;
155
156 css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
157 css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager;
158 if ( !xPropSet.is() )
159 return;
160
161 try
162 {
163 Any aValue = xPropSet->getPropertyValue( g_aLayoutManagerPropName );
164 aValue >>= xLayoutManager;
165
166 if ( xLayoutManager.is() )
167 xLayoutManager->addLayoutManagerEventListener(
168 css::uno::Reference< css::frame::XLayoutManagerListener >(this) );
169
170 xPropSet.set( xLayoutManager, UNO_QUERY );
171 if ( xPropSet.is() )
172 {
173 aValue = xPropSet->getPropertyValue( "LockCount" );
174 aValue >>= m_pWrkWin->m_nLock;
175 }
176 }
177 catch ( css::lang::DisposedException& )
178 {
179 }
180 catch ( const css::uno::RuntimeException& )
181 {
182 throw;
183 }
184 catch ( css::uno::Exception& )
185 {
186 }
187}
188
189
190// XComponent
191
193 const css::uno::Reference< css::lang::XEventListener >& )
194{
195 // do nothing, only internal class
196}
197
199 const css::uno::Reference< css::lang::XEventListener >& )
200{
201 // do nothing, only internal class
202}
203
205{
206 SolarMutexGuard aGuard;
207
208 // reset member
209 m_pWrkWin = nullptr;
210
211 css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame.get(), css::uno::UNO_QUERY );
212 if ( !xFrame.is() )
213 return;
214
215 m_xFrame.clear();
216 m_bHasFrame = false;
217
218 css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, css::uno::UNO_QUERY );
219 css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager;
220 if ( !xPropSet.is() )
221 return;
222
223 try
224 {
225 css::uno::Any aValue = xPropSet->getPropertyValue( g_aLayoutManagerPropName );
226 aValue >>= xLayoutManager;
227
228 // remove as listener from layout manager
229 if ( xLayoutManager.is() )
230 xLayoutManager->removeLayoutManagerEventListener(
231 css::uno::Reference< css::frame::XLayoutManagerListener >(this) );
232 }
233 catch ( css::lang::DisposedException& )
234 {
235 }
236 catch ( const css::uno::RuntimeException& )
237 {
238 throw;
239 }
240 catch ( css::uno::Exception& )
241 {
242 }
243}
244
245
246// XEventListener
247
249 const css::lang::EventObject& )
250{
251 SolarMutexGuard aGuard;
252 m_pWrkWin = nullptr;
253 m_bHasFrame = false;
254 m_xFrame.clear();
255}
256
257
258// XLayoutManagerEventListener
259
261 const css::lang::EventObject&,
262 ::sal_Int16 eLayoutEvent,
263 const css::uno::Any& )
264{
265 SolarMutexGuard aGuard;
266 if ( !m_pWrkWin )
267 return;
268
269 if ( eLayoutEvent == css::frame::LayoutManagerEvents::VISIBLE )
270 {
274 }
275 else if ( eLayoutEvent == css::frame::LayoutManagerEvents::INVISIBLE )
276 {
277 m_pWrkWin->MakeVisible_Impl( false );
280 }
281 else if ( eLayoutEvent == css::frame::LayoutManagerEvents::LOCK )
282 {
283 m_pWrkWin->Lock_Impl( true );
284 }
285 else if ( eLayoutEvent == css::frame::LayoutManagerEvents::UNLOCK )
286 {
287 m_pWrkWin->Lock_Impl( false );
288 }
289}
290
291namespace
292{
293 struct ToolbarIdHash
294 {
295 size_t operator()(ToolbarId t) const
296 {
297 typedef std::underlying_type<ToolbarId>::type underlying_type;
298 return std::hash<underlying_type>()(static_cast<underlying_type>(t));
299 }
300 };
301
302 class FilledToolBarResIdToResourceURLMap
303 {
304 private:
305 typedef std::unordered_map<ToolbarId, OUString, ToolbarIdHash> ToolBarResIdToResourceURLMap;
306 ToolBarResIdToResourceURLMap m_aResIdToResourceURLMap;
307 public:
308 FilledToolBarResIdToResourceURLMap()
309 {
310 sal_Int32 nIndex( 0 );
311 while (pToolBarResToName[nIndex].eId != ToolbarId::None)
312 {
313 OUString aResourceURL( OUString::createFromAscii( pToolBarResToName[nIndex].pName ));
314 m_aResIdToResourceURLMap.emplace(pToolBarResToName[nIndex].eId, aResourceURL);
315 ++nIndex;
316 }
317 }
318
319 OUString findURL(ToolbarId eId) const
320 {
321 ToolBarResIdToResourceURLMap::const_iterator aIter = m_aResIdToResourceURLMap.find(eId);
322 if ( aIter != m_aResIdToResourceURLMap.end() )
323 return aIter->second;
324 return OUString();
325 }
326 };
327}
328
330{
331 static FilledToolBarResIdToResourceURLMap theFilledToolBarResIdToResourceURLMap;
332 return theFilledToolBarResIdToResourceURLMap.findURL(eId);
333}
334
335static sal_uInt16 TbxMatch( sal_uInt16 nPos )
336{
337 switch ( nPos )
338 {
340 return 0;
342 return 1;
344 return 2;
346 return 3;
348 return 4;
352 return nPos+1;
353 default:
354 return nPos;
355 }
356}
357
358static sal_uInt16 ChildAlignValue(SfxChildAlignment eAlign)
359{
360 sal_uInt16 ret = 17;
361
362 switch (eAlign)
363 {
365 ret = 1;
366 break;
368 ret = 2;
369 break;
371 ret = 3;
372 break;
374 ret = 4;
375 break;
377 ret = 5;
378 break;
380 ret = 6;
381 break;
383 ret = 7;
384 break;
386 ret = 8;
387 break;
389 ret = 9;
390 break;
392 ret = 10;
393 break;
395 ret = 11;
396 break;
398 ret = 12;
399 break;
401 ret = 13;
402 break;
404 ret = 14;
405 break;
407 ret = 15;
408 break;
410 ret = 16;
411 break;
413 break; // -Wall not handled...
414 }
415
416 return ret;
417}
418
420{
421 aSortedList.clear();
422 for (size_t i = 0; i < aChildren.size(); ++i)
423 {
424 SfxChild_Impl *pCli = aChildren[i].get();
425 if (pCli)
426 {
427 decltype(aSortedList)::size_type k;
428 for (k=0; k<aSortedList.size(); k++)
429 if (ChildAlignValue( aChildren[aSortedList[k]]->eAlign ) >
430 ChildAlignValue(pCli->eAlign))
431 break;
432 aSortedList.insert( aSortedList.begin() + k, i );
433 }
434 }
435
436 bSorted = true;
437}
438
439constexpr OUStringLiteral g_aStatusBarResName( u"private:resource/statusbar/statusbar" );
440constexpr OUStringLiteral g_aTbxTypeName( u"private:resource/toolbar/" );
441constexpr OUStringLiteral g_aProgressBarResName( u"private:resource/progressbar/progressbar" );
442
443// constructor for workwin of a Frame
444
446 pBindings(&pFrm->GetCurrentViewFrame()->GetBindings()),
447 pWorkWin (pWin),
448 pActiveChild( nullptr ),
449 nUpdateMode(SfxVisibilityFlags::Standard),
450 nChildren( 0 ),
451 nOrigMode( SfxVisibilityFlags::Invisible ),
452 bSorted( true ),
453 bDockingAllowed(true),
454 bInternalDockingAllowed(true),
455 bAllChildrenVisible(true),
456#if !defined(ANDROID) || HAVE_FEATURE_ANDROID_LOK
457 bIsFullScreen( false ),
458#else // Fennec-based Android Viewer
459 bIsFullScreen( true ),
460#endif
461#if HAVE_FEATURE_DESKTOP
462 bShowStatusBar( true ),
463#else
464 bShowStatusBar( sal_False ),
465#endif
466 m_nLock( 0 ),
467 pMasterFrame( pMaster ),
468 pFrame( pFrm )
469{
470 DBG_ASSERT (pBindings, "No Bindings!");
471
472 pBindings->SetWorkWindow_Impl( std::unique_ptr<SfxWorkWindow>(this) );
473
474 // For the ObjectBars an integral place in the Childlist is reserved,
475 // so that they always come in a defined order.
476 for (int i=0; i<SFX_OBJECTBAR_MAX; ++i)
477 aChildren.push_back( nullptr );
478
479 // create and initialize layout manager listener
480 Reference< css::frame::XFrame > xFrame = GetFrameInterface();
481 rtl::Reference<LayoutManagerListener> pLayoutManagerListener = new LayoutManagerListener( this );
482 m_xLayoutManagerListener = pLayoutManagerListener;
483 pLayoutManagerListener->setFrame( xFrame );
484
485 SfxShell* pConfigShell = pFrm->GetCurrentViewFrame();
486 if ( pConfigShell && pConfigShell->GetObjectShell() )
487 {
488 bShowStatusBar = ( !pConfigShell->GetObjectShell()->IsInPlaceActive() );
489 bDockingAllowed = true;
491 }
492
493 // The required split windows (one for each side) can be created
494 for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
495 {
496 // The SplitWindows excludes direct ChildWindows of the WorkWindows
497 // and receives the docked window.
498
499 SfxChildAlignment eAlign =
504 VclPtr<SfxSplitWindow> pSplitWin = VclPtr<SfxSplitWindow>::Create(pWorkWin, eAlign, this, true );
505 pSplit[n] = pSplitWin;
506 }
507
510}
511
512
513// Destructor
514
516{
517
518 // Delete SplitWindows
520 {
521 if (p->GetWindowCount())
523 p.disposeAndClear();
524 }
525
526 // Delete help structure for Child-Windows
527 DBG_ASSERT( aChildren.empty(), "dangling children" );
528
529 if ( m_xLayoutManagerListener.is() )
530 m_xLayoutManagerListener->dispose();
531}
532
533void SfxWorkWindow::Lock_Impl( bool bLock )
534{
535 if ( bLock )
536 m_nLock++;
537 else
538 --m_nLock;
539 if ( m_nLock<0 )
540 {
541 OSL_FAIL("Lock count underflow!");
542 assert(m_nLock >= 0);
543 m_nLock = 0;
544 }
545
546 if ( !m_nLock )
548}
549
550
551// Helper method to release the child lists. Should the destructor not be
552// called after this, instead work continues, then space for the object bars
553// and split windows has to be reserved in the same way as in the constructor
554// of SfxWorkWindow.
555
557{
558
559 // Lock SplitWindows (which means suppressing the Resize-Reaction of the
560 // DockingWindows)
561 for (size_t n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
562 {
564 if (p->GetWindowCount())
565 p->Lock();
566 }
567
568 // Delete Child-Windows
569 while(!aChildWins.empty())
570 {
571 std::unique_ptr<SfxChildWin_Impl> pCW = std::move(*aChildWins.begin());
572 aChildWins.erase(aChildWins.begin());
573 SfxChildWindow *pChild = pCW->pWin;
574 if (pChild)
575 {
577 {
578 vcl::Window* pWindow = pChild->GetWindow();
579 if (pWindow)
580 {
581 pWindow->ReleaseLOKNotifier();
582 }
583 }
584 pChild->Hide();
585
586 // If the child window is a direct child window and not in a
587 // SplitWindow, cancel it at the workwindow.
588 // After TH a cancellation on the SplitWindow is not necessary
589 // since this window is also destroyed (see below).
590 if (pCW->pCli)
591 {
592 if (pChild->GetController())
594 else
595 ReleaseChild_Impl(*pChild->GetWindow());
596 }
597
598 pCW->pWin = nullptr;
599 pWorkWin->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( pChild->GetWindow() );
600 pChild->Destroy();
601 }
602
603 // ATTENTION: The array itself is cleared after this loop!!
604 // Therefore we have to set every array entry to zero as it could be
605 // accessed by calling pChild->Destroy().
606 // Window::NotifyAllChildren() calls SfxWorkWindow::DataChanged_Impl for
607 // 8-bit displays (WM_QUERYPALETTECHANGED message due to focus change)!!
608 }
609
610 Reference< css::frame::XFrame > xFrame = GetFrameInterface();
611 Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
612 Reference< css::frame::XLayoutManager > xLayoutManager;
613 if ( xPropSet.is() )
614 {
615 try
616 {
617 Any aValue = xPropSet->getPropertyValue( g_aLayoutManagerPropName );
618 aValue >>= xLayoutManager;
619 }
620 catch ( Exception& )
621 {
622 }
623 }
624
625 if ( xLayoutManager.is() )
626 {
627 xLayoutManager->reset();
628
629 // Delete StatusBar
631
632 // Delete ObjectBars (this is done last, so that aChildren does not
633 // receive dead Pointers)
635 {
636 // Not every position must be occupied
637 ToolbarId eId = i.eId;
638 if (eId != ToolbarId::None)
639 i.eId = ToolbarId::None;
640 }
641 }
642
643 // ObjectBars are all released at once, since they occupy a
644 // fixed contiguous area in the array pChild
645 aChildren.clear();
646 bSorted = false;
647
648 nChildren = 0;
649}
650
651
652// for placing the child window.
653
655{
656 if ( pFrame->IsClosing_Impl() || ( m_nLock && !bForce ))
657 return;
658
659 SfxInPlaceClient *pClient = nullptr;
661 if ( pF && pF->GetViewShell() )
662 pClient = pF->GetViewShell()->GetIPClient();
663
664 if ( pClient )
665 return;
666
668 if ( aClientArea.IsEmpty() )
669 return;
670
671 SvBorder aBorder;
672 if ( nChildren && IsVisible_Impl() )
673 aBorder = Arrange_Impl();
674 // If the current application document contains an IPClient, then the
675 // object through SetTopToolFramePixel has to be assigned the available
676 // space. The object will then point to its UITools and sets the app border
677 // (-> SfxInPlaceEnv_Impl:: ArrangeChildren_Impl ()). Otherwise the
678 // app border is set here directly to possibly overwrite the Border that
679 // was set by an object from another document. The object does not set
680 // the SetAppBorder when it removes its UI tools so that no-dithering
681 // ObjectBar arises.
682 // (->SfxInPlaceEnv_Impl::ArrangeChildren_Impl())
683
685
686 ArrangeAutoHideWindows( nullptr );
687}
688
690{
691 // tdf#116865, if any windows are being resized, i.e. their
692 // resize timer is active, then calling GetSizePixel on
693 // them forces the timer to fire and sets the final
694 // size to which they are getting resized towards.
695 for (size_t i = 0; i < aChildren.size(); ++i)
696 {
697 SfxChild_Impl *pCli = aChildren[i].get();
698 if (!pCli || !pCli->pWin)
699 continue;
700 (void)pCli->pWin->GetSizePixel();
701 }
702}
703
705
706/* [Description]
707
708 This method organizes all visible child windows so that the docked window
709 sorted in order from the outside to the inside are placed after one
710 another. If a visible window does not fit anymore into the free
711 ClientArea, it is set to "not visible".
712*/
713{
714 //tdf#116865 trigger pending sizing timers now so we arrange
715 //with the final size of the client area.
716 //
717 //Otherwise calling GetSizePixel in the following loop will trigger the
718 //timers, causing reentry into Arrange_Impl again where the inner
719 //Arrange_Impl arranges with the final size, and then returns to this outer
720 //Arrange_Impl which would rearrange with the old client area size
724
725 SvBorder aBorder;
726 if ( !nChildren )
727 return aBorder;
728
729 if (!bSorted)
730 Sort_Impl();
731
732 Point aPos;
733 Size aSize;
735
736 for (sal_uInt16 n : aSortedList)
737 {
738 SfxChild_Impl* pCli = aChildren[n].get();
739 if ( !pCli->pWin )
740 continue;
741
742 // First, we assume that there is room for the window.
744
745 // Skip invisible windows
747 continue;
748
749 if ( pCli->bResize )
750 aSize = pCli->aSize;
751 else
752 aSize = pCli->pWin->GetSizePixel();
753
754 SvBorder aTemp = aBorder;
755 bool bAllowHiding = true;
756 switch ( pCli->eAlign )
757 {
762 aSize.setWidth( aTmp.GetWidth() );
763 if ( pCli->pWin->GetType() == WindowType::SPLITWINDOW )
764 aSize = static_cast<SplitWindow *>(pCli->pWin.get())->CalcLayoutSizePixel( aSize );
765 bAllowHiding = false;
766 aBorder.Top() += aSize.Height();
767 aPos = aTmp.TopLeft();
768 aTmp.AdjustTop(aSize.Height() );
771 break;
772
777 aSize.setWidth( aTmp.GetWidth() );
778 if ( pCli->pWin->GetType() == WindowType::SPLITWINDOW )
779 aSize = static_cast<SplitWindow *>(pCli->pWin.get())->CalcLayoutSizePixel( aSize );
780 aBorder.Bottom() += aSize.Height();
781 aPos = aTmp.BottomLeft();
782 aPos.AdjustY( -(aSize.Height()-1) );
783 aTmp.AdjustBottom( -(aSize.Height()) );
786 break;
787
792 aSize.setHeight( aTmp.GetHeight() );
793 if ( pCli->pWin->GetType() == WindowType::SPLITWINDOW )
794 aSize = static_cast<SplitWindow *>(pCli->pWin.get())->CalcLayoutSizePixel( aSize );
795 bAllowHiding = false;
796 aBorder.Left() += aSize.Width();
797 aPos = aTmp.TopLeft();
798 aTmp.AdjustLeft(aSize.Width() );
801 break;
802
807 aSize.setHeight( aTmp.GetHeight() );
808 if ( pCli->pWin->GetType() == WindowType::SPLITWINDOW )
809 aSize = static_cast<SplitWindow *>(pCli->pWin.get())->CalcLayoutSizePixel( aSize );
810 aBorder.Right() += aSize.Width();
811 aPos = aTmp.TopRight();
812 aPos.AdjustX( -(aSize.Width()-1) );
813 aTmp.AdjustRight( -(aSize.Width()) );
815 aUpperClientArea.AdjustRight( -(aSize.Width()) );
816 break;
817
818 default:
819 pCli->aSize = pCli->pWin->GetSizePixel();
820 pCli->bResize = false;
821 continue;
822 }
823
824 pCli->pWin->SetPosSizePixel( aPos, aSize );
825 pCli->bResize = false;
826 pCli->aSize = aSize;
827 if( bAllowHiding && !RequestTopToolSpacePixel_Impl( aBorder ) )
828 {
830 aBorder = aTemp;
831 }
832 }
833
834 if ( aClientArea.GetWidth() >= aBorder.Left() + aBorder.Right() )
835 {
836 aClientArea.AdjustLeft(aBorder.Left() );
837 aClientArea.AdjustRight( -(aBorder.Right()) );
838 }
839 else
840 {
841 aBorder.Left() = aClientArea.Left();
842 aBorder.Right() = aClientArea.Right();
843 aClientArea.SetRight( aTmp.Left() );
844 aClientArea.SetLeft( aTmp.Left() );
845 }
846
847 if ( aClientArea.GetHeight() >= aBorder.Top() + aBorder.Bottom() )
848 {
849 aClientArea.AdjustTop(aBorder.Top() );
850 aClientArea.AdjustBottom( -(aBorder.Bottom()) );
851 }
852 else
853 {
854 aBorder.Top() = aClientArea.Top();
855 aBorder.Bottom() = aClientArea.Bottom();
856 aClientArea.SetTop(aTmp.Top());
857 aClientArea.SetBottom(aTmp.Top());
858 }
859
860 return IsDockingAllowed() ? aBorder : SvBorder();
861}
862
864{
865 for (const std::unique_ptr<SfxChildWin_Impl> &pCW : aChildWins)
866 {
867 SfxChildWindow *pChild = pCW->pWin;
868 if ( pChild && !pChild->QueryClose() )
869 return false;
870 }
871
872 return true;
873}
874
876 SfxChildAlignment eAlign )
877{
878 DBG_ASSERT( aChildren.size() < 255, "too many children" );
879 DBG_ASSERT( SfxChildAlignValid(eAlign), "invalid align" );
880 DBG_ASSERT( !FindChild_Impl(&rWindow), "child registered more than once" );
881
882
883 if ( rWindow.GetParent() != pWorkWin )
884 rWindow.SetParent( pWorkWin );
885
886 auto pChild = std::make_unique<SfxChild_Impl>(rWindow, rWindow.GetSizePixel(),
887 eAlign, rWindow.IsVisible());
888
889 aChildren.push_back(std::move(pChild));
890 bSorted = false;
891 nChildren++;
892 return aChildren.back().get();
893}
894
895SfxChild_Impl* SfxWorkWindow::RegisterChild_Impl(std::shared_ptr<SfxDialogController>& rController,
896 SfxChildAlignment eAlign )
897{
898 DBG_ASSERT( aChildren.size() < 255, "too many children" );
899 DBG_ASSERT( SfxChildAlignValid(eAlign), "invalid align" );
900
901 auto pChild = std::make_unique<SfxChild_Impl>(rController, eAlign);
902
903 aChildren.push_back(std::move(pChild));
904 bSorted = false;
905 nChildren++;
906 return aChildren.back().get();
907}
908
910{
911
912 SfxChild_Impl *pChild = nullptr;
913 decltype(aChildren)::size_type nPos;
914 for ( nPos = 0; nPos < aChildren.size(); ++nPos )
915 {
916 pChild = aChildren[nPos].get();
917 if ( pChild && pChild->pWin == &rWindow )
918 {
919 bSorted = false;
920 nChildren--;
921 aChildren.erase(aChildren.begin() + nPos);
922 return;
923 }
924 }
925 OSL_FAIL( "releasing unregistered child" );
926}
927
929{
930
931 SfxChild_Impl *pChild = nullptr;
932 decltype(aChildren)::size_type nPos;
933 for ( nPos = 0; nPos < aChildren.size(); ++nPos )
934 {
935 pChild = aChildren[nPos].get();
936 if (pChild && pChild->xController.get() == &rController)
937 {
938 bSorted = false;
939 nChildren--;
940 aChildren.erase(aChildren.begin() + nPos);
941 return;
942 }
943 }
944 OSL_FAIL( "releasing unregistered child" );
945}
946
948{
949
950 sal_uInt16 nCount = aChildren.size();
951 for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
952 {
953 SfxChild_Impl *pChild = aChildren[nPos].get();
954 if ( pChild && pChild->pWin == rWindow )
955 return pChild;
956 }
957
958 return nullptr;
959}
960
962{
963 bool bInvisible = ( !IsVisible_Impl() || ( !pWorkWin->IsReallyVisible() && !pWorkWin->IsReallyShown() ));
964
965 for (std::unique_ptr<SfxChild_Impl>& pCli : aChildren)
966 {
967 if (!pCli)
968 continue;
969 SfxChildWin_Impl* pCW = nullptr;
970 if (pCli->pWin || pCli->xController)
971 {
972 // We have to find the SfxChildWin_Impl to retrieve the
973 // SFX_CHILDWIN flags that can influence visibility.
974 for (const std::unique_ptr<SfxChildWin_Impl>& pCWin : aChildWins)
975 {
976 SfxChild_Impl* pChild = pCWin->pCli;
977 if ( pChild == pCli.get() )
978 {
979 pCW = pCWin.get();
980 break;
981 }
982 }
983
984 bool bVisible( !bInvisible );
985 if ( pCW )
986 {
987 // Check flag SFX_CHILDWIN_NEVERHIDE that forces us to show
988 // the child window even in situations where no child window is
989 // visible.
990 SfxChildWindowFlags nFlags = pCW->aInfo.nFlags;
991 bVisible = !bInvisible || ( nFlags & SfxChildWindowFlags::NEVERHIDE );
992 }
993
995 {
996 if (pCli->xController)
997 {
998 if (!pCli->xController->getDialog()->get_visible())
999 {
1000 auto xController = pCli->xController;
1002 [=](sal_Int32 nResult){
1003 if (nResult == nCloseResponseToJustHide)
1004 return;
1005 xController->Close();
1006 });
1007 }
1008 }
1009 else
1010 {
1011 ShowFlags nFlags = pCli->bSetFocus ? ShowFlags::NONE : ShowFlags::NoFocusChange | ShowFlags::NoActivate;
1012 pCli->pWin->Show(true, nFlags);
1013 }
1014 pCli->bSetFocus = false;
1015 }
1016 else
1017 {
1018 if (pCli->xController)
1019 {
1020 if (pCli->xController->getDialog()->get_visible())
1021 pCli->xController->response(RET_CLOSE);
1022 }
1023 else
1024 pCli->pWin->Hide();
1025 }
1026 }
1027 }
1028}
1029
1030
1032{
1033 for ( sal_uInt16 nPos = aChildren.size(); nPos > 0; --nPos )
1034 {
1035 SfxChild_Impl *pChild = aChildren[nPos-1].get();
1036 if (!pChild)
1037 continue;
1038 if (pChild->xController)
1039 pChild->xController->response(RET_CLOSE);
1040 else if (pChild->pWin)
1041 pChild->pWin->Hide();
1042 }
1043}
1044
1046{
1047 for ( auto & n: aObjBarList )
1048 n.bDestroy = true;
1049
1050 for ( auto & n: aChildWins )
1051 n->nId = 0;
1052}
1053
1055{
1056 DBG_ASSERT( nPos < SFX_OBJECTBAR_MAX, "object bar position overflow" );
1057
1058 SfxObjectBar_Impl aObjBar;
1059 aObjBar.eId = eId;
1060 aObjBar.nMode = nFlags;
1061
1062 for (SfxObjectBar_Impl & rBar : aObjBarList)
1063 {
1064 if ( rBar.eId == aObjBar.eId )
1065 {
1066 rBar = aObjBar;
1067 return;
1068 }
1069 }
1070
1071 aObjBarList.push_back( aObjBar );
1072}
1073
1075{
1076 switch( nUpdateMode )
1077 {
1079 return true;
1081 return false;
1084 return bool(nMode & nUpdateMode);
1085 default:
1086 return (nMode & nOrigMode ) ||
1088 }
1089}
1090
1092{
1093 if ( pFrame->IsClosing_Impl() )
1094 return;
1095
1097
1098 {
1099 ArrangeChildren_Impl( false );
1100
1102 }
1103
1105}
1106
1107Reference< css::task::XStatusIndicator > SfxWorkWindow::GetStatusIndicator()
1108{
1109 Reference< css::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
1110 Reference< css::frame::XLayoutManager > xLayoutManager;
1111 Reference< css::task::XStatusIndicator > xStatusIndicator;
1112
1113 if ( xPropSet.is() )
1114 {
1115 Any aValue = xPropSet->getPropertyValue( g_aLayoutManagerPropName );
1116 aValue >>= xLayoutManager;
1117 if ( xLayoutManager.is() )
1118 {
1119 xLayoutManager->createElement( g_aProgressBarResName );
1120 xLayoutManager->showElement( g_aProgressBarResName );
1121
1122 Reference< css::ui::XUIElement > xProgressBar =
1123 xLayoutManager->getElement( g_aProgressBarResName );
1124 if ( xProgressBar.is() )
1125 {
1126 xStatusIndicator.set( xProgressBar->getRealInterface(), UNO_QUERY );
1127 }
1128 }
1129 }
1130
1131 return xStatusIndicator;
1132}
1133
1134
1136{
1137 if ( pObjShell && pObjShell->GetMedium() )
1138 {
1139 const SfxBoolItem* pViewOnlyItem = pObjShell->GetMedium()->GetItemSet().GetItem(SID_VIEWONLY, false);
1140 if ( pViewOnlyItem && pViewOnlyItem->GetValue() )
1141 return true;
1142 }
1143
1144 return false;
1145}
1146
1147
1148css::uno::Reference< css::frame::XFrame > SfxWorkWindow::GetFrameInterface()
1149{
1150 css::uno::Reference< css::frame::XFrame > xFrame;
1151
1152 SfxDispatcher* pDispatcher( GetBindings().GetDispatcher() );
1153 if ( pDispatcher )
1154 {
1155 SfxViewFrame* pViewFrame = pDispatcher->GetFrame();
1156 if ( pViewFrame )
1157 xFrame = pViewFrame->GetFrame().GetFrameInterface();
1158 }
1159
1160 return xFrame;
1161}
1162
1163
1165{
1167 return;
1168
1169 // Lock SplitWindows (which means suppressing the Resize-Reaction of the
1170 // DockingWindows)
1171 for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
1172 {
1173 VclPtr<SfxSplitWindow> const & p = pSplit[n];
1174 if (p->GetWindowCount())
1175 p->Lock();
1176 }
1177
1178 Reference< css::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
1179 Reference< css::frame::XLayoutManager > xLayoutManager;
1180
1181 if ( xPropSet.is() )
1182 {
1183 Any aValue = xPropSet->getPropertyValue( g_aLayoutManagerPropName );
1184 aValue >>= xLayoutManager;
1185 }
1186
1187 if ( !xLayoutManager.is() )
1188 return;
1189
1190 bool bPluginMode( false );
1191 SfxDispatcher* pDispatcher( GetBindings().GetDispatcher() );
1192
1193 if ( pDispatcher )
1194 {
1195 SfxViewFrame* pViewFrame = pDispatcher->GetFrame();
1196 if ( pViewFrame )
1197 bPluginMode = IsPluginMode( pViewFrame->GetObjectShell() );
1198 }
1199
1200 // Iterate over all Toolboxes
1201 xLayoutManager->lock();
1202 const bool isNotebookBarActive = sfx2::SfxNotebookBar::IsActive(true);
1203 for ( auto const & n: aObjBarList )
1204 {
1205 ToolbarId eId = n.eId;
1206 bool bDestroy = n.bDestroy;
1207
1208 // Determine the valid mode for the ToolBox
1209 SfxVisibilityFlags nTbxMode = n.nMode;
1210 bool bFullScreenTbx( nTbxMode & SfxVisibilityFlags::FullScreen );
1211 nTbxMode &= ~SfxVisibilityFlags::FullScreen;
1212 nTbxMode &= ~SfxVisibilityFlags::Viewer;
1213
1214 // Is a ToolBox required in this context ?
1215 bool bModesMatching = (nUpdateMode != SfxVisibilityFlags::Invisible) && ((nTbxMode & nUpdateMode) == nUpdateMode);
1216 if ( bDestroy || isNotebookBarActive)
1217 {
1218 OUString aTbxId = g_aTbxTypeName + GetResourceURLFromToolbarId(eId);
1219 xLayoutManager->destroyElement( aTbxId );
1220 }
1221 else if ( eId != ToolbarId::None && ( ( bModesMatching && !bIsFullScreen ) ||
1222 ( bIsFullScreen && bFullScreenTbx ) ) )
1223 {
1224 OUString aTbxId = g_aTbxTypeName + GetResourceURLFromToolbarId(eId);
1225 if ( !IsDockingAllowed() && !xLayoutManager->isElementFloating( aTbxId ))
1226 xLayoutManager->destroyElement( aTbxId );
1227 else
1228 {
1229 xLayoutManager->requestElement( aTbxId );
1230 if ( bPluginMode )
1231 xLayoutManager->lockWindow( aTbxId );
1232 }
1233 }
1234 else if ( eId != ToolbarId::None )
1235 {
1236 // Delete the Toolbox at this Position if possible
1237 OUString aTbxId = g_aTbxTypeName + GetResourceURLFromToolbarId(eId);
1238 xLayoutManager->destroyElement( aTbxId );
1239 }
1240 }
1241
1243
1244 // unlocking automatically forces Layout
1245 xLayoutManager->unlock();
1246
1248
1249 // Unlock the SplitWindows again
1250 for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
1251 {
1252 VclPtr<SfxSplitWindow> const & p = pSplit[n];
1253 if (p->GetWindowCount())
1254 p->Lock(false);
1255 }
1256}
1257
1259{
1260 // tdf#100870, tdf#101320: don't use range-based for loop when
1261 // container is modified
1262 for ( size_t n=0; n<aChildWins.size(); n++ )
1263 {
1264 // any current or in the context available Childwindows
1265 SfxChildWin_Impl *pCW = aChildWins[n].get();
1266 SfxChildWindow *pChildWin = pCW->pWin;
1267 bool bCreate = false;
1269 {
1270 // In the context is an appropriate ChildWindow allowed;
1271 // it is also turned on?
1272 if ( pChildWin == nullptr && pCW->bCreate )
1273 {
1274 // Internal docking is only used for embedding into another
1275 // container. We force the floating state of all floatable
1276 // child windows.
1278 {
1279 // Special case for all non-floatable child windows. We have
1280 // to prevent the creation here!
1281 bCreate = !( pCW->aInfo.nFlags & SfxChildWindowFlags::FORCEDOCK );
1282 }
1283 else if ( !IsDockingAllowed() || bIsFullScreen ) // || !bInternalDocking )
1284 {
1285 // In Presentation mode or FullScreen only FloatingWindows
1286 SfxChildAlignment eAlign;
1287 if ( pCW->aInfo.GetExtraData_Impl( &eAlign ) )
1288 bCreate = ( eAlign == SfxChildAlignment::NOALIGNMENT );
1289 }
1290 else
1291 bCreate = true;
1292
1294 pCW->bCreate = bCreate = false; // Don't create and remember that we haven't created.
1295
1296 // Currently, no window here, but it is enabled; windows
1297 // Create window and if possible theContext
1298 if ( bCreate )
1299 CreateChildWin_Impl( pCW, false );
1300
1301 if ( !bAllChildrenVisible && pCW->pCli )
1303 }
1304 else if ( pChildWin )
1305 {
1306 // Window already exists, it should also be visible?
1308 {
1309 // Update Mode is compatible; definitely enable it
1310 bCreate = true;
1311 if ( pCW->pCli )
1312 {
1313 // The window is a direct Child
1317 }
1318 else
1319 {
1321 // The window ia within a SplitWindow
1322 static_cast<SfxDockingWindow*>(pChildWin->GetWindow())->Reappear_Impl();
1323 }
1324 }
1325 }
1326 }
1327
1328 if ( pChildWin && !bCreate )
1329 {
1330 if ( !pChildWin->QueryClose() || pChildWin->IsHideNotDelete() || Application::IsUICaptured() )
1331 {
1332 if ( pCW->pCli )
1333 {
1336 }
1337 else
1338 static_cast<SfxDockingWindow*>(pChildWin->GetWindow())->Disappear_Impl();
1339 }
1340 else
1341 RemoveChildWin_Impl( pCW );
1342 }
1343 }
1344}
1345
1347{
1348 pCW->aInfo.bVisible = true;
1349
1350 SfxChildWindow *pChildWin = SfxChildWindow::CreateChildWindow( pCW->nId, pWorkWin, &GetBindings(), pCW->aInfo).release();
1351 if (!pChildWin)
1352 return;
1353
1354 if ( bSetFocus )
1355 bSetFocus = pChildWin->WantsFocus();
1356 pChildWin->SetWorkWindow_Impl( this );
1357
1358 // At least the extra string is changed during the evaluation,
1359 // also get it anewed
1360 SfxChildWinInfo aInfo = pChildWin->GetInfo();
1361 pCW->aInfo.aExtraString = aInfo.aExtraString;
1362 pCW->aInfo.bVisible = aInfo.bVisible;
1363 pCW->aInfo.nFlags |= aInfo.nFlags;
1364
1365 // The creation was successful
1366 GetBindings().Invalidate(pCW->nId);
1367
1368 sal_uInt16 nPos = pChildWin->GetPosition();
1369 if (nPos != CHILDWIN_NOPOS)
1370 {
1371 DBG_ASSERT(nPos < SFX_OBJECTBAR_MAX, "Illegal objectbar position!");
1372 if ( aChildren[TbxMatch(nPos)] )// &&
1373 {
1374 // ChildWindow replaces ObjectBar
1376 }
1377 }
1378
1379 // make childwin keyboard accessible
1380 pWorkWin->GetSystemWindow()->GetTaskPaneList()->AddWindow( pChildWin->GetWindow() );
1381
1382 pCW->pWin = pChildWin;
1383
1384 if ( pChildWin->GetAlignment() == SfxChildAlignment::NOALIGNMENT || pChildWin->GetWindow()->GetParent() == pWorkWin)
1385 {
1386 // The window is not docked or docked outside of one split windows
1387 // and must therefore be registered explicitly as a Child
1388 if (pChildWin->GetController())
1389 pCW->pCli = RegisterChild_Impl(pChildWin->GetController(), pChildWin->GetAlignment());
1390 else
1391 pCW->pCli = RegisterChild_Impl(*(pChildWin->GetWindow()), pChildWin->GetAlignment());
1395 pCW->pCli->bSetFocus = bSetFocus;
1396 }
1397 else
1398 {
1399 // A docked window which parent is not a WorkingWindow, must lie
1400 // in a SplitWindow and thus not be explicitly registered.
1401 // This happens already in the initialization of SfxDockingWindows!
1402 }
1403
1404 // Save the information in the INI file
1405 SaveStatus_Impl(pChildWin, pCW->aInfo);
1406}
1407
1409{
1410 sal_uInt16 nId = pCW->nSaveId;
1411 SfxChildWindow *pChildWin = pCW->pWin;
1412
1413 // Save the information in the INI file
1414 SfxChildWindowFlags nFlags = pCW->aInfo.nFlags;
1415 pCW->aInfo = pChildWin->GetInfo();
1416 pCW->aInfo.nFlags |= nFlags;
1417 SaveStatus_Impl(pChildWin, pCW->aInfo);
1418
1419 pChildWin->Hide();
1420
1421 if ( pCW->pCli )
1422 {
1423 // Child window is a direct child window and must therefore unregister
1424 // itself from the WorkWindow
1425 pCW->pCli = nullptr;
1426 if (pChildWin->GetController())
1427 ReleaseChild_Impl(*pChildWin->GetController());
1428 else
1429 ReleaseChild_Impl(*pChildWin->GetWindow());
1430 }
1431 else
1432 {
1433 // ChildWindow is within a SplitWindow and unregister itself in
1434 // the destructor.
1435 }
1436
1437 pWorkWin->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( pChildWin->GetWindow() );
1438 pCW->pWin = nullptr;
1439 pChildWin->Destroy();
1440
1442}
1443
1445{
1447}
1448
1450{
1452 aStatBar.eId = eId;
1453}
1454
1456{
1457 Reference< css::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
1458 Reference< css::frame::XLayoutManager > xLayoutManager;
1459
1460 Any aValue = xPropSet->getPropertyValue( g_aLayoutManagerPropName );
1461 aValue >>= xLayoutManager;
1462
1463 // No status bar, if no ID is required or when in FullScreenView or
1464 // if disabled
1467 {
1468 // Id has changed, thus create a suitable Statusbarmanager, this takes
1469 // over the current status bar;
1470 if ( xLayoutManager.is() )
1471 xLayoutManager->requestElement( g_aStatusBarResName );
1472 }
1473 else
1474 {
1475 // Destroy the current StatusBar
1476 // The Manager only creates the Status bar, does not destroy it.
1477 if ( xLayoutManager.is() )
1478 xLayoutManager->destroyElement( g_aStatusBarResName );
1479 }
1480}
1481
1483{
1484 if ( bVis )
1486 else
1488
1489 if ( nOrigMode != nUpdateMode)
1491}
1492
1494{
1496}
1497
1498
1499void SfxWorkWindow::HidePopups_Impl(bool bHide, sal_uInt16 nId )
1500{
1502 return;
1503
1504 for (const std::unique_ptr<SfxChildWin_Impl>& i : aChildWins)
1505 {
1506 SfxChildWindow *pCW = i->pWin;
1507 if (pCW && pCW->GetAlignment() == SfxChildAlignment::NOALIGNMENT && pCW->GetType() != nId)
1508 {
1509 vcl::Window *pWin = pCW->GetWindow();
1510 SfxChild_Impl *pChild = FindChild_Impl(pWin);
1511 if (!pChild)
1512 {
1513 SAL_WARN("sfx.appl", "missing SfxChild_Impl child!");
1514 continue;
1515 }
1516 if (bHide)
1517 {
1519 pCW->Hide();
1520 }
1523 {
1526 pCW->Show( ShowFlags::NoFocusChange | ShowFlags::NoActivate );
1527 }
1528 }
1529 }
1530}
1531
1532
1534 SfxDockingConfig eConfig, sal_uInt16 nId)
1535{
1536 SfxDockingWindow* pDockWin=nullptr;
1537 sal_uInt16 nPos = USHRT_MAX;
1538 vcl::Window *pWin=nullptr;
1539 SfxChildWin_Impl *pCW = nullptr;
1540
1541 // configure direct childwindow
1542 for (const std::unique_ptr<SfxChildWin_Impl>& i : aChildWins)
1543 {
1544 pCW = i.get();
1545 SfxChildWindow *pChild = pCW->pWin;
1546 if ( pChild && (pChild->GetType() == nId ))
1547 {
1548 if (SfxDockingWindow* pSfxDockingWindow = dynamic_cast<SfxDockingWindow*>(pChild->GetWindow()))
1549 {
1550 // it's a DockingWindow
1551 pDockWin = pSfxDockingWindow;
1552 }
1553 else
1554 {
1555 // FloatingWindow or ModelessDialog
1556 pWin = pChild->GetWindow();
1557 }
1558 break;
1559 }
1560 }
1561
1562 if ( pDockWin )
1563 {
1565 {
1567 {
1568 // DockingWindow was dragged out of a SplitWindow
1569 pCW->pCli = RegisterChild_Impl(*pDockWin, pDockWin->GetAlignment());
1571 }
1572
1573 pWin = pDockWin;
1574 }
1575 else
1576 {
1577 SfxSplitWindow *pSplitWin = GetSplitWindow_Impl(pDockWin->GetAlignment());
1578
1579 // configure DockingWindow inside a SplitWindow
1580 if ( eConfig == SfxDockingConfig::TOGGLEFLOATMODE)
1581 {
1582 // DockingWindow was dragged into a SplitWindow
1583 pCW->pCli = nullptr;
1584 ReleaseChild_Impl(*pDockWin);
1585 }
1586
1587 pWin = pSplitWin->GetSplitWindow();
1588 if ( pSplitWin->GetWindowCount() == 1 )
1589 static_cast<SplitWindow*>(pWin)->Show( true, ShowFlags::NoFocusChange | ShowFlags::NoActivate );
1590 }
1591 }
1592
1593 DBG_ASSERT( pCW, "Unknown window!" );
1594
1595 if ( !bSorted )
1596 // windows may have been registered and released without an update until now
1597 Sort_Impl();
1598
1599 decltype(aSortedList)::size_type n;
1600 for ( n=0; n<aSortedList.size(); ++n )
1601 {
1602 SfxChild_Impl *pChild = aChildren[aSortedList[n]].get();
1603 if ( pChild && pChild->pWin == pWin )
1604 break;
1605 }
1606
1607 if ( n < aSortedList.size() )
1608 // sometimes called while toggling float mode
1609 nPos = aSortedList[n];
1610
1611 switch ( eConfig )
1612 {
1614 {
1615 if (nPos == USHRT_MAX || !pDockWin)
1616 return;
1617
1618 tools::Rectangle aOuterRect( GetTopRect_Impl() );
1619 aOuterRect.SetPos( pWorkWin->OutputToScreenPixel( aOuterRect.TopLeft() ));
1620 tools::Rectangle aInnerRect( aOuterRect );
1621
1622 // The current affected window is included in the calculation of
1623 // the inner rectangle!
1624 for (sal_uInt16 i : aSortedList)
1625 {
1626 SfxChild_Impl* pCli = aChildren[i].get();
1627
1628 if ( pCli && pCli->nVisible == SfxChildVisibility::VISIBLE && pCli->pWin )
1629 {
1630 switch ( pCli->eAlign )
1631 {
1633 // Object-Toolboxes come always last
1634 aInnerRect.AdjustTop(pCli->aSize.Height() );
1635 break;
1636
1638 // Always performed first
1639 aInnerRect.AdjustTop(pCli->aSize.Height() );
1640 break;
1641
1643 // Is only counted if it is the current window
1644 if ( i == nPos )
1645 aInnerRect.AdjustTop(pCli->aSize.Height() );
1646 break;
1647
1649 // Object-Toolboxes come always last
1650 aInnerRect.AdjustBottom( -(pCli->aSize.Height()) );
1651 break;
1652
1654 // Always performed first
1655 aInnerRect.AdjustBottom( -(pCli->aSize.Height()) );
1656 break;
1657
1659 // Is only counted if it is the current window
1660 if ( i == nPos )
1661 aInnerRect.AdjustBottom( -(pCli->aSize.Height()) );
1662 break;
1663
1665 // Toolboxes come always last
1666 aInnerRect.AdjustLeft(pCli->aSize.Width() );
1667 break;
1668
1670 // Always performed first
1671 aInnerRect.AdjustLeft(pCli->aSize.Width() );
1672 break;
1673
1675 // Is only counted if it is the current window
1676 if (i == nPos)
1677 aInnerRect.AdjustLeft(pCli->aSize.Width() );
1678 break;
1679
1681 // Toolboxes come always last
1682 aInnerRect.AdjustRight( -(pCli->aSize.Width()) );
1683 break;
1684
1686 // Is only counted if it is the current window
1687 if (i == nPos)
1688 aInnerRect.AdjustRight( -(pCli->aSize.Width()) );
1689 break;
1690
1692 // Always performed first
1693 aInnerRect.AdjustRight( -(pCli->aSize.Width()) );
1694 break;
1695
1696 default:
1697 break;
1698 }
1699 }
1700 }
1701
1702 pDockWin->SetDockingRects(aOuterRect, aInnerRect);
1703 break;
1704 }
1705
1708 {
1709 if ( nPos == USHRT_MAX && !pCW )
1710 return;
1711
1713 SfxChild_Impl *pCli = ( nPos != USHRT_MAX ) ? aChildren[nPos].get() : nullptr;
1714 if ( pCli && pDockWin )
1715 {
1716 eAlign = pDockWin->GetAlignment();
1718 {
1719 // configuration inside the SplitWindow, no change for the SplitWindows' configuration
1720 pCli->bResize = true;
1721 pCli->aSize = pDockWin->GetSizePixel();
1722 }
1723 }
1724
1725 if ( pCli )
1726 {
1727 if( pCli->eAlign != eAlign )
1728 {
1729 bSorted = false;
1730 pCli->eAlign = eAlign;
1731 }
1732
1735 }
1736
1737 if ( pCW && pCW->pWin )
1738 {
1739 // store changed configuration
1740 SfxChildWindowFlags nFlags = pCW->aInfo.nFlags;
1741 pCW->aInfo = pCW->pWin->GetInfo();
1742 pCW->aInfo.nFlags |= nFlags;
1743 SaveStatus_Impl( pCW->pWin, pCW->aInfo);
1744 }
1745
1746 break;
1747 }
1748 }
1749}
1750
1751
1752void SfxWorkWindow::SetChildWindowVisible_Impl( sal_uInt32 lId, bool bEnabled, SfxVisibilityFlags nMode )
1753{
1754 sal_uInt16 nId = static_cast<sal_uInt16>( lId & 0xFFFF );
1755
1756 SfxChildWin_Impl *pCW=nullptr;
1757
1758 if ( !pCW )
1759 {
1760 // If no Parent or the Parent us still unknown, then search here
1761 sal_uInt16 nCount = aChildWins.size();
1762 for (sal_uInt16 n=0; n<nCount; n++)
1763 if (aChildWins[n]->nSaveId == nId)
1764 {
1765 pCW = aChildWins[n].get();
1766 break;
1767 }
1768 }
1769
1770 if ( !pCW )
1771 {
1772 // If new, then initialize, add this here depending on the flag or
1773 // the Parent
1774 pCW = new SfxChildWin_Impl( lId );
1775 pCW->nId = nId;
1776 InitializeChild_Impl( pCW );
1777 aChildWins.push_back( std::unique_ptr<SfxChildWin_Impl>(pCW) );
1778 }
1779
1780 pCW->nId = nId;
1781 pCW->nVisibility = nMode;
1782 pCW->bEnable = bEnabled;
1783}
1784
1785
1786// The on/off status of a ChildWindow is switched
1787
1788void SfxWorkWindow::ToggleChildWindow_Impl(sal_uInt16 nId, bool bSetFocus)
1789{
1790 sal_uInt16 nCount = aChildWins.size();
1791 sal_uInt16 n;
1792 for (n=0; n<nCount; n++)
1793 if (aChildWins[n]->nId == nId)
1794 break;
1795
1796 if ( n<nCount )
1797 {
1798 // The Window is already known
1799 SfxChildWin_Impl *pCW = aChildWins[n].get();
1800 SfxChildWindow *pChild = pCW->pWin;
1801
1802 bool bCreationAllowed( true );
1804 {
1805 // Special case for all non-floatable child windows. We have
1806 // to prevent the creation here!
1807 bCreationAllowed = !( pCW->aInfo.nFlags & SfxChildWindowFlags::FORCEDOCK );
1808 }
1809
1810 if ( bCreationAllowed )
1811 {
1812 if ( pCW->bCreate )
1813 {
1814 if ( pChild )
1815 {
1816 if ( pChild->QueryClose() )
1817 {
1818 pCW->bCreate = false;
1819 // The Window should be switched off
1820 pChild->SetVisible_Impl( false );
1821 RemoveChildWin_Impl( pCW );
1822 }
1823 }
1824 else
1825 {
1826 // no actual Window exists, yet => just remember the "switched off" state
1827 pCW->bCreate = false;
1828 }
1829 }
1830 else
1831 {
1832 pCW->bCreate = true;
1833 if ( pChild )
1834 {
1835 ShowChildWindow_Impl( nId, true, bSetFocus );
1836 }
1837 else
1838 {
1839 // create actual Window
1840 CreateChildWin_Impl( pCW, bSetFocus );
1841 if ( !pCW->pWin )
1842 // no success
1843 pCW->bCreate = false;
1844 }
1845 }
1846 }
1847
1850
1851 if ( pCW->bCreate && bCreationAllowed )
1852 {
1853 if ( !pCW->pCli )
1854 {
1855 SfxDockingWindow *pDock =
1856 static_cast<SfxDockingWindow*>( pCW->pWin->GetWindow() );
1857 if ( pDock->IsAutoHide_Impl() )
1858 pDock->AutoShow_Impl();
1859 }
1860 }
1861
1862 return;
1863 }
1864
1865#ifdef DBG_UTIL
1866 nCount = aChildWins.size();
1867 for (n=0; n<nCount; n++)
1868 if (aChildWins[n]->nSaveId == nId)
1869 break;
1870
1871 if ( n < nCount )
1872 {
1873 OSL_FAIL("The ChildWindow is not in context!");
1874 }
1875 else
1876 {
1877 OSL_FAIL("The ChildWindow is not registered!");
1878 }
1879#endif
1880}
1881
1882
1884{
1885 sal_uInt16 nCount = aChildWins.size();
1886 sal_uInt16 n;
1887 for (n=0; n<nCount; n++)
1888 if (aChildWins[n]->nSaveId == nId)
1889 break;
1890
1891 if (n<nCount)
1892 {
1893 SfxChildWin_Impl *pCW = aChildWins[n].get();
1894 SfxChildWindow *pChild = pCW->pWin;
1895 return ( pChild && pCW->bCreate );
1896 }
1897
1898 return false;
1899}
1900
1901bool SfxWorkWindow::IsFloating( sal_uInt16 nId )
1902{
1903 SfxChildWin_Impl *pCW=nullptr;
1904
1905 if ( !pCW )
1906 {
1907 // If no Parent or the Parent us still unknown, then search here
1908 sal_uInt16 nCount = aChildWins.size();
1909 for (sal_uInt16 n=0; n<nCount; n++)
1910 if (aChildWins[n]->nSaveId == nId)
1911 {
1912 pCW = aChildWins[n].get();
1913 break;
1914 }
1915 }
1916
1917 if ( !pCW )
1918 {
1919 // If new, then initialize, add this here depending on the flag or
1920 // the Parent
1921 pCW = new SfxChildWin_Impl( nId );
1922 pCW->bEnable = false;
1923 pCW->nId = 0;
1925 InitializeChild_Impl( pCW );
1926 aChildWins.push_back( std::unique_ptr<SfxChildWin_Impl>(pCW) );
1927 }
1928
1929 SfxChildAlignment eAlign;
1930 if ( pCW->aInfo.GetExtraData_Impl( &eAlign ) )
1931 return( eAlign == SfxChildAlignment::NOALIGNMENT );
1932 else
1933 return true;
1934}
1935
1936
1938{
1939 SfxChildWin_Impl *pCW=nullptr;
1940 sal_uInt16 nCount = aChildWins.size();
1941 sal_uInt16 n;
1942 for (n=0; n<nCount; n++)
1943 {
1944 pCW = aChildWins[n].get();
1945 if ( pCW->nSaveId == nId)
1946 break;
1947 }
1948
1949 if (n<nCount)
1950 {
1952 return false;
1953 return pCW->bEnable;
1954 }
1955 else
1956 return false;
1957}
1958
1959
1960void SfxWorkWindow::SetChildWindow_Impl(sal_uInt16 nId, bool bOn, bool bSetFocus)
1961{
1962 SfxChildWin_Impl *pCW=nullptr;
1963 SfxWorkWindow *pWork = nullptr;
1964
1965 if ( !pCW )
1966 {
1967 // If no Parent or the Parent us still unknown, then search here
1968 sal_uInt16 nCount = aChildWins.size();
1969 for (sal_uInt16 n=0; n<nCount; n++)
1970 if (aChildWins[n]->nSaveId == nId)
1971 {
1972 pCW = aChildWins[n].get();
1973 pWork = this;
1974 break;
1975 }
1976 }
1977
1978 if ( !pCW )
1979 {
1980 // If new, then initialize, add this here depending on the flag or
1981 // the Parent
1982 pCW = new SfxChildWin_Impl( nId );
1983 InitializeChild_Impl( pCW );
1984 if ( !pWork || pCW->aInfo.nFlags & SfxChildWindowFlags::TASK )
1985 pWork = this;
1986 pWork->aChildWins.push_back( std::unique_ptr<SfxChildWin_Impl>(pCW) );
1987 }
1988
1989 if ( pCW->bCreate != bOn )
1990 pWork->ToggleChildWindow_Impl(nId,bSetFocus);
1991}
1992
1993
1994void SfxWorkWindow::ShowChildWindow_Impl(sal_uInt16 nId, bool bVisible, bool bSetFocus)
1995{
1996 sal_uInt16 nCount = aChildWins.size();
1997 SfxChildWin_Impl* pCW=nullptr;
1998 sal_uInt16 n;
1999 for (n=0; n<nCount; n++)
2000 {
2001 pCW = aChildWins[n].get();
2002 if (pCW->nId == nId)
2003 break;
2004 }
2005
2006 if ( n<nCount )
2007 {
2008 SfxChildWindow *pChildWin = pCW->pWin;
2009 if ( pChildWin )
2010 {
2011 if ( bVisible )
2012 {
2013 if ( pCW->pCli )
2014 {
2015 pCW->pCli->bSetFocus = bSetFocus;
2017 pChildWin->Show( bSetFocus && pChildWin->WantsFocus() ? ShowFlags::NONE : ShowFlags::NoFocusChange | ShowFlags::NoActivate );
2018 }
2019 else
2020 static_cast<SfxDockingWindow*>(pChildWin->GetWindow())->Reappear_Impl();
2021
2022 }
2023 else
2024 {
2025 if ( pCW->pCli )
2026 {
2028 pCW->pWin->Hide();
2029 }
2030 else
2031 static_cast<SfxDockingWindow*>(pChildWin->GetWindow())->Disappear_Impl();
2032
2033 }
2034
2037 }
2038 else if ( bVisible )
2039 {
2040 SetChildWindow_Impl( nId, true, bSetFocus );
2041 pChildWin = pCW->pWin;
2042 }
2043
2044 if ( pChildWin )
2045 {
2046 pChildWin->SetVisible_Impl( bVisible );
2047 SfxChildWindowFlags nFlags = pCW->aInfo.nFlags;
2048 pCW->aInfo = pChildWin->GetInfo();
2049 pCW->aInfo.nFlags |= nFlags;
2050 if ( !pCW->bCreate )
2051 SaveStatus_Impl( pChildWin, pCW->aInfo );
2052 }
2053
2054 return;
2055 }
2056
2057#ifdef DBG_UTIL
2058 nCount = aChildWins.size();
2059 for (n=0; n<nCount; n++)
2060 if (aChildWins[n]->nSaveId == nId)
2061 break;
2062
2063 if ( n<nCount )
2064 {
2065 OSL_FAIL("The ChildWindow is not in context!");
2066 }
2067 else
2068 {
2069 OSL_FAIL("The ChildWindow is not registered");
2070 }
2071#endif
2072}
2073
2074
2076{
2077 sal_uInt16 nCount = aChildWins.size();
2078 sal_uInt16 n;
2079 for (n=0; n<nCount; n++)
2080 if (aChildWins[n]->nSaveId == nId)
2081 break;
2082
2083 if (n<nCount)
2084 return aChildWins[n]->pWin;
2085 return nullptr;
2086}
2087
2088
2090{
2091 for (std::unique_ptr<SfxChildWin_Impl>& pChildWin : aChildWins)
2092 {
2093 pChildWin->nId = 0;
2094 pChildWin->bEnable = false;
2095 }
2096}
2097
2098// returns the size of the area (client area) of the
2099// parent windows, in which the ChildWindow can be fitted.
2100
2102{
2104}
2105
2106
2107// Virtual method to find out if there is room for a ChildWindow in the
2108// client area of the parent.
2109
2111{
2112 return !(!IsDockingAllowed() ||
2113 aClientArea.GetWidth() < aBorder.Left() + aBorder.Right() ||
2114 aClientArea.GetHeight() < aBorder.Top() + aBorder.Bottom());
2115}
2116
2118{
2119 // The Status of the Presentation mode is not saved
2121 pChild->SaveStatus(rInfo);
2122}
2123
2125{
2127 SfxViewFrame *pViewFrame = pDisp ? pDisp->GetFrame() :nullptr;
2128 SfxModule *pMod = pViewFrame ? SfxModule::GetActiveModule(pViewFrame) :nullptr;
2129
2130 OUString sModule;
2131 if (pViewFrame)
2132 {
2133 try
2134 {
2135 uno::Reference< frame::XModuleManager2 > xModuleManager(
2136 frame::ModuleManager::create(::comphelper::getProcessComponentContext()));
2137 sModule = xModuleManager->identify(pViewFrame->GetFrame().GetFrameInterface());
2140 }
2141 catch (...)
2142 {
2143 }
2144 }
2145
2146 SfxChildWinFactory* pFact=nullptr;
2147 SfxApplication *pApp = SfxGetpApp();
2148 {
2149 pFact = pApp->GetChildWinFactoryById(pCW->nSaveId);
2150 if ( pFact )
2151 {
2152 pCW->aInfo = pFact->aInfo;
2153 pCW->aInfo.aModule = sModule;
2155 pCW->nSaveId, pCW->aInfo);
2156 pCW->bCreate = pCW->aInfo.bVisible;
2157 SfxChildWindowFlags nFlags = pFact->aInfo.nFlags;
2158 if ( nFlags & SfxChildWindowFlags::TASK )
2160 if ( nFlags & SfxChildWindowFlags::CANTGETFOCUS )
2162 if ( nFlags & SfxChildWindowFlags::FORCEDOCK )
2164 pFact->aInfo = pCW->aInfo;
2165 return;
2166 }
2167 }
2168
2169 if ( !pMod )
2170 return;
2171
2172 pFact = pMod->GetChildWinFactoryById(pCW->nSaveId);
2173 if ( !pFact )
2174 return;
2175
2176 pCW->aInfo = pFact->aInfo;
2177 pCW->aInfo.aModule = sModule;
2179 pCW->nSaveId, pCW->aInfo);
2180 pCW->bCreate = pCW->aInfo.bVisible;
2181 SfxChildWindowFlags nFlags = pFact->aInfo.nFlags;
2182 if ( nFlags & SfxChildWindowFlags::TASK )
2184 if ( nFlags & SfxChildWindowFlags::CANTGETFOCUS )
2186 if ( nFlags & SfxChildWindowFlags::FORCEDOCK )
2190 pFact->aInfo = pCW->aInfo;
2191}
2192
2194{
2195 switch ( eAlign )
2196 {
2198 return pSplit[2];
2199
2201 return pSplit[3];
2202
2204 return pSplit[0];
2205
2207 return pSplit[1];
2208
2209 default:
2210 return nullptr;
2211 }
2212}
2213
2215{
2216 bAllChildrenVisible = bVis;
2217 if ( bVis )
2218 {
2219 if ( !bSorted )
2220 Sort_Impl();
2221 for (sal_uInt16 n : aSortedList)
2222 {
2223 SfxChild_Impl* pCli = aChildren[n].get();
2226 }
2227 }
2228 else
2229 {
2230 if ( !bSorted )
2231 Sort_Impl();
2232 for (sal_uInt16 n : aSortedList)
2233 {
2234 SfxChild_Impl* pCli = aChildren[n].get();
2236 }
2237 }
2238}
2239
2241{
2242 for (const VclPtr<SfxSplitWindow> & pWin : pSplit)
2243 {
2244 if ( pWin.get() != pSplitWin && pWin->IsAutoHide( true ) )
2245 return true;
2246 }
2247 return false;
2248}
2249
2250
2252{
2254 {
2255 if ( p && p->IsAutoHide(false) )
2256 {
2257 Point aLocalPos = p->ScreenToOutputPixel( aPos );
2258 tools::Rectangle aRect( Point(), p->GetSizePixel() );
2259 if ( !aRect.Contains( aLocalPos ) )
2260 p->FadeOut();
2261 }
2262 }
2263}
2264
2266{
2267 if ( m_nLock )
2268 return;
2269
2271 for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2272 {
2273 // Either dummy window or window in the auto-show-mode are processed
2274 // (not pinned, FadeIn).
2275 // Only the abandoned window may be invisible, because perhaps its
2276 // size is just being calculated before it is displayed.
2277 VclPtr<SfxSplitWindow> const & pSplitWin = pSplit[n];
2278 bool bDummyWindow = !pSplitWin->IsFadeIn();
2279 vcl::Window *pDummy = pSplitWin->GetSplitWindow();
2280 vcl::Window *pWin = bDummyWindow ? pDummy : pSplitWin;
2281 if ( (pSplitWin->IsPinned() && !bDummyWindow) || (!pWin->IsVisible() && pActSplitWin != pSplitWin) )
2282 continue;
2283
2284 // Width and position of the dummy window as a starting point
2285 Size aSize = pDummy->GetSizePixel();
2286 Point aPos = pDummy->GetPosPixel();
2287
2288 switch ( n )
2289 {
2290 case 0 :
2291 {
2292 // Left SplitWindow
2293 // Get the width of the Window yourself, if no DummyWindow
2294 if ( !bDummyWindow )
2295 aSize.setWidth( pSplitWin->GetSizePixel().Width() );
2296
2297 // If a Window is visible to the left, then the free region
2298 // starts to the right from it, for example at the Client area
2299 tools::Long nLeft = aPos.X() + aSize.Width();
2300 if ( nLeft > aArea.Left() )
2301 aArea.SetLeft( nLeft );
2302 break;
2303 }
2304 case 1 :
2305 {
2306 // Right SplitWindow
2307 // Position to correct the difference of the widths
2308 aPos.AdjustX(aSize.Width() );
2309
2310 // Get the width of the Window yourself, if no DummyWindow
2311 if ( !bDummyWindow )
2312 aSize.setWidth( pSplitWin->GetSizePixel().Width() );
2313
2314 aPos.AdjustX( -(aSize.Width()) );
2315
2316 // If already a window is opened at the left side, then the
2317 // right is not allowed to overlap this one.
2318 if ( aPos.X() < aArea.Left() )
2319 {
2320 aPos.setX( aArea.Left() );
2321 aSize.setWidth( aArea.GetWidth() );
2322 }
2323
2324 // If a Window is visible to the right, then the free region
2325 // starts to the left from it, for example at the Client area
2326 tools::Long nRight = aPos.X();
2327 if ( !aArea.IsWidthEmpty() && nRight < aArea.Right() )
2328 aArea.SetRight( nRight );
2329 break;
2330 }
2331 case 2 :
2332 {
2333 // Top SplitWindow
2334 // Get the height of the Window yourself, if no DummyWindow
2335 if ( !bDummyWindow )
2336 aSize.setHeight( pSplitWin->GetSizePixel().Height() );
2337
2338
2339 // Adjust width with regard to if a Window is already open
2340 // to the left or right
2341 aPos.setX( aArea.Left() );
2342 aSize.setWidth( aArea.GetWidth() );
2343
2344 // If a Window is visible at the top, then the free region
2345 // starts beneath it, for example at the Client area
2346 tools::Long nTop = aPos.Y() + aSize.Height();
2347 if ( nTop > aArea.Top() )
2348 aArea.SetTop( nTop );
2349 break;
2350 }
2351 case 3 :
2352 {
2353 // The bottom SplitWindow
2354 // Position to correct the difference of the heights
2355 aPos.AdjustY(aSize.Height() );
2356
2357 // Get the height of the Window yourself, if no DummyWindow
2358 if ( !bDummyWindow )
2359 aSize.setHeight( pSplitWin->GetSizePixel().Height() );
2360
2361 aPos.AdjustY( -(aSize.Height()) );
2362
2363 // Adjust width with regard to if a Window is already open
2364 // to the left or right.
2365 aPos.setX( aArea.Left() );
2366 aSize.setWidth( aArea.GetWidth() );
2367
2368 // If already a window is opened at the top, then the
2369 // bottom one is not allowed to overlap this one.
2370 if ( aPos.Y() < aArea.Top() )
2371 {
2372 aPos.setY( aArea.Top() );
2373 aSize.setHeight( aArea.GetHeight() );
2374 }
2375
2376 break;
2377 }
2378 }
2379
2380 if ( !bDummyWindow )
2381 // the FadeIn-Window is a Floating window, which coordinates are
2382 // set in Screen coordinates.
2383 pSplitWin->SetPosSizePixel( pWorkWin->OutputToScreenPixel(aPos), aSize );
2384 else
2385 // the docked DummyWindow
2386 pDummy->SetPosSizePixel( aPos, aSize );
2387 }
2388}
2389
2391{
2392 if ( bAutoHide )
2393 {
2395 for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2396 {
2397 if ( pSplit[n]->IsPinned() || !pSplit[n]->IsVisible() )
2398 continue;
2399
2400 Size aSize = pSplit[n]->GetSizePixel();
2401 switch ( n )
2402 {
2403 case 0 :
2404 aArea.AdjustLeft(aSize.Width() );
2405 break;
2406 case 1 :
2407 aArea.AdjustRight( -(aSize.Width()) );
2408 break;
2409 case 2 :
2410 aArea.AdjustTop(aSize.Height() );
2411 break;
2412 case 3 :
2413 aArea.AdjustBottom( -(aSize.Height()) );
2414 break;
2415 }
2416 }
2417
2418 return aArea;
2419 }
2420 else
2421 return aClientArea;
2422}
2423
2425{
2426 pActiveChild = pChild;
2427}
2428
2430{
2432}
2433
2434/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyListType t
const char * pName
SfxApplication * SfxGetpApp()
Definition: app.hxx:231
SfxChildAlignment
Definition: chalign.hxx:27
bool SfxChildAlignValid(SfxChildAlignment eAlign)
Definition: chalign.hxx:48
SfxChildWindowFlags
Definition: childwin.hxx:42
const int nCloseResponseToJustHide
Definition: childwin.hxx:158
#define CHILDWIN_NOPOS
Definition: childwin.hxx:58
static bool IsUICaptured()
Size GetSizePixel() const override
SfxWorkWindow * m_pWrkWin
Definition: workwin.hxx:180
void setFrame(const css::uno::Reference< css::frame::XFrame > &rFrame)
Definition: workwin.cxx:144
virtual void SAL_CALL layoutEvent(const css::lang::EventObject &aSource, ::sal_Int16 eLayoutEvent, const css::uno::Any &aInfo) override
Definition: workwin.cxx:260
virtual void SAL_CALL dispose() override
Definition: workwin.cxx:204
virtual void SAL_CALL disposing(const css::lang::EventObject &aEvent) override
Definition: workwin.cxx:248
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: workwin.cxx:192
virtual ~LayoutManagerListener() override
Definition: workwin.cxx:140
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: workwin.cxx:198
LayoutManagerListener(SfxWorkWindow *pWrkWin)
Definition: workwin.cxx:133
css::uno::WeakReference< css::frame::XFrame > m_xFrame
Definition: workwin.hxx:181
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
SAL_DLLPRIVATE SfxChildWinFactory * GetChildWinFactoryById(sal_uInt16 nId) const
Definition: appchild.cxx:48
SAL_DLLPRIVATE SfxDispatcher * GetDispatcher_Impl()
Definition: bindings.hxx:180
SAL_DLLPRIVATE void SetWorkWindow_Impl(std::unique_ptr< SfxWorkWindow >)
Definition: bindings.cxx:1678
void Invalidate(sal_uInt16 nId)
Definition: bindings.cxx:639
bool GetValue() const
virtual void Hide()
Definition: childwin.cxx:511
bool IsHideNotDelete() const
Definition: childwin.cxx:436
void Destroy()
Definition: childwin.cxx:158
static SAL_DLLPRIVATE void InitializeChildWinFactory_Impl(sal_uInt16, SfxChildWinInfo &)
Definition: childwin.cxx:351
sal_uInt16 GetType() const
Definition: childwin.hxx:131
SAL_DLLPRIVATE void SetWorkWindow_Impl(SfxWorkWindow *)
Definition: childwin.cxx:546
void SetVisible_Impl(bool bVis)
Definition: childwin.cxx:506
virtual bool QueryClose()
Definition: childwin.cxx:565
vcl::Window * GetWindow() const
Definition: childwin.hxx:117
SfxChildAlignment GetAlignment() const
Definition: childwin.hxx:125
std::shared_ptr< SfxDialogController > & GetController()
Definition: childwin.hxx:121
void SaveStatus(const SfxChildWinInfo &rInfo)
Definition: childwin.cxx:267
static std::unique_ptr< SfxChildWindow > CreateChildWindow(sal_uInt16, vcl::Window *, SfxBindings *, SfxChildWinInfo const &)
Definition: childwin.cxx:200
virtual SfxChildWinInfo GetInfo() const
Definition: childwin.cxx:304
sal_uInt16 GetPosition() const
Definition: childwin.cxx:346
bool WantsFocus() const
Definition: childwin.cxx:446
virtual void Show(ShowFlags nFlags)
Definition: childwin.cxx:519
SfxViewFrame * GetFrame() const
Returns a pointer to the <SfxViewFrame> instance, which belongs to this SfxDispatcher.
Definition: dispatch.cxx:557
SAL_DLLPRIVATE void AutoShow_Impl()
Definition: dockwin.cxx:1512
SAL_DLLPRIVATE bool IsAutoHide_Impl() const
Definition: dockwin.cxx:1504
SfxChildAlignment GetAlignment() const
Definition: dockwin.hxx:98
void SetDockingRects(const tools::Rectangle &rOuter, const tools::Rectangle &rInner)
Definition: dockwin.hxx:92
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
Definition: frame.cxx:515
SAL_DLLPRIVATE tools::Rectangle GetTopOuterRectPixel_Impl() const
Definition: frame.cxx:582
bool IsClosing_Impl() const
Definition: frame.cxx:197
SAL_DLLPRIVATE void SetToolSpaceBorderPixel_Impl(const SvBorder &)
Definition: frame.cxx:558
SAL_WARN_UNUSED_RESULT SfxViewFrame * GetCurrentViewFrame() const
Definition: frame.cxx:234
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
SfxItemSet & GetItemSet() const
Definition: docfile.cxx:3647
static SfxModule * GetActiveModule(SfxViewFrame *pFrame=nullptr)
Definition: module.cxx:208
SAL_DLLPRIVATE SfxChildWinFactory * GetChildWinFactoryById(sal_uInt16 nId) const
Definition: module.cxx:188
SfxMedium * GetMedium() const
Definition: objsh.hxx:261
bool IsInPlaceActive() const
Definition: objmisc.cxx:1676
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
Definition: shell.hxx:128
virtual SfxObjectShell * GetObjectShell()
Definition: shell.cxx:649
SfxViewShell * GetViewShell() const
Returns the SfxViewShell in which they are located in the subshells.
Definition: shell.cxx:129
SplitWindow * GetSplitWindow()
Definition: splitwin.cxx:1002
bool IsAutoHide(bool bSelf) const
Definition: splitwin.cxx:1015
sal_uInt16 GetWindowCount(sal_uInt16 nLine) const
Definition: splitwin.cxx:880
SfxFrame & GetFrame() const
Definition: viewfrm.cxx:2782
virtual SfxObjectShell * GetObjectShell() override
Definition: viewfrm.cxx:2218
SfxInPlaceClient * GetIPClient() const
Definition: viewsh.cxx:1494
SfxStatBar_Impl aStatBar
Definition: workwin.hxx:189
std::vector< SfxObjectBar_Impl > aObjBarList
Definition: workwin.hxx:190
std::vector< std::unique_ptr< SfxChildWin_Impl > > aChildWins
Definition: workwin.hxx:197
tools::Rectangle aUpperClientArea
Definition: workwin.hxx:192
SfxWorkWindow(vcl::Window *pWin, SfxFrame *pFrm, SfxFrame *pMaster)
Definition: workwin.cxx:445
void ArrangeChildren_Impl(bool bForce=true)
Definition: workwin.cxx:654
void MakeVisible_Impl(bool)
Definition: workwin.cxx:1482
void UpdateObjectBars_Impl()
Definition: workwin.cxx:1091
void ResetObjectBars_Impl()
Definition: workwin.cxx:1045
SfxSplitWindow * GetSplitWindow_Impl(SfxChildAlignment)
Definition: workwin.cxx:2193
bool bShowStatusBar
Definition: workwin.hxx:209
void UpdateObjectBars_Impl2()
Definition: workwin.cxx:1164
void SetActiveChild_Impl(vcl::Window *pChild)
Definition: workwin.cxx:2424
void HidePopups_Impl(bool bHide, sal_uInt16 nId=0)
Definition: workwin.cxx:1499
bool PrepareClose_Impl()
Definition: workwin.cxx:863
bool IsFloating(sal_uInt16 nId)
Definition: workwin.cxx:1901
bool bDockingAllowed
Definition: workwin.hxx:205
void ReleaseChild_Impl(vcl::Window &rWindow)
Definition: workwin.cxx:909
void ConfigChild_Impl(SfxChildIdentifier, SfxDockingConfig, sal_uInt16)
Definition: workwin.cxx:1533
bool HasChildWindow_Impl(sal_uInt16)
Definition: workwin.cxx:1883
void DataChanged_Impl()
Definition: workwin.cxx:2429
bool IsDockingAllowed() const
Definition: workwin.hxx:239
void EndAutoShow_Impl(Point aPos)
Definition: workwin.cxx:2251
void SetStatusBar_Impl(StatusBarId eResId)
Definition: workwin.cxx:1449
SfxBindings & GetBindings()
Definition: workwin.hxx:230
void MakeChildrenVisible_Impl(bool bVis)
Definition: workwin.cxx:2214
SfxChild_Impl * RegisterChild_Impl(vcl::Window &rWindow, SfxChildAlignment eAlign)
Definition: workwin.cxx:875
bool IsVisible_Impl() const
Definition: workwin.cxx:1493
void CreateChildWin_Impl(SfxChildWin_Impl *, bool)
Definition: workwin.cxx:1346
void HideChildren_Impl()
Definition: workwin.cxx:1031
VclPtr< vcl::Window > pWorkWin
Definition: workwin.hxx:199
void RemoveChildWin_Impl(SfxChildWin_Impl *)
Definition: workwin.cxx:1408
void ResetChildWindows_Impl()
Definition: workwin.cxx:2089
bool KnowsChildWindow_Impl(sal_uInt16)
Definition: workwin.cxx:1937
void ShowChildren_Impl()
Definition: workwin.cxx:961
std::vector< sal_uInt16 > aSortedList
Definition: workwin.hxx:188
void SetObjectBar_Impl(sal_uInt16 nPos, SfxVisibilityFlags nFlags, ToolbarId eId)
Definition: workwin.cxx:1054
void SetChildWindow_Impl(sal_uInt16, bool bOn, bool bSetFocus)
Definition: workwin.cxx:1960
sal_uInt16 nChildren
Definition: workwin.hxx:202
css::uno::Reference< css::task::XStatusIndicator > GetStatusIndicator()
Definition: workwin.cxx:1107
SvBorder Arrange_Impl()
Definition: workwin.cxx:704
SfxChild_Impl * FindChild_Impl(const vcl::Window *rWindow) const
Definition: workwin.cxx:947
bool bInternalDockingAllowed
Definition: workwin.hxx:206
bool bIsFullScreen
Definition: workwin.hxx:208
void SetChildWindowVisible_Impl(sal_uInt32, bool, SfxVisibilityFlags)
Definition: workwin.cxx:1752
css::uno::Reference< css::frame::XFrame > GetFrameInterface()
Definition: workwin.cxx:1148
VclPtr< vcl::Window > pActiveChild
Definition: workwin.hxx:200
void SaveStatus_Impl(SfxChildWindow *, const SfxChildWinInfo &)
Definition: workwin.cxx:2117
tools::Rectangle GetTopRect_Impl() const
Definition: workwin.cxx:2101
friend class LayoutManagerListener
Definition: workwin.hxx:186
bool IsAutoHideMode(const SfxSplitWindow *pSplit)
Definition: workwin.cxx:2240
SfxFrame * pFrame
Definition: workwin.hxx:213
tools::Rectangle GetFreeArea(bool bAutoHide) const
Definition: workwin.cxx:2390
SfxVisibilityFlags nUpdateMode
Definition: workwin.hxx:201
css::uno::Reference< css::lang::XComponent > m_xLayoutManagerListener
Definition: workwin.hxx:211
void InitializeChild_Impl(SfxChildWin_Impl *)
Definition: workwin.cxx:2124
tools::Rectangle aClientArea
Definition: workwin.hxx:191
SfxBindings * pBindings
Definition: workwin.hxx:198
void ShowChildWindow_Impl(sal_uInt16, bool bVisible, bool bSetFocus)
Definition: workwin.cxx:1994
bool RequestTopToolSpacePixel_Impl(SvBorder aBorder)
Definition: workwin.cxx:2110
VclPtr< SfxSplitWindow > pSplit[SFX_SPLITWINDOWS_MAX]
Definition: workwin.hxx:193
void Lock_Impl(bool)
Definition: workwin.cxx:533
void ResetStatusBar_Impl()
Definition: workwin.cxx:1444
void UpdateStatusBar_Impl()
Definition: workwin.cxx:1455
bool bAllChildrenVisible
Definition: workwin.hxx:207
void UpdateChildWindows_Impl()
Definition: workwin.cxx:1258
std::vector< std::unique_ptr< SfxChild_Impl > > aChildren
Definition: workwin.hxx:195
void DeleteControllers_Impl()
Definition: workwin.cxx:556
sal_Int32 m_nLock
Definition: workwin.hxx:210
SfxChildWindow * GetChildWindow_Impl(sal_uInt16)
Definition: workwin.cxx:2075
void ArrangeAutoHideWindows(SfxSplitWindow *pSplit)
Definition: workwin.cxx:2265
static bool IsPluginMode(SfxObjectShell const *pObjShell)
Definition: workwin.cxx:1135
SfxFrame * pMasterFrame
Definition: workwin.hxx:212
void ToggleChildWindow_Impl(sal_uInt16, bool)
Definition: workwin.cxx:1788
SfxVisibilityFlags nOrigMode
Definition: workwin.hxx:203
void Sort_Impl()
Definition: workwin.cxx:419
void FlushPendingChildSizes()
Definition: workwin.cxx:689
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
tools::Long & Left()
tools::Long & Top()
tools::Long & Right()
tools::Long & Bottom()
static OUString GetFactoryShortName(EFactory eFactory)
static EFactory ClassifyFactoryByServiceName(std::u16string_view sName)
reference_type * get() const
static VclPtr< reference_type > Create(Arg &&... arg)
static bool IsActive(bool bConsiderSingleToolbar=false)
constexpr tools::Long GetWidth() const
bool Contains(const Point &rPOINT) const
constexpr void SetLeft(tools::Long v)
constexpr void SetTop(tools::Long v)
constexpr tools::Long Top() const
constexpr Point TopLeft() const
void SetPos(const Point &rPoint)
constexpr void SetRight(tools::Long v)
constexpr tools::Long Right() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
constexpr bool IsWidthEmpty() const
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr void SetBottom(tools::Long v)
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
static bool IsFuzzing()
vcl::Window * GetParent() const
void ReleaseLOKNotifier()
virtual Point GetPosPixel() const
void SetParent(vcl::Window *pNewParent)
virtual Size GetSizePixel() const
bool IsVisible() const
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
int nCount
#define DBG_ASSERT(sCon, aError)
virtual SfxBindings & GetBindings() override
float u
sal_Int32 nIndex
void * p
sal_Int64 n
sal_uInt16 nPos
Definition: linksrc.cxx:118
#define SAL_WARN(area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
SfxDispatcher * GetDispatcher()
@ Exception
int i
Invisible
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
long Long
StatusBarId
Definition: objface.hxx:45
#define SFX_OBJECTBAR_APPLICATION
Definition: objface.hxx:33
#define SFX_OBJECTBAR_MAX
Definition: objface.hxx:42
#define SFX_OBJECTBAR_COMMONTASK
Definition: objface.hxx:39
#define SFX_OBJECTBAR_OPTIONS
Definition: objface.hxx:40
#define SFX_OBJECTBAR_OBJECT
Definition: objface.hxx:34
#define SFX_OBJECTBAR_TOOLS
Definition: objface.hxx:35
#define SFX_OBJECTBAR_RECORDING
Definition: objface.hxx:38
#define SFX_OBJECTBAR_MACRO
Definition: objface.hxx:36
#define SFX_OBJECTBAR_FULLSCREEN
Definition: objface.hxx:37
sal_Int16 nId
SfxVisibilityFlags
Definition: shell.hxx:573
SfxChildWinInfo aInfo
Definition: childwin.hxx:88
OUString aModule
Definition: childwin.hxx:64
SfxChildWindowFlags nFlags
Definition: childwin.hxx:68
OUString aExtraString
Definition: childwin.hxx:63
bool GetExtraData_Impl(SfxChildAlignment *pAlign) const
Definition: childwin.cxx:452
SfxVisibilityFlags nVisibility
Definition: workwin.hxx:117
sal_uInt16 nSaveId
Definition: workwin.hxx:111
SfxChild_Impl * pCli
Definition: workwin.hxx:116
SfxChildWinInfo aInfo
Definition: workwin.hxx:115
SfxChildWindow * pWin
Definition: workwin.hxx:113
sal_uInt16 nId
Definition: workwin.hxx:112
bool bResize
Definition: workwin.hxx:89
SfxChildAlignment eAlign
Definition: workwin.hxx:87
std::shared_ptr< SfxDialogController > xController
Definition: workwin.hxx:85
VclPtr< vcl::Window > pWin
Definition: workwin.hxx:84
SfxChildVisibility nVisible
Definition: workwin.hxx:88
bool bSetFocus
Definition: workwin.hxx:90
ToolbarId eId
Definition: workwin.hxx:46
SfxVisibilityFlags nMode
Definition: workwin.hxx:47
StatusBarId eId
Definition: workwin.hxx:61
Reference< XController > xController
Reference< XFrame > xFrame
ToolbarId
Definition: toolbarids.hxx:18
@ Basicide_Objectbar
@ Draw_Viewer_Toolbox
@ Objectbar_Format
@ Webgraphic_Toolbox
@ Draw_Text_Toolbox_Sw
@ Draw_Obj_Toolbox
@ FullScreenToolbox
@ Webtools_Toolbox
@ FormLayer_Toolbox
@ SvxTbx_Form_Filter
@ SvxTbx_Text_Control_Attributes
@ Bezier_Toolbox_Sw
@ Bezier_Toolbox_Sd
@ Draw_Text_Toolbox_Sd
@ Draw_CommonTask_Toolbox
@ Graphic_Objectbar
@ Objectbar_Preview
@ Draw_Options_Toolbox
@ Svx_Fontwork_Bar
@ Graphic_Obj_Toolbox
@ SvxTbx_FormDesign
@ Gluepoints_Toolbox
@ Svx_Extrusion_Bar
@ Draw_Media_Toolbox
@ SvxTbx_Form_Navigation
@ Draw_Graf_Toolbox
@ Slide_Obj_Toolbox
@ Webframe_Toolbox
bool bVisible
#define sal_False
ShowFlags
RET_CLOSE
static OUString GetResourceURLFromToolbarId(ToolbarId eId)
Definition: workwin.cxx:329
constexpr OUStringLiteral g_aLayoutManagerPropName
Definition: workwin.cxx:130
const ResIdToResName pToolBarResToName[]
Definition: workwin.cxx:70
static sal_uInt16 TbxMatch(sal_uInt16 nPos)
Definition: workwin.cxx:335
constexpr OUStringLiteral g_aTbxTypeName(u"private:resource/toolbar/")
constexpr OUStringLiteral g_aProgressBarResName(u"private:resource/progressbar/progressbar")
static sal_uInt16 ChildAlignValue(SfxChildAlignment eAlign)
Definition: workwin.cxx:358
constexpr OUStringLiteral g_aStatusBarResName(u"private:resource/statusbar/statusbar")
#define SFX_SPLITWINDOWS_LEFT
Definition: workwin.hxx:145
#define SFX_SPLITWINDOWS_TOP
Definition: workwin.hxx:146
#define SFX_SPLITWINDOWS_MAX
Definition: workwin.hxx:148
#define SFX_SPLITWINDOWS_RIGHT
Definition: workwin.hxx:147
SfxDockingConfig
Definition: workwin.hxx:138
SfxChildVisibility
Definition: workwin.hxx:69
SfxChildIdentifier
Definition: workwin.hxx:132