fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / querydesign / querycontainerwindow.cxx
blob47ef55bbc19cf99d09ee2f4b90ad39abbffd11a2
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 <tools/debug.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/settings.hxx>
25 #include "JoinController.hxx"
26 #include <toolkit/helper/vclunohelper.hxx>
27 #include "dbustrings.hrc"
28 #include <sfx2/sfxsids.hrc>
29 #include <vcl/fixed.hxx>
30 #include "UITools.hxx"
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/frame/Frame.hpp>
33 #include <com/sun/star/util/XCloseable.hpp>
34 #include <boost/scoped_ptr.hpp>
36 namespace dbaui
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::lang;
41 using namespace ::com::sun::star::frame;
42 using namespace ::com::sun::star::beans;
44 // OQueryContainerWindow
45 OQueryContainerWindow::OQueryContainerWindow(vcl::Window* pParent, OQueryController& _rController,const Reference< XComponentContext >& _rxContext)
46 :ODataView( pParent, _rController, _rxContext )
47 ,m_pViewSwitch(NULL)
48 ,m_pBeamer(NULL)
50 m_pViewSwitch = new OQueryViewSwitch( this, _rController, _rxContext );
52 m_pSplitter = VclPtr<Splitter>::Create(this,WB_VSCROLL);
53 m_pSplitter->Hide();
54 m_pSplitter->SetSplitHdl( LINK( this, OQueryContainerWindow, SplitHdl ) );
55 m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) );
57 OQueryContainerWindow::~OQueryContainerWindow()
59 disposeOnce();
61 void OQueryContainerWindow::dispose()
64 boost::scoped_ptr<OQueryViewSwitch> aTemp(m_pViewSwitch);
65 m_pViewSwitch = NULL;
67 if ( m_pBeamer )
68 ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
69 m_pBeamer.clear();
70 if ( m_xBeamer.is() )
72 Reference< ::com::sun::star::util::XCloseable > xCloseable(m_xBeamer,UNO_QUERY);
73 m_xBeamer = NULL;
74 if(xCloseable.is())
75 xCloseable->close(sal_False); // false - holds the ownership of this frame
78 m_pSplitter.disposeAndClear();
79 ODataView::dispose();
81 bool OQueryContainerWindow::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo )
83 return m_pViewSwitch->switchView( _pErrorInfo );
86 void OQueryContainerWindow::forceInitialView()
88 return m_pViewSwitch->forceInitialView();
91 void OQueryContainerWindow::resizeAll( const Rectangle& _rPlayground )
93 Rectangle aPlayground( _rPlayground );
95 if ( m_pBeamer && m_pBeamer->IsVisible() )
97 // calc pos and size of the splitter
98 Point aSplitPos = m_pSplitter->GetPosPixel();
99 Size aSplitSize = m_pSplitter->GetOutputSizePixel();
100 aSplitSize.Width() = aPlayground.GetWidth();
102 if ( aSplitPos.Y() <= aPlayground.Top() )
103 aSplitPos.Y() = aPlayground.Top() + sal_Int32( aPlayground.GetHeight() * 0.2 );
105 if ( aSplitPos.Y() + aSplitSize.Height() > aPlayground.GetHeight() )
106 aSplitPos.Y() = aPlayground.GetHeight() - aSplitSize.Height();
108 // set pos and size of the splitter
109 m_pSplitter->SetPosSizePixel( aSplitPos, aSplitSize );
110 m_pSplitter->SetDragRectPixel( aPlayground );
112 // set pos and size of the beamer
113 Size aBeamerSize( aPlayground.GetWidth(), aSplitPos.Y() );
114 m_pBeamer->SetPosSizePixel( aPlayground.TopLeft(), aBeamerSize );
116 // shrink the playground by the size which is occupied by the beamer
117 aPlayground.Top() = aSplitPos.Y() + aSplitSize.Height();
120 ODataView::resizeAll( aPlayground );
123 void OQueryContainerWindow::resizeDocumentView( Rectangle& _rPlayground )
125 m_pViewSwitch->SetPosSizePixel( _rPlayground.TopLeft(), Size( _rPlayground.GetWidth(), _rPlayground.GetHeight() ) );
127 ODataView::resizeDocumentView( _rPlayground );
130 void OQueryContainerWindow::GetFocus()
132 ODataView::GetFocus();
133 if(m_pViewSwitch)
134 m_pViewSwitch->GrabFocus();
136 IMPL_LINK_NOARG( OQueryContainerWindow, SplitHdl )
138 m_pSplitter->SetPosPixel( Point( m_pSplitter->GetPosPixel().X(),m_pSplitter->GetSplitPosPixel() ) );
139 Resize();
141 return 0L;
144 void OQueryContainerWindow::Construct()
146 m_pViewSwitch->Construct();
149 void OQueryContainerWindow::disposingPreview()
151 if ( m_pBeamer )
153 // here I know that we will be destroyed from the frame
154 ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
155 m_pBeamer = NULL;
156 m_xBeamer = NULL;
157 m_pSplitter->Hide();
158 Resize();
161 bool OQueryContainerWindow::PreNotify( NotifyEvent& rNEvt )
163 bool bHandled = false;
164 if (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS && m_pViewSwitch)
166 OJoinController& rController = m_pViewSwitch->getDesignView()->getController();
167 rController.InvalidateFeature(SID_CUT);
168 rController.InvalidateFeature(SID_COPY);
169 rController.InvalidateFeature(SID_PASTE);
171 return bHandled || ODataView::PreNotify(rNEvt);
173 void OQueryContainerWindow::showPreview(const Reference<XFrame>& _xFrame)
175 if(!m_pBeamer)
177 m_pBeamer = VclPtr<OBeamer>::Create(this);
179 ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::AddWindow));
181 m_xBeamer = Frame::create( m_pViewSwitch->getORB() );
182 m_xBeamer->initialize( VCLUnoHelper::GetInterface ( m_pBeamer ) );
184 // notify layout manager to not create internal toolbars
187 Reference < XPropertySet > xLMPropSet(m_xBeamer->getLayoutManager(), UNO_QUERY);
188 if ( xLMPropSet.is() )
190 const OUString aAutomaticToolbars( "AutomaticToolbars" );
191 xLMPropSet->setPropertyValue( aAutomaticToolbars, Any( sal_False ));
194 catch( Exception& )
198 m_xBeamer->setName(FRAME_NAME_QUERY_PREVIEW);
200 // append our frame
201 Reference < XFramesSupplier > xSup(_xFrame,UNO_QUERY);
202 Reference < XFrames > xFrames = xSup->getFrames();
203 xFrames->append( Reference<XFrame>(m_xBeamer,UNO_QUERY_THROW) );
205 Size aSize = GetOutputSizePixel();
206 Size aBeamer(aSize.Width(),sal_Int32(aSize.Height()*0.33));
208 const long nFrameHeight = LogicToPixel( Size( 0, 3 ), MAP_APPFONT ).Height();
209 Point aPos(0,aBeamer.Height()+nFrameHeight);
211 m_pBeamer->SetPosSizePixel(Point(0,0),aBeamer);
212 m_pBeamer->Show();
214 m_pSplitter->SetPosSizePixel( Point(0,aBeamer.Height()), Size(aSize.Width(),nFrameHeight) );
215 // a default pos for the splitter, so that the listbox is about 80 (logical) pixels wide
216 m_pSplitter->SetSplitPosPixel( aBeamer.Height() );
217 m_pViewSwitch->SetPosSizePixel(aPos,Size(aBeamer.Width(),aSize.Height() - aBeamer.Height()-nFrameHeight));
219 m_pSplitter->Show();
221 Resize();
225 } // namespace dbaui
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */