include/sfx2/docfac.hxx | 2 sfx2/source/view/viewfrm.cxx | 88 ++++++++++++------------------------------ sfx2/source/view/viewfrm2.cxx | 12 +---- 3 files changed, 32 insertions(+), 70 deletions(-)
New commits: commit 7a2f07c4bd5d26657593044dd441ba5fd168e5de Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sun Mar 19 17:05:49 2017 +0100 Use just geParameter instead of hasParameter + getParameter getParameter returns and empty string if the key is not found, so we can just avoid searching twice for the same key. Change-Id: Ic48debce05fe94d8e087b64bde5a589e54bfb616 diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index bd29aaf003f3..a16fda352944 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -2416,9 +2416,7 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro ) aMacroName = aName.getToken( 0, cTok, nIndex ); // get location - OUString aLocKey("location"); - if ( xUrl->hasParameter( aLocKey ) ) - aLocation = xUrl->getParameter( aLocKey ); + aLocation = xUrl->getParameter( "location" ); } BasicManager* pBasMgr = nullptr; commit e256519a629e88c624c52916f1c38f774cfd445c Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sun Mar 19 12:06:20 2017 +0100 OUString-related simplifications Change-Id: I2f4099410bcdb9e04583cd37bf63ef86ce81f7e5 diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 384af9dfe478..bd29aaf003f3 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -239,7 +239,7 @@ static bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHa else { // 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 @@ -718,7 +718,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) { SfxAllItemSet aSet( pApp->GetPool() ); aSet.Put( SfxStringItem( SID_FILE_NAME, pMedium->GetName() ) ); - aSet.Put( SfxStringItem( SID_TARGETNAME, OUString("_blank") ) ); + aSet.Put( SfxStringItem( SID_TARGETNAME, "_blank" ) ); if ( pSavedOptions ) aSet.Put( *pSavedOptions ); if ( pSavedReferer ) @@ -924,30 +924,18 @@ void SfxViewFrame::StateHistory_Impl( SfxItemSet &rSet ) rSet.DisableItem( SID_CLEARHISTORY ); if ( pShUndoMgr && pShUndoMgr->GetUndoActionCount() ) - { - OUString aTmp(SvtResId(STR_UNDO).toString()); - aTmp+= pShUndoMgr->GetUndoActionComment(); - rSet.Put( SfxStringItem( SID_UNDO, aTmp ) ); - } + rSet.Put( SfxStringItem( SID_UNDO, SvtResId(STR_UNDO).toString()+pShUndoMgr->GetUndoActionComment() ) ); else rSet.DisableItem( SID_UNDO ); if ( pShUndoMgr && pShUndoMgr->GetRedoActionCount() ) - { - OUString aTmp(SvtResId(STR_REDO).toString()); - aTmp += pShUndoMgr->GetRedoActionComment(); - rSet.Put( SfxStringItem( SID_REDO, aTmp ) ); - } + rSet.Put( SfxStringItem( SID_REDO, SvtResId(STR_REDO).toString()+pShUndoMgr->GetRedoActionComment() ) ); else rSet.DisableItem( SID_REDO ); + SfxRepeatTarget *pTarget = pSh->GetRepeatTarget(); - if ( pShUndoMgr && pTarget && pShUndoMgr->GetRepeatActionCount() && - pShUndoMgr->CanRepeat(*pTarget) ) - { - OUString aTmp(SvtResId(STR_REPEAT).toString()); - aTmp += pShUndoMgr->GetRepeatActionComment(*pTarget); - rSet.Put( SfxStringItem( SID_REPEAT, aTmp ) ); - } + if ( pShUndoMgr && pTarget && pShUndoMgr->GetRepeatActionCount() && pShUndoMgr->CanRepeat(*pTarget) ) + rSet.Put( SfxStringItem( SID_REPEAT, SvtResId(STR_REPEAT).toString()+pShUndoMgr->GetRepeatActionComment(*pTarget) ) ); else rSet.DisableItem( SID_REPEAT ); } @@ -1171,7 +1159,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) SignatureState nSignatureState = GetObjectShell()->GetDocumentSignatureState(); InfoBarType aInfoBarType(InfoBarType::Info); - OUString sMessage(""); + OUString sMessage; switch (nSignatureState) { @@ -2370,9 +2358,7 @@ void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, bool bEra else nEndPos++; - OUString aEndStr = rStr.copy( nEndPos ); - rStr = rStr.copy( 0, nStartPos ); - rStr += aEndStr; + rStr = rStr.copy( 0, nStartPos ) + rStr.copy( nEndPos ); } if ( bEraseTrailingEmptyLines && nStartPos != -1 ) { @@ -2382,11 +2368,7 @@ void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, bool bEra n++; if ( n > nStartPos ) - { - OUString aEndStr = rStr.copy( n ); - rStr = rStr.copy( 0, nStartPos ); - rStr += aEndStr; - } + rStr = rStr.copy( 0, nStartPos ) + rStr.copy( n ); } } @@ -2493,29 +2475,26 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro ) xLibCont, css::uno::UNO_QUERY); - OUString sLib( aLibName ); css::uno::Reference< css::container::XNameAccess > xLib; - if(xRoot->hasByName(sLib)) + if(xRoot->hasByName(aLibName)) { // library must be loaded - aTemp = xRoot->getByName(sLib); - xLibCont->loadLibrary(sLib); + aTemp = xRoot->getByName(aLibName); + xLibCont->loadLibrary(aLibName); aTemp >>= xLib; } 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 OUString sCode; OUStringBuffer sRoutine(10000); - OUString sMacroName( aMacroName ); bool bReplace = false; // get module - OUString sModule( aModuleName ); - if(xLib->hasByName(sModule)) + if(xLib->hasByName(aModuleName)) { if ( !aOUSource.isEmpty() ) { @@ -2523,7 +2502,7 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro ) } else { - aTemp = xLib->getByName(sModule); + aTemp = xLib->getByName(aModuleName); aTemp >>= sCode; sRoutine.append( sCode ); } @@ -2533,7 +2512,7 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro ) // append new method sRoutine.append( "\nsub " ); - sRoutine.append(sMacroName); + sRoutine.append(aMacroName); sRoutine.append( "\n" ); sRoutine.append(sMacro); sRoutine.append( "\nend sub\n" ); @@ -2545,14 +2524,14 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro ) css::uno::Reference< css::container::XNameContainer > xModulCont( xLib, css::uno::UNO_QUERY); - xModulCont->replaceByName(sModule,aTemp); + xModulCont->replaceByName(aModuleName,aTemp); } else { css::uno::Reference< css::container::XNameContainer > xModulCont( xLib, css::uno::UNO_QUERY); - xModulCont->insertByName(sModule,aTemp); + xModulCont->insertByName(aModuleName,aTemp); } // #i17355# update the Basic IDE @@ -2586,7 +2565,7 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq ) case SID_RECORDMACRO : { // try to find any active recorder on this frame - OUString sProperty("DispatchRecorderSupplier"); + const OUString sProperty("DispatchRecorderSupplier"); css::uno::Reference< css::frame::XFrame > xFrame( GetFrame().GetFrameInterface(), css::uno::UNO_QUERY); @@ -2667,7 +2646,7 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq ) if ( xLayoutManager.is() ) { - OUString aStatusbarResString( "private:resource/statusbar/statusbar" ); + const OUString aStatusbarResString( "private:resource/statusbar/statusbar" ); // Evaluate parameter. const SfxBoolItem* pShowItem = rReq.GetArg<SfxBoolItem>(rReq.GetSlot()); bool bShow( true ); @@ -2783,12 +2762,11 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet) break; } - OUString sProperty("DispatchRecorderSupplier"); css::uno::Reference< css::beans::XPropertySet > xSet( GetFrame().GetFrameInterface(), 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; if ( aProp >>= xSupplier ) rSet.Put( SfxBoolItem( nWhich, xSupplier.is() ) ); @@ -2808,12 +2786,11 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet) break; } - OUString sProperty("DispatchRecorderSupplier"); css::uno::Reference< css::beans::XPropertySet > xSet( GetFrame().GetFrameInterface(), 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; if ( !(aProp >>= xSupplier) || !xSupplier.is() ) rSet.DisableItem( nWhich ); @@ -2832,8 +2809,7 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet) rSet.Put( SfxBoolItem( nWhich, false )); else { - OUString aStatusbarResString( "private:resource/statusbar/statusbar" ); - bool bShow = xLayoutManager->isElementVisible( aStatusbarResString ); + bool bShow = xLayoutManager->isElementVisible( "private:resource/statusbar/statusbar" ); rSet.Put( SfxBoolItem( nWhich, bShow )); } break; diff --git a/sfx2/source/view/viewfrm2.cxx b/sfx2/source/view/viewfrm2.cxx index 56afe2fcb781..294e64f2ad91 100644 --- a/sfx2/source/view/viewfrm2.cxx +++ b/sfx2/source/view/viewfrm2.cxx @@ -140,8 +140,7 @@ void SfxViewFrame::UpdateTitle() OUString aSbxName = pObjSh->SfxShell::GetName(); if ( IsVisible() ) { - aSbxName += ":"; - aSbxName += OUString::number(m_pImpl->nDocViewNo); + aSbxName += ":" + OUString::number(m_pImpl->nDocViewNo); } SetName( aSbxName ); @@ -213,11 +212,10 @@ void SfxViewFrame::Exec_Impl(SfxRequest &rReq ) } SfxRequest aReq( SID_OPENDOC, SfxCallMode::SYNCHRON, GetPool() ); - OUString aFact("private:factory/"); - aFact += aFactName; + const OUString aFact("private:factory/" + aFactName); aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aFact ) ); aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, &GetFrame() ) ); - aReq.AppendItem( SfxStringItem( SID_TARGETNAME, OUString( "_blank" ) ) ); + aReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_blank" ) ); SfxGetpApp()->ExecuteSlot( aReq ); const SfxViewFrameItem* pItem = dynamic_cast<const SfxViewFrameItem*>( aReq.GetReturnValue() ); if ( pItem ) @@ -293,9 +291,7 @@ void SfxViewFrame::GetState_Impl( SfxItemSet &rSet ) { if ( !m_pImpl->aFactoryName.isEmpty() ) { - OUString aFact("private:factory/"); - aFact += m_pImpl->aFactoryName; - rSet.Put( SfxStringItem( nWhich, aFact ) ); + rSet.Put( SfxStringItem( nWhich, "private:factory/"+m_pImpl->aFactoryName ) ); } break; } commit 4a268ebc3f57f4e896bb53b8ca85747895739f24 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sat Mar 18 14:43:01 2017 +0100 Can return const OUString&, here Thanks to Noel Grandin for his suggestion. Change-Id: Ia0d9c46c03928e5551e766572c814f4e9ba6f278 diff --git a/include/sfx2/docfac.hxx b/include/sfx2/docfac.hxx index f1b73f424281..6cd70b86f586 100644 --- a/include/sfx2/docfac.hxx +++ b/include/sfx2/docfac.hxx @@ -54,7 +54,7 @@ public: const SvGlobalName& GetClassId() const; SfxObjectShellFlags GetFlags() { return nFlags; } OUString GetFactoryURL() const; // shortcut for "private:factory/GetShortName()" - OUString GetFactoryName() const { return m_sFactoryName; } + const OUString& GetFactoryName() const { return m_sFactoryName; } OUString GetModuleName() const; SfxFilterContainer *GetFilterContainer() const; diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 1ddcaf90e5dc..384af9dfe478 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -2774,7 +2774,7 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet) case SID_RECORDMACRO : { SvtMiscOptions aMiscOptions; - const OUString sName{GetObjectShell()->GetFactory().GetFactoryName()}; + const OUString& sName{GetObjectShell()->GetFactory().GetFactoryName()}; if ( !aMiscOptions.IsMacroRecorderMode() || ( sName!="swriter" && sName!="scalc" ) ) { @@ -2800,7 +2800,7 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet) case SID_STOP_RECORDING : { SvtMiscOptions aMiscOptions; - const OUString sName{GetObjectShell()->GetFactory().GetFactoryName()}; + const OUString& sName{GetObjectShell()->GetFactory().GetFactoryName()}; if ( !aMiscOptions.IsMacroRecorderMode() || ( sName!="swriter" && sName!="scalc" ) ) { commit 3563fef9566cdf2828605bcfcb75bd2c9db46c13 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Fri Mar 17 20:25:57 2017 +0100 SfxViewFrame::ExecReload_Impl - remove written-only variable aURL Its only user was commented-out by commit 6c1be80980cbf02ecaf07996b1c2be5777f59124 (2004) and then removed by commit 40fe03745fc75609350cf8115134eb07f04eefa7 (2010) Change-Id: I821a97275b79230e9e389a9b57c82110fa16aa8e diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index e413b86a5cdf..1ddcaf90e5dc 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -553,13 +553,6 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) { SfxMedium *pMedium = xOldObj->GetMedium(); - // Remove Frameset before the FramesetView may disappear - OUString aURL; - if (pURLItem) - aURL = pURLItem->GetValue(); - else - aURL = pMedium->GetName(); - bool bHandsOff = ( pMedium->GetURLObject().GetProtocol() == INetProtocol::File && !xOldObj->IsDocShared() ); @@ -628,7 +621,6 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(pNewSet, SID_DOC_SALVAGE, false); if( pSalvageItem ) { - aURL = pSalvageItem->GetValue(); pNewSet->ClearItem( SID_DOC_SALVAGE ); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits