OUString: constify and avoid temporaries
Change-Id: I1cb48585580f545623b2015318cb16d331519217
This commit is contained in:
@@ -258,7 +258,6 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument
|
|||||||
|
|
||||||
const Reference<XComponentContext> xContext(
|
const Reference<XComponentContext> xContext(
|
||||||
::comphelper::getProcessComponentContext());
|
::comphelper::getProcessComponentContext());
|
||||||
OUString uri;
|
|
||||||
const Reference<frame::XModel> xModel(
|
const Reference<frame::XModel> xModel(
|
||||||
m_pObjectShell->GetModel());
|
m_pObjectShell->GetModel());
|
||||||
const Reference<lang::XMultiComponentFactory> xMsf(
|
const Reference<lang::XMultiComponentFactory> xMsf(
|
||||||
@@ -276,7 +275,7 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument
|
|||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
uri = xContent->getIdentifier()->getContentIdentifier();
|
OUString uri = xContent->getIdentifier()->getContentIdentifier();
|
||||||
OSL_ENSURE(!uri.isEmpty(), "GetDMA: empty uri?");
|
OSL_ENSURE(!uri.isEmpty(), "GetDMA: empty uri?");
|
||||||
if (!uri.isEmpty() && !uri.endsWith("/"))
|
if (!uri.isEmpty() && !uri.endsWith("/"))
|
||||||
{
|
{
|
||||||
@@ -1478,8 +1477,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue >
|
|||||||
&& aSeqArgs[nInd].Name != "FailOnWarning"
|
&& aSeqArgs[nInd].Name != "FailOnWarning"
|
||||||
&& aSeqArgs[nInd].Name != "CheckIn" )
|
&& aSeqArgs[nInd].Name != "CheckIn" )
|
||||||
{
|
{
|
||||||
OUString aMessage( "Unexpected MediaDescriptor parameter: " );
|
const OUString aMessage( "Unexpected MediaDescriptor parameter: " + aSeqArgs[nInd].Name );
|
||||||
aMessage += aSeqArgs[nInd].Name;
|
|
||||||
throw lang::IllegalArgumentException( aMessage, Reference< XInterface >(), 1 );
|
throw lang::IllegalArgumentException( aMessage, Reference< XInterface >(), 1 );
|
||||||
}
|
}
|
||||||
else if ( aSeqArgs[nInd].Name == "CheckIn" )
|
else if ( aSeqArgs[nInd].Name == "CheckIn" )
|
||||||
@@ -1761,8 +1759,7 @@ void SAL_CALL SfxBaseModel::load( const Sequence< beans::PropertyValue >& seqA
|
|||||||
SfxMedium* pMedium = new SfxMedium( seqArguments );
|
SfxMedium* pMedium = new SfxMedium( seqArguments );
|
||||||
|
|
||||||
ErrCode nError = ERRCODE_NONE;
|
ErrCode nError = ERRCODE_NONE;
|
||||||
OUString aFilterProvider = getFilterProvider(*pMedium);
|
if (!getFilterProvider(*pMedium).isEmpty())
|
||||||
if (!aFilterProvider.isEmpty())
|
|
||||||
{
|
{
|
||||||
if (!m_pData->m_pObjectShell->DoLoadExternal(pMedium))
|
if (!m_pData->m_pObjectShell->DoLoadExternal(pMedium))
|
||||||
nError = ERRCODE_IO_GENERAL;
|
nError = ERRCODE_IO_GENERAL;
|
||||||
@@ -1797,7 +1794,7 @@ void SAL_CALL SfxBaseModel::load( const Sequence< beans::PropertyValue >& seqA
|
|||||||
nError = m_pData->m_pObjectShell->GetErrorCode();
|
nError = m_pData->m_pObjectShell->GetErrorCode();
|
||||||
if ( nError == ERRCODE_IO_BROKENPACKAGE && xHandler.is() )
|
if ( nError == ERRCODE_IO_BROKENPACKAGE && xHandler.is() )
|
||||||
{
|
{
|
||||||
OUString aDocName = pMedium->GetURLObject().getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset );
|
const OUString aDocName( pMedium->GetURLObject().getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset ) );
|
||||||
const SfxBoolItem* pRepairItem = SfxItemSet::GetItem<SfxBoolItem>(pMedium->GetItemSet(), SID_REPAIRPACKAGE, false);
|
const SfxBoolItem* pRepairItem = SfxItemSet::GetItem<SfxBoolItem>(pMedium->GetItemSet(), SID_REPAIRPACKAGE, false);
|
||||||
if ( !pRepairItem || !pRepairItem->GetValue() )
|
if ( !pRepairItem || !pRepairItem->GetValue() )
|
||||||
{
|
{
|
||||||
@@ -2458,12 +2455,12 @@ void SAL_CALL SfxBaseModel::checkIn( sal_Bool bIsMajor, const OUString& rMessage
|
|||||||
aProps[2].Name = "CheckIn";
|
aProps[2].Name = "CheckIn";
|
||||||
aProps[2].Value <<= true;
|
aProps[2].Value <<= true;
|
||||||
|
|
||||||
OUString sName( pMedium->GetName( ) );
|
const OUString sName( pMedium->GetName( ) );
|
||||||
storeSelf( aProps );
|
storeSelf( aProps );
|
||||||
|
|
||||||
// Refresh pMedium as it has probably changed during the storeSelf call
|
// Refresh pMedium as it has probably changed during the storeSelf call
|
||||||
pMedium = m_pData->m_pObjectShell->GetMedium( );
|
pMedium = m_pData->m_pObjectShell->GetMedium( );
|
||||||
OUString sNewName( pMedium->GetName( ) );
|
const OUString sNewName( pMedium->GetName( ) );
|
||||||
|
|
||||||
// URL has changed, update the document
|
// URL has changed, update the document
|
||||||
if ( sName != sNewName )
|
if ( sName != sNewName )
|
||||||
@@ -2567,7 +2564,7 @@ void SfxBaseModel::loadCmisProperties( )
|
|||||||
utl::UCBContentHelper::getDefaultCommandEnvironment(),
|
utl::UCBContentHelper::getDefaultCommandEnvironment(),
|
||||||
comphelper::getProcessComponentContext() );
|
comphelper::getProcessComponentContext() );
|
||||||
Reference < beans::XPropertySetInfo > xProps = aContent.getProperties();
|
Reference < beans::XPropertySetInfo > xProps = aContent.getProperties();
|
||||||
OUString aCmisProps( "CmisProperties" );
|
const OUString aCmisProps( "CmisProperties" );
|
||||||
if ( xProps->hasPropertyByName( aCmisProps ) )
|
if ( xProps->hasPropertyByName( aCmisProps ) )
|
||||||
{
|
{
|
||||||
Sequence< document::CmisProperty> aCmisProperties;
|
Sequence< document::CmisProperty> aCmisProperties;
|
||||||
@@ -2677,7 +2674,7 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
|
|||||||
&& m_pData->m_pObjectShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
|
&& m_pData->m_pObjectShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
|
||||||
{
|
{
|
||||||
Reference< embed::XStorage > xConfigStorage;
|
Reference< embed::XStorage > xConfigStorage;
|
||||||
OUString aUIConfigFolderName( "Configurations2" );
|
const OUString aUIConfigFolderName( "Configurations2" );
|
||||||
|
|
||||||
xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, embed::ElementModes::READWRITE );
|
xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, embed::ElementModes::READWRITE );
|
||||||
if ( !xConfigStorage.is() )
|
if ( !xConfigStorage.is() )
|
||||||
@@ -2712,9 +2709,8 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
|
|||||||
|
|
||||||
SfxItemSet *pSet = m_pData->m_pObjectShell->GetMedium()->GetItemSet();
|
SfxItemSet *pSet = m_pData->m_pObjectShell->GetMedium()->GetItemSet();
|
||||||
Sequence< beans::PropertyValue > aArgs;
|
Sequence< beans::PropertyValue > aArgs;
|
||||||
OUString aTitle = m_pData->m_pObjectShell->GetTitle();
|
|
||||||
TransformItems( SID_SAVEASDOC, *pSet, aArgs );
|
TransformItems( SID_SAVEASDOC, *pSet, aArgs );
|
||||||
addTitle_Impl( aArgs, aTitle );
|
addTitle_Impl( aArgs, m_pData->m_pObjectShell->GetTitle() );
|
||||||
attachResource( m_pData->m_pObjectShell->GetMedium()->GetName(), aArgs );
|
attachResource( m_pData->m_pObjectShell->GetMedium()->GetName(), aArgs );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2740,8 +2736,7 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
|
|||||||
|
|
||||||
if ( rHint.GetId() == SfxHintId::TitleChanged )
|
if ( rHint.GetId() == SfxHintId::TitleChanged )
|
||||||
{
|
{
|
||||||
OUString aTitle = m_pData->m_pObjectShell->GetTitle();
|
addTitle_Impl( m_pData->m_seqArguments, m_pData->m_pObjectShell->GetTitle() );
|
||||||
addTitle_Impl( m_pData->m_seqArguments, aTitle );
|
|
||||||
postEvent_Impl( GlobalEventConfig::GetEventName( GlobalEventId::TITLECHANGED ) );
|
postEvent_Impl( GlobalEventConfig::GetEventName( GlobalEventId::TITLECHANGED ) );
|
||||||
}
|
}
|
||||||
else if ( rHint.GetId() == SfxHintId::ModeChanged )
|
else if ( rHint.GetId() == SfxHintId::ModeChanged )
|
||||||
@@ -2849,8 +2844,8 @@ void SfxBaseModel::impl_store( const OUString& sURL
|
|||||||
// this is the same file URL as the current document location, try to use storeOwn if possible
|
// this is the same file URL as the current document location, try to use storeOwn if possible
|
||||||
|
|
||||||
::comphelper::SequenceAsHashMap aArgHash( seqArguments );
|
::comphelper::SequenceAsHashMap aArgHash( seqArguments );
|
||||||
OUString aFilterString( "FilterName" );
|
const OUString aFilterString( "FilterName" );
|
||||||
OUString aFilterName = aArgHash.getUnpackedValueOrDefault( aFilterString, OUString() );
|
const OUString aFilterName( aArgHash.getUnpackedValueOrDefault( aFilterString, OUString() ) );
|
||||||
if ( !aFilterName.isEmpty() )
|
if ( !aFilterName.isEmpty() )
|
||||||
{
|
{
|
||||||
SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium();
|
SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium();
|
||||||
@@ -2871,7 +2866,7 @@ void SfxBaseModel::impl_store( const OUString& sURL
|
|||||||
if ( !bFormerPassword )
|
if ( !bFormerPassword )
|
||||||
{
|
{
|
||||||
aArgHash.erase( aFilterString );
|
aArgHash.erase( aFilterString );
|
||||||
aArgHash.erase( OUString( "URL" ) );
|
aArgHash.erase( "URL" );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -2890,8 +2885,7 @@ void SfxBaseModel::impl_store( const OUString& sURL
|
|||||||
uno::Sequence< beans::NamedValue > aNewEncryptionData = aArgHash.getUnpackedValueOrDefault("EncryptionData", uno::Sequence< beans::NamedValue >() );
|
uno::Sequence< beans::NamedValue > aNewEncryptionData = aArgHash.getUnpackedValueOrDefault("EncryptionData", uno::Sequence< beans::NamedValue >() );
|
||||||
if ( !aNewEncryptionData.getLength() )
|
if ( !aNewEncryptionData.getLength() )
|
||||||
{
|
{
|
||||||
OUString aNewPassword = aArgHash.getUnpackedValueOrDefault("Password", OUString() );
|
aNewEncryptionData = ::comphelper::OStorageHelper::CreatePackageEncryptionData( aArgHash.getUnpackedValueOrDefault("Password", OUString()) );
|
||||||
aNewEncryptionData = ::comphelper::OStorageHelper::CreatePackageEncryptionData( aNewPassword );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uno::Sequence< beans::NamedValue > aOldEncryptionData;
|
uno::Sequence< beans::NamedValue > aOldEncryptionData;
|
||||||
@@ -3389,10 +3383,10 @@ static void ConvertSlotsToCommands( SfxObjectShell const * pDoc, Reference< cont
|
|||||||
GetCommandFromSequence( aCommand, nIndex, aSeqPropValue );
|
GetCommandFromSequence( aCommand, nIndex, aSeqPropValue );
|
||||||
if ( nIndex >= 0 && aCommand.startsWith( "slot:" ) )
|
if ( nIndex >= 0 && aCommand.startsWith( "slot:" ) )
|
||||||
{
|
{
|
||||||
OUString aSlot( aCommand.copy( 5 ));
|
const sal_uInt16 nSlot = aCommand.copy( 5 ).toInt32();
|
||||||
|
|
||||||
// We have to replace the old "slot-Command" with our new ".uno:-Command"
|
// We have to replace the old "slot-Command" with our new ".uno:-Command"
|
||||||
const SfxSlot* pSlot = pModule->GetSlotPool()->GetSlot( sal_uInt16( aSlot.toInt32() ));
|
const SfxSlot* pSlot = pModule->GetSlotPool()->GetSlot( nSlot );
|
||||||
if ( pSlot )
|
if ( pSlot )
|
||||||
{
|
{
|
||||||
OUStringBuffer aStrBuf( ".uno:" );
|
OUStringBuffer aStrBuf( ".uno:" );
|
||||||
@@ -3429,7 +3423,7 @@ Reference< ui::XUIConfigurationManager2 > SfxBaseModel::getUIConfigurationManage
|
|||||||
xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, embed::ElementModes::READWRITE );
|
xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, embed::ElementModes::READWRITE );
|
||||||
if ( xConfigStorage.is() )
|
if ( xConfigStorage.is() )
|
||||||
{
|
{
|
||||||
OUString aMediaTypeProp( "MediaType" );
|
const OUString aMediaTypeProp( "MediaType" );
|
||||||
OUString aMediaType;
|
OUString aMediaType;
|
||||||
Reference< beans::XPropertySet > xPropSet( xConfigStorage, UNO_QUERY );
|
Reference< beans::XPropertySet > xPropSet( xConfigStorage, UNO_QUERY );
|
||||||
Any a = xPropSet->getPropertyValue( aMediaTypeProp );
|
Any a = xPropSet->getPropertyValue( aMediaTypeProp );
|
||||||
@@ -3466,8 +3460,8 @@ Reference< ui::XUIConfigurationManager2 > SfxBaseModel::getUIConfigurationManage
|
|||||||
|
|
||||||
for ( size_t i = 0; i < rToolbars.size(); i++ )
|
for ( size_t i = 0; i < rToolbars.size(); i++ )
|
||||||
{
|
{
|
||||||
OUString aCustomTbxName = "private:resource/toolbar/custom_OOo1x_" + OUString::number( i + 1 );
|
const OUString sId(OUString::number( i + 1 ));
|
||||||
OUString aCustomTbxTitle = "Toolbar " + OUString::number( i + 1 );
|
const OUString aCustomTbxName = "private:resource/toolbar/custom_OOo1x_" + sId;
|
||||||
|
|
||||||
Reference< container::XIndexContainer > xToolbar = rToolbars[i];
|
Reference< container::XIndexContainer > xToolbar = rToolbars[i];
|
||||||
ConvertSlotsToCommands( pObjShell, xToolbar );
|
ConvertSlotsToCommands( pObjShell, xToolbar );
|
||||||
@@ -3479,7 +3473,7 @@ Reference< ui::XUIConfigurationManager2 > SfxBaseModel::getUIConfigurationManage
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
xPropSet->setPropertyValue( "UIName", Any( aCustomTbxTitle ) );
|
xPropSet->setPropertyValue( "UIName", Any( "Toolbar " + sId ) );
|
||||||
}
|
}
|
||||||
catch ( beans::UnknownPropertyException& )
|
catch ( beans::UnknownPropertyException& )
|
||||||
{
|
{
|
||||||
@@ -3627,8 +3621,7 @@ void SAL_CALL SfxBaseModel::storeToStorage( const Reference< embed::XStorage >&
|
|||||||
sal_Int32 nVersion = SOFFICE_FILEFORMAT_CURRENT;
|
sal_Int32 nVersion = SOFFICE_FILEFORMAT_CURRENT;
|
||||||
if( pItem )
|
if( pItem )
|
||||||
{
|
{
|
||||||
OUString aFilterName = pItem->GetValue();
|
std::shared_ptr<const SfxFilter> pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( pItem->GetValue() );
|
||||||
std::shared_ptr<const SfxFilter> pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( aFilterName );
|
|
||||||
if ( pFilter && pFilter->UsesStorage() )
|
if ( pFilter && pFilter->UsesStorage() )
|
||||||
nVersion = pFilter->GetVersion();
|
nVersion = pFilter->GetVersion();
|
||||||
}
|
}
|
||||||
@@ -3818,7 +3811,7 @@ OUString SAL_CALL SfxBaseModel::getTitle()
|
|||||||
= aContent.getProperties();
|
= aContent.getProperties();
|
||||||
if ( xProps.is() )
|
if ( xProps.is() )
|
||||||
{
|
{
|
||||||
OUString aServerTitle( "TitleOnServer" );
|
const OUString aServerTitle( "TitleOnServer" );
|
||||||
if ( xProps->hasPropertyByName( aServerTitle ) )
|
if ( xProps->hasPropertyByName( aServerTitle ) )
|
||||||
{
|
{
|
||||||
Any aAny = aContent.getPropertyValue( aServerTitle );
|
Any aAny = aContent.getPropertyValue( aServerTitle );
|
||||||
|
Reference in New Issue
Block a user