1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_framework.hxx"
31 //_________________________________________________________________________________________________________________
33 //_________________________________________________________________________________________________________________
34 #include <helper/dockingareadefaultacceptor.hxx>
35 #include <threadhelp/resetableguard.hxx>
37 //_________________________________________________________________________________________________________________
39 //_________________________________________________________________________________________________________________
40 #include <com/sun/star/awt/XDevice.hpp>
41 #include <com/sun/star/awt/PosSize.hpp>
42 #include <com/sun/star/awt/XLayoutConstrains.hpp>
44 //_________________________________________________________________________________________________________________
45 // includes of other projects
46 //_________________________________________________________________________________________________________________
48 #include <vcl/svapp.hxx>
50 //_________________________________________________________________________________________________________________
52 //_________________________________________________________________________________________________________________
56 using namespace ::com::sun::star::container
;
57 using namespace ::com::sun::star::frame
;
58 using namespace ::com::sun::star::lang
;
59 using namespace ::com::sun::star::uno
;
60 using namespace ::cppu
;
61 using namespace ::osl
;
62 using namespace ::rtl
;
64 //_________________________________________________________________________________________________________________
66 //_________________________________________________________________________________________________________________
68 //_________________________________________________________________________________________________________________
69 // non exported definitions
70 //_________________________________________________________________________________________________________________
72 //_________________________________________________________________________________________________________________
74 //_________________________________________________________________________________________________________________
76 //*****************************************************************************************************************
78 //*****************************************************************************************************************
79 DockingAreaDefaultAcceptor::DockingAreaDefaultAcceptor( const Reference
< XFrame
>& xOwner
)
80 // Init baseclasses first
81 : ThreadHelpBase ( &Application::GetSolarMutex() )
87 //*****************************************************************************************************************
89 //*****************************************************************************************************************
90 DockingAreaDefaultAcceptor::~DockingAreaDefaultAcceptor()
94 //*****************************************************************************************************************
95 // XDockingAreaAcceptor
96 //*****************************************************************************************************************
97 css::uno::Reference
< css::awt::XWindow
> SAL_CALL
DockingAreaDefaultAcceptor::getContainerWindow() throw (css::uno::RuntimeException
)
99 // Ready for multithreading
100 ResetableGuard
aGuard( m_aLock
);
102 // Try to "lock" the frame for access to taskscontainer.
103 Reference
< XFrame
> xFrame( m_xOwner
.get(), UNO_QUERY
);
104 Reference
< css::awt::XWindow
> xContainerWindow( xFrame
->getContainerWindow() );
106 return xContainerWindow
;
109 sal_Bool SAL_CALL
DockingAreaDefaultAcceptor::requestDockingAreaSpace( const css::awt::Rectangle
& RequestedSpace
) throw (css::uno::RuntimeException
)
111 // Ready for multithreading
112 ResetableGuard
aGuard( m_aLock
);
114 // Try to "lock" the frame for access to taskscontainer.
115 Reference
< XFrame
> xFrame( m_xOwner
.get(), UNO_QUERY
);
118 if ( xFrame
.is() == sal_True
)
120 Reference
< css::awt::XWindow
> xContainerWindow( xFrame
->getContainerWindow() );
121 Reference
< css::awt::XWindow
> xComponentWindow( xFrame
->getComponentWindow() );
123 if (( xContainerWindow
.is() == sal_True
) &&
124 ( xComponentWindow
.is() == sal_True
) )
126 css::uno::Reference
< css::awt::XDevice
> xDevice( xContainerWindow
, css::uno::UNO_QUERY
);
127 // Convert relativ size to output size.
128 css::awt::Rectangle aRectangle
= xContainerWindow
->getPosSize();
129 css::awt::DeviceInfo aInfo
= xDevice
->getInfo();
130 css::awt::Size
aSize ( aRectangle
.Width
- aInfo
.LeftInset
- aInfo
.RightInset
,
131 aRectangle
.Height
- aInfo
.TopInset
- aInfo
.BottomInset
);
133 // client size of container window
134 // css::uno::Reference< css::awt::XLayoutConstrains > xLayoutContrains( xComponentWindow, css::uno::UNO_QUERY );
135 css::awt::Size
aMinSize( 0, 0 ); // = xLayoutContrains->getMinimumSize();
137 // Check if request border space would decrease component window size below minimum size
138 if ((( aSize
.Width
- RequestedSpace
.X
- RequestedSpace
.Width
) < aMinSize
.Width
) ||
139 (( aSize
.Height
- RequestedSpace
.Y
- RequestedSpace
.Height
) < aMinSize
.Height
) )
149 void SAL_CALL
DockingAreaDefaultAcceptor::setDockingAreaSpace( const css::awt::Rectangle
& BorderSpace
) throw (css::uno::RuntimeException
)
151 // Ready for multithreading
152 ResetableGuard
aGuard( m_aLock
);
154 // Try to "lock" the frame for access to taskscontainer.
155 Reference
< XFrame
> xFrame( m_xOwner
.get(), UNO_QUERY
);
156 if ( xFrame
.is() == sal_True
)
158 Reference
< css::awt::XWindow
> xContainerWindow( xFrame
->getContainerWindow() );
159 Reference
< css::awt::XWindow
> xComponentWindow( xFrame
->getComponentWindow() );
161 if (( xContainerWindow
.is() == sal_True
) &&
162 ( xComponentWindow
.is() == sal_True
) )
164 css::uno::Reference
< css::awt::XDevice
> xDevice( xContainerWindow
, css::uno::UNO_QUERY
);
165 // Convert relativ size to output size.
166 css::awt::Rectangle aRectangle
= xContainerWindow
->getPosSize();
167 css::awt::DeviceInfo aInfo
= xDevice
->getInfo();
168 css::awt::Size
aSize ( aRectangle
.Width
- aInfo
.LeftInset
- aInfo
.RightInset
,
169 aRectangle
.Height
- aInfo
.TopInset
- aInfo
.BottomInset
);
170 // client size of container window
171 // css::uno::Reference< css::awt::XLayoutConstrains > xLayoutContrains( xComponentWindow, css::uno::UNO_QUERY );
172 css::awt::Size
aMinSize( 0, 0 );// = xLayoutContrains->getMinimumSize();
174 // Check if request border space would decrease component window size below minimum size
175 sal_Int32 nWidth
= aSize
.Width
- BorderSpace
.X
- BorderSpace
.Width
;
176 sal_Int32 nHeight
= aSize
.Height
- BorderSpace
.Y
- BorderSpace
.Height
;
178 if (( nWidth
> aMinSize
.Width
) && ( nHeight
> aMinSize
.Height
))
180 // Resize our component window.
181 xComponentWindow
->setPosSize( BorderSpace
.X
, BorderSpace
.Y
, nWidth
, nHeight
, css::awt::PosSize::POSSIZE
);
187 } // namespace framework