summaryrefslogtreecommitdiffstats
path: root/dbaccess/source/core/dataaccess/ModelImpl.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/core/dataaccess/ModelImpl.cxx')
-rw-r--r--dbaccess/source/core/dataaccess/ModelImpl.cxx183
1 files changed, 88 insertions, 95 deletions
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index 49a74717e559..818e70b5433b 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -48,7 +48,7 @@
#include <comphelper/processfactory.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/signaturestate.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <osl/file.hxx>
#include <osl/diagnose.h>
#include <sal/log.hxx>
@@ -58,11 +58,11 @@
#include <i18nlangtag/languagetag.hxx>
#include <algorithm>
+#include <utility>
using namespace css;
using namespace ::com::sun::star::document;
using namespace ::com::sun::star::sdbc;
-using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
@@ -71,9 +71,7 @@ using namespace ::com::sun::star::embed;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::io;
-using namespace ::com::sun::star::ucb;
using namespace ::com::sun::star::frame;
-using namespace ::com::sun::star::view;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::script;
using namespace ::cppu;
@@ -353,7 +351,7 @@ void SAL_CALL DocumentStorageAccess::disposing( const css::lang::EventObject& So
// ODatabaseModelImpl
ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XComponentContext >& _rxContext, ODatabaseContext& _rDBContext )
- :m_aContainer(4)
+ :m_aContainer()
,m_aMacroMode( *this )
,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE )
,m_rDBContext( _rDBContext )
@@ -369,7 +367,6 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XComponentContext >& _r
,m_bModified(false)
,m_bDocumentReadOnly(false)
,m_bMacroCallsSeenWhileLoading(false)
- ,m_pSharedConnectionManager(nullptr)
,m_nControllerLockCount(0)
{
// some kind of default
@@ -379,11 +376,11 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XComponentContext >& _r
}
ODatabaseModelImpl::ODatabaseModelImpl(
- const OUString& _rRegistrationName,
+ OUString _sRegistrationName,
const Reference< XComponentContext >& _rxContext,
ODatabaseContext& _rDBContext
)
- :m_aContainer(4)
+ :m_aContainer()
,m_aMacroMode( *this )
,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE )
,m_rDBContext( _rDBContext )
@@ -392,7 +389,7 @@ ODatabaseModelImpl::ODatabaseModelImpl(
,m_bDocumentInitialized( false )
,m_nScriptingSignatureState(SignatureState::UNKNOWN)
,m_aContext( _rxContext )
- ,m_sName(_rRegistrationName)
+ ,m_sName(std::move(_sRegistrationName))
,m_nLoginTimeout(0)
,m_bReadOnly(false)
,m_bPasswordRequired(false)
@@ -400,7 +397,6 @@ ODatabaseModelImpl::ODatabaseModelImpl(
,m_bModified(false)
,m_bDocumentReadOnly(false)
,m_bMacroCallsSeenWhileLoading(false)
- ,m_pSharedConnectionManager(nullptr)
,m_nControllerLockCount(0)
{
impl_construct_nothrow();
@@ -441,7 +437,7 @@ void ODatabaseModelImpl::impl_construct_nothrow()
pSettings->ValueType,
PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT | PropertyAttribute::MAYBEVOID
);
- xSettingsSet->insert( makeAny( aProperty ) );
+ xSettingsSet->insert( Any( aProperty ) );
}
else
{
@@ -467,10 +463,10 @@ namespace
const char* pAsciiName( nullptr );
switch ( _eType )
{
- case ODatabaseModelImpl::E_FORM: pAsciiName = "forms"; break;
- case ODatabaseModelImpl::E_REPORT: pAsciiName = "reports"; break;
- case ODatabaseModelImpl::E_QUERY: pAsciiName = "queries"; break;
- case ODatabaseModelImpl::E_TABLE: pAsciiName = "tables"; break;
+ case ODatabaseModelImpl::ObjectType::Form: pAsciiName = "forms"; break;
+ case ODatabaseModelImpl::ObjectType::Report: pAsciiName = "reports"; break;
+ case ODatabaseModelImpl::ObjectType::Query: pAsciiName = "queries"; break;
+ case ODatabaseModelImpl::ObjectType::Table: pAsciiName = "tables"; break;
default:
throw RuntimeException();
}
@@ -560,7 +556,8 @@ bool ODatabaseModelImpl::objectHasMacros( const Reference< XStorage >& _rxContai
void ODatabaseModelImpl::reset()
{
m_bReadOnly = false;
- std::vector<TContentPtr>(4).swap(m_aContainer);
+ for (auto & i : m_aContainer)
+ i.reset();
if ( m_pStorageAccess.is() )
{
@@ -622,7 +619,6 @@ void ODatabaseModelImpl::clearConnections()
}
}
- m_pSharedConnectionManager = nullptr;
m_xSharedConnectionManager = nullptr;
}
@@ -649,7 +645,8 @@ void ODatabaseModelImpl::dispose()
if ( elem )
elem->m_pDataSource = nullptr;
}
- m_aContainer.clear();
+ for (auto & i : m_aContainer)
+ i.reset();
clearConnections();
@@ -833,7 +830,7 @@ bool ODatabaseModelImpl::commitEmbeddedStorage( bool _bPreventRootCommits )
bool ODatabaseModelImpl::commitStorageIfWriteable_ignoreErrors( const Reference< XStorage >& _rxStorage )
{
bool bTryToPreserveScriptSignature = false;
- utl::TempFile aTempFile;
+ utl::TempFileNamed aTempFile;
aTempFile.EnableKillingFile();
OUString sTmpFileUrl = aTempFile.GetURL();
SignatureState aSignatureState = getScriptingSignatureState();
@@ -887,7 +884,7 @@ bool ODatabaseModelImpl::commitStorageIfWriteable_ignoreErrors( const Reference<
uno::Reference<embed::XStorage> xTargetMetaInf
= _rxStorage->openStorageElement("META-INF", embed::ElementModes::READWRITE);
- if (xMetaInf.is() && xTargetMetaInf.is())
+ if (xMetaInf.is() && xTargetMetaInf.is() && xMetaInf->hasByName(aScriptSignName))
{
xMetaInf->copyElementTo(aScriptSignName, xTargetMetaInf, aScriptSignName);
@@ -976,7 +973,7 @@ Reference< XModel > ODatabaseModelImpl::createNewModel_deliverOwnership()
try
{
Reference< XGlobalEventBroadcaster > xModelCollection = theGlobalEventBroadcaster::get( m_aContext );
- xModelCollection->insert( makeAny( xModel ) );
+ xModelCollection->insert( Any( xModel ) );
}
catch( const Exception& )
{
@@ -1032,68 +1029,68 @@ const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings()
static const AsciiPropertyValue aKnownSettings[] =
{
// known JDBC settings
- AsciiPropertyValue( "JavaDriverClass", makeAny( OUString() ) ),
- AsciiPropertyValue( "JavaDriverClassPath", makeAny( OUString() ) ),
- AsciiPropertyValue( "IgnoreCurrency", makeAny( false ) ),
+ AsciiPropertyValue( "JavaDriverClass", Any( OUString() ) ),
+ AsciiPropertyValue( "JavaDriverClassPath", Any( OUString() ) ),
+ AsciiPropertyValue( "IgnoreCurrency", Any( false ) ),
// known settings for file-based drivers
- AsciiPropertyValue( "Extension", makeAny( OUString() ) ),
- AsciiPropertyValue( "CharSet", makeAny( OUString() ) ),
- AsciiPropertyValue( "HeaderLine", makeAny( true ) ),
- AsciiPropertyValue( "FieldDelimiter", makeAny( OUString( "," ) ) ),
- AsciiPropertyValue( "StringDelimiter", makeAny( OUString( "\"" ) ) ),
- AsciiPropertyValue( "DecimalDelimiter", makeAny( OUString( "." ) ) ),
- AsciiPropertyValue( "ThousandDelimiter", makeAny( OUString() ) ),
- AsciiPropertyValue( "ShowDeleted", makeAny( false ) ),
+ AsciiPropertyValue( "Extension", Any( OUString() ) ),
+ AsciiPropertyValue( "CharSet", Any( OUString() ) ),
+ AsciiPropertyValue( "HeaderLine", Any( true ) ),
+ AsciiPropertyValue( "FieldDelimiter", Any( OUString( "," ) ) ),
+ AsciiPropertyValue( "StringDelimiter", Any( OUString( "\"" ) ) ),
+ AsciiPropertyValue( "DecimalDelimiter", Any( OUString( "." ) ) ),
+ AsciiPropertyValue( "ThousandDelimiter", Any( OUString() ) ),
+ AsciiPropertyValue( "ShowDeleted", Any( false ) ),
// known ODBC settings
- AsciiPropertyValue( "SystemDriverSettings", makeAny( OUString() ) ),
- AsciiPropertyValue( "UseCatalog", makeAny( false ) ),
- AsciiPropertyValue( "TypeInfoSettings", makeAny( Sequence< Any >()) ),
+ AsciiPropertyValue( "SystemDriverSettings", Any( OUString() ) ),
+ AsciiPropertyValue( "UseCatalog", Any( false ) ),
+ AsciiPropertyValue( "TypeInfoSettings", Any( Sequence< Any >()) ),
// settings related to auto increment handling
- AsciiPropertyValue( "AutoIncrementCreation", makeAny( OUString() ) ),
- AsciiPropertyValue( "AutoRetrievingStatement", makeAny( OUString() ) ),
- AsciiPropertyValue( "IsAutoRetrievingEnabled", makeAny( false ) ),
+ AsciiPropertyValue( "AutoIncrementCreation", Any( OUString() ) ),
+ AsciiPropertyValue( "AutoRetrievingStatement", Any( OUString() ) ),
+ AsciiPropertyValue( "IsAutoRetrievingEnabled", Any( false ) ),
// known LDAP driver settings
- AsciiPropertyValue( "HostName", makeAny( OUString() ) ),
- AsciiPropertyValue( "PortNumber", makeAny( sal_Int32(389) ) ),
- AsciiPropertyValue( "BaseDN", makeAny( OUString() ) ),
- AsciiPropertyValue( "MaxRowCount", makeAny( sal_Int32(100) ) ),
+ AsciiPropertyValue( "HostName", Any( OUString() ) ),
+ AsciiPropertyValue( "PortNumber", Any( sal_Int32(389) ) ),
+ AsciiPropertyValue( "BaseDN", Any( OUString() ) ),
+ AsciiPropertyValue( "MaxRowCount", Any( sal_Int32(100) ) ),
// known MySQLNative driver settings
- AsciiPropertyValue( "LocalSocket", makeAny( OUString() ) ),
- AsciiPropertyValue( "NamedPipe", makeAny( OUString() ) ),
+ AsciiPropertyValue( "LocalSocket", Any( OUString() ) ),
+ AsciiPropertyValue( "NamedPipe", Any( OUString() ) ),
// misc known driver settings
- AsciiPropertyValue( "ParameterNameSubstitution", makeAny( false ) ),
- AsciiPropertyValue( "AddIndexAppendix", makeAny( true ) ),
- AsciiPropertyValue( "IgnoreDriverPrivileges", makeAny( true ) ),
+ AsciiPropertyValue( "ParameterNameSubstitution", Any( false ) ),
+ AsciiPropertyValue( "AddIndexAppendix", Any( true ) ),
+ AsciiPropertyValue( "IgnoreDriverPrivileges", Any( true ) ),
AsciiPropertyValue( "ImplicitCatalogRestriction", ::cppu::UnoType< OUString >::get() ),
AsciiPropertyValue( "ImplicitSchemaRestriction", ::cppu::UnoType< OUString >::get() ),
AsciiPropertyValue( "PrimaryKeySupport", ::cppu::UnoType< sal_Bool >::get() ),
- AsciiPropertyValue( "ShowColumnDescription", makeAny( false ) ),
+ AsciiPropertyValue( "ShowColumnDescription", Any( false ) ),
// known SDB level settings
- AsciiPropertyValue( "NoNameLengthLimit", makeAny( false ) ),
- AsciiPropertyValue( "AppendTableAliasName", makeAny( false ) ),
- AsciiPropertyValue( "GenerateASBeforeCorrelationName", makeAny( false ) ),
- AsciiPropertyValue( "ColumnAliasInOrderBy", makeAny( true ) ),
- AsciiPropertyValue( "EnableSQL92Check", makeAny( false ) ),
- AsciiPropertyValue( "BooleanComparisonMode", makeAny( BooleanComparisonMode::EQUAL_INTEGER ) ),
- AsciiPropertyValue( "TableTypeFilterMode", makeAny( sal_Int32(3) ) ),
- AsciiPropertyValue( "RespectDriverResultSetType", makeAny( false ) ),
- AsciiPropertyValue( "UseSchemaInSelect", makeAny( true ) ),
- AsciiPropertyValue( "UseCatalogInSelect", makeAny( true ) ),
- AsciiPropertyValue( "EnableOuterJoinEscape", makeAny( true ) ),
- AsciiPropertyValue( "PreferDosLikeLineEnds", makeAny( false ) ),
- AsciiPropertyValue( "FormsCheckRequiredFields", makeAny( true ) ),
- AsciiPropertyValue( "EscapeDateTime", makeAny( true ) ),
+ AsciiPropertyValue( "NoNameLengthLimit", Any( false ) ),
+ AsciiPropertyValue( "AppendTableAliasName", Any( false ) ),
+ AsciiPropertyValue( "GenerateASBeforeCorrelationName", Any( false ) ),
+ AsciiPropertyValue( "ColumnAliasInOrderBy", Any( true ) ),
+ AsciiPropertyValue( "EnableSQL92Check", Any( false ) ),
+ AsciiPropertyValue( "BooleanComparisonMode", Any( BooleanComparisonMode::EQUAL_INTEGER ) ),
+ AsciiPropertyValue( "TableTypeFilterMode", Any( sal_Int32(3) ) ),
+ AsciiPropertyValue( "RespectDriverResultSetType", Any( false ) ),
+ AsciiPropertyValue( "UseSchemaInSelect", Any( true ) ),
+ AsciiPropertyValue( "UseCatalogInSelect", Any( true ) ),
+ AsciiPropertyValue( "EnableOuterJoinEscape", Any( true ) ),
+ AsciiPropertyValue( "PreferDosLikeLineEnds", Any( false ) ),
+ AsciiPropertyValue( "FormsCheckRequiredFields", Any( true ) ),
+ AsciiPropertyValue( "EscapeDateTime", Any( true ) ),
// known services to handle database tasks
- AsciiPropertyValue( "TableAlterationServiceName", makeAny( OUString() ) ),
- AsciiPropertyValue( "TableRenameServiceName", makeAny( OUString() ) ),
- AsciiPropertyValue( "ViewAlterationServiceName", makeAny( OUString() ) ),
- AsciiPropertyValue( "ViewAccessServiceName", makeAny( OUString() ) ),
- AsciiPropertyValue( "CommandDefinitions", makeAny( OUString() ) ),
- AsciiPropertyValue( "Forms", makeAny( OUString() ) ),
- AsciiPropertyValue( "Reports", makeAny( OUString() ) ),
- AsciiPropertyValue( "KeyAlterationServiceName", makeAny( OUString() ) ),
- AsciiPropertyValue( "IndexAlterationServiceName", makeAny( OUString() ) ),
+ AsciiPropertyValue( "TableAlterationServiceName", Any( OUString() ) ),
+ AsciiPropertyValue( "TableRenameServiceName", Any( OUString() ) ),
+ AsciiPropertyValue( "ViewAlterationServiceName", Any( OUString() ) ),
+ AsciiPropertyValue( "ViewAccessServiceName", Any( OUString() ) ),
+ AsciiPropertyValue( "CommandDefinitions", Any( OUString() ) ),
+ AsciiPropertyValue( "Forms", Any( OUString() ) ),
+ AsciiPropertyValue( "Reports", Any( OUString() ) ),
+ AsciiPropertyValue( "KeyAlterationServiceName", Any( OUString() ) ),
+ AsciiPropertyValue( "IndexAlterationServiceName", Any( OUString() ) ),
AsciiPropertyValue()
};
@@ -1102,7 +1099,6 @@ const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings()
TContentPtr& ODatabaseModelImpl::getObjectContainer( ObjectType _eType )
{
- OSL_PRECOND( _eType >= E_FORM && _eType <= E_TABLE, "ODatabaseModelImpl::getObjectContainer: illegal index!" );
TContentPtr& rContentPtr = m_aContainer[ _eType ];
if ( !rContentPtr )
@@ -1123,7 +1119,8 @@ bool ODatabaseModelImpl::checkMacrosOnLoading()
{
Reference< XInteractionHandler > xInteraction;
xInteraction = m_aMediaDescriptor.getOrDefault( "InteractionHandler", xInteraction );
- return m_aMacroMode.checkMacrosOnLoading( xInteraction );
+ const bool bHasMacros = m_aMacroMode.hasMacros();
+ return m_aMacroMode.checkMacrosOnLoading(xInteraction, false /*HasValidContentSignature*/, bHasMacros);
}
void ODatabaseModelImpl::resetMacroExecutionMode()
@@ -1321,17 +1318,17 @@ ODatabaseModelImpl::EmbeddedMacros ODatabaseModelImpl::determineEmbeddedMacros()
{
if ( ::sfx2::DocumentMacroMode::storageHasMacros( getOrCreateRootStorage() ) )
{
- m_aEmbeddedMacros = eDocumentWideMacros;
+ m_aEmbeddedMacros = EmbeddedMacros::DocumentWide;
}
- else if ( lcl_hasObjectsWithMacros_nothrow( *this, E_FORM )
- || lcl_hasObjectsWithMacros_nothrow( *this, E_REPORT )
+ else if ( lcl_hasObjectsWithMacros_nothrow( *this, ObjectType::Form )
+ || lcl_hasObjectsWithMacros_nothrow( *this, ObjectType::Report )
)
{
- m_aEmbeddedMacros = eSubDocumentMacros;
+ m_aEmbeddedMacros = EmbeddedMacros::SubDocument;
}
else
{
- m_aEmbeddedMacros = eNoMacros;
+ m_aEmbeddedMacros = EmbeddedMacros::NONE;
}
}
return *m_aEmbeddedMacros;
@@ -1340,7 +1337,7 @@ ODatabaseModelImpl::EmbeddedMacros ODatabaseModelImpl::determineEmbeddedMacros()
bool ODatabaseModelImpl::documentStorageHasMacros() const
{
const_cast< ODatabaseModelImpl* >( this )->determineEmbeddedMacros();
- return ( *m_aEmbeddedMacros != eNoMacros );
+ return ( *m_aEmbeddedMacros != EmbeddedMacros::NONE );
}
bool ODatabaseModelImpl::macroCallsSeenWhileLoading() const
@@ -1358,7 +1355,8 @@ SignatureState ODatabaseModelImpl::getScriptingSignatureState()
return m_nScriptingSignatureState;
}
-bool ODatabaseModelImpl::hasTrustedScriptingSignature(bool bAllowUIToAddAuthor)
+bool ODatabaseModelImpl::hasTrustedScriptingSignature(
+ const css::uno::Reference<css::task::XInteractionHandler>& _rxInteraction)
{
bool bResult = false;
@@ -1390,20 +1388,15 @@ bool ODatabaseModelImpl::hasTrustedScriptingSignature(bool bAllowUIToAddAuthor)
});
}
- if (!bResult && bAllowUIToAddAuthor)
+ if (!bResult && _rxInteraction)
{
- Reference<XInteractionHandler> xInteraction;
- xInteraction = m_aMediaDescriptor.getOrDefault("InteractionHandler", xInteraction);
- if (xInteraction.is())
- {
- task::DocumentMacroConfirmationRequest aRequest;
- aRequest.DocumentURL = m_sDocFileLocation;
- aRequest.DocumentStorage = xStorage;
- aRequest.DocumentSignatureInformation = aInfo;
- aRequest.DocumentVersion = aODFVersion;
- aRequest.Classification = task::InteractionClassification_QUERY;
- bResult = SfxMedium::CallApproveHandler(xInteraction, uno::makeAny(aRequest), true);
- }
+ task::DocumentMacroConfirmationRequest aRequest;
+ aRequest.DocumentURL = m_sDocFileLocation;
+ aRequest.DocumentStorage = xStorage;
+ aRequest.DocumentSignatureInformation = aInfo;
+ aRequest.DocumentVersion = aODFVersion;
+ aRequest.Classification = task::InteractionClassification_QUERY;
+ bResult = SfxMedium::CallApproveHandler(_rxInteraction, uno::Any(aRequest), true);
}
}
catch (uno::Exception&)
@@ -1418,8 +1411,8 @@ void ODatabaseModelImpl::storageIsModified()
setModified( true );
}
-ModelDependentComponent::ModelDependentComponent( const ::rtl::Reference< ODatabaseModelImpl >& _model )
- :m_pImpl( _model )
+ModelDependentComponent::ModelDependentComponent( ::rtl::Reference< ODatabaseModelImpl > _model )
+ :m_pImpl(std::move( _model ))
{
}