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