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