LCOV - code coverage report
Current view: top level - extensions/source/bibliography - bibload.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 25 266 9.4 %
Date: 2014-11-03 Functions: 9 33 27.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <osl/mutex.hxx>
      21             : #include <tools/diagnose_ex.h>
      22             : #include <cppuhelper/weak.hxx>
      23             : #include <cppuhelper/supportsservice.hxx>
      24             : #include <svl/itemprop.hxx>
      25             : #include <uno/environment.h>
      26             : #include <svl/urihelper.hxx>
      27             : #include <toolkit/helper/vclunohelper.hxx>
      28             : #include <comphelper/processfactory.hxx>
      29             : #include <cppuhelper/factory.hxx>
      30             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      31             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      32             : #include <com/sun/star/sdb/XColumn.hpp>
      33             : #include <com/sun/star/util/XURLTransformer.hpp>
      34             : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      35             : #include <com/sun/star/sdbc/XRowSet.hpp>
      36             : #include <com/sun/star/sdb/CommandType.hpp>
      37             : #include <com/sun/star/frame/XFrameLoader.hpp>
      38             : #include <com/sun/star/lang/XServiceInfo.hpp>
      39             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      40             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      41             : #include <com/sun/star/beans/XPropertySet.hpp>
      42             : #include <com/sun/star/container/XNameAccess.hpp>
      43             : #include <com/sun/star/text/BibliographyDataField.hpp>
      44             : #include <com/sun/star/form/XLoadListener.hpp>
      45             : #include <com/sun/star/frame/XLayoutManager.hpp>
      46             : #include <com/sun/star/uno/XAggregation.hpp>
      47             : #include <toolkit/awt/vclxwindow.hxx>
      48             : #include <vcl/window.hxx>
      49             : #include <vcl/edit.hxx>
      50             : #include <vcl/svapp.hxx>
      51             : #include <vcl/group.hxx>
      52             : #include <svtools/svmedit.hxx>
      53             : 
      54             : #include "bibresid.hxx"
      55             : #include "bib.hrc"
      56             : #include "bibcont.hxx"
      57             : #include "bibbeam.hxx"
      58             : #include "bibmod.hxx"
      59             : #include "bibview.hxx"
      60             : #include "framectr.hxx"
      61             : #include "datman.hxx"
      62             : #include <bibconfig.hxx>
      63             : #include <cppuhelper/implbase4.hxx>
      64             : 
      65             : using namespace ::com::sun::star;
      66             : using namespace ::com::sun::star::uno;
      67             : using namespace ::com::sun::star::beans;
      68             : using namespace ::com::sun::star::lang;
      69             : using namespace ::com::sun::star::sdb;
      70             : using namespace ::com::sun::star::sdbc;
      71             : using namespace ::com::sun::star::form;
      72             : using namespace ::com::sun::star::container;
      73             : using namespace ::com::sun::star::frame;
      74             : 
      75             : class BibliographyLoader : public cppu::WeakImplHelper4
      76             :                             < XServiceInfo, XNameAccess, XPropertySet, XFrameLoader >
      77             : {
      78             :     HdlBibModul                                     m_pBibMod;
      79             :     Reference< XLoadable >                          m_xDatMan;
      80             :     BibDataManager*                                 m_pDatMan;
      81             :     Reference< XNameAccess >                        m_xColumns;
      82             :     Reference< XResultSet >                         m_xCursor;
      83             : 
      84             : private:
      85             : 
      86             :     void                    loadView(const Reference< XFrame > & aFrame, const OUString& aURL,
      87             :                                 const Sequence< PropertyValue >& aArgs,
      88             :                                 const Reference< XLoadEventListener > & aListener);
      89             : 
      90             :     BibDataManager*         GetDataManager()const;
      91             :     Reference< XNameAccess >            GetDataColumns() const;
      92             :     Reference< XResultSet >             GetDataCursor() const;
      93             :     Reference< sdb::XColumn >               GetIdentifierColumn() const;
      94             : 
      95             : public:
      96             :                             BibliographyLoader();
      97             :                             virtual ~BibliographyLoader();
      98             : 
      99             :     // XServiceInfo
     100             :     OUString               SAL_CALL getImplementationName() throw(std::exception  ) SAL_OVERRIDE;
     101             :     sal_Bool                    SAL_CALL supportsService(const OUString& ServiceName) throw(std::exception  ) SAL_OVERRIDE;
     102             :     Sequence< OUString >   SAL_CALL getSupportedServiceNames(void) throw(std::exception  ) SAL_OVERRIDE;
     103           8 :     static OUString                getImplementationName_Static() throw(  )
     104             : 
     105             :                             {
     106             :                                 //!
     107           8 :                                 return OUString("com.sun.star.extensions.Bibliography");
     108             :                                 //!
     109             :                             }
     110             : 
     111             :     //XNameAccess
     112             :     virtual Any SAL_CALL getByName(const OUString& aName) throw ( NoSuchElementException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE;
     113             :     virtual Sequence< OUString > SAL_CALL getElementNames(void) throw ( RuntimeException, std::exception ) SAL_OVERRIDE;
     114             :     virtual sal_Bool SAL_CALL hasByName(const OUString& aName) throw ( RuntimeException, std::exception ) SAL_OVERRIDE;
     115             : 
     116             :     //XElementAccess
     117             :     virtual Type  SAL_CALL getElementType(void) throw ( RuntimeException, std::exception ) SAL_OVERRIDE;
     118             :     virtual sal_Bool SAL_CALL hasElements(void) throw ( RuntimeException, std::exception ) SAL_OVERRIDE;
     119             : 
     120             :     //XPropertySet
     121             :     virtual Reference< XPropertySetInfo >  SAL_CALL getPropertySetInfo(void) throw ( RuntimeException, std::exception ) SAL_OVERRIDE;
     122             :     virtual void SAL_CALL setPropertyValue(const OUString& PropertyName, const Any& aValue) throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE;
     123             :     virtual Any SAL_CALL getPropertyValue(const OUString& PropertyName) throw ( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE;
     124             :     virtual void SAL_CALL addPropertyChangeListener(const OUString& PropertyName, const Reference< XPropertyChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE;
     125             :     virtual void SAL_CALL removePropertyChangeListener(const OUString& PropertyName, const Reference< XPropertyChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE;
     126             :     virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName, const Reference< XVetoableChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE;
     127             :     virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName, const Reference< XVetoableChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE;
     128             : 
     129             :     static Sequence<OUString>  SAL_CALL getSupportedServiceNames_Static(void) throw(  );
     130             : 
     131             :     friend  Reference< XInterface >     SAL_CALL BibliographyLoader_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception );
     132             : 
     133             :     // XLoader
     134             :     virtual void            SAL_CALL load(const Reference< XFrame > & aFrame, const OUString& aURL,
     135             :                                 const Sequence< PropertyValue >& aArgs,
     136             :                                 const Reference< XLoadEventListener > & aListener) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     137             :     virtual void            SAL_CALL cancel(void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     138             : };
     139             : 
     140           4 : BibliographyLoader::BibliographyLoader() :
     141             :     m_pBibMod(0),
     142           4 :     m_pDatMan(0)
     143             : {
     144           4 : }
     145             : 
     146          12 : BibliographyLoader::~BibliographyLoader()
     147             : {
     148           4 :     Reference< lang::XComponent >  xComp(m_xCursor, UNO_QUERY);
     149           4 :     if (xComp.is())
     150           0 :         xComp->dispose();
     151           4 :     if(m_pBibMod)
     152           0 :         CloseBibModul(m_pBibMod);
     153           8 : }
     154             : 
     155             : 
     156           4 : Reference< XInterface >  SAL_CALL BibliographyLoader_CreateInstance( const Reference< XMultiServiceFactory >  & /*rSMgr*/ ) throw( Exception )
     157             : {
     158           4 :     return *(new BibliographyLoader);
     159             : }
     160             : 
     161             : 
     162             : // XServiceInfo
     163           0 : OUString BibliographyLoader::getImplementationName() throw(std::exception  )
     164             : 
     165             : {
     166           0 :     return getImplementationName_Static();
     167             : }
     168             : 
     169             : // XServiceInfo
     170           0 : sal_Bool BibliographyLoader::supportsService(const OUString& ServiceName) throw(std::exception  )
     171             : {
     172           0 :     return cppu::supportsService(this, ServiceName);
     173             : }
     174             : 
     175             : // XServiceInfo
     176           0 : Sequence< OUString > BibliographyLoader::getSupportedServiceNames(void) throw(std::exception  )
     177             : {
     178           0 :     return getSupportedServiceNames_Static();
     179             : }
     180             : 
     181             : // ORegistryServiceManager_Static
     182           4 : Sequence< OUString > BibliographyLoader::getSupportedServiceNames_Static(void) throw(  )
     183             : {
     184           4 :     Sequence< OUString > aSNS( 2 );
     185           4 :     aSNS.getArray()[0] = "com.sun.star.frame.FrameLoader";
     186             :     //!
     187           4 :     aSNS.getArray()[1] = "com.sun.star.frame.Bibliography";
     188             :     //!
     189           4 :     return aSNS;
     190             : }
     191             : 
     192             : extern "C"
     193             : {
     194           4 :     SAL_DLLPUBLIC_EXPORT void * SAL_CALL bib_component_getFactory(
     195             :         const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
     196             :     {
     197           4 :         void * pRet = 0;
     198           4 :         if (BibliographyLoader::getImplementationName_Static().equalsAscii( pImplName ) )
     199             :         {
     200             :             // create the factory
     201             :             Reference< XSingleServiceFactory > xFactory =
     202             :                 cppu::createSingleFactory(
     203             :                     static_cast<css::lang::XMultiServiceFactory *>(pServiceManager),
     204             :                     BibliographyLoader::getImplementationName_Static(),
     205             :                     BibliographyLoader_CreateInstance,
     206           4 :                     BibliographyLoader::getSupportedServiceNames_Static() );
     207             :             // acquire, because we return an interface pointer instead of a reference
     208           4 :             xFactory->acquire();
     209           4 :             pRet = xFactory.get();
     210             :         }
     211           4 :         return pRet;
     212             :     }
     213             : 
     214             : }
     215             : 
     216           0 : void BibliographyLoader::cancel(void) throw (::com::sun::star::uno::RuntimeException, std::exception)
     217             : {
     218             :     //!
     219             :     //!
     220           0 : }
     221             : 
     222           0 : void BibliographyLoader::load(const Reference< XFrame > & rFrame, const OUString& rURL,
     223             :         const Sequence< PropertyValue >& rArgs,
     224             :         const Reference< XLoadEventListener > & rListener) throw (::com::sun::star::uno::RuntimeException, std::exception)
     225             : {
     226             : 
     227           0 :     SolarMutexGuard aGuard;
     228             : 
     229           0 :     m_pBibMod = OpenBibModul();
     230             : 
     231           0 :     OUString aURLStr( rURL );
     232           0 :     OUString aPartName = aURLStr.getToken( 1, '/' );
     233           0 :     Reference<XPropertySet> xPrSet(rFrame, UNO_QUERY);
     234           0 :     if(xPrSet.is())
     235             :     {
     236           0 :         Any aTitle;
     237           0 :         aTitle <<= BibResId(RID_BIB_STR_FRAME_TITLE).toString();
     238           0 :         xPrSet->setPropertyValue("Title", aTitle);
     239             :     }
     240           0 :     if(aPartName == "View" || aPartName == "View1")
     241             :     {
     242           0 :         loadView(rFrame, rURL, rArgs, rListener);
     243           0 :     }
     244           0 : }
     245             : 
     246             : 
     247           0 : void BibliographyLoader::loadView(const Reference< XFrame > & rFrame, const OUString& /*rURL*/,
     248             :         const Sequence< PropertyValue >& /*rArgs*/,
     249             :         const Reference< XLoadEventListener > & rListener)
     250             : {
     251           0 :     SolarMutexGuard aGuard;
     252             :     //!
     253           0 :     if(!m_pBibMod)
     254           0 :         m_pBibMod = OpenBibModul();
     255             : 
     256           0 :     m_pDatMan = (*m_pBibMod)->createDataManager();
     257           0 :     m_xDatMan = m_pDatMan;
     258           0 :     BibDBDescriptor aBibDesc = BibModul::GetConfig()->GetBibliographyURL();
     259             : 
     260           0 :     if(aBibDesc.sDataSource.isEmpty())
     261             :     {
     262           0 :         DBChangeDialogConfig_Impl aConfig;
     263           0 :         const Sequence<OUString> aSources = aConfig.GetDataSourceNames();
     264           0 :         if(aSources.getLength())
     265           0 :             aBibDesc.sDataSource = aSources.getConstArray()[0];
     266             :     }
     267             : 
     268           0 :     Reference< XForm > xForm = m_pDatMan->createDatabaseForm( aBibDesc );
     269             : 
     270           0 :     Reference< awt::XWindow >  aWindow = rFrame->getContainerWindow();
     271           0 :     VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(aWindow);
     272             :     assert(pParentComponent);
     273             : 
     274           0 :     vcl::Window* pParent = VCLUnoHelper::GetWindow( aWindow );
     275             : 
     276           0 :     BibBookContainer *pMyWindow = new BibBookContainer( pParent );
     277           0 :     pMyWindow->Show();
     278             : 
     279           0 :     ::bib::BibView* pView = new ::bib::BibView( pMyWindow, m_pDatMan, WB_VSCROLL | WB_HSCROLL | WB_3DLOOK );
     280           0 :     pView->Show();
     281           0 :     m_pDatMan->SetView( pView );
     282             : 
     283           0 :     ::bib::BibBeamer* pBeamer = new ::bib::BibBeamer( pMyWindow, m_pDatMan );
     284           0 :     pBeamer->Show();
     285           0 :     pMyWindow->createTopFrame(pBeamer);
     286             : 
     287           0 :     pMyWindow->createBottomFrame(pView);
     288             : 
     289           0 :     Reference< awt::XWindow >  xWin ( pMyWindow->GetComponentInterface(), UNO_QUERY );
     290             : 
     291           0 :     Reference< XController >  xCtrRef( new BibFrameController_Impl( xWin, m_pDatMan ) );
     292             : 
     293           0 :     xCtrRef->attachFrame(rFrame);
     294           0 :     rFrame->setComponent( xWin, xCtrRef);
     295           0 :     pBeamer->SetXController(xCtrRef);
     296             : 
     297           0 :     if (pParentComponent)
     298             :     {
     299             :         // not earlier because SetFocus() is triggered in setVisible()
     300           0 :         pParentComponent->setVisible(sal_True);
     301             :     }
     302             : 
     303           0 :     m_xDatMan->load();
     304             :     // #100312# ----------
     305           0 :     m_pDatMan->RegisterInterceptor(pBeamer);
     306             : 
     307           0 :     if ( rListener.is() )
     308           0 :         rListener->loadFinished( this );
     309             : 
     310             :     // attach menu bar
     311           0 :     Reference< XPropertySet > xPropSet( rFrame, UNO_QUERY );
     312           0 :     Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
     313           0 :     if ( xPropSet.is() )
     314             :     {
     315             :         try
     316             :         {
     317           0 :             Any a = xPropSet->getPropertyValue("LayoutManager");
     318           0 :             a >>= xLayoutManager;
     319             :         }
     320           0 :         catch ( const uno::Exception& )
     321             :         {
     322             :         }
     323             :     }
     324             : 
     325           0 :     if ( xLayoutManager.is() )
     326           0 :         xLayoutManager->createElement( OUString( "private:resource/menubar/menubar" ));
     327           0 : }
     328             : 
     329           0 : BibDataManager* BibliographyLoader::GetDataManager()const
     330             : {
     331           0 :     if(!m_pDatMan)
     332             :     {
     333           0 :         if(!m_pBibMod)
     334           0 :             const_cast< BibliographyLoader* >( this )->m_pBibMod = OpenBibModul();
     335           0 :         const_cast< BibliographyLoader* >( this )->m_pDatMan = (*m_pBibMod)->createDataManager();
     336           0 :         const_cast< BibliographyLoader* >( this )->m_xDatMan = m_pDatMan;
     337             :     }
     338           0 :     return m_pDatMan;
     339             : }
     340             : 
     341           0 : Reference< XNameAccess >  BibliographyLoader::GetDataColumns() const
     342             : {
     343           0 :     if (!m_xColumns.is())
     344             :     {
     345           0 :         Reference< XMultiServiceFactory >  xMgr = comphelper::getProcessServiceFactory();
     346           0 :         Reference< XRowSet >  xRowSet(xMgr->createInstance("com.sun.star.sdb.RowSet"), UNO_QUERY);
     347           0 :         Reference< XPropertySet >  xResultSetProps(xRowSet, UNO_QUERY);
     348             :         DBG_ASSERT(xResultSetProps.is() , "BibliographyLoader::GetDataCursor : invalid row set (no XResultSet or no XPropertySet) !");
     349             : 
     350           0 :         BibDBDescriptor aBibDesc = BibModul::GetConfig()->GetBibliographyURL();
     351             : 
     352           0 :         Any aBibUrlAny; aBibUrlAny <<= aBibDesc.sDataSource;
     353           0 :         xResultSetProps->setPropertyValue("DataSourceName", aBibUrlAny);
     354           0 :         Any aCommandType; aCommandType <<= aBibDesc.nCommandType;
     355           0 :         xResultSetProps->setPropertyValue("CommandType", aCommandType);
     356           0 :         Any aTableName; aTableName <<= aBibDesc.sTableOrQuery;
     357           0 :         xResultSetProps->setPropertyValue("Command", aTableName);
     358           0 :         Any aResultSetType; aResultSetType <<= (sal_Int32)(ResultSetType::SCROLL_INSENSITIVE);
     359           0 :         xResultSetProps->setPropertyValue("ResultSetType", aResultSetType);
     360           0 :         Any aResultSetCurrency; aResultSetCurrency <<= (sal_Int32)(ResultSetConcurrency::UPDATABLE);
     361           0 :         xResultSetProps->setPropertyValue("ResultSetConcurrency", aResultSetCurrency);
     362             : 
     363           0 :         bool bSuccess = false;
     364             :         try
     365             :         {
     366           0 :             xRowSet->execute();
     367           0 :             bSuccess = true;
     368             :         }
     369           0 :         catch(const SQLException&)
     370             :         {
     371             :             DBG_UNHANDLED_EXCEPTION();
     372             :         }
     373           0 :         catch(const Exception& )
     374             :         {
     375             :             DBG_UNHANDLED_EXCEPTION();
     376           0 :             bSuccess = false;
     377             :         }
     378             : 
     379           0 :         if (!bSuccess)
     380             :         {
     381           0 :             Reference< XComponent >  xSetComp(xRowSet, UNO_QUERY);
     382           0 :             if (xSetComp.is())
     383           0 :                 xSetComp->dispose();
     384           0 :             xRowSet = NULL;
     385             :         }
     386             :         else
     387           0 :             ((BibliographyLoader*)this)->m_xCursor = xRowSet.get();
     388             : 
     389           0 :         Reference< sdbcx::XColumnsSupplier >  xSupplyCols(m_xCursor, UNO_QUERY);
     390           0 :         if (xSupplyCols.is())
     391           0 :             ((BibliographyLoader*)this)->m_xColumns = xSupplyCols->getColumns();
     392             :     }
     393             : 
     394           0 :     return m_xColumns;
     395             : }
     396             : 
     397           0 : Reference< sdb::XColumn >  BibliographyLoader::GetIdentifierColumn() const
     398             : {
     399           0 :     BibDataManager* pDatMan = GetDataManager();
     400           0 :     Reference< XNameAccess >  xColumns = GetDataColumns();
     401           0 :     OUString sIdentifierColumnName = pDatMan->GetIdentifierMapping();
     402             : 
     403           0 :     Reference< sdb::XColumn >  xReturn;
     404           0 :     if (xColumns.is() && xColumns->hasByName(sIdentifierColumnName))
     405             :     {
     406           0 :         xReturn = Reference< XColumn > (*(Reference< XInterface > *)
     407           0 :                 xColumns->getByName(sIdentifierColumnName).getValue(), UNO_QUERY);
     408             :     }
     409           0 :     return xReturn;
     410             : }
     411             : 
     412           0 : Reference< XResultSet >  BibliographyLoader::GetDataCursor() const
     413             : {
     414           0 :     if (!m_xCursor.is())
     415           0 :         GetDataColumns();
     416           0 :     if (m_xCursor.is())
     417           0 :         m_xCursor->first();
     418           0 :     return m_xCursor;
     419             : }
     420             : 
     421           0 : static OUString lcl_AddProperty(Reference< XNameAccess >  xColumns,
     422             :         const Mapping* pMapping, const OUString& rColumnName)
     423             : {
     424           0 :     OUString sColumnName(rColumnName);
     425           0 :     if(pMapping)
     426             :     {
     427           0 :         for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
     428             :         {
     429           0 :             if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == rColumnName)
     430             :             {
     431           0 :                 sColumnName = pMapping->aColumnPairs[nEntry].sRealColumnName;
     432           0 :                 break;
     433             :             }
     434             :         }
     435             :     }
     436           0 :     OUString uColumnName(sColumnName);
     437           0 :     OUString uRet;
     438           0 :     Reference< sdb::XColumn >  xCol;
     439           0 :     if (xColumns->hasByName(uColumnName))
     440           0 :         xCol = Reference< sdb::XColumn > (*(Reference< XInterface > *)xColumns->getByName(uColumnName).getValue(), UNO_QUERY);
     441           0 :     if (xCol.is())
     442           0 :         uRet = xCol->getString();
     443           0 :     return uRet;
     444             : }
     445             : 
     446           0 : Any BibliographyLoader::getByName(const OUString& rName) throw
     447             :                         ( NoSuchElementException, WrappedTargetException, RuntimeException, std::exception )
     448             : {
     449           0 :     Any aRet;
     450             :     try
     451             :     {
     452           0 :         BibDataManager* pDatMan = ((BibliographyLoader*)this)->GetDataManager();
     453           0 :         Reference< XResultSet >  xCursor = GetDataCursor();
     454           0 :         Reference< sdbcx::XColumnsSupplier >  xSupplyCols(xCursor, UNO_QUERY);
     455           0 :         Reference< XNameAccess >  xColumns;
     456           0 :         if (!xSupplyCols.is())
     457           0 :             return aRet;
     458           0 :         xColumns = xSupplyCols->getColumns();
     459             :         DBG_ASSERT(xSupplyCols.is(), "BibliographyLoader::getByName : invalid columns returned by the data cursor (may be the result set is not alive ?) !");
     460           0 :         if (!xColumns.is())
     461           0 :             return aRet;
     462             : 
     463           0 :         OUString sIdentifierMapping = pDatMan->GetIdentifierMapping();
     464           0 :         OUString sId = sIdentifierMapping;
     465           0 :         Reference< sdb::XColumn >  xColumn;
     466           0 :         if (xColumns->hasByName(sId))
     467           0 :             xColumn = Reference< sdb::XColumn > (*(Reference< XInterface > *)xColumns->getByName(sId).getValue(), UNO_QUERY);
     468           0 :         if (xColumn.is())
     469             :         {
     470           0 :             do
     471             :             {
     472           0 :                 if ((rName == xColumn->getString()) && !xColumn->wasNull())
     473             :                 {
     474           0 :                     Sequence<PropertyValue> aPropSequ(COLUMN_COUNT);
     475           0 :                     PropertyValue* pValues = aPropSequ.getArray();
     476           0 :                     BibConfig* pConfig = BibModul::GetConfig();
     477           0 :                     BibDBDescriptor aBibDesc = BibModul::GetConfig()->GetBibliographyURL();
     478           0 :                     const Mapping* pMapping = pConfig->GetMapping(aBibDesc);
     479           0 :                     for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
     480             :                     {
     481             :                         const OUString sColName = pConfig->GetDefColumnName(
     482           0 :                                                     nEntry);
     483           0 :                         pValues[nEntry].Name = sColName;
     484           0 :                         pValues[nEntry].Value <<= lcl_AddProperty(xColumns, pMapping, sColName);
     485           0 :                     }
     486           0 :                     aRet.setValue(&aPropSequ, ::getCppuType((Sequence<PropertyValue>*)0));
     487             : 
     488           0 :                     break;
     489             :                 }
     490             :             }
     491           0 :             while(xCursor->next());
     492           0 :         }
     493             :     }
     494           0 :     catch(const Exception&)
     495             :     {
     496             :         DBG_UNHANDLED_EXCEPTION();
     497             :     }
     498           0 :     return aRet;
     499             : }
     500             : 
     501           0 : Sequence< OUString > BibliographyLoader::getElementNames(void) throw ( RuntimeException, std::exception )
     502             : {
     503           0 :     Sequence< OUString > aRet(10);
     504           0 :     int nRealNameCount = 0;
     505             :     try
     506             :     {
     507           0 :         Reference< XResultSet >  xCursor(GetDataCursor());
     508           0 :         Reference< sdb::XColumn >  xIdColumn(GetIdentifierColumn());
     509           0 :         if (xIdColumn.is()) // implies xCursor.is()
     510             :         {
     511           0 :             do
     512             :             {
     513           0 :                 OUString sTemp = xIdColumn->getString();
     514           0 :                 if (!sTemp.isEmpty() && !xIdColumn->wasNull())
     515             :                 {
     516           0 :                     int nLen = aRet.getLength();
     517           0 :                     if(nLen == nRealNameCount)
     518           0 :                         aRet.realloc(nLen + 10);
     519           0 :                     OUString* pArray = aRet.getArray();
     520           0 :                     pArray[nRealNameCount] = sTemp;
     521           0 :                     nRealNameCount++;
     522           0 :                 }
     523             :             }
     524           0 :             while (xCursor->next());
     525           0 :         }
     526             :     }
     527           0 :     catch(const Exception&)
     528             :     {
     529             :         DBG_UNHANDLED_EXCEPTION();
     530             :     }
     531             : 
     532           0 :     aRet.realloc(nRealNameCount);
     533           0 :     return aRet;
     534             : }
     535             : 
     536           0 : sal_Bool BibliographyLoader::hasByName(const OUString& rName) throw ( RuntimeException, std::exception )
     537             : {
     538           0 :     bool bRet = false;
     539             :     try
     540             :     {
     541           0 :         Reference< XResultSet >  xCursor = GetDataCursor();
     542           0 :         Reference< sdb::XColumn >  xIdColumn = GetIdentifierColumn();
     543             : 
     544           0 :         if (xIdColumn.is())     // implies xCursor.is()
     545             :         {
     546           0 :             do
     547             :             {
     548           0 :                 OUString sCurrentId = xIdColumn->getString();
     549           0 :                 if (!xIdColumn->wasNull() && rName.startsWith(sCurrentId))
     550             :                 {
     551           0 :                     bRet = true;
     552           0 :                     break;
     553           0 :                 }
     554             :             }
     555           0 :             while(xCursor->next());
     556           0 :         }
     557             :     }
     558           0 :     catch(const Exception&)
     559             :     {
     560             :         DBG_UNHANDLED_EXCEPTION();
     561             :     }
     562           0 :     return bRet;
     563             : }
     564             : 
     565           0 : Type  BibliographyLoader::getElementType(void) throw ( RuntimeException, std::exception )
     566             : {
     567           0 :     return ::getCppuType((Sequence<PropertyValue>*)0);
     568             : }
     569             : 
     570           0 : sal_Bool BibliographyLoader::hasElements(void) throw ( RuntimeException, std::exception )
     571             : {
     572           0 :     Reference< XResultSet >  xCursor = GetDataCursor();
     573           0 :     Reference< XNameAccess >  xColumns = GetDataColumns();
     574           0 :     return xColumns.is() && (xColumns->getElementNames().getLength() != 0);
     575             : }
     576             : 
     577           0 : Reference< XPropertySetInfo >  BibliographyLoader::getPropertySetInfo(void) throw
     578             :                                             ( RuntimeException, std::exception )
     579             : {
     580             :     static const SfxItemPropertyMapEntry aBibProps_Impl[] =
     581             :     {
     582           0 :         { OUString("BibliographyDataFieldNames"), 0, ::getCppuType((Sequence<PropertyValue>*)0), PropertyAttribute::READONLY, 0},
     583             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     584           0 :     };
     585             :     static Reference< XPropertySetInfo >  xRet =
     586           0 :         SfxItemPropertySet(aBibProps_Impl).getPropertySetInfo();
     587           0 :     return xRet;
     588             : }
     589             : 
     590           0 : void BibliographyLoader::setPropertyValue(const OUString& /*PropertyName*/,
     591             :                                         const Any& /*aValue*/)
     592             :     throw( UnknownPropertyException, PropertyVetoException,
     593             :         IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
     594             : {
     595           0 :     throw UnknownPropertyException();
     596             :     //no changeable properties
     597             : }
     598             : 
     599           0 : Any BibliographyLoader::getPropertyValue(const OUString& rPropertyName)
     600             :     throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
     601             : {
     602           0 :     Any aRet;
     603             :     static const sal_uInt16 aInternalMapping[] =
     604             :     {
     605             :         IDENTIFIER_POS             , // BibliographyDataField_IDENTIFIER
     606             :         AUTHORITYTYPE_POS          , // BibliographyDataField_BIBILIOGRAPHIC_TYPE
     607             :         ADDRESS_POS                , // BibliographyDataField_ADDRESS
     608             :         ANNOTE_POS                 , // BibliographyDataField_ANNOTE
     609             :         AUTHOR_POS                 , // BibliographyDataField_AUTHOR
     610             :         BOOKTITLE_POS              , // BibliographyDataField_BOOKTITLE
     611             :         CHAPTER_POS                , // BibliographyDataField_CHAPTER
     612             :         EDITION_POS                , // BibliographyDataField_EDITION
     613             :         EDITOR_POS                 , // BibliographyDataField_EDITOR
     614             :         HOWPUBLISHED_POS           , // BibliographyDataField_HOWPUBLISHED
     615             :         INSTITUTION_POS            , // BibliographyDataField_INSTITUTION
     616             :         JOURNAL_POS                , // BibliographyDataField_JOURNAL
     617             :         MONTH_POS                  , // BibliographyDataField_MONTH
     618             :         NOTE_POS                   , // BibliographyDataField_NOTE
     619             :         NUMBER_POS                 , // BibliographyDataField_NUMBER
     620             :         ORGANIZATIONS_POS          , // BibliographyDataField_ORGANIZATIONS
     621             :         PAGES_POS                  , // BibliographyDataField_PAGES
     622             :         PUBLISHER_POS              , // BibliographyDataField_PUBLISHER
     623             :         SCHOOL_POS                 , // BibliographyDataField_SCHOOL
     624             :         SERIES_POS                 , // BibliographyDataField_SERIES
     625             :         TITLE_POS                  , // BibliographyDataField_TITLE
     626             :         REPORTTYPE_POS             , // BibliographyDataField_REPORT_TYPE
     627             :         VOLUME_POS                 , // BibliographyDataField_VOLUME
     628             :         YEAR_POS                   , // BibliographyDataField_YEAR
     629             :         URL_POS                    , // BibliographyDataField_URL
     630             :         CUSTOM1_POS                , // BibliographyDataField_CUSTOM1
     631             :         CUSTOM2_POS                , // BibliographyDataField_CUSTOM2
     632             :         CUSTOM3_POS                , // BibliographyDataField_CUSTOM3
     633             :         CUSTOM4_POS                , // BibliographyDataField_CUSTOM4
     634             :         CUSTOM5_POS                , // BibliographyDataField_CUSTOM5
     635             :         ISBN_POS                    //BibliographyDataField_ISBN
     636             :     };
     637           0 :     if(rPropertyName == "BibliographyDataFieldNames")
     638             :     {
     639           0 :         Sequence<PropertyValue> aSeq(COLUMN_COUNT);
     640           0 :         PropertyValue* pArray = aSeq.getArray();
     641           0 :         BibConfig* pConfig = BibModul::GetConfig();
     642           0 :         for(sal_uInt16 i = 0; i <= text::BibliographyDataField::ISBN ; i++)
     643             :         {
     644           0 :             pArray[i].Name = pConfig->GetDefColumnName(aInternalMapping[i]);
     645           0 :             pArray[i].Value <<= (sal_Int16) i;
     646             :         }
     647           0 :         aRet.setValue(&aSeq, ::getCppuType((Sequence<PropertyValue>*)0));
     648             :     }
     649             :     else
     650           0 :         throw UnknownPropertyException();
     651           0 :     return aRet;
     652             : }
     653             : 
     654           0 : void BibliographyLoader::addPropertyChangeListener(
     655             :         const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
     656             :         throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
     657             : {
     658             :     //no bound properties
     659           0 : }
     660             : 
     661           0 : void BibliographyLoader::removePropertyChangeListener(
     662             :         const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
     663             :         throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
     664             : {
     665             :     //no bound properties
     666           0 : }
     667             : 
     668           0 : void BibliographyLoader::addVetoableChangeListener(
     669             :     const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
     670             :     throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
     671             : {
     672             :     //no vetoable properties
     673           0 : }
     674             : 
     675           0 : void BibliographyLoader::removeVetoableChangeListener(
     676             :     const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
     677             :     throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
     678             : {
     679             :     //no vetoable properties
     680          12 : }
     681             : 
     682             : 
     683             : 
     684             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10