1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <vcl/errinf.hxx>
22 #include <tools/stream.hxx>
23 #include <sot/storage.hxx>
24 #include <tools/urlobj.hxx>
25 #include <svl/hint.hxx>
26 #include <basic/sbx.hxx>
27 #include <basic/sbmeth.hxx>
28 #include <sot/storinfo.hxx>
29 #include <unotools/pathoptions.hxx>
30 #include <tools/debug.hxx>
31 #include <comphelper/diagnose_ex.hxx>
32 #include <basic/sbmod.hxx>
33 #include <unotools/transliterationwrapper.hxx>
34 #include <sal/log.hxx>
35 #include <o3tl/string_view.hxx>
37 #include <basic/sberrors.hxx>
38 #include <basic/sbuno.hxx>
39 #include <basic/basmgr.hxx>
41 #include <com/sun/star/script/XLibraryContainer.hpp>
42 #include <com/sun/star/script/XPersistentLibraryContainer.hpp>
44 #include <scriptcont.hxx>
50 #define LIBINFO_SEP 0x02
51 #define LIBINFO_ID 0x1491
52 #define PASSWORD_MARKER 0x31452134
55 // Library API, implemented for XML import/export
57 #include <com/sun/star/container/XNameContainer.hpp>
58 #include <com/sun/star/container/XContainer.hpp>
59 #include <com/sun/star/script/XStarBasicAccess.hpp>
60 #include <com/sun/star/script/XStarBasicModuleInfo.hpp>
61 #include <com/sun/star/script/XStarBasicDialogInfo.hpp>
62 #include <com/sun/star/script/XStarBasicLibraryInfo.hpp>
63 #include <com/sun/star/script/XLibraryContainerPassword.hpp>
64 #include <com/sun/star/script/ModuleInfo.hpp>
65 #include <com/sun/star/script/vba/XVBACompatibility.hpp>
66 #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
67 #include <com/sun/star/ucb/ContentCreationException.hpp>
69 #include <cppuhelper/implbase.hxx>
71 using com::sun::star::uno::Reference
;
72 using namespace com::sun::star
;
73 using namespace com::sun::star::script
;
76 typedef WeakImplHelper
< container::XNameContainer
> NameContainerHelper
;
77 typedef WeakImplHelper
< script::XStarBasicModuleInfo
> ModuleInfoHelper
;
78 typedef WeakImplHelper
< script::XStarBasicAccess
> StarBasicAccessHelper
;
86 // String AbsStorageName
87 // String RelStorageName
91 constexpr OUString szStdLibName
= u
"Standard"_ustr
;
92 constexpr OUString szBasicStorage
= u
"StarBASIC"_ustr
;
93 constexpr OUString szOldManagerStream
= u
"BasicManager"_ustr
;
94 constexpr OUString szManagerStream
= u
"BasicManager2"_ustr
;
95 constexpr OUString szImbedded
= u
"LIBIMBEDDED"_ustr
;
96 constexpr OString szCryptingKey
= "CryptedBasic"_ostr
;
99 const StreamMode eStreamReadMode
= StreamMode::READ
| StreamMode::NOCREATE
| StreamMode::SHARE_DENYALL
;
100 const StreamMode eStorageReadMode
= StreamMode::READ
| StreamMode::SHARE_DENYWRITE
;
102 // BasMgrContainerListenerImpl
105 typedef ::cppu::WeakImplHelper
< container::XContainerListener
> ContainerListenerHelper
;
107 class BasMgrContainerListenerImpl
: public ContainerListenerHelper
110 OUString maLibName
; // empty -> no lib, but lib container
113 BasMgrContainerListenerImpl( BasicManager
* pMgr
, OUString aLibName
)
115 , maLibName(std::move( aLibName
)) {}
117 static void insertLibraryImpl( const uno::Reference
< script::XLibraryContainer
>& xScriptCont
, BasicManager
* pMgr
,
118 const uno::Any
& aLibAny
, const OUString
& aLibName
);
119 static void addLibraryModulesImpl( BasicManager
const * pMgr
, const uno::Reference
< container::XNameAccess
>& xLibNameAccess
,
120 std::u16string_view aLibName
);
124 virtual void SAL_CALL
disposing( const lang::EventObject
& Source
) override
;
126 // XContainerListener
127 virtual void SAL_CALL
elementInserted( const container::ContainerEvent
& Event
) override
;
128 virtual void SAL_CALL
elementReplaced( const container::ContainerEvent
& Event
) override
;
129 virtual void SAL_CALL
elementRemoved( const container::ContainerEvent
& Event
) override
;
133 // BasMgrContainerListenerImpl
136 void BasMgrContainerListenerImpl::insertLibraryImpl( const uno::Reference
< script::XLibraryContainer
>& xScriptCont
,
137 BasicManager
* pMgr
, const uno::Any
& aLibAny
, const OUString
& aLibName
)
139 Reference
< container::XNameAccess
> xLibNameAccess
;
140 aLibAny
>>= xLibNameAccess
;
142 if( !pMgr
->GetLib( aLibName
) )
145 pMgr
->CreateLibForLibContainer( aLibName
, xScriptCont
);
146 DBG_ASSERT( pLib
, "XML Import: Basic library could not be created");
149 uno::Reference
< container::XContainer
> xLibContainer( xLibNameAccess
, uno::UNO_QUERY
);
150 if( xLibContainer
.is() )
152 // Register listener for library
153 Reference
< container::XContainerListener
> xLibraryListener
154 = new BasMgrContainerListenerImpl( pMgr
, aLibName
);
155 xLibContainer
->addContainerListener( xLibraryListener
);
158 if( xScriptCont
->isLibraryLoaded( aLibName
) )
160 addLibraryModulesImpl( pMgr
, xLibNameAccess
, aLibName
);
165 void BasMgrContainerListenerImpl::addLibraryModulesImpl( BasicManager
const * pMgr
,
166 const uno::Reference
< container::XNameAccess
>& xLibNameAccess
, std::u16string_view aLibName
)
168 uno::Sequence
< OUString
> aModuleNames
= xLibNameAccess
->getElementNames();
169 sal_Int32 nModuleCount
= aModuleNames
.getLength();
171 StarBASIC
* pLib
= pMgr
->GetLib( aLibName
);
172 DBG_ASSERT( pLib
, "BasMgrContainerListenerImpl::addLibraryModulesImpl: Unknown lib!");
176 const OUString
* pNames
= aModuleNames
.getConstArray();
177 for( sal_Int32 j
= 0 ; j
< nModuleCount
; j
++ )
179 OUString aModuleName
= pNames
[ j
];
180 uno::Any aElement
= xLibNameAccess
->getByName( aModuleName
);
183 uno::Reference
< vba::XVBAModuleInfo
> xVBAModuleInfo( xLibNameAccess
, uno::UNO_QUERY
);
184 if ( xVBAModuleInfo
.is() && xVBAModuleInfo
->hasModuleInfo( aModuleName
) )
186 ModuleInfo aInfo
= xVBAModuleInfo
->getModuleInfo( aModuleName
);
187 pLib
->MakeModule( aModuleName
, aInfo
, aMod
);
190 pLib
->MakeModule( aModuleName
, aMod
);
193 pLib
->SetModified( false );
200 void SAL_CALL
BasMgrContainerListenerImpl::disposing( const lang::EventObject
& ) {}
202 // XContainerListener
205 void SAL_CALL
BasMgrContainerListenerImpl::elementInserted( const container::ContainerEvent
& Event
)
207 bool bLibContainer
= maLibName
.isEmpty();
209 Event
.Accessor
>>= aName
;
213 uno::Reference
< script::XLibraryContainer
> xScriptCont( Event
.Source
, uno::UNO_QUERY
);
214 if (xScriptCont
.is())
215 insertLibraryImpl(xScriptCont
, mpMgr
, Event
.Element
, aName
);
216 StarBASIC
* pLib
= mpMgr
->GetLib( aName
);
219 uno::Reference
< vba::XVBACompatibility
> xVBACompat( xScriptCont
, uno::UNO_QUERY
);
220 if ( xVBACompat
.is() )
221 pLib
->SetVBAEnabled( xVBACompat
->getVBACompatibilityMode() );
227 StarBASIC
* pLib
= mpMgr
->GetLib( maLibName
);
228 DBG_ASSERT( pLib
, "BasMgrContainerListenerImpl::elementInserted: Unknown lib!");
231 SbModule
* pMod
= pLib
->FindModule( aName
);
235 Event
.Element
>>= aMod
;
236 uno::Reference
< vba::XVBAModuleInfo
> xVBAModuleInfo( Event
.Source
, uno::UNO_QUERY
);
237 if ( xVBAModuleInfo
.is() && xVBAModuleInfo
->hasModuleInfo( aName
) )
239 ModuleInfo aInfo
= xVBAModuleInfo
->getModuleInfo( aName
);
240 pLib
->MakeModule( aName
, aInfo
, aMod
);
243 pLib
->MakeModule( aName
, aMod
);
244 pLib
->SetModified( false );
251 void SAL_CALL
BasMgrContainerListenerImpl::elementReplaced( const container::ContainerEvent
& Event
)
254 Event
.Accessor
>>= aName
;
256 // Replace not possible for library container
257 DBG_ASSERT( !maLibName
.isEmpty(), "library container fired elementReplaced()");
259 StarBASIC
* pLib
= mpMgr
->GetLib( maLibName
);
263 SbModule
* pMod
= pLib
->FindModule( aName
);
265 Event
.Element
>>= aMod
;
268 pMod
->SetSource32( aMod
);
270 pLib
->MakeModule( aName
, aMod
);
272 pLib
->SetModified( false );
276 void SAL_CALL
BasMgrContainerListenerImpl::elementRemoved( const container::ContainerEvent
& Event
)
279 Event
.Accessor
>>= aName
;
281 bool bLibContainer
= maLibName
.isEmpty();
284 StarBASIC
* pLib
= mpMgr
->GetLib( aName
);
287 sal_uInt16 nLibId
= mpMgr
->GetLibId( aName
);
288 mpMgr
->RemoveLib( nLibId
, false );
293 StarBASIC
* pLib
= mpMgr
->GetLib( maLibName
);
294 SbModule
* pMod
= pLib
? pLib
->FindModule( aName
) : nullptr;
297 pLib
->Remove( pMod
);
298 pLib
->SetModified( false );
303 BasicError::BasicError( ErrCodeMsg nId
)
304 : nErrorId(std::move(nId
))
308 BasicError::BasicError( const BasicError
& rErr
)
309 : nErrorId(rErr
.nErrorId
)
318 OUString aStorageName
; // string is sufficient, unique at runtime
319 OUString aRelStorageName
;
325 // Lib represents library in new UNO library container
326 uno::Reference
< script::XLibraryContainer
> mxScriptCont
;
331 bool IsReference() const { return bReference
; }
332 void SetReference(bool b
) { bReference
= b
; }
334 bool IsExtern() const { return aStorageName
!= szImbedded
; }
336 void SetStorageName( const OUString
& rName
) { aStorageName
= rName
; }
337 const OUString
& GetStorageName() const { return aStorageName
; }
339 void SetRelStorageName( const OUString
& rN
) { aRelStorageName
= rN
; }
340 const OUString
& GetRelStorageName() const { return aRelStorageName
; }
342 StarBASICRef
GetLib() const
344 if( mxScriptCont
.is() && mxScriptCont
->hasByName( aLibName
) &&
345 !mxScriptCont
->isLibraryLoaded( aLibName
) )
346 return StarBASICRef();
349 StarBASICRef
& GetLibRef() { return xLib
; }
350 void SetLib( StarBASIC
* pBasic
) { xLib
= pBasic
; }
352 const OUString
& GetLibName() const { return aLibName
; }
353 void SetLibName( const OUString
& rName
) { aLibName
= rName
; }
355 // Only temporary for Load/Save
356 bool DoLoad() const { return bDoLoad
; }
358 bool HasPassword() const { return !aPassword
.isEmpty(); }
359 const OUString
& GetPassword() const { return aPassword
; }
360 void SetPassword( const OUString
& rNewPassword
)
361 { aPassword
= rNewPassword
; }
363 static BasicLibInfo
* Create( SotStorageStream
& rSStream
);
365 const uno::Reference
< script::XLibraryContainer
>& GetLibraryContainer() const
366 { return mxScriptCont
; }
367 void SetLibraryContainer( const uno::Reference
< script::XLibraryContainer
>& xScriptCont
)
368 { mxScriptCont
= xScriptCont
; }
372 BasicLibInfo::BasicLibInfo()
373 : aStorageName(szImbedded
)
374 , aRelStorageName(szImbedded
)
380 BasicLibInfo
* BasicLibInfo::Create( SotStorageStream
& rSStream
)
382 BasicLibInfo
* pInfo
= new BasicLibInfo
;
388 rSStream
.ReadUInt32( nEndPos
);
389 rSStream
.ReadUInt16( nId
);
390 rSStream
.ReadUInt16( nVer
);
392 DBG_ASSERT( nId
== LIBINFO_ID
, "No BasicLibInfo?!" );
393 if( nId
== LIBINFO_ID
)
397 rSStream
.ReadCharAsBool( bDoLoad
);
398 pInfo
->bDoLoad
= bDoLoad
;
400 // The name of the lib...
401 OUString aName
= rSStream
.ReadUniOrByteString(rSStream
.GetStreamCharSet());
402 pInfo
->SetLibName( aName
);
405 OUString aStorageName
= rSStream
.ReadUniOrByteString(rSStream
.GetStreamCharSet());
406 pInfo
->SetStorageName( aStorageName
);
409 OUString aRelStorageName
= rSStream
.ReadUniOrByteString(rSStream
.GetStreamCharSet());
410 pInfo
->SetRelStorageName( aRelStorageName
);
415 rSStream
.ReadCharAsBool( bReferenz
);
416 pInfo
->SetReference(bReferenz
);
419 rSStream
.Seek( nEndPos
);
424 BasicManager::BasicManager( SotStorage
& rStorage
, std::u16string_view rBaseURL
, StarBASIC
* pParentFromStdLib
, OUString
const * pLibPath
, bool bDocMgr
) : mbDocMgr( bDocMgr
)
428 aBasicLibPath
= *pLibPath
;
430 OUString
aStorName( rStorage
.GetName() );
431 maStorageName
= INetURLObject(aStorName
, INetProtocol::File
).GetMainURL( INetURLObject::DecodeMechanism::NONE
);
434 // If there is no Manager Stream, no further actions are necessary
435 if ( rStorage
.IsStream( szManagerStream
) )
437 LoadBasicManager( rStorage
, rBaseURL
);
438 // StdLib contains Parent:
439 StarBASIC
* pStdLib
= GetStdLib();
440 DBG_ASSERT( pStdLib
, "Standard-Lib not loaded?" );
443 // Should never happen, but if it happens we won't crash...
444 pStdLib
= new StarBASIC( nullptr, mbDocMgr
);
449 BasicLibInfo
& rStdLibInfo
= *maLibs
.front();
451 rStdLibInfo
.SetLib( pStdLib
);
452 StarBASICRef xStdLib
= rStdLibInfo
.GetLib();
453 xStdLib
->SetName( szStdLibName
);
454 rStdLibInfo
.SetLibName( szStdLibName
);
455 xStdLib
->SetFlag( SbxFlagBits::DontStore
| SbxFlagBits::ExtSearch
);
456 xStdLib
->SetModified( false );
460 pStdLib
->SetParent( pParentFromStdLib
);
461 // The other get StdLib as parent:
463 for ( sal_uInt16 nBasic
= 1; nBasic
< GetLibCount(); nBasic
++ )
465 StarBASIC
* pBasic
= GetLib( nBasic
);
468 pStdLib
->Insert( pBasic
);
469 pBasic
->SetFlag( SbxFlagBits::ExtSearch
);
472 // Modified through insert
473 pStdLib
->SetModified( false );
478 ImpCreateStdLib( pParentFromStdLib
);
479 if ( rStorage
.IsStream( szOldManagerStream
) )
480 LoadOldBasicManager( rStorage
);
484 static void copyToLibraryContainer( StarBASIC
* pBasic
, const LibraryContainerInfo
& rInfo
)
486 uno::Reference
< script::XLibraryContainer
> xScriptCont( rInfo
.mxScriptCont
);
487 if ( !xScriptCont
.is() )
490 OUString aLibName
= pBasic
->GetName();
491 if( !xScriptCont
->hasByName( aLibName
) )
492 xScriptCont
->createLibrary( aLibName
);
494 uno::Any aLibAny
= xScriptCont
->getByName( aLibName
);
495 uno::Reference
< container::XNameContainer
> xLib
;
500 for ( const auto& pModule
: pBasic
->GetModules() )
502 OUString aModName
= pModule
->GetName();
503 if( !xLib
->hasByName( aModName
) )
505 OUString aSource
= pModule
->GetSource32();
507 aSourceAny
<<= aSource
;
508 xLib
->insertByName( aModName
, aSourceAny
);
513 const uno::Reference
< script::XPersistentLibraryContainer
>& BasicManager::GetDialogLibraryContainer() const
515 return maContainerInfo
.mxDialogCont
;
518 const uno::Reference
< script::XPersistentLibraryContainer
>& BasicManager::GetScriptLibraryContainer() const
520 return maContainerInfo
.mxScriptCont
;
523 void BasicManager::SetLibraryContainerInfo( const LibraryContainerInfo
& rInfo
)
525 maContainerInfo
= rInfo
;
527 uno::Reference
< script::XLibraryContainer
> xScriptCont( maContainerInfo
.mxScriptCont
);
528 if( xScriptCont
.is() )
530 // Register listener for lib container
531 uno::Reference
< container::XContainerListener
> xLibContainerListener
532 = new BasMgrContainerListenerImpl( this, u
""_ustr
);
534 uno::Reference
< container::XContainer
> xLibContainer( xScriptCont
, uno::UNO_QUERY
);
535 xLibContainer
->addContainerListener( xLibContainerListener
);
537 const uno::Sequence
< OUString
> aScriptLibNames
= xScriptCont
->getElementNames();
539 if( aScriptLibNames
.hasElements() )
541 for(const auto& rScriptLibName
: aScriptLibNames
)
543 uno::Any aLibAny
= xScriptCont
->getByName( rScriptLibName
);
545 if ( rScriptLibName
== "Standard" || rScriptLibName
== "VBAProject")
546 xScriptCont
->loadLibrary( rScriptLibName
);
548 BasMgrContainerListenerImpl::insertLibraryImpl
549 ( xScriptCont
, this, aLibAny
, rScriptLibName
);
554 // No libs? Maybe an 5.2 document already loaded
555 for (auto const& rpBasLibInfo
: maLibs
)
557 StarBASIC
* pLib
= rpBasLibInfo
->GetLib().get();
560 bool bLoaded
= ImpLoadLibrary( rpBasLibInfo
.get(), nullptr );
562 pLib
= rpBasLibInfo
->GetLib().get();
566 copyToLibraryContainer( pLib
, maContainerInfo
);
567 if (rpBasLibInfo
->HasPassword())
569 basic::SfxScriptLibraryContainer
* pOldBasicPassword
=
570 maContainerInfo
.mpOldBasicPassword
;
571 if( pOldBasicPassword
)
573 pOldBasicPassword
->setLibraryPassword(
574 pLib
->GetName(), rpBasLibInfo
->GetPassword() );
582 SetGlobalUNOConstant( u
"BasicLibraries"_ustr
, uno::Any( maContainerInfo
.mxScriptCont
) );
583 SetGlobalUNOConstant( u
"DialogLibraries"_ustr
, uno::Any( maContainerInfo
.mxDialogCont
) );
586 BasicManager::BasicManager( StarBASIC
* pSLib
, OUString
const * pLibPath
, bool bDocMgr
) : mbDocMgr( bDocMgr
)
588 DBG_ASSERT( pSLib
, "BasicManager cannot be created with a NULL-Pointer!" );
592 aBasicLibPath
= *pLibPath
;
594 BasicLibInfo
* pStdLibInfo
= CreateLibInfo();
595 pStdLibInfo
->SetLib( pSLib
);
596 StarBASICRef xStdLib
= pStdLibInfo
->GetLib();
597 xStdLib
->SetName(szStdLibName
);
598 pStdLibInfo
->SetLibName(szStdLibName
);
599 pSLib
->SetFlag( SbxFlagBits::DontStore
| SbxFlagBits::ExtSearch
);
601 // Save is only necessary if basic has changed
602 xStdLib
->SetModified( false );
605 void BasicManager::ImpMgrNotLoaded( const OUString
& rStorageName
)
607 // pErrInf is only destroyed if the error os processed by an
609 ErrCodeMsg
aErrInf( ERRCODE_BASMGR_MGROPEN
, rStorageName
, DialogMask::ButtonsOk
);
610 aErrors
.emplace_back(aErrInf
);
612 // Create a stdlib otherwise we crash!
613 BasicLibInfo
* pStdLibInfo
= CreateLibInfo();
614 pStdLibInfo
->SetLib( new StarBASIC( nullptr, mbDocMgr
) );
615 StarBASICRef xStdLib
= pStdLibInfo
->GetLib();
616 xStdLib
->SetName( szStdLibName
);
617 pStdLibInfo
->SetLibName( szStdLibName
);
618 xStdLib
->SetFlag( SbxFlagBits::DontStore
| SbxFlagBits::ExtSearch
);
619 xStdLib
->SetModified( false );
623 void BasicManager::ImpCreateStdLib( StarBASIC
* pParentFromStdLib
)
625 BasicLibInfo
* pStdLibInfo
= CreateLibInfo();
626 StarBASIC
* pStdLib
= new StarBASIC( pParentFromStdLib
, mbDocMgr
);
627 pStdLibInfo
->SetLib( pStdLib
);
628 pStdLib
->SetName( szStdLibName
);
629 pStdLibInfo
->SetLibName( szStdLibName
);
630 pStdLib
->SetFlag( SbxFlagBits::DontStore
| SbxFlagBits::ExtSearch
);
633 void BasicManager::LoadBasicManager( SotStorage
& rStorage
, std::u16string_view rBaseURL
)
635 rtl::Reference
<SotStorageStream
> xManagerStream
= rStorage
.OpenSotStream( szManagerStream
, eStreamReadMode
);
637 OUString
aStorName( rStorage
.GetName() );
638 // #i13114 removed, DBG_ASSERT( aStorName.Len(), "No Storage Name!" );
640 if ( !xManagerStream
.is() || xManagerStream
->GetError() || ( xManagerStream
->TellEnd() == 0 ) )
642 ImpMgrNotLoaded( aStorName
);
646 maStorageName
= INetURLObject(aStorName
, INetProtocol::File
).GetMainURL( INetURLObject::DecodeMechanism::NONE
);
647 // #i13114 removed, DBG_ASSERT(aStorageName.Len() != 0, "Bad storage name");
649 OUString aRealStorageName
= maStorageName
; // for relative paths, can be modified through BaseURL
651 if ( !rBaseURL
.empty() )
653 INetURLObject
aObj( rBaseURL
);
654 if ( aObj
.GetProtocol() == INetProtocol::File
)
656 aRealStorageName
= aObj
.PathToFileName();
660 xManagerStream
->SetBufferSize( 1024 );
661 xManagerStream
->Seek( STREAM_SEEK_TO_BEGIN
);
664 xManagerStream
->ReadUInt32( nEndPos
);
667 xManagerStream
->ReadUInt16( nLibs
);
671 SAL_WARN( "basic", "BasicManager-Stream defect!" );
674 const size_t nMinBasicLibSize(8);
675 const size_t nMaxPossibleLibs
= xManagerStream
->remainingSize() / nMinBasicLibSize
;
676 if (nLibs
> nMaxPossibleLibs
)
678 SAL_WARN("basic", "Parsing error: " << nMaxPossibleLibs
<<
679 " max possible entries, but " << nLibs
<< " claimed, truncating");
680 nLibs
= nMaxPossibleLibs
;
682 for (sal_uInt16 nL
= 0; nL
< nLibs
; ++nL
)
684 BasicLibInfo
* pInfo
= BasicLibInfo::Create( *xManagerStream
);
686 // Correct absolute pathname if relative is existing.
687 // Always try relative first if there are two stands on disk
688 if ( !pInfo
->GetRelStorageName().isEmpty() && pInfo
->GetRelStorageName() != szImbedded
)
690 INetURLObject
aObj( aRealStorageName
, INetProtocol::File
);
691 aObj
.removeSegment();
692 bool bWasAbsolute
= false;
693 aObj
= aObj
.smartRel2Abs( pInfo
->GetRelStorageName(), bWasAbsolute
);
695 //*** TODO: Replace if still necessary
697 if ( ! aBasicLibPath
.isEmpty() )
699 // Search lib in path
700 OUString aSearchFile
= pInfo
->GetRelStorageName();
701 OUString
aSearchFileOldFormat(aSearchFile
);
702 SvtPathOptions aPathCFG
;
703 if( aPathCFG
.SearchFile( aSearchFileOldFormat
, SvtPathOptions::Paths::Basic
) )
705 pInfo
->SetStorageName( aSearchFile
);
710 maLibs
.push_back(std::unique_ptr
<BasicLibInfo
>(pInfo
));
711 // Libs from external files should be loaded only when necessary.
712 // But references are loaded at once, otherwise some big customers get into trouble
713 if ( pInfo
->DoLoad() &&
714 ( !pInfo
->IsExtern() || pInfo
->IsReference()))
716 ImpLoadLibrary( pInfo
, &rStorage
);
720 xManagerStream
->Seek( nEndPos
);
721 xManagerStream
->SetBufferSize( 0 );
722 xManagerStream
.clear();
725 void BasicManager::LoadOldBasicManager( SotStorage
& rStorage
)
727 rtl::Reference
<SotStorageStream
> xManagerStream
= rStorage
.OpenSotStream( szOldManagerStream
, eStreamReadMode
);
729 OUString
aStorName( rStorage
.GetName() );
730 DBG_ASSERT( aStorName
.getLength(), "No Storage Name!" );
732 if ( !xManagerStream
.is() || xManagerStream
->GetError() || ( xManagerStream
->TellEnd() == 0 ) )
734 ImpMgrNotLoaded( aStorName
);
738 xManagerStream
->SetBufferSize( 1024 );
739 xManagerStream
->Seek( STREAM_SEEK_TO_BEGIN
);
740 sal_uInt32 nBasicStartOff
, nBasicEndOff
;
741 xManagerStream
->ReadUInt32( nBasicStartOff
);
742 xManagerStream
->ReadUInt32( nBasicEndOff
);
744 DBG_ASSERT( !xManagerStream
->GetError(), "Invalid Manager-Stream!" );
746 xManagerStream
->Seek( nBasicStartOff
);
747 if (!ImplLoadBasic( *xManagerStream
, maLibs
.front()->GetLibRef() ))
749 ErrCodeMsg
aErrInf( ERRCODE_BASMGR_MGROPEN
, aStorName
, DialogMask::ButtonsOk
);
750 aErrors
.emplace_back(aErrInf
);
751 // and it proceeds ...
753 xManagerStream
->Seek( nBasicEndOff
+1 ); // +1: 0x00 as separator
754 OUString aLibs
= xManagerStream
->ReadUniOrByteString(xManagerStream
->GetStreamCharSet());
755 xManagerStream
->SetBufferSize( 0 );
756 xManagerStream
.clear(); // Close stream
758 if ( aLibs
.isEmpty() )
761 INetURLObject
aCurStorage( aStorName
, INetProtocol::File
);
762 sal_Int32 nLibPos
{0};
764 const OUString
aLibInfo(aLibs
.getToken(0, LIB_SEP
, nLibPos
));
765 sal_Int32 nInfoPos
{0};
766 const OUString
aLibName( aLibInfo
.getToken( 0, LIBINFO_SEP
, nInfoPos
) );
767 DBG_ASSERT( nInfoPos
>= 0, "Invalid Lib-Info!" );
768 const OUString
aLibAbsStorageName( aLibInfo
.getToken( 0, LIBINFO_SEP
, nInfoPos
) );
769 // TODO: fail also here if there are no more tokens?
770 const OUString
aLibRelStorageName( aLibInfo
.getToken( 0, LIBINFO_SEP
, nInfoPos
) );
771 DBG_ASSERT( nInfoPos
< 0, "Invalid Lib-Info!" );
772 INetURLObject
aLibAbsStorage( aLibAbsStorageName
, INetProtocol::File
);
774 INetURLObject
aLibRelStorage( aStorName
);
775 aLibRelStorage
.removeSegment();
776 bool bWasAbsolute
= false;
777 aLibRelStorage
= aLibRelStorage
.smartRel2Abs( aLibRelStorageName
, bWasAbsolute
);
778 DBG_ASSERT(!bWasAbsolute
, "RelStorageName was absolute!" );
780 rtl::Reference
<SotStorage
> xStorageRef
;
781 if ( aLibAbsStorage
== aCurStorage
|| aLibRelStorageName
== szImbedded
)
783 xStorageRef
= &rStorage
;
787 xStorageRef
= new SotStorage( false, aLibAbsStorage
.GetMainURL
788 ( INetURLObject::DecodeMechanism::NONE
), eStorageReadMode
);
789 if ( xStorageRef
->GetError() != ERRCODE_NONE
)
790 xStorageRef
= new SotStorage( false, aLibRelStorage
.
791 GetMainURL( INetURLObject::DecodeMechanism::NONE
), eStorageReadMode
);
793 if ( xStorageRef
.is() )
795 AddLib( *xStorageRef
, aLibName
, false );
799 ErrCodeMsg
aErrInf( ERRCODE_BASMGR_LIBLOAD
, aStorName
, DialogMask::ButtonsOk
);
800 aErrors
.emplace_back(aErrInf
);
802 } while (nLibPos
>=0);
805 BasicManager::~BasicManager()
807 // Notify listener if something needs to be saved
808 Broadcast( SfxHint( SfxHintId::Dying
) );
811 bool BasicManager::HasExeCode( std::u16string_view sLib
)
813 StarBASIC
* pLib
= GetLib(sLib
);
816 for (const auto& pModule
: pLib
->GetModules())
818 if (pModule
->HasExeCode())
825 BasicLibInfo
* BasicManager::CreateLibInfo()
827 maLibs
.push_back(std::make_unique
<BasicLibInfo
>());
828 return maLibs
.back().get();
831 bool BasicManager::ImpLoadLibrary( BasicLibInfo
* pLibInfo
, SotStorage
* pCurStorage
)
834 DBG_ASSERT( pLibInfo
, "LibInfo!?" );
836 OUString
aStorageName( pLibInfo
->GetStorageName() );
837 if ( aStorageName
.isEmpty() || aStorageName
== szImbedded
)
839 aStorageName
= GetStorageName();
841 rtl::Reference
<SotStorage
> xStorage
;
842 // The current must not be opened again...
845 OUString
aStorName( pCurStorage
->GetName() );
846 // #i13114 removed, DBG_ASSERT( aStorName.Len(), "No Storage Name!" );
848 INetURLObject
aCurStorageEntry(aStorName
, INetProtocol::File
);
849 // #i13114 removed, DBG_ASSERT(aCurStorageEntry.GetMainURL( INetURLObject::DecodeMechanism::NONE ).Len() != 0, "Bad storage name");
851 INetURLObject
aStorageEntry(aStorageName
, INetProtocol::File
);
852 // #i13114 removed, DBG_ASSERT(aCurStorageEntry.GetMainURL( INetURLObject::DecodeMechanism::NONE ).Len() != 0, "Bad storage name");
854 if ( aCurStorageEntry
== aStorageEntry
)
856 xStorage
= pCurStorage
;
860 if ( !xStorage
.is() )
862 xStorage
= new SotStorage( false, aStorageName
, eStorageReadMode
);
864 rtl::Reference
<SotStorage
> xBasicStorage
= xStorage
->OpenSotStorage( szBasicStorage
, eStorageReadMode
, false );
866 if ( !xBasicStorage
.is() || xBasicStorage
->GetError() )
868 ErrCodeMsg
aErrInf( ERRCODE_BASMGR_MGROPEN
, xStorage
->GetName(), DialogMask::ButtonsOk
);
869 aErrors
.emplace_back(aErrInf
);
873 // In the Basic-Storage every lib is in a Stream...
874 rtl::Reference
<SotStorageStream
> xBasicStream
= xBasicStorage
->OpenSotStream( pLibInfo
->GetLibName(), eStreamReadMode
);
875 if ( !xBasicStream
.is() || xBasicStream
->GetError() )
877 ErrCodeMsg
aErrInf( ERRCODE_BASMGR_LIBLOAD
, pLibInfo
->GetLibName(), DialogMask::ButtonsOk
);
878 aErrors
.emplace_back(aErrInf
);
882 bool bLoaded
= false;
883 if ( xBasicStream
->TellEnd() != 0 )
885 if ( !pLibInfo
->GetLib().is() )
887 pLibInfo
->SetLib( new StarBASIC( GetStdLib(), mbDocMgr
) );
889 xBasicStream
->SetBufferSize( 1024 );
890 xBasicStream
->Seek( STREAM_SEEK_TO_BEGIN
);
891 bLoaded
= ImplLoadBasic( *xBasicStream
, pLibInfo
->GetLibRef() );
892 xBasicStream
->SetBufferSize( 0 );
893 StarBASICRef xStdLib
= pLibInfo
->GetLib();
894 xStdLib
->SetName( pLibInfo
->GetLibName() );
895 xStdLib
->SetModified( false );
896 xStdLib
->SetFlag( SbxFlagBits::DontStore
);
900 ErrCodeMsg
aErrInf( ERRCODE_BASMGR_LIBLOAD
, pLibInfo
->GetLibName(), DialogMask::ButtonsOk
);
901 aErrors
.emplace_back(aErrInf
);
905 // Perhaps there are additional information in the stream...
906 xBasicStream
->SetCryptMaskKey(szCryptingKey
);
907 xBasicStream
->RefreshBuffer();
908 sal_uInt32 nPasswordMarker
= 0;
909 xBasicStream
->ReadUInt32( nPasswordMarker
);
910 if ( ( nPasswordMarker
== PASSWORD_MARKER
) && !xBasicStream
->eof() )
912 OUString aPassword
= xBasicStream
->ReadUniOrByteString(
913 xBasicStream
->GetStreamCharSet());
914 pLibInfo
->SetPassword( aPassword
);
916 xBasicStream
->SetCryptMaskKey(OString());
917 CheckModules( pLibInfo
->GetLib().get(), pLibInfo
->IsReference() );
923 catch (const css::ucb::ContentCreationException
&)
929 bool BasicManager::ImplEncryptStream( SvStream
& rStrm
)
931 sal_uInt64
const nPos
= rStrm
.Tell();
933 rStrm
.ReadUInt32( nCreator
);
935 bool bProtected
= false;
936 if ( nCreator
!= SBXCR_SBX
)
938 // Should only be the case for encrypted Streams
940 rStrm
.SetCryptMaskKey(szCryptingKey
);
941 rStrm
.RefreshBuffer();
946 // This code is necessary to load the BASIC of Beta 1
947 // TODO: Which Beta 1?
948 bool BasicManager::ImplLoadBasic( SvStream
& rStrm
, StarBASICRef
& rOldBasic
) const
950 bool bProtected
= ImplEncryptStream( rStrm
);
951 SbxBaseRef xNew
= SbxBase::Load( rStrm
);
952 bool bLoaded
= false;
955 if( auto pNew
= dynamic_cast<StarBASIC
*>( xNew
.get() ) )
957 // Use the Parent of the old BASICs
960 pNew
->SetParent( rOldBasic
->GetParent() );
961 if( pNew
->GetParent() )
963 pNew
->GetParent()->Insert( pNew
);
965 pNew
->SetFlag( SbxFlagBits::ExtSearch
);
969 // Fill new library container (5.2 -> 6.0)
970 copyToLibraryContainer( pNew
, maContainerInfo
);
972 pNew
->SetModified( false );
978 rStrm
.SetCryptMaskKey(OString());
983 void BasicManager::CheckModules( StarBASIC
* pLib
, bool bReference
)
989 bool bModified
= pLib
->IsModified();
991 for ( const auto& pModule
: pLib
->GetModules() )
993 DBG_ASSERT(pModule
, "Module not received!");
994 if ( !pModule
->IsCompiled() && !StarBASIC::GetErrorCode() )
1000 // #67477, AB 8.12.99 On demand compile in referenced libs should not
1002 if( !bModified
&& bReference
)
1004 OSL_FAIL( "Referenced basic library is not compiled!" );
1005 pLib
->SetModified( false );
1009 StarBASIC
* BasicManager::AddLib( SotStorage
& rStorage
, const OUString
& rLibName
, bool bReference
)
1011 OUString
aStorName( rStorage
.GetName() );
1012 DBG_ASSERT( !aStorName
.isEmpty(), "No Storage Name!" );
1014 OUString aStorageName
= INetURLObject(aStorName
, INetProtocol::File
).GetMainURL( INetURLObject::DecodeMechanism::NONE
);
1015 DBG_ASSERT(!aStorageName
.isEmpty(), "Bad storage name");
1017 OUString
aNewLibName( rLibName
);
1018 while ( HasLib( aNewLibName
) )
1022 BasicLibInfo
* pLibInfo
= CreateLibInfo();
1023 // Use original name otherwise ImpLoadLibrary fails...
1024 pLibInfo
->SetLibName( rLibName
);
1025 // but doesn't work this way if name exists twice
1026 sal_uInt16 nLibId
= static_cast<sal_uInt16
>(maLibs
.size()) - 1;
1028 // Set StorageName before load because it is compared with pCurStorage
1029 pLibInfo
->SetStorageName( aStorageName
);
1030 bool bLoaded
= ImpLoadLibrary( pLibInfo
, &rStorage
);
1034 if ( aNewLibName
!= rLibName
)
1036 pLibInfo
->SetLibName(aNewLibName
);
1040 pLibInfo
->GetLib()->SetModified( false ); // Don't save in this case
1041 pLibInfo
->SetRelStorageName( OUString() );
1042 pLibInfo
->SetReference(true);
1046 pLibInfo
->GetLib()->SetModified( true ); // Must be saved after Add!
1047 pLibInfo
->SetStorageName( szImbedded
); // Save in BasicManager-Storage
1052 RemoveLib( nLibId
, false );
1056 return pLibInfo
? &*pLibInfo
->GetLib() : nullptr;
1060 bool BasicManager::IsReference( sal_uInt16 nLib
)
1062 DBG_ASSERT( nLib
< maLibs
.size(), "Lib does not exist!" );
1063 if ( nLib
< maLibs
.size() )
1065 return maLibs
[nLib
]->IsReference();
1070 void BasicManager::RemoveLib( sal_uInt16 nLib
)
1072 // Only physical deletion if no reference
1073 RemoveLib( nLib
, !IsReference( nLib
) );
1076 bool BasicManager::RemoveLib( sal_uInt16 nLib
, bool bDelBasicFromStorage
)
1078 DBG_ASSERT( nLib
, "Standard-Lib cannot be removed!" );
1080 DBG_ASSERT( !nLib
|| nLib
< maLibs
.size(), "Lib not found!" );
1082 if( !nLib
|| nLib
< maLibs
.size() )
1084 ErrCodeMsg
aErrInf( ERRCODE_BASMGR_REMOVELIB
, OUString(), DialogMask::ButtonsOk
);
1085 aErrors
.emplace_back(aErrInf
);
1089 auto const itLibInfo
= maLibs
.begin() + nLib
;
1091 // If one of the streams cannot be opened, this is not an error,
1092 // because BASIC was never written before...
1093 if (bDelBasicFromStorage
&& !(*itLibInfo
)->IsReference() &&
1094 (!(*itLibInfo
)->IsExtern() || SotStorage::IsStorageFile((*itLibInfo
)->GetStorageName())))
1096 rtl::Reference
<SotStorage
> xStorage
;
1099 if (!(*itLibInfo
)->IsExtern())
1101 xStorage
= new SotStorage(false, GetStorageName());
1105 xStorage
= new SotStorage(false, (*itLibInfo
)->GetStorageName());
1108 catch (const css::ucb::ContentCreationException
&)
1110 TOOLS_WARN_EXCEPTION("basic", "BasicManager::RemoveLib:");
1113 if (xStorage
.is() && xStorage
->IsStorage(szBasicStorage
))
1115 rtl::Reference
<SotStorage
> xBasicStorage
= xStorage
->OpenSotStorage
1116 ( szBasicStorage
, StreamMode::STD_READWRITE
, false );
1118 if ( !xBasicStorage
.is() || xBasicStorage
->GetError() )
1120 ErrCodeMsg
aErrInf( ERRCODE_BASMGR_REMOVELIB
, OUString(), DialogMask::ButtonsOk
);
1121 aErrors
.emplace_back(aErrInf
);
1123 else if (xBasicStorage
->IsStream((*itLibInfo
)->GetLibName()))
1125 xBasicStorage
->Remove((*itLibInfo
)->GetLibName());
1126 xBasicStorage
->Commit();
1128 // If no further stream available,
1129 // delete the SubStorage.
1130 SvStorageInfoList aInfoList
;
1131 xBasicStorage
->FillInfoList( &aInfoList
);
1132 if ( aInfoList
.empty() )
1134 xBasicStorage
.clear();
1135 xStorage
->Remove( szBasicStorage
);
1137 // If no further Streams or SubStorages available,
1138 // delete the Storage, too.
1140 xStorage
->FillInfoList( &aInfoList
);
1141 if ( aInfoList
.empty() )
1143 //OUString aName_( xStorage->GetName() );
1145 //*** TODO: Replace if still necessary
1146 //SfxContentHelper::Kill( aName );
1153 if ((*itLibInfo
)->GetLib().is())
1155 GetStdLib()->Remove( (*itLibInfo
)->GetLib().get() );
1157 maLibs
.erase(itLibInfo
);
1158 return true; // Remove was successful, del unimportant
1161 sal_uInt16
BasicManager::GetLibCount() const
1163 return static_cast<sal_uInt16
>(maLibs
.size());
1166 StarBASIC
* BasicManager::GetLib( sal_uInt16 nLib
) const
1168 DBG_ASSERT( nLib
< maLibs
.size(), "Lib does not exist!" );
1169 if ( nLib
< maLibs
.size() )
1171 return maLibs
[nLib
]->GetLib().get();
1176 StarBASIC
* BasicManager::GetStdLib() const
1178 StarBASIC
* pLib
= GetLib( 0 );
1182 StarBASIC
* BasicManager::GetLib( std::u16string_view rName
) const
1184 for (auto const& rpLib
: maLibs
)
1186 if (rpLib
->GetLibName().equalsIgnoreAsciiCase(rName
)) // Check if available...
1188 return rpLib
->GetLib().get();
1194 sal_uInt16
BasicManager::GetLibId( std::u16string_view rName
) const
1196 for (size_t i
= 0; i
< maLibs
.size(); i
++)
1198 if (maLibs
[i
]->GetLibName().equalsIgnoreAsciiCase( rName
))
1200 return static_cast<sal_uInt16
>(i
);
1203 return LIB_NOTFOUND
;
1206 bool BasicManager::HasLib( std::u16string_view rName
) const
1208 for (const auto& rpLib
: maLibs
)
1210 if (rpLib
->GetLibName().equalsIgnoreAsciiCase(rName
)) // Check if available...
1218 const OUString
& BasicManager::GetLibName( sal_uInt16 nLib
)
1220 DBG_ASSERT( nLib
< maLibs
.size(), "Lib?!" );
1221 if ( nLib
< maLibs
.size() )
1223 return maLibs
[nLib
]->GetLibName();
1225 return EMPTY_OUSTRING
;
1228 bool BasicManager::LoadLib( sal_uInt16 nLib
)
1231 DBG_ASSERT( nLib
< maLibs
.size() , "Lib?!" );
1232 if ( nLib
< maLibs
.size() )
1234 BasicLibInfo
& rLibInfo
= *maLibs
[nLib
];
1235 uno::Reference
< script::XLibraryContainer
> xLibContainer
= rLibInfo
.GetLibraryContainer();
1236 if( xLibContainer
.is() )
1238 OUString aLibName
= rLibInfo
.GetLibName();
1239 xLibContainer
->loadLibrary( aLibName
);
1240 bDone
= xLibContainer
->isLibraryLoaded( aLibName
);
1244 bDone
= ImpLoadLibrary( &rLibInfo
, nullptr );
1245 StarBASIC
* pLib
= GetLib( nLib
);
1248 GetStdLib()->Insert( pLib
);
1249 pLib
->SetFlag( SbxFlagBits::ExtSearch
);
1255 ErrCodeMsg
aErrInf( ERRCODE_BASMGR_LIBLOAD
, OUString(), DialogMask::ButtonsOk
);
1256 aErrors
.emplace_back(aErrInf
);
1261 StarBASIC
* BasicManager::CreateLib( const OUString
& rLibName
)
1263 if ( GetLib( rLibName
) )
1267 BasicLibInfo
* pLibInfo
= CreateLibInfo();
1268 StarBASIC
* pNew
= new StarBASIC( GetStdLib(), mbDocMgr
);
1269 GetStdLib()->Insert( pNew
);
1270 pNew
->SetFlag( SbxFlagBits::ExtSearch
| SbxFlagBits::DontStore
);
1271 pLibInfo
->SetLib( pNew
);
1272 pLibInfo
->SetLibName( rLibName
);
1273 pLibInfo
->GetLib()->SetName( rLibName
);
1274 return pLibInfo
->GetLib().get();
1277 // For XML import/export:
1278 StarBASIC
* BasicManager::CreateLib( const OUString
& rLibName
, const OUString
& Password
,
1279 const OUString
& LinkTargetURL
)
1281 // Ask if lib exists because standard lib is always there
1282 StarBASIC
* pLib
= GetLib( rLibName
);
1285 if( !LinkTargetURL
.isEmpty())
1289 rtl::Reference
<SotStorage
> xStorage
= new SotStorage(false, LinkTargetURL
, StreamMode::READ
| StreamMode::SHARE_DENYWRITE
);
1290 if (!xStorage
->GetError())
1292 pLib
= AddLib(*xStorage
, rLibName
, true);
1295 catch (const css::ucb::ContentCreationException
&)
1297 TOOLS_WARN_EXCEPTION("basic", "BasicManager::RemoveLib:");
1299 DBG_ASSERT( pLib
, "XML Import: Linked basic library could not be loaded");
1303 pLib
= CreateLib( rLibName
);
1304 if( Password
.isEmpty())
1306 BasicLibInfo
* pLibInfo
= FindLibInfo( pLib
);
1307 pLibInfo
->SetPassword( Password
);
1310 //ExternalSourceURL ?
1315 StarBASIC
* BasicManager::CreateLibForLibContainer( const OUString
& rLibName
,
1316 const uno::Reference
< script::XLibraryContainer
>& xScriptCont
)
1318 if ( GetLib( rLibName
) )
1322 BasicLibInfo
* pLibInfo
= CreateLibInfo();
1323 StarBASIC
* pNew
= new StarBASIC( GetStdLib(), mbDocMgr
);
1324 GetStdLib()->Insert( pNew
);
1325 pNew
->SetFlag( SbxFlagBits::ExtSearch
| SbxFlagBits::DontStore
);
1326 pLibInfo
->SetLib( pNew
);
1327 pLibInfo
->SetLibName( rLibName
);
1328 pLibInfo
->GetLib()->SetName( rLibName
);
1329 pLibInfo
->SetLibraryContainer( xScriptCont
);
1334 BasicLibInfo
* BasicManager::FindLibInfo( StarBASIC
const * pBasic
)
1336 for (auto const& rpLib
: maLibs
)
1338 if (rpLib
->GetLib().get() == pBasic
)
1347 bool BasicManager::IsBasicModified() const
1349 for (auto const& rpLib
: maLibs
)
1351 if (rpLib
->GetLib().is() && rpLib
->GetLib()->IsModified())
1360 bool BasicManager::GetGlobalUNOConstant( const OUString
& rName
, uno::Any
& aOut
)
1363 StarBASIC
* pStandardLib
= GetStdLib();
1364 OSL_PRECOND( pStandardLib
, "BasicManager::GetGlobalUNOConstant: no lib to read from!" );
1366 bRes
= pStandardLib
->GetUNOConstant( rName
, aOut
);
1370 void BasicManager::SetGlobalUNOConstant( const OUString
& rName
, const uno::Any
& _rValue
, css::uno::Any
* pOldValue
)
1372 StarBASIC
* pStandardLib
= GetStdLib();
1373 OSL_PRECOND( pStandardLib
, "BasicManager::SetGlobalUNOConstant: no lib to insert into!" );
1374 if ( !pStandardLib
)
1379 // obtain the old value
1380 SbxVariable
* pVariable
= pStandardLib
->Find( rName
, SbxClassType::Object
);
1382 *pOldValue
= sbxToUnoValue( pVariable
);
1384 SbxObjectRef xUnoObj
= GetSbUnoObject( _rValue
.getValueTypeName () , _rValue
);
1385 xUnoObj
->SetName(rName
);
1386 xUnoObj
->SetFlag( SbxFlagBits::DontStore
);
1387 pStandardLib
->Insert( xUnoObj
.get() );
1390 bool BasicManager::ImgVersion12PsswdBinaryLimitExceeded( std::vector
< OUString
>& _out_rModuleNames
)
1394 uno::Reference
< container::XNameAccess
> xScripts( GetScriptLibraryContainer(), uno::UNO_QUERY_THROW
);
1395 uno::Reference
< script::XLibraryContainerPassword
> xPassword( GetScriptLibraryContainer(), uno::UNO_QUERY_THROW
);
1397 const uno::Sequence
< OUString
> aNames( xScripts
->getElementNames() );
1398 for ( auto const & scriptElementName
: aNames
)
1400 if( !xPassword
->isLibraryPasswordProtected( scriptElementName
) )
1403 StarBASIC
* pBasicLib
= GetLib( scriptElementName
);
1407 uno::Reference
< container::XNameAccess
> xScriptLibrary( xScripts
->getByName( scriptElementName
), uno::UNO_QUERY_THROW
);
1408 const uno::Sequence
< OUString
> aElementNames( xScriptLibrary
->getElementNames() );
1410 std::vector
<OUString
> aBigModules
;
1411 for ( auto const & libraryElementName
: aElementNames
)
1413 SbModule
* pMod
= pBasicLib
->FindModule( libraryElementName
);
1414 if ( pMod
&& pMod
->ExceedsImgVersion12ModuleSize() )
1415 aBigModules
.push_back(libraryElementName
);
1418 if (!aBigModules
.empty())
1420 _out_rModuleNames
.swap(aBigModules
);
1425 catch( const uno::Exception
& )
1427 DBG_UNHANDLED_EXCEPTION("basic");
1435 SbMethod
* lcl_queryMacro( BasicManager
* i_manager
, OUString
const& i_fullyQualifiedName
)
1437 sal_Int32 nLast
= 0;
1438 const OUString sLibName
{i_fullyQualifiedName
.getToken( 0, '.', nLast
)};
1439 const OUString sModule
{i_fullyQualifiedName
.getToken( 0, '.', nLast
)};
1443 sMacro
= i_fullyQualifiedName
.copy(nLast
);
1447 sMacro
= i_fullyQualifiedName
;
1450 utl::TransliterationWrapper
& rTransliteration
= SbGlobal::GetTransliteration();
1451 sal_uInt16 nLibCount
= i_manager
->GetLibCount();
1452 for ( sal_uInt16 nLib
= 0; nLib
< nLibCount
; ++nLib
)
1454 if ( rTransliteration
.isEqual( i_manager
->GetLibName( nLib
), sLibName
) )
1456 StarBASIC
* pLib
= i_manager
->GetLib( nLib
);
1459 bool const bLoaded
= i_manager
->LoadLib( nLib
);
1462 pLib
= i_manager
->GetLib( nLib
);
1468 for ( const auto& pMod
: pLib
->GetModules() )
1470 if ( rTransliteration
.isEqual( pMod
->GetName(), sModule
) )
1472 SbMethod
* pMethod
= static_cast<SbMethod
*>(pMod
->Find( sMacro
, SbxClassType::Method
));
1486 bool BasicManager::HasMacro( OUString
const& i_fullyQualifiedName
) const
1488 return ( lcl_queryMacro( const_cast< BasicManager
* >( this ), i_fullyQualifiedName
) != nullptr );
1491 ErrCode
BasicManager::ExecuteMacro( OUString
const& i_fullyQualifiedName
, SbxArray
* i_arguments
, SbxValue
* i_retValue
)
1493 SbMethod
* pMethod
= lcl_queryMacro( this, i_fullyQualifiedName
);
1494 ErrCode nError
= ERRCODE_NONE
;
1498 pMethod
->SetParameters( i_arguments
);
1499 nError
= pMethod
->Call( i_retValue
);
1502 nError
= ERRCODE_BASIC_PROC_UNDEFINED
;
1506 ErrCode
BasicManager::ExecuteMacro( OUString
const& i_fullyQualifiedName
, std::u16string_view i_commaSeparatedArgs
, SbxValue
* i_retValue
)
1508 SbMethod
* pMethod
= lcl_queryMacro( this, i_fullyQualifiedName
);
1511 return ERRCODE_BASIC_PROC_UNDEFINED
;
1513 // arguments must be quoted
1514 OUString sQuotedArgs
;
1515 OUStringBuffer
sArgs( i_commaSeparatedArgs
);
1516 if ( sArgs
.getLength()<2 || sArgs
[1] == '\"')
1518 // no args or already quoted args
1519 sQuotedArgs
= sArgs
.makeStringAndClear();
1524 sArgs
.remove( 0, 1 );
1525 sArgs
.remove( sArgs
.getLength() - 1, 1 );
1527 OUStringBuffer aBuff
;
1528 OUString sArgs2
= sArgs
.makeStringAndClear();
1531 if (!sArgs2
.isEmpty())
1537 aBuff
.append( OUString::Concat("\"")
1538 + o3tl::getToken(sArgs2
, 0, ',', nPos
)
1542 aBuff
.append( "," );
1545 aBuff
.append( ")" );
1547 sQuotedArgs
= aBuff
.makeStringAndClear();
1550 // add quoted arguments and do the call
1551 OUString sCall
= "["
1552 + pMethod
->GetName()
1556 SbxVariable
* pRet
= pMethod
->GetParent()->Execute( sCall
);
1557 if ( pRet
&& ( pRet
!= pMethod
) )
1559 *i_retValue
= *pRet
;
1561 return SbxBase::GetError();
1566 class ModuleInfo_Impl
: public ModuleInfoHelper
1569 OUString maLanguage
;
1573 ModuleInfo_Impl( OUString aName
, OUString aLanguage
, OUString aSource
)
1574 : maName(std::move( aName
)), maLanguage(std::move( aLanguage
)), maSource(std::move( aSource
)) {}
1576 // Methods XStarBasicModuleInfo
1577 virtual OUString SAL_CALL
getName() override
1579 virtual OUString SAL_CALL
getLanguage() override
1580 { return maLanguage
; }
1581 virtual OUString SAL_CALL
getSource() override
1582 { return maSource
; }
1586 class DialogInfo_Impl
: public WeakImplHelper
< script::XStarBasicDialogInfo
>
1589 uno::Sequence
< sal_Int8
> mData
;
1592 DialogInfo_Impl( OUString aName
, const uno::Sequence
< sal_Int8
>& Data
)
1593 : maName(std::move( aName
)), mData( Data
) {}
1595 // Methods XStarBasicDialogInfo
1596 virtual OUString SAL_CALL
getName() override
1598 virtual uno::Sequence
< sal_Int8
> SAL_CALL
getData() override
1603 class LibraryInfo_Impl
: public WeakImplHelper
< script::XStarBasicLibraryInfo
>
1606 uno::Reference
< container::XNameContainer
> mxModuleContainer
;
1607 uno::Reference
< container::XNameContainer
> mxDialogContainer
;
1608 OUString maPassword
;
1609 OUString maExternaleSourceURL
;
1610 OUString maLinkTargetURL
;
1616 uno::Reference
< container::XNameContainer
> xModuleContainer
,
1617 uno::Reference
< container::XNameContainer
> xDialogContainer
,
1619 OUString aExternaleSourceURL
,
1620 OUString aLinkTargetURL
1622 : maName(std::move( aName
))
1623 , mxModuleContainer(std::move( xModuleContainer
))
1624 , mxDialogContainer(std::move( xDialogContainer
))
1625 , maPassword(std::move( aPassword
))
1626 , maExternaleSourceURL(std::move( aExternaleSourceURL
))
1627 , maLinkTargetURL(std::move( aLinkTargetURL
))
1630 // Methods XStarBasicLibraryInfo
1631 virtual OUString SAL_CALL
getName() override
1633 virtual uno::Reference
< container::XNameContainer
> SAL_CALL
getModuleContainer() override
1634 { return mxModuleContainer
; }
1635 virtual uno::Reference
< container::XNameContainer
> SAL_CALL
getDialogContainer() override
1636 { return mxDialogContainer
; }
1637 virtual OUString SAL_CALL
getPassword() override
1638 { return maPassword
; }
1639 virtual OUString SAL_CALL
getExternalSourceURL() override
1640 { return maExternaleSourceURL
; }
1641 virtual OUString SAL_CALL
getLinkTargetURL() override
1642 { return maLinkTargetURL
; }
1646 class ModuleContainer_Impl
: public NameContainerHelper
1651 explicit ModuleContainer_Impl( StarBASIC
* pLib
)
1654 // Methods XElementAccess
1655 virtual uno::Type SAL_CALL
getElementType() override
;
1656 virtual sal_Bool SAL_CALL
hasElements() override
;
1658 // Methods XNameAccess
1659 virtual uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
1660 virtual uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
1661 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
1663 // Methods XNameReplace
1664 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const uno::Any
& aElement
) override
;
1666 // Methods XNameContainer
1667 virtual void SAL_CALL
insertByName( const OUString
& aName
, const uno::Any
& aElement
) override
;
1668 virtual void SAL_CALL
removeByName( const OUString
& Name
) override
;
1673 // Methods XElementAccess
1674 uno::Type
ModuleContainer_Impl::getElementType()
1676 uno::Type aModuleType
= cppu::UnoType
<script::XStarBasicModuleInfo
>::get();
1680 sal_Bool
ModuleContainer_Impl::hasElements()
1682 return mpLib
&& !mpLib
->GetModules().empty();
1685 // Methods XNameAccess
1686 uno::Any
ModuleContainer_Impl::getByName( const OUString
& aName
)
1688 SbModule
* pMod
= mpLib
? mpLib
->FindModule( aName
) : nullptr;
1690 throw container::NoSuchElementException();
1691 uno::Reference
< script::XStarBasicModuleInfo
> xMod
= new ModuleInfo_Impl( aName
, u
"StarBasic"_ustr
, pMod
->GetSource32() );
1697 uno::Sequence
< OUString
> ModuleContainer_Impl::getElementNames()
1699 sal_uInt16 nMods
= mpLib
? mpLib
->GetModules().size() : 0;
1700 uno::Sequence
< OUString
> aRetSeq( nMods
);
1701 OUString
* pRetSeq
= aRetSeq
.getArray();
1702 for( sal_uInt16 i
= 0 ; i
< nMods
; i
++ )
1704 pRetSeq
[i
] = mpLib
->GetModules()[i
]->GetName();
1709 sal_Bool
ModuleContainer_Impl::hasByName( const OUString
& aName
)
1711 SbModule
* pMod
= mpLib
? mpLib
->FindModule( aName
) : nullptr;
1712 bool bRet
= (pMod
!= nullptr);
1717 // Methods XNameReplace
1718 void ModuleContainer_Impl::replaceByName( const OUString
& aName
, const uno::Any
& aElement
)
1720 removeByName( aName
);
1721 insertByName( aName
, aElement
);
1725 // Methods XNameContainer
1726 void ModuleContainer_Impl::insertByName( const OUString
& aName
, const uno::Any
& aElement
)
1728 uno::Type aModuleType
= cppu::UnoType
<script::XStarBasicModuleInfo
>::get();
1729 const uno::Type
& aAnyType
= aElement
.getValueType();
1730 if( aModuleType
!= aAnyType
)
1732 throw lang::IllegalArgumentException(u
"types do not match"_ustr
, getXWeak(), 2);
1734 uno::Reference
< script::XStarBasicModuleInfo
> xMod
;
1736 mpLib
->MakeModule( aName
, xMod
->getSource() );
1739 void ModuleContainer_Impl::removeByName( const OUString
& Name
)
1741 SbModule
* pMod
= mpLib
? mpLib
->FindModule( Name
) : nullptr;
1744 throw container::NoSuchElementException();
1746 mpLib
->Remove( pMod
);
1750 static uno::Sequence
< sal_Int8
> implGetDialogData( SbxObject
* pDialog
)
1752 SvMemoryStream aMemStream
;
1753 pDialog
->Store( aMemStream
);
1754 sal_Int32 nLen
= aMemStream
.Tell();
1755 if (nLen
< 0) { abort(); }
1756 uno::Sequence
< sal_Int8
> aData( nLen
);
1757 sal_Int8
* pDestData
= aData
.getArray();
1758 const sal_Int8
* pSrcData
= static_cast<const sal_Int8
*>(aMemStream
.GetData());
1759 memcpy( pDestData
, pSrcData
, nLen
);
1763 static SbxObjectRef
implCreateDialog( const uno::Sequence
< sal_Int8
>& aData
)
1765 sal_Int8
* pData
= const_cast< uno::Sequence
< sal_Int8
>& >(aData
).getArray();
1766 SvMemoryStream
aMemStream( pData
, aData
.getLength(), StreamMode::READ
);
1767 SbxBaseRef pBase
= SbxBase::Load( aMemStream
);
1768 return dynamic_cast<SbxObject
*>(pBase
.get());
1771 // HACK! Because this value is defined in basctl/inc/vcsbxdef.hxx
1772 // which we can't include here, we have to use the value directly
1773 #define SBXID_DIALOG 101
1777 class DialogContainer_Impl
: public NameContainerHelper
1782 explicit DialogContainer_Impl( StarBASIC
* pLib
)
1785 // Methods XElementAccess
1786 virtual uno::Type SAL_CALL
getElementType() override
;
1787 virtual sal_Bool SAL_CALL
hasElements() override
;
1789 // Methods XNameAccess
1790 virtual uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
1791 virtual uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
1792 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
1794 // Methods XNameReplace
1795 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const uno::Any
& aElement
) override
;
1797 // Methods XNameContainer
1798 virtual void SAL_CALL
insertByName( const OUString
& aName
, const uno::Any
& aElement
) override
;
1799 virtual void SAL_CALL
removeByName( const OUString
& Name
) override
;
1804 // Methods XElementAccess
1805 uno::Type
DialogContainer_Impl::getElementType()
1807 uno::Type aModuleType
= cppu::UnoType
<script::XStarBasicDialogInfo
>::get();
1811 sal_Bool
DialogContainer_Impl::hasElements()
1815 sal_Int32 nCount
= mpLib
->GetObjects()->Count();
1816 for( sal_Int32 nObj
= 0; nObj
< nCount
; nObj
++ )
1818 SbxVariable
* pVar
= mpLib
->GetObjects()->Get( nObj
);
1819 SbxObject
* pObj
= dynamic_cast<SbxObject
*>(pVar
);
1820 if ( pObj
&& (pObj
->GetSbxId() == SBXID_DIALOG
) )
1829 // Methods XNameAccess
1830 uno::Any
DialogContainer_Impl::getByName( const OUString
& aName
)
1832 SbxVariable
* pVar
= mpLib
->GetObjects()->Find( aName
, SbxClassType::DontCare
);
1833 SbxObject
* pObj
= dynamic_cast<SbxObject
*>(pVar
);
1834 if( !( pObj
&& pObj
->GetSbxId() == SBXID_DIALOG
) )
1836 throw container::NoSuchElementException();
1839 uno::Reference
< script::XStarBasicDialogInfo
> xDialog
=
1840 new DialogInfo_Impl(aName
, implGetDialogData(pObj
));
1843 aRetAny
<<= xDialog
;
1847 uno::Sequence
< OUString
> DialogContainer_Impl::getElementNames()
1849 sal_Int32 nCount
= mpLib
->GetObjects()->Count();
1850 uno::Sequence
< OUString
> aRetSeq( nCount
);
1851 OUString
* pRetSeq
= aRetSeq
.getArray();
1852 sal_Int32 nDialogCounter
= 0;
1854 for( sal_Int32 nObj
= 0; nObj
< nCount
; nObj
++ )
1856 SbxVariable
* pVar
= mpLib
->GetObjects()->Get( nObj
);
1857 SbxObject
* pObj
= dynamic_cast<SbxObject
*> (pVar
);
1858 if ( pObj
&& ( pObj
->GetSbxId() == SBXID_DIALOG
) )
1860 pRetSeq
[ nDialogCounter
] = pVar
->GetName();
1864 aRetSeq
.realloc( nDialogCounter
);
1868 sal_Bool
DialogContainer_Impl::hasByName( const OUString
& aName
)
1871 SbxVariable
* pVar
= mpLib
->GetObjects()->Find( aName
, SbxClassType::DontCare
);
1872 SbxObject
* pObj
= dynamic_cast<SbxObject
*>(pVar
);
1873 if( pObj
&& ( pObj
->GetSbxId() == SBXID_DIALOG
) )
1881 // Methods XNameReplace
1882 void DialogContainer_Impl::replaceByName( const OUString
& aName
, const uno::Any
& aElement
)
1884 removeByName( aName
);
1885 insertByName( aName
, aElement
);
1889 // Methods XNameContainer
1890 void DialogContainer_Impl::insertByName( const OUString
&, const uno::Any
& aElement
)
1892 uno::Type aModuleType
= cppu::UnoType
<script::XStarBasicDialogInfo
>::get();
1893 const uno::Type
& aAnyType
= aElement
.getValueType();
1894 if( aModuleType
!= aAnyType
)
1896 throw lang::IllegalArgumentException(u
"types do not match"_ustr
, getXWeak(), 2);
1898 uno::Reference
< script::XStarBasicDialogInfo
> xMod
;
1900 SbxObjectRef xDialog
= implCreateDialog( xMod
->getData() );
1901 mpLib
->Insert( xDialog
.get() );
1904 void DialogContainer_Impl::removeByName( const OUString
& Name
)
1906 SbxVariable
* pVar
= mpLib
->GetObjects()->Find( Name
, SbxClassType::DontCare
);
1907 SbxObject
* pObj
= dynamic_cast<SbxObject
*>(pVar
);
1908 if( !( pObj
&& ( pObj
->GetSbxId() == SBXID_DIALOG
) ) )
1910 throw container::NoSuchElementException();
1912 mpLib
->Remove( pVar
);
1916 class LibraryContainer_Impl
: public NameContainerHelper
1918 BasicManager
* mpMgr
;
1921 explicit LibraryContainer_Impl( BasicManager
* pMgr
)
1924 // Methods XElementAccess
1925 virtual uno::Type SAL_CALL
getElementType() override
;
1926 virtual sal_Bool SAL_CALL
hasElements() override
;
1928 // Methods XNameAccess
1929 virtual uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
1930 virtual uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
1931 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
1933 // Methods XNameReplace
1934 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const uno::Any
& aElement
) override
;
1936 // Methods XNameContainer
1937 virtual void SAL_CALL
insertByName( const OUString
& aName
, const uno::Any
& aElement
) override
;
1938 virtual void SAL_CALL
removeByName( const OUString
& Name
) override
;
1942 // Methods XElementAccess
1943 uno::Type
LibraryContainer_Impl::getElementType()
1945 uno::Type aType
= cppu::UnoType
<script::XStarBasicLibraryInfo
>::get();
1949 sal_Bool
LibraryContainer_Impl::hasElements()
1951 sal_Int32 nLibs
= mpMgr
->GetLibCount();
1952 bool bRet
= (nLibs
> 0);
1956 // Methods XNameAccess
1957 uno::Any
LibraryContainer_Impl::getByName( const OUString
& aName
)
1960 if( !mpMgr
->HasLib( aName
) )
1961 throw container::NoSuchElementException();
1962 StarBASIC
* pLib
= mpMgr
->GetLib( aName
);
1964 uno::Reference
< container::XNameContainer
> xModuleContainer
=
1965 new ModuleContainer_Impl( pLib
);
1967 uno::Reference
< container::XNameContainer
> xDialogContainer
=
1968 new DialogContainer_Impl( pLib
);
1970 BasicLibInfo
* pLibInfo
= mpMgr
->FindLibInfo( pLib
);
1972 OUString aPassword
= pLibInfo
->GetPassword();
1974 // TODO Only provide extern info!
1975 OUString aExternaleSourceURL
;
1976 OUString aLinkTargetURL
;
1977 if( pLibInfo
->IsReference() )
1979 aLinkTargetURL
= pLibInfo
->GetStorageName();
1981 else if( pLibInfo
->IsExtern() )
1983 aExternaleSourceURL
= pLibInfo
->GetStorageName();
1985 uno::Reference
< script::XStarBasicLibraryInfo
> xLibInfo
= new LibraryInfo_Impl
1991 aExternaleSourceURL
,
1995 aRetAny
<<= xLibInfo
;
1999 uno::Sequence
< OUString
> LibraryContainer_Impl::getElementNames()
2001 sal_uInt16 nLibs
= mpMgr
->GetLibCount();
2002 uno::Sequence
< OUString
> aRetSeq( nLibs
);
2003 OUString
* pRetSeq
= aRetSeq
.getArray();
2004 for( sal_uInt16 i
= 0 ; i
< nLibs
; i
++ )
2006 pRetSeq
[i
] = mpMgr
->GetLibName( i
);
2011 sal_Bool
LibraryContainer_Impl::hasByName( const OUString
& aName
)
2013 bool bRet
= mpMgr
->HasLib( aName
);
2017 // Methods XNameReplace
2018 void LibraryContainer_Impl::replaceByName( const OUString
& aName
, const uno::Any
& aElement
)
2020 removeByName( aName
);
2021 insertByName( aName
, aElement
);
2024 // Methods XNameContainer
2025 void LibraryContainer_Impl::insertByName( const OUString
&, const uno::Any
& )
2027 // TODO: Insert a complete Library?!
2030 void LibraryContainer_Impl::removeByName( const OUString
& Name
)
2032 StarBASIC
* pLib
= mpMgr
->GetLib( Name
);
2035 throw container::NoSuchElementException();
2037 sal_uInt16 nLibId
= mpMgr
->GetLibId( Name
);
2038 mpMgr
->RemoveLib( nLibId
);
2042 typedef WeakImplHelper
< script::XStarBasicAccess
> StarBasicAccessHelper
;
2045 class StarBasicAccess_Impl
: public StarBasicAccessHelper
2047 BasicManager
* mpMgr
;
2048 rtl::Reference
< LibraryContainer_Impl
> mxLibContainer
;
2051 explicit StarBasicAccess_Impl( BasicManager
* pMgr
)
2056 virtual uno::Reference
< container::XNameContainer
> SAL_CALL
getLibraryContainer() override
;
2057 virtual void SAL_CALL
createLibrary( const OUString
& LibName
, const OUString
& Password
,
2058 const OUString
& ExternalSourceURL
, const OUString
& LinkTargetURL
) override
;
2059 virtual void SAL_CALL
addModule( const OUString
& LibraryName
, const OUString
& ModuleName
,
2060 const OUString
& Language
, const OUString
& Source
) override
;
2061 virtual void SAL_CALL
addDialog( const OUString
& LibraryName
, const OUString
& DialogName
,
2062 const uno::Sequence
< sal_Int8
>& Data
) override
;
2065 uno::Reference
< container::XNameContainer
> SAL_CALL
StarBasicAccess_Impl::getLibraryContainer()
2067 if( !mxLibContainer
.is() )
2068 mxLibContainer
= new LibraryContainer_Impl( mpMgr
);
2069 return mxLibContainer
;
2072 void SAL_CALL
StarBasicAccess_Impl::createLibrary
2074 const OUString
& LibName
,
2075 const OUString
& Password
,
2077 const OUString
& LinkTargetURL
2080 StarBASIC
* pLib
= mpMgr
->CreateLib( LibName
, Password
, LinkTargetURL
);
2081 DBG_ASSERT( pLib
, "XML Import: Basic library could not be created");
2084 void SAL_CALL
StarBasicAccess_Impl::addModule
2086 const OUString
& LibraryName
,
2087 const OUString
& ModuleName
,
2089 const OUString
& Source
2092 StarBASIC
* pLib
= mpMgr
->GetLib( LibraryName
);
2093 DBG_ASSERT( pLib
, "XML Import: Lib for module unknown");
2096 pLib
->MakeModule( ModuleName
, Source
);
2100 void SAL_CALL
StarBasicAccess_Impl::addDialog
2104 const uno::Sequence
< sal_Int8
>&
2108 // Basic XML Import/Export
2109 uno::Reference
< script::XStarBasicAccess
> getStarBasicAccess( BasicManager
* pMgr
)
2111 uno::Reference
< script::XStarBasicAccess
> xRet
=
2112 new StarBasicAccess_Impl( pMgr
);
2116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */