basmgr.cxx (870262e3) | basmgr.cxx (c6948b83) |
---|---|
1/************************************************************** | 1/************************************************************** |
2 * | 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 | 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 * | 10 * |
11 * http://www.apache.org/licenses/LICENSE-2.0 | 11 * http://www.apache.org/licenses/LICENSE-2.0 |
12 * | 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. | 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 * | 19 * |
20 *************************************************************/ 21 22 23 24// MARKER(update_precomp.py): autogen include statement, do not remove 25#include "precompiled_basic.hxx" 26#include <tools/stream.hxx> 27#include <sot/storage.hxx> --- 138 unchanged lines hidden (view full) --- 166 167 static void insertLibraryImpl( const Reference< XLibraryContainer >& xScriptCont, BasicManager* pMgr, 168 Any aLibAny, ::rtl::OUString aLibName ); 169 static void addLibraryModulesImpl( BasicManager* pMgr, Reference< XNameAccess > xLibNameAccess, 170 ::rtl::OUString aLibName ); 171 172 173 // XEventListener | 20 *************************************************************/ 21 22 23 24// MARKER(update_precomp.py): autogen include statement, do not remove 25#include "precompiled_basic.hxx" 26#include <tools/stream.hxx> 27#include <sot/storage.hxx> --- 138 unchanged lines hidden (view full) --- 166 167 static void insertLibraryImpl( const Reference< XLibraryContainer >& xScriptCont, BasicManager* pMgr, 168 Any aLibAny, ::rtl::OUString aLibName ); 169 static void addLibraryModulesImpl( BasicManager* pMgr, Reference< XNameAccess > xLibNameAccess, 170 ::rtl::OUString aLibName ); 171 172 173 // XEventListener |
174 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) | 174 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) |
175 throw(::com::sun::star::uno::RuntimeException); 176 177 // XContainerListener 178 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) 179 throw(::com::sun::star::uno::RuntimeException); 180 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) 181 throw(::com::sun::star::uno::RuntimeException); 182 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) --- 8 unchanged lines hidden (view full) --- 191void BasMgrContainerListenerImpl::insertLibraryImpl( const Reference< XLibraryContainer >& xScriptCont, 192 BasicManager* pMgr, Any aLibAny, ::rtl::OUString aLibName ) 193{ 194 Reference< XNameAccess > xLibNameAccess; 195 aLibAny >>= xLibNameAccess; 196 197 if( !pMgr->GetLib( aLibName ) ) 198 { | 175 throw(::com::sun::star::uno::RuntimeException); 176 177 // XContainerListener 178 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) 179 throw(::com::sun::star::uno::RuntimeException); 180 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) 181 throw(::com::sun::star::uno::RuntimeException); 182 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) --- 8 unchanged lines hidden (view full) --- 191void BasMgrContainerListenerImpl::insertLibraryImpl( const Reference< XLibraryContainer >& xScriptCont, 192 BasicManager* pMgr, Any aLibAny, ::rtl::OUString aLibName ) 193{ 194 Reference< XNameAccess > xLibNameAccess; 195 aLibAny >>= xLibNameAccess; 196 197 if( !pMgr->GetLib( aLibName ) ) 198 { |
199 BasicManager* pBasMgr = static_cast< BasicManager* >( pMgr ); | 199 BasicManager* pBasMgr = static_cast< BasicManager* >( pMgr ); |
200#ifdef DBG_UTIL 201 StarBASIC* pLib = 202#endif 203 pBasMgr->CreateLibForLibContainer( aLibName, xScriptCont ); 204 DBG_ASSERT( pLib, "XML Import: Basic library could not be created"); 205 } 206 207 Reference< XContainer> xLibContainer( xLibNameAccess, UNO_QUERY ); --- 45 unchanged lines hidden (view full) --- 253 pLib->SetModified( sal_False ); 254} 255 256 257 258// XEventListener 259//---------------------------------------------------------------------------- 260 | 200#ifdef DBG_UTIL 201 StarBASIC* pLib = 202#endif 203 pBasMgr->CreateLibForLibContainer( aLibName, xScriptCont ); 204 DBG_ASSERT( pLib, "XML Import: Basic library could not be created"); 205 } 206 207 Reference< XContainer> xLibContainer( xLibNameAccess, UNO_QUERY ); --- 45 unchanged lines hidden (view full) --- 253 pLib->SetModified( sal_False ); 254} 255 256 257 258// XEventListener 259//---------------------------------------------------------------------------- 260 |
261void SAL_CALL BasMgrContainerListenerImpl::disposing( const EventObject& Source ) | 261void SAL_CALL BasMgrContainerListenerImpl::disposing( const EventObject& Source ) |
262 throw( RuntimeException ) 263{ | 262 throw( RuntimeException ) 263{ |
264 (void)Source; | 264 (void)Source; |
265} 266 267// XContainerListener 268//---------------------------------------------------------------------------- 269 270void SAL_CALL BasMgrContainerListenerImpl::elementInserted( const ContainerEvent& Event ) 271 throw( RuntimeException ) 272{ 273 sal_Bool bLibContainer = maLibName.isEmpty(); 274 ::rtl::OUString aName; 275 Event.Accessor >>= aName; 276 | 265} 266 267// XContainerListener 268//---------------------------------------------------------------------------- 269 270void SAL_CALL BasMgrContainerListenerImpl::elementInserted( const ContainerEvent& Event ) 271 throw( RuntimeException ) 272{ 273 sal_Bool bLibContainer = maLibName.isEmpty(); 274 ::rtl::OUString aName; 275 Event.Accessor >>= aName; 276 |
277 mpMgr->mpImpl->mbModifiedByLibraryContainer = sal_True; | 277 mpMgr->mpImpl->mbModifiedByLibraryContainer = sal_True; |
278 279 if( bLibContainer ) 280 { | 278 279 if( bLibContainer ) 280 { |
281 Reference< XLibraryContainer > xScriptCont( Event.Source, UNO_QUERY ); | 281 Reference< XLibraryContainer > xScriptCont( Event.Source, UNO_QUERY ); |
282 insertLibraryImpl( xScriptCont, mpMgr, Event.Element, aName ); 283 StarBASIC* pLib = mpMgr->GetLib( aName ); 284 if ( pLib ) 285 { 286 Reference< vba::XVBACompatibility > xVBACompat( xScriptCont, UNO_QUERY ); 287 if ( xVBACompat.is() ) 288 pLib->SetVBAEnabled( xVBACompat->getVBACompatibilityMode() ); 289 } --- 27 unchanged lines hidden (view full) --- 317//---------------------------------------------------------------------------- 318 319void SAL_CALL BasMgrContainerListenerImpl::elementReplaced( const ContainerEvent& Event ) 320 throw( RuntimeException ) 321{ 322 ::rtl::OUString aName; 323 Event.Accessor >>= aName; 324 | 282 insertLibraryImpl( xScriptCont, mpMgr, Event.Element, aName ); 283 StarBASIC* pLib = mpMgr->GetLib( aName ); 284 if ( pLib ) 285 { 286 Reference< vba::XVBACompatibility > xVBACompat( xScriptCont, UNO_QUERY ); 287 if ( xVBACompat.is() ) 288 pLib->SetVBAEnabled( xVBACompat->getVBACompatibilityMode() ); 289 } --- 27 unchanged lines hidden (view full) --- 317//---------------------------------------------------------------------------- 318 319void SAL_CALL BasMgrContainerListenerImpl::elementReplaced( const ContainerEvent& Event ) 320 throw( RuntimeException ) 321{ 322 ::rtl::OUString aName; 323 Event.Accessor >>= aName; 324 |
325 mpMgr->mpImpl->mbModifiedByLibraryContainer = sal_True; | 325 mpMgr->mpImpl->mbModifiedByLibraryContainer = sal_True; |
326 327 // Replace not possible for library container 328#ifdef DBG_UTIL 329 sal_Bool bLibContainer = maLibName.isEmpty(); 330#endif | 326 327 // Replace not possible for library container 328#ifdef DBG_UTIL 329 sal_Bool bLibContainer = maLibName.isEmpty(); 330#endif |
331 DBG_ASSERT( !bLibContainer, "library container fired elementReplaced()"); | 331 DBG_ASSERT( !bLibContainer, "library container fired elementReplaced()"); |
332 333 StarBASIC* pLib = mpMgr->GetLib( maLibName ); 334 if( pLib ) 335 { 336 SbModule* pMod = pLib->FindModule( aName ); 337 ::rtl::OUString aMod; | 332 333 StarBASIC* pLib = mpMgr->GetLib( maLibName ); 334 if( pLib ) 335 { 336 SbModule* pMod = pLib->FindModule( aName ); 337 ::rtl::OUString aMod; |
338 Event.Element >>= aMod; | 338 Event.Element >>= aMod; |
339 340 if( pMod ) | 339 340 if( pMod ) |
341 pMod->SetSource32( aMod ); | 341 pMod->SetSource32( aMod ); |
342 else 343 pLib->MakeModule32( aName, aMod ); | 342 else 343 pLib->MakeModule32( aName, aMod ); |
344 | 344 |
345 pLib->SetModified( sal_False ); 346 } 347} 348 349//---------------------------------------------------------------------------- 350 351void SAL_CALL BasMgrContainerListenerImpl::elementRemoved( const ContainerEvent& Event ) 352 throw( RuntimeException ) 353{ 354 ::rtl::OUString aName; 355 Event.Accessor >>= aName; 356 | 345 pLib->SetModified( sal_False ); 346 } 347} 348 349//---------------------------------------------------------------------------- 350 351void SAL_CALL BasMgrContainerListenerImpl::elementRemoved( const ContainerEvent& Event ) 352 throw( RuntimeException ) 353{ 354 ::rtl::OUString aName; 355 Event.Accessor >>= aName; 356 |
357 mpMgr->mpImpl->mbModifiedByLibraryContainer = sal_True; | 357 mpMgr->mpImpl->mbModifiedByLibraryContainer = sal_True; |
358 359 sal_Bool bLibContainer = maLibName.isEmpty(); 360 if( bLibContainer ) 361 { 362 StarBASIC* pLib = mpMgr->GetLib( aName ); 363 if( pLib ) 364 { 365 sal_uInt16 nLibId = mpMgr->GetLibId( aName ); --- 84 unchanged lines hidden (view full) --- 450 String aRelStorageName; 451 String aPassword; 452 453 sal_Bool bDoLoad; 454 sal_Bool bReference; 455 sal_Bool bPasswordVerified; 456 sal_Bool bFoundInPath; // Must not relativated again! 457 | 358 359 sal_Bool bLibContainer = maLibName.isEmpty(); 360 if( bLibContainer ) 361 { 362 StarBASIC* pLib = mpMgr->GetLib( aName ); 363 if( pLib ) 364 { 365 sal_uInt16 nLibId = mpMgr->GetLibId( aName ); --- 84 unchanged lines hidden (view full) --- 450 String aRelStorageName; 451 String aPassword; 452 453 sal_Bool bDoLoad; 454 sal_Bool bReference; 455 sal_Bool bPasswordVerified; 456 sal_Bool bFoundInPath; // Must not relativated again! 457 |
458 // Lib represents library in new UNO library container 459 Reference< XLibraryContainer > mxScriptCont; | 458 // Lib represents library in new UNO library container 459 Reference< XLibraryContainer > mxScriptCont; |
460 461public: 462 BasicLibInfo(); 463 BasicLibInfo( const String& rStorageName ); 464 465 sal_Bool IsReference() const { return bReference; } 466 sal_Bool& IsReference() { return bReference; } 467 468 sal_Bool IsExtern() const { return ! aStorageName.EqualsAscii(szImbedded); } 469 470 void SetStorageName( const String& rName ) { aStorageName = rName; } 471 const String& GetStorageName() const { return aStorageName; } 472 473 void SetRelStorageName( const String& rN ) { aRelStorageName = rN; } 474 const String& GetRelStorageName() const { return aRelStorageName; } 475 void CalcRelStorageName( const String& rMgrStorageName ); 476 477 StarBASICRef GetLib() const | 460 461public: 462 BasicLibInfo(); 463 BasicLibInfo( const String& rStorageName ); 464 465 sal_Bool IsReference() const { return bReference; } 466 sal_Bool& IsReference() { return bReference; } 467 468 sal_Bool IsExtern() const { return ! aStorageName.EqualsAscii(szImbedded); } 469 470 void SetStorageName( const String& rName ) { aStorageName = rName; } 471 const String& GetStorageName() const { return aStorageName; } 472 473 void SetRelStorageName( const String& rN ) { aRelStorageName = rN; } 474 const String& GetRelStorageName() const { return aRelStorageName; } 475 void CalcRelStorageName( const String& rMgrStorageName ); 476 477 StarBASICRef GetLib() const |
478 { 479 if( mxScriptCont.is() && mxScriptCont->hasByName( aLibName ) && 480 !mxScriptCont->isLibraryLoaded( aLibName ) ) 481 return StarBASICRef(); 482 return xLib; 483 } | 478 { 479 if( mxScriptCont.is() && mxScriptCont->hasByName( aLibName ) && 480 !mxScriptCont->isLibraryLoaded( aLibName ) ) 481 return StarBASICRef(); 482 return xLib; 483 } |
484 StarBASICRef& GetLibRef() { return xLib; } 485 void SetLib( StarBASIC* pBasic ) { xLib = pBasic; } 486 487 const String& GetLibName() const { return aLibName; } 488 void SetLibName( const String& rName ) { aLibName = rName; } 489 490 // Only temporary for Load/Save 491 sal_Bool DoLoad() { return bDoLoad; } --- 6 unchanged lines hidden (view full) --- 498 void SetPasswordVerified() { bPasswordVerified = sal_True; } 499 500 sal_Bool IsFoundInPath() const { return bFoundInPath; } 501 void SetFoundInPath( sal_Bool bInPath ) { bFoundInPath = bInPath; } 502 503 void Store( SotStorageStream& rSStream, const String& rBasMgrStorageName, sal_Bool bUseOldReloadInfo ); 504 static BasicLibInfo* Create( SotStorageStream& rSStream ); 505 | 484 StarBASICRef& GetLibRef() { return xLib; } 485 void SetLib( StarBASIC* pBasic ) { xLib = pBasic; } 486 487 const String& GetLibName() const { return aLibName; } 488 void SetLibName( const String& rName ) { aLibName = rName; } 489 490 // Only temporary for Load/Save 491 sal_Bool DoLoad() { return bDoLoad; } --- 6 unchanged lines hidden (view full) --- 498 void SetPasswordVerified() { bPasswordVerified = sal_True; } 499 500 sal_Bool IsFoundInPath() const { return bFoundInPath; } 501 void SetFoundInPath( sal_Bool bInPath ) { bFoundInPath = bInPath; } 502 503 void Store( SotStorageStream& rSStream, const String& rBasMgrStorageName, sal_Bool bUseOldReloadInfo ); 504 static BasicLibInfo* Create( SotStorageStream& rSStream ); 505 |
506 Reference< XLibraryContainer > GetLibraryContainer( void ) 507 { return mxScriptCont; } 508 void SetLibraryContainer( const Reference< XLibraryContainer >& xScriptCont ) 509 { mxScriptCont = xScriptCont; } | 506 Reference< XLibraryContainer > GetLibraryContainer( void ) 507 { return mxScriptCont; } 508 void SetLibraryContainer( const Reference< XLibraryContainer >& xScriptCont ) 509 { mxScriptCont = xScriptCont; } |
510}; 511 512DECLARE_LIST( BasicLibsBase, BasicLibInfo* ) 513 514class BasicLibs : public BasicLibsBase 515{ 516public: 517 String aBasicLibPath; // TODO: Should be member of manager, but currently not incompatible 518}; 519 520BasicLibInfo::BasicLibInfo() 521{ 522 bReference = sal_False; 523 bPasswordVerified = sal_False; 524 bDoLoad = sal_False; 525 bFoundInPath = sal_False; | 510}; 511 512DECLARE_LIST( BasicLibsBase, BasicLibInfo* ) 513 514class BasicLibs : public BasicLibsBase 515{ 516public: 517 String aBasicLibPath; // TODO: Should be member of manager, but currently not incompatible 518}; 519 520BasicLibInfo::BasicLibInfo() 521{ 522 bReference = sal_False; 523 bPasswordVerified = sal_False; 524 bDoLoad = sal_False; 525 bFoundInPath = sal_False; |
526 mxScriptCont = NULL; | 526 mxScriptCont = NULL; |
527 aStorageName = String::CreateFromAscii(szImbedded); 528 aRelStorageName = String::CreateFromAscii(szImbedded); 529} 530 531BasicLibInfo::BasicLibInfo( const String& rStorageName ) 532{ 533 bReference = sal_True; 534 bPasswordVerified = sal_False; 535 bDoLoad = sal_False; | 527 aStorageName = String::CreateFromAscii(szImbedded); 528 aRelStorageName = String::CreateFromAscii(szImbedded); 529} 530 531BasicLibInfo::BasicLibInfo( const String& rStorageName ) 532{ 533 bReference = sal_True; 534 bPasswordVerified = sal_False; 535 bDoLoad = sal_False; |
536 mxScriptCont = NULL; | 536 mxScriptCont = NULL; |
537 aStorageName = rStorageName; 538} 539 540void BasicLibInfo::Store( SotStorageStream& rSStream, const String& rBasMgrStorageName, sal_Bool bUseOldReloadInfo ) 541{ 542 sal_uIntPtr nStartPos = rSStream.Tell(); 543 sal_uInt32 nEndPos = 0; 544 --- 42 unchanged lines hidden (view full) --- 587 CalcRelStorageName( aCurStorageName ); 588 rSStream.WriteByteString(aRelStorageName); 589 } 590 591 // ------------------------------ 592 // Version 2 593 // ------------------------------ 594 | 537 aStorageName = rStorageName; 538} 539 540void BasicLibInfo::Store( SotStorageStream& rSStream, const String& rBasMgrStorageName, sal_Bool bUseOldReloadInfo ) 541{ 542 sal_uIntPtr nStartPos = rSStream.Tell(); 543 sal_uInt32 nEndPos = 0; 544 --- 42 unchanged lines hidden (view full) --- 587 CalcRelStorageName( aCurStorageName ); 588 rSStream.WriteByteString(aRelStorageName); 589 } 590 591 // ------------------------------ 592 // Version 2 593 // ------------------------------ 594 |
595 // reference... 596 rSStream << bReference; | 595 // reference... 596 rSStream << bReference; |
597 598 // ------------------------------ 599 // End 600 // ------------------------------ 601 602 nEndPos = rSStream.Tell(); 603 rSStream.Seek( nStartPos ); 604 rSStream << nEndPos; --- 149 unchanged lines hidden (view full) --- 754 LoadOldBasicManager( rStorage ); 755 } 756 757 bBasMgrModified = sal_False; 758} 759 760void copyToLibraryContainer( StarBASIC* pBasic, const LibraryContainerInfo& rInfo ) 761{ | 597 598 // ------------------------------ 599 // End 600 // ------------------------------ 601 602 nEndPos = rSStream.Tell(); 603 rSStream.Seek( nStartPos ); 604 rSStream << nEndPos; --- 149 unchanged lines hidden (view full) --- 754 LoadOldBasicManager( rStorage ); 755 } 756 757 bBasMgrModified = sal_False; 758} 759 760void copyToLibraryContainer( StarBASIC* pBasic, const LibraryContainerInfo& rInfo ) 761{ |
762 Reference< XLibraryContainer > xScriptCont( rInfo.mxScriptCont.get() ); 763 if ( !xScriptCont.is() ) 764 return; | 762 Reference< XLibraryContainer > xScriptCont( rInfo.mxScriptCont.get() ); 763 if ( !xScriptCont.is() ) 764 return; |
765 | 765 |
766 String aLibName = pBasic->GetName(); | 766 String aLibName = pBasic->GetName(); |
767 if( !xScriptCont->hasByName( aLibName ) ) 768 xScriptCont->createLibrary( aLibName ); 769 770 Any aLibAny = xScriptCont->getByName( aLibName ); 771 Reference< XNameContainer > xLib; 772 aLibAny >>= xLib; | 767 if( !xScriptCont->hasByName( aLibName ) ) 768 xScriptCont->createLibrary( aLibName ); 769 770 Any aLibAny = xScriptCont->getByName( aLibName ); 771 Reference< XNameContainer > xLib; 772 aLibAny >>= xLib; |
773 if ( !xLib.is() ) 774 return; | 773 if ( !xLib.is() ) 774 return; |
775 | 775 |
776 sal_uInt16 nModCount = pBasic->GetModules()->Count(); | 776 sal_uInt16 nModCount = pBasic->GetModules()->Count(); |
777 for ( sal_uInt16 nMod = 0 ; nMod < nModCount ; nMod++ ) 778 { 779 SbModule* pModule = (SbModule*)pBasic->GetModules()->Get( nMod ); 780 DBG_ASSERT( pModule, "Modul nicht erhalten!" ); 781 782 String aModName = pModule->GetName(); 783 if( !xLib->hasByName( aModName ) ) 784 { 785 ::rtl::OUString aSource = pModule->GetSource32(); 786 Any aSourceAny; 787 aSourceAny <<= aSource; 788 xLib->insertByName( aModName, aSourceAny ); 789 } 790 } 791} 792 | 777 for ( sal_uInt16 nMod = 0 ; nMod < nModCount ; nMod++ ) 778 { 779 SbModule* pModule = (SbModule*)pBasic->GetModules()->Get( nMod ); 780 DBG_ASSERT( pModule, "Modul nicht erhalten!" ); 781 782 String aModName = pModule->GetName(); 783 if( !xLib->hasByName( aModName ) ) 784 { 785 ::rtl::OUString aSource = pModule->GetSource32(); 786 Any aSourceAny; 787 aSourceAny <<= aSource; 788 xLib->insertByName( aModName, aSourceAny ); 789 } 790 } 791} 792 |
793const Reference< XPersistentLibraryContainer >& BasicManager::GetDialogLibraryContainer() const | 793const Reference< XPersistentLibraryContainer >& BasicManager::GetDialogLibraryContainer() const |
794{ | 794{ |
795 return mpImpl->maContainerInfo.mxDialogCont; | 795 return mpImpl->maContainerInfo.mxDialogCont; |
796} 797 | 796} 797 |
798const Reference< XPersistentLibraryContainer >& BasicManager::GetScriptLibraryContainer() const | 798const Reference< XPersistentLibraryContainer >& BasicManager::GetScriptLibraryContainer() const |
799{ | 799{ |
800 return mpImpl->maContainerInfo.mxScriptCont; | 800 return mpImpl->maContainerInfo.mxScriptCont; |
801} 802 803void BasicManager::SetLibraryContainerInfo( const LibraryContainerInfo& rInfo ) 804{ 805 mpImpl->maContainerInfo = rInfo; 806 807 Reference< XLibraryContainer > xScriptCont( mpImpl->maContainerInfo.mxScriptCont.get() ); 808 StarBASIC* pStdLib = GetStdLib(); 809 String aLibName = pStdLib->GetName(); 810 if( xScriptCont.is() ) 811 { 812 // Register listener for lib container 813 ::rtl::OUString aEmptyLibName; 814 Reference< XContainerListener > xLibContainerListener 815 = static_cast< XContainerListener* > 816 ( new BasMgrContainerListenerImpl( this, aEmptyLibName ) ); 817 | 801} 802 803void BasicManager::SetLibraryContainerInfo( const LibraryContainerInfo& rInfo ) 804{ 805 mpImpl->maContainerInfo = rInfo; 806 807 Reference< XLibraryContainer > xScriptCont( mpImpl->maContainerInfo.mxScriptCont.get() ); 808 StarBASIC* pStdLib = GetStdLib(); 809 String aLibName = pStdLib->GetName(); 810 if( xScriptCont.is() ) 811 { 812 // Register listener for lib container 813 ::rtl::OUString aEmptyLibName; 814 Reference< XContainerListener > xLibContainerListener 815 = static_cast< XContainerListener* > 816 ( new BasMgrContainerListenerImpl( this, aEmptyLibName ) ); 817 |
818 Reference< XContainer> xLibContainer( xScriptCont, UNO_QUERY ); | 818 Reference< XContainer> xLibContainer( xScriptCont, UNO_QUERY ); |
819 xLibContainer->addContainerListener( xLibContainerListener ); 820 821 Sequence< ::rtl::OUString > aScriptLibNames = xScriptCont->getElementNames(); 822 const ::rtl::OUString* pScriptLibName = aScriptLibNames.getConstArray(); 823 sal_Int32 i, nNameCount = aScriptLibNames.getLength(); 824 825 if( nNameCount ) 826 { --- 38 unchanged lines hidden (view full) --- 865 } 866 } 867 } 868 869 mpImpl->mbModifiedByLibraryContainer = sal_False; 870 } 871 } 872 | 819 xLibContainer->addContainerListener( xLibContainerListener ); 820 821 Sequence< ::rtl::OUString > aScriptLibNames = xScriptCont->getElementNames(); 822 const ::rtl::OUString* pScriptLibName = aScriptLibNames.getConstArray(); 823 sal_Int32 i, nNameCount = aScriptLibNames.getLength(); 824 825 if( nNameCount ) 826 { --- 38 unchanged lines hidden (view full) --- 865 } 866 } 867 } 868 869 mpImpl->mbModifiedByLibraryContainer = sal_False; 870 } 871 } 872 |
873 SetGlobalUNOConstant( "BasicLibraries", makeAny( mpImpl->maContainerInfo.mxScriptCont ) ); 874 SetGlobalUNOConstant( "DialogLibraries", makeAny( mpImpl->maContainerInfo.mxDialogCont ) ); | 873 SetGlobalUNOConstant( "BasicLibraries", makeAny( mpImpl->maContainerInfo.mxScriptCont ) ); 874 SetGlobalUNOConstant( "DialogLibraries", makeAny( mpImpl->maContainerInfo.mxDialogCont ) ); |
875} 876 877BasicManager::BasicManager( StarBASIC* pSLib, String* pLibPath, sal_Bool bDocMgr ) : mbDocMgr( bDocMgr ) 878{ 879 DBG_CTOR( BasicManager, 0 ); 880 Init(); | 875} 876 877BasicManager::BasicManager( StarBASIC* pSLib, String* pLibPath, sal_Bool bDocMgr ) : mbDocMgr( bDocMgr ) 878{ 879 DBG_CTOR( BasicManager, 0 ); 880 Init(); |
881 DBG_ASSERT( pSLib, "BasicManager cannot be created with a NULL-Pointer!" ); | 881 DBG_ASSERT( pSLib, "BasicManager cannot be created with a NULL-Pointer!" ); |
882 883 if( pLibPath ) 884 pLibs->aBasicLibPath = *pLibPath; 885 886 BasicLibInfo* pStdLibInfo = CreateLibInfo(); 887 pStdLibInfo->SetLib( pSLib ); | 882 883 if( pLibPath ) 884 pLibs->aBasicLibPath = *pLibPath; 885 886 BasicLibInfo* pStdLibInfo = CreateLibInfo(); 887 pStdLibInfo->SetLib( pSLib ); |
888 StarBASICRef xStdLib = pStdLibInfo->GetLib(); | 888 StarBASICRef xStdLib = pStdLibInfo->GetLib(); |
889 xStdLib->SetName( String::CreateFromAscii(szStdLibName)); 890 pStdLibInfo->SetLibName( String::CreateFromAscii(szStdLibName) ); 891 pSLib->SetFlag( SBX_DONTSTORE | SBX_EXTSEARCH ); 892 | 889 xStdLib->SetName( String::CreateFromAscii(szStdLibName)); 890 pStdLibInfo->SetLibName( String::CreateFromAscii(szStdLibName) ); 891 pSLib->SetFlag( SBX_DONTSTORE | SBX_EXTSEARCH ); 892 |
893 // Save is only necessary if basic has changed | 893 // Save is only necessary if basic has changed |
894 xStdLib->SetModified( sal_False ); 895 bBasMgrModified = sal_False; 896} 897 898BasicManager::BasicManager() 899{ 900 DBG_CTOR( BasicManager, 0 ); 901 // This ctor may only be used to adapt relative paths for 'Save As'. 902 // There is no AppBasic so libs must not be loaded... 903 Init(); 904} 905 906void BasicManager::ImpMgrNotLoaded( const String& rStorageName ) 907{ | 894 xStdLib->SetModified( sal_False ); 895 bBasMgrModified = sal_False; 896} 897 898BasicManager::BasicManager() 899{ 900 DBG_CTOR( BasicManager, 0 ); 901 // This ctor may only be used to adapt relative paths for 'Save As'. 902 // There is no AppBasic so libs must not be loaded... 903 Init(); 904} 905 906void BasicManager::ImpMgrNotLoaded( const String& rStorageName ) 907{ |
908 // pErrInf is only destroyed if the error os processed by an | 908 // pErrInf is only destroyed if the error is processed by an |
909 // ErrorHandler 910 StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, rStorageName, ERRCODE_BUTTON_OK ); 911 pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_OPENMGRSTREAM, rStorageName ) ); 912 913 // Create a stdlib otherwise we crash! 914 BasicLibInfo* pStdLibInfo = CreateLibInfo(); 915 pStdLibInfo->SetLib( new StarBASIC( NULL, mbDocMgr ) ); 916 StarBASICRef xStdLib = pStdLibInfo->GetLib(); --- 19 unchanged lines hidden (view full) --- 936{ 937 DBG_CHKTHIS( BasicManager, 0 ); 938 939// StreamMode eStreamMode = STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE; 940 941 SotStorageStreamRef xManagerStream = rStorage.OpenSotStream 942 ( String(RTL_CONSTASCII_USTRINGPARAM(szManagerStream)), eStreamReadMode ); 943 | 909 // ErrorHandler 910 StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, rStorageName, ERRCODE_BUTTON_OK ); 911 pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_OPENMGRSTREAM, rStorageName ) ); 912 913 // Create a stdlib otherwise we crash! 914 BasicLibInfo* pStdLibInfo = CreateLibInfo(); 915 pStdLibInfo->SetLib( new StarBASIC( NULL, mbDocMgr ) ); 916 StarBASICRef xStdLib = pStdLibInfo->GetLib(); --- 19 unchanged lines hidden (view full) --- 936{ 937 DBG_CHKTHIS( BasicManager, 0 ); 938 939// StreamMode eStreamMode = STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE; 940 941 SotStorageStreamRef xManagerStream = rStorage.OpenSotStream 942 ( String(RTL_CONSTASCII_USTRINGPARAM(szManagerStream)), eStreamReadMode ); 943 |
944 String aStorName( rStorage.GetName() ); 945 // #i13114 removed, DBG_ASSERT( aStorName.Len(), "No Storage Name!" ); | 944 String aStorName( rStorage.GetName() ); 945 // #i13114 removed, DBG_ASSERT( aStorName.Len(), "No Storage Name!" ); |
946 947 if ( !xManagerStream.Is() || xManagerStream->GetError() || ( xManagerStream->Seek( STREAM_SEEK_TO_END ) == 0 ) ) 948 { | 946 947 if ( !xManagerStream.Is() || xManagerStream->GetError() || ( xManagerStream->Seek( STREAM_SEEK_TO_END ) == 0 ) ) 948 { |
949 ImpMgrNotLoaded( aStorName ); | 949 ImpMgrNotLoaded( aStorName ); |
950 return; 951 } 952 953 maStorageName = INetURLObject(aStorName, INET_PROT_FILE).GetMainURL( INetURLObject::NO_DECODE ); 954 // #i13114 removed, DBG_ASSERT(aStorageName.Len() != 0, "Bad storage name"); 955 | 950 return; 951 } 952 953 maStorageName = INetURLObject(aStorName, INET_PROT_FILE).GetMainURL( INetURLObject::NO_DECODE ); 954 // #i13114 removed, DBG_ASSERT(aStorageName.Len() != 0, "Bad storage name"); 955 |
956 String aRealStorageName = maStorageName; // for relative paths, can be modified through BaseURL | 956 String aRealStorageName = maStorageName; // for relative paths, can be modified through BaseURL |
957 958 // If loaded from template, only BaseURL is used: 959 //String aBaseURL = INetURLObject::GetBaseURL(); 960 if ( rBaseURL.Len() ) 961 { 962 INetURLObject aObj( rBaseURL ); 963 if ( aObj.GetProtocol() == INET_PROT_FILE ) 964 aRealStorageName = aObj.PathToFileName(); --- 63 unchanged lines hidden (view full) --- 1028{ 1029 DBG_CHKTHIS( BasicManager, 0 ); 1030 1031// StreamMode eStreamMode = STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE; 1032 1033 SotStorageStreamRef xManagerStream = rStorage.OpenSotStream 1034 ( String::CreateFromAscii(szOldManagerStream), eStreamReadMode ); 1035 | 957 958 // If loaded from template, only BaseURL is used: 959 //String aBaseURL = INetURLObject::GetBaseURL(); 960 if ( rBaseURL.Len() ) 961 { 962 INetURLObject aObj( rBaseURL ); 963 if ( aObj.GetProtocol() == INET_PROT_FILE ) 964 aRealStorageName = aObj.PathToFileName(); --- 63 unchanged lines hidden (view full) --- 1028{ 1029 DBG_CHKTHIS( BasicManager, 0 ); 1030 1031// StreamMode eStreamMode = STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE; 1032 1033 SotStorageStreamRef xManagerStream = rStorage.OpenSotStream 1034 ( String::CreateFromAscii(szOldManagerStream), eStreamReadMode ); 1035 |
1036 String aStorName( rStorage.GetName() ); 1037 DBG_ASSERT( aStorName.Len(), "No Storage Name!" ); | 1036 String aStorName( rStorage.GetName() ); 1037 DBG_ASSERT( aStorName.Len(), "No Storage Name!" ); |
1038 1039 if ( !xManagerStream.Is() || xManagerStream->GetError() || ( xManagerStream->Seek( STREAM_SEEK_TO_END ) == 0 ) ) 1040 { | 1038 1039 if ( !xManagerStream.Is() || xManagerStream->GetError() || ( xManagerStream->Seek( STREAM_SEEK_TO_END ) == 0 ) ) 1040 { |
1041 ImpMgrNotLoaded( aStorName ); | 1041 ImpMgrNotLoaded( aStorName ); |
1042 return; 1043 } 1044 1045 xManagerStream->SetBufferSize( 1024 ); 1046 xManagerStream->Seek( STREAM_SEEK_TO_BEGIN ); 1047 sal_uInt32 nBasicStartOff, nBasicEndOff; 1048 *xManagerStream >> nBasicStartOff; 1049 *xManagerStream >> nBasicEndOff; --- 59 unchanged lines hidden (view full) --- 1109 } 1110 } 1111} 1112 1113BasicManager::~BasicManager() 1114{ 1115 DBG_DTOR( BasicManager, 0 ); 1116 | 1042 return; 1043 } 1044 1045 xManagerStream->SetBufferSize( 1024 ); 1046 xManagerStream->Seek( STREAM_SEEK_TO_BEGIN ); 1047 sal_uInt32 nBasicStartOff, nBasicEndOff; 1048 *xManagerStream >> nBasicStartOff; 1049 *xManagerStream >> nBasicEndOff; --- 59 unchanged lines hidden (view full) --- 1109 } 1110 } 1111} 1112 1113BasicManager::~BasicManager() 1114{ 1115 DBG_DTOR( BasicManager, 0 ); 1116 |
1117 // Notify listener if something needs to be saved | 1117 // Notify listener if something needs to be saved |
1118 Broadcast( SfxSimpleHint( SFX_HINT_DYING) ); 1119 | 1118 Broadcast( SfxSimpleHint( SFX_HINT_DYING) ); 1119 |
1120 // Destroy Basic-Infos... 1121 // In reverse order | 1120 // Destroy Basic-Infos... 1121 // In reverse order |
1122 BasicLibInfo* pInf = pLibs->Last(); 1123 while ( pInf ) 1124 { 1125 delete pInf; 1126 pInf = pLibs->Prev(); 1127 } 1128 pLibs->Clear(); 1129 delete pLibs; 1130 delete pErrorMgr; 1131 delete mpImpl; 1132} 1133 1134void BasicManager::LegacyDeleteBasicManager( BasicManager*& _rpManager ) 1135{ | 1122 BasicLibInfo* pInf = pLibs->Last(); 1123 while ( pInf ) 1124 { 1125 delete pInf; 1126 pInf = pLibs->Prev(); 1127 } 1128 pLibs->Clear(); 1129 delete pLibs; 1130 delete pErrorMgr; 1131 delete mpImpl; 1132} 1133 1134void BasicManager::LegacyDeleteBasicManager( BasicManager*& _rpManager ) 1135{ |
1136 delete _rpManager; 1137 _rpManager = NULL; | 1136 delete _rpManager; 1137 _rpManager = NULL; |
1138} 1139 1140void BasicManager::Init() 1141{ 1142 DBG_CHKTHIS( BasicManager, 0 ); 1143 1144 bBasMgrModified = sal_False; 1145 pErrorMgr = new BasicErrorManager; --- 65 unchanged lines hidden (view full) --- 1211 if ( !bInfosOnly ) 1212 { 1213 if ( !pLibInfo->GetLib().Is() ) 1214 pLibInfo->SetLib( new StarBASIC( GetStdLib(), mbDocMgr ) ); 1215 xBasicStream->SetBufferSize( 1024 ); 1216 xBasicStream->Seek( STREAM_SEEK_TO_BEGIN ); 1217 bLoaded = ImplLoadBasic( *xBasicStream, pLibInfo->GetLibRef() ); 1218 xBasicStream->SetBufferSize( 0 ); | 1138} 1139 1140void BasicManager::Init() 1141{ 1142 DBG_CHKTHIS( BasicManager, 0 ); 1143 1144 bBasMgrModified = sal_False; 1145 pErrorMgr = new BasicErrorManager; --- 65 unchanged lines hidden (view full) --- 1211 if ( !bInfosOnly ) 1212 { 1213 if ( !pLibInfo->GetLib().Is() ) 1214 pLibInfo->SetLib( new StarBASIC( GetStdLib(), mbDocMgr ) ); 1215 xBasicStream->SetBufferSize( 1024 ); 1216 xBasicStream->Seek( STREAM_SEEK_TO_BEGIN ); 1217 bLoaded = ImplLoadBasic( *xBasicStream, pLibInfo->GetLibRef() ); 1218 xBasicStream->SetBufferSize( 0 ); |
1219 StarBASICRef xStdLib = pLibInfo->GetLib(); | 1219 StarBASICRef xStdLib = pLibInfo->GetLib(); |
1220 xStdLib->SetName( pLibInfo->GetLibName() ); 1221 xStdLib->SetModified( sal_False ); 1222 xStdLib->SetFlag( SBX_DONTSTORE ); 1223 } 1224 else 1225 { 1226 // Skip Basic... 1227 xBasicStream->Seek( STREAM_SEEK_TO_BEGIN ); --- 64 unchanged lines hidden (view full) --- 1292 pNew->SetParent( rOldBasic->GetParent() ); 1293 if( pNew->GetParent() ) 1294 pNew->GetParent()->Insert( pNew ); 1295 pNew->SetFlag( SBX_EXTSEARCH ); 1296 } 1297 rOldBasic = pNew; 1298 1299 // Fill new libray container (5.2 -> 6.0) | 1220 xStdLib->SetName( pLibInfo->GetLibName() ); 1221 xStdLib->SetModified( sal_False ); 1222 xStdLib->SetFlag( SBX_DONTSTORE ); 1223 } 1224 else 1225 { 1226 // Skip Basic... 1227 xBasicStream->Seek( STREAM_SEEK_TO_BEGIN ); --- 64 unchanged lines hidden (view full) --- 1292 pNew->SetParent( rOldBasic->GetParent() ); 1293 if( pNew->GetParent() ) 1294 pNew->GetParent()->Insert( pNew ); 1295 pNew->SetFlag( SBX_EXTSEARCH ); 1296 } 1297 rOldBasic = pNew; 1298 1299 // Fill new libray container (5.2 -> 6.0) |
1300 copyToLibraryContainer( pNew, mpImpl->maContainerInfo ); | 1300 copyToLibraryContainer( pNew, mpImpl->maContainerInfo ); |
1301 1302/* 1303 if( rOldBasic->GetParent() ) 1304 { 1305 rOldBasic->GetParent()->Insert( rOldBasic ); 1306 rOldBasic->SetFlag( SBX_EXTSEARCH ); 1307 } 1308*/ --- 29 unchanged lines hidden (view full) --- 1338 pLib->SetModified( sal_False ); 1339 } 1340} 1341 1342StarBASIC* BasicManager::AddLib( SotStorage& rStorage, const String& rLibName, sal_Bool bReference ) 1343{ 1344 DBG_CHKTHIS( BasicManager, 0 ); 1345 | 1301 1302/* 1303 if( rOldBasic->GetParent() ) 1304 { 1305 rOldBasic->GetParent()->Insert( rOldBasic ); 1306 rOldBasic->SetFlag( SBX_EXTSEARCH ); 1307 } 1308*/ --- 29 unchanged lines hidden (view full) --- 1338 pLib->SetModified( sal_False ); 1339 } 1340} 1341 1342StarBASIC* BasicManager::AddLib( SotStorage& rStorage, const String& rLibName, sal_Bool bReference ) 1343{ 1344 DBG_CHKTHIS( BasicManager, 0 ); 1345 |
1346 String aStorName( rStorage.GetName() ); 1347 DBG_ASSERT( aStorName.Len(), "No Storage Name!" ); | 1346 String aStorName( rStorage.GetName() ); 1347 DBG_ASSERT( aStorName.Len(), "No Storage Name!" ); |
1348 | 1348 |
1349 String aStorageName = INetURLObject(aStorName, INET_PROT_FILE).GetMainURL( INetURLObject::NO_DECODE ); 1350 DBG_ASSERT(aStorageName.Len() != 0, "Bad storage name"); | 1349 String aStorageName = INetURLObject(aStorName, INET_PROT_FILE).GetMainURL( INetURLObject::NO_DECODE ); 1350 DBG_ASSERT(aStorageName.Len() != 0, "Bad storage name"); |
1351 1352 String aNewLibName( rLibName ); 1353 while ( HasLib( aNewLibName ) ) 1354 aNewLibName += '_'; 1355 1356 BasicLibInfo* pLibInfo = CreateLibInfo(); | 1351 1352 String aNewLibName( rLibName ); 1353 while ( HasLib( aNewLibName ) ) 1354 aNewLibName += '_'; 1355 1356 BasicLibInfo* pLibInfo = CreateLibInfo(); |
1357 // Use original name otherwise ImpLoadLibary failes... | 1357 // Use original name otherwise ImpLoadLibary fails... |
1358 pLibInfo->SetLibName( rLibName ); 1359 // Funktioniert so aber nicht, wenn Name doppelt 1360// sal_uInt16 nLibId = GetLibId( rLibName ); 1361 sal_uInt16 nLibId = (sal_uInt16) pLibs->GetPos( pLibInfo ); 1362 1363 // Set StorageName before load because it is compared with pCurStorage 1364 pLibInfo->SetStorageName( aStorageName ); | 1358 pLibInfo->SetLibName( rLibName ); 1359 // Funktioniert so aber nicht, wenn Name doppelt 1360// sal_uInt16 nLibId = GetLibId( rLibName ); 1361 sal_uInt16 nLibId = (sal_uInt16) pLibs->GetPos( pLibInfo ); 1362 1363 // Set StorageName before load because it is compared with pCurStorage 1364 pLibInfo->SetStorageName( aStorageName ); |
1365 sal_Bool bLoaded = ImpLoadLibary( pLibInfo, &rStorage ); | 1365 sal_Bool bLoaded = ImpLoadLibary( pLibInfo, &rStorage ); |
1366 1367 if ( bLoaded ) 1368 { 1369 if ( aNewLibName != rLibName ) 1370 SetLibName( nLibId, aNewLibName ); 1371 1372 if ( bReference ) 1373 { --- 50 unchanged lines hidden (view full) --- 1424 if ( !pLibInfo || !nLib ) 1425 { 1426// String aErrorText( BasicResId( IDS_SBERR_REMOVELIB ) ); 1427 StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_REMOVELIB, String(), ERRCODE_BUTTON_OK ); 1428 pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_STDLIB, pLibInfo->GetLibName() ) ); 1429 return sal_False; 1430 } 1431 | 1366 1367 if ( bLoaded ) 1368 { 1369 if ( aNewLibName != rLibName ) 1370 SetLibName( nLibId, aNewLibName ); 1371 1372 if ( bReference ) 1373 { --- 50 unchanged lines hidden (view full) --- 1424 if ( !pLibInfo || !nLib ) 1425 { 1426// String aErrorText( BasicResId( IDS_SBERR_REMOVELIB ) ); 1427 StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_REMOVELIB, String(), ERRCODE_BUTTON_OK ); 1428 pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_STDLIB, pLibInfo->GetLibName() ) ); 1429 return sal_False; 1430 } 1431 |
1432 // If one of the streams cannot be opened, this is not an error, 1433 // because BASIC was never written before... | 1432 // If one of the streams cannot be opened, this is not an error, 1433 // because BASIC was never written before... |
1434 if ( bDelBasicFromStorage && !pLibInfo->IsReference() && 1435 ( !pLibInfo->IsExtern() || SotStorage::IsStorageFile( pLibInfo->GetStorageName() ) ) ) 1436 { 1437 SotStorageRef xStorage; 1438 if ( !pLibInfo->IsExtern() ) 1439 xStorage = new SotStorage( sal_False, GetStorageName() ); 1440 else 1441 xStorage = new SotStorage( sal_False, pLibInfo->GetStorageName() ); --- 120 unchanged lines hidden (view full) --- 1562 1563 BasicLibInfo* pLibInfo = pLibs->GetObject( nLib ); 1564 DBG_ASSERT( pLibInfo, "Lib?!" ); 1565 if ( pLibInfo ) 1566 { 1567 pLibInfo->SetLibName( rName ); 1568 if ( pLibInfo->GetLib().Is() ) 1569 { | 1434 if ( bDelBasicFromStorage && !pLibInfo->IsReference() && 1435 ( !pLibInfo->IsExtern() || SotStorage::IsStorageFile( pLibInfo->GetStorageName() ) ) ) 1436 { 1437 SotStorageRef xStorage; 1438 if ( !pLibInfo->IsExtern() ) 1439 xStorage = new SotStorage( sal_False, GetStorageName() ); 1440 else 1441 xStorage = new SotStorage( sal_False, pLibInfo->GetStorageName() ); --- 120 unchanged lines hidden (view full) --- 1562 1563 BasicLibInfo* pLibInfo = pLibs->GetObject( nLib ); 1564 DBG_ASSERT( pLibInfo, "Lib?!" ); 1565 if ( pLibInfo ) 1566 { 1567 pLibInfo->SetLibName( rName ); 1568 if ( pLibInfo->GetLib().Is() ) 1569 { |
1570 StarBASICRef xStdLib = pLibInfo->GetLib(); | 1570 StarBASICRef xStdLib = pLibInfo->GetLib(); |
1571 xStdLib->SetName( rName ); 1572 xStdLib->SetModified( sal_True ); 1573 } 1574 bBasMgrModified = sal_True; 1575 return sal_True; 1576 } 1577 return sal_False; 1578} --- 100 unchanged lines hidden (view full) --- 1679 } 1680 } 1681 //ExternalSourceURL ? 1682 } 1683 return pLib; 1684} 1685 1686StarBASIC* BasicManager::CreateLibForLibContainer( const String& rLibName, | 1571 xStdLib->SetName( rName ); 1572 xStdLib->SetModified( sal_True ); 1573 } 1574 bBasMgrModified = sal_True; 1575 return sal_True; 1576 } 1577 return sal_False; 1578} --- 100 unchanged lines hidden (view full) --- 1679 } 1680 } 1681 //ExternalSourceURL ? 1682 } 1683 return pLib; 1684} 1685 1686StarBASIC* BasicManager::CreateLibForLibContainer( const String& rLibName, |
1687 const Reference< XLibraryContainer >& xScriptCont ) | 1687 const Reference< XLibraryContainer >& xScriptCont ) |
1688{ 1689 DBG_CHKTHIS( BasicManager, 0 ); 1690 if ( GetLib( rLibName ) ) 1691 return 0; 1692 1693 BasicLibInfo* pLibInfo = CreateLibInfo(); 1694 StarBASIC* pNew = new StarBASIC( GetStdLib(), mbDocMgr ); 1695 GetStdLib()->Insert( pNew ); 1696 pNew->SetFlag( SBX_EXTSEARCH | SBX_DONTSTORE ); 1697 pLibInfo->SetLib( pNew ); 1698 pLibInfo->SetLibName( rLibName ); 1699 pLibInfo->GetLib()->SetName( rLibName ); | 1688{ 1689 DBG_CHKTHIS( BasicManager, 0 ); 1690 if ( GetLib( rLibName ) ) 1691 return 0; 1692 1693 BasicLibInfo* pLibInfo = CreateLibInfo(); 1694 StarBASIC* pNew = new StarBASIC( GetStdLib(), mbDocMgr ); 1695 GetStdLib()->Insert( pNew ); 1696 pNew->SetFlag( SBX_EXTSEARCH | SBX_DONTSTORE ); 1697 pLibInfo->SetLib( pNew ); 1698 pLibInfo->SetLibName( rLibName ); 1699 pLibInfo->GetLib()->SetName( rLibName ); |
1700 pLibInfo->SetLibraryContainer( xScriptCont ); | 1700 pLibInfo->SetLibraryContainer( xScriptCont ); |
1701 return pNew; 1702} 1703 1704 1705BasicLibInfo* BasicManager::FindLibInfo( StarBASIC* pBasic ) const 1706{ 1707 DBG_CHKTHIS( BasicManager, 0 ); 1708 --- 460 unchanged lines hidden (view full) --- 2169 Reference< XStarBasicModuleInfo > xMod; 2170 aElement >>= xMod; 2171 mpLib->MakeModule32( aName, xMod->getSource() ); 2172} 2173 2174void ModuleContainer_Impl::removeByName( const ::rtl::OUString& Name ) 2175 throw(NoSuchElementException, WrappedTargetException, RuntimeException) 2176{ | 1701 return pNew; 1702} 1703 1704 1705BasicLibInfo* BasicManager::FindLibInfo( StarBASIC* pBasic ) const 1706{ 1707 DBG_CHKTHIS( BasicManager, 0 ); 1708 --- 460 unchanged lines hidden (view full) --- 2169 Reference< XStarBasicModuleInfo > xMod; 2170 aElement >>= xMod; 2171 mpLib->MakeModule32( aName, xMod->getSource() ); 2172} 2173 2174void ModuleContainer_Impl::removeByName( const ::rtl::OUString& Name ) 2175 throw(NoSuchElementException, WrappedTargetException, RuntimeException) 2176{ |
2177 SbModule* pMod = mpLib ? mpLib->FindModule( Name ) : NULL; | 2177 SbModule* pMod = mpLib ? mpLib->FindModule( Name ) : NULL; |
2178 if( !pMod ) 2179 throw NoSuchElementException(); 2180 mpLib->Remove( pMod ); 2181} 2182 2183 2184//===================================================================== 2185 --- 146 unchanged lines hidden (view full) --- 2332 insertByName( aName, aElement ); 2333} 2334 2335 2336// Methods XNameContainer 2337void DialogContainer_Impl::insertByName( const ::rtl::OUString& aName, const Any& aElement ) 2338 throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException) 2339{ | 2178 if( !pMod ) 2179 throw NoSuchElementException(); 2180 mpLib->Remove( pMod ); 2181} 2182 2183 2184//===================================================================== 2185 --- 146 unchanged lines hidden (view full) --- 2332 insertByName( aName, aElement ); 2333} 2334 2335 2336// Methods XNameContainer 2337void DialogContainer_Impl::insertByName( const ::rtl::OUString& aName, const Any& aElement ) 2338 throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException) 2339{ |
2340 (void)aName; | 2340 (void)aName; |
2341 Type aModuleType = ::getCppuType( (const Reference< XStarBasicDialogInfo > *)0 ); 2342 Type aAnyType = aElement.getValueType(); 2343 if( aModuleType != aAnyType ) 2344 throw IllegalArgumentException(); 2345 Reference< XStarBasicDialogInfo > xMod; 2346 aElement >>= xMod; 2347 SbxObjectRef xDialog = implCreateDialog( xMod->getData() ); 2348 mpLib->Insert( xDialog ); 2349} 2350 2351void DialogContainer_Impl::removeByName( const ::rtl::OUString& Name ) 2352 throw(NoSuchElementException, WrappedTargetException, RuntimeException) 2353{ | 2341 Type aModuleType = ::getCppuType( (const Reference< XStarBasicDialogInfo > *)0 ); 2342 Type aAnyType = aElement.getValueType(); 2343 if( aModuleType != aAnyType ) 2344 throw IllegalArgumentException(); 2345 Reference< XStarBasicDialogInfo > xMod; 2346 aElement >>= xMod; 2347 SbxObjectRef xDialog = implCreateDialog( xMod->getData() ); 2348 mpLib->Insert( xDialog ); 2349} 2350 2351void DialogContainer_Impl::removeByName( const ::rtl::OUString& Name ) 2352 throw(NoSuchElementException, WrappedTargetException, RuntimeException) 2353{ |
2354 (void)Name; | 2354 (void)Name; |
2355 SbxVariable* pVar = mpLib->GetObjects()->Find( Name, SbxCLASS_DONTCARE ); 2356 if( !( pVar && pVar->ISA( SbxObject ) && 2357 ( ((SbxObject*)pVar)->GetSbxId() == SBXID_DIALOG ) ) ) 2358 { 2359 throw NoSuchElementException(); 2360 } 2361 mpLib->Remove( pVar ); 2362} --- 66 unchanged lines hidden (view full) --- 2429 2430 Reference< XNameContainer > xDialogContainer; 2431 (XNameContainer*)new DialogContainer_Impl( pLib ); 2432 2433 BasicLibInfo* pLibInfo = mpMgr->FindLibInfo( pLib ); 2434 2435 ::rtl::OUString aPassword = pLibInfo->GetPassword(); 2436 | 2355 SbxVariable* pVar = mpLib->GetObjects()->Find( Name, SbxCLASS_DONTCARE ); 2356 if( !( pVar && pVar->ISA( SbxObject ) && 2357 ( ((SbxObject*)pVar)->GetSbxId() == SBXID_DIALOG ) ) ) 2358 { 2359 throw NoSuchElementException(); 2360 } 2361 mpLib->Remove( pVar ); 2362} --- 66 unchanged lines hidden (view full) --- 2429 2430 Reference< XNameContainer > xDialogContainer; 2431 (XNameContainer*)new DialogContainer_Impl( pLib ); 2432 2433 BasicLibInfo* pLibInfo = mpMgr->FindLibInfo( pLib ); 2434 2435 ::rtl::OUString aPassword = pLibInfo->GetPassword(); 2436 |
2437 // TODO Only provide extern info! | 2437 // TODO Only provide external info! |
2438 ::rtl::OUString aExternaleSourceURL; 2439 ::rtl::OUString aLinkTargetURL; 2440 if( pLibInfo->IsReference() ) 2441 aLinkTargetURL = pLibInfo->GetStorageName(); 2442 else if( pLibInfo->IsExtern() ) 2443 aExternaleSourceURL = pLibInfo->GetStorageName(); 2444 2445 Reference< XStarBasicLibraryInfo > xLibInfo = new LibraryInfo_Impl --- 37 unchanged lines hidden (view full) --- 2483 removeByName( aName ); 2484 insertByName( aName, aElement ); 2485} 2486 2487// Methods XNameContainer 2488void LibraryContainer_Impl::insertByName( const ::rtl::OUString& aName, const Any& aElement ) 2489 throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException) 2490{ | 2438 ::rtl::OUString aExternaleSourceURL; 2439 ::rtl::OUString aLinkTargetURL; 2440 if( pLibInfo->IsReference() ) 2441 aLinkTargetURL = pLibInfo->GetStorageName(); 2442 else if( pLibInfo->IsExtern() ) 2443 aExternaleSourceURL = pLibInfo->GetStorageName(); 2444 2445 Reference< XStarBasicLibraryInfo > xLibInfo = new LibraryInfo_Impl --- 37 unchanged lines hidden (view full) --- 2483 removeByName( aName ); 2484 insertByName( aName, aElement ); 2485} 2486 2487// Methods XNameContainer 2488void LibraryContainer_Impl::insertByName( const ::rtl::OUString& aName, const Any& aElement ) 2489 throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException) 2490{ |
2491 (void)aName; 2492 (void)aElement; | 2491 (void)aName; 2492 (void)aElement; |
2493 // TODO: Insert a complete Library?! 2494} 2495 2496void LibraryContainer_Impl::removeByName( const ::rtl::OUString& Name ) 2497 throw(NoSuchElementException, WrappedTargetException, RuntimeException) 2498{ 2499 StarBASIC* pLib = mpMgr->GetLib( Name ); 2500 if( !pLib ) --- 45 unchanged lines hidden (view full) --- 2546( 2547 const ::rtl::OUString& LibName, 2548 const ::rtl::OUString& Password, 2549 const ::rtl::OUString& ExternalSourceURL, 2550 const ::rtl::OUString& LinkTargetURL 2551) 2552 throw(ElementExistException, RuntimeException) 2553{ | 2493 // TODO: Insert a complete Library?! 2494} 2495 2496void LibraryContainer_Impl::removeByName( const ::rtl::OUString& Name ) 2497 throw(NoSuchElementException, WrappedTargetException, RuntimeException) 2498{ 2499 StarBASIC* pLib = mpMgr->GetLib( Name ); 2500 if( !pLib ) --- 45 unchanged lines hidden (view full) --- 2546( 2547 const ::rtl::OUString& LibName, 2548 const ::rtl::OUString& Password, 2549 const ::rtl::OUString& ExternalSourceURL, 2550 const ::rtl::OUString& LinkTargetURL 2551) 2552 throw(ElementExistException, RuntimeException) 2553{ |
2554 (void)ExternalSourceURL; | 2554 (void)ExternalSourceURL; |
2555#ifdef DBG_UTIL 2556 StarBASIC* pLib = 2557#endif 2558 mpMgr->CreateLib( LibName, Password, LinkTargetURL ); 2559 DBG_ASSERT( pLib, "XML Import: Basic library could not be created"); 2560} 2561 2562void SAL_CALL StarBasicAccess_Impl::addModule 2563( 2564 const ::rtl::OUString& LibraryName, 2565 const ::rtl::OUString& ModuleName, 2566 const ::rtl::OUString& Language, 2567 const ::rtl::OUString& Source 2568) 2569 throw(NoSuchElementException, RuntimeException) 2570{ | 2555#ifdef DBG_UTIL 2556 StarBASIC* pLib = 2557#endif 2558 mpMgr->CreateLib( LibName, Password, LinkTargetURL ); 2559 DBG_ASSERT( pLib, "XML Import: Basic library could not be created"); 2560} 2561 2562void SAL_CALL StarBasicAccess_Impl::addModule 2563( 2564 const ::rtl::OUString& LibraryName, 2565 const ::rtl::OUString& ModuleName, 2566 const ::rtl::OUString& Language, 2567 const ::rtl::OUString& Source 2568) 2569 throw(NoSuchElementException, RuntimeException) 2570{ |
2571 (void)Language; | 2571 (void)Language; |
2572 StarBASIC* pLib = mpMgr->GetLib( LibraryName ); 2573 DBG_ASSERT( pLib, "XML Import: Lib for module unknown"); 2574 if( pLib ) 2575 pLib->MakeModule32( ModuleName, Source ); 2576} 2577 2578void SAL_CALL StarBasicAccess_Impl::addDialog 2579( --- 19 unchanged lines hidden --- | 2572 StarBASIC* pLib = mpMgr->GetLib( LibraryName ); 2573 DBG_ASSERT( pLib, "XML Import: Lib for module unknown"); 2574 if( pLib ) 2575 pLib->MakeModule32( ModuleName, Source ); 2576} 2577 2578void SAL_CALL StarBasicAccess_Impl::addDialog 2579( --- 19 unchanged lines hidden --- |