diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-06 10:09:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-07 08:19:14 +0100 |
commit | 536a6d6ca67d01c8470c242c6f1fd0750496eed4 (patch) | |
tree | cc2aed75621456aaeb31d26e910cc61baf3bfdd7 /sfx2 | |
parent | 53a318196859140deb4b3c317db583a90cfd604c (diff) |
loplugin:flatten in sfx2
Change-Id: If4e07d497ead58a2ff58b5fdedd282b8784be421
Reviewed-on: https://gerrit.libreoffice.org/67435
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
75 files changed, 5425 insertions, 5426 deletions
diff --git a/sfx2/source/appl/appbaslib.cxx b/sfx2/source/appl/appbaslib.cxx index af666bb7fc66..1e8654eeb530 100644 --- a/sfx2/source/appl/appbaslib.cxx +++ b/sfx2/source/appl/appbaslib.cxx @@ -66,18 +66,18 @@ void SfxBasicManagerHolder::reset( BasicManager* _pBasicManager ) // @see basic::BasicManagerRepository::getDocumentBasicManager mpBasicManager = _pBasicManager; - if ( mpBasicManager ) + if ( !mpBasicManager ) + return; + + StartListening(*mpBasicManager); + try { - StartListening(*mpBasicManager); - try - { - mxBasicContainer.set( mpBasicManager->GetScriptLibraryContainer(), UNO_QUERY_THROW ); - mxDialogContainer.set( mpBasicManager->GetDialogLibraryContainer(), UNO_QUERY_THROW ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("sfx.appl"); - } + mxBasicContainer.set( mpBasicManager->GetScriptLibraryContainer(), UNO_QUERY_THROW ); + mxDialogContainer.set( mpBasicManager->GetDialogLibraryContainer(), UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("sfx.appl"); } #endif } diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx index ff4a1a1023bc..50d9371907d7 100644 --- a/sfx2/source/appl/childwin.cxx +++ b/sfx2/source/appl/childwin.cxx @@ -80,24 +80,24 @@ class DisposeListener : public ::cppu::WeakImplHelper< css::lang::XEventListener if( xComp.is() ) xComp->removeEventListener( this ); - if( m_pOwner && m_pData ) - { - m_pData->xListener.clear(); + if( !m_pOwner || !m_pData ) + return; - if ( m_pData->pWorkWin ) - { - // m_pOwner and m_pData will be killed - m_pData->xFrame.clear(); - m_pData->pWorkWin->GetBindings().Execute( m_pOwner->GetType() ); - } - else - { - delete m_pOwner; - } + m_pData->xListener.clear(); - m_pOwner = nullptr; - m_pData = nullptr; + if ( m_pData->pWorkWin ) + { + // m_pOwner and m_pData will be killed + m_pData->xFrame.clear(); + m_pData->pWorkWin->GetBindings().Execute( m_pOwner->GetType() ); } + else + { + delete m_pOwner; + } + + m_pOwner = nullptr; + m_pData = nullptr; } private: @@ -392,43 +392,43 @@ void SfxChildWindow::InitializeChildWinFactory_Impl(sal_uInt16 nId, SfxChildWinI OUString aWinData( aTmp ); rInfo.aWinState = OUStringToOString(xWinOpt->GetWindowState(), RTL_TEXTENCODING_UTF8); - if ( !aWinData.isEmpty() ) + if ( aWinData.isEmpty() ) + return; + + // Search for version ID + if ( aWinData[0] != 0x0056 ) // 'V' = 56h + // A version ID, so do not use + return; + + // Delete 'V' + aWinData = aWinData.copy(1); + + // Read version + char cToken = ','; + sal_Int32 nPos = aWinData.indexOf( cToken ); + sal_uInt16 nActVersion = static_cast<sal_uInt16>(aWinData.copy( 0, nPos + 1 ).toInt32()); + if ( nActVersion != nVersion ) + return; + + aWinData = aWinData.copy(nPos+1); + + // Load Visibility: is coded as a char + rInfo.bVisible = (aWinData[0] == 0x0056); // 'V' = 56h + aWinData = aWinData.copy(1); + nPos = aWinData.indexOf( cToken ); + if (nPos == -1) + return; + + sal_Int32 nNextPos = aWinData.indexOf( cToken, 2 ); + if ( nNextPos != -1 ) { - // Search for version ID - if ( aWinData[0] != 0x0056 ) // 'V' = 56h - // A version ID, so do not use - return; - - // Delete 'V' - aWinData = aWinData.copy(1); - - // Read version - char cToken = ','; - sal_Int32 nPos = aWinData.indexOf( cToken ); - sal_uInt16 nActVersion = static_cast<sal_uInt16>(aWinData.copy( 0, nPos + 1 ).toInt32()); - if ( nActVersion != nVersion ) - return; - - aWinData = aWinData.copy(nPos+1); - - // Load Visibility: is coded as a char - rInfo.bVisible = (aWinData[0] == 0x0056); // 'V' = 56h - aWinData = aWinData.copy(1); - nPos = aWinData.indexOf( cToken ); - if (nPos != -1) - { - sal_Int32 nNextPos = aWinData.indexOf( cToken, 2 ); - if ( nNextPos != -1 ) - { - // there is extra information - rInfo.nFlags = static_cast<SfxChildWindowFlags>(static_cast<sal_uInt16>(aWinData.copy( nPos+1, nNextPos - nPos - 1 ).toInt32())); - aWinData = aWinData.replaceAt( nPos, nNextPos-nPos+1, "" ); - rInfo.aExtraString = aWinData; - } - else - rInfo.nFlags = static_cast<SfxChildWindowFlags>(static_cast<sal_uInt16>(aWinData.copy( nPos+1 ).toInt32())); - } + // there is extra information + rInfo.nFlags = static_cast<SfxChildWindowFlags>(static_cast<sal_uInt16>(aWinData.copy( nPos+1, nNextPos - nPos - 1 ).toInt32())); + aWinData = aWinData.replaceAt( nPos, nNextPos-nPos+1, "" ); + rInfo.aExtraString = aWinData; } + else + rInfo.nFlags = static_cast<SfxChildWindowFlags>(static_cast<sal_uInt16>(aWinData.copy( nPos+1 ).toInt32())); } void SfxChildWindow::CreateContext( sal_uInt16 nContextId, SfxBindings& rBindings ) @@ -700,24 +700,24 @@ const css::uno::Reference< css::frame::XFrame >& SfxChildWindow::GetFrame() void SfxChildWindow::SetFrame( const css::uno::Reference< css::frame::XFrame > & rFrame ) { // Do nothing if nothing will be changed ... - if( pImpl->xFrame != rFrame ) - { - // ... but stop listening on old frame, if connection exist! - if( pImpl->xFrame.is() ) - pImpl->xFrame->removeEventListener( pImpl->xListener ); - - // If new frame is not NULL -> we must guarantee valid listener for disposing events. - // Use already existing or create new one. - if( rFrame.is() ) - if( !pImpl->xListener.is() ) - pImpl->xListener.set( new DisposeListener( this, pImpl.get() ) ); - - // Set new frame in data container - // and build new listener connection, if necessary. - pImpl->xFrame = rFrame; - if( pImpl->xFrame.is() ) - pImpl->xFrame->addEventListener( pImpl->xListener ); - } + if( pImpl->xFrame == rFrame ) + return; + + // ... but stop listening on old frame, if connection exist! + if( pImpl->xFrame.is() ) + pImpl->xFrame->removeEventListener( pImpl->xListener ); + + // If new frame is not NULL -> we must guarantee valid listener for disposing events. + // Use already existing or create new one. + if( rFrame.is() ) + if( !pImpl->xListener.is() ) + pImpl->xListener.set( new DisposeListener( this, pImpl.get() ) ); + + // Set new frame in data container + // and build new listener connection, if necessary. + pImpl->xFrame = rFrame; + if( pImpl->xFrame.is() ) + pImpl->xFrame->addEventListener( pImpl->xListener ); } void SfxChildWindowContext::RegisterChildWindowContext(SfxModule* pMod, sal_uInt16 nId, std::unique_ptr<SfxChildWinContextFactory> pFact) diff --git a/sfx2/source/appl/fileobj.cxx b/sfx2/source/appl/fileobj.cxx index 7d0cffb21b78..1ff6c891cd7c 100644 --- a/sfx2/source/appl/fileobj.cxx +++ b/sfx2/source/appl/fileobj.cxx @@ -257,65 +257,65 @@ void SvFileObject::Edit(weld::Window* pParent, sfx2::SvBaseLink* pLink, const Li { aEndEditLink = rEndEditHdl; OUString sFile, sRange, sTmpFilter; - if( pLink && pLink->GetLinkManager() ) - { - sfx2::LinkManager::GetDisplayNames( pLink, nullptr, &sFile, &sRange, &sTmpFilter ); - - switch( pLink->GetObjType() ) - { - case OBJECT_CLIENT_GRF: - { - nType = FILETYPE_GRF; // If not set already + if( !pLink || !pLink->GetLinkManager() ) + return; - SvxOpenGraphicDialog aDlg(SfxResId(RID_SVXSTR_EDITGRFLINK), pParent); - aDlg.EnableLink(false); - aDlg.SetPath( sFile, true ); - aDlg.SetCurrentFilter( sTmpFilter ); + sfx2::LinkManager::GetDisplayNames( pLink, nullptr, &sFile, &sRange, &sTmpFilter ); - if( !aDlg.Execute() ) - { - sFile = aDlg.GetPath() - + OUStringLiteral1(sfx2::cTokenSeparator) - + OUStringLiteral1(sfx2::cTokenSeparator) - + aDlg.GetDetectedFilter(); + switch( pLink->GetObjType() ) + { + case OBJECT_CLIENT_GRF: + { + nType = FILETYPE_GRF; // If not set already - aEndEditLink.Call( sFile ); - } - else - sFile.clear(); - } - break; + SvxOpenGraphicDialog aDlg(SfxResId(RID_SVXSTR_EDITGRFLINK), pParent); + aDlg.EnableLink(false); + aDlg.SetPath( sFile, true ); + aDlg.SetCurrentFilter( sTmpFilter ); - case OBJECT_CLIENT_OLE: + if( !aDlg.Execute() ) { - nType = FILETYPE_OBJECT; // if not set already + sFile = aDlg.GetPath() + + OUStringLiteral1(sfx2::cTokenSeparator) + + OUStringLiteral1(sfx2::cTokenSeparator) + + aDlg.GetDetectedFilter(); - ::sfx2::FileDialogHelper & rFileDlg = - pLink->GetInsertFileDialog( OUString() ); - rFileDlg.StartExecuteModal( - LINK( this, SvFileObject, DialogClosedHdl ) ); + aEndEditLink.Call( sFile ); } - break; + else + sFile.clear(); + } + break; - case OBJECT_CLIENT_FILE: - { - nType = FILETYPE_TEXT; // if not set already + case OBJECT_CLIENT_OLE: + { + nType = FILETYPE_OBJECT; // if not set already + + ::sfx2::FileDialogHelper & rFileDlg = + pLink->GetInsertFileDialog( OUString() ); + rFileDlg.StartExecuteModal( + LINK( this, SvFileObject, DialogClosedHdl ) ); + } + break; - OUString sFactory; - SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist(); - if ( pShell ) - sFactory = pShell->GetFactory().GetFactoryName(); + case OBJECT_CLIENT_FILE: + { + nType = FILETYPE_TEXT; // if not set already - ::sfx2::FileDialogHelper & rFileDlg = - pLink->GetInsertFileDialog(sFactory); - rFileDlg.StartExecuteModal( - LINK( this, SvFileObject, DialogClosedHdl ) ); - } - break; + OUString sFactory; + SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist(); + if ( pShell ) + sFactory = pShell->GetFactory().GetFactoryName(); - default: - sFile.clear(); + ::sfx2::FileDialogHelper & rFileDlg = + pLink->GetInsertFileDialog(sFactory); + rFileDlg.StartExecuteModal( + LINK( this, SvFileObject, DialogClosedHdl ) ); } + break; + + default: + sFile.clear(); } } diff --git a/sfx2/source/appl/fwkhelper.cxx b/sfx2/source/appl/fwkhelper.cxx index 64e527c4f4bc..df66d6e3a72f 100644 --- a/sfx2/source/appl/fwkhelper.cxx +++ b/sfx2/source/appl/fwkhelper.cxx @@ -32,21 +32,21 @@ void RefreshToolbars( css::uno::Reference< css::frame::XFrame > const & xFrame ) { SolarMutexGuard aGuard; - if ( xFrame.is() ) + if ( !xFrame.is() ) + return; + + SfxFrame* pFrame=nullptr; + for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = SfxFrame::GetNext( *pFrame ) ) + { + if ( pFrame->GetFrameInterface() == xFrame ) + break; + } + + if ( pFrame ) { - SfxFrame* pFrame=nullptr; - for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = SfxFrame::GetNext( *pFrame ) ) - { - if ( pFrame->GetFrameInterface() == xFrame ) - break; - } - - if ( pFrame ) - { - SfxWorkWindow* pWrkWin = pFrame->GetWorkWindow_Impl(); - if ( pWrkWin ) - pWrkWin->UpdateObjectBars_Impl(); - } + SfxWorkWindow* pWrkWin = pFrame->GetWorkWindow_Impl(); + if ( pWrkWin ) + pWrkWin->UpdateObjectBars_Impl(); } } diff --git a/sfx2/source/appl/helpinterceptor.cxx b/sfx2/source/appl/helpinterceptor.cxx index 3d6ec464c96e..7b8c1f98ddb2 100644 --- a/sfx2/source/appl/helpinterceptor.cxx +++ b/sfx2/source/appl/helpinterceptor.cxx @@ -196,36 +196,36 @@ void SAL_CALL HelpInterceptor_Impl::dispatch( const URL& aURL, const Sequence< css::beans::PropertyValue >& ) { bool bBack = aURL.Complete == ".uno:Backward"; - if ( bBack || aURL.Complete == ".uno:Forward" ) + if ( !bBack && aURL.Complete != ".uno:Forward" ) + return; + + if ( !m_pHistory ) + return; + + if(m_pHistory->size() > m_nCurPos) { - if ( m_pHistory ) + Reference<XFrame> xFrame(m_xIntercepted, UNO_QUERY); + Reference<XController> xController; + if(xFrame.is()) + xController = xFrame->getController(); + if(xController.is()) { - if(m_pHistory->size() > m_nCurPos) - { - Reference<XFrame> xFrame(m_xIntercepted, UNO_QUERY); - Reference<XController> xController; - if(xFrame.is()) - xController = xFrame->getController(); - if(xController.is()) - { - m_pHistory->at( m_nCurPos )->aViewData = xController->getViewData(); - } - } - - sal_uIntPtr nPos = ( bBack && m_nCurPos > 0 ) ? --m_nCurPos - : ( !bBack && m_nCurPos < m_pHistory->size() - 1 ) - ? ++m_nCurPos - : ULONG_MAX; - - if ( nPos < ULONG_MAX ) - { - HelpHistoryEntry_Impl* pEntry = m_pHistory->at( nPos ).get(); - m_pWindow->loadHelpContent(pEntry->aURL, false); // false => don't add item to history again! - } - - m_pWindow->UpdateToolbox(); + m_pHistory->at( m_nCurPos )->aViewData = xController->getViewData(); } } + + sal_uIntPtr nPos = ( bBack && m_nCurPos > 0 ) ? --m_nCurPos + : ( !bBack && m_nCurPos < m_pHistory->size() - 1 ) + ? ++m_nCurPos + : ULONG_MAX; + + if ( nPos < ULONG_MAX ) + { + HelpHistoryEntry_Impl* pEntry = m_pHistory->at( nPos ).get(); + m_pWindow->loadHelpContent(pEntry->aURL, false); // false => don't add item to history again! + } + + m_pWindow->UpdateToolbox(); } diff --git a/sfx2/source/appl/imestatuswindow.cxx b/sfx2/source/appl/imestatuswindow.cxx index c49107ba87ce..4fad9d3e2732 100644 --- a/sfx2/source/appl/imestatuswindow.cxx +++ b/sfx2/source/appl/imestatuswindow.cxx @@ -86,19 +86,21 @@ ImeStatusWindow::ImeStatusWindow( void ImeStatusWindow::init() { - if (Application::CanToggleImeStatusWindow()) - try - { - bool bShow; - if (getConfig()->getPropertyValue("ShowStatusWindow") >>= bShow) - Application::ShowImeStatusWindow(bShow); - } - catch (css::uno::Exception &) - { - OSL_FAIL("com.sun.star.uno.Exception"); - // Degrade gracefully and use the VCL-supplied default if no - // configuration is available. - } + if (!Application::CanToggleImeStatusWindow()) + return; + + try + { + bool bShow; + if (getConfig()->getPropertyValue("ShowStatusWindow") >>= bShow) + Application::ShowImeStatusWindow(bShow); + } + catch (css::uno::Exception &) + { + OSL_FAIL("com.sun.star.uno.Exception"); + // Degrade gracefully and use the VCL-supplied default if no + // configuration is available. + } } bool ImeStatusWindow::isShowing() diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx index 1e631bc949aa..459ded0e88b3 100644 --- a/sfx2/source/appl/linkmgr2.cxx +++ b/sfx2/source/appl/linkmgr2.cxx @@ -132,22 +132,22 @@ void LinkManager::Remove( SvBaseLink const *pLink ) void LinkManager::Remove( size_t nPos, size_t nCnt ) { - if( nCnt && nPos < aLinkTbl.size() ) - { - if (sal::static_int_cast<size_t>(nPos + nCnt) > aLinkTbl.size()) - nCnt = aLinkTbl.size() - nPos; + if( !nCnt || nPos >= aLinkTbl.size() ) + return; + + if (sal::static_int_cast<size_t>(nPos + nCnt) > aLinkTbl.size()) + nCnt = aLinkTbl.size() - nPos; - for( size_t n = nPos; n < nPos + nCnt; ++n) + for( size_t n = nPos; n < nPos + nCnt; ++n) + { + tools::SvRef<SvBaseLink>& rTmp = aLinkTbl[ n ]; + if( rTmp.is() ) { - tools::SvRef<SvBaseLink>& rTmp = aLinkTbl[ n ]; - if( rTmp.is() ) - { - rTmp->Disconnect(); - rTmp->SetLinkManager( nullptr ); - } + rTmp->Disconnect(); + rTmp->SetLinkManager( nullptr ); } - aLinkTbl.erase( aLinkTbl.begin() + nPos, aLinkTbl.begin() + nPos + nCnt ); } + aLinkTbl.erase( aLinkTbl.begin() + nPos, aLinkTbl.begin() + nPos + nCnt ); } bool LinkManager::Insert( SvBaseLink* pLink ) diff --git a/sfx2/source/appl/lnkbase2.cxx b/sfx2/source/appl/lnkbase2.cxx index b86cf3dbdbb5..15bc01f84059 100644 --- a/sfx2/source/appl/lnkbase2.cxx +++ b/sfx2/source/appl/lnkbase2.cxx @@ -586,25 +586,25 @@ bool ImplDdeItem::Put( const DdeData* ) void ImplDdeItem::AdviseLoop( bool bOpen ) { // Connection is closed, so also unsubscribe link - if( pLink->GetObj() ) + if( !pLink->GetObj() ) + return; + + if( bOpen ) { - if( bOpen ) + // A connection is re-established + if( OBJECT_DDE_EXTERN == pLink->GetObjType() ) { - // A connection is re-established - if( OBJECT_DDE_EXTERN == pLink->GetObjType() ) - { - pLink->GetObj()->AddDataAdvise( pLink, "text/plain;charset=utf-16", ADVISEMODE_NODATA ); - pLink->GetObj()->AddConnectAdvise( pLink ); - } - } - else - { - // So that no-one gets the idea to delete the pointer - // when Disconnecting! - tools::SvRef<SvBaseLink> aRef( pLink ); - aRef->Disconnect(); + pLink->GetObj()->AddDataAdvise( pLink, "text/plain;charset=utf-16", ADVISEMODE_NODATA ); + pLink->GetObj()->AddConnectAdvise( pLink ); } } + else + { + // So that no-one gets the idea to delete the pointer + // when Disconnecting! + tools::SvRef<SvBaseLink> aRef( pLink ); + aRef->Disconnect(); + } } } diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx index 1c32be75cd90..267b6d803608 100644 --- a/sfx2/source/appl/macroloader.cxx +++ b/sfx2/source/appl/macroloader.cxx @@ -129,20 +129,20 @@ void SAL_CALL SfxMacroLoader::dispatchWithNotification( uno::Any aAny; ErrCode nErr = loadMacro( aURL.Complete, aAny, GetObjectShell_Impl() ); - if( xListener.is() ) - { - // always call dispatchFinished(), because we didn't load a document but - // executed a macro instead! - frame::DispatchResultEvent aEvent; + if( !xListener.is() ) + return; - aEvent.Source = static_cast< ::cppu::OWeakObject* >(this); - if( nErr == ERRCODE_NONE ) - aEvent.State = frame::DispatchResultState::SUCCESS; - else - aEvent.State = frame::DispatchResultState::FAILURE; + // always call dispatchFinished(), because we didn't load a document but + // executed a macro instead! + frame::DispatchResultEvent aEvent; - xListener->dispatchFinished( aEvent ) ; - } + aEvent.Source = static_cast< ::cppu::OWeakObject* >(this); + if( nErr == ERRCODE_NONE ) + aEvent.State = frame::DispatchResultState::SUCCESS; + else + aEvent.State = frame::DispatchResultState::FAILURE; + + xListener->dispatchFinished( aEvent ) ; } uno::Any SAL_CALL SfxMacroLoader::dispatchWithReturnValue( diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index 78ae4d441905..45cfaeeb9937 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -516,21 +516,21 @@ bool IndexBox_Impl::EventNotify( NotifyEvent& rNEvt ) void IndexBox_Impl::SelectExecutableEntry() { sal_Int32 nPos = GetEntryPos( GetText() ); - if ( nPos != COMBOBOX_ENTRY_NOTFOUND ) - { - sal_Int32 nOldPos = nPos; - OUString aEntryText; - IndexEntry_Impl* pEntry = static_cast<IndexEntry_Impl*>(GetEntryData( nPos )); - sal_Int32 nCount = GetEntryCount(); - while ( nPos < nCount && ( !pEntry || pEntry->m_aURL.isEmpty() ) ) - { - pEntry = static_cast<IndexEntry_Impl*>(GetEntryData( ++nPos )); - aEntryText = GetEntry( nPos ); - } + if ( nPos == COMBOBOX_ENTRY_NOTFOUND ) + return; - if ( nOldPos != nPos ) - SetText( aEntryText ); + sal_Int32 nOldPos = nPos; + OUString aEntryText; + IndexEntry_Impl* pEntry = static_cast<IndexEntry_Impl*>(GetEntryData( nPos )); + sal_Int32 nCount = GetEntryCount(); + while ( nPos < nCount && ( !pEntry || pEntry->m_aURL.isEmpty() ) ) + { + pEntry = static_cast<IndexEntry_Impl*>(GetEntryData( ++nPos )); + aEntryText = GetEntry( nPos ); } + + if ( nOldPos != nPos ) + SetText( aEntryText ); } // class IndexTabPage_Impl ----------------------------------------------- @@ -1016,38 +1016,38 @@ IMPL_LINK_NOARG(SearchTabPage_Impl, ClickHdl, Button*, void) IMPL_LINK_NOARG(SearchTabPage_Impl, SearchHdl, LinkParamNone*, void) { OUString aSearchText = comphelper::string::strip(m_pSearchED->GetText(), ' '); - if ( !aSearchText.isEmpty() ) + if ( aSearchText.isEmpty() ) + return; + + EnterWait(); + ClearSearchResults(); + RememberSearchText( aSearchText ); + OUStringBuffer aSearchURL(HELP_URL); + aSearchURL.append(aFactory); + aSearchURL.append(HELP_SEARCH_TAG); + if ( !m_pFullWordsCB->IsChecked() ) + aSearchText = sfx2::PrepareSearchString( aSearchText, xBreakIterator, true ); + aSearchURL.append(aSearchText); + AppendConfigToken(aSearchURL, false); + if ( m_pScopeCB->IsChecked() ) + aSearchURL.append("&Scope=Heading"); + std::vector< OUString > aFactories = SfxContentHelper::GetResultSet(aSearchURL.makeStringAndClear()); + for (const OUString & rRow : aFactories) { - EnterWait(); - ClearSearchResults(); - RememberSearchText( aSearchText ); - OUStringBuffer aSearchURL(HELP_URL); - aSearchURL.append(aFactory); - aSearchURL.append(HELP_SEARCH_TAG); - if ( !m_pFullWordsCB->IsChecked() ) - aSearchText = sfx2::PrepareSearchString( aSearchText, xBreakIterator, true ); - aSearchURL.append(aSearchText); - AppendConfigToken(aSearchURL, false); - if ( m_pScopeCB->IsChecked() ) - aSearchURL.append("&Scope=Heading"); - std::vector< OUString > aFactories = SfxContentHelper::GetResultSet(aSearchURL.makeStringAndClear()); - for (const OUString & rRow : aFactories) - { - sal_Int32 nIdx = 0; - OUString aTitle = rRow.getToken( 0, '\t', nIdx ); - OUString* pURL = new OUString( rRow.getToken( 1, '\t', nIdx ) ); - const sal_Int32 nPos = m_pResultsLB->InsertEntry( aTitle ); - m_pResultsLB->SetEntryData( nPos, pURL ); - } - LeaveWait(); + sal_Int32 nIdx = 0; + OUString aTitle = rRow.getToken( 0, '\t', nIdx ); + OUString* pURL = new OUString( rRow.getToken( 1, '\t', nIdx ) ); + const sal_Int32 nPos = m_pResultsLB->InsertEntry( aTitle ); + m_pResultsLB->SetEntryData( nPos, pURL ); + } + LeaveWait(); - if ( aFactories.empty() ) - { - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Info, VclButtonsType::Ok, - SfxResId(STR_INFO_NOSEARCHRESULTS))); - xBox->run(); - } + if ( aFactories.empty() ) + { + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_INFO_NOSEARCHRESULTS))); + xBox->run(); } } @@ -2274,19 +2274,19 @@ IMPL_LINK_NOARG( SfxHelpTextWindow_Impl, CloseHdl, LinkParamNone*, void ) IMPL_LINK( SfxHelpTextWindow_Impl, CheckHdl, Button*, pButton, void ) { CheckBox* pBox = static_cast<CheckBox*>(pButton); - if ( xConfiguration.is() ) + if ( !xConfiguration.is() ) + return; + + bool bChecked = pBox->IsChecked(); + try { - bool bChecked = pBox->IsChecked(); - try - { - ConfigurationHelper::writeRelativeKey( - xConfiguration, PATH_OFFICE_FACTORIES + sCurrentFactory, KEY_HELP_ON_OPEN, makeAny( bChecked ) ); - ConfigurationHelper::flush( xConfiguration ); - } - catch( Exception& ) - { - SAL_WARN( "sfx.appl", "SfxHelpTextWindow_Impl::CheckHdl(): unexpected exception" ); - } + ConfigurationHelper::writeRelativeKey( + xConfiguration, PATH_OFFICE_FACTORIES + sCurrentFactory, KEY_HELP_ON_OPEN, makeAny( bChecked ) ); + ConfigurationHelper::flush( xConfiguration ); + } + catch( Exception& ) + { + SAL_WARN( "sfx.appl", "SfxHelpTextWindow_Impl::CheckHdl(): unexpected exception" ); } } @@ -2428,22 +2428,22 @@ bool SfxHelpTextWindow_Impl::PreNotify( NotifyEvent& rNEvt ) void SfxHelpTextWindow_Impl::GetFocus() { - if ( !bIsInClose ) + if ( bIsInClose ) + return; + + try { - try + if( xFrame.is() ) { - if( xFrame.is() ) - { - Reference< css::awt::XWindow > xWindow = xFrame->getComponentWindow(); - if( xWindow.is() ) - xWindow->setFocus(); - } - } - catch( Exception& ) - { - SAL_WARN( "sfx.appl", "SfxHelpTextWindow_Impl::GetFocus(): unexpected exception" ); + Reference< css::awt::XWindow > xWindow = xFrame->getComponentWindow(); + if( xWindow.is() ) + xWindow->setFocus(); } } + catch( Exception& ) + { + SAL_WARN( "sfx.appl", "SfxHelpTextWindow_Impl::GetFocus(): unexpected exception" ); + } } @@ -2553,23 +2553,23 @@ void SfxHelpTextWindow_Impl::CloseFrame() void SfxHelpTextWindow_Impl::DoSearch() { - if (!m_xSrchDlg) + if (m_xSrchDlg) + return; + + // create the search dialog + m_xSrchDlg.reset(new sfx2::SearchDialog(pTextWin->GetFrameWeld(), "HelpSearchDialog")); + // set handler + m_xSrchDlg->SetFindHdl( LINK( this, SfxHelpTextWindow_Impl, FindHdl ) ); + m_xSrchDlg->SetCloseHdl( LINK( this, SfxHelpTextWindow_Impl, CloseHdl ) ); + // get selected text of the help page to set it as the search text + Reference< XTextRange > xCursor = getCursor(); + if ( xCursor.is() ) { - // create the search dialog - m_xSrchDlg.reset(new sfx2::SearchDialog(pTextWin->GetFrameWeld(), "HelpSearchDialog")); - // set handler - m_xSrchDlg->SetFindHdl( LINK( this, SfxHelpTextWindow_Impl, FindHdl ) ); - m_xSrchDlg->SetCloseHdl( LINK( this, SfxHelpTextWindow_Impl, CloseHdl ) ); - // get selected text of the help page to set it as the search text - Reference< XTextRange > xCursor = getCursor(); - if ( xCursor.is() ) - { - OUString sText = xCursor->getString(); - if ( !sText.isEmpty() ) - m_xSrchDlg->SetSearchText( sText ); - } - sfx2::SearchDialog::runAsync(m_xSrchDlg); + OUString sText = xCursor->getString(); + if ( !sText.isEmpty() ) + m_xSrchDlg->SetSearchText( sText ); } + sfx2::SearchDialog::runAsync(m_xSrchDlg); } // class SfxHelpWindow_Impl ---------------------------------------------- @@ -2677,21 +2677,21 @@ void SfxHelpWindow_Impl::MakeLayout() void SfxHelpWindow_Impl::InitSizes() { - if ( xWindow.is() ) - { - css::awt::Rectangle aRect = xWindow->getPosSize(); - nHeight = aRect.Height; + if ( !xWindow.is() ) + return; - if ( bIndex ) - { - nExpandWidth = aRect.Width; - nCollapseWidth = nExpandWidth * nTextSize / 100; - } - else - { - nCollapseWidth = aRect.Width; - nExpandWidth = nTextSize ? nCollapseWidth * 100 / nTextSize : 0; - } + css::awt::Rectangle aRect = xWindow->getPosSize(); + nHeight = aRect.Height; + + if ( bIndex ) + { + nExpandWidth = aRect.Width; + nCollapseWidth = nExpandWidth * nTextSize / 100; + } + else + { + nCollapseWidth = aRect.Width; + nExpandWidth = nTextSize ? nCollapseWidth * 100 / nTextSize : 0; } } @@ -2699,35 +2699,35 @@ void SfxHelpWindow_Impl::InitSizes() void SfxHelpWindow_Impl::LoadConfig() { SvtViewOptions aViewOpt( EViewType::Window, CONFIGNAME_HELPWIN ); - if ( aViewOpt.Exists() ) + if ( !aViewOpt.Exists() ) + return; + + bIndex = aViewOpt.IsVisible(); + Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME ); + OUString aUserData; + if ( aUserItem >>= aUserData ) { - bIndex = aViewOpt.IsVisible(); - Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME ); - OUString aUserData; - if ( aUserItem >>= aUserData ) + DBG_ASSERT( comphelper::string::getTokenCount(aUserData, ';') == 6, "invalid user data" ); + sal_Int32 nIdx = 0; + nIndexSize = aUserData.getToken( 0, ';', nIdx ).toInt32(); + nTextSize = aUserData.getToken( 0, ';', nIdx ).toInt32(); + sal_Int32 nWidth = aUserData.getToken( 0, ';', nIdx ).toInt32(); + nHeight = aUserData.getToken( 0, ';', nIdx ).toInt32(); + aWinPos.setX( aUserData.getToken( 0, ';', nIdx ).toInt32() ); + aWinPos.setY( aUserData.getToken( 0, ';', nIdx ).toInt32() ); + if ( bIndex ) { - DBG_ASSERT( comphelper::string::getTokenCount(aUserData, ';') == 6, "invalid user data" ); - sal_Int32 nIdx = 0; - nIndexSize = aUserData.getToken( 0, ';', nIdx ).toInt32(); - nTextSize = aUserData.getToken( 0, ';', nIdx ).toInt32(); - sal_Int32 nWidth = aUserData.getToken( 0, ';', nIdx ).toInt32(); - nHeight = aUserData.getToken( 0, ';', nIdx ).toInt32(); - aWinPos.setX( aUserData.getToken( 0, ';', nIdx ).toInt32() ); - aWinPos.setY( aUserData.getToken( 0, ';', nIdx ).toInt32() ); - if ( bIndex ) - { - nExpandWidth = nWidth; - nCollapseWidth = nExpandWidth * nTextSize / 100; - } - else if (nTextSize != 0) - { - nCollapseWidth = nWidth; - nExpandWidth = nCollapseWidth * 100 / nTextSize; - } + nExpandWidth = nWidth; + nCollapseWidth = nExpandWidth * nTextSize / 100; + } + else if (nTextSize != 0) + { + nCollapseWidth = nWidth; + nExpandWidth = nCollapseWidth * 100 / nTextSize; } - - pTextWin->ToggleIndex( bIndex ); } + + pTextWin->ToggleIndex( bIndex ); } @@ -2845,40 +2845,40 @@ void SfxHelpWindow_Impl::openDone(const OUString& sURL , } else pIndexWin->GrabFocusBack(); - if ( bSuccess ) + if ( !bSuccess ) + return; + + // set some view settings: "prevent help tips" and "helpid == 68245" + try { - // set some view settings: "prevent help tips" and "helpid == 68245" - try - { - Reference < XController > xController = pTextWin->getFrame()->getController(); - if ( xController.is() ) - { - Reference < XViewSettingsSupplier > xSettings( xController, UNO_QUERY ); - Reference < XPropertySet > xViewProps = xSettings->getViewSettings(); - Reference< XPropertySetInfo > xInfo = xViewProps->getPropertySetInfo(); - xViewProps->setPropertyValue( "ShowContentTips", makeAny( false ) ); - xViewProps->setPropertyValue( "ShowGraphics", makeAny( true ) ); - xViewProps->setPropertyValue( "ShowTables", makeAny( true ) ); - xViewProps->setPropertyValue( "HelpURL", makeAny( OUString("HID:SFX2_HID_HELP_ONHELP") ) ); - OUString sProperty( "IsExecuteHyperlinks" ); - if ( xInfo->hasPropertyByName( sProperty ) ) - xViewProps->setPropertyValue( sProperty, makeAny( true ) ); - xController->restoreViewData(Any()); - } - } - catch( Exception& ) + Reference < XController > xController = pTextWin->getFrame()->getController(); + if ( xController.is() ) { - OSL_FAIL( "SfxHelpWindow_Impl::OpenDoneHdl(): unexpected exception" ); + Reference < XViewSettingsSupplier > xSettings( xController, UNO_QUERY ); + Reference < XPropertySet > xViewProps = xSettings->getViewSettings(); + Reference< XPropertySetInfo > xInfo = xViewProps->getPropertySetInfo(); + xViewProps->setPropertyValue( "ShowContentTips", makeAny( false ) ); + xViewProps->setPropertyValue( "ShowGraphics", makeAny( true ) ); + xViewProps->setPropertyValue( "ShowTables", makeAny( true ) ); + xViewProps->setPropertyValue( "HelpURL", makeAny( OUString("HID:SFX2_HID_HELP_ONHELP") ) ); + OUString sProperty( "IsExecuteHyperlinks" ); + if ( xInfo->hasPropertyByName( sProperty ) ) + xViewProps->setPropertyValue( sProperty, makeAny( true ) ); + xController->restoreViewData(Any()); } + } + catch( Exception& ) + { + OSL_FAIL( "SfxHelpWindow_Impl::OpenDoneHdl(): unexpected exception" ); + } - // When the SearchPage opens the help doc, then select all words, which are equal to its text - OUString sSearchText = comphelper::string::strip(pIndexWin->GetSearchText(), ' '); - if ( !sSearchText.isEmpty() ) - pTextWin->SelectSearchText( sSearchText, pIndexWin->IsFullWordSearch() ); + // When the SearchPage opens the help doc, then select all words, which are equal to its text + OUString sSearchText = comphelper::string::strip(pIndexWin->GetSearchText(), ' '); + if ( !sSearchText.isEmpty() ) + pTextWin->SelectSearchText( sSearchText, pIndexWin->IsFullWordSearch() ); - // no page style header -> this prevents a print output of the URL - pTextWin->SetPageStyleHeaderOff(); - } + // no page style header -> this prevents a print output of the URL + pTextWin->SetPageStyleHeaderOff(); } diff --git a/sfx2/source/appl/opengrf.cxx b/sfx2/source/appl/opengrf.cxx index 873bd7914189..bff6d3d32eea 100644 --- a/sfx2/source/appl/opengrf.cxx +++ b/sfx2/source/appl/opengrf.cxx @@ -199,36 +199,36 @@ void SvxOpenGraphicDialog::SetPath( const OUString& rPath, bool bLinkState ) void SvxOpenGraphicDialog::EnableLink( bool state ) { - if( mpImpl->xCtrlAcc.is() ) + if( !mpImpl->xCtrlAcc.is() ) + return; + + try + { + mpImpl->xCtrlAcc->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK, state ); + } + catch(const IllegalArgumentException&) { - try - { - mpImpl->xCtrlAcc->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK, state ); - } - catch(const IllegalArgumentException&) - { #ifdef DBG_UTIL - OSL_FAIL( "Cannot enable \"link\" checkbox" ); + OSL_FAIL( "Cannot enable \"link\" checkbox" ); #endif - } } } void SvxOpenGraphicDialog::AsLink(bool bState) { - if( mpImpl->xCtrlAcc.is() ) + if( !mpImpl->xCtrlAcc.is() ) + return; + + try + { + mpImpl->xCtrlAcc->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, Any(bState) ); + } + catch(const IllegalArgumentException&) { - try - { - mpImpl->xCtrlAcc->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, Any(bState) ); - } - catch(const IllegalArgumentException&) - { #ifdef DBG_UTIL - OSL_FAIL( "Cannot check \"link\" checkbox" ); + OSL_FAIL( "Cannot check \"link\" checkbox" ); #endif - } } } diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx index b32f14649f96..a5b698f5cc69 100644 --- a/sfx2/source/appl/sfxpicklist.cxx +++ b/sfx2/source/appl/sfxpicklist.cxx @@ -184,64 +184,64 @@ void SfxPickListImpl::Notify( SfxBroadcaster&, const SfxHint& rHint ) } const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint); - if ( pEventHint ) - { - // only ObjectShell-related events with media interest - SfxObjectShell* pDocSh = pEventHint->GetObjShell(); - if( !pDocSh ) - return; + if ( !pEventHint ) + return; - switch ( pEventHint->GetEventId() ) - { - case SfxEventHintId::CreateDoc: - { - bool bAllowModif = pDocSh->IsEnableSetModified(); - if ( bAllowModif ) - pDocSh->EnableSetModified( false ); - - using namespace ::com::sun::star; - uno::Reference<document::XDocumentProperties> xDocProps( - pDocSh->getDocProperties()); - if (xDocProps.is()) { - xDocProps->setAuthor( SvtUserOptions().GetFullName() ); - ::DateTime now( ::DateTime::SYSTEM ); - xDocProps->setCreationDate( now.GetUNODateTime() ); - } + // only ObjectShell-related events with media interest + SfxObjectShell* pDocSh = pEventHint->GetObjShell(); + if( !pDocSh ) + return; - if ( bAllowModif ) - pDocSh->EnableSetModified( bAllowModif ); + switch ( pEventHint->GetEventId() ) + { + case SfxEventHintId::CreateDoc: + { + bool bAllowModif = pDocSh->IsEnableSetModified(); + if ( bAllowModif ) + pDocSh->EnableSetModified( false ); + + using namespace ::com::sun::star; + uno::Reference<document::XDocumentProperties> xDocProps( + pDocSh->getDocProperties()); + if (xDocProps.is()) { + xDocProps->setAuthor( SvtUserOptions().GetFullName() ); + ::DateTime now( ::DateTime::SYSTEM ); + xDocProps->setCreationDate( now.GetUNODateTime() ); } - break; - case SfxEventHintId::OpenDoc: - case SfxEventHintId::SaveDocDone: - case SfxEventHintId::SaveAsDocDone: - case SfxEventHintId::SaveToDocDone: - case SfxEventHintId::CloseDoc: - { - AddDocumentToPickList(pDocSh); - } - break; + if ( bAllowModif ) + pDocSh->EnableSetModified( bAllowModif ); + } + break; + + case SfxEventHintId::OpenDoc: + case SfxEventHintId::SaveDocDone: + case SfxEventHintId::SaveAsDocDone: + case SfxEventHintId::SaveToDocDone: + case SfxEventHintId::CloseDoc: + { + AddDocumentToPickList(pDocSh); + } + break; - case SfxEventHintId::SaveAsDoc: + case SfxEventHintId::SaveAsDoc: + { + SfxMedium *pMedium = pDocSh->GetMedium(); + if (!pMedium) + return; + + // We're starting a "Save As". Add the current document (if it's + // not a "new" document) to the "Recent Documents" list before we + // switch to the new path. + // If the current document is new, path will be empty. + OUString path = pMedium->GetOrigURL(); + if (!path.isEmpty()) { - SfxMedium *pMedium = pDocSh->GetMedium(); - if (!pMedium) - return; - - // We're starting a "Save As". Add the current document (if it's - // not a "new" document) to the "Recent Documents" list before we - // switch to the new path. - // If the current document is new, path will be empty. - OUString path = pMedium->GetOrigURL(); - if (!path.isEmpty()) - { - AddDocumentToPickList(pDocSh); - } + AddDocumentToPickList(pDocSh); } - break; - default: break; } + break; + default: break; } } diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index 65c73de125d9..a05579fbdd89 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -196,32 +196,32 @@ ShutdownIcon::~ShutdownIcon() void ShutdownIcon::OpenURL( const OUString& aURL, const OUString& rTarget, const Sequence< PropertyValue >& aArgs ) { - if ( getInstance() && getInstance()->m_xDesktop.is() ) - { - css::uno::Reference < XDispatchProvider > xDispatchProvider( getInstance()->m_xDesktop, UNO_QUERY ); - if ( xDispatchProvider.is() ) - { - css::util::URL aDispatchURL; - aDispatchURL.Complete = aURL; + if ( !getInstance() || !getInstance()->m_xDesktop.is() ) + return; - css::uno::Reference< util::XURLTransformer > xURLTransformer( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); - try - { - css::uno::Reference< css::frame::XDispatch > xDispatch; + css::uno::Reference < XDispatchProvider > xDispatchProvider( getInstance()->m_xDesktop, UNO_QUERY ); + if ( !xDispatchProvider.is() ) + return; - xURLTransformer->parseStrict( aDispatchURL ); - xDispatch = xDispatchProvider->queryDispatch( aDispatchURL, rTarget, 0 ); - if ( xDispatch.is() ) - xDispatch->dispatch( aDispatchURL, aArgs ); - } - catch ( css::uno::RuntimeException& ) - { - throw; - } - catch ( css::uno::Exception& ) - { - } - } + css::util::URL aDispatchURL; + aDispatchURL.Complete = aURL; + + css::uno::Reference< util::XURLTransformer > xURLTransformer( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); + try + { + css::uno::Reference< css::frame::XDispatch > xDispatch; + + xURLTransformer->parseStrict( aDispatchURL ); + xDispatch = xDispatchProvider->queryDispatch( aDispatchURL, rTarget, 0 ); + if ( xDispatch.is() ) + xDispatch->dispatch( aDispatchURL, aArgs ); + } + catch ( css::uno::RuntimeException& ) + { + throw; + } + catch ( css::uno::Exception& ) + { } } @@ -239,40 +239,40 @@ void ShutdownIcon::FileOpen() void ShutdownIcon::FromTemplate() { - if ( getInstance() && getInstance()->m_xDesktop.is() ) + if ( !getInstance() || !getInstance()->m_xDesktop.is() ) + return; + + css::uno::Reference < css::frame::XFramesSupplier > xDesktop ( getInstance()->m_xDesktop, UNO_QUERY); + css::uno::Reference < css::frame::XFrame > xFrame( xDesktop->getActiveFrame() ); + if ( !xFrame.is() ) + xFrame.set( xDesktop, UNO_QUERY ); + + URL aTargetURL; + aTargetURL.Complete = ".uno:NewDoc"; + css::uno::Reference< util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); + xTrans->parseStrict( aTargetURL ); + + css::uno::Reference < css::frame::XDispatchProvider > xProv( xFrame, UNO_QUERY ); + css::uno::Reference < css::frame::XDispatch > xDisp; + if ( xProv.is() ) { - css::uno::Reference < css::frame::XFramesSupplier > xDesktop ( getInstance()->m_xDesktop, UNO_QUERY); - css::uno::Reference < css::frame::XFrame > xFrame( xDesktop->getActiveFrame() ); - if ( !xFrame.is() ) - xFrame.set( xDesktop, UNO_QUERY ); - - URL aTargetURL; - aTargetURL.Complete = ".uno:NewDoc"; - css::uno::Reference< util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); - xTrans->parseStrict( aTargetURL ); - - css::uno::Reference < css::frame::XDispatchProvider > xProv( xFrame, UNO_QUERY ); - css::uno::Reference < css::frame::XDispatch > xDisp; - if ( xProv.is() ) - { - xDisp = xProv->queryDispatch( aTargetURL, "_self", 0 ); - } - if ( xDisp.is() ) - { - Sequence<PropertyValue> aArgs(1); - PropertyValue* pArg = aArgs.getArray(); - pArg[0].Name = "Referer"; - pArg[0].Value <<= OUString("private:user"); - css::uno::Reference< css::frame::XNotifyingDispatch > xNotifier(xDisp, UNO_QUERY); - if (xNotifier.is()) - { - EnterModalMode(); - xNotifier->dispatchWithNotification(aTargetURL, aArgs, new SfxNotificationListener_Impl); - } - else - xDisp->dispatch( aTargetURL, aArgs ); - } + xDisp = xProv->queryDispatch( aTargetURL, "_self", 0 ); } + if ( !xDisp.is() ) + return; + + Sequence<PropertyValue> aArgs(1); + PropertyValue* pArg = aArgs.getArray(); + pArg[0].Name = "Referer"; + pArg[0].Value <<= OUString("private:user"); + css::uno::Reference< css::frame::XNotifyingDispatch > xNotifier(xDisp, UNO_QUERY); + if (xNotifier.is()) + { + EnterModalMode(); + xNotifier->dispatchWithNotification(aTargetURL, aArgs, new SfxNotificationListener_Impl); + } + else + xDisp->dispatch( aTargetURL, aArgs ); } OUString ShutdownIcon::GetUrlDescription( const OUString& aUrl ) diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx index 20aa4cfab3a9..d27a04d1a27a 100644 --- a/sfx2/source/appl/workwin.cxx +++ b/sfx2/source/appl/workwin.cxx @@ -144,47 +144,47 @@ LayoutManagerListener::~LayoutManagerListener() void LayoutManagerListener::setFrame( const css::uno::Reference< css::frame::XFrame >& xFrame ) { SolarMutexGuard aGuard; - if ( m_pWrkWin && !m_bHasFrame ) - { - m_xFrame = xFrame; - m_bHasFrame = true; + if ( !m_pWrkWin || m_bHasFrame ) + return; - if ( xFrame.is() ) - { - css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY ); - css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager; - if ( xPropSet.is() ) - { - try - { - Any aValue = xPropSet->getPropertyValue( g_aLayoutManagerPropName ); - aValue >>= xLayoutManager; + m_xFrame = xFrame; + m_bHasFrame = true; - if ( xLayoutManager.is() ) - xLayoutManager->addLayoutManagerEventListener( - css::uno::Reference< css::frame::XLayoutManagerListener >( - static_cast< OWeakObject* >( this ), css::uno::UNO_QUERY )); + if ( !xFrame.is() ) + return; - xPropSet.set( xLayoutManager, UNO_QUERY ); - if ( xPropSet.is() ) - { - aValue = xPropSet->getPropertyValue( "LockCount" ); - aValue >>= m_pWrkWin->m_nLock; - } - } - catch ( css::lang::DisposedException& ) - { - } - catch ( const css::uno::RuntimeException& ) - { - throw; - } - catch ( css::uno::Exception& ) - { - } - } + css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY ); + css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager; + if ( !xPropSet.is() ) + return; + + try + { + Any aValue = xPropSet->getPropertyValue( g_aLayoutManagerPropName ); + aValue >>= xLayoutManager; + + if ( xLayoutManager.is() ) + xLayoutManager->addLayoutManagerEventListener( + css::uno::Reference< css::frame::XLayoutManagerListener >( + static_cast< OWeakObject* >( this ), css::uno::UNO_QUERY )); + + xPropSet.set( xLayoutManager, UNO_QUERY ); + if ( xPropSet.is() ) + { + aValue = xPropSet->getPropertyValue( "LockCount" ); + aValue >>= m_pWrkWin->m_nLock; } } + catch ( css::lang::DisposedException& ) + { + } + catch ( const css::uno::RuntimeException& ) + { + throw; + } + catch ( css::uno::Exception& ) + { + } } @@ -210,37 +210,37 @@ void SAL_CALL LayoutManagerListener::dispose() m_pWrkWin = nullptr; css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame.get(), css::uno::UNO_QUERY ); - if ( xFrame.is() ) + if ( !xFrame.is() ) + return; + + m_xFrame.clear(); + m_bHasFrame = false; + + css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, css::uno::UNO_QUERY ); + css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager; + if ( !xPropSet.is() ) + return; + + try { - m_xFrame.clear(); - m_bHasFrame = false; + css::uno::Any aValue = xPropSet->getPropertyValue( g_aLayoutManagerPropName ); + aValue >>= xLayoutManager; - css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, css::uno::UNO_QUERY ); - css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager; - if ( xPropSet.is() ) - { - try - { - css::uno::Any aValue = xPropSet->getPropertyValue( g_aLayoutManagerPropName ); - aValue >>= xLayoutManager; - - // remove as listener from layout manager - if ( xLayoutManager.is() ) - xLayoutManager->removeLayoutManagerEventListener( - css::uno::Reference< css::frame::XLayoutManagerListener >( - static_cast< OWeakObject* >( this ), css::uno::UNO_QUERY )); - } - catch ( css::lang::DisposedException& ) - { - } - catch ( const css::uno::RuntimeException& ) - { - throw; - } - catch ( css::uno::Exception& ) - { - } - } + // remove as listener from layout manager + if ( xLayoutManager.is() ) + xLayoutManager->removeLayoutManagerEventListener( + css::uno::Reference< css::frame::XLayoutManagerListener >( + static_cast< OWeakObject* >( this ), css::uno::UNO_QUERY )); + } + catch ( css::lang::DisposedException& ) + { + } + catch ( const css::uno::RuntimeException& ) + { + throw; + } + catch ( css::uno::Exception& ) + { } } @@ -265,28 +265,28 @@ void SAL_CALL LayoutManagerListener::layoutEvent( const css::uno::Any& ) { SolarMutexGuard aGuard; - if ( m_pWrkWin ) + if ( !m_pWrkWin ) + return; + + if ( eLayoutEvent == css::frame::LayoutManagerEvents::VISIBLE ) { - if ( eLayoutEvent == css::frame::LayoutManagerEvents::VISIBLE ) - { - m_pWrkWin->MakeVisible_Impl( true ); - m_pWrkWin->ShowChildren_Impl(); - m_pWrkWin->ArrangeChildren_Impl(); - } - else if ( eLayoutEvent == css::frame::LayoutManagerEvents::INVISIBLE ) - { - m_pWrkWin->MakeVisible_Impl( false ); - m_pWrkWin->HideChildren_Impl(); - m_pWrkWin->ArrangeChildren_Impl(); - } - else if ( eLayoutEvent == css::frame::LayoutManagerEvents::LOCK ) - { - m_pWrkWin->Lock_Impl( true ); - } - else if ( eLayoutEvent == css::frame::LayoutManagerEvents::UNLOCK ) - { - m_pWrkWin->Lock_Impl( false ); - } + m_pWrkWin->MakeVisible_Impl( true ); + m_pWrkWin->ShowChildren_Impl(); + m_pWrkWin->ArrangeChildren_Impl(); + } + else if ( eLayoutEvent == css::frame::LayoutManagerEvents::INVISIBLE ) + { + m_pWrkWin->MakeVisible_Impl( false ); + m_pWrkWin->HideChildren_Impl(); + m_pWrkWin->ArrangeChildren_Impl(); + } + else if ( eLayoutEvent == css::frame::LayoutManagerEvents::LOCK ) + { + m_pWrkWin->Lock_Impl( true ); + } + else if ( eLayoutEvent == css::frame::LayoutManagerEvents::UNLOCK ) + { + m_pWrkWin->Lock_Impl( false ); } } @@ -1330,64 +1330,64 @@ void SfxWorkWindow::CreateChildWin_Impl( SfxChildWin_Impl *pCW, bool bSetFocus ) pCW->aInfo.bVisible = true; SfxChildWindow *pChildWin = SfxChildWindow::CreateChildWindow( pCW->nId, pWorkWin, &GetBindings(), pCW->aInfo).release(); - if (pChildWin) - { - if ( bSetFocus ) - bSetFocus = pChildWin->WantsFocus(); - pChildWin->SetWorkWindow_Impl( this ); + if (!pChildWin) + return; + + if ( bSetFocus ) + bSetFocus = pChildWin->WantsFocus(); + pChildWin->SetWorkWindow_Impl( this ); - // At least the extra string is changed during the evaluation, - // also get it anewed - SfxChildWinInfo aInfo = pChildWin->GetInfo(); - pCW->aInfo.aExtraString = aInfo.aExtraString; - pCW->aInfo.bVisible = aInfo.bVisible; - pCW->aInfo.nFlags |= aInfo.nFlags; + // At least the extra string is changed during the evaluation, + // also get it anewed + SfxChildWinInfo aInfo = pChildWin->GetInfo(); + pCW->aInfo.aExtraString = aInfo.aExtraString; + pCW->aInfo.bVisible = aInfo.bVisible; + pCW->aInfo.nFlags |= aInfo.nFlags; - // The creation was successful - GetBindings().Invalidate(pCW->nId); + // The creation was successful + GetBindings().Invalidate(pCW->nId); - sal_uInt16 nPos = pChildWin->GetPosition(); - if (nPos != CHILDWIN_NOPOS) + sal_uInt16 nPos = pChildWin->GetPosition(); + if (nPos != CHILDWIN_NOPOS) + { + DBG_ASSERT(nPos < SFX_OBJECTBAR_MAX, "Illegal objectbar position!"); + if ( aChildren[TbxMatch(nPos)] )// && { - DBG_ASSERT(nPos < SFX_OBJECTBAR_MAX, "Illegal objectbar position!"); - if ( aChildren[TbxMatch(nPos)] )// && - { - // ChildWindow replaces ObjectBar - aChildren[TbxMatch(nPos)]->nVisible ^= SfxChildVisibility::NOT_HIDDEN; - } + // ChildWindow replaces ObjectBar + aChildren[TbxMatch(nPos)]->nVisible ^= SfxChildVisibility::NOT_HIDDEN; } + } - // make childwin keyboard accessible - pWorkWin->GetSystemWindow()->GetTaskPaneList()->AddWindow( pChildWin->GetWindow() ); + // make childwin keyboard accessible + pWorkWin->GetSystemWindow()->GetTaskPaneList()->AddWindow( pChildWin->GetWindow() ); - pCW->pWin = pChildWin; + pCW->pWin = pChildWin; - if ( pChildWin->GetAlignment() == SfxChildAlignment::NOALIGNMENT || pChildWin->GetWindow()->GetParent() == pWorkWin) - { - // The window is not docked or docked outside of one split windows - // and must therefore be registered explicitly as a Child - if (pChildWin->GetController()) - pCW->pCli = RegisterChild_Impl(pChildWin->GetController(), pChildWin->GetAlignment()); - else - pCW->pCli = RegisterChild_Impl(*(pChildWin->GetWindow()), pChildWin->GetAlignment()); - pCW->pCli->nVisible = SfxChildVisibility::VISIBLE; - if ( pChildWin->GetAlignment() != SfxChildAlignment::NOALIGNMENT && bIsFullScreen ) - pCW->pCli->nVisible ^= SfxChildVisibility::ACTIVE; - pCW->pCli->bSetFocus = bSetFocus; - } + if ( pChildWin->GetAlignment() == SfxChildAlignment::NOALIGNMENT || pChildWin->GetWindow()->GetParent() == pWorkWin) + { + // The window is not docked or docked outside of one split windows + // and must therefore be registered explicitly as a Child + if (pChildWin->GetController()) + pCW->pCli = RegisterChild_Impl(pChildWin->GetController(), pChildWin->GetAlignment()); else - { - // A docked window which parent is not a WorkingWindow, must lie - // in a SplitWindow and thus not be explicitly registered. - // This happens already in the initialization of SfxDockingWindows! - } + pCW->pCli = RegisterChild_Impl(*(pChildWin->GetWindow()), pChildWin->GetAlignment()); + pCW->pCli->nVisible = SfxChildVisibility::VISIBLE; + if ( pChildWin->GetAlignment() != SfxChildAlignment::NOALIGNMENT && bIsFullScreen ) + pCW->pCli->nVisible ^= SfxChildVisibility::ACTIVE; + pCW->pCli->bSetFocus = bSetFocus; + } + else + { + // A docked window which parent is not a WorkingWindow, must lie + // in a SplitWindow and thus not be explicitly registered. + // This happens already in the initialization of SfxDockingWindows! + } - if ( pCW->nInterfaceId != pChildWin->GetContextId() ) - pChildWin->CreateContext( pCW->nInterfaceId, GetBindings() ); + if ( pCW->nInterfaceId != pChildWin->GetContextId() ) + pChildWin->CreateContext( pCW->nInterfaceId, GetBindings() ); - // Save the information in the INI file - SaveStatus_Impl(pChildWin, pCW->aInfo); - } + // Save the information in the INI file + SaveStatus_Impl(pChildWin, pCW->aInfo); } void SfxWorkWindow::RemoveChildWin_Impl( SfxChildWin_Impl *pCW ) @@ -2153,35 +2153,35 @@ void SfxWorkWindow::InitializeChild_Impl(SfxChildWin_Impl *pCW) } } - if ( pMod ) + if ( !pMod ) + return; + + SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl(); + if ( !pFactories ) + return; + + SfxChildWinFactArr_Impl &rFactories = *pFactories; + for ( size_t nFactory = 0; nFactory < rFactories.size(); ++nFactory ) { - SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl(); - if ( pFactories ) + pFact = &rFactories[nFactory]; + if ( pFact->nId == pCW->nSaveId ) { - SfxChildWinFactArr_Impl &rFactories = *pFactories; - for ( size_t nFactory = 0; nFactory < rFactories.size(); ++nFactory ) - { - pFact = &rFactories[nFactory]; - if ( pFact->nId == pCW->nSaveId ) - { - pCW->aInfo = pFact->aInfo; - pCW->aInfo.aModule = sModule; - SfxChildWindow::InitializeChildWinFactory_Impl( - pCW->nSaveId, pCW->aInfo); - pCW->bCreate = pCW->aInfo.bVisible; - SfxChildWindowFlags nFlags = pFact->aInfo.nFlags; - if ( nFlags & SfxChildWindowFlags::TASK ) - pCW->aInfo.nFlags |= SfxChildWindowFlags::TASK; - if ( nFlags & SfxChildWindowFlags::CANTGETFOCUS ) - pCW->aInfo.nFlags |= SfxChildWindowFlags::CANTGETFOCUS; - if ( nFlags & SfxChildWindowFlags::FORCEDOCK ) - pCW->aInfo.nFlags |= SfxChildWindowFlags::FORCEDOCK; - if ( nFlags & SfxChildWindowFlags::ALWAYSAVAILABLE ) - pCW->aInfo.nFlags |= SfxChildWindowFlags::ALWAYSAVAILABLE; - pFact->aInfo = pCW->aInfo; - return; - } - } + pCW->aInfo = pFact->aInfo; + pCW->aInfo.aModule = sModule; + SfxChildWindow::InitializeChildWinFactory_Impl( + pCW->nSaveId, pCW->aInfo); + pCW->bCreate = pCW->aInfo.bVisible; + SfxChildWindowFlags nFlags = pFact->aInfo.nFlags; + if ( nFlags & SfxChildWindowFlags::TASK ) + pCW->aInfo.nFlags |= SfxChildWindowFlags::TASK; + if ( nFlags & SfxChildWindowFlags::CANTGETFOCUS ) + pCW->aInfo.nFlags |= SfxChildWindowFlags::CANTGETFOCUS; + if ( nFlags & SfxChildWindowFlags::FORCEDOCK ) + pCW->aInfo.nFlags |= SfxChildWindowFlags::FORCEDOCK; + if ( nFlags & SfxChildWindowFlags::ALWAYSAVAILABLE ) + pCW->aInfo.nFlags |= SfxChildWindowFlags::ALWAYSAVAILABLE; + pFact->aInfo = pCW->aInfo; + return; } } } diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx index 062c969f0bc9..a17f43929ab5 100644 --- a/sfx2/source/bastyp/fltfnc.cxx +++ b/sfx2/source/bastyp/fltfnc.cxx @@ -902,189 +902,189 @@ void SfxFilterContainer::ReadSingleFilter_Impl( aResult = uno::Any(); } - if( aResult >>= lFilterProperties ) + if( !(aResult >>= lFilterProperties) ) + return; + + // collect information to add filter to container + // (attention: some information aren't available on filter directly ... you must search for corresponding type too!) + SfxFilterFlags nFlags = SfxFilterFlags::NONE; + SotClipboardFormatId nClipboardId = SotClipboardFormatId::NONE; + sal_Int32 nDocumentIconId = 0 ; + sal_Int32 nFormatVersion = 0 ; + OUString sMimeType ; + OUString sType ; + OUString sUIName ; + OUString sHumanName ; + OUString sDefaultTemplate ; + OUString sUserData ; + OUString sExtension ; + OUString sPattern ; + OUString sServiceName ; + bool bEnabled = true ; + + // first get directly available properties + sal_Int32 nFilterPropertyCount = lFilterProperties.getLength(); + sal_Int32 nFilterProperty = 0 ; + for( nFilterProperty=0; nFilterProperty<nFilterPropertyCount; ++nFilterProperty ) { - // collect information to add filter to container - // (attention: some information aren't available on filter directly ... you must search for corresponding type too!) - SfxFilterFlags nFlags = SfxFilterFlags::NONE; - SotClipboardFormatId nClipboardId = SotClipboardFormatId::NONE; - sal_Int32 nDocumentIconId = 0 ; - sal_Int32 nFormatVersion = 0 ; - OUString sMimeType ; - OUString sType ; - OUString sUIName ; - OUString sHumanName ; - OUString sDefaultTemplate ; - OUString sUserData ; - OUString sExtension ; - OUString sPattern ; - OUString sServiceName ; - bool bEnabled = true ; - - // first get directly available properties - sal_Int32 nFilterPropertyCount = lFilterProperties.getLength(); - sal_Int32 nFilterProperty = 0 ; - for( nFilterProperty=0; nFilterProperty<nFilterPropertyCount; ++nFilterProperty ) + if ( lFilterProperties[nFilterProperty].Name == "FileFormatVersion" ) { - if ( lFilterProperties[nFilterProperty].Name == "FileFormatVersion" ) - { - lFilterProperties[nFilterProperty].Value >>= nFormatVersion; - } - else if ( lFilterProperties[nFilterProperty].Name == "TemplateName" ) - { - lFilterProperties[nFilterProperty].Value >>= sDefaultTemplate; - } - else if ( lFilterProperties[nFilterProperty].Name == "Flags" ) - { - sal_Int32 nTmp(0); - lFilterProperties[nFilterProperty].Value >>= nTmp; - assert((nTmp & ~o3tl::typed_flags<SfxFilterFlags>::mask) == 0); - nFlags = static_cast<SfxFilterFlags>(nTmp); - } - else if ( lFilterProperties[nFilterProperty].Name == "UIName" ) - { - lFilterProperties[nFilterProperty].Value >>= sUIName; - } - else if ( lFilterProperties[nFilterProperty].Name == "UserData" ) - { - uno::Sequence< OUString > lUserData; - lFilterProperties[nFilterProperty].Value >>= lUserData; - sUserData = implc_convertStringlistToString( lUserData, ',', OUString() ); - } - else if ( lFilterProperties[nFilterProperty].Name == "DocumentService" ) + lFilterProperties[nFilterProperty].Value >>= nFormatVersion; + } + else if ( lFilterProperties[nFilterProperty].Name == "TemplateName" ) + { + lFilterProperties[nFilterProperty].Value >>= sDefaultTemplate; + } + else if ( lFilterProperties[nFilterProperty].Name == "Flags" ) + { + sal_Int32 nTmp(0); + lFilterProperties[nFilterProperty].Value >>= nTmp; + assert((nTmp & ~o3tl::typed_flags<SfxFilterFlags>::mask) == 0); + nFlags = static_cast<SfxFilterFlags>(nTmp); + } + else if ( lFilterProperties[nFilterProperty].Name == "UIName" ) + { + lFilterProperties[nFilterProperty].Value >>= sUIName; + } + else if ( lFilterProperties[nFilterProperty].Name == "UserData" ) + { + uno::Sequence< OUString > lUserData; + lFilterProperties[nFilterProperty].Value >>= lUserData; + sUserData = implc_convertStringlistToString( lUserData, ',', OUString() ); + } + else if ( lFilterProperties[nFilterProperty].Name == "DocumentService" ) + { + lFilterProperties[nFilterProperty].Value >>= sServiceName; + } + else if (lFilterProperties[nFilterProperty].Name == "ExportExtension") + { + // Extension preferred by the filter. This takes precedence + // over those that are given in the file format type. + lFilterProperties[nFilterProperty].Value >>= sExtension; + sExtension = "*." + sExtension; + } + else if ( lFilterProperties[nFilterProperty].Name == "Type" ) + { + lFilterProperties[nFilterProperty].Value >>= sType; + // Try to get filter .. but look for any exceptions! + // May be filter was deleted by another thread ... + try { - lFilterProperties[nFilterProperty].Value >>= sServiceName; + aResult = xTypeCFG->getByName( sType ); } - else if (lFilterProperties[nFilterProperty].Name == "ExportExtension") + catch (const container::NoSuchElementException&) { - // Extension preferred by the filter. This takes precedence - // over those that are given in the file format type. - lFilterProperties[nFilterProperty].Value >>= sExtension; - sExtension = "*." + sExtension; + aResult = uno::Any(); } - else if ( lFilterProperties[nFilterProperty].Name == "Type" ) - { - lFilterProperties[nFilterProperty].Value >>= sType; - // Try to get filter .. but look for any exceptions! - // May be filter was deleted by another thread ... - try - { - aResult = xTypeCFG->getByName( sType ); - } - catch (const container::NoSuchElementException&) - { - aResult = uno::Any(); - } - uno::Sequence< beans::PropertyValue > lTypeProperties; - if( aResult >>= lTypeProperties ) + uno::Sequence< beans::PropertyValue > lTypeProperties; + if( aResult >>= lTypeProperties ) + { + // get indirect available properties then (types) + sal_Int32 nTypePropertyCount = lTypeProperties.getLength(); + sal_Int32 nTypeProperty = 0 ; + for( nTypeProperty=0; nTypeProperty<nTypePropertyCount; ++nTypeProperty ) { - // get indirect available properties then (types) - sal_Int32 nTypePropertyCount = lTypeProperties.getLength(); - sal_Int32 nTypeProperty = 0 ; - for( nTypeProperty=0; nTypeProperty<nTypePropertyCount; ++nTypeProperty ) + if ( lTypeProperties[nTypeProperty].Name == "ClipboardFormat" ) { - if ( lTypeProperties[nTypeProperty].Name == "ClipboardFormat" ) - { - lTypeProperties[nTypeProperty].Value >>= sHumanName; - } - else if ( lTypeProperties[nTypeProperty].Name == "DocumentIconID" ) - { - lTypeProperties[nTypeProperty].Value >>= nDocumentIconId; - } - else if ( lTypeProperties[nTypeProperty].Name == "MediaType" ) - { - lTypeProperties[nTypeProperty].Value >>= sMimeType; - } - else if ( lTypeProperties[nTypeProperty].Name == "Extensions" ) - { - if (sExtension.isEmpty()) - { - uno::Sequence< OUString > lExtensions; - lTypeProperties[nTypeProperty].Value >>= lExtensions; - sExtension = implc_convertStringlistToString( lExtensions, ';', "*." ); - } - } - else if ( lTypeProperties[nTypeProperty].Name == "URLPattern" ) + lTypeProperties[nTypeProperty].Value >>= sHumanName; + } + else if ( lTypeProperties[nTypeProperty].Name == "DocumentIconID" ) + { + lTypeProperties[nTypeProperty].Value >>= nDocumentIconId; + } + else if ( lTypeProperties[nTypeProperty].Name == "MediaType" ) + { + lTypeProperties[nTypeProperty].Value >>= sMimeType; + } + else if ( lTypeProperties[nTypeProperty].Name == "Extensions" ) + { + if (sExtension.isEmpty()) { - uno::Sequence< OUString > lPattern; - lTypeProperties[nTypeProperty].Value >>= lPattern; - sPattern = implc_convertStringlistToString( lPattern, ';', OUString() ); + uno::Sequence< OUString > lExtensions; + lTypeProperties[nTypeProperty].Value >>= lExtensions; + sExtension = implc_convertStringlistToString( lExtensions, ';', "*." ); } } + else if ( lTypeProperties[nTypeProperty].Name == "URLPattern" ) + { + uno::Sequence< OUString > lPattern; + lTypeProperties[nTypeProperty].Value >>= lPattern; + sPattern = implc_convertStringlistToString( lPattern, ';', OUString() ); + } } } - else if ( lFilterProperties[nFilterProperty].Name == "Enabled" ) - { - lFilterProperties[nFilterProperty].Value >>= bEnabled; - } - + } + else if ( lFilterProperties[nFilterProperty].Name == "Enabled" ) + { + lFilterProperties[nFilterProperty].Value >>= bEnabled; } - if ( sServiceName.isEmpty() ) - return; + } - // old formats are found ... using HumanPresentableName! - if( !sHumanName.isEmpty() ) - { - nClipboardId = SotExchange::RegisterFormatName( sHumanName ); + if ( sServiceName.isEmpty() ) + return; - // For external filters ignore clipboard IDs - if(nFlags & SfxFilterFlags::STARONEFILTER) - { - nClipboardId = SotClipboardFormatId::NONE; - } - } - // register SfxFilter - // first erase module name from old filter names! - // e.g: "scalc: DIF" => "DIF" - sal_Int32 nStartRealName = sFilterName.indexOf( ": " ); - if( nStartRealName != -1 ) - { - SAL_WARN( "sfx.bastyp", "Old format, not supported!"); - sFilterName = sFilterName.copy( nStartRealName+2 ); - } + // old formats are found ... using HumanPresentableName! + if( !sHumanName.isEmpty() ) + { + nClipboardId = SotExchange::RegisterFormatName( sHumanName ); - std::shared_ptr<const SfxFilter> pFilter = bUpdate ? SfxFilter::GetFilterByName( sFilterName ) : nullptr; - if (!pFilter) - { - pFilter.reset(new SfxFilter( sFilterName , - sExtension , - nFlags , - nClipboardId , - sType , - sMimeType , - sUserData , - sServiceName , - bEnabled )); - rList.push_back( pFilter ); - } - else + // For external filters ignore clipboard IDs + if(nFlags & SfxFilterFlags::STARONEFILTER) { - SfxFilter* pFilt = const_cast<SfxFilter*>(pFilter.get()); - pFilt->maFilterName = sFilterName; - pFilt->aWildCard = WildCard(sExtension, ';'); - pFilt->nFormatType = nFlags; - pFilt->lFormat = nClipboardId; - pFilt->aTypeName = sType; - pFilt->aMimeType = sMimeType; - pFilt->aUserData = sUserData; - pFilt->aServiceName = sServiceName; - pFilt->mbEnabled = bEnabled; + nClipboardId = SotClipboardFormatId::NONE; } + } + // register SfxFilter + // first erase module name from old filter names! + // e.g: "scalc: DIF" => "DIF" + sal_Int32 nStartRealName = sFilterName.indexOf( ": " ); + if( nStartRealName != -1 ) + { + SAL_WARN( "sfx.bastyp", "Old format, not supported!"); + sFilterName = sFilterName.copy( nStartRealName+2 ); + } + std::shared_ptr<const SfxFilter> pFilter = bUpdate ? SfxFilter::GetFilterByName( sFilterName ) : nullptr; + if (!pFilter) + { + pFilter.reset(new SfxFilter( sFilterName , + sExtension , + nFlags , + nClipboardId , + sType , + sMimeType , + sUserData , + sServiceName , + bEnabled )); + rList.push_back( pFilter ); + } + else + { SfxFilter* pFilt = const_cast<SfxFilter*>(pFilter.get()); + pFilt->maFilterName = sFilterName; + pFilt->aWildCard = WildCard(sExtension, ';'); + pFilt->nFormatType = nFlags; + pFilt->lFormat = nClipboardId; + pFilt->aTypeName = sType; + pFilt->aMimeType = sMimeType; + pFilt->aUserData = sUserData; + pFilt->aServiceName = sServiceName; + pFilt->mbEnabled = bEnabled; + } - // Don't forget to set right UIName! - // Otherwise internal name is used as fallback ... - pFilt->SetUIName( sUIName ); - pFilt->SetDefaultTemplate( sDefaultTemplate ); - if( nFormatVersion ) - { - pFilt->SetVersion( nFormatVersion ); - } - pFilt->SetURLPattern(sPattern); + SfxFilter* pFilt = const_cast<SfxFilter*>(pFilter.get()); + + // Don't forget to set right UIName! + // Otherwise internal name is used as fallback ... + pFilt->SetUIName( sUIName ); + pFilt->SetDefaultTemplate( sDefaultTemplate ); + if( nFormatVersion ) + { + pFilt->SetVersion( nFormatVersion ); } + pFilt->SetURLPattern(sPattern); } void SfxFilterContainer::ReadFilters_Impl( bool bUpdate ) diff --git a/sfx2/source/bastyp/frmhtmlw.cxx b/sfx2/source/bastyp/frmhtmlw.cxx index 327cd406f7d6..f5ba6bcf4b50 100644 --- a/sfx2/source/bastyp/frmhtmlw.cxx +++ b/sfx2/source/bastyp/frmhtmlw.cxx @@ -133,100 +133,100 @@ void SfxFrameHTMLWriter::Out_DocInfo( SvStream& rStrm, const OUString& rBaseURL, sGenerator = sGenerator.replaceFirst( "%1", os ); OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_generator, sGenerator, false, eDestEnc, pNonConvertableChars ); - if( i_xDocProps.is() ) + if( !i_xDocProps.is() ) + return; + + // Reload + if( (i_xDocProps->getAutoloadSecs() != 0) || + !i_xDocProps->getAutoloadURL().isEmpty() ) { - // Reload - if( (i_xDocProps->getAutoloadSecs() != 0) || - !i_xDocProps->getAutoloadURL().isEmpty() ) + OUString sContent = OUString::number( + i_xDocProps->getAutoloadSecs() ); + + const OUString &rReloadURL = i_xDocProps->getAutoloadURL(); + if( !rReloadURL.isEmpty() ) { - OUString sContent = OUString::number( - i_xDocProps->getAutoloadSecs() ); + sContent += ";URL="; + sContent += URIHelper::simpleNormalizedMakeRelative( + rBaseURL, rReloadURL); + } - const OUString &rReloadURL = i_xDocProps->getAutoloadURL(); - if( !rReloadURL.isEmpty() ) - { - sContent += ";URL="; - sContent += URIHelper::simpleNormalizedMakeRelative( - rBaseURL, rReloadURL); - } + OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_refresh, sContent, true, + eDestEnc, pNonConvertableChars ); + } - OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_refresh, sContent, true, - eDestEnc, pNonConvertableChars ); - } + // Author + const OUString& rAuthor = i_xDocProps->getAuthor(); + if( !rAuthor.isEmpty() ) + OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_author, rAuthor, false, + eDestEnc, pNonConvertableChars ); - // Author - const OUString& rAuthor = i_xDocProps->getAuthor(); - if( !rAuthor.isEmpty() ) - OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_author, rAuthor, false, - eDestEnc, pNonConvertableChars ); + // created + ::util::DateTime uDT = i_xDocProps->getCreationDate(); + OUStringBuffer aBuffer; + ::sax::Converter::convertTimeOrDateTime(aBuffer, uDT); - // created - ::util::DateTime uDT = i_xDocProps->getCreationDate(); - OUStringBuffer aBuffer; - ::sax::Converter::convertTimeOrDateTime(aBuffer, uDT); + OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_created, aBuffer.makeStringAndClear(), false, + eDestEnc, pNonConvertableChars ); - OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_created, aBuffer.makeStringAndClear(), false, + // changedby + const OUString& rChangedBy = i_xDocProps->getModifiedBy(); + if( !rChangedBy.isEmpty() ) + OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_changedby, rChangedBy, false, eDestEnc, pNonConvertableChars ); - // changedby - const OUString& rChangedBy = i_xDocProps->getModifiedBy(); - if( !rChangedBy.isEmpty() ) - OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_changedby, rChangedBy, false, - eDestEnc, pNonConvertableChars ); + // changed + uDT = i_xDocProps->getModificationDate(); + ::sax::Converter::convertTimeOrDateTime(aBuffer, uDT); - // changed - uDT = i_xDocProps->getModificationDate(); - ::sax::Converter::convertTimeOrDateTime(aBuffer, uDT); + OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_changed, aBuffer.makeStringAndClear(), false, + eDestEnc, pNonConvertableChars ); - OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_changed, aBuffer.makeStringAndClear(), false, + // Subject + const OUString& rTheme = i_xDocProps->getSubject(); + if( !rTheme.isEmpty() ) + OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_classification, rTheme, false, eDestEnc, pNonConvertableChars ); - // Subject - const OUString& rTheme = i_xDocProps->getSubject(); - if( !rTheme.isEmpty() ) - OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_classification, rTheme, false, + // Description + const OUString& rComment = i_xDocProps->getDescription(); + if( !rComment.isEmpty() ) + OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_description, rComment, false, + eDestEnc, pNonConvertableChars); + + // Keywords + OUString Keywords = ::comphelper::string::convertCommaSeparated( + i_xDocProps->getKeywords()); + if( !Keywords.isEmpty() ) + OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_keywords, Keywords, false, + eDestEnc, pNonConvertableChars); + + uno::Reference < script::XTypeConverter > xConverter( script::Converter::create( + ::comphelper::getProcessComponentContext() ) ); + uno::Reference<beans::XPropertySet> xUserDefinedProps( + i_xDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySetInfo> xPropInfo = + xUserDefinedProps->getPropertySetInfo(); + DBG_ASSERT(xPropInfo.is(), "UserDefinedProperties Info is null"); + uno::Sequence<beans::Property> props = xPropInfo->getProperties(); + for (sal_Int32 i = 0; i < props.getLength(); ++i) + { + try + { + OUString name = props[i].Name; + uno::Any aStr = xConverter->convertToSimpleType( + xUserDefinedProps->getPropertyValue(name), + uno::TypeClass_STRING); + OUString str; + aStr >>= str; + OUString valstr(comphelper::string::stripEnd(str, ' ')); + OutMeta( rStrm, pIndent, name, valstr, false, eDestEnc, pNonConvertableChars ); - - // Description - const OUString& rComment = i_xDocProps->getDescription(); - if( !rComment.isEmpty() ) - OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_description, rComment, false, - eDestEnc, pNonConvertableChars); - - // Keywords - OUString Keywords = ::comphelper::string::convertCommaSeparated( - i_xDocProps->getKeywords()); - if( !Keywords.isEmpty() ) - OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_keywords, Keywords, false, - eDestEnc, pNonConvertableChars); - - uno::Reference < script::XTypeConverter > xConverter( script::Converter::create( - ::comphelper::getProcessComponentContext() ) ); - uno::Reference<beans::XPropertySet> xUserDefinedProps( - i_xDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW); - uno::Reference<beans::XPropertySetInfo> xPropInfo = - xUserDefinedProps->getPropertySetInfo(); - DBG_ASSERT(xPropInfo.is(), "UserDefinedProperties Info is null"); - uno::Sequence<beans::Property> props = xPropInfo->getProperties(); - for (sal_Int32 i = 0; i < props.getLength(); ++i) + } + catch (const uno::Exception&) { - try - { - OUString name = props[i].Name; - uno::Any aStr = xConverter->convertToSimpleType( - xUserDefinedProps->getPropertyValue(name), - uno::TypeClass_STRING); - OUString str; - aStr >>= str; - OUString valstr(comphelper::string::stripEnd(str, ' ')); - OutMeta( rStrm, pIndent, name, valstr, false, - eDestEnc, pNonConvertableChars ); - } - catch (const uno::Exception&) - { - // may happen with concurrent modification... - SAL_INFO("sfx", "SfxFrameHTMLWriter::Out_DocInfo: exception"); - } + // may happen with concurrent modification... + SAL_INFO("sfx", "SfxFrameHTMLWriter::Out_DocInfo: exception"); } } } diff --git a/sfx2/source/bastyp/progress.cxx b/sfx2/source/bastyp/progress.cxx index 0659564edf16..a1eb0394c1ec 100644 --- a/sfx2/source/bastyp/progress.cxx +++ b/sfx2/source/bastyp/progress.cxx @@ -268,35 +268,35 @@ void SfxProgress::Resume() { if( pImpl->pActiveProgress ) return; - if ( bSuspended ) - { - SAL_INFO("sfx.bastyp", "SfxProgress: resumed"); - if ( pImpl->xStatusInd.is() ) - { - pImpl->xStatusInd->start( pImpl->aText, pImpl->nMax ); - pImpl->xStatusInd->setValue( nVal ); - } + if ( !bSuspended ) + return; - if ( pImpl->bWaitMode ) - { - if ( pImpl->xObjSh.is() ) - { - for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst(pImpl->xObjSh.get() ); - pFrame; - pFrame = SfxViewFrame::GetNext( *pFrame, pImpl->xObjSh.get() ) ) - pFrame->GetWindow().EnterWait(); - } - } + SAL_INFO("sfx.bastyp", "SfxProgress: resumed"); + if ( pImpl->xStatusInd.is() ) + { + pImpl->xStatusInd->start( pImpl->aText, pImpl->nMax ); + pImpl->xStatusInd->setValue( nVal ); + } + if ( pImpl->bWaitMode ) + { if ( pImpl->xObjSh.is() ) { - SfxViewFrame *pFrame = SfxViewFrame::GetFirst(pImpl->xObjSh.get()); - if ( pFrame ) - pFrame->GetBindings().ENTERREGISTRATIONS(); + for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst(pImpl->xObjSh.get() ); + pFrame; + pFrame = SfxViewFrame::GetNext( *pFrame, pImpl->xObjSh.get() ) ) + pFrame->GetWindow().EnterWait(); } + } - bSuspended = false; + if ( pImpl->xObjSh.is() ) + { + SfxViewFrame *pFrame = SfxViewFrame::GetFirst(pImpl->xObjSh.get()); + if ( pFrame ) + pFrame->GetBindings().ENTERREGISTRATIONS(); } + + bSuspended = false; } @@ -313,30 +313,30 @@ void SfxProgress::Suspend() { if( pImpl->pActiveProgress ) return; - if ( !bSuspended ) - { - SAL_INFO("sfx.bastyp", "SfxProgress: suspended"); - bSuspended = true; + if ( bSuspended ) + return; - if ( pImpl->xStatusInd.is() ) - { - pImpl->xStatusInd->reset(); - } + SAL_INFO("sfx.bastyp", "SfxProgress: suspended"); + bSuspended = true; - if ( pImpl->xObjSh.is() ) - { - for ( SfxViewFrame *pFrame = - SfxViewFrame::GetFirst(pImpl->xObjSh.get()); - pFrame; - pFrame = SfxViewFrame::GetNext( *pFrame, pImpl->xObjSh.get() ) ) - pFrame->GetWindow().LeaveWait(); - } - if ( pImpl->xObjSh.is() ) - { - SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pImpl->xObjSh.get() ); - if ( pFrame ) - pFrame->GetBindings().LEAVEREGISTRATIONS(); - } + if ( pImpl->xStatusInd.is() ) + { + pImpl->xStatusInd->reset(); + } + + if ( pImpl->xObjSh.is() ) + { + for ( SfxViewFrame *pFrame = + SfxViewFrame::GetFirst(pImpl->xObjSh.get()); + pFrame; + pFrame = SfxViewFrame::GetNext( *pFrame, pImpl->xObjSh.get() ) ) + pFrame->GetWindow().LeaveWait(); + } + if ( pImpl->xObjSh.is() ) + { + SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pImpl->xObjSh.get() ); + if ( pFrame ) + pFrame->GetBindings().LEAVEREGISTRATIONS(); } } diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx index 1bf5a179bd0d..53f25cb95423 100644 --- a/sfx2/source/bastyp/sfxhtml.cxx +++ b/sfx2/source/bastyp/sfxhtml.cxx @@ -257,43 +257,43 @@ void SfxHTMLParser::GetScriptType_Impl( SvKeyValueIterator *pHTTPHeader ) { aScriptType = SVX_MACRO_LANGUAGE_JAVASCRIPT; eScriptType = JAVASCRIPT; - if( pHTTPHeader ) + if( !pHTTPHeader ) + return; + + SvKeyValue aKV; + for( bool bCont = pHTTPHeader->GetFirst( aKV ); bCont; + bCont = pHTTPHeader->GetNext( aKV ) ) { - SvKeyValue aKV; - for( bool bCont = pHTTPHeader->GetFirst( aKV ); bCont; - bCont = pHTTPHeader->GetNext( aKV ) ) + if( aKV.GetKey().equalsIgnoreAsciiCase( + OOO_STRING_SVTOOLS_HTML_META_content_script_type ) ) { - if( aKV.GetKey().equalsIgnoreAsciiCase( - OOO_STRING_SVTOOLS_HTML_META_content_script_type ) ) + if( !aKV.GetValue().isEmpty() ) { - if( !aKV.GetValue().isEmpty() ) + OUString aTmp( aKV.GetValue() ); + if( aTmp.startsWithIgnoreAsciiCase( "text/" ) ) + aTmp = aTmp.copy( 5 ); + else if( aTmp.startsWithIgnoreAsciiCase( "application/" ) ) + aTmp = aTmp.copy( 12 ); + else + break; + + if( aTmp.startsWithIgnoreAsciiCase( "x-" ) ) // MIME-experimental + { + aTmp = aTmp.copy( 2 ); + } + + if( aTmp.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_LG_starbasic ) ) + { + eScriptType = STARBASIC; + aScriptType = SVX_MACRO_LANGUAGE_STARBASIC; + } + if( !aTmp.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_LG_javascript ) ) { - OUString aTmp( aKV.GetValue() ); - if( aTmp.startsWithIgnoreAsciiCase( "text/" ) ) - aTmp = aTmp.copy( 5 ); - else if( aTmp.startsWithIgnoreAsciiCase( "application/" ) ) - aTmp = aTmp.copy( 12 ); - else - break; - - if( aTmp.startsWithIgnoreAsciiCase( "x-" ) ) // MIME-experimental - { - aTmp = aTmp.copy( 2 ); - } - - if( aTmp.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_LG_starbasic ) ) - { - eScriptType = STARBASIC; - aScriptType = SVX_MACRO_LANGUAGE_STARBASIC; - } - if( !aTmp.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_LG_javascript ) ) - { - eScriptType = EXTENDED_STYPE; - aScriptType = aTmp; - } + eScriptType = EXTENDED_STYPE; + aScriptType = aTmp; } - break; } + break; } } } diff --git a/sfx2/source/config/evntconf.cxx b/sfx2/source/config/evntconf.cxx index af680f3ff7ec..1e664d6371e3 100644 --- a/sfx2/source/config/evntconf.cxx +++ b/sfx2/source/config/evntconf.cxx @@ -192,30 +192,30 @@ static void PropagateEvent_Impl( SfxObjectShell const *pDoc, const OUString& aEv uno::UNO_QUERY ); } - if ( xSupplier.is() ) + if ( !xSupplier.is() ) + return; + + uno::Reference < container::XNameReplace > xEvents = xSupplier->getEvents(); + if ( !aEventName.isEmpty() ) { - uno::Reference < container::XNameReplace > xEvents = xSupplier->getEvents(); - if ( !aEventName.isEmpty() ) + uno::Any aEventData = CreateEventData_Impl( pMacro ); + + try + { + xEvents->replaceByName( aEventName, aEventData ); + } + catch( const css::lang::IllegalArgumentException& ) { - uno::Any aEventData = CreateEventData_Impl( pMacro ); - - try - { - xEvents->replaceByName( aEventName, aEventData ); - } - catch( const css::lang::IllegalArgumentException& ) - { - SAL_WARN( "sfx.config", "PropagateEvents_Impl: caught IllegalArgumentException" ); - } - catch( const css::container::NoSuchElementException& ) - { - SAL_WARN( "sfx.config", "PropagateEvents_Impl: caught NoSuchElementException" ); - } + SAL_WARN( "sfx.config", "PropagateEvents_Impl: caught IllegalArgumentException" ); } - else { - SAL_INFO( "sfx.config", "PropagateEvents_Impl: Got unknown event" ); + catch( const css::container::NoSuchElementException& ) + { + SAL_WARN( "sfx.config", "PropagateEvents_Impl: caught NoSuchElementException" ); } } + else { + SAL_INFO( "sfx.config", "PropagateEvents_Impl: Got unknown event" ); + } } diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 0a4e1fcc7169..2c8e71e96dee 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -317,51 +317,51 @@ void SfxBindings::Update pImpl->pSubBindings->Update( nId ); SfxStateCache* pCache = GetStateCache( nId ); - if ( pCache ) + if ( !pCache ) + return; + + pImpl->bInUpdate = true; + if ( pImpl->bMsgDirty ) { - pImpl->bInUpdate = true; - if ( pImpl->bMsgDirty ) + UpdateSlotServer_Impl(); + pCache = GetStateCache( nId ); + } + + if (pCache) + { + bool bInternalUpdate = true; + if( pCache->GetDispatch().is() && pCache->GetItemLink() ) { - UpdateSlotServer_Impl(); - pCache = GetStateCache( nId ); + pCache->SetCachedState(true); + bInternalUpdate = ( pCache->GetInternalController() != nullptr ); } - if (pCache) + if ( bInternalUpdate ) { - bool bInternalUpdate = true; - if( pCache->GetDispatch().is() && pCache->GetItemLink() ) + // Query Status + const SfxSlotServer* pMsgServer = pDispatcher ? pCache->GetSlotServer(*pDispatcher, pImpl->xProv) : nullptr; + if ( !pCache->IsControllerDirty() ) { - pCache->SetCachedState(true); - bInternalUpdate = ( pCache->GetInternalController() != nullptr ); + pImpl->bInUpdate = false; + InvalidateSlotsInMap_Impl(); + return; } - - if ( bInternalUpdate ) + if (!pMsgServer) { - // Query Status - const SfxSlotServer* pMsgServer = pDispatcher ? pCache->GetSlotServer(*pDispatcher, pImpl->xProv) : nullptr; - if ( !pCache->IsControllerDirty() ) - { - pImpl->bInUpdate = false; - InvalidateSlotsInMap_Impl(); - return; - } - if (!pMsgServer) - { - pCache->SetState(SfxItemState::DISABLED, nullptr); - pImpl->bInUpdate = false; - InvalidateSlotsInMap_Impl(); - return; - } - - Update_Impl(*pCache); + pCache->SetState(SfxItemState::DISABLED, nullptr); + pImpl->bInUpdate = false; + InvalidateSlotsInMap_Impl(); + return; } - pImpl->bAllDirty = false; + Update_Impl(*pCache); } - pImpl->bInUpdate = false; - InvalidateSlotsInMap_Impl(); + pImpl->bAllDirty = false; } + + pImpl->bInUpdate = false; + InvalidateSlotsInMap_Impl(); } @@ -370,19 +370,19 @@ void SfxBindings::Update() if ( pImpl->pSubBindings ) pImpl->pSubBindings->Update(); - if ( pDispatcher ) - { - if ( nRegLevel ) - return; + if ( !pDispatcher ) + return; - pImpl->bInUpdate = true; - pDispatcher->Flush(); - pDispatcher->Update_Impl(); - while ( !NextJob_Impl(nullptr) ) - ; // loop - pImpl->bInUpdate = false; - InvalidateSlotsInMap_Impl(); - } + if ( nRegLevel ) + return; + + pImpl->bInUpdate = true; + pDispatcher->Flush(); + pDispatcher->Update_Impl(); + while ( !NextJob_Impl(nullptr) ) + ; // loop + pImpl->bInUpdate = false; + InvalidateSlotsInMap_Impl(); } @@ -621,23 +621,23 @@ void SfxBindings::InvalidateShell // Find Level sal_uInt16 nLevel = pDispatcher->GetShellLevel(rSh); - if ( nLevel != USHRT_MAX ) + if ( nLevel == USHRT_MAX ) + return; + + for (std::unique_ptr<SfxStateCache>& pCache : pImpl->pCaches) { - for (std::unique_ptr<SfxStateCache>& pCache : pImpl->pCaches) - { - const SfxSlotServer *pMsgServer = - pCache->GetSlotServer(*pDispatcher, pImpl->xProv); - if ( pMsgServer && pMsgServer->GetShellLevel() == nLevel ) - pCache->Invalidate(false); - } - pImpl->nMsgPos = 0; - if ( !nRegLevel ) - { - pImpl->aAutoTimer.Stop(); - pImpl->aAutoTimer.SetTimeout(TIMEOUT_FIRST); - pImpl->aAutoTimer.Start(); - pImpl->bFirstRound = true; - } + const SfxSlotServer *pMsgServer = + pCache->GetSlotServer(*pDispatcher, pImpl->xProv); + if ( pMsgServer && pMsgServer->GetShellLevel() == nLevel ) + pCache->Invalidate(false); + } + pImpl->nMsgPos = 0; + if ( !nRegLevel ) + { + pImpl->aAutoTimer.Stop(); + pImpl->aAutoTimer.SetTimeout(TIMEOUT_FIRST); + pImpl->aAutoTimer.Start(); + pImpl->bFirstRound = true; } } @@ -692,22 +692,22 @@ void SfxBindings::Invalidate return; SfxStateCache* pCache = GetStateCache(nId); - if ( pCache ) - { - if ( bWithItem ) - pCache->ClearCache(); - pCache->Invalidate(bWithMsg); + if ( !pCache ) + return; - if ( !pDispatcher || pImpl->bAllDirty ) - return; + if ( bWithItem ) + pCache->ClearCache(); + pCache->Invalidate(bWithMsg); - pImpl->nMsgPos = std::min(GetSlotPos(nId), pImpl->nMsgPos); - if ( !nRegLevel ) - { - pImpl->aAutoTimer.Stop(); - pImpl->aAutoTimer.SetTimeout(TIMEOUT_FIRST); - pImpl->aAutoTimer.Start(); - } + if ( !pDispatcher || pImpl->bAllDirty ) + return; + + pImpl->nMsgPos = std::min(GetSlotPos(nId), pImpl->nMsgPos); + if ( !nRegLevel ) + { + pImpl->aAutoTimer.Stop(); + pImpl->aAutoTimer.SetTimeout(TIMEOUT_FIRST); + pImpl->aAutoTimer.Start(); } } @@ -1200,25 +1200,25 @@ void SfxBindings::UpdateControllers_Impl DBG_ASSERT( !pSlot || rCache.GetId() == pSlot->GetSlotId(), "SID mismatch" ); // bound until now, the Controller to update the Slot. - if (rCache.IsControllerDirty()) + if (!rCache.IsControllerDirty()) + return; + + if ( SfxItemState::DONTCARE == eState ) { - if ( SfxItemState::DONTCARE == eState ) - { - // ambiguous - rCache.SetState( SfxItemState::DONTCARE, INVALID_POOL_ITEM ); - } - else if ( SfxItemState::DEFAULT == eState && - SfxItemPool::IsSlot(rFound.nWhichId) ) - { - // no Status or Default but without Pool - SfxVoidItem aVoid(0); - rCache.SetState( SfxItemState::UNKNOWN, &aVoid ); - } - else if ( SfxItemState::DISABLED == eState ) - rCache.SetState(SfxItemState::DISABLED, nullptr); - else - rCache.SetState(SfxItemState::DEFAULT, pItem); + // ambiguous + rCache.SetState( SfxItemState::DONTCARE, INVALID_POOL_ITEM ); } + else if ( SfxItemState::DEFAULT == eState && + SfxItemPool::IsSlot(rFound.nWhichId) ) + { + // no Status or Default but without Pool + SfxVoidItem aVoid(0); + rCache.SetState( SfxItemState::UNKNOWN, &aVoid ); + } + else if ( SfxItemState::DISABLED == eState ) + rCache.SetState(SfxItemState::DISABLED, nullptr); + else + rCache.SetState(SfxItemState::DEFAULT, pItem); } IMPL_LINK( SfxBindings, NextJob, Timer *, pTimer, void ) @@ -1426,63 +1426,63 @@ void SfxBindings::LeaveRegistrations( const char *pFile, int nLine ) void SfxBindings::SetDispatcher( SfxDispatcher *pDisp ) { SfxDispatcher *pOldDispat = pDispatcher; - if ( pDisp != pDispatcher ) + if ( pDisp == pDispatcher ) + return; + + if ( pOldDispat ) { - if ( pOldDispat ) + SfxBindings* pBind = pOldDispat->GetBindings(); + while ( pBind ) { - SfxBindings* pBind = pOldDispat->GetBindings(); - while ( pBind ) - { - if ( pBind->pImpl->pSubBindings == this && pBind->pDispatcher != pDisp ) - pBind->SetSubBindings_Impl( nullptr ); - pBind = pBind->pImpl->pSubBindings; - } + if ( pBind->pImpl->pSubBindings == this && pBind->pDispatcher != pDisp ) + pBind->SetSubBindings_Impl( nullptr ); + pBind = pBind->pImpl->pSubBindings; } + } - pDispatcher = pDisp; + pDispatcher = pDisp; - css::uno::Reference < css::frame::XDispatchProvider > xProv; - if ( pDisp ) - xProv.set( pDisp->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); + css::uno::Reference < css::frame::XDispatchProvider > xProv; + if ( pDisp ) + xProv.set( pDisp->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); - SetDispatchProvider_Impl( xProv ); - InvalidateAll( true ); + SetDispatchProvider_Impl( xProv ); + InvalidateAll( true ); - if ( pDispatcher && !pOldDispat ) + if ( pDispatcher && !pOldDispat ) + { + if ( pImpl->pSubBindings && pImpl->pSubBindings->pDispatcher != pOldDispat ) { - if ( pImpl->pSubBindings && pImpl->pSubBindings->pDispatcher != pOldDispat ) - { - OSL_FAIL( "SubBindings already set before activating!" ); - pImpl->pSubBindings->ENTERREGISTRATIONS(); - } - LEAVEREGISTRATIONS(); + OSL_FAIL( "SubBindings already set before activating!" ); + pImpl->pSubBindings->ENTERREGISTRATIONS(); } - else if( !pDispatcher ) + LEAVEREGISTRATIONS(); + } + else if( !pDispatcher ) + { + ENTERREGISTRATIONS(); + if ( pImpl->pSubBindings && pImpl->pSubBindings->pDispatcher != pOldDispat ) { - ENTERREGISTRATIONS(); - if ( pImpl->pSubBindings && pImpl->pSubBindings->pDispatcher != pOldDispat ) - { - OSL_FAIL( "SubBindings still set even when deactivating!" ); - pImpl->pSubBindings->LEAVEREGISTRATIONS(); - } + OSL_FAIL( "SubBindings still set even when deactivating!" ); + pImpl->pSubBindings->LEAVEREGISTRATIONS(); } + } - Broadcast( SfxHint( SfxHintId::DataChanged ) ); + Broadcast( SfxHint( SfxHintId::DataChanged ) ); - if ( pDisp ) - { - SfxBindings* pBind = pDisp->GetBindings(); - while ( pBind && pBind != this ) - { - if ( !pBind->pImpl->pSubBindings ) - { - pBind->SetSubBindings_Impl( this ); - break; - } + if ( !pDisp ) + return; - pBind = pBind->pImpl->pSubBindings; - } + SfxBindings* pBind = pDisp->GetBindings(); + while ( pBind && pBind != this ) + { + if ( !pBind->pImpl->pSubBindings ) + { + pBind->SetSubBindings_Impl( this ); + break; } + + pBind = pBind->pImpl->pSubBindings; } } diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index b505412d3b4f..06c04362f763 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -314,72 +314,72 @@ void SfxDispatcher::Call_Impl(SfxShell& rShell, const SfxSlot &rSlot, SfxRequest SFX_STACK(SfxDispatcher::Call_Impl); // The slot may be called (meaning enabled) - if ( rSlot.IsMode(SfxSlotMode::FASTCALL) || rShell.CanExecuteSlot_Impl(rSlot) || rShell.IsConditionalFastCall(rReq)) + if ( !rSlot.IsMode(SfxSlotMode::FASTCALL) && !rShell.CanExecuteSlot_Impl(rSlot) && !rShell.IsConditionalFastCall(rReq) ) + return; + + if ( GetFrame() ) { - if ( GetFrame() ) - { - // Recording may start - css::uno::Reference< css::frame::XFrame > xFrame( - GetFrame()->GetFrame().GetFrameInterface(), - css::uno::UNO_QUERY); + // Recording may start + css::uno::Reference< css::frame::XFrame > xFrame( + GetFrame()->GetFrame().GetFrameInterface(), + css::uno::UNO_QUERY); - css::uno::Reference< css::beans::XPropertySet > xSet( - xFrame, - css::uno::UNO_QUERY); + css::uno::Reference< css::beans::XPropertySet > xSet( + xFrame, + css::uno::UNO_QUERY); - if ( xSet.is() ) - { - css::uno::Any aProp = xSet->getPropertyValue("DispatchRecorderSupplier"); - css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier; - css::uno::Reference< css::frame::XDispatchRecorder > xRecorder; - aProp >>= xSupplier; - if(xSupplier.is()) - xRecorder = xSupplier->getDispatchRecorder(); - - if ( bRecord && xRecorder.is() && !rSlot.IsMode(SfxSlotMode::NORECORD) ) - rReq.Record_Impl( rShell, rSlot, xRecorder, GetFrame() ); - } + if ( xSet.is() ) + { + css::uno::Any aProp = xSet->getPropertyValue("DispatchRecorderSupplier"); + css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier; + css::uno::Reference< css::frame::XDispatchRecorder > xRecorder; + aProp >>= xSupplier; + if(xSupplier.is()) + xRecorder = xSupplier->getDispatchRecorder(); + + if ( bRecord && xRecorder.is() && !rSlot.IsMode(SfxSlotMode::NORECORD) ) + rReq.Record_Impl( rShell, rSlot, xRecorder, GetFrame() ); } - // Get all that is needed, because the slot may not have survived the - // Execute if it is a 'pseudo slot' for macros or verbs. - bool bAutoUpdate = rSlot.IsMode(SfxSlotMode::AUTOUPDATE); + } + // Get all that is needed, because the slot may not have survived the + // Execute if it is a 'pseudo slot' for macros or verbs. + bool bAutoUpdate = rSlot.IsMode(SfxSlotMode::AUTOUPDATE); - // API-call parentheses and document-lock during the calls - { - // 'this' must respond in the Destructor - bool bThisDispatcherAlive = true; - bool *pOldInCallAliveFlag = xImp->pInCallAliveFlag; - xImp->pInCallAliveFlag = &bThisDispatcherAlive; + // API-call parentheses and document-lock during the calls + { + // 'this' must respond in the Destructor + bool bThisDispatcherAlive = true; + bool *pOldInCallAliveFlag = xImp->pInCallAliveFlag; + xImp->pInCallAliveFlag = &bThisDispatcherAlive; - SfxExecFunc pFunc = rSlot.GetExecFnc(); - rShell.CallExec( pFunc, rReq ); + SfxExecFunc pFunc = rSlot.GetExecFnc(); + rShell.CallExec( pFunc, rReq ); - // If 'this' is still alive - if ( bThisDispatcherAlive ) - xImp->pInCallAliveFlag = pOldInCallAliveFlag; - else + // If 'this' is still alive + if ( bThisDispatcherAlive ) + xImp->pInCallAliveFlag = pOldInCallAliveFlag; + else + { + if ( pOldInCallAliveFlag ) { - if ( pOldInCallAliveFlag ) - { - // also protect nested stack frames - *pOldInCallAliveFlag = false; - } - - // do nothing after this object is dead - return; + // also protect nested stack frames + *pOldInCallAliveFlag = false; } + + // do nothing after this object is dead + return; } + } - if ( rReq.IsDone() ) - { - SfxBindings *pBindings = GetBindings(); + if ( rReq.IsDone() ) + { + SfxBindings *pBindings = GetBindings(); - // When AutoUpdate update immediately - if ( bAutoUpdate && pBindings ) - { - pBindings->Invalidate(rSlot.GetSlotId()); - pBindings->Update(rSlot.GetSlotId()); - } + // When AutoUpdate update immediately + if ( bAutoUpdate && pBindings ) + { + pBindings->Invalidate(rSlot.GetSlotId()); + pBindings->Update(rSlot.GetSlotId()); } } } @@ -1075,58 +1075,58 @@ void SfxDispatcher::PostMsgHandler(std::unique_ptr<SfxRequest> pReq) SFX_STACK(SfxDispatcher::PostMsgHandler); // Has also the Pool not yet died? - if ( !pReq->IsCancelled() ) + if ( pReq->IsCancelled() ) + return; + + if ( !IsLocked() ) { - if ( !IsLocked() ) + Flush(); + SfxSlotServer aSvr; + if ( FindServer_(pReq->GetSlot(), aSvr ) ) // HACK(x), whatever that was supposed to mean { - Flush(); - SfxSlotServer aSvr; - if ( FindServer_(pReq->GetSlot(), aSvr ) ) // HACK(x), whatever that was supposed to mean - { - const SfxSlot *pSlot = aSvr.GetSlot(); - SfxShell *pSh = GetShell(aSvr.GetShellLevel()); + const SfxSlot *pSlot = aSvr.GetSlot(); + SfxShell *pSh = GetShell(aSvr.GetShellLevel()); - // When the pSlot is a "Pseudoslot" for macros or Verbs, it can - // be destroyed in the Call_Impl, thus do not use it anymore! - pReq->SetSynchronCall( false ); - Call_Impl( *pSh, *pSlot, *pReq, pReq->AllowsRecording() ); //! why bRecord? - } + // When the pSlot is a "Pseudoslot" for macros or Verbs, it can + // be destroyed in the Call_Impl, thus do not use it anymore! + pReq->SetSynchronCall( false ); + Call_Impl( *pSh, *pSlot, *pReq, pReq->AllowsRecording() ); //! why bRecord? } + } + else + { + if ( xImp->bLocked ) + xImp->aReqArr.emplace_back(std::move(pReq)); else - { - if ( xImp->bLocked ) - xImp->aReqArr.emplace_back(std::move(pReq)); - else - xImp->xPoster->Post(std::move(pReq)); - } + xImp->xPoster->Post(std::move(pReq)); } } void SfxDispatcher::SetMenu_Impl() { #if HAVE_FEATURE_DESKTOP - if ( xImp->pFrame ) + if ( !xImp->pFrame ) + return; + + SfxViewFrame* pTop = xImp->pFrame->GetTopViewFrame(); + if ( !pTop || pTop->GetBindings().GetDispatcher() != this ) + return; + + SfxFrame& rFrame = pTop->GetFrame(); + if ( !rFrame.IsMenuBarOn_Impl() ) + return; + + css::uno::Reference < css::beans::XPropertySet > xPropSet( rFrame.GetFrameInterface(), css::uno::UNO_QUERY ); + if ( xPropSet.is() ) { - SfxViewFrame* pTop = xImp->pFrame->GetTopViewFrame(); - if ( pTop && pTop->GetBindings().GetDispatcher() == this ) + css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; + css::uno::Any aValue = xPropSet->getPropertyValue("LayoutManager"); + aValue >>= xLayoutManager; + if ( xLayoutManager.is() ) { - SfxFrame& rFrame = pTop->GetFrame(); - if ( rFrame.IsMenuBarOn_Impl() ) - { - css::uno::Reference < css::beans::XPropertySet > xPropSet( rFrame.GetFrameInterface(), css::uno::UNO_QUERY ); - if ( xPropSet.is() ) - { - css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; - css::uno::Any aValue = xPropSet->getPropertyValue("LayoutManager"); - aValue >>= xLayoutManager; - if ( xLayoutManager.is() ) - { - OUString aMenuBarURL( "private:resource/menubar/menubar" ); - if ( !xLayoutManager->isElementVisible( aMenuBarURL ) ) - xLayoutManager->createElement( aMenuBarURL ); - } - } - } + OUString aMenuBarURL( "private:resource/menubar/menubar" ); + if ( !xLayoutManager->isElementVisible( aMenuBarURL ) ) + xLayoutManager->createElement( aMenuBarURL ); } } #endif @@ -1360,22 +1360,22 @@ void SfxDispatcher::Update_Impl_( bool bUIActive, bool bIsMDIApp, bool bIsIPOwne } } - if ( pTaskWin && ( bIsMDIApp || bIsIPOwner ) ) - { - bool bIsTaskActive = false; + if ( !pTaskWin || ( !bIsMDIApp && !bIsIPOwner ) ) + return; - SfxDispatcher *pActDispatcher = pTaskWin->GetBindings().GetDispatcher_Impl(); - if ( pActDispatcher && !bIsTaskActive ) - { - if ( this == pActDispatcher ) - bIsTaskActive = true; - } + bool bIsTaskActive = false; - if (bIsTaskActive && eStatBarId != StatusBarId::None && xImp->pFrame) - { - // internal frames also may control statusbar - xImp->pFrame->GetFrame().GetWorkWindow_Impl()->SetStatusBar_Impl(eStatBarId); - } + SfxDispatcher *pActDispatcher = pTaskWin->GetBindings().GetDispatcher_Impl(); + if ( pActDispatcher && !bIsTaskActive ) + { + if ( this == pActDispatcher ) + bIsTaskActive = true; + } + + if (bIsTaskActive && eStatBarId != StatusBarId::None && xImp->pFrame) + { + // internal frames also may control statusbar + xImp->pFrame->GetFrame().GetWorkWindow_Impl()->SetStatusBar_Impl(eStatBarId); } } diff --git a/sfx2/source/control/recentdocsviewitem.cxx b/sfx2/source/control/recentdocsviewitem.cxx index 361ea310f929..bee417f91c7f 100644 --- a/sfx2/source/control/recentdocsviewitem.cxx +++ b/sfx2/source/control/recentdocsviewitem.cxx @@ -205,19 +205,19 @@ void RecentDocsViewItem::OpenDocument() xDispatch = xDispatchProvider->queryDispatch(aTargetURL, "_default", 0); - if (xDispatch.is()) - { - // Call dispatch asynchronously as we can be destroyed while dispatch is - // executed. VCL is not able to survive this as it wants to call listeners - // after select!!! - sfx2::LoadRecentFile *const pLoadRecentFile = new sfx2::LoadRecentFile; - pLoadRecentFile->xDispatch = xDispatch; - pLoadRecentFile->aTargetURL = aTargetURL; - pLoadRecentFile->aArgSeq = aArgsList; - pLoadRecentFile->pView.set(&mrParent); - - Application::PostUserEvent(LINK(nullptr, sfx2::RecentDocsView, ExecuteHdl_Impl), pLoadRecentFile, true); - } + if (!xDispatch.is()) + return; + + // Call dispatch asynchronously as we can be destroyed while dispatch is + // executed. VCL is not able to survive this as it wants to call listeners + // after select!!! + sfx2::LoadRecentFile *const pLoadRecentFile = new sfx2::LoadRecentFile; + pLoadRecentFile->xDispatch = xDispatch; + pLoadRecentFile->aTargetURL = aTargetURL; + pLoadRecentFile->aArgSeq = aArgsList; + pLoadRecentFile->pView.set(&mrParent); + + Application::PostUserEvent(LINK(nullptr, sfx2::RecentDocsView, ExecuteHdl_Impl), pLoadRecentFile, true); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx index dbe72939e288..830579b306cb 100644 --- a/sfx2/source/control/request.cxx +++ b/sfx2/source/control/request.cxx @@ -157,20 +157,20 @@ SfxRequest::SfxRequest pImpl->SetPool( rOrig.pImpl->pPool ); // setup macro recording if it was in the original SfxRequest - if (rOrig.pImpl->pViewFrame && rOrig.pImpl->xRecorder.is()) + if (!rOrig.pImpl->pViewFrame || !rOrig.pImpl->xRecorder.is()) + return; + + nSlot = rOrig.nSlot; + pImpl->pViewFrame = rOrig.pImpl->pViewFrame; + if (pImpl->pViewFrame->GetDispatcher()->GetShellAndSlot_Impl(nSlot, &pImpl->pShell, &pImpl->pSlot, true, true)) { - nSlot = rOrig.nSlot; - pImpl->pViewFrame = rOrig.pImpl->pViewFrame; - if (pImpl->pViewFrame->GetDispatcher()->GetShellAndSlot_Impl(nSlot, &pImpl->pShell, &pImpl->pSlot, true, true)) - { - pImpl->SetPool( &pImpl->pShell->GetPool() ); - pImpl->xRecorder = SfxRequest::GetMacroRecorder(pImpl->pViewFrame); - pImpl->aTarget = pImpl->pShell->GetName(); - } - else - { - SAL_WARN("sfx", "Recording unsupported slot: " << pImpl->pPool->GetSlotId(nSlot)); - } + pImpl->SetPool( &pImpl->pShell->GetPool() ); + pImpl->xRecorder = SfxRequest::GetMacroRecorder(pImpl->pViewFrame); + pImpl->aTarget = pImpl->pShell->GetName(); + } + else + { + SAL_WARN("sfx", "Recording unsupported slot: " << pImpl->pPool->GetSlotId(nSlot)); } } @@ -335,42 +335,42 @@ void SfxRequest_Impl::Record OUString aCommand(".uno:"); aCommand += OUString( pSlot->GetUnoName(), strlen( pSlot->GetUnoName() ), RTL_TEXTENCODING_UTF8 ); OUString aCmd( aCommand ); - if(xRecorder.is()) + if(!xRecorder.is()) + return; + + uno::Reference< container::XIndexReplace > xReplace( xRecorder, uno::UNO_QUERY ); + if ( xReplace.is() && aCmd == ".uno:InsertText" ) { - uno::Reference< container::XIndexReplace > xReplace( xRecorder, uno::UNO_QUERY ); - if ( xReplace.is() && aCmd == ".uno:InsertText" ) + sal_Int32 nCount = xReplace->getCount(); + if ( nCount ) { - sal_Int32 nCount = xReplace->getCount(); - if ( nCount ) + frame::DispatchStatement aStatement; + uno::Any aElement = xReplace->getByIndex(nCount-1); + if ( (aElement >>= aStatement) && aStatement.aCommand == aCmd ) { - frame::DispatchStatement aStatement; - uno::Any aElement = xReplace->getByIndex(nCount-1); - if ( (aElement >>= aStatement) && aStatement.aCommand == aCmd ) - { - OUString aStr; - OUString aNew; - aStatement.aArgs[0].Value >>= aStr; - rArgs[0].Value >>= aNew; - aStr += aNew; - aStatement.aArgs[0].Value <<= aStr; - aElement <<= aStatement; - xReplace->replaceByIndex( nCount-1, aElement ); - return; - } + OUString aStr; + OUString aNew; + aStatement.aArgs[0].Value >>= aStr; + rArgs[0].Value >>= aNew; + aStr += aNew; + aStatement.aArgs[0].Value <<= aStr; + aElement <<= aStatement; + xReplace->replaceByIndex( nCount-1, aElement ); + return; } } + } - uno::Reference< util::XURLTransformer > xTransform = util::URLTransformer::create( xContext ); + uno::Reference< util::XURLTransformer > xTransform = util::URLTransformer::create( xContext ); - css::util::URL aURL; - aURL.Complete = aCmd; - xTransform->parseStrict(aURL); + css::util::URL aURL; + aURL.Complete = aCmd; + xTransform->parseStrict(aURL); - if (bDone) - xRecorder->recordDispatch(aURL,rArgs); - else - xRecorder->recordDispatchAsComment(aURL,rArgs); - } + if (bDone) + xRecorder->recordDispatch(aURL,rArgs); + else + xRecorder->recordDispatchAsComment(aURL,rArgs); } diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx index cf370b7dd238..47ad3b43efb9 100644 --- a/sfx2/source/control/shell.cxx +++ b/sfx2/source/control/shell.cxx @@ -595,26 +595,26 @@ void SfxShell::VerbExec(SfxRequest& rReq) { sal_uInt16 nId = rReq.GetSlot(); SfxViewShell *pViewShell = GetViewShell(); - if ( pViewShell ) + if ( !pViewShell ) + return; + + bool bReadOnly = pViewShell->GetObjectShell()->IsReadOnly(); + css::uno::Sequence < css::embed::VerbDescriptor > aList = pViewShell->GetVerbs(); + for (sal_Int32 n=0, nVerb=0; n<aList.getLength(); n++) { - bool bReadOnly = pViewShell->GetObjectShell()->IsReadOnly(); - css::uno::Sequence < css::embed::VerbDescriptor > aList = pViewShell->GetVerbs(); - for (sal_Int32 n=0, nVerb=0; n<aList.getLength(); n++) - { - // check for ReadOnly verbs - if ( bReadOnly && !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_NEVERDIRTIES) ) - continue; + // check for ReadOnly verbs + if ( bReadOnly && !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_NEVERDIRTIES) ) + continue; - // check for verbs that shouldn't appear in the menu - if ( !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU) ) - continue; + // check for verbs that shouldn't appear in the menu + if ( !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU) ) + continue; - if (nId == SID_VERB_START + nVerb++) - { - pViewShell->DoVerb(aList[n].VerbID); - rReq.Done(); - return; - } + if (nId == SID_VERB_START + nVerb++) + { + pViewShell->DoVerb(aList[n].VerbID); + rReq.Done(); + return; } } } diff --git a/sfx2/source/control/statcach.cxx b/sfx2/source/control/statcach.cxx index a190168ea1ce..080d5275a107 100644 --- a/sfx2/source/control/statcach.cxx +++ b/sfx2/source/control/statcach.cxx @@ -329,46 +329,46 @@ void SfxStateCache::SetState void SfxStateCache::SetVisibleState( bool bShow ) { - if ( bShow != bItemVisible ) - { - SfxItemState eState( SfxItemState::DEFAULT ); - const SfxPoolItem* pState( nullptr ); - bool bDeleteItem( false ); + if ( bShow == bItemVisible ) + return; - bItemVisible = bShow; - if ( bShow ) - { - if ( IsInvalidItem(pLastItem) || ( pLastItem == nullptr )) - { - pState = new SfxVoidItem( nId ); - bDeleteItem = true; - } - else - pState = pLastItem; + SfxItemState eState( SfxItemState::DEFAULT ); + const SfxPoolItem* pState( nullptr ); + bool bDeleteItem( false ); - eState = eLastState; - } - else + bItemVisible = bShow; + if ( bShow ) + { + if ( IsInvalidItem(pLastItem) || ( pLastItem == nullptr )) { - pState = new SfxVisibilityItem( nId, false ); + pState = new SfxVoidItem( nId ); bDeleteItem = true; } + else + pState = pLastItem; - // Update Controller - if ( !mxDispatch.is() && pController ) - { - for ( SfxControllerItem *pCtrl = pController; - pCtrl; - pCtrl = pCtrl->GetItemLink() ) - pCtrl->StateChanged( nId, eState, pState ); - } - - if ( pInternalController ) - pInternalController->StateChanged( nId, eState, pState ); + eState = eLastState; + } + else + { + pState = new SfxVisibilityItem( nId, false ); + bDeleteItem = true; + } - if ( bDeleteItem ) - delete pState; + // Update Controller + if ( !mxDispatch.is() && pController ) + { + for ( SfxControllerItem *pCtrl = pController; + pCtrl; + pCtrl = pCtrl->GetItemLink() ) + pCtrl->StateChanged( nId, eState, pState ); } + + if ( pInternalController ) + pInternalController->StateChanged( nId, eState, pState ); + + if ( bDeleteItem ) + delete pState; } @@ -439,23 +439,23 @@ void SfxStateCache::SetCachedState( bool bAlways ) // Only update if cached item exists and also able to process. // (If the State is sent, it must be ensured that a SlotServer is present, // see SfxControllerItem:: GetCoreMetric()) - if ( bAlways || ( !bItemDirty && !bSlotDirty ) ) + if ( !(bAlways || ( !bItemDirty && !bSlotDirty )) ) + return; + + // Update Controller + if ( !mxDispatch.is() && pController ) { - // Update Controller - if ( !mxDispatch.is() && pController ) - { - for ( SfxControllerItem *pCtrl = pController; - pCtrl; - pCtrl = pCtrl->GetItemLink() ) - pCtrl->StateChanged( nId, eLastState, pLastItem ); - } + for ( SfxControllerItem *pCtrl = pController; + pCtrl; + pCtrl = pCtrl->GetItemLink() ) + pCtrl->StateChanged( nId, eLastState, pLastItem ); + } - if ( pInternalController ) - static_cast<SfxDispatchController_Impl *>(pInternalController)->StateChanged( nId, eLastState, pLastItem, &aSlotServ ); + if ( pInternalController ) + static_cast<SfxDispatchController_Impl *>(pInternalController)->StateChanged( nId, eLastState, pLastItem, &aSlotServ ); - // Controller is now ok - bCtrlDirty = true; - } + // Controller is now ok + bCtrlDirty = true; } diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index 3ece5e8fe522..75d9296e390e 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -573,109 +573,109 @@ void TemplateLocalView::moveTemplates(const std::set<const ThumbnailViewItem*, s pTarget = pRegion.get(); } - if (pTarget) - { - bool refresh = false; + if (!pTarget) + return; - sal_uInt16 nTargetRegion = pTarget->mnRegionId; - sal_uInt16 nTargetIdx = mpDocTemplates->GetCount(nTargetRegion); // Next Idx - std::vector<sal_uInt16> aItemIds; // List of moved items ids (also prevents the invalidation of rItems iterators when we remove them as we go) + bool refresh = false; + + sal_uInt16 nTargetRegion = pTarget->mnRegionId; + sal_uInt16 nTargetIdx = mpDocTemplates->GetCount(nTargetRegion); // Next Idx + std::vector<sal_uInt16> aItemIds; // List of moved items ids (also prevents the invalidation of rItems iterators when we remove them as we go) - std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator aSelIter; - for ( aSelIter = rItems.begin(); aSelIter != rItems.end(); ++aSelIter, ++nTargetIdx ) + std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator aSelIter; + for ( aSelIter = rItems.begin(); aSelIter != rItems.end(); ++aSelIter, ++nTargetIdx ) + { + const TemplateViewItem *pViewItem = static_cast<const TemplateViewItem*>(*aSelIter); + sal_uInt16 nSrcRegionId = pViewItem->mnRegionId; + + for (auto const & pRegion : maRegions) { - const TemplateViewItem *pViewItem = static_cast<const TemplateViewItem*>(*aSelIter); - sal_uInt16 nSrcRegionId = pViewItem->mnRegionId; + if (pRegion->mnRegionId == nSrcRegionId) + pSrc = pRegion.get(); + } - for (auto const & pRegion : maRegions) - { - if (pRegion->mnRegionId == nSrcRegionId) - pSrc = pRegion.get(); - } + if(pSrc) + { + bool bCopy = !mpDocTemplates->Move(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId); - if(pSrc) + if (bCopy) { - bool bCopy = !mpDocTemplates->Move(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId); - - if (bCopy) + OUString sQuery = SfxResId(STR_MSG_QUERY_COPY).replaceFirst("$1", pViewItem->maTitle).replaceFirst("$2", + getRegionName(nTargetRegion)); + std::unique_ptr<weld::MessageDialog> xQueryDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, sQuery)); + if (xQueryDlg->run() != RET_YES) { - OUString sQuery = SfxResId(STR_MSG_QUERY_COPY).replaceFirst("$1", pViewItem->maTitle).replaceFirst("$2", - getRegionName(nTargetRegion)); - std::unique_ptr<weld::MessageDialog> xQueryDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, sQuery)); - if (xQueryDlg->run() != RET_YES) - { - OUString sMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE)); - sMsg = sMsg.replaceFirst("$1",getRegionName(nTargetRegion)); - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::Ok, sMsg.replaceFirst( "$2",pViewItem->maTitle))); - xBox->run(); + OUString sMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE)); + sMsg = sMsg.replaceFirst("$1",getRegionName(nTargetRegion)); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, sMsg.replaceFirst( "$2",pViewItem->maTitle))); + xBox->run(); - return; //return if any single move operation fails - } + return; //return if any single move operation fails + } - if (!mpDocTemplates->Copy(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId)) - { - continue; - } + if (!mpDocTemplates->Copy(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId)) + { + continue; } + } - // move template to destination + // move template to destination - TemplateItemProperties aTemplateItem; - aTemplateItem.nId = nTargetIdx + 1; - aTemplateItem.nDocId = nTargetIdx; - aTemplateItem.nRegionId = nTargetRegion; - aTemplateItem.aName = pViewItem->maTitle; - aTemplateItem.aPath = mpDocTemplates->GetPath(nTargetRegion,nTargetIdx); - aTemplateItem.aRegionName = pViewItem->maHelpText; - aTemplateItem.aThumbnail = pViewItem->maPreview1; + TemplateItemProperties aTemplateItem; + aTemplateItem.nId = nTargetIdx + 1; + aTemplateItem.nDocId = nTargetIdx; + aTemplateItem.nRegionId = nTargetRegion; + aTemplateItem.aName = pViewItem->maTitle; + aTemplateItem.aPath = mpDocTemplates->GetPath(nTargetRegion,nTargetIdx); + aTemplateItem.aRegionName = pViewItem->maHelpText; + aTemplateItem.aThumbnail = pViewItem->maPreview1; - pTarget->maTemplates.push_back(aTemplateItem); + pTarget->maTemplates.push_back(aTemplateItem); - if (!bCopy) - { - // remove template from region cached data + if (!bCopy) + { + // remove template from region cached data - std::vector<TemplateItemProperties>::iterator pPropIter; - for (pPropIter = pSrc->maTemplates.begin(); pPropIter != pSrc->maTemplates.end();) + std::vector<TemplateItemProperties>::iterator pPropIter; + for (pPropIter = pSrc->maTemplates.begin(); pPropIter != pSrc->maTemplates.end();) + { + if (pPropIter->nDocId == pViewItem->mnDocId) { - if (pPropIter->nDocId == pViewItem->mnDocId) - { - pPropIter = pSrc->maTemplates.erase(pPropIter); - aItemIds.push_back(pViewItem->mnDocId + 1);//mnid - } - else - { - // Keep region document id synchronized with SfxDocumentTemplates - if (pPropIter->nDocId > pViewItem->mnDocId) - --pPropIter->nDocId; - - ++pPropIter; - } + pPropIter = pSrc->maTemplates.erase(pPropIter); + aItemIds.push_back(pViewItem->mnDocId + 1);//mnid } - - // Keep view document id synchronized with SfxDocumentTemplates - for (auto const& item : mItemList) + else { - auto pTemplateViewItem = static_cast<TemplateViewItem*>(item.get()); - if (pTemplateViewItem->mnDocId > pViewItem->mnDocId) - --pTemplateViewItem->mnDocId; + // Keep region document id synchronized with SfxDocumentTemplates + if (pPropIter->nDocId > pViewItem->mnDocId) + --pPropIter->nDocId; + + ++pPropIter; } } - } - refresh = true; + // Keep view document id synchronized with SfxDocumentTemplates + for (auto const& item : mItemList) + { + auto pTemplateViewItem = static_cast<TemplateViewItem*>(item.get()); + if (pTemplateViewItem->mnDocId > pViewItem->mnDocId) + --pTemplateViewItem->mnDocId; + } + } } - // Remove items from the current view - for (auto const& itemId : aItemIds) - RemoveItem(itemId); + refresh = true; + } - if (refresh) - { - CalculateItemPositions(); - Invalidate(); - } + // Remove items from the current view + for (auto const& itemId : aItemIds) + RemoveItem(itemId); + + if (refresh) + { + CalculateItemPositions(); + Invalidate(); } } diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index e31b95e2226a..cea98594642b 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -1069,54 +1069,54 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId ) return; ThumbnailViewItem* pItem = mFilteredItemList[nItemPos]; - if (!pItem->isSelected()) - { - pItem->setSelection(true); - maItemStateHdl.Call(pItem); + if (pItem->isSelected()) + return; - if (IsReallyVisible() && IsUpdateMode()) - Invalidate(); + pItem->setSelection(true); + maItemStateHdl.Call(pItem); + + if (IsReallyVisible() && IsUpdateMode()) + Invalidate(); - bool bNewOut = IsReallyVisible() && IsUpdateMode(); + bool bNewOut = IsReallyVisible() && IsUpdateMode(); - // if necessary scroll to the visible area - if (mbScroll && nItemId && mnCols) + // if necessary scroll to the visible area + if (mbScroll && nItemId && mnCols) + { + sal_uInt16 nNewLine = static_cast<sal_uInt16>(nItemPos / mnCols); + if ( nNewLine < mnFirstLine ) { - sal_uInt16 nNewLine = static_cast<sal_uInt16>(nItemPos / mnCols); - if ( nNewLine < mnFirstLine ) - { - mnFirstLine = nNewLine; - } - else if ( nNewLine > static_cast<sal_uInt16>(mnFirstLine+mnVisLines-1) ) - { - mnFirstLine = static_cast<sal_uInt16>(nNewLine-mnVisLines+1); - } + mnFirstLine = nNewLine; } - - if ( bNewOut ) + else if ( nNewLine > static_cast<sal_uInt16>(mnFirstLine+mnVisLines-1) ) { - if ( IsReallyVisible() && IsUpdateMode() ) - Invalidate(); + mnFirstLine = static_cast<sal_uInt16>(nNewLine-mnVisLines+1); } + } - if( ImplHasAccessibleListeners() ) - { - // focus event (select) - ThumbnailViewItemAcc* pItemAcc = ThumbnailViewItemAcc::getImplementation( pItem->GetAccessible( false ) ); + if ( bNewOut ) + { + if ( IsReallyVisible() && IsUpdateMode() ) + Invalidate(); + } - if( pItemAcc ) - { - css::uno::Any aOldAny, aNewAny; - aNewAny <<= css::uno::Reference< css::uno::XInterface >( - static_cast< ::cppu::OWeakObject* >( pItemAcc )); - ImplFireAccessibleEvent( css::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny ); - } + if( !ImplHasAccessibleListeners() ) + return; - // selection event - css::uno::Any aOldAny, aNewAny; - ImplFireAccessibleEvent( css::accessibility::AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny ); - } + // focus event (select) + ThumbnailViewItemAcc* pItemAcc = ThumbnailViewItemAcc::getImplementation( pItem->GetAccessible( false ) ); + + if( pItemAcc ) + { + css::uno::Any aOldAny, aNewAny; + aNewAny <<= css::uno::Reference< css::uno::XInterface >( + static_cast< ::cppu::OWeakObject* >( pItemAcc )); + ImplFireAccessibleEvent( css::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny ); } + + // selection event + css::uno::Any aOldAny, aNewAny; + ImplFireAccessibleEvent( css::accessibility::AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny ); } bool ThumbnailView::IsItemSelected( sal_uInt16 nItemId ) const diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx index 7e1dde9ab9fa..1cb7a5e085c7 100644 --- a/sfx2/source/control/thumbnailviewacc.cxx +++ b/sfx2/source/control/thumbnailviewacc.cxx @@ -48,25 +48,25 @@ ThumbnailViewAcc::~ThumbnailViewAcc() void ThumbnailViewAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue ) { - if( nEventId ) - { - ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners ); - accessibility::AccessibleEventObject aEvtObject; + if( !nEventId ) + return; + + ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners ); + accessibility::AccessibleEventObject aEvtObject; - aEvtObject.EventId = nEventId; - aEvtObject.Source = static_cast<uno::XWeak*>(this); - aEvtObject.NewValue = rNewValue; - aEvtObject.OldValue = rOldValue; + aEvtObject.EventId = nEventId; + aEvtObject.Source = static_cast<uno::XWeak*>(this); + aEvtObject.NewValue = rNewValue; + aEvtObject.OldValue = rOldValue; - for (auto const& tmpListener : aTmpListeners) + for (auto const& tmpListener : aTmpListeners) + { + try + { + tmpListener->notifyEvent( aEvtObject ); + } + catch(const uno::Exception&) { - try - { - tmpListener->notifyEvent( aEvtObject ); - } - catch(const uno::Exception&) - { - } } } } @@ -265,22 +265,22 @@ void SAL_CALL ThumbnailViewAcc::addAccessibleEventListener( const uno::Reference ThrowIfDisposed(); ::osl::MutexGuard aGuard (m_aMutex); - if( rxListener.is() ) - { - bool bFound = false; + if( !rxListener.is() ) + return; + + bool bFound = false; - for (auto const& eventListener : mxEventListeners) + for (auto const& eventListener : mxEventListeners) + { + if( eventListener == rxListener ) { - if( eventListener == rxListener ) - { - bFound = true; - break; - } + bFound = true; + break; } - - if (!bFound) - mxEventListeners.push_back( rxListener ); } + + if (!bFound) + mxEventListeners.push_back( rxListener ); } void SAL_CALL ThumbnailViewAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener ) @@ -743,22 +743,22 @@ void SAL_CALL ThumbnailViewItemAcc::addAccessibleEventListener( const uno::Refer { const ::osl::MutexGuard aGuard( maMutex ); - if( rxListener.is() ) - { - bool bFound = false; + if( !rxListener.is() ) + return; + + bool bFound = false; - for (auto const& eventListener : mxEventListeners) + for (auto const& eventListener : mxEventListeners) + { + if( eventListener == rxListener ) { - if( eventListener == rxListener ) - { - bFound = true; - break; - } + bFound = true; + break; } - - if (!bFound) - mxEventListeners.push_back( rxListener ); } + + if (!bFound) + mxEventListeners.push_back( rxListener ); } void SAL_CALL ThumbnailViewItemAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener ) diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index bba646d4ff53..e6a590a4053f 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -359,79 +359,79 @@ void SfxDispatchController_Impl::addParametersToArgs( const css::util::URL& aURL { // Extract the parameter from the URL and put them into the property value sequence sal_Int32 nQueryIndex = aURL.Complete.indexOf( '?' ); - if ( nQueryIndex > 0 ) + if ( nQueryIndex <= 0 ) + return; + + OUString aParamString( aURL.Complete.copy( nQueryIndex+1 )); + sal_Int32 nIndex = 0; + do { - OUString aParamString( aURL.Complete.copy( nQueryIndex+1 )); - sal_Int32 nIndex = 0; - do - { - OUString aToken = aParamString.getToken( 0, '&', nIndex ); + OUString aToken = aParamString.getToken( 0, '&', nIndex ); - sal_Int32 nParmIndex = 0; - OUString aParamType; - OUString aParamName = aToken.getToken( 0, '=', nParmIndex ); - OUString aValue = (nParmIndex!=-1) ? aToken.getToken( 0, '=', nParmIndex ) : OUString(); + sal_Int32 nParmIndex = 0; + OUString aParamType; + OUString aParamName = aToken.getToken( 0, '=', nParmIndex ); + OUString aValue = (nParmIndex!=-1) ? aToken.getToken( 0, '=', nParmIndex ) : OUString(); - if ( !aParamName.isEmpty() ) - { - nParmIndex = 0; - aToken = aParamName; - aParamName = aToken.getToken( 0, ':', nParmIndex ); - aParamType = (nParmIndex!=-1) ? aToken.getToken( 0, ':', nParmIndex ) : OUString(); - } + if ( !aParamName.isEmpty() ) + { + nParmIndex = 0; + aToken = aParamName; + aParamName = aToken.getToken( 0, ':', nParmIndex ); + aParamType = (nParmIndex!=-1) ? aToken.getToken( 0, ':', nParmIndex ) : OUString(); + } - sal_Int32 nLen = rArgs.getLength(); - rArgs.realloc( nLen+1 ); - rArgs[nLen].Name = aParamName; + sal_Int32 nLen = rArgs.getLength(); + rArgs.realloc( nLen+1 ); + rArgs[nLen].Name = aParamName; - if ( aParamType.isEmpty() ) - { - // Default: LONG - rArgs[nLen].Value <<= aValue.toInt32(); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_BOOL], 4 )) - { - // sal_Bool support - rArgs[nLen].Value <<= aValue.toBoolean(); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_BYTE], 4 )) - { - // sal_uInt8 support - rArgs[nLen].Value <<= sal_Int8( aValue.toInt32() ); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_LONG], 4 )) - { - // LONG support - rArgs[nLen].Value <<= aValue.toInt32(); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_SHORT], 5 )) - { - // SHORT support - rArgs[nLen].Value <<= sal_Int16( aValue.toInt32() ); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_HYPER], 5 )) - { - // HYPER support - rArgs[nLen].Value <<= aValue.toInt64(); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_FLOAT], 5 )) - { - // FLOAT support - rArgs[nLen].Value <<= aValue.toFloat(); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_STRING], 6 )) - { - // STRING support - rArgs[nLen].Value <<= INetURLObject::decode( aValue, INetURLObject::DecodeMechanism::WithCharset ); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_DOUBLE], 6)) - { - // DOUBLE support - rArgs[nLen].Value <<= aValue.toDouble(); - } + if ( aParamType.isEmpty() ) + { + // Default: LONG + rArgs[nLen].Value <<= aValue.toInt32(); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_BOOL], 4 )) + { + // sal_Bool support + rArgs[nLen].Value <<= aValue.toBoolean(); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_BYTE], 4 )) + { + // sal_uInt8 support + rArgs[nLen].Value <<= sal_Int8( aValue.toInt32() ); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_LONG], 4 )) + { + // LONG support + rArgs[nLen].Value <<= aValue.toInt32(); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_SHORT], 5 )) + { + // SHORT support + rArgs[nLen].Value <<= sal_Int16( aValue.toInt32() ); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_HYPER], 5 )) + { + // HYPER support + rArgs[nLen].Value <<= aValue.toInt64(); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_FLOAT], 5 )) + { + // FLOAT support + rArgs[nLen].Value <<= aValue.toFloat(); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_STRING], 6 )) + { + // STRING support + rArgs[nLen].Value <<= INetURLObject::decode( aValue, INetURLObject::DecodeMechanism::WithCharset ); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_DOUBLE], 6)) + { + // DOUBLE support + rArgs[nLen].Value <<= aValue.toDouble(); } - while ( nIndex >= 0 ); } + while ( nIndex >= 0 ); } MapUnit SfxDispatchController_Impl::GetCoreMetric( SfxItemPool const & rPool, sal_uInt16 nSlotId ) @@ -612,201 +612,201 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, SolarMutexGuard aGuard; if ( - pDispatch && + !(pDispatch && ( (aURL.Protocol == ".uno:" && aURL.Path == aDispatchURL.Path) || (aURL.Protocol == "slot:" && aURL.Path.toInt32() == GetId()) - ) + )) ) - { - if ( !pDispatcher && pBindings ) - pDispatcher = GetBindings().GetDispatcher_Impl(); + return; + + if ( !pDispatcher && pBindings ) + pDispatcher = GetBindings().GetDispatcher_Impl(); - css::uno::Sequence< css::beans::PropertyValue > lNewArgs; - sal_Int32 nCount = aArgs.getLength(); + css::uno::Sequence< css::beans::PropertyValue > lNewArgs; + sal_Int32 nCount = aArgs.getLength(); - // Support for URL based arguments - INetURLObject aURLObj( aURL.Complete ); - if ( aURLObj.HasParam() ) - addParametersToArgs( aURL, lNewArgs ); + // Support for URL based arguments + INetURLObject aURLObj( aURL.Complete ); + if ( aURLObj.HasParam() ) + addParametersToArgs( aURL, lNewArgs ); - // Try to find call mode and frame name inside given arguments... - SfxCallMode nCall = SfxCallMode::RECORD; - sal_Int32 nMarkArg = -1; + // Try to find call mode and frame name inside given arguments... + SfxCallMode nCall = SfxCallMode::RECORD; + sal_Int32 nMarkArg = -1; - // Filter arguments which shouldn't be part of the sequence property value - sal_uInt16 nModifier(0); - std::vector< css::beans::PropertyValue > aAddArgs; - for( sal_Int32 n=0; n<nCount; n++ ) + // Filter arguments which shouldn't be part of the sequence property value + sal_uInt16 nModifier(0); + std::vector< css::beans::PropertyValue > aAddArgs; + for( sal_Int32 n=0; n<nCount; n++ ) + { + const css::beans::PropertyValue& rProp = aArgs[n]; + if( rProp.Name == "SynchronMode" ) { - const css::beans::PropertyValue& rProp = aArgs[n]; - if( rProp.Name == "SynchronMode" ) - { - bool bTemp; - if( rProp.Value >>= bTemp ) - nCall = bTemp ? SfxCallMode::SYNCHRON : SfxCallMode::ASYNCHRON; - } - else if( rProp.Name == "Bookmark" ) - { - nMarkArg = n; - aAddArgs.push_back( aArgs[n] ); - } - else if( rProp.Name == "KeyModifier" ) - rProp.Value >>= nModifier; - else - aAddArgs.push_back( aArgs[n] ); + bool bTemp; + if( rProp.Value >>= bTemp ) + nCall = bTemp ? SfxCallMode::SYNCHRON : SfxCallMode::ASYNCHRON; } - - // Add needed arguments to sequence property value - sal_uInt32 nAddArgs = aAddArgs.size(); - if ( nAddArgs > 0 ) + else if( rProp.Name == "Bookmark" ) { - sal_uInt32 nIndex( lNewArgs.getLength() ); - - lNewArgs.realloc( lNewArgs.getLength()+aAddArgs.size() ); - for ( sal_uInt32 i = 0; i < nAddArgs; i++ ) - lNewArgs[nIndex++] = aAddArgs[i]; + nMarkArg = n; + aAddArgs.push_back( aArgs[n] ); } + else if( rProp.Name == "KeyModifier" ) + rProp.Value >>= nModifier; + else + aAddArgs.push_back( aArgs[n] ); + } - // Overwrite possible detected synchron argument, if real listener exists (currently no other way) - if ( rListener.is() ) - nCall = SfxCallMode::SYNCHRON; + // Add needed arguments to sequence property value + sal_uInt32 nAddArgs = aAddArgs.size(); + if ( nAddArgs > 0 ) + { + sal_uInt32 nIndex( lNewArgs.getLength() ); - if( GetId() == SID_JUMPTOMARK && nMarkArg == - 1 ) - { - // we offer dispatches for SID_JUMPTOMARK if the URL points to a bookmark inside the document - // so we must retrieve this as an argument from the parsed URL - lNewArgs.realloc( lNewArgs.getLength()+1 ); - nMarkArg = lNewArgs.getLength()-1; - lNewArgs[nMarkArg].Name = "Bookmark"; - lNewArgs[nMarkArg].Value <<= aURL.Mark; - } + lNewArgs.realloc( lNewArgs.getLength()+aAddArgs.size() ); + for ( sal_uInt32 i = 0; i < nAddArgs; i++ ) + lNewArgs[nIndex++] = aAddArgs[i]; + } - css::uno::Reference< css::frame::XFrame > xFrameRef(xFrame.get(), css::uno::UNO_QUERY); - if (! xFrameRef.is() && pDispatcher) - { - SfxViewFrame* pViewFrame = pDispatcher->GetFrame(); - if (pViewFrame) - xFrameRef = pViewFrame->GetFrame().GetFrameInterface(); - } + // Overwrite possible detected synchron argument, if real listener exists (currently no other way) + if ( rListener.is() ) + nCall = SfxCallMode::SYNCHRON; - bool bSuccess = false; - const SfxPoolItem* pItem = nullptr; - MapUnit eMapUnit( MapUnit::Map100thMM ); + if( GetId() == SID_JUMPTOMARK && nMarkArg == - 1 ) + { + // we offer dispatches for SID_JUMPTOMARK if the URL points to a bookmark inside the document + // so we must retrieve this as an argument from the parsed URL + lNewArgs.realloc( lNewArgs.getLength()+1 ); + nMarkArg = lNewArgs.getLength()-1; + lNewArgs[nMarkArg].Name = "Bookmark"; + lNewArgs[nMarkArg].Value <<= aURL.Mark; + } - // Extra scope so that aInternalSet is destroyed before - // rListener->dispatchFinished potentially calls - // framework::Desktop::terminate -> SfxApplication::Deinitialize -> - // ~CntItemPool: - if (pDispatcher) - { - SfxAllItemSet aInternalSet( SfxGetpApp()->GetPool() ); - if (xFrameRef.is()) // an empty set is no problem ... but an empty frame reference can be a problem ! - aInternalSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrameRef ) ); + css::uno::Reference< css::frame::XFrame > xFrameRef(xFrame.get(), css::uno::UNO_QUERY); + if (! xFrameRef.is() && pDispatcher) + { + SfxViewFrame* pViewFrame = pDispatcher->GetFrame(); + if (pViewFrame) + xFrameRef = pViewFrame->GetFrame().GetFrameInterface(); + } - SfxShell* pShell( nullptr ); - // #i102619# Retrieve metric from shell before execution - the shell could be destroyed after execution - if ( pDispatcher->GetBindings() ) + bool bSuccess = false; + const SfxPoolItem* pItem = nullptr; + MapUnit eMapUnit( MapUnit::Map100thMM ); + + // Extra scope so that aInternalSet is destroyed before + // rListener->dispatchFinished potentially calls + // framework::Desktop::terminate -> SfxApplication::Deinitialize -> + // ~CntItemPool: + if (pDispatcher) + { + SfxAllItemSet aInternalSet( SfxGetpApp()->GetPool() ); + if (xFrameRef.is()) // an empty set is no problem ... but an empty frame reference can be a problem ! + aInternalSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrameRef ) ); + + SfxShell* pShell( nullptr ); + // #i102619# Retrieve metric from shell before execution - the shell could be destroyed after execution + if ( pDispatcher->GetBindings() ) + { + if ( !pDispatcher->IsLocked() ) { - if ( !pDispatcher->IsLocked() ) + const SfxSlot *pSlot = nullptr; + if ( pDispatcher->GetShellAndSlot_Impl( GetId(), &pShell, &pSlot, false, false ) ) { - const SfxSlot *pSlot = nullptr; - if ( pDispatcher->GetShellAndSlot_Impl( GetId(), &pShell, &pSlot, false, false ) ) + if ( bMasterSlave ) { - if ( bMasterSlave ) - { - // Extract slave command and add argument to the args list. Master slot MUST - // have a argument that has the same name as the master slot and type is SfxStringItem. - sal_Int32 nIndex = lNewArgs.getLength(); - lNewArgs.realloc( nIndex+1 ); - lNewArgs[nIndex].Name = OUString::createFromAscii( pSlot->pUnoName ); - lNewArgs[nIndex].Value <<= SfxDispatchController_Impl::getSlaveCommand( aDispatchURL ); - } + // Extract slave command and add argument to the args list. Master slot MUST + // have a argument that has the same name as the master slot and type is SfxStringItem. + sal_Int32 nIndex = lNewArgs.getLength(); + lNewArgs.realloc( nIndex+1 ); + lNewArgs[nIndex].Name = OUString::createFromAscii( pSlot->pUnoName ); + lNewArgs[nIndex].Value <<= SfxDispatchController_Impl::getSlaveCommand( aDispatchURL ); + } - eMapUnit = GetCoreMetric( pShell->GetPool(), GetId() ); - std::unique_ptr<SfxAllItemSet> xSet(new SfxAllItemSet(pShell->GetPool())); - TransformParameters(GetId(), lNewArgs, *xSet, pSlot); - if (xSet->Count()) - { - // execute with arguments - call directly - pItem = pDispatcher->Execute(GetId(), nCall, xSet.get(), &aInternalSet, nModifier); - if ( pItem != nullptr ) - { - if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem)) - bSuccess = pBoolItem->GetValue(); - else if ( !pItem->IsVoidItem() ) - bSuccess = true; // all other types are true - } - // else bSuccess = false look to line 664 it is false - } - else + eMapUnit = GetCoreMetric( pShell->GetPool(), GetId() ); + std::unique_ptr<SfxAllItemSet> xSet(new SfxAllItemSet(pShell->GetPool())); + TransformParameters(GetId(), lNewArgs, *xSet, pSlot); + if (xSet->Count()) + { + // execute with arguments - call directly + pItem = pDispatcher->Execute(GetId(), nCall, xSet.get(), &aInternalSet, nModifier); + if ( pItem != nullptr ) { - // Be sure to delete this before we send a dispatch - // request, which will destroy the current shell. - xSet.reset(); - - // execute using bindings, enables support for toggle/enum etc. - SfxRequest aReq( GetId(), nCall, pShell->GetPool() ); - aReq.SetModifier( nModifier ); - aReq.SetInternalArgs_Impl(aInternalSet); - pDispatcher->GetBindings()->Execute_Impl( aReq, pSlot, pShell ); - pItem = aReq.GetReturnValue(); - bSuccess = aReq.IsDone() || pItem != nullptr; + if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem)) + bSuccess = pBoolItem->GetValue(); + else if ( !pItem->IsVoidItem() ) + bSuccess = true; // all other types are true } + // else bSuccess = false look to line 664 it is false } else - SAL_INFO("sfx.control", "MacroPlayer: Unknown slot dispatched!"); - } - } - else - { - eMapUnit = GetCoreMetric( SfxGetpApp()->GetPool(), GetId() ); - // AppDispatcher - SfxAllItemSet aSet( SfxGetpApp()->GetPool() ); - TransformParameters( GetId(), lNewArgs, aSet ); - - if ( aSet.Count() ) - pItem = pDispatcher->Execute(GetId(), nCall, &aSet, &aInternalSet, nModifier); - else - // SfxRequests take empty sets as argument sets, GetArgs() returning non-zero! - pItem = pDispatcher->Execute(GetId(), nCall, nullptr, &aInternalSet, nModifier); - - // no bindings, no invalidate ( usually done in SfxDispatcher::Call_Impl()! ) - if (SfxApplication* pApp = SfxApplication::Get()) - { - SfxDispatcher* pAppDispat = pApp->GetAppDispatcher_Impl(); - if ( pAppDispat ) { - const SfxPoolItem* pState=nullptr; - SfxItemState eState = pDispatcher->QueryState( GetId(), pState ); - StateChanged( GetId(), eState, pState ); + // Be sure to delete this before we send a dispatch + // request, which will destroy the current shell. + xSet.reset(); + + // execute using bindings, enables support for toggle/enum etc. + SfxRequest aReq( GetId(), nCall, pShell->GetPool() ); + aReq.SetModifier( nModifier ); + aReq.SetInternalArgs_Impl(aInternalSet); + pDispatcher->GetBindings()->Execute_Impl( aReq, pSlot, pShell ); + pItem = aReq.GetReturnValue(); + bSuccess = aReq.IsDone() || pItem != nullptr; } } - - bSuccess = (pItem != nullptr); + else + SAL_INFO("sfx.control", "MacroPlayer: Unknown slot dispatched!"); } } - - if ( rListener.is() ) + else { - css::frame::DispatchResultEvent aEvent; - if ( bSuccess ) - aEvent.State = css::frame::DispatchResultState::SUCCESS; + eMapUnit = GetCoreMetric( SfxGetpApp()->GetPool(), GetId() ); + // AppDispatcher + SfxAllItemSet aSet( SfxGetpApp()->GetPool() ); + TransformParameters( GetId(), lNewArgs, aSet ); + + if ( aSet.Count() ) + pItem = pDispatcher->Execute(GetId(), nCall, &aSet, &aInternalSet, nModifier); else - aEvent.State = css::frame::DispatchResultState::FAILURE; + // SfxRequests take empty sets as argument sets, GetArgs() returning non-zero! + pItem = pDispatcher->Execute(GetId(), nCall, nullptr, &aInternalSet, nModifier); - aEvent.Source = static_cast<css::frame::XDispatch*>(pDispatch); - if ( bSuccess && pItem && !pItem->IsVoidItem() ) + // no bindings, no invalidate ( usually done in SfxDispatcher::Call_Impl()! ) + if (SfxApplication* pApp = SfxApplication::Get()) { - sal_uInt16 nSubId( 0 ); - if ( eMapUnit == MapUnit::MapTwip ) - nSubId |= CONVERT_TWIPS; - pItem->QueryValue( aEvent.Result, static_cast<sal_uInt8>(nSubId) ); + SfxDispatcher* pAppDispat = pApp->GetAppDispatcher_Impl(); + if ( pAppDispat ) + { + const SfxPoolItem* pState=nullptr; + SfxItemState eState = pDispatcher->QueryState( GetId(), pState ); + StateChanged( GetId(), eState, pState ); + } } - rListener->dispatchFinished( aEvent ); + bSuccess = (pItem != nullptr); } } + + if ( !rListener.is() ) + return; + + css::frame::DispatchResultEvent aEvent; + if ( bSuccess ) + aEvent.State = css::frame::DispatchResultState::SUCCESS; + else + aEvent.State = css::frame::DispatchResultState::FAILURE; + + aEvent.Source = static_cast<css::frame::XDispatch*>(pDispatch); + if ( bSuccess && pItem && !pItem->IsVoidItem() ) + { + sal_uInt16 nSubId( 0 ); + if ( eMapUnit == MapUnit::MapTwip ) + nSubId |= CONVERT_TWIPS; + pItem->QueryValue( aEvent.Result, static_cast<sal_uInt8>(nSubId) ); + } + + rListener->dispatchFinished( aEvent ); } SfxDispatcher* SfxDispatchController_Impl::GetDispatcher() @@ -909,57 +909,57 @@ void SfxDispatchController_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eSt pLastState = pState; } - if (bNotify) - { - css::uno::Any aState; - if ( ( eState >= SfxItemState::DEFAULT ) && pState && !IsInvalidItem( pState ) && !pState->IsVoidItem() ) - { - // Retrieve metric from pool to have correct sub ID when calling QueryValue - sal_uInt16 nSubId( 0 ); - MapUnit eMapUnit( MapUnit::Map100thMM ); - - // retrieve the core metric - // it's enough to check the objectshell, the only shell that does not use the pool of the document - // is SfxViewFrame, but it hasn't any metric parameters - // TODO/LATER: what about the FormShell? Does it use any metric data?! Perhaps it should use the Pool of the document! - if ( pSlotServ && pDispatcher ) - { - SfxShell* pShell = pDispatcher->GetShell( pSlotServ->GetShellLevel() ); - DBG_ASSERT( pShell, "Can't get core metric without shell!" ); - if ( pShell ) - eMapUnit = GetCoreMetric( pShell->GetPool(), nSID ); - } + if (!bNotify) + return; - if ( eMapUnit == MapUnit::MapTwip ) - nSubId |= CONVERT_TWIPS; + css::uno::Any aState; + if ( ( eState >= SfxItemState::DEFAULT ) && pState && !IsInvalidItem( pState ) && !pState->IsVoidItem() ) + { + // Retrieve metric from pool to have correct sub ID when calling QueryValue + sal_uInt16 nSubId( 0 ); + MapUnit eMapUnit( MapUnit::Map100thMM ); - pState->QueryValue( aState, static_cast<sal_uInt8>(nSubId) ); - } - else if ( eState == SfxItemState::DONTCARE ) + // retrieve the core metric + // it's enough to check the objectshell, the only shell that does not use the pool of the document + // is SfxViewFrame, but it hasn't any metric parameters + // TODO/LATER: what about the FormShell? Does it use any metric data?! Perhaps it should use the Pool of the document! + if ( pSlotServ && pDispatcher ) { - // Use special uno struct to transport don't care state - css::frame::status::ItemStatus aItemStatus; - aItemStatus.State = css::frame::status::ItemState::DONT_CARE; - aState <<= aItemStatus; + SfxShell* pShell = pDispatcher->GetShell( pSlotServ->GetShellLevel() ); + DBG_ASSERT( pShell, "Can't get core metric without shell!" ); + if ( pShell ) + eMapUnit = GetCoreMetric( pShell->GetPool(), nSID ); } - css::frame::FeatureStateEvent aEvent; - aEvent.FeatureURL = aDispatchURL; - aEvent.Source = static_cast<css::frame::XDispatch*>(pDispatch); - aEvent.IsEnabled = eState != SfxItemState::DISABLED; - aEvent.Requery = false; - aEvent.State = aState; + if ( eMapUnit == MapUnit::MapTwip ) + nSubId |= CONVERT_TWIPS; - if (pDispatcher && pDispatcher->GetFrame()) - { - InterceptLOKStateChangeEvent(pDispatcher->GetFrame(), aEvent, pState); - } + pState->QueryValue( aState, static_cast<sal_uInt8>(nSubId) ); + } + else if ( eState == SfxItemState::DONTCARE ) + { + // Use special uno struct to transport don't care state + css::frame::status::ItemStatus aItemStatus; + aItemStatus.State = css::frame::status::ItemState::DONT_CARE; + aState <<= aItemStatus; + } - for (const OUString& rName: pDispatch->GetListeners().getContainedTypes()) - { - if (rName == aDispatchURL.Main || rName == aDispatchURL.Complete) - sendStatusChanged(rName, aEvent); - } + css::frame::FeatureStateEvent aEvent; + aEvent.FeatureURL = aDispatchURL; + aEvent.Source = static_cast<css::frame::XDispatch*>(pDispatch); + aEvent.IsEnabled = eState != SfxItemState::DISABLED; + aEvent.Requery = false; + aEvent.State = aState; + + if (pDispatcher && pDispatcher->GetFrame()) + { + InterceptLOKStateChangeEvent(pDispatcher->GetFrame(), aEvent, pState); + } + + for (const OUString& rName: pDispatch->GetListeners().getContainedTypes()) + { + if (rName == aDispatchURL.Main || rName == aDispatchURL.Complete) + sendStatusChanged(rName, aEvent); } } diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx index 453ccfad72c4..962f706775a8 100644 --- a/sfx2/source/dialog/backingcomp.cxx +++ b/sfx2/source/dialog/backingcomp.cxx @@ -405,24 +405,24 @@ void SAL_CALL BackingComp::attachFrame( /*IN*/ const css::uno::Reference< css::f } // Set a minimum size for Start Center - if( pParent && pBack ) - { - long nMenuHeight = 0; - vcl::Window* pMenu = pParent->GetWindow(GetWindowType::Next); - if( pMenu ) - nMenuHeight = pMenu->GetSizePixel().Height(); - - m_aInitialWindowMinSize = pParent->GetMinOutputSizePixel(); - if (!m_aInitialWindowMinSize.Width()) - m_aInitialWindowMinSize.AdjustWidth(1); - if (!m_aInitialWindowMinSize.Height()) - m_aInitialWindowMinSize.AdjustHeight(1); - - pParent->SetMinOutputSizePixel( - Size( - pBack->get_width_request(), - pBack->get_height_request() + nMenuHeight)); - } + if( !pParent || !pBack ) + return; + + long nMenuHeight = 0; + vcl::Window* pMenu = pParent->GetWindow(GetWindowType::Next); + if( pMenu ) + nMenuHeight = pMenu->GetSizePixel().Height(); + + m_aInitialWindowMinSize = pParent->GetMinOutputSizePixel(); + if (!m_aInitialWindowMinSize.Width()) + m_aInitialWindowMinSize.AdjustWidth(1); + if (!m_aInitialWindowMinSize.Height()) + m_aInitialWindowMinSize.AdjustHeight(1); + + pParent->SetMinOutputSizePixel( + Size( + pBack->get_width_request(), + pBack->get_height_request() + nMenuHeight)); /* } SAFE */ } @@ -729,24 +729,24 @@ css::uno::Sequence < css::uno::Reference< css::frame::XDispatch > > SAL_CALL Bac void SAL_CALL BackingComp::dispatch( const css::util::URL& aURL, const css::uno::Sequence < css::beans::PropertyValue >& /*lArgs*/ ) { // vnd.org.libreoffice.recentdocs:ClearRecentFileList - clear recent files - if ( aURL.Path == "ClearRecentFileList" ) + if ( aURL.Path != "ClearRecentFileList" ) + return; + + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(m_xWindow); + BackingWindow* pBack = dynamic_cast<BackingWindow*>(pWindow.get()); + if( !pBack ) + return; + + pBack->clearRecentFileList(); + + // Recalculate minimum width + css::uno::Reference< css::awt::XWindow > xParentWindow = m_xFrame->getContainerWindow(); + VclPtr< WorkWindow > pParent = static_cast<WorkWindow*>(VCLUnoHelper::GetWindow(xParentWindow).get()); + if( pParent ) { - VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(m_xWindow); - BackingWindow* pBack = dynamic_cast<BackingWindow*>(pWindow.get()); - if( pBack ) - { - pBack->clearRecentFileList(); - - // Recalculate minimum width - css::uno::Reference< css::awt::XWindow > xParentWindow = m_xFrame->getContainerWindow(); - VclPtr< WorkWindow > pParent = static_cast<WorkWindow*>(VCLUnoHelper::GetWindow(xParentWindow).get()); - if( pParent ) - { - pParent->SetMinOutputSizePixel( Size( - pBack->get_width_request(), - pParent->GetMinOutputSizePixel().Height()) ); - } - } + pParent->SetMinOutputSizePixel( Size( + pBack->get_width_request(), + pParent->GetMinOutputSizePixel().Height()) ); } } diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index 8faffab94069..434450dbce41 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -513,37 +513,37 @@ IMPL_LINK(BackingWindow, ExtLinkClickHdl, Button*, pButton, void) if (pButton == mpExtensionsButton) aNode = "AddFeatureURL"; - if (!aNode.isEmpty()) + if (aNode.isEmpty()) + return; + + try { - try + uno::Sequence<uno::Any> args(comphelper::InitAnyPropertySequence( { - uno::Sequence<uno::Any> args(comphelper::InitAnyPropertySequence( - { - {"nodepath", uno::Any(OUString("/org.openoffice.Office.Common/Help/StartCenter"))} - })); + {"nodepath", uno::Any(OUString("/org.openoffice.Office.Common/Help/StartCenter"))} + })); - Reference<lang::XMultiServiceFactory> xConfig = configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() ); - Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS, args), UNO_QUERY); - if (xNameAccess.is()) - { - OUString sURL; - Any value(xNameAccess->getByName(aNode)); - - sURL = value.get<OUString>(); - localizeWebserviceURI(sURL); - - Reference<css::system::XSystemShellExecute> const - xSystemShellExecute( - css::system::SystemShellExecute::create( - ::comphelper::getProcessComponentContext())); - xSystemShellExecute->execute(sURL, OUString(), - css::system::SystemShellExecuteFlags::URIS_ONLY); - } - } - catch (const Exception&) + Reference<lang::XMultiServiceFactory> xConfig = configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() ); + Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS, args), UNO_QUERY); + if (xNameAccess.is()) { + OUString sURL; + Any value(xNameAccess->getByName(aNode)); + + sURL = value.get<OUString>(); + localizeWebserviceURI(sURL); + + Reference<css::system::XSystemShellExecute> const + xSystemShellExecute( + css::system::SystemShellExecute::create( + ::comphelper::getProcessComponentContext())); + xSystemShellExecute->execute(sURL, OUString(), + css::system::SystemShellExecuteFlags::URIS_ONLY); } } + catch (const Exception&) + { + } } IMPL_LINK( BackingWindow, ClickHdl, Button*, pButton, void ) diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index 499c9a6e59a2..a1e6bb7ddf6f 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -806,30 +806,30 @@ void SfxSingleTabDialog::SetTabPage(SfxTabPage* pTabPage) pImpl->m_pSfxPage.disposeAndClear(); pImpl->m_pSfxPage = pTabPage; - if ( pImpl->m_pSfxPage ) - { - // First obtain the user data, only then Reset() - OUString sConfigId = OStringToOUString(pImpl->m_pSfxPage->GetConfigId(), RTL_TEXTENCODING_UTF8); - SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId); - Any aUserItem = aPageOpt.GetUserItem( USERITEM_NAME ); - OUString sUserData; - aUserItem >>= sUserData; - pImpl->m_pSfxPage->SetUserData(sUserData); - pImpl->m_pSfxPage->Reset( GetInputItemSet() ); - pImpl->m_pSfxPage->Show(); - - pHelpBtn->Show(Help::IsContextHelpEnabled()); - - // Set TabPage text in the Dialog if there is any - OUString sTitle(pImpl->m_pSfxPage->GetText()); - if (!sTitle.isEmpty()) - SetText(sTitle); - - // Dialog receives the HelpId of TabPage if there is any - OString sHelpId(pImpl->m_pSfxPage->GetHelpId()); - if (!sHelpId.isEmpty()) - SetHelpId(sHelpId); - } + if ( !pImpl->m_pSfxPage ) + return; + + // First obtain the user data, only then Reset() + OUString sConfigId = OStringToOUString(pImpl->m_pSfxPage->GetConfigId(), RTL_TEXTENCODING_UTF8); + SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId); + Any aUserItem = aPageOpt.GetUserItem( USERITEM_NAME ); + OUString sUserData; + aUserItem >>= sUserData; + pImpl->m_pSfxPage->SetUserData(sUserData); + pImpl->m_pSfxPage->Reset( GetInputItemSet() ); + pImpl->m_pSfxPage->Show(); + + pHelpBtn->Show(Help::IsContextHelpEnabled()); + + // Set TabPage text in the Dialog if there is any + OUString sTitle(pImpl->m_pSfxPage->GetText()); + if (!sTitle.isEmpty()) + SetText(sTitle); + + // Dialog receives the HelpId of TabPage if there is any + OString sHelpId(pImpl->m_pSfxPage->GetHelpId()); + if (!sHelpId.isEmpty()) + SetHelpId(sHelpId); } SfxDialogController::SfxDialogController(weld::Widget* pParent, const OUString& rUIFile, @@ -871,29 +871,29 @@ void SfxSingleTabDialogController::SetTabPage(SfxTabPage* pTabPage) m_xSfxPage.disposeAndClear(); m_xSfxPage = pTabPage; - if (m_xSfxPage) - { - // First obtain the user data, only then Reset() - OUString sConfigId = OStringToOUString(m_xSfxPage->GetConfigId(), RTL_TEXTENCODING_UTF8); - SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId); - Any aUserItem = aPageOpt.GetUserItem( USERITEM_NAME ); - OUString sUserData; - aUserItem >>= sUserData; - m_xSfxPage->SetUserData(sUserData); - m_xSfxPage->Reset(GetInputItemSet()); - - m_xHelpBtn->show(Help::IsContextHelpEnabled()); - - // Set TabPage text in the Dialog if there is any - OUString sTitle(m_xSfxPage->GetText()); - if (!sTitle.isEmpty()) - m_xDialog->set_title(sTitle); - - // Dialog receives the HelpId of TabPage if there is any - OString sHelpId(m_xSfxPage->GetHelpId()); - if (!sHelpId.isEmpty()) - m_xDialog->set_help_id(sHelpId); - } + if (!m_xSfxPage) + return; + + // First obtain the user data, only then Reset() + OUString sConfigId = OStringToOUString(m_xSfxPage->GetConfigId(), RTL_TEXTENCODING_UTF8); + SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId); + Any aUserItem = aPageOpt.GetUserItem( USERITEM_NAME ); + OUString sUserData; + aUserItem >>= sUserData; + m_xSfxPage->SetUserData(sUserData); + m_xSfxPage->Reset(GetInputItemSet()); + + m_xHelpBtn->show(Help::IsContextHelpEnabled()); + + // Set TabPage text in the Dialog if there is any + OUString sTitle(m_xSfxPage->GetText()); + if (!sTitle.isEmpty()) + m_xDialog->set_title(sTitle); + + // Dialog receives the HelpId of TabPage if there is any + OString sHelpId(m_xSfxPage->GetHelpId()); + if (!sHelpId.isEmpty()) + m_xDialog->set_help_id(sHelpId); } /* [Description] diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 6068eeae789c..0322ba3d6ac9 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -832,37 +832,37 @@ IMPL_LINK_NOARG(SfxDocumentPage, ChangePassHdl, Button*, void) void SfxDocumentPage::ImplUpdateSignatures() { SfxObjectShell* pDoc = SfxObjectShell::Current(); - if ( pDoc ) + if ( !pDoc ) + return; + + SfxMedium* pMedium = pDoc->GetMedium(); + if ( !pMedium || pMedium->GetName().isEmpty() || !pMedium->GetStorage().is() ) + return; + + Reference< security::XDocumentDigitalSignatures > xD; + try { - SfxMedium* pMedium = pDoc->GetMedium(); - if ( pMedium && !pMedium->GetName().isEmpty() && pMedium->GetStorage().is() ) - { - Reference< security::XDocumentDigitalSignatures > xD; - try - { - xD = security::DocumentDigitalSignatures::createDefault(comphelper::getProcessComponentContext()); - } - catch ( const css::uno::DeploymentException& ) - { - } - OUString s; - Sequence< security::DocumentSignatureInformation > aInfos; - - if ( xD.is() ) - aInfos = xD->verifyDocumentContentSignatures( pMedium->GetZipStorageToSign_Impl(), - uno::Reference< io::XInputStream >() ); - if ( aInfos.getLength() > 1 ) - s = m_aMultiSignedStr; - else if ( aInfos.getLength() == 1 ) - { - const security::DocumentSignatureInformation& rInfo = aInfos[ 0 ]; - s = utl::GetDateTimeString( rInfo.SignatureDate, rInfo.SignatureTime ); - s += ", "; - s += comphelper::xmlsec::GetContentPart(rInfo.Signer->getSubjectName()); - } - m_pSignedValFt->SetText( s ); - } + xD = security::DocumentDigitalSignatures::createDefault(comphelper::getProcessComponentContext()); + } + catch ( const css::uno::DeploymentException& ) + { + } + OUString s; + Sequence< security::DocumentSignatureInformation > aInfos; + + if ( xD.is() ) + aInfos = xD->verifyDocumentContentSignatures( pMedium->GetZipStorageToSign_Impl(), + uno::Reference< io::XInputStream >() ); + if ( aInfos.getLength() > 1 ) + s = m_aMultiSignedStr; + else if ( aInfos.getLength() == 1 ) + { + const security::DocumentSignatureInformation& rInfo = aInfos[ 0 ]; + s = utl::GetDateTimeString( rInfo.SignatureDate, rInfo.SignatureTime ); + s += ", "; + s += comphelper::xmlsec::GetContentPart(rInfo.Signer->getSubjectName()); } + m_pSignedValFt->SetText( s ); } void SfxDocumentPage::ImplCheckPasswordState() diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx index 8bc31fc87e0e..233c66293c33 100644 --- a/sfx2/source/dialog/dockwin.cxx +++ b/sfx2/source/dialog/dockwin.cxx @@ -331,17 +331,17 @@ void SfxDockingWindowFactory( const uno::Reference< frame::XFrame >& rFrame, con sal_uInt16 nID = sal_uInt16(rDockingWindowName.toInt32()); // Check the range of the provided ID otherwise nothing will happen - if ( lcl_checkDockingWindowID( nID )) + if ( !lcl_checkDockingWindowID( nID )) + return; + + SfxWorkWindow* pWorkWindow = lcl_getWorkWindowFromXFrame( rFrame ); + if ( pWorkWindow ) { - SfxWorkWindow* pWorkWindow = lcl_getWorkWindowFromXFrame( rFrame ); - if ( pWorkWindow ) + SfxChildWindow* pChildWindow = pWorkWindow->GetChildWindow_Impl(nID); + if ( !pChildWindow ) { - SfxChildWindow* pChildWindow = pWorkWindow->GetChildWindow_Impl(nID); - if ( !pChildWindow ) - { - // Register window at the workwindow child window list - pWorkWindow->SetChildWindow_Impl( nID, true, false ); - } + // Register window at the workwindow child window list + pWorkWindow->SetChildWindow_Impl( nID, true, false ); } } } @@ -435,39 +435,39 @@ void SfxDockingWindow::Resize() { DockingWindow::Resize(); Invalidate(); - if ( pImpl && pImpl->bConstructed && pMgr ) + if ( !pImpl || !pImpl->bConstructed || !pMgr ) + return; + + if ( IsFloatingMode() ) { - if ( IsFloatingMode() ) - { - // start timer for saving window status information - pImpl->aMoveIdle.Start(); - } - else + // start timer for saving window status information + pImpl->aMoveIdle.Start(); + } + else + { + Size aSize( GetSizePixel() ); + switch ( pImpl->GetDockAlignment() ) { - Size aSize( GetSizePixel() ); - switch ( pImpl->GetDockAlignment() ) - { - case SfxChildAlignment::LEFT: - case SfxChildAlignment::FIRSTLEFT: - case SfxChildAlignment::LASTLEFT: - case SfxChildAlignment::RIGHT: - case SfxChildAlignment::FIRSTRIGHT: - case SfxChildAlignment::LASTRIGHT: - pImpl->nHorizontalSize = aSize.Width(); - pImpl->aSplitSize = aSize; - break; - case SfxChildAlignment::TOP: - case SfxChildAlignment::LOWESTTOP: - case SfxChildAlignment::HIGHESTTOP: - case SfxChildAlignment::BOTTOM: - case SfxChildAlignment::HIGHESTBOTTOM: - case SfxChildAlignment::LOWESTBOTTOM: - pImpl->nVerticalSize = aSize.Height(); - pImpl->aSplitSize = aSize; - break; - default: - break; - } + case SfxChildAlignment::LEFT: + case SfxChildAlignment::FIRSTLEFT: + case SfxChildAlignment::LASTLEFT: + case SfxChildAlignment::RIGHT: + case SfxChildAlignment::FIRSTRIGHT: + case SfxChildAlignment::LASTRIGHT: + pImpl->nHorizontalSize = aSize.Width(); + pImpl->aSplitSize = aSize; + break; + case SfxChildAlignment::TOP: + case SfxChildAlignment::LOWESTTOP: + case SfxChildAlignment::HIGHESTTOP: + case SfxChildAlignment::BOTTOM: + case SfxChildAlignment::HIGHESTBOTTOM: + case SfxChildAlignment::LOWESTBOTTOM: + pImpl->nVerticalSize = aSize.Height(); + pImpl->aSplitSize = aSize; + break; + default: + break; } } } diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 016e4ecdbd70..5405c991948e 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -457,35 +457,35 @@ void FileDialogHelper_Impl::updateFilterOptionsBox() void FileDialogHelper_Impl::updateExportButton() { uno::Reference < XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY ); - if ( xCtrlAccess.is() ) + if ( !xCtrlAccess.is() ) + return; + + OUString sOldLabel( xCtrlAccess->getLabel( CommonFilePickerElementIds::PUSHBUTTON_OK ) ); + + // initialize button label; we need the label with the mnemonic char + if ( maButtonLabel.isEmpty() || maButtonLabel.indexOf( MNEMONIC_CHAR ) == -1 ) { - OUString sOldLabel( xCtrlAccess->getLabel( CommonFilePickerElementIds::PUSHBUTTON_OK ) ); + // cut the ellipses, if necessary + sal_Int32 nIndex = sOldLabel.indexOf( "..." ); + if ( -1 == nIndex ) + nIndex = sOldLabel.getLength(); + maButtonLabel = sOldLabel.copy( 0, nIndex ); + } + + OUString sLabel = maButtonLabel; + // filter with options -> append ellipses on export button label + if ( CheckFilterOptionsCapability( getCurentSfxFilter() ) ) + sLabel += "..."; - // initialize button label; we need the label with the mnemonic char - if ( maButtonLabel.isEmpty() || maButtonLabel.indexOf( MNEMONIC_CHAR ) == -1 ) + if ( sOldLabel != sLabel ) + { + try { - // cut the ellipses, if necessary - sal_Int32 nIndex = sOldLabel.indexOf( "..." ); - if ( -1 == nIndex ) - nIndex = sOldLabel.getLength(); - maButtonLabel = sOldLabel.copy( 0, nIndex ); + xCtrlAccess->setLabel( CommonFilePickerElementIds::PUSHBUTTON_OK, sLabel ); } - - OUString sLabel = maButtonLabel; - // filter with options -> append ellipses on export button label - if ( CheckFilterOptionsCapability( getCurentSfxFilter() ) ) - sLabel += "..."; - - if ( sOldLabel != sLabel ) + catch( const IllegalArgumentException& ) { - try - { - xCtrlAccess->setLabel( CommonFilePickerElementIds::PUSHBUTTON_OK, sLabel ); - } - catch( const IllegalArgumentException& ) - { - SAL_WARN( "sfx.dialog", "FileDialogHelper_Impl::updateExportButton: caught an exception!" ); - } + SAL_WARN( "sfx.dialog", "FileDialogHelper_Impl::updateExportButton: caught an exception!" ); } } } @@ -563,38 +563,38 @@ void FileDialogHelper_Impl::enablePasswordBox( bool bInit ) void FileDialogHelper_Impl::updatePreviewState( bool _bUpdatePreviewWindow ) { - if ( mbHasPreview ) + if ( !mbHasPreview ) + return; + + uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY ); + + // check, whether or not we have to display a preview + if ( !xCtrlAccess.is() ) + return; + + try { - uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY ); + Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0 ); + bool bShowPreview = false; - // check, whether or not we have to display a preview - if ( xCtrlAccess.is() ) + if ( aValue >>= bShowPreview ) { - try - { - Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0 ); - bool bShowPreview = false; - - if ( aValue >>= bShowPreview ) - { - mbShowPreview = bShowPreview; + mbShowPreview = bShowPreview; - // setShowState has currently no effect for the - // OpenOffice FilePicker (see svtools/source/filepicker/iodlg.cxx) - uno::Reference< XFilePreview > xFilePreview( mxFileDlg, UNO_QUERY ); - if ( xFilePreview.is() ) - xFilePreview->setShowState( mbShowPreview ); + // setShowState has currently no effect for the + // OpenOffice FilePicker (see svtools/source/filepicker/iodlg.cxx) + uno::Reference< XFilePreview > xFilePreview( mxFileDlg, UNO_QUERY ); + if ( xFilePreview.is() ) + xFilePreview->setShowState( mbShowPreview ); - if ( _bUpdatePreviewWindow ) - TimeOutHdl_Impl( nullptr ); - } - } - catch( const Exception& ) - { - SAL_WARN( "sfx.dialog", "FileDialogHelper_Impl::updatePreviewState: caught an exception!" ); - } + if ( _bUpdatePreviewWindow ) + TimeOutHdl_Impl( nullptr ); } } + catch( const Exception& ) + { + SAL_WARN( "sfx.dialog", "FileDialogHelper_Impl::updatePreviewState: caught an exception!" ); + } } void FileDialogHelper_Impl::updateVersions() @@ -645,21 +645,21 @@ void FileDialogHelper_Impl::updateVersions() sal_Int32 nCount = aEntries.getLength(); - if ( nCount ) + if ( !nCount ) + return; + + try { - try - { - aValue <<= aEntries; - xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION, - ControlActions::ADD_ITEMS, aValue ); + aValue <<= aEntries; + xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION, + ControlActions::ADD_ITEMS, aValue ); - Any aPos; - aPos <<= sal_Int32(0); - xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION, - ControlActions::SET_SELECT_ITEM, aPos ); - } - catch( const IllegalArgumentException& ){} + Any aPos; + aPos <<= sal_Int32(0); + xDlg->setValue( ExtendedFilePickerElementIds::LISTBOX_VERSION, + ControlActions::SET_SELECT_ITEM, aPos ); } + catch( const IllegalArgumentException& ){} } IMPL_LINK_NOARG(FileDialogHelper_Impl, TimeOutHdl_Impl, Timer *, void) @@ -1234,39 +1234,39 @@ void FileDialogHelper_Impl::postExecute( sal_Int16 _nResult ) void FileDialogHelper_Impl::implInitializeFileName( ) { - if ( !maFileName.isEmpty() ) + if ( maFileName.isEmpty() ) + return; + + INetURLObject aObj( maPath ); + aObj.Append( maFileName ); + + // in case we're operating as save dialog, and "auto extension" is checked, + // cut the extension from the name + if ( !(mbIsSaveDlg && mbHasAutoExt) ) + return; + + try { - INetURLObject aObj( maPath ); - aObj.Append( maFileName ); + bool bAutoExtChecked = false; - // in case we're operating as save dialog, and "auto extension" is checked, - // cut the extension from the name - if ( mbIsSaveDlg && mbHasAutoExt ) + uno::Reference < XFilePickerControlAccess > xControlAccess( mxFileDlg, UNO_QUERY ); + if ( xControlAccess.is() + && ( xControlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0 ) + >>= bAutoExtChecked + ) + ) { - try - { - bool bAutoExtChecked = false; - - uno::Reference < XFilePickerControlAccess > xControlAccess( mxFileDlg, UNO_QUERY ); - if ( xControlAccess.is() - && ( xControlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0 ) - >>= bAutoExtChecked - ) - ) - { - if ( bAutoExtChecked ) - { // cut the extension - aObj.removeExtension( ); - mxFileDlg->setDefaultName( aObj.GetName( INetURLObject::DecodeMechanism::WithCharset ) ); - } - } - } - catch( const Exception& ) - { - OSL_FAIL( "FileDialogHelper_Impl::implInitializeFileName: could not ask for the auto-extension current-value!" ); + if ( bAutoExtChecked ) + { // cut the extension + aObj.removeExtension( ); + mxFileDlg->setDefaultName( aObj.GetName( INetURLObject::DecodeMechanism::WithCharset ) ); } } } + catch( const Exception& ) + { + OSL_FAIL( "FileDialogHelper_Impl::implInitializeFileName: could not ask for the auto-extension current-value!" ); + } } sal_Int16 FileDialogHelper_Impl::implDoExecute() diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index 249973507d53..eb9b216f3900 100644 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -314,49 +314,49 @@ void SfxSecurityPage_Impl::Reset_Impl() IMPL_LINK_NOARG(SfxSecurityPage_Impl, RecordChangesCBToggleHdl, weld::ToggleButton&, void) { // when change recording gets disabled protection must be disabled as well - if (!m_xRecordChangesCB->get_active()) // the new check state is already present, thus the '!' + if (m_xRecordChangesCB->get_active()) // the new check state is already present, thus the '!' + return; + + bool bAlreadyDone = false; + if (!m_bEndRedliningWarningDone) { - bool bAlreadyDone = false; - if (!m_bEndRedliningWarningDone) - { - std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(m_rMyTabPage.GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::YesNo, - m_aEndRedliningWarning)); - xWarn->set_default_response(RET_NO); - if (xWarn->run() != RET_YES) - bAlreadyDone = true; - else - m_bEndRedliningWarningDone = true; - } + std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(m_rMyTabPage.GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::YesNo, + m_aEndRedliningWarning)); + xWarn->set_default_response(RET_NO); + if (xWarn->run() != RET_YES) + bAlreadyDone = true; + else + m_bEndRedliningWarningDone = true; + } - const bool bNeedPasssword = !m_bOrigPasswordIsConfirmed - && m_xProtectPB->get_visible(); - if (!bAlreadyDone && bNeedPasssword) - { - OUString aPasswordText; + const bool bNeedPasssword = !m_bOrigPasswordIsConfirmed + && m_xProtectPB->get_visible(); + if (!bAlreadyDone && bNeedPasssword) + { + OUString aPasswordText; - // dialog canceled or no password provided - if (!lcl_GetPassword( m_rMyTabPage.GetFrameWeld(), false, aPasswordText )) - bAlreadyDone = true; + // dialog canceled or no password provided + if (!lcl_GetPassword( m_rMyTabPage.GetFrameWeld(), false, aPasswordText )) + bAlreadyDone = true; - // ask for password and if dialog is canceled or no password provided return - if (lcl_IsPasswordCorrect( aPasswordText )) - m_bOrigPasswordIsConfirmed = true; - else - bAlreadyDone = true; - } - - if (bAlreadyDone) - m_xRecordChangesCB->set_active(true); // restore original state + // ask for password and if dialog is canceled or no password provided return + if (lcl_IsPasswordCorrect( aPasswordText )) + m_bOrigPasswordIsConfirmed = true; else - { - // remember required values to change protection and change recording in - // FillItemSet_Impl later on if password was correct. - m_bNewPasswordIsValid = true; - m_aNewPassword.clear(); - m_xProtectPB->show(); - m_xUnProtectPB->hide(); - } + bAlreadyDone = true; + } + + if (bAlreadyDone) + m_xRecordChangesCB->set_active(true); // restore original state + else + { + // remember required values to change protection and change recording in + // FillItemSet_Impl later on if password was correct. + m_bNewPasswordIsValid = true; + m_aNewPassword.clear(); + m_xProtectPB->show(); + m_xUnProtectPB->hide(); } } diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index f17752082c35..2c7f0a4e3c63 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -925,48 +925,48 @@ IMPL_LINK_NOARG(SfxTabDialog, ResetHdl, Button*, void) pDataObject->pTabPage->Reset( m_pSet.get() ); // Also reset relevant items of ExampleSet and OutSet to initial state - if (pDataObject->fnGetRanges) + if (!pDataObject->fnGetRanges) + return; + + if (!m_pExampleSet) + m_pExampleSet = new SfxItemSet(*m_pSet); + + const SfxItemPool* pPool = m_pSet->GetPool(); + const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)(); + + while (*pTmpRanges) { - if (!m_pExampleSet) - m_pExampleSet = new SfxItemSet(*m_pSet); + const sal_uInt16* pU = pTmpRanges + 1; - const SfxItemPool* pPool = m_pSet->GetPool(); - const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)(); + // Correct Range with multiple values + sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU; + DBG_ASSERT(nTmp <= nTmpEnd, "Range is sorted the wrong way"); - while (*pTmpRanges) + if (nTmp > nTmpEnd) { - const sal_uInt16* pU = pTmpRanges + 1; - - // Correct Range with multiple values - sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU; - DBG_ASSERT(nTmp <= nTmpEnd, "Range is sorted the wrong way"); + // If really sorted wrongly, then set new + std::swap(nTmp, nTmpEnd); + } - if (nTmp > nTmpEnd) + while (nTmp && nTmp <= nTmpEnd) + { + // Iterate over the Range and set the Items + sal_uInt16 nWh = pPool->GetWhich(nTmp); + const SfxPoolItem* pItem; + if (SfxItemState::SET == m_pSet->GetItemState(nWh, false, &pItem)) { - // If really sorted wrongly, then set new - std::swap(nTmp, nTmpEnd); + m_pExampleSet->Put(*pItem); + m_pOutSet->Put(*pItem); } - - while (nTmp && nTmp <= nTmpEnd) + else { - // Iterate over the Range and set the Items - sal_uInt16 nWh = pPool->GetWhich(nTmp); - const SfxPoolItem* pItem; - if (SfxItemState::SET == m_pSet->GetItemState(nWh, false, &pItem)) - { - m_pExampleSet->Put(*pItem); - m_pOutSet->Put(*pItem); - } - else - { - m_pExampleSet->ClearItem(nWh); - m_pOutSet->ClearItem(nWh); - } - nTmp++; + m_pExampleSet->ClearItem(nWh); + m_pOutSet->ClearItem(nWh); } - // Go to the next pair - pTmpRanges += 2; + nTmp++; } + // Go to the next pair + pTmpRanges += 2; } } @@ -987,48 +987,48 @@ IMPL_LINK_NOARG(SfxTabDialog, BaseFmtHdl, Button*, void) Data_Impl* pDataObject = Find( m_pImpl->aData, nId ); DBG_ASSERT( pDataObject, "Id not known" ); - if ( pDataObject->fnGetRanges ) - { - if ( !m_pExampleSet ) - m_pExampleSet = new SfxItemSet( *m_pSet ); + if ( !pDataObject->fnGetRanges ) + return; - const SfxItemPool* pPool = m_pSet->GetPool(); - const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)(); - SfxItemSet aTmpSet( *m_pExampleSet ); + if ( !m_pExampleSet ) + m_pExampleSet = new SfxItemSet( *m_pSet ); - while ( *pTmpRanges ) - { - const sal_uInt16* pU = pTmpRanges + 1; + const SfxItemPool* pPool = m_pSet->GetPool(); + const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)(); + SfxItemSet aTmpSet( *m_pExampleSet ); - // Correct Range with multiple values - sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU; - DBG_ASSERT( nTmp <= nTmpEnd, "Range is sorted the wrong way" ); + while ( *pTmpRanges ) + { + const sal_uInt16* pU = pTmpRanges + 1; - if ( nTmp > nTmpEnd ) - { - // If really sorted wrongly, then set new - std::swap(nTmp, nTmpEnd); - } + // Correct Range with multiple values + sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU; + DBG_ASSERT( nTmp <= nTmpEnd, "Range is sorted the wrong way" ); - while ( nTmp && nTmp <= nTmpEnd ) // guard against overflow - { - // Iterate over the Range and set the Items - sal_uInt16 nWh = pPool->GetWhich( nTmp ); - m_pExampleSet->ClearItem( nWh ); - aTmpSet.ClearItem( nWh ); - // At the Outset of InvalidateItem, - // so that the change takes effect - m_pOutSet->InvalidateItem( nWh ); - nTmp++; - } - // Go to the next pair - pTmpRanges += 2; + if ( nTmp > nTmpEnd ) + { + // If really sorted wrongly, then set new + std::swap(nTmp, nTmpEnd); } - // Set all Items as new -> the call the current Page Reset() - DBG_ASSERT( pDataObject->pTabPage, "the Page is gone" ); - pDataObject->pTabPage->Reset( &aTmpSet ); - pDataObject->pTabPage->pImpl->mbStandard = true; + + while ( nTmp && nTmp <= nTmpEnd ) // guard against overflow + { + // Iterate over the Range and set the Items + sal_uInt16 nWh = pPool->GetWhich( nTmp ); + m_pExampleSet->ClearItem( nWh ); + aTmpSet.ClearItem( nWh ); + // At the Outset of InvalidateItem, + // so that the change takes effect + m_pOutSet->InvalidateItem( nWh ); + nTmp++; + } + // Go to the next pair + pTmpRanges += 2; } + // Set all Items as new -> the call the current Page Reset() + DBG_ASSERT( pDataObject->pTabPage, "the Page is gone" ); + pDataObject->pTabPage->Reset( &aTmpSet ); + pDataObject->pTabPage->pImpl->mbStandard = true; } @@ -1464,48 +1464,48 @@ IMPL_LINK_NOARG(SfxTabDialogController, ResetHdl, weld::Button&, void) pDataObject->pTabPage->Reset(m_pSet.get()); // Also reset relevant items of ExampleSet and OutSet to initial state - if (pDataObject->fnGetRanges) + if (!pDataObject->fnGetRanges) + return; + + if (!m_xExampleSet) + m_xExampleSet.reset(new SfxItemSet(*m_pSet)); + + const SfxItemPool* pPool = m_pSet->GetPool(); + const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)(); + + while (*pTmpRanges) { - if (!m_xExampleSet) - m_xExampleSet.reset(new SfxItemSet(*m_pSet)); + const sal_uInt16* pU = pTmpRanges + 1; - const SfxItemPool* pPool = m_pSet->GetPool(); - const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)(); + // Correct Range with multiple values + sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU; + DBG_ASSERT(nTmp <= nTmpEnd, "Range is sorted the wrong way"); - while (*pTmpRanges) + if (nTmp > nTmpEnd) { - const sal_uInt16* pU = pTmpRanges + 1; - - // Correct Range with multiple values - sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU; - DBG_ASSERT(nTmp <= nTmpEnd, "Range is sorted the wrong way"); + // If really sorted wrongly, then set new + std::swap(nTmp, nTmpEnd); + } - if (nTmp > nTmpEnd) + while (nTmp && nTmp <= nTmpEnd) + { + // Iterate over the Range and set the Items + sal_uInt16 nWh = pPool->GetWhich(nTmp); + const SfxPoolItem* pItem; + if (SfxItemState::SET == m_pSet->GetItemState(nWh, false, &pItem)) { - // If really sorted wrongly, then set new - std::swap(nTmp, nTmpEnd); + m_xExampleSet->Put(*pItem); + m_pOutSet->Put(*pItem); } - - while (nTmp && nTmp <= nTmpEnd) + else { - // Iterate over the Range and set the Items - sal_uInt16 nWh = pPool->GetWhich(nTmp); - const SfxPoolItem* pItem; - if (SfxItemState::SET == m_pSet->GetItemState(nWh, false, &pItem)) - { - m_xExampleSet->Put(*pItem); - m_pOutSet->Put(*pItem); - } - else - { - m_xExampleSet->ClearItem(nWh); - m_pOutSet->ClearItem(nWh); - } - nTmp++; + m_xExampleSet->ClearItem(nWh); + m_pOutSet->ClearItem(nWh); } - // Go to the next pair - pTmpRanges += 2; + nTmp++; } + // Go to the next pair + pTmpRanges += 2; } } @@ -1522,48 +1522,48 @@ IMPL_LINK_NOARG(SfxTabDialogController, BaseFmtHdl, weld::Button&, void) Data_Impl* pDataObject = Find(m_pImpl->aData, m_xTabCtrl->get_current_page_ident()); assert(pDataObject && "Id not known"); - if (pDataObject->fnGetRanges) - { - if (!m_xExampleSet) - m_xExampleSet.reset(new SfxItemSet(*m_pSet)); + if (!pDataObject->fnGetRanges) + return; - const SfxItemPool* pPool = m_pSet->GetPool(); - const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)(); - SfxItemSet aTmpSet(*m_xExampleSet); + if (!m_xExampleSet) + m_xExampleSet.reset(new SfxItemSet(*m_pSet)); - while (*pTmpRanges) - { - const sal_uInt16* pU = pTmpRanges + 1; + const SfxItemPool* pPool = m_pSet->GetPool(); + const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)(); + SfxItemSet aTmpSet(*m_xExampleSet); - // Correct Range with multiple values - sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU; - DBG_ASSERT( nTmp <= nTmpEnd, "Range is sorted the wrong way" ); + while (*pTmpRanges) + { + const sal_uInt16* pU = pTmpRanges + 1; - if ( nTmp > nTmpEnd ) - { - // If really sorted wrongly, then set new - std::swap(nTmp, nTmpEnd); - } + // Correct Range with multiple values + sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU; + DBG_ASSERT( nTmp <= nTmpEnd, "Range is sorted the wrong way" ); - while ( nTmp && nTmp <= nTmpEnd ) // guard against overflow - { - // Iterate over the Range and set the Items - sal_uInt16 nWh = pPool->GetWhich(nTmp); - m_xExampleSet->ClearItem(nWh); - aTmpSet.ClearItem(nWh); - // At the Outset of InvalidateItem, - // so that the change takes effect - m_pOutSet->InvalidateItem(nWh); - nTmp++; - } - // Go to the next pair - pTmpRanges += 2; + if ( nTmp > nTmpEnd ) + { + // If really sorted wrongly, then set new + std::swap(nTmp, nTmpEnd); + } + + while ( nTmp && nTmp <= nTmpEnd ) // guard against overflow + { + // Iterate over the Range and set the Items + sal_uInt16 nWh = pPool->GetWhich(nTmp); + m_xExampleSet->ClearItem(nWh); + aTmpSet.ClearItem(nWh); + // At the Outset of InvalidateItem, + // so that the change takes effect + m_pOutSet->InvalidateItem(nWh); + nTmp++; } - // Set all Items as new -> the call the current Page Reset() - assert(pDataObject->pTabPage && "the Page is gone"); - pDataObject->pTabPage->Reset( &aTmpSet ); - pDataObject->pTabPage->pImpl->mbStandard = true; + // Go to the next pair + pTmpRanges += 2; } + // Set all Items as new -> the call the current Page Reset() + assert(pDataObject->pTabPage && "the Page is gone"); + pDataObject->pTabPage->Reset( &aTmpSet ); + pDataObject->pTabPage->pImpl->mbStandard = true; } IMPL_LINK(SfxTabDialogController, ActivatePageHdl, const OString&, rPage, void) diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index a749ff062842..a92ebe458bfa 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -1020,62 +1020,62 @@ void SfxCommonTemplateDialog_Impl::EnableTreeDrag( bool bEnable ) void SfxCommonTemplateDialog_Impl::FillTreeBox() { OSL_ENSURE( pTreeBox, "FillTreeBox() without treebox"); - if (pStyleSheetPool && nActFamily != 0xffff) - { - const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl(); - if (!pItem) - return; - pStyleSheetPool->SetSearchMask(pItem->GetFamily(), SfxStyleSearchBits::AllVisible); - StyleTreeArr_Impl aArr; - SfxStyleSheetBase* pStyle = pStyleSheetPool->First(); - - if(pStyle && pStyle->HasParentSupport() && bTreeDrag ) - pTreeBox->SetDragDropMode(DragDropMode::CTRL_MOVE); - else - pTreeBox->SetDragDropMode(DragDropMode::NONE); + if (!pStyleSheetPool || nActFamily == 0xffff) + return; - while (pStyle) - { - StyleTree_Impl* pNew = new StyleTree_Impl(pStyle->GetName(), pStyle->GetParent()); - aArr.emplace_back(pNew); - pStyle = pStyleSheetPool->Next(); - } + const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl(); + if (!pItem) + return; + pStyleSheetPool->SetSearchMask(pItem->GetFamily(), SfxStyleSearchBits::AllVisible); + StyleTreeArr_Impl aArr; + SfxStyleSheetBase* pStyle = pStyleSheetPool->First(); - MakeTree_Impl(aArr); - std::vector<OUString> aEntries; - pTreeBox->MakeExpanded_Impl(aEntries); - pTreeBox->SetUpdateMode( false ); - pTreeBox->Clear(); - const sal_uInt16 nCount = aArr.size(); + if(pStyle && pStyle->HasParentSupport() && bTreeDrag ) + pTreeBox->SetDragDropMode(DragDropMode::CTRL_MOVE); + else + pTreeBox->SetDragDropMode(DragDropMode::NONE); - for (sal_uInt16 i = 0; i < nCount; ++i) - { - FillBox_Impl(pTreeBox, aArr[i].get(), aEntries, pItem->GetFamily(), nullptr); - aArr[i].reset(); - } - pTreeBox->Recalc(); + while (pStyle) + { + StyleTree_Impl* pNew = new StyleTree_Impl(pStyle->GetName(), pStyle->GetParent()); + aArr.emplace_back(pNew); + pStyle = pStyleSheetPool->Next(); + } - EnableItem(SID_STYLE_WATERCAN, false); + MakeTree_Impl(aArr); + std::vector<OUString> aEntries; + pTreeBox->MakeExpanded_Impl(aEntries); + pTreeBox->SetUpdateMode( false ); + pTreeBox->Clear(); + const sal_uInt16 nCount = aArr.size(); - SfxTemplateItem* pState = pFamilyState[nActFamily - 1].get(); + for (sal_uInt16 i = 0; i < nCount; ++i) + { + FillBox_Impl(pTreeBox, aArr[i].get(), aEntries, pItem->GetFamily(), nullptr); + aArr[i].reset(); + } + pTreeBox->Recalc(); - if (nCount) - pTreeBox->Expand(pTreeBox->First()); + EnableItem(SID_STYLE_WATERCAN, false); - for (SvTreeListEntry* pEntry = pTreeBox->First(); pEntry; pEntry = pTreeBox->Next(pEntry)) - { - if (IsExpanded_Impl(aEntries, pTreeBox->GetEntryText(pEntry))) - pTreeBox->Expand(pEntry); - } + SfxTemplateItem* pState = pFamilyState[nActFamily - 1].get(); - pTreeBox->SetUpdateMode( true ); + if (nCount) + pTreeBox->Expand(pTreeBox->First()); - OUString aStyle; - if(pState) // Select current entry - aStyle = pState->GetStyleName(); - SelectStyle(aStyle); - EnableDelete(); + for (SvTreeListEntry* pEntry = pTreeBox->First(); pEntry; pEntry = pTreeBox->Next(pEntry)) + { + if (IsExpanded_Impl(aEntries, pTreeBox->GetEntryText(pEntry))) + pTreeBox->Expand(pEntry); } + + pTreeBox->SetUpdateMode( true ); + + OUString aStyle; + if(pState) // Select current entry + aStyle = pState->GetStyleName(); + SelectStyle(aStyle); + EnableDelete(); } bool SfxCommonTemplateDialog_Impl::HasSelectedStyle() const @@ -1112,122 +1112,122 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags) nFilter = nAppFilter; OSL_ENSURE(pStyleSheetPool, "no StyleSheetPool"); - if(pStyleSheetPool) - { - pStyleSheetPool->SetSearchMask(eFam, nFilter); - pItem = GetFamilyItem_Impl(); - if(nFlags & StyleFlags::UpdateFamily) // Update view type list (Hierarchical, All, etc. - { - CheckItem(nActFamily); // check Button in Toolbox - aFilterLb->SetUpdateMode(false); - aFilterLb->Clear(); - //insert hierarchical at the beginning - sal_Int32 nPos = aFilterLb->InsertEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL), 0); - aFilterLb->SetEntryData( nPos, reinterpret_cast<void*>(SfxStyleSearchBits::All) ); - const SfxStyleFilter& rFilter = pItem->GetFilterList(); - for(const SfxFilterTuple& i : rFilter) - { - SfxStyleSearchBits nFilterFlags = i.nFlags; - nPos = aFilterLb->InsertEntry( i.aName ); - aFilterLb->SetEntryData( nPos, reinterpret_cast<void*>(nFilterFlags) ); - } - if(nActFilter < aFilterLb->GetEntryCount() - 1) - aFilterLb->SelectEntryPos(nActFilter + 1); - else - { - nActFilter = 0; - aFilterLb->SelectEntryPos(1); - SfxStyleSearchBits nFilterFlags = (nActFilter < rFilter.size()) ? rFilter[nActFilter].nFlags : SfxStyleSearchBits::Auto; - pStyleSheetPool->SetSearchMask(eFam, nFilterFlags); - } - - // if the tree view again, select family hierarchy - if (pTreeBox->IsVisible() || m_bWantHierarchical) - { - aFilterLb->SelectEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL)); - EnableHierarchical(true); - } + if(!pStyleSheetPool) + return; - // show maximum 14 entries - aFilterLb->SetDropDownLineCount( MAX_FILTER_ENTRIES ); - aFilterLb->SetUpdateMode(true); + pStyleSheetPool->SetSearchMask(eFam, nFilter); + pItem = GetFamilyItem_Impl(); + if(nFlags & StyleFlags::UpdateFamily) // Update view type list (Hierarchical, All, etc. + { + CheckItem(nActFamily); // check Button in Toolbox + aFilterLb->SetUpdateMode(false); + aFilterLb->Clear(); + //insert hierarchical at the beginning + sal_Int32 nPos = aFilterLb->InsertEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL), 0); + aFilterLb->SetEntryData( nPos, reinterpret_cast<void*>(SfxStyleSearchBits::All) ); + const SfxStyleFilter& rFilter = pItem->GetFilterList(); + for(const SfxFilterTuple& i : rFilter) + { + SfxStyleSearchBits nFilterFlags = i.nFlags; + nPos = aFilterLb->InsertEntry( i.aName ); + aFilterLb->SetEntryData( nPos, reinterpret_cast<void*>(nFilterFlags) ); } + if(nActFilter < aFilterLb->GetEntryCount() - 1) + aFilterLb->SelectEntryPos(nActFilter + 1); else { - if (nActFilter < aFilterLb->GetEntryCount() - 1) - aFilterLb->SelectEntryPos(nActFilter + 1); - else - { - nActFilter = 0; - aFilterLb->SelectEntryPos(1); - } + nActFilter = 0; + aFilterLb->SelectEntryPos(1); + SfxStyleSearchBits nFilterFlags = (nActFilter < rFilter.size()) ? rFilter[nActFilter].nFlags : SfxStyleSearchBits::Auto; + pStyleSheetPool->SetSearchMask(eFam, nFilterFlags); } - if(nFlags & StyleFlags::UpdateFamilyList) + // if the tree view again, select family hierarchy + if (pTreeBox->IsVisible() || m_bWantHierarchical) { - EnableItem(SID_STYLE_WATERCAN,false); + aFilterLb->SelectEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL)); + EnableHierarchical(true); + } - SfxStyleSheetBase *pStyle = pStyleSheetPool->First(); - SvTreeListEntry* pEntry = aFmtLb->First(); - std::vector<OUString> aStrings; + // show maximum 14 entries + aFilterLb->SetDropDownLineCount( MAX_FILTER_ENTRIES ); + aFilterLb->SetUpdateMode(true); + } + else + { + if (nActFilter < aFilterLb->GetEntryCount() - 1) + aFilterLb->SelectEntryPos(nActFilter + 1); + else + { + nActFilter = 0; + aFilterLb->SelectEntryPos(1); + } + } - comphelper::string::NaturalStringSorter aSorter( - ::comphelper::getProcessComponentContext(), - Application::GetSettings().GetLanguageTag().getLocale()); + if(!(nFlags & StyleFlags::UpdateFamilyList)) + return; - while( pStyle ) - { - //Bubblesort - size_t nPos; - for(nPos = aStrings.size(); nPos && aSorter.compare(aStrings[nPos-1], pStyle->GetName()) > 0; --nPos) - {}; - aStrings.insert(aStrings.begin() + nPos, pStyle->GetName()); - pStyle = pStyleSheetPool->Next(); - } + EnableItem(SID_STYLE_WATERCAN,false); - size_t nCount = aStrings.size(); - size_t nPos = 0; - while(nPos < nCount && pEntry && - aStrings[nPos] == aFmtLb->GetEntryText(pEntry)) - { - ++nPos; - pEntry = aFmtLb->Next( pEntry ); - } + SfxStyleSheetBase *pStyle = pStyleSheetPool->First(); + SvTreeListEntry* pEntry = aFmtLb->First(); + std::vector<OUString> aStrings; - if( nPos < nCount || pEntry ) - { - // Fills the display box - aFmtLb->SetUpdateMode(false); - aFmtLb->Clear(); + comphelper::string::NaturalStringSorter aSorter( + ::comphelper::getProcessComponentContext(), + Application::GetSettings().GetLanguageTag().getLocale()); - for(nPos = 0; nPos < nCount; ++nPos) - { - SvTreeListEntry* pTreeListEntry = aFmtLb->InsertEntry(aStrings[nPos], nullptr, false, nPos); - if (officecfg::Office::Common::StylesAndFormatting::Preview::get()) - { - pTreeListEntry->ReplaceItem(std::make_unique<StyleLBoxString>(aStrings[nPos], eFam), 1); - } - aFmtLb->GetModel()->InvalidateEntry(pTreeListEntry); - } - aFmtLb->Recalc(); - aFmtLb->SetUpdateMode(true); + while( pStyle ) + { + //Bubblesort + size_t nPos; + for(nPos = aStrings.size(); nPos && aSorter.compare(aStrings[nPos-1], pStyle->GetName()) > 0; --nPos) + {}; + aStrings.insert(aStrings.begin() + nPos, pStyle->GetName()); + pStyle = pStyleSheetPool->Next(); + } + + size_t nCount = aStrings.size(); + size_t nPos = 0; + while(nPos < nCount && pEntry && + aStrings[nPos] == aFmtLb->GetEntryText(pEntry)) + { + ++nPos; + pEntry = aFmtLb->Next( pEntry ); + } + + if( nPos < nCount || pEntry ) + { + // Fills the display box + aFmtLb->SetUpdateMode(false); + aFmtLb->Clear(); + + for(nPos = 0; nPos < nCount; ++nPos) + { + SvTreeListEntry* pTreeListEntry = aFmtLb->InsertEntry(aStrings[nPos], nullptr, false, nPos); + if (officecfg::Office::Common::StylesAndFormatting::Preview::get()) + { + pTreeListEntry->ReplaceItem(std::make_unique<StyleLBoxString>(aStrings[nPos], eFam), 1); } - // Selects the current style if any - SfxTemplateItem *pState = pFamilyState[nActFamily-1].get(); - OUString aStyle; - if(pState) - aStyle = pState->GetStyleName(); + aFmtLb->GetModel()->InvalidateEntry(pTreeListEntry); + } + aFmtLb->Recalc(); + aFmtLb->SetUpdateMode(true); + } + // Selects the current style if any + SfxTemplateItem *pState = pFamilyState[nActFamily-1].get(); + OUString aStyle; + if(pState) + aStyle = pState->GetStyleName(); #if defined STYLESPREVIEW - mbIgnoreSelect = true; // in case we get a selection change - // in any case we should stop any preview - Execute_Impl(SID_STYLE_END_PREVIEW, - OUString(), OUString(), - 0, 0, 0, 0 ); + mbIgnoreSelect = true; // in case we get a selection change + // in any case we should stop any preview + Execute_Impl(SID_STYLE_END_PREVIEW, + OUString(), OUString(), + 0, 0, 0, 0 ); #endif - SelectStyle(aStyle); - EnableDelete(); - } - } + SelectStyle(aStyle); + EnableDelete(); } // Updated display: Watering the house @@ -1504,22 +1504,22 @@ void SfxCommonTemplateDialog_Impl::FilterSelect( bool bForce ) // Force update, even if the new filter is // equal to the current { - if( nEntry != nActFilter || bForce ) - { - nActFilter = nEntry; - SfxObjectShell *const pDocShell = SaveSelection(); - SfxStyleSheetBasePool *pOldStyleSheetPool = pStyleSheetPool; - pStyleSheetPool = pDocShell? pDocShell->GetStyleSheetPool(): nullptr; - if ( pOldStyleSheetPool != pStyleSheetPool ) - { - if ( pOldStyleSheetPool ) - EndListening(*pOldStyleSheetPool); - if ( pStyleSheetPool ) - StartListening(*pStyleSheetPool); - } + if( nEntry == nActFilter && !bForce ) + return; - UpdateStyles_Impl(StyleFlags::UpdateFamilyList); + nActFilter = nEntry; + SfxObjectShell *const pDocShell = SaveSelection(); + SfxStyleSheetBasePool *pOldStyleSheetPool = pStyleSheetPool; + pStyleSheetPool = pDocShell? pDocShell->GetStyleSheetPool(): nullptr; + if ( pOldStyleSheetPool != pStyleSheetPool ) + { + if ( pOldStyleSheetPool ) + EndListening(*pOldStyleSheetPool); + if ( pStyleSheetPool ) + StartListening(*pStyleSheetPool); } + + UpdateStyles_Impl(StyleFlags::UpdateFamilyList); } // Internal: Perform functions through the Dispatcher @@ -1795,27 +1795,27 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, DropHdl, StyleTreeListBox_Impl&, rBox, // Handler for the New-Buttons void SfxCommonTemplateDialog_Impl::NewHdl() { - if ( nActFamily != 0xffff && (pTreeBox->IsVisible() || aFmtLb->GetSelectionCount() <= 1)) + if ( nActFamily == 0xffff || !(pTreeBox->IsVisible() || aFmtLb->GetSelectionCount() <= 1)) + return; + + const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); + const SfxStyleFamily eFam=pItem->GetFamily(); + SfxStyleSearchBits nMask; + if( nActFilter != 0xffff ) { - const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); - const SfxStyleFamily eFam=pItem->GetFamily(); - SfxStyleSearchBits nMask; - if( nActFilter != 0xffff ) - { - nMask = pItem->GetFilterList()[nActFilter].nFlags; - if(nMask == SfxStyleSearchBits::Auto) // automatic - nMask = nAppFilter; - } - else - nMask=pStyleSheetPool->GetSearchMask(); + nMask = pItem->GetFilterList()[nActFilter].nFlags; + if(nMask == SfxStyleSearchBits::Auto) // automatic + nMask = nAppFilter; + } + else + nMask=pStyleSheetPool->GetSearchMask(); - pStyleSheetPool->SetSearchMask(eFam,nMask); + pStyleSheetPool->SetSearchMask(eFam,nMask); - Execute_Impl(SID_STYLE_NEW, - "", GetSelectedEntry(), - static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()), - nMask); - } + Execute_Impl(SID_STYLE_NEW, + "", GetSelectedEntry(), + static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()), + nMask); } // Handler for the edit-Buttons @@ -1834,103 +1834,102 @@ void SfxCommonTemplateDialog_Impl::EditHdl() // Handler for the Delete-Buttons void SfxCommonTemplateDialog_Impl::DeleteHdl() { - if ( IsInitialized() && HasSelectedStyle() ) - { - bool bUsedStyle = false; // one of the selected styles are used in the document? + if ( !IsInitialized() || !HasSelectedStyle() ) + return; - std::vector<SvTreeListEntry*> aList; - SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected(); - const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl(); + bool bUsedStyle = false; // one of the selected styles are used in the document? - OUStringBuffer aMsg; - aMsg.append(SfxResId(STR_DELETE_STYLE_USED)).append(SfxResId(STR_DELETE_STYLE)); + std::vector<SvTreeListEntry*> aList; + SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected(); + const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl(); - while (pEntry) - { - aList.push_back( pEntry ); - // check the style is used or not - const OUString aTemplName(pTreeBox->IsVisible() ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry)); + OUStringBuffer aMsg; + aMsg.append(SfxResId(STR_DELETE_STYLE_USED)).append(SfxResId(STR_DELETE_STYLE)); - SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( aTemplName, pItem->GetFamily() ); + while (pEntry) + { + aList.push_back( pEntry ); + // check the style is used or not + const OUString aTemplName(pTreeBox->IsVisible() ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry)); - if ( pStyle->IsUsed() ) // pStyle is in use in the document? - { - if (bUsedStyle) // add a separator for the second and later styles - aMsg.append(", "); - aMsg.append(aTemplName); - bUsedStyle = true; - } + SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( aTemplName, pItem->GetFamily() ); - pEntry = pTreeBox->IsVisible() ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry); + if ( pStyle->IsUsed() ) // pStyle is in use in the document? + { + if (bUsedStyle) // add a separator for the second and later styles + aMsg.append(", "); + aMsg.append(aTemplName); + bUsedStyle = true; } - bool aApproved = false; + pEntry = pTreeBox->IsVisible() ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry); + } - // we only want to show the dialog once and if we want to delete a style in use (UX-advice) - if ( bUsedStyle ) - { - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Question, VclButtonsType::YesNo, - aMsg.makeStringAndClear())); - aApproved = xBox->run() == RET_YES; - } + bool aApproved = false; - // if there are no used styles selected or the user approved the changes - if ( !bUsedStyle || aApproved ) - { - for (auto const& elem : aList) - { - const OUString aTemplName(pTreeBox->IsVisible() ? pTreeBox->GetEntryText(elem) : aFmtLb->GetEntryText(elem)); - bDontUpdate = true; // To prevent the Treelistbox to shut down while deleting - Execute_Impl( SID_STYLE_DELETE, aTemplName, - OUString(), static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) ); + // we only want to show the dialog once and if we want to delete a style in use (UX-advice) + if ( bUsedStyle ) + { + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + aMsg.makeStringAndClear())); + aApproved = xBox->run() == RET_YES; + } - if ( pTreeBox->IsVisible() ) - { - pTreeBox->RemoveParentKeepChildren(elem); - bDontUpdate = false; - } - } - bDontUpdate = false; //if everything is deleted set bDontUpdate back to false - UpdateStyles_Impl(StyleFlags::UpdateFamilyList); //and force-update the list + // if there are no used styles selected or the user approved the changes + if ( !(!bUsedStyle || aApproved) ) + return; + + for (auto const& elem : aList) + { + const OUString aTemplName(pTreeBox->IsVisible() ? pTreeBox->GetEntryText(elem) : aFmtLb->GetEntryText(elem)); + bDontUpdate = true; // To prevent the Treelistbox to shut down while deleting + Execute_Impl( SID_STYLE_DELETE, aTemplName, + OUString(), static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) ); + + if ( pTreeBox->IsVisible() ) + { + pTreeBox->RemoveParentKeepChildren(elem); + bDontUpdate = false; } } + bDontUpdate = false; //if everything is deleted set bDontUpdate back to false + UpdateStyles_Impl(StyleFlags::UpdateFamilyList); //and force-update the list } void SfxCommonTemplateDialog_Impl::HideHdl() { - if ( IsInitialized() && HasSelectedStyle() ) - { - SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected(); + if ( !IsInitialized() || !HasSelectedStyle() ) + return; - while (pEntry) - { - OUString aTemplName = pTreeBox->IsVisible() ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry); + SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected(); - Execute_Impl( SID_STYLE_HIDE, aTemplName, - OUString(), static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) ); + while (pEntry) + { + OUString aTemplName = pTreeBox->IsVisible() ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry); - pEntry = pTreeBox->IsVisible() ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry); - } + Execute_Impl( SID_STYLE_HIDE, aTemplName, + OUString(), static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) ); + + pEntry = pTreeBox->IsVisible() ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry); } } void SfxCommonTemplateDialog_Impl::ShowHdl() { + if ( !IsInitialized() || !HasSelectedStyle() ) + return; - if ( IsInitialized() && HasSelectedStyle() ) - { - SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected(); + SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected(); - while (pEntry) - { - OUString aTemplName = pTreeBox->IsVisible() ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry); + while (pEntry) + { + OUString aTemplName = pTreeBox->IsVisible() ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry); - Execute_Impl( SID_STYLE_SHOW, aTemplName, - OUString(), static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) ); + Execute_Impl( SID_STYLE_SHOW, aTemplName, + OUString(), static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) ); - pEntry = pTreeBox->IsVisible() ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry); - } + pEntry = pTreeBox->IsVisible() ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry); } } @@ -2041,27 +2040,27 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, FmtSelectHdl, SvTreeListBox *, pListBox EnableItem(SID_STYLE_WATERCAN, !bWaterDisabled); EnableDelete(); } - if( pListBox ) - { - SelectStyle( pListBox->GetEntryText( pListBox->GetHdlEntry() )); + if( !pListBox ) + return; + + SelectStyle( pListBox->GetEntryText( pListBox->GetHdlEntry() )); #if defined STYLESPREVIEW - sal_uInt16 nModifier = aFmtLb->GetModifier(); - if ( mbIgnoreSelect ) - { - Execute_Impl(SID_STYLE_END_PREVIEW, - OUString(), OUString(), - 0, 0, 0, 0 ); - mbIgnoreSelect = false; - } - else - { - Execute_Impl(SID_STYLE_PREVIEW, - GetSelectedEntry(), OUString(), - ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily(), - 0, 0, &nModifier ); - } -#endif + sal_uInt16 nModifier = aFmtLb->GetModifier(); + if ( mbIgnoreSelect ) + { + Execute_Impl(SID_STYLE_END_PREVIEW, + OUString(), OUString(), + 0, 0, 0, 0 ); + mbIgnoreSelect = false; } + else + { + Execute_Impl(SID_STYLE_PREVIEW, + GetSelectedEntry(), OUString(), + ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily(), + 0, 0, &nModifier ); + } +#endif } IMPL_LINK( SfxCommonTemplateDialog_Impl, MenuSelectHdl, Menu*, pMenu, bool ) @@ -2374,34 +2373,34 @@ IMPL_LINK( SfxTemplateDialog_Impl, ToolBoxRSelect, ToolBox *, pBox, void ) IMPL_LINK( SfxTemplateDialog_Impl, ToolBoxRClick, ToolBox *, pBox, void ) { const sal_uInt16 nEntry = pBox->GetCurItemId(); - if(nEntry == SID_STYLE_NEW_BY_EXAMPLE && - ToolBoxItemBits::DROPDOWN == (pBox->GetItemBits(nEntry)&ToolBoxItemBits::DROPDOWN)) - { - //create a popup menu in Writer - ScopedVclPtrInstance<PopupMenu> pMenu; - OUString sTextDoc("com.sun.star.text.TextDocument"); + if(nEntry != SID_STYLE_NEW_BY_EXAMPLE || + !(pBox->GetItemBits(nEntry) & ToolBoxItemBits::DROPDOWN)) + return; - OUString sLabel = vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:StyleNewByExample", sTextDoc); - pMenu->InsertItem( SID_STYLE_NEW_BY_EXAMPLE, sLabel ); - pMenu->SetHelpId(SID_STYLE_NEW_BY_EXAMPLE, HID_TEMPLDLG_NEWBYEXAMPLE); + //create a popup menu in Writer + ScopedVclPtrInstance<PopupMenu> pMenu; + OUString sTextDoc("com.sun.star.text.TextDocument"); - sLabel = vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:StyleUpdateByExample", sTextDoc); - pMenu->InsertItem( SID_STYLE_UPDATE_BY_EXAMPLE, sLabel ); - pMenu->SetHelpId(SID_STYLE_UPDATE_BY_EXAMPLE, HID_TEMPLDLG_UPDATEBYEXAMPLE); + OUString sLabel = vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:StyleNewByExample", sTextDoc); + pMenu->InsertItem( SID_STYLE_NEW_BY_EXAMPLE, sLabel ); + pMenu->SetHelpId(SID_STYLE_NEW_BY_EXAMPLE, HID_TEMPLDLG_NEWBYEXAMPLE); - pMenu->InsertSeparator(); + sLabel = vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:StyleUpdateByExample", sTextDoc); + pMenu->InsertItem( SID_STYLE_UPDATE_BY_EXAMPLE, sLabel ); + pMenu->SetHelpId(SID_STYLE_UPDATE_BY_EXAMPLE, HID_TEMPLDLG_UPDATEBYEXAMPLE); - sLabel = vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:LoadStyles", sTextDoc); - pMenu->InsertItem( SID_TEMPLATE_LOAD, sLabel ); - pMenu->SetHelpId(SID_TEMPLATE_LOAD, ".uno:LoadStyles"); + pMenu->InsertSeparator(); - pMenu->SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, MenuSelectHdl)); - pMenu->Execute( pBox, - pBox->GetItemRect(nEntry), - PopupMenuFlags::ExecuteDown ); - pBox->EndSelection(); - pBox->Invalidate(); - } + sLabel = vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:LoadStyles", sTextDoc); + pMenu->InsertItem( SID_TEMPLATE_LOAD, sLabel ); + pMenu->SetHelpId(SID_TEMPLATE_LOAD, ".uno:LoadStyles"); + + pMenu->SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, MenuSelectHdl)); + pMenu->Execute( pBox, + pBox->GetItemRect(nEntry), + PopupMenuFlags::ExecuteDown ); + pBox->EndSelection(); + pBox->Invalidate(); } IMPL_LINK( SfxTemplateDialog_Impl, MenuSelectHdl, Menu*, pMenu, bool) diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx index 980e6ec06d37..51f50406b124 100644 --- a/sfx2/source/doc/DocumentMetadataAccess.cxx +++ b/sfx2/source/doc/DocumentMetadataAccess.cxx @@ -1341,20 +1341,21 @@ DocumentMetadataAccess::storeMetadataToMedium( } storeMetadataToStorage(xStorage); - if (sfx) { - const bool bOk = aMedium.Commit(); - aMedium.Close(); - if ( !bOk ) { - ErrCode nError = aMedium.GetError(); - if ( nError == ERRCODE_NONE ) { - nError = ERRCODE_IO_GENERAL; - } - task::ErrorCodeIOException ex( - "DocumentMetadataAccess::storeMetadataToMedium Commit failed: " + nError.toHexString(), - uno::Reference< uno::XInterface >(), sal_uInt32(nError)); - throw lang::WrappedTargetException(OUString(), *this, - uno::makeAny(ex)); + if (!sfx) + return; + + const bool bOk = aMedium.Commit(); + aMedium.Close(); + if ( !bOk ) { + ErrCode nError = aMedium.GetError(); + if ( nError == ERRCODE_NONE ) { + nError = ERRCODE_IO_GENERAL; } + task::ErrorCodeIOException ex( + "DocumentMetadataAccess::storeMetadataToMedium Commit failed: " + nError.toHexString(), + uno::Reference< uno::XInterface >(), sal_uInt32(nError)); + throw lang::WrappedTargetException(OUString(), *this, + uno::makeAny(ex)); } } diff --git a/sfx2/source/doc/Metadatable.cxx b/sfx2/source/doc/Metadatable.cxx index ca27a7701a8b..012bc5b92219 100644 --- a/sfx2/source/doc/Metadatable.cxx +++ b/sfx2/source/doc/Metadatable.cxx @@ -930,18 +930,18 @@ rmIter(ClipboardXmlIdMap_t & i_rXmlIdMap, ClipboardXmlIdMap_t::iterator const& i_rIter, OUString const & i_rStream, Metadatable const& i_rObject) { - if (i_rIter != i_rXmlIdMap.end()) + if (i_rIter == i_rXmlIdMap.end()) + return; + + Metadatable *& rMeta = isContentFile(i_rStream) + ? i_rIter->second.first : i_rIter->second.second; + if (rMeta == &i_rObject) { - Metadatable *& rMeta = isContentFile(i_rStream) - ? i_rIter->second.first : i_rIter->second.second; - if (rMeta == &i_rObject) - { - rMeta = nullptr; - } - if (!i_rIter->second.first && !i_rIter->second.second) - { - i_rXmlIdMap.erase(i_rIter); - } + rMeta = nullptr; + } + if (!i_rIter->second.first && !i_rIter->second.second) + { + i_rXmlIdMap.erase(i_rIter); } } diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index 7fb8ffe696bb..549844e18663 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -2099,38 +2099,38 @@ void SfxDocumentMetaData::createUserDefined() { // user-defined meta data: create PropertyBag which only accepts property // values of allowed types - if ( !m_xUserDefined.is() ) - { - css::uno::Sequence<css::uno::Type> types(13); - types[ 0] = ::cppu::UnoType<bool>::get(); - types[ 1] = ::cppu::UnoType< OUString>::get(); - types[ 2] = ::cppu::UnoType<css::util::DateTime>::get(); - types[ 3] = ::cppu::UnoType<css::util::Date>::get(); - types[ 4] = ::cppu::UnoType<css::util::DateTimeWithTimezone>::get(); - types[ 5] = ::cppu::UnoType<css::util::DateWithTimezone>::get(); - types[ 6] = ::cppu::UnoType<css::util::Duration>::get(); - types[ 7] = ::cppu::UnoType<float>::get(); - types[ 8] = ::cppu::UnoType<double>::get(); - types[ 9] = ::cppu::UnoType<sal_Int16>::get(); - types[10] = ::cppu::UnoType<sal_Int32>::get(); - types[11] = ::cppu::UnoType<sal_Int64>::get(); - // Time is supported for backward compatibility with OOo 3.x, x<=2 - types[12] = ::cppu::UnoType<css::util::Time>::get(); - // #i94175#: ODF allows empty user-defined property names! - m_xUserDefined.set( - css::beans::PropertyBag::createWithTypes( m_xContext, types, true/*AllowEmptyPropertyName*/, false/*AutomaticAddition*/ ), - css::uno::UNO_QUERY_THROW); + if ( m_xUserDefined.is() ) + return; - const css::uno::Reference<css::util::XModifyBroadcaster> xMB( - m_xUserDefined, css::uno::UNO_QUERY); - if (xMB.is()) - { - const std::vector<css::uno::Reference<css::uno::XInterface> > - listeners(m_NotifyListeners.getElements()); - for (const auto& l : listeners) { - xMB->addModifyListener( - css::uno::Reference< css::util::XModifyListener >(l, css::uno::UNO_QUERY) ); - } + css::uno::Sequence<css::uno::Type> types(13); + types[ 0] = ::cppu::UnoType<bool>::get(); + types[ 1] = ::cppu::UnoType< OUString>::get(); + types[ 2] = ::cppu::UnoType<css::util::DateTime>::get(); + types[ 3] = ::cppu::UnoType<css::util::Date>::get(); + types[ 4] = ::cppu::UnoType<css::util::DateTimeWithTimezone>::get(); + types[ 5] = ::cppu::UnoType<css::util::DateWithTimezone>::get(); + types[ 6] = ::cppu::UnoType<css::util::Duration>::get(); + types[ 7] = ::cppu::UnoType<float>::get(); + types[ 8] = ::cppu::UnoType<double>::get(); + types[ 9] = ::cppu::UnoType<sal_Int16>::get(); + types[10] = ::cppu::UnoType<sal_Int32>::get(); + types[11] = ::cppu::UnoType<sal_Int64>::get(); + // Time is supported for backward compatibility with OOo 3.x, x<=2 + types[12] = ::cppu::UnoType<css::util::Time>::get(); + // #i94175#: ODF allows empty user-defined property names! + m_xUserDefined.set( + css::beans::PropertyBag::createWithTypes( m_xContext, types, true/*AllowEmptyPropertyName*/, false/*AutomaticAddition*/ ), + css::uno::UNO_QUERY_THROW); + + const css::uno::Reference<css::util::XModifyBroadcaster> xMB( + m_xUserDefined, css::uno::UNO_QUERY); + if (xMB.is()) + { + const std::vector<css::uno::Reference<css::uno::XInterface> > + listeners(m_NotifyListeners.getElements()); + for (const auto& l : listeners) { + xMB->addModifyListener( + css::uno::Reference< css::util::XModifyListener >(l, css::uno::UNO_QUERY) ); } } } diff --git a/sfx2/source/doc/docfac.cxx b/sfx2/source/doc/docfac.cxx index ee08443654b8..17ccf55e2db5 100644 --- a/sfx2/source/doc/docfac.cxx +++ b/sfx2/source/doc/docfac.cxx @@ -153,94 +153,94 @@ void SfxObjectFactory::SetSystemTemplate( const OUString& rServiceName, const OU sPath = OUString( aPathBuffer ); osl::FileBase::getFileURLFromSystemPath( sPath, sUserTemplateURL ); - if ( !sUserTemplateURL.isEmpty()) + if ( sUserTemplateURL.isEmpty()) + return; + + try { - try + uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); + uno::Reference< uno::XInterface > xConfig = ::comphelper::ConfigurationHelper::openConfig( + ::comphelper::getProcessComponentContext(), "/org.openoffice.Setup", ::comphelper::EConfigurationModes::Standard ); + + OUString aActualFilter; + ::comphelper::ConfigurationHelper::readRelativeKey( xConfig, sConfPath, "ooSetupFactoryActualFilter" ) >>= aActualFilter; + bool bChanged(false); + ::comphelper::ConfigurationHelper::readRelativeKey( xConfig, sConfPath, PROP_DEF_TEMPL_CHANGED ) >>= bChanged; + + uno::Reference< container::XNameAccess > xFilterFactory( + xFactory->createInstance( "com.sun.star.document.FilterFactory" ), uno::UNO_QUERY_THROW ); + uno::Reference< container::XNameAccess > xTypeDetection( + xFactory->createInstance( "com.sun.star.document.TypeDetection" ), uno::UNO_QUERY_THROW ); + + OUString aActualFilterTypeName; + uno::Sequence< beans::PropertyValue > aActuralFilterData; + xFilterFactory->getByName( aActualFilter ) >>= aActuralFilterData; + for ( sal_Int32 nInd = 0; nInd < aActuralFilterData.getLength(); nInd++ ) + if ( aActuralFilterData[nInd].Name == "Type" ) + aActuralFilterData[nInd].Value >>= aActualFilterTypeName; + ::comphelper::SequenceAsHashMap aProps1( xTypeDetection->getByName( aActualFilterTypeName ) ); + uno::Sequence< OUString > aAllExt = + aProps1.getUnpackedValueOrDefault("Extensions", uno::Sequence< OUString >() ); + //To-do: check if aAllExt is empty first + const OUString aExt = DEF_TPL_STR + aAllExt[0]; + + sUserTemplateURL += aExt; + + uno::Reference<ucb::XSimpleFileAccess3> xSimpleFileAccess( + ucb::SimpleFileAccess::create( ::comphelper::getComponentContext(xFactory) ) ); + + OUString aBackupURL; + ::osl::Security().getConfigDir(aBackupURL); + aBackupURL += "/temp"; + + if ( !xSimpleFileAccess->exists( aBackupURL ) ) + xSimpleFileAccess->createFolder( aBackupURL ); + + aBackupURL += aExt; + + if ( !rTemplateName.isEmpty() ) { - uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - uno::Reference< uno::XInterface > xConfig = ::comphelper::ConfigurationHelper::openConfig( - ::comphelper::getProcessComponentContext(), "/org.openoffice.Setup", ::comphelper::EConfigurationModes::Standard ); - - OUString aActualFilter; - ::comphelper::ConfigurationHelper::readRelativeKey( xConfig, sConfPath, "ooSetupFactoryActualFilter" ) >>= aActualFilter; - bool bChanged(false); - ::comphelper::ConfigurationHelper::readRelativeKey( xConfig, sConfPath, PROP_DEF_TEMPL_CHANGED ) >>= bChanged; - - uno::Reference< container::XNameAccess > xFilterFactory( - xFactory->createInstance( "com.sun.star.document.FilterFactory" ), uno::UNO_QUERY_THROW ); - uno::Reference< container::XNameAccess > xTypeDetection( - xFactory->createInstance( "com.sun.star.document.TypeDetection" ), uno::UNO_QUERY_THROW ); - - OUString aActualFilterTypeName; - uno::Sequence< beans::PropertyValue > aActuralFilterData; - xFilterFactory->getByName( aActualFilter ) >>= aActuralFilterData; - for ( sal_Int32 nInd = 0; nInd < aActuralFilterData.getLength(); nInd++ ) - if ( aActuralFilterData[nInd].Name == "Type" ) - aActuralFilterData[nInd].Value >>= aActualFilterTypeName; - ::comphelper::SequenceAsHashMap aProps1( xTypeDetection->getByName( aActualFilterTypeName ) ); - uno::Sequence< OUString > aAllExt = - aProps1.getUnpackedValueOrDefault("Extensions", uno::Sequence< OUString >() ); - //To-do: check if aAllExt is empty first - const OUString aExt = DEF_TPL_STR + aAllExt[0]; - - sUserTemplateURL += aExt; - - uno::Reference<ucb::XSimpleFileAccess3> xSimpleFileAccess( - ucb::SimpleFileAccess::create( ::comphelper::getComponentContext(xFactory) ) ); - - OUString aBackupURL; - ::osl::Security().getConfigDir(aBackupURL); - aBackupURL += "/temp"; - - if ( !xSimpleFileAccess->exists( aBackupURL ) ) - xSimpleFileAccess->createFolder( aBackupURL ); - - aBackupURL += aExt; - - if ( !rTemplateName.isEmpty() ) - { - if ( xSimpleFileAccess->exists( sUserTemplateURL ) && !bChanged ) - xSimpleFileAccess->copy( sUserTemplateURL, aBackupURL ); - - uno::Reference< document::XTypeDetection > xTypeDetector( xTypeDetection, uno::UNO_QUERY ); - ::comphelper::SequenceAsHashMap aProps2( xTypeDetection->getByName( xTypeDetector->queryTypeByURL( rTemplateName ) ) ); - OUString aFilterName = - aProps2.getUnpackedValueOrDefault("PreferredFilter", OUString() ); - - uno::Sequence< beans::PropertyValue > aArgs( 3 ); - aArgs[0].Name = "FilterName"; - aArgs[0].Value <<= aFilterName; - aArgs[1].Name = "AsTemplate"; - aArgs[1].Value <<= true; - aArgs[2].Name = "URL"; - aArgs[2].Value <<= rTemplateName; - - uno::Reference< frame::XLoadable > xLoadable( xFactory->createInstance( rServiceName ), uno::UNO_QUERY ); - xLoadable->load( aArgs ); - - aArgs.realloc( 2 ); - aArgs[1].Name = "Overwrite"; - aArgs[1].Value <<= true; - - uno::Reference< frame::XStorable > xStorable( xLoadable, uno::UNO_QUERY ); - xStorable->storeToURL( sUserTemplateURL, aArgs ); - ::comphelper::ConfigurationHelper::writeRelativeKey( xConfig, sConfPath, PROP_DEF_TEMPL_CHANGED, uno::makeAny( true )); - ::comphelper::ConfigurationHelper::flush( xConfig ); - } - else - { - DBG_ASSERT( bChanged, "invalid ooSetupFactorySystemDefaultTemplateChanged value!" ); - - xSimpleFileAccess->copy( aBackupURL, sUserTemplateURL ); - xSimpleFileAccess->kill( aBackupURL ); - ::comphelper::ConfigurationHelper::writeRelativeKey( xConfig, sConfPath, PROP_DEF_TEMPL_CHANGED, uno::makeAny( false )); - ::comphelper::ConfigurationHelper::flush( xConfig ); - } + if ( xSimpleFileAccess->exists( sUserTemplateURL ) && !bChanged ) + xSimpleFileAccess->copy( sUserTemplateURL, aBackupURL ); + + uno::Reference< document::XTypeDetection > xTypeDetector( xTypeDetection, uno::UNO_QUERY ); + ::comphelper::SequenceAsHashMap aProps2( xTypeDetection->getByName( xTypeDetector->queryTypeByURL( rTemplateName ) ) ); + OUString aFilterName = + aProps2.getUnpackedValueOrDefault("PreferredFilter", OUString() ); + + uno::Sequence< beans::PropertyValue > aArgs( 3 ); + aArgs[0].Name = "FilterName"; + aArgs[0].Value <<= aFilterName; + aArgs[1].Name = "AsTemplate"; + aArgs[1].Value <<= true; + aArgs[2].Name = "URL"; + aArgs[2].Value <<= rTemplateName; + + uno::Reference< frame::XLoadable > xLoadable( xFactory->createInstance( rServiceName ), uno::UNO_QUERY ); + xLoadable->load( aArgs ); + + aArgs.realloc( 2 ); + aArgs[1].Name = "Overwrite"; + aArgs[1].Value <<= true; + + uno::Reference< frame::XStorable > xStorable( xLoadable, uno::UNO_QUERY ); + xStorable->storeToURL( sUserTemplateURL, aArgs ); + ::comphelper::ConfigurationHelper::writeRelativeKey( xConfig, sConfPath, PROP_DEF_TEMPL_CHANGED, uno::makeAny( true )); + ::comphelper::ConfigurationHelper::flush( xConfig ); } - catch(const uno::Exception&) + else { + DBG_ASSERT( bChanged, "invalid ooSetupFactorySystemDefaultTemplateChanged value!" ); + + xSimpleFileAccess->copy( aBackupURL, sUserTemplateURL ); + xSimpleFileAccess->kill( aBackupURL ); + ::comphelper::ConfigurationHelper::writeRelativeKey( xConfig, sConfPath, PROP_DEF_TEMPL_CHANGED, uno::makeAny( false )); + ::comphelper::ConfigurationHelper::flush( xConfig ); } } + catch(const uno::Exception&) + { + } } void SfxObjectFactory::SetStandardTemplate( const OUString& rServiceName, const OUString& rTemplate ) diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 3cc4fc64664a..ef0f6e2d8943 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -399,38 +399,38 @@ ErrCode SfxMedium::GetErrorCode() const void SfxMedium::CheckFileDate( const util::DateTime& aInitDate ) { GetInitFileDate( true ); - if ( pImpl->m_aDateTime.Seconds != aInitDate.Seconds - || pImpl->m_aDateTime.Minutes != aInitDate.Minutes - || pImpl->m_aDateTime.Hours != aInitDate.Hours - || pImpl->m_aDateTime.Day != aInitDate.Day - || pImpl->m_aDateTime.Month != aInitDate.Month - || pImpl->m_aDateTime.Year != aInitDate.Year ) - { - uno::Reference< task::XInteractionHandler > xHandler = GetInteractionHandler(); + if ( pImpl->m_aDateTime.Seconds == aInitDate.Seconds + && pImpl->m_aDateTime.Minutes == aInitDate.Minutes + && pImpl->m_aDateTime.Hours == aInitDate.Hours + && pImpl->m_aDateTime.Day == aInitDate.Day + && pImpl->m_aDateTime.Month == aInitDate.Month + && pImpl->m_aDateTime.Year == aInitDate.Year ) + return; - if ( xHandler.is() ) - { - try - { - ::rtl::Reference< ::ucbhelper::InteractionRequest > xInteractionRequestImpl = new ::ucbhelper::InteractionRequest( uno::makeAny( - document::ChangedByOthersRequest() ) ); - uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 3 ); - aContinuations[0] = new ::ucbhelper::InteractionAbort( xInteractionRequestImpl.get() ); - aContinuations[1] = new ::ucbhelper::InteractionApprove( xInteractionRequestImpl.get() ); - xInteractionRequestImpl->setContinuations( aContinuations ); + uno::Reference< task::XInteractionHandler > xHandler = GetInteractionHandler(); - xHandler->handle( xInteractionRequestImpl.get() ); + if ( !xHandler.is() ) + return; - ::rtl::Reference< ::ucbhelper::InteractionContinuation > xSelected = xInteractionRequestImpl->getSelection(); - if ( uno::Reference< task::XInteractionAbort >( xSelected.get(), uno::UNO_QUERY ).is() ) - { - SetError(ERRCODE_ABORT); - } - } - catch ( const uno::Exception& ) - {} + try + { + ::rtl::Reference< ::ucbhelper::InteractionRequest > xInteractionRequestImpl = new ::ucbhelper::InteractionRequest( uno::makeAny( + document::ChangedByOthersRequest() ) ); + uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 3 ); + aContinuations[0] = new ::ucbhelper::InteractionAbort( xInteractionRequestImpl.get() ); + aContinuations[1] = new ::ucbhelper::InteractionApprove( xInteractionRequestImpl.get() ); + xInteractionRequestImpl->setContinuations( aContinuations ); + + xHandler->handle( xInteractionRequestImpl.get() ); + + ::rtl::Reference< ::ucbhelper::InteractionContinuation > xSelected = xInteractionRequestImpl->getSelection(); + if ( uno::Reference< task::XInteractionAbort >( xSelected.get(), uno::UNO_QUERY ).is() ) + { + SetError(ERRCODE_ABORT); } } + catch ( const uno::Exception& ) + {} } bool SfxMedium::DocNeedsFileDateCheck() const @@ -851,26 +851,26 @@ uno::Reference < embed::XStorage > SfxMedium::GetOutputStorage() void SfxMedium::SetEncryptionDataToStorage_Impl() { // in case media-descriptor contains password it should be used on opening - if ( pImpl->xStorage.is() && pImpl->m_pSet ) - { - uno::Sequence< beans::NamedValue > aEncryptionData; - if ( GetEncryptionData_Impl( pImpl->m_pSet.get(), aEncryptionData ) ) - { - // replace the password with encryption data - pImpl->m_pSet->ClearItem( SID_PASSWORD ); - pImpl->m_pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ) ); + if ( !pImpl->xStorage.is() || !pImpl->m_pSet ) + return; - try - { - ::comphelper::OStorageHelper::SetCommonStorageEncryptionData( pImpl->xStorage, aEncryptionData ); - } - catch( const uno::Exception& ) - { - SAL_WARN( "sfx.doc", "It must be possible to set a common password for the storage" ); - // TODO/LATER: set the error code in case of problem - // SetError(ERRCODE_IO_GENERAL); - } - } + uno::Sequence< beans::NamedValue > aEncryptionData; + if ( !GetEncryptionData_Impl( pImpl->m_pSet.get(), aEncryptionData ) ) + return; + + // replace the password with encryption data + pImpl->m_pSet->ClearItem( SID_PASSWORD ); + pImpl->m_pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ) ); + + try + { + ::comphelper::OStorageHelper::SetCommonStorageEncryptionData( pImpl->xStorage, aEncryptionData ); + } + catch( const uno::Exception& ) + { + SAL_WARN( "sfx.doc", "It must be possible to set a common password for the storage" ); + // TODO/LATER: set the error code in case of problem + // SetError(ERRCODE_IO_GENERAL); } } @@ -1941,103 +1941,103 @@ void SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource, pImpl->m_eError = ERRCODE_IO_GENERAL; } - if( !pImpl->m_eError || pImpl->m_eError.IsWarning() ) - { - if ( pImpl->xStorage.is() ) - CloseStorage(); + if( pImpl->m_eError && !pImpl->m_eError.IsWarning() ) + return; - CloseStreams_Impl(); + if ( pImpl->xStorage.is() ) + CloseStorage(); + + CloseStreams_Impl(); - ::ucbhelper::Content aTempCont; - if( ::ucbhelper::Content::create( aSource.GetMainURL( INetURLObject::DecodeMechanism::NONE ), xDummyEnv, comphelper::getProcessComponentContext(), aTempCont ) ) + ::ucbhelper::Content aTempCont; + if( ::ucbhelper::Content::create( aSource.GetMainURL( INetURLObject::DecodeMechanism::NONE ), xDummyEnv, comphelper::getProcessComponentContext(), aTempCont ) ) + { + bool bTransactStarted = false; + const SfxBoolItem* pOverWrite = SfxItemSet::GetItem<SfxBoolItem>(GetItemSet(), SID_OVERWRITE, false); + bool bOverWrite = !pOverWrite || pOverWrite->GetValue(); + + try { - bool bTransactStarted = false; - const SfxBoolItem* pOverWrite = SfxItemSet::GetItem<SfxBoolItem>(GetItemSet(), SID_OVERWRITE, false); - bool bOverWrite = !pOverWrite || pOverWrite->GetValue(); + OUString aSourceMainURL = aSource.GetMainURL(INetURLObject::DecodeMechanism::NONE); + OUString aDestMainURL = aDest.GetMainURL(INetURLObject::DecodeMechanism::NONE); - try + sal_uInt64 nAttributes = GetDefaultFileAttributes(aDestMainURL); + if (IsFileMovable(aDest) + && osl::File::replace(aSourceMainURL, aDestMainURL) == osl::FileBase::E_None) { - OUString aSourceMainURL = aSource.GetMainURL(INetURLObject::DecodeMechanism::NONE); - OUString aDestMainURL = aDest.GetMainURL(INetURLObject::DecodeMechanism::NONE); - - sal_uInt64 nAttributes = GetDefaultFileAttributes(aDestMainURL); - if (IsFileMovable(aDest) - && osl::File::replace(aSourceMainURL, aDestMainURL) == osl::FileBase::E_None) - { - if (nAttributes) - // Adjust attributes, source might be created with - // the osl_File_OpenFlag_Private flag. - osl::File::setAttributes(aDestMainURL, nAttributes); - bResult = true; - } - else + if (nAttributes) + // Adjust attributes, source might be created with + // the osl_File_OpenFlag_Private flag. + osl::File::setAttributes(aDestMainURL, nAttributes); + bResult = true; + } + else + { + if (bOverWrite && ::utl::UCBContentHelper::IsDocument(aDestMainURL)) { - if (bOverWrite && ::utl::UCBContentHelper::IsDocument(aDestMainURL)) - { - if( pImpl->m_aBackupURL.isEmpty() ) - DoInternalBackup_Impl( aOriginalContent ); + if( pImpl->m_aBackupURL.isEmpty() ) + DoInternalBackup_Impl( aOriginalContent ); - if( !pImpl->m_aBackupURL.isEmpty() ) - { - Reference< XInputStream > aTempInput = aTempCont.openStream(); - bTransactStarted = true; - aOriginalContent.setPropertyValue( "Size", uno::makeAny( sal_Int64(0) ) ); - aOriginalContent.writeStream( aTempInput, bOverWrite ); - bResult = true; - } - else - { - pImpl->m_eError = ERRCODE_SFX_CANTCREATEBACKUP; - } - } - else + if( !pImpl->m_aBackupURL.isEmpty() ) { Reference< XInputStream > aTempInput = aTempCont.openStream(); + bTransactStarted = true; + aOriginalContent.setPropertyValue( "Size", uno::makeAny( sal_Int64(0) ) ); aOriginalContent.writeStream( aTempInput, bOverWrite ); bResult = true; } + else + { + pImpl->m_eError = ERRCODE_SFX_CANTCREATEBACKUP; + } } - } - catch ( const css::ucb::CommandAbortedException& ) - { - pImpl->m_eError = ERRCODE_ABORT; - } - catch ( const css::ucb::CommandFailedException& ) - { - pImpl->m_eError = ERRCODE_ABORT; - } - catch ( const css::ucb::InteractiveIOException& r ) - { - if ( r.Code == IOErrorCode_ACCESS_DENIED ) - pImpl->m_eError = ERRCODE_IO_ACCESSDENIED; - else if ( r.Code == IOErrorCode_NOT_EXISTING ) - pImpl->m_eError = ERRCODE_IO_NOTEXISTS; - else if ( r.Code == IOErrorCode_CANT_READ ) - pImpl->m_eError = ERRCODE_IO_CANTREAD; else - pImpl->m_eError = ERRCODE_IO_GENERAL; - } - catch ( const css::uno::Exception& ) - { - pImpl->m_eError = ERRCODE_IO_GENERAL; - } - - if ( bResult ) - { - if ( pImpl->pTempFile ) { - pImpl->pTempFile->EnableKillingFile(); - pImpl->pTempFile.reset(); + Reference< XInputStream > aTempInput = aTempCont.openStream(); + aOriginalContent.writeStream( aTempInput, bOverWrite ); + bResult = true; } } - else if ( bTransactStarted ) + } + catch ( const css::ucb::CommandAbortedException& ) + { + pImpl->m_eError = ERRCODE_ABORT; + } + catch ( const css::ucb::CommandFailedException& ) + { + pImpl->m_eError = ERRCODE_ABORT; + } + catch ( const css::ucb::InteractiveIOException& r ) + { + if ( r.Code == IOErrorCode_ACCESS_DENIED ) + pImpl->m_eError = ERRCODE_IO_ACCESSDENIED; + else if ( r.Code == IOErrorCode_NOT_EXISTING ) + pImpl->m_eError = ERRCODE_IO_NOTEXISTS; + else if ( r.Code == IOErrorCode_CANT_READ ) + pImpl->m_eError = ERRCODE_IO_CANTREAD; + else + pImpl->m_eError = ERRCODE_IO_GENERAL; + } + catch ( const css::uno::Exception& ) + { + pImpl->m_eError = ERRCODE_IO_GENERAL; + } + + if ( bResult ) + { + if ( pImpl->pTempFile ) { - UseBackupToRestore_Impl( aOriginalContent, xDummyEnv ); + pImpl->pTempFile->EnableKillingFile(); + pImpl->pTempFile.reset(); } } - else - pImpl->m_eError = ERRCODE_IO_CANTREAD; + else if ( bTransactStarted ) + { + UseBackupToRestore_Impl( aOriginalContent, xDummyEnv ); + } } + else + pImpl->m_eError = ERRCODE_IO_CANTREAD; } @@ -2121,279 +2121,279 @@ void SfxMedium::Transfer_Impl() SAL_WARN( "sfx.doc", "The medium name is not convertible!" ); } - if ( !aNameURL.isEmpty() && ( !pImpl->m_eError || pImpl->m_eError.IsWarning() ) ) - { - SAL_INFO( "sfx.doc", "SfxMedium::Transfer_Impl, copying to target" ); + if ( aNameURL.isEmpty() || ( pImpl->m_eError && !pImpl->m_eError.IsWarning() ) ) + return; - Reference < css::ucb::XCommandEnvironment > xEnv; - Reference< XOutputStream > rOutStream; + SAL_INFO( "sfx.doc", "SfxMedium::Transfer_Impl, copying to target" ); - // in case an output stream is provided from outside and the URL is correct - // commit to the stream - if (pImpl->m_aLogicName.startsWith("private:stream")) + Reference < css::ucb::XCommandEnvironment > xEnv; + Reference< XOutputStream > rOutStream; + + // in case an output stream is provided from outside and the URL is correct + // commit to the stream + if (pImpl->m_aLogicName.startsWith("private:stream")) + { + // TODO/LATER: support storing to SID_STREAM + const SfxUnoAnyItem* pOutStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_OUTPUTSTREAM, false); + if( pOutStreamItem && ( pOutStreamItem->GetValue() >>= rOutStream ) ) { - // TODO/LATER: support storing to SID_STREAM - const SfxUnoAnyItem* pOutStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_OUTPUTSTREAM, false); - if( pOutStreamItem && ( pOutStreamItem->GetValue() >>= rOutStream ) ) - { - if ( pImpl->xStorage.is() ) - CloseStorage(); + if ( pImpl->xStorage.is() ) + CloseStorage(); - CloseStreams_Impl(); + CloseStreams_Impl(); - INetURLObject aSource( aNameURL ); - ::ucbhelper::Content aTempCont; - if( ::ucbhelper::Content::create( aSource.GetMainURL( INetURLObject::DecodeMechanism::NONE ), xEnv, comphelper::getProcessComponentContext(), aTempCont ) ) + INetURLObject aSource( aNameURL ); + ::ucbhelper::Content aTempCont; + if( ::ucbhelper::Content::create( aSource.GetMainURL( INetURLObject::DecodeMechanism::NONE ), xEnv, comphelper::getProcessComponentContext(), aTempCont ) ) + { + try { - try - { - sal_Int32 nRead; - sal_Int32 nBufferSize = 32767; - Sequence < sal_Int8 > aSequence ( nBufferSize ); - Reference< XInputStream > aTempInput = aTempCont.openStream(); + sal_Int32 nRead; + sal_Int32 nBufferSize = 32767; + Sequence < sal_Int8 > aSequence ( nBufferSize ); + Reference< XInputStream > aTempInput = aTempCont.openStream(); - do + do + { + nRead = aTempInput->readBytes ( aSequence, nBufferSize ); + if ( nRead < nBufferSize ) { - nRead = aTempInput->readBytes ( aSequence, nBufferSize ); - if ( nRead < nBufferSize ) - { - Sequence < sal_Int8 > aTempBuf ( aSequence.getConstArray(), nRead ); - rOutStream->writeBytes ( aTempBuf ); - } - else - rOutStream->writeBytes ( aSequence ); + Sequence < sal_Int8 > aTempBuf ( aSequence.getConstArray(), nRead ); + rOutStream->writeBytes ( aTempBuf ); } - while ( nRead == nBufferSize ); + else + rOutStream->writeBytes ( aSequence ); + } + while ( nRead == nBufferSize ); - // remove temporary file - if ( pImpl->pTempFile ) - { - pImpl->pTempFile->EnableKillingFile(); - pImpl->pTempFile.reset(); - } + // remove temporary file + if ( pImpl->pTempFile ) + { + pImpl->pTempFile->EnableKillingFile(); + pImpl->pTempFile.reset(); } - catch( const Exception& ) - {} } + catch( const Exception& ) + {} } - else - { - SAL_WARN( "sfx.doc", "Illegal Output stream parameter!" ); - SetError(ERRCODE_IO_GENERAL); - } - - // free the reference - if ( pImpl->m_pSet ) - pImpl->m_pSet->ClearItem( SID_OUTPUTSTREAM ); - - return; } - - GetContent(); - if ( !pImpl->aContent.get().is() ) + else { - pImpl->m_eError = ERRCODE_IO_NOTEXISTS; - return; + SAL_WARN( "sfx.doc", "Illegal Output stream parameter!" ); + SetError(ERRCODE_IO_GENERAL); } - INetURLObject aDest( GetURLObject() ); + // free the reference + if ( pImpl->m_pSet ) + pImpl->m_pSet->ClearItem( SID_OUTPUTSTREAM ); - // source is the temp file written so far - INetURLObject aSource( aNameURL ); + return; + } - // a special case, an interaction handler should be used for - // authentication in case it is available - Reference< css::ucb::XCommandEnvironment > xComEnv; - Reference< css::task::XInteractionHandler > xInteractionHandler = GetInteractionHandler(); - if (xInteractionHandler.is()) - xComEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, - Reference< css::ucb::XProgressHandler >() ); + GetContent(); + if ( !pImpl->aContent.get().is() ) + { + pImpl->m_eError = ERRCODE_IO_NOTEXISTS; + return; + } - OUString aDestURL( aDest.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + INetURLObject aDest( GetURLObject() ); - if ( comphelper::isFileUrl( aDestURL ) || !aDest.removeSegment() ) - { - TransactedTransferForFS_Impl( aSource, aDest, xComEnv ); + // source is the temp file written so far + INetURLObject aSource( aNameURL ); + + // a special case, an interaction handler should be used for + // authentication in case it is available + Reference< css::ucb::XCommandEnvironment > xComEnv; + Reference< css::task::XInteractionHandler > xInteractionHandler = GetInteractionHandler(); + if (xInteractionHandler.is()) + xComEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, + Reference< css::ucb::XProgressHandler >() ); + + OUString aDestURL( aDest.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + + if ( comphelper::isFileUrl( aDestURL ) || !aDest.removeSegment() ) + { + TransactedTransferForFS_Impl( aSource, aDest, xComEnv ); - if (!pImpl->m_bDisableFileSync) + if (!pImpl->m_bDisableFileSync) + { + // Hideous - no clean way to do this, so we re-open the file just to fsync it + osl::File aFile( aDestURL ); + if ( aFile.open( osl_File_OpenFlag_Write ) == osl::FileBase::E_None ) { - // Hideous - no clean way to do this, so we re-open the file just to fsync it - osl::File aFile( aDestURL ); - if ( aFile.open( osl_File_OpenFlag_Write ) == osl::FileBase::E_None ) - { - aFile.sync(); - SAL_INFO( "sfx.doc", "fsync'd saved file '" << aDestURL << "'" ); - aFile.close(); - } + aFile.sync(); + SAL_INFO( "sfx.doc", "fsync'd saved file '" << aDestURL << "'" ); + aFile.close(); } } - else + } + else + { + // create content for the parent folder and call transfer on that content with the source content + // and the destination file name as parameters + ::ucbhelper::Content aSourceContent; + ::ucbhelper::Content aTransferContent; + + ::ucbhelper::Content aDestContent; + (void)::ucbhelper::Content::create( aDestURL, xComEnv, comphelper::getProcessComponentContext(), aDestContent ); + // For checkin, we need the object URL, not the parent folder: + if ( !IsInCheckIn( ) ) { - // create content for the parent folder and call transfer on that content with the source content - // and the destination file name as parameters - ::ucbhelper::Content aSourceContent; - ::ucbhelper::Content aTransferContent; - - ::ucbhelper::Content aDestContent; - (void)::ucbhelper::Content::create( aDestURL, xComEnv, comphelper::getProcessComponentContext(), aDestContent ); - // For checkin, we need the object URL, not the parent folder: - if ( !IsInCheckIn( ) ) + // Get the parent URL from the XChild if possible: why would the URL necessarily have + // a hierarchical path? It's not always the case for CMIS. + Reference< css::container::XChild> xChild( aDestContent.get(), uno::UNO_QUERY ); + OUString sParentUrl; + if ( xChild.is( ) ) { - // Get the parent URL from the XChild if possible: why would the URL necessarily have - // a hierarchical path? It's not always the case for CMIS. - Reference< css::container::XChild> xChild( aDestContent.get(), uno::UNO_QUERY ); - OUString sParentUrl; - if ( xChild.is( ) ) + Reference< css::ucb::XContent > xParent( xChild->getParent( ), uno::UNO_QUERY ); + if ( xParent.is( ) ) { - Reference< css::ucb::XContent > xParent( xChild->getParent( ), uno::UNO_QUERY ); - if ( xParent.is( ) ) - { - sParentUrl = xParent->getIdentifier( )->getContentIdentifier(); - } + sParentUrl = xParent->getIdentifier( )->getContentIdentifier(); } - - if ( sParentUrl.isEmpty() ) - aDestURL = aDest.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - // adjust to above aDest.removeSegment() - else - aDestURL = sParentUrl; } - // LongName wasn't defined anywhere, only used here... get the Title instead - // as it's less probably empty - OUString aFileName; - Any aAny = aDestContent.getPropertyValue("Title"); - aAny >>= aFileName; - aAny = aDestContent.getPropertyValue( "ObjectId" ); - OUString sObjectId; - aAny >>= sObjectId; - if ( aFileName.isEmpty() ) - aFileName = GetURLObject().getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset ); + if ( sParentUrl.isEmpty() ) + aDestURL = aDest.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + // adjust to above aDest.removeSegment() + else + aDestURL = sParentUrl; + } - try - { - aTransferContent = ::ucbhelper::Content( aDestURL, xComEnv, comphelper::getProcessComponentContext() ); - } - catch (const css::ucb::ContentCreationException& ex) - { - pImpl->m_eError = ERRCODE_IO_GENERAL; - if ( - (ex.eError == css::ucb::ContentCreationError_NO_CONTENT_PROVIDER ) || - (ex.eError == css::ucb::ContentCreationError_CONTENT_CREATION_FAILED) - ) - { - pImpl->m_eError = ERRCODE_IO_NOTEXISTSPATH; - } - } - catch (const css::uno::Exception&) + // LongName wasn't defined anywhere, only used here... get the Title instead + // as it's less probably empty + OUString aFileName; + Any aAny = aDestContent.getPropertyValue("Title"); + aAny >>= aFileName; + aAny = aDestContent.getPropertyValue( "ObjectId" ); + OUString sObjectId; + aAny >>= sObjectId; + if ( aFileName.isEmpty() ) + aFileName = GetURLObject().getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset ); + + try + { + aTransferContent = ::ucbhelper::Content( aDestURL, xComEnv, comphelper::getProcessComponentContext() ); + } + catch (const css::ucb::ContentCreationException& ex) + { + pImpl->m_eError = ERRCODE_IO_GENERAL; + if ( + (ex.eError == css::ucb::ContentCreationError_NO_CONTENT_PROVIDER ) || + (ex.eError == css::ucb::ContentCreationError_CONTENT_CREATION_FAILED) + ) { - pImpl->m_eError = ERRCODE_IO_GENERAL; + pImpl->m_eError = ERRCODE_IO_NOTEXISTSPATH; } + } + catch (const css::uno::Exception&) + { + pImpl->m_eError = ERRCODE_IO_GENERAL; + } - if ( !pImpl->m_eError || pImpl->m_eError.IsWarning() ) - { - // free resources, otherwise the transfer may fail - if ( pImpl->xStorage.is() ) - CloseStorage(); + if ( !pImpl->m_eError || pImpl->m_eError.IsWarning() ) + { + // free resources, otherwise the transfer may fail + if ( pImpl->xStorage.is() ) + CloseStorage(); - CloseStreams_Impl(); + CloseStreams_Impl(); - (void)::ucbhelper::Content::create( aSource.GetMainURL( INetURLObject::DecodeMechanism::NONE ), xEnv, comphelper::getProcessComponentContext(), aSourceContent ); + (void)::ucbhelper::Content::create( aSource.GetMainURL( INetURLObject::DecodeMechanism::NONE ), xEnv, comphelper::getProcessComponentContext(), aSourceContent ); - // check for external parameters that may customize the handling of NameClash situations - const SfxBoolItem* pOverWrite = SfxItemSet::GetItem<SfxBoolItem>(GetItemSet(), SID_OVERWRITE, false); - sal_Int32 nNameClash; - if ( pOverWrite && !pOverWrite->GetValue() ) - // argument says: never overwrite - nNameClash = NameClash::ERROR; - else - // default is overwrite existing files - nNameClash = NameClash::OVERWRITE; + // check for external parameters that may customize the handling of NameClash situations + const SfxBoolItem* pOverWrite = SfxItemSet::GetItem<SfxBoolItem>(GetItemSet(), SID_OVERWRITE, false); + sal_Int32 nNameClash; + if ( pOverWrite && !pOverWrite->GetValue() ) + // argument says: never overwrite + nNameClash = NameClash::ERROR; + else + // default is overwrite existing files + nNameClash = NameClash::OVERWRITE; + try + { + OUString aMimeType = pImpl->getFilterMimeType(); + ::ucbhelper::InsertOperation eOperation = ::ucbhelper::InsertOperation::Copy; + bool bMajor = false; + OUString sComment; + if ( IsInCheckIn( ) ) + { + eOperation = ::ucbhelper::InsertOperation::Checkin; + const SfxBoolItem* pMajor = SfxItemSet::GetItem<SfxBoolItem>(GetItemSet(), SID_DOCINFO_MAJOR, false); + bMajor = pMajor && pMajor->GetValue( ); + const SfxStringItem* pComments = SfxItemSet::GetItem<SfxStringItem>(GetItemSet(), SID_DOCINFO_COMMENTS, false); + if ( pComments ) + sComment = pComments->GetValue( ); + } + OUString sResultURL; + aTransferContent.transferContent( + aSourceContent, eOperation, + aFileName, nNameClash, aMimeType, bMajor, sComment, + &sResultURL, sObjectId ); + + if ( !sResultURL.isEmpty( ) ) // Likely to happen only for checkin + SwitchDocumentToFile( sResultURL ); try { - OUString aMimeType = pImpl->getFilterMimeType(); - ::ucbhelper::InsertOperation eOperation = ::ucbhelper::InsertOperation::Copy; - bool bMajor = false; - OUString sComment; - if ( IsInCheckIn( ) ) + if ( GetURLObject().isAnyKnownWebDAVScheme() && + eOperation == ::ucbhelper::InsertOperation::Copy ) { - eOperation = ::ucbhelper::InsertOperation::Checkin; - const SfxBoolItem* pMajor = SfxItemSet::GetItem<SfxBoolItem>(GetItemSet(), SID_DOCINFO_MAJOR, false); - bMajor = pMajor && pMajor->GetValue( ); - const SfxStringItem* pComments = SfxItemSet::GetItem<SfxStringItem>(GetItemSet(), SID_DOCINFO_COMMENTS, false); - if ( pComments ) - sComment = pComments->GetValue( ); + // tdf#95272 try to re-issue a lock command when a new file is created. + // This may be needed because some WebDAV servers fail to implement the + // 'LOCK on unallocated reference', see issue comment: + // <https://bugs.documentfoundation.org/show_bug.cgi?id=95792#c8> + // and specification at: + // <http://tools.ietf.org/html/rfc4918#section-7.3> + // If the WebDAV resource is already locked by this LO instance, nothing will + // happen, e.g. the LOCK method will not be sent to the server. + ::ucbhelper::Content aLockContent = ::ucbhelper::Content( GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ), xComEnv, comphelper::getProcessComponentContext() ); + aLockContent.lock(); } - OUString sResultURL; - aTransferContent.transferContent( - aSourceContent, eOperation, - aFileName, nNameClash, aMimeType, bMajor, sComment, - &sResultURL, sObjectId ); - - if ( !sResultURL.isEmpty( ) ) // Likely to happen only for checkin - SwitchDocumentToFile( sResultURL ); - try - { - if ( GetURLObject().isAnyKnownWebDAVScheme() && - eOperation == ::ucbhelper::InsertOperation::Copy ) - { - // tdf#95272 try to re-issue a lock command when a new file is created. - // This may be needed because some WebDAV servers fail to implement the - // 'LOCK on unallocated reference', see issue comment: - // <https://bugs.documentfoundation.org/show_bug.cgi?id=95792#c8> - // and specification at: - // <http://tools.ietf.org/html/rfc4918#section-7.3> - // If the WebDAV resource is already locked by this LO instance, nothing will - // happen, e.g. the LOCK method will not be sent to the server. - ::ucbhelper::Content aLockContent = ::ucbhelper::Content( GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ), xComEnv, comphelper::getProcessComponentContext() ); - aLockContent.lock(); - } - } - catch ( css::uno::Exception & e ) - { - SAL_WARN( "sfx.doc", "LOCK not working while re-issuing it. Exception message: " << e ); - } - } - catch ( const css::ucb::CommandAbortedException& ) - { - pImpl->m_eError = ERRCODE_ABORT; } - catch ( const css::ucb::CommandFailedException& ) + catch ( css::uno::Exception & e ) { - pImpl->m_eError = ERRCODE_ABORT; - } - catch ( const css::ucb::InteractiveIOException& r ) - { - if ( r.Code == IOErrorCode_ACCESS_DENIED ) - pImpl->m_eError = ERRCODE_IO_ACCESSDENIED; - else if ( r.Code == IOErrorCode_NOT_EXISTING ) - pImpl->m_eError = ERRCODE_IO_NOTEXISTS; - else if ( r.Code == IOErrorCode_CANT_READ ) - pImpl->m_eError = ERRCODE_IO_CANTREAD; - else - pImpl->m_eError = ERRCODE_IO_GENERAL; + SAL_WARN( "sfx.doc", "LOCK not working while re-issuing it. Exception message: " << e ); } - catch ( const css::uno::Exception& ) - { + } + catch ( const css::ucb::CommandAbortedException& ) + { + pImpl->m_eError = ERRCODE_ABORT; + } + catch ( const css::ucb::CommandFailedException& ) + { + pImpl->m_eError = ERRCODE_ABORT; + } + catch ( const css::ucb::InteractiveIOException& r ) + { + if ( r.Code == IOErrorCode_ACCESS_DENIED ) + pImpl->m_eError = ERRCODE_IO_ACCESSDENIED; + else if ( r.Code == IOErrorCode_NOT_EXISTING ) + pImpl->m_eError = ERRCODE_IO_NOTEXISTS; + else if ( r.Code == IOErrorCode_CANT_READ ) + pImpl->m_eError = ERRCODE_IO_CANTREAD; + else pImpl->m_eError = ERRCODE_IO_GENERAL; - } - - // do not switch from temporary file in case of nonfile protocol } + catch ( const css::uno::Exception& ) + { + pImpl->m_eError = ERRCODE_IO_GENERAL; + } + + // do not switch from temporary file in case of nonfile protocol } + } - if ( ( !pImpl->m_eError || pImpl->m_eError.IsWarning() ) && !pImpl->pTempFile ) + if ( ( !pImpl->m_eError || pImpl->m_eError.IsWarning() ) && !pImpl->pTempFile ) + { + // without a TempFile the physical and logical name should be the same after successful transfer + if (osl::FileBase::getSystemPathFromFileURL( + GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ), pImpl->m_aName ) + != osl::FileBase::E_None) { - // without a TempFile the physical and logical name should be the same after successful transfer - if (osl::FileBase::getSystemPathFromFileURL( - GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ), pImpl->m_aName ) - != osl::FileBase::E_None) - { - pImpl->m_aName.clear(); - } - pImpl->m_bSalvageMode = false; + pImpl->m_aName.clear(); } + pImpl->m_bSalvageMode = false; } } @@ -2455,19 +2455,19 @@ void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalCont if( ::utl::UCBContentHelper::ensureFolder(comphelper::getProcessComponentContext(), xEnv, aBakDir, aContent) ) DoInternalBackup_Impl( aOriginalContent, aPrefix, aExtension, aBakDir ); - if ( pImpl->m_aBackupURL.isEmpty() ) - { - // the copiing to the backup catalog failed ( for example because - // of using an encrypted partition as target catalog ) - // since the user did not specify to make backup explicitly - // office should try to make backup in another place, - // target catalog does not look bad for this case ( and looks - // to be the only way for encrypted partitions ) - - INetURLObject aDest = GetURLObject(); - if ( aDest.removeSegment() ) - DoInternalBackup_Impl( aOriginalContent, aPrefix, aExtension, aDest.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); - } + if ( !pImpl->m_aBackupURL.isEmpty() ) + return; + + // the copiing to the backup catalog failed ( for example because + // of using an encrypted partition as target catalog ) + // since the user did not specify to make backup explicitly + // office should try to make backup in another place, + // target catalog does not look bad for this case ( and looks + // to be the only way for encrypted partitions ) + + INetURLObject aDest = GetURLObject(); + if ( aDest.removeSegment() ) + DoInternalBackup_Impl( aOriginalContent, aPrefix, aExtension, aDest.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); } @@ -2555,175 +2555,175 @@ void SfxMedium::ClearBackup_Impl() void SfxMedium::GetLockingStream_Impl() { - if ( GetURLObject().GetProtocol() == INetProtocol::File - && !pImpl->m_xLockingStream.is() ) - { - const SfxUnoAnyItem* pWriteStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_STREAM, false); - if ( pWriteStreamItem ) - pWriteStreamItem->GetValue() >>= pImpl->m_xLockingStream; + if ( GetURLObject().GetProtocol() != INetProtocol::File + || pImpl->m_xLockingStream.is() ) + return; - if ( !pImpl->m_xLockingStream.is() ) - { - // open the original document - uno::Sequence< beans::PropertyValue > xProps; - TransformItems( SID_OPENDOC, *GetItemSet(), xProps ); - utl::MediaDescriptor aMedium( xProps ); + const SfxUnoAnyItem* pWriteStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_STREAM, false); + if ( pWriteStreamItem ) + pWriteStreamItem->GetValue() >>= pImpl->m_xLockingStream; + + if ( pImpl->m_xLockingStream.is() ) + return; - aMedium.addInputStreamOwnLock(); + // open the original document + uno::Sequence< beans::PropertyValue > xProps; + TransformItems( SID_OPENDOC, *GetItemSet(), xProps ); + utl::MediaDescriptor aMedium( xProps ); - uno::Reference< io::XInputStream > xInputStream; - aMedium[utl::MediaDescriptor::PROP_STREAM()] >>= pImpl->m_xLockingStream; - aMedium[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream; + aMedium.addInputStreamOwnLock(); - if ( !pImpl->pTempFile && pImpl->m_aName.isEmpty() ) - { - // the medium is still based on the original file, it makes sense to initialize the streams - if ( pImpl->m_xLockingStream.is() ) - pImpl->xStream = pImpl->m_xLockingStream; + uno::Reference< io::XInputStream > xInputStream; + aMedium[utl::MediaDescriptor::PROP_STREAM()] >>= pImpl->m_xLockingStream; + aMedium[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream; - if ( xInputStream.is() ) - pImpl->xInputStream = xInputStream; + if ( !pImpl->pTempFile && pImpl->m_aName.isEmpty() ) + { + // the medium is still based on the original file, it makes sense to initialize the streams + if ( pImpl->m_xLockingStream.is() ) + pImpl->xStream = pImpl->m_xLockingStream; - if ( !pImpl->xInputStream.is() && pImpl->xStream.is() ) - pImpl->xInputStream = pImpl->xStream->getInputStream(); - } - } + if ( xInputStream.is() ) + pImpl->xInputStream = xInputStream; + + if ( !pImpl->xInputStream.is() && pImpl->xStream.is() ) + pImpl->xInputStream = pImpl->xStream->getInputStream(); } } void SfxMedium::GetMedium_Impl() { - if ( !pImpl->m_pInStream - || (pImpl->bIsTemp && !pImpl->xInputStream.is() && !pImpl->m_xInputStreamToLoadFrom.is() && !pImpl->xStream.is() && !pImpl->m_xLockingStream.is() ) ) + if ( pImpl->m_pInStream + && (!pImpl->bIsTemp || pImpl->xInputStream.is() || pImpl->m_xInputStreamToLoadFrom.is() || pImpl->xStream.is() || pImpl->m_xLockingStream.is() ) ) + return; + + pImpl->bDownloadDone = false; + Reference< css::task::XInteractionHandler > xInteractionHandler = GetInteractionHandler(); + + //TODO/MBA: need support for SID_STREAM + const SfxUnoAnyItem* pWriteStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_STREAM, false); + const SfxUnoAnyItem* pInStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_INPUTSTREAM, false); + if ( pWriteStreamItem ) { - pImpl->bDownloadDone = false; - Reference< css::task::XInteractionHandler > xInteractionHandler = GetInteractionHandler(); + pWriteStreamItem->GetValue() >>= pImpl->xStream; - //TODO/MBA: need support for SID_STREAM - const SfxUnoAnyItem* pWriteStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_STREAM, false); - const SfxUnoAnyItem* pInStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_INPUTSTREAM, false); - if ( pWriteStreamItem ) + if ( pInStreamItem ) + pInStreamItem->GetValue() >>= pImpl->xInputStream; + + if ( !pImpl->xInputStream.is() && pImpl->xStream.is() ) + pImpl->xInputStream = pImpl->xStream->getInputStream(); + } + else if ( pInStreamItem ) + { + pInStreamItem->GetValue() >>= pImpl->xInputStream; + } + else + { + uno::Sequence < beans::PropertyValue > xProps; + OUString aFileName; + if (!pImpl->m_aName.isEmpty()) { - pWriteStreamItem->GetValue() >>= pImpl->xStream; + if ( osl::FileBase::getFileURLFromSystemPath( pImpl->m_aName, aFileName ) + != osl::FileBase::E_None ) + { + SAL_WARN( "sfx.doc", "Physical name not convertible!"); + } + } + else + aFileName = GetName(); - if ( pInStreamItem ) - pInStreamItem->GetValue() >>= pImpl->xInputStream; + // in case the temporary file exists the streams should be initialized from it, + // but the original MediaDescriptor should not be changed + bool bFromTempFile = ( pImpl->pTempFile != nullptr ); - if ( !pImpl->xInputStream.is() && pImpl->xStream.is() ) - pImpl->xInputStream = pImpl->xStream->getInputStream(); + if ( !bFromTempFile ) + { + GetItemSet()->Put( SfxStringItem( SID_FILE_NAME, aFileName ) ); + if( !(pImpl->m_nStorOpenMode & StreamMode::WRITE) ) + GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, true ) ); + if (xInteractionHandler.is()) + GetItemSet()->Put( SfxUnoAnyItem( SID_INTERACTIONHANDLER, makeAny(xInteractionHandler) ) ); } - else if ( pInStreamItem ) + + if ( pImpl->m_xInputStreamToLoadFrom.is() ) { - pInStreamItem->GetValue() >>= pImpl->xInputStream; + pImpl->xInputStream = pImpl->m_xInputStreamToLoadFrom; + if (pImpl->m_bInputStreamIsReadOnly) + GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, true ) ); } else { - uno::Sequence < beans::PropertyValue > xProps; - OUString aFileName; - if (!pImpl->m_aName.isEmpty()) - { - if ( osl::FileBase::getFileURLFromSystemPath( pImpl->m_aName, aFileName ) - != osl::FileBase::E_None ) - { - SAL_WARN( "sfx.doc", "Physical name not convertible!"); - } - } - else - aFileName = GetName(); - - // in case the temporary file exists the streams should be initialized from it, - // but the original MediaDescriptor should not be changed - bool bFromTempFile = ( pImpl->pTempFile != nullptr ); - - if ( !bFromTempFile ) - { - GetItemSet()->Put( SfxStringItem( SID_FILE_NAME, aFileName ) ); - if( !(pImpl->m_nStorOpenMode & StreamMode::WRITE) ) - GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, true ) ); - if (xInteractionHandler.is()) - GetItemSet()->Put( SfxUnoAnyItem( SID_INTERACTIONHANDLER, makeAny(xInteractionHandler) ) ); - } + TransformItems( SID_OPENDOC, *GetItemSet(), xProps ); + utl::MediaDescriptor aMedium( xProps ); - if ( pImpl->m_xInputStreamToLoadFrom.is() ) + if ( pImpl->m_xLockingStream.is() && !bFromTempFile ) { - pImpl->xInputStream = pImpl->m_xInputStreamToLoadFrom; - if (pImpl->m_bInputStreamIsReadOnly) - GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, true ) ); + // the medium is not based on the temporary file, so the original stream can be used + pImpl->xStream = pImpl->m_xLockingStream; } else { - TransformItems( SID_OPENDOC, *GetItemSet(), xProps ); - utl::MediaDescriptor aMedium( xProps ); - - if ( pImpl->m_xLockingStream.is() && !bFromTempFile ) + if ( bFromTempFile ) + { + aMedium[utl::MediaDescriptor::PROP_URL()] <<= aFileName; + aMedium.erase( utl::MediaDescriptor::PROP_READONLY() ); + aMedium.addInputStream(); + } + else if ( GetURLObject().GetProtocol() == INetProtocol::File ) { - // the medium is not based on the temporary file, so the original stream can be used - pImpl->xStream = pImpl->m_xLockingStream; + // use the special locking approach only for file URLs + aMedium.addInputStreamOwnLock(); } else { - if ( bFromTempFile ) + // add a check for protocol, if it's http or https or provide webdav then add + // the interaction handler to be used by the authentication dialog + if ( GetURLObject().isAnyKnownWebDAVScheme() ) { - aMedium[utl::MediaDescriptor::PROP_URL()] <<= aFileName; - aMedium.erase( utl::MediaDescriptor::PROP_READONLY() ); - aMedium.addInputStream(); + aMedium[utl::MediaDescriptor::PROP_AUTHENTICATIONHANDLER()] <<= GetInteractionHandler( true ); } - else if ( GetURLObject().GetProtocol() == INetProtocol::File ) - { - // use the special locking approach only for file URLs - aMedium.addInputStreamOwnLock(); - } - else - { - // add a check for protocol, if it's http or https or provide webdav then add - // the interaction handler to be used by the authentication dialog - if ( GetURLObject().isAnyKnownWebDAVScheme() ) - { - aMedium[utl::MediaDescriptor::PROP_AUTHENTICATIONHANDLER()] <<= GetInteractionHandler( true ); - } - aMedium.addInputStream(); - } - // the ReadOnly property set in aMedium is ignored - // the check is done in LockOrigFileOnDemand() for file and non-file URLs - - //TODO/MBA: what happens if property is not there?! - aMedium[utl::MediaDescriptor::PROP_STREAM()] >>= pImpl->xStream; - aMedium[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= pImpl->xInputStream; + aMedium.addInputStream(); } + // the ReadOnly property set in aMedium is ignored + // the check is done in LockOrigFileOnDemand() for file and non-file URLs - GetContent(); - if ( !pImpl->xInputStream.is() && pImpl->xStream.is() ) - pImpl->xInputStream = pImpl->xStream->getInputStream(); + //TODO/MBA: what happens if property is not there?! + aMedium[utl::MediaDescriptor::PROP_STREAM()] >>= pImpl->xStream; + aMedium[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= pImpl->xInputStream; } - if ( !bFromTempFile ) - { - //TODO/MBA: need support for SID_STREAM - if ( pImpl->xStream.is() ) - GetItemSet()->Put( SfxUnoAnyItem( SID_STREAM, makeAny( pImpl->xStream ) ) ); - - GetItemSet()->Put( SfxUnoAnyItem( SID_INPUTSTREAM, makeAny( pImpl->xInputStream ) ) ); - } + GetContent(); + if ( !pImpl->xInputStream.is() && pImpl->xStream.is() ) + pImpl->xInputStream = pImpl->xStream->getInputStream(); } - //TODO/MBA: ErrorHandling - how to transport error from MediaDescriptor - if ( !GetError() && !pImpl->xStream.is() && !pImpl->xInputStream.is() ) - SetError(ERRCODE_IO_ACCESSDENIED); - - if ( !GetError() && !pImpl->m_pInStream ) + if ( !bFromTempFile ) { + //TODO/MBA: need support for SID_STREAM if ( pImpl->xStream.is() ) - pImpl->m_pInStream = utl::UcbStreamHelper::CreateStream( pImpl->xStream ); - else if ( pImpl->xInputStream.is() ) - pImpl->m_pInStream = utl::UcbStreamHelper::CreateStream( pImpl->xInputStream ); + GetItemSet()->Put( SfxUnoAnyItem( SID_STREAM, makeAny( pImpl->xStream ) ) ); + + GetItemSet()->Put( SfxUnoAnyItem( SID_INPUTSTREAM, makeAny( pImpl->xInputStream ) ) ); } + } - pImpl->bDownloadDone = true; - pImpl->aDoneLink.ClearPendingCall(); - ErrCode nError = GetError(); - pImpl->aDoneLink.Call( reinterpret_cast<void*>(sal_uInt32(nError)) ); + //TODO/MBA: ErrorHandling - how to transport error from MediaDescriptor + if ( !GetError() && !pImpl->xStream.is() && !pImpl->xInputStream.is() ) + SetError(ERRCODE_IO_ACCESSDENIED); + + if ( !GetError() && !pImpl->m_pInStream ) + { + if ( pImpl->xStream.is() ) + pImpl->m_pInStream = utl::UcbStreamHelper::CreateStream( pImpl->xStream ); + else if ( pImpl->xInputStream.is() ) + pImpl->m_pInStream = utl::UcbStreamHelper::CreateStream( pImpl->xInputStream ); } + + pImpl->bDownloadDone = true; + pImpl->aDoneLink.ClearPendingCall(); + ErrCode nError = GetError(); + pImpl->aDoneLink.Call( reinterpret_cast<void*>(sal_uInt32(nError)) ); } bool SfxMedium::IsRemote() const @@ -3026,29 +3026,29 @@ void SfxMedium::UnlockFile( bool bReleaseLockStream ) pImpl->m_xLockingStream.clear(); } - if ( pImpl->m_bLocked ) - { - ::svt::DocumentLockFile aLockFile( pImpl->m_aLogicName ); + if ( !pImpl->m_bLocked ) + return; + ::svt::DocumentLockFile aLockFile( pImpl->m_aLogicName ); + + try + { + pImpl->m_bLocked = false; + // TODO/LATER: A warning could be shown in case the file is not the own one + aLockFile.RemoveFile(); + } + catch( const io::WrongFormatException& ) + { try { - pImpl->m_bLocked = false; - // TODO/LATER: A warning could be shown in case the file is not the own one - aLockFile.RemoveFile(); - } - catch( const io::WrongFormatException& ) - { - try - { - // erase the empty or corrupt file - aLockFile.RemoveFileDirectly(); - } - catch( const uno::Exception& ) - {} + // erase the empty or corrupt file + aLockFile.RemoveFileDirectly(); } catch( const uno::Exception& ) {} } + catch( const uno::Exception& ) + {} #endif } @@ -3071,18 +3071,18 @@ void SfxMedium::CloseAndReleaseStreams_Impl() CloseStreams_Impl(); // in case of salvage mode the storage is based on the streams - if ( !pImpl->m_bSalvageMode ) + if ( pImpl->m_bSalvageMode ) + return; + + try + { + if ( xInToClose.is() ) + xInToClose->closeInput(); + if ( xOutToClose.is() ) + xOutToClose->closeOutput(); + } + catch ( const uno::Exception& ) { - try - { - if ( xInToClose.is() ) - xInToClose->closeInput(); - if ( xOutToClose.is() ) - xOutToClose->closeOutput(); - } - catch ( const uno::Exception& ) - { - } } } @@ -3334,19 +3334,19 @@ SfxMedium::~SfxMedium() Close(); - if( pImpl->bIsTemp && !pImpl->m_aName.isEmpty() ) + if( !pImpl->bIsTemp || pImpl->m_aName.isEmpty() ) + return; + + OUString aTemp; + if ( osl::FileBase::getFileURLFromSystemPath( pImpl->m_aName, aTemp ) + != osl::FileBase::E_None ) { - OUString aTemp; - if ( osl::FileBase::getFileURLFromSystemPath( pImpl->m_aName, aTemp ) - != osl::FileBase::E_None ) - { - SAL_WARN( "sfx.doc", "Physical name not convertible!"); - } + SAL_WARN( "sfx.doc", "Physical name not convertible!"); + } - if ( !::utl::UCBContentHelper::Kill( aTemp ) ) - { - SAL_WARN( "sfx.doc", "Couldn't remove temporary file!"); - } + if ( !::utl::UCBContentHelper::Kill( aTemp ) ) + { + SAL_WARN( "sfx.doc", "Couldn't remove temporary file!"); } } @@ -3482,32 +3482,32 @@ uno::Sequence < util::RevisionTag > SfxMedium::GetVersionList( const uno::Refere void SfxMedium::AddVersion_Impl( util::RevisionTag& rRevision ) { - if ( GetStorage().is() ) - { - // To determine a unique name for the stream - std::vector<sal_uInt32> aLongs; - sal_Int32 nLength = pImpl->aVersions.getLength(); - for ( sal_Int32 m=0; m<nLength; m++ ) - { - sal_uInt32 nVer = static_cast<sal_uInt32>( pImpl->aVersions[m].Identifier.copy(7).toInt32()); - size_t n; - for ( n=0; n<aLongs.size(); ++n ) - if ( nVer<aLongs[n] ) - break; - - aLongs.insert( aLongs.begin()+n, nVer ); - } + if ( !GetStorage().is() ) + return; - std::vector<sal_uInt32>::size_type nKey; - for ( nKey=0; nKey<aLongs.size(); ++nKey ) - if ( aLongs[nKey] > nKey+1 ) + // To determine a unique name for the stream + std::vector<sal_uInt32> aLongs; + sal_Int32 nLength = pImpl->aVersions.getLength(); + for ( sal_Int32 m=0; m<nLength; m++ ) + { + sal_uInt32 nVer = static_cast<sal_uInt32>( pImpl->aVersions[m].Identifier.copy(7).toInt32()); + size_t n; + for ( n=0; n<aLongs.size(); ++n ) + if ( nVer<aLongs[n] ) break; - OUString aRevName = "Version" + OUString::number( nKey + 1 ); - pImpl->aVersions.realloc( nLength+1 ); - rRevision.Identifier = aRevName; - pImpl->aVersions[nLength] = rRevision; + aLongs.insert( aLongs.begin()+n, nVer ); } + + std::vector<sal_uInt32>::size_type nKey; + for ( nKey=0; nKey<aLongs.size(); ++nKey ) + if ( aLongs[nKey] > nKey+1 ) + break; + + OUString aRevName = "Version" + OUString::number( nKey + 1 ); + pImpl->aVersions.realloc( nLength+1 ); + rRevision.Identifier = aRevName; + pImpl->aVersions[nLength] = rRevision; } void SfxMedium::RemoveVersion_Impl( const OUString& rName ) @@ -3541,20 +3541,20 @@ bool SfxMedium::TransferVersionList_Impl( SfxMedium const & rMedium ) void SfxMedium::SaveVersionList_Impl() { - if ( GetStorage().is() ) - { - if ( !pImpl->aVersions.getLength() ) - return; + if ( !GetStorage().is() ) + return; - uno::Reference < document::XDocumentRevisionListPersistence > xWriter = - document::DocumentRevisionListPersistence::create( comphelper::getProcessComponentContext() ); - try - { - xWriter->store( GetStorage(), pImpl->aVersions ); - } - catch ( const uno::Exception& ) - { - } + if ( !pImpl->aVersions.getLength() ) + return; + + uno::Reference < document::XDocumentRevisionListPersistence > xWriter = + document::DocumentRevisionListPersistence::create( comphelper::getProcessComponentContext() ); + try + { + xWriter->store( GetStorage(), pImpl->aVersions ); + } + catch ( const uno::Exception& ) + { } } diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx index d92c89644526..5dcbd550ec9f 100644 --- a/sfx2/source/doc/doctempl.cxx +++ b/sfx2/source/doc/doctempl.cxx @@ -1347,23 +1347,23 @@ void RegionData_Impl::AddEntry( const OUString& rTitle, bool bFound = false; size_t nPos = GetEntryPos( rTitle, bFound ); - if ( !bFound ) - { - if ( pPos ) - nPos = *pPos; - - auto pEntry = std::make_unique<DocTempl_EntryData_Impl>( - this, rTitle ); - pEntry->SetTargetURL( rTargetURL ); - pEntry->SetHierarchyURL( aLinkURL ); - if ( nPos < maEntries.size() ) { - auto it = maEntries.begin(); - std::advance( it, nPos ); - maEntries.insert( it, std::move(pEntry) ); - } - else - maEntries.push_back( std::move(pEntry) ); + if ( bFound ) + return; + + if ( pPos ) + nPos = *pPos; + + auto pEntry = std::make_unique<DocTempl_EntryData_Impl>( + this, rTitle ); + pEntry->SetTargetURL( rTargetURL ); + pEntry->SetHierarchyURL( aLinkURL ); + if ( nPos < maEntries.size() ) { + auto it = maEntries.begin(); + std::advance( it, nPos ); + maEntries.insert( it, std::move(pEntry) ); } + else + maEntries.push_back( std::move(pEntry) ); } @@ -1514,19 +1514,19 @@ void SfxDocTemplate_Impl::AddRegion( const OUString& rTitle, } catch ( Exception& ) {} - if ( xResultSet.is() ) - { - uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); + if ( !xResultSet.is() ) + return; - try + uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); + + try + { + while ( xResultSet->next() ) { - while ( xResultSet->next() ) - { - pRegionTmp->AddEntry( xRow->getString( 1 ), xRow->getString( 2 ), nullptr ); - } + pRegionTmp->AddEntry( xRow->getString( 1 ), xRow->getString( 2 ), nullptr ); } - catch ( Exception& ) {} } + catch ( Exception& ) {} } @@ -1544,24 +1544,24 @@ void SfxDocTemplate_Impl::CreateFromHierarchy( Content &rTemplRoot ) } catch ( Exception& ) {} - if ( xResultSet.is() ) - { - uno::Reference< XCommandEnvironment > aCmdEnv; - uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); - uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); + if ( !xResultSet.is() ) + return; - try + uno::Reference< XCommandEnvironment > aCmdEnv; + uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); + uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); + + try + { + while ( xResultSet->next() ) { - while ( xResultSet->next() ) - { - const OUString aId = xContentAccess->queryContentIdentifierString(); - Content aContent( aId, aCmdEnv, comphelper::getProcessComponentContext() ); + const OUString aId = xContentAccess->queryContentIdentifierString(); + Content aContent( aId, aCmdEnv, comphelper::getProcessComponentContext() ); - AddRegion( xRow->getString( 1 ), aContent ); - } + AddRegion( xRow->getString( 1 ), aContent ); } - catch ( Exception& ) {} } + catch ( Exception& ) {} } diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index c6027ffbd92f..cc6a7110c24c 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -2336,45 +2336,45 @@ void SfxDocTplService_Impl::addHierGroup( GroupList_Impl& rList, } catch (Exception&) {} - if ( xResultSet.is() ) - { - GroupData_Impl *pGroup = new GroupData_Impl( rTitle ); - pGroup->setHierarchy( true ); - pGroup->setHierarchyURL( rOwnURL ); - rList.push_back( std::unique_ptr<GroupData_Impl>(pGroup) ); + if ( !xResultSet.is() ) + return; - uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); - uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); + GroupData_Impl *pGroup = new GroupData_Impl( rTitle ); + pGroup->setHierarchy( true ); + pGroup->setHierarchyURL( rOwnURL ); + rList.push_back( std::unique_ptr<GroupData_Impl>(pGroup) ); - try - { - while ( xResultSet->next() ) - { - bool bUpdateType = false; - DocTemplates_EntryData_Impl *pData; + uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); + uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); - const OUString aTitle( xRow->getString( 1 ) ); - const OUString aTargetDir( xRow->getString( 2 ) ); - OUString aType( xRow->getString( 3 ) ); - const OUString aHierURL {xContentAccess->queryContentIdentifierString()}; + try + { + while ( xResultSet->next() ) + { + bool bUpdateType = false; + DocTemplates_EntryData_Impl *pData; - if ( aType.isEmpty() ) - { - OUString aTmpTitle; + const OUString aTitle( xRow->getString( 1 ) ); + const OUString aTargetDir( xRow->getString( 2 ) ); + OUString aType( xRow->getString( 3 ) ); + const OUString aHierURL {xContentAccess->queryContentIdentifierString()}; - bool bDocHasTitle = false; - getTitleFromURL( aTargetDir, aTmpTitle, aType, bDocHasTitle ); + if ( aType.isEmpty() ) + { + OUString aTmpTitle; - if ( !aType.isEmpty() ) - bUpdateType = true; - } + bool bDocHasTitle = false; + getTitleFromURL( aTargetDir, aTmpTitle, aType, bDocHasTitle ); - pData = pGroup->addEntry( aTitle, aTargetDir, aType, aHierURL ); - pData->setUpdateType( bUpdateType ); + if ( !aType.isEmpty() ) + bUpdateType = true; } + + pData = pGroup->addEntry( aTitle, aTargetDir, aType, aHierURL ); + pData->setUpdateType( bUpdateType ); } - catch ( Exception& ) {} } + catch ( Exception& ) {} } @@ -2438,30 +2438,30 @@ void SfxDocTplService_Impl::addFsysGroup( GroupList_Impl& rList, } catch ( Exception& ) {} - if ( xResultSet.is() ) - { - uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); - uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); + if ( !xResultSet.is() ) + return; - try + uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); + uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); + + try + { + while ( xResultSet->next() ) { - while ( xResultSet->next() ) - { - OUString aChildTitle( xRow->getString( 1 ) ); - const OUString aTargetURL {xContentAccess->queryContentIdentifierString()}; - OUString aType; + OUString aChildTitle( xRow->getString( 1 ) ); + const OUString aTargetURL {xContentAccess->queryContentIdentifierString()}; + OUString aType; - if ( aChildTitle == "sfx.tlx" || aChildTitle == "groupuinames.xml" ) - continue; + if ( aChildTitle == "sfx.tlx" || aChildTitle == "groupuinames.xml" ) + continue; - bool bDocHasTitle = false; - getTitleFromURL( aTargetURL, aChildTitle, aType, bDocHasTitle ); + bool bDocHasTitle = false; + getTitleFromURL( aTargetURL, aChildTitle, aType, bDocHasTitle ); - pGroup->addEntry( aChildTitle, aTargetURL, aType, OUString() ); - } + pGroup->addEntry( aChildTitle, aTargetURL, aType, OUString() ); } - catch ( Exception& ) {} } + catch ( Exception& ) {} } @@ -2496,37 +2496,37 @@ void SfxDocTplService_Impl::createFromContent( GroupList_Impl& rList, } catch ( Exception& ) {} - if ( xResultSet.is() ) - { - uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); - uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); + if ( !xResultSet.is() ) + return; - try + uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); + uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); + + try + { + while ( xResultSet->next() ) { - while ( xResultSet->next() ) + // TODO/LATER: clarify the encoding of the Title + const OUString aTitle( xRow->getString( 1 ) ); + const OUString aTargetSubfolderURL( xContentAccess->queryContentIdentifierString() ); + + if ( bHierarchy ) + addHierGroup( rList, aTitle, aTargetSubfolderURL ); + else { - // TODO/LATER: clarify the encoding of the Title - const OUString aTitle( xRow->getString( 1 ) ); - const OUString aTargetSubfolderURL( xContentAccess->queryContentIdentifierString() ); + OUString aUITitle; + for (beans::StringPair & rUIName : aUINames) + if ( rUIName.First == aTitle ) + { + aUITitle = rUIName.Second; + break; + } - if ( bHierarchy ) - addHierGroup( rList, aTitle, aTargetSubfolderURL ); - else - { - OUString aUITitle; - for (beans::StringPair & rUIName : aUINames) - if ( rUIName.First == aTitle ) - { - aUITitle = rUIName.Second; - break; - } - - addFsysGroup( rList, aTitle, aUITitle, aTargetSubfolderURL, bWriteableContent ); - } + addFsysGroup( rList, aTitle, aUITitle, aTargetSubfolderURL, bWriteableContent ); } } - catch ( Exception& ) {} } + catch ( Exception& ) {} } diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx index ed196a0a384d..2b0c9b566e5e 100644 --- a/sfx2/source/doc/new.cxx +++ b/sfx2/source/doc/new.cxx @@ -119,51 +119,51 @@ IMPL_LINK_NOARG(SfxNewFileDialog, Update, Timer*, void) return; } - if (m_xMoreBt->get_expanded() && (m_nFlags == SfxNewFileDialogMode::Preview)) + if (!m_xMoreBt->get_expanded() || (m_nFlags != SfxNewFileDialogMode::Preview)) + return; + + OUString aFileName = m_aTemplates.GetPath(m_xRegionLb->get_selected_index(), nEntry - 1); + INetURLObject aTestObj(aFileName); + if (aTestObj.GetProtocol() == INetProtocol::NotValid) { - OUString aFileName = m_aTemplates.GetPath(m_xRegionLb->get_selected_index(), nEntry - 1); - INetURLObject aTestObj(aFileName); - if (aTestObj.GetProtocol() == INetProtocol::NotValid) - { - // temp. fix until Templates are managed by UCB compatible service - // does NOT work with locally cached components ! - OUString aTemp; - osl::FileBase::getFileURLFromSystemPath( aFileName, aTemp ); - aFileName = aTemp; - } + // temp. fix until Templates are managed by UCB compatible service + // does NOT work with locally cached components ! + OUString aTemp; + osl::FileBase::getFileURLFromSystemPath( aFileName, aTemp ); + aFileName = aTemp; + } - INetURLObject aObj(aFileName); - for (SfxObjectShell* pTmp = SfxObjectShell::GetFirst(); pTmp; pTmp = SfxObjectShell::GetNext(*pTmp)) - { - //! fsys bug op== - if (pTmp->GetMedium()) - // ??? HasName() MM - if (INetURLObject( pTmp->GetMedium()->GetName() ) == aObj) - { - m_xDocShell = pTmp; - break; - } - } + INetURLObject aObj(aFileName); + for (SfxObjectShell* pTmp = SfxObjectShell::GetFirst(); pTmp; pTmp = SfxObjectShell::GetNext(*pTmp)) + { + //! fsys bug op== + if (pTmp->GetMedium()) + // ??? HasName() MM + if (INetURLObject( pTmp->GetMedium()->GetName() ) == aObj) + { + m_xDocShell = pTmp; + break; + } + } + if (!m_xDocShell.Is()) + { + SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE, m_xDialog.get()); + SfxApplication *pSfxApp = SfxGetpApp(); + std::unique_ptr<SfxItemSet> pSet(new SfxAllItemSet(pSfxApp->GetPool())); + pSet->Put(SfxBoolItem(SID_TEMPLATE, true)); + pSet->Put(SfxBoolItem(SID_PREVIEW, true)); + ErrCode lErr = pSfxApp->LoadTemplate(m_xDocShell, aFileName, std::move(pSet)); + if (lErr) + ErrorHandler::HandleError(lErr); if (!m_xDocShell.Is()) { - SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE, m_xDialog.get()); - SfxApplication *pSfxApp = SfxGetpApp(); - std::unique_ptr<SfxItemSet> pSet(new SfxAllItemSet(pSfxApp->GetPool())); - pSet->Put(SfxBoolItem(SID_TEMPLATE, true)); - pSet->Put(SfxBoolItem(SID_PREVIEW, true)); - ErrCode lErr = pSfxApp->LoadTemplate(m_xDocShell, aFileName, std::move(pSet)); - if (lErr) - ErrorHandler::HandleError(lErr); - if (!m_xDocShell.Is()) - { - m_xPreviewController->SetObjectShell(nullptr); - return; - } + m_xPreviewController->SetObjectShell(nullptr); + return; } - - m_xPreviewController->SetObjectShell(m_xDocShell); } + + m_xPreviewController->SetObjectShell(m_xDocShell); } IMPL_LINK( SfxNewFileDialog, RegionSelect, weld::TreeView&, rBox, void ) diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index aaf494b639d9..5e17b9757cf9 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -443,88 +443,88 @@ void SfxObjectShell::UpdateFromTemplate_Impl( ) aTempl.GetFull( OUString(), aTemplName, aFoundName ); } - if ( !aFoundName.isEmpty() ) - { - // check existence of template storage - aTemplURL = aFoundName; + if ( aFoundName.isEmpty() ) + return; - // should the document checked against changes in the template ? - if ( IsQueryLoadTemplate() ) - { - bool bLoad = false; + // check existence of template storage + aTemplURL = aFoundName; - // load document properties of template - bool bOK = false; - util::DateTime aTemplDate; - try - { - Reference<document::XDocumentProperties> const - xTemplateDocProps( document::DocumentProperties::create( - ::comphelper::getProcessComponentContext())); - xTemplateDocProps->loadFromMedium(aTemplURL, - Sequence<beans::PropertyValue>()); - aTemplDate = xTemplateDocProps->getModificationDate(); - bOK = true; - } - catch (const Exception& e) - { - SAL_INFO("sfx.doc", e); - } + // should the document checked against changes in the template ? + if ( !IsQueryLoadTemplate() ) + return; - // if modify date was read successfully - if ( bOK ) + bool bLoad = false; + + // load document properties of template + bool bOK = false; + util::DateTime aTemplDate; + try + { + Reference<document::XDocumentProperties> const + xTemplateDocProps( document::DocumentProperties::create( + ::comphelper::getProcessComponentContext())); + xTemplateDocProps->loadFromMedium(aTemplURL, + Sequence<beans::PropertyValue>()); + aTemplDate = xTemplateDocProps->getModificationDate(); + bOK = true; + } + catch (const Exception& e) + { + SAL_INFO("sfx.doc", e); + } + + // if modify date was read successfully + if ( bOK ) + { + // compare modify data of template with the last check date of the document + const util::DateTime aInfoDate( xDocProps->getTemplateDate() ); + if ( aTemplDate > aInfoDate ) + { + // ask user + if( bCanUpdateFromTemplate == document::UpdateDocMode::QUIET_UPDATE + || bCanUpdateFromTemplate == document::UpdateDocMode::FULL_UPDATE ) + bLoad = true; + else if ( bCanUpdateFromTemplate == document::UpdateDocMode::ACCORDING_TO_CONFIG ) { - // compare modify data of template with the last check date of the document - const util::DateTime aInfoDate( xDocProps->getTemplateDate() ); - if ( aTemplDate > aInfoDate ) - { - // ask user - if( bCanUpdateFromTemplate == document::UpdateDocMode::QUIET_UPDATE - || bCanUpdateFromTemplate == document::UpdateDocMode::FULL_UPDATE ) - bLoad = true; - else if ( bCanUpdateFromTemplate == document::UpdateDocMode::ACCORDING_TO_CONFIG ) - { - const OUString sMessage( SfxResId(STR_QRYTEMPL_MESSAGE).replaceAll( "$(ARG1)", aTemplName ) ); - vcl::Window *pWin = GetDialogParent(); - QueryTemplateBox aBox(pWin ? pWin->GetFrameWeld() : nullptr, sMessage); - if (RET_YES == aBox.run()) - bLoad = true; - } - - if( !bLoad ) - { - // user refuses, so don't ask again for this document - SetQueryLoadTemplate(false); - SetModified(); - } - } + const OUString sMessage( SfxResId(STR_QRYTEMPL_MESSAGE).replaceAll( "$(ARG1)", aTemplName ) ); + vcl::Window *pWin = GetDialogParent(); + QueryTemplateBox aBox(pWin ? pWin->GetFrameWeld() : nullptr, sMessage); + if (RET_YES == aBox.run()) + bLoad = true; } - if ( bLoad ) + if( !bLoad ) { - // styles should be updated, create document in organizer mode to read in the styles - //TODO: testen! - SfxObjectShellLock xTemplDoc = CreateObjectByFactoryName( GetFactory().GetFactoryName(), SfxObjectCreateMode::ORGANIZER ); - xTemplDoc->DoInitNew(); - - // TODO/MBA: do we need a BaseURL? Then LoadFrom must be extended! - //xTemplDoc->SetBaseURL( aFoundName ); - - // TODO/LATER: make sure that we don't use binary templates! - SfxMedium aMedium( aFoundName, StreamMode::STD_READ ); - if ( xTemplDoc->LoadFrom( aMedium ) ) - { - // transfer styles from xTemplDoc to this document - // TODO/MBA: make sure that no BaseURL is needed in *this* document - LoadStyles(*xTemplDoc); - - // remember date/time of check - xDocProps->setTemplateDate(aTemplDate); - // TODO/LATER: new functionality to store document info is required ( didn't work for SO7 XML format ) - } + // user refuses, so don't ask again for this document + SetQueryLoadTemplate(false); + SetModified(); } } } + + if ( !bLoad ) + return; + + // styles should be updated, create document in organizer mode to read in the styles + //TODO: testen! + SfxObjectShellLock xTemplDoc = CreateObjectByFactoryName( GetFactory().GetFactoryName(), SfxObjectCreateMode::ORGANIZER ); + xTemplDoc->DoInitNew(); + + // TODO/MBA: do we need a BaseURL? Then LoadFrom must be extended! + //xTemplDoc->SetBaseURL( aFoundName ); + + // TODO/LATER: make sure that we don't use binary templates! + SfxMedium aMedium( aFoundName, StreamMode::STD_READ ); + if ( xTemplDoc->LoadFrom( aMedium ) ) + { + // transfer styles from xTemplDoc to this document + // TODO/MBA: make sure that no BaseURL is needed in *this* document + LoadStyles(*xTemplDoc); + + // remember date/time of check + xDocProps->setTemplateDate(aTemplDate); + // TODO/LATER: new functionality to store document info is required ( didn't work for SO7 XML format ) + } } bool SfxObjectShell::IsHelpDocument() const @@ -536,32 +536,32 @@ bool SfxObjectShell::IsHelpDocument() const void SfxObjectShell::ResetFromTemplate( const OUString& rTemplateName, const OUString& rFileName ) { // only care about resetting this data for LibreOffice formats otherwise - if ( IsOwnStorageFormat( *GetMedium()) ) - { - uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties()); - xDocProps->setTemplateURL( OUString() ); - xDocProps->setTemplateName( OUString() ); - xDocProps->setTemplateDate( util::DateTime() ); - xDocProps->resetUserData( OUString() ); + if ( !IsOwnStorageFormat( *GetMedium()) ) + return; + + uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties()); + xDocProps->setTemplateURL( OUString() ); + xDocProps->setTemplateName( OUString() ); + xDocProps->setTemplateDate( util::DateTime() ); + xDocProps->resetUserData( OUString() ); - // TODO/REFACTOR: - // Title? + // TODO/REFACTOR: + // Title? - if( comphelper::isFileUrl( rFileName ) ) - { - OUString aFoundName; - if( SfxGetpApp()->Get_Impl()->GetDocumentTemplates()->GetFull( OUString(), rTemplateName, aFoundName ) ) - { - INetURLObject aObj( rFileName ); - xDocProps->setTemplateURL( aObj.GetMainURL(INetURLObject::DecodeMechanism::ToIUri) ); - xDocProps->setTemplateName( rTemplateName ); + if( !comphelper::isFileUrl( rFileName ) ) + return; - ::DateTime now( ::DateTime::SYSTEM ); - xDocProps->setTemplateDate( now.GetUNODateTime() ); + OUString aFoundName; + if( SfxGetpApp()->Get_Impl()->GetDocumentTemplates()->GetFull( OUString(), rTemplateName, aFoundName ) ) + { + INetURLObject aObj( rFileName ); + xDocProps->setTemplateURL( aObj.GetMainURL(INetURLObject::DecodeMechanism::ToIUri) ); + xDocProps->setTemplateName( rTemplateName ); - SetQueryLoadTemplate( true ); - } - } + ::DateTime now( ::DateTime::SYSTEM ); + xDocProps->setTemplateDate( now.GetUNODateTime() ); + + SetQueryLoadTemplate( true ); } } diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index b3e00909e375..151de48fb17e 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -374,23 +374,23 @@ void SfxObjectShell::SetReadOnly() // medium open mode is adjusted accordingly, and the write lock // on the file is removed. - if ( pMedium && !IsReadOnlyMedium() ) - { - bool bWasROUI = IsReadOnly(); + if ( !pMedium || IsReadOnlyMedium() ) + return; - pMedium->UnlockFile( false ); + bool bWasROUI = IsReadOnly(); - // the storage-based mediums are already based on the temporary file - // so UnlockFile has already closed the locking stream - if ( !pMedium->HasStorage_Impl() && IsLoadingFinished() ) - pMedium->CloseInStream(); + pMedium->UnlockFile( false ); - pMedium->SetOpenMode( SFX_STREAM_READONLY, true ); - pMedium->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, true ) ); + // the storage-based mediums are already based on the temporary file + // so UnlockFile has already closed the locking stream + if ( !pMedium->HasStorage_Impl() && IsLoadingFinished() ) + pMedium->CloseInStream(); - if ( !bWasROUI ) - Broadcast( SfxHint(SfxHintId::ModeChanged) ); - } + pMedium->SetOpenMode( SFX_STREAM_READONLY, true ); + pMedium->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, true ) ); + + if ( !bWasROUI ) + Broadcast( SfxHint(SfxHintId::ModeChanged) ); } @@ -425,19 +425,19 @@ void SfxObjectShell::SetModalMode_Impl( bool bModal ) { // Broadcast only if modified, or otherwise it will possibly go into // an endless loop - if ( !pImpl->bModalMode != !bModal ) - { - // Central count - sal_uInt16 &rDocModalCount = SfxGetpApp()->Get_Impl()->nDocModalMode; - if ( bModal ) - ++rDocModalCount; - else - --rDocModalCount; + if ( pImpl->bModalMode == bModal ) + return; - // Switch - pImpl->bModalMode = bModal; - Broadcast( SfxHint( SfxHintId::ModeChanged ) ); - } + // Central count + sal_uInt16 &rDocModalCount = SfxGetpApp()->Get_Impl()->nDocModalMode; + if ( bModal ) + ++rDocModalCount; + else + --rDocModalCount; + + // Switch + pImpl->bModalMode = bModal; + Broadcast( SfxHint( SfxHintId::ModeChanged ) ); } #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT @@ -560,29 +560,29 @@ void SfxObjectShell::FreeSharedFile( const OUString& aTempFileURL ) { SetSharedXMLFlag( false ); - if ( IsDocShared() && !aTempFileURL.isEmpty() - && !::utl::UCBContentHelper::EqualURLs( aTempFileURL, GetSharedFileURL() ) ) + if ( !IsDocShared() || aTempFileURL.isEmpty() + || ::utl::UCBContentHelper::EqualURLs( aTempFileURL, GetSharedFileURL() ) ) + return; + + if ( pImpl->m_bAllowShareControlFileClean ) { - if ( pImpl->m_bAllowShareControlFileClean ) + try { - try - { - ::svt::ShareControlFile aControlFile( GetSharedFileURL() ); - aControlFile.RemoveEntry(); - } - catch( uno::Exception& ) - { - } + ::svt::ShareControlFile aControlFile( GetSharedFileURL() ); + aControlFile.RemoveEntry(); } + catch( uno::Exception& ) + { + } + } - // the cleaning is forbidden only once - pImpl->m_bAllowShareControlFileClean = true; + // the cleaning is forbidden only once + pImpl->m_bAllowShareControlFileClean = true; - // now remove the temporary file the document is based currently on - ::utl::UCBContentHelper::Kill( aTempFileURL ); + // now remove the temporary file the document is based currently on + ::utl::UCBContentHelper::Kill( aTempFileURL ); - pImpl->m_aSharedFileURL.clear(); - } + pImpl->m_aSharedFileURL.clear(); } @@ -877,18 +877,18 @@ void SfxObjectShell::SetProgress_Impl void SfxObjectShell::PostActivateEvent_Impl( SfxViewFrame const * pFrame ) { SfxApplication* pSfxApp = SfxGetpApp(); - if ( !pSfxApp->IsDowning() && !IsLoading() && pFrame && !pFrame->GetFrame().IsClosing_Impl() ) + if ( pSfxApp->IsDowning() || IsLoading() || !pFrame || pFrame->GetFrame().IsClosing_Impl() ) + return; + + const SfxBoolItem* pHiddenItem = SfxItemSet::GetItem<SfxBoolItem>(pMedium->GetItemSet(), SID_HIDDEN, false); + if ( !pHiddenItem || !pHiddenItem->GetValue() ) { - const SfxBoolItem* pHiddenItem = SfxItemSet::GetItem<SfxBoolItem>(pMedium->GetItemSet(), SID_HIDDEN, false); - if ( !pHiddenItem || !pHiddenItem->GetValue() ) - { - SfxEventHintId nId = pImpl->nEventId; - pImpl->nEventId = SfxEventHintId::NONE; - if ( nId == SfxEventHintId::OpenDoc ) - pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(GlobalEventId::OPENDOC), this, pFrame->GetFrame().GetController() ), false); - else if (nId == SfxEventHintId::CreateDoc ) - pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(GlobalEventId::CREATEDOC), this, pFrame->GetFrame().GetController() ), false); - } + SfxEventHintId nId = pImpl->nEventId; + pImpl->nEventId = SfxEventHintId::NONE; + if ( nId == SfxEventHintId::OpenDoc ) + pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(GlobalEventId::OPENDOC), this, pFrame->GetFrame().GetController() ), false); + else if (nId == SfxEventHintId::CreateDoc ) + pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(GlobalEventId::CREATEDOC), this, pFrame->GetFrame().GetController() ), false); } } @@ -948,25 +948,25 @@ void SfxObjectShell::CheckEncryption_Impl( const uno::Reference< task::XInteract { } - if ( aVersion.compareTo( ODFVER_012_TEXT ) >= 0 ) - { - // this is ODF1.2 or later - if ( bIsEncrypted && bHasNonEncrypted ) - { - if ( !pImpl->m_bIncomplEncrWarnShown ) - { - // this is an encrypted document with nonencrypted streams inside, show the warning - css::task::ErrorCodeRequest aErrorCode; - aErrorCode.ErrCode = sal_uInt32(ERRCODE_SFX_INCOMPLETE_ENCRYPTION); + if ( aVersion.compareTo( ODFVER_012_TEXT ) < 0 ) + return; - SfxMedium::CallApproveHandler( xHandler, uno::makeAny( aErrorCode ), false ); - pImpl->m_bIncomplEncrWarnShown = true; - } + // this is ODF1.2 or later + if ( !(bIsEncrypted && bHasNonEncrypted) ) + return; - // broken signatures imply no macro execution at all - pImpl->aMacroMode.disallowMacroExecution(); - } + if ( !pImpl->m_bIncomplEncrWarnShown ) + { + // this is an encrypted document with nonencrypted streams inside, show the warning + css::task::ErrorCodeRequest aErrorCode; + aErrorCode.ErrCode = sal_uInt32(ERRCODE_SFX_INCOMPLETE_ENCRYPTION); + + SfxMedium::CallApproveHandler( xHandler, uno::makeAny( aErrorCode ), false ); + pImpl->m_bIncomplEncrWarnShown = true; } + + // broken signatures imply no macro execution at all + pImpl->aMacroMode.disallowMacroExecution(); } @@ -1007,37 +1007,37 @@ bool SfxObjectShell::IsLoadingFinished() const void SfxObjectShell::InitOwnModel_Impl() { - if ( !pImpl->bModelInitialized ) - { - const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(pMedium->GetItemSet(), SID_DOC_SALVAGE, false); - if ( pSalvageItem ) - { - pImpl->aTempName = pMedium->GetPhysicalName(); - pMedium->GetItemSet()->ClearItem( SID_DOC_SALVAGE ); - pMedium->GetItemSet()->ClearItem( SID_FILE_NAME ); - pMedium->GetItemSet()->Put( SfxStringItem( SID_FILE_NAME, pMedium->GetOrigURL() ) ); - } - else - { - pMedium->GetItemSet()->ClearItem( SID_PROGRESS_STATUSBAR_CONTROL ); - pMedium->GetItemSet()->ClearItem( SID_DOCUMENT ); - } + if ( pImpl->bModelInitialized ) + return; - pMedium->GetItemSet()->ClearItem( SID_REFERER ); - uno::Reference< frame::XModel > xModel ( GetModel(), uno::UNO_QUERY ); - if ( xModel.is() ) - { - SfxItemSet *pSet = GetMedium()->GetItemSet(); - if ( !GetMedium()->IsReadOnly() ) - pSet->ClearItem( SID_INPUTSTREAM ); - uno::Sequence< beans::PropertyValue > aArgs; - TransformItems( SID_OPENDOC, *pSet, aArgs ); - xModel->attachResource( GetMedium()->GetOrigURL(), aArgs ); - impl_addToModelCollection(xModel); - } + const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(pMedium->GetItemSet(), SID_DOC_SALVAGE, false); + if ( pSalvageItem ) + { + pImpl->aTempName = pMedium->GetPhysicalName(); + pMedium->GetItemSet()->ClearItem( SID_DOC_SALVAGE ); + pMedium->GetItemSet()->ClearItem( SID_FILE_NAME ); + pMedium->GetItemSet()->Put( SfxStringItem( SID_FILE_NAME, pMedium->GetOrigURL() ) ); + } + else + { + pMedium->GetItemSet()->ClearItem( SID_PROGRESS_STATUSBAR_CONTROL ); + pMedium->GetItemSet()->ClearItem( SID_DOCUMENT ); + } - pImpl->bModelInitialized = true; + pMedium->GetItemSet()->ClearItem( SID_REFERER ); + uno::Reference< frame::XModel > xModel ( GetModel(), uno::UNO_QUERY ); + if ( xModel.is() ) + { + SfxItemSet *pSet = GetMedium()->GetItemSet(); + if ( !GetMedium()->IsReadOnly() ) + pSet->ClearItem( SID_INPUTSTREAM ); + uno::Sequence< beans::PropertyValue > aArgs; + TransformItems( SID_OPENDOC, *pSet, aArgs ); + xModel->attachResource( GetMedium()->GetOrigURL(), aArgs ); + impl_addToModelCollection(xModel); } + + pImpl->bModelInitialized = true; } void SfxObjectShell::FinishedLoading( SfxLoadedFlags nFlags ) @@ -1095,44 +1095,44 @@ void SfxObjectShell::FinishedLoading( SfxLoadedFlags nFlags ) pImpl->nLoadedFlags |= nFlags; - if ( pImpl->nFlagsInProgress == SfxLoadedFlags::NONE ) - { - // in case of reentrance calls the first called FinishedLoading() call on the stack - // should do the notification, in result the notification is done when all the FinishedLoading() calls are finished + if ( pImpl->nFlagsInProgress != SfxLoadedFlags::NONE ) + return; - if ( bSetModifiedTRUE ) - SetModified(); - else - SetModified( false ); + // in case of reentrance calls the first called FinishedLoading() call on the stack + // should do the notification, in result the notification is done when all the FinishedLoading() calls are finished - if ( (pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) && (pImpl->nLoadedFlags & SfxLoadedFlags::IMAGES ) ) - { - const SfxBoolItem* pTemplateItem = SfxItemSet::GetItem<SfxBoolItem>(pMedium->GetItemSet(), SID_TEMPLATE, false); - bool bTemplate = pTemplateItem && pTemplateItem->GetValue(); + if ( bSetModifiedTRUE ) + SetModified(); + else + SetModified( false ); - // closing the streams on loading should be under control of SFX! - DBG_ASSERT( pMedium->IsOpen(), "Don't close the medium when loading documents!" ); + if ( (pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) && (pImpl->nLoadedFlags & SfxLoadedFlags::IMAGES ) ) + { + const SfxBoolItem* pTemplateItem = SfxItemSet::GetItem<SfxBoolItem>(pMedium->GetItemSet(), SID_TEMPLATE, false); + bool bTemplate = pTemplateItem && pTemplateItem->GetValue(); - if ( bTemplate ) - { - TemplateDisconnectionAfterLoad(); - } - else - { - // if a readonly medium has storage then it's stream is already based on temporary file - if( !(pMedium->GetOpenMode() & StreamMode::WRITE) && !pMedium->HasStorage_Impl() ) - // don't lock file opened read only - pMedium->CloseInStream(); - } + // closing the streams on loading should be under control of SFX! + DBG_ASSERT( pMedium->IsOpen(), "Don't close the medium when loading documents!" ); + + if ( bTemplate ) + { + TemplateDisconnectionAfterLoad(); + } + else + { + // if a readonly medium has storage then it's stream is already based on temporary file + if( !(pMedium->GetOpenMode() & StreamMode::WRITE) && !pMedium->HasStorage_Impl() ) + // don't lock file opened read only + pMedium->CloseInStream(); } + } - SetInitialized_Impl( false ); + SetInitialized_Impl( false ); - // Title is not available until loading has finished - Broadcast( SfxHint( SfxHintId::TitleChanged ) ); - if ( pImpl->nEventId != SfxEventHintId::NONE ) - PostActivateEvent_Impl(SfxViewFrame::GetFirst(this)); - } + // Title is not available until loading has finished + Broadcast( SfxHint( SfxHintId::TitleChanged ) ); + if ( pImpl->nEventId != SfxEventHintId::NONE ) + PostActivateEvent_Impl(SfxViewFrame::GetFirst(this)); } void SfxObjectShell::TemplateDisconnectionAfterLoad() @@ -1141,89 +1141,89 @@ void SfxObjectShell::TemplateDisconnectionAfterLoad() //TODO/LATER: should the templates always be XML docs! SfxMedium* pTmpMedium = pMedium; - if ( pTmpMedium ) + if ( !pTmpMedium ) + return; + + const OUString aName( pTmpMedium->GetName() ); + const SfxStringItem* pTemplNamItem = SfxItemSet::GetItem<SfxStringItem>(pTmpMedium->GetItemSet(), SID_TEMPLATE_NAME, false); + OUString aTemplateName; + if ( pTemplNamItem ) + aTemplateName = pTemplNamItem->GetValue(); + else { - const OUString aName( pTmpMedium->GetName() ); - const SfxStringItem* pTemplNamItem = SfxItemSet::GetItem<SfxStringItem>(pTmpMedium->GetItemSet(), SID_TEMPLATE_NAME, false); - OUString aTemplateName; - if ( pTemplNamItem ) - aTemplateName = pTemplNamItem->GetValue(); - else + // !TODO/LATER: what's this?! + // Interactive ( DClick, Contextmenu ) no long name is included + aTemplateName = getDocProperties()->getTitle(); + if ( aTemplateName.isEmpty() ) { - // !TODO/LATER: what's this?! - // Interactive ( DClick, Contextmenu ) no long name is included - aTemplateName = getDocProperties()->getTitle(); - if ( aTemplateName.isEmpty() ) - { - INetURLObject aURL( aName ); - aURL.CutExtension(); - aTemplateName = aURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset ); - } + INetURLObject aURL( aName ); + aURL.CutExtension(); + aTemplateName = aURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset ); } + } - // set medium to noname - pTmpMedium->SetName( OUString(), true ); - pTmpMedium->Init_Impl(); + // set medium to noname + pTmpMedium->SetName( OUString(), true ); + pTmpMedium->Init_Impl(); - // drop resource - SetNoName(); - InvalidateName(); + // drop resource + SetNoName(); + InvalidateName(); - if( IsPackageStorageFormat_Impl( *pTmpMedium ) ) + if( IsPackageStorageFormat_Impl( *pTmpMedium ) ) + { + // untitled document must be based on temporary storage + // the medium should not dispose the storage in this case + uno::Reference < embed::XStorage > xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage(); + GetStorage()->copyToStorage( xTmpStor ); + + // the medium should disconnect from the original location + // the storage should not be disposed since the document is still + // based on it, but in DoSaveCompleted it will be disposed + pTmpMedium->CanDisposeStorage_Impl( false ); + pTmpMedium->Close(); + + // setting the new storage the medium will be based on + pTmpMedium->SetStorage_Impl( xTmpStor ); + + pMedium = nullptr; + bool ok = DoSaveCompleted( pTmpMedium ); + assert(pMedium != nullptr); + if( ok ) { - // untitled document must be based on temporary storage - // the medium should not dispose the storage in this case - uno::Reference < embed::XStorage > xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage(); - GetStorage()->copyToStorage( xTmpStor ); - - // the medium should disconnect from the original location - // the storage should not be disposed since the document is still - // based on it, but in DoSaveCompleted it will be disposed - pTmpMedium->CanDisposeStorage_Impl( false ); - pTmpMedium->Close(); - - // setting the new storage the medium will be based on - pTmpMedium->SetStorage_Impl( xTmpStor ); - - pMedium = nullptr; - bool ok = DoSaveCompleted( pTmpMedium ); - assert(pMedium != nullptr); - if( ok ) - { - const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(pMedium->GetItemSet(), SID_DOC_SALVAGE, false); - bool bSalvage = pSalvageItem != nullptr; - - if ( !bSalvage ) - { - // some further initializations for templates - SetTemplate_Impl( aName, aTemplateName, this ); - } + const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(pMedium->GetItemSet(), SID_DOC_SALVAGE, false); + bool bSalvage = pSalvageItem != nullptr; - // the medium should not dispose the storage, DoSaveCompleted() has let it to do so - pTmpMedium->CanDisposeStorage_Impl( false ); - } - else + if ( !bSalvage ) { - SetError(ERRCODE_IO_GENERAL); + // some further initializations for templates + SetTemplate_Impl( aName, aTemplateName, this ); } + + // the medium should not dispose the storage, DoSaveCompleted() has let it to do so + pTmpMedium->CanDisposeStorage_Impl( false ); } else { - // some further initializations for templates - SetTemplate_Impl( aName, aTemplateName, this ); - pTmpMedium->CreateTempFile(); + SetError(ERRCODE_IO_GENERAL); } + } + else + { + // some further initializations for templates + SetTemplate_Impl( aName, aTemplateName, this ); + pTmpMedium->CreateTempFile(); + } - // templates are never readonly - pTmpMedium->GetItemSet()->ClearItem( SID_DOC_READONLY ); - pTmpMedium->SetOpenMode( SFX_STREAM_READWRITE, true ); + // templates are never readonly + pTmpMedium->GetItemSet()->ClearItem( SID_DOC_READONLY ); + pTmpMedium->SetOpenMode( SFX_STREAM_READWRITE, true ); - // notifications about possible changes in readonly state and document info - Broadcast( SfxHint(SfxHintId::ModeChanged) ); + // notifications about possible changes in readonly state and document info + Broadcast( SfxHint(SfxHintId::ModeChanged) ); - // created untitled document can't be modified - SetModified( false ); - } + // created untitled document can't be modified + SetModified( false ); } diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 2d202cc79376..f18ddcc5d0bb 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -223,30 +223,30 @@ bool SfxInstanceCloseGuard_Impl::Init_Impl( const uno::Reference< util::XCloseab SfxInstanceCloseGuard_Impl::~SfxInstanceCloseGuard_Impl() { - if ( m_xCloseable.is() && m_xPreventer.is() ) + if ( !m_xCloseable.is() || !m_xPreventer.is() ) + return; + + try { - try - { - m_xCloseable->removeCloseListener( m_xPreventer.get() ); - } - catch( uno::Exception& ) - { - } + m_xCloseable->removeCloseListener( m_xPreventer.get() ); + } + catch( uno::Exception& ) + { + } - try + try + { + if ( m_xPreventer.is() ) { - if ( m_xPreventer.is() ) - { - m_xPreventer->SetPreventClose( false ); + m_xPreventer->SetPreventClose( false ); - if ( m_xPreventer->HasOwnership() ) - m_xCloseable->close( true ); // TODO: do it asynchronously - } - } - catch( uno::Exception& ) - { + if ( m_xPreventer->HasOwnership() ) + m_xCloseable->close( true ); // TODO: do it asynchronously } } + catch( uno::Exception& ) + { + } } diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index b21a8012d8c9..06b9ff7d061f 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -306,78 +306,77 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto { uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY ); - if ( xProps.is() ) - { - SotClipboardFormatId nClipFormat = SotClipboardFormatId::NONE; + if ( !xProps.is() ) + return; - SvGlobalName aName; - OUString aFullTypeName, aShortTypeName, aAppName; - FillClass( &aName, &nClipFormat, &aAppName, &aFullTypeName, &aShortTypeName, nVersion, bTemplate ); + SotClipboardFormatId nClipFormat = SotClipboardFormatId::NONE; - if ( nClipFormat != SotClipboardFormatId::NONE ) - { - // basic doesn't have a ClipFormat - // without MediaType the storage is not really usable, but currently the BasicIDE still - // is an SfxObjectShell and so we can't take this as an error - datatransfer::DataFlavor aDataFlavor; - SotExchange::GetFormatDataFlavor( nClipFormat, aDataFlavor ); - if ( !aDataFlavor.MimeType.isEmpty() ) - { - try - { - xProps->setPropertyValue("MediaType", uno::makeAny( aDataFlavor.MimeType ) ); - } - catch( uno::Exception& ) - { - const_cast<SfxObjectShell*>( this )->SetError(ERRCODE_IO_GENERAL); - } + SvGlobalName aName; + OUString aFullTypeName, aShortTypeName, aAppName; + FillClass( &aName, &nClipFormat, &aAppName, &aFullTypeName, &aShortTypeName, nVersion, bTemplate ); - SvtSaveOptions::ODFDefaultVersion nDefVersion = SvtSaveOptions::ODFVER_012; - if (!utl::ConfigManager::IsFuzzing()) - { - SvtSaveOptions aSaveOpt; - nDefVersion = aSaveOpt.GetODFDefaultVersion(); - } + if ( nClipFormat == SotClipboardFormatId::NONE ) + return; - // the default values, that should be used for ODF1.1 and older formats - uno::Sequence< beans::NamedValue > aEncryptionAlgs - { - { "StartKeyGenerationAlgorithm", css::uno::makeAny(xml::crypto::DigestID::SHA1) }, - { "EncryptionAlgorithm", css::uno::makeAny(xml::crypto::CipherID::BLOWFISH_CFB_8) }, - { "ChecksumAlgorithm", css::uno::makeAny(xml::crypto::DigestID::SHA1_1K) } - }; + // basic doesn't have a ClipFormat + // without MediaType the storage is not really usable, but currently the BasicIDE still + // is an SfxObjectShell and so we can't take this as an error + datatransfer::DataFlavor aDataFlavor; + SotExchange::GetFormatDataFlavor( nClipFormat, aDataFlavor ); + if ( aDataFlavor.MimeType.isEmpty() ) + return; - if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) - { - try - { - // older versions can not have this property set, it exists only starting from ODF1.2 - xProps->setPropertyValue("Version", uno::makeAny<OUString>( ODFVER_012_TEXT ) ); - } - catch( uno::Exception& ) - { - } + try + { + xProps->setPropertyValue("MediaType", uno::makeAny( aDataFlavor.MimeType ) ); + } + catch( uno::Exception& ) + { + const_cast<SfxObjectShell*>( this )->SetError(ERRCODE_IO_GENERAL); + } - aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA256; - aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA256_1K; - aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; - } + SvtSaveOptions::ODFDefaultVersion nDefVersion = SvtSaveOptions::ODFVER_012; + if (!utl::ConfigManager::IsFuzzing()) + { + SvtSaveOptions aSaveOpt; + nDefVersion = aSaveOpt.GetODFDefaultVersion(); + } - try - { - // set the encryption algorithms accordingly; - // the setting does not trigger encryption, - // it just provides the format for the case that contents should be encrypted - uno::Reference< embed::XEncryptionProtectedStorage > xEncr( xStorage, uno::UNO_QUERY_THROW ); - xEncr->setEncryptionAlgorithms( aEncryptionAlgs ); - } - catch( uno::Exception& ) - { - const_cast<SfxObjectShell*>( this )->SetError(ERRCODE_IO_GENERAL); - } + // the default values, that should be used for ODF1.1 and older formats + uno::Sequence< beans::NamedValue > aEncryptionAlgs + { + { "StartKeyGenerationAlgorithm", css::uno::makeAny(xml::crypto::DigestID::SHA1) }, + { "EncryptionAlgorithm", css::uno::makeAny(xml::crypto::CipherID::BLOWFISH_CFB_8) }, + { "ChecksumAlgorithm", css::uno::makeAny(xml::crypto::DigestID::SHA1_1K) } + }; - } + if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) + { + try + { + // older versions can not have this property set, it exists only starting from ODF1.2 + xProps->setPropertyValue("Version", uno::makeAny<OUString>( ODFVER_012_TEXT ) ); } + catch( uno::Exception& ) + { + } + + aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA256; + aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA256_1K; + aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; + } + + try + { + // set the encryption algorithms accordingly; + // the setting does not trigger encryption, + // it just provides the format for the case that contents should be encrypted + uno::Reference< embed::XEncryptionProtectedStorage > xEncr( xStorage, uno::UNO_QUERY_THROW ); + xEncr->setEncryptionAlgorithms( aEncryptionAlgs ); + } + catch( uno::Exception& ) + { + const_cast<SfxObjectShell*>( this )->SetError(ERRCODE_IO_GENERAL); } } diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 093fbbc4ecc9..4bf33375a479 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -890,30 +890,30 @@ void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComp #if HAVE_FEATURE_SCRIPTING BasicManager* pAppMgr = SfxApplication::GetBasicManager(); rTheCurrentComponent = _rxComponent; - if ( pAppMgr ) - { - // set "ThisComponent" for Basic - pAppMgr->SetGlobalUNOConstant( "ThisComponent", Any( _rxComponent ) ); + if ( !pAppMgr ) + return; + + // set "ThisComponent" for Basic + pAppMgr->SetGlobalUNOConstant( "ThisComponent", Any( _rxComponent ) ); - // set new current component for VBA compatibility - if ( _rxComponent.is() ) + // set new current component for VBA compatibility + if ( _rxComponent.is() ) + { + OUString aVBAConstName = lclGetVBAGlobalConstName( _rxComponent ); + if ( !aVBAConstName.isEmpty() ) { - OUString aVBAConstName = lclGetVBAGlobalConstName( _rxComponent ); - if ( !aVBAConstName.isEmpty() ) - { - pAppMgr->SetGlobalUNOConstant( aVBAConstName, Any( _rxComponent ) ); - s_aRegisteredVBAConstants[ _rxComponent.get() ] = aVBAConstName; - } + pAppMgr->SetGlobalUNOConstant( aVBAConstName, Any( _rxComponent ) ); + s_aRegisteredVBAConstants[ _rxComponent.get() ] = aVBAConstName; } - // no new component passed -> remove last registered VBA component - else if ( xOldCurrentComp.is() ) + } + // no new component passed -> remove last registered VBA component + else if ( xOldCurrentComp.is() ) + { + OUString aVBAConstName = lclGetVBAGlobalConstName( xOldCurrentComp ); + if ( !aVBAConstName.isEmpty() ) { - OUString aVBAConstName = lclGetVBAGlobalConstName( xOldCurrentComp ); - if ( !aVBAConstName.isEmpty() ) - { - pAppMgr->SetGlobalUNOConstant( aVBAConstName, Any( Reference< XInterface >() ) ); - s_aRegisteredVBAConstants.erase( xOldCurrentComp.get() ); - } + pAppMgr->SetGlobalUNOConstant( aVBAConstName, Any( Reference< XInterface >() ) ); + s_aRegisteredVBAConstants.erase( xOldCurrentComp.get() ); } } #endif diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx index de1a2c269ea4..6d39bfad10c0 100644 --- a/sfx2/source/doc/printhelper.cxx +++ b/sfx2/source/doc/printhelper.cxx @@ -151,18 +151,18 @@ SfxPrintHelper::SfxPrintHelper() void SAL_CALL SfxPrintHelper::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) { - if ( aArguments.getLength() ) + if ( !aArguments.getLength() ) + return; + + css::uno::Reference < css::frame::XModel > xModel; + aArguments[0] >>= xModel; + uno::Reference < lang::XUnoTunnel > xObj( xModel, uno::UNO_QUERY ); + uno::Sequence < sal_Int8 > aSeq( SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence() ); + sal_Int64 nHandle = xObj->getSomething( aSeq ); + if ( nHandle ) { - css::uno::Reference < css::frame::XModel > xModel; - aArguments[0] >>= xModel; - uno::Reference < lang::XUnoTunnel > xObj( xModel, uno::UNO_QUERY ); - uno::Sequence < sal_Int8 > aSeq( SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence() ); - sal_Int64 nHandle = xObj->getSomething( aSeq ); - if ( nHandle ) - { - m_pData->m_pObjectShell = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle )); - m_pData->StartListening(*m_pData->m_pObjectShell); - } + m_pData->m_pObjectShell = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle )); + m_pData->StartListening(*m_pData->m_pObjectShell); } } @@ -764,20 +764,20 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& // a) printing finished => move the file directly and forget the watcher thread // b) printing is asynchron and runs currently => start watcher thread and exit this method // This thread make all necessary things by itself. - if (pUCBPrintTempFile) + if (!pUCBPrintTempFile) + return; + + // a) + SfxPrinter* pPrinter = pView->GetPrinter(); + if ( ! pPrinter->IsPrinting() ) + ImplUCBPrintWatcher::moveAndDeleteTemp(&pUCBPrintTempFile,sUcbUrl); + // b) + else { - // a) - SfxPrinter* pPrinter = pView->GetPrinter(); - if ( ! pPrinter->IsPrinting() ) - ImplUCBPrintWatcher::moveAndDeleteTemp(&pUCBPrintTempFile,sUcbUrl); - // b) - else - { - // Note: we create(d) some resource on the heap (thread and temp file). - // They will be deleted by the thread automatically if he finish his run() method. - ImplUCBPrintWatcher* pWatcher = new ImplUCBPrintWatcher( pPrinter, pUCBPrintTempFile, sUcbUrl ); - pWatcher->create(); - } + // Note: we create(d) some resource on the heap (thread and temp file). + // They will be deleted by the thread automatically if he finish his run() method. + ImplUCBPrintWatcher* pWatcher = new ImplUCBPrintWatcher( pPrinter, pUCBPrintTempFile, sUcbUrl ); + pWatcher->create(); } } diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index e163345dac7a..e220b8eee639 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -471,20 +471,20 @@ SfxSaveGuard::~SfxSaveGuard() // Now we have to call close() again and delegate the ownership to the next one, which // can't accept that. Close(sal_False) can't work in this case. Because then the document will may be never closed ... - if ( m_pData->m_bSuicide ) + if ( !m_pData->m_bSuicide ) + return; + + // Reset this state. In case the new close() request is not accepted by someone else ... + // it's not a good idea to have two "owners" for close .-) + m_pData->m_bSuicide = false; + try { - // Reset this state. In case the new close() request is not accepted by someone else ... - // it's not a good idea to have two "owners" for close .-) - m_pData->m_bSuicide = false; - try - { - Reference< util::XCloseable > xClose(m_xModel, UNO_QUERY); - if (xClose.is()) - xClose->close(true); - } - catch(const util::CloseVetoException&) - {} + Reference< util::XCloseable > xClose(m_xModel, UNO_QUERY); + if (xClose.is()) + xClose->close(true); } + catch(const util::CloseVetoException&) + {} } SfxBaseModel::SfxBaseModel( SfxObjectShell *pObjectShell ) @@ -1522,115 +1522,115 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue > { SfxModelGuard aGuard( *this ); - if ( m_pData->m_pObjectShell.is() ) - { - SfxSaveGuard aSaveGuard(this, m_pData.get()); + if ( !m_pData->m_pObjectShell.is() ) + return; + + SfxSaveGuard aSaveGuard(this, m_pData.get()); - bool bCheckIn = false; - bool bOnMainThread = false; - for ( sal_Int32 nInd = 0; nInd < aSeqArgs.getLength(); nInd++ ) + bool bCheckIn = false; + bool bOnMainThread = false; + for ( sal_Int32 nInd = 0; nInd < aSeqArgs.getLength(); nInd++ ) + { + // check that only acceptable parameters are provided here + if ( aSeqArgs[nInd].Name != "VersionComment" && aSeqArgs[nInd].Name != "Author" + && aSeqArgs[nInd].Name != "DontTerminateEdit" + && aSeqArgs[nInd].Name != "InteractionHandler" && aSeqArgs[nInd].Name != "StatusIndicator" + && aSeqArgs[nInd].Name != "VersionMajor" + && aSeqArgs[nInd].Name != "FailOnWarning" + && aSeqArgs[nInd].Name != "CheckIn" + && aSeqArgs[nInd].Name != "NoFileSync" + && aSeqArgs[nInd].Name != "OnMainThread" ) { - // check that only acceptable parameters are provided here - if ( aSeqArgs[nInd].Name != "VersionComment" && aSeqArgs[nInd].Name != "Author" - && aSeqArgs[nInd].Name != "DontTerminateEdit" - && aSeqArgs[nInd].Name != "InteractionHandler" && aSeqArgs[nInd].Name != "StatusIndicator" - && aSeqArgs[nInd].Name != "VersionMajor" - && aSeqArgs[nInd].Name != "FailOnWarning" - && aSeqArgs[nInd].Name != "CheckIn" - && aSeqArgs[nInd].Name != "NoFileSync" - && aSeqArgs[nInd].Name != "OnMainThread" ) - { - const OUString aMessage( "Unexpected MediaDescriptor parameter: " + aSeqArgs[nInd].Name ); - throw lang::IllegalArgumentException( aMessage, Reference< XInterface >(), 1 ); - } - else if ( aSeqArgs[nInd].Name == "CheckIn" ) - { - aSeqArgs[nInd].Value >>= bCheckIn; - } - else if (aSeqArgs[nInd].Name == "OnMainThread") - { - aSeqArgs[nInd].Value >>= bOnMainThread; - } + const OUString aMessage( "Unexpected MediaDescriptor parameter: " + aSeqArgs[nInd].Name ); + throw lang::IllegalArgumentException( aMessage, Reference< XInterface >(), 1 ); } + else if ( aSeqArgs[nInd].Name == "CheckIn" ) + { + aSeqArgs[nInd].Value >>= bCheckIn; + } + else if (aSeqArgs[nInd].Name == "OnMainThread") + { + aSeqArgs[nInd].Value >>= bOnMainThread; + } + } - // Remove CheckIn property if needed - sal_uInt16 nSlotId = SID_SAVEDOC; - Sequence< beans::PropertyValue > aArgs = aSeqArgs; - if ( bCheckIn ) + // Remove CheckIn property if needed + sal_uInt16 nSlotId = SID_SAVEDOC; + Sequence< beans::PropertyValue > aArgs = aSeqArgs; + if ( bCheckIn ) + { + nSlotId = SID_CHECKIN; + sal_Int32 nLength = aSeqArgs.getLength( ); + aArgs = Sequence< beans::PropertyValue >( nLength - 1 ); + sal_Int32 nNewI = 0; + for ( sal_Int32 i = 0; i < nLength; ++i ) { - nSlotId = SID_CHECKIN; - sal_Int32 nLength = aSeqArgs.getLength( ); - aArgs = Sequence< beans::PropertyValue >( nLength - 1 ); - sal_Int32 nNewI = 0; - for ( sal_Int32 i = 0; i < nLength; ++i ) + beans::PropertyValue aProp = aSeqArgs[i]; + if ( aProp.Name != "CheckIn" ) { - beans::PropertyValue aProp = aSeqArgs[i]; - if ( aProp.Name != "CheckIn" ) - { - aArgs[nNewI] = aProp; - ++nNewI; - } + aArgs[nNewI] = aProp; + ++nNewI; } } + } - std::unique_ptr<SfxAllItemSet> pParams(new SfxAllItemSet( SfxGetpApp()->GetPool() )); - TransformParameters( nSlotId, aArgs, *pParams ); + std::unique_ptr<SfxAllItemSet> pParams(new SfxAllItemSet( SfxGetpApp()->GetPool() )); + TransformParameters( nSlotId, aArgs, *pParams ); - SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::SaveDoc, GlobalEventConfig::GetEventName(GlobalEventId::SAVEDOC), m_pData->m_pObjectShell.get() ) ); + SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::SaveDoc, GlobalEventConfig::GetEventName(GlobalEventId::SAVEDOC), m_pData->m_pObjectShell.get() ) ); - bool bRet = false; + bool bRet = false; - // TODO/LATER: let the embedded case of saving be handled more careful - if ( m_pData->m_pObjectShell->GetCreateMode() == SfxObjectCreateMode::EMBEDDED ) + // TODO/LATER: let the embedded case of saving be handled more careful + if ( m_pData->m_pObjectShell->GetCreateMode() == SfxObjectCreateMode::EMBEDDED ) + { + // If this is an embedded object that has no URL based location it should be stored to own storage. + // An embedded object can have a location based on URL in case it is a link, then it should be + // stored in normal way. + if ( !hasLocation() || getLocation().startsWith("private:") ) { - // If this is an embedded object that has no URL based location it should be stored to own storage. - // An embedded object can have a location based on URL in case it is a link, then it should be - // stored in normal way. - if ( !hasLocation() || getLocation().startsWith("private:") ) - { - // actually in this very rare case only UI parameters have sense - // TODO/LATER: should be done later, after integration of sb19 - bRet = m_pData->m_pObjectShell->DoSave() - && m_pData->m_pObjectShell->DoSaveCompleted(); - } - else - { - bRet = m_pData->m_pObjectShell->Save_Impl( pParams.get() ); - } + // actually in this very rare case only UI parameters have sense + // TODO/LATER: should be done later, after integration of sb19 + bRet = m_pData->m_pObjectShell->DoSave() + && m_pData->m_pObjectShell->DoSaveCompleted(); } else { - // Tell the SfxMedium if we are in checkin instead of normal save - m_pData->m_pObjectShell->GetMedium( )->SetInCheckIn( nSlotId == SID_CHECKIN ); - if (bOnMainThread) - bRet = vcl::solarthread::syncExecute( - std::bind(&SaveImplStatic, m_pData->m_pObjectShell.get(), pParams.get())); - else - bRet = m_pData->m_pObjectShell->Save_Impl(pParams.get()); - m_pData->m_pObjectShell->GetMedium( )->SetInCheckIn( nSlotId != SID_CHECKIN ); + bRet = m_pData->m_pObjectShell->Save_Impl( pParams.get() ); } + } + else + { + // Tell the SfxMedium if we are in checkin instead of normal save + m_pData->m_pObjectShell->GetMedium( )->SetInCheckIn( nSlotId == SID_CHECKIN ); + if (bOnMainThread) + bRet = vcl::solarthread::syncExecute( + std::bind(&SaveImplStatic, m_pData->m_pObjectShell.get(), pParams.get())); + else + bRet = m_pData->m_pObjectShell->Save_Impl(pParams.get()); + m_pData->m_pObjectShell->GetMedium( )->SetInCheckIn( nSlotId != SID_CHECKIN ); + } - pParams.reset(); + pParams.reset(); - ErrCode nErrCode = m_pData->m_pObjectShell->GetError() ? m_pData->m_pObjectShell->GetError() - : ERRCODE_IO_CANTWRITE; - m_pData->m_pObjectShell->ResetError(); + ErrCode nErrCode = m_pData->m_pObjectShell->GetError() ? m_pData->m_pObjectShell->GetError() + : ERRCODE_IO_CANTWRITE; + m_pData->m_pObjectShell->ResetError(); - if ( bRet ) - { - m_pData->m_aPreusedFilterName = GetMediumFilterName_Impl(); + if ( bRet ) + { + m_pData->m_aPreusedFilterName = GetMediumFilterName_Impl(); - SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::SaveDocDone, GlobalEventConfig::GetEventName(GlobalEventId::SAVEDOCDONE), m_pData->m_pObjectShell.get() ) ); - } - else - { - // write the contents of the logger to the file - SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::SaveDocFailed, GlobalEventConfig::GetEventName(GlobalEventId::SAVEDOCFAILED), m_pData->m_pObjectShell.get() ) ); + SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::SaveDocDone, GlobalEventConfig::GetEventName(GlobalEventId::SAVEDOCDONE), m_pData->m_pObjectShell.get() ) ); + } + else + { + // write the contents of the logger to the file + SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::SaveDocFailed, GlobalEventConfig::GetEventName(GlobalEventId::SAVEDOCFAILED), m_pData->m_pObjectShell.get() ) ); - throw task::ErrorCodeIOException( - "SfxBaseModel::storeSelf: " + nErrCode.toHexString(), - Reference< XInterface >(), sal_uInt32(nErrCode)); - } + throw task::ErrorCodeIOException( + "SfxBaseModel::storeSelf: " + nErrCode.toHexString(), + Reference< XInterface >(), sal_uInt32(nErrCode)); } } @@ -1655,23 +1655,23 @@ void SAL_CALL SfxBaseModel::storeAsURL( const OUString& rURL SfxModelGuard aGuard( *this ); comphelper::ProfileZone aZone("storeAs"); - if ( m_pData->m_pObjectShell.is() ) - { - SfxSaveGuard aSaveGuard(this, m_pData.get()); + if ( !m_pData->m_pObjectShell.is() ) + return; - impl_store( rURL, rArgs, false ); + SfxSaveGuard aSaveGuard(this, m_pData.get()); - Sequence< beans::PropertyValue > aSequence ; - TransformItems( SID_OPENDOC, *m_pData->m_pObjectShell->GetMedium()->GetItemSet(), aSequence ); - attachResource( rURL, aSequence ); + impl_store( rURL, rArgs, false ); - loadCmisProperties( ); + Sequence< beans::PropertyValue > aSequence ; + TransformItems( SID_OPENDOC, *m_pData->m_pObjectShell->GetMedium()->GetItemSet(), aSequence ); + attachResource( rURL, aSequence ); + + loadCmisProperties( ); #if OSL_DEBUG_LEVEL > 0 - const SfxStringItem* pPasswdItem = SfxItemSet::GetItem<SfxStringItem>(m_pData->m_pObjectShell->GetMedium()->GetItemSet(), SID_PASSWORD, false); - OSL_ENSURE( !pPasswdItem, "There should be no Password property in the document MediaDescriptor!" ); + const SfxStringItem* pPasswdItem = SfxItemSet::GetItem<SfxStringItem>(m_pData->m_pObjectShell->GetMedium()->GetItemSet(), SID_PASSWORD, false); + OSL_ENSURE( !pPasswdItem, "There should be no Password property in the document MediaDescriptor!" ); #endif - } } @@ -1695,24 +1695,24 @@ void SAL_CALL SfxBaseModel::storeToURL( const OUString& rURL SfxModelGuard aGuard( *this ); comphelper::ProfileZone aZone("storeToURL"); - if ( m_pData->m_pObjectShell.is() ) + if ( !m_pData->m_pObjectShell.is() ) + return; + + SfxSaveGuard aSaveGuard(this, m_pData.get()); + try { + utl::MediaDescriptor aDescriptor(rArgs); + bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault("OnMainThread", false); + if (bOnMainThread) + vcl::solarthread::syncExecute(std::bind(&ImplStoreStatic, this, rURL, rArgs, true)); + else + impl_store(rURL, rArgs, true); + } + catch (const uno::Exception &e) { - SfxSaveGuard aSaveGuard(this, m_pData.get()); - try { - utl::MediaDescriptor aDescriptor(rArgs); - bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault("OnMainThread", false); - if (bOnMainThread) - vcl::solarthread::syncExecute(std::bind(&ImplStoreStatic, this, rURL, rArgs, true)); - else - impl_store(rURL, rArgs, true); - } - catch (const uno::Exception &e) - { - // convert to the exception we announce in the throw - // (eg. neon likes to throw InteractiveAugmentedIOException which - // is not an io::IOException) - throw io::IOException(e.Message, e.Context); - } + // convert to the exception we announce in the throw + // (eg. neon likes to throw InteractiveAugmentedIOException which + // is not an io::IOException) + throw io::IOException(e.Message, e.Context); } } @@ -1773,21 +1773,21 @@ void SAL_CALL SfxBaseModel::initNew() // the object shell should exist always DBG_ASSERT( m_pData->m_pObjectShell.is(), "Model is useless without an ObjectShell" ); - if ( m_pData->m_pObjectShell.is() ) - { - if( m_pData->m_pObjectShell->GetMedium() ) - throw frame::DoubleInitializationException(); + if ( !m_pData->m_pObjectShell.is() ) + return; - bool bRes = m_pData->m_pObjectShell->DoInitNew(); - ErrCode nErrCode = m_pData->m_pObjectShell->GetError() ? - m_pData->m_pObjectShell->GetError() : ERRCODE_IO_CANTCREATE; - m_pData->m_pObjectShell->ResetError(); + if( m_pData->m_pObjectShell->GetMedium() ) + throw frame::DoubleInitializationException(); - if ( !bRes ) - throw task::ErrorCodeIOException( - "SfxBaseModel::initNew: " + nErrCode.toHexString(), - Reference< XInterface >(), sal_uInt32(nErrCode)); - } + bool bRes = m_pData->m_pObjectShell->DoInitNew(); + ErrCode nErrCode = m_pData->m_pObjectShell->GetError() ? + m_pData->m_pObjectShell->GetError() : ERRCODE_IO_CANTCREATE; + m_pData->m_pObjectShell->ResetError(); + + if ( !bRes ) + throw task::ErrorCodeIOException( + "SfxBaseModel::initNew: " + nErrCode.toHexString(), + Reference< XInterface >(), sal_uInt32(nErrCode)); } namespace { @@ -2427,23 +2427,23 @@ void SAL_CALL SfxBaseModel::setCmisProperties( const Sequence< document::CmisPro void SAL_CALL SfxBaseModel::updateCmisProperties( const Sequence< document::CmisProperty >& aProperties ) { SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium(); - if ( pMedium ) + if ( !pMedium ) + return; + + try { - try - { - ::ucbhelper::Content aContent( pMedium->GetName( ), - Reference<ucb::XCommandEnvironment>(), - comphelper::getProcessComponentContext() ); + ::ucbhelper::Content aContent( pMedium->GetName( ), + Reference<ucb::XCommandEnvironment>(), + comphelper::getProcessComponentContext() ); - aContent.executeCommand( "updateProperties", uno::makeAny( aProperties ) ); - loadCmisProperties( ); - } - catch (const Exception & e) - { - css::uno::Any anyEx = cppu::getCaughtException(); - throw lang::WrappedTargetRuntimeException( e.Message, - e.Context, anyEx ); - } + aContent.executeCommand( "updateProperties", uno::makeAny( aProperties ) ); + loadCmisProperties( ); + } + catch (const Exception & e) + { + css::uno::Any anyEx = cppu::getCaughtException(); + throw lang::WrappedTargetRuntimeException( e.Message, + e.Context, anyEx ); } } @@ -2451,104 +2451,104 @@ void SAL_CALL SfxBaseModel::updateCmisProperties( const Sequence< document::Cmis void SAL_CALL SfxBaseModel::checkOut( ) { SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium(); - if ( pMedium ) + if ( !pMedium ) + return; + + try { - try - { - ::ucbhelper::Content aContent( pMedium->GetName(), - Reference<ucb::XCommandEnvironment>(), - comphelper::getProcessComponentContext() ); + ::ucbhelper::Content aContent( pMedium->GetName(), + Reference<ucb::XCommandEnvironment>(), + comphelper::getProcessComponentContext() ); - Any aResult = aContent.executeCommand( "checkout", Any( ) ); - OUString sURL; - aResult >>= sURL; + Any aResult = aContent.executeCommand( "checkout", Any( ) ); + OUString sURL; + aResult >>= sURL; - m_pData->m_pObjectShell->GetMedium( )->SetName( sURL ); - m_pData->m_pObjectShell->GetMedium( )->GetMedium_Impl( ); - m_pData->m_xDocumentProperties->setTitle( getTitle( ) ); - Sequence< beans::PropertyValue > aSequence ; - TransformItems( SID_OPENDOC, *pMedium->GetItemSet(), aSequence ); - attachResource( sURL, aSequence ); + m_pData->m_pObjectShell->GetMedium( )->SetName( sURL ); + m_pData->m_pObjectShell->GetMedium( )->GetMedium_Impl( ); + m_pData->m_xDocumentProperties->setTitle( getTitle( ) ); + Sequence< beans::PropertyValue > aSequence ; + TransformItems( SID_OPENDOC, *pMedium->GetItemSet(), aSequence ); + attachResource( sURL, aSequence ); - // Reload the CMIS properties - loadCmisProperties( ); - } - catch ( const Exception & e ) - { - css::uno::Any anyEx = cppu::getCaughtException(); - throw lang::WrappedTargetRuntimeException( e.Message, - e.Context, anyEx ); - } + // Reload the CMIS properties + loadCmisProperties( ); + } + catch ( const Exception & e ) + { + css::uno::Any anyEx = cppu::getCaughtException(); + throw lang::WrappedTargetRuntimeException( e.Message, + e.Context, anyEx ); } } void SAL_CALL SfxBaseModel::cancelCheckOut( ) { SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium(); - if ( pMedium ) + if ( !pMedium ) + return; + + try { - try - { - ::ucbhelper::Content aContent( pMedium->GetName(), - Reference<ucb::XCommandEnvironment>(), - comphelper::getProcessComponentContext() ); + ::ucbhelper::Content aContent( pMedium->GetName(), + Reference<ucb::XCommandEnvironment>(), + comphelper::getProcessComponentContext() ); - Any aResult = aContent.executeCommand( "cancelCheckout", Any( ) ); - OUString sURL; - aResult >>= sURL; + Any aResult = aContent.executeCommand( "cancelCheckout", Any( ) ); + OUString sURL; + aResult >>= sURL; - m_pData->m_pObjectShell->GetMedium( )->SetName( sURL ); - } - catch ( const Exception & e ) - { - css::uno::Any anyEx = cppu::getCaughtException(); - throw lang::WrappedTargetRuntimeException( e.Message, - e.Context, anyEx ); - } + m_pData->m_pObjectShell->GetMedium( )->SetName( sURL ); + } + catch ( const Exception & e ) + { + css::uno::Any anyEx = cppu::getCaughtException(); + throw lang::WrappedTargetRuntimeException( e.Message, + e.Context, anyEx ); } } void SAL_CALL SfxBaseModel::checkIn( sal_Bool bIsMajor, const OUString& rMessage ) { SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium(); - if ( pMedium ) + if ( !pMedium ) + return; + + try { - try + Sequence< beans::PropertyValue > aProps( 3 ); + aProps[0].Name = "VersionMajor"; + aProps[0].Value <<= bIsMajor; + aProps[1].Name = "VersionComment"; + aProps[1].Value <<= rMessage; + aProps[2].Name = "CheckIn"; + aProps[2].Value <<= true; + + const OUString sName( pMedium->GetName( ) ); + storeSelf( aProps ); + + // Refresh pMedium as it has probably changed during the storeSelf call + pMedium = m_pData->m_pObjectShell->GetMedium( ); + const OUString sNewName( pMedium->GetName( ) ); + + // URL has changed, update the document + if ( sName != sNewName ) { - Sequence< beans::PropertyValue > aProps( 3 ); - aProps[0].Name = "VersionMajor"; - aProps[0].Value <<= bIsMajor; - aProps[1].Name = "VersionComment"; - aProps[1].Value <<= rMessage; - aProps[2].Name = "CheckIn"; - aProps[2].Value <<= true; - - const OUString sName( pMedium->GetName( ) ); - storeSelf( aProps ); - - // Refresh pMedium as it has probably changed during the storeSelf call - pMedium = m_pData->m_pObjectShell->GetMedium( ); - const OUString sNewName( pMedium->GetName( ) ); - - // URL has changed, update the document - if ( sName != sNewName ) - { - m_pData->m_xDocumentProperties->setTitle( getTitle( ) ); - Sequence< beans::PropertyValue > aSequence ; - TransformItems( SID_OPENDOC, *pMedium->GetItemSet(), aSequence ); - attachResource( sNewName, aSequence ); + m_pData->m_xDocumentProperties->setTitle( getTitle( ) ); + Sequence< beans::PropertyValue > aSequence ; + TransformItems( SID_OPENDOC, *pMedium->GetItemSet(), aSequence ); + attachResource( sNewName, aSequence ); - // Reload the CMIS properties - loadCmisProperties( ); - } - } - catch ( const Exception & e ) - { - css::uno::Any anyEx = cppu::getCaughtException(); - throw lang::WrappedTargetRuntimeException( e.Message, - e.Context, anyEx ); + // Reload the CMIS properties + loadCmisProperties( ); } } + catch ( const Exception & e ) + { + css::uno::Any anyEx = cppu::getCaughtException(); + throw lang::WrappedTargetRuntimeException( e.Message, + e.Context, anyEx ); + } } uno::Sequence< document::CmisVersion > SAL_CALL SfxBaseModel::getAllVersions( ) @@ -2628,29 +2628,29 @@ sal_Bool SAL_CALL SfxBaseModel::canCheckIn( ) void SfxBaseModel::loadCmisProperties( ) { SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium(); - if ( pMedium ) + if ( !pMedium ) + return; + + try { - try - { - ::ucbhelper::Content aContent( pMedium->GetName( ), - utl::UCBContentHelper::getDefaultCommandEnvironment(), - comphelper::getProcessComponentContext() ); - Reference < beans::XPropertySetInfo > xProps = aContent.getProperties(); - const OUString aCmisProps( "CmisProperties" ); - if ( xProps->hasPropertyByName( aCmisProps ) ) - { - Sequence< document::CmisProperty> aCmisProperties; - aContent.getPropertyValue( aCmisProps ) >>= aCmisProperties; - setCmisProperties( aCmisProperties ); - } - } - catch (const ucb::ContentCreationException &) - { - } - catch (const ucb::CommandAbortedException &) + ::ucbhelper::Content aContent( pMedium->GetName( ), + utl::UCBContentHelper::getDefaultCommandEnvironment(), + comphelper::getProcessComponentContext() ); + Reference < beans::XPropertySetInfo > xProps = aContent.getProperties(); + const OUString aCmisProps( "CmisProperties" ); + if ( xProps->hasPropertyByName( aCmisProps ) ) { + Sequence< document::CmisProperty> aCmisProperties; + aContent.getPropertyValue( aCmisProps ) >>= aCmisProperties; + setCmisProperties( aCmisProperties ); } } + catch (const ucb::ContentCreationException &) + { + } + catch (const ucb::CommandAbortedException &) + { + } } SfxMedium* SfxBaseModel::handleLoadError( ErrCode nError, SfxMedium* pMedium ) @@ -2729,92 +2729,92 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC , if ( !m_pData ) return; - if ( &rBC == m_pData->m_pObjectShell.get() ) + if ( &rBC != m_pData->m_pObjectShell.get() ) + return; + + if ( rHint.GetId() == SfxHintId::DocChanged ) + changing(); + + const SfxEventHint* pNamedHint = dynamic_cast<const SfxEventHint*>(&rHint); + if ( pNamedHint ) { - if ( rHint.GetId() == SfxHintId::DocChanged ) - changing(); - const SfxEventHint* pNamedHint = dynamic_cast<const SfxEventHint*>(&rHint); - if ( pNamedHint ) + switch ( pNamedHint->GetEventId() ) { - - switch ( pNamedHint->GetEventId() ) - { - case SfxEventHintId::StorageChanged: + case SfxEventHintId::StorageChanged: + { + if ( m_pData->m_xUIConfigurationManager.is() + && m_pData->m_pObjectShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) { - if ( m_pData->m_xUIConfigurationManager.is() - && m_pData->m_pObjectShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) - { - Reference< embed::XStorage > xConfigStorage; - const OUString aUIConfigFolderName( "Configurations2" ); + Reference< embed::XStorage > xConfigStorage; + const OUString aUIConfigFolderName( "Configurations2" ); - xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, embed::ElementModes::READWRITE ); - if ( !xConfigStorage.is() ) - xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, embed::ElementModes::READ ); + xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, embed::ElementModes::READWRITE ); + if ( !xConfigStorage.is() ) + xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, embed::ElementModes::READ ); - if ( xConfigStorage.is() || !m_pData->m_pObjectShell->GetStorage()->hasByName( aUIConfigFolderName ) ) - { - // the storage is different, since otherwise it could not be opened, so it must be exchanged - m_pData->m_xUIConfigurationManager->setStorage( xConfigStorage ); - } - else - { - OSL_FAIL( "Unexpected scenario!" ); - } + if ( xConfigStorage.is() || !m_pData->m_pObjectShell->GetStorage()->hasByName( aUIConfigFolderName ) ) + { + // the storage is different, since otherwise it could not be opened, so it must be exchanged + m_pData->m_xUIConfigurationManager->setStorage( xConfigStorage ); + } + else + { + OSL_FAIL( "Unexpected scenario!" ); } - - ListenForStorage_Impl( m_pData->m_pObjectShell->GetStorage() ); - } - break; - - case SfxEventHintId::LoadFinished: - { - impl_getPrintHelper(); - ListenForStorage_Impl( m_pData->m_pObjectShell->GetStorage() ); - m_pData->m_bModifiedSinceLastSave = false; } - break; - - case SfxEventHintId::SaveAsDocDone: - { - m_pData->m_sURL = m_pData->m_pObjectShell->GetMedium()->GetName(); - SfxItemSet *pSet = m_pData->m_pObjectShell->GetMedium()->GetItemSet(); - Sequence< beans::PropertyValue > aArgs; - TransformItems( SID_SAVEASDOC, *pSet, aArgs ); - addTitle_Impl( aArgs, m_pData->m_pObjectShell->GetTitle() ); - attachResource( m_pData->m_pObjectShell->GetMedium()->GetName(), aArgs ); - } - break; + ListenForStorage_Impl( m_pData->m_pObjectShell->GetStorage() ); + } + break; - case SfxEventHintId::DocCreated: - { - impl_getPrintHelper(); - m_pData->m_bModifiedSinceLastSave = false; - } - break; + case SfxEventHintId::LoadFinished: + { + impl_getPrintHelper(); + ListenForStorage_Impl( m_pData->m_pObjectShell->GetStorage() ); + m_pData->m_bModifiedSinceLastSave = false; + } + break; - case SfxEventHintId::ModifyChanged: - { - m_pData->m_bModifiedSinceLastSave = isModified(); - } - break; - default: break; - } + case SfxEventHintId::SaveAsDocDone: + { + m_pData->m_sURL = m_pData->m_pObjectShell->GetMedium()->GetName(); - const SfxViewEventHint* pViewHint = dynamic_cast<const SfxViewEventHint*>(&rHint); - postEvent_Impl( pNamedHint->GetEventName(), pViewHint ? pViewHint->GetController() : Reference< frame::XController2 >() ); + SfxItemSet *pSet = m_pData->m_pObjectShell->GetMedium()->GetItemSet(); + Sequence< beans::PropertyValue > aArgs; + TransformItems( SID_SAVEASDOC, *pSet, aArgs ); + addTitle_Impl( aArgs, m_pData->m_pObjectShell->GetTitle() ); + attachResource( m_pData->m_pObjectShell->GetMedium()->GetName(), aArgs ); } + break; - if ( rHint.GetId() == SfxHintId::TitleChanged ) + case SfxEventHintId::DocCreated: { - addTitle_Impl( m_pData->m_seqArguments, m_pData->m_pObjectShell->GetTitle() ); - postEvent_Impl( GlobalEventConfig::GetEventName( GlobalEventId::TITLECHANGED ) ); + impl_getPrintHelper(); + m_pData->m_bModifiedSinceLastSave = false; } - else if ( rHint.GetId() == SfxHintId::ModeChanged ) + break; + + case SfxEventHintId::ModifyChanged: { - postEvent_Impl( GlobalEventConfig::GetEventName( GlobalEventId::MODECHANGED ) ); + m_pData->m_bModifiedSinceLastSave = isModified(); + } + break; + default: break; } + + const SfxViewEventHint* pViewHint = dynamic_cast<const SfxViewEventHint*>(&rHint); + postEvent_Impl( pNamedHint->GetEventName(), pViewHint ? pViewHint->GetController() : Reference< frame::XController2 >() ); + } + + if ( rHint.GetId() == SfxHintId::TitleChanged ) + { + addTitle_Impl( m_pData->m_seqArguments, m_pData->m_pObjectShell->GetTitle() ); + postEvent_Impl( GlobalEventConfig::GetEventName( GlobalEventId::TITLECHANGED ) ); + } + else if ( rHint.GetId() == SfxHintId::ModeChanged ) + { + postEvent_Impl( GlobalEventConfig::GetEventName( GlobalEventId::MODECHANGED ) ); } } @@ -2979,129 +2979,129 @@ void SfxBaseModel::impl_store( const OUString& sURL } } - if ( !bSaved && m_pData->m_pObjectShell.is() ) - { - SfxGetpApp()->NotifyEvent( SfxEventHint( bSaveTo ? SfxEventHintId::SaveToDoc : SfxEventHintId::SaveAsDoc, GlobalEventConfig::GetEventName( bSaveTo ? GlobalEventId::SAVETODOC : GlobalEventId::SAVEASDOC ), - m_pData->m_pObjectShell.get() ) ); + if ( !(!bSaved && m_pData->m_pObjectShell.is()) ) + return; - std::unique_ptr<SfxAllItemSet> pItemSet(new SfxAllItemSet(SfxGetpApp()->GetPool())); - pItemSet->Put(SfxStringItem(SID_FILE_NAME, sURL)); - if ( bSaveTo ) - pItemSet->Put(SfxBoolItem(SID_SAVETO, true)); + SfxGetpApp()->NotifyEvent( SfxEventHint( bSaveTo ? SfxEventHintId::SaveToDoc : SfxEventHintId::SaveAsDoc, GlobalEventConfig::GetEventName( bSaveTo ? GlobalEventId::SAVETODOC : GlobalEventId::SAVEASDOC ), + m_pData->m_pObjectShell.get() ) ); - TransformParameters(SID_SAVEASDOC, seqArguments, *pItemSet); + std::unique_ptr<SfxAllItemSet> pItemSet(new SfxAllItemSet(SfxGetpApp()->GetPool())); + pItemSet->Put(SfxStringItem(SID_FILE_NAME, sURL)); + if ( bSaveTo ) + pItemSet->Put(SfxBoolItem(SID_SAVETO, true)); - const SfxBoolItem* pCopyStreamItem = pItemSet->GetItem<SfxBoolItem>(SID_COPY_STREAM_IF_POSSIBLE, false); + TransformParameters(SID_SAVEASDOC, seqArguments, *pItemSet); - if ( pCopyStreamItem && pCopyStreamItem->GetValue() && !bSaveTo ) - { - throw frame::IllegalArgumentIOException( - "CopyStreamIfPossible parameter is not acceptable for storeAsURL() call!" ); - } + const SfxBoolItem* pCopyStreamItem = pItemSet->GetItem<SfxBoolItem>(SID_COPY_STREAM_IF_POSSIBLE, false); - sal_uInt32 nModifyPasswordHash = 0; - Sequence< beans::PropertyValue > aModifyPasswordInfo; - const SfxUnoAnyItem* pModifyPasswordInfoItem = pItemSet->GetItem<SfxUnoAnyItem>(SID_MODIFYPASSWORDINFO, false); - if ( pModifyPasswordInfoItem ) - { - // it contains either a simple hash or a set of PropertyValues - // TODO/LATER: the sequence of PropertyValue should replace the hash completely in future - sal_Int32 nMPHTmp = 0; - pModifyPasswordInfoItem->GetValue() >>= nMPHTmp; - nModifyPasswordHash = static_cast<sal_uInt32>(nMPHTmp); - pModifyPasswordInfoItem->GetValue() >>= aModifyPasswordInfo; - } - pItemSet->ClearItem(SID_MODIFYPASSWORDINFO); - sal_uInt32 nOldModifyPasswordHash = m_pData->m_pObjectShell->GetModifyPasswordHash(); - m_pData->m_pObjectShell->SetModifyPasswordHash( nModifyPasswordHash ); - Sequence< beans::PropertyValue > aOldModifyPasswordInfo = m_pData->m_pObjectShell->GetModifyPasswordInfo(); - m_pData->m_pObjectShell->SetModifyPasswordInfo( aModifyPasswordInfo ); - - // since saving a document modifies its DocumentProperties, the current - // DocumentProperties must be saved on "SaveTo", so it can be restored - // after saving - bool bCopyTo = bSaveTo || - m_pData->m_pObjectShell->GetCreateMode() == SfxObjectCreateMode::EMBEDDED; - Reference<document::XDocumentProperties> xOldDocProps; - if ( bCopyTo ) - { - xOldDocProps = getDocumentProperties(); - const Reference<util::XCloneable> xCloneable(xOldDocProps, - UNO_QUERY_THROW); - const Reference<document::XDocumentProperties> xNewDocProps( - xCloneable->createClone(), UNO_QUERY_THROW); - m_pData->m_xDocumentProperties = xNewDocProps; - } + if ( pCopyStreamItem && pCopyStreamItem->GetValue() && !bSaveTo ) + { + throw frame::IllegalArgumentIOException( + "CopyStreamIfPossible parameter is not acceptable for storeAsURL() call!" ); + } - bool bRet = m_pData->m_pObjectShell->APISaveAs_Impl(sURL, *pItemSet); + sal_uInt32 nModifyPasswordHash = 0; + Sequence< beans::PropertyValue > aModifyPasswordInfo; + const SfxUnoAnyItem* pModifyPasswordInfoItem = pItemSet->GetItem<SfxUnoAnyItem>(SID_MODIFYPASSWORDINFO, false); + if ( pModifyPasswordInfoItem ) + { + // it contains either a simple hash or a set of PropertyValues + // TODO/LATER: the sequence of PropertyValue should replace the hash completely in future + sal_Int32 nMPHTmp = 0; + pModifyPasswordInfoItem->GetValue() >>= nMPHTmp; + nModifyPasswordHash = static_cast<sal_uInt32>(nMPHTmp); + pModifyPasswordInfoItem->GetValue() >>= aModifyPasswordInfo; + } + pItemSet->ClearItem(SID_MODIFYPASSWORDINFO); + sal_uInt32 nOldModifyPasswordHash = m_pData->m_pObjectShell->GetModifyPasswordHash(); + m_pData->m_pObjectShell->SetModifyPasswordHash( nModifyPasswordHash ); + Sequence< beans::PropertyValue > aOldModifyPasswordInfo = m_pData->m_pObjectShell->GetModifyPasswordInfo(); + m_pData->m_pObjectShell->SetModifyPasswordInfo( aModifyPasswordInfo ); + + // since saving a document modifies its DocumentProperties, the current + // DocumentProperties must be saved on "SaveTo", so it can be restored + // after saving + bool bCopyTo = bSaveTo || + m_pData->m_pObjectShell->GetCreateMode() == SfxObjectCreateMode::EMBEDDED; + Reference<document::XDocumentProperties> xOldDocProps; + if ( bCopyTo ) + { + xOldDocProps = getDocumentProperties(); + const Reference<util::XCloneable> xCloneable(xOldDocProps, + UNO_QUERY_THROW); + const Reference<document::XDocumentProperties> xNewDocProps( + xCloneable->createClone(), UNO_QUERY_THROW); + m_pData->m_xDocumentProperties = xNewDocProps; + } - if ( bCopyTo ) - { - // restore DocumentProperties if a copy was created - m_pData->m_xDocumentProperties = xOldDocProps; - } + bool bRet = m_pData->m_pObjectShell->APISaveAs_Impl(sURL, *pItemSet); - Reference < task::XInteractionHandler > xHandler; - const SfxUnoAnyItem* pItem = pItemSet->GetItem<SfxUnoAnyItem>(SID_INTERACTIONHANDLER, false); - if ( pItem ) - pItem->GetValue() >>= xHandler; + if ( bCopyTo ) + { + // restore DocumentProperties if a copy was created + m_pData->m_xDocumentProperties = xOldDocProps; + } - pItemSet.reset(); + Reference < task::XInteractionHandler > xHandler; + const SfxUnoAnyItem* pItem = pItemSet->GetItem<SfxUnoAnyItem>(SID_INTERACTIONHANDLER, false); + if ( pItem ) + pItem->GetValue() >>= xHandler; - ErrCode nErrCode = m_pData->m_pObjectShell->GetErrorCode(); - if ( !bRet && !nErrCode ) - { - SAL_WARN("sfx.doc", "Storing has failed, no error is set!"); - nErrCode = ERRCODE_IO_CANTWRITE; - } - m_pData->m_pObjectShell->ResetError(); + pItemSet.reset(); - if ( bRet ) + ErrCode nErrCode = m_pData->m_pObjectShell->GetErrorCode(); + if ( !bRet && !nErrCode ) + { + SAL_WARN("sfx.doc", "Storing has failed, no error is set!"); + nErrCode = ERRCODE_IO_CANTWRITE; + } + m_pData->m_pObjectShell->ResetError(); + + if ( bRet ) + { + if ( nErrCode ) { - if ( nErrCode ) + // must be a warning - use Interactionhandler if possible or abandon + if ( xHandler.is() ) { - // must be a warning - use Interactionhandler if possible or abandon - if ( xHandler.is() ) - { - // TODO/LATER: a general way to set the error context should be available - SfxErrorContext aEc( ERRCTX_SFX_SAVEASDOC, m_pData->m_pObjectShell->GetTitle() ); + // TODO/LATER: a general way to set the error context should be available + SfxErrorContext aEc( ERRCTX_SFX_SAVEASDOC, m_pData->m_pObjectShell->GetTitle() ); - task::ErrorCodeRequest aErrorCode; - aErrorCode.ErrCode = sal_uInt32(nErrCode); - SfxMedium::CallApproveHandler( xHandler, makeAny( aErrorCode ), false ); - } + task::ErrorCodeRequest aErrorCode; + aErrorCode.ErrCode = sal_uInt32(nErrCode); + SfxMedium::CallApproveHandler( xHandler, makeAny( aErrorCode ), false ); } + } - if ( !bSaveTo ) - { - m_pData->m_aPreusedFilterName = GetMediumFilterName_Impl(); - m_pData->m_pObjectShell->SetModifyPasswordEntered(); - - SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::SaveAsDocDone, GlobalEventConfig::GetEventName(GlobalEventId::SAVEASDOCDONE), m_pData->m_pObjectShell.get() ) ); - } - else - { - m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash ); - m_pData->m_pObjectShell->SetModifyPasswordInfo( aOldModifyPasswordInfo ); + if ( !bSaveTo ) + { + m_pData->m_aPreusedFilterName = GetMediumFilterName_Impl(); + m_pData->m_pObjectShell->SetModifyPasswordEntered(); - SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::SaveToDocDone, GlobalEventConfig::GetEventName(GlobalEventId::SAVETODOCDONE), m_pData->m_pObjectShell.get() ) ); - } + SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::SaveAsDocDone, GlobalEventConfig::GetEventName(GlobalEventId::SAVEASDOCDONE), m_pData->m_pObjectShell.get() ) ); } else { m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash ); m_pData->m_pObjectShell->SetModifyPasswordInfo( aOldModifyPasswordInfo ); + SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::SaveToDocDone, GlobalEventConfig::GetEventName(GlobalEventId::SAVETODOCDONE), m_pData->m_pObjectShell.get() ) ); + } + } + else + { + m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash ); + m_pData->m_pObjectShell->SetModifyPasswordInfo( aOldModifyPasswordInfo ); + - SfxGetpApp()->NotifyEvent( SfxEventHint( bSaveTo ? SfxEventHintId::SaveToDocFailed : SfxEventHintId::SaveAsDocFailed, GlobalEventConfig::GetEventName( bSaveTo ? GlobalEventId::SAVETODOCFAILED : GlobalEventId::SAVEASDOCFAILED), - m_pData->m_pObjectShell.get() ) ); + SfxGetpApp()->NotifyEvent( SfxEventHint( bSaveTo ? SfxEventHintId::SaveToDocFailed : SfxEventHintId::SaveAsDocFailed, GlobalEventConfig::GetEventName( bSaveTo ? GlobalEventId::SAVETODOCFAILED : GlobalEventId::SAVEASDOCFAILED), + m_pData->m_pObjectShell.get() ) ); - std::stringstream aErrCode; - aErrCode << nErrCode; - throw task::ErrorCodeIOException( - "SfxBaseModel::impl_store <" + sURL + "> failed: " + OUString::fromUtf8(aErrCode.str().c_str()), - Reference< XInterface >(), sal_uInt32(nErrCode)); - } + std::stringstream aErrCode; + aErrCode << nErrCode; + throw task::ErrorCodeIOException( + "SfxBaseModel::impl_store <" + sURL + "> failed: " + OUString::fromUtf8(aErrCode.str().c_str()), + Reference< XInterface >(), sal_uInt32(nErrCode)); } } @@ -3231,20 +3231,20 @@ void SfxBaseModel::notifyEvent( const document::EventObject& aEvent ) const ::cppu::OInterfaceContainerHelper* pIC = m_pData->m_aInterfaceContainer.getContainer( cppu::UnoType<document::XEventListener>::get()); - if( pIC ) + if( !pIC ) + + return; + ::cppu::OInterfaceIteratorHelper aIt( *pIC ); + while( aIt.hasMoreElements() ) { - ::cppu::OInterfaceIteratorHelper aIt( *pIC ); - while( aIt.hasMoreElements() ) + try { - try - { - static_cast<document::XEventListener *>(aIt.next())->notifyEvent( aEvent ); - } - catch( RuntimeException& ) - { - aIt.remove(); - } + static_cast<document::XEventListener *>(aIt.next())->notifyEvent( aEvent ); + } + catch( RuntimeException& ) + { + aIt.remove(); } } } @@ -3438,34 +3438,34 @@ static void GetCommandFromSequence( OUString& rCommand, sal_Int32& nIndex, const static void ConvertSlotsToCommands( SfxObjectShell const * pDoc, Reference< container::XIndexContainer > const & rToolbarDefinition ) { - if ( pDoc ) + if ( !pDoc ) + return; + + SfxModule* pModule( pDoc->GetFactory().GetModule() ); + Sequence< beans::PropertyValue > aSeqPropValue; + + for ( sal_Int32 i = 0; i < rToolbarDefinition->getCount(); i++ ) { - SfxModule* pModule( pDoc->GetFactory().GetModule() ); - Sequence< beans::PropertyValue > aSeqPropValue; + sal_Int32 nIndex( -1 ); + OUString aCommand; - for ( sal_Int32 i = 0; i < rToolbarDefinition->getCount(); i++ ) + if ( rToolbarDefinition->getByIndex( i ) >>= aSeqPropValue ) { - sal_Int32 nIndex( -1 ); - OUString aCommand; - - if ( rToolbarDefinition->getByIndex( i ) >>= aSeqPropValue ) + GetCommandFromSequence( aCommand, nIndex, aSeqPropValue ); + if ( nIndex >= 0 && aCommand.startsWith( "slot:" ) ) { - GetCommandFromSequence( aCommand, nIndex, aSeqPropValue ); - if ( nIndex >= 0 && aCommand.startsWith( "slot:" ) ) - { - const sal_uInt16 nSlot = aCommand.copy( 5 ).toInt32(); + const sal_uInt16 nSlot = aCommand.copy( 5 ).toInt32(); - // We have to replace the old "slot-Command" with our new ".uno:-Command" - const SfxSlot* pSlot = pModule->GetSlotPool()->GetSlot( nSlot ); - if ( pSlot ) - { - OUStringBuffer aStrBuf( ".uno:" ); - aStrBuf.appendAscii( pSlot->GetUnoName() ); + // We have to replace the old "slot-Command" with our new ".uno:-Command" + const SfxSlot* pSlot = pModule->GetSlotPool()->GetSlot( nSlot ); + if ( pSlot ) + { + OUStringBuffer aStrBuf( ".uno:" ); + aStrBuf.appendAscii( pSlot->GetUnoName() ); - aCommand = aStrBuf.makeStringAndClear(); - aSeqPropValue[nIndex].Value <<= aCommand; - rToolbarDefinition->replaceByIndex( i, Any( aSeqPropValue )); - } + aCommand = aStrBuf.makeStringAndClear(); + aSeqPropValue[nIndex].Value <<= aCommand; + rToolbarDefinition->replaceByIndex( i, Any( aSeqPropValue )); } } } diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 006d00235a93..dd932c987493 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -942,40 +942,40 @@ void SfxTemplateManagerDlg::OnTemplateImportCategory(const OUString& sCategory) ErrCode nCode = aFileDlg.Execute(); - if ( nCode == ERRCODE_NONE ) - { - css::uno::Sequence<OUString> aFiles = aFileDlg.GetSelectedFiles(); + if ( nCode != ERRCODE_NONE ) + return; + + css::uno::Sequence<OUString> aFiles = aFileDlg.GetSelectedFiles(); - if (aFiles.hasElements()) + if (!aFiles.hasElements()) + return; + + //Import to the selected regions + TemplateContainerItem* pContItem = mpLocalView->getRegion(sCategory); + if(!pContItem) + return; + + OUString aTemplateList; + + for (size_t i = 0, n = aFiles.getLength(); i < n; ++i) + { + if(!mpLocalView->copyFrom(pContItem,aFiles[i])) { - //Import to the selected regions - TemplateContainerItem* pContItem = mpLocalView->getRegion(sCategory); - if(pContItem) - { - OUString aTemplateList; - - for (size_t i = 0, n = aFiles.getLength(); i < n; ++i) - { - if(!mpLocalView->copyFrom(pContItem,aFiles[i])) - { - if (aTemplateList.isEmpty()) - aTemplateList = aFiles[i]; - else - aTemplateList = aTemplateList + "\n" + aFiles[i]; - } - } - - if (!aTemplateList.isEmpty()) - { - OUString aMsg(SfxResId(STR_MSG_ERROR_IMPORT)); - aMsg = aMsg.replaceFirst("$1",pContItem->maTitle); - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, - aMsg.replaceFirst("$2",aTemplateList))); - xBox->run(); - } - } + if (aTemplateList.isEmpty()) + aTemplateList = aFiles[i]; + else + aTemplateList = aTemplateList + "\n" + aFiles[i]; } } + + if (!aTemplateList.isEmpty()) + { + OUString aMsg(SfxResId(STR_MSG_ERROR_IMPORT)); + aMsg = aMsg.replaceFirst("$1",pContItem->maTitle); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + aMsg.replaceFirst("$2",aTemplateList))); + xBox->run(); + } } void SfxTemplateManagerDlg::OnTemplateExport() @@ -988,89 +988,89 @@ void SfxTemplateManagerDlg::OnTemplateExport() sal_Int16 nResult = xFolderPicker->execute(); sal_Int16 nCount = maSelTemplates.size(); - if( nResult == ExecutableDialogResults::OK ) + if( nResult != ExecutableDialogResults::OK ) + return; + + OUString aTemplateList; + INetURLObject aPathObj(xFolderPicker->getDirectory()); + aPathObj.setFinalSlash(); + + if (mpSearchView->IsVisible()) { - OUString aTemplateList; - INetURLObject aPathObj(xFolderPicker->getDirectory()); - aPathObj.setFinalSlash(); + sal_uInt16 i = 1; - if (mpSearchView->IsVisible()) + for (auto const& selTemplate : maSelTemplates) { - sal_uInt16 i = 1; + const TemplateSearchViewItem *pItem = static_cast<const TemplateSearchViewItem*>(selTemplate); - for (auto const& selTemplate : maSelTemplates) - { - const TemplateSearchViewItem *pItem = static_cast<const TemplateSearchViewItem*>(selTemplate); + INetURLObject aItemPath(pItem->getPath()); - INetURLObject aItemPath(pItem->getPath()); + if ( 1 == i ) + aPathObj.Append(aItemPath.getName()); + else + aPathObj.setName(aItemPath.getName()); + + OUString aPath = aPathObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - if ( 1 == i ) - aPathObj.Append(aItemPath.getName()); + if (!mpLocalView->exportTo(pItem->mnAssocId,pItem->mnRegionId,aPath)) + { + if (aTemplateList.isEmpty()) + aTemplateList = pItem->maTitle; else - aPathObj.setName(aItemPath.getName()); - - OUString aPath = aPathObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - - if (!mpLocalView->exportTo(pItem->mnAssocId,pItem->mnRegionId,aPath)) - { - if (aTemplateList.isEmpty()) - aTemplateList = pItem->maTitle; - else - aTemplateList = aTemplateList + "\n" + pItem->maTitle; - } - ++i; + aTemplateList = aTemplateList + "\n" + pItem->maTitle; } - - mpSearchView->deselectItems(); + ++i; } - else + + mpSearchView->deselectItems(); + } + else + { + // export templates from the current view + + sal_uInt16 i = 1; + + for (auto const& selTemplate : maSelTemplates) { - // export templates from the current view + const TemplateViewItem *pItem = static_cast<const TemplateViewItem*>(selTemplate); - sal_uInt16 i = 1; + INetURLObject aItemPath(pItem->getPath()); - for (auto const& selTemplate : maSelTemplates) - { - const TemplateViewItem *pItem = static_cast<const TemplateViewItem*>(selTemplate); + if ( 1 == i ) + aPathObj.Append(aItemPath.getName()); + else + aPathObj.setName(aItemPath.getName()); - INetURLObject aItemPath(pItem->getPath()); + OUString aPath = aPathObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - if ( 1 == i ) - aPathObj.Append(aItemPath.getName()); + if (!mpLocalView->exportTo(pItem->mnDocId + 1, //mnId w.r.t. region = mDocId + 1 + mpLocalView->getRegionId(pItem->mnRegionId), //pItem->mnRegionId does not store actual region Id + aPath)) + { + if (aTemplateList.isEmpty()) + aTemplateList = pItem->maTitle; else - aPathObj.setName(aItemPath.getName()); - - OUString aPath = aPathObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - - if (!mpLocalView->exportTo(pItem->mnDocId + 1, //mnId w.r.t. region = mDocId + 1 - mpLocalView->getRegionId(pItem->mnRegionId), //pItem->mnRegionId does not store actual region Id - aPath)) - { - if (aTemplateList.isEmpty()) - aTemplateList = pItem->maTitle; - else - aTemplateList = aTemplateList + "\n" + pItem->maTitle; - } - ++i; + aTemplateList = aTemplateList + "\n" + pItem->maTitle; } - - mpLocalView->deselectItems(); + ++i; } - if (!aTemplateList.isEmpty()) - { - OUString aText( SfxResId(STR_MSG_ERROR_EXPORT) ); - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, - aText.replaceFirst("$1",aTemplateList))); - xBox->run(); - } - else - { - OUString sText( SfxResId(STR_MSG_EXPORT_SUCCESS) ); - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Info, VclButtonsType::Ok, - sText.replaceFirst("$1", OUString::number(nCount)))); - xBox->run(); - } + mpLocalView->deselectItems(); + } + + if (!aTemplateList.isEmpty()) + { + OUString aText( SfxResId(STR_MSG_ERROR_EXPORT) ); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + aText.replaceFirst("$1",aTemplateList))); + xBox->run(); + } + else + { + OUString sText( SfxResId(STR_MSG_EXPORT_SUCCESS) ); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Info, VclButtonsType::Ok, + sText.replaceFirst("$1", OUString::number(nCount)))); + xBox->run(); } } @@ -1116,19 +1116,19 @@ void SfxTemplateManagerDlg::OnCategoryNew() int ret = dlg.run(); - if (ret) - { - OUString aName = dlg.GetEntryText(); + if (!ret) + return; - if(mpLocalView->createRegion(aName)) - mpCBFolder->InsertEntry(aName); - else - { - OUString aMsg( SfxResId(STR_CREATE_ERROR) ); - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, - aMsg.replaceFirst("$1", aName))); - xBox->run(); - } + OUString aName = dlg.GetEntryText(); + + if(mpLocalView->createRegion(aName)) + mpCBFolder->InsertEntry(aName); + else + { + OUString aMsg( SfxResId(STR_CREATE_ERROR) ); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + aMsg.replaceFirst("$1", aName))); + xBox->run(); } } @@ -1140,27 +1140,27 @@ void SfxTemplateManagerDlg::OnCategoryRename() dlg.SetEntryText(sCategory); int ret = dlg.run(); - if (ret) - { - OUString aName = dlg.GetEntryText(); + if (!ret) + return; - if(mpLocalView->renameRegion(sCategory, aName)) - { - sal_Int32 nPos = mpCBFolder->GetEntryPos(sCategory); - mpCBFolder->RemoveEntry(nPos); - mpCBFolder->InsertEntry(aName, nPos); - mpCBFolder->SelectEntryPos(nPos); + OUString aName = dlg.GetEntryText(); - mpLocalView->reload(); - mpLocalView->showRegion(aName); - } - else - { - OUString aMsg( SfxResId(STR_CREATE_ERROR) ); - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, - aMsg.replaceFirst("$1", aName))); - xBox->run(); - } + if(mpLocalView->renameRegion(sCategory, aName)) + { + sal_Int32 nPos = mpCBFolder->GetEntryPos(sCategory); + mpCBFolder->RemoveEntry(nPos); + mpCBFolder->InsertEntry(aName, nPos); + mpCBFolder->SelectEntryPos(nPos); + + mpLocalView->reload(); + mpLocalView->showRegion(aName); + } + else + { + OUString aMsg( SfxResId(STR_CREATE_ERROR) ); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + aMsg.replaceFirst("$1", aName))); + xBox->run(); } } diff --git a/sfx2/source/inet/inettbc.cxx b/sfx2/source/inet/inettbc.cxx index 370f9bd3706a..a8f42dbc3154 100644 --- a/sfx2/source/inet/inettbc.cxx +++ b/sfx2/source/inet/inettbc.cxx @@ -90,37 +90,37 @@ void SfxURLToolBoxControl_Impl::OpenURL( const OUString& rName ) const return; Reference< XDispatchProvider > xDispatchProvider( getFrameInterface(), UNO_QUERY ); - if ( xDispatchProvider.is() ) - { - URL aTargetURL; - aTargetURL.Complete = aName; + if ( !xDispatchProvider.is() ) + return; - getURLTransformer()->parseStrict( aTargetURL ); - Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, "_default", 0 ); - if ( xDispatch.is() ) - { - Sequence< PropertyValue > aArgs( 2 ); - aArgs[0].Name = "Referer"; - aArgs[0].Value <<= OUString( "private:user" ); - aArgs[1].Name = "FileName"; - aArgs[1].Value <<= aName; + URL aTargetURL; + aTargetURL.Complete = aName; - if ( !aFilter.isEmpty() ) - { - aArgs.realloc( 4 ); - aArgs[2].Name = "FilterOptions"; - aArgs[2].Value <<= OUString(); - aArgs[3].Name = "FilterName"; - aArgs[3].Value <<= aFilter; - } + getURLTransformer()->parseStrict( aTargetURL ); + Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, "_default", 0 ); + if ( !xDispatch.is() ) + return; - SfxURLToolBoxControl_Impl::ExecuteInfo* pExecuteInfo = new SfxURLToolBoxControl_Impl::ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - Application::PostUserEvent( LINK( nullptr, SfxURLToolBoxControl_Impl, ExecuteHdl_Impl), pExecuteInfo ); - } + Sequence< PropertyValue > aArgs( 2 ); + aArgs[0].Name = "Referer"; + aArgs[0].Value <<= OUString( "private:user" ); + aArgs[1].Name = "FileName"; + aArgs[1].Value <<= aName; + + if ( !aFilter.isEmpty() ) + { + aArgs.realloc( 4 ); + aArgs[2].Name = "FilterOptions"; + aArgs[2].Value <<= OUString(); + aArgs[3].Name = "FilterName"; + aArgs[3].Value <<= aFilter; } + + SfxURLToolBoxControl_Impl::ExecuteInfo* pExecuteInfo = new SfxURLToolBoxControl_Impl::ExecuteInfo; + pExecuteInfo->xDispatch = xDispatch; + pExecuteInfo->aTargetURL = aTargetURL; + pExecuteInfo->aArgs = aArgs; + Application::PostUserEvent( LINK( nullptr, SfxURLToolBoxControl_Impl, ExecuteHdl_Impl), pExecuteInfo ); } @@ -191,52 +191,52 @@ void SfxURLToolBoxControl_Impl::StateChanged GetURLBox()->Enable( SfxItemState::DISABLED != eState ); } - if ( GetURLBox()->IsEnabled() ) + if ( !GetURLBox()->IsEnabled() ) + return; + + if( nSID == SID_FOCUSURLBOX ) { - if( nSID == SID_FOCUSURLBOX ) - { - if ( GetURLBox()->IsVisible() ) - GetURLBox()->GrabFocus(); - } - else if ( !GetURLBox()->IsModified() && SfxItemState::DEFAULT == eState ) - { - SvtURLBox* pURLBox = GetURLBox(); - pURLBox->Clear(); + if ( GetURLBox()->IsVisible() ) + GetURLBox()->GrabFocus(); + } + else if ( !GetURLBox()->IsModified() && SfxItemState::DEFAULT == eState ) + { + SvtURLBox* pURLBox = GetURLBox(); + pURLBox->Clear(); - css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > lList = SvtHistoryOptions().GetList(ePICKLIST); - for (sal_Int32 i=0; i<lList.getLength(); ++i) + css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > lList = SvtHistoryOptions().GetList(ePICKLIST); + for (sal_Int32 i=0; i<lList.getLength(); ++i) + { + css::uno::Sequence< css::beans::PropertyValue > lProps = lList[i]; + for (sal_Int32 p=0; p<lProps.getLength(); ++p) { - css::uno::Sequence< css::beans::PropertyValue > lProps = lList[i]; - for (sal_Int32 p=0; p<lProps.getLength(); ++p) - { - if (lProps[p].Name != HISTORY_PROPERTYNAME_URL) - continue; - - OUString sURL; - if (!(lProps[p].Value>>=sURL) || sURL.isEmpty()) - continue; - - INetURLObject aURL ( sURL ); - OUString sMainURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::WithCharset ) ); - OUString sFile; - - if (osl::FileBase::getSystemPathFromFileURL(sMainURL, sFile) == osl::FileBase::E_None) - pURLBox->InsertEntry(sFile); - else - pURLBox->InsertEntry(sMainURL); - } - } + if (lProps[p].Name != HISTORY_PROPERTYNAME_URL) + continue; - const SfxStringItem *pURL = dynamic_cast< const SfxStringItem* >(pState); - INetURLObject aURL( pURL->GetValue() ); - INetProtocol eProt = aURL.GetProtocol(); - if ( eProt == INetProtocol::File ) - { - pURLBox->SetText( aURL.PathToFileName() ); + OUString sURL; + if (!(lProps[p].Value>>=sURL) || sURL.isEmpty()) + continue; + + INetURLObject aURL ( sURL ); + OUString sMainURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::WithCharset ) ); + OUString sFile; + + if (osl::FileBase::getSystemPathFromFileURL(sMainURL, sFile) == osl::FileBase::E_None) + pURLBox->InsertEntry(sFile); + else + pURLBox->InsertEntry(sMainURL); } - else - pURLBox->SetText( aURL.GetURLNoPass() ); } + + const SfxStringItem *pURL = dynamic_cast< const SfxStringItem* >(pState); + INetURLObject aURL( pURL->GetValue() ); + INetProtocol eProt = aURL.GetProtocol(); + if ( eProt == INetProtocol::File ) + { + pURLBox->SetText( aURL.PathToFileName() ); + } + else + pURLBox->SetText( aURL.GetURLNoPass() ); } } diff --git a/sfx2/source/notebookbar/NotebookbarTabControl.cxx b/sfx2/source/notebookbar/NotebookbarTabControl.cxx index 2e5f18af3150..8066f36fc532 100644 --- a/sfx2/source/notebookbar/NotebookbarTabControl.cxx +++ b/sfx2/source/notebookbar/NotebookbarTabControl.cxx @@ -327,33 +327,33 @@ void NotebookbarTabControl::FillShortcutsToolBox(Reference<XComponentContext> co IMPL_LINK(NotebookbarTabControl, OpenNotebookbarPopupMenu, NotebookBar*, pNotebookbar, void) { - if (pNotebookbar && m_xFrame.is()) - { - Sequence<Any> aArgs { - makeAny(comphelper::makePropertyValue("Value", OUString("notebookbar"))), - makeAny(comphelper::makePropertyValue("Frame", m_xFrame)) }; + if (!pNotebookbar || !m_xFrame.is()) + return; - Reference<XComponentContext> xContext = comphelper::getProcessComponentContext(); - Reference<XPopupMenuController> xPopupController( - xContext->getServiceManager()->createInstanceWithArgumentsAndContext( - "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), UNO_QUERY); + Sequence<Any> aArgs { + makeAny(comphelper::makePropertyValue("Value", OUString("notebookbar"))), + makeAny(comphelper::makePropertyValue("Frame", m_xFrame)) }; - Reference<css::awt::XPopupMenu> xPopupMenu(xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.awt.PopupMenu", xContext), UNO_QUERY); + Reference<XComponentContext> xContext = comphelper::getProcessComponentContext(); + Reference<XPopupMenuController> xPopupController( + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), UNO_QUERY); - if (!xPopupController.is() || !xPopupMenu.is()) - return; + Reference<css::awt::XPopupMenu> xPopupMenu(xContext->getServiceManager()->createInstanceWithContext( + "com.sun.star.awt.PopupMenu", xContext), UNO_QUERY); - xPopupController->setPopupMenu(xPopupMenu); - VCLXMenu* pAwtMenu = VCLXMenu::GetImplementation(xPopupMenu); - PopupMenu* pVCLMenu = static_cast<PopupMenu*>(pAwtMenu->GetMenu()); - Point aPos(pNotebookbar->GetSizePixel().getWidth(), NotebookbarTabControl::GetHeaderHeight() - ICON_SIZE + 10); - pVCLMenu->Execute(pNotebookbar, tools::Rectangle(aPos, aPos),PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose); + if (!xPopupController.is() || !xPopupMenu.is()) + return; - Reference<css::lang::XComponent> xComponent(xPopupController, UNO_QUERY); - if (xComponent.is()) - xComponent->dispose(); - } + xPopupController->setPopupMenu(xPopupMenu); + VCLXMenu* pAwtMenu = VCLXMenu::GetImplementation(xPopupMenu); + PopupMenu* pVCLMenu = static_cast<PopupMenu*>(pAwtMenu->GetMenu()); + Point aPos(pNotebookbar->GetSizePixel().getWidth(), NotebookbarTabControl::GetHeaderHeight() - ICON_SIZE + 10); + pVCLMenu->Execute(pNotebookbar, tools::Rectangle(aPos, aPos),PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose); + + Reference<css::lang::XComponent> xComponent(xPopupController, UNO_QUERY); + if (xComponent.is()) + xComponent->dispose(); } Size NotebookbarTabControl::calculateRequisition() const diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index c45b4c80f0df..68a9e7797d26 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -383,56 +383,56 @@ void SfxNotebookBar::RemoveListeners(SystemWindow const * pSysWindow) void SfxNotebookBar::ShowMenubar(bool bShow) { - if (!m_bLock) - { - m_bLock = true; + if (m_bLock) + return; - Reference<frame::XFrame> xFrame; - vcl::EnumContext::Application eCurrentApp = vcl::EnumContext::Application::NONE; - uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); - const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( xContext ); + m_bLock = true; - if ( SfxViewFrame::Current() ) - { - xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); - eCurrentApp = vcl::EnumContext::GetApplicationEnum( xModuleManager->identify( xFrame ) ); - } + Reference<frame::XFrame> xFrame; + vcl::EnumContext::Application eCurrentApp = vcl::EnumContext::Application::NONE; + uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); + const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( xContext ); - SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(); - while( pViewFrame ) + if ( SfxViewFrame::Current() ) + { + xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); + eCurrentApp = vcl::EnumContext::GetApplicationEnum( xModuleManager->identify( xFrame ) ); + } + + SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(); + while( pViewFrame ) + { + xFrame = pViewFrame->GetFrame().GetFrameInterface(); + if ( xFrame.is() ) { - xFrame = pViewFrame->GetFrame().GetFrameInterface(); - if ( xFrame.is() ) + vcl::EnumContext::Application eApp = + vcl::EnumContext::GetApplicationEnum( xModuleManager->identify( xFrame ) ); + + if ( eApp == eCurrentApp ) { - vcl::EnumContext::Application eApp = - vcl::EnumContext::GetApplicationEnum( xModuleManager->identify( xFrame ) ); + const Reference<frame::XLayoutManager>& xLayoutManager = + lcl_getLayoutManager( xFrame ); - if ( eApp == eCurrentApp ) + if (xLayoutManager.is()) { - const Reference<frame::XLayoutManager>& xLayoutManager = - lcl_getLayoutManager( xFrame ); + xLayoutManager->lock(); - if (xLayoutManager.is()) + if (xLayoutManager->getElement(MENUBAR_STR).is()) { - xLayoutManager->lock(); - - if (xLayoutManager->getElement(MENUBAR_STR).is()) - { - if (xLayoutManager->isElementVisible(MENUBAR_STR) && !bShow) - xLayoutManager->hideElement(MENUBAR_STR); - else if(!xLayoutManager->isElementVisible(MENUBAR_STR) && bShow) - xLayoutManager->showElement(MENUBAR_STR); - } - - xLayoutManager->unlock(); + if (xLayoutManager->isElementVisible(MENUBAR_STR) && !bShow) + xLayoutManager->hideElement(MENUBAR_STR); + else if(!xLayoutManager->isElementVisible(MENUBAR_STR) && bShow) + xLayoutManager->showElement(MENUBAR_STR); } + + xLayoutManager->unlock(); } } - - pViewFrame = SfxViewFrame::GetNext( *pViewFrame ); } - m_bLock = false; + + pViewFrame = SfxViewFrame::GetNext( *pViewFrame ); } + m_bLock = false; } void SfxNotebookBar::ShowMenubar(SfxViewFrame const * pViewFrame, bool bShow) @@ -469,35 +469,35 @@ void SfxNotebookBar::ShowMenubar(SfxViewFrame const * pViewFrame, bool bShow) void SfxNotebookBar::ToggleMenubar() { - if (SfxViewFrame::Current()) - { - const Reference<frame::XFrame>& xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); - if (xFrame.is()) - { - const Reference<frame::XLayoutManager>& xLayoutManager = - lcl_getLayoutManager(xFrame); + if (!SfxViewFrame::Current()) + return; - bool bShow = true; - if (xLayoutManager.is() && xLayoutManager->getElement(MENUBAR_STR).is()) - { - if (xLayoutManager->isElementVisible(MENUBAR_STR)) - { - SfxNotebookBar::ShowMenubar(false); - bShow = false; - } - else - SfxNotebookBar::ShowMenubar(true); - } + const Reference<frame::XFrame>& xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); + if (!xFrame.is()) + return; - // Save menubar settings - if (IsActive()) - { - utl::OConfigurationTreeRoot aRoot(lcl_getCurrentImplConfigRoot()); - utl::OConfigurationNode aModeNode(lcl_getCurrentImplConfigNode(xFrame, aRoot)); - aModeNode.setNodeValue( "HasMenubar", toAny<bool>( bShow ) ); - aRoot.commit(); - } + const Reference<frame::XLayoutManager>& xLayoutManager = + lcl_getLayoutManager(xFrame); + + bool bShow = true; + if (xLayoutManager.is() && xLayoutManager->getElement(MENUBAR_STR).is()) + { + if (xLayoutManager->isElementVisible(MENUBAR_STR)) + { + SfxNotebookBar::ShowMenubar(false); + bShow = false; } + else + SfxNotebookBar::ShowMenubar(true); + } + + // Save menubar settings + if (IsActive()) + { + utl::OConfigurationTreeRoot aRoot(lcl_getCurrentImplConfigRoot()); + utl::OConfigurationNode aModeNode(lcl_getCurrentImplConfigNode(xFrame, aRoot)); + aModeNode.setNodeValue( "HasMenubar", toAny<bool>( bShow ) ); + aRoot.commit(); } } diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx index ea23654f59b3..adc098be5b27 100644 --- a/sfx2/source/notify/eventsupplier.cxx +++ b/sfx2/source/notify/eventsupplier.cxx @@ -171,93 +171,93 @@ sal_Bool SAL_CALL SfxEvents_Impl::hasElements() void SfxEvents_Impl::Execute( uno::Any const & aEventData, const document::DocumentEvent& aTrigger, SfxObjectShell* pDoc ) { uno::Sequence < beans::PropertyValue > aProperties; - if ( aEventData >>= aProperties ) - { - OUString aType; - OUString aScript; - OUString aLibrary; - OUString aMacroName; + if ( !(aEventData >>= aProperties) ) + return; - sal_Int32 nCount = aProperties.getLength(); + OUString aType; + OUString aScript; + OUString aLibrary; + OUString aMacroName; - if ( !nCount ) - return; + sal_Int32 nCount = aProperties.getLength(); - sal_Int32 nIndex = 0; - while ( nIndex < nCount ) - { - if ( aProperties[ nIndex ].Name == PROP_EVENT_TYPE ) - aProperties[ nIndex ].Value >>= aType; - else if ( aProperties[ nIndex ].Name == PROP_SCRIPT ) - aProperties[ nIndex ].Value >>= aScript; - else if ( aProperties[ nIndex ].Name == PROP_LIBRARY ) - aProperties[ nIndex ].Value >>= aLibrary; - else if ( aProperties[ nIndex ].Name == PROP_MACRO_NAME ) - aProperties[ nIndex ].Value >>= aMacroName; - else { - OSL_FAIL("Unknown property value!"); - } - nIndex += 1; - } + if ( !nCount ) + return; - if (aType == STAR_BASIC && !aScript.isEmpty()) - { - uno::Any aAny; - SfxMacroLoader::loadMacro( aScript, aAny, pDoc ); + sal_Int32 nIndex = 0; + while ( nIndex < nCount ) + { + if ( aProperties[ nIndex ].Name == PROP_EVENT_TYPE ) + aProperties[ nIndex ].Value >>= aType; + else if ( aProperties[ nIndex ].Name == PROP_SCRIPT ) + aProperties[ nIndex ].Value >>= aScript; + else if ( aProperties[ nIndex ].Name == PROP_LIBRARY ) + aProperties[ nIndex ].Value >>= aLibrary; + else if ( aProperties[ nIndex ].Name == PROP_MACRO_NAME ) + aProperties[ nIndex ].Value >>= aMacroName; + else { + OSL_FAIL("Unknown property value!"); } - else if (aType == "Service" || - aType == "Script") + nIndex += 1; + } + + if (aType == STAR_BASIC && !aScript.isEmpty()) + { + uno::Any aAny; + SfxMacroLoader::loadMacro( aScript, aAny, pDoc ); + } + else if (aType == "Service" || + aType == "Script") + { + if ( !aScript.isEmpty() ) { - if ( !aScript.isEmpty() ) - { - SfxViewFrame* pView = pDoc ? - SfxViewFrame::GetFirst( pDoc ) : - SfxViewFrame::Current(); + SfxViewFrame* pView = pDoc ? + SfxViewFrame::GetFirst( pDoc ) : + SfxViewFrame::Current(); - uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); + uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); - util::URL aURL; - aURL.Complete = aScript; - xTrans->parseStrict( aURL ); + util::URL aURL; + aURL.Complete = aScript; + xTrans->parseStrict( aURL ); - uno::Reference - < frame::XDispatchProvider > xProv; + uno::Reference + < frame::XDispatchProvider > xProv; - if ( pView != nullptr ) - { - xProv = uno::Reference - < frame::XDispatchProvider > ( - pView->GetFrame().GetFrameInterface(), uno::UNO_QUERY ); - } - else - { - xProv.set( frame::Desktop::create( ::comphelper::getProcessComponentContext() ), - uno::UNO_QUERY ); - } - - uno::Reference < frame::XDispatch > xDisp; - if ( xProv.is() ) - xDisp = xProv->queryDispatch( aURL, OUString(), 0 ); - - if ( xDisp.is() ) - { - - beans::PropertyValue aEventParam; - aEventParam.Value <<= aTrigger; - uno::Sequence< beans::PropertyValue > aDispatchArgs( &aEventParam, 1 ); - xDisp->dispatch( aURL, aDispatchArgs ); - } + if ( pView != nullptr ) + { + xProv = uno::Reference + < frame::XDispatchProvider > ( + pView->GetFrame().GetFrameInterface(), uno::UNO_QUERY ); + } + else + { + xProv.set( frame::Desktop::create( ::comphelper::getProcessComponentContext() ), + uno::UNO_QUERY ); + } + + uno::Reference < frame::XDispatch > xDisp; + if ( xProv.is() ) + xDisp = xProv->queryDispatch( aURL, OUString(), 0 ); + + if ( xDisp.is() ) + { + + beans::PropertyValue aEventParam; + aEventParam.Value <<= aTrigger; + uno::Sequence< beans::PropertyValue > aDispatchArgs( &aEventParam, 1 ); + xDisp->dispatch( aURL, aDispatchArgs ); } - } - else if ( aType.isEmpty() ) - { - // Empty type means no active binding for the event. Just ignore do nothing. - } - else - { - SAL_WARN( "sfx.notify", "notifyEvent(): Unsupported event type" ); } } + else if ( aType.isEmpty() ) + { + // Empty type means no active binding for the event. Just ignore do nothing. + } + else + { + SAL_WARN( "sfx.notify", "notifyEvent(): Unsupported event type" ); + } } @@ -419,54 +419,54 @@ void SfxEvents_Impl::NormalizeMacro( const ::comphelper::NamedValueCollection& i if ( !aScript.isEmpty() ) o_normalizedDescriptor.put( PROP_SCRIPT, aScript ); - if ( aType == STAR_BASIC ) + if ( aType != STAR_BASIC ) + return; + + if ( !aScript.isEmpty() ) { - if ( !aScript.isEmpty() ) + if ( aMacroName.isEmpty() || aLibrary.isEmpty() ) { - if ( aMacroName.isEmpty() || aLibrary.isEmpty() ) + sal_Int32 nThirdSlashPos = aScript.indexOf( '/', 8 ); + sal_Int32 nArgsPos = aScript.indexOf( '(' ); + if ( ( nThirdSlashPos != -1 ) && ( nArgsPos == -1 || nThirdSlashPos < nArgsPos ) ) { - sal_Int32 nThirdSlashPos = aScript.indexOf( '/', 8 ); - sal_Int32 nArgsPos = aScript.indexOf( '(' ); - if ( ( nThirdSlashPos != -1 ) && ( nArgsPos == -1 || nThirdSlashPos < nArgsPos ) ) - { - OUString aBasMgrName( INetURLObject::decode( aScript.copy( 8, nThirdSlashPos-8 ), INetURLObject::DecodeMechanism::WithCharset ) ); - if ( aBasMgrName == "." ) - aLibrary = pDoc->GetTitle(); - else - aLibrary = SfxGetpApp()->GetName(); - - // Get the macro name - aMacroName = aScript.copy( nThirdSlashPos+1, nArgsPos - nThirdSlashPos - 1 ); - } + OUString aBasMgrName( INetURLObject::decode( aScript.copy( 8, nThirdSlashPos-8 ), INetURLObject::DecodeMechanism::WithCharset ) ); + if ( aBasMgrName == "." ) + aLibrary = pDoc->GetTitle(); else - { - SAL_WARN( "sfx.notify", "ConvertToMacro: Unknown macro url format" ); - } - } - } - else if ( !aMacroName.isEmpty() ) - { - aScript = "macro://"; - if ( aLibrary != SfxGetpApp()->GetName() && aLibrary != "StarDesktop" && aLibrary != "application" ) - aScript += "."; - aScript += "/" + aMacroName + "()"; - } - else - // wrong properties - return; + aLibrary = SfxGetpApp()->GetName(); - if (aLibrary != "document") - { - if ( aLibrary.isEmpty() || (pDoc && ( aLibrary == pDoc->GetTitle( SFX_TITLE_APINAME ) || aLibrary == pDoc->GetTitle() )) ) - aLibrary = "document"; + // Get the macro name + aMacroName = aScript.copy( nThirdSlashPos+1, nArgsPos - nThirdSlashPos - 1 ); + } else - aLibrary = "application"; + { + SAL_WARN( "sfx.notify", "ConvertToMacro: Unknown macro url format" ); + } } + } + else if ( !aMacroName.isEmpty() ) + { + aScript = "macro://"; + if ( aLibrary != SfxGetpApp()->GetName() && aLibrary != "StarDesktop" && aLibrary != "application" ) + aScript += "."; + aScript += "/" + aMacroName + "()"; + } + else + // wrong properties + return; - o_normalizedDescriptor.put( PROP_SCRIPT, aScript ); - o_normalizedDescriptor.put( PROP_LIBRARY, aLibrary ); - o_normalizedDescriptor.put( PROP_MACRO_NAME, aMacroName ); + if (aLibrary != "document") + { + if ( aLibrary.isEmpty() || (pDoc && ( aLibrary == pDoc->GetTitle( SFX_TITLE_APINAME ) || aLibrary == pDoc->GetTitle() )) ) + aLibrary = "document"; + else + aLibrary = "application"; } + + o_normalizedDescriptor.put( PROP_SCRIPT, aScript ); + o_normalizedDescriptor.put( PROP_LIBRARY, aLibrary ); + o_normalizedDescriptor.put( PROP_MACRO_NAME, aMacroName ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/sidebar/ContextList.cxx b/sfx2/source/sidebar/ContextList.cxx index d6148191431d..8f0c82783f60 100644 --- a/sfx2/source/sidebar/ContextList.cxx +++ b/sfx2/source/sidebar/ContextList.cxx @@ -83,20 +83,20 @@ void ContextList::ToggleVisibilityForContext( const Context &rContext, const boo { ContextList::Entry *pEntry = GetMatch( rContext ); - if ( pEntry ) - { - const sal_Int32 nMatch( rContext.EvaluateMatch( pEntry->maContext ) ); + if ( !pEntry ) + return; - if ( nMatch & Context::ApplicationWildcardMatch ) - { - // Create a separate context list entry for this app if 'any' - // is the only context that matches. Toggling the visibility - // for 'any' would change it for all apps, not just this one - AddContextDescription( rContext, bVisible, OUString() ); - } - else if ( nMatch == Context::OptimalMatch || nMatch == Context::ContextWildcardMatch ) - pEntry->mbIsInitiallyVisible = bVisible; + const sal_Int32 nMatch( rContext.EvaluateMatch( pEntry->maContext ) ); + + if ( nMatch & Context::ApplicationWildcardMatch ) + { + // Create a separate context list entry for this app if 'any' + // is the only context that matches. Toggling the visibility + // for 'any' would change it for all apps, not just this one + AddContextDescription( rContext, bVisible, OUString() ); } + else if ( nMatch == Context::OptimalMatch || nMatch == Context::ContextWildcardMatch ) + pEntry->mbIsInitiallyVisible = bVisible; } } } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx index 7202d5a750cc..e0405c9c279c 100644 --- a/sfx2/source/sidebar/Deck.cxx +++ b/sfx2/source/sidebar/Deck.cxx @@ -240,31 +240,30 @@ Panel* Deck::GetPanel(const OUString & panelId) void Deck::ShowPanel(const Panel& rPanel) { - if (mpVerticalScrollBar && mpVerticalScrollBar->IsVisible()) - { - // Get vertical extent of the panel. - sal_Int32 nPanelTop (rPanel.GetPosPixel().Y()); - const sal_Int32 nPanelBottom (nPanelTop + rPanel.GetSizePixel().Height() - 1); - // Add the title bar into the extent. - if (rPanel.GetTitleBar() && rPanel.GetTitleBar()->IsVisible()) - nPanelTop = rPanel.GetTitleBar()->GetPosPixel().Y(); - - // Determine what the new thumb position should be like. - // When the whole panel does not fit then make its top visible - // and it off at the bottom. - sal_Int32 nNewThumbPos (mpVerticalScrollBar->GetThumbPos()); - if (nPanelBottom >= nNewThumbPos+mpVerticalScrollBar->GetVisibleSize()) - nNewThumbPos = nPanelBottom - mpVerticalScrollBar->GetVisibleSize(); - if (nPanelTop < nNewThumbPos) - nNewThumbPos = nPanelTop; - - mpVerticalScrollBar->SetThumbPos(nNewThumbPos); - mpScrollContainer->SetPosPixel( - Point( - mpScrollContainer->GetPosPixel().X(), - -nNewThumbPos)); - - } + if (!mpVerticalScrollBar || !mpVerticalScrollBar->IsVisible()) + return; + + // Get vertical extent of the panel. + sal_Int32 nPanelTop (rPanel.GetPosPixel().Y()); + const sal_Int32 nPanelBottom (nPanelTop + rPanel.GetSizePixel().Height() - 1); + // Add the title bar into the extent. + if (rPanel.GetTitleBar() && rPanel.GetTitleBar()->IsVisible()) + nPanelTop = rPanel.GetTitleBar()->GetPosPixel().Y(); + + // Determine what the new thumb position should be like. + // When the whole panel does not fit then make its top visible + // and it off at the bottom. + sal_Int32 nNewThumbPos (mpVerticalScrollBar->GetThumbPos()); + if (nPanelBottom >= nNewThumbPos+mpVerticalScrollBar->GetVisibleSize()) + nNewThumbPos = nPanelBottom - mpVerticalScrollBar->GetVisibleSize(); + if (nPanelTop < nNewThumbPos) + nNewThumbPos = nPanelTop; + + mpVerticalScrollBar->SetThumbPos(nNewThumbPos); + mpScrollContainer->SetPosPixel( + Point( + mpScrollContainer->GetPosPixel().X(), + -nNewThumbPos)); } static const OUString GetWindowClassification(const vcl::Window* pWindow) diff --git a/sfx2/source/sidebar/DeckTitleBar.cxx b/sfx2/source/sidebar/DeckTitleBar.cxx index 35e62b9eee4b..c0cf41d2e23e 100644 --- a/sfx2/source/sidebar/DeckTitleBar.cxx +++ b/sfx2/source/sidebar/DeckTitleBar.cxx @@ -56,20 +56,20 @@ DeckTitleBar::DeckTitleBar (const OUString& rsTitle, void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible) { - if (mbIsCloserVisible != bIsCloserVisible) + if (mbIsCloserVisible == bIsCloserVisible) + return; + + mbIsCloserVisible = bIsCloserVisible; + + if (mbIsCloserVisible) { - mbIsCloserVisible = bIsCloserVisible; - - if (mbIsCloserVisible) - { - maToolBox->InsertItem(mnCloserItemIndex, - Theme::GetImage(Theme::Image_Closer)); - maToolBox->SetQuickHelpText(mnCloserItemIndex, - SfxResId(SFX_STR_SIDEBAR_CLOSE_DECK)); - } - else - maToolBox->RemoveItem(maToolBox->GetItemPos(mnCloserItemIndex)); + maToolBox->InsertItem(mnCloserItemIndex, + Theme::GetImage(Theme::Image_Closer)); + maToolBox->SetQuickHelpText(mnCloserItemIndex, + SfxResId(SFX_STR_SIDEBAR_CLOSE_DECK)); } + else + maToolBox->RemoveItem(maToolBox->GetItemPos(mnCloserItemIndex)); } tools::Rectangle DeckTitleBar::GetTitleArea (const tools::Rectangle& rTitleBarBox) diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx index f1057ad2027b..028097dfb0c8 100644 --- a/sfx2/source/sidebar/Panel.cxx +++ b/sfx2/source/sidebar/Panel.cxx @@ -117,18 +117,18 @@ void Panel::SetExpanded (const bool bIsExpanded) { SidebarController* pSidebarController = SidebarController::GetSidebarControllerForFrame(mxFrame); - if (mbIsExpanded != bIsExpanded) + if (mbIsExpanded == bIsExpanded) + return; + + mbIsExpanded = bIsExpanded; + maDeckLayoutTrigger(); + + if (maContextAccess && pSidebarController) { - mbIsExpanded = bIsExpanded; - maDeckLayoutTrigger(); - - if (maContextAccess && pSidebarController) - { - pSidebarController->GetResourceManager()->StorePanelExpansionState( - msPanelId, - bIsExpanded, - maContextAccess()); - } + pSidebarController->GetResourceManager()->StorePanelExpansionState( + msPanelId, + bIsExpanded, + maContextAccess()); } } diff --git a/sfx2/source/sidebar/PanelTitleBar.cxx b/sfx2/source/sidebar/PanelTitleBar.cxx index 50e5656a2347..fd97787c51c7 100644 --- a/sfx2/source/sidebar/PanelTitleBar.cxx +++ b/sfx2/source/sidebar/PanelTitleBar.cxx @@ -71,34 +71,34 @@ void PanelTitleBar::SetMoreOptionsCommand(const OUString& rsCommandName, const css::uno::Reference<css::frame::XFrame>& rxFrame, const css::uno::Reference<css::frame::XController>& rxController) { - if (rsCommandName != msMoreOptionsCommand) - { - if (msMoreOptionsCommand.getLength() > 0) - maToolBox->RemoveItem(maToolBox->GetItemPos(mnMenuItemIndex)); + if (rsCommandName == msMoreOptionsCommand) + return; - msMoreOptionsCommand = rsCommandName; - mxFrame = rxFrame; + if (msMoreOptionsCommand.getLength() > 0) + maToolBox->RemoveItem(maToolBox->GetItemPos(mnMenuItemIndex)); - if (msMoreOptionsCommand.getLength() > 0) - { - maToolBox->InsertItem( - mnMenuItemIndex, - Theme::GetImage(Theme::Image_PanelMenu)); - Reference<frame::XToolbarController> xController ( - ControllerFactory::CreateToolBoxController( - maToolBox.get(), - mnMenuItemIndex, - msMoreOptionsCommand, - rxFrame, rxController, - VCLUnoHelper::GetInterface(maToolBox.get()), - 0)); - maToolBox->SetController(mnMenuItemIndex, xController); - maToolBox->SetOutStyle(TOOLBOX_STYLE_FLAT); - maToolBox->SetQuickHelpText( - mnMenuItemIndex, - SfxResId(SFX_STR_SIDEBAR_MORE_OPTIONS)); - } - } + msMoreOptionsCommand = rsCommandName; + mxFrame = rxFrame; + + if (msMoreOptionsCommand.getLength() <= 0) + return; + + maToolBox->InsertItem( + mnMenuItemIndex, + Theme::GetImage(Theme::Image_PanelMenu)); + Reference<frame::XToolbarController> xController ( + ControllerFactory::CreateToolBoxController( + maToolBox.get(), + mnMenuItemIndex, + msMoreOptionsCommand, + rxFrame, rxController, + VCLUnoHelper::GetInterface(maToolBox.get()), + 0)); + maToolBox->SetController(mnMenuItemIndex, xController); + maToolBox->SetOutStyle(TOOLBOX_STYLE_FLAT); + maToolBox->SetQuickHelpText( + mnMenuItemIndex, + SfxResId(SFX_STR_SIDEBAR_MORE_OPTIONS)); } tools::Rectangle PanelTitleBar::GetTitleArea (const tools::Rectangle& rTitleBarBox) @@ -138,21 +138,23 @@ Paint PanelTitleBar::GetBackgroundPaint() void PanelTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex) { - if (nItemIndex == mnMenuItemIndex) - if (msMoreOptionsCommand.getLength() > 0) - { - try - { - const util::URL aURL (Tools::GetURL(msMoreOptionsCommand)); - Reference<frame::XDispatch> xDispatch (Tools::GetDispatch(mxFrame, aURL)); - if (xDispatch.is()) - xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>()); - } - catch(Exception const &) - { - DBG_UNHANDLED_EXCEPTION("sfx"); - } - } + if (nItemIndex != mnMenuItemIndex) + return; + + if (msMoreOptionsCommand.getLength() <= 0) + return; + + try + { + const util::URL aURL (Tools::GetURL(msMoreOptionsCommand)); + Reference<frame::XDispatch> xDispatch (Tools::GetDispatch(mxFrame, aURL)); + if (xDispatch.is()) + xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>()); + } + catch(Exception const &) + { + DBG_UNHANDLED_EXCEPTION("sfx"); + } } Reference<accessibility::XAccessible> PanelTitleBar::CreateAccessible() diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 2e818c133c4e..650bcefd3cab 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -432,80 +432,78 @@ void SidebarController::ProcessNewWidth (const sal_Int32 nNewWidth) void SidebarController::UpdateConfigurations() { + if (maCurrentContext == maRequestedContext + && mnRequestedForceFlags == SwitchFlag_NoForce) + return; - if (maCurrentContext != maRequestedContext - || mnRequestedForceFlags!=SwitchFlag_NoForce) + if ((maCurrentContext.msApplication != "none") && + !maCurrentContext.msApplication.isEmpty()) { + mpResourceManager->SaveDecksSettings(maCurrentContext); + mpResourceManager->SetLastActiveDeck(maCurrentContext, msCurrentDeckId); + } - if ((maCurrentContext.msApplication != "none") && - !maCurrentContext.msApplication.isEmpty()) - { - mpResourceManager->SaveDecksSettings(maCurrentContext); - mpResourceManager->SetLastActiveDeck(maCurrentContext, msCurrentDeckId); - } + // get last active deck for this application on first update + if (!maRequestedContext.msApplication.isEmpty() && + (maCurrentContext.msApplication != maRequestedContext.msApplication)) + { + OUString sLastActiveDeck = mpResourceManager->GetLastActiveDeck( maRequestedContext ); + if (!sLastActiveDeck.isEmpty()) + msCurrentDeckId = sLastActiveDeck; + } - // get last active deck for this application on first update - if (!maRequestedContext.msApplication.isEmpty() && - (maCurrentContext.msApplication != maRequestedContext.msApplication)) - { - OUString sLastActiveDeck = mpResourceManager->GetLastActiveDeck( maRequestedContext ); - if (!sLastActiveDeck.isEmpty()) - msCurrentDeckId = sLastActiveDeck; - } + maCurrentContext = maRequestedContext; + + mpResourceManager->InitDeckContext(GetCurrentContext()); - maCurrentContext = maRequestedContext; + // Find the set of decks that could be displayed for the new context. + ResourceManager::DeckContextDescriptorContainer aDecks; - mpResourceManager->InitDeckContext(GetCurrentContext()); + css::uno::Reference<css::frame::XController> xController = mxCurrentController.is() ? mxCurrentController : mxFrame->getController(); - // Find the set of decks that could be displayed for the new context. - ResourceManager::DeckContextDescriptorContainer aDecks; + mpResourceManager->GetMatchingDecks ( + aDecks, + maCurrentContext, + mbIsDocumentReadOnly, + xController); - css::uno::Reference<css::frame::XController> xController = mxCurrentController.is() ? mxCurrentController : mxFrame->getController(); + // Notify the tab bar about the updated set of decks. + mpTabBar->SetDecks(aDecks); - mpResourceManager->GetMatchingDecks ( - aDecks, - maCurrentContext, - mbIsDocumentReadOnly, - xController); - - // Notify the tab bar about the updated set of decks. - mpTabBar->SetDecks(aDecks); - - // Find the new deck. By default that is the same as the old - // one. If that is not set or not enabled, then choose the - // first enabled deck (which is PropertyDeck). - OUString sNewDeckId; - for (const auto& rDeck : aDecks) + // Find the new deck. By default that is the same as the old + // one. If that is not set or not enabled, then choose the + // first enabled deck (which is PropertyDeck). + OUString sNewDeckId; + for (const auto& rDeck : aDecks) + { + if (rDeck.mbIsEnabled) { - if (rDeck.mbIsEnabled) + if (rDeck.msId == msCurrentDeckId) { - if (rDeck.msId == msCurrentDeckId) - { - sNewDeckId = msCurrentDeckId; - break; - } - else if (sNewDeckId.getLength() == 0) - sNewDeckId = rDeck.msId; + sNewDeckId = msCurrentDeckId; + break; } + else if (sNewDeckId.getLength() == 0) + sNewDeckId = rDeck.msId; } + } - if (sNewDeckId.getLength() == 0) - { - // We did not find a valid deck. - RequestCloseDeck(); - return; - } + if (sNewDeckId.getLength() == 0) + { + // We did not find a valid deck. + RequestCloseDeck(); + return; + } - // Tell the tab bar to highlight the button associated - // with the deck. - mpTabBar->HighlightDeck(sNewDeckId); + // Tell the tab bar to highlight the button associated + // with the deck. + mpTabBar->HighlightDeck(sNewDeckId); - std::shared_ptr<DeckDescriptor> xDescriptor = mpResourceManager->GetDeckDescriptor(sNewDeckId); + std::shared_ptr<DeckDescriptor> xDescriptor = mpResourceManager->GetDeckDescriptor(sNewDeckId); - if (xDescriptor) - { - SwitchToDeck(*xDescriptor, maCurrentContext); - } + if (xDescriptor) + { + SwitchToDeck(*xDescriptor, maCurrentContext); } } @@ -593,22 +591,22 @@ void SidebarController::CreateDeck(const OUString& rDeckId, const Context& rCont { std::shared_ptr<DeckDescriptor> xDeckDescriptor = mpResourceManager->GetDeckDescriptor(rDeckId); - if (xDeckDescriptor) + if (!xDeckDescriptor) + return; + + VclPtr<Deck> aDeck = xDeckDescriptor->mpDeck; + if (aDeck.get()==nullptr || bForceCreate) { - VclPtr<Deck> aDeck = xDeckDescriptor->mpDeck; - if (aDeck.get()==nullptr || bForceCreate) - { - if (aDeck.get()!=nullptr) - aDeck.disposeAndClear(); + if (aDeck.get()!=nullptr) + aDeck.disposeAndClear(); - aDeck = VclPtr<Deck>::Create( - *xDeckDescriptor, - mpParentWindow, - [this]() { return this->RequestCloseDeck(); }); - } - xDeckDescriptor->mpDeck = aDeck; - CreatePanels(rDeckId, rContext); + aDeck = VclPtr<Deck>::Create( + *xDeckDescriptor, + mpParentWindow, + [this]() { return this->RequestCloseDeck(); }); } + xDeckDescriptor->mpDeck = aDeck; + CreatePanels(rDeckId, rContext); } void SidebarController::CreatePanels(const OUString& rDeckId, const Context& rContext) @@ -1141,30 +1139,29 @@ void SidebarController::UpdateDeckOpenState() // Update (change) the open state when it either has not yet been initialized // or when its value differs from the requested state. - if ( ! mbIsDeckOpen - || mbIsDeckOpen.get() != mbIsDeckRequestedOpen.get()) + if ( mbIsDeckOpen && mbIsDeckOpen.get() == mbIsDeckRequestedOpen.get() ) + return; + + if (mbIsDeckRequestedOpen.get()) { - if (mbIsDeckRequestedOpen.get()) - { - if (mnSavedSidebarWidth <= nTabBarDefaultWidth) - SetChildWindowWidth(SidebarChildWindow::GetDefaultWidth(mpParentWindow)); - else - SetChildWindowWidth(mnSavedSidebarWidth); - } + if (mnSavedSidebarWidth <= nTabBarDefaultWidth) + SetChildWindowWidth(SidebarChildWindow::GetDefaultWidth(mpParentWindow)); else - { - if ( ! mpParentWindow->IsFloatingMode()) - mnSavedSidebarWidth = SetChildWindowWidth(nTabBarDefaultWidth); - if (mnWidthOnSplitterButtonDown > nTabBarDefaultWidth) - mnSavedSidebarWidth = mnWidthOnSplitterButtonDown; - mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE); - } - - mbIsDeckOpen = mbIsDeckRequestedOpen.get(); - if (mbIsDeckOpen.get() && mpCurrentDeck) - mpCurrentDeck->Show(mbIsDeckOpen.get()); - NotifyResize(); + SetChildWindowWidth(mnSavedSidebarWidth); } + else + { + if ( ! mpParentWindow->IsFloatingMode()) + mnSavedSidebarWidth = SetChildWindowWidth(nTabBarDefaultWidth); + if (mnWidthOnSplitterButtonDown > nTabBarDefaultWidth) + mnSavedSidebarWidth = mnWidthOnSplitterButtonDown; + mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE); + } + + mbIsDeckOpen = mbIsDeckRequestedOpen.get(); + if (mbIsDeckOpen.get() && mpCurrentDeck) + mpCurrentDeck->Show(mbIsDeckOpen.get()); + NotifyResize(); } bool SidebarController::CanModifyChildWindowWidth() diff --git a/sfx2/source/statbar/stbitem.cxx b/sfx2/source/statbar/stbitem.cxx index 9512c25c1bf6..ffa258f639c8 100644 --- a/sfx2/source/statbar/stbitem.cxx +++ b/sfx2/source/statbar/stbitem.cxx @@ -217,71 +217,71 @@ void SAL_CALL SfxStatusBarControl::statusChanged( const frame::FeatureStateEvent if ( pSlot ) nSlotID = pSlot->GetSlotId(); - if ( nSlotID > 0 ) + if ( nSlotID <= 0 ) + return; + + if ( rEvent.Requery ) + svt::StatusbarController::statusChanged( rEvent ); + else { - if ( rEvent.Requery ) - svt::StatusbarController::statusChanged( rEvent ); - else + SfxItemState eState = SfxItemState::DISABLED; + std::unique_ptr<SfxPoolItem> pItem; + if ( rEvent.IsEnabled ) { - SfxItemState eState = SfxItemState::DISABLED; - std::unique_ptr<SfxPoolItem> pItem; - if ( rEvent.IsEnabled ) - { - eState = SfxItemState::DEFAULT; - uno::Type aType = rEvent.State.getValueType(); + eState = SfxItemState::DEFAULT; + uno::Type aType = rEvent.State.getValueType(); - if ( aType == cppu::UnoType<void>::get() ) - { - pItem.reset( new SfxVoidItem( nSlotID ) ); - eState = SfxItemState::UNKNOWN; - } - else if ( aType == cppu::UnoType<bool>::get() ) - { - bool bTemp = false; - rEvent.State >>= bTemp ; - pItem.reset( new SfxBoolItem( nSlotID, bTemp ) ); - } - else if ( aType == ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get() ) - { - sal_uInt16 nTemp = 0; - rEvent.State >>= nTemp ; - pItem.reset( new SfxUInt16Item( nSlotID, nTemp ) ); - } - else if ( aType == cppu::UnoType<sal_uInt32>::get() ) - { - sal_uInt32 nTemp = 0; - rEvent.State >>= nTemp ; - pItem.reset( new SfxUInt32Item( nSlotID, nTemp ) ); - } - else if ( aType == cppu::UnoType<OUString>::get() ) - { - OUString sTemp ; - rEvent.State >>= sTemp ; - pItem.reset( new SfxStringItem( nSlotID, sTemp ) ); - } - else if ( aType == cppu::UnoType< css::frame::status::ItemStatus>::get() ) + if ( aType == cppu::UnoType<void>::get() ) + { + pItem.reset( new SfxVoidItem( nSlotID ) ); + eState = SfxItemState::UNKNOWN; + } + else if ( aType == cppu::UnoType<bool>::get() ) + { + bool bTemp = false; + rEvent.State >>= bTemp ; + pItem.reset( new SfxBoolItem( nSlotID, bTemp ) ); + } + else if ( aType == ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get() ) + { + sal_uInt16 nTemp = 0; + rEvent.State >>= nTemp ; + pItem.reset( new SfxUInt16Item( nSlotID, nTemp ) ); + } + else if ( aType == cppu::UnoType<sal_uInt32>::get() ) + { + sal_uInt32 nTemp = 0; + rEvent.State >>= nTemp ; + pItem.reset( new SfxUInt32Item( nSlotID, nTemp ) ); + } + else if ( aType == cppu::UnoType<OUString>::get() ) + { + OUString sTemp ; + rEvent.State >>= sTemp ; + pItem.reset( new SfxStringItem( nSlotID, sTemp ) ); + } + else if ( aType == cppu::UnoType< css::frame::status::ItemStatus>::get() ) + { + frame::status::ItemStatus aItemStatus; + rEvent.State >>= aItemStatus; + eState = static_cast<SfxItemState>(aItemStatus.State); + pItem.reset( new SfxVoidItem( nSlotID ) ); + } + else + { + if ( pSlot ) + pItem = pSlot->GetType()->CreateItem(); + if ( pItem ) { - frame::status::ItemStatus aItemStatus; - rEvent.State >>= aItemStatus; - eState = static_cast<SfxItemState>(aItemStatus.State); - pItem.reset( new SfxVoidItem( nSlotID ) ); + pItem->SetWhich( nSlotID ); + pItem->PutValue( rEvent.State, 0 ); } else - { - if ( pSlot ) - pItem = pSlot->GetType()->CreateItem(); - if ( pItem ) - { - pItem->SetWhich( nSlotID ); - pItem->PutValue( rEvent.State, 0 ); - } - else - pItem.reset( new SfxVoidItem( nSlotID ) ); - } + pItem.reset( new SfxVoidItem( nSlotID ) ); } - - StateChanged( nSlotID, eState, pItem.get() ); } + + StateChanged( nSlotID, eState, pItem.get() ); } } diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index c5d698be764c..7241d98101f2 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -442,83 +442,83 @@ void SAL_CALL SfxToolBoxControl::statusChanged( const FeatureStateEvent& rEvent else if ( m_aCommandURL == rEvent.FeatureURL.Path ) nSlotId = GetSlotId(); - if ( nSlotId > 0 ) + if ( nSlotId <= 0 ) + return; + + if ( rEvent.Requery ) + svt::ToolboxController::statusChanged( rEvent ); + else { - if ( rEvent.Requery ) - svt::ToolboxController::statusChanged( rEvent ); - else + SfxItemState eState = SfxItemState::DISABLED; + std::unique_ptr<SfxPoolItem> pItem; + if ( rEvent.IsEnabled ) { - SfxItemState eState = SfxItemState::DISABLED; - std::unique_ptr<SfxPoolItem> pItem; - if ( rEvent.IsEnabled ) - { - eState = SfxItemState::DEFAULT; - css::uno::Type aType = rEvent.State.getValueType(); + eState = SfxItemState::DEFAULT; + css::uno::Type aType = rEvent.State.getValueType(); - if ( aType == cppu::UnoType<void>::get() ) - { - pItem.reset(new SfxVoidItem( nSlotId )); - eState = SfxItemState::UNKNOWN; - } - else if ( aType == cppu::UnoType<bool>::get() ) - { - bool bTemp = false; - rEvent.State >>= bTemp ; - pItem.reset(new SfxBoolItem( nSlotId, bTemp )); - } - else if ( aType == ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get()) - { - sal_uInt16 nTemp = 0; - rEvent.State >>= nTemp ; - pItem.reset(new SfxUInt16Item( nSlotId, nTemp )); - } - else if ( aType == cppu::UnoType<sal_uInt32>::get() ) - { - sal_uInt32 nTemp = 0; - rEvent.State >>= nTemp ; - pItem.reset(new SfxUInt32Item( nSlotId, nTemp )); - } - else if ( aType == cppu::UnoType<OUString>::get() ) - { - OUString sTemp ; - rEvent.State >>= sTemp ; - pItem.reset(new SfxStringItem( nSlotId, sTemp )); - } - else if ( aType == cppu::UnoType< css::frame::status::ItemStatus>::get() ) - { - ItemStatus aItemStatus; - rEvent.State >>= aItemStatus; - SfxItemState tmpState = static_cast<SfxItemState>(aItemStatus.State); - // make sure no-one tries to send us a combination of states - if (tmpState != SfxItemState::UNKNOWN && tmpState != SfxItemState::DISABLED && - tmpState != SfxItemState::READONLY && tmpState != SfxItemState::DONTCARE && - tmpState != SfxItemState::DEFAULT && tmpState != SfxItemState::SET) - throw css::uno::RuntimeException("unknown status"); - eState = tmpState; - pItem.reset(new SfxVoidItem( nSlotId )); - } - else if ( aType == cppu::UnoType< css::frame::status::Visibility>::get() ) + if ( aType == cppu::UnoType<void>::get() ) + { + pItem.reset(new SfxVoidItem( nSlotId )); + eState = SfxItemState::UNKNOWN; + } + else if ( aType == cppu::UnoType<bool>::get() ) + { + bool bTemp = false; + rEvent.State >>= bTemp ; + pItem.reset(new SfxBoolItem( nSlotId, bTemp )); + } + else if ( aType == ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get()) + { + sal_uInt16 nTemp = 0; + rEvent.State >>= nTemp ; + pItem.reset(new SfxUInt16Item( nSlotId, nTemp )); + } + else if ( aType == cppu::UnoType<sal_uInt32>::get() ) + { + sal_uInt32 nTemp = 0; + rEvent.State >>= nTemp ; + pItem.reset(new SfxUInt32Item( nSlotId, nTemp )); + } + else if ( aType == cppu::UnoType<OUString>::get() ) + { + OUString sTemp ; + rEvent.State >>= sTemp ; + pItem.reset(new SfxStringItem( nSlotId, sTemp )); + } + else if ( aType == cppu::UnoType< css::frame::status::ItemStatus>::get() ) + { + ItemStatus aItemStatus; + rEvent.State >>= aItemStatus; + SfxItemState tmpState = static_cast<SfxItemState>(aItemStatus.State); + // make sure no-one tries to send us a combination of states + if (tmpState != SfxItemState::UNKNOWN && tmpState != SfxItemState::DISABLED && + tmpState != SfxItemState::READONLY && tmpState != SfxItemState::DONTCARE && + tmpState != SfxItemState::DEFAULT && tmpState != SfxItemState::SET) + throw css::uno::RuntimeException("unknown status"); + eState = tmpState; + pItem.reset(new SfxVoidItem( nSlotId )); + } + else if ( aType == cppu::UnoType< css::frame::status::Visibility>::get() ) + { + Visibility aVisibilityStatus; + rEvent.State >>= aVisibilityStatus; + pItem.reset(new SfxVisibilityItem( nSlotId, aVisibilityStatus.bVisible )); + } + else + { + if ( pSlot ) + pItem = pSlot->GetType()->CreateItem(); + if ( pItem ) { - Visibility aVisibilityStatus; - rEvent.State >>= aVisibilityStatus; - pItem.reset(new SfxVisibilityItem( nSlotId, aVisibilityStatus.bVisible )); + pItem->SetWhich( nSlotId ); + pItem->PutValue( rEvent.State, 0 ); } else - { - if ( pSlot ) - pItem = pSlot->GetType()->CreateItem(); - if ( pItem ) - { - pItem->SetWhich( nSlotId ); - pItem->PutValue( rEvent.State, 0 ); - } - else - pItem.reset(new SfxVoidItem( nSlotId )); - } + pItem.reset(new SfxVoidItem( nSlotId )); } - - StateChanged( nSlotId, eState, pItem.get() ); } + + StateChanged( nSlotId, eState, pItem.get() ); } } diff --git a/sfx2/source/uitest/sfx_uiobject.cxx b/sfx2/source/uitest/sfx_uiobject.cxx index 37cfab79200b..5a56b4168e18 100644 --- a/sfx2/source/uitest/sfx_uiobject.cxx +++ b/sfx2/source/uitest/sfx_uiobject.cxx @@ -45,28 +45,28 @@ StringMap SfxTabDialogUIObject::get_state() void SfxTabDialogUIObject::execute(const OUString& rAction, const StringMap& rParameters) { - if (rAction == "SELECT") + if (rAction != "SELECT") + return; + + if (rParameters.find("POS") != rParameters.end()) { - if (rParameters.find("POS") != rParameters.end()) - { - auto itr = rParameters.find("POS"); - sal_uInt32 nPos = itr->second.toUInt32(); - std::vector<sal_uInt16> aIds = mxTabDialog->m_pTabCtrl->GetPageIDs(); - sal_uInt16 nPageId = aIds[nPos]; - mxTabDialog->ShowPage(nPageId); - } - else if (rParameters.find("NAME") != rParameters.end()) + auto itr = rParameters.find("POS"); + sal_uInt32 nPos = itr->second.toUInt32(); + std::vector<sal_uInt16> aIds = mxTabDialog->m_pTabCtrl->GetPageIDs(); + sal_uInt16 nPageId = aIds[nPos]; + mxTabDialog->ShowPage(nPageId); + } + else if (rParameters.find("NAME") != rParameters.end()) + { + auto itr = rParameters.find("NAME"); + OUString aName = itr->second; + std::vector<sal_uInt16> aIds = mxTabDialog->m_pTabCtrl->GetPageIDs(); + for (auto const& elem : aIds) { - auto itr = rParameters.find("NAME"); - OUString aName = itr->second; - std::vector<sal_uInt16> aIds = mxTabDialog->m_pTabCtrl->GetPageIDs(); - for (auto const& elem : aIds) + if (mxTabDialog->GetPageText(elem) == aName) { - if (mxTabDialog->GetPageText(elem) == aName) - { - mxTabDialog->ShowPage(elem); - break; - } + mxTabDialog->ShowPage(elem); + break; } } } diff --git a/sfx2/source/view/frame.cxx b/sfx2/source/view/frame.cxx index c7e8c7738f5d..d50ca359bc8d 100644 --- a/sfx2/source/view/frame.cxx +++ b/sfx2/source/view/frame.cxx @@ -221,29 +221,29 @@ void SfxFrame::SetIsClosing_Impl() void SfxFrame::CancelTransfers() { - if( !pImpl->bInCancelTransfers ) + if( pImpl->bInCancelTransfers ) + return; + + pImpl->bInCancelTransfers = true; + SfxObjectShell* pObj = GetCurrentDocument(); + if( pObj ) //&& !( pObj->Get_Impl()->nLoadedFlags & SfxLoadedFlags::ALL )) { - pImpl->bInCancelTransfers = true; - SfxObjectShell* pObj = GetCurrentDocument(); - if( pObj ) //&& !( pObj->Get_Impl()->nLoadedFlags & SfxLoadedFlags::ALL )) + SfxViewFrame* pFrm; + for( pFrm = SfxViewFrame::GetFirst( pObj ); + pFrm && &pFrm->GetFrame() == this; + pFrm = SfxViewFrame::GetNext( *pFrm, pObj ) ) ; + // No more Frame in Document -> Cancel + if( !pFrm ) { - SfxViewFrame* pFrm; - for( pFrm = SfxViewFrame::GetFirst( pObj ); - pFrm && &pFrm->GetFrame() == this; - pFrm = SfxViewFrame::GetNext( *pFrm, pObj ) ) ; - // No more Frame in Document -> Cancel - if( !pFrm ) - { - pObj->CancelTransfers(); - GetCurrentDocument()->Broadcast( SfxHint(SfxHintId::TitleChanged) ); - } + pObj->CancelTransfers(); + GetCurrentDocument()->Broadcast( SfxHint(SfxHintId::TitleChanged) ); } - - // Check if StarOne-Loader should be canceled - SfxFrameWeakRef wFrame( this ); - if (wFrame.is()) - pImpl->bInCancelTransfers = false; } + + // Check if StarOne-Loader should be canceled + SfxFrameWeakRef wFrame( this ); + if (wFrame.is()) + pImpl->bInCancelTransfers = false; } SfxViewFrame* SfxFrame::GetCurrentViewFrame() const @@ -577,24 +577,24 @@ void SfxFrame::SetToolSpaceBorderPixel_Impl( const SvBorder& rBorder ) { pImpl->aBorder = rBorder; SfxViewFrame *pF = GetCurrentViewFrame(); - if ( pF ) - { - Point aPos ( rBorder.Left(), rBorder.Top() ); - Size aSize( GetWindow().GetOutputSizePixel() ); - long nDeltaX = rBorder.Left() + rBorder.Right(); - if ( aSize.Width() > nDeltaX ) - aSize.AdjustWidth( -nDeltaX ); - else - aSize.setWidth( 0 ); + if ( !pF ) + return; - long nDeltaY = rBorder.Top() + rBorder.Bottom(); - if ( aSize.Height() > nDeltaY ) - aSize.AdjustHeight( -nDeltaY ); - else - aSize.setHeight( 0 ); + Point aPos ( rBorder.Left(), rBorder.Top() ); + Size aSize( GetWindow().GetOutputSizePixel() ); + long nDeltaX = rBorder.Left() + rBorder.Right(); + if ( aSize.Width() > nDeltaX ) + aSize.AdjustWidth( -nDeltaX ); + else + aSize.setWidth( 0 ); - pF->GetWindow().SetPosSizePixel( aPos, aSize ); - } + long nDeltaY = rBorder.Top() + rBorder.Bottom(); + if ( aSize.Height() > nDeltaY ) + aSize.AdjustHeight( -nDeltaY ); + else + aSize.setHeight( 0 ); + + pF->GetWindow().SetPosSizePixel( aPos, aSize ); } tools::Rectangle SfxFrame::GetTopOuterRectPixel_Impl() const diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index c478986cc444..8d79c52ebc0b 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -367,20 +367,20 @@ void SfxFrameLoader_Impl::impl_determineFilter( ::comphelper::NamedValueCollecti pFilter = rMatcher.GetFilter4FilterName( sSelectedFilter ); } - if ( pFilter ) - { - io_rDescriptor.put( "FilterName", pFilter->GetFilterName() ); + if ( !pFilter ) + return; - // If detected filter indicates using of an own template format - // add property "AsTemplate" to descriptor. But suppress this step - // if such property already exists. - if ( pFilter->IsOwnTemplateFormat() && !io_rDescriptor.has( "AsTemplate" ) ) - io_rDescriptor.put( "AsTemplate", true ); + io_rDescriptor.put( "FilterName", pFilter->GetFilterName() ); - // The DocumentService property will finally be used to determine the document type to create, so - // override it with the service name as indicated by the found filter. - io_rDescriptor.put( "DocumentService", pFilter->GetServiceName() ); - } + // If detected filter indicates using of an own template format + // add property "AsTemplate" to descriptor. But suppress this step + // if such property already exists. + if ( pFilter->IsOwnTemplateFormat() && !io_rDescriptor.has( "AsTemplate" ) ) + io_rDescriptor.put( "AsTemplate", true ); + + // The DocumentService property will finally be used to determine the document type to create, so + // override it with the service name as indicated by the found filter. + io_rDescriptor.put( "DocumentService", pFilter->GetServiceName() ); } diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index 9dd4503eff7f..9f59d7335e0c 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -635,22 +635,22 @@ SfxInPlaceClient::~SfxInPlaceClient() void SfxInPlaceClient::SetObjectState( sal_Int32 nState ) { - if ( GetObject().is() ) + if ( !GetObject().is() ) + return; + + if ( m_xImp->m_nAspect == embed::Aspects::MSOLE_ICON + && ( nState == embed::EmbedStates::UI_ACTIVE || nState == embed::EmbedStates::INPLACE_ACTIVE ) ) { - if ( m_xImp->m_nAspect == embed::Aspects::MSOLE_ICON - && ( nState == embed::EmbedStates::UI_ACTIVE || nState == embed::EmbedStates::INPLACE_ACTIVE ) ) - { - OSL_FAIL( "Iconified object should not be activated inplace!" ); - return; - } + OSL_FAIL( "Iconified object should not be activated inplace!" ); + return; + } - try - { - GetObject()->changeState( nState ); - } - catch ( uno::Exception& ) - {} + try + { + GetObject()->changeState( nState ); } + catch ( uno::Exception& ) + {} } @@ -1025,73 +1025,73 @@ void SfxInPlaceClient::FormatChanged() void SfxInPlaceClient::DeactivateObject() { - if ( GetObject().is() ) + if ( !GetObject().is() ) + return; + + try { - try + m_xImp->m_bUIActive = false; + bool bHasFocus = false; + uno::Reference< frame::XModel > xModel( m_xImp->m_xObject->getComponent(), uno::UNO_QUERY ); + if ( xModel.is() ) { - m_xImp->m_bUIActive = false; - bool bHasFocus = false; - uno::Reference< frame::XModel > xModel( m_xImp->m_xObject->getComponent(), uno::UNO_QUERY ); - if ( xModel.is() ) + uno::Reference< frame::XController > xController = xModel->getCurrentController(); + if ( xController.is() ) { - uno::Reference< frame::XController > xController = xModel->getCurrentController(); - if ( xController.is() ) - { - VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xController->getFrame()->getContainerWindow() ); - bHasFocus = pWindow->HasChildPathFocus( true ); - } + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xController->getFrame()->getContainerWindow() ); + bHasFocus = pWindow->HasChildPathFocus( true ); } + } - m_pViewSh->GetViewFrame()->GetFrame().LockResize_Impl(true); + m_pViewSh->GetViewFrame()->GetFrame().LockResize_Impl(true); - if ( m_xImp->m_xObject->getStatus( m_xImp->m_nAspect ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE ) - { - m_xImp->m_xObject->changeState( embed::EmbedStates::INPLACE_ACTIVE ); - if (bHasFocus) - m_pViewSh->GetWindow()->GrabFocus(); - } + if ( m_xImp->m_xObject->getStatus( m_xImp->m_nAspect ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE ) + { + m_xImp->m_xObject->changeState( embed::EmbedStates::INPLACE_ACTIVE ); + if (bHasFocus) + m_pViewSh->GetWindow()->GrabFocus(); + } + else + { + // the links should not stay in running state for long time because of locking + uno::Reference< embed::XLinkageSupport > xLink( m_xImp->m_xObject, uno::UNO_QUERY ); + if ( xLink.is() && xLink->isLink() ) + m_xImp->m_xObject->changeState( embed::EmbedStates::LOADED ); else - { - // the links should not stay in running state for long time because of locking - uno::Reference< embed::XLinkageSupport > xLink( m_xImp->m_xObject, uno::UNO_QUERY ); - if ( xLink.is() && xLink->isLink() ) - m_xImp->m_xObject->changeState( embed::EmbedStates::LOADED ); - else - m_xImp->m_xObject->changeState( embed::EmbedStates::RUNNING ); - } - - SfxViewFrame* pFrame = m_pViewSh->GetViewFrame(); - SfxViewFrame::SetViewFrame( pFrame ); - pFrame->GetFrame().LockResize_Impl(false); - pFrame->GetFrame().Resize(); + m_xImp->m_xObject->changeState( embed::EmbedStates::RUNNING ); } - catch (css::uno::Exception& ) - {} + + SfxViewFrame* pFrame = m_pViewSh->GetViewFrame(); + SfxViewFrame::SetViewFrame( pFrame ); + pFrame->GetFrame().LockResize_Impl(false); + pFrame->GetFrame().Resize(); } + catch (css::uno::Exception& ) + {} } void SfxInPlaceClient::ResetObject() { - if ( GetObject().is() ) + if ( !GetObject().is() ) + return; + + try { - try + m_xImp->m_bUIActive = false; + if ( m_xImp->m_xObject->getStatus( m_xImp->m_nAspect ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE ) + m_xImp->m_xObject->changeState( embed::EmbedStates::INPLACE_ACTIVE ); + else { - m_xImp->m_bUIActive = false; - if ( m_xImp->m_xObject->getStatus( m_xImp->m_nAspect ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE ) - m_xImp->m_xObject->changeState( embed::EmbedStates::INPLACE_ACTIVE ); + // the links should not stay in running state for long time because of locking + uno::Reference< embed::XLinkageSupport > xLink( m_xImp->m_xObject, uno::UNO_QUERY ); + if ( xLink.is() && xLink->isLink() ) + m_xImp->m_xObject->changeState( embed::EmbedStates::LOADED ); else - { - // the links should not stay in running state for long time because of locking - uno::Reference< embed::XLinkageSupport > xLink( m_xImp->m_xObject, uno::UNO_QUERY ); - if ( xLink.is() && xLink->isLink() ) - m_xImp->m_xObject->changeState( embed::EmbedStates::LOADED ); - else - m_xImp->m_xObject->changeState( embed::EmbedStates::RUNNING ); - } + m_xImp->m_xObject->changeState( embed::EmbedStates::RUNNING ); } - catch (css::uno::Exception& ) - {} } + catch (css::uno::Exception& ) + {} } bool SfxInPlaceClient::IsUIActive() diff --git a/sfx2/source/view/lokcharthelper.cxx b/sfx2/source/view/lokcharthelper.cxx index dd68454b8e59..b17fbb28fdcf 100644 --- a/sfx2/source/view/lokcharthelper.cxx +++ b/sfx2/source/view/lokcharthelper.cxx @@ -193,46 +193,46 @@ bool LokChartHelper::HitAny(const Point& aPos) void LokChartHelper::PaintTile(VirtualDevice& rRenderContext, const tools::Rectangle& rTileRect) { - if (mpViewShell) - { - vcl::Window* pChartWindow = GetWindow(); - if (pChartWindow) - { - tools::Rectangle aChartRect = GetChartBoundingBox(); - tools::Rectangle aTestRect = rTileRect; - aTestRect.Intersection( aChartRect ); - if (!aTestRect.IsEmpty()) - { - Point aOffset( aChartRect.Left() - rTileRect.Left(), aChartRect.Top() - rTileRect.Top() ); - Point aOffsetFromTile = lcl_TwipsToHMM(aOffset); - Size aSize = lcl_TwipsToHMM(aChartRect.GetSize()); - tools::Rectangle aRectangle(Point(0,0), aSize); + if (!mpViewShell) + return; - bool bEnableMapMode = !pChartWindow->IsMapModeEnabled(); - pChartWindow->EnableMapMode(); - bool bRenderContextEnableMapMode = !rRenderContext.IsMapModeEnabled(); - rRenderContext.EnableMapMode(); + vcl::Window* pChartWindow = GetWindow(); + if (!pChartWindow) + return; - rRenderContext.Push(PushFlags::MAPMODE); + tools::Rectangle aChartRect = GetChartBoundingBox(); + tools::Rectangle aTestRect = rTileRect; + aTestRect.Intersection( aChartRect ); + if (aTestRect.IsEmpty()) + return; - MapMode aCWMapMode = pChartWindow->GetMapMode(); - aCWMapMode.SetScaleX(rRenderContext.GetMapMode().GetScaleX()); - aCWMapMode.SetScaleY(rRenderContext.GetMapMode().GetScaleY()); + Point aOffset( aChartRect.Left() - rTileRect.Left(), aChartRect.Top() - rTileRect.Top() ); + Point aOffsetFromTile = lcl_TwipsToHMM(aOffset); + Size aSize = lcl_TwipsToHMM(aChartRect.GetSize()); + tools::Rectangle aRectangle(Point(0,0), aSize); - aCWMapMode.SetOrigin(aOffsetFromTile); - rRenderContext.SetMapMode(aCWMapMode); + bool bEnableMapMode = !pChartWindow->IsMapModeEnabled(); + pChartWindow->EnableMapMode(); + bool bRenderContextEnableMapMode = !rRenderContext.IsMapModeEnabled(); + rRenderContext.EnableMapMode(); - pChartWindow->Paint(rRenderContext, aRectangle); + rRenderContext.Push(PushFlags::MAPMODE); - rRenderContext.Pop(); + MapMode aCWMapMode = pChartWindow->GetMapMode(); + aCWMapMode.SetScaleX(rRenderContext.GetMapMode().GetScaleX()); + aCWMapMode.SetScaleY(rRenderContext.GetMapMode().GetScaleY()); - if (bRenderContextEnableMapMode) - rRenderContext.EnableMapMode(false); - if (bEnableMapMode) - pChartWindow->EnableMapMode(false); - } - } - } + aCWMapMode.SetOrigin(aOffsetFromTile); + rRenderContext.SetMapMode(aCWMapMode); + + pChartWindow->Paint(rRenderContext, aRectangle); + + rRenderContext.Pop(); + + if (bRenderContextEnableMapMode) + rRenderContext.EnableMapMode(false); + if (bEnableMapMode) + pChartWindow->EnableMapMode(false); } void LokChartHelper::PaintAllChartsOnTile(VirtualDevice& rDevice, @@ -240,37 +240,37 @@ void LokChartHelper::PaintAllChartsOnTile(VirtualDevice& rDevice, int nTilePosX, int nTilePosY, long nTileWidth, long nTileHeight) { - if (!comphelper::LibreOfficeKit::isTiledAnnotations()) + if (comphelper::LibreOfficeKit::isTiledAnnotations()) + return; + + // Resizes the virtual device so to contain the entries context + rDevice.SetOutputSizePixel(Size(nOutputWidth, nOutputHeight)); + + rDevice.Push(PushFlags::MAPMODE); + MapMode aMapMode(rDevice.GetMapMode()); + + // Scaling. Must convert from pixels to twips. We know + // that VirtualDevices use a DPI of 96. + Fraction scaleX = Fraction(nOutputWidth, 96) * Fraction(1440) / Fraction(nTileWidth); + Fraction scaleY = Fraction(nOutputHeight, 96) * Fraction(1440) / Fraction(nTileHeight); + aMapMode.SetScaleX(scaleX); + aMapMode.SetScaleY(scaleY); + rDevice.SetMapMode(aMapMode); + + SfxViewShell* pCurView = SfxViewShell::Current(); + int nPartForCurView = pCurView ? pCurView->getPart() : -1; + tools::Rectangle aTileRect(Point(nTilePosX, nTilePosY), Size(nTileWidth, nTileHeight)); + SfxViewShell* pViewShell = SfxViewShell::GetFirst(); + while (pViewShell) { - // Resizes the virtual device so to contain the entries context - rDevice.SetOutputSizePixel(Size(nOutputWidth, nOutputHeight)); - - rDevice.Push(PushFlags::MAPMODE); - MapMode aMapMode(rDevice.GetMapMode()); - - // Scaling. Must convert from pixels to twips. We know - // that VirtualDevices use a DPI of 96. - Fraction scaleX = Fraction(nOutputWidth, 96) * Fraction(1440) / Fraction(nTileWidth); - Fraction scaleY = Fraction(nOutputHeight, 96) * Fraction(1440) / Fraction(nTileHeight); - aMapMode.SetScaleX(scaleX); - aMapMode.SetScaleY(scaleY); - rDevice.SetMapMode(aMapMode); - - SfxViewShell* pCurView = SfxViewShell::Current(); - int nPartForCurView = pCurView ? pCurView->getPart() : -1; - tools::Rectangle aTileRect(Point(nTilePosX, nTilePosY), Size(nTileWidth, nTileHeight)); - SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - while (pViewShell) + if (pViewShell->getPart() == nPartForCurView) { - if (pViewShell->getPart() == nPartForCurView) - { - LokChartHelper aChartHelper(pViewShell); - aChartHelper.PaintTile(rDevice, aTileRect); - } - pViewShell = SfxViewShell::GetNext(*pViewShell); + LokChartHelper aChartHelper(pViewShell); + aChartHelper.PaintTile(rDevice, aTileRect); } - rDevice.Pop(); + pViewShell = SfxViewShell::GetNext(*pViewShell); } + rDevice.Pop(); } bool LokChartHelper::postMouseEvent(int nType, int nX, int nY, diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 88fdd373f8b2..79f720f18143 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -516,22 +516,22 @@ void SAL_CALL SfxBaseController::attachFrame( const Reference< frame::XFrame >& m_pData->m_xFrame = xFrame; - if ( xFrame.is() ) - { - xFrame->addFrameActionListener( m_pData->m_xListener ) ; - Reference < util::XCloseBroadcaster > xCloseable( xFrame, uno::UNO_QUERY ); - if ( xCloseable.is() ) - xCloseable->addCloseListener( m_pData->m_xCloseListener ); + if ( !xFrame.is() ) + return; - if ( m_pData->m_pViewShell ) - { - ConnectSfxFrame_Impl( E_CONNECT ); - ShowInfoBars( ); + xFrame->addFrameActionListener( m_pData->m_xListener ) ; + Reference < util::XCloseBroadcaster > xCloseable( xFrame, uno::UNO_QUERY ); + if ( xCloseable.is() ) + xCloseable->addCloseListener( m_pData->m_xCloseListener ); - // attaching the frame to the controller is the last step in the creation of a new view, so notify this - SfxViewEventHint aHint( SfxEventHintId::ViewCreated, GlobalEventConfig::GetEventName( GlobalEventId::VIEWCREATED ), m_pData->m_pViewShell->GetObjectShell(), Reference< frame::XController2 >( this ) ); - SfxGetpApp()->NotifyEvent( aHint ); - } + if ( m_pData->m_pViewShell ) + { + ConnectSfxFrame_Impl( E_CONNECT ); + ShowInfoBars( ); + + // attaching the frame to the controller is the last step in the creation of a new view, so notify this + SfxViewEventHint aHint( SfxEventHintId::ViewCreated, GlobalEventConfig::GetEventName( GlobalEventId::VIEWCREATED ), m_pData->m_pViewShell->GetObjectShell(), Reference< frame::XController2 >( this ) ); + SfxGetpApp()->NotifyEvent( aHint ); } } @@ -894,22 +894,22 @@ void SfxBaseController::BorderWidthsChanged_Impl() { ::cppu::OInterfaceContainerHelper* pContainer = m_pData->m_aListenerContainer.getContainer( cppu::UnoType<frame::XBorderResizeListener>::get()); - if ( pContainer ) - { - frame::BorderWidths aBWidths = getBorder(); - Reference< uno::XInterface > xThis( static_cast< ::cppu::OWeakObject* >(this), uno::UNO_QUERY ); + if ( !pContainer ) + return; + + frame::BorderWidths aBWidths = getBorder(); + Reference< uno::XInterface > xThis( static_cast< ::cppu::OWeakObject* >(this), uno::UNO_QUERY ); - ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); - while (pIterator.hasMoreElements()) + ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); + while (pIterator.hasMoreElements()) + { + try { - try - { - static_cast<frame::XBorderResizeListener*>(pIterator.next())->borderWidthsChanged( xThis, aBWidths ); - } - catch (const RuntimeException&) - { - pIterator.remove(); - } + static_cast<frame::XBorderResizeListener*>(pIterator.next())->borderWidthsChanged( xThis, aBWidths ); + } + catch (const RuntimeException&) + { + pIterator.remove(); } } } @@ -931,56 +931,56 @@ void SAL_CALL SfxBaseController::dispose() if ( m_pData->m_pController && m_pData->m_pController->getFrame().is() ) m_pData->m_pController->getFrame()->removeFrameActionListener( m_pData->m_xListener ) ; - if ( m_pData->m_pViewShell ) - { - SfxViewFrame* pFrame = m_pData->m_pViewShell->GetViewFrame() ; - if ( pFrame && pFrame->GetViewShell() == m_pData->m_pViewShell ) - pFrame->GetFrame().SetIsClosing_Impl(); - m_pData->m_pViewShell->DisconnectAllClients(); + if ( !m_pData->m_pViewShell ) + return; - if ( pFrame ) - { - lang::EventObject aObject; - aObject.Source = *this ; + SfxViewFrame* pFrame = m_pData->m_pViewShell->GetViewFrame() ; + if ( pFrame && pFrame->GetViewShell() == m_pData->m_pViewShell ) + pFrame->GetFrame().SetIsClosing_Impl(); + m_pData->m_pViewShell->DisconnectAllClients(); - SfxObjectShell* pDoc = pFrame->GetObjectShell() ; - SfxViewFrame *pView = SfxViewFrame::GetFirst(pDoc); - while( pView ) - { - // if there is another ViewFrame or currently the ViewShell in my ViewFrame is switched (PagePreview) - if ( pView != pFrame || pView->GetViewShell() != m_pData->m_pViewShell ) - break; - pView = SfxViewFrame::GetNext( *pView, pDoc ); - } + if ( !pFrame ) + return; - SfxGetpApp()->NotifyEvent( SfxViewEventHint(SfxEventHintId::CloseView, GlobalEventConfig::GetEventName( GlobalEventId::CLOSEVIEW ), pDoc, Reference< frame::XController2 >( this ) ) ); - if ( !pView ) - SfxGetpApp()->NotifyEvent( SfxEventHint(SfxEventHintId::CloseDoc, GlobalEventConfig::GetEventName( GlobalEventId::CLOSEDOC ), pDoc) ); + lang::EventObject aObject; + aObject.Source = *this ; - Reference< frame::XModel > xModel = pDoc->GetModel(); - Reference < util::XCloseable > xCloseable( xModel, uno::UNO_QUERY ); - if ( xModel.is() ) - { - xModel->disconnectController( this ); - if ( xCloseable.is() ) - xCloseable->removeCloseListener( m_pData->m_xCloseListener ); - } + SfxObjectShell* pDoc = pFrame->GetObjectShell() ; + SfxViewFrame *pView = SfxViewFrame::GetFirst(pDoc); + while( pView ) + { + // if there is another ViewFrame or currently the ViewShell in my ViewFrame is switched (PagePreview) + if ( pView != pFrame || pView->GetViewShell() != m_pData->m_pViewShell ) + break; + pView = SfxViewFrame::GetNext( *pView, pDoc ); + } - Reference < frame::XFrame > aXFrame; - attachFrame( aXFrame ); + SfxGetpApp()->NotifyEvent( SfxViewEventHint(SfxEventHintId::CloseView, GlobalEventConfig::GetEventName( GlobalEventId::CLOSEVIEW ), pDoc, Reference< frame::XController2 >( this ) ) ); + if ( !pView ) + SfxGetpApp()->NotifyEvent( SfxEventHint(SfxEventHintId::CloseDoc, GlobalEventConfig::GetEventName( GlobalEventId::CLOSEDOC ), pDoc) ); - m_pData->m_xListener->disposing( aObject ); - SfxViewShell *pShell = m_pData->m_pViewShell; - m_pData->m_pViewShell = nullptr; - if ( pFrame->GetViewShell() == pShell ) - { - // Enter registrations only allowed if we are the owner! - if ( pFrame->GetFrame().OwnsBindings_Impl() ) - pFrame->GetBindings().ENTERREGISTRATIONS(); - pFrame->GetFrame().SetFrameInterface_Impl( aXFrame ); - pFrame->GetFrame().DoClose_Impl(); - } - } + Reference< frame::XModel > xModel = pDoc->GetModel(); + Reference < util::XCloseable > xCloseable( xModel, uno::UNO_QUERY ); + if ( xModel.is() ) + { + xModel->disconnectController( this ); + if ( xCloseable.is() ) + xCloseable->removeCloseListener( m_pData->m_xCloseListener ); + } + + Reference < frame::XFrame > aXFrame; + attachFrame( aXFrame ); + + m_pData->m_xListener->disposing( aObject ); + SfxViewShell *pShell = m_pData->m_pViewShell; + m_pData->m_pViewShell = nullptr; + if ( pFrame->GetViewShell() == pShell ) + { + // Enter registrations only allowed if we are the owner! + if ( pFrame->GetFrame().OwnsBindings_Impl() ) + pFrame->GetBindings().ENTERREGISTRATIONS(); + pFrame->GetFrame().SetFrameInterface_Impl( aXFrame ); + pFrame->GetFrame().DoClose_Impl(); } } @@ -1005,22 +1005,22 @@ void SAL_CALL SfxBaseController::removeEventListener( const Reference< lang::XEv void SfxBaseController::ReleaseShell_Impl() { SolarMutexGuard aGuard; - if ( m_pData->m_pViewShell ) - { - SfxObjectShell* pDoc = m_pData->m_pViewShell->GetObjectShell() ; - Reference< frame::XModel > xModel = pDoc->GetModel(); - Reference < util::XCloseable > xCloseable( xModel, uno::UNO_QUERY ); - if ( xModel.is() ) - { - xModel->disconnectController( this ); - if ( xCloseable.is() ) - xCloseable->removeCloseListener( m_pData->m_xCloseListener ); - } - m_pData->m_pViewShell = nullptr; + if ( !m_pData->m_pViewShell ) + return; - Reference < frame::XFrame > aXFrame; - attachFrame( aXFrame ); + SfxObjectShell* pDoc = m_pData->m_pViewShell->GetObjectShell() ; + Reference< frame::XModel > xModel = pDoc->GetModel(); + Reference < util::XCloseable > xCloseable( xModel, uno::UNO_QUERY ); + if ( xModel.is() ) + { + xModel->disconnectController( this ); + if ( xCloseable.is() ) + xCloseable->removeCloseListener( m_pData->m_xCloseListener ); } + m_pData->m_pViewShell = nullptr; + + Reference < frame::XFrame > aXFrame; + attachFrame( aXFrame ); } SfxViewShell* SfxBaseController::GetViewShell_Impl() const @@ -1360,49 +1360,49 @@ void SfxBaseController::ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect ) void SfxBaseController::ShowInfoBars( ) { - if ( m_pData->m_pViewShell ) - { - // CMIS verifications - Reference< document::XCmisDocument > xCmisDoc( m_pData->m_pViewShell->GetObjectShell()->GetModel(), uno::UNO_QUERY ); - if ( xCmisDoc.is( ) && xCmisDoc->canCheckOut( ) ) - { - uno::Sequence< document::CmisProperty> aCmisProperties = xCmisDoc->getCmisProperties( ); + if ( !m_pData->m_pViewShell ) + return; - if ( xCmisDoc->isVersionable( ) && aCmisProperties.hasElements( ) ) - { - // Loop over the CMIS Properties to find cmis:isVersionSeriesCheckedOut - // and find if it is a Google Drive file. - bool bIsGoogleFile = false; - bool bCheckedOut = false; - for ( sal_Int32 i = 0; i < aCmisProperties.getLength(); ++i ) - { - if ( aCmisProperties[i].Id == "cmis:isVersionSeriesCheckedOut" ) { - uno::Sequence< sal_Bool > bTmp; - aCmisProperties[i].Value >>= bTmp; - bCheckedOut = bTmp[0]; - } - // if it is a Google Drive file, we don't need the checkout bar, - // still need the checkout feature for the version dialog. - if ( aCmisProperties[i].Name == "title" ) - bIsGoogleFile = true; - } + // CMIS verifications + Reference< document::XCmisDocument > xCmisDoc( m_pData->m_pViewShell->GetObjectShell()->GetModel(), uno::UNO_QUERY ); + if ( !xCmisDoc.is( ) || !xCmisDoc->canCheckOut( ) ) + return; - if ( !bCheckedOut && !bIsGoogleFile ) - { - // Get the Frame and show the InfoBar if not checked out - SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame(); - auto pInfoBar = pViewFrame->AppendInfoBar( "checkout", SfxResId( STR_NONCHECKEDOUT_DOCUMENT ), InfoBarType::Warning); - if (pInfoBar) - { - VclPtrInstance<PushButton> xBtn(&pViewFrame->GetWindow()); - xBtn->SetText(SfxResId(STR_CHECKOUT)); - xBtn->SetSizePixel(xBtn->GetOptimalSize()); - xBtn->SetClickHdl(LINK(this, SfxBaseController, CheckOutHandler)); - pInfoBar->addButton(xBtn); - } - } - } + uno::Sequence< document::CmisProperty> aCmisProperties = xCmisDoc->getCmisProperties( ); + + if ( !(xCmisDoc->isVersionable( ) && aCmisProperties.hasElements( )) ) + return; + + // Loop over the CMIS Properties to find cmis:isVersionSeriesCheckedOut + // and find if it is a Google Drive file. + bool bIsGoogleFile = false; + bool bCheckedOut = false; + for ( sal_Int32 i = 0; i < aCmisProperties.getLength(); ++i ) + { + if ( aCmisProperties[i].Id == "cmis:isVersionSeriesCheckedOut" ) { + uno::Sequence< sal_Bool > bTmp; + aCmisProperties[i].Value >>= bTmp; + bCheckedOut = bTmp[0]; } + // if it is a Google Drive file, we don't need the checkout bar, + // still need the checkout feature for the version dialog. + if ( aCmisProperties[i].Name == "title" ) + bIsGoogleFile = true; + } + + if ( !(!bCheckedOut && !bIsGoogleFile) ) + return; + + // Get the Frame and show the InfoBar if not checked out + SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame(); + auto pInfoBar = pViewFrame->AppendInfoBar( "checkout", SfxResId( STR_NONCHECKEDOUT_DOCUMENT ), InfoBarType::Warning); + if (pInfoBar) + { + VclPtrInstance<PushButton> xBtn(&pViewFrame->GetWindow()); + xBtn->SetText(SfxResId(STR_CHECKOUT)); + xBtn->SetSizePixel(xBtn->GetOptimalSize()); + xBtn->SetClickHdl(LINK(this, SfxBaseController, CheckOutHandler)); + pInfoBar->addButton(xBtn); } } diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 1c47240100b8..049307823e24 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1125,19 +1125,19 @@ void SfxViewFrame::DoDeactivate(bool bUI, SfxViewFrame const * pNewFrame ) void SfxViewFrame::InvalidateBorderImpl( const SfxViewShell* pSh ) { - if( pSh && !m_nAdjustPosPixelLock ) + if( !pSh || m_nAdjustPosPixelLock ) + return; + + if ( GetViewShell() && GetWindow().IsVisible() ) { - if ( GetViewShell() && GetWindow().IsVisible() ) + if ( GetFrame().IsInPlace() ) { - if ( GetFrame().IsInPlace() ) - { - return; - } - - DoAdjustPosSizePixel( GetViewShell(), Point(), - GetWindow().GetOutputSizePixel(), - false ); + return; } + + DoAdjustPosSizePixel( GetViewShell(), Point(), + GetWindow().GetOutputSizePixel(), + false ); } } @@ -1671,30 +1671,30 @@ void SfxViewFrame::GetDocNumber_Impl() void SfxViewFrame::Enable( bool bEnable ) { - if ( bEnable != m_pImpl->bEnabled ) - { - m_pImpl->bEnabled = bEnable; + if ( bEnable == m_pImpl->bEnabled ) + return; - vcl::Window *pWindow = &GetFrame().GetWindow(); - if ( !bEnable ) - m_pImpl->bWindowWasEnabled = pWindow->IsInputEnabled(); - if ( !bEnable || m_pImpl->bWindowWasEnabled ) - pWindow->EnableInput( bEnable ); + m_pImpl->bEnabled = bEnable; - // cursor and focus - SfxViewShell* pViewSh = GetViewShell(); - if ( bEnable ) - { - // show cursor - if ( pViewSh ) - pViewSh->ShowCursor(); - } - else - { - // hide cursor - if ( pViewSh ) - pViewSh->ShowCursor(false); - } + vcl::Window *pWindow = &GetFrame().GetWindow(); + if ( !bEnable ) + m_pImpl->bWindowWasEnabled = pWindow->IsInputEnabled(); + if ( !bEnable || m_pImpl->bWindowWasEnabled ) + pWindow->EnableInput( bEnable ); + + // cursor and focus + SfxViewShell* pViewSh = GetViewShell(); + if ( bEnable ) + { + // show cursor + if ( pViewSh ) + pViewSh->ShowCursor(); + } + else + { + // hide cursor + if ( pViewSh ) + pViewSh->ShowCursor(false); } } @@ -1749,42 +1749,42 @@ void SfxViewFrame::LockObjectShell_Impl() void SfxViewFrame::MakeActive_Impl( bool bGrabFocus ) { - if ( GetViewShell() && !GetFrame().IsClosing_Impl() ) + if ( !GetViewShell() || GetFrame().IsClosing_Impl() ) + return; + + if ( !IsVisible() ) + return; + + bool bPreview = false; + if (GetObjectShell()->IsPreview()) { - if ( IsVisible() ) - { - bool bPreview = false; - if (GetObjectShell()->IsPreview()) - { - bPreview = true; - } + bPreview = true; + } - css::uno::Reference<css::frame::XFrame> xFrame = GetFrame().GetFrameInterface(); - if (!bPreview) - { - SetViewFrame(this); - GetBindings().SetActiveFrame(css::uno::Reference<css::frame::XFrame>()); - uno::Reference<frame::XFramesSupplier> xSupp(xFrame, uno::UNO_QUERY); - if (xSupp.is()) - xSupp->setActiveFrame(uno::Reference<frame::XFrame>()); - - css::uno::Reference< css::awt::XWindow > xContainerWindow = xFrame->getContainerWindow(); - VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xContainerWindow); - if (pWindow && pWindow->HasChildPathFocus() && bGrabFocus) - { - SfxInPlaceClient *pCli = GetViewShell()->GetUIActiveClient(); - if (!pCli || !pCli->IsObjectUIActive()) - GetFrame().GrabFocusOnComponent_Impl(); - } - } - else - { - GetBindings().SetDispatcher(GetDispatcher()); - GetBindings().SetActiveFrame(css::uno::Reference<css::frame::XFrame>()); - GetDispatcher()->Update_Impl(); - } + css::uno::Reference<css::frame::XFrame> xFrame = GetFrame().GetFrameInterface(); + if (!bPreview) + { + SetViewFrame(this); + GetBindings().SetActiveFrame(css::uno::Reference<css::frame::XFrame>()); + uno::Reference<frame::XFramesSupplier> xSupp(xFrame, uno::UNO_QUERY); + if (xSupp.is()) + xSupp->setActiveFrame(uno::Reference<frame::XFrame>()); + + css::uno::Reference< css::awt::XWindow > xContainerWindow = xFrame->getContainerWindow(); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xContainerWindow); + if (pWindow && pWindow->HasChildPathFocus() && bGrabFocus) + { + SfxInPlaceClient *pCli = GetViewShell()->GetUIActiveClient(); + if (!pCli || !pCli->IsObjectUIActive()) + GetFrame().GrabFocusOnComponent_Impl(); } } + else + { + GetBindings().SetDispatcher(GetDispatcher()); + GetBindings().SetActiveFrame(css::uno::Reference<css::frame::XFrame>()); + GetDispatcher()->Update_Impl(); + } } SfxObjectShell* SfxViewFrame::GetObjectShell() @@ -2403,21 +2403,21 @@ bool SfxViewFrame::IsInModalMode() const void SfxViewFrame::Resize( bool bForce ) { Size aSize = GetWindow().GetOutputSizePixel(); - if ( bForce || aSize != m_pImpl->aSize ) + if ( !bForce && aSize == m_pImpl->aSize ) + return; + + m_pImpl->aSize = aSize; + SfxViewShell *pShell = GetViewShell(); + if ( pShell ) { - m_pImpl->aSize = aSize; - SfxViewShell *pShell = GetViewShell(); - if ( pShell ) + if ( GetFrame().IsInPlace() ) { - if ( GetFrame().IsInPlace() ) - { - Point aPoint = GetWindow().GetPosPixel(); - DoAdjustPosSizePixel( pShell, aPoint, aSize, true ); - } - else - { - DoAdjustPosSizePixel( pShell, Point(), aSize, false ); - } + Point aPoint = GetWindow().GetPosPixel(); + DoAdjustPosSizePixel( pShell, aPoint, aSize, true ); + } + else + { + DoAdjustPosSizePixel( pShell, Point(), aSize, false ); } } } diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 0fad3be55591..fcbf0d9bf9f5 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -270,140 +270,140 @@ Sequence< beans::PropertyValue > SfxPrinterController::getPageParameters( int i_ void SfxPrinterController::printPage( int i_nPage ) const { VclPtr<Printer> xPrinter( getPrinter() ); - if( mxRenderable.is() && xPrinter ) + if( !mxRenderable.is() || !xPrinter ) + return; + + Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() ); + try { - Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() ); - try - { - mxRenderable->render( i_nPage, getSelectionObject(), aJobOptions ); - } - catch( lang::IllegalArgumentException& ) - { - // don't care enough about nonexistent page here - // to provoke a crash - } - catch (lang::DisposedException &) - { - SAL_WARN("sfx", "SfxPrinterController: document disposed while printing"); - const_cast<SfxPrinterController*>(this)->setJobState( - view::PrintableState_JOB_ABORTED); - } + mxRenderable->render( i_nPage, getSelectionObject(), aJobOptions ); + } + catch( lang::IllegalArgumentException& ) + { + // don't care enough about nonexistent page here + // to provoke a crash + } + catch (lang::DisposedException &) + { + SAL_WARN("sfx", "SfxPrinterController: document disposed while printing"); + const_cast<SfxPrinterController*>(this)->setJobState( + view::PrintableState_JOB_ABORTED); } } void SfxPrinterController::jobStarted() { - if ( mpObjectShell ) - { - m_bOrigStatus = mpObjectShell->IsEnableSetModified(); + if ( !mpObjectShell ) + return; - // check configuration: shall update of printing information in DocInfo set the document to "modified"? - if ( m_bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() ) - { - mpObjectShell->EnableSetModified( false ); - m_bNeedsChange = true; - } + m_bOrigStatus = mpObjectShell->IsEnableSetModified(); - // refresh document info - uno::Reference<document::XDocumentProperties> xDocProps(mpObjectShell->getDocProperties()); - m_aLastPrintedBy = xDocProps->getPrintedBy(); - m_aLastPrinted = xDocProps->getPrintDate(); + // check configuration: shall update of printing information in DocInfo set the document to "modified"? + if ( m_bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() ) + { + mpObjectShell->EnableSetModified( false ); + m_bNeedsChange = true; + } - xDocProps->setPrintedBy( mpObjectShell->IsUseUserData() - ? SvtUserOptions().GetFullName() - : OUString() ); - ::DateTime now( ::DateTime::SYSTEM ); + // refresh document info + uno::Reference<document::XDocumentProperties> xDocProps(mpObjectShell->getDocProperties()); + m_aLastPrintedBy = xDocProps->getPrintedBy(); + m_aLastPrinted = xDocProps->getPrintDate(); - xDocProps->setPrintDate( now.GetUNODateTime() ); + xDocProps->setPrintedBy( mpObjectShell->IsUseUserData() + ? SvtUserOptions().GetFullName() + : OUString() ); + ::DateTime now( ::DateTime::SYSTEM ); - SfxGetpApp()->NotifyEvent( SfxEventHint(SfxEventHintId::PrintDoc, GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ), mpObjectShell ) ); - uno::Sequence < beans::PropertyValue > aOpts; - aOpts = getJobProperties( aOpts ); + xDocProps->setPrintDate( now.GetUNODateTime() ); - uno::Reference< frame::XController2 > xController; - if ( mpViewShell ) - xController.set( mpViewShell->GetController(), uno::UNO_QUERY ); + SfxGetpApp()->NotifyEvent( SfxEventHint(SfxEventHintId::PrintDoc, GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ), mpObjectShell ) ); + uno::Sequence < beans::PropertyValue > aOpts; + aOpts = getJobProperties( aOpts ); - mpObjectShell->Broadcast( SfxPrintingHint( - view::PrintableState_JOB_STARTED, aOpts, mpObjectShell, xController ) ); - } + uno::Reference< frame::XController2 > xController; + if ( mpViewShell ) + xController.set( mpViewShell->GetController(), uno::UNO_QUERY ); + + mpObjectShell->Broadcast( SfxPrintingHint( + view::PrintableState_JOB_STARTED, aOpts, mpObjectShell, xController ) ); } void SfxPrinterController::jobFinished( css::view::PrintableState nState ) { - if ( mpObjectShell ) + if ( !mpObjectShell ) + return; + + bool bCopyJobSetup = false; + mpObjectShell->Broadcast( SfxPrintingHint( nState ) ); + switch ( nState ) { - bool bCopyJobSetup = false; - mpObjectShell->Broadcast( SfxPrintingHint( nState ) ); - switch ( nState ) + case view::PrintableState_JOB_SPOOLING_FAILED : + case view::PrintableState_JOB_FAILED : { - case view::PrintableState_JOB_SPOOLING_FAILED : - case view::PrintableState_JOB_FAILED : + // "real" problem (not simply printing cancelled by user) + OUString aMsg( SfxResId(STR_NOSTARTPRINTER) ); + if ( !m_bApi ) { - // "real" problem (not simply printing cancelled by user) - OUString aMsg( SfxResId(STR_NOSTARTPRINTER) ); - if ( !m_bApi ) - { - vcl::Window* pWindow = mpViewShell->GetWindow(); - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, - VclMessageType::Warning, VclButtonsType::Ok, - aMsg)); - xBox->run(); - } - [[fallthrough]]; - } - case view::PrintableState_JOB_ABORTED : - { - // printing not successful, reset DocInfo - uno::Reference<document::XDocumentProperties> xDocProps(mpObjectShell->getDocProperties()); - xDocProps->setPrintedBy(m_aLastPrintedBy); - xDocProps->setPrintDate(m_aLastPrinted); - break; - } - - case view::PrintableState_JOB_SPOOLED : - case view::PrintableState_JOB_COMPLETED : - { - SfxBindings& rBind = mpViewShell->GetViewFrame()->GetBindings(); - rBind.Invalidate( SID_PRINTDOC ); - rBind.Invalidate( SID_PRINTDOCDIRECT ); - rBind.Invalidate( SID_SETUPPRINTER ); - bCopyJobSetup = ! m_bTempPrinter; - break; + vcl::Window* pWindow = mpViewShell->GetWindow(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::Ok, + aMsg)); + xBox->run(); } + [[fallthrough]]; + } + case view::PrintableState_JOB_ABORTED : + { + // printing not successful, reset DocInfo + uno::Reference<document::XDocumentProperties> xDocProps(mpObjectShell->getDocProperties()); + xDocProps->setPrintedBy(m_aLastPrintedBy); + xDocProps->setPrintDate(m_aLastPrinted); + break; + } - default: - break; + case view::PrintableState_JOB_SPOOLED : + case view::PrintableState_JOB_COMPLETED : + { + SfxBindings& rBind = mpViewShell->GetViewFrame()->GetBindings(); + rBind.Invalidate( SID_PRINTDOC ); + rBind.Invalidate( SID_PRINTDOCDIRECT ); + rBind.Invalidate( SID_SETUPPRINTER ); + bCopyJobSetup = ! m_bTempPrinter; + break; } - if( bCopyJobSetup && mpViewShell ) + default: + break; + } + + if( bCopyJobSetup && mpViewShell ) + { + // #i114306# + // Note: this possibly creates a printer that gets immediately replaced + // by a new one. The reason for this is that otherwise we would not get + // the printer's SfxItemSet here to copy. Awkward, but at the moment there is no + // other way here to get the item set. + SfxPrinter* pDocPrt = mpViewShell->GetPrinter(true); + if( pDocPrt ) { - // #i114306# - // Note: this possibly creates a printer that gets immediately replaced - // by a new one. The reason for this is that otherwise we would not get - // the printer's SfxItemSet here to copy. Awkward, but at the moment there is no - // other way here to get the item set. - SfxPrinter* pDocPrt = mpViewShell->GetPrinter(true); - if( pDocPrt ) + if( pDocPrt->GetName() == getPrinter()->GetName() ) + pDocPrt->SetJobSetup( getPrinter()->GetJobSetup() ); + else { - if( pDocPrt->GetName() == getPrinter()->GetName() ) - pDocPrt->SetJobSetup( getPrinter()->GetJobSetup() ); - else - { - VclPtr<SfxPrinter> pNewPrt = VclPtr<SfxPrinter>::Create( pDocPrt->GetOptions().Clone(), getPrinter()->GetName() ); - pNewPrt->SetJobSetup( getPrinter()->GetJobSetup() ); - mpViewShell->SetPrinter( pNewPrt, SfxPrinterChangeFlags::PRINTER | SfxPrinterChangeFlags::JOBSETUP ); - } + VclPtr<SfxPrinter> pNewPrt = VclPtr<SfxPrinter>::Create( pDocPrt->GetOptions().Clone(), getPrinter()->GetName() ); + pNewPrt->SetJobSetup( getPrinter()->GetJobSetup() ); + mpViewShell->SetPrinter( pNewPrt, SfxPrinterChangeFlags::PRINTER | SfxPrinterChangeFlags::JOBSETUP ); } } + } - if ( m_bNeedsChange ) - mpObjectShell->EnableSetModified( m_bOrigStatus ); + if ( m_bNeedsChange ) + mpObjectShell->EnableSetModified( m_bOrigStatus ); - if ( mpViewShell ) - { - mpViewShell->pImpl->m_xPrinterController.reset(); - } + if ( mpViewShell ) + { + mpViewShell->pImpl->m_xPrinterController.reset(); } } diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 246d5ea0c1ab..8471cdc845c8 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -157,18 +157,18 @@ SfxClipboardChangeListener::SfxClipboardChangeListener( SfxViewShell* pView, con void SfxClipboardChangeListener::ChangedContents() { const SolarMutexGuard aGuard; - if (m_pViewShell) - { - SfxBindings& rBind = m_pViewShell->GetViewFrame()->GetBindings(); - rBind.Invalidate(SID_PASTE); - rBind.Invalidate(SID_PASTE_SPECIAL); - rBind.Invalidate(SID_CLIPBOARD_FORMAT_ITEMS); + if (!m_pViewShell) + return; - if (comphelper::LibreOfficeKit::isActive()) - { - // In the future we might send the payload as well. - SfxLokHelper::notifyAllViews(LOK_CALLBACK_CLIPBOARD_CHANGED, ""); - } + SfxBindings& rBind = m_pViewShell->GetViewFrame()->GetBindings(); + rBind.Invalidate(SID_PASTE); + rBind.Invalidate(SID_PASTE_SPECIAL); + rBind.Invalidate(SID_CLIPBOARD_FORMAT_ITEMS); + + if (comphelper::LibreOfficeKit::isActive()) + { + // In the future we might send the payload as well. + SfxLokHelper::notifyAllViews(LOK_CALLBACK_CLIPBOARD_CHANGED, ""); } } @@ -1403,26 +1403,26 @@ void SfxViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint); - if ( pEventHint && pEventHint->GetEventId() == SfxEventHintId::LoadFinished ) + if ( !(pEventHint && pEventHint->GetEventId() == SfxEventHintId::LoadFinished) ) + return; + + if ( !GetController().is() ) + return; + + // avoid access to dangling ViewShells + SfxViewFrameArr_Impl &rFrames = SfxGetpApp()->GetViewFrames_Impl(); + for (SfxViewFrame* frame : rFrames) { - if ( GetController().is() ) + if ( frame == GetViewFrame() && &rBC == GetObjectShell() ) { - // avoid access to dangling ViewShells - SfxViewFrameArr_Impl &rFrames = SfxGetpApp()->GetViewFrames_Impl(); - for (SfxViewFrame* frame : rFrames) + SfxItemSet* pSet = GetObjectShell()->GetMedium()->GetItemSet(); + const SfxUnoAnyItem* pItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pSet, SID_VIEW_DATA, false); + if ( pItem ) { - if ( frame == GetViewFrame() && &rBC == GetObjectShell() ) - { - SfxItemSet* pSet = GetObjectShell()->GetMedium()->GetItemSet(); - const SfxUnoAnyItem* pItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pSet, SID_VIEW_DATA, false); - if ( pItem ) - { - pImpl->m_pController->restoreViewData( pItem->GetValue() ); - pSet->ClearItem( SID_VIEW_DATA ); - } - break; - } + pImpl->m_pController->restoreViewData( pItem->GetValue() ); + pSet->ClearItem( SID_VIEW_DATA ); } + break; } } } @@ -1652,21 +1652,21 @@ void SfxViewShell::CheckIPClient_Impl( ( pIPClient->GetObjectMiscStatus() & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE ) != 0; // this method is called when a client is created - if (!pIPClient->IsObjectInPlaceActive()) + if (pIPClient->IsObjectInPlaceActive()) + return; + + // object in client is currently not active + // check if the object wants to be activated always or when it becomes at least partially visible + // TODO/LATER: maybe we should use the scaled area instead of the ObjArea?! + if (bAlwaysActive || (bActiveWhenVisible && rVisArea.IsOver(pIPClient->GetObjArea()))) { - // object in client is currently not active - // check if the object wants to be activated always or when it becomes at least partially visible - // TODO/LATER: maybe we should use the scaled area instead of the ObjArea?! - if (bAlwaysActive || (bActiveWhenVisible && rVisArea.IsOver(pIPClient->GetObjArea()))) + try { - try - { - pIPClient->GetObject()->changeState( embed::EmbedStates::INPLACE_ACTIVE ); - } - catch (const uno::Exception& e) - { - SAL_WARN("sfx.view", "SfxViewShell::CheckIPClient_Impl: " << e); - } + pIPClient->GetObject()->changeState( embed::EmbedStates::INPLACE_ACTIVE ); + } + catch (const uno::Exception& e) + { + SAL_WARN("sfx.view", "SfxViewShell::CheckIPClient_Impl: " << e); } } } |