LibreOffice Module dbaccess (master) 1
querycontainerwindow.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
21#include <QueryDesignView.hxx>
22#include <vcl/svapp.hxx>
23#include <vcl/settings.hxx>
24#include <JoinController.hxx>
26#include <strings.hxx>
27#include <sfx2/sfxsids.hrc>
28#include <vcl/event.hxx>
29#include <UITools.hxx>
30#include <com/sun/star/beans/XPropertySet.hpp>
31#include <com/sun/star/frame/Frame.hpp>
32#include <com/sun/star/util/XCloseable.hpp>
33
34namespace dbaui
35{
36
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::lang;
39 using namespace ::com::sun::star::frame;
40 using namespace ::com::sun::star::beans;
41
42 // OQueryContainerWindow
44 :ODataView( pParent, _rController, _rxContext )
45 ,m_pViewSwitch(nullptr)
46 ,m_pBeamer(nullptr)
47 {
48 m_pViewSwitch = new OQueryViewSwitch( this, _rController, _rxContext );
49
51 m_pSplitter->Hide();
52 m_pSplitter->SetSplitHdl( LINK( this, OQueryContainerWindow, SplitHdl ) );
53 m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) );
54 }
56 {
58 }
60 {
61 {
63 m_pViewSwitch = nullptr;
64 delete pTemp;
65 }
66 if ( m_pBeamer )
68 m_pBeamer.clear();
69 if ( m_xBeamer.is() )
70 {
72 m_xBeamer = nullptr;
73 if(xCloseable.is())
74 xCloseable->close(false); // false - holds the ownership of this frame
75 }
76
79 }
81 {
82 return m_pViewSwitch->switchView( _pErrorInfo );
83 }
84
86 {
88 }
89
91 {
92 tools::Rectangle aPlayground( _rPlayground );
93
94 if ( m_pBeamer && m_pBeamer->IsVisible() )
95 {
96 // calc pos and size of the splitter
97 Point aSplitPos = m_pSplitter->GetPosPixel();
98 Size aSplitSize = m_pSplitter->GetOutputSizePixel();
99 aSplitSize.setWidth( aPlayground.GetWidth() );
100
101 if ( aSplitPos.Y() <= aPlayground.Top() )
102 aSplitPos.setY( aPlayground.Top() + sal_Int32( aPlayground.GetHeight() * 0.2 ) );
103
104 if ( aSplitPos.Y() + aSplitSize.Height() > aPlayground.GetHeight() )
105 aSplitPos.setY( aPlayground.GetHeight() - aSplitSize.Height() );
106
107 // set pos and size of the splitter
108 m_pSplitter->SetPosSizePixel( aSplitPos, aSplitSize );
109 m_pSplitter->SetDragRectPixel( aPlayground );
110
111 // set pos and size of the beamer
112 Size aBeamerSize( aPlayground.GetWidth(), aSplitPos.Y() );
113 m_pBeamer->SetPosSizePixel( aPlayground.TopLeft(), aBeamerSize );
114
115 // shrink the playground by the size which is occupied by the beamer
116 aPlayground.SetTop( aSplitPos.Y() + aSplitSize.Height() );
117 }
118
119 ODataView::resizeAll( aPlayground );
120 }
121
123 {
124 m_pViewSwitch->SetPosSizePixel( _rPlayground.TopLeft(), Size( _rPlayground.GetWidth(), _rPlayground.GetHeight() ) );
125
126 ODataView::resizeDocumentView( _rPlayground );
127 }
128
130 {
132 if(m_pViewSwitch)
134 }
136 {
137 m_pSplitter->SetPosPixel( Point( m_pSplitter->GetPosPixel().X(),m_pSplitter->GetSplitPosPixel() ) );
138 Resize();
139 }
140
142 {
144 }
145
147 {
148 if ( m_pBeamer )
149 {
150 // here I know that we will be destroyed from the frame
152 m_pBeamer = nullptr;
153 m_xBeamer = nullptr;
154 m_pSplitter->Hide();
155 Resize();
156 }
157 }
159 {
160 if (rNEvt.GetType() == NotifyEventType::GETFOCUS && m_pViewSwitch)
161 {
163 rController.InvalidateFeature(SID_CUT);
164 rController.InvalidateFeature(SID_COPY);
165 rController.InvalidateFeature(SID_PASTE);
166 }
167 return ODataView::PreNotify(rNEvt);
168 }
170 {
171 if(m_pBeamer)
172 return;
173
175
177
178 m_xBeamer = Frame::create( m_pViewSwitch->getORB() );
180
181 // notify layout manager to not create internal toolbars
182 try
183 {
184 Reference < XPropertySet > xLMPropSet(m_xBeamer->getLayoutManager(), UNO_QUERY);
185 if ( xLMPropSet.is() )
186 {
187 xLMPropSet->setPropertyValue( "AutomaticToolbars", Any( false ));
188 }
189 }
190 catch( Exception& )
191 {
192 }
193
195
196 // append our frame
197 Reference < XFramesSupplier > xSup(_xFrame,UNO_QUERY);
198 Reference < XFrames > xFrames = xSup->getFrames();
199 xFrames->append( Reference<XFrame>(m_xBeamer,UNO_QUERY_THROW) );
200
201 Size aSize = GetOutputSizePixel();
202 Size aBeamer(aSize.Width(),sal_Int32(aSize.Height()*0.33));
203
204 const tools::Long nFrameHeight = LogicToPixel(Size(0, 3), MapMode(MapUnit::MapAppFont)).Height();
205 Point aPos(0,aBeamer.Height()+nFrameHeight);
206
207 m_pBeamer->SetPosSizePixel(Point(0,0),aBeamer);
208 m_pBeamer->Show();
209
210 m_pSplitter->SetPosSizePixel( Point(0,aBeamer.Height()), Size(aSize.Width(),nFrameHeight) );
211 // a default pos for the splitter, so that the listbox is about 80 (logical) pixels wide
212 m_pSplitter->SetSplitPosPixel( aBeamer.Height() );
213 m_pViewSwitch->SetPosSizePixel(aPos,Size(aBeamer.Width(),aSize.Height() - aBeamer.Height()-nFrameHeight));
214
215 m_pSplitter->Show();
216
217 Resize();
218 }
219
220} // namespace dbaui
221
222/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static const AllSettings & GetSettings()
NotifyEventType GetType() const
constexpr tools::Long Y() const
void setY(tools::Long nY)
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
constexpr tools::Long Width() const
void AddWindow(vcl::Window *pWindow)
void RemoveWindow(vcl::Window *pWindow)
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
void disposeAndClear()
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void resizeDocumentView(tools::Rectangle &_rPlayground)
Definition: dataview.cxx:65
virtual void dispose() override
Definition: dataview.cxx:58
virtual void resizeAll(const tools::Rectangle &_rPlayground)
re-arrange all controls, including the toolbox, it's separator, and the "real view"
Definition: dataview.cxx:84
virtual void Resize() override
Definition: dataview.cxx:91
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: dataview.cxx:96
OJoinController & getController() const
void showPreview(const css::uno::Reference< css::frame::XFrame > &_xFrame)
virtual void dispose() override
virtual void Construct() override
late construction
virtual void resizeDocumentView(tools::Rectangle &_rPlayground) override
virtual ~OQueryContainerWindow() override
css::uno::Reference< css::frame::XFrame2 > m_xBeamer
virtual void GetFocus() override
virtual bool PreNotify(NotifyEvent &rNEvt) override
virtual void resizeAll(const tools::Rectangle &_rPlayground) override
re-arrange all controls, including the toolbox, it's separator, and the "real view"
OQueryContainerWindow(vcl::Window *pParent, OQueryController &_rController, const css::uno::Reference< css::uno::XComponentContext > &)
bool switchView(::dbtools::SQLExceptionInfo *_pErrorInfo)
css::uno::Reference< css::uno::XComponentContext > const & getORB() const
void Construct()
late construction
bool switchView(::dbtools::SQLExceptionInfo *_pErrorInfo)
show the text or the design view
void SetPosSizePixel(Point _rPt, Size _rSize)
OQueryDesignView * getDesignView() const
constexpr tools::Long GetWidth() const
constexpr void SetTop(tools::Long v)
constexpr tools::Long Top() const
constexpr Point TopLeft() const
constexpr tools::Long GetHeight() const
virtual void GetFocus()
Point LogicToPixel(const Point &rLogicPt) const
Size GetOutputSizePixel() const
@ Exception
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
void notifySystemWindow(vcl::Window const *_pWindow, vcl::Window *_pToRegister, const ::comphelper::mem_fun1_t< TaskPaneList, vcl::Window * > &_rMemFunc)
notifySystemWindow adds or remove the given window _pToRegister at the Systemwindow found when search...
Definition: UITools.cxx:918
long Long
constexpr OUStringLiteral FRAME_NAME_QUERY_PREVIEW
Definition: strings.hxx:256
WinBits const WB_VSCROLL