LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/dbaccess/source/ui/querydesign - querycontainerwindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 105 1.0 %
Date: 2013-07-09 Functions: 2 16 12.5 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      20             : 
      21             : #include "querycontainerwindow.hxx"
      22             : #include "QueryDesignView.hxx"
      23             : #include <tools/debug.hxx>
      24             : #include <vcl/svapp.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             : 
      35             : //.........................................................................
      36             : namespace dbaui
      37             : {
      38             : //.........................................................................
      39             : 
      40             :     using namespace ::com::sun::star::uno;
      41             :     using namespace ::com::sun::star::lang;
      42             :     using namespace ::com::sun::star::frame;
      43             :     using namespace ::com::sun::star::beans;
      44             : 
      45             :     //=====================================================================
      46             :     //= OQueryContainerWindow
      47             :     //=====================================================================
      48             :     DBG_NAME(OQueryContainerWindow)
      49           0 :     OQueryContainerWindow::OQueryContainerWindow(Window* pParent, OQueryController& _rController,const Reference< XComponentContext >& _rxContext)
      50             :         :ODataView( pParent, _rController, _rxContext )
      51             :         ,m_pViewSwitch(NULL)
      52           0 :         ,m_pBeamer(NULL)
      53             :     {
      54             :         DBG_CTOR(OQueryContainerWindow,NULL);
      55           0 :         m_pViewSwitch = new OQueryViewSwitch( this, _rController, _rxContext );
      56             : 
      57           0 :         m_pSplitter = new Splitter(this,WB_VSCROLL);
      58           0 :         m_pSplitter->Hide();
      59           0 :         m_pSplitter->SetSplitHdl( LINK( this, OQueryContainerWindow, SplitHdl ) );
      60           0 :         m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) );
      61           0 :     }
      62             :     // -----------------------------------------------------------------------------
      63           0 :     OQueryContainerWindow::~OQueryContainerWindow()
      64             :     {
      65             :         DBG_DTOR(OQueryContainerWindow,NULL);
      66             :         {
      67           0 :             ::std::auto_ptr<OQueryViewSwitch> aTemp(m_pViewSwitch);
      68           0 :             m_pViewSwitch = NULL;
      69             :         }
      70           0 :         if ( m_pBeamer )
      71           0 :             ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
      72           0 :         m_pBeamer = NULL;
      73           0 :         if ( m_xBeamer.is() )
      74             :         {
      75           0 :             Reference< ::com::sun::star::util::XCloseable > xCloseable(m_xBeamer,UNO_QUERY);
      76           0 :             m_xBeamer = NULL;
      77           0 :             if(xCloseable.is())
      78           0 :                 xCloseable->close(sal_False); // false - holds the owner ship of this frame
      79             :         }
      80             : 
      81           0 :         ::std::auto_ptr<Window> aTemp(m_pSplitter);
      82           0 :         m_pSplitter = NULL;
      83             : 
      84           0 :     }
      85             :     // -----------------------------------------------------------------------------
      86           0 :     bool OQueryContainerWindow::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo )
      87             :     {
      88           0 :         return m_pViewSwitch->switchView( _pErrorInfo );
      89             :     }
      90             : 
      91             :     // -----------------------------------------------------------------------------
      92           0 :     void OQueryContainerWindow::forceInitialView()
      93             :     {
      94           0 :         return m_pViewSwitch->forceInitialView();
      95             :     }
      96             : 
      97             :     // -----------------------------------------------------------------------------
      98           0 :     void OQueryContainerWindow::resizeAll( const Rectangle& _rPlayground )
      99             :     {
     100           0 :         Rectangle aPlayground( _rPlayground );
     101             : 
     102           0 :         if ( m_pBeamer && m_pBeamer->IsVisible() )
     103             :         {
     104             :             // calc pos and size of the splitter
     105           0 :             Point aSplitPos     = m_pSplitter->GetPosPixel();
     106           0 :             Size aSplitSize     = m_pSplitter->GetOutputSizePixel();
     107           0 :             aSplitSize.Width() = aPlayground.GetWidth();
     108             : 
     109           0 :             if ( aSplitPos.Y() <= aPlayground.Top() )
     110           0 :                 aSplitPos.Y() = aPlayground.Top() + sal_Int32( aPlayground.GetHeight() * 0.2 );
     111             : 
     112           0 :             if ( aSplitPos.Y() + aSplitSize.Height() > aPlayground.GetHeight() )
     113           0 :                 aSplitPos.Y() = aPlayground.GetHeight() - aSplitSize.Height();
     114             : 
     115             :             // set pos and size of the splitter
     116           0 :             m_pSplitter->SetPosSizePixel( aSplitPos, aSplitSize );
     117           0 :             m_pSplitter->SetDragRectPixel(  aPlayground );
     118             : 
     119             :             // set pos and size of the beamer
     120           0 :             Size aBeamerSize( aPlayground.GetWidth(), aSplitPos.Y() );
     121           0 :             m_pBeamer->SetPosSizePixel( aPlayground.TopLeft(), aBeamerSize );
     122             : 
     123             :             // shrink the playground by the size which is occupied by the beamer
     124           0 :             aPlayground.Top() = aSplitPos.Y() + aSplitSize.Height();
     125             :         }
     126             : 
     127           0 :         ODataView::resizeAll( aPlayground );
     128           0 :     }
     129             : 
     130             :     // -----------------------------------------------------------------------------
     131           0 :     void OQueryContainerWindow::resizeDocumentView( Rectangle& _rPlayground )
     132             :     {
     133           0 :         m_pViewSwitch->SetPosSizePixel( _rPlayground.TopLeft(), Size( _rPlayground.GetWidth(), _rPlayground.GetHeight() ) );
     134             : 
     135           0 :         ODataView::resizeDocumentView( _rPlayground );
     136           0 :     }
     137             : 
     138             :     // -----------------------------------------------------------------------------
     139           0 :     void OQueryContainerWindow::GetFocus()
     140             :     {
     141           0 :         ODataView::GetFocus();
     142           0 :         if(m_pViewSwitch)
     143           0 :             m_pViewSwitch->GrabFocus();
     144           0 :     }
     145             :     // -----------------------------------------------------------------------------
     146           0 :     IMPL_LINK( OQueryContainerWindow, SplitHdl, void*, /*p*/ )
     147             :     {
     148           0 :         m_pSplitter->SetPosPixel( Point( m_pSplitter->GetPosPixel().X(),m_pSplitter->GetSplitPosPixel() ) );
     149           0 :         Resize();
     150             : 
     151           0 :         return 0L;
     152             :     }
     153             : 
     154             :     // -----------------------------------------------------------------------------
     155           0 :     void OQueryContainerWindow::Construct()
     156             :     {
     157           0 :         m_pViewSwitch->Construct();
     158           0 :     }
     159             : 
     160             :     // -----------------------------------------------------------------------------
     161           0 :     void OQueryContainerWindow::disposingPreview()
     162             :     {
     163           0 :         if ( m_pBeamer )
     164             :         {
     165             :             // here I know that we will be destroyed from the frame
     166           0 :             ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
     167           0 :             m_pBeamer = NULL;
     168           0 :             m_xBeamer = NULL;
     169           0 :             m_pSplitter->Hide();
     170           0 :             Resize();
     171             :         }
     172           0 :     }
     173             :     // -----------------------------------------------------------------------------
     174           0 :     long OQueryContainerWindow::PreNotify( NotifyEvent& rNEvt )
     175             :     {
     176           0 :         sal_Bool bHandled = sal_False;
     177           0 :         switch (rNEvt.GetType())
     178             :         {
     179             :             case  EVENT_GETFOCUS:
     180           0 :                 if ( m_pViewSwitch )
     181             :                 {
     182           0 :                     OJoinController& rController = m_pViewSwitch->getDesignView()->getController();
     183           0 :                     rController.InvalidateFeature(SID_CUT);
     184           0 :                     rController.InvalidateFeature(SID_COPY);
     185           0 :                     rController.InvalidateFeature(SID_PASTE);
     186             :                 }
     187             :         }
     188           0 :         return bHandled ? 1L : ODataView::PreNotify(rNEvt);
     189             :     }
     190             :     // -----------------------------------------------------------------------------
     191           0 :     void OQueryContainerWindow::showPreview(const Reference<XFrame>& _xFrame)
     192             :     {
     193           0 :         if(!m_pBeamer)
     194             :         {
     195           0 :             m_pBeamer = new OBeamer(this);
     196             : 
     197           0 :             ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::AddWindow));
     198             : 
     199           0 :             m_xBeamer = Frame::create( m_pViewSwitch->getORB() );
     200           0 :             m_xBeamer->initialize( VCLUnoHelper::GetInterface ( m_pBeamer ) );
     201             : 
     202             :             // notify layout manager to not create internal toolbars
     203             :             try
     204             :             {
     205           0 :                 Reference < XPropertySet > xLMPropSet(m_xBeamer->getLayoutManager(), UNO_QUERY);
     206           0 :                 if ( xLMPropSet.is() )
     207             :                 {
     208           0 :                     const OUString aAutomaticToolbars( "AutomaticToolbars" );
     209           0 :                     xLMPropSet->setPropertyValue( aAutomaticToolbars, Any( sal_False ));
     210           0 :                 }
     211             :             }
     212           0 :             catch( Exception& )
     213             :             {
     214             :             }
     215             : 
     216           0 :             m_xBeamer->setName(FRAME_NAME_QUERY_PREVIEW);
     217             : 
     218             :             // append our frame
     219           0 :             Reference < XFramesSupplier > xSup(_xFrame,UNO_QUERY);
     220           0 :             Reference < XFrames > xFrames = xSup->getFrames();
     221           0 :             xFrames->append( Reference<XFrame>(m_xBeamer,UNO_QUERY_THROW) );
     222             : 
     223           0 :             Size aSize = GetOutputSizePixel();
     224           0 :             Size aBeamer(aSize.Width(),sal_Int32(aSize.Height()*0.33));
     225             : 
     226           0 :             const long  nFrameHeight = LogicToPixel( Size( 0, 3 ), MAP_APPFONT ).Height();
     227           0 :             Point aPos(0,aBeamer.Height()+nFrameHeight);
     228             : 
     229           0 :             m_pBeamer->SetPosSizePixel(Point(0,0),aBeamer);
     230           0 :             m_pBeamer->Show();
     231             : 
     232           0 :             m_pSplitter->SetPosSizePixel( Point(0,aBeamer.Height()), Size(aSize.Width(),nFrameHeight) );
     233             :             // a default pos for the splitter, so that the listbox is about 80 (logical) pixels wide
     234           0 :             m_pSplitter->SetSplitPosPixel( aBeamer.Height() );
     235           0 :             m_pViewSwitch->SetPosSizePixel(aPos,Size(aBeamer.Width(),aSize.Height() - aBeamer.Height()-nFrameHeight));
     236             : 
     237           0 :             m_pSplitter->Show();
     238             : 
     239           0 :             Resize();
     240             :         }
     241           0 :     }
     242             :     // -----------------------------------------------------------------------------
     243             : 
     244             : 
     245             : //.........................................................................
     246          12 : }   // namespace dbaui
     247             : //.........................................................................
     248             : 
     249             : 
     250             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10