sfx2/source/doc/iframe.cxx | 4 - sfx2/source/doc/objcont.cxx | 7 +-- sfx2/source/doc/objmisc.cxx | 20 ++++----- sfx2/source/doc/objserv.cxx | 16 +------ sfx2/source/doc/objstor.cxx | 59 ++++++++++++++--------------- svx/inc/sdr/properties/itemsettools.hxx | 18 +++----- svx/source/sdr/properties/itemsettools.cxx | 34 +--------------- 7 files changed, 59 insertions(+), 99 deletions(-)
New commits: commit 1d1eb99f7a5ac0c10fb6cb7349e82ca069f432a5 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Mon May 1 22:03:25 2017 +0200 OUStrings: constify, reduce temporaries and scope Change-Id: I8b5fdf6c36908704dfc90cd77d4f258373354042 diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 660a7da9d932..d7a36c7aac37 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -354,9 +354,7 @@ void SfxObjectShell::CheckIn( ) ScopedVclPtrInstance< SfxCheckinDialog > checkinDlg(&GetFrame( )->GetWindow( )); if ( checkinDlg->Execute( ) == RET_OK ) { - OUString sComment = checkinDlg->GetComment( ); - bool bMajor = checkinDlg->IsMajor( ); - xCmisDoc->checkIn( bMajor, sComment ); + xCmisDoc->checkIn( checkinDlg->IsMajor(), checkinDlg->GetComment() ); uno::Reference< util::XModifiable > xModifiable( GetModel( ), uno::UNO_QUERY ); if ( xModifiable.is( ) ) xModifiable->setModified( false ); @@ -1069,22 +1067,16 @@ void SfxObjectShell::ExecProps_Impl(SfxRequest &rReq) break; case SID_DOCINFO_AUTHOR : - { - OUString aStr = static_cast<const SfxStringItem&>(rReq.GetArgs()->Get(rReq.GetSlot())).GetValue(); - getDocProperties()->setAuthor( aStr ); + getDocProperties()->setAuthor( static_cast<const SfxStringItem&>(rReq.GetArgs()->Get(rReq.GetSlot())).GetValue() ); break; - } case SID_DOCINFO_COMMENTS : - { - OUString aStr = static_cast<const SfxStringItem&>(rReq.GetArgs()->Get(rReq.GetSlot())).GetValue(); - getDocProperties()->setDescription( aStr ); + getDocProperties()->setDescription( static_cast<const SfxStringItem&>(rReq.GetArgs()->Get(rReq.GetSlot())).GetValue() ); break; - } case SID_DOCINFO_KEYWORDS : { - OUString aStr = static_cast<const SfxStringItem&>(rReq.GetArgs()->Get(rReq.GetSlot())).GetValue(); + const OUString aStr = static_cast<const SfxStringItem&>(rReq.GetArgs()->Get(rReq.GetSlot())).GetValue(); getDocProperties()->setKeywords( ::comphelper::string::convertCommaSeparated(aStr) ); break; diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index c93c593e3126..56fdf502076f 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -196,8 +196,7 @@ bool GetEncryptionData_Impl( const SfxItemSet* pSet, uno::Sequence< beans::Named const SfxStringItem* pPasswordItem = SfxItemSet::GetItem<SfxStringItem>(pSet, SID_PASSWORD, false); if ( pPasswordItem ) { - OUString aPassword = pPasswordItem->GetValue(); - o_rEncryptionData = ::comphelper::OStorageHelper::CreatePackageEncryptionData( aPassword ); + o_rEncryptionData = ::comphelper::OStorageHelper::CreatePackageEncryptionData( pPasswordItem->GetValue() ); bResult = true; } } @@ -335,12 +334,14 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto if ( xProps.is() ) { - SvGlobalName aName; - OUString aFullTypeName, aShortTypeName, aAppName; SotClipboardFormatId nClipFormat = SotClipboardFormatId::NONE; if(!bChart) + { + SvGlobalName aName; + OUString aFullTypeName, aShortTypeName, aAppName; FillClass( &aName, &nClipFormat, &aAppName, &aFullTypeName, &aShortTypeName, nVersion, bTemplate ); + } else nClipFormat = GetChartVersion(nVersion, bTemplate); @@ -532,7 +533,7 @@ bool SfxObjectShell::DoInitNew( SfxMedium* pMed ) sal_Int32 nLength = aArgs.getLength(); aArgs.realloc( nLength + 1 ); aArgs[nLength].Name = "Title"; - aArgs[nLength].Value <<= OUString( GetTitle( SFX_TITLE_DETECT ) ); + aArgs[nLength].Value <<= GetTitle( SFX_TITLE_DETECT ); xModel->attachResource( OUString(), aArgs ); if (!utl::ConfigManager::IsAvoidConfig()) impl_addToModelCollection(xModel); @@ -644,8 +645,7 @@ bool SfxObjectShell::DoLoad( SfxMedium *pMed ) { if ( pSalvageItem ) { - OUString aName( pMed->GetPhysicalName() ); - osl::FileBase::getFileURLFromSystemPath( aName, aBaseURL ); + osl::FileBase::getFileURLFromSystemPath( pMed->GetPhysicalName(), aBaseURL ); } else aBaseURL = pMed->GetBaseURL(); @@ -748,7 +748,7 @@ bool SfxObjectShell::DoLoad( SfxMedium *pMed ) if ( pMedium->GetFilter() && ( pMedium->GetFilter()->GetFilterFlags() & SfxFilterFlags::STARONEFILTER ) ) { uno::Reference < beans::XPropertySet > xSet( GetModel(), uno::UNO_QUERY ); - OUString sLockUpdates("LockUpdates"); + const OUString sLockUpdates("LockUpdates"); bool bSetProperty = true; try { @@ -790,9 +790,9 @@ bool SfxObjectShell::DoLoad( SfxMedium *pMed ) css::uno::Reference < XPropertySetInfo > xProps = aContent.getProperties(); if ( xProps.is() ) { - OUString aAuthor( "Author" ); - OUString aKeywords( "Keywords" ); - OUString aSubject( "Subject" ); + const OUString aAuthor( "Author" ); + const OUString aKeywords( "Keywords" ); + const OUString aSubject( "Subject" ); Any aAny; OUString aValue; uno::Reference<document::XDocumentPropertiesSupplier> xDPS( @@ -1030,8 +1030,8 @@ bool SfxObjectShell::DoSave() if ( !xTmpStorage.is() ) throw uno::RuntimeException(); - OUString aBasicStorageName( "Basic" ); - OUString aDialogsStorageName( "Dialogs" ); + const OUString aBasicStorageName( "Basic" ); + const OUString aDialogsStorageName( "Dialogs" ); if ( GetMedium()->GetStorage()->hasByName( aBasicStorageName ) ) GetMedium()->GetStorage()->copyElementTo( aBasicStorageName, xTmpStorage, aBasicStorageName ); if ( GetMedium()->GetStorage()->hasByName( aDialogsStorageName ) ) @@ -1426,7 +1426,7 @@ bool SfxObjectShell::SaveTo_Impl if ( aVersions.getLength() ) { // copy the version streams - OUString aVersionsName( "Versions" ); + const OUString aVersionsName( "Versions" ); uno::Reference< embed::XStorage > xNewVerStor = xMedStorage->openStorageElement( aVersionsName, embed::ElementModes::READWRITE ); @@ -1545,7 +1545,7 @@ bool SfxObjectShell::SaveTo_Impl xDDSigns = security::DocumentDigitalSignatures::createWithVersion(comphelper::getProcessComponentContext(), aVersion); - OUString aScriptSignName = xDDSigns->getScriptingContentSignatureDefaultStreamName(); + const OUString aScriptSignName = xDDSigns->getScriptingContentSignatureDefaultStreamName(); if ( !aScriptSignName.isEmpty() ) { @@ -1609,9 +1609,9 @@ bool SfxObjectShell::SaveTo_Impl rMedium.CloseZipStorage_Impl(); } - OUString sName( rMedium.GetName( ) ); + const OUString sName( rMedium.GetName( ) ); bOk = rMedium.Commit(); - OUString sNewName( rMedium.GetName( ) ); + const OUString sNewName( rMedium.GetName( ) ); if ( sName != sNewName ) GetMedium( )->SwitchDocumentToFile( sNewName ); @@ -1665,9 +1665,9 @@ bool SfxObjectShell::SaveTo_Impl css::uno::Reference < XPropertySetInfo > xProps = aContent.getProperties(); if ( xProps.is() ) { - OUString aAuthor( "Author" ); - OUString aKeywords( "Keywords" ); - OUString aSubject( "Subject" ); + const OUString aAuthor( "Author" ); + const OUString aKeywords( "Keywords" ); + const OUString aSubject( "Subject" ); uno::Reference<document::XDocumentPropertiesSupplier> xDPS( GetModel(), uno::UNO_QUERY_THROW); @@ -1715,7 +1715,7 @@ bool SfxObjectShell::DisconnectStorage_Impl( SfxMedium& rSrcMedium, SfxMedium& r try { uno::Reference< embed::XOptimizedStorage > xOptStorage( xStorage, uno::UNO_QUERY_THROW ); - OUString aBackupURL = rTargetMedium.GetBackup_Impl(); + const OUString aBackupURL = rTargetMedium.GetBackup_Impl(); if ( aBackupURL.isEmpty() ) { // the backup could not be created, try to disconnect the storage and close the source SfxMedium @@ -2009,7 +2009,7 @@ bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed, bool bRegisterRecent ) uno::Reference< frame::XModel > xModel = GetModel(); if ( xModel.is() ) { - OUString aURL = pNewMed->GetOrigURL(); + const OUString aURL {pNewMed->GetOrigURL()}; uno::Sequence< beans::PropertyValue > aMediaDescr; TransformItems( SID_OPENDOC, *pNewMed->GetItemSet(), aMediaDescr ); try @@ -2123,7 +2123,7 @@ bool SfxObjectShell::ConvertFrom bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, css::uno::Reference<css::text::XTextRange> const& xInsertPosition) { - OUString aFilterName( rMedium.GetFilter()->GetFilterName() ); + const OUString aFilterName( rMedium.GetFilter()->GetFilterName() ); uno::Reference< lang::XMultiServiceFactory > xMan = ::comphelper::getProcessServiceFactory(); uno::Reference < lang::XMultiServiceFactory > xFilterFact ( @@ -2222,8 +2222,7 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames(); for ( sal_Int32 n = 0; n < aNames.getLength(); ++n ) { - OUString aName = aNames[n]; - uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( aName ); + uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( aNames[n] ); OSL_ENSURE( xObj.is(), "An empty entry in the embedded objects list!" ); if ( xObj.is() ) { @@ -2260,7 +2259,7 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, catch (const std::exception& e) { const char *msg = e.what(); - OUString sError(msg, strlen(msg), RTL_TEXTENCODING_ASCII_US); + const OUString sError(msg, strlen(msg), RTL_TEXTENCODING_ASCII_US); SetError(*new StringErrorInfo(ERRCODE_SFX_DOLOADFAILED, sError, DialogMask::ButtonsOk | DialogMask::MessageError)); } @@ -2275,7 +2274,7 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) { - OUString aFilterName( rMedium.GetFilter()->GetFilterName() ); + const OUString aFilterName( rMedium.GetFilter()->GetFilterName() ); uno::Reference< document::XExporter > xExporter; { @@ -2342,7 +2341,7 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) { pNewValue[i] = pOldValue[i]; if ( pOldValue[i].Name == "FileName" ) - pNewValue[i].Value <<= OUString ( rMedium.GetName() ); + pNewValue[i].Value <<= rMedium.GetName(); else if ( pOldValue[i].Name == sOutputStream ) bHasOutputStream = true; else if ( pOldValue[i].Name == sStream ) @@ -3201,7 +3200,7 @@ bool StoragesOfUnknownMediaTypeAreCopied_Impl( const uno::Reference< embed::XSto if ( xSource->isStorageElement( aSubElements[nInd] ) ) { OUString aMediaType; - OUString aMediaTypePropName( "MediaType" ); + const OUString aMediaTypePropName( "MediaType" ); bool bGotMediaType = false; try @@ -3333,7 +3332,7 @@ bool SfxObjectShell::CopyStoragesOfUnknownMediaType( const uno::Reference< embed else if ( xSource->isStorageElement( aSubElements[nInd] ) ) { OUString aMediaType; - OUString aMediaTypePropName( "MediaType" ); + const OUString aMediaTypePropName( "MediaType" ); bool bGotMediaType = false; try commit e4bd8e218b68a4a70f798a0096cd904fdd344de3 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Mon May 1 18:19:41 2017 +0200 Avoid 'else' after 'return' Change-Id: I38daa42f0f764e05c8894f26faad14e947ee77ef diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index ab039b5d0e2c..543ac85a0416 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -735,7 +735,8 @@ OUString SfxObjectShell::GetTitle( sal_uInt16 nMaxLength ) const bRecur = false; return aTitle; } - else if (SFX_TITLE_APINAME == nMaxLength ) + + if (SFX_TITLE_APINAME == nMaxLength ) return GetAPIName(); // Picklist/Caption is mapped @@ -785,9 +786,9 @@ OUString SfxObjectShell::GetTitle( sal_uInt16 nMaxLength ) const { if ( nMaxLength == SFX_TITLE_FULLNAME ) return aURL.HasMark() ? INetURLObject( aURL.GetURLNoMark() ).PathToFileName() : aURL.PathToFileName(); - else if ( nMaxLength == SFX_TITLE_FILENAME ) + if ( nMaxLength == SFX_TITLE_FILENAME ) return aURL.getName(INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset); - else if ( pImpl->aTitle.isEmpty() ) + if ( pImpl->aTitle.isEmpty() ) pImpl->aTitle = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset ); } @@ -798,15 +799,14 @@ OUString SfxObjectShell::GetTitle( sal_uInt16 nMaxLength ) const const OUString aComplete( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); if( aComplete.getLength() > nMaxLength ) return "..." + aComplete.copy( aComplete.getLength() - nMaxLength + 3, nMaxLength - 3 ); - else - return aComplete; + return aComplete; } - else if ( nMaxLength == SFX_TITLE_FILENAME ) + if ( nMaxLength == SFX_TITLE_FILENAME ) { const OUString aName = INetURLObject::decode( aURL.GetBase(), INetURLObject::DecodeMechanism::WithCharset ); return aName.isEmpty() ? aURL.GetURLNoPass() : aName; } - else if ( nMaxLength == SFX_TITLE_FULLNAME ) + if ( nMaxLength == SFX_TITLE_FULLNAME ) return aURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ); // Generate Title from file name if possible commit 5e661008a58677e8871abf93209f81200507b29f Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Mon May 1 18:12:17 2017 +0200 OUStrings: constify and reduce temporaries Change-Id: Id1db5c17a346916a326529b750d2ff0a765af5da diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx index ad44a090ef2a..8070c90c1e2c 100644 --- a/sfx2/source/doc/iframe.cxx +++ b/sfx2/source/doc/iframe.cxx @@ -327,12 +327,12 @@ uno::Any SAL_CALL IFrameObject::getPropertyValue(const OUString& aPropertyName) { case WID_FRAME_URL: { - aAny <<= OUString( maFrmDescr.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + aAny <<= maFrmDescr.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ); } break; case WID_FRAME_NAME: { - aAny <<= OUString( maFrmDescr.GetName() ); + aAny <<= maFrmDescr.GetName(); } break; case WID_FRAME_IS_AUTO_SCROLL: diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 61d736c027bf..148e265ae524 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -187,7 +187,7 @@ void SfxObjectShell::UpdateDocInfoForSave() } else if ( IsModified() ) { - OUString aUserName = SvtUserOptions().GetFullName(); + const OUString aUserName = SvtUserOptions().GetFullName(); if ( !IsUseUserData() ) { // remove all data pointing to the current user @@ -394,7 +394,7 @@ void SfxObjectShell::UpdateFromTemplate_Impl( ) // created from template? uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties()); - OUString aTemplName( xDocProps->getTemplateName() ); + const OUString aTemplName( xDocProps->getTemplateName() ); OUString aTemplURL( xDocProps->getTemplateURL() ); OUString aFoundName; @@ -462,8 +462,7 @@ void SfxObjectShell::UpdateFromTemplate_Impl( ) bLoad = true; else if ( bCanUpdateFromTemplate == document::UpdateDocMode::ACCORDING_TO_CONFIG ) { - OUString sMessage( SfxResId(STR_QRYTEMPL_MESSAGE).toString() ); - sMessage = sMessage.replaceAll( "$(ARG1)", aTemplName ); + const OUString sMessage( SfxResId(STR_QRYTEMPL_MESSAGE).toString().replaceAll( "$(ARG1)", aTemplName ) ); ScopedVclPtrInstance< sfx2::QueryTemplateBox > aBox(GetDialogParent(), sMessage); if ( RET_YES == aBox->Execute() ) bLoad = true; diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index c91acbf1b401..ab039b5d0e2c 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -203,7 +203,7 @@ void SfxObjectShell::FlushDocInfo() SetModified(); uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties()); DoFlushDocInfo(); // call template method - OUString url(xDocProps->getAutoloadURL()); + const OUString url(xDocProps->getAutoloadURL()); sal_Int32 delay(xDocProps->getAutoloadSecs()); SetAutoLoad( INetURLObject(url), delay * 1000, (delay > 0) || !url.isEmpty() ); @@ -758,11 +758,11 @@ OUString SfxObjectShell::GetTitle( sal_uInt16 nMaxLength ) const return pImpl->aTitle; // must it be numbered? - OUString aNoName(SFX2_RESSTR(STR_NONAME)); + const OUString aNoName(SFX2_RESSTR(STR_NONAME)); if (pImpl->bIsNamedVisible) { // Append number - aNoName += " " + OUString::number(pImpl->nVisualDocumentNumber); + return aNoName + " " + OUString::number(pImpl->nVisualDocumentNumber); } // Document called "Untitled" for the time being commit 3908064e9034074c82ed62bf60f5107f27ca4061 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Mon Apr 24 16:37:46 2017 +0200 Simplify sdr::properties::ItemChangeBroadcaster Change-Id: Ie731294b6490165cf208335e7ec404a35f8a6a95 diff --git a/svx/inc/sdr/properties/itemsettools.hxx b/svx/inc/sdr/properties/itemsettools.hxx index c9cb93261ad0..4559f8f2e3c8 100644 --- a/svx/inc/sdr/properties/itemsettools.hxx +++ b/svx/inc/sdr/properties/itemsettools.hxx @@ -21,11 +21,11 @@ #define INCLUDED_SVX_INC_SDR_PROPERTIES_ITEMSETTOOLS_HXX #include <sal/types.h> -#include <vcl/region.hxx> +#include <tools/gen.hxx> +#include <vector> class SdrObject; class SfxItemSet; -namespace tools { class Rectangle; } class Fraction; // class to remember broadcast start positions @@ -35,21 +35,19 @@ namespace sdr { class ItemChangeBroadcaster { - bool mbSingleRect; - union { - RectangleVector* mpRectangleVector; - tools::Rectangle* mpRectangle; - }; + std::vector< tools::Rectangle > maRectangles; public: explicit ItemChangeBroadcaster(const SdrObject& rObj); - ~ItemChangeBroadcaster(); sal_uInt32 GetRectangleCount() const { - return mbSingleRect ? 1 : mpRectangleVector->size(); + return maRectangles.size(); + } + const tools::Rectangle& GetRectangle(sal_uInt32 nIndex) const + { + return maRectangles[nIndex]; } - const tools::Rectangle& GetRectangle(sal_uInt32 nIndex) const; }; } // end of namespace properties } // end of namespace sdr diff --git a/svx/source/sdr/properties/itemsettools.cxx b/svx/source/sdr/properties/itemsettools.cxx index c11c54dcf445..6e7d990ef781 100644 --- a/svx/source/sdr/properties/itemsettools.cxx +++ b/svx/source/sdr/properties/itemsettools.cxx @@ -38,8 +38,7 @@ namespace sdr if (const SdrObjGroup* pGroupObj = dynamic_cast<const SdrObjGroup*>(&rObj)) { SdrObjListIter aIter(*pGroupObj, SdrIterMode::DeepNoGroups); - mpRectangleVector = new RectangleVector; - mpRectangleVector->reserve(aIter.Count()); + maRectangles.reserve(aIter.Count()); while(aIter.IsMore()) { @@ -47,40 +46,13 @@ namespace sdr if(pObj) { - mpRectangleVector->push_back(pObj->GetLastBoundRect()); + maRectangles.push_back(pObj->GetLastBoundRect()); } } - - mbSingleRect = false; - } - else - { - mpRectangle = new tools::Rectangle(rObj.GetLastBoundRect()); - mbSingleRect = true; - } - } - - ItemChangeBroadcaster::~ItemChangeBroadcaster() - { - if (!mbSingleRect) - { - delete mpRectangleVector; - } - else - { - delete mpRectangle; - } - } - - const tools::Rectangle& ItemChangeBroadcaster::GetRectangle(sal_uInt32 nIndex) const - { - if (!mbSingleRect) - { - return (*mpRectangleVector)[nIndex]; } else { - return *mpRectangle; + maRectangles.push_back(rObj.GetLastBoundRect()); } } } // end of namespace properties _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits