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

Generated by: LCOV version 1.10