diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-29 16:13:56 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-30 08:27:52 +0200 |
commit | 5f646281f777019a4e91c467f1d6f8a7f2083ffd (patch) | |
tree | 742667b0a19517c75f1397df86ba45dd7e18b231 /sc | |
parent | a5be8e97b7699c7d12fa3ae5404af7b2eb50fafb (diff) |
loplugin:flatten in sc/ui
Change-Id: I4e12da123924b1036c1348ad1b04eef1826ae26a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99703
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
31 files changed, 2141 insertions, 2139 deletions
diff --git a/sc/source/ui/app/client.cxx b/sc/source/ui/app/client.cxx index b58efdf5218d..a121531c4782 100644 --- a/sc/source/ui/app/client.cxx +++ b/sc/source/ui/app/client.cxx @@ -96,42 +96,42 @@ void ScClient::RequestNewObjectArea( tools::Rectangle& aLogicRect ) sal_uInt16 nTab = pViewSh->GetViewData().GetTabNo(); SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(static_cast<sal_Int16>(nTab))); - if ( pPage && aLogicRect != aOldRect ) + if ( !(pPage && aLogicRect != aOldRect) ) + return; + + Point aPos; + Size aSize = pPage->GetSize(); + if ( aSize.Width() < 0 ) { - Point aPos; - Size aSize = pPage->GetSize(); - if ( aSize.Width() < 0 ) - { - aPos.setX( aSize.Width() + 1 ); // negative - aSize.setWidth( -aSize.Width() ); // positive - } - tools::Rectangle aPageRect( aPos, aSize ); + aPos.setX( aSize.Width() + 1 ); // negative + aSize.setWidth( -aSize.Width() ); // positive + } + tools::Rectangle aPageRect( aPos, aSize ); - if (aLogicRect.Right() > aPageRect.Right()) - { - long nDiff = aLogicRect.Right() - aPageRect.Right(); - aLogicRect.AdjustLeft( -nDiff ); - aLogicRect.AdjustRight( -nDiff ); - } - if (aLogicRect.Bottom() > aPageRect.Bottom()) - { - long nDiff = aLogicRect.Bottom() - aPageRect.Bottom(); - aLogicRect.AdjustTop( -nDiff ); - aLogicRect.AdjustBottom( -nDiff ); - } + if (aLogicRect.Right() > aPageRect.Right()) + { + long nDiff = aLogicRect.Right() - aPageRect.Right(); + aLogicRect.AdjustLeft( -nDiff ); + aLogicRect.AdjustRight( -nDiff ); + } + if (aLogicRect.Bottom() > aPageRect.Bottom()) + { + long nDiff = aLogicRect.Bottom() - aPageRect.Bottom(); + aLogicRect.AdjustTop( -nDiff ); + aLogicRect.AdjustBottom( -nDiff ); + } - if (aLogicRect.Left() < aPageRect.Left()) - { - long nDiff = aLogicRect.Left() - aPageRect.Left(); - aLogicRect.AdjustRight( -nDiff ); - aLogicRect.AdjustLeft( -nDiff ); - } - if (aLogicRect.Top() < aPageRect.Top()) - { - long nDiff = aLogicRect.Top() - aPageRect.Top(); - aLogicRect.AdjustBottom( -nDiff ); - aLogicRect.AdjustTop( -nDiff ); - } + if (aLogicRect.Left() < aPageRect.Left()) + { + long nDiff = aLogicRect.Left() - aPageRect.Left(); + aLogicRect.AdjustRight( -nDiff ); + aLogicRect.AdjustLeft( -nDiff ); + } + if (aLogicRect.Top() < aPageRect.Top()) + { + long nDiff = aLogicRect.Top() - aPageRect.Top(); + aLogicRect.AdjustBottom( -nDiff ); + aLogicRect.AdjustTop( -nDiff ); } } @@ -147,30 +147,30 @@ void ScClient::ObjectAreaChanged() // Take over position and size into document SdrOle2Obj* pDrawObj = GetDrawObj(); - if (pDrawObj) - { - tools::Rectangle aNewRectangle(GetScaledObjArea()); - - // #i118524# if sheared/rotated, center to non-rotated LogicRect - pDrawObj->setSuppressSetVisAreaSize(true); - - if(pDrawObj->GetGeoStat().nRotationAngle || pDrawObj->GetGeoStat().nShearAngle) - { - pDrawObj->SetLogicRect( aNewRectangle ); + if (!pDrawObj) + return; - const tools::Rectangle& rBoundRect = pDrawObj->GetCurrentBoundRect(); - const Point aDelta(aNewRectangle.Center() - rBoundRect.Center()); + tools::Rectangle aNewRectangle(GetScaledObjArea()); - aNewRectangle.Move(aDelta.X(), aDelta.Y()); - } + // #i118524# if sheared/rotated, center to non-rotated LogicRect + pDrawObj->setSuppressSetVisAreaSize(true); + if(pDrawObj->GetGeoStat().nRotationAngle || pDrawObj->GetGeoStat().nShearAngle) + { pDrawObj->SetLogicRect( aNewRectangle ); - pDrawObj->setSuppressSetVisAreaSize(false); - // set document modified (SdrModel::SetChanged is not used) - pViewSh->GetViewData().GetDocShell()->SetDrawModified(); - pViewSh->ScrollToObject(pDrawObj); + const tools::Rectangle& rBoundRect = pDrawObj->GetCurrentBoundRect(); + const Point aDelta(aNewRectangle.Center() - rBoundRect.Center()); + + aNewRectangle.Move(aDelta.X(), aDelta.Y()); } + + pDrawObj->SetLogicRect( aNewRectangle ); + pDrawObj->setSuppressSetVisAreaSize(false); + + // set document modified (SdrModel::SetChanged is not used) + pViewSh->GetViewData().GetDocShell()->SetDrawModified(); + pViewSh->ScrollToObject(pDrawObj); } void ScClient::ViewChanged() @@ -200,32 +200,32 @@ void ScClient::ViewChanged() // Take over position and size into document SdrOle2Obj* pDrawObj = GetDrawObj(); - if (pDrawObj) + if (!pDrawObj) + return; + + tools::Rectangle aLogicRect = pDrawObj->GetLogicRect(); + Fraction aFractX = GetScaleWidth() * aVisSize.Width(); + Fraction aFractY = GetScaleHeight() * aVisSize.Height(); + aVisSize = Size( static_cast<long>(aFractX), static_cast<long>(aFractY) ); // Scaled for Draw model + + // pClientData->SetObjArea before pDrawObj->SetLogicRect, so that we don't + // calculate wrong scalings: + //Rectangle aObjArea = aLogicRect; + //aObjArea.SetSize( aVisSize ); // Document size from the server + //SetObjArea( aObjArea ); + + SfxViewShell* pSfxViewSh = GetViewShell(); + ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( pSfxViewSh ); + if ( pViewSh ) { - tools::Rectangle aLogicRect = pDrawObj->GetLogicRect(); - Fraction aFractX = GetScaleWidth() * aVisSize.Width(); - Fraction aFractY = GetScaleHeight() * aVisSize.Height(); - aVisSize = Size( static_cast<long>(aFractX), static_cast<long>(aFractY) ); // Scaled for Draw model - - // pClientData->SetObjArea before pDrawObj->SetLogicRect, so that we don't - // calculate wrong scalings: - //Rectangle aObjArea = aLogicRect; - //aObjArea.SetSize( aVisSize ); // Document size from the server - //SetObjArea( aObjArea ); - - SfxViewShell* pSfxViewSh = GetViewShell(); - ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( pSfxViewSh ); - if ( pViewSh ) + vcl::Window* pWin = pViewSh->GetActiveWin(); + if ( pWin->LogicToPixel( aVisSize ) != pWin->LogicToPixel( aLogicRect.GetSize() ) ) { - vcl::Window* pWin = pViewSh->GetActiveWin(); - if ( pWin->LogicToPixel( aVisSize ) != pWin->LogicToPixel( aLogicRect.GetSize() ) ) - { - aLogicRect.SetSize( aVisSize ); - pDrawObj->SetLogicRect( aLogicRect ); + aLogicRect.SetSize( aVisSize ); + pDrawObj->SetLogicRect( aLogicRect ); - // set document modified (SdrModel::SetChanged is not used) - pViewSh->GetViewData().GetDocShell()->SetDrawModified(); - } + // set document modified (SdrModel::SetChanged is not used) + pViewSh->GetViewData().GetDocShell()->SetDrawModified(); } } } diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx index ac338fa2c115..dcb90a5e06ed 100644 --- a/sc/source/ui/app/drwtrans.cxx +++ b/sc/source/ui/app/drwtrans.cxx @@ -685,57 +685,57 @@ void ScDrawTransferObj::CreateOLEData() void ScDrawTransferObj::InitDocShell() { - if ( !m_aDocShellRef.is() ) - { - ScDocShell* pDocSh = new ScDocShell; - m_aDocShellRef = pDocSh; // ref must be there before InitNew + if ( m_aDocShellRef.is() ) + return; - pDocSh->DoInitNew(); + ScDocShell* pDocSh = new ScDocShell; + m_aDocShellRef = pDocSh; // ref must be there before InitNew - ScDocument& rDestDoc = pDocSh->GetDocument(); - rDestDoc.InitDrawLayer( pDocSh ); + pDocSh->DoInitNew(); - SdrModel* pDestModel = rDestDoc.GetDrawLayer(); - // #i71538# use complete SdrViews - // SdrExchangeView aDestView( pDestModel ); - SdrView aDestView(*pDestModel); - aDestView.ShowSdrPage(aDestView.GetModel()->GetPage(0)); - aDestView.Paste( - *m_pModel, - Point(m_aSrcSize.Width()/2, m_aSrcSize.Height()/2), - nullptr, SdrInsertFlags::NONE); + ScDocument& rDestDoc = pDocSh->GetDocument(); + rDestDoc.InitDrawLayer( pDocSh ); - // put objects to right layer (see ScViewFunc::PasteDataFormat for SotClipboardFormatId::DRAWING) + SdrModel* pDestModel = rDestDoc.GetDrawLayer(); + // #i71538# use complete SdrViews + // SdrExchangeView aDestView( pDestModel ); + SdrView aDestView(*pDestModel); + aDestView.ShowSdrPage(aDestView.GetModel()->GetPage(0)); + aDestView.Paste( + *m_pModel, + Point(m_aSrcSize.Width()/2, m_aSrcSize.Height()/2), + nullptr, SdrInsertFlags::NONE); - SdrPage* pPage = pDestModel->GetPage(0); - if (pPage) + // put objects to right layer (see ScViewFunc::PasteDataFormat for SotClipboardFormatId::DRAWING) + + SdrPage* pPage = pDestModel->GetPage(0); + if (pPage) + { + SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups ); + SdrObject* pObject = aIter.Next(); + while (pObject) { - SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups ); - SdrObject* pObject = aIter.Next(); - while (pObject) - { - if ( dynamic_cast<const SdrUnoObj*>( pObject) != nullptr ) - pObject->NbcSetLayer(SC_LAYER_CONTROLS); - else - pObject->NbcSetLayer(SC_LAYER_FRONT); - pObject = aIter.Next(); - } + if ( dynamic_cast<const SdrUnoObj*>( pObject) != nullptr ) + pObject->NbcSetLayer(SC_LAYER_CONTROLS); + else + pObject->NbcSetLayer(SC_LAYER_FRONT); + pObject = aIter.Next(); } + } - tools::Rectangle aDestArea( Point(), m_aSrcSize ); - pDocSh->SetVisArea( aDestArea ); + tools::Rectangle aDestArea( Point(), m_aSrcSize ); + pDocSh->SetVisArea( aDestArea ); - ScViewOptions aViewOpt( rDestDoc.GetViewOptions() ); - aViewOpt.SetOption( VOPT_GRID, false ); - rDestDoc.SetViewOptions( aViewOpt ); + ScViewOptions aViewOpt( rDestDoc.GetViewOptions() ); + aViewOpt.SetOption( VOPT_GRID, false ); + rDestDoc.SetViewOptions( aViewOpt ); - ScViewData aViewData( pDocSh, nullptr ); - aViewData.SetTabNo( 0 ); - aViewData.SetScreen( aDestArea ); - aViewData.SetCurX( 0 ); - aViewData.SetCurY( 0 ); - pDocSh->UpdateOle(&aViewData, true); - } + ScViewData aViewData( pDocSh, nullptr ); + aViewData.SetTabNo( 0 ); + aViewData.SetScreen( aDestArea ); + aViewData.SetCurX( 0 ); + aViewData.SetCurY( 0 ); + pDocSh->UpdateOle(&aViewData, true); } namespace diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index a62887cbbb50..b130cb87a0b4 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -564,24 +564,24 @@ void ScInputHandler::SetDocumentDisposing( bool b ) static void lcl_Replace( EditView* pView, const OUString& rNewStr, const ESelection& rOldSel ) { - if ( pView ) - { - ESelection aOldSel = pView->GetSelection(); - if (aOldSel.HasRange()) - pView->SetSelection( ESelection( aOldSel.nEndPara, aOldSel.nEndPos, - aOldSel.nEndPara, aOldSel.nEndPos ) ); + if ( !pView ) + return; - EditEngine* pEngine = pView->GetEditEngine(); - pEngine->QuickInsertText( rNewStr, rOldSel ); + ESelection aOldSel = pView->GetSelection(); + if (aOldSel.HasRange()) + pView->SetSelection( ESelection( aOldSel.nEndPara, aOldSel.nEndPos, + aOldSel.nEndPara, aOldSel.nEndPos ) ); - // Dummy InsertText for Update and Paint - // To do that we need to cancel the selection from above (before QuickInsertText) - pView->InsertText( EMPTY_OUSTRING ); + EditEngine* pEngine = pView->GetEditEngine(); + pEngine->QuickInsertText( rNewStr, rOldSel ); - sal_Int32 nLen = pEngine->GetTextLen(0); - ESelection aSel( 0, nLen, 0, nLen ); - pView->SetSelection( aSel ); // Set cursor to the end - } + // Dummy InsertText for Update and Paint + // To do that we need to cancel the selection from above (before QuickInsertText) + pView->InsertText( EMPTY_OUSTRING ); + + sal_Int32 nLen = pEngine->GetTextLen(0); + ESelection aSel( 0, nLen, 0, nLen ); + pView->SetSelection( aSel ); // Set cursor to the end } void ScInputHandler::UpdateRange( sal_uInt16 nIndex, const ScRange& rNew ) @@ -867,25 +867,25 @@ void ScInputHandler::UpdateRefDevice() void ScInputHandler::ImplCreateEditEngine() { - if ( !mpEditEngine ) + if ( mpEditEngine ) + return; + + if ( pActiveViewSh ) { - if ( pActiveViewSh ) - { - ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocShell()->GetDocument(); - mpEditEngine = std::make_unique<ScFieldEditEngine>(&rDoc, rDoc.GetEnginePool(), rDoc.GetEditPool()); - } - else - mpEditEngine = std::make_unique<ScFieldEditEngine>(nullptr, EditEngine::CreatePool(), nullptr, true); + ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocShell()->GetDocument(); + mpEditEngine = std::make_unique<ScFieldEditEngine>(&rDoc, rDoc.GetEnginePool(), rDoc.GetEditPool()); + } + else + mpEditEngine = std::make_unique<ScFieldEditEngine>(nullptr, EditEngine::CreatePool(), nullptr, true); - mpEditEngine->SetWordDelimiters( ScEditUtil::ModifyDelimiters( mpEditEngine->GetWordDelimiters() ) ); - UpdateRefDevice(); // also sets MapMode - mpEditEngine->SetPaperSize( Size( 1000000, 1000000 ) ); - pEditDefaults.reset( new SfxItemSet( mpEditEngine->GetEmptyItemSet() ) ); + mpEditEngine->SetWordDelimiters( ScEditUtil::ModifyDelimiters( mpEditEngine->GetWordDelimiters() ) ); + UpdateRefDevice(); // also sets MapMode + mpEditEngine->SetPaperSize( Size( 1000000, 1000000 ) ); + pEditDefaults.reset( new SfxItemSet( mpEditEngine->GetEmptyItemSet() ) ); - mpEditEngine->SetControlWord( mpEditEngine->GetControlWord() | EEControlBits::AUTOCORRECT ); - mpEditEngine->SetReplaceLeadingSingleQuotationMark( false ); - mpEditEngine->SetModifyHdl( LINK( this, ScInputHandler, ModifyHdl ) ); - } + mpEditEngine->SetControlWord( mpEditEngine->GetControlWord() | EEControlBits::AUTOCORRECT ); + mpEditEngine->SetReplaceLeadingSingleQuotationMark( false ); + mpEditEngine->SetModifyHdl( LINK( this, ScInputHandler, ModifyHdl ) ); } void ScInputHandler::UpdateAutoCorrFlag() @@ -906,54 +906,54 @@ void ScInputHandler::UpdateAutoCorrFlag() void ScInputHandler::UpdateSpellSettings( bool bFromStartTab ) { - if ( pActiveViewSh ) - { - ScViewData& rViewData = pActiveViewSh->GetViewData(); - bool bOnlineSpell = rViewData.GetDocument()->GetDocOptions().IsAutoSpell(); + if ( !pActiveViewSh ) + return; - // SetDefaultLanguage is independent of the language attributes, - // ScGlobal::GetEditDefaultLanguage is always used. - // It must be set every time in case the office language was changed. + ScViewData& rViewData = pActiveViewSh->GetViewData(); + bool bOnlineSpell = rViewData.GetDocument()->GetDocOptions().IsAutoSpell(); - mpEditEngine->SetDefaultLanguage( ScGlobal::GetEditDefaultLanguage() ); + // SetDefaultLanguage is independent of the language attributes, + // ScGlobal::GetEditDefaultLanguage is always used. + // It must be set every time in case the office language was changed. - // if called for changed options, update flags only if already editing - // if called from StartTable, always update flags + mpEditEngine->SetDefaultLanguage( ScGlobal::GetEditDefaultLanguage() ); - if ( bFromStartTab || eMode != SC_INPUT_NONE ) - { - EEControlBits nCntrl = mpEditEngine->GetControlWord(); - EEControlBits nOld = nCntrl; - if( bOnlineSpell ) - nCntrl |= EEControlBits::ONLINESPELLING; - else - nCntrl &= ~EEControlBits::ONLINESPELLING; - // No AutoCorrect for Symbol Font (EditEngine does no evaluate Default) - if ( pLastPattern && pLastPattern->IsSymbolFont() ) - nCntrl &= ~EEControlBits::AUTOCORRECT; - else - nCntrl |= EEControlBits::AUTOCORRECT; - if ( nCntrl != nOld ) - mpEditEngine->SetControlWord(nCntrl); - - ScDocument* pDoc = rViewData.GetDocument(); - pDoc->ApplyAsianEditSettings( *mpEditEngine ); - mpEditEngine->SetDefaultHorizontalTextDirection( - pDoc->GetEditTextDirection( rViewData.GetTabNo() ) ); - mpEditEngine->SetFirstWordCapitalization( false ); - } + // if called for changed options, update flags only if already editing + // if called from StartTable, always update flags - // Language is set separately, so the speller is needed only if online spelling is active - if ( bOnlineSpell ) { - css::uno::Reference<css::linguistic2::XSpellChecker1> xXSpellChecker1( LinguMgr::GetSpellChecker() ); - mpEditEngine->SetSpeller( xXSpellChecker1 ); - } + if ( bFromStartTab || eMode != SC_INPUT_NONE ) + { + EEControlBits nCntrl = mpEditEngine->GetControlWord(); + EEControlBits nOld = nCntrl; + if( bOnlineSpell ) + nCntrl |= EEControlBits::ONLINESPELLING; + else + nCntrl &= ~EEControlBits::ONLINESPELLING; + // No AutoCorrect for Symbol Font (EditEngine does no evaluate Default) + if ( pLastPattern && pLastPattern->IsSymbolFont() ) + nCntrl &= ~EEControlBits::AUTOCORRECT; + else + nCntrl |= EEControlBits::AUTOCORRECT; + if ( nCntrl != nOld ) + mpEditEngine->SetControlWord(nCntrl); - bool bHyphen = pLastPattern && pLastPattern->GetItem(ATTR_HYPHENATE).GetValue(); - if ( bHyphen ) { - css::uno::Reference<css::linguistic2::XHyphenator> xXHyphenator( LinguMgr::GetHyphenator() ); - mpEditEngine->SetHyphenator( xXHyphenator ); - } + ScDocument* pDoc = rViewData.GetDocument(); + pDoc->ApplyAsianEditSettings( *mpEditEngine ); + mpEditEngine->SetDefaultHorizontalTextDirection( + pDoc->GetEditTextDirection( rViewData.GetTabNo() ) ); + mpEditEngine->SetFirstWordCapitalization( false ); + } + + // Language is set separately, so the speller is needed only if online spelling is active + if ( bOnlineSpell ) { + css::uno::Reference<css::linguistic2::XSpellChecker1> xXSpellChecker1( LinguMgr::GetSpellChecker() ); + mpEditEngine->SetSpeller( xXSpellChecker1 ); + } + + bool bHyphen = pLastPattern && pLastPattern->GetItem(ATTR_HYPHENATE).GetValue(); + if ( bHyphen ) { + css::uno::Reference<css::linguistic2::XHyphenator> xXHyphenator( LinguMgr::GetHyphenator() ); + mpEditEngine->SetHyphenator( xXHyphenator ); } } @@ -962,49 +962,49 @@ void ScInputHandler::UpdateSpellSettings( bool bFromStartTab ) // The other types are defined in ScDocument::GetFormulaEntries void ScInputHandler::GetFormulaData() { - if ( pActiveViewSh ) - { - ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocShell()->GetDocument(); + if ( !pActiveViewSh ) + return; - if ( pFormulaData ) - pFormulaData->clear(); - else - { - pFormulaData.reset( new ScTypedCaseStrSet ); - } + ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocShell()->GetDocument(); - if( pFormulaDataPara ) - pFormulaDataPara->clear(); - else - pFormulaDataPara.reset( new ScTypedCaseStrSet ); + if ( pFormulaData ) + pFormulaData->clear(); + else + { + pFormulaData.reset( new ScTypedCaseStrSet ); + } + + if( pFormulaDataPara ) + pFormulaDataPara->clear(); + else + pFormulaDataPara.reset( new ScTypedCaseStrSet ); - const OUString aParenthesesReplacement( cParenthesesReplacement); - const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList(); - sal_uInt32 nListCount = pFuncList->GetCount(); - for(sal_uInt32 i=0;i<nListCount;i++) + const OUString aParenthesesReplacement( cParenthesesReplacement); + const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList(); + sal_uInt32 nListCount = pFuncList->GetCount(); + for(sal_uInt32 i=0;i<nListCount;i++) + { + const ScFuncDesc* pDesc = pFuncList->GetFunction( i ); + if ( pDesc->mxFuncName ) { - const ScFuncDesc* pDesc = pFuncList->GetFunction( i ); - if ( pDesc->mxFuncName ) + const sal_Unicode* pName = pDesc->mxFuncName->getStr(); + const sal_Int32 nLen = pDesc->mxFuncName->getLength(); + // fdo#75264 fill maFormulaChar with all characters used in formula names + for ( sal_Int32 j = 0; j < nLen; j++ ) { - const sal_Unicode* pName = pDesc->mxFuncName->getStr(); - const sal_Int32 nLen = pDesc->mxFuncName->getLength(); - // fdo#75264 fill maFormulaChar with all characters used in formula names - for ( sal_Int32 j = 0; j < nLen; j++ ) - { - sal_Unicode c = pName[ j ]; - maFormulaChar.insert( c ); - } - OUString aFuncName = *pDesc->mxFuncName + aParenthesesReplacement; - pFormulaData->insert(ScTypedStrData(aFuncName, 0.0, ScTypedStrData::Standard)); - pDesc->initArgumentInfo(); - OUString aEntry = pDesc->getSignature(); - pFormulaDataPara->insert(ScTypedStrData(aEntry, 0.0, ScTypedStrData::Standard)); + sal_Unicode c = pName[ j ]; + maFormulaChar.insert( c ); } + OUString aFuncName = *pDesc->mxFuncName + aParenthesesReplacement; + pFormulaData->insert(ScTypedStrData(aFuncName, 0.0, ScTypedStrData::Standard)); + pDesc->initArgumentInfo(); + OUString aEntry = pDesc->getSignature(); + pFormulaDataPara->insert(ScTypedStrData(aEntry, 0.0, ScTypedStrData::Standard)); } - miAutoPosFormula = pFormulaData->end(); - rDoc.GetFormulaEntries( *pFormulaData ); - rDoc.GetFormulaEntries( *pFormulaDataPara ); } + miAutoPosFormula = pFormulaData->end(); + rDoc.GetFormulaEntries( *pFormulaData ); + rDoc.GetFormulaEntries( *pFormulaDataPara ); } IMPL_LINK( ScInputHandler, ShowHideTipVisibleParentListener, VclWindowEvent&, rEvent, void ) @@ -1220,21 +1220,21 @@ void ScInputHandler::ShowTipCursor() HideTipBelow(); EditView* pActiveView = pTopView ? pTopView : pTableView; - if ( bFormulaMode && pActiveView && pFormulaDataPara && mpEditEngine->GetParagraphCount() == 1 ) - { - OUString aParagraph = mpEditEngine->GetText( 0 ); - ESelection aSel = pActiveView->GetSelection(); - aSel.Adjust(); + if ( !(bFormulaMode && pActiveView && pFormulaDataPara && mpEditEngine->GetParagraphCount() == 1) ) + return; + + OUString aParagraph = mpEditEngine->GetText( 0 ); + ESelection aSel = pActiveView->GetSelection(); + aSel.Adjust(); - if ( aParagraph.getLength() < aSel.nEndPos ) - return; + if ( aParagraph.getLength() < aSel.nEndPos ) + return; - if ( aSel.nEndPos > 0 ) - { - OUString aSelText( aParagraph.copy( 0, aSel.nEndPos )); + if ( aSel.nEndPos > 0 ) + { + OUString aSelText( aParagraph.copy( 0, aSel.nEndPos )); - ShowArgumentsTip( aSelText ); - } + ShowArgumentsTip( aSelText ); } } @@ -1246,20 +1246,20 @@ void ScInputHandler::ShowTip( const OUString& rText ) HideTipBelow(); EditView* pActiveView = pTopView ? pTopView : pTableView; - if (pActiveView) - { - Point aPos; - pTipVisibleParent = pActiveView->GetWindow(); - vcl::Cursor* pCur = pActiveView->GetCursor(); - if (pCur) - aPos = pTipVisibleParent->LogicToPixel( pCur->GetPos() ); - aPos = pTipVisibleParent->OutputToScreenPixel( aPos ); - tools::Rectangle aRect( aPos, aPos ); + if (!pActiveView) + return; - QuickHelpFlags const nAlign = QuickHelpFlags::Left|QuickHelpFlags::Bottom; - nTipVisible = Help::ShowPopover(pTipVisibleParent, aRect, rText, nAlign); - pTipVisibleParent->AddEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleParentListener ) ); - } + Point aPos; + pTipVisibleParent = pActiveView->GetWindow(); + vcl::Cursor* pCur = pActiveView->GetCursor(); + if (pCur) + aPos = pTipVisibleParent->LogicToPixel( pCur->GetPos() ); + aPos = pTipVisibleParent->OutputToScreenPixel( aPos ); + tools::Rectangle aRect( aPos, aPos ); + + QuickHelpFlags const nAlign = QuickHelpFlags::Left|QuickHelpFlags::Bottom; + nTipVisible = Help::ShowPopover(pTipVisibleParent, aRect, rText, nAlign); + pTipVisibleParent->AddEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleParentListener ) ); } void ScInputHandler::ShowTipBelow( const OUString& rText ) @@ -1267,23 +1267,23 @@ void ScInputHandler::ShowTipBelow( const OUString& rText ) HideTipBelow(); EditView* pActiveView = pTopView ? pTopView : pTableView; - if ( pActiveView ) + if ( !pActiveView ) + return; + + Point aPos; + pTipVisibleSecParent = pActiveView->GetWindow(); + vcl::Cursor* pCur = pActiveView->GetCursor(); + if ( pCur ) { - Point aPos; - pTipVisibleSecParent = pActiveView->GetWindow(); - vcl::Cursor* pCur = pActiveView->GetCursor(); - if ( pCur ) - { - Point aLogicPos = pCur->GetPos(); - aLogicPos.AdjustY(pCur->GetHeight() ); - aPos = pTipVisibleSecParent->LogicToPixel( aLogicPos ); - } - aPos = pTipVisibleSecParent->OutputToScreenPixel( aPos ); - tools::Rectangle aRect( aPos, aPos ); - QuickHelpFlags const nAlign = QuickHelpFlags::Left | QuickHelpFlags::Top | QuickHelpFlags::NoEvadePointer; - nTipVisibleSec = Help::ShowPopover(pTipVisibleSecParent, aRect, rText, nAlign); - pTipVisibleSecParent->AddEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleSecParentListener ) ); + Point aLogicPos = pCur->GetPos(); + aLogicPos.AdjustY(pCur->GetHeight() ); + aPos = pTipVisibleSecParent->LogicToPixel( aLogicPos ); } + aPos = pTipVisibleSecParent->OutputToScreenPixel( aPos ); + tools::Rectangle aRect( aPos, aPos ); + QuickHelpFlags const nAlign = QuickHelpFlags::Left | QuickHelpFlags::Top | QuickHelpFlags::NoEvadePointer; + nTipVisibleSec = Help::ShowPopover(pTipVisibleSecParent, aRect, rText, nAlign); + pTipVisibleSecParent->AddEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleSecParentListener ) ); } bool ScInputHandler::GetFuncName( OUString& aStart, OUString& aResult ) @@ -1454,68 +1454,68 @@ void ScInputHandler::UseFormulaData() EditView* pActiveView = pTopView ? pTopView : pTableView; // Formulas may only have 1 paragraph - if ( pActiveView && pFormulaData && mpEditEngine->GetParagraphCount() == 1 ) - { - OUString aParagraph = mpEditEngine->GetText( 0 ); - ESelection aSel = pActiveView->GetSelection(); - aSel.Adjust(); + if ( !(pActiveView && pFormulaData && mpEditEngine->GetParagraphCount() == 1) ) + return; - // Due to differences between table and input cell (e.g clipboard with line breaks), - // the selection may not be in line with the EditEngine anymore. - // Just return without any indication as to why. - if ( aSel.nEndPos > aParagraph.getLength() ) - return; - - if ( aParagraph.getLength() > aSel.nEndPos && - ( ScGlobal::getCharClassPtr()->isLetterNumeric( aParagraph, aSel.nEndPos ) || - aParagraph[ aSel.nEndPos ] == '_' || - aParagraph[ aSel.nEndPos ] == '.' || - aParagraph[ aSel.nEndPos ] == '$' ) ) - return; - - // Is the cursor at the end of a word? - if ( aSel.nEndPos > 0 ) - { - OUString aSelText( aParagraph.copy( 0, aSel.nEndPos )); + OUString aParagraph = mpEditEngine->GetText( 0 ); + ESelection aSel = pActiveView->GetSelection(); + aSel.Adjust(); + + // Due to differences between table and input cell (e.g clipboard with line breaks), + // the selection may not be in line with the EditEngine anymore. + // Just return without any indication as to why. + if ( aSel.nEndPos > aParagraph.getLength() ) + return; + + if ( aParagraph.getLength() > aSel.nEndPos && + ( ScGlobal::getCharClassPtr()->isLetterNumeric( aParagraph, aSel.nEndPos ) || + aParagraph[ aSel.nEndPos ] == '_' || + aParagraph[ aSel.nEndPos ] == '.' || + aParagraph[ aSel.nEndPos ] == '$' ) ) + return; - OUString aText; - if ( GetFuncName( aSelText, aText ) ) + // Is the cursor at the end of a word? + if ( aSel.nEndPos <= 0 ) + return; + + OUString aSelText( aParagraph.copy( 0, aSel.nEndPos )); + + OUString aText; + if ( GetFuncName( aSelText, aText ) ) + { + // function name is incomplete: + // show matching functions name as tip above cell + ::std::vector<OUString> aNewVec; + miAutoPosFormula = pFormulaData->end(); + miAutoPosFormula = findTextAll(*pFormulaData, miAutoPosFormula, aText, aNewVec, false); + if (miAutoPosFormula != pFormulaData->end()) + { + // check if partial function name is not between quotes + sal_Unicode cBetweenQuotes = 0; + for ( int n = 0; n < aSelText.getLength(); n++ ) { - // function name is incomplete: - // show matching functions name as tip above cell - ::std::vector<OUString> aNewVec; - miAutoPosFormula = pFormulaData->end(); - miAutoPosFormula = findTextAll(*pFormulaData, miAutoPosFormula, aText, aNewVec, false); - if (miAutoPosFormula != pFormulaData->end()) + if (cBetweenQuotes) { - // check if partial function name is not between quotes - sal_Unicode cBetweenQuotes = 0; - for ( int n = 0; n < aSelText.getLength(); n++ ) - { - if (cBetweenQuotes) - { - if (aSelText[n] == cBetweenQuotes) - cBetweenQuotes = 0; - } - else if ( aSelText[ n ] == '"' ) - cBetweenQuotes = '"'; - else if ( aSelText[ n ] == '\'' ) - cBetweenQuotes = '\''; - } - if ( cBetweenQuotes ) - return; // we're between quotes - - ShowFuncList(aNewVec); - aAutoSearch = aText; + if (aSelText[n] == cBetweenQuotes) + cBetweenQuotes = 0; } - return; + else if ( aSelText[ n ] == '"' ) + cBetweenQuotes = '"'; + else if ( aSelText[ n ] == '\'' ) + cBetweenQuotes = '\''; } + if ( cBetweenQuotes ) + return; // we're between quotes - // function name is complete: - // show tip below the cell with function name and arguments of function - ShowArgumentsTip( aSelText ); + ShowFuncList(aNewVec); + aAutoSearch = aText; } + return; } + + // function name is complete: + // show tip below the cell with function name and arguments of function + ShowArgumentsTip( aSelText ); } void ScInputHandler::NextFormulaEntry( bool bBack ) @@ -1541,95 +1541,95 @@ namespace { void completeFunction( EditView* pView, const OUString& rInsert, bool& rParInserted ) { - if (pView) + if (!pView) + return; + + ESelection aSel = pView->GetSelection(); + + bool bNoInitialLetter = false; + OUString aOld = pView->GetEditEngine()->GetText(0); + // in case we want just insert a function and not completing + if ( comphelper::LibreOfficeKit::isActive() ) { - ESelection aSel = pView->GetSelection(); + ESelection aSelRange = aSel; + --aSelRange.nStartPos; + --aSelRange.nEndPos; + pView->SetSelection(aSelRange); + pView->SelectCurrentWord(); - bool bNoInitialLetter = false; - OUString aOld = pView->GetEditEngine()->GetText(0); - // in case we want just insert a function and not completing - if ( comphelper::LibreOfficeKit::isActive() ) + if ( aOld == "=" ) { - ESelection aSelRange = aSel; - --aSelRange.nStartPos; - --aSelRange.nEndPos; + bNoInitialLetter = true; + aSelRange.nStartPos = 1; + aSelRange.nEndPos = 1; pView->SetSelection(aSelRange); - pView->SelectCurrentWord(); - - if ( aOld == "=" ) - { - bNoInitialLetter = true; - aSelRange.nStartPos = 1; - aSelRange.nEndPos = 1; - pView->SetSelection(aSelRange); - } - else if ( pView->GetSelected().startsWith("()") ) - { - bNoInitialLetter = true; - ++aSelRange.nStartPos; - ++aSelRange.nEndPos; - pView->SetSelection(aSelRange); - } } - - if(!bNoInitialLetter) + else if ( pView->GetSelected().startsWith("()") ) { - const sal_Int32 nMinLen = std::max(aSel.nEndPos - aSel.nStartPos, sal_Int32(1)); - // Since transliteration service is used to test for match, the replaced string could be - // longer than rInsert, so in order to find longest match before the cursor, test whole - // string from start to current cursor position (don't limit to length of rInsert) - // Disclaimer: I really don't know if a match longer than rInsert is actually possible, - // so the above is based on assumptions how "transliteration" might possibly work. If - // it's in fact impossible, an optimization would be useful to limit aSel.nStartPos to - // std::max(sal_Int32(0), aSel.nEndPos - rInsert.getLength()). - aSel.nStartPos = 0; - pView->SetSelection(aSel); - const OUString aAll = pView->GetSelected(); - OUString aMatch; - for (sal_Int32 n = aAll.getLength(); n >= nMinLen && aMatch.isEmpty(); --n) - { - const OUString aTest = aAll.copy(aAll.getLength() - n); // n trailing chars - if (ScGlobal::GetpTransliteration()->isMatch(aTest, rInsert)) - aMatch = aTest; // Found => break the loop - } - - aSel.nStartPos = aSel.nEndPos - aMatch.getLength(); - pView->SetSelection(aSel); + bNoInitialLetter = true; + ++aSelRange.nStartPos; + ++aSelRange.nEndPos; + pView->SetSelection(aSelRange); } + } - OUString aInsStr = rInsert; - sal_Int32 nInsLen = aInsStr.getLength(); - bool bDoParen = ( nInsLen > 1 && aInsStr[nInsLen-2] == '(' - && aInsStr[nInsLen-1] == ')' ); - if ( bDoParen ) + if(!bNoInitialLetter) + { + const sal_Int32 nMinLen = std::max(aSel.nEndPos - aSel.nStartPos, sal_Int32(1)); + // Since transliteration service is used to test for match, the replaced string could be + // longer than rInsert, so in order to find longest match before the cursor, test whole + // string from start to current cursor position (don't limit to length of rInsert) + // Disclaimer: I really don't know if a match longer than rInsert is actually possible, + // so the above is based on assumptions how "transliteration" might possibly work. If + // it's in fact impossible, an optimization would be useful to limit aSel.nStartPos to + // std::max(sal_Int32(0), aSel.nEndPos - rInsert.getLength()). + aSel.nStartPos = 0; + pView->SetSelection(aSel); + const OUString aAll = pView->GetSelected(); + OUString aMatch; + for (sal_Int32 n = aAll.getLength(); n >= nMinLen && aMatch.isEmpty(); --n) { - // Do not insert parentheses after function names if there already are some - // (e.g. if the function name was edited). - ESelection aWordSel = pView->GetSelection(); + const OUString aTest = aAll.copy(aAll.getLength() - n); // n trailing chars + if (ScGlobal::GetpTransliteration()->isMatch(aTest, rInsert)) + aMatch = aTest; // Found => break the loop + } - // aWordSel.EndPos points one behind string if word at end - if (aWordSel.nEndPos < aOld.getLength()) + aSel.nStartPos = aSel.nEndPos - aMatch.getLength(); + pView->SetSelection(aSel); + } + + OUString aInsStr = rInsert; + sal_Int32 nInsLen = aInsStr.getLength(); + bool bDoParen = ( nInsLen > 1 && aInsStr[nInsLen-2] == '(' + && aInsStr[nInsLen-1] == ')' ); + if ( bDoParen ) + { + // Do not insert parentheses after function names if there already are some + // (e.g. if the function name was edited). + ESelection aWordSel = pView->GetSelection(); + + // aWordSel.EndPos points one behind string if word at end + if (aWordSel.nEndPos < aOld.getLength()) + { + sal_Unicode cNext = aOld[aWordSel.nEndPos]; + if ( cNext == '(' ) { - sal_Unicode cNext = aOld[aWordSel.nEndPos]; - if ( cNext == '(' ) - { - bDoParen = false; - aInsStr = aInsStr.copy( 0, nInsLen - 2 ); // Skip parentheses - } + bDoParen = false; + aInsStr = aInsStr.copy( 0, nInsLen - 2 ); // Skip parentheses } } + } - pView->InsertText( aInsStr ); + pView->InsertText( aInsStr ); - if ( bDoParen ) // Put cursor between parentheses - { - aSel = pView->GetSelection(); - --aSel.nStartPos; - --aSel.nEndPos; - pView->SetSelection(aSel); + if ( bDoParen ) // Put cursor between parentheses + { + aSel = pView->GetSelection(); + --aSel.nStartPos; + --aSel.nEndPos; + pView->SetSelection(aSel); - rParInserted = true; - } + rParInserted = true; } } @@ -1664,37 +1664,37 @@ void ScInputHandler::PasteFunctionData() void ScInputHandler::LOKPasteFunctionData(const OUString& rFunctionName) { - if (pActiveViewSh && (pTopView || pTableView)) + if (!(pActiveViewSh && (pTopView || pTableView))) + return; + + bool bEdit = false; + OUString aFormula; + EditView* pEditView = pTopView ? pTopView : pTableView; + const EditEngine* pEditEngine = pEditView->GetEditEngine(); + if (pEditEngine) { - bool bEdit = false; - OUString aFormula; - EditView* pEditView = pTopView ? pTopView : pTableView; - const EditEngine* pEditEngine = pEditView->GetEditEngine(); - if (pEditEngine) - { - aFormula = pEditEngine->GetText(0); - bEdit = aFormula.getLength() > 1 && (aFormula[0] == '=' || aFormula[0] == '+' || aFormula[0] == '-'); - } + aFormula = pEditEngine->GetText(0); + bEdit = aFormula.getLength() > 1 && (aFormula[0] == '=' || aFormula[0] == '+' || aFormula[0] == '-'); + } - if ( !bEdit ) - { - OUString aNewFormula('='); - if ( aFormula.startsWith("=") ) - aNewFormula = aFormula; + if ( !bEdit ) + { + OUString aNewFormula('='); + if ( aFormula.startsWith("=") ) + aNewFormula = aFormula; - InputReplaceSelection( aNewFormula ); - } + InputReplaceSelection( aNewFormula ); + } - if (pFormulaData) - { - OUString aNew; - ScTypedCaseStrSet::const_iterator aPos = findText(*pFormulaData, pFormulaData->begin(), rFunctionName, aNew, /* backward = */false); + if (pFormulaData) + { + OUString aNew; + ScTypedCaseStrSet::const_iterator aPos = findText(*pFormulaData, pFormulaData->begin(), rFunctionName, aNew, /* backward = */false); - if (aPos != pFormulaData->end()) - { - miAutoPosFormula = aPos; - PasteFunctionData(); - } + if (aPos != pFormulaData->end()) + { + miAutoPosFormula = aPos; + PasteFunctionData(); } } } @@ -1900,92 +1900,92 @@ void ScInputHandler::SkipClosingPar() void ScInputHandler::GetColData() { - if ( pActiveViewSh ) - { - ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocShell()->GetDocument(); + if ( !pActiveViewSh ) + return; - if ( pColumnData ) - pColumnData->clear(); - else - pColumnData.reset( new ScTypedCaseStrSet ); + ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocShell()->GetDocument(); - std::vector<ScTypedStrData> aEntries; - rDoc.GetDataEntries( - aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aEntries, true); - if (!aEntries.empty()) - pColumnData->insert(aEntries.begin(), aEntries.end()); + if ( pColumnData ) + pColumnData->clear(); + else + pColumnData.reset( new ScTypedCaseStrSet ); - miAutoPosColumn = pColumnData->end(); - } + std::vector<ScTypedStrData> aEntries; + rDoc.GetDataEntries( + aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aEntries, true); + if (!aEntries.empty()) + pColumnData->insert(aEntries.begin(), aEntries.end()); + + miAutoPosColumn = pColumnData->end(); } void ScInputHandler::UseColData() // When typing { EditView* pActiveView = pTopView ? pTopView : pTableView; - if ( pActiveView && pColumnData ) - { - // Only change when cursor is at the end - ESelection aSel = pActiveView->GetSelection(); - aSel.Adjust(); + if ( !(pActiveView && pColumnData) ) + return; - sal_Int32 nParCnt = mpEditEngine->GetParagraphCount(); - if ( aSel.nEndPara+1 == nParCnt ) - { - sal_Int32 nParLen = mpEditEngine->GetTextLen( aSel.nEndPara ); - if ( aSel.nEndPos == nParLen ) - { - OUString aText = GetEditText(mpEditEngine.get()); - if (!aText.isEmpty()) - { - OUString aNew; - miAutoPosColumn = pColumnData->end(); - miAutoPosColumn = findText(*pColumnData, miAutoPosColumn, aText, aNew, false); - if (miAutoPosColumn != pColumnData->end()) - { - // Strings can contain line endings (e.g. due to dBase import), - // which would result in multiple paragraphs here, which is not desirable. - //! Then GetExactMatch doesn't work either - lcl_RemoveLineEnd( aNew ); + // Only change when cursor is at the end + ESelection aSel = pActiveView->GetSelection(); + aSel.Adjust(); - // Keep paragraph, just append the rest - //! Exact replacement in EnterHandler !!! - // One Space between paragraphs: - sal_Int32 nEdLen = mpEditEngine->GetTextLen() + nParCnt - 1; - OUString aIns = aNew.copy(nEdLen); + sal_Int32 nParCnt = mpEditEngine->GetParagraphCount(); + if ( aSel.nEndPara+1 != nParCnt ) + return; - // Selection must be "backwards", so the cursor stays behind the last - // typed character - ESelection aSelection( aSel.nEndPara, aSel.nEndPos + aIns.getLength(), - aSel.nEndPara, aSel.nEndPos ); + sal_Int32 nParLen = mpEditEngine->GetTextLen( aSel.nEndPara ); + if ( aSel.nEndPos != nParLen ) + return; - // When editing in input line, apply to both edit views - if ( pTableView ) - { - pTableView->InsertText( aIns ); - pTableView->SetSelection( aSelection ); - } - if ( pTopView ) - { - pTopView->InsertText( aIns ); - pTopView->SetSelection( aSelection ); - } + OUString aText = GetEditText(mpEditEngine.get()); + if (aText.isEmpty()) + return; - aAutoSearch = aText; // To keep searching - nAutoPos is set + OUString aNew; + miAutoPosColumn = pColumnData->end(); + miAutoPosColumn = findText(*pColumnData, miAutoPosColumn, aText, aNew, false); + if (miAutoPosColumn != pColumnData->end()) + { + // Strings can contain line endings (e.g. due to dBase import), + // which would result in multiple paragraphs here, which is not desirable. + //! Then GetExactMatch doesn't work either + lcl_RemoveLineEnd( aNew ); - if (aText.getLength() == aNew.getLength()) - { - // If the inserted text is found, consume TAB only if there's more coming - OUString aDummy; - ScTypedCaseStrSet::const_iterator itNextPos = - findText(*pColumnData, miAutoPosColumn, aText, aDummy, false); - bUseTab = itNextPos != pColumnData->end(); - } - else - bUseTab = true; - } - } - } + // Keep paragraph, just append the rest + //! Exact replacement in EnterHandler !!! + // One Space between paragraphs: + sal_Int32 nEdLen = mpEditEngine->GetTextLen() + nParCnt - 1; + OUString aIns = aNew.copy(nEdLen); + + // Selection must be "backwards", so the cursor stays behind the last + // typed character + ESelection aSelection( aSel.nEndPara, aSel.nEndPos + aIns.getLength(), + aSel.nEndPara, aSel.nEndPos ); + + // When editing in input line, apply to both edit views + if ( pTableView ) + { + pTableView->InsertText( aIns ); + pTableView->SetSelection( aSelection ); } + if ( pTopView ) + { + pTopView->InsertText( aIns ); + pTopView->SetSelection( aSelection ); + } + + aAutoSearch = aText; // To keep searching - nAutoPos is set + + if (aText.getLength() == aNew.getLength()) + { + // If the inserted text is found, consume TAB only if there's more coming + OUString aDummy; + ScTypedCaseStrSet::const_iterator itNextPos = + findText(*pColumnData, miAutoPosColumn, aText, aDummy, false); + bUseTab = itNextPos != pColumnData->end(); + } + else + bUseTab = true; } } @@ -2712,30 +2712,30 @@ void ScInputHandler::ShowRefFrame() // checks in NotifyChange, and lead to keeping the wrong value in pActiveViewSh. // A local variable is used instead. ScTabViewShell* pVisibleSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); - if ( pRefViewSh && pRefViewSh != pVisibleSh ) + if ( !(pRefViewSh && pRefViewSh != pVisibleSh) ) + return; + + bool bFound = false; + SfxViewFrame* pRefFrame = pRefViewSh->GetViewFrame(); + SfxViewFrame* pOneFrame = SfxViewFrame::GetFirst(); + while ( pOneFrame && !bFound ) { - bool bFound = false; - SfxViewFrame* pRefFrame = pRefViewSh->GetViewFrame(); - SfxViewFrame* pOneFrame = SfxViewFrame::GetFirst(); - while ( pOneFrame && !bFound ) - { - if ( pOneFrame == pRefFrame ) - bFound = true; - pOneFrame = SfxViewFrame::GetNext( *pOneFrame ); - } + if ( pOneFrame == pRefFrame ) + bFound = true; + pOneFrame = SfxViewFrame::GetNext( *pOneFrame ); + } - if (bFound) - { - // We count on Activate working synchronously here - // (pActiveViewSh is set while doing so) - pRefViewSh->SetActive(); // Appear and SetViewFrame + if (bFound) + { + // We count on Activate working synchronously here + // (pActiveViewSh is set while doing so) + pRefViewSh->SetActive(); // Appear and SetViewFrame - // pLastState is set correctly in the NotifyChange from the Activate - } - else - { - OSL_FAIL("ViewFrame for reference input is not here anymore"); - } + // pLastState is set correctly in the NotifyChange from the Activate + } + else + { + OSL_FAIL("ViewFrame for reference input is not here anymore"); } } @@ -2757,34 +2757,34 @@ void ScInputHandler::RemoveSelection() void ScInputHandler::InvalidateAttribs() { SfxViewFrame* pViewFrm = SfxViewFrame::Current(); - if (pViewFrm) - { - SfxBindings& rBindings = pViewFrm->GetBindings(); + if (!pViewFrm) + return; - rBindings.Invalidate( SID_ATTR_CHAR_FONT ); - rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); - rBindings.Invalidate( SID_ATTR_CHAR_COLOR ); + SfxBindings& rBindings = pViewFrm->GetBindings(); - rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT ); - rBindings.Invalidate( SID_ATTR_CHAR_POSTURE ); - rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE ); - rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE ); - rBindings.Invalidate( SID_ULINE_VAL_NONE ); - rBindings.Invalidate( SID_ULINE_VAL_SINGLE ); - rBindings.Invalidate( SID_ULINE_VAL_DOUBLE ); - rBindings.Invalidate( SID_ULINE_VAL_DOTTED ); + rBindings.Invalidate( SID_ATTR_CHAR_FONT ); + rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); + rBindings.Invalidate( SID_ATTR_CHAR_COLOR ); - rBindings.Invalidate( SID_HYPERLINK_GETLINK ); + rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT ); + rBindings.Invalidate( SID_ATTR_CHAR_POSTURE ); + rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE ); + rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE ); + rBindings.Invalidate( SID_ULINE_VAL_NONE ); + rBindings.Invalidate( SID_ULINE_VAL_SINGLE ); + rBindings.Invalidate( SID_ULINE_VAL_DOUBLE ); + rBindings.Invalidate( SID_ULINE_VAL_DOTTED ); - rBindings.Invalidate( SID_ATTR_CHAR_KERNING ); - rBindings.Invalidate( SID_SET_SUPER_SCRIPT ); - rBindings.Invalidate( SID_SET_SUB_SCRIPT ); - rBindings.Invalidate( SID_ATTR_CHAR_STRIKEOUT ); - rBindings.Invalidate( SID_ATTR_CHAR_SHADOWED ); + rBindings.Invalidate( SID_HYPERLINK_GETLINK ); - rBindings.Invalidate( SID_SAVEDOC ); - rBindings.Invalidate( SID_DOC_MODIFIED ); - } + rBindings.Invalidate( SID_ATTR_CHAR_KERNING ); + rBindings.Invalidate( SID_SET_SUPER_SCRIPT ); + rBindings.Invalidate( SID_SET_SUB_SCRIPT ); + rBindings.Invalidate( SID_ATTR_CHAR_STRIKEOUT ); + rBindings.Invalidate( SID_ATTR_CHAR_SHADOWED ); + + rBindings.Invalidate( SID_SAVEDOC ); + rBindings.Invalidate( SID_DOC_MODIFIED ); } // --------------- public methods -------------------------------------------- @@ -4146,33 +4146,33 @@ void ScInputHandler::ResetDelayTimer() IMPL_LINK_NOARG( ScInputHandler, DelayTimer, Timer*, void ) { - if ( nullptr == pLastState || SC_MOD()->IsFormulaMode() || SC_MOD()->IsRefDialogOpen()) + if ( !(nullptr == pLastState || SC_MOD()->IsFormulaMode() || SC_MOD()->IsRefDialogOpen())) + return; + + //! New method at ScModule to query if function autopilot is open + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + if ( pViewFrm && pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) ) { - //! New method at ScModule to query if function autopilot is open - SfxViewFrame* pViewFrm = SfxViewFrame::Current(); - if ( pViewFrm && pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) ) + if ( pInputWin) { - if ( pInputWin) - { - pInputWin->EnableButtons( false ); - pInputWin->Disable(); - } + pInputWin->EnableButtons( false ); + pInputWin->Disable(); } - else if ( !bFormulaMode ) // Keep formula e.g. for help - { - bInOwnChange = true; // disable ModifyHdl (reset below) - - pActiveViewSh = nullptr; - mpEditEngine->SetTextCurrentDefaults( EMPTY_OUSTRING ); - if ( pInputWin ) - { - pInputWin->SetPosString( EMPTY_OUSTRING ); - pInputWin->SetTextString( EMPTY_OUSTRING ); - pInputWin->Disable(); - } + } + else if ( !bFormulaMode ) // Keep formula e.g. for help + { + bInOwnChange = true; // disable ModifyHdl (reset below) - bInOwnChange = false; + pActiveViewSh = nullptr; + mpEditEngine->SetTextCurrentDefaults( EMPTY_OUSTRING ); + if ( pInputWin ) + { + pInputWin->SetPosString( EMPTY_OUSTRING ); + pInputWin->SetTextString( EMPTY_OUSTRING ); + pInputWin->Disable(); } + + bInOwnChange = false; } } diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index c67c8963327e..a867220207f4 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -527,19 +527,19 @@ void ScInputWindow::NotifyLOKClient() if (comphelper::LibreOfficeKit::isActive() && !GetLOKNotifier() && mpViewShell) SetLOKNotifier(mpViewShell); - if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) - { - Size aSize = GetSizePixel(); - if (!aSize.IsEmpty()) - { - std::vector<vcl::LOKPayloadItem> aItems; - aItems.emplace_back("type", "calc-input-win"); - aItems.emplace_back(std::make_pair("position", Point(GetOutOffXPixel(), GetOutOffYPixel()).toString())); - aItems.emplace_back(std::make_pair("size", aSize.toString())); - aItems.emplace_back("lines", OString::number(aTextWindow.GetNumLines())); - pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems); - } + const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier(); + if (!pNotifier) + return; + Size aSize = GetSizePixel(); + if (!aSize.IsEmpty()) + { + std::vector<vcl::LOKPayloadItem> aItems; + aItems.emplace_back("type", "calc-input-win"); + aItems.emplace_back(std::make_pair("position", Point(GetOutOffXPixel(), GetOutOffYPixel()).toString())); + aItems.emplace_back(std::make_pair("size", aSize.toString())); + aItems.emplace_back("lines", OString::number(aTextWindow.GetNumLines())); + pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems); } } @@ -551,29 +551,29 @@ void ScInputWindow::SetFuncString( const OUString& rString, bool bDoEdit ) aTextWindow.StartEditEngine(); ScModule* pScMod = SC_MOD(); - if ( pScMod->IsEditMode() ) - { - if ( bDoEdit ) - aTextWindow.GrabFocus(); - aTextWindow.SetTextString( rString ); - EditView* pView = aTextWindow.GetEditView(); - if (pView) - { - sal_Int32 nLen = rString.getLength(); + if ( !pScMod->IsEditMode() ) + return; - if ( nLen > 0 ) - { - nLen--; - pView->SetSelection( ESelection( 0, nLen, 0, nLen ) ); - } + if ( bDoEdit ) + aTextWindow.GrabFocus(); + aTextWindow.SetTextString( rString ); + EditView* pView = aTextWindow.GetEditView(); + if (!pView) + return; - pScMod->InputChanged(pView); - if ( bDoEdit ) - SetOkCancelMode(); // Not the case if immediately followed by Enter/Cancel + sal_Int32 nLen = rString.getLength(); - pView->SetEditEngineUpdateMode(true); - } + if ( nLen > 0 ) + { + nLen--; + pView->SetSelection( ESelection( 0, nLen, 0, nLen ) ); } + + pScMod->InputChanged(pView); + if ( bDoEdit ) + SetOkCancelMode(); // Not the case if immediately followed by Enter/Cancel + + pView->SetEditEngineUpdateMode(true); } void ScInputWindow::SetPosString( const OUString& rStr ) @@ -595,20 +595,20 @@ void ScInputWindow::SetOkCancelMode() SfxViewFrame* pViewFrm = SfxViewFrame::Current(); EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) ); - if (!bIsOkCancelMode) - { - EnableItem ( SID_INPUT_SUM, false ); - EnableItem ( SID_INPUT_EQUAL, false ); - HideItem ( SID_INPUT_SUM ); - HideItem ( SID_INPUT_EQUAL ); + if (bIsOkCancelMode) + return; - ShowItem ( SID_INPUT_CANCEL, true ); - ShowItem ( SID_INPUT_OK, true ); - EnableItem ( SID_INPUT_CANCEL, true ); - EnableItem ( SID_INPUT_OK, true ); + EnableItem ( SID_INPUT_SUM, false ); + EnableItem ( SID_INPUT_EQUAL, false ); + HideItem ( SID_INPUT_SUM ); + HideItem ( SID_INPUT_EQUAL ); - bIsOkCancelMode = true; - } + ShowItem ( SID_INPUT_CANCEL, true ); + ShowItem ( SID_INPUT_OK, true ); + EnableItem ( SID_INPUT_CANCEL, true ); + EnableItem ( SID_INPUT_OK, true ); + + bIsOkCancelMode = true; } void ScInputWindow::SetSumAssignMode() @@ -617,22 +617,22 @@ void ScInputWindow::SetSumAssignMode() SfxViewFrame* pViewFrm = SfxViewFrame::Current(); EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) ); - if (bIsOkCancelMode) - { - EnableItem ( SID_INPUT_CANCEL, false ); - EnableItem ( SID_INPUT_OK, false ); - HideItem ( SID_INPUT_CANCEL ); - HideItem ( SID_INPUT_OK ); + if (!bIsOkCancelMode) + return; - ShowItem ( SID_INPUT_SUM, true ); - ShowItem ( SID_INPUT_EQUAL, true ); - EnableItem ( SID_INPUT_SUM, true ); - EnableItem ( SID_INPUT_EQUAL, true ); + EnableItem ( SID_INPUT_CANCEL, false ); + EnableItem ( SID_INPUT_OK, false ); + HideItem ( SID_INPUT_CANCEL ); + HideItem ( SID_INPUT_OK ); - bIsOkCancelMode = false; + ShowItem ( SID_INPUT_SUM, true ); + ShowItem ( SID_INPUT_EQUAL, true ); + EnableItem ( SID_INPUT_SUM, true ); + EnableItem ( SID_INPUT_EQUAL, true ); - SetFormulaMode(false); // No editing -> no formula - } + bIsOkCancelMode = false; + + SetFormulaMode(false); // No editing -> no formula } void ScInputWindow::SetFormulaMode( bool bSet ) @@ -824,36 +824,36 @@ void ScInputWindow::AutoSum( bool& bRangeFinder, bool& bSubTotal, OpCode eCode ) { ScModule* pScMod = SC_MOD(); ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); - if ( pViewSh ) - { - const OUString aFormula = pViewSh->DoAutoSum(bRangeFinder, bSubTotal, eCode); - if ( !aFormula.isEmpty() ) - { - SetFuncString( aFormula ); - const sal_Int32 aOpen = aFormula.indexOf('('); - const sal_Int32 aLen = aFormula.getLength(); - if (bRangeFinder && pScMod->IsEditMode()) - { - ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh ); - if ( pHdl ) - { - pHdl->InitRangeFinder( aFormula ); + if ( !pViewSh ) + return; - //! SetSelection at the InputHandler? - //! Set bSelIsRef? - if ( aOpen != -1 && aLen > aOpen ) - { - ESelection aSel( 0, aOpen + (bSubTotal ? 3 : 1), 0, aLen-1 ); - EditView* pTableView = pHdl->GetTableView(); - if ( pTableView ) - pTableView->SetSelection( aSel ); - EditView* pTopView = pHdl->GetTopView(); - if ( pTopView ) - pTopView->SetSelection( aSel ); - } - } - } - } + const OUString aFormula = pViewSh->DoAutoSum(bRangeFinder, bSubTotal, eCode); + if ( aFormula.isEmpty() ) + return; + + SetFuncString( aFormula ); + const sal_Int32 aOpen = aFormula.indexOf('('); + const sal_Int32 aLen = aFormula.getLength(); + if (!(bRangeFinder && pScMod->IsEditMode())) + return; + + ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh ); + if ( !pHdl ) + return; + + pHdl->InitRangeFinder( aFormula ); + + //! SetSelection at the InputHandler? + //! Set bSelIsRef? + if ( aOpen != -1 && aLen > aOpen ) + { + ESelection aSel( 0, aOpen + (bSubTotal ? 3 : 1), 0, aLen-1 ); + EditView* pTableView = pHdl->GetTableView(); + if ( pTableView ) + pTableView->SetSelection( aSel ); + EditView* pTopView = pHdl->GetTopView(); + if ( pTopView ) + pTopView->SetSelection( aSel ); } } @@ -1081,39 +1081,39 @@ void ScInputBarGroup::TriggerToolboxLayout() if ( !mnVertOffset ) mnVertOffset = rParent.GetItemPosRect( rParent.GetItemCount() - 1 ).Top(); - if ( pViewFrm ) - { - Reference< css::beans::XPropertySet > xPropSet( pViewFrm->GetFrame().GetFrameInterface(), UNO_QUERY ); - Reference< css::frame::XLayoutManager > xLayoutManager; + if ( !pViewFrm ) + return; - if ( xPropSet.is() ) - { - css::uno::Any aValue = xPropSet->getPropertyValue("LayoutManager"); - aValue >>= xLayoutManager; - } + Reference< css::beans::XPropertySet > xPropSet( pViewFrm->GetFrame().GetFrameInterface(), UNO_QUERY ); + Reference< css::frame::XLayoutManager > xLayoutManager; - if ( xLayoutManager.is() ) - { - xLayoutManager->lock(); - DataChangedEvent aFakeUpdate( DataChangedEventType::SETTINGS, nullptr, AllSettingsFlags::STYLE ); - - // this basically will trigger the repositioning of the - // items in the toolbar from ImplFormat ( which is controlled by - // mnWinHeight ) which in turn is updated in ImplCalcItem which is - // controlled by mbCalc. Additionally the ImplFormat above is - // controlled via mbFormat. It seems the easiest way to get these - // booleans set is to send in the fake event below. - rParent.DataChanged( aFakeUpdate); - - // highest item in toolbar will have been calculated via the - // event above. Call resize on InputBar to pick up the height - // change - rParent.Resize(); - - // unlock relayouts the toolbars in the 4 quadrants - xLayoutManager->unlock(); - } + if ( xPropSet.is() ) + { + css::uno::Any aValue = xPropSet->getPropertyValue("LayoutManager"); + aValue >>= xLayoutManager; } + + if ( !xLayoutManager.is() ) + return; + + xLayoutManager->lock(); + DataChangedEvent aFakeUpdate( DataChangedEventType::SETTINGS, nullptr, AllSettingsFlags::STYLE ); + + // this basically will trigger the repositioning of the + // items in the toolbar from ImplFormat ( which is controlled by + // mnWinHeight ) which in turn is updated in ImplCalcItem which is + // controlled by mbCalc. Additionally the ImplFormat above is + // controlled via mbFormat. It seems the easiest way to get these + // booleans set is to send in the fake event below. + rParent.DataChanged( aFakeUpdate); + + // highest item in toolbar will have been calculated via the + // event above. Call resize on InputBar to pick up the height + // change + rParent.Resize(); + + // unlock relayouts the toolbars in the 4 quadrants + xLayoutManager->unlock(); } void ScInputBarGroup::TextGrabFocus() @@ -2277,21 +2277,21 @@ void ScPosWnd::FillFunctions() void ScPosWnd::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( !bFormulaMode ) + if ( bFormulaMode ) + return; + + // Does the list of range names need updating? + if ( dynamic_cast<const SfxEventHint*>(&rHint) ) { - // Does the list of range names need updating? - if ( dynamic_cast<const SfxEventHint*>(&rHint) ) - { - SfxEventHintId nEventId = static_cast<const SfxEventHint*>(&rHint)->GetEventId(); - if ( nEventId == SfxEventHintId::ActivateDoc ) - FillRangeNames(); - } - else - { - const SfxHintId nHintId = rHint.GetId(); - if ( nHintId == SfxHintId::ScAreasChanged || nHintId == SfxHintId::ScNavigatorUpdateAll) - FillRangeNames(); - } + SfxEventHintId nEventId = static_cast<const SfxEventHint*>(&rHint)->GetEventId(); + if ( nEventId == SfxEventHintId::ActivateDoc ) + FillRangeNames(); + } + else + { + const SfxHintId nHintId = rHint.GetId(); + if ( nHintId == SfxHintId::ScAreasChanged || nHintId == SfxHintId::ScNavigatorUpdateAll) + FillRangeNames(); } } @@ -2362,53 +2362,53 @@ IMPL_LINK_NOARG(ScPosWnd, ModifyHdl, weld::ComboBox&, void) return; } - if (!bFormulaMode) - { - // determine the action that would be taken for the current input + if (bFormulaMode) + return; - ScNameInputType eType = lcl_GetInputType(m_xWidget->get_active_text()); // uses current view - const char* pStrId = nullptr; - switch ( eType ) - { - case SC_NAME_INPUT_CELL: - pStrId = STR_NAME_INPUT_CELL; - break; - case SC_NAME_INPUT_RANGE: - case SC_NAME_INPUT_NAMEDRANGE: - pStrId = STR_NAME_INPUT_RANGE; // named range or range reference - break; - case SC_NAME_INPUT_DATABASE: - pStrId = STR_NAME_INPUT_DBRANGE; - break; - case SC_NAME_INPUT_ROW: - pStrId = STR_NAME_INPUT_ROW; - break; - case SC_NAME_INPUT_SHEET: - pStrId = STR_NAME_INPUT_SHEET; - break; - case SC_NAME_INPUT_DEFINE: - pStrId = STR_NAME_INPUT_DEFINE; - break; - default: - // other cases (error): no tip help - break; - } + // determine the action that would be taken for the current input - if (pStrId) - { - // show the help tip at the text cursor position - Point aPos; - vcl::Cursor* pCur = GetCursor(); - if (pCur) - aPos = LogicToPixel( pCur->GetPos() ); - aPos = OutputToScreenPixel( aPos ); - tools::Rectangle aRect( aPos, aPos ); - - OUString aText = ScResId(pStrId); - QuickHelpFlags const nAlign = QuickHelpFlags::Left|QuickHelpFlags::Bottom; - nTipVisible = Help::ShowPopover(this, aRect, aText, nAlign); - } + ScNameInputType eType = lcl_GetInputType(m_xWidget->get_active_text()); // uses current view + const char* pStrId = nullptr; + switch ( eType ) + { + case SC_NAME_INPUT_CELL: + pStrId = STR_NAME_INPUT_CELL; + break; + case SC_NAME_INPUT_RANGE: + case SC_NAME_INPUT_NAMEDRANGE: + pStrId = STR_NAME_INPUT_RANGE; // named range or range reference + break; + case SC_NAME_INPUT_DATABASE: + pStrId = STR_NAME_INPUT_DBRANGE; + break; + case SC_NAME_INPUT_ROW: + pStrId = STR_NAME_INPUT_ROW; + break; + case SC_NAME_INPUT_SHEET: + pStrId = STR_NAME_INPUT_SHEET; + break; + case SC_NAME_INPUT_DEFINE: + pStrId = STR_NAME_INPUT_DEFINE; + break; + default: + // other cases (error): no tip help + break; } + + if (!pStrId) + return; + + // show the help tip at the text cursor position + Point aPos; + vcl::Cursor* pCur = GetCursor(); + if (pCur) + aPos = LogicToPixel( pCur->GetPos() ); + aPos = OutputToScreenPixel( aPos ); + tools::Rectangle aRect( aPos, aPos ); + + OUString aText = ScResId(pStrId); + QuickHelpFlags const nAlign = QuickHelpFlags::Left|QuickHelpFlags::Bottom; + nTipVisible = Help::ShowPopover(this, aRect, aText, nAlign); } void ScPosWnd::DoEnter() diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index db559c4ce4a9..8c9bf33d3056 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -686,34 +686,34 @@ const ScDocOptions& ScModule::GetDocOptions() void ScModule::InsertEntryToLRUList(sal_uInt16 nFIndex) { - if(nFIndex != 0) - { - const ScAppOptions& rAppOpt = GetAppOptions(); - sal_uInt16 nLRUFuncCount = std::min( rAppOpt.GetLRUFuncListCount(), sal_uInt16(LRU_MAX) ); - sal_uInt16* pLRUListIds = rAppOpt.GetLRUFuncList(); + if(nFIndex == 0) + return; - sal_uInt16 aIdxList[LRU_MAX]; - sal_uInt16 n = 0; - bool bFound = false; + const ScAppOptions& rAppOpt = GetAppOptions(); + sal_uInt16 nLRUFuncCount = std::min( rAppOpt.GetLRUFuncListCount(), sal_uInt16(LRU_MAX) ); + sal_uInt16* pLRUListIds = rAppOpt.GetLRUFuncList(); - while ((n < LRU_MAX) && n<nLRUFuncCount) // Iterate through old list - { - if (!bFound && (pLRUListIds[n]== nFIndex)) - bFound = true; // First hit! - else if (bFound) - aIdxList[n ] = pLRUListIds[n]; // Copy after hit - else if ((n+1) < LRU_MAX) - aIdxList[n+1] = pLRUListIds[n]; // Move before hit - n++; - } - if (!bFound && (n < LRU_MAX)) // Entry not found? - n++; // One more - aIdxList[0] = nFIndex; // Current on Top + sal_uInt16 aIdxList[LRU_MAX]; + sal_uInt16 n = 0; + bool bFound = false; - ScAppOptions aNewOpts(rAppOpt); // Let App know - aNewOpts.SetLRUFuncList(aIdxList, n); - SetAppOptions(aNewOpts); + while ((n < LRU_MAX) && n<nLRUFuncCount) // Iterate through old list + { + if (!bFound && (pLRUListIds[n]== nFIndex)) + bFound = true; // First hit! + else if (bFound) + aIdxList[n ] = pLRUListIds[n]; // Copy after hit + else if ((n+1) < LRU_MAX) + aIdxList[n+1] = pLRUListIds[n]; // Move before hit + n++; } + if (!bFound && (n < LRU_MAX)) // Entry not found? + n++; // One more + aIdxList[0] = nFIndex; // Current on Top + + ScAppOptions aNewOpts(rAppOpt); // Let App know + aNewOpts.SetLRUFuncList(aIdxList, n); + SetAppOptions(aNewOpts); } void ScModule::SetAppOptions( const ScAppOptions& rOpt ) @@ -1255,45 +1255,45 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) } // update ref device (for all documents) - if ( bUpdateRefDev ) + if ( !bUpdateRefDev ) + return; + + // for all documents: recalc output factor, update row heights + SfxObjectShell* pObjSh = SfxObjectShell::GetFirst(); + while ( pObjSh ) { - // for all documents: recalc output factor, update row heights - SfxObjectShell* pObjSh = SfxObjectShell::GetFirst(); - while ( pObjSh ) + if ( dynamic_cast<const ScDocShell *>(pObjSh) != nullptr ) { - if ( dynamic_cast<const ScDocShell *>(pObjSh) != nullptr ) - { - ScDocShell* pOneDocSh = static_cast<ScDocShell*>(pObjSh); - pOneDocSh->CalcOutputFactor(); - SCTAB nTabCount = pOneDocSh->GetDocument().GetTableCount(); - for (SCTAB nTab=0; nTab<nTabCount; nTab++) - pOneDocSh->AdjustRowHeight( 0, pDocSh->GetDocument().MaxRow(), nTab ); - } - pObjSh = SfxObjectShell::GetNext( *pObjSh ); + ScDocShell* pOneDocSh = static_cast<ScDocShell*>(pObjSh); + pOneDocSh->CalcOutputFactor(); + SCTAB nTabCount = pOneDocSh->GetDocument().GetTableCount(); + for (SCTAB nTab=0; nTab<nTabCount; nTab++) + pOneDocSh->AdjustRowHeight( 0, pDocSh->GetDocument().MaxRow(), nTab ); } + pObjSh = SfxObjectShell::GetNext( *pObjSh ); + } - // for all (tab-) views: - SfxViewShell* pSh = SfxViewShell::GetFirst( true, checkSfxViewShell<ScTabViewShell> ); - while ( pSh ) - { - ScTabViewShell* pOneViewSh = static_cast<ScTabViewShell*>(pSh); + // for all (tab-) views: + SfxViewShell* pSh = SfxViewShell::GetFirst( true, checkSfxViewShell<ScTabViewShell> ); + while ( pSh ) + { + ScTabViewShell* pOneViewSh = static_cast<ScTabViewShell*>(pSh); - // set ref-device for EditEngine - ScInputHandler* pHdl = GetInputHdl(pOneViewSh); - if (pHdl) - pHdl->UpdateRefDevice(); + // set ref-device for EditEngine + ScInputHandler* pHdl = GetInputHdl(pOneViewSh); + if (pHdl) + pHdl->UpdateRefDevice(); - // update view scale - ScViewData& rViewData = pOneViewSh->GetViewData(); - pOneViewSh->SetZoom( rViewData.GetZoomX(), rViewData.GetZoomY(), false ); + // update view scale + ScViewData& rViewData = pOneViewSh->GetViewData(); + pOneViewSh->SetZoom( rViewData.GetZoomX(), rViewData.GetZoomY(), false ); - // repaint - pOneViewSh->PaintGrid(); - pOneViewSh->PaintTop(); - pOneViewSh->PaintLeft(); + // repaint + pOneViewSh->PaintGrid(); + pOneViewSh->PaintTop(); + pOneViewSh->PaintLeft(); - pSh = SfxViewShell::GetNext( *pSh, true, checkSfxViewShell<ScTabViewShell> ); - } + pSh = SfxViewShell::GetNext( *pSh, true, checkSfxViewShell<ScTabViewShell> ); } } @@ -1430,34 +1430,34 @@ void ScModule::InputTurnOffWinEngine() void ScModule::ActivateInputWindow( const OUString* pStrFormula, bool bMatrix ) { ScInputHandler* pHdl = GetInputHdl(); - if ( pHdl ) + if ( !pHdl ) + return; + + ScInputWindow* pWin = pHdl->GetInputWindow(); + if ( pStrFormula ) { - ScInputWindow* pWin = pHdl->GetInputWindow(); - if ( pStrFormula ) + // Take over formula + if ( pWin ) { - // Take over formula - if ( pWin ) - { - pWin->SetFuncString( *pStrFormula, false ); - // SetSumAssignMode due to sal_False not necessary - } - ScEnterMode nMode = bMatrix ? ScEnterMode::MATRIX : ScEnterMode::NORMAL; - pHdl->EnterHandler( nMode ); - - // Without Invalidate the selection remains active, if the formula has not changed - if (pWin) - pWin->TextInvalidate(); + pWin->SetFuncString( *pStrFormula, false ); + // SetSumAssignMode due to sal_False not necessary } - else + ScEnterMode nMode = bMatrix ? ScEnterMode::MATRIX : ScEnterMode::NORMAL; + pHdl->EnterHandler( nMode ); + + // Without Invalidate the selection remains active, if the formula has not changed + if (pWin) + pWin->TextInvalidate(); + } + else + { + // Cancel + if ( pWin ) { - // Cancel - if ( pWin ) - { - pWin->SetFuncString( EMPTY_OUSTRING, false ); - // SetSumAssignMode due to sal_False no necessary - } - pHdl->CancelHandler(); + pWin->SetFuncString( EMPTY_OUSTRING, false ); + // SetSumAssignMode due to sal_False no necessary } + pHdl->CancelHandler(); } } @@ -1468,47 +1468,47 @@ void ScModule::SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm ) { //TODO: Move reference dialog handling to view // Just keep function autopilot here for references to other documents - if ( m_nCurRefDlgId == 0 || ( nId == m_nCurRefDlgId && !bVis ) - || ( comphelper::LibreOfficeKit::isActive() ) ) - { - if ( !pViewFrm ) - pViewFrm = SfxViewFrame::Current(); + if ( !(m_nCurRefDlgId == 0 || ( nId == m_nCurRefDlgId && !bVis ) + || ( comphelper::LibreOfficeKit::isActive() )) ) + return; - // bindings update causes problems with update of stylist if - // current style family has changed - //if ( pViewFrm ) - // pViewFrm->GetBindings().Update(); // to avoid trouble in LockDispatcher + if ( !pViewFrm ) + pViewFrm = SfxViewFrame::Current(); - // before SetChildWindow - if ( comphelper::LibreOfficeKit::isActive() ) - { - if ( bVis ) - m_nCurRefDlgId = nId; - } - else - { - m_nCurRefDlgId = bVis ? nId : 0; - } + // bindings update causes problems with update of stylist if + // current style family has changed + //if ( pViewFrm ) + // pViewFrm->GetBindings().Update(); // to avoid trouble in LockDispatcher - if ( pViewFrm ) - { - // store the dialog id also in the view shell - SfxViewShell* pViewSh = pViewFrm->GetViewShell(); - if (ScTabViewShell* pTabViewSh = dynamic_cast<ScTabViewShell*>(pViewSh)) - pTabViewSh->SetCurRefDlgId(m_nCurRefDlgId); - else - { - // no ScTabViewShell - possible for example from a Basic macro - bVis = false; - m_nCurRefDlgId = 0; // don't set nCurRefDlgId if no dialog is created - } + // before SetChildWindow + if ( comphelper::LibreOfficeKit::isActive() ) + { + if ( bVis ) + m_nCurRefDlgId = nId; + } + else + { + m_nCurRefDlgId = bVis ? nId : 0; + } - pViewFrm->SetChildWindow( nId, bVis ); + if ( pViewFrm ) + { + // store the dialog id also in the view shell + SfxViewShell* pViewSh = pViewFrm->GetViewShell(); + if (ScTabViewShell* pTabViewSh = dynamic_cast<ScTabViewShell*>(pViewSh)) + pTabViewSh->SetCurRefDlgId(m_nCurRefDlgId); + else + { + // no ScTabViewShell - possible for example from a Basic macro + bVis = false; + m_nCurRefDlgId = 0; // don't set nCurRefDlgId if no dialog is created } - SfxApplication* pSfxApp = SfxGetpApp(); - pSfxApp->Broadcast( SfxHint( SfxHintId::ScRefModeChanged ) ); + pViewFrm->SetChildWindow( nId, bVis ); } + + SfxApplication* pSfxApp = SfxGetpApp(); + pSfxApp->Broadcast( SfxHint( SfxHintId::ScRefModeChanged ) ); } static SfxChildWindow* lcl_GetChildWinFromCurrentView( sal_uInt16 nId ) @@ -1756,26 +1756,26 @@ void ScModule::EndReference() // We also annul the ZoomIn again in RefDialogs //FIXME: ShowRefFrame at InputHdl, if the Function AutoPilot is open? - if ( m_nCurRefDlgId ) - { - SfxChildWindow* pChildWnd = nullptr; + if ( !m_nCurRefDlgId ) + return; - if ( comphelper::LibreOfficeKit::isActive() ) - pChildWnd = lcl_GetChildWinFromCurrentView( m_nCurRefDlgId ); - else - pChildWnd = lcl_GetChildWinFromAnyView( m_nCurRefDlgId ); + SfxChildWindow* pChildWnd = nullptr; - OSL_ENSURE( pChildWnd, "NoChildWin" ); - if ( pChildWnd ) + if ( comphelper::LibreOfficeKit::isActive() ) + pChildWnd = lcl_GetChildWinFromCurrentView( m_nCurRefDlgId ); + else + pChildWnd = lcl_GetChildWinFromAnyView( m_nCurRefDlgId ); + + OSL_ENSURE( pChildWnd, "NoChildWin" ); + if ( pChildWnd ) + { + if (pChildWnd->GetController()) { - if (pChildWnd->GetController()) + IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); + assert(pRefDlg); + if(pRefDlg) { - IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); - assert(pRefDlg); - if(pRefDlg) - { - pRefDlg->SetActive(); - } + pRefDlg->SetActive(); } } } diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index fd75eeac6486..ddb7ce5b670f 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -663,153 +663,153 @@ ScMarkData ScTransferObj::GetSourceMarkData() const void ScTransferObj::InitDocShell(bool bLimitToPageSize) { - if ( !m_aDocShellRef.is() ) - { - ScDocShell* pDocSh = new ScDocShell; - m_aDocShellRef = pDocSh; // ref must be there before InitNew + if ( m_aDocShellRef.is() ) + return; - pDocSh->DoInitNew(); + ScDocShell* pDocSh = new ScDocShell; + m_aDocShellRef = pDocSh; // ref must be there before InitNew - ScDocument& rDestDoc = pDocSh->GetDocument(); - ScMarkData aDestMark(rDestDoc.GetSheetLimits()); - aDestMark.SelectTable( 0, true ); + pDocSh->DoInitNew(); - rDestDoc.SetDocOptions( m_pDoc->GetDocOptions() ); // #i42666# + ScDocument& rDestDoc = pDocSh->GetDocument(); + ScMarkData aDestMark(rDestDoc.GetSheetLimits()); + aDestMark.SelectTable( 0, true ); - OUString aTabName; - m_pDoc->GetName( m_aBlock.aStart.Tab(), aTabName ); - rDestDoc.RenameTab( 0, aTabName ); + rDestDoc.SetDocOptions( m_pDoc->GetDocOptions() ); // #i42666# - rDestDoc.CopyStdStylesFrom( m_pDoc.get() ); + OUString aTabName; + m_pDoc->GetName( m_aBlock.aStart.Tab(), aTabName ); + rDestDoc.RenameTab( 0, aTabName ); - SCCOL nStartX = m_aBlock.aStart.Col(); - SCROW nStartY = m_aBlock.aStart.Row(); - SCCOL nEndX = m_aBlock.aEnd.Col(); - SCROW nEndY = m_aBlock.aEnd.Row(); + rDestDoc.CopyStdStylesFrom( m_pDoc.get() ); - // widths / heights - // (must be copied before CopyFromClip, for drawing objects) + SCCOL nStartX = m_aBlock.aStart.Col(); + SCROW nStartY = m_aBlock.aStart.Row(); + SCCOL nEndX = m_aBlock.aEnd.Col(); + SCROW nEndY = m_aBlock.aEnd.Row(); - SCCOL nCol; - SCTAB nSrcTab = m_aBlock.aStart.Tab(); - rDestDoc.SetLayoutRTL(0, m_pDoc->IsLayoutRTL(nSrcTab)); - for (nCol=nStartX; nCol<=nEndX; nCol++) - if ( m_pDoc->ColHidden(nCol, nSrcTab) ) - rDestDoc.ShowCol( nCol, 0, false ); - else - rDestDoc.SetColWidth( nCol, 0, m_pDoc->GetColWidth( nCol, nSrcTab ) ); + // widths / heights + // (must be copied before CopyFromClip, for drawing objects) - if (nStartY > 0) - { - // Set manual height for all previous rows so we can ensure - // that visible area will not change due to autoheight - rDestDoc.SetManualHeight(0, nStartY - 1, 0, true); - } - for (SCROW nRow = nStartY; nRow <= nEndY; ++nRow) + SCCOL nCol; + SCTAB nSrcTab = m_aBlock.aStart.Tab(); + rDestDoc.SetLayoutRTL(0, m_pDoc->IsLayoutRTL(nSrcTab)); + for (nCol=nStartX; nCol<=nEndX; nCol++) + if ( m_pDoc->ColHidden(nCol, nSrcTab) ) + rDestDoc.ShowCol( nCol, 0, false ); + else + rDestDoc.SetColWidth( nCol, 0, m_pDoc->GetColWidth( nCol, nSrcTab ) ); + + if (nStartY > 0) + { + // Set manual height for all previous rows so we can ensure + // that visible area will not change due to autoheight + rDestDoc.SetManualHeight(0, nStartY - 1, 0, true); + } + for (SCROW nRow = nStartY; nRow <= nEndY; ++nRow) + { + if ( m_pDoc->RowHidden(nRow, nSrcTab) ) + rDestDoc.ShowRow( nRow, 0, false ); + else { - if ( m_pDoc->RowHidden(nRow, nSrcTab) ) - rDestDoc.ShowRow( nRow, 0, false ); - else - { - rDestDoc.SetRowHeight( nRow, 0, m_pDoc->GetOriginalHeight( nRow, nSrcTab ) ); + rDestDoc.SetRowHeight( nRow, 0, m_pDoc->GetOriginalHeight( nRow, nSrcTab ) ); - // if height was set manually, that flag has to be copied, too - bool bManual = m_pDoc->IsManualRowHeight(nRow, nSrcTab); - rDestDoc.SetManualHeight(nRow, nRow, 0, bManual); - } + // if height was set manually, that flag has to be copied, too + bool bManual = m_pDoc->IsManualRowHeight(nRow, nSrcTab); + rDestDoc.SetManualHeight(nRow, nRow, 0, bManual); } + } - if (m_pDoc->GetDrawLayer() || m_pDoc->HasNotes()) - pDocSh->MakeDrawLayer(); + if (m_pDoc->GetDrawLayer() || m_pDoc->HasNotes()) + pDocSh->MakeDrawLayer(); - // cell range is copied to the original position, but on the first sheet - // -> bCutMode must be set - // pDoc is always a Clipboard-document + // cell range is copied to the original position, but on the first sheet + // -> bCutMode must be set + // pDoc is always a Clipboard-document - ScRange aDestRange( nStartX,nStartY,0, nEndX,nEndY,0 ); - bool bWasCut = m_pDoc->IsCutMode(); - if (!bWasCut) - m_pDoc->SetClipArea( aDestRange, true ); // Cut - rDestDoc.CopyFromClip( aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, m_pDoc.get(), false ); - m_pDoc->SetClipArea( aDestRange, bWasCut ); + ScRange aDestRange( nStartX,nStartY,0, nEndX,nEndY,0 ); + bool bWasCut = m_pDoc->IsCutMode(); + if (!bWasCut) + m_pDoc->SetClipArea( aDestRange, true ); // Cut + rDestDoc.CopyFromClip( aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, m_pDoc.get(), false ); + m_pDoc->SetClipArea( aDestRange, bWasCut ); - StripRefs( m_pDoc.get(), nStartX,nStartY, nEndX,nEndY, &rDestDoc ); + StripRefs( m_pDoc.get(), nStartX,nStartY, nEndX,nEndY, &rDestDoc ); - ScRange aMergeRange = aDestRange; - rDestDoc.ExtendMerge( aMergeRange, true ); + ScRange aMergeRange = aDestRange; + rDestDoc.ExtendMerge( aMergeRange, true ); - m_pDoc->CopyDdeLinks( &rDestDoc ); // copy values of DDE Links + m_pDoc->CopyDdeLinks( &rDestDoc ); // copy values of DDE Links - // page format (grid etc) and page size (maximum size for ole object) + // page format (grid etc) and page size (maximum size for ole object) - Size aPaperSize = SvxPaperInfo::GetPaperSize( PAPER_A4 ); // Twips - ScStyleSheetPool* pStylePool = m_pDoc->GetStyleSheetPool(); - OUString aStyleName = m_pDoc->GetPageStyle( m_aBlock.aStart.Tab() ); - SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SfxStyleFamily::Page ); - if (pStyleSheet) - { - const SfxItemSet& rSourceSet = pStyleSheet->GetItemSet(); - aPaperSize = rSourceSet.Get(ATTR_PAGE_SIZE).GetSize(); + Size aPaperSize = SvxPaperInfo::GetPaperSize( PAPER_A4 ); // Twips + ScStyleSheetPool* pStylePool = m_pDoc->GetStyleSheetPool(); + OUString aStyleName = m_pDoc->GetPageStyle( m_aBlock.aStart.Tab() ); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SfxStyleFamily::Page ); + if (pStyleSheet) + { + const SfxItemSet& rSourceSet = pStyleSheet->GetItemSet(); + aPaperSize = rSourceSet.Get(ATTR_PAGE_SIZE).GetSize(); - // CopyStyleFrom copies SetItems with correct pool - ScStyleSheetPool* pDestPool = rDestDoc.GetStyleSheetPool(); - pDestPool->CopyStyleFrom( pStylePool, aStyleName, SfxStyleFamily::Page ); - } + // CopyStyleFrom copies SetItems with correct pool + ScStyleSheetPool* pDestPool = rDestDoc.GetStyleSheetPool(); + pDestPool->CopyStyleFrom( pStylePool, aStyleName, SfxStyleFamily::Page ); + } - ScViewData aViewData( pDocSh, nullptr ); - aViewData.SetScreen( nStartX,nStartY, nEndX,nEndY ); - aViewData.SetCurX( nStartX ); - aViewData.SetCurY( nStartY ); + ScViewData aViewData( pDocSh, nullptr ); + aViewData.SetScreen( nStartX,nStartY, nEndX,nEndY ); + aViewData.SetCurX( nStartX ); + aViewData.SetCurY( nStartY ); - rDestDoc.SetViewOptions( m_pDoc->GetViewOptions() ); + rDestDoc.SetViewOptions( m_pDoc->GetViewOptions() ); - // Size - //! get while copying sizes + // Size + //! get while copying sizes - long nPosX = 0; - long nPosY = 0; + long nPosX = 0; + long nPosY = 0; - for (nCol=0; nCol<nStartX; nCol++) - nPosX += rDestDoc.GetColWidth( nCol, 0 ); - nPosY += rDestDoc.GetRowHeight( 0, nStartY-1, 0 ); - nPosX = static_cast<long>( nPosX * HMM_PER_TWIPS ); - nPosY = static_cast<long>( nPosY * HMM_PER_TWIPS ); + for (nCol=0; nCol<nStartX; nCol++) + nPosX += rDestDoc.GetColWidth( nCol, 0 ); + nPosY += rDestDoc.GetRowHeight( 0, nStartY-1, 0 ); + nPosX = static_cast<long>( nPosX * HMM_PER_TWIPS ); + nPosY = static_cast<long>( nPosY * HMM_PER_TWIPS ); - aPaperSize.setWidth( aPaperSize.Width() * 2 ); // limit OLE object to double of page size - aPaperSize.setHeight( aPaperSize.Height() * 2 ); + aPaperSize.setWidth( aPaperSize.Width() * 2 ); // limit OLE object to double of page size + aPaperSize.setHeight( aPaperSize.Height() * 2 ); - long nSizeX = 0; - long nSizeY = 0; - for (nCol=nStartX; nCol<=nEndX; nCol++) - { - long nAdd = rDestDoc.GetColWidth( nCol, 0 ); - if ( bLimitToPageSize && nSizeX+nAdd > aPaperSize.Width() && nSizeX ) // above limit? - break; - nSizeX += nAdd; - } - for (SCROW nRow=nStartY; nRow<=nEndY; nRow++) - { - long nAdd = rDestDoc.GetRowHeight( nRow, 0 ); - if ( bLimitToPageSize && nSizeY+nAdd > aPaperSize.Height() && nSizeY ) // above limit? - break; - nSizeY += nAdd; - } - nSizeX = static_cast<long>( nSizeX * HMM_PER_TWIPS ); - nSizeY = static_cast<long>( nSizeY * HMM_PER_TWIPS ); + long nSizeX = 0; + long nSizeY = 0; + for (nCol=nStartX; nCol<=nEndX; nCol++) + { + long nAdd = rDestDoc.GetColWidth( nCol, 0 ); + if ( bLimitToPageSize && nSizeX+nAdd > aPaperSize.Width() && nSizeX ) // above limit? + break; + nSizeX += nAdd; + } + for (SCROW nRow=nStartY; nRow<=nEndY; nRow++) + { + long nAdd = rDestDoc.GetRowHeight( nRow, 0 ); + if ( bLimitToPageSize && nSizeY+nAdd > aPaperSize.Height() && nSizeY ) // above limit? + break; + nSizeY += nAdd; + } + nSizeX = static_cast<long>( nSizeX * HMM_PER_TWIPS ); + nSizeY = static_cast<long>( nSizeY * HMM_PER_TWIPS ); // pDocSh->SetVisAreaSize( Size(nSizeX,nSizeY) ); - tools::Rectangle aNewArea( Point(nPosX,nPosY), Size(nSizeX,nSizeY) ); - //TODO/LATER: why twice?! - //pDocSh->SvInPlaceObject::SetVisArea( aNewArea ); - pDocSh->SetVisArea( aNewArea ); + tools::Rectangle aNewArea( Point(nPosX,nPosY), Size(nSizeX,nSizeY) ); + //TODO/LATER: why twice?! + //pDocSh->SvInPlaceObject::SetVisArea( aNewArea ); + pDocSh->SetVisArea( aNewArea ); - pDocSh->UpdateOle(&aViewData, true); + pDocSh->UpdateOle(&aViewData, true); - //! SetDocumentModified? - if ( rDestDoc.IsChartListenerCollectionNeedsUpdate() ) - rDestDoc.UpdateChartListenerCollection(); - } + //! SetDocumentModified? + if ( rDestDoc.IsChartListenerCollectionNeedsUpdate() ) + rDestDoc.UpdateChartListenerCollection(); } SfxObjectShell* ScTransferObj::SetDrawClipDoc( bool bAnyOle ) diff --git a/sc/source/ui/cctrl/cbnumberformat.cxx b/sc/source/ui/cctrl/cbnumberformat.cxx index 9407b08e491c..05d7281ab96d 100644 --- a/sc/source/ui/cctrl/cbnumberformat.cxx +++ b/sc/source/ui/cctrl/cbnumberformat.cxx @@ -68,18 +68,18 @@ void ScNumberFormat::GetFocus() IMPL_STATIC_LINK(ScNumberFormat, NumFormatSelectHdl, weld::ComboBox&, rBox, void) { auto* pCurSh = SfxViewFrame::Current(); - if (pCurSh) + if (!pCurSh) + return; + + SfxDispatcher* pDisp = pCurSh->GetBindings().GetDispatcher(); + if (pDisp) { - SfxDispatcher* pDisp = pCurSh->GetBindings().GetDispatcher(); - if (pDisp) - { - const sal_Int32 nVal = rBox.get_active(); - SfxUInt16Item aItem(SID_NUMBER_TYPE_FORMAT, nVal); - pDisp->ExecuteList(SID_NUMBER_TYPE_FORMAT, - SfxCallMode::RECORD, {&aItem}); + const sal_Int32 nVal = rBox.get_active(); + SfxUInt16Item aItem(SID_NUMBER_TYPE_FORMAT, nVal); + pDisp->ExecuteList(SID_NUMBER_TYPE_FORMAT, + SfxCallMode::RECORD, {&aItem}); - pCurSh->GetWindow().GrabFocus(); - } + pCurSh->GetWindow().GrabFocus(); } } diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index 123cc1824bdf..a369aff364e5 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -332,22 +332,22 @@ void ScCheckListMenuControl::selectMenuItem(size_t nPos, bool bSubMenuTimer) } - if (nPos != MENU_NOT_SELECTED) - { - ScCheckListMenuWindow* pParentMenu = mxFrame->GetParentMenu(); - if (pParentMenu) - pParentMenu->get_widget().setSubMenuFocused(this); + if (nPos == MENU_NOT_SELECTED) + return; - if (bSubMenuTimer) + ScCheckListMenuWindow* pParentMenu = mxFrame->GetParentMenu(); + if (pParentMenu) + pParentMenu->get_widget().setSubMenuFocused(this); + + if (bSubMenuTimer) + { + if (maMenuItems[nPos].mxSubMenuWin) { - if (maMenuItems[nPos].mxSubMenuWin) - { - ScCheckListMenuWindow* pSubMenu = maMenuItems[nPos].mxSubMenuWin.get(); - queueLaunchSubMenu(nPos, pSubMenu); - } - else - queueCloseSubMenu(); + ScCheckListMenuWindow* pSubMenu = maMenuItems[nPos].mxSubMenuWin.get(); + queueLaunchSubMenu(nPos, pSubMenu); } + else + queueCloseSubMenu(); } } @@ -932,35 +932,35 @@ std::unique_ptr<weld::TreeIter> ScCheckListMenuControl::FindEntry(const weld::Tr void ScCheckListMenuControl::GetRecursiveChecked(const weld::TreeIter* pEntry, std::unordered_set<OUString>& vOut, OUString& rLabel) { - if (mxChecks->get_toggle(*pEntry) == TRISTATE_TRUE) - { - // We have to hash parents and children together. - // Per convention for easy access in getResult() - // "child;parent;grandparent" while descending. - if (rLabel.isEmpty()) - rLabel = mxChecks->get_text(*pEntry, 0); - else - rLabel = mxChecks->get_text(*pEntry, 0) + ";" + rLabel; + if (mxChecks->get_toggle(*pEntry) != TRISTATE_TRUE) + return; - // Prerequisite: the selection mechanism guarantees that if a child is - // selected then also the parent is selected, so we only have to - // inspect the children in case the parent is selected. - if (mxChecks->iter_has_child(*pEntry)) - { - std::unique_ptr<weld::TreeIter> xChild(mxChecks->make_iterator(pEntry)); - bool bChild = mxChecks->iter_children(*xChild); - while (bChild) - { - OUString aLabel = rLabel; - GetRecursiveChecked(xChild.get(), vOut, aLabel); - if (!aLabel.isEmpty() && aLabel != rLabel) - vOut.insert(aLabel); - bChild = mxChecks->iter_next_sibling(*xChild); - } - // Let the caller not add the parent alone. - rLabel.clear(); - } + // We have to hash parents and children together. + // Per convention for easy access in getResult() + // "child;parent;grandparent" while descending. + if (rLabel.isEmpty()) + rLabel = mxChecks->get_text(*pEntry, 0); + else + rLabel = mxChecks->get_text(*pEntry, 0) + ";" + rLabel; + + // Prerequisite: the selection mechanism guarantees that if a child is + // selected then also the parent is selected, so we only have to + // inspect the children in case the parent is selected. + if (!mxChecks->iter_has_child(*pEntry)) + return; + + std::unique_ptr<weld::TreeIter> xChild(mxChecks->make_iterator(pEntry)); + bool bChild = mxChecks->iter_children(*xChild); + while (bChild) + { + OUString aLabel = rLabel; + GetRecursiveChecked(xChild.get(), vOut, aLabel); + if (!aLabel.isEmpty() && aLabel != rLabel) + vOut.insert(aLabel); + bChild = mxChecks->iter_next_sibling(*xChild); } + // Let the caller not add the parent alone. + rLabel.clear(); } std::unordered_set<OUString> ScCheckListMenuControl::GetAllChecked() @@ -1014,31 +1014,31 @@ void ScCheckListMenuControl::CheckEntry(const weld::TreeIter* pParent, bool bChe CheckAllChildren(pParent, bCheck); // checking pParent can affect ancestors, e.g. if ancestor is unchecked and pParent is // now checked then the ancestor needs to be checked also - if (pParent && mxChecks->get_iter_depth(*pParent)) + if (!(pParent && mxChecks->get_iter_depth(*pParent))) + return; + + std::unique_ptr<weld::TreeIter> xAncestor(mxChecks->make_iterator(pParent)); + bool bAncestor = mxChecks->iter_parent(*xAncestor); + while (bAncestor) { - std::unique_ptr<weld::TreeIter> xAncestor(mxChecks->make_iterator(pParent)); - bool bAncestor = mxChecks->iter_parent(*xAncestor); - while (bAncestor) + // if any first level children checked then ancestor + // needs to be checked, similarly if no first level children + // checked then ancestor needs to be unchecked + std::unique_ptr<weld::TreeIter> xChild(mxChecks->make_iterator(xAncestor.get())); + bool bChild = mxChecks->iter_children(*xChild); + bool bChildChecked = false; + + while (bChild) { - // if any first level children checked then ancestor - // needs to be checked, similarly if no first level children - // checked then ancestor needs to be unchecked - std::unique_ptr<weld::TreeIter> xChild(mxChecks->make_iterator(xAncestor.get())); - bool bChild = mxChecks->iter_children(*xChild); - bool bChildChecked = false; - - while (bChild) + if (mxChecks->get_toggle(*xChild) == TRISTATE_TRUE) { - if (mxChecks->get_toggle(*xChild) == TRISTATE_TRUE) - { - bChildChecked = true; - break; - } - bChild = mxChecks->iter_next_sibling(*xChild); + bChildChecked = true; + break; } - mxChecks->set_toggle(*xAncestor, bChildChecked ? TRISTATE_TRUE : TRISTATE_FALSE); - bAncestor = mxChecks->iter_parent(*xAncestor); + bChild = mxChecks->iter_next_sibling(*xChild); } + mxChecks->set_toggle(*xAncestor, bChildChecked ? TRISTATE_TRUE : TRISTATE_FALSE); + bAncestor = mxChecks->iter_parent(*xAncestor); } } diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx index d38d70d2a213..5d32b070dd55 100644 --- a/sc/source/ui/condformat/condformatdlg.cxx +++ b/sc/source/ui/condformat/condformatdlg.cxx @@ -535,32 +535,32 @@ void ScCondFormatDlg::SetReference(const ScRange& rRef, ScDocument&) if (!mpLastEdit) pEdit = mxEdRange.get(); - if (pEdit->GetWidget()->get_sensitive()) - { - if(rRef.aStart != rRef.aEnd) - RefInputStart(pEdit); + if (!pEdit->GetWidget()->get_sensitive()) + return; - ScRefFlags nFlags; - if (mpLastEdit && mpLastEdit != mxEdRange.get()) - nFlags = ScRefFlags::RANGE_ABS_3D; - else - nFlags = ScRefFlags::RANGE_ABS; + if(rRef.aStart != rRef.aEnd) + RefInputStart(pEdit); - const ScDocument* pDoc = mpViewData->GetDocument(); - OUString aRefStr(rRef.Format(*pDoc, nFlags, - ScAddress::Details(pDoc->GetAddressConvention(), 0, 0))); - if (pEdit != mxEdRange.get()) - { - Selection sel = pEdit->GetSelection(); - sel.Justify(); // in case of RTL selection - sel.Max() = sel.Min() + aRefStr.getLength(); - pEdit->GetWidget()->replace_selection(aRefStr); - pEdit->SetSelection(sel); // to replace it again with next drag event - } - else - pEdit->SetRefString( aRefStr ); - updateTitle(); + ScRefFlags nFlags; + if (mpLastEdit && mpLastEdit != mxEdRange.get()) + nFlags = ScRefFlags::RANGE_ABS_3D; + else + nFlags = ScRefFlags::RANGE_ABS; + + const ScDocument* pDoc = mpViewData->GetDocument(); + OUString aRefStr(rRef.Format(*pDoc, nFlags, + ScAddress::Details(pDoc->GetAddressConvention(), 0, 0))); + if (pEdit != mxEdRange.get()) + { + Selection sel = pEdit->GetSelection(); + sel.Justify(); // in case of RTL selection + sel.Max() = sel.Min() + aRefStr.getLength(); + pEdit->GetWidget()->replace_selection(aRefStr); + pEdit->SetSelection(sel); // to replace it again with next drag event } + else + pEdit->SetRefString( aRefStr ); + updateTitle(); } std::unique_ptr<ScConditionalFormat> ScCondFormatDlg::GetConditionalFormat() const diff --git a/sc/source/ui/dbgui/consdlg.cxx b/sc/source/ui/dbgui/consdlg.cxx index db55aaa0c657..7f6252fe248a 100644 --- a/sc/source/ui/dbgui/consdlg.cxx +++ b/sc/source/ui/dbgui/consdlg.cxx @@ -232,26 +232,26 @@ void ScConsolidateDlg::FillAreaLists() void ScConsolidateDlg::SetReference( const ScRange& rRef, ScDocument& rDocP ) { - if ( m_pRefInputEdit ) - { - if ( rRef.aStart != rRef.aEnd ) - RefInputStart( m_pRefInputEdit ); + if ( !m_pRefInputEdit ) + return; - OUString aStr; - ScRefFlags nFmt = ScRefFlags::RANGE_ABS_3D; //!!! nCurTab is still missing - const formula::FormulaGrammar::AddressConvention eConv = rDocP.GetAddressConvention(); + if ( rRef.aStart != rRef.aEnd ) + RefInputStart( m_pRefInputEdit ); - if ( rRef.aStart.Tab() != rRef.aEnd.Tab() ) - nFmt |= ScRefFlags::TAB2_3D; + OUString aStr; + ScRefFlags nFmt = ScRefFlags::RANGE_ABS_3D; //!!! nCurTab is still missing + const formula::FormulaGrammar::AddressConvention eConv = rDocP.GetAddressConvention(); - if ( m_pRefInputEdit == m_xEdDataArea.get()) - aStr = rRef.Format(rDocP, nFmt, eConv); - else if ( m_pRefInputEdit == m_xEdDestArea.get() ) - aStr = rRef.aStart.Format(nFmt, &rDocP, eConv); + if ( rRef.aStart.Tab() != rRef.aEnd.Tab() ) + nFmt |= ScRefFlags::TAB2_3D; - m_pRefInputEdit->SetRefString( aStr ); - ModifyHdl( *m_pRefInputEdit ); - } + if ( m_pRefInputEdit == m_xEdDataArea.get()) + aStr = rRef.Format(rDocP, nFmt, eConv); + else if ( m_pRefInputEdit == m_xEdDestArea.get() ) + aStr = rRef.aStart.Format(nFmt, &rDocP, eConv); + + m_pRefInputEdit->SetRefString( aStr ); + ModifyHdl( *m_pRefInputEdit ); } void ScConsolidateDlg::Close() diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx index dad4e9f2d299..056bf4022a11 100644 --- a/sc/source/ui/dbgui/csvgrid.cxx +++ b/sc/source/ui/dbgui/csvgrid.cxx @@ -349,29 +349,29 @@ void ScCsvGrid::RemoveSplit( sal_Int32 nPos ) void ScCsvGrid::MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos ) { sal_uInt32 nColIx = GetColumnFromPos( nPos ); - if( nColIx != CSV_COLUMN_INVALID ) + if( nColIx == CSV_COLUMN_INVALID ) + return; + + DisableRepaint(); + if( (GetColumnPos( nColIx - 1 ) < nNewPos) && (nNewPos < GetColumnPos( nColIx + 1 )) ) { - DisableRepaint(); - if( (GetColumnPos( nColIx - 1 ) < nNewPos) && (nNewPos < GetColumnPos( nColIx + 1 )) ) - { - // move a split in the range between 2 others -> keep selection state of both columns - maSplits.Remove( nPos ); - maSplits.Insert( nNewPos ); - Execute( CSVCMD_UPDATECELLTEXTS ); - ImplDrawColumn( nColIx - 1 ); - ImplDrawColumn( nColIx ); - ValidateGfx(); // performance: do not redraw all columns - AccSendTableUpdateEvent( nColIx - 1, nColIx ); - } - else - { - ImplRemoveSplit( nPos ); - ImplInsertSplit( nNewPos ); - Execute( CSVCMD_EXPORTCOLUMNTYPE ); - Execute( CSVCMD_UPDATECELLTEXTS ); - } - EnableRepaint(); + // move a split in the range between 2 others -> keep selection state of both columns + maSplits.Remove( nPos ); + maSplits.Insert( nNewPos ); + Execute( CSVCMD_UPDATECELLTEXTS ); + ImplDrawColumn( nColIx - 1 ); + ImplDrawColumn( nColIx ); + ValidateGfx(); // performance: do not redraw all columns + AccSendTableUpdateEvent( nColIx - 1, nColIx ); + } + else + { + ImplRemoveSplit( nPos ); + ImplInsertSplit( nNewPos ); + Execute( CSVCMD_EXPORTCOLUMNTYPE ); + Execute( CSVCMD_UPDATECELLTEXTS ); } + EnableRepaint(); } void ScCsvGrid::RemoveAllSplits() @@ -712,28 +712,28 @@ void ScCsvGrid::MoveCursor( sal_uInt32 nColIndex ) void ScCsvGrid::MoveCursorRel( ScMoveMode eDir ) { - if( GetFocusColumn() != CSV_COLUMN_INVALID ) + if( GetFocusColumn() == CSV_COLUMN_INVALID ) + return; + + switch( eDir ) { - switch( eDir ) + case MOVE_FIRST: + MoveCursor( 0 ); + break; + case MOVE_LAST: + MoveCursor( GetColumnCount() - 1 ); + break; + case MOVE_PREV: + if( GetFocusColumn() > 0 ) + MoveCursor( GetFocusColumn() - 1 ); + break; + case MOVE_NEXT: + if( GetFocusColumn() < GetColumnCount() - 1 ) + MoveCursor( GetFocusColumn() + 1 ); + break; + default: { - case MOVE_FIRST: - MoveCursor( 0 ); - break; - case MOVE_LAST: - MoveCursor( GetColumnCount() - 1 ); - break; - case MOVE_PREV: - if( GetFocusColumn() > 0 ) - MoveCursor( GetFocusColumn() - 1 ); - break; - case MOVE_NEXT: - if( GetFocusColumn() < GetColumnCount() - 1 ) - MoveCursor( GetFocusColumn() + 1 ); - break; - default: - { - // added to avoid warnings - } + // added to avoid warnings } } } diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx index 294f22526974..d4d5a0c7ecdc 100644 --- a/sc/source/ui/dbgui/csvruler.cxx +++ b/sc/source/ui/dbgui/csvruler.cxx @@ -44,26 +44,26 @@ static void load_FixedWidthList(ScCsvSplits &rSplits) aValues = aItem.GetProperties( aNames ); pProperties = aValues.getConstArray(); - if( pProperties[0].hasValue() ) - { - rSplits.Clear(); + if( !pProperties[0].hasValue() ) + return; + + rSplits.Clear(); - OUString sFixedWidthLists; - pProperties[0] >>= sFixedWidthLists; + OUString sFixedWidthLists; + pProperties[0] >>= sFixedWidthLists; - sal_Int32 nIdx {0}; - for(;;) + sal_Int32 nIdx {0}; + for(;;) + { + const sal_Int32 n {sFixedWidthLists.getToken(0, ';', nIdx).toInt32()}; + if (nIdx<0) { - const sal_Int32 n {sFixedWidthLists.getToken(0, ';', nIdx).toInt32()}; - if (nIdx<0) - { - // String ends with a semi-colon so there - // is no useful 'int' after the last one. - // This also works in case of empty string - break; - } - rSplits.Insert(n); + // String ends with a semi-colon so there + // is no useful 'int' after the last one. + // This also works in case of empty string + break; } + rSplits.Insert(n); } } static void save_FixedWidthList(const ScCsvSplits& rSplits) @@ -190,52 +190,52 @@ void ScCsvRuler::MoveCursor( sal_Int32 nPos, bool bScroll ) void ScCsvRuler::MoveCursorRel( ScMoveMode eDir ) { - if( GetRulerCursorPos() != CSV_POS_INVALID ) + if( GetRulerCursorPos() == CSV_POS_INVALID ) + return; + + switch( eDir ) { - switch( eDir ) + case MOVE_FIRST: + MoveCursor( 1 ); + break; + case MOVE_LAST: + MoveCursor( GetPosCount() - 1 ); + break; + case MOVE_PREV: + if( GetRulerCursorPos() > 1 ) + MoveCursor( GetRulerCursorPos() - 1 ); + break; + case MOVE_NEXT: + if( GetRulerCursorPos() < GetPosCount() - 1 ) + MoveCursor( GetRulerCursorPos() + 1 ); + break; + default: { - case MOVE_FIRST: - MoveCursor( 1 ); - break; - case MOVE_LAST: - MoveCursor( GetPosCount() - 1 ); - break; - case MOVE_PREV: - if( GetRulerCursorPos() > 1 ) - MoveCursor( GetRulerCursorPos() - 1 ); - break; - case MOVE_NEXT: - if( GetRulerCursorPos() < GetPosCount() - 1 ) - MoveCursor( GetRulerCursorPos() + 1 ); - break; - default: - { - // added to avoid warnings - } + // added to avoid warnings } } } void ScCsvRuler::MoveCursorToSplit( ScMoveMode eDir ) { - if( GetRulerCursorPos() != CSV_POS_INVALID ) + if( GetRulerCursorPos() == CSV_POS_INVALID ) + return; + + sal_uInt32 nIndex = CSV_VEC_NOTFOUND; + switch( eDir ) { - sal_uInt32 nIndex = CSV_VEC_NOTFOUND; - switch( eDir ) + case MOVE_FIRST: nIndex = maSplits.LowerBound( 0 ); break; + case MOVE_LAST: nIndex = maSplits.UpperBound( GetPosCount() ); break; + case MOVE_PREV: nIndex = maSplits.UpperBound( GetRulerCursorPos() - 1 ); break; + case MOVE_NEXT: nIndex = maSplits.LowerBound( GetRulerCursorPos() + 1 ); break; + default: { - case MOVE_FIRST: nIndex = maSplits.LowerBound( 0 ); break; - case MOVE_LAST: nIndex = maSplits.UpperBound( GetPosCount() ); break; - case MOVE_PREV: nIndex = maSplits.UpperBound( GetRulerCursorPos() - 1 ); break; - case MOVE_NEXT: nIndex = maSplits.LowerBound( GetRulerCursorPos() + 1 ); break; - default: - { - // added to avoid warnings - } + // added to avoid warnings } - sal_Int32 nPos = maSplits[ nIndex ]; - if( nPos != CSV_POS_INVALID ) - MoveCursor( nPos ); } + sal_Int32 nPos = maSplits[ nIndex ]; + if( nPos != CSV_POS_INVALID ) + MoveCursor( nPos ); } void ScCsvRuler::ScrollVertRel( ScMoveMode eDir ) diff --git a/sc/source/ui/dbgui/csvtablebox.cxx b/sc/source/ui/dbgui/csvtablebox.cxx index e424e6499511..9f1de427291a 100644 --- a/sc/source/ui/dbgui/csvtablebox.cxx +++ b/sc/source/ui/dbgui/csvtablebox.cxx @@ -60,41 +60,41 @@ ScCsvTableBox::~ScCsvTableBox() void ScCsvTableBox::SetSeparatorsMode() { - if( mbFixedMode ) - { - // rescue data for fixed width mode - mnFixedWidth = mxGrid->GetPosCount(); - maFixColStates = mxGrid->GetColumnStates(); - // switch to separators mode - mbFixedMode = false; - // reset and reinitialize controls - mxGrid->DisableRepaint(); - mxGrid->Execute( CSVCMD_SETLINEOFFSET, 0 ); - mxGrid->Execute( CSVCMD_SETPOSCOUNT, 1 ); - mxGrid->Execute( CSVCMD_NEWCELLTEXTS ); - mxGrid->SetColumnStates( maSepColStates ); - InitControls(); - mxGrid->EnableRepaint(); - } + if( !mbFixedMode ) + return; + + // rescue data for fixed width mode + mnFixedWidth = mxGrid->GetPosCount(); + maFixColStates = mxGrid->GetColumnStates(); + // switch to separators mode + mbFixedMode = false; + // reset and reinitialize controls + mxGrid->DisableRepaint(); + mxGrid->Execute( CSVCMD_SETLINEOFFSET, 0 ); + mxGrid->Execute( CSVCMD_SETPOSCOUNT, 1 ); + mxGrid->Execute( CSVCMD_NEWCELLTEXTS ); + mxGrid->SetColumnStates( maSepColStates ); + InitControls(); + mxGrid->EnableRepaint(); } void ScCsvTableBox::SetFixedWidthMode() { - if( !mbFixedMode ) - { - // rescue data for separators mode - maSepColStates = mxGrid->GetColumnStates(); - // switch to fixed width mode - mbFixedMode = true; - // reset and reinitialize controls - mxGrid->DisableRepaint(); - mxGrid->Execute( CSVCMD_SETLINEOFFSET, 0 ); - mxGrid->Execute( CSVCMD_SETPOSCOUNT, mnFixedWidth ); - mxGrid->SetSplits( mxRuler->GetSplits() ); - mxGrid->SetColumnStates( maFixColStates ); - InitControls(); - mxGrid->EnableRepaint(); - } + if( mbFixedMode ) + return; + + // rescue data for separators mode + maSepColStates = mxGrid->GetColumnStates(); + // switch to fixed width mode + mbFixedMode = true; + // reset and reinitialize controls + mxGrid->DisableRepaint(); + mxGrid->Execute( CSVCMD_SETLINEOFFSET, 0 ); + mxGrid->Execute( CSVCMD_SETPOSCOUNT, mnFixedWidth ); + mxGrid->SetSplits( mxRuler->GetSplits() ); + mxGrid->SetColumnStates( maFixColStates ); + InitControls(); + mxGrid->EnableRepaint(); } void ScCsvTableBox::Init() diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx index 04fbc91ecddb..07515d0914d0 100644 --- a/sc/source/ui/dbgui/dbnamdlg.cxx +++ b/sc/source/ui/dbgui/dbnamdlg.cxx @@ -280,20 +280,20 @@ void ScDbNameDlg::SetInfoStrings( const ScDBData* pDBData ) void ScDbNameDlg::SetReference( const ScRange& rRef, ScDocument& rDocP ) { - if (m_xEdAssign->GetWidget()->get_sensitive()) - { - if ( rRef.aStart != rRef.aEnd ) - RefInputStart(m_xEdAssign.get()); + if (!m_xEdAssign->GetWidget()->get_sensitive()) + return; - theCurArea = rRef; + if ( rRef.aStart != rRef.aEnd ) + RefInputStart(m_xEdAssign.get()); - OUString aRefStr(theCurArea.Format(rDocP, ScRefFlags::RANGE_ABS_3D, aAddrDetails)); - m_xEdAssign->SetRefString( aRefStr ); - m_xOptions->set_sensitive(true); - m_xBtnAdd->set_sensitive(true); - bSaved = true; - pSaveObj->Save(); - } + theCurArea = rRef; + + OUString aRefStr(theCurArea.Format(rDocP, ScRefFlags::RANGE_ABS_3D, aAddrDetails)); + m_xEdAssign->SetRefString( aRefStr ); + m_xOptions->set_sensitive(true); + m_xBtnAdd->set_sensitive(true); + bSaved = true; + pSaveObj->Save(); } void ScDbNameDlg::Close() @@ -404,83 +404,83 @@ IMPL_LINK_NOARG(ScDbNameDlg, AddBtnHdl, weld::Button&, void) OUString aNewName = comphelper::string::strip(m_xEdName->get_active_text(), ' '); OUString aNewArea = m_xEdAssign->GetText(); - if ( !aNewName.isEmpty() && !aNewArea.isEmpty() ) + if ( aNewName.isEmpty() || aNewArea.isEmpty() ) + return; + + if ( ScRangeData::IsNameValid( aNewName, &rDoc ) == ScRangeData::NAME_VALID && aNewName != STR_DB_LOCAL_NONAME ) { - if ( ScRangeData::IsNameValid( aNewName, &rDoc ) == ScRangeData::NAME_VALID && aNewName != STR_DB_LOCAL_NONAME ) + // because editing can be done now, parsing is needed first + ScRange aTmpRange; + OUString aText = m_xEdAssign->GetText(); + if ( aTmpRange.ParseAny( aText, &rDoc, aAddrDetails ) & ScRefFlags::VALID ) { - // because editing can be done now, parsing is needed first - ScRange aTmpRange; - OUString aText = m_xEdAssign->GetText(); - if ( aTmpRange.ParseAny( aText, &rDoc, aAddrDetails ) & ScRefFlags::VALID ) - { - theCurArea = aTmpRange; - ScAddress aStart = theCurArea.aStart; - ScAddress aEnd = theCurArea.aEnd; + theCurArea = aTmpRange; + ScAddress aStart = theCurArea.aStart; + ScAddress aEnd = theCurArea.aEnd; - ScDBData* pOldEntry = aLocalDbCol.getNamedDBs().findByUpperName(ScGlobal::getCharClassPtr()->uppercase(aNewName)); - if (pOldEntry) - { - // modify area - - pOldEntry->MoveTo( aStart.Tab(), aStart.Col(), aStart.Row(), - aEnd.Col(), aEnd.Row() ); - pOldEntry->SetByRow( true ); - pOldEntry->SetHeader( m_xBtnHeader->get_active() ); - pOldEntry->SetTotals( m_xBtnTotals->get_active() ); - pOldEntry->SetDoSize( m_xBtnDoSize->get_active() ); - pOldEntry->SetKeepFmt( m_xBtnKeepFmt->get_active() ); - pOldEntry->SetStripData( m_xBtnStripData->get_active() ); - } - else - { - // insert new area - - std::unique_ptr<ScDBData> pNewEntry(new ScDBData( aNewName, aStart.Tab(), - aStart.Col(), aStart.Row(), - aEnd.Col(), aEnd.Row(), - true, m_xBtnHeader->get_active(), - m_xBtnTotals->get_active() )); - pNewEntry->SetDoSize( m_xBtnDoSize->get_active() ); - pNewEntry->SetKeepFmt( m_xBtnKeepFmt->get_active() ); - pNewEntry->SetStripData( m_xBtnStripData->get_active() ); - - bool ins = aLocalDbCol.getNamedDBs().insert(std::move(pNewEntry)); - assert(ins); (void)ins; - } - - UpdateNames(); - - m_xEdName->set_entry_text( EMPTY_OUSTRING ); - m_xEdName->grab_focus(); - m_xBtnAdd->set_label( aStrAdd ); - m_xBtnAdd->set_sensitive(false); - m_xBtnRemove->set_sensitive(false); - m_xEdAssign->SetText( EMPTY_OUSTRING ); - m_xBtnHeader->set_active(true); // Default: with column headers - m_xBtnTotals->set_active( false ); // Default: without totals row - m_xBtnDoSize->set_active( false ); - m_xBtnKeepFmt->set_active( false ); - m_xBtnStripData->set_active( false ); - SetInfoStrings( nullptr ); // empty - theCurArea = ScRange(); - bSaved = true; - pSaveObj->Save(); - NameModifyHdl( *m_xEdName ); + ScDBData* pOldEntry = aLocalDbCol.getNamedDBs().findByUpperName(ScGlobal::getCharClassPtr()->uppercase(aNewName)); + if (pOldEntry) + { + // modify area + + pOldEntry->MoveTo( aStart.Tab(), aStart.Col(), aStart.Row(), + aEnd.Col(), aEnd.Row() ); + pOldEntry->SetByRow( true ); + pOldEntry->SetHeader( m_xBtnHeader->get_active() ); + pOldEntry->SetTotals( m_xBtnTotals->get_active() ); + pOldEntry->SetDoSize( m_xBtnDoSize->get_active() ); + pOldEntry->SetKeepFmt( m_xBtnKeepFmt->get_active() ); + pOldEntry->SetStripData( m_xBtnStripData->get_active() ); } else { - ERRORBOX(m_xDialog.get(), aStrInvalid); - m_xEdAssign->SelectAll(); - m_xEdAssign->GrabFocus(); + // insert new area + + std::unique_ptr<ScDBData> pNewEntry(new ScDBData( aNewName, aStart.Tab(), + aStart.Col(), aStart.Row(), + aEnd.Col(), aEnd.Row(), + true, m_xBtnHeader->get_active(), + m_xBtnTotals->get_active() )); + pNewEntry->SetDoSize( m_xBtnDoSize->get_active() ); + pNewEntry->SetKeepFmt( m_xBtnKeepFmt->get_active() ); + pNewEntry->SetStripData( m_xBtnStripData->get_active() ); + + bool ins = aLocalDbCol.getNamedDBs().insert(std::move(pNewEntry)); + assert(ins); (void)ins; } + + UpdateNames(); + + m_xEdName->set_entry_text( EMPTY_OUSTRING ); + m_xEdName->grab_focus(); + m_xBtnAdd->set_label( aStrAdd ); + m_xBtnAdd->set_sensitive(false); + m_xBtnRemove->set_sensitive(false); + m_xEdAssign->SetText( EMPTY_OUSTRING ); + m_xBtnHeader->set_active(true); // Default: with column headers + m_xBtnTotals->set_active( false ); // Default: without totals row + m_xBtnDoSize->set_active( false ); + m_xBtnKeepFmt->set_active( false ); + m_xBtnStripData->set_active( false ); + SetInfoStrings( nullptr ); // empty + theCurArea = ScRange(); + bSaved = true; + pSaveObj->Save(); + NameModifyHdl( *m_xEdName ); } else { - ERRORBOX(m_xDialog.get(), ScResId(STR_INVALIDNAME)); - m_xEdName->select_entry_region(0, -1); - m_xEdName->grab_focus(); + ERRORBOX(m_xDialog.get(), aStrInvalid); + m_xEdAssign->SelectAll(); + m_xEdAssign->GrabFocus(); } } + else + { + ERRORBOX(m_xDialog.get(), ScResId(STR_INVALIDNAME)); + m_xEdName->select_entry_region(0, -1); + m_xEdName->grab_focus(); + } } namespace { @@ -505,45 +505,45 @@ IMPL_LINK_NOARG(ScDbNameDlg, RemoveBtnHdl, weld::Button&, void) ScDBCollection::NamedDBs::iterator itr = ::std::find_if(rDBs.begin(), rDBs.end(), FindByName(aStrEntry)); - if (itr != rDBs.end()) - { - OUString aStrDelMsg = ScResId( STR_QUERY_DELENTRY ); - OUString sMsg{ aStrDelMsg.getToken(0, '#') + aStrEntry + aStrDelMsg.getToken(1, '#') }; - std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(), - VclMessageType::Question, VclButtonsType::YesNo, - sMsg)); - xQueryBox->set_default_response(RET_YES); - if (RET_YES == xQueryBox->run()) - { - SCTAB nTab; - SCCOL nColStart, nColEnd; - SCROW nRowStart, nRowEnd; - (*itr)->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd ); - aRemoveList.emplace_back( ScAddress( nColStart, nRowStart, nTab ), - ScAddress( nColEnd, nRowEnd, nTab ) ); + if (itr == rDBs.end()) + return; - rDBs.erase(itr); + OUString aStrDelMsg = ScResId( STR_QUERY_DELENTRY ); + OUString sMsg{ aStrDelMsg.getToken(0, '#') + aStrEntry + aStrDelMsg.getToken(1, '#') }; + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(), + VclMessageType::Question, VclButtonsType::YesNo, + sMsg)); + xQueryBox->set_default_response(RET_YES); + if (RET_YES != xQueryBox->run()) + return; - UpdateNames(); + SCTAB nTab; + SCCOL nColStart, nColEnd; + SCROW nRowStart, nRowEnd; + (*itr)->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd ); + aRemoveList.emplace_back( ScAddress( nColStart, nRowStart, nTab ), + ScAddress( nColEnd, nRowEnd, nTab ) ); - m_xEdName->set_entry_text( EMPTY_OUSTRING ); - m_xEdName->grab_focus(); - m_xBtnAdd->set_label( aStrAdd ); - m_xBtnAdd->set_sensitive(false); - m_xBtnRemove->set_sensitive(false); - m_xEdAssign->SetText( EMPTY_OUSTRING ); - theCurArea = ScRange(); - m_xBtnHeader->set_active(true); // Default: with column headers - m_xBtnTotals->set_active( false ); // Default: without totals row - m_xBtnDoSize->set_active( false ); - m_xBtnKeepFmt->set_active( false ); - m_xBtnStripData->set_active( false ); - SetInfoStrings( nullptr ); // empty - bSaved=false; - pSaveObj->Restore(); - NameModifyHdl( *m_xEdName ); - } - } + rDBs.erase(itr); + + UpdateNames(); + + m_xEdName->set_entry_text( EMPTY_OUSTRING ); + m_xEdName->grab_focus(); + m_xBtnAdd->set_label( aStrAdd ); + m_xBtnAdd->set_sensitive(false); + m_xBtnRemove->set_sensitive(false); + m_xEdAssign->SetText( EMPTY_OUSTRING ); + theCurArea = ScRange(); + m_xBtnHeader->set_active(true); // Default: with column headers + m_xBtnTotals->set_active( false ); // Default: without totals row + m_xBtnDoSize->set_active( false ); + m_xBtnKeepFmt->set_active( false ); + m_xBtnStripData->set_active( false ); + SetInfoStrings( nullptr ); // empty + bSaved=false; + pSaveObj->Restore(); + NameModifyHdl( *m_xEdName ); } IMPL_LINK_NOARG(ScDbNameDlg, NameModifyHdl, weld::ComboBox&, void) diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx index 22cc256baf74..ff1f87137095 100644 --- a/sc/source/ui/dbgui/filtdlg.cxx +++ b/sc/source/ui/dbgui/filtdlg.cxx @@ -634,57 +634,57 @@ bool ScFilterDlg::IsRefInputMode() const IMPL_LINK( ScFilterDlg, BtnClearHdl, weld::Button&, rBtn, void ) { - if ( &rBtn == m_xBtnClear.get() ) - { - // scroll to the top - m_xScrollBar->vadjustment_set_value(0); - size_t nOffset = 0; - RefreshEditRow( nOffset); - - // clear all conditions - m_xLbConnect1->set_active(-1); - m_xLbConnect2->set_active(-1); - m_xLbConnect3->set_active(-1); - m_xLbConnect4->set_active(-1); - m_xLbField1->set_active(0); - m_xLbField2->set_active(0); - m_xLbField3->set_active(0); - m_xLbField4->set_active(0); - m_xLbCond1->set_active(0); - m_xLbCond2->set_active(0); - m_xLbCond3->set_active(0); - m_xLbCond4->set_active(0); - ClearValueList( 1 ); - ClearValueList( 2 ); - ClearValueList( 3 ); - ClearValueList( 4 ); - - // disable fields for second row onward - m_xLbConnect2->set_sensitive(false); - m_xLbConnect3->set_sensitive(false); - m_xLbConnect4->set_sensitive(false); - m_xLbField2->set_sensitive(false); - m_xLbField3->set_sensitive(false); - m_xLbField4->set_sensitive(false); - m_xLbCond2->set_sensitive(false); - m_xLbCond3->set_sensitive(false); - m_xLbCond4->set_sensitive(false); - m_xEdVal2->set_sensitive(false); - m_xEdVal3->set_sensitive(false); - m_xEdVal4->set_sensitive(false); + if ( &rBtn != m_xBtnClear.get() ) + return; - // clear query data objects - SCSIZE nCount = theQueryData.GetEntryCount(); - if (maRefreshExceptQuery.size() < nCount + 1) - maRefreshExceptQuery.resize(nCount + 1, false); - for (SCSIZE i = 0; i < nCount; ++i) - { - theQueryData.GetEntry(i).bDoQuery = false; - maRefreshExceptQuery[i] = false; - theQueryData.GetEntry(i).nField = static_cast<SCCOL>(0); - } - maRefreshExceptQuery[0] = true; + // scroll to the top + m_xScrollBar->vadjustment_set_value(0); + size_t nOffset = 0; + RefreshEditRow( nOffset); + + // clear all conditions + m_xLbConnect1->set_active(-1); + m_xLbConnect2->set_active(-1); + m_xLbConnect3->set_active(-1); + m_xLbConnect4->set_active(-1); + m_xLbField1->set_active(0); + m_xLbField2->set_active(0); + m_xLbField3->set_active(0); + m_xLbField4->set_active(0); + m_xLbCond1->set_active(0); + m_xLbCond2->set_active(0); + m_xLbCond3->set_active(0); + m_xLbCond4->set_active(0); + ClearValueList( 1 ); + ClearValueList( 2 ); + ClearValueList( 3 ); + ClearValueList( 4 ); + + // disable fields for second row onward + m_xLbConnect2->set_sensitive(false); + m_xLbConnect3->set_sensitive(false); + m_xLbConnect4->set_sensitive(false); + m_xLbField2->set_sensitive(false); + m_xLbField3->set_sensitive(false); + m_xLbField4->set_sensitive(false); + m_xLbCond2->set_sensitive(false); + m_xLbCond3->set_sensitive(false); + m_xLbCond4->set_sensitive(false); + m_xEdVal2->set_sensitive(false); + m_xEdVal3->set_sensitive(false); + m_xEdVal4->set_sensitive(false); + + // clear query data objects + SCSIZE nCount = theQueryData.GetEntryCount(); + if (maRefreshExceptQuery.size() < nCount + 1) + maRefreshExceptQuery.resize(nCount + 1, false); + for (SCSIZE i = 0; i < nCount; ++i) + { + theQueryData.GetEntry(i).bDoQuery = false; + maRefreshExceptQuery[i] = false; + theQueryData.GetEntry(i).nField = static_cast<SCCOL>(0); } + maRefreshExceptQuery[0] = true; } IMPL_LINK( ScFilterDlg, EndDlgHdl, weld::Button&, rBtn, void ) @@ -1083,39 +1083,39 @@ IMPL_LINK( ScFilterDlg, ValModifyHdl, weld::ComboBox&, rEd, void ) bool bDoThis = (pLbField->get_active() != 0); rEntry.bDoQuery = bDoThis; - if ( rEntry.bDoQuery || maRefreshExceptQuery[nQE] ) + if ( !(rEntry.bDoQuery || maRefreshExceptQuery[nQE]) ) + return; + + bool bByEmptyOrNotByEmpty = false; + if ( aStrEmpty == aStrVal ) { - bool bByEmptyOrNotByEmpty = false; - if ( aStrEmpty == aStrVal ) - { - bByEmptyOrNotByEmpty = true; - rEntry.SetQueryByEmpty(); - } - else if ( aStrNotEmpty == aStrVal ) - { - bByEmptyOrNotByEmpty = true; - rEntry.SetQueryByNonEmpty(); - } - else - { - rItem.maString = pDoc->GetSharedStringPool().intern(aStrVal); - rItem.mfVal = 0.0; + bByEmptyOrNotByEmpty = true; + rEntry.SetQueryByEmpty(); + } + else if ( aStrNotEmpty == aStrVal ) + { + bByEmptyOrNotByEmpty = true; + rEntry.SetQueryByNonEmpty(); + } + else + { + rItem.maString = pDoc->GetSharedStringPool().intern(aStrVal); + rItem.mfVal = 0.0; - sal_uInt32 nIndex = 0; - bool bNumber = pDoc->GetFormatTable()->IsNumberFormat( - rItem.maString.getString(), nIndex, rItem.mfVal); - rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString; - } + sal_uInt32 nIndex = 0; + bool bNumber = pDoc->GetFormatTable()->IsNumberFormat( + rItem.maString.getString(), nIndex, rItem.mfVal); + rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString; + } - const sal_Int32 nField = pLbField->get_active(); - rEntry.nField = nField ? (theQueryData.nCol1 + - static_cast<SCCOL>(nField) - 1) : static_cast<SCCOL>(0); + const sal_Int32 nField = pLbField->get_active(); + rEntry.nField = nField ? (theQueryData.nCol1 + + static_cast<SCCOL>(nField) - 1) : static_cast<SCCOL>(0); - ScQueryOp eOp = static_cast<ScQueryOp>(pLbCond->get_active()); - rEntry.eOp = eOp; - if (maHasDates[nQE] && !bByEmptyOrNotByEmpty) - rItem.meType = ScQueryEntry::ByDate; - } + ScQueryOp eOp = static_cast<ScQueryOp>(pLbCond->get_active()); + rEntry.eOp = eOp; + if (maHasDates[nQE] && !bByEmptyOrNotByEmpty) + rItem.meType = ScQueryEntry::ByDate; } IMPL_LINK_NOARG(ScFilterDlg, ScrollHdl, weld::ScrolledWindow&, void) diff --git a/sc/source/ui/dbgui/foptmgr.cxx b/sc/source/ui/dbgui/foptmgr.cxx index adaeb0c8c51f..af13177bda8c 100644 --- a/sc/source/ui/dbgui/foptmgr.cxx +++ b/sc/source/ui/dbgui/foptmgr.cxx @@ -215,49 +215,49 @@ IMPL_LINK( ScFilterOptionsMgr, LbAreaSelHdl, weld::ComboBox&, rLb, void ) IMPL_LINK( ScFilterOptionsMgr, EdAreaModifyHdl, formula::RefEdit&, rEd, void ) { - if ( &rEd == pEdCopyArea ) + if ( &rEd != pEdCopyArea ) + return; + + OUString theCurPosStr = rEd.GetText(); + ScRefFlags nResult = ScAddress().Parse( theCurPosStr, pDoc, pDoc->GetAddressConvention() ); + + if ( (nResult & ScRefFlags::VALID) == ScRefFlags::VALID) { - OUString theCurPosStr = rEd.GetText(); - ScRefFlags nResult = ScAddress().Parse( theCurPosStr, pDoc, pDoc->GetAddressConvention() ); + const sal_Int32 nCount = pLbCopyArea->get_count(); - if ( (nResult & ScRefFlags::VALID) == ScRefFlags::VALID) + for ( sal_Int32 i=2; i<nCount; ++i ) { - const sal_Int32 nCount = pLbCopyArea->get_count(); - - for ( sal_Int32 i=2; i<nCount; ++i ) + OUString aStr = pLbCopyArea->get_id(i); + if (theCurPosStr == aStr) { - OUString aStr = pLbCopyArea->get_id(i); - if (theCurPosStr == aStr) - { - pLbCopyArea->set_active( i ); - return; - } + pLbCopyArea->set_active( i ); + return; } - } - pLbCopyArea->set_active( 0 ); + } + pLbCopyArea->set_active( 0 ); } IMPL_LINK( ScFilterOptionsMgr, BtnCopyResultHdl, weld::ToggleButton&, rBox, void ) { - if ( &rBox == pBtnCopyResult ) + if ( &rBox != pBtnCopyResult ) + return; + + if ( rBox.get_active() ) { - if ( rBox.get_active() ) - { - pBtnDestPers->set_sensitive(true); - pLbCopyArea->set_sensitive(true); - pEdCopyArea->GetWidget()->set_sensitive(true); - pRbCopyArea->GetWidget()->set_sensitive(true); - pEdCopyArea->GrabFocus(); - } - else - { - pBtnDestPers->set_sensitive(false); - pLbCopyArea->set_sensitive(false); - pEdCopyArea->GetWidget()->set_sensitive(false); - pRbCopyArea->GetWidget()->set_sensitive(false); - } + pBtnDestPers->set_sensitive(true); + pLbCopyArea->set_sensitive(true); + pEdCopyArea->GetWidget()->set_sensitive(true); + pRbCopyArea->GetWidget()->set_sensitive(true); + pEdCopyArea->GrabFocus(); + } + else + { + pBtnDestPers->set_sensitive(false); + pLbCopyArea->set_sensitive(false); + pEdCopyArea->GetWidget()->set_sensitive(false); + pRbCopyArea->GetWidget()->set_sensitive(false); } } diff --git a/sc/source/ui/dbgui/imoptdlg.cxx b/sc/source/ui/dbgui/imoptdlg.cxx index 4229c2a307a5..071f1b0257bc 100644 --- a/sc/source/ui/dbgui/imoptdlg.cxx +++ b/sc/source/ui/dbgui/imoptdlg.cxx @@ -44,39 +44,39 @@ ScImportOptions::ScImportOptions( const OUString& rStr ) bSaveFormulas = false; bRemoveSpace = false; sal_Int32 nTokenCount = comphelper::string::getTokenCount(rStr, ','); - if ( nTokenCount >= 3 ) - { - sal_Int32 nIdx{ 0 }; - // first 3 tokens: common - OUString aToken( rStr.getToken( 0, ',', nIdx ) ); - if( aToken.equalsIgnoreAsciiCase( pStrFix ) ) - bFixedWidth = true; - else - nFieldSepCode = ScAsciiOptions::GetWeightedFieldSep( aToken, true); - nTextSepCode = static_cast<sal_Unicode>(rStr.getToken(0, ',', nIdx).toInt32()); - aStrFont = rStr.getToken(0, ',', nIdx); - eCharSet = ScGlobal::GetCharsetValue(aStrFont); + if ( nTokenCount < 3 ) + return; + + sal_Int32 nIdx{ 0 }; + // first 3 tokens: common + OUString aToken( rStr.getToken( 0, ',', nIdx ) ); + if( aToken.equalsIgnoreAsciiCase( pStrFix ) ) + bFixedWidth = true; + else + nFieldSepCode = ScAsciiOptions::GetWeightedFieldSep( aToken, true); + nTextSepCode = static_cast<sal_Unicode>(rStr.getToken(0, ',', nIdx).toInt32()); + aStrFont = rStr.getToken(0, ',', nIdx); + eCharSet = ScGlobal::GetCharsetValue(aStrFont); - if ( nTokenCount == 4 ) - { - // compatibility with old options string: "Save as shown" as 4th token, numeric - bSaveAsShown = rStr.getToken(0, ',', nIdx).toInt32() != 0; - bQuoteAllText = true; // use old default then - } - else - { - // look at the same positions as in ScAsciiOptions - if ( nTokenCount >= 7 ) - bQuoteAllText = rStr.getToken(3, ',', nIdx) == "true"; // 7th token - if ( nTokenCount >= 8 ) - bSaveNumberAsSuch = rStr.getToken(0, ',', nIdx) == "true"; - if ( nTokenCount >= 9 ) - bSaveAsShown = rStr.getToken(0, ',', nIdx) == "true"; - if ( nTokenCount >= 10 ) - bSaveFormulas = rStr.getToken(0, ',', nIdx) == "true"; - if ( nTokenCount >= 11 ) - bRemoveSpace = rStr.getToken(0, ',', nIdx) == "true"; - } + if ( nTokenCount == 4 ) + { + // compatibility with old options string: "Save as shown" as 4th token, numeric + bSaveAsShown = rStr.getToken(0, ',', nIdx).toInt32() != 0; + bQuoteAllText = true; // use old default then + } + else + { + // look at the same positions as in ScAsciiOptions + if ( nTokenCount >= 7 ) + bQuoteAllText = rStr.getToken(3, ',', nIdx) == "true"; // 7th token + if ( nTokenCount >= 8 ) + bSaveNumberAsSuch = rStr.getToken(0, ',', nIdx) == "true"; + if ( nTokenCount >= 9 ) + bSaveAsShown = rStr.getToken(0, ',', nIdx) == "true"; + if ( nTokenCount >= 10 ) + bSaveFormulas = rStr.getToken(0, ',', nIdx) == "true"; + if ( nTokenCount >= 11 ) + bRemoveSpace = rStr.getToken(0, ',', nIdx) == "true"; } } diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx index b482588fbb18..4d966ce9ddea 100644 --- a/sc/source/ui/dbgui/sfiltdlg.cxx +++ b/sc/source/ui/dbgui/sfiltdlg.cxx @@ -197,21 +197,21 @@ void ScSpecialFilterDlg::Close() void ScSpecialFilterDlg::SetReference( const ScRange& rRef, ScDocument& rDocP ) { - if ( bRefInputMode && m_pRefInputEdit ) // only possible if in the reference edit mode - { - if ( rRef.aStart != rRef.aEnd ) - RefInputStart( m_pRefInputEdit ); + if ( !(bRefInputMode && m_pRefInputEdit) ) // only possible if in the reference edit mode + return; - OUString aRefStr; - const formula::FormulaGrammar::AddressConvention eConv = rDocP.GetAddressConvention(); + if ( rRef.aStart != rRef.aEnd ) + RefInputStart( m_pRefInputEdit ); - if (m_pRefInputEdit == m_xEdCopyArea.get()) - aRefStr = rRef.aStart.Format(ScRefFlags::ADDR_ABS_3D, &rDocP, eConv); - else if (m_pRefInputEdit == m_xEdFilterArea.get()) - aRefStr = rRef.Format(rDocP, ScRefFlags::RANGE_ABS_3D, eConv); + OUString aRefStr; + const formula::FormulaGrammar::AddressConvention eConv = rDocP.GetAddressConvention(); - m_pRefInputEdit->SetRefString( aRefStr ); - } + if (m_pRefInputEdit == m_xEdCopyArea.get()) + aRefStr = rRef.aStart.Format(ScRefFlags::ADDR_ABS_3D, &rDocP, eConv); + else if (m_pRefInputEdit == m_xEdFilterArea.get()) + aRefStr = rRef.Format(rDocP, ScRefFlags::RANGE_ABS_3D, eConv); + + m_pRefInputEdit->SetRefString( aRefStr ); } void ScSpecialFilterDlg::SetActive() @@ -371,23 +371,23 @@ IMPL_LINK_NOARG(ScSpecialFilterDlg, RefInputButtonHdl, formula::RefButton&, void void ScSpecialFilterDlg::RefInputHdl() { - if (m_xDialog->has_toplevel_focus()) + if (!m_xDialog->has_toplevel_focus()) + return; + + if( m_xEdCopyArea->GetWidget()->has_focus() || m_xRbCopyArea->GetWidget()->has_focus() ) { - if( m_xEdCopyArea->GetWidget()->has_focus() || m_xRbCopyArea->GetWidget()->has_focus() ) - { - m_pRefInputEdit = m_xEdCopyArea.get(); - bRefInputMode = true; - } - else if( m_xEdFilterArea->GetWidget()->has_focus() || m_xRbFilterArea->GetWidget()->has_focus() ) - { - m_pRefInputEdit = m_xEdFilterArea.get(); - bRefInputMode = true; - } - else if( bRefInputMode ) - { - m_pRefInputEdit = nullptr; - bRefInputMode = false; - } + m_pRefInputEdit = m_xEdCopyArea.get(); + bRefInputMode = true; + } + else if( m_xEdFilterArea->GetWidget()->has_focus() || m_xRbFilterArea->GetWidget()->has_focus() ) + { + m_pRefInputEdit = m_xEdFilterArea.get(); + bRefInputMode = true; + } + else if( bRefInputMode ) + { + m_pRefInputEdit = nullptr; + bRefInputMode = false; } } @@ -407,31 +407,31 @@ IMPL_LINK(ScSpecialFilterDlg, FilterAreaSelHdl, weld::ComboBox&, rLb, void) IMPL_LINK( ScSpecialFilterDlg, FilterAreaModHdl, formula::RefEdit&, rEd, void ) { - if (&rEd == m_xEdFilterArea.get()) + if (&rEd != m_xEdFilterArea.get()) + return; + + if ( pDoc && pViewData ) { - if ( pDoc && pViewData ) - { - OUString theCurAreaStr = rEd.GetText(); - ScRefFlags nResult = ScRange().Parse( theCurAreaStr, pDoc ); + OUString theCurAreaStr = rEd.GetText(); + ScRefFlags nResult = ScRange().Parse( theCurAreaStr, pDoc ); - if ( (nResult & ScRefFlags::VALID) == ScRefFlags::VALID ) + if ( (nResult & ScRefFlags::VALID) == ScRefFlags::VALID ) + { + const sal_Int32 nCount = m_xLbFilterArea->get_count(); + for (sal_Int32 i = 1; i < nCount; ++i) { - const sal_Int32 nCount = m_xLbFilterArea->get_count(); - for (sal_Int32 i = 1; i < nCount; ++i) + OUString aStr = m_xLbFilterArea->get_id(i); + if (theCurAreaStr == aStr) { - OUString aStr = m_xLbFilterArea->get_id(i); - if (theCurAreaStr == aStr) - { - m_xLbFilterArea->set_active( i ); - return; - } + m_xLbFilterArea->set_active( i ); + return; } - m_xLbFilterArea->set_active( 0 ); } - } - else m_xLbFilterArea->set_active( 0 ); + } } + else + m_xLbFilterArea->set_active( 0 ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx index 33d5fcd485a7..74b9fff08716 100644 --- a/sc/source/ui/dbgui/validate.cxx +++ b/sc/source/ui/dbgui/validate.cxx @@ -139,28 +139,29 @@ void ScTPValidationValue:: SetActiveHdl() void ScTPValidationValue::RefInputStartPreHdl( formula::RefEdit* pEdit, const formula::RefButton* pButton ) { - if (ScValidationDlg *pValidationDlg = GetValidationDlg()) - { - weld::Container* pNewParent = pValidationDlg->get_refinput_shrink_parent(); - if (pEdit == m_pRefEdit && pNewParent != m_pRefEditParent) - { - m_xRefGrid->move(m_pRefEdit->GetWidget(), pNewParent); - m_pRefEditParent = pNewParent; - } + ScValidationDlg *pValidationDlg = GetValidationDlg(); + if (!pValidationDlg) + return; - if (pNewParent != m_pBtnRefParent) - { - // if Edit SetParent but button not, the tab order will be - // incorrect, so move button anyway, and restore - // parent later in order to restore the tab order. But - // hide it if it's moved but unwanted. - m_xRefGrid->move(m_xBtnRef->GetWidget(), pNewParent); - m_xBtnRef->GetWidget()->set_visible(pButton == m_xBtnRef.get()); - m_pBtnRefParent = pNewParent; - } + weld::Container* pNewParent = pValidationDlg->get_refinput_shrink_parent(); + if (pEdit == m_pRefEdit && pNewParent != m_pRefEditParent) + { + m_xRefGrid->move(m_pRefEdit->GetWidget(), pNewParent); + m_pRefEditParent = pNewParent; + } - pNewParent->show(); + if (pNewParent != m_pBtnRefParent) + { + // if Edit SetParent but button not, the tab order will be + // incorrect, so move button anyway, and restore + // parent later in order to restore the tab order. But + // hide it if it's moved but unwanted. + m_xRefGrid->move(m_xBtnRef->GetWidget(), pNewParent); + m_xBtnRef->GetWidget()->set_visible(pButton == m_xBtnRef.get()); + m_pBtnRefParent = pNewParent; } + + pNewParent->show(); } void ScTPValidationValue::RefInputDonePostHdl() @@ -530,59 +531,61 @@ ScValidationDlg * ScTPValidationValue::GetValidationDlg() void ScTPValidationValue::SetupRefDlg() { - if( ScValidationDlg *pValidationDlg = GetValidationDlg() ) - { - if( pValidationDlg->SetupRefDlg() ) - { - pValidationDlg->SetHandler( this ); - pValidationDlg->SetSetRefHdl( static_cast<ScRefHandlerHelper::PFUNCSETREFHDLTYPE>( &ScTPValidationValue::SetReferenceHdl ) ); - pValidationDlg->SetSetActHdl( static_cast<ScRefHandlerHelper::PCOMMONHDLTYPE>( &ScTPValidationValue::SetActiveHdl ) ); - pValidationDlg->SetRefInputStartPreHdl( static_cast<ScRefHandlerHelper::PINPUTSTARTDLTYPE>( &ScTPValidationValue::RefInputStartPreHdl ) ); - pValidationDlg->SetRefInputDonePostHdl( static_cast<ScRefHandlerHelper::PCOMMONHDLTYPE>( &ScTPValidationValue::RefInputDonePostHdl ) ); + ScValidationDlg *pValidationDlg = GetValidationDlg(); + if( !pValidationDlg ) + return; - weld::Label* pLabel = nullptr; + if( !pValidationDlg->SetupRefDlg() ) + return; - if (m_xEdMax->GetWidget()->get_visible()) - { - m_pRefEdit = m_xEdMax.get(); - pLabel = m_xFtMax.get(); - } - else if (m_xEdMin->GetWidget()->get_visible()) - { - m_pRefEdit = m_xEdMin.get(); - pLabel = m_xFtMin.get(); - } + pValidationDlg->SetHandler( this ); + pValidationDlg->SetSetRefHdl( static_cast<ScRefHandlerHelper::PFUNCSETREFHDLTYPE>( &ScTPValidationValue::SetReferenceHdl ) ); + pValidationDlg->SetSetActHdl( static_cast<ScRefHandlerHelper::PCOMMONHDLTYPE>( &ScTPValidationValue::SetActiveHdl ) ); + pValidationDlg->SetRefInputStartPreHdl( static_cast<ScRefHandlerHelper::PINPUTSTARTDLTYPE>( &ScTPValidationValue::RefInputStartPreHdl ) ); + pValidationDlg->SetRefInputDonePostHdl( static_cast<ScRefHandlerHelper::PCOMMONHDLTYPE>( &ScTPValidationValue::RefInputDonePostHdl ) ); - if (m_pRefEdit && !m_pRefEdit->GetWidget()->has_focus()) - m_pRefEdit->GrabFocus(); + weld::Label* pLabel = nullptr; - if( m_pRefEdit ) - m_pRefEdit->SetReferences( pValidationDlg, pLabel ); - - m_xBtnRef->SetReferences( pValidationDlg, m_pRefEdit ); - } + if (m_xEdMax->GetWidget()->get_visible()) + { + m_pRefEdit = m_xEdMax.get(); + pLabel = m_xFtMax.get(); + } + else if (m_xEdMin->GetWidget()->get_visible()) + { + m_pRefEdit = m_xEdMin.get(); + pLabel = m_xFtMin.get(); } + + if (m_pRefEdit && !m_pRefEdit->GetWidget()->has_focus()) + m_pRefEdit->GrabFocus(); + + if( m_pRefEdit ) + m_pRefEdit->SetReferences( pValidationDlg, pLabel ); + + m_xBtnRef->SetReferences( pValidationDlg, m_pRefEdit ); } void ScTPValidationValue::RemoveRefDlg(bool bRestoreModal) { - if( ScValidationDlg *pValidationDlg = GetValidationDlg() ) - { - if( pValidationDlg->RemoveRefDlg(bRestoreModal) ) - { - pValidationDlg->SetHandler( nullptr ); - pValidationDlg->SetSetRefHdl( nullptr ); - pValidationDlg->SetSetActHdl( nullptr ); - pValidationDlg->SetRefInputStartPreHdl( nullptr ); - pValidationDlg->SetRefInputDonePostHdl( nullptr ); + ScValidationDlg *pValidationDlg = GetValidationDlg(); + if( !pValidationDlg ) + return; - if( m_pRefEdit ) - m_pRefEdit->SetReferences( nullptr, nullptr ); - m_pRefEdit = nullptr; + if( !pValidationDlg->RemoveRefDlg(bRestoreModal) ) + return; - m_xBtnRef->SetReferences( nullptr, nullptr ); - } - } + pValidationDlg->SetHandler( nullptr ); + pValidationDlg->SetSetRefHdl( nullptr ); + pValidationDlg->SetSetActHdl( nullptr ); + pValidationDlg->SetRefInputStartPreHdl( nullptr ); + pValidationDlg->SetRefInputDonePostHdl( nullptr ); + + if( m_pRefEdit ) + m_pRefEdit->SetReferences( nullptr, nullptr ); + m_pRefEdit = nullptr; + + m_xBtnRef->SetReferences( nullptr, nullptr ); } IMPL_LINK_NOARG(ScTPValidationValue, EditSetFocusHdl, formula::RefEdit&, void) diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index d1e14561d4b5..eee2d68010cb 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -214,31 +214,31 @@ void ScDBDocFunc::ModifyDBData( const ScDBData& rNewData ) else pData = pDocColl->getNamedDBs().findByUpperName(rNewData.GetUpperName()); - if (pData) - { - ScDocShellModificator aModificator( rDocShell ); - ScRange aOldRange, aNewRange; - pData->GetArea(aOldRange); - rNewData.GetArea(aNewRange); - bool bAreaChanged = ( aOldRange != aNewRange ); // then a recompilation is needed + if (!pData) + return; - std::unique_ptr<ScDBCollection> pUndoColl; - if (bUndo) - pUndoColl.reset( new ScDBCollection( *pDocColl ) ); + ScDocShellModificator aModificator( rDocShell ); + ScRange aOldRange, aNewRange; + pData->GetArea(aOldRange); + rNewData.GetArea(aNewRange); + bool bAreaChanged = ( aOldRange != aNewRange ); // then a recompilation is needed - *pData = rNewData; - if (bAreaChanged) - rDoc.CompileDBFormula(); + std::unique_ptr<ScDBCollection> pUndoColl; + if (bUndo) + pUndoColl.reset( new ScDBCollection( *pDocColl ) ); - if (bUndo) - { - rDocShell.GetUndoManager()->AddUndoAction( - std::make_unique<ScUndoDBData>( &rDocShell, std::move(pUndoColl), - std::make_unique<ScDBCollection>( *pDocColl ) ) ); - } + *pData = rNewData; + if (bAreaChanged) + rDoc.CompileDBFormula(); - aModificator.SetDocumentModified(); + if (bUndo) + { + rDocShell.GetUndoManager()->AddUndoAction( + std::make_unique<ScUndoDBData>( &rDocShell, std::move(pUndoColl), + std::make_unique<ScDBCollection>( *pDocColl ) ) ); } + + aModificator.SetDocumentModified(); } void ScDBDocFunc::ModifyAllDBData( const ScDBCollection& rNewColl, const std::vector<ScRange>& rDelAreaList ) @@ -1027,115 +1027,115 @@ void ScDBDocFunc::DoSubTotals( SCTAB nTab, const ScSubTotalParam& rParam, } } - if (bOk) - { - weld::WaitObject aWait( ScDocShell::GetActiveDialogParent() ); - ScDocShellModificator aModificator( rDocShell ); + if (!bOk) + return; - ScSubTotalParam aNewParam( rParam ); // end of range is being changed - ScDocumentUniquePtr pUndoDoc; - std::unique_ptr<ScOutlineTable> pUndoTab; - std::unique_ptr<ScRangeName> pUndoRange; - std::unique_ptr<ScDBCollection> pUndoDB; + weld::WaitObject aWait( ScDocShell::GetActiveDialogParent() ); + ScDocShellModificator aModificator( rDocShell ); + + ScSubTotalParam aNewParam( rParam ); // end of range is being changed + ScDocumentUniquePtr pUndoDoc; + std::unique_ptr<ScOutlineTable> pUndoTab; + std::unique_ptr<ScRangeName> pUndoRange; + std::unique_ptr<ScDBCollection> pUndoDB; + + if (bRecord) // secure old data + { + bool bOldFilter = bDo && rParam.bDoSort; - if (bRecord) // secure old data + SCTAB nTabCount = rDoc.GetTableCount(); + pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); + ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab ); + if (pTable) { - bool bOldFilter = bDo && rParam.bDoSort; + pUndoTab.reset(new ScOutlineTable( *pTable )); - SCTAB nTabCount = rDoc.GetTableCount(); - pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); - ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab ); - if (pTable) - { - pUndoTab.reset(new ScOutlineTable( *pTable )); + // column/row state + SCCOLROW nOutStartCol, nOutEndCol; + SCCOLROW nOutStartRow, nOutEndRow; + pTable->GetColArray().GetRange( nOutStartCol, nOutEndCol ); + pTable->GetRowArray().GetRange( nOutStartRow, nOutEndRow ); - // column/row state - SCCOLROW nOutStartCol, nOutEndCol; - SCCOLROW nOutStartRow, nOutEndRow; - pTable->GetColArray().GetRange( nOutStartCol, nOutEndCol ); - pTable->GetRowArray().GetRange( nOutStartRow, nOutEndRow ); + pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true ); + rDoc.CopyToDocument(static_cast<SCCOL>(nOutStartCol), 0, nTab, static_cast<SCCOL>(nOutEndCol), rDoc.MaxRow(), nTab, InsertDeleteFlags::NONE, false, *pUndoDoc); + rDoc.CopyToDocument(0, nOutStartRow, nTab, rDoc.MaxCol(), nOutEndRow, nTab, InsertDeleteFlags::NONE, false, *pUndoDoc); + } + else + pUndoDoc->InitUndo( &rDoc, nTab, nTab, false, bOldFilter ); - pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true ); - rDoc.CopyToDocument(static_cast<SCCOL>(nOutStartCol), 0, nTab, static_cast<SCCOL>(nOutEndCol), rDoc.MaxRow(), nTab, InsertDeleteFlags::NONE, false, *pUndoDoc); - rDoc.CopyToDocument(0, nOutStartRow, nTab, rDoc.MaxCol(), nOutEndRow, nTab, InsertDeleteFlags::NONE, false, *pUndoDoc); - } - else - pUndoDoc->InitUndo( &rDoc, nTab, nTab, false, bOldFilter ); + // secure data range - incl. filtering result + rDoc.CopyToDocument(0, rParam.nRow1+1,nTab, rDoc.MaxCol(),rParam.nRow2,nTab, + InsertDeleteFlags::ALL, false, *pUndoDoc); - // secure data range - incl. filtering result - rDoc.CopyToDocument(0, rParam.nRow1+1,nTab, rDoc.MaxCol(),rParam.nRow2,nTab, - InsertDeleteFlags::ALL, false, *pUndoDoc); + // all formulas because of references + rDoc.CopyToDocument(0, 0, 0, rDoc.MaxCol(),rDoc.MaxRow(),nTabCount-1, + InsertDeleteFlags::FORMULA, false, *pUndoDoc); - // all formulas because of references - rDoc.CopyToDocument(0, 0, 0, rDoc.MaxCol(),rDoc.MaxRow(),nTabCount-1, - InsertDeleteFlags::FORMULA, false, *pUndoDoc); - - // ranges of DB and other - ScRangeName* pDocRange = rDoc.GetRangeName(); - if (!pDocRange->empty()) - pUndoRange.reset(new ScRangeName( *pDocRange )); - ScDBCollection* pDocDB = rDoc.GetDBCollection(); - if (!pDocDB->empty()) - pUndoDB.reset(new ScDBCollection( *pDocDB )); - } + // ranges of DB and other + ScRangeName* pDocRange = rDoc.GetRangeName(); + if (!pDocRange->empty()) + pUndoRange.reset(new ScRangeName( *pDocRange )); + ScDBCollection* pDocDB = rDoc.GetDBCollection(); + if (!pDocDB->empty()) + pUndoDB.reset(new ScDBCollection( *pDocDB )); + } // rDoc.SetOutlineTable( nTab, NULL ); - ScOutlineTable* pOut = rDoc.GetOutlineTable( nTab ); - if (pOut) - pOut->GetRowArray().RemoveAll(); // only delete row outlines - - if (rParam.bReplace) - rDoc.RemoveSubTotals( nTab, aNewParam ); - bool bSuccess = true; - if (bDo) - { - // sort - if ( rParam.bDoSort ) - { - pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 ); + ScOutlineTable* pOut = rDoc.GetOutlineTable( nTab ); + if (pOut) + pOut->GetRowArray().RemoveAll(); // only delete row outlines - // set partial result field to before the sorting - // (Duplicates are omitted, so can be called again) + if (rParam.bReplace) + rDoc.RemoveSubTotals( nTab, aNewParam ); + bool bSuccess = true; + if (bDo) + { + // sort + if ( rParam.bDoSort ) + { + pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 ); - ScSortParam aOldSort; - pDBData->GetSortParam( aOldSort ); - ScSortParam aSortParam( aNewParam, aOldSort ); - Sort( nTab, aSortParam, false, false, bApi ); - } + // set partial result field to before the sorting + // (Duplicates are omitted, so can be called again) - bSuccess = rDoc.DoSubTotals( nTab, aNewParam ); - rDoc.SetDrawPageSize(nTab); + ScSortParam aOldSort; + pDBData->GetSortParam( aOldSort ); + ScSortParam aSortParam( aNewParam, aOldSort ); + Sort( nTab, aSortParam, false, false, bApi ); } - ScRange aDirtyRange( aNewParam.nCol1, aNewParam.nRow1, nTab, - aNewParam.nCol2, aNewParam.nRow2, nTab ); - rDoc.SetDirty( aDirtyRange, true ); - if (bRecord) - { + bSuccess = rDoc.DoSubTotals( nTab, aNewParam ); + rDoc.SetDrawPageSize(nTab); + } + ScRange aDirtyRange( aNewParam.nCol1, aNewParam.nRow1, nTab, + aNewParam.nCol2, aNewParam.nRow2, nTab ); + rDoc.SetDirty( aDirtyRange, true ); + + if (bRecord) + { // ScDBData* pUndoDBData = pDBData ? new ScDBData( *pDBData ) : NULL; - rDocShell.GetUndoManager()->AddUndoAction( - std::make_unique<ScUndoSubTotals>( &rDocShell, nTab, - rParam, aNewParam.nRow2, - std::move(pUndoDoc), std::move(pUndoTab), // pUndoDBData, - std::move(pUndoRange), std::move(pUndoDB) ) ); - } + rDocShell.GetUndoManager()->AddUndoAction( + std::make_unique<ScUndoSubTotals>( &rDocShell, nTab, + rParam, aNewParam.nRow2, + std::move(pUndoDoc), std::move(pUndoTab), // pUndoDBData, + std::move(pUndoRange), std::move(pUndoDB) ) ); + } - if (!bSuccess) - { - // "Cannot insert rows" - if (!bApi) - rDocShell.ErrorMessage(STR_MSSG_DOSUBTOTALS_2); - } + if (!bSuccess) + { + // "Cannot insert rows" + if (!bApi) + rDocShell.ErrorMessage(STR_MSSG_DOSUBTOTALS_2); + } - // memorize - pDBData->SetSubTotalParam( aNewParam ); - pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 ); - rDoc.CompileDBFormula(); + // memorize + pDBData->SetSubTotalParam( aNewParam ); + pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 ); + rDoc.CompileDBFormula(); - rDocShell.PostPaint(ScRange(0, 0, nTab, rDoc.MaxCol(),rDoc.MaxRow(),nTab), - PaintPartFlags::Grid | PaintPartFlags::Left | PaintPartFlags::Top | PaintPartFlags::Size); - aModificator.SetDocumentModified(); - } + rDocShell.PostPaint(ScRange(0, 0, nTab, rDoc.MaxCol(),rDoc.MaxRow(),nTab), + PaintPartFlags::Grid | PaintPartFlags::Left | PaintPartFlags::Top | PaintPartFlags::Size); + aModificator.SetDocumentModified(); } namespace { @@ -1709,23 +1709,23 @@ void ScDBDocFunc::UpdateImport( const OUString& rTarget, const svx::ODataAccessD // repeat DB operations ScTabViewShell* pViewSh = rDocShell.GetBestViewShell(); - if (pViewSh) - { - ScRange aRange; - pData->GetArea(aRange); - pViewSh->MarkRange(aRange); // select + if (!pViewSh) + return; - if ( bContinue ) // error at import -> abort - { - // internal operations, if some are saved + ScRange aRange; + pData->GetArea(aRange); + pViewSh->MarkRange(aRange); // select - if ( pData->HasQueryParam() || pData->HasSortParam() || pData->HasSubTotalParam() ) - pViewSh->RepeatDB(); + if ( bContinue ) // error at import -> abort + { + // internal operations, if some are saved - // pivot tables which have the range as source data + if ( pData->HasQueryParam() || pData->HasSortParam() || pData->HasSubTotalParam() ) + pViewSh->RepeatDB(); - rDocShell.RefreshPivotTables(aRange); - } + // pivot tables which have the range as source data + + rDocShell.RefreshPivotTables(aRange); } } diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx index c4960acce7b4..c99693dd00ec 100644 --- a/sc/source/ui/docshell/dbdocimp.cxx +++ b/sc/source/ui/docshell/dbdocimp.cxx @@ -80,27 +80,27 @@ void ScDBDocFunc::ShowInBeamer( const ScImportParam& rParam, const SfxViewFrame* uno::Reference<frame::XFrame> xBeamerFrame = xFrame->findFrame( "_beamer", frame::FrameSearchFlag::CHILDREN); - if (xBeamerFrame.is()) + if (!xBeamerFrame.is()) + return; + + uno::Reference<frame::XController> xController = xBeamerFrame->getController(); + uno::Reference<view::XSelectionSupplier> xControllerSelection(xController, uno::UNO_QUERY); + if (xControllerSelection.is()) { - uno::Reference<frame::XController> xController = xBeamerFrame->getController(); - uno::Reference<view::XSelectionSupplier> xControllerSelection(xController, uno::UNO_QUERY); - if (xControllerSelection.is()) - { - sal_Int32 nType = rParam.bSql ? sdb::CommandType::COMMAND : - ( (rParam.nType == ScDbQuery) ? sdb::CommandType::QUERY : - sdb::CommandType::TABLE ); + sal_Int32 nType = rParam.bSql ? sdb::CommandType::COMMAND : + ( (rParam.nType == ScDbQuery) ? sdb::CommandType::QUERY : + sdb::CommandType::TABLE ); - svx::ODataAccessDescriptor aSelection; - aSelection.setDataSource(rParam.aDBName); - aSelection[svx::DataAccessDescriptorProperty::Command] <<= rParam.aStatement; - aSelection[svx::DataAccessDescriptorProperty::CommandType] <<= nType; + svx::ODataAccessDescriptor aSelection; + aSelection.setDataSource(rParam.aDBName); + aSelection[svx::DataAccessDescriptorProperty::Command] <<= rParam.aStatement; + aSelection[svx::DataAccessDescriptorProperty::CommandType] <<= nType; - xControllerSelection->select(uno::makeAny(aSelection.createPropertyValueSequence())); - } - else - { - OSL_FAIL("no selection supplier in the beamer!"); - } + xControllerSelection->select(uno::makeAny(aSelection.createPropertyValueSequence())); + } + else + { + OSL_FAIL("no selection supplier in the beamer!"); } } diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 587aeb18509e..58252c418227 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -1106,19 +1106,19 @@ bool ScDocFunc::SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCel void ScDocFunc::NotifyInputHandler( const ScAddress& rPos ) { ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); - if ( pViewSh && pViewSh->GetViewData().GetDocShell() == &rDocShell ) + if ( !(pViewSh && pViewSh->GetViewData().GetDocShell() == &rDocShell) ) + return; + + ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(); + if ( pInputHdl && pInputHdl->GetCursorPos() == rPos ) { - ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(); - if ( pInputHdl && pInputHdl->GetCursorPos() == rPos ) - { - bool bIsEditMode(pInputHdl->IsEditMode()); + bool bIsEditMode(pInputHdl->IsEditMode()); - // set modified if in editmode, because so the string is not set in the InputWindow like in the cell - // (the cell shows the same like the InputWindow) - if (bIsEditMode) - pInputHdl->SetModified(); - pViewSh->UpdateInputHandler(false, !bIsEditMode); - } + // set modified if in editmode, because so the string is not set in the InputWindow like in the cell + // (the cell shows the same like the InputWindow) + if (bIsEditMode) + pInputHdl->SetModified(); + pViewSh->UpdateInputHandler(false, !bIsEditMode); } } @@ -1200,20 +1200,20 @@ void ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, bRet = SetStringCell(rPos, aText, !bApi); } - if ( bRet && aTester.NeedsCellAttr() ) + if ( !(bRet && aTester.NeedsCellAttr()) ) + return; + + const SfxItemSet& rEditAttr = aTester.GetAttribs(); + ScPatternAttr aPattern( rDoc.GetPool() ); + aPattern.GetFromEditItemSet( &rEditAttr ); + aPattern.DeleteUnchanged( rDoc.GetPattern( rPos.Col(), rPos.Row(), rPos.Tab() ) ); + aPattern.GetItemSet().ClearItem( ATTR_HOR_JUSTIFY ); // wasn't removed above if no edit object + if ( aPattern.GetItemSet().Count() > 0 ) { - const SfxItemSet& rEditAttr = aTester.GetAttribs(); - ScPatternAttr aPattern( rDoc.GetPool() ); - aPattern.GetFromEditItemSet( &rEditAttr ); - aPattern.DeleteUnchanged( rDoc.GetPattern( rPos.Col(), rPos.Row(), rPos.Tab() ) ); - aPattern.GetItemSet().ClearItem( ATTR_HOR_JUSTIFY ); // wasn't removed above if no edit object - if ( aPattern.GetItemSet().Count() > 0 ) - { - ScMarkData aMark(rDoc.GetSheetLimits()); - aMark.SelectTable( rPos.Tab(), true ); - aMark.SetMarkArea( ScRange( rPos ) ); - ApplyAttributes( aMark, aPattern, bApi ); - } + ScMarkData aMark(rDoc.GetSheetLimits()); + aMark.SelectTable( rPos.Tab(), true ); + aMark.SetMarkArea( ScRange( rPos ) ); + ApplyAttributes( aMark, aPattern, bApi ); } } @@ -3191,28 +3191,27 @@ void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, const OUString& sSource ) uno::Any aLibAny = xLibContainer->getByName( aLibName ); aLibAny >>= xLib; } - if( xLib.is() ) - { - // if the Module with codename exists then find a new name - sal_Int32 nNum = 1; - OUString genModuleName = "Sheet1"; - while( xLib->hasByName( genModuleName ) ) - genModuleName = "Sheet" + OUString::number( ++nNum ); - - uno::Any aSourceAny; - OUString sTmpSource = sSource; - if ( sTmpSource.isEmpty() ) - sTmpSource = "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n"; - aSourceAny <<= sTmpSource; - uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); - if ( xVBAModuleInfo.is() ) - { - rDoc.SetCodeName( nTab, genModuleName ); - script::ModuleInfo sModuleInfo = lcl_InitModuleInfo( rDocSh, genModuleName ); - xVBAModuleInfo->insertModuleInfo( genModuleName, sModuleInfo ); - xLib->insertByName( genModuleName, aSourceAny ); - } + if( !xLib.is() ) + return; + // if the Module with codename exists then find a new name + sal_Int32 nNum = 1; + OUString genModuleName = "Sheet1"; + while( xLib->hasByName( genModuleName ) ) + genModuleName = "Sheet" + OUString::number( ++nNum ); + + uno::Any aSourceAny; + OUString sTmpSource = sSource; + if ( sTmpSource.isEmpty() ) + sTmpSource = "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n"; + aSourceAny <<= sTmpSource; + uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); + if ( xVBAModuleInfo.is() ) + { + rDoc.SetCodeName( nTab, genModuleName ); + script::ModuleInfo sModuleInfo = lcl_InitModuleInfo( rDocSh, genModuleName ); + xVBAModuleInfo->insertModuleInfo( genModuleName, sModuleInfo ); + xLib->insertByName( genModuleName, aSourceAny ); } } @@ -5205,60 +5204,60 @@ void ScDocFunc::CreateOneName( ScRangeName& rList, return; ScDocument& rDoc = rDocShell.GetDocument(); - if (!rDoc.HasValueData( nPosX, nPosY, nTab )) - { - OUString aName = rDoc.GetString(nPosX, nPosY, nTab); - ScRangeData::MakeValidName(&rDoc, aName); - if (!aName.isEmpty()) - { - OUString aContent(ScRange( nX1, nY1, nTab, nX2, nY2, nTab ).Format(rDoc, ScRefFlags::RANGE_ABS_3D)); + if (rDoc.HasValueData( nPosX, nPosY, nTab )) + return; - bool bInsert = false; - ScRangeData* pOld = rList.findByUpperName(ScGlobal::getCharClassPtr()->uppercase(aName)); - if (pOld) - { - OUString aOldStr; - pOld->GetSymbol( aOldStr ); - if (aOldStr != aContent) - { - if (bApi) - bInsert = true; // don't check via API - else - { - OUString aTemplate = ScResId( STR_CREATENAME_REPLACE ); - OUString aMessage = aTemplate.getToken( 0, '#' ) + aName + aTemplate.getToken( 1, '#' ); + OUString aName = rDoc.GetString(nPosX, nPosY, nTab); + ScRangeData::MakeValidName(&rDoc, aName); + if (aName.isEmpty()) + return; - std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(ScDocShell::GetActiveDialogParent(), - VclMessageType::Question, VclButtonsType::YesNo, - aMessage)); - xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL); - xQueryBox->set_default_response(RET_YES); + OUString aContent(ScRange( nX1, nY1, nTab, nX2, nY2, nTab ).Format(rDoc, ScRefFlags::RANGE_ABS_3D)); - short nResult = xQueryBox->run(); - if ( nResult == RET_YES ) - { - rList.erase(*pOld); - bInsert = true; - } - else if ( nResult == RET_CANCEL ) - rCancel = true; - } - } - } + bool bInsert = false; + ScRangeData* pOld = rList.findByUpperName(ScGlobal::getCharClassPtr()->uppercase(aName)); + if (pOld) + { + OUString aOldStr; + pOld->GetSymbol( aOldStr ); + if (aOldStr != aContent) + { + if (bApi) + bInsert = true; // don't check via API else - bInsert = true; - - if (bInsert) { - ScRangeData* pData = new ScRangeData( &rDoc, aName, aContent, - ScAddress( nPosX, nPosY, nTab)); - if (!rList.insert(pData)) + OUString aTemplate = ScResId( STR_CREATENAME_REPLACE ); + OUString aMessage = aTemplate.getToken( 0, '#' ) + aName + aTemplate.getToken( 1, '#' ); + + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(ScDocShell::GetActiveDialogParent(), + VclMessageType::Question, VclButtonsType::YesNo, + aMessage)); + xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL); + xQueryBox->set_default_response(RET_YES); + + short nResult = xQueryBox->run(); + if ( nResult == RET_YES ) { - OSL_FAIL("nanu?"); + rList.erase(*pOld); + bInsert = true; } + else if ( nResult == RET_CANCEL ) + rCancel = true; } } } + else + bInsert = true; + + if (bInsert) + { + ScRangeData* pData = new ScRangeData( &rDoc, aName, aContent, + ScAddress( nPosX, nPosY, nTab)); + if (!rList.insert(pData)) + { + OSL_FAIL("nanu?"); + } + } } bool ScDocFunc::CreateNames( const ScRange& rRange, CreateNameFlags nFlags, bool bApi, SCTAB aTab ) @@ -5468,38 +5467,38 @@ void ScDocFunc::ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd OUString aFormula; rDoc.GetFormula( nStartCol, nStartRow, nTab, aFormula ); - if ( aFormula.startsWith("{") && aFormula.endsWith("}") ) + if ( !(aFormula.startsWith("{") && aFormula.endsWith("}")) ) + return; + + OUString aUndo = ScResId( STR_UNDO_RESIZEMATRIX ); + bool bUndo(rDoc.IsUndoEnabled()); + if (bUndo) { - OUString aUndo = ScResId( STR_UNDO_RESIZEMATRIX ); - bool bUndo(rDoc.IsUndoEnabled()); - if (bUndo) - { - ViewShellId nViewShellId(1); - if (ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell()) - nViewShellId = pViewSh->GetViewShellId(); - rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo, 0, nViewShellId ); - } + ViewShellId nViewShellId(1); + if (ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell()) + nViewShellId = pViewSh->GetViewShellId(); + rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo, 0, nViewShellId ); + } - aFormula = aFormula.copy(1, aFormula.getLength()-2); + aFormula = aFormula.copy(1, aFormula.getLength()-2); - ScMarkData aMark(rDoc.GetSheetLimits()); - aMark.SetMarkArea( rOldRange ); - aMark.SelectTable( nTab, true ); - ScRange aNewRange( rOldRange.aStart, rNewEnd ); + ScMarkData aMark(rDoc.GetSheetLimits()); + aMark.SetMarkArea( rOldRange ); + aMark.SelectTable( nTab, true ); + ScRange aNewRange( rOldRange.aStart, rNewEnd ); - if ( DeleteContents( aMark, InsertDeleteFlags::CONTENTS, true, false/*bApi*/ ) ) + if ( DeleteContents( aMark, InsertDeleteFlags::CONTENTS, true, false/*bApi*/ ) ) + { + // GRAM_API for API compatibility. + if (!EnterMatrix( aNewRange, &aMark, nullptr, aFormula, false/*bApi*/, false, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_API )) { - // GRAM_API for API compatibility. - if (!EnterMatrix( aNewRange, &aMark, nullptr, aFormula, false/*bApi*/, false, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_API )) - { - // try to restore the previous state - EnterMatrix( rOldRange, &aMark, nullptr, aFormula, false/*bApi*/, false, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_API ); - } + // try to restore the previous state + EnterMatrix( rOldRange, &aMark, nullptr, aFormula, false/*bApi*/, false, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_API ); } - - if (bUndo) - rDocShell.GetUndoManager()->LeaveListAction(); } + + if (bUndo) + rDocShell.GetUndoManager()->LeaveListAction(); } void ScDocFunc::InsertAreaLink( const OUString& rFile, const OUString& rFilter, diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index ef5b61f03e53..f9aca0c64d6c 100644 --- a/sc/source/ui/docshell/docsh2.cxx +++ b/sc/source/ui/docshell/docsh2.cxx @@ -114,45 +114,45 @@ void ScDocShell::InitItems() PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) ); } - if (!utl::ConfigManager::IsFuzzing() && - (!m_aDocument.GetForbiddenCharacters() || !m_aDocument.IsValidAsianCompression() || !m_aDocument.IsValidAsianKerning())) - { - // get settings from SvxAsianConfig - SvxAsianConfig aAsian; + if (!(!utl::ConfigManager::IsFuzzing() && + (!m_aDocument.GetForbiddenCharacters() || !m_aDocument.IsValidAsianCompression() || !m_aDocument.IsValidAsianKerning()))) + return; - if (!m_aDocument.GetForbiddenCharacters()) - { - // set forbidden characters if necessary - const uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales(); - if (aLocales.hasElements()) - { - std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenTable( - SvxForbiddenCharactersTable::makeForbiddenCharactersTable(comphelper::getProcessComponentContext())); + // get settings from SvxAsianConfig + SvxAsianConfig aAsian; - for (const lang::Locale& rLocale : aLocales) - { - i18n::ForbiddenCharacters aForbidden; - aAsian.GetStartEndChars( rLocale, aForbidden.beginLine, aForbidden.endLine ); - LanguageType eLang = LanguageTag::convertToLanguageType(rLocale); + if (!m_aDocument.GetForbiddenCharacters()) + { + // set forbidden characters if necessary + const uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales(); + if (aLocales.hasElements()) + { + std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenTable( + SvxForbiddenCharactersTable::makeForbiddenCharactersTable(comphelper::getProcessComponentContext())); - xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden ); - } + for (const lang::Locale& rLocale : aLocales) + { + i18n::ForbiddenCharacters aForbidden; + aAsian.GetStartEndChars( rLocale, aForbidden.beginLine, aForbidden.endLine ); + LanguageType eLang = LanguageTag::convertToLanguageType(rLocale); - m_aDocument.SetForbiddenCharacters( xForbiddenTable ); + xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden ); } - } - if ( !m_aDocument.IsValidAsianCompression() ) - { - // set compression mode from configuration if not already set (e.g. XML import) - m_aDocument.SetAsianCompression( aAsian.GetCharDistanceCompression() ); + m_aDocument.SetForbiddenCharacters( xForbiddenTable ); } + } - if ( !m_aDocument.IsValidAsianKerning() ) - { - // set asian punctuation kerning from configuration if not already set (e.g. XML import) - m_aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed - } + if ( !m_aDocument.IsValidAsianCompression() ) + { + // set compression mode from configuration if not already set (e.g. XML import) + m_aDocument.SetAsianCompression( aAsian.GetCharDistanceCompression() ); + } + + if ( !m_aDocument.IsValidAsianKerning() ) + { + // set asian punctuation kerning from configuration if not already set (e.g. XML import) + m_aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed } } diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index a3fc1cb492fe..552d03820b39 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -614,19 +614,19 @@ ScChangeAction* ScDocShell::GetChangeAction( const ScAddress& rPos ) void ScDocShell::SetChangeComment( ScChangeAction* pAction, const OUString& rComment ) { - if (pAction) - { - pAction->SetComment( rComment ); - //! Undo ??? - SetDocumentModified(); + if (!pAction) + return; - // Dialog-Notify - ScChangeTrack* pTrack = GetDocument().GetChangeTrack(); - if (pTrack) - { - sal_uLong nNumber = pAction->GetActionNumber(); - pTrack->NotifyModified( ScChangeTrackMsgType::Change, nNumber, nNumber ); - } + pAction->SetComment( rComment ); + //! Undo ??? + SetDocumentModified(); + + // Dialog-Notify + ScChangeTrack* pTrack = GetDocument().GetChangeTrack(); + if (pTrack) + { + sal_uLong nNumber = pAction->GetActionNumber(); + pTrack->NotifyModified( ScChangeTrackMsgType::Change, nNumber, nNumber ); } } diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index ffb31aaeaa5f..dab72363ce3f 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1436,31 +1436,31 @@ void ScDocShell::DoRecalc( bool bApi ) pSh->UpdateInputHandler(); } } - if (!bDone) // otherwise re-calculate document + if (bDone) // otherwise re-calculate document + return; + + weld::WaitObject aWaitObj( GetActiveDialogParent() ); + if ( pHdl ) { - weld::WaitObject aWaitObj( GetActiveDialogParent() ); - if ( pHdl ) - { - // tdf97897 set current cell to Dirty to force recalculation of cell - ScFormulaCell* pFC = m_aDocument.GetFormulaCell( pHdl->GetCursorPos()); - if (pFC) - pFC->SetDirty(); - } - m_aDocument.CalcFormulaTree(); - if ( pSh ) - pSh->UpdateCharts(true); + // tdf97897 set current cell to Dirty to force recalculation of cell + ScFormulaCell* pFC = m_aDocument.GetFormulaCell( pHdl->GetCursorPos()); + if (pFC) + pFC->SetDirty(); + } + m_aDocument.CalcFormulaTree(); + if ( pSh ) + pSh->UpdateCharts(true); - m_aDocument.BroadcastUno( SfxHint( SfxHintId::DataChanged ) ); + m_aDocument.BroadcastUno( SfxHint( SfxHintId::DataChanged ) ); - // If there are charts, then paint everything, so that PostDataChanged - // and the charts do not come one after the other and parts are painted twice. + // If there are charts, then paint everything, so that PostDataChanged + // and the charts do not come one after the other and parts are painted twice. - ScChartListenerCollection* pCharts = m_aDocument.GetChartListenerCollection(); - if ( pCharts && pCharts->hasListeners() ) - PostPaintGridAll(); - else - PostDataChanged(); - } + ScChartListenerCollection* pCharts = m_aDocument.GetChartListenerCollection(); + if ( pCharts && pCharts->hasListeners() ) + PostPaintGridAll(); + else + PostDataChanged(); } void ScDocShell::DoHardRecalc() @@ -1509,19 +1509,19 @@ void ScDocShell::DoAutoStyle( const ScRange& rRange, const OUString& rStyle ) if (!pStyleSheet) pStyleSheet = static_cast<ScStyleSheet*>( pStylePool->Find( ScResId(STR_STYLENAME_STANDARD_CELL), SfxStyleFamily::Para )); - if (pStyleSheet) - { - OSL_ENSURE(rRange.aStart.Tab() == rRange.aEnd.Tab(), - "DoAutoStyle with several tables"); - SCTAB nTab = rRange.aStart.Tab(); - SCCOL nStartCol = rRange.aStart.Col(); - SCROW nStartRow = rRange.aStart.Row(); - SCCOL nEndCol = rRange.aEnd.Col(); - SCROW nEndRow = rRange.aEnd.Row(); - m_aDocument.ApplyStyleAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, *pStyleSheet ); - m_aDocument.ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab ); - PostPaint( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab, PaintPartFlags::Grid ); - } + if (!pStyleSheet) + return; + + OSL_ENSURE(rRange.aStart.Tab() == rRange.aEnd.Tab(), + "DoAutoStyle with several tables"); + SCTAB nTab = rRange.aStart.Tab(); + SCCOL nStartCol = rRange.aStart.Col(); + SCROW nStartRow = rRange.aStart.Row(); + SCCOL nEndCol = rRange.aEnd.Col(); + SCROW nEndRow = rRange.aEnd.Row(); + m_aDocument.ApplyStyleAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, *pStyleSheet ); + m_aDocument.ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab ); + PostPaint( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab, PaintPartFlags::Grid ); } void ScDocShell::NotifyStyle( const SfxStyleSheetHint& rHint ) @@ -1604,31 +1604,31 @@ void ScDocShell::SetPrintZoom( SCTAB nTab, sal_uInt16 nScale, sal_uInt16 nPages ScStyleSheetPool* pStylePool = m_aDocument.GetStyleSheetPool(); SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SfxStyleFamily::Page ); OSL_ENSURE( pStyleSheet, "PageStyle not found" ); - if ( pStyleSheet ) - { - ScDocShellModificator aModificator( *this ); + if ( !pStyleSheet ) + return; - SfxItemSet& rSet = pStyleSheet->GetItemSet(); - const bool bUndo(m_aDocument.IsUndoEnabled()); - if (bUndo) - { - sal_uInt16 nOldScale = rSet.Get(ATTR_PAGE_SCALE).GetValue(); - sal_uInt16 nOldPages = rSet.Get(ATTR_PAGE_SCALETOPAGES).GetValue(); - GetUndoManager()->AddUndoAction( std::make_unique<ScUndoPrintZoom>( - this, nTab, nOldScale, nOldPages, nScale, nPages ) ); - } + ScDocShellModificator aModificator( *this ); - rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nScale ) ); - rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, nPages ) ); + SfxItemSet& rSet = pStyleSheet->GetItemSet(); + const bool bUndo(m_aDocument.IsUndoEnabled()); + if (bUndo) + { + sal_uInt16 nOldScale = rSet.Get(ATTR_PAGE_SCALE).GetValue(); + sal_uInt16 nOldPages = rSet.Get(ATTR_PAGE_SCALETOPAGES).GetValue(); + GetUndoManager()->AddUndoAction( std::make_unique<ScUndoPrintZoom>( + this, nTab, nOldScale, nOldPages, nScale, nPages ) ); + } - ScPrintFunc aPrintFunc( this, GetPrinter(), nTab ); - aPrintFunc.UpdatePages(); - aModificator.SetDocumentModified(); + rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nScale ) ); + rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, nPages ) ); - SfxBindings* pBindings = GetViewBindings(); - if (pBindings) - pBindings->Invalidate( FID_RESET_PRINTZOOM ); - } + ScPrintFunc aPrintFunc( this, GetPrinter(), nTab ); + aPrintFunc.UpdatePages(); + aModificator.SetDocumentModified(); + + SfxBindings* pBindings = GetViewBindings(); + if (pBindings) + pBindings->Invalidate( FID_RESET_PRINTZOOM ); } bool ScDocShell::AdjustPrintZoom( const ScRange& rRange ) diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 2df6f6ec9b8f..db59950de64f 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -370,33 +370,33 @@ void ScDocShell::CancelAutoDBRange() { // called when dialog is cancelled //moggi:TODO - if ( m_pOldAutoDBRange ) + if ( !m_pOldAutoDBRange ) + return; + + SCTAB nTab = GetCurTab(); + ScDBData* pDBData = m_aDocument.GetAnonymousDBData(nTab); + if ( pDBData ) { - SCTAB nTab = GetCurTab(); - ScDBData* pDBData = m_aDocument.GetAnonymousDBData(nTab); - if ( pDBData ) - { - SCCOL nRangeX1; - SCROW nRangeY1; - SCCOL nRangeX2; - SCROW nRangeY2; - SCTAB nRangeTab; - pDBData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); - DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2 ); + SCCOL nRangeX1; + SCROW nRangeY1; + SCCOL nRangeX2; + SCROW nRangeY2; + SCTAB nRangeTab; + pDBData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); + DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2 ); - *pDBData = *m_pOldAutoDBRange; // restore old settings + *pDBData = *m_pOldAutoDBRange; // restore old settings - if ( m_pOldAutoDBRange->HasAutoFilter() ) - { - // restore AutoFilter buttons - m_pOldAutoDBRange->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); - m_aDocument.ApplyFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, ScMF::Auto ); - PostPaint( nRangeX1, nRangeY1, nRangeTab, nRangeX2, nRangeY1, nRangeTab, PaintPartFlags::Grid ); - } + if ( m_pOldAutoDBRange->HasAutoFilter() ) + { + // restore AutoFilter buttons + m_pOldAutoDBRange->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); + m_aDocument.ApplyFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, ScMF::Auto ); + PostPaint( nRangeX1, nRangeY1, nRangeTab, nRangeX2, nRangeY1, nRangeTab, PaintPartFlags::Grid ); } - - m_pOldAutoDBRange.reset(); } + + m_pOldAutoDBRange.reset(); } // adjust height diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx index 103d05e954de..905ac7ef84c2 100644 --- a/sc/source/ui/docshell/docsh6.cxx +++ b/sc/source/ui/docshell/docsh6.cxx @@ -129,19 +129,19 @@ void ScDocShell::SetVisAreaOrSize( const tools::Rectangle& rVisArea ) } } - if (m_aDocument.IsEmbedded()) - { - ScRange aOld; - m_aDocument.GetEmbedded( aOld); - m_aDocument.SetEmbedded( m_aDocument.GetVisibleTab(), aArea ); - ScRange aNew; - m_aDocument.GetEmbedded( aNew); - if (aOld != aNew) - PostPaint(0,0,0,m_aDocument.MaxCol(),m_aDocument.MaxRow(),MAXTAB,PaintPartFlags::Grid); - - //TODO/LATER: currently not implemented - //ViewChanged( ASPECT_CONTENT ); // show in the container as well - } + if (!m_aDocument.IsEmbedded()) + return; + + ScRange aOld; + m_aDocument.GetEmbedded( aOld); + m_aDocument.SetEmbedded( m_aDocument.GetVisibleTab(), aArea ); + ScRange aNew; + m_aDocument.GetEmbedded( aNew); + if (aOld != aNew) + PostPaint(0,0,0,m_aDocument.MaxCol(),m_aDocument.MaxRow(),MAXTAB,PaintPartFlags::Grid); + + //TODO/LATER: currently not implemented + //ViewChanged( ASPECT_CONTENT ); // show in the container as well } bool ScDocShell::IsOle() const diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 9ba5e0b5e0cf..c4391e553cbf 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -1833,32 +1833,32 @@ void initDocInCache(ScExternalRefCache& rRefCache, const ScDocument* pSrcDoc, sa return; SCTAB nTabCount = pSrcDoc->GetTableCount(); - if (nTabCount) + if (!nTabCount) + return; + + // Populate the cache with all table names in the source document. + vector<OUString> aTabNames; + aTabNames.reserve(nTabCount); + for (SCTAB i = 0; i < nTabCount; ++i) { - // Populate the cache with all table names in the source document. - vector<OUString> aTabNames; - aTabNames.reserve(nTabCount); - for (SCTAB i = 0; i < nTabCount; ++i) - { - OUString aName; - pSrcDoc->GetName(i, aName); - aTabNames.push_back(aName); - } + OUString aName; + pSrcDoc->GetName(i, aName); + aTabNames.push_back(aName); + } - // Obtain the base name, don't bother if there are more than one sheets. - OUString aBaseName; - if (nTabCount == 1) + // Obtain the base name, don't bother if there are more than one sheets. + OUString aBaseName; + if (nTabCount == 1) + { + const SfxObjectShell* pShell = pSrcDoc->GetDocumentShell(); + if (pShell && pShell->GetMedium()) { - const SfxObjectShell* pShell = pSrcDoc->GetDocumentShell(); - if (pShell && pShell->GetMedium()) - { - OUString aName = pShell->GetMedium()->GetName(); - aBaseName = INetURLObject( aName).GetBase(); - } + OUString aName = pShell->GetMedium()->GetName(); + aBaseName = INetURLObject( aName).GetBase(); } - - rRefCache.initializeDoc(nFileId, aTabNames, aBaseName); } + + rRefCache.initializeDoc(nFileId, aTabNames, aBaseName); } } @@ -3172,29 +3172,29 @@ void ScExternalRefManager::transformUnsavedRefToSavedRef( SfxObjectShell* pShell void ScExternalRefManager::Notify( SfxBroadcaster&, const SfxHint& rHint ) { const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint); - if ( pEventHint ) + if ( !pEventHint ) + return; + + SfxEventHintId nEventId = pEventHint->GetEventId(); + switch ( nEventId ) { - SfxEventHintId nEventId = pEventHint->GetEventId(); - switch ( nEventId ) - { - case SfxEventHintId::PrepareCloseDoc: - { - std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(ScDocShell::GetActiveDialogParent(), - VclMessageType::Warning, VclButtonsType::Ok, - ScResId(STR_CLOSE_WITH_UNSAVED_REFS))); - xWarn->run(); - } - break; - case SfxEventHintId::SaveDocDone: - case SfxEventHintId::SaveAsDocDone: - { - SfxObjectShell* pObjShell = static_cast<const SfxEventHint&>( rHint ).GetObjShell(); - transformUnsavedRefToSavedRef(pObjShell); - } - break; - default: - break; - } + case SfxEventHintId::PrepareCloseDoc: + { + std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(ScDocShell::GetActiveDialogParent(), + VclMessageType::Warning, VclButtonsType::Ok, + ScResId(STR_CLOSE_WITH_UNSAVED_REFS))); + xWarn->run(); + } + break; + case SfxEventHintId::SaveDocDone: + case SfxEventHintId::SaveAsDocDone: + { + SfxObjectShell* pObjShell = static_cast<const SfxEventHint&>( rHint ).GetObjShell(); + transformUnsavedRefToSavedRef(pObjShell); + } + break; + default: + break; } } diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx index 6c54c6e8b3cb..2302367e9aa1 100644 --- a/sc/source/ui/drawfunc/drawsh.cxx +++ b/sc/source/ui/drawfunc/drawsh.cxx @@ -429,32 +429,32 @@ void ScDrawShell::ExecuteMacroAssign(SdrObject* pObj, weld::Window* pWin) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); ScopedVclPtr<SfxAbstractDialog> pMacroDlg(pFact->CreateEventConfigDialog( pWin, *pItemSet, xFrame )); - if ( pMacroDlg->Execute() == RET_OK ) + if ( pMacroDlg->Execute() != RET_OK ) + return; + + const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet(); + const SfxPoolItem* pItem; + if( SfxItemState::SET != pOutSet->GetItemState( SID_ATTR_MACROITEM, false, &pItem )) + return; + + OUString sMacro; + const SvxMacro* pMacro = static_cast<const SvxMacroItem*>(pItem)->GetMacroTable().Get( SvMacroItemId::OnClick ); + if ( pMacro ) + sMacro = pMacro->GetMacName(); + + if ( pObj->IsGroupObject() ) { - const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet(); - const SfxPoolItem* pItem; - if( SfxItemState::SET == pOutSet->GetItemState( SID_ATTR_MACROITEM, false, &pItem )) + SdrObjList* pOL = pObj->GetSubList(); + const size_t nObj = pOL->GetObjCount(); + for ( size_t index=0; index<nObj; ++index ) { - OUString sMacro; - const SvxMacro* pMacro = static_cast<const SvxMacroItem*>(pItem)->GetMacroTable().Get( SvMacroItemId::OnClick ); - if ( pMacro ) - sMacro = pMacro->GetMacName(); - - if ( pObj->IsGroupObject() ) - { - SdrObjList* pOL = pObj->GetSubList(); - const size_t nObj = pOL->GetObjCount(); - for ( size_t index=0; index<nObj; ++index ) - { - pInfo = ScDrawLayer::GetMacroInfo( pOL->GetObj(index), true ); - pInfo->SetMacro( sMacro ); - } - } - else - pInfo->SetMacro( sMacro ); - lcl_setModified( GetObjectShell() ); + pInfo = ScDrawLayer::GetMacroInfo( pOL->GetObj(index), true ); + pInfo->SetMacro( sMacro ); } } + else + pInfo->SetMacro( sMacro ); + lcl_setModified( GetObjectShell() ); } void ScDrawShell::ExecuteLineDlg( const SfxRequest& rReq ) diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx index b34b3c19522b..15d70334c028 100644 --- a/sc/source/ui/drawfunc/drawsh2.cxx +++ b/sc/source/ui/drawfunc/drawsh2.cxx @@ -111,34 +111,34 @@ void ScDrawShell::GetState( SfxItemSet& rSet ) // Conditions / Toggles } } - if ( !bDisableAnchor ) + if ( bDisableAnchor ) + return; + + switch( pView->GetAnchorType() ) { - switch( pView->GetAnchorType() ) - { - case SCA_PAGE: - rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, true ) ); - rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, false ) ); - rSet.Put( SfxBoolItem( SID_ANCHOR_CELL_RESIZE, false ) ); - break; - - case SCA_CELL: - rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, false ) ); - rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, true ) ); - rSet.Put( SfxBoolItem( SID_ANCHOR_CELL_RESIZE, false ) ); - break; - - case SCA_CELL_RESIZE: - rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, false ) ); - rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, false ) ); - rSet.Put( SfxBoolItem( SID_ANCHOR_CELL_RESIZE, true ) ); - break; - - default: - rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, false ) ); - rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, false ) ); - rSet.Put( SfxBoolItem( SID_ANCHOR_CELL_RESIZE, false ) ); - break; - } + case SCA_PAGE: + rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, true ) ); + rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, false ) ); + rSet.Put( SfxBoolItem( SID_ANCHOR_CELL_RESIZE, false ) ); + break; + + case SCA_CELL: + rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, false ) ); + rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, true ) ); + rSet.Put( SfxBoolItem( SID_ANCHOR_CELL_RESIZE, false ) ); + break; + + case SCA_CELL_RESIZE: + rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, false ) ); + rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, false ) ); + rSet.Put( SfxBoolItem( SID_ANCHOR_CELL_RESIZE, true ) ); + break; + + default: + rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, false ) ); + rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, false ) ); + rSet.Put( SfxBoolItem( SID_ANCHOR_CELL_RESIZE, false ) ); + break; } } @@ -328,49 +328,49 @@ void ScDrawShell::GetDrawAttrState( SfxItemSet& rSet ) } SdrPageView* pPV = pDrView->GetSdrPageView(); - if ( pPV ) - { - // #i52073# when a sheet with an active OLE object is deleted, - // the slot state is queried without an active page view + if ( !pPV ) + return; + + // #i52073# when a sheet with an active OLE object is deleted, + // the slot state is queried without an active page view - // Items for position and size (see ScGridWindow::UpdateStatusPosSize, #108137#) + // Items for position and size (see ScGridWindow::UpdateStatusPosSize, #108137#) - // #i34458# The SvxSizeItem in SID_TABLE_CELL is no longer needed by - // SvxPosSizeStatusBarControl, it's enough to have it in SID_ATTR_SIZE. + // #i34458# The SvxSizeItem in SID_TABLE_CELL is no longer needed by + // SvxPosSizeStatusBarControl, it's enough to have it in SID_ATTR_SIZE. - bool bActionItem = false; - if ( pDrView->IsAction() ) // action rectangle + bool bActionItem = false; + if ( pDrView->IsAction() ) // action rectangle + { + tools::Rectangle aRect; + pDrView->TakeActionRect( aRect ); + if ( !aRect.IsEmpty() ) { - tools::Rectangle aRect; - pDrView->TakeActionRect( aRect ); - if ( !aRect.IsEmpty() ) - { - pPV->LogicToPagePos(aRect); - rSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) ); - Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ); - rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize ) ); - bActionItem = true; - } - } - if ( !bActionItem ) - { - if ( pDrView->AreObjectsMarked() ) // selected objects - { - tools::Rectangle aRect = pDrView->GetAllMarkedRect(); - pPV->LogicToPagePos(aRect); - rSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) ); - Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ); - rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize ) ); - } - else // mouse position - { - // aPos is initialized above - pPV->LogicToPagePos(aPos); - rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos ) ); - rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) ); - } + pPV->LogicToPagePos(aRect); + rSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) ); + Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ); + rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize ) ); + bActionItem = true; } } + if ( bActionItem ) + return; + + if ( pDrView->AreObjectsMarked() ) // selected objects + { + tools::Rectangle aRect = pDrView->GetAllMarkedRect(); + pPV->LogicToPagePos(aRect); + rSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) ); + Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ); + rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize ) ); + } + else // mouse position + { + // aPos is initialized above + pPV->LogicToPagePos(aPos); + rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos ) ); + rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) ); + } } void ScDrawShell::GetAttrFuncState(SfxItemSet &rSet) diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index 06012848c489..c4a83616eef5 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -900,63 +900,63 @@ void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq ) pArgs = rReq.GetArgs(); } - if ( pArgs ) + if ( !pArgs ) + return; + + if ( bArgsInReq && + ( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT || + nSlot == SID_ATTR_CHAR_WEIGHT || nSlot == SID_ATTR_CHAR_POSTURE ) ) { - if ( bArgsInReq && - ( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT || - nSlot == SID_ATTR_CHAR_WEIGHT || nSlot == SID_ATTR_CHAR_POSTURE ) ) - { - // font items from toolbox controller have to be applied for the right script type + // font items from toolbox controller have to be applied for the right script type - // #i78017 establish the same behaviour as in Writer - SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX; - if (nSlot == SID_ATTR_CHAR_FONT) - nScript = pView->GetScriptType(); + // #i78017 establish the same behaviour as in Writer + SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX; + if (nSlot == SID_ATTR_CHAR_FONT) + nScript = pView->GetScriptType(); - SfxItemPool& rPool = GetPool(); - SvxScriptSetItem aSetItem( nSlot, rPool ); - sal_uInt16 nWhich = rPool.GetWhich( nSlot ); - aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) ); + SfxItemPool& rPool = GetPool(); + SvxScriptSetItem aSetItem( nSlot, rPool ); + sal_uInt16 nWhich = rPool.GetWhich( nSlot ); + aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) ); - pView->SetAttributes( aSetItem.GetItemSet() ); - } - else if( nSlot == SID_ATTR_PARA_LRSPACE ) - { - sal_uInt16 nId = SID_ATTR_PARA_LRSPACE; - const SvxLRSpaceItem& rItem = static_cast<const SvxLRSpaceItem&>( - pArgs->Get( nId )); - SfxItemSet aAttr( GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} ); - nId = EE_PARA_LRSPACE; - SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(), - rItem.GetRight(), rItem.GetTextLeft(), - rItem.GetTextFirstLineOffset(), nId ); - aAttr.Put( aLRSpaceItem ); - pView->SetAttributes( aAttr ); - } - else if( nSlot == SID_ATTR_PARA_LINESPACE ) - { - SvxLineSpacingItem aLineSpaceItem = static_cast<const SvxLineSpacingItem&>(pArgs->Get( - GetPool().GetWhich(nSlot))); - SfxItemSet aAttr( GetPool(), svl::Items<EE_PARA_SBL, EE_PARA_SBL>{} ); - aAttr.Put( aLineSpaceItem ); - pView->SetAttributes( aAttr ); - } - else if( nSlot == SID_ATTR_PARA_ULSPACE ) - { - SvxULSpaceItem aULSpaceItem = static_cast<const SvxULSpaceItem&>(pArgs->Get( - GetPool().GetWhich(nSlot))); - SfxItemSet aAttr( GetPool(), svl::Items<EE_PARA_ULSPACE, EE_PARA_ULSPACE>{} ); - aULSpaceItem.SetWhich(EE_PARA_ULSPACE); - aAttr.Put( aULSpaceItem ); - pView->SetAttributes( aAttr ); - } - else - { - // use args directly - pView->SetAttributes( *pArgs ); - } - pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); + pView->SetAttributes( aSetItem.GetItemSet() ); + } + else if( nSlot == SID_ATTR_PARA_LRSPACE ) + { + sal_uInt16 nId = SID_ATTR_PARA_LRSPACE; + const SvxLRSpaceItem& rItem = static_cast<const SvxLRSpaceItem&>( + pArgs->Get( nId )); + SfxItemSet aAttr( GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} ); + nId = EE_PARA_LRSPACE; + SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(), + rItem.GetRight(), rItem.GetTextLeft(), + rItem.GetTextFirstLineOffset(), nId ); + aAttr.Put( aLRSpaceItem ); + pView->SetAttributes( aAttr ); + } + else if( nSlot == SID_ATTR_PARA_LINESPACE ) + { + SvxLineSpacingItem aLineSpaceItem = static_cast<const SvxLineSpacingItem&>(pArgs->Get( + GetPool().GetWhich(nSlot))); + SfxItemSet aAttr( GetPool(), svl::Items<EE_PARA_SBL, EE_PARA_SBL>{} ); + aAttr.Put( aLineSpaceItem ); + pView->SetAttributes( aAttr ); + } + else if( nSlot == SID_ATTR_PARA_ULSPACE ) + { + SvxULSpaceItem aULSpaceItem = static_cast<const SvxULSpaceItem&>(pArgs->Get( + GetPool().GetWhich(nSlot))); + SfxItemSet aAttr( GetPool(), svl::Items<EE_PARA_ULSPACE, EE_PARA_ULSPACE>{} ); + aULSpaceItem.SetWhich(EE_PARA_ULSPACE); + aAttr.Put( aULSpaceItem ); + pView->SetAttributes( aAttr ); } + else + { + // use args directly + pView->SetAttributes( *pArgs ); + } + pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); } void ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet ) @@ -1171,19 +1171,19 @@ void ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet ) void ScDrawTextObjectBar::ExecuteTrans( const SfxRequest& rReq ) { TransliterationFlags nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() ); - if ( nType != TransliterationFlags::NONE ) + if ( nType == TransliterationFlags::NONE ) + return; + + ScDrawView* pView = pViewData->GetScDrawView(); + OutlinerView* pOutView = pView->GetTextEditOutlinerView(); + if ( pOutView ) { - ScDrawView* pView = pViewData->GetScDrawView(); - OutlinerView* pOutView = pView->GetTextEditOutlinerView(); - if ( pOutView ) - { - // change selected text in object - pOutView->TransliterateText( nType ); - } - else - { - //! apply to whole objects? - } + // change selected text in object + pOutView->TransliterateText( nType ); + } + else + { + //! apply to whole objects? } } |