namespace basic
{ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::frame::XModel; using ::com::sun::star::frame::Desktop; using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::embed::XStorage; using ::com::sun::star::script::XStorageBasedLibraryContainer; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::Exception; using ::com::sun::star::document::XStorageBasedDocument; using ::com::sun::star::document::XEmbeddedScripts;
/** creates the application-wide BasicManager
*/
BasicManager* impl_createApplicationBasicManager();
/** notifies all listeners which expressed interest in the creation of BasicManager instances.
*/ void impl_notifyCreationListeners( const Reference< XModel >& _rxDocumentModel,
BasicManager& _rManager
);
/** retrieves the current storage of a given document
/** initializes the given library containers, which belong to a document
*/ staticvoid impl_initDocLibraryContainers_nothrow( const Reference<XStorageBasedLibraryContainer>& _rxBasicLibraries, const Reference<XStorageBasedLibraryContainer>& _rxDialogLibraries
);
ImplRepository::~ImplRepository()
{ // Avoid double-delete of managers when they are destroyed in our dtor, and start notify us for (auto& it : m_aStore)
EndListening(*it.second);
}
/* #163556# (DR) - This function may be called recursively while constructingtheBasicmanagerandloadingtheBasicstorage.By passingthemapentryreceivedfromimpl_getLocationForModel()to thefunctionimpl_createManagerForModel(),thenewBasicmanager willbeputimmediatelyintothemapofexistingBasicmanagers, thusarecursivecallofthisfunctionwillfindandreturnit withoutcreatinganotherinstance.
*/ autoconst loc = impl_getLocationForModel( _rxDocumentModel ); if (loc->second != nullptr) return loc->second.get(); if (impl_createManagerForModel(loc, _rxDocumentModel)) return loc->second.get(); return nullptr;
}
// Create basic and load it // AppBasicDir is now a PATH
INetURLObject aAppBasic( SvtPathOptions().SubstituteVariable(u"$(progurl)"_ustr) );
aAppBasic.insertName( Application::GetAppName() );
BasicManager* pBasicManager = new BasicManager( new StarBASIC, &aAppBasicDir );
setApplicationBasicManager( std::unique_ptr<BasicManager>(pBasicManager) );
// The first dir in the path as destination:
OUString aFileName( aAppBasic.getName() );
aAppBasic = INetURLObject( o3tl::getToken(aAppBasicDir, 1, ';') );
DBG_ASSERT(aAppBasic.GetProtocol() != INetProtocol::NotValid,
OString("Invalid URL: \"" +
OUStringToOString(aAppBasicDir, osl_getThreadTextEncoding()) + "\"").getStr());
aAppBasic.insertName( aFileName );
pBasicManager->SetStorageName( aAppBasic.PathToFileName() );
_out_rpBasicManager = nullptr;
Reference< XStorage > xStorage; if ( !impl_getDocumentStorage_nothrow( _rxDocumentModel, xStorage ) )
{
m_aStore.erase(location); // the document is not able to provide the storage it is based on. returnfalse;
}
Reference<XStorageBasedLibraryContainer> xBasicLibs;
Reference<XStorageBasedLibraryContainer> xDialogLibs; if ( !impl_getDocumentLibraryContainers_nothrow( _rxDocumentModel, xBasicLibs, xDialogLibs ) )
{
m_aStore.erase(location); // the document does not have BasicLibraries and DialogLibraries returnfalse;
}
// register as listener for this model being disposed/closed
OSL_ENSURE( _rxDocumentModel.is(), "ImplRepository::impl_createManagerForModel: the document must be an XComponent!" );
assert(impl_hasLocationForModel(_rxDocumentModel));
startComponentListening( _rxDocumentModel );
bool bOk = false; // startComponentListening may fail in a disposed _rxDocumentModel, in which case _out_rpBasicManager will be removed // from the map and destroyed if (impl_hasLocationForModel(_rxDocumentModel))
{
bOk = true; // register as listener for the BasicManager being destroyed
StartListening( *_out_rpBasicManager );
}
// #i104876: Library container must not be modified just after // creation. This happens as side effect when creating default // "Standard" libraries and needs to be corrected here
xBasicLibs->setModified( false );
xDialogLibs->setModified( false ); return bOk;
}
BasicManagerStore::iterator it = std::find_if(m_aStore.begin(), m_aStore.end(),
[&xNormalizedSource](BasicManagerStore::reference rEntry) { return rEntry.first.get() == xNormalizedSource.get(); }); if (it != m_aStore.end())
{
impl_removeFromRepository( it ); return;
}
OSL_FAIL( "ImplRepository::_disposing: where does this come from?" );
}
void ImplRepository::Notify( SfxBroadcaster& _rBC, const SfxHint& _rHint )
{ if ( _rHint.GetId() != SfxHintId::Dying ) // not interested in return;
BasicManager* pManager = dynamic_cast< BasicManager* >( &_rBC );
OSL_ENSURE( pManager, "ImplRepository::Notify: where does this come from?" );
BasicManagerStore::iterator it = std::find_if(m_aStore.begin(), m_aStore.end(),
[&pManager](BasicManagerStore::reference rEntry) { return rEntry.second.get() == pManager; }); if (it != m_aStore.end())
{ // a BasicManager which is still in our repository is being deleted. // That's bad, since by definition, we *own* all instances in our // repository.
OSL_FAIL( "ImplRepository::Notify: nobody should tamper with the managers, except ourself!" );
m_aStore.erase( it );
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.