[Libreoffice-commits] core.git: 8 commits - sfx2/inc sfx2/source svx/source
Matteo Casalin
matteo.casalin at yahoo.com
Mon Apr 24 11:54:58 UTC 2017
sfx2/inc/guisaveas.hxx | 1
sfx2/source/doc/DocumentMetadataAccess.cxx | 23 --
sfx2/source/doc/graphhelp.cxx | 3
sfx2/source/doc/guisaveas.cxx | 229 ++++++++++-------------------
sfx2/source/doc/objserv.cxx | 1
sfx2/source/view/ipclient.cxx | 1
svx/source/sdr/properties/properties.cxx | 11 -
svx/source/svdraw/svdundo.cxx | 22 --
8 files changed, 97 insertions(+), 194 deletions(-)
New commits:
commit 653e455e1bd5bab87dbc6a20853c8a9ca0af6175
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 24 13:23:51 2017 +0200
Do not pass a suggested name to GUIStoreModel: it is always overwritten
Change-Id: Iac60c012f05916c5324e1ea8bae142ab329aa4e0
diff --git a/sfx2/inc/guisaveas.hxx b/sfx2/inc/guisaveas.hxx
index ee044218caad..cc8a091a3bfc 100644
--- a/sfx2/inc/guisaveas.hxx
+++ b/sfx2/inc/guisaveas.hxx
@@ -62,7 +62,6 @@ public:
const OUString& aSlotName,
css::uno::Sequence< css::beans::PropertyValue >& aArgsSequence,
bool bPreselectPassword,
- const OUString& aUserSelectedName,
SignatureState nDocumentSignatureState );
static bool CheckFilterOptionsAppearance(
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 02f6a11747dc..573a84ded23c 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -1254,10 +1254,8 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
const OUString& aSlotName,
uno::Sequence< beans::PropertyValue >& aArgsSequence,
bool bPreselectPassword,
- const OUString& _aSuggestedName,
SignatureState nDocumentSignatureState )
{
- OUString aSuggestedName = _aSuggestedName;
ModelData_Impl aModelData( *this, xModel, aArgsSequence );
bool bDialogUsed = false;
@@ -1454,7 +1452,7 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
aSuggestedDir = aModelData.GetDocProps().getUnpackedValueOrDefault("SuggestedSaveAsDir", OUString() );
}
- aSuggestedName = aModelData.GetMediaDescr().getUnpackedValueOrDefault("SuggestedSaveAsName", OUString() );
+ OUString aSuggestedName = aModelData.GetMediaDescr().getUnpackedValueOrDefault("SuggestedSaveAsName", OUString() );
if ( aSuggestedName.isEmpty() )
aSuggestedName = aModelData.GetDocProps().getUnpackedValueOrDefault("SuggestedSaveAsName", OUString() );
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 48903d1346ae..660a7da9d932 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -631,7 +631,6 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
OUString::createFromAscii( pSlot->GetUnoName() ),
aDispatchArgs,
bPreselectPassword,
- GetSharedFileURL(),
GetDocumentSignatureState() );
}
else
diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx
index b3fa11e945af..a60a84c822b9 100644
--- a/sfx2/source/view/ipclient.cxx
+++ b/sfx2/source/view/ipclient.cxx
@@ -844,7 +844,6 @@ ErrCode SfxInPlaceClient::DoVerb( long nVerb )
"SaveAs",
aDispatchArgs,
false,
- "",
SignatureState::NOSIGNATURES );
}
catch( const task::ErrorCodeIOException& aErrorEx )
commit 92b8b8b04cdceedcdc4e58041d9d4d1c7dee21b8
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 24 13:12:35 2017 +0200
OUStrings: constify and avoid temporaries some more
Change-Id: I965ea920880bb631e108bd963ac1ab21582222ef
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 36a4fe8492f7..02f6a11747dc 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -482,9 +482,7 @@ uno::Sequence< beans::PropertyValue > ModelData_Impl::GetDocServiceDefaultFilter
{
uno::Sequence< beans::PropertyValue > aProps;
- OUString aFilterName = GetModuleProps().getUnpackedValueOrDefault(
- "ooSetupFactoryDefaultFilter",
- OUString() );
+ const OUString aFilterName = GetModuleProps().getUnpackedValueOrDefault( "ooSetupFactoryDefaultFilter", OUString() );
m_pOwner->GetFilterConfiguration()->getByName( aFilterName ) >>= aProps;
@@ -697,12 +695,7 @@ sal_Int8 ModelData_Impl::CheckStateForSave()
GetMediaDescr() = aAcceptedArgs;
// check that the old filter is acceptable
- OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault(
- aFilterNameString,
- OUString() );
- sal_Int8 nResult = CheckFilter( aOldFilterName );
-
- return nResult;
+ return CheckFilter( GetDocProps().getUnpackedValueOrDefault(aFilterNameString, OUString()) );
}
sal_Int8 ModelData_Impl::CheckFilter( const OUString& aFilterName )
@@ -774,10 +767,7 @@ bool ModelData_Impl::CheckFilterOptionsDialogExistence()
if ( xFilterEnum->nextElement() >>= aProps )
{
::comphelper::SequenceAsHashMap aPropsHM( aProps );
- OUString aUIServName = aPropsHM.getUnpackedValueOrDefault(
- "UIComponent",
- OUString() );
- if ( !aUIServName.isEmpty() )
+ if ( !aPropsHM.getUnpackedValueOrDefault("UIComponent", OUString()).isEmpty() )
return true;
}
}
@@ -1289,7 +1279,7 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
sal_Int8 nStatusSave = STATUS_NO_ACTION;
::comphelper::SequenceAsHashMap::const_iterator aSaveACopyIter =
- aModelData.GetMediaDescr().find( ::rtl::OUString("SaveACopy") );
+ aModelData.GetMediaDescr().find( OUString("SaveACopy") );
if ( aSaveACopyIter != aModelData.GetMediaDescr().end() )
{
bool bSaveACopy = false;
@@ -1664,8 +1654,7 @@ bool SfxStoringHelper::CheckFilterOptionsAppearance(
if ( aAny >>= aProps )
{
::comphelper::SequenceAsHashMap aPropsHM( aProps );
- OUString aServiceName = aPropsHM.getUnpackedValueOrDefault( "UIComponent", OUString() );
- if( !aServiceName.isEmpty() )
+ if( !aPropsHM.getUnpackedValueOrDefault( "UIComponent", OUString() ).isEmpty() )
bUseFilterOptions = true;
}
}
commit de457f10a7da65a64c032362f391e7046822f91c
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 24 12:56:02 2017 +0200
Minor optimizations to loops
* Use const value for for checks
* Early bail out
Change-Id: I8d280a4bfb68da108925ae6b1a3d1b0b827dc3a5
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 52eb9ee9e5c2..36a4fe8492f7 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -563,7 +563,7 @@ bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName )
uno::Any aAny = m_pOwner->GetFilterConfiguration()->getByName( aFilterName );
if ( aAny >>= aProps )
{
- sal_Int32 nPropertyCount = aProps.getLength();
+ const sal_Int32 nPropertyCount = aProps.getLength();
for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty )
{
if( aProps[nProperty].Name == "UIComponent" )
@@ -593,7 +593,8 @@ bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName )
{
uno::Sequence< beans::PropertyValue > aPropsFromDialog =
xFilterProperties->getPropertyValues();
- for ( sal_Int32 nInd = 0; nInd < aPropsFromDialog.getLength(); nInd++ )
+ const sal_Int32 nPropsLen {aPropsFromDialog.getLength()};
+ for ( sal_Int32 nInd = 0; nInd < nPropsLen; ++nInd )
GetMediaDescr()[aPropsFromDialog[nInd].Name] = aPropsFromDialog[nInd].Value;
}
else
@@ -1480,8 +1481,7 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
if ( aBlackListIter != aModelData.GetMediaDescr().end() )
aBlackListIter->second >>= aBlackList;
- bool bExit = false;
- while ( !bExit )
+ for (;;)
{
// in case the dialog is opened a second time the folder should be the same as previously navigated to by the user, not what was handed over by initial parameters
bUseFilterOptions = aModelData.OutputFileDialog( nStoreMode, aFilterProps, bSetStandardName, aSuggestedName, bPreselectPassword, aSuggestedDir, nDialog, sStandardDir, aBlackList );
@@ -1498,11 +1498,11 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
else if ( nStatusFilterSave == STATUS_SAVE )
{
// user confirmed alien filter or "good" filter is used
- bExit = true;
+ break;
}
}
else
- bExit = true;
+ break;
}
bDialogUsed = true;
@@ -1705,9 +1705,8 @@ void SfxStoringHelper::SetDocInfoState(
uno::Reference< beans::XPropertySetInfo > xSetInfo = xSet->getPropertySetInfo();
uno::Sequence< beans::Property > lProps = xSetInfo->getProperties();
const beans::Property* pProps = lProps.getConstArray();
- sal_Int32 c = lProps.getLength();
- sal_Int32 i = 0;
- for (i=0; i<c; ++i)
+ const sal_Int32 nPropLen = lProps.getLength();
+ for (sal_Int32 i=0; i<nPropLen; ++i)
{
uno::Any aValue = xPropSet->getPropertyValue( pProps[i].Name );
if ( pProps[i].Attributes & css::beans::PropertyAttribute::REMOVABLE )
commit f3902b2369cbcf123059fce9bc9269a123d979a1
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 24 12:45:29 2017 +0200
Fix indentation
Change-Id: I1c974fb556d5fbe8492356a7471e659035308d0e
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index a1ab9ca47d02..52eb9ee9e5c2 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -1659,16 +1659,14 @@ bool SfxStoringHelper::CheckFilterOptionsAppearance(
if( xFilterCFG.is() )
{
try {
- uno::Sequence < beans::PropertyValue > aProps;
+ uno::Sequence < beans::PropertyValue > aProps;
uno::Any aAny = xFilterCFG->getByName( aFilterName );
- if ( aAny >>= aProps )
- {
+ if ( aAny >>= aProps )
+ {
::comphelper::SequenceAsHashMap aPropsHM( aProps );
- OUString aServiceName = aPropsHM.getUnpackedValueOrDefault(
- "UIComponent",
- OUString() );
+ OUString aServiceName = aPropsHM.getUnpackedValueOrDefault( "UIComponent", OUString() );
if( !aServiceName.isEmpty() )
- bUseFilterOptions = true;
+ bUseFilterOptions = true;
}
}
catch( const uno::Exception& )
commit 67d461ca4f558eedefd1dfce2c7c25a708326eaa
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 24 12:17:29 2017 +0200
OUStrings: constify and avoid temporaries
Change-Id: I2e4a36a5ac25d1c44c674eb3f721c974f29b1fd9
diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx
index 419dc7865612..581895ba693f 100644
--- a/sfx2/source/doc/graphhelp.cxx
+++ b/sfx2/source/doc/graphhelp.cxx
@@ -214,8 +214,7 @@ bool GraphicHelper::getThumbnailReplacement_Impl( sal_Int32 nResID, const uno::R
try
{
uno::Reference< graphic::XGraphicProvider > xGraphProvider(graphic::GraphicProvider::create(xContext));
- OUString aURL("private:resource/sfx/bitmapex/");
- aURL += OUString::number( nResID );
+ const OUString aURL{"private:resource/sfx/bitmapex/"+OUString::number( nResID )};
uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
aMediaProps[0].Name = "URL";
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 91f17c39fc1c..a1ab9ca47d02 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -338,12 +338,10 @@ ModelData_Impl::ModelData_Impl( SfxStoringHelper& aOwner,
, m_bRecommendReadOnly( false )
{
CheckInteractionHandler();
- OUString sModuleName;
try
{
uno::Reference< lang::XComponent > xCurrentComponent = frame::Desktop::create( comphelper::getProcessComponentContext() )->getCurrentComponent();
- sModuleName = aOwner.GetModuleManager()->identify(xCurrentComponent);
- if(sModuleName == "com.sun.star.chart2.ChartDocument")
+ if (aOwner.GetModuleManager()->identify(xCurrentComponent) == "com.sun.star.chart2.ChartDocument")
{
// let us switch the model and set the xStorable and
// XStorable2 to the old model.
@@ -458,13 +456,14 @@ OUString ModelData_Impl::GetDocServiceName()
void ModelData_Impl::CheckInteractionHandler()
{
+ const OUString sInteractionHandler {"InteractionHandler"};
::comphelper::SequenceAsHashMap::const_iterator aInteractIter =
- m_aMediaDescrHM.find( OUString("InteractionHandler") );
+ m_aMediaDescrHM.find( sInteractionHandler );
if ( aInteractIter == m_aMediaDescrHM.end() )
{
try {
- m_aMediaDescrHM[ OUString("InteractionHandler") ]
+ m_aMediaDescrHM[ sInteractionHandler ]
<<= task::InteractionHandler::createWithParent( comphelper::getProcessComponentContext(), nullptr);
}
catch( const uno::Exception& )
@@ -643,9 +642,8 @@ sal_Int8 ModelData_Impl::CheckSaveAcceptable( sal_Int8 nCurStatus )
// the saving is acceptable
// in case the configuration entry is not set or set to false
// or in case of version creation
- OUString aVersionCommentString = "VersionComment";
if ( officecfg::Office::Common::Save::Document::AlwaysSaveAs::get()
- && GetMediaDescr().find( aVersionCommentString ) == GetMediaDescr().end() )
+ && GetMediaDescr().find( OUString("VersionComment") ) == GetMediaDescr().end() )
{
// notify the user that SaveAs is going to be done
vcl::Window* pWin = SfxStoringHelper::GetModelWindow( m_xModel );
@@ -671,12 +669,12 @@ sal_Int8 ModelData_Impl::CheckStateForSave()
// check acceptable entries for media descriptor
::comphelper::SequenceAsHashMap aAcceptedArgs;
- OUString aVersionCommentString("VersionComment");
- OUString aAuthorString("Author");
- OUString aDontTerminateEdit("DontTerminateEdit");
- OUString aInteractionHandlerString("InteractionHandler");
- OUString aStatusIndicatorString("StatusIndicator");
- OUString aFailOnWarningString("FailOnWarning");
+ const OUString aVersionCommentString("VersionComment");
+ const OUString aAuthorString("Author");
+ const OUString aDontTerminateEdit("DontTerminateEdit");
+ const OUString aInteractionHandlerString("InteractionHandler");
+ const OUString aStatusIndicatorString("StatusIndicator");
+ const OUString aFailOnWarningString("FailOnWarning");
if ( GetMediaDescr().find( aVersionCommentString ) != GetMediaDescr().end() )
aAcceptedArgs[ aVersionCommentString ] = GetMediaDescr()[ aVersionCommentString ];
@@ -744,16 +742,11 @@ sal_Int8 ModelData_Impl::CheckFilter( const OUString& aFilterName )
{
// the default filter is acceptable and the old filter is alien one
// so ask to make a saveAs operation
- OUString aUIName = aFiltPropsHM.getUnpackedValueOrDefault("UIName",
- OUString() );
- OUString aDefUIName = aDefFiltPropsHM.getUnpackedValueOrDefault("UIName",
- OUString() );
- OUString aPreusedFilterName = GetDocProps().getUnpackedValueOrDefault(
- "PreusedFilterName",
- OUString() );
-
- OUString aDefType = aDefFiltPropsHM.getUnpackedValueOrDefault( "Type", OUString() );
- OUString aDefExtension = GetRecommendedExtension( aDefType );
+ const OUString aUIName = aFiltPropsHM.getUnpackedValueOrDefault("UIName", OUString() );
+ const OUString aDefUIName = aDefFiltPropsHM.getUnpackedValueOrDefault("UIName", OUString() );
+ const OUString aPreusedFilterName = GetDocProps().getUnpackedValueOrDefault("PreusedFilterName", OUString() );
+ const OUString aDefType = aDefFiltPropsHM.getUnpackedValueOrDefault( "Type", OUString() );
+ const OUString aDefExtension = GetRecommendedExtension( aDefType );
if ( !aPreusedFilterName.equals( aFilterName ) && !aUIName.equals( aDefUIName ) )
{
@@ -854,7 +847,7 @@ bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
std::unique_ptr<sfx2::FileDialogHelper> pFileDlg;
- OUString aDocServiceName = GetDocServiceName();
+ const OUString aDocServiceName {GetDocServiceName()};
DBG_ASSERT( !aDocServiceName.isEmpty(), "No document service for this module set!" );
SfxFilterFlags nMust = getMustFlags( nStoreMode );
@@ -867,10 +860,7 @@ bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
{
// this is a PDF export
// the filter options has been shown already
- OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault(
- "UIName",
- OUString() );
-
+ const OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "UIName", OUString() );
pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aFilterUIName, "pdf", rStandardDir, rBlackList ));
pFileDlg->SetCurrentFilter( aFilterUIName );
}
@@ -898,11 +888,8 @@ bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
if ( xControlAccess.is() )
{
- OUString aCtrlText = SfxResId(STR_EXPORTBUTTON).toString();
- xControlAccess->setLabel( ui::dialogs::CommonFilePickerElementIds::PUSHBUTTON_OK, aCtrlText );
-
- aCtrlText = SfxResId(STR_LABEL_FILEFORMAT).toString();
- xControlAccess->setLabel( ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER_LABEL, aCtrlText );
+ xControlAccess->setLabel( ui::dialogs::CommonFilePickerElementIds::PUSHBUTTON_OK, SfxResId(STR_EXPORTBUTTON).toString() );
+ xControlAccess->setLabel( ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER_LABEL, SfxResId(STR_LABEL_FILEFORMAT).toString() );
}
}
else
@@ -921,21 +908,14 @@ bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
if ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) )
{
// it is export, set the preselected filter
- OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault(
- "UIName",
- OUString() );
- pFileDlg->SetCurrentFilter( aFilterUIName );
- aAdjustToType = aPreselectedFilterPropsHM.getUnpackedValueOrDefault(
- "Type",
- OUString() );
+ pFileDlg->SetCurrentFilter( aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "UIName", OUString() ) );
+ aAdjustToType = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "Type", OUString() );
}
// it is no export, bSetStandardName == true means that user agreed to store document in the default (default default ;-)) format
else if ( bSetStandardName || GetStorable()->hasLocation() )
{
uno::Sequence< beans::PropertyValue > aOldFilterProps;
- OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault(
- sFilterNameString,
- OUString() );
+ const OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault( sFilterNameString, OUString() );
if ( !aOldFilterName.isEmpty() )
m_pOwner->GetFilterConfiguration()->getByName( aOldFilterName ) >>= aOldFilterProps;
@@ -946,14 +926,8 @@ bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
if ( bSetStandardName || ( nOldFiltFlags & nMust ) != nMust || bool(nOldFiltFlags & nDont) )
{
// the suggested type will be changed, the extension should be adjusted
- aAdjustToType = aPreselectedFilterPropsHM.getUnpackedValueOrDefault(
- "Type",
- OUString() );
-
- OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault(
- "UIName",
- OUString() );
- pFileDlg->SetCurrentFilter( aFilterUIName );
+ aAdjustToType = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "Type", OUString() );
+ pFileDlg->SetCurrentFilter( aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "UIName", OUString() ) );
}
else
{
@@ -963,10 +937,10 @@ bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
}
}
- OUString aRecommendedDir = GetRecommendedDir( aSuggestedDir );
+ const OUString aRecommendedDir {GetRecommendedDir( aSuggestedDir )};
if ( !aRecommendedDir.isEmpty() )
pFileDlg->SetDisplayFolder( aRecommendedDir );
- OUString aRecommendedName = GetRecommendedName( aSuggestedName, aAdjustToType );
+ const OUString aRecommendedName {GetRecommendedName( aSuggestedName, aAdjustToType )};
if ( !aRecommendedName.isEmpty() )
pFileDlg->SetFileName( aRecommendedName );
@@ -996,17 +970,15 @@ bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
aDialogParams.Put( SfxBoolItem( SID_PASSWORDINTERACTION, true ) );
}
- // aStringTypeFN is a pure output parameter, pDialogParams is an in/out parameter
- OUString aStringTypeFN;
- if ( pFileDlg->Execute( pDialogParams, aStringTypeFN ) != ERRCODE_NONE )
+ // aFilterName is a pure output parameter, pDialogParams is an in/out parameter
+ OUString aFilterName;
+ if ( pFileDlg->Execute( pDialogParams, aFilterName ) != ERRCODE_NONE )
{
throw task::ErrorCodeIOException(
"ModelData_Impl::OutputFileDialog: ERRCODE_IO_ABORT",
uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT);
}
- OUString aFilterName = aStringTypeFN;
-
// the following two arguments can not be converted in MediaDescriptor,
// so they should be removed from the ItemSet after retrieving
const SfxBoolItem* pRecommendReadOnly = SfxItemSet::GetItem<SfxBoolItem>(pDialogParams, SID_RECOMMENDREADONLY, false);
@@ -1025,12 +997,8 @@ bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
// old filter options should be cleared in case different filter is used
- OUString aFilterFromMediaDescr = GetMediaDescr().getUnpackedValueOrDefault(
- sFilterNameString,
- OUString() );
- OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault(
- sFilterNameString,
- OUString() );
+ const OUString aFilterFromMediaDescr = GetMediaDescr().getUnpackedValueOrDefault( sFilterNameString, OUString() );
+ const OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault( sFilterNameString, OUString() );
const OUString sFilterOptionsString(aFilterOptionsString);
const OUString sFilterDataString(aFilterDataString);
@@ -1102,8 +1070,7 @@ bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
}
// merge in results of the dialog execution
- GetMediaDescr()[OUString("URL")] <<=
- OUString( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ));
+ GetMediaDescr()[OUString("URL")] <<= aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
GetMediaDescr()[sFilterNameString] <<= aFilterName;
return bUseFilterOptions;
@@ -1176,8 +1143,6 @@ OUString ModelData_Impl::GetRecommendedExtension( const OUString& aTypeName )
OUString ModelData_Impl::GetRecommendedDir( const OUString& aSuggestedDir )
{
- OUString aRecommendedDir;
-
if ( ( !aSuggestedDir.isEmpty() || GetStorable()->hasLocation() )
&& !GetMediaDescr().getUnpackedValueOrDefault("RepairPackage", false ) )
{
@@ -1186,7 +1151,7 @@ OUString ModelData_Impl::GetRecommendedDir( const OUString& aSuggestedDir )
aLocation = INetURLObject( aSuggestedDir );
else
{
- OUString aOldURL = GetStorable()->getLocation();
+ const OUString aOldURL = GetStorable()->getLocation();
if ( !aOldURL.isEmpty() )
{
INetURLObject aTmp( aOldURL );
@@ -1204,52 +1169,46 @@ OUString ModelData_Impl::GetRecommendedDir( const OUString& aSuggestedDir )
aLocation.setFinalSlash();
if ( !aLocation.HasError() )
- aRecommendedDir = aLocation.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- }
- else
- {
- aRecommendedDir = INetURLObject( SvtPathOptions().GetWorkPath() ).GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ return aLocation.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+
+ return OUString();
}
- return aRecommendedDir;
+ return INetURLObject( SvtPathOptions().GetWorkPath() ).GetMainURL( INetURLObject::DecodeMechanism::NONE );
}
OUString ModelData_Impl::GetRecommendedName( const OUString& aSuggestedName, const OUString& aTypeName )
{
// the last used name might be provided by aSuggestedName from the old selection, or from the MediaDescriptor
- OUString aRecommendedName;
-
if ( !aSuggestedName.isEmpty() )
- aRecommendedName = aSuggestedName;
- else
+ return aSuggestedName;
+
+ OUString aRecommendedName {INetURLObject( GetStorable()->getLocation() ).GetName( INetURLObject::DecodeMechanism::WithCharset )};
+ if ( aRecommendedName.isEmpty() )
{
- aRecommendedName = INetURLObject( GetStorable()->getLocation() ).GetName( INetURLObject::DecodeMechanism::WithCharset );
- if ( aRecommendedName.isEmpty() )
- {
- try {
- uno::Reference< frame::XTitle > xTitle( GetModel(), uno::UNO_QUERY_THROW );
- aRecommendedName = xTitle->getTitle();
- } catch( const uno::Exception& ) {}
- }
+ try {
+ uno::Reference< frame::XTitle > xTitle( GetModel(), uno::UNO_QUERY_THROW );
+ aRecommendedName = xTitle->getTitle();
+ } catch( const uno::Exception& ) {}
+ }
- if ( !aRecommendedName.isEmpty() && !aTypeName.isEmpty() )
+ if ( !aRecommendedName.isEmpty() && !aTypeName.isEmpty() )
+ {
+ // adjust the extension to the type
+ uno::Reference< container::XNameAccess > xTypeDetection(
+ comphelper::getProcessServiceFactory()->createInstance("com.sun.star.document.TypeDetection"),
+ uno::UNO_QUERY );
+ if ( xTypeDetection.is() )
{
- // adjust the extension to the type
- uno::Reference< container::XNameAccess > xTypeDetection(
- comphelper::getProcessServiceFactory()->createInstance("com.sun.star.document.TypeDetection"),
- uno::UNO_QUERY );
- if ( xTypeDetection.is() )
- {
- INetURLObject aObj( "c:/" + aRecommendedName, INetProtocol::File,
- INetURLObject::EncodeMechanism::All, RTL_TEXTENCODING_UTF8, FSysStyle::Dos );
+ INetURLObject aObj( "c:/" + aRecommendedName, INetProtocol::File,
+ INetURLObject::EncodeMechanism::All, RTL_TEXTENCODING_UTF8, FSysStyle::Dos );
- OUString aExtension = GetRecommendedExtension( aTypeName );
- if ( !aExtension.isEmpty() )
- aObj.SetExtension( aExtension );
+ const OUString aExtension = GetRecommendedExtension( aTypeName );
+ if ( !aExtension.isEmpty() )
+ aObj.SetExtension( aExtension );
- aRecommendedName = aObj.GetName( INetURLObject::DecodeMechanism::WithCharset );
- }
+ aRecommendedName = aObj.GetName( INetURLObject::DecodeMechanism::WithCharset );
}
}
@@ -1442,18 +1401,12 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
uno::Reference< uno::XInterface >(), ERRCODE_IO_INVALIDPARAMETER);
::comphelper::SequenceAsHashMap aFilterPropsHM( aFilterProps );
- OUString aFilterName = aFilterPropsHM.getUnpackedValueOrDefault(
- "Name",
- OUString() );
+ OUString aFilterName = aFilterPropsHM.getUnpackedValueOrDefault( "Name", OUString() );
const OUString sFilterNameString(aFilterNameString);
- OUString aFilterFromMediaDescr = aModelData.GetMediaDescr().getUnpackedValueOrDefault(
- sFilterNameString,
- OUString() );
- OUString aOldFilterName = aModelData.GetDocProps().getUnpackedValueOrDefault(
- sFilterNameString,
- OUString() );
+ const OUString aFilterFromMediaDescr = aModelData.GetMediaDescr().getUnpackedValueOrDefault( sFilterNameString, OUString() );
+ const OUString aOldFilterName = aModelData.GetDocProps().getUnpackedValueOrDefault( sFilterNameString, OUString() );
bool bUseFilterOptions = false;
::comphelper::SequenceAsHashMap::const_iterator aFileNameIter = aModelData.GetMediaDescr().find( OUString("URL") );
@@ -1535,9 +1488,7 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
if ( nStoreMode == SAVEAS_REQUESTED )
{
// in case of saving check filter for possible alien warning
- OUString aSelFilterName = aModelData.GetMediaDescr().getUnpackedValueOrDefault(
- sFilterNameString,
- OUString() );
+ const OUString aSelFilterName = aModelData.GetMediaDescr().getUnpackedValueOrDefault( sFilterNameString, OUString() );
sal_Int8 nStatusFilterSave = aModelData.CheckFilter( aSelFilterName );
if ( nStatusFilterSave == STATUS_SAVEAS_STANDARDNAME )
{
commit e14046943dea4b3ac0a47bb6224c0aeeb1f417e0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 24 11:20:24 2017 +0200
OUStrings: avoid temporaries and OUStringBuffers
Change-Id: Ibb8493807acd292add892b80839b6f6d3d90a8e9
diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx
index 2d7d3c685e40..fd3a14808ea9 100644
--- a/sfx2/source/doc/DocumentMetadataAccess.cxx
+++ b/sfx2/source/doc/DocumentMetadataAccess.cxx
@@ -159,8 +159,7 @@ uno::Reference<rdf::XURI> createBaseURI(
const sal_Int32 count( xBaseURI->getPathSegmentCount() );
if (count > 0)
{
- const OUString last( xBaseURI->getPathSegment(count - 1) );
- buf.append(last);
+ buf.append(xBaseURI->getPathSegment(count - 1));
}
buf.append('/');
}
@@ -169,11 +168,10 @@ uno::Reference<rdf::XURI> createBaseURI(
buf.append(i_rSubDocument);
buf.append('/');
}
- const OUString Path(buf.makeStringAndClear());
- if (!Path.isEmpty())
+ if (!buf.isEmpty())
{
const uno::Reference< uri::XUriReference > xPathURI(
- xUriFactory->parse(Path), uno::UNO_SET_THROW );
+ xUriFactory->parse(buf.makeStringAndClear()), uno::UNO_SET_THROW );
xBaseURI.set(
xUriFactory->makeAbsolute(xBaseURI, xPathURI,
true, uri::RelativeUriExcessParentSegments_ERROR),
@@ -549,9 +547,7 @@ readStream(struct DocumentMetadataAccess_Impl & i_rImpl,
return;
}
} catch (const uno::Exception &) { }
- OUStringBuffer buf(i_rBaseURI);
- buf.append(dir).append('/');
- readStream(i_rImpl, xDir, rest, buf.makeStringAndClear() );
+ readStream(i_rImpl, xDir, rest, i_rBaseURI+dir+"/" );
} else {
throw mkException(
"readStream: is not a directory",
@@ -650,10 +646,7 @@ writeStream(struct DocumentMetadataAccess_Impl & i_rImpl,
return;
}
} catch (const uno::Exception &) { }
- OUStringBuffer buf(i_rBaseURI);
- buf.append(dir).append('/');
- writeStream(i_rImpl, xDir, i_xGraphName, rest,
- buf.makeStringAndClear());
+ writeStream(i_rImpl, xDir, i_xGraphName, rest, i_rBaseURI+dir+"/");
uno::Reference<embed::XTransactedObject> const xTransaction(
xDir, uno::UNO_QUERY);
if (xTransaction.is()) {
@@ -684,7 +677,6 @@ retry:
i_rImpl.m_xRepository.set(rdf::Repository::create(i_rImpl.m_xContext),
uno::UNO_SET_THROW);
- const OUString baseURI( i_xBaseURI->getStringValue() );
// try to delay raising errors until after initialization is done
uno::Any rterr;
ucb::InteractiveAugmentedIOException iaioe;
@@ -693,7 +685,7 @@ retry:
const uno::Reference <rdf::XURI> xManifest(
getURIForStream(i_rImpl, s_manifest));
try {
- readStream(i_rImpl, i_xStorage, s_manifest, baseURI);
+ readStream(i_rImpl, i_xStorage, s_manifest, i_xBaseURI->getStringValue());
} catch (const ucb::InteractiveAugmentedIOException & e) {
// no manifest.rdf: this is not an error in ODF < 1.2
if (!(ucb::IOErrorCode_NOT_EXISTING_PATH == e.Code)) {
@@ -852,10 +844,9 @@ DocumentMetadataAccess::getElementByURI(
if (!name.match(baseURI)) {
return nullptr;
}
- const OUString relName( name.copy(baseURI.getLength()) );
OUString path;
OUString idref;
- if (!splitXmlId(relName, path, idref)) {
+ if (!splitXmlId(name.copy(baseURI.getLength()), path, idref)) {
return nullptr;
}
commit a1f9de6bbd957e0e119b99a4fe7cfab54677be30
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 24 10:52:54 2017 +0200
OUStrings: constify and avoid temporaries
Change-Id: I9d75924b414f21dacad2d72908c1e4e3af291672
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index b411e935c88e..8380f0cf8e40 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -216,24 +216,16 @@ SdrUndoObj::SdrUndoObj(SdrObject& rNewObj)
OUString SdrUndoObj::GetDescriptionStringForObject( const SdrObject& _rForObject, sal_uInt16 nStrCacheID, bool bRepeat )
{
- OUString rStr = ImpGetResStr(nStrCacheID);
+ const OUString rStr {ImpGetResStr(nStrCacheID)};
- sal_Int32 nPos = rStr.indexOf("%1");
+ const sal_Int32 nPos = rStr.indexOf("%1");
+ if (nPos < 0)
+ return rStr;
- if(nPos != -1)
- {
- if(bRepeat)
- {
- rStr = rStr.replaceAt(nPos, 2, ImpGetResStr(STR_ObjNameSingulPlural));
- }
- else
- {
- OUString aStr(_rForObject.TakeObjNameSingul());
- rStr = rStr.replaceAt(nPos, 2, aStr);
- }
- }
+ if (bRepeat)
+ return rStr.replaceAt(nPos, 2, ImpGetResStr(STR_ObjNameSingulPlural));
- return rStr;
+ return rStr.replaceAt(nPos, 2, _rForObject.TakeObjNameSingul());
}
void SdrUndoObj::ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, OUString& rStr, bool bRepeat) const
commit 90f492d46014068c64767100dc870bafc04d2ac7
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Mon Apr 24 10:18:37 2017 +0200
Remove code commented-out since 2003-11-24
Change-Id: Iad2fb481969a1cc9cfd3e687b94ac99796466926
diff --git a/svx/source/sdr/properties/properties.cxx b/svx/source/sdr/properties/properties.cxx
index 1cda9c4328d6..9c4c8fc3585f 100644
--- a/svx/source/sdr/properties/properties.cxx
+++ b/svx/source/sdr/properties/properties.cxx
@@ -132,13 +132,6 @@ namespace sdr
{
const sal_uInt32 nCount(rChange.GetRectangleCount());
- // #110094#-14 Reduce to do only second change
- //// invalidate all remembered rectangles
- //for(sal_uInt32 a(0); a < nCount; a++)
- //{
- // GetSdrObject().BroadcastObjectChange(rChange.GetRectangle(a));
- //}
-
// invalidate all new rectangles
if(dynamic_cast<const SdrObjGroup*>( &GetSdrObject() ) != nullptr)
{
@@ -147,15 +140,11 @@ namespace sdr
while(aIter.IsMore())
{
SdrObject* pObj = aIter.Next();
- // This is done with ItemSetChanged
- // pObj->SetChanged();
pObj->BroadcastObjectChange();
}
}
else
{
- // This is done with ItemSetChanged
- // GetSdrObject().SetChanged();
GetSdrObject().BroadcastObjectChange();
}
More information about the Libreoffice-commits
mailing list