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/diagnose_ex.h> 32*cdf0e10cSrcweir #include <tools/urlobj.hxx> 33*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 34*cdf0e10cSrcweir #include <com/sun/star/io/XPersistObject.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetType.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetUpdate.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XRowLocate.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/sdb/XDatabaseEnvironment.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/uno/XNamingService.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/sdbc/XDataSource.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/sdb/XCompletedConnection.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/form/XLoadable.hpp> 51*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 52*cdf0e10cSrcweir #include <com/sun/star/form/XGridColumnFactory.hpp> 53*cdf0e10cSrcweir #include <com/sun/star/io/XDataInputStream.hpp> 54*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp> 55*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProvider.hpp> 56*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentAccess.hpp> 57*cdf0e10cSrcweir #include <ucbhelper/contentbroker.hxx> 58*cdf0e10cSrcweir #include <ucbhelper/content.hxx> 59*cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx> 60*cdf0e10cSrcweir #include <comphelper/container.hxx> 61*cdf0e10cSrcweir #include <svl/urihelper.hxx> 62*cdf0e10cSrcweir #include <svtools/svtabbx.hxx> 63*cdf0e10cSrcweir #include <svtools/headbar.hxx> 64*cdf0e10cSrcweir #include <vcl/dialog.hxx> 65*cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX 66*cdf0e10cSrcweir #include <vcl/button.hxx> 67*cdf0e10cSrcweir #endif 68*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 69*cdf0e10cSrcweir #include <vcl/fixed.hxx> 70*cdf0e10cSrcweir #include <vcl/group.hxx> 71*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 72*cdf0e10cSrcweir #include <vcl/edit.hxx> 73*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 74*cdf0e10cSrcweir #include <tools/debug.hxx> 75*cdf0e10cSrcweir #include "datman.hxx" 76*cdf0e10cSrcweir #include "bibresid.hxx" 77*cdf0e10cSrcweir #include "bibmod.hxx" 78*cdf0e10cSrcweir #include "bibview.hxx" 79*cdf0e10cSrcweir // #100312# --------- 80*cdf0e10cSrcweir #include "bibbeam.hxx" 81*cdf0e10cSrcweir #include "bibprop.hrc" 82*cdf0e10cSrcweir #include "toolbar.hxx" 83*cdf0e10cSrcweir #include "toolbar.hrc" 84*cdf0e10cSrcweir #include "bibconfig.hxx" 85*cdf0e10cSrcweir #include "bibbeam.hxx" 86*cdf0e10cSrcweir #include "bib.hrc" 87*cdf0e10cSrcweir #include "datman.hrc" 88*cdf0e10cSrcweir #include "bibliography.hrc" 89*cdf0e10cSrcweir #include <connectivity/dbtools.hxx> 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir using namespace ::com::sun::star; 92*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 93*cdf0e10cSrcweir using namespace ::com::sun::star::container; 94*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 95*cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 96*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 97*cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 98*cdf0e10cSrcweir using namespace ::com::sun::star::form; 99*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 100*cdf0e10cSrcweir using namespace ::com::sun::star::ucb; 101*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 102*cdf0e10cSrcweir using namespace ::ucb; 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir #define C2U(cChar) ::rtl::OUString::createFromAscii(cChar) 105*cdf0e10cSrcweir #define C2S(cChar) String::CreateFromAscii(cChar) 106*cdf0e10cSrcweir #define MAP_TOKEN ';' 107*cdf0e10cSrcweir #define PAIR_TOKEN ':' 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir /* -----------------17.01.00 14:38------------------- 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir --------------------------------------------------*/ 113*cdf0e10cSrcweir Reference< XConnection > getConnection(const ::rtl::OUString& _rURL) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir // first get the sdb::DataSource corresponding to the url 116*cdf0e10cSrcweir Reference< XDataSource > xDataSource; 117*cdf0e10cSrcweir // is it a favorite title ? 118*cdf0e10cSrcweir Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); 119*cdf0e10cSrcweir Reference<XInterface> xNamingContextIfc = xMgr->createInstance(C2U("com.sun.star.sdb.DatabaseContext")); 120*cdf0e10cSrcweir Reference< XNameAccess > xNamingContext(xNamingContextIfc, UNO_QUERY); 121*cdf0e10cSrcweir if (xNamingContext.is() && xNamingContext->hasByName(_rURL)) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir DBG_ASSERT(Reference< XNamingService > (xNamingContext, UNO_QUERY).is(), "::getDataSource : no NamingService interface on the sdb::DatabaseAccessContext !"); 124*cdf0e10cSrcweir try 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir xDataSource = Reference< XDataSource > (Reference< XNamingService > (xNamingContext, UNO_QUERY)->getRegisteredObject(_rURL), UNO_QUERY); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir catch(Exception eEx) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir (void) eEx; // make compiler happy 131*cdf0e10cSrcweir DBG_ERROR("Exception caught in ODatabaseContext::getRegisteredObject()"); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir // build the connection from the data source 135*cdf0e10cSrcweir Reference< XConnection > xConn; 136*cdf0e10cSrcweir if (xDataSource.is()) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir // need user/pwd for this 139*cdf0e10cSrcweir ::rtl::OUString sUser, sPwd; 140*cdf0e10cSrcweir Reference< XPropertySet > xDataSourceProps(xDataSource, UNO_QUERY); 141*cdf0e10cSrcweir Reference< XCompletedConnection > xComplConn(xDataSource, UNO_QUERY); 142*cdf0e10cSrcweir /* Reference< XPropertySetInfo > xInfo = xDataSourceProps.is() ? xDataSourceProps->getPropertySetInfo() : Reference< XPropertySetInfo > (); 143*cdf0e10cSrcweir if (xInfo.is() && xInfo->hasPropertyByName(C2U("User"))) 144*cdf0e10cSrcweir xDataSourceProps->getPropertyValue(C2U("User")) >>= sUser; 145*cdf0e10cSrcweir if (xInfo.is() && xInfo->hasPropertyByName(C2U("Password"))) 146*cdf0e10cSrcweir xDataSourceProps->getPropertyValue(C2U("Password"))>>= sPwd; 147*cdf0e10cSrcweir */ 148*cdf0e10cSrcweir try 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir Reference<XInterface> xHdl = xMgr->createInstance(C2U("com.sun.star.task.InteractionHandler")); 152*cdf0e10cSrcweir Reference<task::XInteractionHandler> xIHdl(xHdl, UNO_QUERY); 153*cdf0e10cSrcweir xConn = xComplConn->connectWithCompletion(xIHdl); 154*cdf0e10cSrcweir // xConn = xDataSource->getConnection(sUser, sPwd); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir catch(SQLException&) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir // TODO : a real error handling 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir catch(Exception& e ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir (void) e; // make compiler happy 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir return xConn; 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir /* -----------------17.01.00 14:46------------------- 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir --------------------------------------------------*/ 172*cdf0e10cSrcweir Reference< XConnection > getConnection(const Reference< XInterface > & xRowSet) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir Reference< XConnection > xConn; 175*cdf0e10cSrcweir try 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir Reference< XPropertySet > xFormProps(xRowSet, UNO_QUERY); 178*cdf0e10cSrcweir if (!xFormProps.is()) 179*cdf0e10cSrcweir return xConn; 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir xConn = Reference< XConnection > (*(Reference< XInterface > *)xFormProps->getPropertyValue(C2U("ActiveConnection")).getValue(), UNO_QUERY); 182*cdf0e10cSrcweir if (!xConn.is()) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir DBG_WARNING("no active connection"); 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir catch(Exception& e ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir (void) e; // make compiler happy 190*cdf0e10cSrcweir DBG_ERROR("exception in getConnection"); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir return xConn; 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir /* -----------------17.01.00 16:07------------------- 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir --------------------------------------------------*/ 198*cdf0e10cSrcweir Reference< XNameAccess > getColumns(const Reference< XForm > & _rxForm) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir Reference< XNameAccess > xReturn; 201*cdf0e10cSrcweir // check if the form is alive 202*cdf0e10cSrcweir Reference< XColumnsSupplier > xSupplyCols( _rxForm, UNO_QUERY ); 203*cdf0e10cSrcweir if (xSupplyCols.is()) 204*cdf0e10cSrcweir xReturn = xSupplyCols->getColumns(); 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir if (!xReturn.is() || (xReturn->getElementNames().getLength() == 0)) 207*cdf0e10cSrcweir { // no .... 208*cdf0e10cSrcweir xReturn = NULL; 209*cdf0e10cSrcweir // -> get the table the form is bound to and ask it for their columns 210*cdf0e10cSrcweir Reference< XTablesSupplier > xSupplyTables( getConnection( _rxForm ), UNO_QUERY ); 211*cdf0e10cSrcweir Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY ); 212*cdf0e10cSrcweir if (xFormProps.is() && xSupplyTables.is()) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir try 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir DBG_ASSERT((*(sal_Int32*)xFormProps->getPropertyValue(C2U("CommandType")).getValue()) == CommandType::TABLE, 217*cdf0e10cSrcweir "::getColumns : invalid form (has no table as data source) !"); 218*cdf0e10cSrcweir ::rtl::OUString sTable; 219*cdf0e10cSrcweir xFormProps->getPropertyValue(C2U("Command")) >>= sTable; 220*cdf0e10cSrcweir Reference< XNameAccess > xTables = xSupplyTables->getTables(); 221*cdf0e10cSrcweir if (xTables.is() && xTables->hasByName(sTable)) 222*cdf0e10cSrcweir xSupplyCols = Reference< XColumnsSupplier > ( 223*cdf0e10cSrcweir *(Reference< XInterface > *)xTables->getByName(sTable).getValue(), UNO_QUERY); 224*cdf0e10cSrcweir if (xSupplyCols.is()) 225*cdf0e10cSrcweir xReturn = xSupplyCols->getColumns(); 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir #ifdef DBG_UTIL 228*cdf0e10cSrcweir catch(Exception& e ) 229*cdf0e10cSrcweir #else 230*cdf0e10cSrcweir catch(Exception&) 231*cdf0e10cSrcweir #endif 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir #ifdef DBG_UTIL 234*cdf0e10cSrcweir String sMsg(String::CreateFromAscii("::getColumns : catched an exception (")); 235*cdf0e10cSrcweir sMsg += String(e.Message); 236*cdf0e10cSrcweir sMsg.AppendAscii(") ..."); 237*cdf0e10cSrcweir DBG_ERROR( ByteString(sMsg, RTL_TEXTENCODING_ASCII_US ).GetBuffer()); 238*cdf0e10cSrcweir #endif 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir return xReturn; 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir /* -----------------11.11.99 15:54------------------- 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir --------------------------------------------------*/ 249*cdf0e10cSrcweir class MappingDialog_Impl : public ModalDialog 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir BibDataManager* pDatMan; 252*cdf0e10cSrcweir OKButton aOKBT; 253*cdf0e10cSrcweir CancelButton aCancelBT; 254*cdf0e10cSrcweir HelpButton aHelpBT; 255*cdf0e10cSrcweir FixedLine aMapGB; 256*cdf0e10cSrcweir FixedText aIdentifierFT; 257*cdf0e10cSrcweir ListBox aIdentifierLB; 258*cdf0e10cSrcweir FixedText aAuthorityTypeFT; 259*cdf0e10cSrcweir ListBox aAuthorityTypeLB; 260*cdf0e10cSrcweir FixedText aAuthorFT; 261*cdf0e10cSrcweir ListBox aAuthorLB; 262*cdf0e10cSrcweir FixedText aTitleFT; 263*cdf0e10cSrcweir ListBox aTitleLB; 264*cdf0e10cSrcweir FixedText aMonthFT; 265*cdf0e10cSrcweir ListBox aMonthLB; 266*cdf0e10cSrcweir FixedText aYearFT; 267*cdf0e10cSrcweir ListBox aYearLB; 268*cdf0e10cSrcweir FixedText aISBNFT; 269*cdf0e10cSrcweir ListBox aISBNLB; 270*cdf0e10cSrcweir FixedText aBooktitleFT; 271*cdf0e10cSrcweir ListBox aBooktitleLB; 272*cdf0e10cSrcweir FixedText aChapterFT; 273*cdf0e10cSrcweir ListBox aChapterLB; 274*cdf0e10cSrcweir FixedText aEditionFT; 275*cdf0e10cSrcweir ListBox aEditionLB; 276*cdf0e10cSrcweir FixedText aEditorFT; 277*cdf0e10cSrcweir ListBox aEditorLB; 278*cdf0e10cSrcweir FixedText aHowpublishedFT; 279*cdf0e10cSrcweir ListBox aHowpublishedLB; 280*cdf0e10cSrcweir FixedText aInstitutionFT; 281*cdf0e10cSrcweir ListBox aInstitutionLB; 282*cdf0e10cSrcweir FixedText aJournalFT; 283*cdf0e10cSrcweir ListBox aJournalLB; 284*cdf0e10cSrcweir FixedText aNoteFT; 285*cdf0e10cSrcweir ListBox aNoteLB; 286*cdf0e10cSrcweir FixedText aAnnoteFT; 287*cdf0e10cSrcweir ListBox aAnnoteLB; 288*cdf0e10cSrcweir FixedText aNumberFT; 289*cdf0e10cSrcweir ListBox aNumberLB; 290*cdf0e10cSrcweir FixedText aOrganizationsFT; 291*cdf0e10cSrcweir ListBox aOrganizationsLB; 292*cdf0e10cSrcweir FixedText aPagesFT; 293*cdf0e10cSrcweir ListBox aPagesLB; 294*cdf0e10cSrcweir FixedText aPublisherFT; 295*cdf0e10cSrcweir ListBox aPublisherLB; 296*cdf0e10cSrcweir FixedText aAddressFT; 297*cdf0e10cSrcweir ListBox aAddressLB; 298*cdf0e10cSrcweir FixedText aSchoolFT; 299*cdf0e10cSrcweir ListBox aSchoolLB; 300*cdf0e10cSrcweir FixedText aSeriesFT; 301*cdf0e10cSrcweir ListBox aSeriesLB; 302*cdf0e10cSrcweir FixedText aReportTypeFT; 303*cdf0e10cSrcweir ListBox aReportTypeLB; 304*cdf0e10cSrcweir FixedText aVolumeFT; 305*cdf0e10cSrcweir ListBox aVolumeLB; 306*cdf0e10cSrcweir FixedText aURLFT; 307*cdf0e10cSrcweir ListBox aURLLB; 308*cdf0e10cSrcweir FixedText aCustom1FT; 309*cdf0e10cSrcweir ListBox aCustom1LB; 310*cdf0e10cSrcweir FixedText aCustom2FT; 311*cdf0e10cSrcweir ListBox aCustom2LB; 312*cdf0e10cSrcweir FixedText aCustom3FT; 313*cdf0e10cSrcweir ListBox aCustom3LB; 314*cdf0e10cSrcweir FixedText aCustom4FT; 315*cdf0e10cSrcweir ListBox aCustom4LB; 316*cdf0e10cSrcweir FixedText aCustom5FT; 317*cdf0e10cSrcweir ListBox aCustom5LB; 318*cdf0e10cSrcweir ListBox* aListBoxes[COLUMN_COUNT]; 319*cdf0e10cSrcweir String sNone; 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir sal_Bool bModified; 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir DECL_LINK(OkHdl, OKButton*); 326*cdf0e10cSrcweir DECL_LINK(ListBoxSelectHdl, ListBox*); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir public: 329*cdf0e10cSrcweir MappingDialog_Impl(Window* pParent, BibDataManager* pDatMan); 330*cdf0e10cSrcweir ~MappingDialog_Impl(); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir void SetModified() {bModified = sal_True;} 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir }; 335*cdf0e10cSrcweir /* -----------------11.11.99 16:42------------------- 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir --------------------------------------------------*/ 338*cdf0e10cSrcweir sal_uInt16 lcl_FindLogicalName(BibConfig* pConfig , 339*cdf0e10cSrcweir const ::rtl::OUString& rLogicalColumnName) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir if(rLogicalColumnName == pConfig->GetDefColumnName(i)) 344*cdf0e10cSrcweir return i; 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir return USHRT_MAX; 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir //----------------------------------------------------------------------------- 349*cdf0e10cSrcweir MappingDialog_Impl::MappingDialog_Impl(Window* pParent, BibDataManager* pMan) : 350*cdf0e10cSrcweir ModalDialog(pParent, BibResId(RID_DLG_MAPPING) ), 351*cdf0e10cSrcweir pDatMan(pMan), 352*cdf0e10cSrcweir aOKBT(this, BibResId( BT_OK )), 353*cdf0e10cSrcweir aCancelBT(this, BibResId( BT_CANCEL )), 354*cdf0e10cSrcweir aHelpBT(this, BibResId( BT_HELP )), 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir aMapGB(this, BibResId( GB_MAPPING )), 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir aIdentifierFT(this, BibResId( FT_IDENTIFIER )), 359*cdf0e10cSrcweir aIdentifierLB(this, BibResId( LB_IDENTIFIER )), 360*cdf0e10cSrcweir aAuthorityTypeFT(this, BibResId( FT_AUTHORITYTYPE )), 361*cdf0e10cSrcweir aAuthorityTypeLB(this, BibResId( LB_AUTHORITYTYPE )), 362*cdf0e10cSrcweir aAuthorFT(this, BibResId( FT_AUTHOR )), 363*cdf0e10cSrcweir aAuthorLB(this, BibResId( LB_AUTHOR )), 364*cdf0e10cSrcweir aTitleFT(this, BibResId( FT_TITLE )), 365*cdf0e10cSrcweir aTitleLB(this, BibResId( LB_TITLE )), 366*cdf0e10cSrcweir aMonthFT(this, BibResId( FT_MONTH )), 367*cdf0e10cSrcweir aMonthLB(this, BibResId( LB_MONTH )), 368*cdf0e10cSrcweir aYearFT(this, BibResId( FT_YEAR )), 369*cdf0e10cSrcweir aYearLB(this, BibResId( LB_YEAR )), 370*cdf0e10cSrcweir aISBNFT(this, BibResId( FT_ISBN )), 371*cdf0e10cSrcweir aISBNLB(this, BibResId( LB_ISBN )), 372*cdf0e10cSrcweir aBooktitleFT(this, BibResId( FT_BOOKTITLE )), 373*cdf0e10cSrcweir aBooktitleLB(this, BibResId( LB_BOOKTITLE )), 374*cdf0e10cSrcweir aChapterFT(this, BibResId( FT_CHAPTER )), 375*cdf0e10cSrcweir aChapterLB(this, BibResId( LB_CHAPTER )), 376*cdf0e10cSrcweir aEditionFT(this, BibResId( FT_EDITION )), 377*cdf0e10cSrcweir aEditionLB(this, BibResId( LB_EDITION )), 378*cdf0e10cSrcweir aEditorFT(this, BibResId( FT_EDITOR )), 379*cdf0e10cSrcweir aEditorLB(this, BibResId( LB_EDITOR )), 380*cdf0e10cSrcweir aHowpublishedFT(this, BibResId( FT_HOWPUBLISHED )), 381*cdf0e10cSrcweir aHowpublishedLB(this, BibResId( LB_HOWPUBLISHED )), 382*cdf0e10cSrcweir aInstitutionFT(this, BibResId( FT_INSTITUTION )), 383*cdf0e10cSrcweir aInstitutionLB(this, BibResId( LB_INSTITUTION )), 384*cdf0e10cSrcweir aJournalFT(this, BibResId( FT_JOURNAL )), 385*cdf0e10cSrcweir aJournalLB(this, BibResId( LB_JOURNAL )), 386*cdf0e10cSrcweir aNoteFT(this, BibResId( FT_NOTE )), 387*cdf0e10cSrcweir aNoteLB(this, BibResId( LB_NOTE )), 388*cdf0e10cSrcweir aAnnoteFT(this, BibResId( FT_ANNOTE )), 389*cdf0e10cSrcweir aAnnoteLB(this, BibResId( LB_ANNOTE )), 390*cdf0e10cSrcweir aNumberFT(this, BibResId( FT_NUMBER )), 391*cdf0e10cSrcweir aNumberLB(this, BibResId( LB_NUMBER )), 392*cdf0e10cSrcweir aOrganizationsFT(this, BibResId( FT_ORGANIZATIONS )), 393*cdf0e10cSrcweir aOrganizationsLB(this, BibResId( LB_ORGANIZATIONS )), 394*cdf0e10cSrcweir aPagesFT(this, BibResId( FT_PAGES )), 395*cdf0e10cSrcweir aPagesLB(this, BibResId( LB_PAGES )), 396*cdf0e10cSrcweir aPublisherFT(this, BibResId( FT_PUBLISHER )), 397*cdf0e10cSrcweir aPublisherLB(this, BibResId( LB_PUBLISHER )), 398*cdf0e10cSrcweir aAddressFT(this, BibResId( FT_ADDRESS )), 399*cdf0e10cSrcweir aAddressLB(this, BibResId( LB_ADDRESS )), 400*cdf0e10cSrcweir aSchoolFT(this, BibResId( FT_SCHOOL )), 401*cdf0e10cSrcweir aSchoolLB(this, BibResId( LB_SCHOOL )), 402*cdf0e10cSrcweir aSeriesFT(this, BibResId( FT_SERIES )), 403*cdf0e10cSrcweir aSeriesLB(this, BibResId( LB_SERIES )), 404*cdf0e10cSrcweir aReportTypeFT(this, BibResId( FT_REPORTTYPE )), 405*cdf0e10cSrcweir aReportTypeLB(this, BibResId( LB_REPORTTYPE )), 406*cdf0e10cSrcweir aVolumeFT(this, BibResId( FT_VOLUME )), 407*cdf0e10cSrcweir aVolumeLB(this, BibResId( LB_VOLUME )), 408*cdf0e10cSrcweir aURLFT(this, BibResId( FT_URL )), 409*cdf0e10cSrcweir aURLLB(this, BibResId( LB_URL )), 410*cdf0e10cSrcweir aCustom1FT(this, BibResId( FT_CUSTOM1 )), 411*cdf0e10cSrcweir aCustom1LB(this, BibResId( LB_CUSTOM1 )), 412*cdf0e10cSrcweir aCustom2FT(this, BibResId( FT_CUSTOM2 )), 413*cdf0e10cSrcweir aCustom2LB(this, BibResId( LB_CUSTOM2 )), 414*cdf0e10cSrcweir aCustom3FT(this, BibResId( FT_CUSTOM3 )), 415*cdf0e10cSrcweir aCustom3LB(this, BibResId( LB_CUSTOM3 )), 416*cdf0e10cSrcweir aCustom4FT(this, BibResId( FT_CUSTOM4 )), 417*cdf0e10cSrcweir aCustom4LB(this, BibResId( LB_CUSTOM4 )), 418*cdf0e10cSrcweir aCustom5FT(this, BibResId( FT_CUSTOM5 )), 419*cdf0e10cSrcweir aCustom5LB(this, BibResId( LB_CUSTOM5 )), 420*cdf0e10cSrcweir sNone(BibResId(ST_NONE)), 421*cdf0e10cSrcweir bModified(sal_False) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir FreeResource(); 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir aIdentifierFT.SetText(String( BibResId( ST_IDENTIFIER ))); 426*cdf0e10cSrcweir aAuthorityTypeFT.SetText(String( BibResId( ST_AUTHTYPE ))); 427*cdf0e10cSrcweir aAuthorFT.SetText(String( BibResId( ST_AUTHOR ))); 428*cdf0e10cSrcweir aTitleFT.SetText(String( BibResId( ST_TITLE ))); 429*cdf0e10cSrcweir aMonthFT.SetText(String( BibResId( ST_MONTH ))); 430*cdf0e10cSrcweir aYearFT.SetText(String( BibResId( ST_YEAR ))); 431*cdf0e10cSrcweir aISBNFT.SetText(String( BibResId( ST_ISBN ))); 432*cdf0e10cSrcweir aBooktitleFT.SetText(String( BibResId( ST_BOOKTITLE ))); 433*cdf0e10cSrcweir aChapterFT.SetText(String( BibResId( ST_CHAPTER ))); 434*cdf0e10cSrcweir aEditionFT.SetText(String( BibResId( ST_EDITION ))); 435*cdf0e10cSrcweir aEditorFT.SetText(String( BibResId( ST_EDITOR ))); 436*cdf0e10cSrcweir aHowpublishedFT.SetText(String( BibResId( ST_HOWPUBLISHED ))); 437*cdf0e10cSrcweir aInstitutionFT.SetText(String( BibResId( ST_INSTITUTION ))); 438*cdf0e10cSrcweir aJournalFT.SetText(String( BibResId( ST_JOURNAL ))); 439*cdf0e10cSrcweir aNoteFT.SetText(String( BibResId( ST_NOTE ))); 440*cdf0e10cSrcweir aAnnoteFT.SetText(String( BibResId( ST_ANNOTE ))); 441*cdf0e10cSrcweir aNumberFT.SetText(String( BibResId( ST_NUMBER ))); 442*cdf0e10cSrcweir aOrganizationsFT.SetText(String( BibResId( ST_ORGANIZATION ))); 443*cdf0e10cSrcweir aPagesFT.SetText(String( BibResId( ST_PAGE ))); 444*cdf0e10cSrcweir aPublisherFT.SetText(String( BibResId( ST_PUBLISHER ))); 445*cdf0e10cSrcweir aAddressFT.SetText(String( BibResId( ST_ADDRESS ))); 446*cdf0e10cSrcweir aSchoolFT.SetText(String( BibResId( ST_SCHOOL ))); 447*cdf0e10cSrcweir aSeriesFT.SetText(String( BibResId( ST_SERIES ))); 448*cdf0e10cSrcweir aReportTypeFT.SetText(String( BibResId( ST_REPORT ))); 449*cdf0e10cSrcweir aVolumeFT.SetText(String( BibResId( ST_VOLUME ))); 450*cdf0e10cSrcweir aURLFT.SetText(String( BibResId( ST_URL ))); 451*cdf0e10cSrcweir aCustom1FT.SetText(String( BibResId( ST_CUSTOM1 ))); 452*cdf0e10cSrcweir aCustom2FT.SetText(String( BibResId( ST_CUSTOM2 ))); 453*cdf0e10cSrcweir aCustom3FT.SetText(String( BibResId( ST_CUSTOM3 ))); 454*cdf0e10cSrcweir aCustom4FT.SetText(String( BibResId( ST_CUSTOM4 ))); 455*cdf0e10cSrcweir aCustom5FT.SetText(String( BibResId( ST_CUSTOM5 ))); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir aOKBT.SetClickHdl(LINK(this, MappingDialog_Impl, OkHdl)); 458*cdf0e10cSrcweir String sTitle = GetText(); 459*cdf0e10cSrcweir sTitle.SearchAndReplace(C2S("%1"), pDatMan->getActiveDataTable(), 0); 460*cdf0e10cSrcweir SetText(sTitle); 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir aListBoxes[0] = &aIdentifierLB; 463*cdf0e10cSrcweir aListBoxes[1] = &aAuthorityTypeLB; 464*cdf0e10cSrcweir aListBoxes[2] = &aAuthorLB; 465*cdf0e10cSrcweir aListBoxes[3] = &aTitleLB; 466*cdf0e10cSrcweir aListBoxes[4] = &aYearLB; 467*cdf0e10cSrcweir aListBoxes[5] = &aISBNLB; 468*cdf0e10cSrcweir aListBoxes[6] = &aBooktitleLB; 469*cdf0e10cSrcweir aListBoxes[7] = &aChapterLB; 470*cdf0e10cSrcweir aListBoxes[8] = &aEditionLB; 471*cdf0e10cSrcweir aListBoxes[9] = &aEditorLB; 472*cdf0e10cSrcweir aListBoxes[10] = &aHowpublishedLB; 473*cdf0e10cSrcweir aListBoxes[11] = &aInstitutionLB; 474*cdf0e10cSrcweir aListBoxes[12] = &aJournalLB; 475*cdf0e10cSrcweir aListBoxes[13] = &aMonthLB; 476*cdf0e10cSrcweir aListBoxes[14] = &aNoteLB; 477*cdf0e10cSrcweir aListBoxes[15] = &aAnnoteLB; 478*cdf0e10cSrcweir aListBoxes[16] = &aNumberLB; 479*cdf0e10cSrcweir aListBoxes[17] = &aOrganizationsLB; 480*cdf0e10cSrcweir aListBoxes[18] = &aPagesLB; 481*cdf0e10cSrcweir aListBoxes[19] = &aPublisherLB; 482*cdf0e10cSrcweir aListBoxes[20] = &aAddressLB; 483*cdf0e10cSrcweir aListBoxes[21] = &aSchoolLB; 484*cdf0e10cSrcweir aListBoxes[22] = &aSeriesLB; 485*cdf0e10cSrcweir aListBoxes[23] = &aReportTypeLB; 486*cdf0e10cSrcweir aListBoxes[24] = &aVolumeLB; 487*cdf0e10cSrcweir aListBoxes[25] = &aURLLB; 488*cdf0e10cSrcweir aListBoxes[26] = &aCustom1LB; 489*cdf0e10cSrcweir aListBoxes[27] = &aCustom2LB; 490*cdf0e10cSrcweir aListBoxes[28] = &aCustom3LB; 491*cdf0e10cSrcweir aListBoxes[29] = &aCustom4LB; 492*cdf0e10cSrcweir aListBoxes[30] = &aCustom5LB; 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir aListBoxes[0]->InsertEntry(sNone); 495*cdf0e10cSrcweir Reference< XNameAccess > xFields = getColumns( pDatMan->getForm() ); 496*cdf0e10cSrcweir DBG_ASSERT(xFields.is(), "MappingDialog_Impl::MappingDialog_Impl : gave me an invalid form !"); 497*cdf0e10cSrcweir if(xFields.is()) 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames = xFields->getElementNames(); 500*cdf0e10cSrcweir sal_Int32 nFieldsCount = aNames.getLength(); 501*cdf0e10cSrcweir const ::rtl::OUString* pNames = aNames.getConstArray(); 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir for(sal_Int32 nField = 0; nField < nFieldsCount; nField++) 504*cdf0e10cSrcweir aListBoxes[0]->InsertEntry(pNames[nField]); 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir Link aLnk = LINK(this, MappingDialog_Impl, ListBoxSelectHdl); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir aListBoxes[0]->SelectEntryPos(0); 510*cdf0e10cSrcweir aListBoxes[0]->SetSelectHdl(aLnk); 511*cdf0e10cSrcweir for(sal_uInt16 i = 1; i < COLUMN_COUNT; i++) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir for(sal_uInt16 j = 0; j < aListBoxes[0]->GetEntryCount();j++) 514*cdf0e10cSrcweir aListBoxes[i]->InsertEntry(aListBoxes[0]->GetEntry(j)); 515*cdf0e10cSrcweir aListBoxes[i]->SelectEntryPos(0); 516*cdf0e10cSrcweir aListBoxes[i]->SetSelectHdl(aLnk); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir BibConfig* pConfig = BibModul::GetConfig(); 519*cdf0e10cSrcweir BibDBDescriptor aDesc; 520*cdf0e10cSrcweir aDesc.sDataSource = pDatMan->getActiveDataSource(); 521*cdf0e10cSrcweir aDesc.sTableOrQuery = pDatMan->getActiveDataTable(); 522*cdf0e10cSrcweir aDesc.nCommandType = CommandType::TABLE; 523*cdf0e10cSrcweir const Mapping* pMapping = pConfig->GetMapping(aDesc); 524*cdf0e10cSrcweir if(pMapping) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++) 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir sal_uInt16 nListBoxIndex = lcl_FindLogicalName( pConfig, pMapping->aColumnPairs[nEntry].sLogicalColumnName); 529*cdf0e10cSrcweir if(nListBoxIndex < COLUMN_COUNT) 530*cdf0e10cSrcweir { 531*cdf0e10cSrcweir aListBoxes[nListBoxIndex]->SelectEntry(pMapping->aColumnPairs[nEntry].sRealColumnName); 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir /* -----------------11.11.99 16:44------------------- 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir --------------------------------------------------*/ 539*cdf0e10cSrcweir MappingDialog_Impl::~MappingDialog_Impl() 540*cdf0e10cSrcweir {} 541*cdf0e10cSrcweir /* -----------------15.11.99 10:38------------------- 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir --------------------------------------------------*/ 544*cdf0e10cSrcweir IMPL_LINK(MappingDialog_Impl, ListBoxSelectHdl, ListBox*, pListBox) 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir sal_uInt16 nEntryPos = pListBox->GetSelectEntryPos(); 547*cdf0e10cSrcweir if(0 < nEntryPos) 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir if(pListBox != aListBoxes[i] && aListBoxes[i]->GetSelectEntryPos() == nEntryPos) 552*cdf0e10cSrcweir aListBoxes[i]->SelectEntryPos(0); 553*cdf0e10cSrcweir } 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir SetModified(); 556*cdf0e10cSrcweir return 0; 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir /* -----------------12.11.99 14:50------------------- 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir --------------------------------------------------*/ 561*cdf0e10cSrcweir IMPL_LINK(MappingDialog_Impl, OkHdl, OKButton*, EMPTYARG) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir if(bModified) 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir Mapping aNew; 566*cdf0e10cSrcweir aNew.sTableName = String(pDatMan->getActiveDataTable()); 567*cdf0e10cSrcweir aNew.sURL = String(pDatMan->getActiveDataSource()); 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir sal_uInt16 nWriteIndex = 0; 570*cdf0e10cSrcweir BibConfig* pConfig = BibModul::GetConfig(); 571*cdf0e10cSrcweir for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++) 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir String sSel = aListBoxes[nEntry]->GetSelectEntry(); 574*cdf0e10cSrcweir if(sSel != sNone) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir aNew.aColumnPairs[nWriteIndex].sRealColumnName = sSel; 577*cdf0e10cSrcweir aNew.aColumnPairs[nWriteIndex].sLogicalColumnName = pConfig->GetDefColumnName(nEntry); 578*cdf0e10cSrcweir nWriteIndex++; 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir BibDBDescriptor aDesc; 582*cdf0e10cSrcweir aDesc.sDataSource = pDatMan->getActiveDataSource(); 583*cdf0e10cSrcweir aDesc.sTableOrQuery = pDatMan->getActiveDataTable(); 584*cdf0e10cSrcweir aDesc.nCommandType = CommandType::TABLE; 585*cdf0e10cSrcweir pDatMan->ResetIdentifierMapping(); 586*cdf0e10cSrcweir pConfig->SetMapping(aDesc, &aNew); 587*cdf0e10cSrcweir } 588*cdf0e10cSrcweir EndDialog(bModified ? RET_OK : RET_CANCEL); 589*cdf0e10cSrcweir return 0; 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir /* -----------------18.11.99 10:23------------------- 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir --------------------------------------------------*/ 594*cdf0e10cSrcweir class DBChangeDialog_Impl : public ModalDialog 595*cdf0e10cSrcweir { 596*cdf0e10cSrcweir OKButton aOKBT; 597*cdf0e10cSrcweir CancelButton aCancelBT; 598*cdf0e10cSrcweir HelpButton aHelpBT; 599*cdf0e10cSrcweir FixedLine aSelectionGB; 600*cdf0e10cSrcweir SvTabListBox aSelectionLB; 601*cdf0e10cSrcweir HeaderBar aSelectionHB; 602*cdf0e10cSrcweir DBChangeDialogConfig_Impl aConfig; 603*cdf0e10cSrcweir String aEntryST; 604*cdf0e10cSrcweir String aURLST; 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir BibDataManager* pDatMan; 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir // DECL_LINK(EndDragHdl, HeaderBar*); 609*cdf0e10cSrcweir DECL_LINK(DoubleClickHdl, SvTabListBox*); 610*cdf0e10cSrcweir public: 611*cdf0e10cSrcweir DBChangeDialog_Impl(Window* pParent, BibDataManager* pMan ); 612*cdf0e10cSrcweir ~DBChangeDialog_Impl(); 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir String GetCurrentURL()const; 615*cdf0e10cSrcweir }; 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir /*-- 18.11.99 10:35:20--------------------------------------------------- 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 620*cdf0e10cSrcweir DBChangeDialog_Impl::DBChangeDialog_Impl(Window* pParent, BibDataManager* pMan ) : 621*cdf0e10cSrcweir ModalDialog(pParent, BibResId(RID_DLG_DBCHANGE) ), 622*cdf0e10cSrcweir aOKBT(this, BibResId( BT_OK )), 623*cdf0e10cSrcweir aCancelBT(this, BibResId( BT_CANCEL )), 624*cdf0e10cSrcweir aHelpBT(this, BibResId( BT_HELP )), 625*cdf0e10cSrcweir aSelectionGB(this, BibResId( GB_SELECTION )), 626*cdf0e10cSrcweir aSelectionLB(this, BibResId( LB_SELECTION )), 627*cdf0e10cSrcweir aSelectionHB(this, BibResId( HB_SELECTION )), 628*cdf0e10cSrcweir aEntryST(BibResId(ST_ENTRY)), 629*cdf0e10cSrcweir aURLST( BibResId(ST_URL)), 630*cdf0e10cSrcweir pDatMan(pMan) 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir FreeResource(); 633*cdf0e10cSrcweir aSelectionLB.SetDoubleClickHdl( LINK(this, DBChangeDialog_Impl, DoubleClickHdl)); 634*cdf0e10cSrcweir try 635*cdf0e10cSrcweir { 636*cdf0e10cSrcweir Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir ::Size aSize = aSelectionHB.GetSizePixel(); 639*cdf0e10cSrcweir long nTabs[2]; 640*cdf0e10cSrcweir nTabs[0] = 1;// Number of Tabs 641*cdf0e10cSrcweir nTabs[1] = aSize.Width() / 4; 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir aSelectionHB.SetStyle(aSelectionHB.GetStyle()|WB_STDHEADERBAR); 644*cdf0e10cSrcweir aSelectionHB.InsertItem( 1, aEntryST, aSize.Width()); 645*cdf0e10cSrcweir aSelectionHB.SetSizePixel(aSelectionHB.CalcWindowSizePixel()); 646*cdf0e10cSrcweir aSelectionHB.Show(); 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir aSelectionLB.SetTabs( &nTabs[0], MAP_PIXEL ); 649*cdf0e10cSrcweir aSelectionLB.SetStyle(aSelectionLB.GetStyle()|WB_CLIPCHILDREN|WB_SORT); 650*cdf0e10cSrcweir aSelectionLB.GetModel()->SetSortMode(SortAscending); 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir ::rtl::OUString sActiveSource = pDatMan->getActiveDataSource(); 653*cdf0e10cSrcweir const Sequence< ::rtl::OUString >& rSources = aConfig.GetDataSourceNames(); 654*cdf0e10cSrcweir const ::rtl::OUString* pSourceNames = rSources.getConstArray(); 655*cdf0e10cSrcweir for(int i = 0; i < rSources.getLength(); i++) 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir SvLBoxEntry* pEntry = aSelectionLB.InsertEntry(pSourceNames[i]); 658*cdf0e10cSrcweir if(pSourceNames[i] == sActiveSource) 659*cdf0e10cSrcweir { 660*cdf0e10cSrcweir aSelectionLB.Select(pEntry); 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir aSelectionLB.GetModel()->Resort(); 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir catch(Exception& e ) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir (void) e; // make compiler happy 668*cdf0e10cSrcweir DBG_ERROR("Exception in BibDataManager::DBChangeDialog_Impl::DBChangeDialog_Impl"); 669*cdf0e10cSrcweir } 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir } 673*cdf0e10cSrcweir /* -----------------06.12.99 12:09------------------- 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir --------------------------------------------------*/ 676*cdf0e10cSrcweir IMPL_LINK(DBChangeDialog_Impl, DoubleClickHdl, SvTabListBox*, /*pLB*/) 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir EndDialog(RET_OK); 679*cdf0e10cSrcweir return 0; 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir /* -----------------18.11.99 11:17------------------- 682*cdf0e10cSrcweir 683*cdf0e10cSrcweir --------------------------------------------------*/ 684*cdf0e10cSrcweir /*IMPL_LINK(DBChangeDialog_Impl, EndDragHdl, HeaderBar*, pHB) 685*cdf0e10cSrcweir { 686*cdf0e10cSrcweir long nTabs[3]; 687*cdf0e10cSrcweir nTabs[0] = 2;// Number of Tabs 688*cdf0e10cSrcweir nTabs[1] = 0; 689*cdf0e10cSrcweir nTabs[2] = pHB->GetItemSize( 1 ); 690*cdf0e10cSrcweir aSelectionLB.SetTabs( &nTabs[0], MAP_PIXEL ); 691*cdf0e10cSrcweir return 0; 692*cdf0e10cSrcweir };*/ 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir /*-- 18.11.99 10:35:20--------------------------------------------------- 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 697*cdf0e10cSrcweir DBChangeDialog_Impl::~DBChangeDialog_Impl() 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir } 700*cdf0e10cSrcweir /* -----------------18.11.99 12:36------------------- 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir --------------------------------------------------*/ 703*cdf0e10cSrcweir String DBChangeDialog_Impl::GetCurrentURL()const 704*cdf0e10cSrcweir { 705*cdf0e10cSrcweir String sRet; 706*cdf0e10cSrcweir SvLBoxEntry* pEntry = aSelectionLB.FirstSelected(); 707*cdf0e10cSrcweir if(pEntry) 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir sRet = aSelectionLB.GetEntryText(pEntry, 0); 710*cdf0e10cSrcweir } 711*cdf0e10cSrcweir return sRet; 712*cdf0e10cSrcweir } 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir // #100312# -------------------------------------------------------------------- 715*cdf0e10cSrcweir // XDispatchProvider 716*cdf0e10cSrcweir BibInterceptorHelper::BibInterceptorHelper( ::bib::BibBeamer* pBibBeamer, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch) 717*cdf0e10cSrcweir { 718*cdf0e10cSrcweir if( pBibBeamer ) 719*cdf0e10cSrcweir { 720*cdf0e10cSrcweir xInterception = pBibBeamer->getDispatchProviderInterception(); 721*cdf0e10cSrcweir if( xInterception.is() ) 722*cdf0e10cSrcweir xInterception->registerDispatchProviderInterceptor( this ); 723*cdf0e10cSrcweir } 724*cdf0e10cSrcweir if( xDispatch.is() ) 725*cdf0e10cSrcweir xFormDispatch = xDispatch; 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir BibInterceptorHelper::~BibInterceptorHelper( ) 729*cdf0e10cSrcweir { 730*cdf0e10cSrcweir } 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir void BibInterceptorHelper::ReleaseInterceptor() 733*cdf0e10cSrcweir { 734*cdf0e10cSrcweir if ( xInterception.is() ) 735*cdf0e10cSrcweir xInterception->releaseDispatchProviderInterceptor( this ); 736*cdf0e10cSrcweir xInterception.clear(); 737*cdf0e10cSrcweir } 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL 740*cdf0e10cSrcweir BibInterceptorHelper::queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw (::com::sun::star::uno::RuntimeException) 741*cdf0e10cSrcweir { 742*cdf0e10cSrcweir Reference< XDispatch > xReturn; 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir String aCommand( aURL.Path ); 745*cdf0e10cSrcweir if ( aCommand.EqualsAscii("FormSlots/ConfirmDeletion") ) 746*cdf0e10cSrcweir xReturn = xFormDispatch; 747*cdf0e10cSrcweir else 748*cdf0e10cSrcweir if ( xSlaveDispatchProvider.is() ) 749*cdf0e10cSrcweir xReturn = xSlaveDispatchProvider->queryDispatch( aURL, aTargetFrameName, nSearchFlags); 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir return xReturn; 752*cdf0e10cSrcweir } 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL 755*cdf0e10cSrcweir BibInterceptorHelper::queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw (::com::sun::star::uno::RuntimeException) 756*cdf0e10cSrcweir { 757*cdf0e10cSrcweir Sequence< Reference< XDispatch> > aReturn( aDescripts.getLength() ); 758*cdf0e10cSrcweir Reference< XDispatch >* pReturn = aReturn.getArray(); 759*cdf0e10cSrcweir const DispatchDescriptor* pDescripts = aDescripts.getConstArray(); 760*cdf0e10cSrcweir for ( sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts ) 761*cdf0e10cSrcweir { 762*cdf0e10cSrcweir *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags ); 763*cdf0e10cSrcweir } 764*cdf0e10cSrcweir return aReturn; 765*cdf0e10cSrcweir } 766*cdf0e10cSrcweir 767*cdf0e10cSrcweir // XDispatchProviderInterceptor 768*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL 769*cdf0e10cSrcweir BibInterceptorHelper::getSlaveDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException) 770*cdf0e10cSrcweir { 771*cdf0e10cSrcweir return xSlaveDispatchProvider; 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir 774*cdf0e10cSrcweir void SAL_CALL BibInterceptorHelper::setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlaveDispatchProvider ) throw (::com::sun::star::uno::RuntimeException) 775*cdf0e10cSrcweir { 776*cdf0e10cSrcweir xSlaveDispatchProvider = xNewSlaveDispatchProvider; 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL 780*cdf0e10cSrcweir BibInterceptorHelper::getMasterDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException) 781*cdf0e10cSrcweir { 782*cdf0e10cSrcweir return xMasterDispatchProvider; 783*cdf0e10cSrcweir } 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir void SAL_CALL BibInterceptorHelper::setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMasterDispatchProvider ) throw (::com::sun::star::uno::RuntimeException) 786*cdf0e10cSrcweir { 787*cdf0e10cSrcweir xMasterDispatchProvider = xNewMasterDispatchProvider; 788*cdf0e10cSrcweir } 789*cdf0e10cSrcweir 790*cdf0e10cSrcweir //----------------------------------------------------------------------------- 791*cdf0e10cSrcweir #define STR_UID "uid" 792*cdf0e10cSrcweir ::rtl::OUString gGridName(C2U("theGrid")); 793*cdf0e10cSrcweir ::rtl::OUString gViewName(C2U("theView")); 794*cdf0e10cSrcweir ::rtl::OUString gGlobalName(C2U("theGlobals")); 795*cdf0e10cSrcweir ::rtl::OUString gBeamerSize(C2U("theBeamerSize")); 796*cdf0e10cSrcweir ::rtl::OUString gViewSize(C2U("theViewSize")); 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir BibDataManager::BibDataManager() 799*cdf0e10cSrcweir :BibDataManager_Base( GetMutex() ) 800*cdf0e10cSrcweir // #100312# -------------- 801*cdf0e10cSrcweir ,m_pInterceptorHelper( NULL ) 802*cdf0e10cSrcweir ,m_aLoadListeners(m_aMutex) 803*cdf0e10cSrcweir ,pBibView( NULL ) 804*cdf0e10cSrcweir ,pToolbar(0) 805*cdf0e10cSrcweir { 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir /* -------------------------------------------------- 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir --------------------------------------------------*/ 811*cdf0e10cSrcweir BibDataManager::~BibDataManager() 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir Reference< XLoadable > xLoad( m_xForm, UNO_QUERY ); 814*cdf0e10cSrcweir Reference< XPropertySet > xPrSet( m_xForm, UNO_QUERY ); 815*cdf0e10cSrcweir Reference< XComponent > xComp( m_xForm, UNO_QUERY ); 816*cdf0e10cSrcweir if ( m_xForm.is() ) 817*cdf0e10cSrcweir { 818*cdf0e10cSrcweir Reference< XComponent > xConnection; 819*cdf0e10cSrcweir xPrSet->getPropertyValue(C2U("ActiveConnection")) >>= xConnection; 820*cdf0e10cSrcweir RemoveMeAsUidListener(); 821*cdf0e10cSrcweir if (xLoad.is()) 822*cdf0e10cSrcweir xLoad->unload(); 823*cdf0e10cSrcweir if (xComp.is()) 824*cdf0e10cSrcweir xComp->dispose(); 825*cdf0e10cSrcweir if(xConnection.is()) 826*cdf0e10cSrcweir xConnection->dispose(); 827*cdf0e10cSrcweir m_xForm = NULL; 828*cdf0e10cSrcweir } 829*cdf0e10cSrcweir // #100312# ---------------- 830*cdf0e10cSrcweir if( m_pInterceptorHelper ) 831*cdf0e10cSrcweir { 832*cdf0e10cSrcweir m_pInterceptorHelper->ReleaseInterceptor(); 833*cdf0e10cSrcweir m_pInterceptorHelper->release(); 834*cdf0e10cSrcweir m_pInterceptorHelper = NULL; 835*cdf0e10cSrcweir } 836*cdf0e10cSrcweir } 837*cdf0e10cSrcweir //------------------------------------------------------------------------ 838*cdf0e10cSrcweir void BibDataManager::InsertFields(const Reference< XFormComponent > & _rxGrid) 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir if ( !_rxGrid.is() ) 841*cdf0e10cSrcweir return; 842*cdf0e10cSrcweir 843*cdf0e10cSrcweir try 844*cdf0e10cSrcweir { 845*cdf0e10cSrcweir Reference< XNameContainer > xColContainer( _rxGrid, UNO_QUERY ); 846*cdf0e10cSrcweir // remove the old fields 847*cdf0e10cSrcweir if ( xColContainer->hasElements() ) 848*cdf0e10cSrcweir { 849*cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames = xColContainer->getElementNames(); 850*cdf0e10cSrcweir const ::rtl::OUString* pNames = aNames.getConstArray(); 851*cdf0e10cSrcweir const ::rtl::OUString* pNamesEnd = pNames + aNames.getLength(); 852*cdf0e10cSrcweir for ( ; pNames != pNamesEnd; ++pNames ) 853*cdf0e10cSrcweir xColContainer->removeByName( *pNames ); 854*cdf0e10cSrcweir } 855*cdf0e10cSrcweir 856*cdf0e10cSrcweir Reference< XNameAccess > xFields = getColumns( m_xForm ); 857*cdf0e10cSrcweir if (!xFields.is()) 858*cdf0e10cSrcweir return; 859*cdf0e10cSrcweir 860*cdf0e10cSrcweir Reference< XGridColumnFactory > xColFactory( _rxGrid, UNO_QUERY ); 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir Reference< XPropertySet > xField; 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir Sequence< ::rtl::OUString > aFields( xFields->getElementNames() ); 865*cdf0e10cSrcweir const ::rtl::OUString* pFields = aFields.getConstArray(); 866*cdf0e10cSrcweir const ::rtl::OUString* pFieldsEnd = pFields + aFields.getLength(); 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir for ( ; pFields != pFieldsEnd; ++pFields ) 869*cdf0e10cSrcweir { 870*cdf0e10cSrcweir xFields->getByName( *pFields ) >>= xField; 871*cdf0e10cSrcweir 872*cdf0e10cSrcweir ::rtl::OUString sCurrentModelType; 873*cdf0e10cSrcweir const ::rtl::OUString sType(C2U("Type")); 874*cdf0e10cSrcweir sal_Int32 nType = 0; 875*cdf0e10cSrcweir sal_Bool bIsFormatted = sal_False; 876*cdf0e10cSrcweir sal_Bool bFormattedIsNumeric = sal_True; 877*cdf0e10cSrcweir xField->getPropertyValue(sType) >>= nType; 878*cdf0e10cSrcweir switch(nType) 879*cdf0e10cSrcweir { 880*cdf0e10cSrcweir case DataType::BIT: 881*cdf0e10cSrcweir case DataType::BOOLEAN: 882*cdf0e10cSrcweir sCurrentModelType = C2U("CheckBox"); 883*cdf0e10cSrcweir break; 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir case DataType::BINARY: 886*cdf0e10cSrcweir case DataType::VARBINARY: 887*cdf0e10cSrcweir case DataType::LONGVARBINARY: 888*cdf0e10cSrcweir case DataType::BLOB: 889*cdf0e10cSrcweir sCurrentModelType = C2U("TextField"); 890*cdf0e10cSrcweir break; 891*cdf0e10cSrcweir 892*cdf0e10cSrcweir case DataType::VARCHAR: 893*cdf0e10cSrcweir case DataType::LONGVARCHAR: 894*cdf0e10cSrcweir case DataType::CHAR: 895*cdf0e10cSrcweir case DataType::CLOB: 896*cdf0e10cSrcweir bFormattedIsNumeric = sal_False; 897*cdf0e10cSrcweir // _NO_ break ! 898*cdf0e10cSrcweir default: 899*cdf0e10cSrcweir sCurrentModelType = C2U("FormattedField"); 900*cdf0e10cSrcweir bIsFormatted = sal_True; 901*cdf0e10cSrcweir break; 902*cdf0e10cSrcweir } 903*cdf0e10cSrcweir 904*cdf0e10cSrcweir Reference< XPropertySet > xCurrentCol = xColFactory->createColumn(sCurrentModelType); 905*cdf0e10cSrcweir if (bIsFormatted) 906*cdf0e10cSrcweir { 907*cdf0e10cSrcweir ::rtl::OUString sFormatKey(C2U("FormatKey")); 908*cdf0e10cSrcweir xCurrentCol->setPropertyValue(sFormatKey, xField->getPropertyValue(sFormatKey)); 909*cdf0e10cSrcweir Any aFormatted(&bFormattedIsNumeric, ::getBooleanCppuType()); 910*cdf0e10cSrcweir xCurrentCol->setPropertyValue(C2U("TreatAsNumber"), aFormatted); 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir Any aColName = makeAny( *pFields ); 913*cdf0e10cSrcweir xCurrentCol->setPropertyValue(FM_PROP_CONTROLSOURCE, aColName); 914*cdf0e10cSrcweir xCurrentCol->setPropertyValue(FM_PROP_LABEL, aColName); 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir xColContainer->insertByName( *pFields, makeAny( xCurrentCol ) ); 917*cdf0e10cSrcweir } 918*cdf0e10cSrcweir } 919*cdf0e10cSrcweir catch(Exception& e ) 920*cdf0e10cSrcweir { 921*cdf0e10cSrcweir (void) e; // make compiler happy 922*cdf0e10cSrcweir DBG_ERROR("Exception in BibDataManager::InsertFields"); 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir } 925*cdf0e10cSrcweir /* -------------------------------------------------- 926*cdf0e10cSrcweir 927*cdf0e10cSrcweir --------------------------------------------------*/ 928*cdf0e10cSrcweir Reference< awt::XControlModel > BibDataManager::updateGridModel() 929*cdf0e10cSrcweir { 930*cdf0e10cSrcweir return updateGridModel( m_xForm ); 931*cdf0e10cSrcweir } 932*cdf0e10cSrcweir /* -------------------------------------------------- 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir --------------------------------------------------*/ 935*cdf0e10cSrcweir Reference< awt::XControlModel > BibDataManager::updateGridModel(const Reference< XForm > & xDbForm) 936*cdf0e10cSrcweir { 937*cdf0e10cSrcweir try 938*cdf0e10cSrcweir { 939*cdf0e10cSrcweir Reference< XPropertySet > aFormPropSet( xDbForm, UNO_QUERY ); 940*cdf0e10cSrcweir ::rtl::OUString sName; 941*cdf0e10cSrcweir aFormPropSet->getPropertyValue(C2U("Command")) >>= sName; 942*cdf0e10cSrcweir 943*cdf0e10cSrcweir if ( !m_xGridModel.is() ) 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir m_xGridModel = createGridModel( gGridName ); 946*cdf0e10cSrcweir 947*cdf0e10cSrcweir Reference< XNameContainer > xNameCont(xDbForm, UNO_QUERY); 948*cdf0e10cSrcweir // if (xNameCont->hasByName(sName)) 949*cdf0e10cSrcweir // xNameCont->removeByName(sName); 950*cdf0e10cSrcweir // 951*cdf0e10cSrcweir xNameCont->insertByName( sName, makeAny( m_xGridModel ) ); 952*cdf0e10cSrcweir } 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir // insert the fields 955*cdf0e10cSrcweir Reference< XFormComponent > xFormComp( m_xGridModel, UNO_QUERY ); 956*cdf0e10cSrcweir InsertFields( xFormComp ); 957*cdf0e10cSrcweir } 958*cdf0e10cSrcweir catch(Exception& e ) 959*cdf0e10cSrcweir { 960*cdf0e10cSrcweir (void) e; // make compiler happy 961*cdf0e10cSrcweir DBG_ERROR("::updateGridModel: something went wrong !"); 962*cdf0e10cSrcweir } 963*cdf0e10cSrcweir 964*cdf0e10cSrcweir 965*cdf0e10cSrcweir return m_xGridModel; 966*cdf0e10cSrcweir } 967*cdf0e10cSrcweir /* -------------------------------------------------- 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir --------------------------------------------------*/ 970*cdf0e10cSrcweir Reference< XForm > BibDataManager::createDatabaseForm(BibDBDescriptor& rDesc) 971*cdf0e10cSrcweir { 972*cdf0e10cSrcweir Reference< XForm > xResult; 973*cdf0e10cSrcweir try 974*cdf0e10cSrcweir { 975*cdf0e10cSrcweir Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); 976*cdf0e10cSrcweir m_xForm = Reference< XForm > ( xMgr->createInstance( C2U("com.sun.star.form.component.Form") ), UNO_QUERY ); 977*cdf0e10cSrcweir 978*cdf0e10cSrcweir Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY ); 979*cdf0e10cSrcweir 980*cdf0e10cSrcweir aDataSourceURL = rDesc.sDataSource; 981*cdf0e10cSrcweir if(aPropertySet.is()) 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir Any aVal; 984*cdf0e10cSrcweir aVal <<= (sal_Int32)ResultSetType::SCROLL_INSENSITIVE; 985*cdf0e10cSrcweir aPropertySet->setPropertyValue(C2U("ResultSetType"),aVal ); 986*cdf0e10cSrcweir aVal <<= (sal_Int32)ResultSetConcurrency::READ_ONLY; 987*cdf0e10cSrcweir aPropertySet->setPropertyValue(C2U("ResultSetConcurrency"), aVal); 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir //Caching for Performance 990*cdf0e10cSrcweir aVal <<= (sal_Int32)50; 991*cdf0e10cSrcweir aPropertySet->setPropertyValue(C2U("FetchSize"), aVal); 992*cdf0e10cSrcweir 993*cdf0e10cSrcweir Reference< XConnection > xConnection = getConnection(rDesc.sDataSource); 994*cdf0e10cSrcweir aVal <<= xConnection; 995*cdf0e10cSrcweir aPropertySet->setPropertyValue(C2U("ActiveConnection"), aVal); 996*cdf0e10cSrcweir 997*cdf0e10cSrcweir Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY); 998*cdf0e10cSrcweir Reference< XNameAccess > xTables = xSupplyTables.is() ? 999*cdf0e10cSrcweir xSupplyTables->getTables() : Reference< XNameAccess > (); 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir Sequence< ::rtl::OUString > aTableNameSeq; 1002*cdf0e10cSrcweir if (xTables.is()) 1003*cdf0e10cSrcweir aTableNameSeq = xTables->getElementNames(); 1004*cdf0e10cSrcweir 1005*cdf0e10cSrcweir if(aTableNameSeq.getLength() > 0) 1006*cdf0e10cSrcweir { 1007*cdf0e10cSrcweir const ::rtl::OUString* pTableNames = aTableNameSeq.getConstArray(); 1008*cdf0e10cSrcweir if(rDesc.sTableOrQuery.getLength()) 1009*cdf0e10cSrcweir aActiveDataTable = rDesc.sTableOrQuery; 1010*cdf0e10cSrcweir else 1011*cdf0e10cSrcweir { 1012*cdf0e10cSrcweir rDesc.sTableOrQuery = aActiveDataTable = pTableNames[0]; 1013*cdf0e10cSrcweir rDesc.nCommandType = CommandType::TABLE; 1014*cdf0e10cSrcweir } 1015*cdf0e10cSrcweir 1016*cdf0e10cSrcweir aVal <<= aActiveDataTable; 1017*cdf0e10cSrcweir aPropertySet->setPropertyValue(C2U("Command"), aVal); 1018*cdf0e10cSrcweir aVal <<= rDesc.nCommandType; 1019*cdf0e10cSrcweir aPropertySet->setPropertyValue(C2U("CommandType"), aVal); 1020*cdf0e10cSrcweir 1021*cdf0e10cSrcweir 1022*cdf0e10cSrcweir Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); 1023*cdf0e10cSrcweir aQuoteChar = xMetaData->getIdentifierQuoteString(); 1024*cdf0e10cSrcweir 1025*cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY); 1026*cdf0e10cSrcweir if ( xFactory.is() ) 1027*cdf0e10cSrcweir m_xParser.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), UNO_QUERY ); 1028*cdf0e10cSrcweir 1029*cdf0e10cSrcweir ::rtl::OUString aString(C2U("SELECT * FROM ")); 1030*cdf0e10cSrcweir 1031*cdf0e10cSrcweir ::rtl::OUString sCatalog, sSchema, sName; 1032*cdf0e10cSrcweir ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation ); 1033*cdf0e10cSrcweir aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName ); 1034*cdf0e10cSrcweir 1035*cdf0e10cSrcweir m_xParser->setElementaryQuery(aString); 1036*cdf0e10cSrcweir BibConfig* pConfig = BibModul::GetConfig(); 1037*cdf0e10cSrcweir pConfig->setQueryField(getQueryField()); 1038*cdf0e10cSrcweir startQueryWith(pConfig->getQueryText()); 1039*cdf0e10cSrcweir 1040*cdf0e10cSrcweir xResult = m_xForm; 1041*cdf0e10cSrcweir } 1042*cdf0e10cSrcweir } 1043*cdf0e10cSrcweir } 1044*cdf0e10cSrcweir catch(Exception& e ) 1045*cdf0e10cSrcweir { 1046*cdf0e10cSrcweir (void) e; // make compiler happy 1047*cdf0e10cSrcweir DBG_ERROR("::createDatabaseForm: something went wrong !"); 1048*cdf0e10cSrcweir } 1049*cdf0e10cSrcweir 1050*cdf0e10cSrcweir 1051*cdf0e10cSrcweir return xResult; 1052*cdf0e10cSrcweir } 1053*cdf0e10cSrcweir //------------------------------------------------------------------------ 1054*cdf0e10cSrcweir Sequence< ::rtl::OUString > BibDataManager::getDataSources() 1055*cdf0e10cSrcweir { 1056*cdf0e10cSrcweir Sequence< ::rtl::OUString > aTableNameSeq; 1057*cdf0e10cSrcweir 1058*cdf0e10cSrcweir try 1059*cdf0e10cSrcweir { 1060*cdf0e10cSrcweir Reference< XTablesSupplier > xSupplyTables( getConnection( m_xForm ), UNO_QUERY ); 1061*cdf0e10cSrcweir Reference< XNameAccess > xTables; 1062*cdf0e10cSrcweir if (xSupplyTables.is()) 1063*cdf0e10cSrcweir xTables = xSupplyTables->getTables(); 1064*cdf0e10cSrcweir if (xTables.is()) 1065*cdf0e10cSrcweir aTableNameSeq = xTables->getElementNames(); 1066*cdf0e10cSrcweir } 1067*cdf0e10cSrcweir catch(Exception& e ) 1068*cdf0e10cSrcweir { 1069*cdf0e10cSrcweir (void) e; // make compiler happy 1070*cdf0e10cSrcweir DBG_ERROR("::getDataSources: something went wrong !"); 1071*cdf0e10cSrcweir } 1072*cdf0e10cSrcweir 1073*cdf0e10cSrcweir 1074*cdf0e10cSrcweir return aTableNameSeq; 1075*cdf0e10cSrcweir } 1076*cdf0e10cSrcweir //------------------------------------------------------------------------ 1077*cdf0e10cSrcweir ::rtl::OUString BibDataManager::getActiveDataTable() 1078*cdf0e10cSrcweir { 1079*cdf0e10cSrcweir return aActiveDataTable; 1080*cdf0e10cSrcweir } 1081*cdf0e10cSrcweir //------------------------------------------------------------------------ 1082*cdf0e10cSrcweir void BibDataManager::setFilter(const ::rtl::OUString& rQuery) 1083*cdf0e10cSrcweir { 1084*cdf0e10cSrcweir if(!m_xParser.is()) 1085*cdf0e10cSrcweir return; 1086*cdf0e10cSrcweir try 1087*cdf0e10cSrcweir { 1088*cdf0e10cSrcweir m_xParser->setFilter( rQuery ); 1089*cdf0e10cSrcweir ::rtl::OUString aQuery = m_xParser->getFilter(); 1090*cdf0e10cSrcweir Reference< XPropertySet > xFormProps( m_xForm, UNO_QUERY_THROW ); 1091*cdf0e10cSrcweir xFormProps->setPropertyValue( C2U( "Filter" ), makeAny( aQuery ) ); 1092*cdf0e10cSrcweir xFormProps->setPropertyValue( C2U( "ApplyFilter" ), makeAny( sal_True ) ); 1093*cdf0e10cSrcweir reload(); 1094*cdf0e10cSrcweir } 1095*cdf0e10cSrcweir catch(Exception& e ) 1096*cdf0e10cSrcweir { 1097*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1098*cdf0e10cSrcweir } 1099*cdf0e10cSrcweir 1100*cdf0e10cSrcweir 1101*cdf0e10cSrcweir } 1102*cdf0e10cSrcweir //------------------------------------------------------------------------ 1103*cdf0e10cSrcweir ::rtl::OUString BibDataManager::getFilter() 1104*cdf0e10cSrcweir { 1105*cdf0e10cSrcweir 1106*cdf0e10cSrcweir ::rtl::OUString aQueryString; 1107*cdf0e10cSrcweir try 1108*cdf0e10cSrcweir { 1109*cdf0e10cSrcweir Reference< XPropertySet > xFormProps( m_xForm, UNO_QUERY_THROW ); 1110*cdf0e10cSrcweir OSL_VERIFY( xFormProps->getPropertyValue( C2U( "Filter" ) ) >>= aQueryString ); 1111*cdf0e10cSrcweir } 1112*cdf0e10cSrcweir catch( const Exception& ) 1113*cdf0e10cSrcweir { 1114*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1115*cdf0e10cSrcweir } 1116*cdf0e10cSrcweir 1117*cdf0e10cSrcweir 1118*cdf0e10cSrcweir return aQueryString; 1119*cdf0e10cSrcweir 1120*cdf0e10cSrcweir } 1121*cdf0e10cSrcweir //------------------------------------------------------------------------ 1122*cdf0e10cSrcweir Sequence< ::rtl::OUString > BibDataManager::getQueryFields() 1123*cdf0e10cSrcweir { 1124*cdf0e10cSrcweir Sequence< ::rtl::OUString > aFieldSeq; 1125*cdf0e10cSrcweir Reference< XNameAccess > xFields = getColumns( m_xForm ); 1126*cdf0e10cSrcweir if (xFields.is()) 1127*cdf0e10cSrcweir aFieldSeq = xFields->getElementNames(); 1128*cdf0e10cSrcweir return aFieldSeq; 1129*cdf0e10cSrcweir } 1130*cdf0e10cSrcweir //------------------------------------------------------------------------ 1131*cdf0e10cSrcweir ::rtl::OUString BibDataManager::getQueryField() 1132*cdf0e10cSrcweir { 1133*cdf0e10cSrcweir BibConfig* pConfig = BibModul::GetConfig(); 1134*cdf0e10cSrcweir ::rtl::OUString aFieldString = pConfig->getQueryField(); 1135*cdf0e10cSrcweir if(!aFieldString.getLength()) 1136*cdf0e10cSrcweir { 1137*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSeq = getQueryFields(); 1138*cdf0e10cSrcweir const ::rtl::OUString* pFields = aSeq.getConstArray(); 1139*cdf0e10cSrcweir if(aSeq.getLength()>0) 1140*cdf0e10cSrcweir { 1141*cdf0e10cSrcweir aFieldString=pFields[0]; 1142*cdf0e10cSrcweir } 1143*cdf0e10cSrcweir } 1144*cdf0e10cSrcweir return aFieldString; 1145*cdf0e10cSrcweir } 1146*cdf0e10cSrcweir //------------------------------------------------------------------------ 1147*cdf0e10cSrcweir void BibDataManager::startQueryWith(const ::rtl::OUString& rQuery) 1148*cdf0e10cSrcweir { 1149*cdf0e10cSrcweir BibConfig* pConfig = BibModul::GetConfig(); 1150*cdf0e10cSrcweir pConfig->setQueryText( rQuery ); 1151*cdf0e10cSrcweir 1152*cdf0e10cSrcweir ::rtl::OUString aQueryString; 1153*cdf0e10cSrcweir if(rQuery.getLength()>0) 1154*cdf0e10cSrcweir { 1155*cdf0e10cSrcweir aQueryString=aQuoteChar; 1156*cdf0e10cSrcweir aQueryString+=getQueryField(); 1157*cdf0e10cSrcweir aQueryString+=aQuoteChar; 1158*cdf0e10cSrcweir aQueryString+=C2U(" like '"); 1159*cdf0e10cSrcweir String sQuery(rQuery); 1160*cdf0e10cSrcweir sQuery.SearchAndReplaceAll('?','_'); 1161*cdf0e10cSrcweir sQuery.SearchAndReplaceAll('*','%'); 1162*cdf0e10cSrcweir aQueryString += sQuery; 1163*cdf0e10cSrcweir aQueryString+=C2U("%'"); 1164*cdf0e10cSrcweir } 1165*cdf0e10cSrcweir setFilter(aQueryString); 1166*cdf0e10cSrcweir } 1167*cdf0e10cSrcweir /* -----------------03.12.99 15:05------------------- 1168*cdf0e10cSrcweir 1169*cdf0e10cSrcweir --------------------------------------------------*/ 1170*cdf0e10cSrcweir void BibDataManager::setActiveDataSource(const ::rtl::OUString& rURL) 1171*cdf0e10cSrcweir { 1172*cdf0e10cSrcweir ::rtl::OUString uTable; 1173*cdf0e10cSrcweir ::rtl::OUString sTmp(aDataSourceURL); 1174*cdf0e10cSrcweir aDataSourceURL = rURL; 1175*cdf0e10cSrcweir 1176*cdf0e10cSrcweir Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY ); 1177*cdf0e10cSrcweir if(aPropertySet.is()) 1178*cdf0e10cSrcweir { 1179*cdf0e10cSrcweir unload(); 1180*cdf0e10cSrcweir 1181*cdf0e10cSrcweir Reference< XComponent > xOldConnection; 1182*cdf0e10cSrcweir aPropertySet->getPropertyValue(C2U("ActiveConnection")) >>= xOldConnection; 1183*cdf0e10cSrcweir 1184*cdf0e10cSrcweir Reference< XConnection > xConnection = getConnection(rURL); 1185*cdf0e10cSrcweir if(!xConnection.is()) 1186*cdf0e10cSrcweir { 1187*cdf0e10cSrcweir aDataSourceURL = sTmp; 1188*cdf0e10cSrcweir return; 1189*cdf0e10cSrcweir } 1190*cdf0e10cSrcweir Any aVal; aVal <<= xConnection; 1191*cdf0e10cSrcweir aPropertySet->setPropertyValue(C2U("ActiveConnection"), aVal); 1192*cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY); 1193*cdf0e10cSrcweir if ( xFactory.is() ) 1194*cdf0e10cSrcweir m_xParser.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), UNO_QUERY ); 1195*cdf0e10cSrcweir 1196*cdf0e10cSrcweir if(xOldConnection.is()) 1197*cdf0e10cSrcweir xOldConnection->dispose(); 1198*cdf0e10cSrcweir 1199*cdf0e10cSrcweir Sequence< ::rtl::OUString > aTableNameSeq; 1200*cdf0e10cSrcweir Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY); 1201*cdf0e10cSrcweir if(xSupplyTables.is()) 1202*cdf0e10cSrcweir { 1203*cdf0e10cSrcweir Reference< XNameAccess > xAccess = xSupplyTables->getTables(); 1204*cdf0e10cSrcweir aTableNameSeq = xAccess->getElementNames(); 1205*cdf0e10cSrcweir } 1206*cdf0e10cSrcweir if(aTableNameSeq.getLength() > 0) 1207*cdf0e10cSrcweir { 1208*cdf0e10cSrcweir const ::rtl::OUString* pTableNames = aTableNameSeq.getConstArray(); 1209*cdf0e10cSrcweir aActiveDataTable = pTableNames[0]; 1210*cdf0e10cSrcweir aVal <<= aActiveDataTable; 1211*cdf0e10cSrcweir aPropertySet->setPropertyValue(C2U("Command"), aVal); 1212*cdf0e10cSrcweir aPropertySet->setPropertyValue(C2U("CommandType"), makeAny(CommandType::TABLE)); 1213*cdf0e10cSrcweir //Caching for Performance 1214*cdf0e10cSrcweir aVal <<= (sal_Int32)50; 1215*cdf0e10cSrcweir aPropertySet->setPropertyValue(C2U("FetchSize"), aVal); 1216*cdf0e10cSrcweir ::rtl::OUString aString(C2U("SELECT * FROM ")); 1217*cdf0e10cSrcweir // quote the table name which may contain catalog.schema.table 1218*cdf0e10cSrcweir Reference<XDatabaseMetaData> xMetaData(xConnection->getMetaData(),UNO_QUERY); 1219*cdf0e10cSrcweir aQuoteChar = xMetaData->getIdentifierQuoteString(); 1220*cdf0e10cSrcweir 1221*cdf0e10cSrcweir ::rtl::OUString sCatalog, sSchema, sName; 1222*cdf0e10cSrcweir ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation ); 1223*cdf0e10cSrcweir aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName ); 1224*cdf0e10cSrcweir 1225*cdf0e10cSrcweir m_xParser->setElementaryQuery(aString); 1226*cdf0e10cSrcweir BibConfig* pConfig = BibModul::GetConfig(); 1227*cdf0e10cSrcweir pConfig->setQueryField(getQueryField()); 1228*cdf0e10cSrcweir startQueryWith(pConfig->getQueryText()); 1229*cdf0e10cSrcweir setActiveDataTable(aActiveDataTable); 1230*cdf0e10cSrcweir } 1231*cdf0e10cSrcweir FeatureStateEvent aEvent; 1232*cdf0e10cSrcweir util::URL aURL; 1233*cdf0e10cSrcweir aEvent.IsEnabled = sal_True; 1234*cdf0e10cSrcweir aEvent.Requery = sal_False; 1235*cdf0e10cSrcweir aEvent.FeatureDescriptor = getActiveDataTable(); 1236*cdf0e10cSrcweir 1237*cdf0e10cSrcweir aEvent.State = makeAny( getDataSources() ); 1238*cdf0e10cSrcweir 1239*cdf0e10cSrcweir if(pToolbar) 1240*cdf0e10cSrcweir { 1241*cdf0e10cSrcweir aURL.Complete =C2U(".uno:Bib/source"); 1242*cdf0e10cSrcweir aEvent.FeatureURL = aURL; 1243*cdf0e10cSrcweir pToolbar->statusChanged( aEvent ); 1244*cdf0e10cSrcweir } 1245*cdf0e10cSrcweir 1246*cdf0e10cSrcweir updateGridModel(); 1247*cdf0e10cSrcweir load(); 1248*cdf0e10cSrcweir } 1249*cdf0e10cSrcweir } 1250*cdf0e10cSrcweir 1251*cdf0e10cSrcweir /* -------------------------------------------------- 1252*cdf0e10cSrcweir 1253*cdf0e10cSrcweir --------------------------------------------------*/ 1254*cdf0e10cSrcweir void BibDataManager::setActiveDataTable(const ::rtl::OUString& rTable) 1255*cdf0e10cSrcweir { 1256*cdf0e10cSrcweir ResetIdentifierMapping(); 1257*cdf0e10cSrcweir try 1258*cdf0e10cSrcweir { 1259*cdf0e10cSrcweir Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY ); 1260*cdf0e10cSrcweir 1261*cdf0e10cSrcweir if(aPropertySet.is()) 1262*cdf0e10cSrcweir { 1263*cdf0e10cSrcweir Reference< XConnection > xConnection = getConnection( m_xForm ); 1264*cdf0e10cSrcweir Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY); 1265*cdf0e10cSrcweir Reference< XNameAccess > xAccess = xSupplyTables->getTables(); 1266*cdf0e10cSrcweir Sequence< ::rtl::OUString > aTableNameSeq = xAccess->getElementNames(); 1267*cdf0e10cSrcweir sal_uInt32 nCount = aTableNameSeq.getLength(); 1268*cdf0e10cSrcweir 1269*cdf0e10cSrcweir const ::rtl::OUString* pTableNames = aTableNameSeq.getConstArray(); 1270*cdf0e10cSrcweir const ::rtl::OUString* pTableNamesEnd = pTableNames + nCount; 1271*cdf0e10cSrcweir 1272*cdf0e10cSrcweir for ( ; pTableNames != pTableNamesEnd; ++pTableNames ) 1273*cdf0e10cSrcweir { 1274*cdf0e10cSrcweir if ( rTable == *pTableNames ) 1275*cdf0e10cSrcweir { 1276*cdf0e10cSrcweir aActiveDataTable = rTable; 1277*cdf0e10cSrcweir Any aVal; aVal <<= rTable; 1278*cdf0e10cSrcweir aPropertySet->setPropertyValue( C2U("Command"), aVal ); 1279*cdf0e10cSrcweir break; 1280*cdf0e10cSrcweir } 1281*cdf0e10cSrcweir } 1282*cdf0e10cSrcweir if (pTableNames != pTableNamesEnd) 1283*cdf0e10cSrcweir { 1284*cdf0e10cSrcweir Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); 1285*cdf0e10cSrcweir aQuoteChar = xMetaData->getIdentifierQuoteString(); 1286*cdf0e10cSrcweir 1287*cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY); 1288*cdf0e10cSrcweir if ( xFactory.is() ) 1289*cdf0e10cSrcweir m_xParser.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), UNO_QUERY ); 1290*cdf0e10cSrcweir 1291*cdf0e10cSrcweir ::rtl::OUString aString(C2U("SELECT * FROM ")); 1292*cdf0e10cSrcweir 1293*cdf0e10cSrcweir ::rtl::OUString sCatalog, sSchema, sName; 1294*cdf0e10cSrcweir ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation ); 1295*cdf0e10cSrcweir aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName ); 1296*cdf0e10cSrcweir 1297*cdf0e10cSrcweir m_xParser->setElementaryQuery(aString); 1298*cdf0e10cSrcweir 1299*cdf0e10cSrcweir BibConfig* pConfig = BibModul::GetConfig(); 1300*cdf0e10cSrcweir pConfig->setQueryField(getQueryField()); 1301*cdf0e10cSrcweir startQueryWith(pConfig->getQueryText()); 1302*cdf0e10cSrcweir 1303*cdf0e10cSrcweir BibDBDescriptor aDesc; 1304*cdf0e10cSrcweir aDesc.sDataSource = aDataSourceURL; 1305*cdf0e10cSrcweir aDesc.sTableOrQuery = aActiveDataTable; 1306*cdf0e10cSrcweir aDesc.nCommandType = CommandType::TABLE; 1307*cdf0e10cSrcweir BibModul::GetConfig()->SetBibliographyURL(aDesc); 1308*cdf0e10cSrcweir } 1309*cdf0e10cSrcweir } 1310*cdf0e10cSrcweir } 1311*cdf0e10cSrcweir catch(Exception& e ) 1312*cdf0e10cSrcweir { 1313*cdf0e10cSrcweir (void) e; // make compiler happy 1314*cdf0e10cSrcweir DBG_ERROR("::setActiveDataTable: something went wrong !"); 1315*cdf0e10cSrcweir } 1316*cdf0e10cSrcweir 1317*cdf0e10cSrcweir } 1318*cdf0e10cSrcweir 1319*cdf0e10cSrcweir //------------------------------------------------------------------------ 1320*cdf0e10cSrcweir void SAL_CALL BibDataManager::load( ) throw (RuntimeException) 1321*cdf0e10cSrcweir { 1322*cdf0e10cSrcweir if ( isLoaded() ) 1323*cdf0e10cSrcweir // nothing to do 1324*cdf0e10cSrcweir return; 1325*cdf0e10cSrcweir 1326*cdf0e10cSrcweir Reference< XLoadable > xFormAsLoadable( m_xForm, UNO_QUERY ); 1327*cdf0e10cSrcweir DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::load: invalid form!"); 1328*cdf0e10cSrcweir if ( xFormAsLoadable.is() ) 1329*cdf0e10cSrcweir { 1330*cdf0e10cSrcweir xFormAsLoadable->load(); 1331*cdf0e10cSrcweir SetMeAsUidListener(); 1332*cdf0e10cSrcweir 1333*cdf0e10cSrcweir EventObject aEvt( static_cast< XWeak* >( this ) ); 1334*cdf0e10cSrcweir m_aLoadListeners.notifyEach( &XLoadListener::loaded, aEvt ); 1335*cdf0e10cSrcweir } 1336*cdf0e10cSrcweir } 1337*cdf0e10cSrcweir 1338*cdf0e10cSrcweir //------------------------------------------------------------------------ 1339*cdf0e10cSrcweir void SAL_CALL BibDataManager::unload( ) throw (RuntimeException) 1340*cdf0e10cSrcweir { 1341*cdf0e10cSrcweir if ( !isLoaded() ) 1342*cdf0e10cSrcweir // nothing to do 1343*cdf0e10cSrcweir return; 1344*cdf0e10cSrcweir 1345*cdf0e10cSrcweir Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY ); 1346*cdf0e10cSrcweir DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::unload: invalid form!"); 1347*cdf0e10cSrcweir if ( xFormAsLoadable.is() ) 1348*cdf0e10cSrcweir { 1349*cdf0e10cSrcweir EventObject aEvt( static_cast< XWeak* >( this ) ); 1350*cdf0e10cSrcweir 1351*cdf0e10cSrcweir { 1352*cdf0e10cSrcweir m_aLoadListeners.notifyEach( &XLoadListener::unloading, aEvt ); 1353*cdf0e10cSrcweir } 1354*cdf0e10cSrcweir 1355*cdf0e10cSrcweir RemoveMeAsUidListener(); 1356*cdf0e10cSrcweir xFormAsLoadable->unload(); 1357*cdf0e10cSrcweir 1358*cdf0e10cSrcweir { 1359*cdf0e10cSrcweir m_aLoadListeners.notifyEach( &XLoadListener::unloaded, aEvt ); 1360*cdf0e10cSrcweir } 1361*cdf0e10cSrcweir } 1362*cdf0e10cSrcweir } 1363*cdf0e10cSrcweir 1364*cdf0e10cSrcweir //------------------------------------------------------------------------ 1365*cdf0e10cSrcweir void SAL_CALL BibDataManager::reload( ) throw (RuntimeException) 1366*cdf0e10cSrcweir { 1367*cdf0e10cSrcweir if ( !isLoaded() ) 1368*cdf0e10cSrcweir // nothing to do 1369*cdf0e10cSrcweir return; 1370*cdf0e10cSrcweir 1371*cdf0e10cSrcweir Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY ); 1372*cdf0e10cSrcweir DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::unload: invalid form!"); 1373*cdf0e10cSrcweir if ( xFormAsLoadable.is() ) 1374*cdf0e10cSrcweir { 1375*cdf0e10cSrcweir EventObject aEvt( static_cast< XWeak* >( this ) ); 1376*cdf0e10cSrcweir 1377*cdf0e10cSrcweir { 1378*cdf0e10cSrcweir m_aLoadListeners.notifyEach( &XLoadListener::reloading, aEvt ); 1379*cdf0e10cSrcweir } 1380*cdf0e10cSrcweir 1381*cdf0e10cSrcweir xFormAsLoadable->reload(); 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir { 1384*cdf0e10cSrcweir m_aLoadListeners.notifyEach( &XLoadListener::reloaded, aEvt ); 1385*cdf0e10cSrcweir } 1386*cdf0e10cSrcweir } 1387*cdf0e10cSrcweir } 1388*cdf0e10cSrcweir 1389*cdf0e10cSrcweir //------------------------------------------------------------------------ 1390*cdf0e10cSrcweir sal_Bool SAL_CALL BibDataManager::isLoaded( ) throw (RuntimeException) 1391*cdf0e10cSrcweir { 1392*cdf0e10cSrcweir Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY ); 1393*cdf0e10cSrcweir DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::isLoaded: invalid form!"); 1394*cdf0e10cSrcweir 1395*cdf0e10cSrcweir sal_Bool bLoaded = sal_False; 1396*cdf0e10cSrcweir if ( xFormAsLoadable.is() ) 1397*cdf0e10cSrcweir bLoaded = xFormAsLoadable->isLoaded(); 1398*cdf0e10cSrcweir return bLoaded; 1399*cdf0e10cSrcweir } 1400*cdf0e10cSrcweir 1401*cdf0e10cSrcweir //------------------------------------------------------------------------ 1402*cdf0e10cSrcweir void SAL_CALL BibDataManager::addLoadListener( const Reference< XLoadListener >& aListener ) throw (RuntimeException) 1403*cdf0e10cSrcweir { 1404*cdf0e10cSrcweir m_aLoadListeners.addInterface( aListener ); 1405*cdf0e10cSrcweir } 1406*cdf0e10cSrcweir 1407*cdf0e10cSrcweir //------------------------------------------------------------------------ 1408*cdf0e10cSrcweir void SAL_CALL BibDataManager::removeLoadListener( const Reference< XLoadListener >& aListener ) throw (RuntimeException) 1409*cdf0e10cSrcweir { 1410*cdf0e10cSrcweir m_aLoadListeners.removeInterface( aListener ); 1411*cdf0e10cSrcweir } 1412*cdf0e10cSrcweir 1413*cdf0e10cSrcweir //------------------------------------------------------------------------ 1414*cdf0e10cSrcweir Reference< awt::XControlModel > BibDataManager::createGridModel(const ::rtl::OUString& rName) 1415*cdf0e10cSrcweir { 1416*cdf0e10cSrcweir Reference< awt::XControlModel > xModel; 1417*cdf0e10cSrcweir 1418*cdf0e10cSrcweir try 1419*cdf0e10cSrcweir { 1420*cdf0e10cSrcweir // create the control model 1421*cdf0e10cSrcweir Reference< XMultiServiceFactory > xMgr = ::comphelper::getProcessServiceFactory(); 1422*cdf0e10cSrcweir Reference< XInterface > xObject = xMgr->createInstance(C2U("com.sun.star.form.component.GridControl")); 1423*cdf0e10cSrcweir xModel=Reference< awt::XControlModel > ( xObject, UNO_QUERY ); 1424*cdf0e10cSrcweir 1425*cdf0e10cSrcweir // set the 1426*cdf0e10cSrcweir Reference< XPropertySet > xPropSet( xModel, UNO_QUERY ); 1427*cdf0e10cSrcweir xPropSet->setPropertyValue( C2U("Name"), makeAny( rName ) ); 1428*cdf0e10cSrcweir 1429*cdf0e10cSrcweir // set the name of the to-be-created control 1430*cdf0e10cSrcweir ::rtl::OUString aControlName(C2U("com.sun.star.form.control.InteractionGridControl")); 1431*cdf0e10cSrcweir Any aAny; aAny <<= aControlName; 1432*cdf0e10cSrcweir xPropSet->setPropertyValue( C2U("DefaultControl"),aAny ); 1433*cdf0e10cSrcweir 1434*cdf0e10cSrcweir // the the helpURL 1435*cdf0e10cSrcweir ::rtl::OUString uProp(C2U("HelpURL")); 1436*cdf0e10cSrcweir Reference< XPropertySetInfo > xPropInfo = xPropSet->getPropertySetInfo(); 1437*cdf0e10cSrcweir if (xPropInfo->hasPropertyByName(uProp)) 1438*cdf0e10cSrcweir { 1439*cdf0e10cSrcweir ::rtl::OUString sId = ::rtl::OUString::createFromAscii( INET_HID_SCHEME ); 1440*cdf0e10cSrcweir sId += ::rtl::OUString::createFromAscii( HID_BIB_DB_GRIDCTRL ); 1441*cdf0e10cSrcweir xPropSet->setPropertyValue( uProp, makeAny( sId ) ); 1442*cdf0e10cSrcweir } 1443*cdf0e10cSrcweir } 1444*cdf0e10cSrcweir catch(Exception& e ) 1445*cdf0e10cSrcweir { 1446*cdf0e10cSrcweir (void) e; // make compiler happy 1447*cdf0e10cSrcweir DBG_ERROR("::createGridModel: something went wrong !"); 1448*cdf0e10cSrcweir } 1449*cdf0e10cSrcweir 1450*cdf0e10cSrcweir 1451*cdf0e10cSrcweir return xModel; 1452*cdf0e10cSrcweir } 1453*cdf0e10cSrcweir //------------------------------------------------------------------------ 1454*cdf0e10cSrcweir ::rtl::OUString BibDataManager::getControlName(sal_Int32 nFormatKey ) 1455*cdf0e10cSrcweir { 1456*cdf0e10cSrcweir ::rtl::OUString aResStr; 1457*cdf0e10cSrcweir switch (nFormatKey) 1458*cdf0e10cSrcweir { 1459*cdf0e10cSrcweir case DataType::BIT: 1460*cdf0e10cSrcweir case DataType::BOOLEAN: 1461*cdf0e10cSrcweir aResStr=C2U("CheckBox"); 1462*cdf0e10cSrcweir break; 1463*cdf0e10cSrcweir case DataType::TINYINT: 1464*cdf0e10cSrcweir case DataType::SMALLINT: 1465*cdf0e10cSrcweir case DataType::INTEGER: 1466*cdf0e10cSrcweir aResStr=C2U("NumericField"); ; 1467*cdf0e10cSrcweir break; 1468*cdf0e10cSrcweir case DataType::REAL: 1469*cdf0e10cSrcweir case DataType::DOUBLE: 1470*cdf0e10cSrcweir case DataType::NUMERIC: 1471*cdf0e10cSrcweir case DataType::DECIMAL: 1472*cdf0e10cSrcweir aResStr=C2U("FormattedField"); 1473*cdf0e10cSrcweir break; 1474*cdf0e10cSrcweir case DataType::TIMESTAMP: 1475*cdf0e10cSrcweir aResStr=C2U("FormattedField"); 1476*cdf0e10cSrcweir break; 1477*cdf0e10cSrcweir case DataType::DATE: 1478*cdf0e10cSrcweir aResStr=C2U("DateField"); 1479*cdf0e10cSrcweir break; 1480*cdf0e10cSrcweir case DataType::TIME: 1481*cdf0e10cSrcweir aResStr=C2U("TimeField"); 1482*cdf0e10cSrcweir break; 1483*cdf0e10cSrcweir case DataType::CHAR: 1484*cdf0e10cSrcweir case DataType::VARCHAR: 1485*cdf0e10cSrcweir case DataType::LONGVARCHAR: 1486*cdf0e10cSrcweir default: 1487*cdf0e10cSrcweir aResStr=C2U("TextField"); 1488*cdf0e10cSrcweir break; 1489*cdf0e10cSrcweir } 1490*cdf0e10cSrcweir return aResStr; 1491*cdf0e10cSrcweir } 1492*cdf0e10cSrcweir //------------------------------------------------------------------------ 1493*cdf0e10cSrcweir Reference< awt::XControlModel > BibDataManager::loadControlModel( 1494*cdf0e10cSrcweir const ::rtl::OUString& rName, sal_Bool bForceListBox) 1495*cdf0e10cSrcweir { 1496*cdf0e10cSrcweir Reference< awt::XControlModel > xModel; 1497*cdf0e10cSrcweir ::rtl::OUString aName(C2U("View_")); 1498*cdf0e10cSrcweir aName += rName; 1499*cdf0e10cSrcweir 1500*cdf0e10cSrcweir try 1501*cdf0e10cSrcweir { 1502*cdf0e10cSrcweir Reference< XNameAccess > xFields = getColumns( m_xForm ); 1503*cdf0e10cSrcweir if (!xFields.is()) 1504*cdf0e10cSrcweir return xModel; 1505*cdf0e10cSrcweir Reference< XPropertySet > xField; 1506*cdf0e10cSrcweir 1507*cdf0e10cSrcweir Any aElement; 1508*cdf0e10cSrcweir 1509*cdf0e10cSrcweir if(xFields->hasByName(rName)) 1510*cdf0e10cSrcweir { 1511*cdf0e10cSrcweir aElement = xFields->getByName(rName); 1512*cdf0e10cSrcweir aElement >>= xField; 1513*cdf0e10cSrcweir Reference< XPropertySetInfo > xInfo = xField.is() ? xField->getPropertySetInfo() : Reference< XPropertySetInfo > (); 1514*cdf0e10cSrcweir 1515*cdf0e10cSrcweir ::rtl::OUString sCurrentModelType; 1516*cdf0e10cSrcweir const ::rtl::OUString sType(C2U("Type")); 1517*cdf0e10cSrcweir sal_Int32 nFormatKey = 0; 1518*cdf0e10cSrcweir xField->getPropertyValue(sType) >>= nFormatKey; 1519*cdf0e10cSrcweir 1520*cdf0e10cSrcweir ::rtl::OUString aInstanceName(C2U("com.sun.star.form.component.")); 1521*cdf0e10cSrcweir 1522*cdf0e10cSrcweir if (bForceListBox) 1523*cdf0e10cSrcweir aInstanceName += C2U("ListBox"); 1524*cdf0e10cSrcweir else 1525*cdf0e10cSrcweir aInstanceName += getControlName(nFormatKey); 1526*cdf0e10cSrcweir 1527*cdf0e10cSrcweir Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); 1528*cdf0e10cSrcweir Reference< XInterface > xObject = xMgr->createInstance(aInstanceName); 1529*cdf0e10cSrcweir xModel=Reference< awt::XControlModel > ( xObject, UNO_QUERY ); 1530*cdf0e10cSrcweir Reference< XPropertySet > xPropSet( xModel, UNO_QUERY ); 1531*cdf0e10cSrcweir Any aFieldName; aFieldName <<= aName; 1532*cdf0e10cSrcweir 1533*cdf0e10cSrcweir xPropSet->setPropertyValue( FM_PROP_NAME,aFieldName); 1534*cdf0e10cSrcweir xPropSet->setPropertyValue( FM_PROP_CONTROLSOURCE, makeAny( rName ) ); 1535*cdf0e10cSrcweir xPropSet->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NativeWidgetLook" ) ), makeAny( (sal_Bool)sal_True ) ); 1536*cdf0e10cSrcweir 1537*cdf0e10cSrcweir Reference< XFormComponent > aFormComp(xModel,UNO_QUERY ); 1538*cdf0e10cSrcweir 1539*cdf0e10cSrcweir Reference< XNameContainer > xNameCont( m_xForm, UNO_QUERY ); 1540*cdf0e10cSrcweir xNameCont->insertByName(aName, makeAny( aFormComp ) ); 1541*cdf0e10cSrcweir 1542*cdf0e10cSrcweir // now if the form where we inserted the new model is already loaded, notify the model of this 1543*cdf0e10cSrcweir // Note that this implementation below is a HACK as it relies on the fact that the model adds itself 1544*cdf0e10cSrcweir // as load listener to it's parent, which is an implementation detail of the model. 1545*cdf0e10cSrcweir // 1546*cdf0e10cSrcweir // the better solution would be the following: 1547*cdf0e10cSrcweir // in the current scenario, we insert a control model into a form. This results in the control model 1548*cdf0e10cSrcweir // adding itself as load listener to the form. Now, the form should realize that it's already loaded 1549*cdf0e10cSrcweir // and notify the model (which it knows as XLoadListener only) immediately. This seems to make sense. 1550*cdf0e10cSrcweir // (as an anologon to the XStatusListener semantics). 1551*cdf0e10cSrcweir // 1552*cdf0e10cSrcweir // But this would be way too risky for this last-day fix here. 1553*cdf0e10cSrcweir // 97140 - 30.01.2002 - fs@openoffice.org 1554*cdf0e10cSrcweir Reference< XLoadable > xLoad( m_xForm, UNO_QUERY ); 1555*cdf0e10cSrcweir if ( xLoad.is() && xLoad->isLoaded() ) 1556*cdf0e10cSrcweir { 1557*cdf0e10cSrcweir Reference< XLoadListener > xListener( aFormComp, UNO_QUERY ); 1558*cdf0e10cSrcweir if ( xListener.is() ) 1559*cdf0e10cSrcweir { 1560*cdf0e10cSrcweir EventObject aLoadSource; 1561*cdf0e10cSrcweir aLoadSource.Source = xLoad; 1562*cdf0e10cSrcweir xListener->loaded( aLoadSource ); 1563*cdf0e10cSrcweir } 1564*cdf0e10cSrcweir } 1565*cdf0e10cSrcweir } 1566*cdf0e10cSrcweir } 1567*cdf0e10cSrcweir catch(Exception& e ) 1568*cdf0e10cSrcweir { 1569*cdf0e10cSrcweir (void) e; // make compiler happy 1570*cdf0e10cSrcweir DBG_ERROR("::loadControlModel: something went wrong !"); 1571*cdf0e10cSrcweir } 1572*cdf0e10cSrcweir return xModel; 1573*cdf0e10cSrcweir } 1574*cdf0e10cSrcweir //------------------------------------------------------------------------ 1575*cdf0e10cSrcweir void SAL_CALL BibDataManager::disposing() 1576*cdf0e10cSrcweir { 1577*cdf0e10cSrcweir BibDataManager_Base::WeakComponentImplHelperBase::disposing(); 1578*cdf0e10cSrcweir } 1579*cdf0e10cSrcweir 1580*cdf0e10cSrcweir //------------------------------------------------------------------------ 1581*cdf0e10cSrcweir void BibDataManager::disposing( const EventObject& /*Source*/ ) throw( ::com::sun::star::uno::RuntimeException ) 1582*cdf0e10cSrcweir { 1583*cdf0e10cSrcweir // not interested in 1584*cdf0e10cSrcweir } 1585*cdf0e10cSrcweir 1586*cdf0e10cSrcweir //------------------------------------------------------------------------ 1587*cdf0e10cSrcweir void BibDataManager::propertyChange(const beans::PropertyChangeEvent& evt) throw( RuntimeException ) 1588*cdf0e10cSrcweir { 1589*cdf0e10cSrcweir try 1590*cdf0e10cSrcweir { 1591*cdf0e10cSrcweir sal_Bool bFlag=sal_False; 1592*cdf0e10cSrcweir if(evt.PropertyName == FM_PROP_VALUE) 1593*cdf0e10cSrcweir { 1594*cdf0e10cSrcweir if( evt.NewValue.getValueType() == ::getCppuType((Reference<io::XInputStream>*)0) ) 1595*cdf0e10cSrcweir { 1596*cdf0e10cSrcweir Reference< io::XDataInputStream > xStream( 1597*cdf0e10cSrcweir *(const Reference< io::XInputStream > *)evt.NewValue.getValue(), UNO_QUERY ); 1598*cdf0e10cSrcweir aUID <<= xStream->readUTF(); 1599*cdf0e10cSrcweir } 1600*cdf0e10cSrcweir else 1601*cdf0e10cSrcweir aUID = evt.NewValue; 1602*cdf0e10cSrcweir 1603*cdf0e10cSrcweir Reference< XRowLocate > xLocate(xBibCursor, UNO_QUERY); 1604*cdf0e10cSrcweir DBG_ASSERT(xLocate.is(), "BibDataManager::propertyChange : invalid cursor !"); 1605*cdf0e10cSrcweir bFlag = xLocate->moveToBookmark(aUID); 1606*cdf0e10cSrcweir } 1607*cdf0e10cSrcweir } 1608*cdf0e10cSrcweir catch(Exception& e ) 1609*cdf0e10cSrcweir { 1610*cdf0e10cSrcweir (void) e; // make compiler happy 1611*cdf0e10cSrcweir DBG_ERROR("::propertyChange: something went wrong !"); 1612*cdf0e10cSrcweir } 1613*cdf0e10cSrcweir 1614*cdf0e10cSrcweir 1615*cdf0e10cSrcweir } 1616*cdf0e10cSrcweir //------------------------------------------------------------------------ 1617*cdf0e10cSrcweir void BibDataManager::SetMeAsUidListener() 1618*cdf0e10cSrcweir { 1619*cdf0e10cSrcweir try 1620*cdf0e10cSrcweir { 1621*cdf0e10cSrcweir Reference< XNameAccess > xFields = getColumns( m_xForm ); 1622*cdf0e10cSrcweir if (!xFields.is()) 1623*cdf0e10cSrcweir return; 1624*cdf0e10cSrcweir 1625*cdf0e10cSrcweir Sequence< ::rtl::OUString > aFields(xFields->getElementNames()); 1626*cdf0e10cSrcweir const ::rtl::OUString* pFields = aFields.getConstArray(); 1627*cdf0e10cSrcweir sal_Int32 nCount=aFields.getLength(); 1628*cdf0e10cSrcweir String StrUID(C2S(STR_UID)); 1629*cdf0e10cSrcweir ::rtl::OUString theFieldName; 1630*cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; i++ ) 1631*cdf0e10cSrcweir { 1632*cdf0e10cSrcweir String aName= pFields[i]; 1633*cdf0e10cSrcweir 1634*cdf0e10cSrcweir if(aName.EqualsIgnoreCaseAscii(StrUID)) 1635*cdf0e10cSrcweir { 1636*cdf0e10cSrcweir theFieldName=pFields[i]; 1637*cdf0e10cSrcweir break; 1638*cdf0e10cSrcweir } 1639*cdf0e10cSrcweir } 1640*cdf0e10cSrcweir 1641*cdf0e10cSrcweir if(theFieldName.getLength()>0) 1642*cdf0e10cSrcweir { 1643*cdf0e10cSrcweir Reference< XPropertySet > xPropSet; 1644*cdf0e10cSrcweir Any aElement; 1645*cdf0e10cSrcweir 1646*cdf0e10cSrcweir aElement = xFields->getByName(theFieldName); 1647*cdf0e10cSrcweir xPropSet = *(Reference< XPropertySet > *)aElement.getValue(); 1648*cdf0e10cSrcweir 1649*cdf0e10cSrcweir xPropSet->addPropertyChangeListener(FM_PROP_VALUE, this); 1650*cdf0e10cSrcweir } 1651*cdf0e10cSrcweir 1652*cdf0e10cSrcweir } 1653*cdf0e10cSrcweir catch(Exception& e ) 1654*cdf0e10cSrcweir { 1655*cdf0e10cSrcweir (void) e; // make compiler happy 1656*cdf0e10cSrcweir DBG_ERROR("Exception in BibDataManager::SetMeAsUidListener"); 1657*cdf0e10cSrcweir } 1658*cdf0e10cSrcweir 1659*cdf0e10cSrcweir 1660*cdf0e10cSrcweir } 1661*cdf0e10cSrcweir //------------------------------------------------------------------------ 1662*cdf0e10cSrcweir void BibDataManager::RemoveMeAsUidListener() 1663*cdf0e10cSrcweir { 1664*cdf0e10cSrcweir try 1665*cdf0e10cSrcweir { 1666*cdf0e10cSrcweir Reference< XNameAccess > xFields = getColumns( m_xForm ); 1667*cdf0e10cSrcweir if (!xFields.is()) 1668*cdf0e10cSrcweir return; 1669*cdf0e10cSrcweir 1670*cdf0e10cSrcweir 1671*cdf0e10cSrcweir Sequence< ::rtl::OUString > aFields(xFields->getElementNames()); 1672*cdf0e10cSrcweir const ::rtl::OUString* pFields = aFields.getConstArray(); 1673*cdf0e10cSrcweir sal_Int32 nCount=aFields.getLength(); 1674*cdf0e10cSrcweir String StrUID(C2S(STR_UID)); 1675*cdf0e10cSrcweir ::rtl::OUString theFieldName; 1676*cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; i++ ) 1677*cdf0e10cSrcweir { 1678*cdf0e10cSrcweir String aName= pFields[i]; 1679*cdf0e10cSrcweir 1680*cdf0e10cSrcweir if(aName.EqualsIgnoreCaseAscii(StrUID)) 1681*cdf0e10cSrcweir { 1682*cdf0e10cSrcweir theFieldName=pFields[i]; 1683*cdf0e10cSrcweir break; 1684*cdf0e10cSrcweir } 1685*cdf0e10cSrcweir } 1686*cdf0e10cSrcweir 1687*cdf0e10cSrcweir if(theFieldName.getLength()>0) 1688*cdf0e10cSrcweir { 1689*cdf0e10cSrcweir Reference< XPropertySet > xPropSet; 1690*cdf0e10cSrcweir Any aElement; 1691*cdf0e10cSrcweir 1692*cdf0e10cSrcweir aElement = xFields->getByName(theFieldName); 1693*cdf0e10cSrcweir xPropSet = *(Reference< XPropertySet > *)aElement.getValue(); 1694*cdf0e10cSrcweir 1695*cdf0e10cSrcweir xPropSet->removePropertyChangeListener(FM_PROP_VALUE, this); 1696*cdf0e10cSrcweir } 1697*cdf0e10cSrcweir 1698*cdf0e10cSrcweir } 1699*cdf0e10cSrcweir catch(Exception& e ) 1700*cdf0e10cSrcweir { 1701*cdf0e10cSrcweir (void) e; // make compiler happy 1702*cdf0e10cSrcweir DBG_ERROR("Exception in BibDataManager::RemoveMeAsUidListener"); 1703*cdf0e10cSrcweir } 1704*cdf0e10cSrcweir 1705*cdf0e10cSrcweir 1706*cdf0e10cSrcweir } 1707*cdf0e10cSrcweir /* -----------------11.11.99 15:51------------------- 1708*cdf0e10cSrcweir 1709*cdf0e10cSrcweir --------------------------------------------------*/ 1710*cdf0e10cSrcweir void BibDataManager::CreateMappingDialog(Window* pParent) 1711*cdf0e10cSrcweir { 1712*cdf0e10cSrcweir MappingDialog_Impl* pDlg = new MappingDialog_Impl(pParent, this); 1713*cdf0e10cSrcweir if(RET_OK == pDlg->Execute() && pBibView) 1714*cdf0e10cSrcweir { 1715*cdf0e10cSrcweir reload(); 1716*cdf0e10cSrcweir // unload(); 1717*cdf0e10cSrcweir // pBibView->UpdatePages(); 1718*cdf0e10cSrcweir // load(); 1719*cdf0e10cSrcweir } 1720*cdf0e10cSrcweir delete pDlg; 1721*cdf0e10cSrcweir } 1722*cdf0e10cSrcweir /* -------------------------------------------------- 1723*cdf0e10cSrcweir 1724*cdf0e10cSrcweir --------------------------------------------------*/ 1725*cdf0e10cSrcweir ::rtl::OUString BibDataManager::CreateDBChangeDialog(Window* pParent) 1726*cdf0e10cSrcweir { 1727*cdf0e10cSrcweir ::rtl::OUString uRet; 1728*cdf0e10cSrcweir DBChangeDialog_Impl * pDlg = new DBChangeDialog_Impl(pParent, this ); 1729*cdf0e10cSrcweir if(RET_OK == pDlg->Execute()) 1730*cdf0e10cSrcweir { 1731*cdf0e10cSrcweir String sNewURL = pDlg->GetCurrentURL(); 1732*cdf0e10cSrcweir if(sNewURL != String(getActiveDataSource())) 1733*cdf0e10cSrcweir { 1734*cdf0e10cSrcweir uRet = sNewURL; 1735*cdf0e10cSrcweir } 1736*cdf0e10cSrcweir } 1737*cdf0e10cSrcweir delete pDlg; 1738*cdf0e10cSrcweir return uRet; 1739*cdf0e10cSrcweir } 1740*cdf0e10cSrcweir /*-- 18.05.2004 15:20:15--------------------------------------------------- 1741*cdf0e10cSrcweir 1742*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 1743*cdf0e10cSrcweir void BibDataManager::DispatchDBChangeDialog() 1744*cdf0e10cSrcweir { 1745*cdf0e10cSrcweir if(pToolbar) 1746*cdf0e10cSrcweir pToolbar->SendDispatch(TBC_BT_CHANGESOURCE, Sequence< PropertyValue >()); 1747*cdf0e10cSrcweir } 1748*cdf0e10cSrcweir /* -----------------06.12.99 15:11------------------- 1749*cdf0e10cSrcweir 1750*cdf0e10cSrcweir --------------------------------------------------*/ 1751*cdf0e10cSrcweir const ::rtl::OUString& BibDataManager::GetIdentifierMapping() 1752*cdf0e10cSrcweir { 1753*cdf0e10cSrcweir if(!sIdentifierMapping.getLength()) 1754*cdf0e10cSrcweir { 1755*cdf0e10cSrcweir BibConfig* pConfig = BibModul::GetConfig(); 1756*cdf0e10cSrcweir BibDBDescriptor aDesc; 1757*cdf0e10cSrcweir aDesc.sDataSource = getActiveDataSource(); 1758*cdf0e10cSrcweir aDesc.sTableOrQuery = getActiveDataTable(); 1759*cdf0e10cSrcweir aDesc.nCommandType = CommandType::TABLE; 1760*cdf0e10cSrcweir const Mapping* pMapping = pConfig->GetMapping(aDesc); 1761*cdf0e10cSrcweir sIdentifierMapping = pConfig->GetDefColumnName(IDENTIFIER_POS); 1762*cdf0e10cSrcweir if(pMapping) 1763*cdf0e10cSrcweir { 1764*cdf0e10cSrcweir for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++) 1765*cdf0e10cSrcweir { 1766*cdf0e10cSrcweir if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == sIdentifierMapping) 1767*cdf0e10cSrcweir { 1768*cdf0e10cSrcweir sIdentifierMapping = pMapping->aColumnPairs[nEntry].sRealColumnName; 1769*cdf0e10cSrcweir break; 1770*cdf0e10cSrcweir } 1771*cdf0e10cSrcweir } 1772*cdf0e10cSrcweir } 1773*cdf0e10cSrcweir } 1774*cdf0e10cSrcweir return sIdentifierMapping; 1775*cdf0e10cSrcweir } 1776*cdf0e10cSrcweir /* -----------------------------20.11.00 10:31-------------------------------- 1777*cdf0e10cSrcweir 1778*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 1779*cdf0e10cSrcweir void BibDataManager::SetToolbar(BibToolBar* pSet) 1780*cdf0e10cSrcweir { 1781*cdf0e10cSrcweir pToolbar = pSet; 1782*cdf0e10cSrcweir if(pToolbar) 1783*cdf0e10cSrcweir pToolbar->SetDatMan(*this); 1784*cdf0e10cSrcweir } 1785*cdf0e10cSrcweir /* -----------------------------08.05.2002 09:26------------------------------ 1786*cdf0e10cSrcweir 1787*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 1788*cdf0e10cSrcweir uno::Reference< form::runtime::XFormController > BibDataManager::GetFormController() 1789*cdf0e10cSrcweir { 1790*cdf0e10cSrcweir if(!m_xFormCtrl.is()) 1791*cdf0e10cSrcweir { 1792*cdf0e10cSrcweir Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); 1793*cdf0e10cSrcweir m_xFormCtrl = uno::Reference< form::runtime::XFormController > ( 1794*cdf0e10cSrcweir xMgr->createInstance(C2U("com.sun.star.form.runtime.FormController")), UNO_QUERY); 1795*cdf0e10cSrcweir m_xFormCtrl->setModel(uno::Reference< awt::XTabControllerModel > (getForm(), UNO_QUERY)); 1796*cdf0e10cSrcweir // #100312# ------------- 1797*cdf0e10cSrcweir m_xFormDispatch = uno::Reference< frame::XDispatch > ( m_xFormCtrl, UNO_QUERY); 1798*cdf0e10cSrcweir } 1799*cdf0e10cSrcweir return m_xFormCtrl; 1800*cdf0e10cSrcweir } 1801*cdf0e10cSrcweir 1802*cdf0e10cSrcweir // #100312# ---------- 1803*cdf0e10cSrcweir void BibDataManager::RegisterInterceptor( ::bib::BibBeamer* pBibBeamer) 1804*cdf0e10cSrcweir { 1805*cdf0e10cSrcweir DBG_ASSERT( !m_pInterceptorHelper, "BibDataManager::RegisterInterceptor: called twice!" ); 1806*cdf0e10cSrcweir 1807*cdf0e10cSrcweir if( pBibBeamer ) 1808*cdf0e10cSrcweir m_pInterceptorHelper = new BibInterceptorHelper( pBibBeamer, m_xFormDispatch); 1809*cdf0e10cSrcweir if( m_pInterceptorHelper ) 1810*cdf0e10cSrcweir m_pInterceptorHelper->acquire(); 1811*cdf0e10cSrcweir } 1812*cdf0e10cSrcweir 1813*cdf0e10cSrcweir /*-- 18.05.2004 17:04:20--------------------------------------------------- 1814*cdf0e10cSrcweir 1815*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 1816*cdf0e10cSrcweir sal_Bool BibDataManager::HasActiveConnection()const 1817*cdf0e10cSrcweir { 1818*cdf0e10cSrcweir sal_Bool bRet = sal_False; 1819*cdf0e10cSrcweir Reference< XPropertySet > xPrSet( m_xForm, UNO_QUERY ); 1820*cdf0e10cSrcweir if( xPrSet.is() ) 1821*cdf0e10cSrcweir { 1822*cdf0e10cSrcweir Reference< XComponent > xConnection; 1823*cdf0e10cSrcweir xPrSet->getPropertyValue(C2U("ActiveConnection")) >>= xConnection; 1824*cdf0e10cSrcweir bRet = xConnection.is(); 1825*cdf0e10cSrcweir } 1826*cdf0e10cSrcweir return bRet; 1827*cdf0e10cSrcweir } 1828*cdf0e10cSrcweir /*-- 04.06.2004 14:37:29--------------------------------------------------- 1829*cdf0e10cSrcweir 1830*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 1831*cdf0e10cSrcweir sal_Bool BibDataManager::HasActiveConnection() 1832*cdf0e10cSrcweir { 1833*cdf0e10cSrcweir return getConnection( m_xForm ).is(); 1834*cdf0e10cSrcweir } 1835