1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_extensions.hxx" 30*cdf0e10cSrcweir #include <osl/mutex.hxx> 31*cdf0e10cSrcweir #include <tools/urlobj.hxx> 32*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 33*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 34*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include "bibliography.hrc" 39*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 40*cdf0e10cSrcweir #include <vcl/edit.hxx> 41*cdf0e10cSrcweir #include <tools/debug.hxx> 42*cdf0e10cSrcweir #include "bibbeam.hxx" 43*cdf0e10cSrcweir #include "toolbar.hrc" 44*cdf0e10cSrcweir #include "bibresid.hxx" 45*cdf0e10cSrcweir #include "datman.hxx" 46*cdf0e10cSrcweir #ifndef BIBTOOLS_HXX 47*cdf0e10cSrcweir #include "bibtools.hxx" 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir using namespace rtl; 51*cdf0e10cSrcweir using namespace ::com::sun::star; 52*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 53*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #define C2U(cChar) OUString::createFromAscii(cChar) 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir #define PROPERTY_FRAME 1 58*cdf0e10cSrcweir #define ID_TOOLBAR 1 59*cdf0e10cSrcweir #define ID_GRIDWIN 2 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir //......................................................................... 62*cdf0e10cSrcweir namespace bib 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir //......................................................................... 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir void HandleTaskPaneList( Window* pWindow, sal_Bool bAddToList ) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir Window* pParent = pWindow->GetParent(); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir DBG_ASSERT( pParent, "-GetTaskPaneList(): everybody here should have a parent!" ); 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir SystemWindow* pSysWin = pParent->GetSystemWindow(); 75*cdf0e10cSrcweir if( pSysWin ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir TaskPaneList* pTaskPaneList = pSysWin->GetTaskPaneList(); 78*cdf0e10cSrcweir if( pTaskPaneList ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir if( bAddToList ) 81*cdf0e10cSrcweir pTaskPaneList->AddWindow( pWindow ); 82*cdf0e10cSrcweir else 83*cdf0e10cSrcweir pTaskPaneList->RemoveWindow( pWindow ); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir //===================================================================== 89*cdf0e10cSrcweir //= BibGridwin 90*cdf0e10cSrcweir //===================================================================== 91*cdf0e10cSrcweir class BibGridwin 92*cdf0e10cSrcweir :public Window //DockingWindow 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir private: 95*cdf0e10cSrcweir Reference< awt::XWindow > m_xGridWin; 96*cdf0e10cSrcweir Reference< awt::XControlModel > m_xGridModel; 97*cdf0e10cSrcweir Reference< awt::XControl > m_xControl; 98*cdf0e10cSrcweir Reference< awt::XControlContainer > m_xControlContainer; 99*cdf0e10cSrcweir // #100312# --------- 100*cdf0e10cSrcweir Reference< frame::XDispatchProviderInterception> m_xDispatchProviderInterception; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir protected: 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir virtual void Resize(); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir public: 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir BibGridwin(Window* pParent, WinBits nStyle = WB_3DLOOK ); 109*cdf0e10cSrcweir ~BibGridwin(); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir void createGridWin(const Reference< awt::XControlModel > & xDbForm); 112*cdf0e10cSrcweir void disposeGridWin(); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir const Reference< awt::XControlContainer >& getControlContainer() const { return m_xControlContainer; } 115*cdf0e10cSrcweir // #100312# --------- 116*cdf0e10cSrcweir const Reference< frame::XDispatchProviderInterception>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception; } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir virtual void GetFocus(); 119*cdf0e10cSrcweir }; 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir //--------------------------------------------------------------------- 122*cdf0e10cSrcweir BibGridwin::BibGridwin( Window* _pParent, WinBits _nStyle ) : Window( _pParent, _nStyle ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir m_xControlContainer = VCLUnoHelper::CreateControlContainer(this); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir AddToTaskPaneList( this ); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir //--------------------------------------------------------------------- 130*cdf0e10cSrcweir BibGridwin::~BibGridwin() 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir RemoveFromTaskPaneList( this ); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir disposeGridWin(); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir //--------------------------------------------------------------------- 138*cdf0e10cSrcweir void BibGridwin::Resize() 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir if(m_xGridWin.is()) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir ::Size aSize = GetOutputSizePixel(); 143*cdf0e10cSrcweir m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::SIZE); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir //--------------------------------------------------------------------- 148*cdf0e10cSrcweir void BibGridwin::createGridWin(const uno::Reference< awt::XControlModel > & xGModel) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir m_xGridModel = xGModel; 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir if( m_xControlContainer.is()) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir if ( m_xGridModel.is() && xMgr.is()) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir uno::Reference< XPropertySet > xPropSet( m_xGridModel, UNO_QUERY ); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir if ( xPropSet.is() && m_xGridModel.is() ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir uno::Any aAny = xPropSet->getPropertyValue( C2U("DefaultControl") ); 163*cdf0e10cSrcweir rtl::OUString aControlName; 164*cdf0e10cSrcweir aAny >>= aControlName; 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir m_xControl = Reference< awt::XControl > (xMgr->createInstance( aControlName ), UNO_QUERY ); 167*cdf0e10cSrcweir DBG_ASSERT( m_xControl.is(), "no GridControl created" ); 168*cdf0e10cSrcweir if ( m_xControl.is() ) 169*cdf0e10cSrcweir m_xControl->setModel( m_xGridModel ); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir if ( m_xControl.is() ) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir // Peer als Child zu dem FrameWindow 175*cdf0e10cSrcweir m_xControlContainer->addControl(C2U("GridControl"), m_xControl); 176*cdf0e10cSrcweir m_xGridWin=uno::Reference< awt::XWindow > (m_xControl, UNO_QUERY ); 177*cdf0e10cSrcweir // #100312# ----- 178*cdf0e10cSrcweir m_xDispatchProviderInterception=uno::Reference< frame::XDispatchProviderInterception > (m_xControl, UNO_QUERY ); 179*cdf0e10cSrcweir m_xGridWin->setVisible( sal_True ); 180*cdf0e10cSrcweir m_xControl->setDesignMode( sal_True ); 181*cdf0e10cSrcweir // initially switch on the desing mode - switch it off _after_ loading the form 182*cdf0e10cSrcweir // 17.10.2001 - 93107 - frank.schoenheit@sun.com 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir ::Size aSize = GetOutputSizePixel(); 185*cdf0e10cSrcweir m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::POSSIZE); 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir //--------------------------------------------------------------------- 192*cdf0e10cSrcweir void BibGridwin::disposeGridWin() 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir if ( m_xControl.is() ) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir Reference< awt::XControl > xDel( m_xControl ); 197*cdf0e10cSrcweir m_xControl = NULL; 198*cdf0e10cSrcweir m_xGridWin = NULL; 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir m_xControlContainer->removeControl( xDel ); 201*cdf0e10cSrcweir xDel->dispose(); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir //--------------------------------------------------------------------- 206*cdf0e10cSrcweir void BibGridwin::GetFocus() 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir if(m_xGridWin.is()) 209*cdf0e10cSrcweir m_xGridWin->setFocus(); 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir //--------------------------------------------------------------------- 213*cdf0e10cSrcweir BibBeamer::BibBeamer( Window* _pParent, BibDataManager* _pDM, WinBits _nStyle ) 214*cdf0e10cSrcweir :BibSplitWindow( _pParent, _nStyle | WB_NOSPLITDRAW ) 215*cdf0e10cSrcweir ,pDatMan( _pDM ) 216*cdf0e10cSrcweir ,pToolBar( NULL ) 217*cdf0e10cSrcweir ,pGridWin( NULL ) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir createToolBar(); 220*cdf0e10cSrcweir createGridWin(); 221*cdf0e10cSrcweir if ( pDatMan ) 222*cdf0e10cSrcweir pDatMan->SetToolbar(pToolBar); 223*cdf0e10cSrcweir pGridWin->Show(); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir if ( pDatMan ) 226*cdf0e10cSrcweir connectForm( pDatMan ); 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir //--------------------------------------------------------------------- 230*cdf0e10cSrcweir BibBeamer::~BibBeamer() 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir if ( isFormConnected() ) 233*cdf0e10cSrcweir disconnectForm(); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir if ( m_xToolBarRef.is() ) 236*cdf0e10cSrcweir m_xToolBarRef->dispose(); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir if ( pToolBar ) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir if ( pDatMan ) 241*cdf0e10cSrcweir pDatMan->SetToolbar(0); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir DELETEZ( pToolBar ); 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir if( pGridWin ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir BibGridwin* pDel = pGridWin; 249*cdf0e10cSrcweir pGridWin = NULL; 250*cdf0e10cSrcweir pDel->disposeGridWin(); 251*cdf0e10cSrcweir delete pDel; 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir //--------------------------------------------------------------------- 257*cdf0e10cSrcweir void BibBeamer::createToolBar() 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir pToolBar= new BibToolBar(this, LINK( this, BibBeamer, RecalcLayout_Impl )); 260*cdf0e10cSrcweir ::Size aSize=pToolBar->GetSizePixel(); 261*cdf0e10cSrcweir InsertItem(ID_TOOLBAR, pToolBar, aSize.Height(), 0, 0, SWIB_FIXED ); 262*cdf0e10cSrcweir if ( m_xController.is() ) 263*cdf0e10cSrcweir pToolBar->SetXController( m_xController ); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir //--------------------------------------------------------------------- 267*cdf0e10cSrcweir void BibBeamer::createGridWin() 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir pGridWin = new BibGridwin(this,0); 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir InsertItem(ID_GRIDWIN, pGridWin, 40, 1, 0, SWIB_RELATIVESIZE ); 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir pGridWin->createGridWin( pDatMan->updateGridModel() ); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir //--------------------------------------------------------------------- 277*cdf0e10cSrcweir Reference< awt::XControlContainer > BibBeamer::getControlContainer() 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir Reference< awt::XControlContainer > xReturn; 280*cdf0e10cSrcweir if ( pGridWin ) 281*cdf0e10cSrcweir xReturn = pGridWin->getControlContainer(); 282*cdf0e10cSrcweir return xReturn; 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir // #100312# ----------------------------------------------------------- 286*cdf0e10cSrcweir Reference< frame::XDispatchProviderInterception > BibBeamer::getDispatchProviderInterception() 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir Reference< frame::XDispatchProviderInterception > xReturn; 289*cdf0e10cSrcweir if ( pGridWin ) 290*cdf0e10cSrcweir xReturn = pGridWin->getDispatchProviderInterception(); 291*cdf0e10cSrcweir return xReturn; 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir //--------------------------------------------------------------------- 295*cdf0e10cSrcweir void BibBeamer::SetXController(const uno::Reference< frame::XController > & xCtr) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir m_xController = xCtr; 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir if ( pToolBar ) 300*cdf0e10cSrcweir pToolBar->SetXController( m_xController ); 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir //--------------------------------------------------------------------- 305*cdf0e10cSrcweir void BibBeamer::GetFocus() 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir if( pGridWin ) 308*cdf0e10cSrcweir pGridWin->GrabFocus(); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir //--------------------------------------------------------------------- 312*cdf0e10cSrcweir IMPL_LINK( BibBeamer, RecalcLayout_Impl, void*, /*pVoid*/ ) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir long nHeight = pToolBar->GetSizePixel().Height(); 315*cdf0e10cSrcweir SetItemSize( ID_TOOLBAR, nHeight ); 316*cdf0e10cSrcweir return 0L; 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir //......................................................................... 320*cdf0e10cSrcweir } // namespace bib 321*cdf0e10cSrcweir //......................................................................... 322