LCOV - code coverage report
Current view: top level - extensions/source/bibliography - datman.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 6 789 0.8 %
Date: 2014-11-03 Functions: 2 68 2.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <osl/mutex.hxx>
      21             : #include <tools/diagnose_ex.h>
      22             : #include <comphelper/processfactory.hxx>
      23             : #include <com/sun/star/io/XPersistObject.hpp>
      24             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      25             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      26             : #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
      27             : #include <com/sun/star/sdbcx/XRowLocate.hpp>
      28             : #include <com/sun/star/sdbc/DataType.hpp>
      29             : #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
      30             : #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
      31             : #include <com/sun/star/sdb/XDatabaseEnvironment.hpp>
      32             : #include <com/sun/star/uno/XNamingService.hpp>
      33             : #include <com/sun/star/sdbc/XDataSource.hpp>
      34             : #include <com/sun/star/sdb/CommandType.hpp>
      35             : #include <com/sun/star/sdb/DatabaseContext.hpp>
      36             : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      37             : #include <com/sun/star/sdbc/XConnection.hpp>
      38             : #include <com/sun/star/sdb/XCompletedConnection.hpp>
      39             : #include <com/sun/star/task/InteractionHandler.hpp>
      40             : #include <com/sun/star/form/XLoadable.hpp>
      41             : #include <com/sun/star/form/runtime/FormController.hpp>
      42             : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      43             : #include <com/sun/star/form/XGridColumnFactory.hpp>
      44             : #include <com/sun/star/io/XDataInputStream.hpp>
      45             : #include <com/sun/star/container/XNameContainer.hpp>
      46             : #include <comphelper/container.hxx>
      47             : #include <svl/urihelper.hxx>
      48             : #include <svtools/svtabbx.hxx>
      49             : #include <svtools/headbar.hxx>
      50             : #include <vcl/dialog.hxx>
      51             : #include <vcl/button.hxx>
      52             : #include <vcl/fixed.hxx>
      53             : #include <vcl/group.hxx>
      54             : #include <vcl/lstbox.hxx>
      55             : #include <vcl/edit.hxx>
      56             : #include <vcl/msgbox.hxx>
      57             : #include <tools/debug.hxx>
      58             : #include "datman.hxx"
      59             : #include "bibresid.hxx"
      60             : #include "bibmod.hxx"
      61             : #include "bibview.hxx"
      62             : // #100312# ---------
      63             : #include "bibprop.hrc"
      64             : #include "toolbar.hxx"
      65             : #include "toolbar.hrc"
      66             : #include "bibconfig.hxx"
      67             : #include "bibbeam.hxx"
      68             : #include "bib.hrc"
      69             : #include "bibliography.hrc"
      70             : #include <connectivity/dbtools.hxx>
      71             : #include <boost/scoped_ptr.hpp>
      72             : 
      73             : using namespace ::com::sun::star;
      74             : using namespace ::com::sun::star::beans;
      75             : using namespace ::com::sun::star::container;
      76             : using namespace ::com::sun::star::uno;
      77             : using namespace ::com::sun::star::sdb;
      78             : using namespace ::com::sun::star::sdbc;
      79             : using namespace ::com::sun::star::sdbcx;
      80             : using namespace ::com::sun::star::form;
      81             : using namespace ::com::sun::star::frame;
      82             : using namespace ::com::sun::star::lang;
      83             : 
      84           0 : Reference< XConnection > getConnection(const OUString& _rURL)
      85             : {
      86             :     // first get the sdb::DataSource corresponding to the url
      87           0 :     Reference< XDataSource >    xDataSource;
      88             :     // is it a favorite title ?
      89           0 :     Reference<XComponentContext>  xContext = comphelper::getProcessComponentContext();
      90           0 :     Reference< XDatabaseContext >  xNamingContext = DatabaseContext::create(xContext);
      91           0 :     if (xNamingContext->hasByName(_rURL))
      92             :     {
      93             :         DBG_ASSERT(xNamingContext.is(), "::getDataSource : no NamingService interface on the sdb::DatabaseAccessContext !");
      94             :         try
      95             :         {
      96           0 :             xDataSource = Reference< XDataSource > (xNamingContext->getRegisteredObject(_rURL), UNO_QUERY);
      97             :         }
      98           0 :         catch (const Exception&)
      99             :         {
     100             :             OSL_FAIL("Exception caught in ODatabaseContext::getRegisteredObject()");
     101             :         }
     102             :     }
     103             :     // build the connection from the data source
     104           0 :     Reference< XConnection > xConn;
     105           0 :     if (xDataSource.is())
     106             :     {
     107             :         // need user/pwd for this
     108           0 :         Reference< XPropertySet >  xDataSourceProps(xDataSource, UNO_QUERY);
     109           0 :         Reference< XCompletedConnection > xComplConn(xDataSource, UNO_QUERY);
     110             :         try
     111             :         {
     112           0 :             Reference<task::XInteractionHandler> xIHdl( task::InteractionHandler::createWithParent(xContext, 0), UNO_QUERY_THROW);
     113           0 :             xConn = xComplConn->connectWithCompletion(xIHdl);
     114             :         }
     115           0 :         catch (const SQLException&)
     116             :         {
     117             :             // TODO : a real error handling
     118             :         }
     119           0 :         catch (const Exception&)
     120             :         {
     121           0 :         }
     122             :     }
     123           0 :     return xConn;
     124             : }
     125             : 
     126           0 : Reference< XConnection >    getConnection(const Reference< XInterface > & xRowSet)
     127             : {
     128           0 :     Reference< XConnection >    xConn;
     129             :     try
     130             :     {
     131           0 :         Reference< XPropertySet >  xFormProps(xRowSet, UNO_QUERY);
     132           0 :         if (!xFormProps.is())
     133           0 :             return xConn;
     134             : 
     135           0 :         xConn = Reference< XConnection > (*(Reference< XInterface > *)xFormProps->getPropertyValue("ActiveConnection").getValue(), UNO_QUERY);
     136           0 :         if (!xConn.is())
     137             :         {
     138             :             DBG_WARNING("no active connection");
     139           0 :         }
     140             :     }
     141           0 :     catch (const Exception&)
     142             :     {
     143             :         OSL_FAIL("exception in getConnection");
     144             :     }
     145             : 
     146           0 :     return xConn;
     147             : }
     148             : 
     149           0 : Reference< XNameAccess >  getColumns(const Reference< XForm > & _rxForm)
     150             : {
     151           0 :     Reference< XNameAccess >  xReturn;
     152             :     // check if the form is alive
     153           0 :     Reference< XColumnsSupplier >  xSupplyCols( _rxForm, UNO_QUERY );
     154           0 :     if (xSupplyCols.is())
     155           0 :         xReturn = xSupplyCols->getColumns();
     156             : 
     157           0 :     if (!xReturn.is() || (xReturn->getElementNames().getLength() == 0))
     158             :     {   // no ....
     159           0 :         xReturn = NULL;
     160             :         // -> get the table the form is bound to and ask it for their columns
     161           0 :         Reference< XTablesSupplier >  xSupplyTables( getConnection( _rxForm ), UNO_QUERY );
     162           0 :         Reference< XPropertySet >  xFormProps( _rxForm, UNO_QUERY );
     163           0 :         if (xFormProps.is() && xSupplyTables.is())
     164             :         {
     165             :             try
     166             :             {
     167             :                 DBG_ASSERT((*(sal_Int32*)xFormProps->getPropertyValue("CommandType").getValue()) == CommandType::TABLE,
     168             :                     "::getColumns : invalid form (has no table as data source) !");
     169           0 :                 OUString sTable;
     170           0 :                 xFormProps->getPropertyValue("Command") >>= sTable;
     171           0 :                 Reference< XNameAccess >  xTables = xSupplyTables->getTables();
     172           0 :                 if (xTables.is() && xTables->hasByName(sTable))
     173           0 :                     xSupplyCols = Reference< XColumnsSupplier > (
     174           0 :                         *(Reference< XInterface > *)xTables->getByName(sTable).getValue(), UNO_QUERY);
     175           0 :                 if (xSupplyCols.is())
     176           0 :                     xReturn = xSupplyCols->getColumns();
     177             :             }
     178           0 :             catch (const Exception& e)
     179             :             {
     180             : #ifdef DBG_UTIL
     181             :                 OUString sMsg( "::getColumns : catched an exception (" + e.Message + ") ..." );
     182             : 
     183             :                 OSL_FAIL(OUStringToOString(sMsg, RTL_TEXTENCODING_ASCII_US ).getStr());
     184             : #else
     185             :                 (void)e;
     186             : #endif
     187             :             }
     188             : 
     189           0 :         }
     190             :     }
     191           0 :     return xReturn;
     192             : }
     193             : 
     194             : class MappingDialog_Impl : public ModalDialog
     195             : {
     196             :     BibDataManager* pDatMan;
     197             :     OKButton*       pOKBT;
     198             :     ListBox*        pIdentifierLB;
     199             :     ListBox*        pAuthorityTypeLB;
     200             :     ListBox*        pAuthorLB;
     201             :     ListBox*        pTitleLB;
     202             :     ListBox*        pMonthLB;
     203             :     ListBox*        pYearLB;
     204             :     ListBox*        pISBNLB;
     205             :     ListBox*        pBooktitleLB;
     206             :     ListBox*        pChapterLB;
     207             :     ListBox*        pEditionLB;
     208             :     ListBox*        pEditorLB;
     209             :     ListBox*        pHowpublishedLB;
     210             :     ListBox*        pInstitutionLB;
     211             :     ListBox*        pJournalLB;
     212             :     ListBox*        pNoteLB;
     213             :     ListBox*        pAnnoteLB;
     214             :     ListBox*        pNumberLB;
     215             :     ListBox*        pOrganizationsLB;
     216             :     ListBox*        pPagesLB;
     217             :     ListBox*        pPublisherLB;
     218             :     ListBox*        pAddressLB;
     219             :     ListBox*        pSchoolLB;
     220             :     ListBox*        pSeriesLB;
     221             :     ListBox*        pReportTypeLB;
     222             :     ListBox*        pVolumeLB;
     223             :     ListBox*        pURLLB;
     224             :     ListBox*        pCustom1LB;
     225             :     ListBox*        pCustom2LB;
     226             :     ListBox*        pCustom3LB;
     227             :     ListBox*        pCustom4LB;
     228             :     ListBox*        pCustom5LB;
     229             :     ListBox*        aListBoxes[COLUMN_COUNT];
     230             :     OUString        sNone;
     231             : 
     232             :     bool        bModified;
     233             : 
     234             : 
     235             : 
     236             :     DECL_LINK(OkHdl, void *);
     237             :     DECL_LINK(ListBoxSelectHdl, ListBox*);
     238             : 
     239             : public:
     240             :     MappingDialog_Impl(vcl::Window* pParent, BibDataManager* pDatMan);
     241             :     virtual ~MappingDialog_Impl();
     242             : 
     243           0 :     void    SetModified() {bModified = true;}
     244             : 
     245             : };
     246             : 
     247           0 : static sal_uInt16 lcl_FindLogicalName(BibConfig* pConfig ,
     248             :                                     const OUString& rLogicalColumnName)
     249             : {
     250           0 :     for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++)
     251             :     {
     252           0 :         if(rLogicalColumnName == pConfig->GetDefColumnName(i))
     253           0 :             return i;
     254             :     }
     255           0 :     return USHRT_MAX;
     256             : }
     257             : 
     258           0 : MappingDialog_Impl::MappingDialog_Impl(vcl::Window* pParent, BibDataManager* pMan)
     259             :     : ModalDialog(pParent, "MappingDialog", "modules/sbibliography/ui/mappingdialog.ui")
     260             :     , pDatMan(pMan)
     261             :     , sNone(BIB_RESSTR(RID_BIB_STR_NONE))
     262           0 :     , bModified(false)
     263             : {
     264           0 :     get(pOKBT, "ok");
     265           0 :     get(pIdentifierLB, "identifierCombobox");
     266           0 :     get(pAuthorityTypeLB, "authorityTypeCombobox");
     267           0 :     get(pAuthorLB, "authorCombobox");
     268           0 :     get(pTitleLB, "titleCombobox");
     269           0 :     get(pMonthLB, "monthCombobox");
     270           0 :     get(pYearLB, "yearCombobox");
     271           0 :     get(pISBNLB, "ISBNCombobox");
     272           0 :     get(pBooktitleLB, "bookTitleCombobox");
     273           0 :     get(pChapterLB, "chapterCombobox");
     274           0 :     get(pEditionLB, "editionCombobox");
     275           0 :     get(pEditorLB, "editorCombobox");
     276           0 :     get(pHowpublishedLB, "howPublishedCombobox");
     277           0 :     get(pInstitutionLB, "institutionCombobox");
     278           0 :     get(pJournalLB, "journalCombobox");
     279           0 :     get(pNoteLB, "noteCombobox");
     280           0 :     get(pAnnoteLB, "annoteCombobox");
     281           0 :     get(pNumberLB, "numberCombobox");
     282           0 :     get(pOrganizationsLB, "organizationCombobox");
     283           0 :     get(pPagesLB, "pagesCombobox");
     284           0 :     get(pPublisherLB, "publisherCombobox");
     285           0 :     get(pAddressLB, "addressCombobox");
     286           0 :     get(pSchoolLB, "schoolCombobox");
     287           0 :     get(pSeriesLB, "seriesCombobox");
     288           0 :     get(pReportTypeLB, "reportTypeCombobox");
     289           0 :     get(pVolumeLB, "volumeCombobox");
     290           0 :     get(pURLLB, "URLCombobox");
     291           0 :     get(pCustom1LB, "custom1Combobox");
     292           0 :     get(pCustom2LB, "custom2Combobox");
     293           0 :     get(pCustom3LB, "custom3Combobox");
     294           0 :     get(pCustom4LB, "custom4Combobox");
     295           0 :     get(pCustom5LB, "custom5Combobox");
     296             : 
     297           0 :     pOKBT->SetClickHdl(LINK(this, MappingDialog_Impl, OkHdl));
     298           0 :     OUString sTitle = GetText();
     299           0 :     sTitle = sTitle.replaceFirst("%1", pDatMan->getActiveDataTable());
     300           0 :     SetText(sTitle);
     301             : 
     302           0 :     aListBoxes[0] = pIdentifierLB;
     303           0 :     aListBoxes[1] = pAuthorityTypeLB;
     304           0 :     aListBoxes[2] = pAuthorLB;
     305           0 :     aListBoxes[3] = pTitleLB;
     306           0 :     aListBoxes[4] = pYearLB;
     307           0 :     aListBoxes[5] = pISBNLB;
     308           0 :     aListBoxes[6] = pBooktitleLB;
     309           0 :     aListBoxes[7] = pChapterLB;
     310           0 :     aListBoxes[8] = pEditionLB;
     311           0 :     aListBoxes[9] = pEditorLB;
     312           0 :     aListBoxes[10] = pHowpublishedLB;
     313           0 :     aListBoxes[11] = pInstitutionLB;
     314           0 :     aListBoxes[12] = pJournalLB;
     315           0 :     aListBoxes[13] = pMonthLB;
     316           0 :     aListBoxes[14] = pNoteLB;
     317           0 :     aListBoxes[15] = pAnnoteLB;
     318           0 :     aListBoxes[16] = pNumberLB;
     319           0 :     aListBoxes[17] = pOrganizationsLB;
     320           0 :     aListBoxes[18] = pPagesLB;
     321           0 :     aListBoxes[19] = pPublisherLB;
     322           0 :     aListBoxes[20] = pAddressLB;
     323           0 :     aListBoxes[21] = pSchoolLB;
     324           0 :     aListBoxes[22] = pSeriesLB;
     325           0 :     aListBoxes[23] = pReportTypeLB;
     326           0 :     aListBoxes[24] = pVolumeLB;
     327           0 :     aListBoxes[25] = pURLLB;
     328           0 :     aListBoxes[26] = pCustom1LB;
     329           0 :     aListBoxes[27] = pCustom2LB;
     330           0 :     aListBoxes[28] = pCustom3LB;
     331           0 :     aListBoxes[29] = pCustom4LB;
     332           0 :     aListBoxes[30] = pCustom5LB;
     333             : 
     334           0 :     aListBoxes[0]->InsertEntry(sNone);
     335           0 :     Reference< XNameAccess >  xFields = getColumns( pDatMan->getForm() );
     336             :     DBG_ASSERT(xFields.is(), "MappingDialog_Impl::MappingDialog_Impl : gave me an invalid form !");
     337           0 :     if(xFields.is())
     338             :     {
     339           0 :         Sequence< OUString > aNames = xFields->getElementNames();
     340           0 :         sal_Int32 nFieldsCount = aNames.getLength();
     341           0 :         const OUString* pNames = aNames.getConstArray();
     342             : 
     343           0 :         for(sal_Int32 nField = 0; nField < nFieldsCount; nField++)
     344           0 :             aListBoxes[0]->InsertEntry(pNames[nField]);
     345             :     }
     346             : 
     347           0 :     Link aLnk = LINK(this, MappingDialog_Impl, ListBoxSelectHdl);
     348             : 
     349           0 :     aListBoxes[0]->SelectEntryPos(0);
     350           0 :     aListBoxes[0]->SetSelectHdl(aLnk);
     351           0 :     for(sal_uInt16 i = 1; i < COLUMN_COUNT; i++)
     352             :     {
     353           0 :         for(sal_uInt16 j = 0; j < aListBoxes[0]->GetEntryCount();j++)
     354           0 :             aListBoxes[i]->InsertEntry(aListBoxes[0]->GetEntry(j));
     355           0 :         aListBoxes[i]->SelectEntryPos(0);
     356           0 :         aListBoxes[i]->SetSelectHdl(aLnk);
     357             :     }
     358           0 :     BibConfig* pConfig = BibModul::GetConfig();
     359           0 :     BibDBDescriptor aDesc;
     360           0 :     aDesc.sDataSource = pDatMan->getActiveDataSource();
     361           0 :     aDesc.sTableOrQuery = pDatMan->getActiveDataTable();
     362           0 :     aDesc.nCommandType = CommandType::TABLE;
     363           0 :     const Mapping* pMapping = pConfig->GetMapping(aDesc);
     364           0 :     if(pMapping)
     365             :     {
     366           0 :         for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
     367             :         {
     368           0 :             sal_uInt16 nListBoxIndex = lcl_FindLogicalName( pConfig, pMapping->aColumnPairs[nEntry].sLogicalColumnName);
     369           0 :             if(nListBoxIndex < COLUMN_COUNT)
     370             :             {
     371           0 :                 aListBoxes[nListBoxIndex]->SelectEntry(pMapping->aColumnPairs[nEntry].sRealColumnName);
     372             :             }
     373             :         }
     374           0 :     }
     375           0 : }
     376             : 
     377           0 : MappingDialog_Impl::~MappingDialog_Impl()
     378           0 : {}
     379             : 
     380           0 : IMPL_LINK(MappingDialog_Impl, ListBoxSelectHdl, ListBox*, pListBox)
     381             : {
     382           0 :     sal_uInt16 nEntryPos = pListBox->GetSelectEntryPos();
     383           0 :     if(0 < nEntryPos)
     384             :     {
     385           0 :         for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++)
     386             :         {
     387           0 :             if(pListBox != aListBoxes[i] && aListBoxes[i]->GetSelectEntryPos() == nEntryPos)
     388           0 :                 aListBoxes[i]->SelectEntryPos(0);
     389             :         }
     390             :     }
     391           0 :     SetModified();
     392           0 :     return 0;
     393             : }
     394             : 
     395           0 : IMPL_LINK_NOARG(MappingDialog_Impl, OkHdl)
     396             : {
     397           0 :     if(bModified)
     398             :     {
     399           0 :         Mapping aNew;
     400           0 :         aNew.sTableName = pDatMan->getActiveDataTable();
     401           0 :         aNew.sURL = pDatMan->getActiveDataSource();
     402             : 
     403           0 :         sal_uInt16 nWriteIndex = 0;
     404           0 :         BibConfig* pConfig = BibModul::GetConfig();
     405           0 :         for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
     406             :         {
     407           0 :             OUString sSel = aListBoxes[nEntry]->GetSelectEntry();
     408           0 :             if(sSel != sNone)
     409             :             {
     410           0 :                 aNew.aColumnPairs[nWriteIndex].sRealColumnName = sSel;
     411           0 :                 aNew.aColumnPairs[nWriteIndex].sLogicalColumnName = pConfig->GetDefColumnName(nEntry);
     412           0 :                 nWriteIndex++;
     413             :             }
     414           0 :         }
     415           0 :         BibDBDescriptor aDesc;
     416           0 :         aDesc.sDataSource = pDatMan->getActiveDataSource();
     417           0 :         aDesc.sTableOrQuery = pDatMan->getActiveDataTable();
     418           0 :         aDesc.nCommandType = CommandType::TABLE;
     419           0 :         pDatMan->ResetIdentifierMapping();
     420           0 :         pConfig->SetMapping(aDesc, &aNew);
     421             :     }
     422           0 :     EndDialog(bModified ? RET_OK : RET_CANCEL);
     423           0 :     return 0;
     424             : }
     425             : 
     426             : class DBChangeDialog_Impl : public ModalDialog
     427             : {
     428             :     ListBox*    m_pSelectionLB;
     429             :     DBChangeDialogConfig_Impl   aConfig;
     430             : 
     431             :     BibDataManager* pDatMan;
     432             : 
     433             :     DECL_LINK(DoubleClickHdl, SvTabListBox*);
     434             : public:
     435             :     DBChangeDialog_Impl(vcl::Window* pParent, BibDataManager* pMan );
     436             :     virtual ~DBChangeDialog_Impl();
     437             : 
     438             :     OUString     GetCurrentURL()const;
     439             : };
     440             : 
     441           0 : DBChangeDialog_Impl::DBChangeDialog_Impl(vcl::Window* pParent, BibDataManager* pMan )
     442             :     : ModalDialog(pParent, "ChooseDataSourceDialog",
     443             :         "modules/sbibliography/ui/choosedatasourcedialog.ui")
     444             :     ,
     445           0 :     pDatMan(pMan)
     446             : {
     447           0 :     get(m_pSelectionLB, "treeview");
     448           0 :     m_pSelectionLB->set_height_request(m_pSelectionLB->GetTextHeight() * 6);
     449             : 
     450           0 :     m_pSelectionLB->SetStyle(m_pSelectionLB->GetStyle() | WB_SORT);
     451           0 :     m_pSelectionLB->SetDoubleClickHdl( LINK(this, DBChangeDialog_Impl, DoubleClickHdl));
     452             : 
     453             :     try
     454             :     {
     455           0 :         OUString sActiveSource = pDatMan->getActiveDataSource();
     456           0 :         const Sequence< OUString >& rSources = aConfig.GetDataSourceNames();
     457           0 :         const OUString* pSourceNames = rSources.getConstArray();
     458           0 :         for (sal_Int32 i = 0; i < rSources.getLength(); ++i)
     459           0 :             m_pSelectionLB->InsertEntry(pSourceNames[i]);
     460             : 
     461           0 :         m_pSelectionLB->SelectEntry(sActiveSource);
     462             :     }
     463           0 :     catch (const Exception& e)
     464             :     {
     465             :         SAL_WARN("extensions.biblio",
     466             :             "Exception in BibDataManager::DBChangeDialog_Impl::DBChangeDialog_Impl "
     467             :             << e.Message);
     468             :     }
     469           0 : }
     470             : 
     471           0 : IMPL_LINK(DBChangeDialog_Impl, DoubleClickHdl, SvTabListBox*, /*pLB*/)
     472             : {
     473           0 :     EndDialog(RET_OK);
     474           0 :     return 0;
     475             : }
     476             : 
     477           0 : DBChangeDialog_Impl::~DBChangeDialog_Impl()
     478             : {
     479           0 : }
     480             : 
     481           0 : OUString  DBChangeDialog_Impl::GetCurrentURL()const
     482             : {
     483           0 :     return m_pSelectionLB->GetSelectEntry();
     484             : }
     485             : 
     486             : // XDispatchProvider
     487           0 : BibInterceptorHelper::BibInterceptorHelper( ::bib::BibBeamer* pBibBeamer, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch)
     488             : {
     489           0 :     if( pBibBeamer )
     490             :     {
     491           0 :         xInterception = pBibBeamer->getDispatchProviderInterception();
     492           0 :         if( xInterception.is() )
     493           0 :             xInterception->registerDispatchProviderInterceptor( this );
     494             :     }
     495           0 :     if( xDispatch.is() )
     496           0 :         xFormDispatch = xDispatch;
     497           0 : }
     498             : 
     499           0 : BibInterceptorHelper::~BibInterceptorHelper( )
     500             : {
     501           0 : }
     502             : 
     503           0 : void BibInterceptorHelper::ReleaseInterceptor()
     504             : {
     505           0 :     if ( xInterception.is() )
     506           0 :         xInterception->releaseDispatchProviderInterceptor( this );
     507           0 :     xInterception.clear();
     508           0 : }
     509             : 
     510             : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL
     511           0 :     BibInterceptorHelper::queryDispatch( const ::com::sun::star::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     512             : {
     513           0 :     Reference< XDispatch > xReturn;
     514             : 
     515           0 :     OUString aCommand( aURL.Path );
     516           0 :     if ( aCommand == "FormSlots/ConfirmDeletion" )
     517           0 :         xReturn = xFormDispatch;
     518             :     else
     519           0 :         if ( xSlaveDispatchProvider.is() )
     520           0 :             xReturn = xSlaveDispatchProvider->queryDispatch( aURL, aTargetFrameName, nSearchFlags);
     521             : 
     522           0 :     return xReturn;
     523             : }
     524             : 
     525             : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL
     526           0 :     BibInterceptorHelper::queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     527             : {
     528           0 :     Sequence< Reference< XDispatch> > aReturn( aDescripts.getLength() );
     529           0 :     Reference< XDispatch >* pReturn = aReturn.getArray();
     530           0 :     const DispatchDescriptor* pDescripts = aDescripts.getConstArray();
     531           0 :     for ( sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts )
     532             :     {
     533           0 :         *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
     534             :     }
     535           0 :     return aReturn;
     536             : }
     537             : 
     538             : // XDispatchProviderInterceptor
     539             : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
     540           0 :     BibInterceptorHelper::getSlaveDispatchProvider(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     541             : {
     542           0 :     return xSlaveDispatchProvider;
     543             : }
     544             : 
     545           0 : void SAL_CALL BibInterceptorHelper::setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlaveDispatchProvider ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     546             : {
     547           0 :     xSlaveDispatchProvider = xNewSlaveDispatchProvider;
     548           0 : }
     549             : 
     550             : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
     551           0 :     BibInterceptorHelper::getMasterDispatchProvider(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     552             : {
     553           0 :     return xMasterDispatchProvider;
     554             : }
     555             : 
     556           0 : void SAL_CALL BibInterceptorHelper::setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMasterDispatchProvider ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     557             : {
     558           0 :     xMasterDispatchProvider = xNewMasterDispatchProvider;
     559           0 : }
     560             : 
     561             : 
     562             : #define STR_UID "uid"
     563           4 : OUString gGridName("theGrid");
     564           4 : OUString gViewName("theView");
     565           4 : OUString gGlobalName("theGlobals");
     566           4 : OUString gBeamerSize("theBeamerSize");
     567           4 : OUString gViewSize("theViewSize");
     568             : 
     569           0 : BibDataManager::BibDataManager()
     570           0 :     :BibDataManager_Base( GetMutex() )
     571             :     ,m_pInterceptorHelper( NULL )
     572             :     ,m_aLoadListeners(m_aMutex)
     573             :     ,pBibView( NULL )
     574           0 :     ,pToolbar(0)
     575             : {
     576           0 : }
     577             : 
     578             : 
     579           0 : BibDataManager::~BibDataManager()
     580             : {
     581           0 :     Reference< XLoadable >      xLoad( m_xForm, UNO_QUERY );
     582           0 :     Reference< XPropertySet >   xPrSet( m_xForm, UNO_QUERY );
     583           0 :     Reference< XComponent >     xComp( m_xForm, UNO_QUERY );
     584           0 :     if ( m_xForm.is() )
     585             :     {
     586           0 :         Reference< XComponent >  xConnection;
     587           0 :         xPrSet->getPropertyValue("ActiveConnection") >>= xConnection;
     588           0 :         RemoveMeAsUidListener();
     589           0 :         if (xLoad.is())
     590           0 :             xLoad->unload();
     591           0 :         if (xComp.is())
     592           0 :             xComp->dispose();
     593           0 :         if(xConnection.is())
     594           0 :             xConnection->dispose();
     595           0 :         m_xForm = NULL;
     596             :     }
     597           0 :     if( m_pInterceptorHelper )
     598             :     {
     599           0 :         m_pInterceptorHelper->ReleaseInterceptor();
     600           0 :         m_pInterceptorHelper->release();
     601           0 :         m_pInterceptorHelper = NULL;
     602           0 :     }
     603           0 : }
     604             : 
     605           0 : void BibDataManager::InsertFields(const Reference< XFormComponent > & _rxGrid)
     606             : {
     607           0 :     if ( !_rxGrid.is() )
     608           0 :         return;
     609             : 
     610             :     try
     611             :     {
     612           0 :         Reference< XNameContainer > xColContainer( _rxGrid, UNO_QUERY );
     613             :         // remove the old fields
     614           0 :         if ( xColContainer->hasElements() )
     615             :         {
     616           0 :             Sequence< OUString > aNames = xColContainer->getElementNames();
     617           0 :             const OUString* pNames = aNames.getConstArray();
     618           0 :             const OUString* pNamesEnd = pNames + aNames.getLength();
     619           0 :             for ( ; pNames != pNamesEnd; ++pNames )
     620           0 :                 xColContainer->removeByName( *pNames );
     621             :         }
     622             : 
     623           0 :         Reference< XNameAccess >  xFields = getColumns( m_xForm );
     624           0 :         if (!xFields.is())
     625           0 :             return;
     626             : 
     627           0 :         Reference< XGridColumnFactory > xColFactory( _rxGrid, UNO_QUERY );
     628             : 
     629           0 :         Reference< XPropertySet >  xField;
     630             : 
     631           0 :         Sequence< OUString > aFields( xFields->getElementNames() );
     632           0 :         const OUString* pFields = aFields.getConstArray();
     633           0 :         const OUString* pFieldsEnd = pFields + aFields.getLength();
     634             : 
     635           0 :         for ( ; pFields != pFieldsEnd; ++pFields )
     636             :         {
     637           0 :             xFields->getByName( *pFields ) >>= xField;
     638             : 
     639           0 :             OUString sCurrentModelType;
     640           0 :             const OUString sType("Type");
     641           0 :             sal_Int32 nType = 0;
     642           0 :             bool bIsFormatted           = false;
     643           0 :             sal_Bool bFormattedIsNumeric    = sal_True;
     644           0 :             xField->getPropertyValue(sType) >>= nType;
     645           0 :             switch(nType)
     646             :             {
     647             :                 case DataType::BIT:
     648             :                 case DataType::BOOLEAN:
     649           0 :                     sCurrentModelType = "CheckBox";
     650           0 :                     break;
     651             : 
     652             :                 case DataType::BINARY:
     653             :                 case DataType::VARBINARY:
     654             :                 case DataType::LONGVARBINARY:
     655             :                 case DataType::BLOB:
     656           0 :                     sCurrentModelType = "TextField";
     657           0 :                     break;
     658             : 
     659             :                 case DataType::VARCHAR:
     660             :                 case DataType::LONGVARCHAR:
     661             :                 case DataType::CHAR:
     662             :                 case DataType::CLOB:
     663           0 :                     bFormattedIsNumeric = sal_False;
     664             :                     // _NO_ break !
     665             :                 default:
     666           0 :                     sCurrentModelType = "FormattedField";
     667           0 :                     bIsFormatted = true;
     668           0 :                     break;
     669             :             }
     670             : 
     671           0 :             Reference< XPropertySet >  xCurrentCol = xColFactory->createColumn(sCurrentModelType);
     672           0 :             if (bIsFormatted)
     673             :             {
     674           0 :                 OUString sFormatKey("FormatKey");
     675           0 :                 xCurrentCol->setPropertyValue(sFormatKey, xField->getPropertyValue(sFormatKey));
     676           0 :                 Any aFormatted(&bFormattedIsNumeric, ::getBooleanCppuType());
     677           0 :                 xCurrentCol->setPropertyValue("TreatAsNumber", aFormatted);
     678             :             }
     679           0 :             Any aColName = makeAny( *pFields );
     680           0 :             xCurrentCol->setPropertyValue(FM_PROP_CONTROLSOURCE,    aColName);
     681           0 :             xCurrentCol->setPropertyValue(FM_PROP_LABEL, aColName);
     682             : 
     683           0 :             xColContainer->insertByName( *pFields, makeAny( xCurrentCol ) );
     684           0 :         }
     685             :     }
     686           0 :     catch (const Exception&)
     687             :     {
     688             :         OSL_FAIL("Exception in BibDataManager::InsertFields");
     689             :     }
     690             : }
     691             : 
     692           0 : Reference< awt::XControlModel > BibDataManager::updateGridModel()
     693             : {
     694           0 :     return updateGridModel( m_xForm );
     695             : }
     696             : 
     697           0 : Reference< awt::XControlModel > BibDataManager::updateGridModel(const Reference< XForm > & xDbForm)
     698             : {
     699             :     try
     700             :     {
     701           0 :         Reference< XPropertySet >  aFormPropSet( xDbForm, UNO_QUERY );
     702           0 :         OUString sName;
     703           0 :         aFormPropSet->getPropertyValue("Command") >>= sName;
     704             : 
     705           0 :         if ( !m_xGridModel.is() )
     706             :         {
     707           0 :             m_xGridModel = createGridModel( gGridName );
     708             : 
     709           0 :             Reference< XNameContainer >  xNameCont(xDbForm, UNO_QUERY);
     710           0 :             xNameCont->insertByName( sName, makeAny( m_xGridModel ) );
     711             :         }
     712             : 
     713             :         // insert the fields
     714           0 :         Reference< XFormComponent > xFormComp( m_xGridModel, UNO_QUERY );
     715           0 :         InsertFields( xFormComp );
     716             :     }
     717           0 :     catch (const Exception&)
     718             :     {
     719             :         OSL_FAIL("::updateGridModel: something went wrong !");
     720             :     }
     721             : 
     722           0 :     return m_xGridModel;
     723             : }
     724             : 
     725           0 : Reference< XForm >  BibDataManager::createDatabaseForm(BibDBDescriptor& rDesc)
     726             : {
     727           0 :     Reference< XForm >  xResult;
     728             :     try
     729             :     {
     730           0 :         Reference< XMultiServiceFactory >  xMgr = comphelper::getProcessServiceFactory();
     731           0 :         m_xForm = Reference< XForm > ( xMgr->createInstance( "com.sun.star.form.component.Form" ), UNO_QUERY );
     732             : 
     733           0 :         Reference< XPropertySet >  aPropertySet( m_xForm, UNO_QUERY );
     734             : 
     735           0 :         aDataSourceURL = rDesc.sDataSource;
     736           0 :         if(aPropertySet.is())
     737             :         {
     738           0 :             Any aVal;
     739           0 :             aVal <<= (sal_Int32)ResultSetType::SCROLL_INSENSITIVE;
     740           0 :             aPropertySet->setPropertyValue("ResultSetType",aVal );
     741           0 :             aVal <<= (sal_Int32)ResultSetConcurrency::READ_ONLY;
     742           0 :             aPropertySet->setPropertyValue("ResultSetConcurrency", aVal);
     743             : 
     744             :             //Caching for Performance
     745           0 :             aVal <<= (sal_Int32)50;
     746           0 :             aPropertySet->setPropertyValue("FetchSize", aVal);
     747             : 
     748           0 :             Reference< XConnection >    xConnection = getConnection(rDesc.sDataSource);
     749           0 :             aVal <<= xConnection;
     750           0 :             aPropertySet->setPropertyValue("ActiveConnection", aVal);
     751             : 
     752           0 :             Reference< XTablesSupplier >  xSupplyTables(xConnection, UNO_QUERY);
     753           0 :             Reference< XNameAccess >  xTables = xSupplyTables.is() ?
     754           0 :                                 xSupplyTables->getTables() : Reference< XNameAccess > ();
     755             : 
     756           0 :             Sequence< OUString > aTableNameSeq;
     757           0 :             if (xTables.is())
     758           0 :                 aTableNameSeq = xTables->getElementNames();
     759             : 
     760           0 :             if(aTableNameSeq.getLength() > 0)
     761             :             {
     762           0 :                 const OUString* pTableNames = aTableNameSeq.getConstArray();
     763           0 :                 if(!rDesc.sTableOrQuery.isEmpty())
     764           0 :                     aActiveDataTable = rDesc.sTableOrQuery;
     765             :                 else
     766             :                 {
     767           0 :                     rDesc.sTableOrQuery = aActiveDataTable = pTableNames[0];
     768           0 :                     rDesc.nCommandType = CommandType::TABLE;
     769             :                 }
     770             : 
     771           0 :                 aVal <<= aActiveDataTable;
     772           0 :                 aPropertySet->setPropertyValue("Command", aVal);
     773           0 :                 aVal <<= rDesc.nCommandType;
     774           0 :                 aPropertySet->setPropertyValue("CommandType", aVal);
     775             : 
     776             : 
     777           0 :                 Reference< XDatabaseMetaData >  xMetaData = xConnection->getMetaData();
     778           0 :                 aQuoteChar = xMetaData->getIdentifierQuoteString();
     779             : 
     780           0 :                 Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY);
     781           0 :                 if ( xFactory.is() )
     782           0 :                     m_xParser.set( xFactory->createInstance("com.sun.star.sdb.SingleSelectQueryComposer"), UNO_QUERY );
     783             : 
     784           0 :                 OUString aString("SELECT * FROM ");
     785             : 
     786           0 :                 OUString sCatalog, sSchema, sName;
     787           0 :                 ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
     788           0 :                 aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
     789             : 
     790           0 :                 m_xParser->setElementaryQuery(aString);
     791           0 :                 BibConfig* pConfig = BibModul::GetConfig();
     792           0 :                 pConfig->setQueryField(getQueryField());
     793           0 :                 startQueryWith(pConfig->getQueryText());
     794             : 
     795           0 :                 xResult = m_xForm;
     796           0 :             }
     797           0 :         }
     798             :     }
     799           0 :     catch (const Exception&)
     800             :     {
     801             :         OSL_FAIL("::createDatabaseForm: something went wrong !");
     802             :     }
     803             : 
     804           0 :     return xResult;
     805             : }
     806             : 
     807           0 : Sequence< OUString > BibDataManager::getDataSources()
     808             : {
     809           0 :     Sequence< OUString > aTableNameSeq;
     810             : 
     811             :     try
     812             :     {
     813           0 :         Reference< XTablesSupplier >  xSupplyTables( getConnection( m_xForm ), UNO_QUERY );
     814           0 :         Reference< XNameAccess >  xTables;
     815           0 :         if (xSupplyTables.is())
     816           0 :             xTables = xSupplyTables->getTables();
     817           0 :         if (xTables.is())
     818           0 :             aTableNameSeq = xTables->getElementNames();
     819             :     }
     820           0 :     catch (const Exception&)
     821             :     {
     822             :         OSL_FAIL("::getDataSources: something went wrong !");
     823             :     }
     824             : 
     825           0 :     return aTableNameSeq;
     826             : }
     827             : 
     828             : 
     829           0 : void BibDataManager::setFilter(const OUString& rQuery)
     830             : {
     831           0 :     if(!m_xParser.is())
     832           0 :         return;
     833             :     try
     834             :     {
     835           0 :         m_xParser->setFilter( rQuery );
     836           0 :         OUString aQuery = m_xParser->getFilter();
     837           0 :         Reference< XPropertySet >  xFormProps( m_xForm, UNO_QUERY_THROW );
     838           0 :         xFormProps->setPropertyValue( "Filter", makeAny( aQuery ) );
     839           0 :         xFormProps->setPropertyValue( "ApplyFilter", makeAny( sal_True ) );
     840           0 :         reload();
     841             :     }
     842           0 :     catch (const Exception&)
     843             :     {
     844             :         DBG_UNHANDLED_EXCEPTION();
     845             :     }
     846             : 
     847             : 
     848             : }
     849             : 
     850           0 : OUString BibDataManager::getFilter()
     851             : {
     852             : 
     853           0 :     OUString aQueryString;
     854             :     try
     855             :     {
     856           0 :         Reference< XPropertySet > xFormProps( m_xForm, UNO_QUERY_THROW );
     857           0 :         OSL_VERIFY( xFormProps->getPropertyValue( "Filter"  ) >>= aQueryString );
     858             :     }
     859           0 :     catch (const Exception&)
     860             :     {
     861             :         DBG_UNHANDLED_EXCEPTION();
     862             :     }
     863             : 
     864             : 
     865           0 :     return aQueryString;
     866             : 
     867             : }
     868             : 
     869           0 : Sequence< OUString > BibDataManager::getQueryFields()
     870             : {
     871           0 :     Sequence< OUString > aFieldSeq;
     872           0 :     Reference< XNameAccess >  xFields = getColumns( m_xForm );
     873           0 :     if (xFields.is())
     874           0 :         aFieldSeq = xFields->getElementNames();
     875           0 :     return aFieldSeq;
     876             : }
     877             : 
     878           0 : OUString BibDataManager::getQueryField()
     879             : {
     880           0 :     BibConfig* pConfig = BibModul::GetConfig();
     881           0 :     OUString aFieldString = pConfig->getQueryField();
     882           0 :     if(aFieldString.isEmpty())
     883             :     {
     884           0 :         Sequence< OUString > aSeq = getQueryFields();
     885           0 :         const OUString* pFields = aSeq.getConstArray();
     886           0 :         if(aSeq.getLength()>0)
     887             :         {
     888           0 :             aFieldString=pFields[0];
     889           0 :         }
     890             :     }
     891           0 :     return aFieldString;
     892             : }
     893             : 
     894           0 : void BibDataManager::startQueryWith(const OUString& rQuery)
     895             : {
     896           0 :     BibConfig* pConfig = BibModul::GetConfig();
     897           0 :     pConfig->setQueryText( rQuery );
     898             : 
     899           0 :     OUString aQueryString;
     900           0 :     if(!rQuery.isEmpty())
     901             :     {
     902           0 :         aQueryString=aQuoteChar;
     903           0 :         aQueryString+=getQueryField();
     904           0 :         aQueryString+=aQuoteChar;
     905           0 :         aQueryString+=" like '";
     906           0 :         OUString sQuery(rQuery);
     907           0 :         sQuery = sQuery.replaceAll("?","_");
     908           0 :         sQuery = sQuery.replaceAll("*","%");
     909           0 :         aQueryString += sQuery;
     910           0 :         aQueryString+="%'";
     911             :     }
     912           0 :     setFilter(aQueryString);
     913           0 : }
     914             : 
     915           0 : void BibDataManager::setActiveDataSource(const OUString& rURL)
     916             : {
     917           0 :     OUString sTmp(aDataSourceURL);
     918           0 :     aDataSourceURL = rURL;
     919             : 
     920           0 :     Reference< XPropertySet >  aPropertySet( m_xForm, UNO_QUERY );
     921           0 :     if(aPropertySet.is())
     922             :     {
     923           0 :         unload();
     924             : 
     925           0 :         Reference< XComponent >  xOldConnection;
     926           0 :         aPropertySet->getPropertyValue("ActiveConnection") >>= xOldConnection;
     927             : 
     928           0 :         Reference< XConnection >    xConnection = getConnection(rURL);
     929           0 :         if(!xConnection.is())
     930             :         {
     931           0 :             aDataSourceURL = sTmp;
     932           0 :             return;
     933             :         }
     934           0 :         Any aVal; aVal <<= xConnection;
     935           0 :         aPropertySet->setPropertyValue("ActiveConnection", aVal);
     936           0 :         Reference< XMultiServiceFactory >   xFactory(xConnection, UNO_QUERY);
     937           0 :         if ( xFactory.is() )
     938           0 :             m_xParser.set( xFactory->createInstance("com.sun.star.sdb.SingleSelectQueryComposer"), UNO_QUERY );
     939             : 
     940           0 :         if(xOldConnection.is())
     941           0 :             xOldConnection->dispose();
     942             : 
     943           0 :         Sequence< OUString > aTableNameSeq;
     944           0 :         Reference< XTablesSupplier >  xSupplyTables(xConnection, UNO_QUERY);
     945           0 :         if(xSupplyTables.is())
     946             :         {
     947           0 :             Reference< XNameAccess >  xAccess = xSupplyTables->getTables();
     948           0 :             aTableNameSeq = xAccess->getElementNames();
     949             :         }
     950           0 :         if(aTableNameSeq.getLength() > 0)
     951             :         {
     952           0 :             const OUString* pTableNames = aTableNameSeq.getConstArray();
     953           0 :             aActiveDataTable = pTableNames[0];
     954           0 :             aVal <<= aActiveDataTable;
     955           0 :             aPropertySet->setPropertyValue("Command", aVal);
     956           0 :             aPropertySet->setPropertyValue("CommandType", makeAny(CommandType::TABLE));
     957             :             //Caching for Performance
     958           0 :             aVal <<= (sal_Int32)50;
     959           0 :             aPropertySet->setPropertyValue("FetchSize", aVal);
     960           0 :             OUString aString("SELECT * FROM ");
     961             :             // quote the table name which may contain catalog.schema.table
     962           0 :             Reference<XDatabaseMetaData> xMetaData(xConnection->getMetaData(),UNO_QUERY);
     963           0 :             aQuoteChar = xMetaData->getIdentifierQuoteString();
     964             : 
     965           0 :             OUString sCatalog, sSchema, sName;
     966           0 :             ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
     967           0 :             aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
     968             : 
     969           0 :             m_xParser->setElementaryQuery(aString);
     970           0 :             BibConfig* pConfig = BibModul::GetConfig();
     971           0 :             pConfig->setQueryField(getQueryField());
     972           0 :             startQueryWith(pConfig->getQueryText());
     973           0 :             setActiveDataTable(aActiveDataTable);
     974             :         }
     975           0 :         FeatureStateEvent aEvent;
     976           0 :         util::URL aURL;
     977           0 :         aEvent.IsEnabled  = sal_True;
     978           0 :         aEvent.Requery    = sal_False;
     979           0 :         aEvent.FeatureDescriptor = getActiveDataTable();
     980             : 
     981           0 :         aEvent.State = makeAny( getDataSources() );
     982             : 
     983           0 :         if(pToolbar)
     984             :         {
     985           0 :             aURL.Complete =".uno:Bib/source";
     986           0 :             aEvent.FeatureURL = aURL;
     987           0 :             pToolbar->statusChanged( aEvent );
     988             :         }
     989             : 
     990           0 :         updateGridModel();
     991           0 :         load();
     992           0 :     }
     993             : }
     994             : 
     995             : 
     996           0 : void BibDataManager::setActiveDataTable(const OUString& rTable)
     997             : {
     998           0 :     ResetIdentifierMapping();
     999             :     try
    1000             :     {
    1001           0 :         Reference< XPropertySet >  aPropertySet( m_xForm, UNO_QUERY );
    1002             : 
    1003           0 :         if(aPropertySet.is())
    1004             :         {
    1005           0 :             Reference< XConnection >    xConnection = getConnection( m_xForm );
    1006           0 :             Reference< XTablesSupplier >  xSupplyTables(xConnection, UNO_QUERY);
    1007           0 :             Reference< XNameAccess > xAccess = xSupplyTables->getTables();
    1008           0 :             Sequence< OUString > aTableNameSeq = xAccess->getElementNames();
    1009           0 :             sal_uInt32 nCount = aTableNameSeq.getLength();
    1010             : 
    1011           0 :             const OUString* pTableNames = aTableNameSeq.getConstArray();
    1012           0 :             const OUString* pTableNamesEnd = pTableNames + nCount;
    1013             : 
    1014           0 :             for ( ; pTableNames != pTableNamesEnd; ++pTableNames )
    1015             :             {
    1016           0 :                 if ( rTable == *pTableNames )
    1017             :                 {
    1018           0 :                     aActiveDataTable = rTable;
    1019           0 :                     Any aVal; aVal <<= rTable;
    1020           0 :                     aPropertySet->setPropertyValue( "Command", aVal );
    1021           0 :                     break;
    1022             :                 }
    1023             :             }
    1024           0 :             if (pTableNames != pTableNamesEnd)
    1025             :             {
    1026           0 :                 Reference< XDatabaseMetaData >  xMetaData = xConnection->getMetaData();
    1027           0 :                 aQuoteChar = xMetaData->getIdentifierQuoteString();
    1028             : 
    1029           0 :                 Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY);
    1030           0 :                 if ( xFactory.is() )
    1031           0 :                     m_xParser.set( xFactory->createInstance("com.sun.star.sdb.SingleSelectQueryComposer"), UNO_QUERY );
    1032             : 
    1033           0 :                 OUString aString("SELECT * FROM ");
    1034             : 
    1035           0 :                 OUString sCatalog, sSchema, sName;
    1036           0 :                 ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
    1037           0 :                 aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
    1038             : 
    1039           0 :                 m_xParser->setElementaryQuery(aString);
    1040             : 
    1041           0 :                 BibConfig* pConfig = BibModul::GetConfig();
    1042           0 :                 pConfig->setQueryField(getQueryField());
    1043           0 :                 startQueryWith(pConfig->getQueryText());
    1044             : 
    1045           0 :                 BibDBDescriptor aDesc;
    1046           0 :                 aDesc.sDataSource = aDataSourceURL;
    1047           0 :                 aDesc.sTableOrQuery = aActiveDataTable;
    1048           0 :                 aDesc.nCommandType = CommandType::TABLE;
    1049           0 :                 BibModul::GetConfig()->SetBibliographyURL(aDesc);
    1050           0 :             }
    1051           0 :         }
    1052             :     }
    1053           0 :     catch (const Exception&)
    1054             :     {
    1055             :         OSL_FAIL("::setActiveDataTable: something went wrong !");
    1056             :     }
    1057           0 : }
    1058             : 
    1059             : 
    1060           0 : void SAL_CALL BibDataManager::load(  ) throw (RuntimeException, std::exception)
    1061             : {
    1062           0 :     if ( isLoaded() )
    1063             :         // nothing to do
    1064           0 :         return;
    1065             : 
    1066           0 :     Reference< XLoadable > xFormAsLoadable( m_xForm, UNO_QUERY );
    1067             :     DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::load: invalid form!");
    1068           0 :     if ( xFormAsLoadable.is() )
    1069             :     {
    1070           0 :         xFormAsLoadable->load();
    1071           0 :         SetMeAsUidListener();
    1072             : 
    1073           0 :         EventObject aEvt( static_cast< XWeak* >( this ) );
    1074           0 :         m_aLoadListeners.notifyEach( &XLoadListener::loaded, aEvt );
    1075           0 :     }
    1076             : }
    1077             : 
    1078             : 
    1079           0 : void SAL_CALL BibDataManager::unload(  ) throw (RuntimeException, std::exception)
    1080             : {
    1081           0 :     if ( !isLoaded() )
    1082             :         // nothing to do
    1083           0 :         return;
    1084             : 
    1085           0 :     Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY );
    1086             :     DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::unload: invalid form!");
    1087           0 :     if ( xFormAsLoadable.is() )
    1088             :     {
    1089           0 :         EventObject aEvt( static_cast< XWeak* >( this ) );
    1090             : 
    1091             :         {
    1092           0 :             m_aLoadListeners.notifyEach( &XLoadListener::unloading, aEvt );
    1093             :         }
    1094             : 
    1095           0 :         RemoveMeAsUidListener();
    1096           0 :         xFormAsLoadable->unload();
    1097             : 
    1098             :         {
    1099           0 :             m_aLoadListeners.notifyEach( &XLoadListener::unloaded, aEvt );
    1100           0 :         }
    1101           0 :     }
    1102             : }
    1103             : 
    1104             : 
    1105           0 : void SAL_CALL BibDataManager::reload(  ) throw (RuntimeException, std::exception)
    1106             : {
    1107           0 :     if ( !isLoaded() )
    1108             :         // nothing to do
    1109           0 :         return;
    1110             : 
    1111           0 :     Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY );
    1112             :     DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::unload: invalid form!");
    1113           0 :     if ( xFormAsLoadable.is() )
    1114             :     {
    1115           0 :         EventObject aEvt( static_cast< XWeak* >( this ) );
    1116             : 
    1117             :         {
    1118           0 :             m_aLoadListeners.notifyEach( &XLoadListener::reloading, aEvt );
    1119             :         }
    1120             : 
    1121           0 :         xFormAsLoadable->reload();
    1122             : 
    1123             :         {
    1124           0 :             m_aLoadListeners.notifyEach( &XLoadListener::reloaded, aEvt );
    1125           0 :         }
    1126           0 :     }
    1127             : }
    1128             : 
    1129             : 
    1130           0 : sal_Bool SAL_CALL BibDataManager::isLoaded(  ) throw (RuntimeException, std::exception)
    1131             : {
    1132           0 :     Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY );
    1133             :     DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::isLoaded: invalid form!");
    1134             : 
    1135           0 :     bool bLoaded = false;
    1136           0 :     if ( xFormAsLoadable.is() )
    1137           0 :         bLoaded = xFormAsLoadable->isLoaded();
    1138           0 :     return bLoaded;
    1139             : }
    1140             : 
    1141             : 
    1142           0 : void SAL_CALL BibDataManager::addLoadListener( const Reference< XLoadListener >& aListener ) throw (RuntimeException, std::exception)
    1143             : {
    1144           0 :     m_aLoadListeners.addInterface( aListener );
    1145           0 : }
    1146             : 
    1147             : 
    1148           0 : void SAL_CALL BibDataManager::removeLoadListener( const Reference< XLoadListener >& aListener ) throw (RuntimeException, std::exception)
    1149             : {
    1150           0 :     m_aLoadListeners.removeInterface( aListener );
    1151           0 : }
    1152             : 
    1153             : 
    1154           0 : Reference< awt::XControlModel > BibDataManager::createGridModel(const OUString& rName)
    1155             : {
    1156           0 :     Reference< awt::XControlModel > xModel;
    1157             : 
    1158             :     try
    1159             :     {
    1160             :         // create the control model
    1161           0 :         Reference< XMultiServiceFactory >  xMgr = ::comphelper::getProcessServiceFactory();
    1162           0 :         Reference< XInterface >  xObject = xMgr->createInstance("com.sun.star.form.component.GridControl");
    1163           0 :         xModel=Reference< awt::XControlModel > ( xObject, UNO_QUERY );
    1164             : 
    1165             :         // set the
    1166           0 :         Reference< XPropertySet > xPropSet( xModel, UNO_QUERY );
    1167           0 :         xPropSet->setPropertyValue( "Name", makeAny( rName ) );
    1168             : 
    1169             :         // set the name of the to-be-created control
    1170           0 :         OUString aControlName("com.sun.star.form.control.InteractionGridControl");
    1171           0 :         Any aAny; aAny <<= aControlName;
    1172           0 :         xPropSet->setPropertyValue( "DefaultControl",aAny );
    1173             : 
    1174             :         // the helpURL
    1175           0 :         OUString uProp("HelpURL");
    1176           0 :         Reference< XPropertySetInfo > xPropInfo = xPropSet->getPropertySetInfo();
    1177           0 :         if (xPropInfo->hasPropertyByName(uProp))
    1178             :         {
    1179           0 :             OUString sId( INET_HID_SCHEME );
    1180           0 :             sId += OUString::createFromAscii( HID_BIB_DB_GRIDCTRL );
    1181           0 :             xPropSet->setPropertyValue( uProp, makeAny( sId ) );
    1182           0 :         }
    1183             :     }
    1184           0 :     catch (const Exception&)
    1185             :     {
    1186             :         OSL_FAIL("::createGridModel: something went wrong !");
    1187             :     }
    1188             : 
    1189           0 :     return xModel;
    1190             : }
    1191             : 
    1192           0 : OUString BibDataManager::getControlName(sal_Int32 nFormatKey )
    1193             : {
    1194           0 :     OUString aResStr;
    1195           0 :     switch (nFormatKey)
    1196             :     {
    1197             :         case DataType::BIT:
    1198             :         case DataType::BOOLEAN:
    1199           0 :             aResStr="CheckBox";
    1200           0 :             break;
    1201             :         case DataType::TINYINT:
    1202             :         case DataType::SMALLINT:
    1203             :         case DataType::INTEGER:
    1204           0 :             aResStr="NumericField";
    1205           0 :             break;
    1206             :         case DataType::REAL:
    1207             :         case DataType::DOUBLE:
    1208             :         case DataType::NUMERIC:
    1209             :         case DataType::DECIMAL:
    1210           0 :             aResStr="FormattedField";
    1211           0 :             break;
    1212             :         case DataType::TIMESTAMP:
    1213           0 :             aResStr="FormattedField";
    1214           0 :             break;
    1215             :         case DataType::DATE:
    1216           0 :             aResStr="DateField";
    1217           0 :             break;
    1218             :         case DataType::TIME:
    1219           0 :             aResStr="TimeField";
    1220           0 :             break;
    1221             :         case DataType::CHAR:
    1222             :         case DataType::VARCHAR:
    1223             :         case DataType::LONGVARCHAR:
    1224             :         default:
    1225           0 :             aResStr="TextField";
    1226           0 :             break;
    1227             :     }
    1228           0 :     return aResStr;
    1229             : }
    1230             : 
    1231           0 : Reference< awt::XControlModel > BibDataManager::loadControlModel(
    1232             :                     const OUString& rName, bool bForceListBox)
    1233             : {
    1234           0 :     Reference< awt::XControlModel > xModel;
    1235           0 :     OUString aName("View_");
    1236           0 :     aName += rName;
    1237             : 
    1238             :     try
    1239             :     {
    1240           0 :         Reference< XNameAccess >  xFields = getColumns( m_xForm );
    1241           0 :         if (!xFields.is())
    1242           0 :             return xModel;
    1243           0 :         Reference< XPropertySet >  xField;
    1244             : 
    1245           0 :         Any aElement;
    1246             : 
    1247           0 :         if(xFields->hasByName(rName))
    1248             :         {
    1249           0 :             aElement = xFields->getByName(rName);
    1250           0 :             aElement >>= xField;
    1251           0 :             Reference< XPropertySetInfo >  xInfo = xField.is() ? xField->getPropertySetInfo() : Reference< XPropertySetInfo > ();
    1252             : 
    1253           0 :             const OUString sType("Type");
    1254           0 :             sal_Int32 nFormatKey = 0;
    1255           0 :             xField->getPropertyValue(sType) >>= nFormatKey;
    1256             : 
    1257           0 :             OUString aInstanceName("com.sun.star.form.component.");
    1258             : 
    1259           0 :             if (bForceListBox)
    1260           0 :                 aInstanceName += "ListBox";
    1261             :             else
    1262           0 :                 aInstanceName += getControlName(nFormatKey);
    1263             : 
    1264           0 :             Reference< XComponentContext >  xContext = comphelper::getProcessComponentContext();
    1265           0 :             Reference< XInterface >  xObject = xContext->getServiceManager()->createInstanceWithContext(aInstanceName, xContext);
    1266           0 :             xModel=Reference< awt::XControlModel > ( xObject, UNO_QUERY );
    1267           0 :             Reference< XPropertySet >  xPropSet( xModel, UNO_QUERY );
    1268           0 :             Any aFieldName; aFieldName <<= aName;
    1269             : 
    1270           0 :             xPropSet->setPropertyValue( FM_PROP_NAME,aFieldName);
    1271           0 :             xPropSet->setPropertyValue( FM_PROP_CONTROLSOURCE, makeAny( rName ) );
    1272           0 :             xPropSet->setPropertyValue("NativeWidgetLook", makeAny( true ) );
    1273             : 
    1274           0 :             Reference< XFormComponent >  aFormComp(xModel,UNO_QUERY );
    1275             : 
    1276           0 :             Reference< XNameContainer >  xNameCont( m_xForm, UNO_QUERY );
    1277           0 :             xNameCont->insertByName(aName, makeAny( aFormComp ) );
    1278             : 
    1279             :             // now if the form where we inserted the new model is already loaded, notify the model of this
    1280             :             // Note that this implementation below is a HACK as it relies on the fact that the model adds itself
    1281             :             // as load listener to its parent, which is an implementation detail of the model.
    1282             :             //
    1283             :             // the better solution would be the following:
    1284             :             // in the current scenario, we insert a control model into a form. This results in the control model
    1285             :             // adding itself as load listener to the form. Now, the form should realize that it's already loaded
    1286             :             // and notify the model (which it knows as XLoadListener only) immediately. This seems to make sense.
    1287             :             // (as an anologon to the XStatusListener semantics).
    1288             :             //
    1289             :             // But this would be way too risky for this last-day fix here.
    1290           0 :             Reference< XLoadable > xLoad( m_xForm, UNO_QUERY );
    1291           0 :             if ( xLoad.is() && xLoad->isLoaded() )
    1292             :             {
    1293           0 :                 Reference< XLoadListener > xListener( aFormComp, UNO_QUERY );
    1294           0 :                 if ( xListener.is() )
    1295             :                 {
    1296           0 :                     EventObject aLoadSource;
    1297           0 :                     aLoadSource.Source = xLoad;
    1298           0 :                     xListener->loaded( aLoadSource );
    1299           0 :                 }
    1300           0 :             }
    1301           0 :         }
    1302             :     }
    1303           0 :     catch (const Exception&)
    1304             :     {
    1305             :         OSL_FAIL("::loadControlModel: something went wrong !");
    1306             :     }
    1307           0 :     return xModel;
    1308             : }
    1309             : 
    1310           0 : void SAL_CALL BibDataManager::disposing()
    1311             : {
    1312           0 :     BibDataManager_Base::WeakComponentImplHelperBase::disposing();
    1313           0 : }
    1314             : 
    1315             : 
    1316           0 : void BibDataManager::disposing( const EventObject& /*Source*/ ) throw( ::com::sun::star::uno::RuntimeException, std::exception )
    1317             : {
    1318             :     // not interested in
    1319           0 : }
    1320             : 
    1321             : 
    1322           0 : void BibDataManager::propertyChange(const beans::PropertyChangeEvent& evt) throw( RuntimeException, std::exception )
    1323             : {
    1324             :     try
    1325             :     {
    1326           0 :         if(evt.PropertyName == FM_PROP_VALUE)
    1327             :         {
    1328           0 :             if( evt.NewValue.getValueType() == cppu::UnoType<io::XInputStream>::get())
    1329             :             {
    1330             :                 Reference< io::XDataInputStream >  xStream(
    1331           0 :                     *(const Reference< io::XInputStream > *)evt.NewValue.getValue(), UNO_QUERY );
    1332           0 :                 aUID <<= xStream->readUTF();
    1333             :             }
    1334             :             else
    1335           0 :                 aUID = evt.NewValue;
    1336             : 
    1337           0 :             Reference< XRowLocate > xLocate(xBibCursor, UNO_QUERY);
    1338             :             DBG_ASSERT(xLocate.is(), "BibDataManager::propertyChange : invalid cursor !");
    1339           0 :             xLocate->moveToBookmark(aUID);
    1340             :         }
    1341             :     }
    1342           0 :     catch (const Exception&)
    1343             :     {
    1344             :         OSL_FAIL("::propertyChange: something went wrong !");
    1345             :     }
    1346           0 : }
    1347             : 
    1348             : 
    1349           0 : void BibDataManager::SetMeAsUidListener()
    1350             : {
    1351             :     try
    1352             :     {
    1353           0 :         Reference< XNameAccess >  xFields = getColumns( m_xForm );
    1354           0 :         if (!xFields.is())
    1355           0 :             return;
    1356             : 
    1357           0 :         Sequence< OUString > aFields(xFields->getElementNames());
    1358           0 :         const OUString* pFields = aFields.getConstArray();
    1359           0 :         sal_Int32 nCount=aFields.getLength();
    1360           0 :         OUString StrUID(STR_UID);
    1361           0 :         OUString theFieldName;
    1362           0 :         for( sal_Int32 i=0; i<nCount; i++ )
    1363             :         {
    1364           0 :             const OUString& rName = pFields[i];
    1365             : 
    1366           0 :             if (rName.equalsIgnoreAsciiCase(StrUID))
    1367             :             {
    1368           0 :                 theFieldName=pFields[i];
    1369           0 :                 break;
    1370             :             }
    1371             :         }
    1372             : 
    1373           0 :         if(!theFieldName.isEmpty())
    1374             :         {
    1375           0 :             Reference< XPropertySet >  xPropSet;
    1376           0 :             Any aElement;
    1377             : 
    1378           0 :             aElement = xFields->getByName(theFieldName);
    1379           0 :             xPropSet = *(Reference< XPropertySet > *)aElement.getValue();
    1380             : 
    1381           0 :             xPropSet->addPropertyChangeListener(FM_PROP_VALUE, this);
    1382           0 :         }
    1383             : 
    1384             :     }
    1385           0 :     catch (const Exception&)
    1386             :     {
    1387             :         OSL_FAIL("Exception in BibDataManager::SetMeAsUidListener");
    1388             :     }
    1389             : }
    1390             : 
    1391             : 
    1392           0 : void BibDataManager::RemoveMeAsUidListener()
    1393             : {
    1394             :     try
    1395             :     {
    1396           0 :         Reference< XNameAccess >  xFields = getColumns( m_xForm );
    1397           0 :         if (!xFields.is())
    1398           0 :             return;
    1399             : 
    1400             : 
    1401           0 :         Sequence< OUString > aFields(xFields->getElementNames());
    1402           0 :         const OUString* pFields = aFields.getConstArray();
    1403           0 :         sal_Int32 nCount=aFields.getLength();
    1404           0 :         OUString StrUID(STR_UID);
    1405           0 :         OUString theFieldName;
    1406           0 :         for( sal_Int32 i=0; i<nCount; i++ )
    1407             :         {
    1408           0 :             const OUString& rName = pFields[i];
    1409             : 
    1410           0 :             if (rName.equalsIgnoreAsciiCase(StrUID))
    1411             :             {
    1412           0 :                 theFieldName=pFields[i];
    1413           0 :                 break;
    1414             :             }
    1415             :         }
    1416             : 
    1417           0 :         if(!theFieldName.isEmpty())
    1418             :         {
    1419           0 :             Reference< XPropertySet >  xPropSet;
    1420           0 :             Any aElement;
    1421             : 
    1422           0 :             aElement = xFields->getByName(theFieldName);
    1423           0 :             xPropSet = *(Reference< XPropertySet > *)aElement.getValue();
    1424             : 
    1425           0 :             xPropSet->removePropertyChangeListener(FM_PROP_VALUE, this);
    1426           0 :         }
    1427             : 
    1428             :     }
    1429           0 :     catch (const Exception&)
    1430             :     {
    1431             :         OSL_FAIL("Exception in BibDataManager::RemoveMeAsUidListener");
    1432             :     }
    1433             : }
    1434             : 
    1435           0 : void BibDataManager::CreateMappingDialog(vcl::Window* pParent)
    1436             : {
    1437           0 :     boost::scoped_ptr<MappingDialog_Impl> pDlg(new MappingDialog_Impl(pParent, this));
    1438           0 :     if(RET_OK == pDlg->Execute() && pBibView)
    1439             :     {
    1440           0 :         reload();
    1441           0 :     }
    1442           0 : }
    1443             : 
    1444           0 : OUString BibDataManager::CreateDBChangeDialog(vcl::Window* pParent)
    1445             : {
    1446           0 :     OUString uRet;
    1447           0 :     boost::scoped_ptr<DBChangeDialog_Impl> pDlg(new DBChangeDialog_Impl(pParent, this ));
    1448           0 :     if(RET_OK == pDlg->Execute())
    1449             :     {
    1450           0 :         OUString sNewURL = pDlg->GetCurrentURL();
    1451           0 :         if(sNewURL != getActiveDataSource())
    1452             :         {
    1453           0 :             uRet = sNewURL;
    1454           0 :         }
    1455             :     }
    1456           0 :     return uRet;
    1457             : }
    1458             : 
    1459           0 : void BibDataManager::DispatchDBChangeDialog()
    1460             : {
    1461           0 :     if(pToolbar)
    1462           0 :         pToolbar->SendDispatch(TBC_BT_CHANGESOURCE, Sequence< PropertyValue >());
    1463           0 : }
    1464             : 
    1465           0 : const OUString& BibDataManager::GetIdentifierMapping()
    1466             : {
    1467           0 :     if(sIdentifierMapping.isEmpty())
    1468             :     {
    1469           0 :         BibConfig* pConfig = BibModul::GetConfig();
    1470           0 :         BibDBDescriptor aDesc;
    1471           0 :         aDesc.sDataSource = getActiveDataSource();
    1472           0 :         aDesc.sTableOrQuery = getActiveDataTable();
    1473           0 :         aDesc.nCommandType = CommandType::TABLE;
    1474           0 :         const Mapping* pMapping = pConfig->GetMapping(aDesc);
    1475           0 :         sIdentifierMapping = pConfig->GetDefColumnName(IDENTIFIER_POS);
    1476           0 :         if(pMapping)
    1477             :         {
    1478           0 :             for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
    1479             :             {
    1480           0 :                 if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == sIdentifierMapping)
    1481             :                 {
    1482           0 :                     sIdentifierMapping = pMapping->aColumnPairs[nEntry].sRealColumnName;
    1483           0 :                     break;
    1484             :                 }
    1485             :             }
    1486           0 :         }
    1487             :     }
    1488           0 :     return sIdentifierMapping;
    1489             : }
    1490             : 
    1491           0 : void BibDataManager::SetToolbar(BibToolBar* pSet)
    1492             : {
    1493           0 :     pToolbar = pSet;
    1494           0 :     if(pToolbar)
    1495           0 :         pToolbar->SetDatMan(*this);
    1496           0 : }
    1497             : 
    1498           0 : uno::Reference< form::runtime::XFormController > BibDataManager::GetFormController()
    1499             : {
    1500           0 :     if(!m_xFormCtrl.is())
    1501             :     {
    1502           0 :         Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
    1503           0 :         m_xFormCtrl = form::runtime::FormController::create(xContext);
    1504           0 :         m_xFormCtrl->setModel(uno::Reference< awt::XTabControllerModel > (getForm(), UNO_QUERY));
    1505           0 :         m_xFormDispatch = uno::Reference< frame::XDispatch > ( m_xFormCtrl, UNO_QUERY);
    1506             :     }
    1507           0 :     return m_xFormCtrl;
    1508             : }
    1509             : 
    1510           0 : void BibDataManager::RegisterInterceptor( ::bib::BibBeamer* pBibBeamer)
    1511             : {
    1512             :     DBG_ASSERT( !m_pInterceptorHelper, "BibDataManager::RegisterInterceptor: called twice!" );
    1513             : 
    1514           0 :     if( pBibBeamer )
    1515           0 :         m_pInterceptorHelper = new BibInterceptorHelper( pBibBeamer, m_xFormDispatch);
    1516           0 :     if( m_pInterceptorHelper )
    1517           0 :         m_pInterceptorHelper->acquire();
    1518           0 : }
    1519             : 
    1520             : 
    1521           0 : bool BibDataManager::HasActiveConnection()const
    1522             : {
    1523           0 :     bool bRet = false;
    1524           0 :     Reference< XPropertySet >   xPrSet( m_xForm, UNO_QUERY );
    1525           0 :     if( xPrSet.is() )
    1526             :     {
    1527           0 :         Reference< XComponent >  xConnection;
    1528           0 :         xPrSet->getPropertyValue("ActiveConnection") >>= xConnection;
    1529           0 :         bRet = xConnection.is();
    1530             :     }
    1531           0 :     return bRet;
    1532             : }
    1533             : 
    1534           0 : bool BibDataManager::HasActiveConnection()
    1535             : {
    1536           0 :     return getConnection( m_xForm ).is();
    1537          12 : }
    1538             : 
    1539             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10