LCOV - code coverage report
Current view: top level - extensions/source/bibliography - datman.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 806 0.7 %
Date: 2012-08-25 Functions: 2 69 2.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 2124 0.1 %

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

Generated by: LCOV version 1.10