22#include <com/sun/star/ui/DockingArea.hpp>
23#include <com/sun/star/awt/Toolkit.hpp>
24#include <com/sun/star/awt/XTopWindow.hpp>
25#include <com/sun/star/frame/DispatchHelper.hpp>
26#include <com/sun/star/awt/XDockableWindow.hpp>
27#include <com/sun/star/awt/XDockableWindowListener.hpp>
28#include <com/sun/star/awt/XWindowListener.hpp>
29#include <com/sun/star/ui/XUIElement.hpp>
45 return ( rSize.Width == 0 ) && ( rSize.Height == 0 );
60 ui::DockingArea eDockArea =
static_cast< ui::DockingArea
>( nDockArea );
61 return (( eDockArea == ui::DockingArea_DOCKINGAREA_BOTTOM ) ||
62 ( eDockArea == ui::DockingArea_DOCKINGAREA_RIGHT ));
68 return (( pToolBox->
GetAlign() == WindowAlign::Top ) || ( pToolBox->
GetAlign() == WindowAlign::Bottom ));
74 return (( nDockingArea == ui::DockingArea_DOCKINGAREA_TOP ) ||
75 ( nDockingArea == ui::DockingArea_DOCKINGAREA_BOTTOM ));
85 OUString aToolbarName;
87 if ( pWindow->
GetType() == WindowType::TOOLBOX )
93 sal_Int32
i = aToolbarName.lastIndexOf(
':' );
94 if ( !aToolbarName.isEmpty() && (
i > 0 ) && ((
i + 1 ) < aToolbarName.getLength() ))
95 aToolbarName = aToolbarName.copy(
i+1 );
106 if ( pWindow->
GetType() == WindowType::TOOLBOX )
107 pToolbox =
dynamic_cast<ToolBox*
>( pWindow );
114 uno::Reference< awt::XWindow > xWindow;
115 if ( xUIElement.is() )
116 xWindow.set( xUIElement->getRealInterface(), uno::UNO_QUERY );
123 while ( pWindow && !pWindow->IsSystemWindow() )
124 pWindow = pWindow->GetParent();
137bool lcl_checkUIElement(
const uno::Reference< ui::XUIElement >& xUIElement, awt::Rectangle& _rPosSize, uno::Reference< awt::XWindow >& _xWindow)
139 bool bRet = xUIElement.is();
143 _xWindow.set( xUIElement->getRealInterface(), uno::UNO_QUERY );
144 _rPosSize = _xWindow->getPosSize();
147 if ( pWindow->GetType() == WindowType::TOOLBOX )
149 ::Size aSize =
static_cast<ToolBox*
>(pWindow.
get())->CalcWindowSizePixel( 1 );
150 _rPosSize.Width = aSize.
Width();
151 _rPosSize.Height = aSize.
Height();
157uno::Reference< awt::XVclWindowPeer >
createToolkitWindow(
const uno::Reference< uno::XComponentContext >& rxContext,
const uno::Reference< awt::XVclWindowPeer >& rParent,
const char* pService )
159 uno::Reference< awt::XToolkit2 > xToolkit = awt::Toolkit::create( rxContext );
162 css::awt::WindowDescriptor aDescriptor;
163 aDescriptor.Type = awt::WindowClass_SIMPLE;
164 aDescriptor.WindowServiceName = OUString::createFromAscii( pService );
165 aDescriptor.ParentIndex = -1;
166 aDescriptor.Parent = rParent;
167 aDescriptor.Bounds = awt::Rectangle(0,0,0,0);
168 aDescriptor.WindowAttributes = 0;
171 uno::Reference< awt::XWindowPeer > xPeer = xToolkit->createWindow( aDescriptor );
172 uno::Reference< awt::XVclWindowPeer > xVclPeer(xPeer, uno::UNO_QUERY);
173 assert(xVclPeer || !xPeer);
180 if ( aAlignment == ui::DockingArea_DOCKINGAREA_LEFT )
181 return WindowAlign::Left;
182 else if ( aAlignment == ui::DockingArea_DOCKINGAREA_RIGHT )
183 return WindowAlign::Right;
184 else if ( aAlignment == ui::DockingArea_DOCKINGAREA_TOP )
185 return WindowAlign::Top;
187 return WindowAlign::Bottom;
198 return std::u16string_view();
201void parseResourceURL( std::u16string_view aResourceURL, OUString& aElementType, OUString& aElementName )
213 css::awt::Rectangle aRect;
214 aRect.X = rRect.Left();
215 aRect.Y = rRect.Top();
216 aRect.Width = rRect.Right();
217 aRect.Height = rRect.Bottom();
234 const css::awt::Rectangle& rRect2 )
236 return (( rRect1.X == rRect2.X ) &&
237 ( rRect1.Y == rRect2.Y ) &&
238 ( rRect1.Width == rRect2.Width ) &&
239 ( rRect1.Height == rRect2.Height ));
245 uno::Reference< frame::XModel >
xModel;
248 uno::Reference< frame::XController >
xController = rFrame->getController();
277 uno::Reference< awt::XTopWindow > xWindowCheck(
xFrame->getContainerWindow(), uno::UNO_QUERY);
278 if (xWindowCheck.is())
282 uno::Reference< awt::XWindow > xWindow( xWindowCheck, uno::UNO_QUERY );
284 return pWindow && pWindow->IsSystemWindow();
290void impl_setDockingWindowVisibility(
const css::uno::Reference< css::uno::XComponentContext>& rxContext,
const css::uno::Reference< css::frame::XFrame >& rFrame, std::u16string_view rDockingWindowName,
bool bVisible )
295 css::uno::Reference< css::frame::XDispatchProvider > xProvider(rFrame, css::uno::UNO_QUERY);
296 if ( !(
nIndex >= 0 && xProvider.is()) )
299 OUString aDockWinArgName =
"DockingWindow" + OUString::number(
nIndex );
304 css::uno::Reference< css::frame::XDispatchHelper > xDispatcher = css::frame::DispatchHelper::create( rxContext );
306 OUString aDockWinCommand =
".uno:" + aDockWinArgName;
307 xDispatcher->executeDispatch(
316 const css::uno::Reference< css::uno::XInterface >& xThis,
317 const css::uno::Reference< css::ui::XUIElement >& xUIElement )
319 css::uno::Reference< css::awt::XWindow > xWindow( xUIElement->getRealInterface(), css::uno::UNO_QUERY );
320 css::uno::Reference< css::awt::XDockableWindow > xDockWindow( xUIElement->getRealInterface(), css::uno::UNO_QUERY );
321 if ( !(xDockWindow.is() && xWindow.is()) )
326 xDockWindow->addDockableWindowListener(
327 css::uno::Reference< css::awt::XDockableWindowListener >(
328 xThis, css::uno::UNO_QUERY ));
329 xWindow->addWindowListener(
330 css::uno::Reference< css::awt::XWindowListener >(
331 xThis, css::uno::UNO_QUERY ));
332 xDockWindow->enableDocking(
true );
334 catch (
const css::uno::Exception& )
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
reference_type * get() const
WindowType GetType() const
const OUString & GetHelpId() const
constexpr OUStringLiteral UIRESOURCE_URL
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
css::awt::Rectangle putRectangleValueToAWT(const ::tools::Rectangle &rRect)
const sal_Int32 DOCKWIN_ID_BASE
WindowAlign ImplConvertAlignment(ui::DockingArea aAlignment)
void parseResourceURL(std::u16string_view aResourceURL, OUString &aElementType, OUString &aElementName)
OUString retrieveToolbarNameFromHelpURL(vcl::Window *pWindow)
bool isHorizontalDockingArea(const ui::DockingArea &nDockingArea)
ToolBox * getToolboxPtr(vcl::Window *pWindow)
uno::Reference< awt::XVclWindowPeer > createToolkitWindow(const uno::Reference< uno::XComponentContext > &rxContext, const uno::Reference< awt::XVclWindowPeer > &rParent, const char *pService)
void impl_addWindowListeners(const css::uno::Reference< css::uno::XInterface > &xThis, const css::uno::Reference< css::ui::XUIElement > &xUIElement)
::tools::Rectangle putAWTToRectangle(const css::awt::Rectangle &rRect)
bool isToolboxHorizontalAligned(ToolBox const *pToolBox)
SystemWindow * getTopSystemWindow(const uno::Reference< awt::XWindow > &xWindow)
vcl::Window * getWindowFromXUIElement(const uno::Reference< ui::XUIElement > &xUIElement)
uno::Reference< frame::XModel > impl_getModelFromFrame(const uno::Reference< frame::XFrame > &rFrame)
void impl_setDockingWindowVisibility(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XFrame > &rFrame, std::u16string_view rDockingWindowName, bool bVisible)
std::u16string_view getElementTypeFromResourceURL(std::u16string_view aResourceURL)
bool implts_isPreviewModel(const uno::Reference< frame::XModel > &xModel)
bool hasEmptySize(const css::awt::Size &rSize)
bool implts_isFrameOrWindowTop(const uno::Reference< frame::XFrame > &xFrame)
bool equalRectangles(const css::awt::Rectangle &rRect1, const css::awt::Rectangle &rRect2)
bool isReverseOrderDockingArea(const sal_Int32 nDockArea)
bool lcl_checkUIElement(const uno::Reference< ui::XUIElement > &xUIElement, awt::Rectangle &_rPosSize, uno::Reference< awt::XWindow > &_xWindow)
bool isDefaultPos(const css::awt::Point &rPos)
bool hasDefaultPosValue(const css::awt::Point &rPos)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
Reference< XController > xController
Reference< XFrame > xFrame
Reference< XModel > xModel