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