android: Update app icon to new startcenter icon
[LibreOffice.git] / dbaccess / source / ui / querydesign / querycontainerwindow.cxx
blob7a14b7e3c4da7b0beddad2c81d646d2017db98dd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <querycontainerwindow.hxx>
21 #include <QueryDesignView.hxx>
22 #include <vcl/svapp.hxx>
23 #include <vcl/settings.hxx>
24 #include <JoinController.hxx>
25 #include <toolkit/helper/vclunohelper.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>
34 namespace dbaui
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;
42 // OQueryContainerWindow
43 OQueryContainerWindow::OQueryContainerWindow(vcl::Window* pParent, OQueryController& _rController,const Reference< XComponentContext >& _rxContext)
44 :ODataView( pParent, _rController, _rxContext )
45 ,m_pViewSwitch(nullptr)
46 ,m_pBeamer(nullptr)
48 m_pViewSwitch = new OQueryViewSwitch( this, _rController, _rxContext );
50 m_pSplitter = VclPtr<Splitter>::Create(this,WB_VSCROLL);
51 m_pSplitter->Hide();
52 m_pSplitter->SetSplitHdl( LINK( this, OQueryContainerWindow, SplitHdl ) );
53 m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) );
55 OQueryContainerWindow::~OQueryContainerWindow()
57 disposeOnce();
59 void OQueryContainerWindow::dispose()
62 OQueryViewSwitch* pTemp = m_pViewSwitch;
63 m_pViewSwitch = nullptr;
64 delete pTemp;
66 if ( m_pBeamer )
67 ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
68 m_pBeamer.clear();
69 if ( m_xBeamer.is() )
71 Reference< css::util::XCloseable > xCloseable(m_xBeamer,UNO_QUERY);
72 m_xBeamer = nullptr;
73 if(xCloseable.is())
74 xCloseable->close(false); // false - holds the ownership of this frame
77 m_pSplitter.disposeAndClear();
78 ODataView::dispose();
80 bool OQueryContainerWindow::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo )
82 return m_pViewSwitch->switchView( _pErrorInfo );
85 void OQueryContainerWindow::forceInitialView()
87 return m_pViewSwitch->forceInitialView();
90 void OQueryContainerWindow::resizeAll( const tools::Rectangle& _rPlayground )
92 tools::Rectangle aPlayground( _rPlayground );
94 if ( m_pBeamer && m_pBeamer->IsVisible() )
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() );
101 if ( aSplitPos.Y() <= aPlayground.Top() )
102 aSplitPos.setY( aPlayground.Top() + sal_Int32( aPlayground.GetHeight() * 0.2 ) );
104 if ( aSplitPos.Y() + aSplitSize.Height() > aPlayground.GetHeight() )
105 aSplitPos.setY( aPlayground.GetHeight() - aSplitSize.Height() );
107 // set pos and size of the splitter
108 m_pSplitter->SetPosSizePixel( aSplitPos, aSplitSize );
109 m_pSplitter->SetDragRectPixel( aPlayground );
111 // set pos and size of the beamer
112 Size aBeamerSize( aPlayground.GetWidth(), aSplitPos.Y() );
113 m_pBeamer->SetPosSizePixel( aPlayground.TopLeft(), aBeamerSize );
115 // shrink the playground by the size which is occupied by the beamer
116 aPlayground.SetTop( aSplitPos.Y() + aSplitSize.Height() );
119 ODataView::resizeAll( aPlayground );
122 void OQueryContainerWindow::resizeDocumentView( tools::Rectangle& _rPlayground )
124 m_pViewSwitch->SetPosSizePixel( _rPlayground.TopLeft(), Size( _rPlayground.GetWidth(), _rPlayground.GetHeight() ) );
126 ODataView::resizeDocumentView( _rPlayground );
129 void OQueryContainerWindow::GetFocus()
131 ODataView::GetFocus();
132 if(m_pViewSwitch)
133 m_pViewSwitch->GrabFocus();
135 IMPL_LINK_NOARG( OQueryContainerWindow, SplitHdl, Splitter*, void )
137 m_pSplitter->SetPosPixel( Point( m_pSplitter->GetPosPixel().X(),m_pSplitter->GetSplitPosPixel() ) );
138 Resize();
141 void OQueryContainerWindow::Construct()
143 m_pViewSwitch->Construct();
146 void OQueryContainerWindow::disposingPreview()
148 if ( m_pBeamer )
150 // here I know that we will be destroyed from the frame
151 ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
152 m_pBeamer = nullptr;
153 m_xBeamer = nullptr;
154 m_pSplitter->Hide();
155 Resize();
158 bool OQueryContainerWindow::PreNotify( NotifyEvent& rNEvt )
160 if (rNEvt.GetType() == NotifyEventType::GETFOCUS && m_pViewSwitch)
162 OJoinController& rController = m_pViewSwitch->getDesignView()->getController();
163 rController.InvalidateFeature(SID_CUT);
164 rController.InvalidateFeature(SID_COPY);
165 rController.InvalidateFeature(SID_PASTE);
167 return ODataView::PreNotify(rNEvt);
169 void OQueryContainerWindow::showPreview(const Reference<XFrame>& _xFrame)
171 if(m_pBeamer)
172 return;
174 m_pBeamer = VclPtr<OBeamer>::Create(this);
176 ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::AddWindow));
178 m_xBeamer = Frame::create( m_pViewSwitch->getORB() );
179 m_xBeamer->initialize( VCLUnoHelper::GetInterface ( m_pBeamer ) );
181 // notify layout manager to not create internal toolbars
184 Reference < XPropertySet > xLMPropSet(m_xBeamer->getLayoutManager(), UNO_QUERY);
185 if ( xLMPropSet.is() )
187 xLMPropSet->setPropertyValue( "AutomaticToolbars", Any( false ));
190 catch( Exception& )
194 m_xBeamer->setName(FRAME_NAME_QUERY_PREVIEW);
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) );
201 Size aSize = GetOutputSizePixel();
202 Size aBeamer(aSize.Width(),sal_Int32(aSize.Height()*0.33));
204 const tools::Long nFrameHeight = LogicToPixel(Size(0, 3), MapMode(MapUnit::MapAppFont)).Height();
205 Point aPos(0,aBeamer.Height()+nFrameHeight);
207 m_pBeamer->SetPosSizePixel(Point(0,0),aBeamer);
208 m_pBeamer->Show();
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));
215 m_pSplitter->Show();
217 Resize();
220 } // namespace dbaui
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */