1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "PaneDockingWindow.hxx"
28 #include "Window.hxx"
29 #include "ViewShellBase.hxx"
30 #include "framework/FrameworkHelper.hxx"
31 #include "sdresid.hxx"
32 #include "res_bmp.hrc"
33 #include <sfx2/dispatch.hxx>
34 #include <vcl/toolbox.hxx>
35 #include <vcl/taskpanelist.hxx>
36 #include <vcl/splitwin.hxx>
37 #include <vcl/svapp.hxx>
38 #include <tools/wintypes.hxx>
39 #include <boost/bind.hpp>
40 
41 using namespace ::com::sun::star;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::drawing::framework;
44 using ::sfx2::TitledDockingWindow;
45 
46 namespace sd {
47 
PaneDockingWindow(SfxBindings * _pBindings,SfxChildWindow * pChildWindow,::Window * pParent,const ResId & rResId,const::rtl::OUString & rsTitle)48 PaneDockingWindow::PaneDockingWindow(
49         SfxBindings *_pBindings, SfxChildWindow *pChildWindow, ::Window* pParent,
50         const ResId& rResId, const ::rtl::OUString& rsTitle )
51         :TitledDockingWindow( _pBindings, pChildWindow, pParent, rResId )
52 {
53     SetTitle( rsTitle );
54 }
55 
~PaneDockingWindow(void)56 PaneDockingWindow::~PaneDockingWindow (void)
57 {
58 }
59 
StateChanged(StateChangedType nType)60 void PaneDockingWindow::StateChanged( StateChangedType nType )
61 {
62     switch (nType)
63     {
64         case STATE_CHANGE_INITSHOW:
65             Resize();
66             GetContentWindow().SetStyle(GetContentWindow().GetStyle() | WB_DIALOGCONTROL);
67             break;
68 
69         case STATE_CHANGE_VISIBLE:
70             // The visibility of the docking window has changed.  Tell the
71             // ConfigurationController so that it can activate or deactivate
72             // a/the view for the pane.
73             // Without this the side panes remain empty after closing an
74             // in-place slide show.
75             ViewShellBase* pBase = ViewShellBase::GetViewShellBase(
76                 GetBindings().GetDispatcher()->GetFrame());
77             if (pBase != NULL)
78             {
79                 framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration();
80             }
81             break;
82     }
83     SfxDockingWindow::StateChanged (nType);
84 }
85 
MouseButtonDown(const MouseEvent & rEvent)86 void PaneDockingWindow::MouseButtonDown (const MouseEvent& rEvent)
87 {
88     if (rEvent.GetButtons() == MOUSE_LEFT)
89     {
90         // For some strange reason we have to set the WB_DIALOGCONTROL at
91         // the content window in order to have it pass focus to its content
92         // window.  Without setting this flag here that works only on views
93         // that have not been taken from the cash and relocated to this pane
94         // docking window.
95         GetContentWindow().SetStyle(GetContentWindow().GetStyle() | WB_DIALOGCONTROL);
96         GetContentWindow().GrabFocus();
97     }
98     SfxDockingWindow::MouseButtonDown(rEvent);
99 }
100 
101 
102 
103 
104 
105 
106 
107 
SetValidSizeRange(const Range aValidSizeRange)108 void PaneDockingWindow::SetValidSizeRange (const Range aValidSizeRange)
109 {
110     SplitWindow* pSplitWindow = dynamic_cast<SplitWindow*>(GetParent());
111     if (pSplitWindow != NULL)
112     {
113         const sal_uInt16 nId (pSplitWindow->GetItemId(static_cast< ::Window*>(this)));
114         const sal_uInt16 nSetId (pSplitWindow->GetSet(nId));
115         // Because the PaneDockingWindow paints its own decoration, we have
116         // to compensate the valid size range for that.
117         const SvBorder aBorder (GetDecorationBorder());
118         sal_Int32 nCompensation (pSplitWindow->IsHorizontal()
119             ? mnTitleBarHeight + aBorder.Top() + aBorder.Bottom()
120             : aBorder.Left() + aBorder.Right());
121         pSplitWindow->SetItemSizeRange(
122             nSetId,
123             Range(
124                 aValidSizeRange.Min() + nCompensation,
125                 aValidSizeRange.Max() + nCompensation));
126     }
127 }
128 
129 
130 
131 
GetOrientation(void) const132 PaneDockingWindow::Orientation PaneDockingWindow::GetOrientation (void) const
133 {
134     SplitWindow* pSplitWindow = dynamic_cast<SplitWindow*>(GetParent());
135     if (pSplitWindow == NULL)
136         return UnknownOrientation;
137     else if (pSplitWindow->IsHorizontal())
138         return HorizontalOrientation;
139     else
140         return VerticalOrientation;
141 }
142 
143 } // end of namespace ::sd
144