LCOV - code coverage report
Current view: top level - extensions/source/bibliography - bibbeam.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 117 0.0 %
Date: 2014-04-11 Functions: 0 21 0.0 %
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             : #include <osl/mutex.hxx>
      21             : #include <toolkit/helper/vclunohelper.hxx>
      22             : #include <comphelper/processfactory.hxx>
      23             : #include <com/sun/star/awt/PosSize.hpp>
      24             : #include <com/sun/star/frame/XDispatch.hpp>
      25             : #include <com/sun/star/util/XURLTransformer.hpp>
      26             : 
      27             : #include "bibliography.hrc"
      28             : #include <vcl/lstbox.hxx>
      29             : #include <vcl/edit.hxx>
      30             : #include <tools/debug.hxx>
      31             : #include "bibbeam.hxx"
      32             : #include "toolbar.hrc"
      33             : #include "bibresid.hxx"
      34             : #include "datman.hxx"
      35             : #include "bibtools.hxx"
      36             : 
      37             : using namespace ::com::sun::star;
      38             : using namespace ::com::sun::star::beans;
      39             : using namespace ::com::sun::star::uno;
      40             : 
      41             : 
      42             : #define ID_TOOLBAR                          1
      43             : #define ID_GRIDWIN                          2
      44             : 
      45             : namespace bib
      46             : {
      47             : 
      48             :     using namespace ::com::sun::star::uno;
      49             : 
      50           0 :     void HandleTaskPaneList( Window* pWindow, sal_Bool bAddToList )
      51             :     {
      52           0 :         Window*             pParent = pWindow->GetParent();
      53             : 
      54             :         DBG_ASSERT( pParent, "-GetTaskPaneList(): everybody here should have a parent!" );
      55             : 
      56           0 :         SystemWindow*       pSysWin = pParent->GetSystemWindow();
      57           0 :         if( pSysWin )
      58             :         {
      59           0 :             TaskPaneList*   pTaskPaneList = pSysWin->GetTaskPaneList();
      60           0 :             if( pTaskPaneList )
      61             :             {
      62           0 :                 if( bAddToList )
      63           0 :                     pTaskPaneList->AddWindow( pWindow );
      64             :                 else
      65           0 :                     pTaskPaneList->RemoveWindow( pWindow );
      66             :             }
      67             :         }
      68           0 :     }
      69             : 
      70             : 
      71             :     class BibGridwin
      72             :                 :public Window //DockingWindow
      73             :     {
      74             :     private:
      75             :             Reference< awt::XWindow >           m_xGridWin;
      76             :             Reference< awt::XControlModel >     m_xGridModel;
      77             :             Reference< awt::XControl >          m_xControl;
      78             :             Reference< awt::XControlContainer > m_xControlContainer;
      79             :             // #100312#
      80             :             Reference< frame::XDispatchProviderInterception> m_xDispatchProviderInterception;
      81             : 
      82             :     protected:
      83             : 
      84             :             virtual void        Resize() SAL_OVERRIDE;
      85             : 
      86             :     public:
      87             : 
      88             :             BibGridwin(Window* pParent, WinBits nStyle = WB_3DLOOK );
      89             :             virtual ~BibGridwin();
      90             : 
      91             :             void createGridWin(const Reference< awt::XControlModel > & xDbForm);
      92             :             void disposeGridWin();
      93             : 
      94           0 :             const Reference< awt::XControlContainer >& getControlContainer() const { return m_xControlContainer; }
      95             :             // #100312#
      96           0 :             const Reference< frame::XDispatchProviderInterception>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception; }
      97             : 
      98             :             virtual void GetFocus() SAL_OVERRIDE;
      99             :     };
     100             : 
     101           0 :     BibGridwin::BibGridwin( Window* _pParent, WinBits _nStyle ) : Window( _pParent, _nStyle )
     102             :     {
     103           0 :         m_xControlContainer = VCLUnoHelper::CreateControlContainer(this);
     104             : 
     105           0 :         AddToTaskPaneList( this );
     106           0 :     }
     107             : 
     108           0 :     BibGridwin::~BibGridwin()
     109             :     {
     110           0 :         RemoveFromTaskPaneList( this );
     111             : 
     112           0 :         disposeGridWin();
     113           0 :     }
     114             : 
     115           0 :     void BibGridwin::Resize()
     116             :     {
     117           0 :         if(m_xGridWin.is())
     118             :         {
     119           0 :             ::Size aSize = GetOutputSizePixel();
     120           0 :             m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::SIZE);
     121             :         }
     122           0 :     }
     123             : 
     124           0 :     void BibGridwin::createGridWin(const uno::Reference< awt::XControlModel > & xGModel)
     125             :     {
     126           0 :         m_xGridModel = xGModel;
     127             : 
     128           0 :         if( m_xControlContainer.is())
     129             :         {
     130           0 :             uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
     131             : 
     132           0 :             if ( m_xGridModel.is())
     133             :             {
     134           0 :                 uno::Reference< XPropertySet >  xPropSet( m_xGridModel, UNO_QUERY );
     135             : 
     136           0 :                 if ( xPropSet.is() && m_xGridModel.is() )
     137             :                 {
     138           0 :                     uno::Any aAny = xPropSet->getPropertyValue( "DefaultControl" );
     139           0 :                     OUString aControlName;
     140           0 :                     aAny >>= aControlName;
     141             : 
     142           0 :                     m_xControl = Reference< awt::XControl > ( xContext->getServiceManager()->createInstanceWithContext(aControlName, xContext), UNO_QUERY_THROW );
     143           0 :                     m_xControl->setModel( m_xGridModel );
     144             :                 }
     145             : 
     146           0 :                 if ( m_xControl.is() )
     147             :                 {
     148             :                     // Peer as Child to the FrameWindow
     149           0 :                     m_xControlContainer->addControl("GridControl", m_xControl);
     150           0 :                     m_xGridWin=uno::Reference< awt::XWindow > (m_xControl, UNO_QUERY );
     151             :                     // #100312#
     152           0 :                     m_xDispatchProviderInterception=uno::Reference< frame::XDispatchProviderInterception > (m_xControl, UNO_QUERY );
     153           0 :                     m_xGridWin->setVisible( sal_True );
     154           0 :                     m_xControl->setDesignMode( sal_True );
     155             :                     // initially switch on the design mode - switch it off _after_ loading the form
     156             : 
     157           0 :                     ::Size aSize = GetOutputSizePixel();
     158           0 :                     m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::POSSIZE);
     159           0 :                 }
     160           0 :             }
     161             :         }
     162           0 :     }
     163             : 
     164           0 :     void BibGridwin::disposeGridWin()
     165             :     {
     166           0 :         if ( m_xControl.is() )
     167             :         {
     168           0 :             Reference< awt::XControl > xDel( m_xControl );
     169           0 :             m_xControl = NULL;
     170           0 :             m_xGridWin = NULL;
     171             : 
     172           0 :             m_xControlContainer->removeControl( xDel );
     173           0 :             xDel->dispose();
     174             :         }
     175           0 :     }
     176             : 
     177           0 :     void BibGridwin::GetFocus()
     178             :     {
     179           0 :         if(m_xGridWin.is())
     180           0 :             m_xGridWin->setFocus();
     181           0 :     }
     182             : 
     183           0 :     BibBeamer::BibBeamer( Window* _pParent, BibDataManager* _pDM, WinBits _nStyle )
     184             :         :BibSplitWindow( _pParent, _nStyle | WB_NOSPLITDRAW )
     185             :         ,pDatMan( _pDM )
     186             :         ,pToolBar( NULL )
     187           0 :         ,pGridWin( NULL )
     188             :     {
     189           0 :         createToolBar();
     190           0 :         createGridWin();
     191           0 :         pDatMan->SetToolbar(pToolBar);
     192           0 :         pGridWin->Show();
     193           0 :         connectForm( pDatMan );
     194           0 :     }
     195             : 
     196           0 :     BibBeamer::~BibBeamer()
     197             :     {
     198           0 :         if ( isFormConnected() )
     199           0 :             disconnectForm();
     200             : 
     201           0 :         if ( m_xToolBarRef.is() )
     202           0 :             m_xToolBarRef->dispose();
     203             : 
     204           0 :         if ( pToolBar )
     205             :         {
     206           0 :             pDatMan->SetToolbar(0);
     207             : 
     208           0 :             DELETEZ( pToolBar );
     209             :         }
     210             : 
     211           0 :         if( pGridWin )
     212             :         {
     213           0 :             BibGridwin* pDel = pGridWin;
     214           0 :             pGridWin = NULL;
     215           0 :             pDel->disposeGridWin();
     216           0 :             delete pDel;
     217             :         }
     218             : 
     219           0 :     }
     220             : 
     221           0 :     void BibBeamer::createToolBar()
     222             :     {
     223           0 :         pToolBar= new BibToolBar(this, LINK( this, BibBeamer, RecalcLayout_Impl ));
     224           0 :         ::Size aSize=pToolBar->GetSizePixel();
     225           0 :         InsertItem(ID_TOOLBAR, pToolBar, aSize.Height(), 0, 0, SWIB_FIXED );
     226           0 :         if ( m_xController.is() )
     227           0 :             pToolBar->SetXController( m_xController );
     228           0 :     }
     229             : 
     230           0 :     void BibBeamer::createGridWin()
     231             :     {
     232           0 :         pGridWin = new BibGridwin(this,0);
     233             : 
     234           0 :         InsertItem(ID_GRIDWIN, pGridWin, 40, 1, 0, SWIB_RELATIVESIZE );
     235             : 
     236           0 :         pGridWin->createGridWin( pDatMan->updateGridModel() );
     237           0 :     }
     238             : 
     239           0 :     Reference< awt::XControlContainer > BibBeamer::getControlContainer()
     240             :     {
     241           0 :         Reference< awt::XControlContainer > xReturn;
     242           0 :         if ( pGridWin )
     243           0 :             xReturn = pGridWin->getControlContainer();
     244           0 :         return xReturn;
     245             :     }
     246             : 
     247             :     // #100312#
     248           0 :     Reference< frame::XDispatchProviderInterception > BibBeamer::getDispatchProviderInterception()
     249             :     {
     250           0 :         Reference< frame::XDispatchProviderInterception > xReturn;
     251           0 :         if ( pGridWin )
     252           0 :             xReturn = pGridWin->getDispatchProviderInterception();
     253           0 :         return xReturn;
     254             :     }
     255             : 
     256           0 :     void BibBeamer::SetXController(const uno::Reference< frame::XController > & xCtr)
     257             :     {
     258           0 :         m_xController = xCtr;
     259             : 
     260           0 :         if ( pToolBar )
     261           0 :             pToolBar->SetXController( m_xController );
     262             : 
     263           0 :     }
     264             : 
     265           0 :     void BibBeamer::GetFocus()
     266             :     {
     267           0 :         if( pGridWin )
     268           0 :             pGridWin->GrabFocus();
     269           0 :     }
     270             : 
     271           0 :     IMPL_LINK( BibBeamer, RecalcLayout_Impl, void*, /*pVoid*/ )
     272             :     {
     273           0 :         long nHeight = pToolBar->GetSizePixel().Height();
     274           0 :         SetItemSize( ID_TOOLBAR, nHeight );
     275           0 :         return 0L;
     276             :     }
     277             : 
     278             : }   // namespace bib
     279             : 
     280             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10