Update ooo320-m1
[ooovba.git] / extensions / source / bibliography / datman.cxx
blob202206cd6621937c2fe0ce2f17033e56e28e04fd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datman.cxx,v $
10 * $Revision: 1.47 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
33 #include <osl/mutex.hxx>
34 #include <tools/urlobj.hxx>
35 #include <comphelper/processfactory.hxx>
36 #include <com/sun/star/io/XPersistObject.hpp>
37 #include <com/sun/star/sdbc/ResultSetType.hpp>
38 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
39 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
40 #include <com/sun/star/sdbcx/XRowLocate.hpp>
41 #include <com/sun/star/sdbc/DataType.hpp>
42 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
43 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
44 #include <com/sun/star/sdb/XDatabaseEnvironment.hpp>
45 #include <com/sun/star/uno/XNamingService.hpp>
46 #include <com/sun/star/sdbc/XDataSource.hpp>
47 #include <com/sun/star/sdb/CommandType.hpp>
48 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
49 #include <com/sun/star/sdbc/XConnection.hpp>
50 #include <com/sun/star/sdb/XCompletedConnection.hpp>
51 #include <com/sun/star/task/XInteractionHandler.hpp>
52 #include <com/sun/star/form/XLoadable.hpp>
53 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
54 #include <com/sun/star/form/XGridColumnFactory.hpp>
55 #include <com/sun/star/io/XDataInputStream.hpp>
56 #include <com/sun/star/container/XNameContainer.hpp>
57 #include <com/sun/star/ucb/XContentProvider.hpp>
58 #include <com/sun/star/ucb/XContentAccess.hpp>
59 #include <ucbhelper/contentbroker.hxx>
60 #include <ucbhelper/content.hxx>
61 #include <ucbhelper/contentidentifier.hxx>
62 #include <comphelper/container.hxx>
63 #include <svtools/urihelper.hxx>
64 #include <svtools/svtabbx.hxx>
65 #include <svtools/headbar.hxx>
66 #include <vcl/dialog.hxx>
67 #ifndef _SV_BUTTON_HXX
68 #include <vcl/button.hxx>
69 #endif
70 #include <vcl/lstbox.hxx>
71 #include <vcl/fixed.hxx>
72 #include <vcl/group.hxx>
73 #include <vcl/lstbox.hxx>
74 #include <vcl/edit.hxx>
75 #include <vcl/msgbox.hxx>
76 #include <tools/debug.hxx>
77 #include "datman.hxx"
78 #include "bibresid.hxx"
79 #include "bibmod.hxx"
80 #include "bibview.hxx"
81 // #100312# ---------
82 #include "bibbeam.hxx"
83 #ifndef _BIB_FMPROP_HRC
84 #include "bibprop.hrc"
85 #endif
86 #include "toolbar.hxx"
87 #include "toolbar.hrc"
88 #include "bibconfig.hxx"
89 #include "bibbeam.hxx"
90 #ifndef BIB_HRC
91 #include "bib.hrc"
92 #endif
93 #include "datman.hrc"
94 #ifndef EXTENSIONS_INC_EXTENSIO_HRC
95 #include "extensio.hrc"
96 #endif
97 #include <connectivity/dbtools.hxx>
99 using namespace ::com::sun::star;
100 using namespace ::com::sun::star::beans;
101 using namespace ::com::sun::star::container;
102 using namespace ::com::sun::star::uno;
103 using namespace ::com::sun::star::sdb;
104 using namespace ::com::sun::star::sdbc;
105 using namespace ::com::sun::star::sdbcx;
106 using namespace ::com::sun::star::form;
107 using namespace ::com::sun::star::frame;
108 using namespace ::com::sun::star::ucb;
109 using namespace ::com::sun::star::lang;
110 using namespace ::ucb;
112 #define C2U(cChar) ::rtl::OUString::createFromAscii(cChar)
113 #define C2S(cChar) String::CreateFromAscii(cChar)
114 #define MAP_TOKEN ';'
115 #define PAIR_TOKEN ':'
118 /* -----------------17.01.00 14:38-------------------
120 --------------------------------------------------*/
121 Reference< XConnection > getConnection(const ::rtl::OUString& _rURL)
123 // first get the sdb::DataSource corresponding to the url
124 Reference< XDataSource > xDataSource;
125 // is it a favorite title ?
126 Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
127 Reference<XInterface> xNamingContextIfc = xMgr->createInstance(C2U("com.sun.star.sdb.DatabaseContext"));
128 Reference< XNameAccess > xNamingContext(xNamingContextIfc, UNO_QUERY);
129 if (xNamingContext.is() && xNamingContext->hasByName(_rURL))
131 DBG_ASSERT(Reference< XNamingService > (xNamingContext, UNO_QUERY).is(), "::getDataSource : no NamingService interface on the sdb::DatabaseAccessContext !");
134 xDataSource = Reference< XDataSource > (Reference< XNamingService > (xNamingContext, UNO_QUERY)->getRegisteredObject(_rURL), UNO_QUERY);
136 catch(Exception eEx)
138 (void) eEx; // make compiler happy
139 DBG_ERROR("Exception caught in ODatabaseContext::getRegisteredObject()");
142 // build the connection from the data source
143 Reference< XConnection > xConn;
144 if (xDataSource.is())
146 // need user/pwd for this
147 ::rtl::OUString sUser, sPwd;
148 Reference< XPropertySet > xDataSourceProps(xDataSource, UNO_QUERY);
149 Reference< XCompletedConnection > xComplConn(xDataSource, UNO_QUERY);
150 /* Reference< XPropertySetInfo > xInfo = xDataSourceProps.is() ? xDataSourceProps->getPropertySetInfo() : Reference< XPropertySetInfo > ();
151 if (xInfo.is() && xInfo->hasPropertyByName(C2U("User")))
152 xDataSourceProps->getPropertyValue(C2U("User")) >>= sUser;
153 if (xInfo.is() && xInfo->hasPropertyByName(C2U("Password")))
154 xDataSourceProps->getPropertyValue(C2U("Password"))>>= sPwd;
159 Reference<XInterface> xHdl = xMgr->createInstance(C2U("com.sun.star.sdb.InteractionHandler"));
160 Reference<task::XInteractionHandler> xIHdl(xHdl, UNO_QUERY);
161 xConn = xComplConn->connectWithCompletion(xIHdl);
162 // xConn = xDataSource->getConnection(sUser, sPwd);
164 catch(SQLException&)
166 // TODO : a real error handling
168 catch(Exception& e )
170 (void) e; // make compiler happy
174 return xConn;
177 /* -----------------17.01.00 14:46-------------------
179 --------------------------------------------------*/
180 Reference< XConnection > getConnection(const Reference< XInterface > & xRowSet)
182 Reference< XConnection > xConn;
185 Reference< XPropertySet > xFormProps(xRowSet, UNO_QUERY);
186 if (!xFormProps.is())
187 return xConn;
189 xConn = Reference< XConnection > (*(Reference< XInterface > *)xFormProps->getPropertyValue(C2U("ActiveConnection")).getValue(), UNO_QUERY);
190 if (!xConn.is())
192 DBG_WARNING("no active connection");
195 catch(Exception& e )
197 (void) e; // make compiler happy
198 DBG_ERROR("exception in getConnection");
201 return xConn;
203 /* -----------------17.01.00 16:07-------------------
205 --------------------------------------------------*/
206 Reference< XNameAccess > getColumns(const Reference< XForm > & _rxForm)
208 Reference< XNameAccess > xReturn;
209 // check if the form is alive
210 Reference< XColumnsSupplier > xSupplyCols( _rxForm, UNO_QUERY );
211 if (xSupplyCols.is())
212 xReturn = xSupplyCols->getColumns();
214 if (!xReturn.is() || (xReturn->getElementNames().getLength() == 0))
215 { // no ....
216 xReturn = NULL;
217 // -> get the table the form is bound to and ask it for their columns
218 Reference< XTablesSupplier > xSupplyTables( getConnection( _rxForm ), UNO_QUERY );
219 Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY );
220 if (xFormProps.is() && xSupplyTables.is())
224 DBG_ASSERT((*(sal_Int32*)xFormProps->getPropertyValue(C2U("CommandType")).getValue()) == CommandType::TABLE,
225 "::getColumns : invalid form (has no table as data source) !");
226 ::rtl::OUString sTable;
227 xFormProps->getPropertyValue(C2U("Command")) >>= sTable;
228 Reference< XNameAccess > xTables = xSupplyTables->getTables();
229 if (xTables.is() && xTables->hasByName(sTable))
230 xSupplyCols = Reference< XColumnsSupplier > (
231 *(Reference< XInterface > *)xTables->getByName(sTable).getValue(), UNO_QUERY);
232 if (xSupplyCols.is())
233 xReturn = xSupplyCols->getColumns();
235 #ifdef DBG_UTIL
236 catch(Exception& e )
237 #else
238 catch(Exception&)
239 #endif
241 #ifdef DBG_UTIL
242 String sMsg(String::CreateFromAscii("::getColumns : catched an exception ("));
243 sMsg += String(e.Message);
244 sMsg.AppendAscii(") ...");
245 DBG_ERROR( ByteString(sMsg, RTL_TEXTENCODING_ASCII_US ).GetBuffer());
246 #endif
251 return xReturn;
254 /* -----------------11.11.99 15:54-------------------
256 --------------------------------------------------*/
257 class MappingDialog_Impl : public ModalDialog
259 BibDataManager* pDatMan;
260 OKButton aOKBT;
261 CancelButton aCancelBT;
262 HelpButton aHelpBT;
263 FixedLine aMapGB;
264 FixedText aIdentifierFT;
265 ListBox aIdentifierLB;
266 FixedText aAuthorityTypeFT;
267 ListBox aAuthorityTypeLB;
268 FixedText aAuthorFT;
269 ListBox aAuthorLB;
270 FixedText aTitleFT;
271 ListBox aTitleLB;
272 FixedText aMonthFT;
273 ListBox aMonthLB;
274 FixedText aYearFT;
275 ListBox aYearLB;
276 FixedText aISBNFT;
277 ListBox aISBNLB;
278 FixedText aBooktitleFT;
279 ListBox aBooktitleLB;
280 FixedText aChapterFT;
281 ListBox aChapterLB;
282 FixedText aEditionFT;
283 ListBox aEditionLB;
284 FixedText aEditorFT;
285 ListBox aEditorLB;
286 FixedText aHowpublishedFT;
287 ListBox aHowpublishedLB;
288 FixedText aInstitutionFT;
289 ListBox aInstitutionLB;
290 FixedText aJournalFT;
291 ListBox aJournalLB;
292 FixedText aNoteFT;
293 ListBox aNoteLB;
294 FixedText aAnnoteFT;
295 ListBox aAnnoteLB;
296 FixedText aNumberFT;
297 ListBox aNumberLB;
298 FixedText aOrganizationsFT;
299 ListBox aOrganizationsLB;
300 FixedText aPagesFT;
301 ListBox aPagesLB;
302 FixedText aPublisherFT;
303 ListBox aPublisherLB;
304 FixedText aAddressFT;
305 ListBox aAddressLB;
306 FixedText aSchoolFT;
307 ListBox aSchoolLB;
308 FixedText aSeriesFT;
309 ListBox aSeriesLB;
310 FixedText aReportTypeFT;
311 ListBox aReportTypeLB;
312 FixedText aVolumeFT;
313 ListBox aVolumeLB;
314 FixedText aURLFT;
315 ListBox aURLLB;
316 FixedText aCustom1FT;
317 ListBox aCustom1LB;
318 FixedText aCustom2FT;
319 ListBox aCustom2LB;
320 FixedText aCustom3FT;
321 ListBox aCustom3LB;
322 FixedText aCustom4FT;
323 ListBox aCustom4LB;
324 FixedText aCustom5FT;
325 ListBox aCustom5LB;
326 ListBox* aListBoxes[COLUMN_COUNT];
327 String sNone;
329 sal_Bool bModified;
333 DECL_LINK(OkHdl, OKButton*);
334 DECL_LINK(ListBoxSelectHdl, ListBox*);
336 public:
337 MappingDialog_Impl(Window* pParent, BibDataManager* pDatMan);
338 ~MappingDialog_Impl();
340 void SetModified() {bModified = TRUE;}
343 /* -----------------11.11.99 16:42-------------------
345 --------------------------------------------------*/
346 sal_uInt16 lcl_FindLogicalName(BibConfig* pConfig ,
347 const ::rtl::OUString& rLogicalColumnName)
349 for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++)
351 if(rLogicalColumnName == pConfig->GetDefColumnName(i))
352 return i;
354 return USHRT_MAX;
356 //-----------------------------------------------------------------------------
357 MappingDialog_Impl::MappingDialog_Impl(Window* pParent, BibDataManager* pMan) :
358 ModalDialog(pParent, BibResId(RID_DLG_MAPPING) ),
359 pDatMan(pMan),
360 aOKBT(this, BibResId( BT_OK )),
361 aCancelBT(this, BibResId( BT_CANCEL )),
362 aHelpBT(this, BibResId( BT_HELP )),
364 aMapGB(this, BibResId( GB_MAPPING )),
366 aIdentifierFT(this, BibResId( FT_IDENTIFIER )),
367 aIdentifierLB(this, BibResId( LB_IDENTIFIER )),
368 aAuthorityTypeFT(this, BibResId( FT_AUTHORITYTYPE )),
369 aAuthorityTypeLB(this, BibResId( LB_AUTHORITYTYPE )),
370 aAuthorFT(this, BibResId( FT_AUTHOR )),
371 aAuthorLB(this, BibResId( LB_AUTHOR )),
372 aTitleFT(this, BibResId( FT_TITLE )),
373 aTitleLB(this, BibResId( LB_TITLE )),
374 aMonthFT(this, BibResId( FT_MONTH )),
375 aMonthLB(this, BibResId( LB_MONTH )),
376 aYearFT(this, BibResId( FT_YEAR )),
377 aYearLB(this, BibResId( LB_YEAR )),
378 aISBNFT(this, BibResId( FT_ISBN )),
379 aISBNLB(this, BibResId( LB_ISBN )),
380 aBooktitleFT(this, BibResId( FT_BOOKTITLE )),
381 aBooktitleLB(this, BibResId( LB_BOOKTITLE )),
382 aChapterFT(this, BibResId( FT_CHAPTER )),
383 aChapterLB(this, BibResId( LB_CHAPTER )),
384 aEditionFT(this, BibResId( FT_EDITION )),
385 aEditionLB(this, BibResId( LB_EDITION )),
386 aEditorFT(this, BibResId( FT_EDITOR )),
387 aEditorLB(this, BibResId( LB_EDITOR )),
388 aHowpublishedFT(this, BibResId( FT_HOWPUBLISHED )),
389 aHowpublishedLB(this, BibResId( LB_HOWPUBLISHED )),
390 aInstitutionFT(this, BibResId( FT_INSTITUTION )),
391 aInstitutionLB(this, BibResId( LB_INSTITUTION )),
392 aJournalFT(this, BibResId( FT_JOURNAL )),
393 aJournalLB(this, BibResId( LB_JOURNAL )),
394 aNoteFT(this, BibResId( FT_NOTE )),
395 aNoteLB(this, BibResId( LB_NOTE )),
396 aAnnoteFT(this, BibResId( FT_ANNOTE )),
397 aAnnoteLB(this, BibResId( LB_ANNOTE )),
398 aNumberFT(this, BibResId( FT_NUMBER )),
399 aNumberLB(this, BibResId( LB_NUMBER )),
400 aOrganizationsFT(this, BibResId( FT_ORGANIZATIONS )),
401 aOrganizationsLB(this, BibResId( LB_ORGANIZATIONS )),
402 aPagesFT(this, BibResId( FT_PAGES )),
403 aPagesLB(this, BibResId( LB_PAGES )),
404 aPublisherFT(this, BibResId( FT_PUBLISHER )),
405 aPublisherLB(this, BibResId( LB_PUBLISHER )),
406 aAddressFT(this, BibResId( FT_ADDRESS )),
407 aAddressLB(this, BibResId( LB_ADDRESS )),
408 aSchoolFT(this, BibResId( FT_SCHOOL )),
409 aSchoolLB(this, BibResId( LB_SCHOOL )),
410 aSeriesFT(this, BibResId( FT_SERIES )),
411 aSeriesLB(this, BibResId( LB_SERIES )),
412 aReportTypeFT(this, BibResId( FT_REPORTTYPE )),
413 aReportTypeLB(this, BibResId( LB_REPORTTYPE )),
414 aVolumeFT(this, BibResId( FT_VOLUME )),
415 aVolumeLB(this, BibResId( LB_VOLUME )),
416 aURLFT(this, BibResId( FT_URL )),
417 aURLLB(this, BibResId( LB_URL )),
418 aCustom1FT(this, BibResId( FT_CUSTOM1 )),
419 aCustom1LB(this, BibResId( LB_CUSTOM1 )),
420 aCustom2FT(this, BibResId( FT_CUSTOM2 )),
421 aCustom2LB(this, BibResId( LB_CUSTOM2 )),
422 aCustom3FT(this, BibResId( FT_CUSTOM3 )),
423 aCustom3LB(this, BibResId( LB_CUSTOM3 )),
424 aCustom4FT(this, BibResId( FT_CUSTOM4 )),
425 aCustom4LB(this, BibResId( LB_CUSTOM4 )),
426 aCustom5FT(this, BibResId( FT_CUSTOM5 )),
427 aCustom5LB(this, BibResId( LB_CUSTOM5 )),
428 sNone(BibResId(ST_NONE)),
429 bModified(sal_False)
431 FreeResource();
433 aIdentifierFT.SetText(String( BibResId( ST_IDENTIFIER )));
434 aAuthorityTypeFT.SetText(String( BibResId( ST_AUTHTYPE )));
435 aAuthorFT.SetText(String( BibResId( ST_AUTHOR )));
436 aTitleFT.SetText(String( BibResId( ST_TITLE )));
437 aMonthFT.SetText(String( BibResId( ST_MONTH )));
438 aYearFT.SetText(String( BibResId( ST_YEAR )));
439 aISBNFT.SetText(String( BibResId( ST_ISBN )));
440 aBooktitleFT.SetText(String( BibResId( ST_BOOKTITLE )));
441 aChapterFT.SetText(String( BibResId( ST_CHAPTER )));
442 aEditionFT.SetText(String( BibResId( ST_EDITION )));
443 aEditorFT.SetText(String( BibResId( ST_EDITOR )));
444 aHowpublishedFT.SetText(String( BibResId( ST_HOWPUBLISHED )));
445 aInstitutionFT.SetText(String( BibResId( ST_INSTITUTION )));
446 aJournalFT.SetText(String( BibResId( ST_JOURNAL )));
447 aNoteFT.SetText(String( BibResId( ST_NOTE )));
448 aAnnoteFT.SetText(String( BibResId( ST_ANNOTE )));
449 aNumberFT.SetText(String( BibResId( ST_NUMBER )));
450 aOrganizationsFT.SetText(String( BibResId( ST_ORGANIZATION )));
451 aPagesFT.SetText(String( BibResId( ST_PAGE )));
452 aPublisherFT.SetText(String( BibResId( ST_PUBLISHER )));
453 aAddressFT.SetText(String( BibResId( ST_ADDRESS )));
454 aSchoolFT.SetText(String( BibResId( ST_SCHOOL )));
455 aSeriesFT.SetText(String( BibResId( ST_SERIES )));
456 aReportTypeFT.SetText(String( BibResId( ST_REPORT )));
457 aVolumeFT.SetText(String( BibResId( ST_VOLUME )));
458 aURLFT.SetText(String( BibResId( ST_URL )));
459 aCustom1FT.SetText(String( BibResId( ST_CUSTOM1 )));
460 aCustom2FT.SetText(String( BibResId( ST_CUSTOM2 )));
461 aCustom3FT.SetText(String( BibResId( ST_CUSTOM3 )));
462 aCustom4FT.SetText(String( BibResId( ST_CUSTOM4 )));
463 aCustom5FT.SetText(String( BibResId( ST_CUSTOM5 )));
465 aOKBT.SetClickHdl(LINK(this, MappingDialog_Impl, OkHdl));
466 String sTitle = GetText();
467 sTitle.SearchAndReplace(C2S("%1"), pDatMan->getActiveDataTable(), 0);
468 SetText(sTitle);
470 aListBoxes[0] = &aIdentifierLB;
471 aListBoxes[1] = &aAuthorityTypeLB;
472 aListBoxes[2] = &aAuthorLB;
473 aListBoxes[3] = &aTitleLB;
474 aListBoxes[4] = &aYearLB;
475 aListBoxes[5] = &aISBNLB;
476 aListBoxes[6] = &aBooktitleLB;
477 aListBoxes[7] = &aChapterLB;
478 aListBoxes[8] = &aEditionLB;
479 aListBoxes[9] = &aEditorLB;
480 aListBoxes[10] = &aHowpublishedLB;
481 aListBoxes[11] = &aInstitutionLB;
482 aListBoxes[12] = &aJournalLB;
483 aListBoxes[13] = &aMonthLB;
484 aListBoxes[14] = &aNoteLB;
485 aListBoxes[15] = &aAnnoteLB;
486 aListBoxes[16] = &aNumberLB;
487 aListBoxes[17] = &aOrganizationsLB;
488 aListBoxes[18] = &aPagesLB;
489 aListBoxes[19] = &aPublisherLB;
490 aListBoxes[20] = &aAddressLB;
491 aListBoxes[21] = &aSchoolLB;
492 aListBoxes[22] = &aSeriesLB;
493 aListBoxes[23] = &aReportTypeLB;
494 aListBoxes[24] = &aVolumeLB;
495 aListBoxes[25] = &aURLLB;
496 aListBoxes[26] = &aCustom1LB;
497 aListBoxes[27] = &aCustom2LB;
498 aListBoxes[28] = &aCustom3LB;
499 aListBoxes[29] = &aCustom4LB;
500 aListBoxes[30] = &aCustom5LB;
502 aListBoxes[0]->InsertEntry(sNone);
503 Reference< XNameAccess > xFields = getColumns( pDatMan->getForm() );
504 DBG_ASSERT(xFields.is(), "MappingDialog_Impl::MappingDialog_Impl : gave me an invalid form !");
505 if(xFields.is())
507 Sequence< ::rtl::OUString > aNames = xFields->getElementNames();
508 sal_Int32 nFieldsCount = aNames.getLength();
509 const ::rtl::OUString* pNames = aNames.getConstArray();
511 for(sal_Int32 nField = 0; nField < nFieldsCount; nField++)
512 aListBoxes[0]->InsertEntry(pNames[nField]);
515 Link aLnk = LINK(this, MappingDialog_Impl, ListBoxSelectHdl);
517 aListBoxes[0]->SelectEntryPos(0);
518 aListBoxes[0]->SetSelectHdl(aLnk);
519 for(sal_uInt16 i = 1; i < COLUMN_COUNT; i++)
521 for(sal_uInt16 j = 0; j < aListBoxes[0]->GetEntryCount();j++)
522 aListBoxes[i]->InsertEntry(aListBoxes[0]->GetEntry(j));
523 aListBoxes[i]->SelectEntryPos(0);
524 aListBoxes[i]->SetSelectHdl(aLnk);
526 BibConfig* pConfig = BibModul::GetConfig();
527 BibDBDescriptor aDesc;
528 aDesc.sDataSource = pDatMan->getActiveDataSource();
529 aDesc.sTableOrQuery = pDatMan->getActiveDataTable();
530 aDesc.nCommandType = CommandType::TABLE;
531 const Mapping* pMapping = pConfig->GetMapping(aDesc);
532 if(pMapping)
534 for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
536 sal_uInt16 nListBoxIndex = lcl_FindLogicalName( pConfig, pMapping->aColumnPairs[nEntry].sLogicalColumnName);
537 if(nListBoxIndex < COLUMN_COUNT)
539 aListBoxes[nListBoxIndex]->SelectEntry(pMapping->aColumnPairs[nEntry].sRealColumnName);
544 /* -----------------11.11.99 16:44-------------------
546 --------------------------------------------------*/
547 MappingDialog_Impl::~MappingDialog_Impl()
549 /* -----------------15.11.99 10:38-------------------
551 --------------------------------------------------*/
552 IMPL_LINK(MappingDialog_Impl, ListBoxSelectHdl, ListBox*, pListBox)
554 sal_uInt16 nEntryPos = pListBox->GetSelectEntryPos();
555 if(0 < nEntryPos)
557 for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++)
559 if(pListBox != aListBoxes[i] && aListBoxes[i]->GetSelectEntryPos() == nEntryPos)
560 aListBoxes[i]->SelectEntryPos(0);
563 SetModified();
564 return 0;
566 /* -----------------12.11.99 14:50-------------------
568 --------------------------------------------------*/
569 IMPL_LINK(MappingDialog_Impl, OkHdl, OKButton*, EMPTYARG)
571 if(bModified)
573 Mapping aNew;
574 aNew.sTableName = String(pDatMan->getActiveDataTable());
575 aNew.sURL = String(pDatMan->getActiveDataSource());
577 sal_uInt16 nWriteIndex = 0;
578 BibConfig* pConfig = BibModul::GetConfig();
579 for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
581 String sSel = aListBoxes[nEntry]->GetSelectEntry();
582 if(sSel != sNone)
584 aNew.aColumnPairs[nWriteIndex].sRealColumnName = sSel;
585 aNew.aColumnPairs[nWriteIndex].sLogicalColumnName = pConfig->GetDefColumnName(nEntry);
586 nWriteIndex++;
589 BibDBDescriptor aDesc;
590 aDesc.sDataSource = pDatMan->getActiveDataSource();
591 aDesc.sTableOrQuery = pDatMan->getActiveDataTable();
592 aDesc.nCommandType = CommandType::TABLE;
593 pDatMan->ResetIdentifierMapping();
594 pConfig->SetMapping(aDesc, &aNew);
596 EndDialog(bModified ? RET_OK : RET_CANCEL);
597 return 0;
599 /* -----------------18.11.99 10:23-------------------
601 --------------------------------------------------*/
602 class DBChangeDialog_Impl : public ModalDialog
604 OKButton aOKBT;
605 CancelButton aCancelBT;
606 HelpButton aHelpBT;
607 FixedLine aSelectionGB;
608 SvTabListBox aSelectionLB;
609 HeaderBar aSelectionHB;
610 DBChangeDialogConfig_Impl aConfig;
611 String aEntryST;
612 String aURLST;
614 BibDataManager* pDatMan;
616 // DECL_LINK(EndDragHdl, HeaderBar*);
617 DECL_LINK(DoubleClickHdl, SvTabListBox*);
618 public:
619 DBChangeDialog_Impl(Window* pParent, BibDataManager* pMan );
620 ~DBChangeDialog_Impl();
622 String GetCurrentURL()const;
625 /*-- 18.11.99 10:35:20---------------------------------------------------
627 -----------------------------------------------------------------------*/
628 DBChangeDialog_Impl::DBChangeDialog_Impl(Window* pParent, BibDataManager* pMan ) :
629 ModalDialog(pParent, BibResId(RID_DLG_DBCHANGE) ),
630 aOKBT(this, BibResId( BT_OK )),
631 aCancelBT(this, BibResId( BT_CANCEL )),
632 aHelpBT(this, BibResId( BT_HELP )),
633 aSelectionGB(this, BibResId( GB_SELECTION )),
634 aSelectionLB(this, BibResId( LB_SELECTION )),
635 aSelectionHB(this, BibResId( HB_SELECTION )),
636 aEntryST(BibResId(ST_ENTRY)),
637 aURLST( BibResId(ST_URL)),
638 pDatMan(pMan)
640 FreeResource();
641 aSelectionLB.SetDoubleClickHdl( LINK(this, DBChangeDialog_Impl, DoubleClickHdl));
644 Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
646 ::Size aSize = aSelectionHB.GetSizePixel();
647 long nTabs[2];
648 nTabs[0] = 1;// Number of Tabs
649 nTabs[1] = aSize.Width() / 4;
651 aSelectionHB.SetStyle(aSelectionHB.GetStyle()|WB_STDHEADERBAR);
652 aSelectionHB.InsertItem( 1, aEntryST, aSize.Width());
653 aSelectionHB.SetSizePixel(aSelectionHB.CalcWindowSizePixel());
654 aSelectionHB.Show();
656 aSelectionLB.SetTabs( &nTabs[0], MAP_PIXEL );
657 aSelectionLB.SetWindowBits(WB_CLIPCHILDREN|WB_SORT);
658 aSelectionLB.GetModel()->SetSortMode(SortAscending);
660 ::rtl::OUString sActiveSource = pDatMan->getActiveDataSource();
661 const Sequence< ::rtl::OUString >& rSources = aConfig.GetDataSourceNames();
662 const ::rtl::OUString* pSourceNames = rSources.getConstArray();
663 for(int i = 0; i < rSources.getLength(); i++)
665 SvLBoxEntry* pEntry = aSelectionLB.InsertEntry(pSourceNames[i]);
666 if(pSourceNames[i] == sActiveSource)
668 aSelectionLB.Select(pEntry);
671 aSelectionLB.GetModel()->Resort();
673 catch(Exception& e )
675 (void) e; // make compiler happy
676 DBG_ERROR("Exception in BibDataManager::DBChangeDialog_Impl::DBChangeDialog_Impl");
681 /* -----------------06.12.99 12:09-------------------
683 --------------------------------------------------*/
684 IMPL_LINK(DBChangeDialog_Impl, DoubleClickHdl, SvTabListBox*, /*pLB*/)
686 EndDialog(RET_OK);
687 return 0;
689 /* -----------------18.11.99 11:17-------------------
691 --------------------------------------------------*/
692 /*IMPL_LINK(DBChangeDialog_Impl, EndDragHdl, HeaderBar*, pHB)
694 long nTabs[3];
695 nTabs[0] = 2;// Number of Tabs
696 nTabs[1] = 0;
697 nTabs[2] = pHB->GetItemSize( 1 );
698 aSelectionLB.SetTabs( &nTabs[0], MAP_PIXEL );
699 return 0;
700 };*/
702 /*-- 18.11.99 10:35:20---------------------------------------------------
704 -----------------------------------------------------------------------*/
705 DBChangeDialog_Impl::~DBChangeDialog_Impl()
708 /* -----------------18.11.99 12:36-------------------
710 --------------------------------------------------*/
711 String DBChangeDialog_Impl::GetCurrentURL()const
713 String sRet;
714 SvLBoxEntry* pEntry = aSelectionLB.FirstSelected();
715 if(pEntry)
717 sRet = aSelectionLB.GetEntryText(pEntry, 0);
719 return sRet;
722 // #100312# --------------------------------------------------------------------
723 // XDispatchProvider
724 BibInterceptorHelper::BibInterceptorHelper( ::bib::BibBeamer* pBibBeamer, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch)
726 if( pBibBeamer )
728 xInterception = pBibBeamer->getDispatchProviderInterception();
729 if( xInterception.is() )
730 xInterception->registerDispatchProviderInterceptor( this );
732 if( xDispatch.is() )
733 xFormDispatch = xDispatch;
736 BibInterceptorHelper::~BibInterceptorHelper( )
740 void BibInterceptorHelper::ReleaseInterceptor()
742 if ( xInterception.is() )
743 xInterception->releaseDispatchProviderInterceptor( this );
744 xInterception.clear();
747 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL
748 BibInterceptorHelper::queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw (::com::sun::star::uno::RuntimeException)
750 Reference< XDispatch > xReturn;
752 String aCommand( aURL.Path );
753 if ( aCommand.EqualsAscii("FormSlots/ConfirmDeletion") )
754 xReturn = xFormDispatch;
755 else
756 if ( xSlaveDispatchProvider.is() )
757 xReturn = xSlaveDispatchProvider->queryDispatch( aURL, aTargetFrameName, nSearchFlags);
759 return xReturn;
762 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL
763 BibInterceptorHelper::queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw (::com::sun::star::uno::RuntimeException)
765 Sequence< Reference< XDispatch> > aReturn( aDescripts.getLength() );
766 Reference< XDispatch >* pReturn = aReturn.getArray();
767 const DispatchDescriptor* pDescripts = aDescripts.getConstArray();
768 for ( sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts )
770 *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
772 return aReturn;
775 // XDispatchProviderInterceptor
776 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
777 BibInterceptorHelper::getSlaveDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException)
779 return xSlaveDispatchProvider;
782 void SAL_CALL BibInterceptorHelper::setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlaveDispatchProvider ) throw (::com::sun::star::uno::RuntimeException)
784 xSlaveDispatchProvider = xNewSlaveDispatchProvider;
787 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
788 BibInterceptorHelper::getMasterDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException)
790 return xMasterDispatchProvider;
793 void SAL_CALL BibInterceptorHelper::setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMasterDispatchProvider ) throw (::com::sun::star::uno::RuntimeException)
795 xMasterDispatchProvider = xNewMasterDispatchProvider;
798 //-----------------------------------------------------------------------------
799 #define STR_UID "uid"
800 ::rtl::OUString gGridName(C2U("theGrid"));
801 ::rtl::OUString gViewName(C2U("theView"));
802 ::rtl::OUString gGlobalName(C2U("theGlobals"));
803 ::rtl::OUString gBeamerSize(C2U("theBeamerSize"));
804 ::rtl::OUString gViewSize(C2U("theViewSize"));
806 BibDataManager::BibDataManager()
807 :BibDataManager_Base( GetMutex() )
808 // #100312# --------------
809 ,m_pInterceptorHelper( NULL )
810 ,m_aLoadListeners(m_aMutex)
811 ,pBibView( NULL )
812 ,pToolbar(0)
816 /* --------------------------------------------------
818 --------------------------------------------------*/
819 BibDataManager::~BibDataManager()
821 Reference< XLoadable > xLoad( m_xForm, UNO_QUERY );
822 Reference< XPropertySet > xPrSet( m_xForm, UNO_QUERY );
823 Reference< XComponent > xComp( m_xForm, UNO_QUERY );
824 if ( m_xForm.is() )
826 Reference< XComponent > xConnection;
827 xPrSet->getPropertyValue(C2U("ActiveConnection")) >>= xConnection;
828 RemoveMeAsUidListener();
829 if (xLoad.is())
830 xLoad->unload();
831 if (xComp.is())
832 xComp->dispose();
833 if(xConnection.is())
834 xConnection->dispose();
835 m_xForm = NULL;
837 // #100312# ----------------
838 if( m_pInterceptorHelper )
840 m_pInterceptorHelper->ReleaseInterceptor();
841 m_pInterceptorHelper->release();
842 m_pInterceptorHelper = NULL;
845 //------------------------------------------------------------------------
846 void BibDataManager::InsertFields(const Reference< XFormComponent > & _rxGrid)
848 if ( !_rxGrid.is() )
849 return;
853 Reference< XNameContainer > xColContainer( _rxGrid, UNO_QUERY );
854 // remove the old fields
855 if ( xColContainer->hasElements() )
857 Sequence< ::rtl::OUString > aNames = xColContainer->getElementNames();
858 const ::rtl::OUString* pNames = aNames.getConstArray();
859 const ::rtl::OUString* pNamesEnd = pNames + aNames.getLength();
860 for ( ; pNames != pNamesEnd; ++pNames )
861 xColContainer->removeByName( *pNames );
864 Reference< XNameAccess > xFields = getColumns( m_xForm );
865 if (!xFields.is())
866 return;
868 Reference< XGridColumnFactory > xColFactory( _rxGrid, UNO_QUERY );
870 Reference< XPropertySet > xField;
872 Sequence< ::rtl::OUString > aFields( xFields->getElementNames() );
873 const ::rtl::OUString* pFields = aFields.getConstArray();
874 const ::rtl::OUString* pFieldsEnd = pFields + aFields.getLength();
876 for ( ; pFields != pFieldsEnd; ++pFields )
878 xFields->getByName( *pFields ) >>= xField;
880 ::rtl::OUString sCurrentModelType;
881 const ::rtl::OUString sType(C2U("Type"));
882 sal_Int32 nType = 0;
883 sal_Bool bIsFormatted = sal_False;
884 sal_Bool bFormattedIsNumeric = sal_True;
885 xField->getPropertyValue(sType) >>= nType;
886 switch(nType)
888 case DataType::BIT:
889 case DataType::BOOLEAN:
890 sCurrentModelType = C2U("CheckBox");
891 break;
893 case DataType::BINARY:
894 case DataType::VARBINARY:
895 case DataType::LONGVARBINARY:
896 sCurrentModelType = C2U("TextField");
897 break;
899 case DataType::VARCHAR:
900 case DataType::LONGVARCHAR:
901 case DataType::CHAR:
902 bFormattedIsNumeric = sal_False;
903 // _NO_ break !
904 default:
905 sCurrentModelType = C2U("FormattedField");
906 bIsFormatted = sal_True;
907 break;
910 Reference< XPropertySet > xCurrentCol = xColFactory->createColumn(sCurrentModelType);
911 if (bIsFormatted)
913 ::rtl::OUString sFormatKey(C2U("FormatKey"));
914 xCurrentCol->setPropertyValue(sFormatKey, xField->getPropertyValue(sFormatKey));
915 Any aFormatted(&bFormattedIsNumeric, ::getBooleanCppuType());
916 xCurrentCol->setPropertyValue(C2U("TreatAsNumber"), aFormatted);
918 Any aColName = makeAny( *pFields );
919 xCurrentCol->setPropertyValue(FM_PROP_CONTROLSOURCE, aColName);
920 xCurrentCol->setPropertyValue(FM_PROP_LABEL, aColName);
922 xColContainer->insertByName( *pFields, makeAny( xCurrentCol ) );
925 catch(Exception& e )
927 (void) e; // make compiler happy
928 DBG_ERROR("Exception in BibDataManager::InsertFields");
931 /* --------------------------------------------------
933 --------------------------------------------------*/
934 Reference< awt::XControlModel > BibDataManager::updateGridModel()
936 return updateGridModel( m_xForm );
938 /* --------------------------------------------------
940 --------------------------------------------------*/
941 Reference< awt::XControlModel > BibDataManager::updateGridModel(const Reference< XForm > & xDbForm)
945 Reference< XPropertySet > aFormPropSet( xDbForm, UNO_QUERY );
946 ::rtl::OUString sName;
947 aFormPropSet->getPropertyValue(C2U("Command")) >>= sName;
949 if ( !m_xGridModel.is() )
951 m_xGridModel = createGridModel( gGridName );
953 Reference< XNameContainer > xNameCont(xDbForm, UNO_QUERY);
954 // if (xNameCont->hasByName(sName))
955 // xNameCont->removeByName(sName);
957 xNameCont->insertByName( sName, makeAny( m_xGridModel ) );
960 // insert the fields
961 Reference< XFormComponent > xFormComp( m_xGridModel, UNO_QUERY );
962 InsertFields( xFormComp );
964 catch(Exception& e )
966 (void) e; // make compiler happy
967 DBG_ERROR("::updateGridModel: something went wrong !");
971 return m_xGridModel;
973 /* --------------------------------------------------
975 --------------------------------------------------*/
976 Reference< XForm > BibDataManager::createDatabaseForm(BibDBDescriptor& rDesc)
978 Reference< XForm > xResult;
981 Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
982 m_xForm = Reference< XForm > ( xMgr->createInstance( C2U("com.sun.star.form.component.Form") ), UNO_QUERY );
984 Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY );
986 aDataSourceURL = rDesc.sDataSource;
987 if(aPropertySet.is())
989 Any aVal;
990 aVal <<= (sal_Int32)ResultSetType::SCROLL_INSENSITIVE;
991 aPropertySet->setPropertyValue(C2U("ResultSetType"),aVal );
992 aVal <<= (sal_Int32)ResultSetConcurrency::READ_ONLY;
993 aPropertySet->setPropertyValue(C2U("ResultSetConcurrency"), aVal);
995 //Caching for Performance
996 aVal <<= (sal_Int32)50;
997 aPropertySet->setPropertyValue(C2U("FetchSize"), aVal);
999 Reference< XConnection > xConnection = getConnection(rDesc.sDataSource);
1000 aVal <<= xConnection;
1001 aPropertySet->setPropertyValue(C2U("ActiveConnection"), aVal);
1003 Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
1004 Reference< XNameAccess > xTables = xSupplyTables.is() ?
1005 xSupplyTables->getTables() : Reference< XNameAccess > ();
1007 Sequence< ::rtl::OUString > aTableNameSeq;
1008 if (xTables.is())
1009 aTableNameSeq = xTables->getElementNames();
1011 if(aTableNameSeq.getLength() > 0)
1013 const ::rtl::OUString* pTableNames = aTableNameSeq.getConstArray();
1014 if(rDesc.sTableOrQuery.getLength())
1015 aActiveDataTable = rDesc.sTableOrQuery;
1016 else
1018 rDesc.sTableOrQuery = aActiveDataTable = pTableNames[0];
1019 rDesc.nCommandType = CommandType::TABLE;
1022 aVal <<= aActiveDataTable;
1023 aPropertySet->setPropertyValue(C2U("Command"), aVal);
1024 aVal <<= rDesc.nCommandType;
1025 aPropertySet->setPropertyValue(C2U("CommandType"), aVal);
1028 Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
1029 aQuoteChar = xMetaData->getIdentifierQuoteString();
1031 Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY);
1032 if ( xFactory.is() )
1033 m_xParser.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), UNO_QUERY );
1035 ::rtl::OUString aString(C2U("SELECT * FROM "));
1037 ::rtl::OUString sCatalog, sSchema, sName;
1038 ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
1039 aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
1041 m_xParser->setElementaryQuery(aString);
1042 BibConfig* pConfig = BibModul::GetConfig();
1043 pConfig->setQueryField(getQueryField());
1044 startQueryWith(pConfig->getQueryText());
1046 xResult = m_xForm;
1050 catch(Exception& e )
1052 (void) e; // make compiler happy
1053 DBG_ERROR("::createDatabaseForm: something went wrong !");
1057 return xResult;
1059 //------------------------------------------------------------------------
1060 Sequence< ::rtl::OUString > BibDataManager::getDataSources()
1062 Sequence< ::rtl::OUString > aTableNameSeq;
1066 Reference< XTablesSupplier > xSupplyTables( getConnection( m_xForm ), UNO_QUERY );
1067 Reference< XNameAccess > xTables;
1068 if (xSupplyTables.is())
1069 xTables = xSupplyTables->getTables();
1070 if (xTables.is())
1071 aTableNameSeq = xTables->getElementNames();
1073 catch(Exception& e )
1075 (void) e; // make compiler happy
1076 DBG_ERROR("::getDataSources: something went wrong !");
1080 return aTableNameSeq;
1082 //------------------------------------------------------------------------
1083 ::rtl::OUString BibDataManager::getActiveDataTable()
1085 return aActiveDataTable;
1087 //------------------------------------------------------------------------
1088 void BibDataManager::setFilter(const ::rtl::OUString& rQuery)
1090 if(!m_xParser.is())
1091 return;
1094 m_xParser->setFilter(rQuery);
1095 ::rtl::OUString aQuery=m_xParser->getFilter();
1096 Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY );
1097 Any aVal; aVal <<= aQuery;
1098 aPropertySet->setPropertyValue(C2U("Filter"), aVal);
1099 BOOL bVal = sal_True;
1100 aVal.setValue(&bVal, ::getBooleanCppuType());
1101 aPropertySet->setPropertyValue(C2U("ApplyFilter"), aVal);
1102 reload();
1104 catch(Exception& e )
1106 (void) e; // make compiler happy
1107 DBG_ERROR("::setFilterOnActiveDataSource: something went wrong !");
1112 //------------------------------------------------------------------------
1113 ::rtl::OUString BibDataManager::getFilter()
1116 ::rtl::OUString aQueryString;
1119 Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY );
1120 Any aQuery=aPropertySet->getPropertyValue(C2U("Filter"));
1122 if(aQuery.getValueType() == ::getCppuType((::rtl::OUString*)0))
1124 aQueryString=*(::rtl::OUString*)aQuery.getValue();
1127 catch(Exception& e )
1129 (void) e; // make compiler happy
1130 DBG_ERROR("::getFilterOnActiveDataSource: something went wrong !");
1134 return aQueryString;
1137 //------------------------------------------------------------------------
1138 Sequence< ::rtl::OUString > BibDataManager::getQueryFields()
1140 Sequence< ::rtl::OUString > aFieldSeq;
1141 Reference< XNameAccess > xFields = getColumns( m_xForm );
1142 if (xFields.is())
1143 aFieldSeq = xFields->getElementNames();
1144 return aFieldSeq;
1146 //------------------------------------------------------------------------
1147 ::rtl::OUString BibDataManager::getQueryField()
1149 BibConfig* pConfig = BibModul::GetConfig();
1150 ::rtl::OUString aFieldString = pConfig->getQueryField();
1151 if(!aFieldString.getLength())
1153 Sequence< ::rtl::OUString > aSeq = getQueryFields();
1154 const ::rtl::OUString* pFields = aSeq.getConstArray();
1155 if(aSeq.getLength()>0)
1157 aFieldString=pFields[0];
1160 return aFieldString;
1162 //------------------------------------------------------------------------
1163 void BibDataManager::startQueryWith(const ::rtl::OUString& rQuery)
1165 BibConfig* pConfig = BibModul::GetConfig();
1166 pConfig->setQueryText( rQuery );
1168 ::rtl::OUString aQueryString;
1169 if(rQuery.getLength()>0)
1171 aQueryString=aQuoteChar;
1172 aQueryString+=getQueryField();
1173 aQueryString+=aQuoteChar;
1174 aQueryString+=C2U(" like '");
1175 String sQuery(rQuery);
1176 sQuery.SearchAndReplaceAll('?','_');
1177 sQuery.SearchAndReplaceAll('*','%');
1178 aQueryString += sQuery;
1179 aQueryString+=C2U("%'");
1181 setFilter(aQueryString);
1183 /* -----------------03.12.99 15:05-------------------
1185 --------------------------------------------------*/
1186 void BibDataManager::setActiveDataSource(const ::rtl::OUString& rURL)
1188 ::rtl::OUString uTable;
1189 ::rtl::OUString sTmp(aDataSourceURL);
1190 aDataSourceURL = rURL;
1192 Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY );
1193 if(aPropertySet.is())
1195 unload();
1197 Reference< XComponent > xOldConnection;
1198 aPropertySet->getPropertyValue(C2U("ActiveConnection")) >>= xOldConnection;
1200 Reference< XConnection > xConnection = getConnection(rURL);
1201 if(!xConnection.is())
1203 aDataSourceURL = sTmp;
1204 return;
1206 Any aVal; aVal <<= xConnection;
1207 aPropertySet->setPropertyValue(C2U("ActiveConnection"), aVal);
1208 Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY);
1209 if ( xFactory.is() )
1210 m_xParser.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), UNO_QUERY );
1212 if(xOldConnection.is())
1213 xOldConnection->dispose();
1215 Sequence< ::rtl::OUString > aTableNameSeq;
1216 Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
1217 if(xSupplyTables.is())
1219 Reference< XNameAccess > xAccess = xSupplyTables->getTables();
1220 aTableNameSeq = xAccess->getElementNames();
1222 if(aTableNameSeq.getLength() > 0)
1224 const ::rtl::OUString* pTableNames = aTableNameSeq.getConstArray();
1225 aActiveDataTable = pTableNames[0];
1226 aVal <<= aActiveDataTable;
1227 aPropertySet->setPropertyValue(C2U("Command"), aVal);
1228 aPropertySet->setPropertyValue(C2U("CommandType"), makeAny(CommandType::TABLE));
1229 //Caching for Performance
1230 aVal <<= (sal_Int32)50;
1231 aPropertySet->setPropertyValue(C2U("FetchSize"), aVal);
1232 ::rtl::OUString aString(C2U("SELECT * FROM "));
1233 // quote the table name which may contain catalog.schema.table
1234 Reference<XDatabaseMetaData> xMetaData(xConnection->getMetaData(),UNO_QUERY);
1235 aQuoteChar = xMetaData->getIdentifierQuoteString();
1237 ::rtl::OUString sCatalog, sSchema, sName;
1238 ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
1239 aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
1241 m_xParser->setElementaryQuery(aString);
1242 BibConfig* pConfig = BibModul::GetConfig();
1243 pConfig->setQueryField(getQueryField());
1244 startQueryWith(pConfig->getQueryText());
1245 setActiveDataTable(aActiveDataTable);
1247 FeatureStateEvent aEvent;
1248 util::URL aURL;
1249 aEvent.IsEnabled = sal_True;
1250 aEvent.Requery = sal_False;
1251 aEvent.FeatureDescriptor = getActiveDataTable();
1253 aEvent.State = makeAny( getDataSources() );
1255 if(pToolbar)
1257 aURL.Complete =C2U(".uno:Bib/source");
1258 aEvent.FeatureURL = aURL;
1259 pToolbar->statusChanged( aEvent );
1262 updateGridModel();
1263 load();
1267 /* --------------------------------------------------
1269 --------------------------------------------------*/
1270 void BibDataManager::setActiveDataTable(const ::rtl::OUString& rTable)
1272 ResetIdentifierMapping();
1275 Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY );
1277 if(aPropertySet.is())
1279 Reference< XConnection > xConnection = getConnection( m_xForm );
1280 Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
1281 Reference< XNameAccess > xAccess = xSupplyTables->getTables();
1282 Sequence< ::rtl::OUString > aTableNameSeq = xAccess->getElementNames();
1283 sal_uInt32 nCount = aTableNameSeq.getLength();
1285 const ::rtl::OUString* pTableNames = aTableNameSeq.getConstArray();
1286 const ::rtl::OUString* pTableNamesEnd = pTableNames + nCount;
1288 for ( ; pTableNames != pTableNamesEnd; ++pTableNames )
1290 if ( rTable == *pTableNames )
1292 aActiveDataTable = rTable;
1293 Any aVal; aVal <<= rTable;
1294 aPropertySet->setPropertyValue( C2U("Command"), aVal );
1295 break;
1298 if (pTableNames != pTableNamesEnd)
1300 Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
1301 aQuoteChar = xMetaData->getIdentifierQuoteString();
1303 Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY);
1304 if ( xFactory.is() )
1305 m_xParser.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), UNO_QUERY );
1307 ::rtl::OUString aString(C2U("SELECT * FROM "));
1309 ::rtl::OUString sCatalog, sSchema, sName;
1310 ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
1311 aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
1313 m_xParser->setElementaryQuery(aString);
1315 BibConfig* pConfig = BibModul::GetConfig();
1316 pConfig->setQueryField(getQueryField());
1317 startQueryWith(pConfig->getQueryText());
1319 BibDBDescriptor aDesc;
1320 aDesc.sDataSource = aDataSourceURL;
1321 aDesc.sTableOrQuery = aActiveDataTable;
1322 aDesc.nCommandType = CommandType::TABLE;
1323 BibModul::GetConfig()->SetBibliographyURL(aDesc);
1327 catch(Exception& e )
1329 (void) e; // make compiler happy
1330 DBG_ERROR("::setActiveDataTable: something went wrong !");
1335 //------------------------------------------------------------------------
1336 void SAL_CALL BibDataManager::load( ) throw (RuntimeException)
1338 if ( isLoaded() )
1339 // nothing to do
1340 return;
1342 Reference< XLoadable > xFormAsLoadable( m_xForm, UNO_QUERY );
1343 DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::load: invalid form!");
1344 if ( xFormAsLoadable.is() )
1346 xFormAsLoadable->load();
1347 SetMeAsUidListener();
1349 EventObject aEvt( static_cast< XWeak* >( this ) );
1350 m_aLoadListeners.notifyEach( &XLoadListener::loaded, aEvt );
1354 //------------------------------------------------------------------------
1355 void SAL_CALL BibDataManager::unload( ) throw (RuntimeException)
1357 if ( !isLoaded() )
1358 // nothing to do
1359 return;
1361 Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY );
1362 DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::unload: invalid form!");
1363 if ( xFormAsLoadable.is() )
1365 EventObject aEvt( static_cast< XWeak* >( this ) );
1368 m_aLoadListeners.notifyEach( &XLoadListener::unloading, aEvt );
1371 RemoveMeAsUidListener();
1372 xFormAsLoadable->unload();
1375 m_aLoadListeners.notifyEach( &XLoadListener::unloaded, aEvt );
1380 //------------------------------------------------------------------------
1381 void SAL_CALL BibDataManager::reload( ) throw (RuntimeException)
1383 if ( !isLoaded() )
1384 // nothing to do
1385 return;
1387 Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY );
1388 DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::unload: invalid form!");
1389 if ( xFormAsLoadable.is() )
1391 EventObject aEvt( static_cast< XWeak* >( this ) );
1394 m_aLoadListeners.notifyEach( &XLoadListener::reloading, aEvt );
1397 xFormAsLoadable->reload();
1400 m_aLoadListeners.notifyEach( &XLoadListener::reloaded, aEvt );
1405 //------------------------------------------------------------------------
1406 sal_Bool SAL_CALL BibDataManager::isLoaded( ) throw (RuntimeException)
1408 Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY );
1409 DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::isLoaded: invalid form!");
1411 sal_Bool bLoaded = sal_False;
1412 if ( xFormAsLoadable.is() )
1413 bLoaded = xFormAsLoadable->isLoaded();
1414 return bLoaded;
1417 //------------------------------------------------------------------------
1418 void SAL_CALL BibDataManager::addLoadListener( const Reference< XLoadListener >& aListener ) throw (RuntimeException)
1420 m_aLoadListeners.addInterface( aListener );
1423 //------------------------------------------------------------------------
1424 void SAL_CALL BibDataManager::removeLoadListener( const Reference< XLoadListener >& aListener ) throw (RuntimeException)
1426 m_aLoadListeners.removeInterface( aListener );
1429 //------------------------------------------------------------------------
1430 Reference< awt::XControlModel > BibDataManager::createGridModel(const ::rtl::OUString& rName)
1432 Reference< awt::XControlModel > xModel;
1436 // create the control model
1437 Reference< XMultiServiceFactory > xMgr = ::comphelper::getProcessServiceFactory();
1438 Reference< XInterface > xObject = xMgr->createInstance(C2U("com.sun.star.form.component.GridControl"));
1439 xModel=Reference< awt::XControlModel > ( xObject, UNO_QUERY );
1441 // set the
1442 Reference< XPropertySet > xPropSet( xModel, UNO_QUERY );
1443 xPropSet->setPropertyValue( C2U("Name"), makeAny( rName ) );
1445 // set the name of the to-be-created control
1446 ::rtl::OUString aControlName(C2U("com.sun.star.form.control.InteractionGridControl"));
1447 Any aAny; aAny <<= aControlName;
1448 xPropSet->setPropertyValue( C2U("DefaultControl"),aAny );
1450 // the the helpURL
1451 ::rtl::OUString uProp(C2U("HelpURL"));
1452 Reference< XPropertySetInfo > xPropInfo = xPropSet->getPropertySetInfo();
1453 if (xPropInfo->hasPropertyByName(uProp))
1455 ::rtl::OUString sId = ::rtl::OUString::createFromAscii( "HID:" );
1456 sId += ::rtl::OUString::valueOf( (sal_Int32) HID_BIB_DB_GRIDCTRL );
1457 xPropSet->setPropertyValue( uProp, makeAny( ::rtl::OUString( sId ) ) );
1460 catch(Exception& e )
1462 (void) e; // make compiler happy
1463 DBG_ERROR("::createGridModel: something went wrong !");
1467 return xModel;
1469 //------------------------------------------------------------------------
1470 ::rtl::OUString BibDataManager::getControlName(sal_Int32 nFormatKey )
1472 ::rtl::OUString aResStr;
1473 switch (nFormatKey)
1475 case DataType::BIT:
1476 case DataType::BOOLEAN:
1477 aResStr=C2U("CheckBox");
1478 break;
1479 case DataType::TINYINT:
1480 case DataType::SMALLINT:
1481 case DataType::INTEGER:
1482 aResStr=C2U("NumericField"); ;
1483 break;
1484 case DataType::REAL:
1485 case DataType::DOUBLE:
1486 case DataType::NUMERIC:
1487 case DataType::DECIMAL:
1488 aResStr=C2U("FormattedField");
1489 break;
1490 case DataType::TIMESTAMP:
1491 aResStr=C2U("FormattedField");
1492 break;
1493 case DataType::DATE:
1494 aResStr=C2U("DateField");
1495 break;
1496 case DataType::TIME:
1497 aResStr=C2U("TimeField");
1498 break;
1499 case DataType::CHAR:
1500 case DataType::VARCHAR:
1501 case DataType::LONGVARCHAR:
1502 default:
1503 aResStr=C2U("TextField");
1504 break;
1506 return aResStr;
1508 //------------------------------------------------------------------------
1509 Reference< awt::XControlModel > BibDataManager::loadControlModel(
1510 const ::rtl::OUString& rName, sal_Bool bForceListBox)
1512 Reference< awt::XControlModel > xModel;
1513 ::rtl::OUString aName(C2U("View_"));
1514 aName += rName;
1518 Reference< XNameAccess > xFields = getColumns( m_xForm );
1519 if (!xFields.is())
1520 return xModel;
1521 Reference< XPropertySet > xField;
1523 Any aElement;
1525 if(xFields->hasByName(rName))
1527 aElement = xFields->getByName(rName);
1528 aElement >>= xField;
1529 Reference< XPropertySetInfo > xInfo = xField.is() ? xField->getPropertySetInfo() : Reference< XPropertySetInfo > ();
1531 ::rtl::OUString sCurrentModelType;
1532 const ::rtl::OUString sType(C2U("Type"));
1533 sal_Int32 nFormatKey = 0;
1534 xField->getPropertyValue(sType) >>= nFormatKey;
1536 ::rtl::OUString aInstanceName(C2U("com.sun.star.form.component."));
1538 if (bForceListBox)
1539 aInstanceName += C2U("ListBox");
1540 else
1541 aInstanceName += getControlName(nFormatKey);
1543 Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
1544 Reference< XInterface > xObject = xMgr->createInstance(aInstanceName);
1545 xModel=Reference< awt::XControlModel > ( xObject, UNO_QUERY );
1546 Reference< XPropertySet > xPropSet( xModel, UNO_QUERY );
1547 Any aFieldName; aFieldName <<= aName;
1549 xPropSet->setPropertyValue( FM_PROP_NAME,aFieldName);
1550 xPropSet->setPropertyValue( FM_PROP_CONTROLSOURCE, makeAny( rName ) );
1551 xPropSet->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NativeWidgetLook" ) ), makeAny( (sal_Bool)sal_True ) );
1553 Reference< XFormComponent > aFormComp(xModel,UNO_QUERY );
1555 Reference< XNameContainer > xNameCont( m_xForm, UNO_QUERY );
1556 xNameCont->insertByName(aName, makeAny( aFormComp ) );
1558 // now if the form where we inserted the new model is already loaded, notify the model of this
1559 // Note that this implementation below is a HACK as it relies on the fact that the model adds itself
1560 // as load listener to it's parent, which is an implementation detail of the model.
1562 // the better solution would be the following:
1563 // in the current scenario, we insert a control model into a form. This results in the control model
1564 // adding itself as load listener to the form. Now, the form should realize that it's already loaded
1565 // and notify the model (which it knows as XLoadListener only) immediately. This seems to make sense.
1566 // (as an anologon to the XStatusListener semantics).
1568 // But this would be way too risky for this last-day fix here.
1569 // 97140 - 30.01.2002 - fs@openoffice.org
1570 Reference< XLoadable > xLoad( m_xForm, UNO_QUERY );
1571 if ( xLoad.is() && xLoad->isLoaded() )
1573 Reference< XLoadListener > xListener( aFormComp, UNO_QUERY );
1574 if ( xListener.is() )
1576 EventObject aLoadSource;
1577 aLoadSource.Source = xLoad;
1578 xListener->loaded( aLoadSource );
1583 catch(Exception& e )
1585 (void) e; // make compiler happy
1586 DBG_ERROR("::loadControlModel: something went wrong !");
1588 return xModel;
1590 //------------------------------------------------------------------------
1591 void SAL_CALL BibDataManager::disposing()
1593 BibDataManager_Base::WeakComponentImplHelperBase::disposing();
1596 //------------------------------------------------------------------------
1597 void BibDataManager::disposing( const EventObject& /*Source*/ ) throw( ::com::sun::star::uno::RuntimeException )
1599 // not interested in
1602 //------------------------------------------------------------------------
1603 void BibDataManager::propertyChange(const beans::PropertyChangeEvent& evt) throw( RuntimeException )
1607 sal_Bool bFlag=sal_False;
1608 if(evt.PropertyName == FM_PROP_VALUE)
1610 if( evt.NewValue.getValueType() == ::getCppuType((Reference<io::XInputStream>*)0) )
1612 Reference< io::XDataInputStream > xStream(
1613 *(const Reference< io::XInputStream > *)evt.NewValue.getValue(), UNO_QUERY );
1614 aUID <<= xStream->readUTF();
1616 else
1617 aUID = evt.NewValue;
1619 Reference< XRowLocate > xLocate(xBibCursor, UNO_QUERY);
1620 DBG_ASSERT(xLocate.is(), "BibDataManager::propertyChange : invalid cursor !");
1621 bFlag = xLocate->moveToBookmark(aUID);
1624 catch(Exception& e )
1626 (void) e; // make compiler happy
1627 DBG_ERROR("::propertyChange: something went wrong !");
1632 //------------------------------------------------------------------------
1633 void BibDataManager::SetMeAsUidListener()
1637 Reference< XNameAccess > xFields = getColumns( m_xForm );
1638 if (!xFields.is())
1639 return;
1641 Sequence< ::rtl::OUString > aFields(xFields->getElementNames());
1642 const ::rtl::OUString* pFields = aFields.getConstArray();
1643 sal_Int32 nCount=aFields.getLength();
1644 String StrUID(C2S(STR_UID));
1645 ::rtl::OUString theFieldName;
1646 for( sal_Int32 i=0; i<nCount; i++ )
1648 String aName= pFields[i];
1650 if(aName.EqualsIgnoreCaseAscii(StrUID))
1652 theFieldName=pFields[i];
1653 break;
1657 if(theFieldName.getLength()>0)
1659 Reference< XPropertySet > xPropSet;
1660 Any aElement;
1662 aElement = xFields->getByName(theFieldName);
1663 xPropSet = *(Reference< XPropertySet > *)aElement.getValue();
1665 xPropSet->addPropertyChangeListener(FM_PROP_VALUE, this);
1669 catch(Exception& e )
1671 (void) e; // make compiler happy
1672 DBG_ERROR("Exception in BibDataManager::SetMeAsUidListener");
1677 //------------------------------------------------------------------------
1678 void BibDataManager::RemoveMeAsUidListener()
1682 Reference< XNameAccess > xFields = getColumns( m_xForm );
1683 if (!xFields.is())
1684 return;
1687 Sequence< ::rtl::OUString > aFields(xFields->getElementNames());
1688 const ::rtl::OUString* pFields = aFields.getConstArray();
1689 sal_Int32 nCount=aFields.getLength();
1690 String StrUID(C2S(STR_UID));
1691 ::rtl::OUString theFieldName;
1692 for( sal_Int32 i=0; i<nCount; i++ )
1694 String aName= pFields[i];
1696 if(aName.EqualsIgnoreCaseAscii(StrUID))
1698 theFieldName=pFields[i];
1699 break;
1703 if(theFieldName.getLength()>0)
1705 Reference< XPropertySet > xPropSet;
1706 Any aElement;
1708 aElement = xFields->getByName(theFieldName);
1709 xPropSet = *(Reference< XPropertySet > *)aElement.getValue();
1711 xPropSet->removePropertyChangeListener(FM_PROP_VALUE, this);
1715 catch(Exception& e )
1717 (void) e; // make compiler happy
1718 DBG_ERROR("Exception in BibDataManager::RemoveMeAsUidListener");
1723 /* -----------------11.11.99 15:51-------------------
1725 --------------------------------------------------*/
1726 void BibDataManager::CreateMappingDialog(Window* pParent)
1728 MappingDialog_Impl* pDlg = new MappingDialog_Impl(pParent, this);
1729 if(RET_OK == pDlg->Execute() && pBibView)
1731 reload();
1732 // unload();
1733 // pBibView->UpdatePages();
1734 // load();
1736 delete pDlg;
1738 /* --------------------------------------------------
1740 --------------------------------------------------*/
1741 ::rtl::OUString BibDataManager::CreateDBChangeDialog(Window* pParent)
1743 ::rtl::OUString uRet;
1744 DBChangeDialog_Impl * pDlg = new DBChangeDialog_Impl(pParent, this );
1745 if(RET_OK == pDlg->Execute())
1747 String sNewURL = pDlg->GetCurrentURL();
1748 if(sNewURL != String(getActiveDataSource()))
1750 uRet = sNewURL;
1753 delete pDlg;
1754 return uRet;
1756 /*-- 18.05.2004 15:20:15---------------------------------------------------
1758 -----------------------------------------------------------------------*/
1759 void BibDataManager::DispatchDBChangeDialog()
1761 if(pToolbar)
1762 pToolbar->SendDispatch(TBC_BT_CHANGESOURCE, Sequence< PropertyValue >());
1764 /* -----------------06.12.99 15:11-------------------
1766 --------------------------------------------------*/
1767 const ::rtl::OUString& BibDataManager::GetIdentifierMapping()
1769 if(!sIdentifierMapping.getLength())
1771 BibConfig* pConfig = BibModul::GetConfig();
1772 BibDBDescriptor aDesc;
1773 aDesc.sDataSource = getActiveDataSource();
1774 aDesc.sTableOrQuery = getActiveDataTable();
1775 aDesc.nCommandType = CommandType::TABLE;
1776 const Mapping* pMapping = pConfig->GetMapping(aDesc);
1777 sIdentifierMapping = pConfig->GetDefColumnName(IDENTIFIER_POS);
1778 if(pMapping)
1780 for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
1782 if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == sIdentifierMapping)
1784 sIdentifierMapping = pMapping->aColumnPairs[nEntry].sRealColumnName;
1785 break;
1790 return sIdentifierMapping;
1792 /* -----------------------------20.11.00 10:31--------------------------------
1794 ---------------------------------------------------------------------------*/
1795 void BibDataManager::SetToolbar(BibToolBar* pSet)
1797 pToolbar = pSet;
1798 if(pToolbar)
1799 pToolbar->SetDatMan(*this);
1801 /* -----------------------------08.05.2002 09:26------------------------------
1803 ---------------------------------------------------------------------------*/
1804 uno::Reference< form::XFormController > BibDataManager::GetFormController()
1806 if(!m_xFormCtrl.is())
1808 Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
1809 m_xFormCtrl = uno::Reference< form::XFormController > (
1810 xMgr->createInstance(C2U("com.sun.star.form.FormController")), UNO_QUERY);
1811 m_xFormCtrl->setModel(uno::Reference< awt::XTabControllerModel > (getForm(), UNO_QUERY));
1812 // #100312# -------------
1813 m_xFormDispatch = uno::Reference< frame::XDispatch > ( m_xFormCtrl, UNO_QUERY);
1815 return m_xFormCtrl;
1818 // #100312# ----------
1819 void BibDataManager::RegisterInterceptor( ::bib::BibBeamer* pBibBeamer)
1821 DBG_ASSERT( !m_pInterceptorHelper, "BibDataManager::RegisterInterceptor: called twice!" );
1823 if( pBibBeamer )
1824 m_pInterceptorHelper = new BibInterceptorHelper( pBibBeamer, m_xFormDispatch);
1825 if( m_pInterceptorHelper )
1826 m_pInterceptorHelper->acquire();
1829 /*-- 18.05.2004 17:04:20---------------------------------------------------
1831 -----------------------------------------------------------------------*/
1832 sal_Bool BibDataManager::HasActiveConnection()const
1834 sal_Bool bRet = sal_False;
1835 Reference< XPropertySet > xPrSet( m_xForm, UNO_QUERY );
1836 if( xPrSet.is() )
1838 Reference< XComponent > xConnection;
1839 xPrSet->getPropertyValue(C2U("ActiveConnection")) >>= xConnection;
1840 bRet = xConnection.is();
1842 return bRet;
1844 /*-- 04.06.2004 14:37:29---------------------------------------------------
1846 -----------------------------------------------------------------------*/
1847 sal_Bool BibDataManager::HasActiveConnection()
1849 return getConnection( m_xForm ).is();