Update ooo320-m1
[ooovba.git] / extensions / source / bibliography / bibload.cxx
blob7c611b350add0f9f02d28e133da2ba9ab7340a8d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bibload.cxx,v $
10 * $Revision: 1.25 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
35 #include <osl/mutex.hxx>
36 #include <tools/urlobj.hxx>
37 #include <tools/diagnose_ex.h>
38 #include <cppuhelper/weak.hxx>
39 #include <svtools/itemprop.hxx>
40 #include <uno/environment.h>
41 #include <svtools/urihelper.hxx>
42 #ifndef _TOOLKIT_UNOHLP_HXX
43 #include <toolkit/helper/vclunohelper.hxx>
44 #endif
45 #include <comphelper/processfactory.hxx>
46 #include <cppuhelper/factory.hxx> // helper for factories
47 #include <com/sun/star/sdbc/ResultSetType.hpp>
48 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
49 #include <com/sun/star/sdb/XColumn.hpp>
50 #include <com/sun/star/util/XURLTransformer.hpp>
51 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
52 #include <com/sun/star/sdbc/XRowSet.hpp>
53 #include <com/sun/star/sdb/CommandType.hpp>
54 #include <com/sun/star/frame/XFrameLoader.hpp>
55 #include <com/sun/star/lang/XServiceInfo.hpp>
56 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
57 #include <com/sun/star/beans/PropertyAttribute.hpp>
58 #include <com/sun/star/beans/XPropertySet.hpp>
59 #include <com/sun/star/container/XNameAccess.hpp>
60 #include <com/sun/star/text/BibliographyDataField.hpp>
61 #include <com/sun/star/form/XLoadListener.hpp>
62 #include <com/sun/star/frame/XLayoutManager.hpp>
63 #include <toolkit/awt/vclxwindow.hxx>
64 #include <vcl/window.hxx>
65 #include <vcl/edit.hxx>
66 #include <vcl/svapp.hxx>
67 #include <vcl/group.hxx>
68 #include <svtools/svmedit.hxx>
70 #include "bibresid.hxx"
71 #ifndef BIB_HRC
72 #include "bib.hrc"
73 #endif
74 #include "bibcont.hxx"
75 #include "bibbeam.hxx"
76 #include "bibmod.hxx"
77 #include "bibview.hxx"
78 #include "framectr.hxx"
79 #include "datman.hxx"
80 #include <bibconfig.hxx>
81 #include <cppuhelper/implbase4.hxx> // helper for implementations
83 using namespace ::rtl;
84 using namespace ::com::sun::star;
85 using namespace ::com::sun::star::uno;
86 using namespace ::com::sun::star::beans;
87 using namespace ::com::sun::star::lang;
88 using namespace ::com::sun::star::sdb;
89 using namespace ::com::sun::star::sdbc;
90 using namespace ::com::sun::star::form;
91 using namespace ::com::sun::star::container;
92 using namespace ::com::sun::star::frame;
94 #define C2U(cChar) OUString::createFromAscii(cChar)
97 //-----------------------------------------------------------------------------
99 #define PROPERTY_FRAME 1
101 class BibliographyLoader : public cppu::WeakImplHelper4
102 < XServiceInfo, XNameAccess, XPropertySet, XFrameLoader >
104 HdlBibModul m_pBibMod;
105 Reference< XLoadable > m_xDatMan;
106 BibDataManager* m_pDatMan;
107 Reference< XNameAccess > m_xColumns;
108 Reference< XResultSet > m_xCursor;
110 private:
112 void loadView(const Reference< XFrame > & aFrame, const rtl::OUString& aURL,
113 const Sequence< PropertyValue >& aArgs,
114 const Reference< XLoadEventListener > & aListener);
116 BibDataManager* GetDataManager()const;
117 Reference< XNameAccess > GetDataColumns() const;
118 Reference< XResultSet > GetDataCursor() const;
119 Reference< sdb::XColumn > GetIdentifierColumn() const;
121 public:
122 BibliographyLoader();
123 ~BibliographyLoader();
125 // XServiceInfo
126 rtl::OUString SAL_CALL getImplementationName() throw( );
127 sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( );
128 Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( );
129 static rtl::OUString getImplementationName_Static() throw( )
133 return C2U("com.sun.star.extensions.Bibliography");
137 //XNameAccess
138 virtual Any SAL_CALL getByName(const rtl::OUString& aName) throw ( NoSuchElementException, WrappedTargetException, RuntimeException );
139 virtual Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw ( RuntimeException );
140 virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& aName) throw ( RuntimeException );
142 //XElementAccess
143 virtual Type SAL_CALL getElementType(void) throw ( RuntimeException );
144 virtual sal_Bool SAL_CALL hasElements(void) throw ( RuntimeException );
146 //XPropertySet
147 virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo(void) throw ( RuntimeException );
148 virtual void SAL_CALL setPropertyValue(const rtl::OUString& PropertyName, const Any& aValue) throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException );
149 virtual Any SAL_CALL getPropertyValue(const rtl::OUString& PropertyName) throw ( UnknownPropertyException, WrappedTargetException, RuntimeException );
150 virtual void SAL_CALL addPropertyChangeListener(const rtl::OUString& PropertyName, const Reference< XPropertyChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
151 virtual void SAL_CALL removePropertyChangeListener(const rtl::OUString& PropertyName, const Reference< XPropertyChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
152 virtual void SAL_CALL addVetoableChangeListener(const rtl::OUString& PropertyName, const Reference< XVetoableChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
153 virtual void SAL_CALL removeVetoableChangeListener(const rtl::OUString& PropertyName, const Reference< XVetoableChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
155 static Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames_Static(void) throw( );
157 friend Reference< XInterface > SAL_CALL BibliographyLoader_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception );
159 // XLoader
160 virtual void SAL_CALL load(const Reference< XFrame > & aFrame, const rtl::OUString& aURL,
161 const Sequence< PropertyValue >& aArgs,
162 const Reference< XLoadEventListener > & aListener) throw (::com::sun::star::uno::RuntimeException);
163 virtual void SAL_CALL cancel(void) throw (::com::sun::star::uno::RuntimeException);
166 BibliographyLoader::BibliographyLoader() :
167 m_pBibMod(0),
168 m_pDatMan(0)
172 BibliographyLoader::~BibliographyLoader()
174 Reference< lang::XComponent > xComp(m_xCursor, UNO_QUERY);
175 if (xComp.is())
176 xComp->dispose();
177 if(m_pBibMod)
178 CloseBibModul(m_pBibMod);
182 Reference< XInterface > SAL_CALL BibliographyLoader_CreateInstance( const Reference< XMultiServiceFactory > & /*rSMgr*/ ) throw( Exception )
184 return *(new BibliographyLoader);
188 // XServiceInfo
189 rtl::OUString BibliographyLoader::getImplementationName() throw( )
192 return getImplementationName_Static();
195 // XServiceInfo
196 sal_Bool BibliographyLoader::supportsService(const rtl::OUString& ServiceName) throw( )
198 Sequence< rtl::OUString > aSNL = getSupportedServiceNames();
199 const rtl::OUString * pArray = aSNL.getConstArray();
200 for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
201 if( pArray[i] == ServiceName )
202 return sal_True;
203 return sal_False;
206 // XServiceInfo
207 Sequence< rtl::OUString > BibliographyLoader::getSupportedServiceNames(void) throw( )
209 return getSupportedServiceNames_Static();
212 // ORegistryServiceManager_Static
213 Sequence< rtl::OUString > BibliographyLoader::getSupportedServiceNames_Static(void) throw( )
215 Sequence< rtl::OUString > aSNS( 2 );
216 aSNS.getArray()[0] = C2U("com.sun.star.frame.FrameLoader");
218 aSNS.getArray()[1] = C2U("com.sun.star.frame.Bibliography");
220 return aSNS;
223 extern "C"
225 void SAL_CALL component_getImplementationEnvironment(
226 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
228 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
231 sal_Bool SAL_CALL component_writeInfo( void * //pServiceManager
232 , registry::XRegistryKey * pRegistryKey )
236 rtl::OUString sKey = rtl::OUString::createFromAscii("/");
237 sKey += BibliographyLoader::getImplementationName_Static();
238 //creates the impl key: /com.sun.star.extensions.Bibliography
239 Reference< registry::XRegistryKey > xImplKey = pRegistryKey->createKey(sKey);
242 //sKey += rtl::OUString::createFromAscii("/UNO/SERVICES");
243 Reference< registry::XRegistryKey > xNewKey = xImplKey->createKey( C2U("/UNO/SERVICES") );
244 Sequence< rtl::OUString > aServices = BibliographyLoader::getSupportedServiceNames_Static();
245 for( INT32 i = 0; i < aServices.getLength(); i++ )
246 xNewKey->createKey( aServices.getConstArray()[i]);
247 xNewKey = xImplKey->createKey( C2U("/UNO/Loader"));
249 Reference< registry::XRegistryKey > xPatternKey = xImplKey->createKey( C2U("/Loader/Pattern" ));
250 xPatternKey->setAsciiValue( C2U( ".component:Bibliography/*" ) );
252 return sal_True;
254 catch (Exception &)
256 return sal_False;
261 void * SAL_CALL component_getFactory(
262 const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, void * /*pRegistryKey*/ )
264 void * pRet = 0;
265 if (!BibliographyLoader::getImplementationName_Static().compareToAscii( pImplName ) )
267 // create the factory
268 Reference< XSingleServiceFactory > xFactory =
269 cppu::createSingleFactory(
270 pServiceManager,
271 BibliographyLoader::getImplementationName_Static(),
272 BibliographyLoader_CreateInstance,
273 BibliographyLoader::getSupportedServiceNames_Static() );
274 // acquire, because we return an interface pointer instead of a reference
275 xFactory->acquire();
276 pRet = xFactory.get();
278 return pRet;
282 // -----------------------------------------------------------------------
283 void BibliographyLoader::cancel(void) throw (::com::sun::star::uno::RuntimeException)
289 // -----------------------------------------------------------------------
290 void BibliographyLoader::load(const Reference< XFrame > & rFrame, const rtl::OUString& rURL,
291 const Sequence< PropertyValue >& rArgs,
292 const Reference< XLoadEventListener > & rListener) throw (::com::sun::star::uno::RuntimeException)
296 vos::OGuard aGuard(Application::GetSolarMutex());
297 m_pBibMod = OpenBibModul();
299 String aURLStr( rURL );
300 String aPartName = aURLStr.GetToken( 1, '/' );
301 Reference<XPropertySet> xPrSet(rFrame, UNO_QUERY);
302 if(xPrSet.is())
304 Any aTitle;
305 aTitle <<= OUString(String(BibResId(RID_BIB_STR_FRAME_TITLE)));
306 xPrSet->setPropertyValue(C2U("Title"), aTitle);
308 if(aPartName.EqualsAscii("View") || aPartName.EqualsAscii("View1"))
310 loadView(rFrame, rURL, rArgs, rListener);
314 // -----------------------------------------------------------------------
315 void BibliographyLoader::loadView(const Reference< XFrame > & rFrame, const rtl::OUString& /*rURL*/,
316 const Sequence< PropertyValue >& /*rArgs*/,
317 const Reference< XLoadEventListener > & rListener)
319 vos::OGuard aGuard(Application::GetSolarMutex());
321 if(!m_pBibMod)
322 m_pBibMod = OpenBibModul();
325 //create the menu
326 ResMgr* pResMgr = (*m_pBibMod)->GetResMgr();
327 INetURLObject aEntry( URIHelper::SmartRelToAbs(pResMgr->GetFileName()) );
328 String aMenuRes( RTL_CONSTASCII_USTRINGPARAM( "private:resource/" ));
329 aMenuRes += ( aEntry.GetName() += '/' );
330 aMenuRes+=String::CreateFromInt32(RID_MAIN_MENU);
332 util::URL aURL;
333 aURL.Complete = aMenuRes;
335 Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
336 Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY );
337 if( xTrans.is() )
339 // Datei laden
340 xTrans->parseStrict( aURL );
342 Reference< XDispatchProvider > xProv( rFrame, UNO_QUERY );
343 if ( xProv.is() )
345 Reference< XDispatch > aDisp = xProv->queryDispatch( aURL, C2U("_menubar"), 12 );
346 if ( aDisp.is() )
347 aDisp->dispatch( aURL, Sequence<PropertyValue>() );
351 m_pDatMan = (*m_pBibMod)->createDataManager();
352 m_xDatMan = m_pDatMan;
353 BibDBDescriptor aBibDesc = BibModul::GetConfig()->GetBibliographyURL();
355 if(!aBibDesc.sDataSource.getLength())
357 DBChangeDialogConfig_Impl aConfig;
358 const Sequence<OUString> aSources = aConfig.GetDataSourceNames();
359 if(aSources.getLength())
360 aBibDesc.sDataSource = aSources.getConstArray()[0];
363 Reference< XForm > xForm = m_pDatMan->createDatabaseForm( aBibDesc );
365 Reference< awt::XWindow > aWindow = rFrame->getContainerWindow();
366 VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(aWindow);
368 Window* pParent = VCLUnoHelper::GetWindow( aWindow );
370 BibBookContainer *pMyWindow = new BibBookContainer( pParent, m_pDatMan );
371 pMyWindow->Show();
373 ::bib::BibView* pView = new ::bib::BibView( pMyWindow, m_pDatMan, WB_SECTION_STYLE | WB_3DLOOK );
374 pView->Show();
375 m_pDatMan->SetView( pView );
377 ::bib::BibBeamer* pBeamer = new ::bib::BibBeamer( pMyWindow, m_pDatMan );
378 pBeamer->Show();
379 pMyWindow->createTopFrame(pBeamer);
381 pMyWindow->createBottomFrame(pView);
383 Reference< awt::XWindow > xWin ( pMyWindow->GetComponentInterface(), UNO_QUERY );
385 Reference< XController > xCtrRef( new BibFrameController_Impl( xWin, m_pDatMan ) );
387 xCtrRef->attachFrame(rFrame);
388 rFrame->setComponent( xWin, xCtrRef);
389 pBeamer->SetXController(xCtrRef);
392 // not earlier because SetFocus() is triggered in setVisible()
393 pParentComponent->setVisible(sal_True);
395 m_xDatMan->load();
396 // #100312# ----------
397 m_pDatMan->RegisterInterceptor(pBeamer);
399 if ( rListener.is() )
400 rListener->loadFinished( this );
402 // attach menu bar
403 Reference< XPropertySet > xPropSet( rFrame, UNO_QUERY );
404 Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
405 if ( xPropSet.is() )
409 Any a = xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
410 a >>= xLayoutManager;
412 catch ( uno::Exception& )
417 if ( xLayoutManager.is() )
418 xLayoutManager->createElement( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" )));
420 /* -----------------06.12.99 14:37-------------------
422 --------------------------------------------------*/
423 BibDataManager* BibliographyLoader::GetDataManager()const
425 if(!m_pDatMan)
427 if(!m_pBibMod)
428 const_cast< BibliographyLoader* >( this )->m_pBibMod = OpenBibModul();
429 const_cast< BibliographyLoader* >( this )->m_pDatMan = (*m_pBibMod)->createDataManager();
430 const_cast< BibliographyLoader* >( this )->m_xDatMan = m_pDatMan;
432 return m_pDatMan;
434 /* -----------------06.12.99 14:39-------------------
436 --------------------------------------------------*/
437 Reference< XNameAccess > BibliographyLoader::GetDataColumns() const
439 if (!m_xColumns.is())
441 Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
442 Reference< XRowSet > xRowSet(xMgr->createInstance(C2U("com.sun.star.sdb.RowSet")), UNO_QUERY);
443 Reference< XPropertySet > xResultSetProps(xRowSet, UNO_QUERY);
444 DBG_ASSERT(xResultSetProps.is() , "BibliographyLoader::GetDataCursor : invalid row set (no XResultSet or no XPropertySet) !");
446 BibDBDescriptor aBibDesc = BibModul::GetConfig()->GetBibliographyURL();
448 Any aBibUrlAny; aBibUrlAny <<= aBibDesc.sDataSource;
449 xResultSetProps->setPropertyValue(C2U("DataSourceName"), aBibUrlAny);
450 Any aCommandType; aCommandType <<= aBibDesc.nCommandType;
451 xResultSetProps->setPropertyValue(C2U("CommandType"), aCommandType);
452 Any aTableName; aTableName <<= aBibDesc.sTableOrQuery;
453 xResultSetProps->setPropertyValue(C2U("Command"), aTableName);
454 Any aResultSetType; aResultSetType <<= (sal_Int32)(ResultSetType::SCROLL_INSENSITIVE);
455 xResultSetProps->setPropertyValue(C2U("ResultSetType"), aResultSetType);
456 Any aResultSetCurrency; aResultSetCurrency <<= (sal_Int32)(ResultSetConcurrency::UPDATABLE);
457 xResultSetProps->setPropertyValue(C2U("ResultSetConcurrency"), aResultSetCurrency);
459 sal_Bool bSuccess = sal_False;
462 xRowSet->execute();
463 bSuccess = sal_True;
465 catch(const SQLException&)
467 DBG_UNHANDLED_EXCEPTION();
469 catch(const Exception& )
471 DBG_UNHANDLED_EXCEPTION();
472 bSuccess = sal_False;
475 if (!bSuccess)
477 Reference< XComponent > xSetComp(xRowSet, UNO_QUERY);
478 if (xSetComp.is())
479 xSetComp->dispose();
480 xRowSet = NULL;
482 else
483 ((BibliographyLoader*)this)->m_xCursor = xRowSet.get();
485 Reference< sdbcx::XColumnsSupplier > xSupplyCols(m_xCursor, UNO_QUERY);
486 if (xSupplyCols.is())
487 ((BibliographyLoader*)this)->m_xColumns = xSupplyCols->getColumns();
490 return m_xColumns;
492 /* -----------------17.12.99 12:29-------------------
494 --------------------------------------------------*/
495 Reference< sdb::XColumn > BibliographyLoader::GetIdentifierColumn() const
497 BibDataManager* pDatMan = GetDataManager();
498 Reference< XNameAccess > xColumns = GetDataColumns();
499 rtl::OUString sIdentifierColumnName = pDatMan->GetIdentifierMapping();
501 Reference< sdb::XColumn > xReturn;
502 if (xColumns.is() && xColumns->hasByName(sIdentifierColumnName))
504 xReturn = Reference< XColumn > (*(Reference< XInterface > *)
505 xColumns->getByName(sIdentifierColumnName).getValue(), UNO_QUERY);
507 return xReturn;
510 /* -----------------06.12.99 15:05-------------------
512 --------------------------------------------------*/
513 Reference< XResultSet > BibliographyLoader::GetDataCursor() const
515 if (!m_xCursor.is())
516 GetDataColumns();
517 if (m_xCursor.is())
518 m_xCursor->first();
519 return m_xCursor;
522 /*-- 17.11.99 12:51:38---------------------------------------------------
524 -----------------------------------------------------------------------*/
525 rtl::OUString lcl_AddProperty(Reference< XNameAccess > xColumns,
526 const Mapping* pMapping, const String& rColumnName)
528 String sColumnName(rColumnName);
529 if(pMapping)
531 for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
533 if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == OUString(rColumnName))
535 sColumnName = pMapping->aColumnPairs[nEntry].sRealColumnName;
536 break;
540 rtl::OUString uColumnName(sColumnName);
541 rtl::OUString uRet;
542 Reference< sdb::XColumn > xCol;
543 if (xColumns->hasByName(uColumnName))
544 xCol = Reference< sdb::XColumn > (*(Reference< XInterface > *)xColumns->getByName(uColumnName).getValue(), UNO_QUERY);
545 if (xCol.is())
546 uRet = xCol->getString();
547 return uRet;
549 //-----------------------------------------------------------------------------
550 Any BibliographyLoader::getByName(const rtl::OUString& rName) throw
551 ( NoSuchElementException, WrappedTargetException, RuntimeException )
553 Any aRet;
556 BibDataManager* pDatMan = ((BibliographyLoader*)this)->GetDataManager();
557 Reference< XResultSet > xCursor = GetDataCursor();
558 Reference< sdbcx::XColumnsSupplier > xSupplyCols(xCursor, UNO_QUERY);
559 Reference< XNameAccess > xColumns;
560 if (!xSupplyCols.is())
561 return aRet;
562 xColumns = xSupplyCols->getColumns();
563 DBG_ASSERT(xSupplyCols.is(), "BibliographyLoader::getByName : invalid columns returned by the data cursor (may be the result set is not alive ?) !");
564 if (!xColumns.is())
565 return aRet;
567 String sIdentifierMapping = pDatMan->GetIdentifierMapping();
568 rtl::OUString sId = sIdentifierMapping;
569 Reference< sdb::XColumn > xColumn;
570 if (xColumns->hasByName(sId))
571 xColumn = Reference< sdb::XColumn > (*(Reference< XInterface > *)xColumns->getByName(sId).getValue(), UNO_QUERY);
572 if (xColumn.is())
576 if ((rName == xColumn->getString()) && !xColumn->wasNull())
578 Sequence<PropertyValue> aPropSequ(COLUMN_COUNT);
579 PropertyValue* pValues = aPropSequ.getArray();
580 BibConfig* pConfig = BibModul::GetConfig();
581 BibDBDescriptor aBibDesc = BibModul::GetConfig()->GetBibliographyURL();
582 const Mapping* pMapping = pConfig->GetMapping(aBibDesc);
583 for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
585 const String sColName = pConfig->GetDefColumnName(
586 nEntry);
587 pValues[nEntry].Name = sColName;
588 pValues[nEntry].Value <<= lcl_AddProperty(xColumns, pMapping, sColName);
590 aRet.setValue(&aPropSequ, ::getCppuType((Sequence<PropertyValue>*)0));
592 break;
595 while(xCursor->next());
598 catch(const Exception&)
600 DBG_UNHANDLED_EXCEPTION();
602 return aRet;
604 /*-- 17.11.99 12:51:39---------------------------------------------------
606 -----------------------------------------------------------------------*/
607 Sequence< rtl::OUString > BibliographyLoader::getElementNames(void) throw ( RuntimeException )
609 Sequence< rtl::OUString > aRet(10);
610 int nRealNameCount = 0;
613 Reference< XResultSet > xCursor(GetDataCursor());
614 Reference< sdb::XColumn > xIdColumn(GetIdentifierColumn());
615 if (xIdColumn.is()) // implies xCursor.is()
619 rtl::OUString sTemp = xIdColumn->getString();
620 if (sTemp.getLength() && !xIdColumn->wasNull())
622 int nLen = aRet.getLength();
623 if(nLen == nRealNameCount)
624 aRet.realloc(nLen + 10);
625 rtl::OUString* pArray = aRet.getArray();
626 pArray[nRealNameCount] = sTemp;
627 nRealNameCount++;
630 while (xCursor->next());
633 catch(const Exception&)
635 DBG_UNHANDLED_EXCEPTION();
638 aRet.realloc(nRealNameCount);
639 return aRet;
641 /*-- 17.11.99 12:51:39---------------------------------------------------
643 -----------------------------------------------------------------------*/
644 sal_Bool BibliographyLoader::hasByName(const rtl::OUString& rName) throw ( RuntimeException )
646 sal_Bool bRet = sal_False;
649 Reference< XResultSet > xCursor = GetDataCursor();
650 Reference< sdb::XColumn > xIdColumn = GetIdentifierColumn();
652 if (xIdColumn.is()) // implies xCursor.is()
656 rtl::OUString sCurrentId = xIdColumn->getString();
657 if (!xIdColumn->wasNull() && (rName.compareTo(sCurrentId) == COMPARE_EQUAL))
659 bRet = sal_True;
660 break;
663 while(xCursor->next());
666 catch(const Exception&)
668 DBG_UNHANDLED_EXCEPTION();
670 return bRet;
672 /*-- 17.11.99 12:51:39---------------------------------------------------
674 -----------------------------------------------------------------------*/
675 Type BibliographyLoader::getElementType(void) throw ( RuntimeException )
677 return ::getCppuType((Sequence<PropertyValue>*)0);
679 /*-- 17.11.99 12:51:40---------------------------------------------------
681 -----------------------------------------------------------------------*/
682 sal_Bool BibliographyLoader::hasElements(void) throw ( RuntimeException )
684 Reference< XResultSet > xCursor = GetDataCursor();
685 Reference< XNameAccess > xColumns = GetDataColumns();
686 return xColumns.is() && (xColumns->getElementNames().getLength() != 0);
689 /*-- 07.12.99 14:28:39---------------------------------------------------
691 -----------------------------------------------------------------------*/
692 Reference< XPropertySetInfo > BibliographyLoader::getPropertySetInfo(void) throw
693 ( RuntimeException )
695 static SfxItemPropertyMapEntry aBibProps_Impl[] =
697 { MAP_CHAR_LEN("BibliographyDataFieldNames"), 0, &::getCppuType((Sequence<PropertyValue>*)0), PropertyAttribute::READONLY, 0},
698 {0,0,0,0,0,0}
700 static Reference< XPropertySetInfo > xRet =
701 SfxItemPropertySet(aBibProps_Impl).getPropertySetInfo();
702 return xRet;
704 /*-- 07.12.99 14:28:39---------------------------------------------------
706 -----------------------------------------------------------------------*/
707 void BibliographyLoader::setPropertyValue(const rtl::OUString& /*PropertyName*/,
708 const Any& /*aValue*/)
709 throw( UnknownPropertyException, PropertyVetoException,
710 IllegalArgumentException, WrappedTargetException, RuntimeException)
712 throw UnknownPropertyException();
713 //no changeable properties
715 /*-- 07.12.99 14:28:39---------------------------------------------------
717 -----------------------------------------------------------------------*/
718 Any BibliographyLoader::getPropertyValue(const rtl::OUString& rPropertyName)
719 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
721 Any aRet;
722 static const sal_uInt16 aInternalMapping[] =
724 IDENTIFIER_POS , // BibliographyDataField_IDENTIFIER
725 AUTHORITYTYPE_POS , // BibliographyDataField_BIBILIOGRAPHIC_TYPE
726 ADDRESS_POS , // BibliographyDataField_ADDRESS
727 ANNOTE_POS , // BibliographyDataField_ANNOTE
728 AUTHOR_POS , // BibliographyDataField_AUTHOR
729 BOOKTITLE_POS , // BibliographyDataField_BOOKTITLE
730 CHAPTER_POS , // BibliographyDataField_CHAPTER
731 EDITION_POS , // BibliographyDataField_EDITION
732 EDITOR_POS , // BibliographyDataField_EDITOR
733 HOWPUBLISHED_POS , // BibliographyDataField_HOWPUBLISHED
734 INSTITUTION_POS , // BibliographyDataField_INSTITUTION
735 JOURNAL_POS , // BibliographyDataField_JOURNAL
736 MONTH_POS , // BibliographyDataField_MONTH
737 NOTE_POS , // BibliographyDataField_NOTE
738 NUMBER_POS , // BibliographyDataField_NUMBER
739 ORGANIZATIONS_POS , // BibliographyDataField_ORGANIZATIONS
740 PAGES_POS , // BibliographyDataField_PAGES
741 PUBLISHER_POS , // BibliographyDataField_PUBLISHER
742 SCHOOL_POS , // BibliographyDataField_SCHOOL
743 SERIES_POS , // BibliographyDataField_SERIES
744 TITLE_POS , // BibliographyDataField_TITLE
745 REPORTTYPE_POS , // BibliographyDataField_REPORT_TYPE
746 VOLUME_POS , // BibliographyDataField_VOLUME
747 YEAR_POS , // BibliographyDataField_YEAR
748 URL_POS , // BibliographyDataField_URL
749 CUSTOM1_POS , // BibliographyDataField_CUSTOM1
750 CUSTOM2_POS , // BibliographyDataField_CUSTOM2
751 CUSTOM3_POS , // BibliographyDataField_CUSTOM3
752 CUSTOM4_POS , // BibliographyDataField_CUSTOM4
753 CUSTOM5_POS , // BibliographyDataField_CUSTOM5
754 ISBN_POS //BibliographyDataField_ISBN
756 if(C2U("BibliographyDataFieldNames") == rPropertyName)
758 Sequence<PropertyValue> aSeq(COLUMN_COUNT);
759 PropertyValue* pArray = aSeq.getArray();
760 BibConfig* pConfig = BibModul::GetConfig();
761 for(sal_uInt16 i = 0; i <= text::BibliographyDataField::ISBN ; i++)
763 pArray[i].Name = pConfig->GetDefColumnName(aInternalMapping[i]);
764 pArray[i].Value <<= (sal_Int16) i;
766 aRet.setValue(&aSeq, ::getCppuType((Sequence<PropertyValue>*)0));
768 else
769 throw UnknownPropertyException();
770 return aRet;
772 /*-- 07.12.99 14:28:40---------------------------------------------------
774 -----------------------------------------------------------------------*/
775 void BibliographyLoader::addPropertyChangeListener(
776 const rtl::OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
777 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
779 //no bound properties
781 /*-- 07.12.99 14:28:40---------------------------------------------------
783 -----------------------------------------------------------------------*/
784 void BibliographyLoader::removePropertyChangeListener(
785 const rtl::OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
786 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
788 //no bound properties
790 /*-- 07.12.99 14:28:40---------------------------------------------------
792 -----------------------------------------------------------------------*/
793 void BibliographyLoader::addVetoableChangeListener(
794 const rtl::OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
795 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
797 //no vetoable properties
799 /*-- 07.12.99 14:28:40---------------------------------------------------
801 -----------------------------------------------------------------------*/
802 void BibliographyLoader::removeVetoableChangeListener(
803 const rtl::OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
804 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
806 //no vetoable properties