1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
32 #include <osl/mutex.hxx>
33 #include <tools/urlobj.hxx>
34 #include <tools/diagnose_ex.h>
35 #include <cppuhelper/weak.hxx>
36 #include <svl/itemprop.hxx>
37 #include <uno/environment.h>
38 #include <svl/urihelper.hxx>
39 #ifndef _TOOLKIT_UNOHLP_HXX
40 #include <toolkit/helper/vclunohelper.hxx>
42 #include <comphelper/processfactory.hxx>
43 #include <cppuhelper/factory.hxx> // helper for factories
44 #include <com/sun/star/sdbc/ResultSetType.hpp>
45 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
46 #include <com/sun/star/sdb/XColumn.hpp>
47 #include <com/sun/star/util/XURLTransformer.hpp>
48 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
49 #include <com/sun/star/sdbc/XRowSet.hpp>
50 #include <com/sun/star/sdb/CommandType.hpp>
51 #include <com/sun/star/frame/XFrameLoader.hpp>
52 #include <com/sun/star/lang/XServiceInfo.hpp>
53 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
54 #include <com/sun/star/beans/PropertyAttribute.hpp>
55 #include <com/sun/star/beans/XPropertySet.hpp>
56 #include <com/sun/star/container/XNameAccess.hpp>
57 #include <com/sun/star/text/BibliographyDataField.hpp>
58 #include <com/sun/star/form/XLoadListener.hpp>
59 #include <com/sun/star/frame/XLayoutManager.hpp>
60 #include <toolkit/awt/vclxwindow.hxx>
61 #include <vcl/window.hxx>
62 #include <vcl/edit.hxx>
63 #include <vcl/svapp.hxx>
64 #include <vcl/group.hxx>
65 #include <svtools/svmedit.hxx>
67 #include "bibresid.hxx"
71 #include "bibcont.hxx"
72 #include "bibbeam.hxx"
74 #include "bibview.hxx"
75 #include "framectr.hxx"
77 #include <bibconfig.hxx>
78 #include <cppuhelper/implbase4.hxx> // helper for implementations
80 using namespace ::rtl
;
81 using namespace ::com::sun::star
;
82 using namespace ::com::sun::star::uno
;
83 using namespace ::com::sun::star::beans
;
84 using namespace ::com::sun::star::lang
;
85 using namespace ::com::sun::star::sdb
;
86 using namespace ::com::sun::star::sdbc
;
87 using namespace ::com::sun::star::form
;
88 using namespace ::com::sun::star::container
;
89 using namespace ::com::sun::star::frame
;
91 #define C2U(cChar) OUString::createFromAscii(cChar)
94 //-----------------------------------------------------------------------------
96 #define PROPERTY_FRAME 1
98 class BibliographyLoader
: public cppu::WeakImplHelper4
99 < XServiceInfo
, XNameAccess
, XPropertySet
, XFrameLoader
>
101 HdlBibModul m_pBibMod
;
102 Reference
< XLoadable
> m_xDatMan
;
103 BibDataManager
* m_pDatMan
;
104 Reference
< XNameAccess
> m_xColumns
;
105 Reference
< XResultSet
> m_xCursor
;
109 void loadView(const Reference
< XFrame
> & aFrame
, const rtl::OUString
& aURL
,
110 const Sequence
< PropertyValue
>& aArgs
,
111 const Reference
< XLoadEventListener
> & aListener
);
113 BibDataManager
* GetDataManager()const;
114 Reference
< XNameAccess
> GetDataColumns() const;
115 Reference
< XResultSet
> GetDataCursor() const;
116 Reference
< sdb::XColumn
> GetIdentifierColumn() const;
119 BibliographyLoader();
120 ~BibliographyLoader();
123 rtl::OUString SAL_CALL
getImplementationName() throw( );
124 sal_Bool SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( );
125 Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( );
126 static rtl::OUString
getImplementationName_Static() throw( )
130 return C2U("com.sun.star.extensions.Bibliography");
135 virtual Any SAL_CALL
getByName(const rtl::OUString
& aName
) throw ( NoSuchElementException
, WrappedTargetException
, RuntimeException
);
136 virtual Sequence
< rtl::OUString
> SAL_CALL
getElementNames(void) throw ( RuntimeException
);
137 virtual sal_Bool SAL_CALL
hasByName(const rtl::OUString
& aName
) throw ( RuntimeException
);
140 virtual Type SAL_CALL
getElementType(void) throw ( RuntimeException
);
141 virtual sal_Bool SAL_CALL
hasElements(void) throw ( RuntimeException
);
144 virtual Reference
< XPropertySetInfo
> SAL_CALL
getPropertySetInfo(void) throw ( RuntimeException
);
145 virtual void SAL_CALL
setPropertyValue(const rtl::OUString
& PropertyName
, const Any
& aValue
) throw( UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
);
146 virtual Any SAL_CALL
getPropertyValue(const rtl::OUString
& PropertyName
) throw ( UnknownPropertyException
, WrappedTargetException
, RuntimeException
);
147 virtual void SAL_CALL
addPropertyChangeListener(const rtl::OUString
& PropertyName
, const Reference
< XPropertyChangeListener
> & aListener
) throw( UnknownPropertyException
, WrappedTargetException
, RuntimeException
);
148 virtual void SAL_CALL
removePropertyChangeListener(const rtl::OUString
& PropertyName
, const Reference
< XPropertyChangeListener
> & aListener
) throw( UnknownPropertyException
, WrappedTargetException
, RuntimeException
);
149 virtual void SAL_CALL
addVetoableChangeListener(const rtl::OUString
& PropertyName
, const Reference
< XVetoableChangeListener
> & aListener
) throw( UnknownPropertyException
, WrappedTargetException
, RuntimeException
);
150 virtual void SAL_CALL
removeVetoableChangeListener(const rtl::OUString
& PropertyName
, const Reference
< XVetoableChangeListener
> & aListener
) throw( UnknownPropertyException
, WrappedTargetException
, RuntimeException
);
152 static Sequence
<rtl::OUString
> SAL_CALL
getSupportedServiceNames_Static(void) throw( );
154 friend Reference
< XInterface
> SAL_CALL
BibliographyLoader_CreateInstance( const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
);
157 virtual void SAL_CALL
load(const Reference
< XFrame
> & aFrame
, const rtl::OUString
& aURL
,
158 const Sequence
< PropertyValue
>& aArgs
,
159 const Reference
< XLoadEventListener
> & aListener
) throw (::com::sun::star::uno::RuntimeException
);
160 virtual void SAL_CALL
cancel(void) throw (::com::sun::star::uno::RuntimeException
);
163 BibliographyLoader::BibliographyLoader() :
169 BibliographyLoader::~BibliographyLoader()
171 Reference
< lang::XComponent
> xComp(m_xCursor
, UNO_QUERY
);
175 CloseBibModul(m_pBibMod
);
179 Reference
< XInterface
> SAL_CALL
BibliographyLoader_CreateInstance( const Reference
< XMultiServiceFactory
> & /*rSMgr*/ ) throw( Exception
)
181 return *(new BibliographyLoader
);
186 rtl::OUString
BibliographyLoader::getImplementationName() throw( )
189 return getImplementationName_Static();
193 sal_Bool
BibliographyLoader::supportsService(const rtl::OUString
& ServiceName
) throw( )
195 Sequence
< rtl::OUString
> aSNL
= getSupportedServiceNames();
196 const rtl::OUString
* pArray
= aSNL
.getConstArray();
197 for( sal_Int32 i
= 0; i
< aSNL
.getLength(); i
++ )
198 if( pArray
[i
] == ServiceName
)
204 Sequence
< rtl::OUString
> BibliographyLoader::getSupportedServiceNames(void) throw( )
206 return getSupportedServiceNames_Static();
209 // ORegistryServiceManager_Static
210 Sequence
< rtl::OUString
> BibliographyLoader::getSupportedServiceNames_Static(void) throw( )
212 Sequence
< rtl::OUString
> aSNS( 2 );
213 aSNS
.getArray()[0] = C2U("com.sun.star.frame.FrameLoader");
215 aSNS
.getArray()[1] = C2U("com.sun.star.frame.Bibliography");
222 void SAL_CALL
component_getImplementationEnvironment(
223 const sal_Char
** ppEnvTypeName
, uno_Environment
** /*ppEnv*/ )
225 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
228 void * SAL_CALL
component_getFactory(
229 const sal_Char
* pImplName
, XMultiServiceFactory
* pServiceManager
, void * /*pRegistryKey*/ )
232 if (!BibliographyLoader::getImplementationName_Static().compareToAscii( pImplName
) )
234 // create the factory
235 Reference
< XSingleServiceFactory
> xFactory
=
236 cppu::createSingleFactory(
238 BibliographyLoader::getImplementationName_Static(),
239 BibliographyLoader_CreateInstance
,
240 BibliographyLoader::getSupportedServiceNames_Static() );
241 // acquire, because we return an interface pointer instead of a reference
243 pRet
= xFactory
.get();
249 // -----------------------------------------------------------------------
250 void BibliographyLoader::cancel(void) throw (::com::sun::star::uno::RuntimeException
)
256 // -----------------------------------------------------------------------
257 void BibliographyLoader::load(const Reference
< XFrame
> & rFrame
, const rtl::OUString
& rURL
,
258 const Sequence
< PropertyValue
>& rArgs
,
259 const Reference
< XLoadEventListener
> & rListener
) throw (::com::sun::star::uno::RuntimeException
)
263 vos::OGuard
aGuard(Application::GetSolarMutex());
264 m_pBibMod
= OpenBibModul();
266 String
aURLStr( rURL
);
267 String aPartName
= aURLStr
.GetToken( 1, '/' );
268 Reference
<XPropertySet
> xPrSet(rFrame
, UNO_QUERY
);
272 aTitle
<<= OUString(String(BibResId(RID_BIB_STR_FRAME_TITLE
)));
273 xPrSet
->setPropertyValue(C2U("Title"), aTitle
);
275 if(aPartName
.EqualsAscii("View") || aPartName
.EqualsAscii("View1"))
277 loadView(rFrame
, rURL
, rArgs
, rListener
);
281 // -----------------------------------------------------------------------
282 void BibliographyLoader::loadView(const Reference
< XFrame
> & rFrame
, const rtl::OUString
& /*rURL*/,
283 const Sequence
< PropertyValue
>& /*rArgs*/,
284 const Reference
< XLoadEventListener
> & rListener
)
286 vos::OGuard
aGuard(Application::GetSolarMutex());
289 m_pBibMod
= OpenBibModul();
293 ResMgr* pResMgr = (*m_pBibMod)->GetResMgr();
294 INetURLObject aEntry( URIHelper::SmartRelToAbs(pResMgr->GetFileName()) );
295 String aMenuRes( RTL_CONSTASCII_USTRINGPARAM( "private:resource/" ));
296 aMenuRes += ( aEntry.GetName() += '/' );
297 aMenuRes+=String::CreateFromInt32(RID_MAIN_MENU);
300 aURL.Complete = aMenuRes;
302 Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
303 Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY );
307 xTrans->parseStrict( aURL );
309 Reference< XDispatchProvider > xProv( rFrame, UNO_QUERY );
312 Reference< XDispatch > aDisp = xProv->queryDispatch( aURL, C2U("_menubar"), 12 );
314 aDisp->dispatch( aURL, Sequence<PropertyValue>() );
318 m_pDatMan
= (*m_pBibMod
)->createDataManager();
319 m_xDatMan
= m_pDatMan
;
320 BibDBDescriptor aBibDesc
= BibModul::GetConfig()->GetBibliographyURL();
322 if(!aBibDesc
.sDataSource
.getLength())
324 DBChangeDialogConfig_Impl aConfig
;
325 const Sequence
<OUString
> aSources
= aConfig
.GetDataSourceNames();
326 if(aSources
.getLength())
327 aBibDesc
.sDataSource
= aSources
.getConstArray()[0];
330 Reference
< XForm
> xForm
= m_pDatMan
->createDatabaseForm( aBibDesc
);
332 Reference
< awt::XWindow
> aWindow
= rFrame
->getContainerWindow();
333 VCLXWindow
* pParentComponent
= VCLXWindow::GetImplementation(aWindow
);
335 Window
* pParent
= VCLUnoHelper::GetWindow( aWindow
);
337 BibBookContainer
*pMyWindow
= new BibBookContainer( pParent
, m_pDatMan
);
340 ::bib::BibView
* pView
= new ::bib::BibView( pMyWindow
, m_pDatMan
, WB_VSCROLL
| WB_HSCROLL
| WB_3DLOOK
);
342 m_pDatMan
->SetView( pView
);
344 ::bib::BibBeamer
* pBeamer
= new ::bib::BibBeamer( pMyWindow
, m_pDatMan
);
346 pMyWindow
->createTopFrame(pBeamer
);
348 pMyWindow
->createBottomFrame(pView
);
350 Reference
< awt::XWindow
> xWin ( pMyWindow
->GetComponentInterface(), UNO_QUERY
);
352 Reference
< XController
> xCtrRef( new BibFrameController_Impl( xWin
, m_pDatMan
) );
354 xCtrRef
->attachFrame(rFrame
);
355 rFrame
->setComponent( xWin
, xCtrRef
);
356 pBeamer
->SetXController(xCtrRef
);
359 // not earlier because SetFocus() is triggered in setVisible()
360 pParentComponent
->setVisible(sal_True
);
363 // #100312# ----------
364 m_pDatMan
->RegisterInterceptor(pBeamer
);
366 if ( rListener
.is() )
367 rListener
->loadFinished( this );
370 Reference
< XPropertySet
> xPropSet( rFrame
, UNO_QUERY
);
371 Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
376 Any a
= xPropSet
->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
377 a
>>= xLayoutManager
;
379 catch ( uno::Exception
& )
384 if ( xLayoutManager
.is() )
385 xLayoutManager
->createElement( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" )));
387 /* -----------------06.12.99 14:37-------------------
389 --------------------------------------------------*/
390 BibDataManager
* BibliographyLoader::GetDataManager()const
395 const_cast< BibliographyLoader
* >( this )->m_pBibMod
= OpenBibModul();
396 const_cast< BibliographyLoader
* >( this )->m_pDatMan
= (*m_pBibMod
)->createDataManager();
397 const_cast< BibliographyLoader
* >( this )->m_xDatMan
= m_pDatMan
;
401 /* -----------------06.12.99 14:39-------------------
403 --------------------------------------------------*/
404 Reference
< XNameAccess
> BibliographyLoader::GetDataColumns() const
406 if (!m_xColumns
.is())
408 Reference
< XMultiServiceFactory
> xMgr
= comphelper::getProcessServiceFactory();
409 Reference
< XRowSet
> xRowSet(xMgr
->createInstance(C2U("com.sun.star.sdb.RowSet")), UNO_QUERY
);
410 Reference
< XPropertySet
> xResultSetProps(xRowSet
, UNO_QUERY
);
411 DBG_ASSERT(xResultSetProps
.is() , "BibliographyLoader::GetDataCursor : invalid row set (no XResultSet or no XPropertySet) !");
413 BibDBDescriptor aBibDesc
= BibModul::GetConfig()->GetBibliographyURL();
415 Any aBibUrlAny
; aBibUrlAny
<<= aBibDesc
.sDataSource
;
416 xResultSetProps
->setPropertyValue(C2U("DataSourceName"), aBibUrlAny
);
417 Any aCommandType
; aCommandType
<<= aBibDesc
.nCommandType
;
418 xResultSetProps
->setPropertyValue(C2U("CommandType"), aCommandType
);
419 Any aTableName
; aTableName
<<= aBibDesc
.sTableOrQuery
;
420 xResultSetProps
->setPropertyValue(C2U("Command"), aTableName
);
421 Any aResultSetType
; aResultSetType
<<= (sal_Int32
)(ResultSetType::SCROLL_INSENSITIVE
);
422 xResultSetProps
->setPropertyValue(C2U("ResultSetType"), aResultSetType
);
423 Any aResultSetCurrency
; aResultSetCurrency
<<= (sal_Int32
)(ResultSetConcurrency::UPDATABLE
);
424 xResultSetProps
->setPropertyValue(C2U("ResultSetConcurrency"), aResultSetCurrency
);
426 sal_Bool bSuccess
= sal_False
;
432 catch(const SQLException
&)
434 DBG_UNHANDLED_EXCEPTION();
436 catch(const Exception
& )
438 DBG_UNHANDLED_EXCEPTION();
439 bSuccess
= sal_False
;
444 Reference
< XComponent
> xSetComp(xRowSet
, UNO_QUERY
);
450 ((BibliographyLoader
*)this)->m_xCursor
= xRowSet
.get();
452 Reference
< sdbcx::XColumnsSupplier
> xSupplyCols(m_xCursor
, UNO_QUERY
);
453 if (xSupplyCols
.is())
454 ((BibliographyLoader
*)this)->m_xColumns
= xSupplyCols
->getColumns();
459 /* -----------------17.12.99 12:29-------------------
461 --------------------------------------------------*/
462 Reference
< sdb::XColumn
> BibliographyLoader::GetIdentifierColumn() const
464 BibDataManager
* pDatMan
= GetDataManager();
465 Reference
< XNameAccess
> xColumns
= GetDataColumns();
466 rtl::OUString sIdentifierColumnName
= pDatMan
->GetIdentifierMapping();
468 Reference
< sdb::XColumn
> xReturn
;
469 if (xColumns
.is() && xColumns
->hasByName(sIdentifierColumnName
))
471 xReturn
= Reference
< XColumn
> (*(Reference
< XInterface
> *)
472 xColumns
->getByName(sIdentifierColumnName
).getValue(), UNO_QUERY
);
477 /* -----------------06.12.99 15:05-------------------
479 --------------------------------------------------*/
480 Reference
< XResultSet
> BibliographyLoader::GetDataCursor() const
489 /*-- 17.11.99 12:51:38---------------------------------------------------
491 -----------------------------------------------------------------------*/
492 rtl::OUString
lcl_AddProperty(Reference
< XNameAccess
> xColumns
,
493 const Mapping
* pMapping
, const String
& rColumnName
)
495 String
sColumnName(rColumnName
);
498 for(sal_uInt16 nEntry
= 0; nEntry
< COLUMN_COUNT
; nEntry
++)
500 if(pMapping
->aColumnPairs
[nEntry
].sLogicalColumnName
== OUString(rColumnName
))
502 sColumnName
= pMapping
->aColumnPairs
[nEntry
].sRealColumnName
;
507 rtl::OUString
uColumnName(sColumnName
);
509 Reference
< sdb::XColumn
> xCol
;
510 if (xColumns
->hasByName(uColumnName
))
511 xCol
= Reference
< sdb::XColumn
> (*(Reference
< XInterface
> *)xColumns
->getByName(uColumnName
).getValue(), UNO_QUERY
);
513 uRet
= xCol
->getString();
516 //-----------------------------------------------------------------------------
517 Any
BibliographyLoader::getByName(const rtl::OUString
& rName
) throw
518 ( NoSuchElementException
, WrappedTargetException
, RuntimeException
)
523 BibDataManager
* pDatMan
= ((BibliographyLoader
*)this)->GetDataManager();
524 Reference
< XResultSet
> xCursor
= GetDataCursor();
525 Reference
< sdbcx::XColumnsSupplier
> xSupplyCols(xCursor
, UNO_QUERY
);
526 Reference
< XNameAccess
> xColumns
;
527 if (!xSupplyCols
.is())
529 xColumns
= xSupplyCols
->getColumns();
530 DBG_ASSERT(xSupplyCols
.is(), "BibliographyLoader::getByName : invalid columns returned by the data cursor (may be the result set is not alive ?) !");
534 String sIdentifierMapping
= pDatMan
->GetIdentifierMapping();
535 rtl::OUString sId
= sIdentifierMapping
;
536 Reference
< sdb::XColumn
> xColumn
;
537 if (xColumns
->hasByName(sId
))
538 xColumn
= Reference
< sdb::XColumn
> (*(Reference
< XInterface
> *)xColumns
->getByName(sId
).getValue(), UNO_QUERY
);
543 if ((rName
== xColumn
->getString()) && !xColumn
->wasNull())
545 Sequence
<PropertyValue
> aPropSequ(COLUMN_COUNT
);
546 PropertyValue
* pValues
= aPropSequ
.getArray();
547 BibConfig
* pConfig
= BibModul::GetConfig();
548 BibDBDescriptor aBibDesc
= BibModul::GetConfig()->GetBibliographyURL();
549 const Mapping
* pMapping
= pConfig
->GetMapping(aBibDesc
);
550 for(sal_uInt16 nEntry
= 0; nEntry
< COLUMN_COUNT
; nEntry
++)
552 const String sColName
= pConfig
->GetDefColumnName(
554 pValues
[nEntry
].Name
= sColName
;
555 pValues
[nEntry
].Value
<<= lcl_AddProperty(xColumns
, pMapping
, sColName
);
557 aRet
.setValue(&aPropSequ
, ::getCppuType((Sequence
<PropertyValue
>*)0));
562 while(xCursor
->next());
565 catch(const Exception
&)
567 DBG_UNHANDLED_EXCEPTION();
571 /*-- 17.11.99 12:51:39---------------------------------------------------
573 -----------------------------------------------------------------------*/
574 Sequence
< rtl::OUString
> BibliographyLoader::getElementNames(void) throw ( RuntimeException
)
576 Sequence
< rtl::OUString
> aRet(10);
577 int nRealNameCount
= 0;
580 Reference
< XResultSet
> xCursor(GetDataCursor());
581 Reference
< sdb::XColumn
> xIdColumn(GetIdentifierColumn());
582 if (xIdColumn
.is()) // implies xCursor.is()
586 rtl::OUString sTemp
= xIdColumn
->getString();
587 if (sTemp
.getLength() && !xIdColumn
->wasNull())
589 int nLen
= aRet
.getLength();
590 if(nLen
== nRealNameCount
)
591 aRet
.realloc(nLen
+ 10);
592 rtl::OUString
* pArray
= aRet
.getArray();
593 pArray
[nRealNameCount
] = sTemp
;
597 while (xCursor
->next());
600 catch(const Exception
&)
602 DBG_UNHANDLED_EXCEPTION();
605 aRet
.realloc(nRealNameCount
);
608 /*-- 17.11.99 12:51:39---------------------------------------------------
610 -----------------------------------------------------------------------*/
611 sal_Bool
BibliographyLoader::hasByName(const rtl::OUString
& rName
) throw ( RuntimeException
)
613 sal_Bool bRet
= sal_False
;
616 Reference
< XResultSet
> xCursor
= GetDataCursor();
617 Reference
< sdb::XColumn
> xIdColumn
= GetIdentifierColumn();
619 if (xIdColumn
.is()) // implies xCursor.is()
623 rtl::OUString sCurrentId
= xIdColumn
->getString();
624 if (!xIdColumn
->wasNull() && (rName
.compareTo(sCurrentId
) == COMPARE_EQUAL
))
630 while(xCursor
->next());
633 catch(const Exception
&)
635 DBG_UNHANDLED_EXCEPTION();
639 /*-- 17.11.99 12:51:39---------------------------------------------------
641 -----------------------------------------------------------------------*/
642 Type
BibliographyLoader::getElementType(void) throw ( RuntimeException
)
644 return ::getCppuType((Sequence
<PropertyValue
>*)0);
646 /*-- 17.11.99 12:51:40---------------------------------------------------
648 -----------------------------------------------------------------------*/
649 sal_Bool
BibliographyLoader::hasElements(void) throw ( RuntimeException
)
651 Reference
< XResultSet
> xCursor
= GetDataCursor();
652 Reference
< XNameAccess
> xColumns
= GetDataColumns();
653 return xColumns
.is() && (xColumns
->getElementNames().getLength() != 0);
656 /*-- 07.12.99 14:28:39---------------------------------------------------
658 -----------------------------------------------------------------------*/
659 Reference
< XPropertySetInfo
> BibliographyLoader::getPropertySetInfo(void) throw
662 static SfxItemPropertyMapEntry aBibProps_Impl
[] =
664 { MAP_CHAR_LEN("BibliographyDataFieldNames"), 0, &::getCppuType((Sequence
<PropertyValue
>*)0), PropertyAttribute::READONLY
, 0},
667 static Reference
< XPropertySetInfo
> xRet
=
668 SfxItemPropertySet(aBibProps_Impl
).getPropertySetInfo();
671 /*-- 07.12.99 14:28:39---------------------------------------------------
673 -----------------------------------------------------------------------*/
674 void BibliographyLoader::setPropertyValue(const rtl::OUString
& /*PropertyName*/,
675 const Any
& /*aValue*/)
676 throw( UnknownPropertyException
, PropertyVetoException
,
677 IllegalArgumentException
, WrappedTargetException
, RuntimeException
)
679 throw UnknownPropertyException();
680 //no changeable properties
682 /*-- 07.12.99 14:28:39---------------------------------------------------
684 -----------------------------------------------------------------------*/
685 Any
BibliographyLoader::getPropertyValue(const rtl::OUString
& rPropertyName
)
686 throw( UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
689 static const sal_uInt16 aInternalMapping
[] =
691 IDENTIFIER_POS
, // BibliographyDataField_IDENTIFIER
692 AUTHORITYTYPE_POS
, // BibliographyDataField_BIBILIOGRAPHIC_TYPE
693 ADDRESS_POS
, // BibliographyDataField_ADDRESS
694 ANNOTE_POS
, // BibliographyDataField_ANNOTE
695 AUTHOR_POS
, // BibliographyDataField_AUTHOR
696 BOOKTITLE_POS
, // BibliographyDataField_BOOKTITLE
697 CHAPTER_POS
, // BibliographyDataField_CHAPTER
698 EDITION_POS
, // BibliographyDataField_EDITION
699 EDITOR_POS
, // BibliographyDataField_EDITOR
700 HOWPUBLISHED_POS
, // BibliographyDataField_HOWPUBLISHED
701 INSTITUTION_POS
, // BibliographyDataField_INSTITUTION
702 JOURNAL_POS
, // BibliographyDataField_JOURNAL
703 MONTH_POS
, // BibliographyDataField_MONTH
704 NOTE_POS
, // BibliographyDataField_NOTE
705 NUMBER_POS
, // BibliographyDataField_NUMBER
706 ORGANIZATIONS_POS
, // BibliographyDataField_ORGANIZATIONS
707 PAGES_POS
, // BibliographyDataField_PAGES
708 PUBLISHER_POS
, // BibliographyDataField_PUBLISHER
709 SCHOOL_POS
, // BibliographyDataField_SCHOOL
710 SERIES_POS
, // BibliographyDataField_SERIES
711 TITLE_POS
, // BibliographyDataField_TITLE
712 REPORTTYPE_POS
, // BibliographyDataField_REPORT_TYPE
713 VOLUME_POS
, // BibliographyDataField_VOLUME
714 YEAR_POS
, // BibliographyDataField_YEAR
715 URL_POS
, // BibliographyDataField_URL
716 CUSTOM1_POS
, // BibliographyDataField_CUSTOM1
717 CUSTOM2_POS
, // BibliographyDataField_CUSTOM2
718 CUSTOM3_POS
, // BibliographyDataField_CUSTOM3
719 CUSTOM4_POS
, // BibliographyDataField_CUSTOM4
720 CUSTOM5_POS
, // BibliographyDataField_CUSTOM5
721 ISBN_POS
//BibliographyDataField_ISBN
723 if(C2U("BibliographyDataFieldNames") == rPropertyName
)
725 Sequence
<PropertyValue
> aSeq(COLUMN_COUNT
);
726 PropertyValue
* pArray
= aSeq
.getArray();
727 BibConfig
* pConfig
= BibModul::GetConfig();
728 for(sal_uInt16 i
= 0; i
<= text::BibliographyDataField::ISBN
; i
++)
730 pArray
[i
].Name
= pConfig
->GetDefColumnName(aInternalMapping
[i
]);
731 pArray
[i
].Value
<<= (sal_Int16
) i
;
733 aRet
.setValue(&aSeq
, ::getCppuType((Sequence
<PropertyValue
>*)0));
736 throw UnknownPropertyException();
739 /*-- 07.12.99 14:28:40---------------------------------------------------
741 -----------------------------------------------------------------------*/
742 void BibliographyLoader::addPropertyChangeListener(
743 const rtl::OUString
& /*PropertyName*/, const Reference
< XPropertyChangeListener
> & /*aListener*/)
744 throw( UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
746 //no bound properties
748 /*-- 07.12.99 14:28:40---------------------------------------------------
750 -----------------------------------------------------------------------*/
751 void BibliographyLoader::removePropertyChangeListener(
752 const rtl::OUString
& /*PropertyName*/, const Reference
< XPropertyChangeListener
> & /*aListener*/)
753 throw( UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
755 //no bound properties
757 /*-- 07.12.99 14:28:40---------------------------------------------------
759 -----------------------------------------------------------------------*/
760 void BibliographyLoader::addVetoableChangeListener(
761 const rtl::OUString
& /*PropertyName*/, const Reference
< XVetoableChangeListener
> & /*aListener*/)
762 throw( UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
764 //no vetoable properties
766 /*-- 07.12.99 14:28:40---------------------------------------------------
768 -----------------------------------------------------------------------*/
769 void BibliographyLoader::removeVetoableChangeListener(
770 const rtl::OUString
& /*PropertyName*/, const Reference
< XVetoableChangeListener
> & /*aListener*/)
771 throw( UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
773 //no vetoable properties