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 31*cdf0e10cSrcweir #ifndef BIB_HRC 32*cdf0e10cSrcweir #include "bib.hrc" 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir #include "bibcont.hxx" 35*cdf0e10cSrcweir #include "bibbeam.hxx" 36*cdf0e10cSrcweir #include "bibmod.hxx" 37*cdf0e10cSrcweir #include "general.hxx" 38*cdf0e10cSrcweir #include "bibview.hxx" 39*cdf0e10cSrcweir #include "datman.hxx" 40*cdf0e10cSrcweir #include "bibresid.hxx" 41*cdf0e10cSrcweir #include "bibmod.hxx" 42*cdf0e10cSrcweir #include "sections.hrc" 43*cdf0e10cSrcweir #include "bibconfig.hxx" 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <vcl/svapp.hxx> 47*cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetUpdate.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/form/XLoadable.hpp> 49*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 50*cdf0e10cSrcweir #include <tools/debug.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir using namespace ::com::sun::star; 53*cdf0e10cSrcweir using namespace ::com::sun::star::form; 54*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 55*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 56*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir #define C2U( cChar ) ::rtl::OUString::createFromAscii( cChar ) 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir //......................................................................... 61*cdf0e10cSrcweir namespace bib 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir //......................................................................... 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir // ----------------------------------------------------------------------- 66*cdf0e10cSrcweir BibView::BibView( Window* _pParent, BibDataManager* _pManager, WinBits _nStyle ) 67*cdf0e10cSrcweir :BibWindow( _pParent, _nStyle ) 68*cdf0e10cSrcweir ,m_pDatMan( _pManager ) 69*cdf0e10cSrcweir ,m_xDatMan( _pManager ) 70*cdf0e10cSrcweir ,m_pGeneralPage( NULL ) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir if ( m_xDatMan.is() ) 73*cdf0e10cSrcweir connectForm( m_xDatMan ); 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir // ----------------------------------------------------------------------- 77*cdf0e10cSrcweir BibView::~BibView() 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir BibGeneralPage* pGeneralPage = m_pGeneralPage; 80*cdf0e10cSrcweir m_pGeneralPage = NULL; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir pGeneralPage->CommitActiveControl(); 83*cdf0e10cSrcweir Reference< XForm > xForm = m_pDatMan->getForm(); 84*cdf0e10cSrcweir Reference< XPropertySet > xProps( xForm, UNO_QUERY ); 85*cdf0e10cSrcweir Reference< sdbc::XResultSetUpdate > xResUpd( xProps, UNO_QUERY ); 86*cdf0e10cSrcweir DBG_ASSERT( xResUpd.is(), "BibView::~BibView: invalid form!" ); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir if ( xResUpd.is() ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir Any aModified = xProps->getPropertyValue( C2U( "IsModified" ) ); 91*cdf0e10cSrcweir sal_Bool bFlag = sal_False; 92*cdf0e10cSrcweir if ( ( aModified >>= bFlag ) && bFlag ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir try 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir Any aNew = xProps->getPropertyValue( C2U( "IsNew" ) ); 98*cdf0e10cSrcweir aNew >>= bFlag; 99*cdf0e10cSrcweir if ( bFlag ) 100*cdf0e10cSrcweir xResUpd->insertRow(); 101*cdf0e10cSrcweir else 102*cdf0e10cSrcweir xResUpd->updateRow(); 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir catch( const uno::Exception& rEx) 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir (void) rEx; 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir if ( isFormConnected() ) 112*cdf0e10cSrcweir disconnectForm(); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir pGeneralPage->RemoveListeners(); 115*cdf0e10cSrcweir m_xGeneralPage = NULL; 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir /* -----------------16.11.99 13:13------------------- 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir --------------------------------------------------*/ 121*cdf0e10cSrcweir void BibView::UpdatePages() 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir // TODO: 124*cdf0e10cSrcweir // this is _strange_: Why not updating the existent general page? 125*cdf0e10cSrcweir // I consider the current behaviour a HACK. 126*cdf0e10cSrcweir // frank.schoenheit@sun.com 127*cdf0e10cSrcweir if ( m_pGeneralPage ) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir m_pGeneralPage->Hide(); 130*cdf0e10cSrcweir m_pGeneralPage->RemoveListeners(); 131*cdf0e10cSrcweir m_xGeneralPage = 0; 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir m_xGeneralPage = m_pGeneralPage = new BibGeneralPage( this, m_pDatMan ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir Resize(); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir if( HasFocus() ) 139*cdf0e10cSrcweir // "delayed" GetFocus() because GetFocus() is initially called before GeneralPage is created 140*cdf0e10cSrcweir m_pGeneralPage->GrabFocus(); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir String sErrorString( m_pGeneralPage->GetErrorString() ); 143*cdf0e10cSrcweir if ( sErrorString.Len() ) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir sal_Bool bExecute = BibModul::GetConfig()->IsShowColumnAssignmentWarning(); 146*cdf0e10cSrcweir if(!m_pDatMan->HasActiveConnection()) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir //no connection is available -> the data base has to be assigned 149*cdf0e10cSrcweir m_pDatMan->DispatchDBChangeDialog(); 150*cdf0e10cSrcweir bExecute = sal_False; 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir else if(bExecute) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir sErrorString += '\n'; 155*cdf0e10cSrcweir sErrorString += String( BibResId( RID_MAP_QUESTION ) ); 156*cdf0e10cSrcweir QueryBox aQuery( this, WB_YES_NO, sErrorString ); 157*cdf0e10cSrcweir aQuery.SetDefaultCheckBoxText(); 158*cdf0e10cSrcweir short nResult = aQuery.Execute(); 159*cdf0e10cSrcweir BibModul::GetConfig()->SetShowColumnAssignmentWarning( 160*cdf0e10cSrcweir !aQuery.GetCheckBoxState()); 161*cdf0e10cSrcweir if( RET_YES != nResult ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir bExecute = sal_False; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir if(bExecute) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir Application::PostUserEvent( STATIC_LINK( this, BibView, CallMappingHdl ) ); 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir //--------------------------------------------------------------------- 173*cdf0e10cSrcweir //--- 19.10.01 16:55:49 ----------------------------------------------- 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir void BibView::_loaded( const EventObject& _rEvent ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir UpdatePages(); 178*cdf0e10cSrcweir FormControlContainer::_loaded( _rEvent ); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir void BibView::_reloaded( const EventObject& _rEvent ) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir UpdatePages(); 184*cdf0e10cSrcweir FormControlContainer::_loaded( _rEvent ); 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir /* -----------------------------02.02.00 16:49-------------------------------- 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 190*cdf0e10cSrcweir IMPL_STATIC_LINK( BibView, CallMappingHdl, BibView*, EMPTYARG ) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir pThis->m_pDatMan->CreateMappingDialog( pThis ); 193*cdf0e10cSrcweir return 0; 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir /* -----------------------------13.04.00 16:12-------------------------------- 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 198*cdf0e10cSrcweir void BibView::Resize() 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir if ( m_pGeneralPage ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir ::Size aSz( GetOutputSizePixel() ); 203*cdf0e10cSrcweir m_pGeneralPage->SetSizePixel( aSz ); 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir Window::Resize(); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir //--------------------------------------------------------------------- 209*cdf0e10cSrcweir //--- 18.10.01 18:52:45 ----------------------------------------------- 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir Reference< awt::XControlContainer > BibView::getControlContainer() 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir Reference< awt::XControlContainer > xReturn; 214*cdf0e10cSrcweir if ( m_pGeneralPage ) 215*cdf0e10cSrcweir xReturn = m_pGeneralPage->GetControlContainer(); 216*cdf0e10cSrcweir return xReturn; 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir void BibView::GetFocus() 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir if( m_pGeneralPage ) 222*cdf0e10cSrcweir m_pGeneralPage->GrabFocus(); 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir sal_Bool BibView::HandleShortCutKey( const KeyEvent& rKeyEvent ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir return m_pGeneralPage? m_pGeneralPage->HandleShortCutKey( rKeyEvent ) : sal_False; 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir //......................................................................... 231*cdf0e10cSrcweir } // namespace bib 232*cdf0e10cSrcweir //......................................................................... 233