1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dockingareadefaultacceptor.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
37 #include <helper/dockingareadefaultacceptor.hxx>
38 #include <threadhelp/resetableguard.hxx>
40 //_________________________________________________________________________________________________________________
42 //_________________________________________________________________________________________________________________
43 #include <com/sun/star/awt/XDevice.hpp>
44 #include <com/sun/star/awt/PosSize.hpp>
45 #include <com/sun/star/awt/XLayoutConstrains.hpp>
47 //_________________________________________________________________________________________________________________
48 // includes of other projects
49 //_________________________________________________________________________________________________________________
51 #include <vcl/svapp.hxx>
53 //_________________________________________________________________________________________________________________
55 //_________________________________________________________________________________________________________________
59 using namespace ::com::sun::star::container
;
60 using namespace ::com::sun::star::frame
;
61 using namespace ::com::sun::star::lang
;
62 using namespace ::com::sun::star::uno
;
63 using namespace ::cppu
;
64 using namespace ::osl
;
65 using namespace ::rtl
;
67 //_________________________________________________________________________________________________________________
69 //_________________________________________________________________________________________________________________
71 //_________________________________________________________________________________________________________________
72 // non exported definitions
73 //_________________________________________________________________________________________________________________
75 //_________________________________________________________________________________________________________________
77 //_________________________________________________________________________________________________________________
79 //*****************************************************************************************************************
81 //*****************************************************************************************************************
82 DockingAreaDefaultAcceptor::DockingAreaDefaultAcceptor( const Reference
< XFrame
>& xOwner
)
83 // Init baseclasses first
84 : ThreadHelpBase ( &Application::GetSolarMutex() )
90 //*****************************************************************************************************************
92 //*****************************************************************************************************************
93 DockingAreaDefaultAcceptor::~DockingAreaDefaultAcceptor()
97 //*****************************************************************************************************************
98 // XDockingAreaAcceptor
99 //*****************************************************************************************************************
100 css::uno::Reference
< css::awt::XWindow
> SAL_CALL
DockingAreaDefaultAcceptor::getContainerWindow() throw (css::uno::RuntimeException
)
102 // Ready for multithreading
103 ResetableGuard
aGuard( m_aLock
);
105 // Try to "lock" the frame for access to taskscontainer.
106 Reference
< XFrame
> xFrame( m_xOwner
.get(), UNO_QUERY
);
107 Reference
< css::awt::XWindow
> xContainerWindow( xFrame
->getContainerWindow() );
109 return xContainerWindow
;
112 sal_Bool SAL_CALL
DockingAreaDefaultAcceptor::requestDockingAreaSpace( const css::awt::Rectangle
& RequestedSpace
) throw (css::uno::RuntimeException
)
114 // Ready for multithreading
115 ResetableGuard
aGuard( m_aLock
);
117 // Try to "lock" the frame for access to taskscontainer.
118 Reference
< XFrame
> xFrame( m_xOwner
.get(), UNO_QUERY
);
121 if ( xFrame
.is() == sal_True
)
123 Reference
< css::awt::XWindow
> xContainerWindow( xFrame
->getContainerWindow() );
124 Reference
< css::awt::XWindow
> xComponentWindow( xFrame
->getComponentWindow() );
126 if (( xContainerWindow
.is() == sal_True
) &&
127 ( xComponentWindow
.is() == sal_True
) )
129 css::uno::Reference
< css::awt::XDevice
> xDevice( xContainerWindow
, css::uno::UNO_QUERY
);
130 // Convert relativ size to output size.
131 css::awt::Rectangle aRectangle
= xContainerWindow
->getPosSize();
132 css::awt::DeviceInfo aInfo
= xDevice
->getInfo();
133 css::awt::Size
aSize ( aRectangle
.Width
- aInfo
.LeftInset
- aInfo
.RightInset
,
134 aRectangle
.Height
- aInfo
.TopInset
- aInfo
.BottomInset
);
136 // client size of container window
137 // css::uno::Reference< css::awt::XLayoutConstrains > xLayoutContrains( xComponentWindow, css::uno::UNO_QUERY );
138 css::awt::Size
aMinSize( 0, 0 ); // = xLayoutContrains->getMinimumSize();
140 // Check if request border space would decrease component window size below minimum size
141 if ((( aSize
.Width
- RequestedSpace
.X
- RequestedSpace
.Width
) < aMinSize
.Width
) ||
142 (( aSize
.Height
- RequestedSpace
.Y
- RequestedSpace
.Height
) < aMinSize
.Height
) )
152 void SAL_CALL
DockingAreaDefaultAcceptor::setDockingAreaSpace( const css::awt::Rectangle
& BorderSpace
) throw (css::uno::RuntimeException
)
154 // Ready for multithreading
155 ResetableGuard
aGuard( m_aLock
);
157 // Try to "lock" the frame for access to taskscontainer.
158 Reference
< XFrame
> xFrame( m_xOwner
.get(), UNO_QUERY
);
159 if ( xFrame
.is() == sal_True
)
161 Reference
< css::awt::XWindow
> xContainerWindow( xFrame
->getContainerWindow() );
162 Reference
< css::awt::XWindow
> xComponentWindow( xFrame
->getComponentWindow() );
164 if (( xContainerWindow
.is() == sal_True
) &&
165 ( xComponentWindow
.is() == sal_True
) )
167 css::uno::Reference
< css::awt::XDevice
> xDevice( xContainerWindow
, css::uno::UNO_QUERY
);
168 // Convert relativ size to output size.
169 css::awt::Rectangle aRectangle
= xContainerWindow
->getPosSize();
170 css::awt::DeviceInfo aInfo
= xDevice
->getInfo();
171 css::awt::Size
aSize ( aRectangle
.Width
- aInfo
.LeftInset
- aInfo
.RightInset
,
172 aRectangle
.Height
- aInfo
.TopInset
- aInfo
.BottomInset
);
173 // client size of container window
174 // css::uno::Reference< css::awt::XLayoutConstrains > xLayoutContrains( xComponentWindow, css::uno::UNO_QUERY );
175 css::awt::Size
aMinSize( 0, 0 );// = xLayoutContrains->getMinimumSize();
177 // Check if request border space would decrease component window size below minimum size
178 sal_Int32 nWidth
= aSize
.Width
- BorderSpace
.X
- BorderSpace
.Width
;
179 sal_Int32 nHeight
= aSize
.Height
- BorderSpace
.Y
- BorderSpace
.Height
;
181 if (( nWidth
> aMinSize
.Width
) && ( nHeight
> aMinSize
.Height
))
183 // Resize our component window.
184 xComponentWindow
->setPosSize( BorderSpace
.X
, BorderSpace
.Y
, nWidth
, nHeight
, css::awt::PosSize::POSSIZE
);
190 } // namespace framework