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

Generated by: LCOV version 1.10