avoid uno casting cost, and simplify

these are always XStorageBasedLibraryContainers, so transport
around as that and can avoid casting and some expensive throw/catches

Change-Id: I772efceea3bb4f38d70be0497345f5f81173494c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181156
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
This commit is contained in:
Caolán McNamara 2025-02-05 10:22:46 +00:00
parent 09a351281a
commit 7daf54c93d
22 changed files with 106 additions and 141 deletions

View File

@ -1124,7 +1124,7 @@ void EditorWindow::CreateEditEngine()
// set readonly mode for readonly libraries
ScriptDocument aDocument(rModulWindow.GetDocument());
OUString aOULibName(rModulWindow.GetLibName());
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
if (xModLibContainer.is()
&& xModLibContainer->hasByName(aOULibName)
&& xModLibContainer->isLibraryReadOnly(aOULibName))

View File

@ -95,7 +95,7 @@ DialogWindow::DialogWindow(DialogWindowLayout* pParent, ScriptDocument const& rD
SetHelpId( HID_BASICIDE_DIALOGWINDOW );
// set readonly mode for readonly libraries
Reference< script::XLibraryContainer2 > xDlgLibContainer( GetDocument().getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( GetDocument().getLibraryContainer( E_DIALOGS ) );
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) )
SetReadOnly(true);

View File

@ -1278,8 +1278,8 @@ void Shell::GetState(SfxItemSet &rSet)
case SID_BASICIDE_NEWMODULE:
case SID_BASICIDE_NEWDIALOG:
{
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ) );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ) );
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( m_aCurLibName ) && xModLibContainer->isLibraryReadOnly( m_aCurLibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( m_aCurLibName ) && xDlgLibContainer->isLibraryReadOnly( m_aCurLibName ) ) )
rSet.DisableItem(nWh);

View File

@ -383,8 +383,8 @@ void MacroChooser::CheckButtons()
{
const ScriptDocument& aDocument( aDesc.GetDocument() );
const OUString& aOULibName( aDesc.GetLibName() );
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ) );
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) )
{

View File

@ -274,8 +274,8 @@ IMPL_LINK(LibPage, EditingEntryHdl, const weld::TreeIter&, rIter, bool)
}
// check, if library is readonly
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ) );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ) );
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) && !xModLibContainer->isLibraryLink( aLibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) && !xDlgLibContainer->isLibraryLink( aLibName ) ) )
{
@ -317,11 +317,11 @@ IMPL_LINK(LibPage, EditedEntryHdl, const IterString&, rIterString, bool)
{
try
{
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ) );
if ( xModLibContainer.is() )
xModLibContainer->renameLibrary( aOldName, sNewName );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ) );
if ( xDlgLibContainer.is() )
xDlgLibContainer->renameLibrary( aOldName, sNewName );
@ -378,8 +378,8 @@ void LibPage::CheckButtons()
return;
OUString aLibName = m_xLibBox->get_text(*xCur, 0);
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ) );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ) );
if ( m_eCurLocation == LIBRARY_LOCATION_SHARE )
{
@ -735,9 +735,9 @@ void ImportLib(const ScriptDocument& rDocument, weld::Dialog* pDialog,
{
OUString aLibName(rView.get_text(nLib));
Reference<script::XLibraryContainer2> xModLibContainer(
rDocument.getLibraryContainer(E_SCRIPTS), UNO_QUERY);
rDocument.getLibraryContainer(E_SCRIPTS));
Reference<script::XLibraryContainer2> xDlgLibContainer(
rDocument.getLibraryContainer(E_DIALOGS), UNO_QUERY);
rDocument.getLibraryContainer(E_DIALOGS));
// check, if the library is already existing
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) ) ||
@ -958,8 +958,7 @@ void ImportLib(const ScriptDocument& rDocument, weld::Dialog* pDialog,
void Export(const ScriptDocument& rDocument, const OUString& aLibName, weld::Dialog* pDialog)
{
// Password verification
Reference<script::XLibraryContainer2> xModLibContainer(rDocument.getLibraryContainer(E_SCRIPTS),
UNO_QUERY);
Reference<script::XLibraryContainer2> xModLibContainer(rDocument.getLibraryContainer(E_SCRIPTS));
if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && !xModLibContainer->isLibraryLoaded( aLibName ) )
{
@ -1190,8 +1189,8 @@ void LibPage::DeleteCurrent()
// check, if library is link
bool bIsLibraryLink = false;
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ) );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ) );
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryLink( aLibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryLink( aLibName ) ) )
{
@ -1280,7 +1279,7 @@ void LibPage::ImpInsertLibEntry( const OUString& rLibName, int nPos )
{
// check, if library is password protected
bool bProtected = false;
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ) );
if ( xModLibContainer.is() && xModLibContainer->hasByName( rLibName ) )
{
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
@ -1374,9 +1373,9 @@ void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
// cannot be renamed/moved since the SfxLibraryContainer::renameLibrary
// moves the folders/files on the file system
Reference<script::XLibraryContainer2> xModLibContainer(
rDocument.getLibraryContainer(E_SCRIPTS), UNO_QUERY);
rDocument.getLibraryContainer(E_SCRIPTS));
Reference<script::XLibraryContainer2> xDlgLibContainer(
rDocument.getLibraryContainer(E_DIALOGS), UNO_QUERY);
rDocument.getLibraryContainer(E_DIALOGS));
Reference<script::XPersistentLibraryContainer> xModPersLibContainer(xModLibContainer,
UNO_QUERY);
if (xModPersLibContainer.is())

View File

@ -64,8 +64,8 @@ IMPL_LINK(ObjectPage, EditingEntryHdl, const weld::TreeIter&, rEntry, bool)
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(&rEntry);
const ScriptDocument& aDocument( aDesc.GetDocument() );
const OUString& aLibName( aDesc.GetLibName() );
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ) );
if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
{
@ -283,8 +283,8 @@ private:
const ScriptDocument& aDocument( aDesc.GetDocument() );
const OUString& aLibName( aDesc.GetLibName() );
// allow MOVE mode only for libraries, which are not readonly
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ) );
if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
{
@ -355,7 +355,7 @@ private:
const OUString& aDestLibName = aDestDesc.GetLibName();
// check if module library is not loaded, readonly or password protected
Reference< script::XLibraryContainer2 > xModLibContainer( rDestDoc.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xModLibContainer( rDestDoc.getLibraryContainer( E_SCRIPTS ) );
if ( xModLibContainer.is() && xModLibContainer->hasByName( aDestLibName ) )
{
if ( !xModLibContainer->isLibraryLoaded( aDestLibName ) )
@ -370,7 +370,7 @@ private:
}
// check if dialog library is not loaded or readonly
Reference< script::XLibraryContainer2 > xDlgLibContainer( rDestDoc.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( rDestDoc.getLibraryContainer( E_DIALOGS ) );
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aDestLibName ) )
{
if ( !xDlgLibContainer->isLibraryLoaded( aDestLibName ) )
@ -647,8 +647,8 @@ void ObjectPage::CheckButtons()
bool bReadOnly = false;
if ( nDepth > 0 )
{
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ) );
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) )
{

View File

@ -75,6 +75,7 @@ namespace basctl
using ::com::sun::star::frame::XModel;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::script::XLibraryContainer;
using ::com::sun::star::script::XStorageBasedLibraryContainer;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::uno::UNO_SET_THROW;
using ::com::sun::star::uno::Exception;
@ -206,7 +207,7 @@ namespace basctl
getDocumentRef() const { return m_xDocument; }
/// returns a library container belonging to the document
Reference< XLibraryContainer >
Reference< XStorageBasedLibraryContainer >
getLibraryContainer( LibraryContainerType _eType ) const;
/// determines whether a given library is part of the shared installation
@ -332,23 +333,22 @@ namespace basctl
return m_bValid;
}
Reference< XLibraryContainer > ScriptDocument::Impl::getLibraryContainer( LibraryContainerType _eType ) const
Reference<XStorageBasedLibraryContainer> ScriptDocument::Impl::getLibraryContainer( LibraryContainerType _eType ) const
{
OSL_ENSURE( isValid(), "ScriptDocument::Impl::getLibraryContainer: invalid!" );
Reference< XLibraryContainer > xContainer;
Reference<XStorageBasedLibraryContainer> xContainer;
if ( !isValid() )
return xContainer;
try
{
if ( isApplication() )
xContainer.set( _eType == E_SCRIPTS ? SfxGetpApp()->GetBasicContainer() : SfxGetpApp()->GetDialogContainer(), UNO_QUERY_THROW );
xContainer.set(_eType == E_SCRIPTS ? SfxGetpApp()->GetBasicContainer() : SfxGetpApp()->GetDialogContainer());
else
{
xContainer.set(
_eType == E_SCRIPTS ? m_xScriptAccess->getBasicLibraries() : m_xScriptAccess->getDialogLibraries(),
UNO_QUERY_THROW );
_eType == E_SCRIPTS ? m_xScriptAccess->getBasicLibraries() : m_xScriptAccess->getDialogLibraries());
}
}
catch( const Exception& )
@ -1160,7 +1160,7 @@ namespace basctl
}
Reference< XLibraryContainer > ScriptDocument::getLibraryContainer( LibraryContainerType _eType ) const
Reference< XStorageBasedLibraryContainer > ScriptDocument::getLibraryContainer( LibraryContainerType _eType ) const
{
return m_pImpl->getLibraryContainer( _eType );
}

View File

@ -55,7 +55,7 @@ namespace basic
using ::com::sun::star::uno::XInterface;
using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::embed::XStorage;
using ::com::sun::star::script::XPersistentLibraryContainer;
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;
@ -168,15 +168,15 @@ namespace basic
*/
static bool impl_getDocumentLibraryContainers_nothrow(
const Reference< XModel >& _rxDocument,
Reference< XPersistentLibraryContainer >& _out_rxBasicLibraries,
Reference< XPersistentLibraryContainer >& _out_rxDialogLibraries
Reference<XStorageBasedLibraryContainer>& _out_rxBasicLibraries,
Reference<XStorageBasedLibraryContainer>& _out_rxDialogLibraries
);
/** initializes the given library containers, which belong to a document
*/
static void impl_initDocLibraryContainers_nothrow(
const Reference< XPersistentLibraryContainer >& _rxBasicLibraries,
const Reference< XPersistentLibraryContainer >& _rxDialogLibraries
const Reference<XStorageBasedLibraryContainer>& _rxBasicLibraries,
const Reference<XStorageBasedLibraryContainer>& _rxDialogLibraries
);
// OEventListenerAdapter overridables
@ -374,7 +374,7 @@ namespace basic
return m_aStore.find(xNormalized) != m_aStore.end();
}
void ImplRepository::impl_initDocLibraryContainers_nothrow( const Reference< XPersistentLibraryContainer >& _rxBasicLibraries, const Reference< XPersistentLibraryContainer >& _rxDialogLibraries )
void ImplRepository::impl_initDocLibraryContainers_nothrow( const Reference<XStorageBasedLibraryContainer>& _rxBasicLibraries, const Reference<XStorageBasedLibraryContainer>& _rxDialogLibraries )
{
OSL_PRECOND( _rxBasicLibraries.is() && _rxDialogLibraries.is(),
"ImplRepository::impl_initDocLibraryContainers_nothrow: illegal library containers, this will crash!" );
@ -413,8 +413,8 @@ namespace basic
// the document is not able to provide the storage it is based on.
return false;
}
Reference< XPersistentLibraryContainer > xBasicLibs;
Reference< XPersistentLibraryContainer > xDialogLibs;
Reference<XStorageBasedLibraryContainer> xBasicLibs;
Reference<XStorageBasedLibraryContainer> xDialogLibs;
if ( !impl_getDocumentLibraryContainers_nothrow( _rxDocumentModel, xBasicLibs, xDialogLibs ) )
{
m_aStore.erase(location);
@ -519,15 +519,15 @@ namespace basic
bool ImplRepository::impl_getDocumentLibraryContainers_nothrow( const Reference< XModel >& _rxDocument,
Reference< XPersistentLibraryContainer >& _out_rxBasicLibraries, Reference< XPersistentLibraryContainer >& _out_rxDialogLibraries )
Reference<XStorageBasedLibraryContainer>& _out_rxBasicLibraries, Reference<XStorageBasedLibraryContainer>& _out_rxDialogLibraries )
{
_out_rxBasicLibraries.clear();
_out_rxDialogLibraries.clear();
try
{
Reference< XEmbeddedScripts > xScripts( _rxDocument, UNO_QUERY_THROW );
_out_rxBasicLibraries.set( xScripts->getBasicLibraries(), UNO_QUERY_THROW );
_out_rxDialogLibraries.set( xScripts->getDialogLibraries(), UNO_QUERY_THROW );
_out_rxBasicLibraries.set( xScripts->getBasicLibraries() );
_out_rxDialogLibraries.set( xScripts->getDialogLibraries() );
}
catch( const Exception& )
{

View File

@ -510,12 +510,12 @@ static void copyToLibraryContainer( StarBASIC* pBasic, const LibraryContainerInf
}
}
const uno::Reference< script::XPersistentLibraryContainer >& BasicManager::GetDialogLibraryContainer() const
const uno::Reference< script::XStorageBasedLibraryContainer >& BasicManager::GetDialogLibraryContainer() const
{
return maContainerInfo.mxDialogCont;
}
const uno::Reference< script::XPersistentLibraryContainer >& BasicManager::GetScriptLibraryContainer() const
const uno::Reference< script::XStorageBasedLibraryContainer >& BasicManager::GetScriptLibraryContainer() const
{
return maContainerInfo.mxScriptCont;
}

View File

@ -413,7 +413,7 @@ void ScriptContainersListBox::Insert(
OUString aLibName = m_xTreeView->get_text(*xNewEntryIter);
css::uno::Reference<css::script::XLibraryContainer2> xModLibContainer(
aDocument.getLibraryContainer(basctl::E_SCRIPTS), css::uno::UNO_QUERY);
aDocument.getLibraryContainer(basctl::E_SCRIPTS));
if (xModLibContainer.is() && xModLibContainer->hasByName(aLibName))
{
css::uno::Reference<css::script::XLibraryContainerPassword> xPasswd(
@ -572,7 +572,7 @@ IMPL_LINK(ScriptContainersListBox, QueryTooltip, const weld::TreeIter&, rEntryIt
return OUString();
css::uno::Reference<css::script::XLibraryContainer2> xModLibContainer(
aDocument.getLibraryContainer(basctl::E_SCRIPTS), css::uno::UNO_QUERY);
aDocument.getLibraryContainer(basctl::E_SCRIPTS));
// check for linked library
OUString aLibName = m_xTreeView->get_text(rEntryIter);
if (xModLibContainer.is() && xModLibContainer->hasByName(aLibName)
@ -605,7 +605,7 @@ IMPL_LINK(ScriptContainersListBox, ExpandingHdl, const weld::TreeIter&, rEntryIt
// check if the library is password protected
css::uno::Reference<css::script::XLibraryContainer2> xModLibContainer(
aDocument.getLibraryContainer(basctl::E_SCRIPTS), css::uno::UNO_QUERY);
aDocument.getLibraryContainer(basctl::E_SCRIPTS));
if (xModLibContainer.is() && xModLibContainer->hasByName(aLibName))
{
css::uno::Reference<css::script::XLibraryContainerPassword> xPasswd(
@ -963,7 +963,7 @@ void MacroManagerDialog::UpdateUI()
{
// if this is a Basic linked library use the link url name for the description string
css::uno::Reference<css::script::XLibraryContainer2> xModLibContainer(
aDocument.getLibraryContainer(basctl::E_SCRIPTS), css::uno::UNO_QUERY);
aDocument.getLibraryContainer(basctl::E_SCRIPTS));
OUString aLibName = rTreeView.get_text(*xSelectedIter);
if (xModLibContainer.is() && xModLibContainer->hasByName(aLibName)
&& xModLibContainer->isLibraryLink(aLibName))
@ -1077,7 +1077,7 @@ void MacroManagerDialog::CheckButtons()
{
// check, if library is readonly
css::uno::Reference<css::script::XLibraryContainer2> xModLibContainer(
aDocument.getLibraryContainer(basctl::E_SCRIPTS), css::uno::UNO_QUERY);
aDocument.getLibraryContainer(basctl::E_SCRIPTS));
bool bReadOnly = xModLibContainer.is() && xModLibContainer->hasByName(aLibName)
&& xModLibContainer->isLibraryReadOnly(aLibName);
@ -1111,9 +1111,9 @@ void MacroManagerDialog::CheckButtons()
ScriptContainerType::LIBRARY);
css::uno::Reference<css::script::XLibraryContainer2> xModLibContainer(
aDocument.getLibraryContainer(basctl::E_SCRIPTS), css::uno::UNO_QUERY);
aDocument.getLibraryContainer(basctl::E_SCRIPTS));
css::uno::Reference<css::script::XLibraryContainer2> xDlgLibContainer(
aDocument.getLibraryContainer(basctl::E_DIALOGS), css::uno::UNO_QUERY);
aDocument.getLibraryContainer(basctl::E_DIALOGS));
bool bReadOnly
= (xModLibContainer.is() && xModLibContainer->hasByName(aLibName)
@ -1261,7 +1261,7 @@ void MacroManagerDialog::BasicScriptsCreateLibrary(const basctl::ScriptDocument&
// cannot be renamed/moved since the SfxLibraryContainer::renameLibrary
// moves the folders/files on the file system
css::uno::Reference<css::script::XLibraryContainer2> xModLibContainer(
rDocument.getLibraryContainer(basctl::E_SCRIPTS), css::uno::UNO_QUERY);
rDocument.getLibraryContainer(basctl::E_SCRIPTS));
css::uno::Reference<css::script::XPersistentLibraryContainer> xModPersLibContainer(
xModLibContainer, css::uno::UNO_QUERY);
if (xModPersLibContainer.is())
@ -1684,9 +1684,9 @@ bool MacroManagerDialog::IsLibraryReadOnlyOrFailedPasswordQuery(
const basctl::ScriptDocument& rDocument, weld::TreeIter* pIter)
{
css::uno::Reference<css::script::XLibraryContainer2> xModLibContainer(
rDocument.getLibraryContainer(basctl::E_SCRIPTS), css::uno::UNO_QUERY);
rDocument.getLibraryContainer(basctl::E_SCRIPTS));
css::uno::Reference<css::script::XLibraryContainer2> xDlgLibContainer(
rDocument.getLibraryContainer(basctl::E_DIALOGS), css::uno::UNO_QUERY);
rDocument.getLibraryContainer(basctl::E_DIALOGS));
OUString aLibName
= m_xScriptContainersListBox->GetContainerName(*pIter, ScriptContainerType::LIBRARY);
@ -1772,11 +1772,11 @@ void MacroManagerDialog::BasicScriptsLibraryModuleDialogRename(
try
{
css::uno::Reference<css::script::XLibraryContainer2> xModLibContainer(
rDocument.getLibraryContainer(basctl::E_SCRIPTS), css::uno::UNO_QUERY);
rDocument.getLibraryContainer(basctl::E_SCRIPTS));
if (xModLibContainer.is() && xModLibContainer->hasByName(sOldName))
xModLibContainer->renameLibrary(sOldName, sNewName);
css::uno::Reference<css::script::XLibraryContainer2> xDlgLibContainer(
rDocument.getLibraryContainer(basctl::E_DIALOGS), css::uno::UNO_QUERY);
rDocument.getLibraryContainer(basctl::E_DIALOGS));
if (xDlgLibContainer.is() && xDlgLibContainer->hasByName(sOldName))
xDlgLibContainer->renameLibrary(sOldName, sNewName);
}
@ -1860,9 +1860,9 @@ void MacroManagerDialog::BasicScriptsLibraryModuleDialogDelete(
// check, if library is link
bool bIsLibraryLink = false;
css::uno::Reference<css::script::XLibraryContainer2> xModLibContainer(
rDocument.getLibraryContainer(basctl::E_SCRIPTS), css::uno::UNO_QUERY);
rDocument.getLibraryContainer(basctl::E_SCRIPTS));
css::uno::Reference<css::script::XLibraryContainer2> xDlgLibContainer(
rDocument.getLibraryContainer(basctl::E_DIALOGS), css::uno::UNO_QUERY);
rDocument.getLibraryContainer(basctl::E_DIALOGS));
if ((xModLibContainer.is() && xModLibContainer->hasByName(aLibName)
&& xModLibContainer->isLibraryLink(aLibName))
|| (xDlgLibContainer.is() && xDlgLibContainer->hasByName(aLibName)

View File

@ -21,7 +21,7 @@
#include "basctldllapi.h"
#include <com/sun/star/script/XLibraryContainer.hpp>
#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
#include <com/sun/star/io/XInputStreamProvider.hpp>
@ -208,7 +208,7 @@ namespace basctl
If the document is not valid, <NULL/> is returned.
*/
css::uno::Reference< css::script::XLibraryContainer >
css::uno::Reference< css::script::XStorageBasedLibraryContainer >
getLibraryContainer( LibraryContainerType _eType ) const;
/** determines whether there exists a library of the given type, with the given name

View File

@ -29,7 +29,7 @@
namespace basic { class SfxScriptLibraryContainer; }
namespace com::sun::star::script { class XLibraryContainer; }
namespace com::sun::star::script { class XPersistentLibraryContainer; }
namespace com::sun::star::script { class XStorageBasedLibraryContainer; }
namespace com::sun::star::script { class XStarBasicAccess; }
class BasicManager;
@ -58,8 +58,8 @@ namespace basic { class ImplRepository; }
struct LibraryContainerInfo
{
css::uno::Reference< css::script::XPersistentLibraryContainer > mxScriptCont;
css::uno::Reference< css::script::XPersistentLibraryContainer > mxDialogCont;
css::uno::Reference< css::script::XStorageBasedLibraryContainer > mxScriptCont;
css::uno::Reference< css::script::XStorageBasedLibraryContainer > mxDialogCont;
basic::SfxScriptLibraryContainer* mpOldBasicPassword;
LibraryContainerInfo()
@ -69,8 +69,8 @@ struct LibraryContainerInfo
LibraryContainerInfo
(
css::uno::Reference< css::script::XPersistentLibraryContainer > xScriptCont,
css::uno::Reference< css::script::XPersistentLibraryContainer > xDialogCont,
css::uno::Reference< css::script::XStorageBasedLibraryContainer > xScriptCont,
css::uno::Reference< css::script::XStorageBasedLibraryContainer > xDialogCont,
basic::SfxScriptLibraryContainer* pOldBasicPassword
)
: mxScriptCont(std::move( xScriptCont ))
@ -136,9 +136,9 @@ public:
*/
void SetLibraryContainerInfo( const LibraryContainerInfo& rInfo );
const css::uno::Reference< css::script::XPersistentLibraryContainer >&
const css::uno::Reference< css::script::XStorageBasedLibraryContainer >&
GetDialogLibraryContainer() const;
const css::uno::Reference< css::script::XPersistentLibraryContainer >&
const css::uno::Reference< css::script::XStorageBasedLibraryContainer >&
GetScriptLibraryContainer() const;
bool LoadLib( sal_uInt16 nLib );

View File

@ -33,7 +33,7 @@
#include <sfx2/shell.hxx>
namespace com::sun::star::frame { class XFrame; }
namespace com::sun::star::script { class XLibraryContainer; }
namespace com::sun::star::script { class XStorageBasedLibraryContainer; }
namespace weld { class Window; }
@ -156,8 +156,8 @@ public:
static ErrCode CallAppBasic( const OUString& i_macroName )
{ return CallBasic( i_macroName, SfxApplication::GetBasicManager(), nullptr, nullptr ); }
static BasicManager* GetBasicManager();
css::script::XLibraryContainer * GetDialogContainer();
css::script::XLibraryContainer * GetBasicContainer();
css::script::XStorageBasedLibraryContainer* GetDialogContainer();
css::script::XStorageBasedLibraryContainer* GetBasicContainer();
static StarBASIC* GetBasic();
void SaveBasicAndDialogContainer() const;

View File

@ -103,7 +103,7 @@ namespace com::sun::star::document { class XDocumentProperties; }
namespace com::sun::star::embed { class XStorage; }
namespace com::sun::star::graphic { class XGraphic; }
namespace com::sun::star::io { class XStream; }
namespace com::sun::star::script { class XLibraryContainer; }
namespace com::sun::star::script { class XStorageBasedLibraryContainer ; }
namespace com::sun::star::security { class XCertificate; }
namespace com::sun::star::security { class XDocumentDigitalSignatures; }
namespace com::sun::star::security { struct DocumentSignatureInformation; }
@ -576,9 +576,9 @@ public:
sal_uInt16 GetAutoStyleFilterIndex() const;
bool HasBasic() const;
BasicManager* GetBasicManager() const;
css::uno::Reference< css::script::XLibraryContainer >
css::uno::Reference< css::script::XStorageBasedLibraryContainer >
GetBasicContainer();
css::uno::Reference< css::script::XLibraryContainer >
css::uno::Reference< css::script::XStorageBasedLibraryContainer >
GetDialogContainer();
StarBASIC* GetBasic() const;

View File

@ -23,7 +23,7 @@
#include <cassert>
#include <com/sun/star/script/XLibraryContainer.hpp>
#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
#include <officecfg/Office/Common.hxx>
#include <svl/intitem.hxx>
#include <svl/eitem.hxx>
@ -70,7 +70,7 @@ BasicManager* SfxApplication::GetBasicManager()
#endif
}
XLibraryContainer * SfxApplication::GetDialogContainer()
XStorageBasedLibraryContainer* SfxApplication::GetDialogContainer()
{
#if !HAVE_FEATURE_SCRIPTING
return nullptr;
@ -84,7 +84,7 @@ XLibraryContainer * SfxApplication::GetDialogContainer()
}
XLibraryContainer * SfxApplication::GetBasicContainer()
XStorageBasedLibraryContainer* SfxApplication::GetBasicContainer()
{
#if !HAVE_FEATURE_SCRIPTING
return nullptr;

View File

@ -67,15 +67,8 @@ void SfxBasicManagerHolder::reset( BasicManager* _pBasicManager )
return;
StartListening(*mpBasicManager);
try
{
mxBasicContainer.set( mpBasicManager->GetScriptLibraryContainer(), UNO_QUERY_THROW );
mxDialogContainer.set( mpBasicManager->GetDialogLibraryContainer(), UNO_QUERY_THROW );
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("sfx.appl");
}
mxBasicContainer.set( mpBasicManager->GetScriptLibraryContainer() );
mxDialogContainer.set( mpBasicManager->GetDialogLibraryContainer() );
#endif
}
@ -130,7 +123,7 @@ void SfxBasicManagerHolder::storeLibrariesToStorage( const Reference< XStorage >
#endif
}
XLibraryContainer * SfxBasicManagerHolder::getLibraryContainer( ContainerType _eType )
XStorageBasedLibraryContainer* SfxBasicManagerHolder::getLibraryContainer( ContainerType _eType )
{
OSL_PRECOND( isValid(), "SfxBasicManagerHolder::getLibraryContainer: not initialized!" );
@ -167,7 +160,7 @@ com_sun_star_comp_sfx2_ApplicationDialogLibraryContainer_get_implementation(
css::uno::Sequence<css::uno::Any> const &)
{
SfxApplication::GetBasicManager();
css::uno::XInterface* pRet = SfxGetpApp()->GetDialogContainer();
css::uno::XInterface* pRet = static_cast<css::script::XLibraryContainer*>(SfxGetpApp()->GetDialogContainer());
pRet->acquire();
return pRet;
}
@ -179,7 +172,7 @@ com_sun_star_comp_sfx2_ApplicationScriptLibraryContainer_get_implementation(
css::uno::Sequence<css::uno::Any> const &)
{
SfxApplication::GetBasicManager();
css::uno::XInterface* pRet = SfxGetpApp()->GetBasicContainer();
css::uno::XInterface* pRet = static_cast<css::script::XLibraryContainer*>(SfxGetpApp()->GetBasicContainer());
pRet->acquire();
return pRet;
}

View File

@ -2280,23 +2280,10 @@ bool SfxObjectShell::ConnectTmpStorage_Impl(
{
pImpl->aBasicManager.setStorage( xTmpStorage );
// Get rid of this workaround after issue i113914 is fixed
try
{
uno::Reference< script::XStorageBasedLibraryContainer > xBasicLibraries( pImpl->xBasicLibraries, uno::UNO_QUERY );
if (xBasicLibraries)
xBasicLibraries->setRootStorage( xTmpStorage );
}
catch( uno::Exception& )
{}
try
{
uno::Reference< script::XStorageBasedLibraryContainer > xDialogLibraries( pImpl->xDialogLibraries, uno::UNO_QUERY );
if (xDialogLibraries)
xDialogLibraries->setRootStorage( xTmpStorage );
}
catch( uno::Exception& )
{}
if (pImpl->xBasicLibraries)
pImpl->xBasicLibraries->setRootStorage( xTmpStorage );
if (pImpl->xDialogLibraries)
pImpl->xDialogLibraries->setRootStorage( xTmpStorage );
}
}
catch( uno::Exception& )
@ -2446,23 +2433,10 @@ bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed, bool bRegisterRecent )
// Set storage in document library containers
pImpl->aBasicManager.setStorage( xStorage );
// Get rid of this workaround after issue i113914 is fixed
try
{
uno::Reference< script::XStorageBasedLibraryContainer > xBasicLibraries( pImpl->xBasicLibraries, uno::UNO_QUERY );
if (xBasicLibraries)
xBasicLibraries->setRootStorage( xStorage );
}
catch( uno::Exception& )
{}
try
{
uno::Reference< script::XStorageBasedLibraryContainer > xDialogLibraries( pImpl->xDialogLibraries, uno::UNO_QUERY );
if (xDialogLibraries)
xDialogLibraries->setRootStorage( xStorage );
}
catch( uno::Exception& )
{}
if (pImpl->xBasicLibraries)
pImpl->xBasicLibraries->setRootStorage( xStorage );
if (pImpl->xDialogLibraries)
pImpl->xDialogLibraries->setRootStorage( xStorage );
}
else
{

View File

@ -717,8 +717,8 @@ bool SfxObjectShell::HasBasic() const
#if HAVE_FEATURE_SCRIPTING
namespace
{
const Reference< XLibraryContainer >&
lcl_getOrCreateLibraryContainer( bool _bScript, Reference< XLibraryContainer >& _rxContainer,
const Reference< XStorageBasedLibraryContainer >&
lcl_getOrCreateLibraryContainer( bool _bScript, Reference< XStorageBasedLibraryContainer >& _rxContainer,
const Reference< XModel >& _rxDocument )
{
if ( !_rxContainer.is() )
@ -732,8 +732,7 @@ namespace
? DocumentScriptLibraryContainer::create(
xContext, xStorageDoc )
: DocumentDialogLibraryContainer::create(
xContext, xStorageDoc )
, UNO_QUERY_THROW );
xContext, xStorageDoc ));
}
catch (const Exception&)
{
@ -745,7 +744,7 @@ namespace
}
#endif
Reference< XLibraryContainer > SfxObjectShell::GetDialogContainer()
Reference< XStorageBasedLibraryContainer > SfxObjectShell::GetDialogContainer()
{
#if HAVE_FEATURE_SCRIPTING
try
@ -767,7 +766,7 @@ Reference< XLibraryContainer > SfxObjectShell::GetDialogContainer()
return SfxGetpApp()->GetDialogContainer();
}
Reference< XLibraryContainer > SfxObjectShell::GetBasicContainer()
Reference< XStorageBasedLibraryContainer > SfxObjectShell::GetBasicContainer()
{
#if HAVE_FEATURE_SCRIPTING
if (!comphelper::IsFuzzing())

View File

@ -2473,7 +2473,7 @@ Reference< script::XStorageBasedLibraryContainer > SAL_CALL SfxBaseModel::getBas
Reference< script::XStorageBasedLibraryContainer > xBasicLibraries;
if ( m_pData->m_pObjectShell.is() )
xBasicLibraries.set(m_pData->m_pObjectShell->GetBasicContainer(), UNO_QUERY);
xBasicLibraries.set(m_pData->m_pObjectShell->GetBasicContainer());
return xBasicLibraries;
}
@ -2483,7 +2483,7 @@ Reference< script::XStorageBasedLibraryContainer > SAL_CALL SfxBaseModel::getDia
Reference< script::XStorageBasedLibraryContainer > xDialogLibraries;
if ( m_pData->m_pObjectShell.is() )
xDialogLibraries.set(m_pData->m_pObjectShell->GetDialogContainer(), UNO_QUERY);
xDialogLibraries.set(m_pData->m_pObjectShell->GetDialogContainer());
return xDialogLibraries;
}

View File

@ -62,7 +62,7 @@ public:
*/
void reset( BasicManager* _pBasicManager );
css::script::XLibraryContainer *
css::script::XStorageBasedLibraryContainer*
getLibraryContainer( ContainerType _eType );
/** calls the storeLibraries at both our script and basic library container

View File

@ -55,9 +55,9 @@ struct SfxObjectShell_Impl final : public ::sfx2::IMacroDocumentAccess
std::unique_ptr<::comphelper::EmbeddedObjectContainer> mxObjectContainer;
SfxBasicManagerHolder aBasicManager;
SfxObjectShell& rDocShell;
css::uno::Reference< css::script::XLibraryContainer >
css::uno::Reference< css::script::XStorageBasedLibraryContainer >
xBasicLibraries;
css::uno::Reference< css::script::XLibraryContainer >
css::uno::Reference< css::script::XStorageBasedLibraryContainer >
xDialogLibraries;
::sfx2::DocumentMacroMode
aMacroMode;

View File

@ -30,7 +30,7 @@
#include <com/sun/star/document/XEventsSupplier.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/script/XLibraryContainer.hpp>
#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <fmtfld.hxx>
@ -114,7 +114,7 @@ void SwHTMLParser::EndScript()
aLibName = "Standard";
// get module library container
Reference< script::XLibraryContainer > xModLibContainer = pDocSh->GetBasicContainer();
Reference< script::XStorageBasedLibraryContainer > xModLibContainer = pDocSh->GetBasicContainer();
if ( xModLibContainer.is() )
{
@ -156,7 +156,7 @@ void SwHTMLParser::EndScript()
}
// get dialog library container
Reference< script::XLibraryContainer > xDlgLibContainer = pDocSh->GetDialogContainer();
Reference< script::XStorageBasedLibraryContainer > xDlgLibContainer = pDocSh->GetDialogContainer();
if ( xDlgLibContainer.is() )
{