OUString-related simplifications

Change-Id: I2f4099410bcdb9e04583cd37bf63ef86ce81f7e5
This commit is contained in:
Matteo Casalin
2017-03-19 12:06:20 +01:00
parent 4a268ebc3f
commit e256519a62
2 changed files with 28 additions and 56 deletions

View File

@@ -239,7 +239,7 @@ static bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHa
else else
{ {
// the binary format // the binary format
bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), OUString( "com.sun.star.text.TextDocument" ).equals( pFilter->GetServiceName() ) ) == nPasswordHash ); bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), pFilter->GetServiceName()=="com.sun.star.text.TextDocument" ) == nPasswordHash );
} }
} }
else else
@@ -718,7 +718,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
{ {
SfxAllItemSet aSet( pApp->GetPool() ); SfxAllItemSet aSet( pApp->GetPool() );
aSet.Put( SfxStringItem( SID_FILE_NAME, pMedium->GetName() ) ); aSet.Put( SfxStringItem( SID_FILE_NAME, pMedium->GetName() ) );
aSet.Put( SfxStringItem( SID_TARGETNAME, OUString("_blank") ) ); aSet.Put( SfxStringItem( SID_TARGETNAME, "_blank" ) );
if ( pSavedOptions ) if ( pSavedOptions )
aSet.Put( *pSavedOptions ); aSet.Put( *pSavedOptions );
if ( pSavedReferer ) if ( pSavedReferer )
@@ -924,30 +924,18 @@ void SfxViewFrame::StateHistory_Impl( SfxItemSet &rSet )
rSet.DisableItem( SID_CLEARHISTORY ); rSet.DisableItem( SID_CLEARHISTORY );
if ( pShUndoMgr && pShUndoMgr->GetUndoActionCount() ) if ( pShUndoMgr && pShUndoMgr->GetUndoActionCount() )
{ rSet.Put( SfxStringItem( SID_UNDO, SvtResId(STR_UNDO).toString()+pShUndoMgr->GetUndoActionComment() ) );
OUString aTmp(SvtResId(STR_UNDO).toString());
aTmp+= pShUndoMgr->GetUndoActionComment();
rSet.Put( SfxStringItem( SID_UNDO, aTmp ) );
}
else else
rSet.DisableItem( SID_UNDO ); rSet.DisableItem( SID_UNDO );
if ( pShUndoMgr && pShUndoMgr->GetRedoActionCount() ) if ( pShUndoMgr && pShUndoMgr->GetRedoActionCount() )
{ rSet.Put( SfxStringItem( SID_REDO, SvtResId(STR_REDO).toString()+pShUndoMgr->GetRedoActionComment() ) );
OUString aTmp(SvtResId(STR_REDO).toString());
aTmp += pShUndoMgr->GetRedoActionComment();
rSet.Put( SfxStringItem( SID_REDO, aTmp ) );
}
else else
rSet.DisableItem( SID_REDO ); rSet.DisableItem( SID_REDO );
SfxRepeatTarget *pTarget = pSh->GetRepeatTarget(); SfxRepeatTarget *pTarget = pSh->GetRepeatTarget();
if ( pShUndoMgr && pTarget && pShUndoMgr->GetRepeatActionCount() && if ( pShUndoMgr && pTarget && pShUndoMgr->GetRepeatActionCount() && pShUndoMgr->CanRepeat(*pTarget) )
pShUndoMgr->CanRepeat(*pTarget) ) rSet.Put( SfxStringItem( SID_REPEAT, SvtResId(STR_REPEAT).toString()+pShUndoMgr->GetRepeatActionComment(*pTarget) ) );
{
OUString aTmp(SvtResId(STR_REPEAT).toString());
aTmp += pShUndoMgr->GetRepeatActionComment(*pTarget);
rSet.Put( SfxStringItem( SID_REPEAT, aTmp ) );
}
else else
rSet.DisableItem( SID_REPEAT ); rSet.DisableItem( SID_REPEAT );
} }
@@ -1171,7 +1159,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
SignatureState nSignatureState = GetObjectShell()->GetDocumentSignatureState(); SignatureState nSignatureState = GetObjectShell()->GetDocumentSignatureState();
InfoBarType aInfoBarType(InfoBarType::Info); InfoBarType aInfoBarType(InfoBarType::Info);
OUString sMessage(""); OUString sMessage;
switch (nSignatureState) switch (nSignatureState)
{ {
@@ -2370,9 +2358,7 @@ void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, bool bEra
else else
nEndPos++; nEndPos++;
OUString aEndStr = rStr.copy( nEndPos ); rStr = rStr.copy( 0, nStartPos ) + rStr.copy( nEndPos );
rStr = rStr.copy( 0, nStartPos );
rStr += aEndStr;
} }
if ( bEraseTrailingEmptyLines && nStartPos != -1 ) if ( bEraseTrailingEmptyLines && nStartPos != -1 )
{ {
@@ -2382,11 +2368,7 @@ void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, bool bEra
n++; n++;
if ( n > nStartPos ) if ( n > nStartPos )
{ rStr = rStr.copy( 0, nStartPos ) + rStr.copy( n );
OUString aEndStr = rStr.copy( n );
rStr = rStr.copy( 0, nStartPos );
rStr += aEndStr;
}
} }
} }
@@ -2493,29 +2475,26 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro )
xLibCont, xLibCont,
css::uno::UNO_QUERY); css::uno::UNO_QUERY);
OUString sLib( aLibName );
css::uno::Reference< css::container::XNameAccess > xLib; css::uno::Reference< css::container::XNameAccess > xLib;
if(xRoot->hasByName(sLib)) if(xRoot->hasByName(aLibName))
{ {
// library must be loaded // library must be loaded
aTemp = xRoot->getByName(sLib); aTemp = xRoot->getByName(aLibName);
xLibCont->loadLibrary(sLib); xLibCont->loadLibrary(aLibName);
aTemp >>= xLib; aTemp >>= xLib;
} }
else else
{ {
xLib.set( xLibCont->createLibrary(sLib), css::uno::UNO_QUERY); xLib.set( xLibCont->createLibrary(aLibName), css::uno::UNO_QUERY);
} }
// pack the macro as direct usable "sub" routine // pack the macro as direct usable "sub" routine
OUString sCode; OUString sCode;
OUStringBuffer sRoutine(10000); OUStringBuffer sRoutine(10000);
OUString sMacroName( aMacroName );
bool bReplace = false; bool bReplace = false;
// get module // get module
OUString sModule( aModuleName ); if(xLib->hasByName(aModuleName))
if(xLib->hasByName(sModule))
{ {
if ( !aOUSource.isEmpty() ) if ( !aOUSource.isEmpty() )
{ {
@@ -2523,7 +2502,7 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro )
} }
else else
{ {
aTemp = xLib->getByName(sModule); aTemp = xLib->getByName(aModuleName);
aTemp >>= sCode; aTemp >>= sCode;
sRoutine.append( sCode ); sRoutine.append( sCode );
} }
@@ -2533,7 +2512,7 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro )
// append new method // append new method
sRoutine.append( "\nsub " ); sRoutine.append( "\nsub " );
sRoutine.append(sMacroName); sRoutine.append(aMacroName);
sRoutine.append( "\n" ); sRoutine.append( "\n" );
sRoutine.append(sMacro); sRoutine.append(sMacro);
sRoutine.append( "\nend sub\n" ); sRoutine.append( "\nend sub\n" );
@@ -2545,14 +2524,14 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro )
css::uno::Reference< css::container::XNameContainer > xModulCont( css::uno::Reference< css::container::XNameContainer > xModulCont(
xLib, xLib,
css::uno::UNO_QUERY); css::uno::UNO_QUERY);
xModulCont->replaceByName(sModule,aTemp); xModulCont->replaceByName(aModuleName,aTemp);
} }
else else
{ {
css::uno::Reference< css::container::XNameContainer > xModulCont( css::uno::Reference< css::container::XNameContainer > xModulCont(
xLib, xLib,
css::uno::UNO_QUERY); css::uno::UNO_QUERY);
xModulCont->insertByName(sModule,aTemp); xModulCont->insertByName(aModuleName,aTemp);
} }
// #i17355# update the Basic IDE // #i17355# update the Basic IDE
@@ -2586,7 +2565,7 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq )
case SID_RECORDMACRO : case SID_RECORDMACRO :
{ {
// try to find any active recorder on this frame // try to find any active recorder on this frame
OUString sProperty("DispatchRecorderSupplier"); const OUString sProperty("DispatchRecorderSupplier");
css::uno::Reference< css::frame::XFrame > xFrame( css::uno::Reference< css::frame::XFrame > xFrame(
GetFrame().GetFrameInterface(), GetFrame().GetFrameInterface(),
css::uno::UNO_QUERY); css::uno::UNO_QUERY);
@@ -2667,7 +2646,7 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq )
if ( xLayoutManager.is() ) if ( xLayoutManager.is() )
{ {
OUString aStatusbarResString( "private:resource/statusbar/statusbar" ); const OUString aStatusbarResString( "private:resource/statusbar/statusbar" );
// Evaluate parameter. // Evaluate parameter.
const SfxBoolItem* pShowItem = rReq.GetArg<SfxBoolItem>(rReq.GetSlot()); const SfxBoolItem* pShowItem = rReq.GetArg<SfxBoolItem>(rReq.GetSlot());
bool bShow( true ); bool bShow( true );
@@ -2783,12 +2762,11 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet)
break; break;
} }
OUString sProperty("DispatchRecorderSupplier");
css::uno::Reference< css::beans::XPropertySet > xSet( css::uno::Reference< css::beans::XPropertySet > xSet(
GetFrame().GetFrameInterface(), GetFrame().GetFrameInterface(),
css::uno::UNO_QUERY); css::uno::UNO_QUERY);
css::uno::Any aProp = xSet->getPropertyValue(sProperty); css::uno::Any aProp = xSet->getPropertyValue("DispatchRecorderSupplier");
css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier; css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier;
if ( aProp >>= xSupplier ) if ( aProp >>= xSupplier )
rSet.Put( SfxBoolItem( nWhich, xSupplier.is() ) ); rSet.Put( SfxBoolItem( nWhich, xSupplier.is() ) );
@@ -2808,12 +2786,11 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet)
break; break;
} }
OUString sProperty("DispatchRecorderSupplier");
css::uno::Reference< css::beans::XPropertySet > xSet( css::uno::Reference< css::beans::XPropertySet > xSet(
GetFrame().GetFrameInterface(), GetFrame().GetFrameInterface(),
css::uno::UNO_QUERY); css::uno::UNO_QUERY);
css::uno::Any aProp = xSet->getPropertyValue(sProperty); css::uno::Any aProp = xSet->getPropertyValue("DispatchRecorderSupplier");
css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier; css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier;
if ( !(aProp >>= xSupplier) || !xSupplier.is() ) if ( !(aProp >>= xSupplier) || !xSupplier.is() )
rSet.DisableItem( nWhich ); rSet.DisableItem( nWhich );
@@ -2832,8 +2809,7 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet)
rSet.Put( SfxBoolItem( nWhich, false )); rSet.Put( SfxBoolItem( nWhich, false ));
else else
{ {
OUString aStatusbarResString( "private:resource/statusbar/statusbar" ); bool bShow = xLayoutManager->isElementVisible( "private:resource/statusbar/statusbar" );
bool bShow = xLayoutManager->isElementVisible( aStatusbarResString );
rSet.Put( SfxBoolItem( nWhich, bShow )); rSet.Put( SfxBoolItem( nWhich, bShow ));
} }
break; break;

View File

@@ -140,8 +140,7 @@ void SfxViewFrame::UpdateTitle()
OUString aSbxName = pObjSh->SfxShell::GetName(); OUString aSbxName = pObjSh->SfxShell::GetName();
if ( IsVisible() ) if ( IsVisible() )
{ {
aSbxName += ":"; aSbxName += ":" + OUString::number(m_pImpl->nDocViewNo);
aSbxName += OUString::number(m_pImpl->nDocViewNo);
} }
SetName( aSbxName ); SetName( aSbxName );
@@ -213,11 +212,10 @@ void SfxViewFrame::Exec_Impl(SfxRequest &rReq )
} }
SfxRequest aReq( SID_OPENDOC, SfxCallMode::SYNCHRON, GetPool() ); SfxRequest aReq( SID_OPENDOC, SfxCallMode::SYNCHRON, GetPool() );
OUString aFact("private:factory/"); const OUString aFact("private:factory/" + aFactName);
aFact += aFactName;
aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aFact ) ); aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aFact ) );
aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, &GetFrame() ) ); aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, &GetFrame() ) );
aReq.AppendItem( SfxStringItem( SID_TARGETNAME, OUString( "_blank" ) ) ); aReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_blank" ) );
SfxGetpApp()->ExecuteSlot( aReq ); SfxGetpApp()->ExecuteSlot( aReq );
const SfxViewFrameItem* pItem = dynamic_cast<const SfxViewFrameItem*>( aReq.GetReturnValue() ); const SfxViewFrameItem* pItem = dynamic_cast<const SfxViewFrameItem*>( aReq.GetReturnValue() );
if ( pItem ) if ( pItem )
@@ -293,9 +291,7 @@ void SfxViewFrame::GetState_Impl( SfxItemSet &rSet )
{ {
if ( !m_pImpl->aFactoryName.isEmpty() ) if ( !m_pImpl->aFactoryName.isEmpty() )
{ {
OUString aFact("private:factory/"); rSet.Put( SfxStringItem( nWhich, "private:factory/"+m_pImpl->aFactoryName ) );
aFact += m_pImpl->aFactoryName;
rSet.Put( SfxStringItem( nWhich, aFact ) );
} }
break; break;
} }