From df37937018fe8e87dad5dd97689632044ba56de3 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 9 Aug 2020 11:59:18 +0200 Subject: loplugin:flatten in sc/ui/view Change-Id: I0ea33fc076a280e5f4559eea8420b1b7fa442361 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100400 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sc/source/ui/view/cellsh3.cxx | 138 +++--- sc/source/ui/view/dbfunc.cxx | 88 ++-- sc/source/ui/view/dbfunc3.cxx | 336 ++++++------- sc/source/ui/view/drawvie3.cxx | 118 ++--- sc/source/ui/view/drawvie4.cxx | 64 +-- sc/source/ui/view/drawview.cxx | 214 ++++---- sc/source/ui/view/editsh.cxx | 26 +- sc/source/ui/view/gridmerg.cxx | 60 +-- sc/source/ui/view/gridwin.cxx | 642 ++++++++++++------------ sc/source/ui/view/gridwin3.cxx | 22 +- sc/source/ui/view/gridwin4.cxx | 536 ++++++++++---------- sc/source/ui/view/gridwin_dbgutil.cxx | 34 +- sc/source/ui/view/hdrcont.cxx | 64 +-- sc/source/ui/view/invmerge.cxx | 65 ++- sc/source/ui/view/notemark.cxx | 90 ++-- sc/source/ui/view/olinewin.cxx | 38 +- sc/source/ui/view/output.cxx | 420 ++++++++-------- sc/source/ui/view/output2.cxx | 92 ++-- sc/source/ui/view/preview.cxx | 498 +++++++++---------- sc/source/ui/view/prevloc.cxx | 84 ++-- sc/source/ui/view/prevwsh.cxx | 64 +-- sc/source/ui/view/printfun.cxx | 253 +++++----- sc/source/ui/view/select.cxx | 94 ++-- sc/source/ui/view/tabcont.cxx | 70 +-- sc/source/ui/view/tabview.cxx | 252 +++++----- sc/source/ui/view/tabview2.cxx | 300 ++++++------ sc/source/ui/view/tabview3.cxx | 888 +++++++++++++++++----------------- sc/source/ui/view/tabview4.cxx | 134 ++--- sc/source/ui/view/tabview5.cxx | 307 ++++++------ sc/source/ui/view/tabvwsh2.cxx | 102 ++-- sc/source/ui/view/tabvwsh4.cxx | 376 +++++++------- sc/source/ui/view/tabvwshb.cxx | 76 +-- sc/source/ui/view/tabvwshc.cxx | 46 +- sc/source/ui/view/viewdata.cxx | 212 ++++---- sc/source/ui/view/viewfun2.cxx | 561 ++++++++++----------- sc/source/ui/view/viewfun3.cxx | 114 ++--- sc/source/ui/view/viewfun6.cxx | 58 +-- sc/source/ui/view/viewfunc.cxx | 75 +-- 38 files changed, 3805 insertions(+), 3806 deletions(-) (limited to 'sc') diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index df42b593bc3d..c7a40214c053 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -70,85 +70,85 @@ OString escapeJSON(const OUString &aStr) void lcl_lokGetWholeFunctionList() { const SfxViewShell* pViewShell = SfxViewShell::Current(); - if (comphelper::LibreOfficeKit::isActive() - && pViewShell && pViewShell->isLOKMobilePhone()) + if (!(comphelper::LibreOfficeKit::isActive() + && pViewShell && pViewShell->isLOKMobilePhone())) + return; + + const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList(); + sal_uInt32 nListCount = pFuncList->GetCount(); + std::set aFuncNameOrderedSet; + for(sal_uInt32 i = 0; i < nListCount; ++i) { - const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList(); - sal_uInt32 nListCount = pFuncList->GetCount(); - std::set aFuncNameOrderedSet; - 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 ) - { - aFuncNameOrderedSet.insert(*pDesc->mxFuncName); - } + aFuncNameOrderedSet.insert(*pDesc->mxFuncName); } - ScFunctionMgr* pFuncManager = ScGlobal::GetStarCalcFunctionMgr(); - if (pFuncManager && aFuncNameOrderedSet.size()) - { - OStringBuffer aPayload; - aPayload.append("{ \"wholeList\": true, "); - aPayload.append("\"categories\": [ "); + } + ScFunctionMgr* pFuncManager = ScGlobal::GetStarCalcFunctionMgr(); + if (!(pFuncManager && aFuncNameOrderedSet.size())) + return; - formula::FormulaHelper aHelper(pFuncManager); - sal_uInt32 nCategoryCount = pFuncManager->getCount(); - for (sal_uInt32 i = 0; i < nCategoryCount; ++i) - { - OUString sCategoryName = ScFunctionMgr::GetCategoryName(i); - aPayload.append("{"); - aPayload.append("\"name\": \""); - aPayload.append(escapeJSON(sCategoryName)); - aPayload.append("\"}, "); - } - sal_Int32 nLen = aPayload.getLength(); - aPayload[nLen - 2] = ' '; - aPayload[nLen - 1] = ']'; - aPayload.append(", "); - - OUString aDescFuncNameStr; - aPayload.append("\"functions\": [ "); - sal_uInt32 nCurIndex = 0; - for (const OUString& aFuncNameStr : aFuncNameOrderedSet) + OStringBuffer aPayload; + aPayload.append("{ \"wholeList\": true, "); + aPayload.append("\"categories\": [ "); + + formula::FormulaHelper aHelper(pFuncManager); + sal_uInt32 nCategoryCount = pFuncManager->getCount(); + for (sal_uInt32 i = 0; i < nCategoryCount; ++i) + { + OUString sCategoryName = ScFunctionMgr::GetCategoryName(i); + aPayload.append("{"); + aPayload.append("\"name\": \""); + aPayload.append(escapeJSON(sCategoryName)); + aPayload.append("\"}, "); + } + sal_Int32 nLen = aPayload.getLength(); + aPayload[nLen - 2] = ' '; + aPayload[nLen - 1] = ']'; + aPayload.append(", "); + + OUString aDescFuncNameStr; + aPayload.append("\"functions\": [ "); + sal_uInt32 nCurIndex = 0; + for (const OUString& aFuncNameStr : aFuncNameOrderedSet) + { + aDescFuncNameStr = aFuncNameStr + "()"; + sal_Int32 nNextFStart = 0; + const formula::IFunctionDescription* ppFDesc; + ::std::vector< OUString > aArgs; + OUString eqPlusFuncName = "=" + aDescFuncNameStr; + if ( aHelper.GetNextFunc( eqPlusFuncName, false, nNextFStart, nullptr, &ppFDesc, &aArgs ) ) + { + if ( ppFDesc && !ppFDesc->getFunctionName().isEmpty() ) { - aDescFuncNameStr = aFuncNameStr + "()"; - sal_Int32 nNextFStart = 0; - const formula::IFunctionDescription* ppFDesc; - ::std::vector< OUString > aArgs; - OUString eqPlusFuncName = "=" + aDescFuncNameStr; - if ( aHelper.GetNextFunc( eqPlusFuncName, false, nNextFStart, nullptr, &ppFDesc, &aArgs ) ) + if (ppFDesc->getCategory()) { - if ( ppFDesc && !ppFDesc->getFunctionName().isEmpty() ) - { - if (ppFDesc->getCategory()) - { - aPayload.append("{"); - aPayload.append("\"index\": "); - aPayload.append(OString::number(nCurIndex)); - aPayload.append(", "); - aPayload.append("\"category\": "); - aPayload.append(OString::number(ppFDesc->getCategory()->getNumber())); - aPayload.append(", "); - aPayload.append("\"signature\": \""); - aPayload.append(escapeJSON(ppFDesc->getSignature())); - aPayload.append("\", "); - aPayload.append("\"description\": \""); - aPayload.append(escapeJSON(ppFDesc->getDescription())); - aPayload.append("\"}, "); - } - } + aPayload.append("{"); + aPayload.append("\"index\": "); + aPayload.append(OString::number(nCurIndex)); + aPayload.append(", "); + aPayload.append("\"category\": "); + aPayload.append(OString::number(ppFDesc->getCategory()->getNumber())); + aPayload.append(", "); + aPayload.append("\"signature\": \""); + aPayload.append(escapeJSON(ppFDesc->getSignature())); + aPayload.append("\", "); + aPayload.append("\"description\": \""); + aPayload.append(escapeJSON(ppFDesc->getDescription())); + aPayload.append("\"}, "); } - ++nCurIndex; } - nLen = aPayload.getLength(); - aPayload[nLen - 2] = ' '; - aPayload[nLen - 1] = ']'; - aPayload.append(" }"); - - OString s = aPayload.makeStringAndClear(); - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CALC_FUNCTION_LIST, s.getStr()); } + ++nCurIndex; } + nLen = aPayload.getLength(); + aPayload[nLen - 2] = ' '; + aPayload[nLen - 1] = ']'; + aPayload.append(" }"); + + OString s = aPayload.makeStringAndClear(); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CALC_FUNCTION_LIST, s.getStr()); } } // end namespace diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx index ba99e9185a8c..2f559ddea045 100644 --- a/sc/source/ui/view/dbfunc.cxx +++ b/sc/source/ui/view/dbfunc.cxx @@ -55,24 +55,24 @@ void ScDBFunc::GotoDBArea( const OUString& rDBName ) ScDocument* pDoc = GetViewData().GetDocument(); ScDBCollection* pDBCol = pDoc->GetDBCollection(); ScDBData* pData = pDBCol->getNamedDBs().findByUpperName(ScGlobal::getCharClassPtr()->uppercase(rDBName)); - if (pData) - { - SCTAB nTab = 0; - SCCOL nStartCol = 0; - SCROW nStartRow = 0; - SCCOL nEndCol = 0; - SCROW nEndRow = 0; - - pData->GetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); - SetTabNo( nTab ); - - MoveCursorAbs( nStartCol, nStartRow, SC_FOLLOW_JUMP, - false, false ); // bShift,bControl - DoneBlockMode(); - InitBlockMode( nStartCol, nStartRow, nTab ); - MarkCursor( nEndCol, nEndRow, nTab ); - SelectionChanged(); - } + if (!pData) + return; + + SCTAB nTab = 0; + SCCOL nStartCol = 0; + SCROW nStartRow = 0; + SCCOL nEndCol = 0; + SCROW nEndRow = 0; + + pData->GetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); + SetTabNo( nTab ); + + MoveCursorAbs( nStartCol, nStartRow, SC_FOLLOW_JUMP, + false, false ); // bShift,bControl + DoneBlockMode(); + InitBlockMode( nStartCol, nStartRow, nTab ); + MarkCursor( nEndCol, nEndRow, nTab ); + SelectionChanged(); } // search current datarange for sort / filter @@ -237,37 +237,37 @@ void ScDBFunc::Query( const ScQueryParam& rQueryParam, const ScRange* pAdvSource ScDBDocFunc aDBDocFunc( *pDocSh ); bool bSuccess = aDBDocFunc.Query( nTab, rQueryParam, pAdvSource, bRecord, false ); - if (bSuccess) - { - bool bCopy = !rQueryParam.bInplace; - if (bCopy) - { - // mark target range (data base range has been set up if applicable) - ScDocument& rDoc = pDocSh->GetDocument(); - ScDBData* pDestData = rDoc.GetDBAtCursor( - rQueryParam.nDestCol, rQueryParam.nDestRow, - rQueryParam.nDestTab, ScDBDataPortion::TOP_LEFT ); - if (pDestData) - { - ScRange aDestRange; - pDestData->GetArea(aDestRange); - MarkRange( aDestRange ); - } - } + if (!bSuccess) + return; - if (!bCopy) + bool bCopy = !rQueryParam.bInplace; + if (bCopy) + { + // mark target range (data base range has been set up if applicable) + ScDocument& rDoc = pDocSh->GetDocument(); + ScDBData* pDestData = rDoc.GetDBAtCursor( + rQueryParam.nDestCol, rQueryParam.nDestRow, + rQueryParam.nDestTab, ScDBDataPortion::TOP_LEFT ); + if (pDestData) { - ScTabViewShell::notifyAllViewsSheetGeomInvalidation( - GetViewData().GetViewShell(), - false /* bColumns */, true /* bRows */, - false /* bSizes*/, true /* bHidden */, true /* bFiltered */, - false /* bGroups */, nTab); - UpdateScrollBars(ROW_HEADER); - SelectionChanged(); // for attribute states (filtered rows are ignored) + ScRange aDestRange; + pDestData->GetArea(aDestRange); + MarkRange( aDestRange ); } + } - GetViewData().GetBindings().Invalidate( SID_UNFILTER ); + if (!bCopy) + { + ScTabViewShell::notifyAllViewsSheetGeomInvalidation( + GetViewData().GetViewShell(), + false /* bColumns */, true /* bRows */, + false /* bSizes*/, true /* bHidden */, true /* bFiltered */, + false /* bGroups */, nTab); + UpdateScrollBars(ROW_HEADER); + SelectionChanged(); // for attribute states (filtered rows are ignored) } + + GetViewData().GetBindings().Invalidate( SID_UNFILTER ); } // autofilter-buttons show / hide diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index 429725af03dd..5f19e0f7af59 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -475,128 +475,128 @@ void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, bool bRecord, } } - if (bOk) - { - ScDocShellModificator aModificator( *pDocSh ); - - ScSubTotalParam aNewParam( rParam ); // change end of range - ScDocumentUniquePtr pUndoDoc; - std::unique_ptr pUndoTab; - std::unique_ptr pUndoRange; - std::unique_ptr pUndoDB; - - if (bRecord) // record old data - { - bool bOldFilter = bDo && rParam.bDoSort; - SCTAB nTabCount = rDoc.GetTableCount(); - pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); - ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab ); - if (pTable) - { - pUndoTab.reset(new ScOutlineTable( *pTable )); - - SCCOLROW nOutStartCol; // row/column status - SCCOLROW nOutStartRow; - SCCOLROW nOutEndCol; - SCCOLROW nOutEndRow; - pTable->GetColArray().GetRange( nOutStartCol, nOutEndCol ); - pTable->GetRowArray().GetRange( nOutStartRow, nOutEndRow ); - - pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true ); - rDoc.CopyToDocument( static_cast(nOutStartCol), 0, nTab, static_cast(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 ); + if (!bOk) + return; - // record data range - including filter results - rDoc.CopyToDocument( 0,rParam.nRow1+1,nTab, rDoc.MaxCol(),rParam.nRow2,nTab, - InsertDeleteFlags::ALL, false, *pUndoDoc ); + ScDocShellModificator aModificator( *pDocSh ); - // all formulas for reference - rDoc.CopyToDocument( 0,0,0, rDoc.MaxCol(),rDoc.MaxRow(),nTabCount-1, - InsertDeleteFlags::FORMULA, false, *pUndoDoc ); + ScSubTotalParam aNewParam( rParam ); // change end of range + ScDocumentUniquePtr pUndoDoc; + std::unique_ptr pUndoTab; + std::unique_ptr pUndoRange; + std::unique_ptr pUndoDB; - // database and other ranges - ScRangeName* pDocRange = rDoc.GetRangeName(); - if (!pDocRange->empty()) - pUndoRange.reset(new ScRangeName( *pDocRange )); - ScDBCollection* pDocDB = rDoc.GetDBCollection(); - if (!pDocDB->empty()) - pUndoDB.reset(new ScDBCollection( *pDocDB )); + if (bRecord) // record old data + { + bool bOldFilter = bDo && rParam.bDoSort; + SCTAB nTabCount = rDoc.GetTableCount(); + pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); + ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab ); + if (pTable) + { + pUndoTab.reset(new ScOutlineTable( *pTable )); + + SCCOLROW nOutStartCol; // row/column status + SCCOLROW nOutStartRow; + SCCOLROW nOutEndCol; + SCCOLROW nOutEndRow; + pTable->GetColArray().GetRange( nOutStartCol, nOutEndCol ); + pTable->GetRowArray().GetRange( nOutStartRow, nOutEndRow ); + + pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true ); + rDoc.CopyToDocument( static_cast(nOutStartCol), 0, nTab, static_cast(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 ); + + // record data range - including filter results + rDoc.CopyToDocument( 0,rParam.nRow1+1,nTab, rDoc.MaxCol(),rParam.nRow2,nTab, + InsertDeleteFlags::ALL, false, *pUndoDoc ); + + // all formulas for reference + rDoc.CopyToDocument( 0,0,0, rDoc.MaxCol(),rDoc.MaxRow(),nTabCount-1, + InsertDeleteFlags::FORMULA, false, *pUndoDoc ); + + // database and other ranges + ScRangeName* pDocRange = rDoc.GetRangeName(); + if (!pDocRange->empty()) + pUndoRange.reset(new ScRangeName( *pDocRange )); + ScDBCollection* pDocDB = rDoc.GetDBCollection(); + if (!pDocDB->empty()) + pUndoDB.reset(new ScDBCollection( *pDocDB )); + } - ScOutlineTable* pOut = rDoc.GetOutlineTable( nTab ); - if (pOut) + ScOutlineTable* pOut = rDoc.GetOutlineTable( nTab ); + if (pOut) + { + // Remove all existing outlines in the specified range. + ScOutlineArray& rRowArray = pOut->GetRowArray(); + sal_uInt16 nDepth = rRowArray.GetDepth(); + for (sal_uInt16 i = 0; i < nDepth; ++i) { - // Remove all existing outlines in the specified range. - ScOutlineArray& rRowArray = pOut->GetRowArray(); - sal_uInt16 nDepth = rRowArray.GetDepth(); - for (sal_uInt16 i = 0; i < nDepth; ++i) - { - bool bSize; - rRowArray.Remove(aNewParam.nRow1, aNewParam.nRow2, bSize); - } + bool bSize; + rRowArray.Remove(aNewParam.nRow1, aNewParam.nRow2, bSize); } + } - if (rParam.bReplace) - rDoc.RemoveSubTotals( nTab, aNewParam ); - bool bSuccess = true; - if (bDo) + if (rParam.bReplace) + rDoc.RemoveSubTotals( nTab, aNewParam ); + bool bSuccess = true; + if (bDo) + { + // Sort + if ( rParam.bDoSort || pForceNewSort ) { - // Sort - if ( rParam.bDoSort || pForceNewSort ) - { - pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 ); + pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 ); - // set subtotal fields before sorting - // (duplicate values are dropped, so that they can be called again) + // set subtotal fields before sorting + // (duplicate values are dropped, so that they can be called again) - ScSortParam aOldSort; - pDBData->GetSortParam( aOldSort ); - ScSortParam aSortParam( aNewParam, pForceNewSort ? *pForceNewSort : aOldSort ); - Sort( aSortParam, false, false ); - } - - bSuccess = rDoc.DoSubTotals( nTab, aNewParam ); + ScSortParam aOldSort; + pDBData->GetSortParam( aOldSort ); + ScSortParam aSortParam( aNewParam, pForceNewSort ? *pForceNewSort : aOldSort ); + Sort( aSortParam, false, false ); } - ScRange aDirtyRange( aNewParam.nCol1, aNewParam.nRow1, nTab, - aNewParam.nCol2, aNewParam.nRow2, nTab ); - rDoc.SetDirty( aDirtyRange, true ); - if (bRecord) - { - pDocSh->GetUndoManager()->AddUndoAction( - std::make_unique( pDocSh, nTab, - rParam, aNewParam.nRow2, - std::move(pUndoDoc), std::move(pUndoTab), // pUndoDBData, - std::move(pUndoRange), std::move(pUndoDB) ) ); - } + bSuccess = rDoc.DoSubTotals( nTab, aNewParam ); + } + ScRange aDirtyRange( aNewParam.nCol1, aNewParam.nRow1, nTab, + aNewParam.nCol2, aNewParam.nRow2, nTab ); + rDoc.SetDirty( aDirtyRange, true ); - if (!bSuccess) - { - // "Can not insert any rows" - ErrorMessage(STR_MSSG_DOSUBTOTALS_2); - } + if (bRecord) + { + pDocSh->GetUndoManager()->AddUndoAction( + std::make_unique( pDocSh, nTab, + rParam, aNewParam.nRow2, + std::move(pUndoDoc), std::move(pUndoTab), // pUndoDBData, + std::move(pUndoRange), std::move(pUndoDB) ) ); + } - // store - pDBData->SetSubTotalParam( aNewParam ); - pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 ); - rDoc.CompileDBFormula(); + if (!bSuccess) + { + // "Can not insert any rows" + ErrorMessage(STR_MSSG_DOSUBTOTALS_2); + } - DoneBlockMode(); - InitOwnBlockMode(); - rMark.SetMarkArea( ScRange( aNewParam.nCol1,aNewParam.nRow1,nTab, - aNewParam.nCol2,aNewParam.nRow2,nTab ) ); - MarkDataChanged(); + // store + pDBData->SetSubTotalParam( aNewParam ); + pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 ); + rDoc.CompileDBFormula(); - pDocSh->PostPaint(ScRange(0, 0, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab), - PaintPartFlags::Grid | PaintPartFlags::Left | PaintPartFlags::Top | PaintPartFlags::Size); + DoneBlockMode(); + InitOwnBlockMode(); + rMark.SetMarkArea( ScRange( aNewParam.nCol1,aNewParam.nRow1,nTab, + aNewParam.nCol2,aNewParam.nRow2,nTab ) ); + MarkDataChanged(); - aModificator.SetDocumentModified(); + pDocSh->PostPaint(ScRange(0, 0, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab), + PaintPartFlags::Grid | PaintPartFlags::Left | PaintPartFlags::Top | PaintPartFlags::Size); - SelectionChanged(); - } + aModificator.SetDocumentModified(); + + SelectionChanged(); } // consolidate @@ -1945,86 +1945,86 @@ void ScDBFunc::SetDataPilotDetails(bool bShow, const OUString* pNewDimensionName { ScDPObject* pDPObj = GetViewData().GetDocument()->GetDPAtCursor( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() ); - if ( pDPObj ) - { - ScDPUniqueStringSet aEntries; - long nSelectDimension = -1; - GetSelectedMemberList( aEntries, nSelectDimension ); + if ( !pDPObj ) + return; - if (!aEntries.empty()) - { - bool bIsDataLayout; - OUString aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout ); - if ( !bIsDataLayout ) - { - ScDPSaveData aData( *pDPObj->GetSaveData() ); - ScDPSaveDimension* pDim = aData.GetDimensionByName( aDimName ); + ScDPUniqueStringSet aEntries; + long nSelectDimension = -1; + GetSelectedMemberList( aEntries, nSelectDimension ); - if ( bShow && pNewDimensionName ) - { - // add the new dimension with the same orientation, at the end + if (aEntries.empty()) + return; - ScDPSaveDimension* pNewDim = aData.GetDimensionByName( *pNewDimensionName ); - ScDPSaveDimension* pDuplicated = nullptr; - if ( pNewDim->GetOrientation() == sheet::DataPilotFieldOrientation_DATA ) - { - // Need to duplicate the dimension, create column/row in addition to data: - // The duplicated dimension inherits the existing settings, pNewDim is modified below. - pDuplicated = aData.DuplicateDimension( *pNewDimensionName ); - } + bool bIsDataLayout; + OUString aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout ); + if ( bIsDataLayout ) + return; - css::sheet::DataPilotFieldOrientation nOrientation = pDim->GetOrientation(); - pNewDim->SetOrientation( nOrientation ); + ScDPSaveData aData( *pDPObj->GetSaveData() ); + ScDPSaveDimension* pDim = aData.GetDimensionByName( aDimName ); - long nPosition = LONG_MAX; - aData.SetPosition( pNewDim, nPosition ); + if ( bShow && pNewDimensionName ) + { + // add the new dimension with the same orientation, at the end - ScDPSaveDimension* pDataLayout = aData.GetDataLayoutDimension(); - if ( pDataLayout->GetOrientation() == nOrientation && - aData.GetDataDimensionCount() <= 1 ) - { - // If there is only one data dimension, the data layout dimension - // must still be the last one in its orientation. - aData.SetPosition( pDataLayout, nPosition ); - } + ScDPSaveDimension* pNewDim = aData.GetDimensionByName( *pNewDimensionName ); + ScDPSaveDimension* pDuplicated = nullptr; + if ( pNewDim->GetOrientation() == sheet::DataPilotFieldOrientation_DATA ) + { + // Need to duplicate the dimension, create column/row in addition to data: + // The duplicated dimension inherits the existing settings, pNewDim is modified below. + pDuplicated = aData.DuplicateDimension( *pNewDimensionName ); + } - if ( pDuplicated ) - { - // The duplicated (data) dimension needs to be behind the original dimension - aData.SetPosition( pDuplicated, nPosition ); - } + css::sheet::DataPilotFieldOrientation nOrientation = pDim->GetOrientation(); + pNewDim->SetOrientation( nOrientation ); - // Hide details for all visible members (selected are changed below). - //! Use all members from source level instead (including non-visible)? + long nPosition = LONG_MAX; + aData.SetPosition( pNewDim, nPosition ); - ScDPUniqueStringSet aVisibleEntries; - pDPObj->GetMemberResultNames( aVisibleEntries, nSelectDimension ); + ScDPSaveDimension* pDataLayout = aData.GetDataLayoutDimension(); + if ( pDataLayout->GetOrientation() == nOrientation && + aData.GetDataDimensionCount() <= 1 ) + { + // If there is only one data dimension, the data layout dimension + // must still be the last one in its orientation. + aData.SetPosition( pDataLayout, nPosition ); + } - for (const OUString& aVisName : aVisibleEntries) - { - ScDPSaveMember* pMember = pDim->GetMemberByName( aVisName ); - pMember->SetShowDetails( false ); - } - } + if ( pDuplicated ) + { + // The duplicated (data) dimension needs to be behind the original dimension + aData.SetPosition( pDuplicated, nPosition ); + } - for (const auto& rEntry : aEntries) - { - ScDPSaveMember* pMember = pDim->GetMemberByName(rEntry); - pMember->SetShowDetails( bShow ); - } + // Hide details for all visible members (selected are changed below). + //! Use all members from source level instead (including non-visible)? - // apply changes - ScDBDocFunc aFunc( *GetViewData().GetDocShell() ); - std::unique_ptr pNewObj(new ScDPObject( *pDPObj )); - pNewObj->SetSaveData( aData ); - aFunc.DataPilotUpdate( pDPObj, pNewObj.get(), true, false ); - pNewObj.reset(); + ScDPUniqueStringSet aVisibleEntries; + pDPObj->GetMemberResultNames( aVisibleEntries, nSelectDimension ); - // unmark cell selection - Unmark(); - } + for (const OUString& aVisName : aVisibleEntries) + { + ScDPSaveMember* pMember = pDim->GetMemberByName( aVisName ); + pMember->SetShowDetails( false ); } } + + for (const auto& rEntry : aEntries) + { + ScDPSaveMember* pMember = pDim->GetMemberByName(rEntry); + pMember->SetShowDetails( bShow ); + } + + // apply changes + ScDBDocFunc aFunc( *GetViewData().GetDocShell() ); + std::unique_ptr pNewObj(new ScDPObject( *pDPObj )); + pNewObj->SetSaveData( aData ); + aFunc.DataPilotUpdate( pDPObj, pNewObj.get(), true, false ); + pNewObj.reset(); + + // unmark cell selection + Unmark(); } void ScDBFunc::ShowDataPilotSourceData( ScDPObject& rDPObj, const Sequence& rFilters ) diff --git a/sc/source/ui/view/drawvie3.cxx b/sc/source/ui/view/drawvie3.cxx index 9a657ddb7361..83dcd0305fc5 100644 --- a/sc/source/ui/view/drawvie3.cxx +++ b/sc/source/ui/view/drawvie3.cxx @@ -57,27 +57,27 @@ ScDrawView::ScDrawView( void ScDrawView::SetPageAnchored() { - if( AreObjectsMarked() ) - { - const SdrMarkList* pMark = &GetMarkedObjectList(); - const size_t nCount = pMark->GetMarkCount(); - - BegUndo(ScResId(SCSTR_UNDO_PAGE_ANCHOR)); - for( size_t i=0; iGetMark(i)->GetMarkedSdrObj(); - AddUndo (std::make_unique( pObj, pDoc, nTab )); - ScDrawLayer::SetPageAnchored( *pObj ); - } - EndUndo(); + if( !AreObjectsMarked() ) + return; - if ( pViewData ) - pViewData->GetDocShell()->SetDrawModified(); + const SdrMarkList* pMark = &GetMarkedObjectList(); + const size_t nCount = pMark->GetMarkCount(); - // Remove the anchor object. - maHdlList.RemoveAllByKind(SdrHdlKind::Anchor); - maHdlList.RemoveAllByKind(SdrHdlKind::Anchor_TR); + BegUndo(ScResId(SCSTR_UNDO_PAGE_ANCHOR)); + for( size_t i=0; iGetMark(i)->GetMarkedSdrObj(); + AddUndo (std::make_unique( pObj, pDoc, nTab )); + ScDrawLayer::SetPageAnchored( *pObj ); } + EndUndo(); + + if ( pViewData ) + pViewData->GetDocShell()->SetDrawModified(); + + // Remove the anchor object. + maHdlList.RemoveAllByKind(SdrHdlKind::Anchor); + maHdlList.RemoveAllByKind(SdrHdlKind::Anchor_TR); } void ScDrawView::SetCellAnchored(bool bResizeWithCell) @@ -85,27 +85,27 @@ void ScDrawView::SetCellAnchored(bool bResizeWithCell) if (!pDoc) return; - if( AreObjectsMarked() ) - { - const SdrMarkList* pMark = &GetMarkedObjectList(); - const size_t nCount = pMark->GetMarkCount(); + if( !AreObjectsMarked() ) + return; - BegUndo(ScResId(SCSTR_UNDO_CELL_ANCHOR)); - for( size_t i=0; iGetMark(i)->GetMarkedSdrObj(); - AddUndo (std::make_unique( pObj, pDoc, nTab )); - ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, nTab, bResizeWithCell); - } - EndUndo(); + const SdrMarkList* pMark = &GetMarkedObjectList(); + const size_t nCount = pMark->GetMarkCount(); - if ( pViewData ) - { - pViewData->GetDocShell()->SetDrawModified(); + BegUndo(ScResId(SCSTR_UNDO_CELL_ANCHOR)); + for( size_t i=0; iGetMark(i)->GetMarkedSdrObj(); + AddUndo (std::make_unique( pObj, pDoc, nTab )); + ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, nTab, bResizeWithCell); + } + EndUndo(); - // Set the anchor object. - AddCustomHdl(); - } + if ( pViewData ) + { + pViewData->GetDocShell()->SetDrawModified(); + + // Set the anchor object. + AddCustomHdl(); } } @@ -204,32 +204,32 @@ void ScDrawView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) void ScDrawView::UpdateIMap( SdrObject* pObj ) { - if ( pViewData && + if ( !(pViewData && pViewData->GetViewShell()->GetViewFrame()->HasChildWindow( ScIMapChildWindowId() ) && - pObj && ( dynamic_cast( pObj) != nullptr || dynamic_cast( pObj) != nullptr ) ) - { - Graphic aGraphic; - TargetList aTargetList; - SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo( pObj ); - const ImageMap* pImageMap = nullptr; - if ( pIMapInfo ) - pImageMap = &pIMapInfo->GetImageMap(); - - // handle target list - SfxViewFrame::GetTargetList( aTargetList ); - - // handle graphics from object - if ( dynamic_cast( pObj) != nullptr ) - aGraphic = static_cast(pObj)->GetGraphic(); - else - { - const Graphic* pGraphic = static_cast(pObj)->GetGraphic(); - if ( pGraphic ) - aGraphic = *pGraphic; - } + pObj && ( dynamic_cast( pObj) != nullptr || dynamic_cast( pObj) != nullptr )) ) + return; + + Graphic aGraphic; + TargetList aTargetList; + SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo( pObj ); + const ImageMap* pImageMap = nullptr; + if ( pIMapInfo ) + pImageMap = &pIMapInfo->GetImageMap(); - ScIMapDlgSet( aGraphic, pImageMap, &aTargetList, pObj ); // from imapwrap + // handle target list + SfxViewFrame::GetTargetList( aTargetList ); + + // handle graphics from object + if ( dynamic_cast( pObj) != nullptr ) + aGraphic = static_cast(pObj)->GetGraphic(); + else + { + const Graphic* pGraphic = static_cast(pObj)->GetGraphic(); + if ( pGraphic ) + aGraphic = *pGraphic; } + + ScIMapDlgSet( aGraphic, pImageMap, &aTargetList, pObj ); // from imapwrap } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx index 178f43c45f24..5c6364850308 100644 --- a/sc/source/ui/view/drawvie4.cxx +++ b/sc/source/ui/view/drawvie4.cxx @@ -56,48 +56,48 @@ Point aDragStartDiff; void ScDrawView::BeginDrag( vcl::Window* pWindow, const Point& rStartPos ) { - if ( AreObjectsMarked() ) - { - BrkAction(); + if ( !AreObjectsMarked() ) + return; - tools::Rectangle aMarkedRect = GetAllMarkedRect(); + BrkAction(); - aDragStartDiff = rStartPos - aMarkedRect.TopLeft(); + tools::Rectangle aMarkedRect = GetAllMarkedRect(); - bool bAnyOle, bOneOle; - const SdrMarkList& rMarkList = GetMarkedObjectList(); - CheckOle( rMarkList, bAnyOle, bOneOle ); + aDragStartDiff = rStartPos - aMarkedRect.TopLeft(); - ScDocShellRef aDragShellRef; - if (bAnyOle) - { - aDragShellRef = new ScDocShell; // DocShell needs a Ref immediately - aDragShellRef->DoInitNew(); - } - ScDrawLayer::SetGlobalDrawPersist( aDragShellRef.get() ); - std::unique_ptr pModel(CreateMarkedObjModel()); - ScDrawLayer::SetGlobalDrawPersist(nullptr); + bool bAnyOle, bOneOle; + const SdrMarkList& rMarkList = GetMarkedObjectList(); + CheckOle( rMarkList, bAnyOle, bOneOle ); - // Charts now always copy their data in addition to the source reference, so - // there's no need to call SchDLL::Update for the charts in the clipboard doc. - // Update with the data (including NumberFormatter) from the live document would - // also store the NumberFormatter in the clipboard chart (#88749#) + ScDocShellRef aDragShellRef; + if (bAnyOle) + { + aDragShellRef = new ScDocShell; // DocShell needs a Ref immediately + aDragShellRef->DoInitNew(); + } + ScDrawLayer::SetGlobalDrawPersist( aDragShellRef.get() ); + std::unique_ptr pModel(CreateMarkedObjModel()); + ScDrawLayer::SetGlobalDrawPersist(nullptr); - ScDocShell* pDocSh = pViewData->GetDocShell(); + // Charts now always copy their data in addition to the source reference, so + // there's no need to call SchDLL::Update for the charts in the clipboard doc. + // Update with the data (including NumberFormatter) from the live document would + // also store the NumberFormatter in the clipboard chart (#88749#) - TransferableObjectDescriptor aObjDesc; - pDocSh->FillTransferableObjectDescriptor( aObjDesc ); - aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); - // maSize is set in ScDrawTransferObj ctor + ScDocShell* pDocSh = pViewData->GetDocShell(); - rtl::Reference pTransferObj = new ScDrawTransferObj( std::move(pModel), pDocSh, aObjDesc ); + TransferableObjectDescriptor aObjDesc; + pDocSh->FillTransferableObjectDescriptor( aObjDesc ); + aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); + // maSize is set in ScDrawTransferObj ctor - pTransferObj->SetDrawPersist( aDragShellRef.get() ); // keep persist for ole objects alive - pTransferObj->SetDragSource( this ); // copies selection + rtl::Reference pTransferObj = new ScDrawTransferObj( std::move(pModel), pDocSh, aObjDesc ); - SC_MOD()->SetDragObject( nullptr, pTransferObj.get() ); // for internal D&D - pTransferObj->StartDrag( pWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK ); - } + pTransferObj->SetDrawPersist( aDragShellRef.get() ); // keep persist for ole objects alive + pTransferObj->SetDragSource( this ); // copies selection + + SC_MOD()->SetDragObject( nullptr, pTransferObj.get() ); // for internal D&D + pTransferObj->StartDrag( pWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK ); } namespace { diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index f15b6c57c310..4fe6c0cbdc76 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -209,34 +209,34 @@ void ScDrawView::InvalidateDrawTextAttrs() void ScDrawView::SetMarkedToLayer( SdrLayerID nLayerNo ) { - if (AreObjectsMarked()) - { - // #i11702# use SdrUndoObjectLayerChange for undo - // STR_UNDO_SELATTR is "Attributes" - should use a different text later - BegUndo( ScResId( STR_UNDO_SELATTR ) ); + if (!AreObjectsMarked()) + return; + + // #i11702# use SdrUndoObjectLayerChange for undo + // STR_UNDO_SELATTR is "Attributes" - should use a different text later + BegUndo( ScResId( STR_UNDO_SELATTR ) ); - const SdrMarkList& rMark = GetMarkedObjectList(); - const size_t nCount = rMark.GetMarkCount(); - for (size_t i=0; iGetMarkedSdrObj(); + if ( dynamic_cast( pObj) == nullptr && (pObj->GetLayer() != SC_LAYER_INTERN) ) { - SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj(); - if ( dynamic_cast( pObj) == nullptr && (pObj->GetLayer() != SC_LAYER_INTERN) ) - { - AddUndo( std::make_unique( *pObj, pObj->GetLayer(), nLayerNo) ); - pObj->SetLayer( nLayerNo ); - } + AddUndo( std::make_unique( *pObj, pObj->GetLayer(), nLayerNo) ); + pObj->SetLayer( nLayerNo ); } + } - EndUndo(); + EndUndo(); - // repaint is done in SetLayer + // repaint is done in SetLayer - pViewData->GetDocShell()->SetDrawModified(); + pViewData->GetDocShell()->SetDrawModified(); - // check mark list now instead of later in a timer - CheckMarked(); - MarkListHasChanged(); - } + // check mark list now instead of later in a timer + CheckMarked(); + MarkListHasChanged(); } bool ScDrawView::HasMarkedControl() const @@ -332,17 +332,17 @@ void ScDrawView::RecalcScale() resetGridOffsetsForAllSdrPageViews(); SdrPageView* pPV = GetSdrPageView(); - if ( pViewData && pPV ) + if ( !(pViewData && pPV) ) + return; + + if ( SdrPage* pPage = pPV->GetPage() ) { - if ( SdrPage* pPage = pPV->GetPage() ) + const size_t nCount = pPage->GetObjCount(); + for ( size_t i = 0; i < nCount; ++i ) { - const size_t nCount = pPage->GetObjCount(); - for ( size_t i = 0; i < nCount; ++i ) - { - SdrObject* pObj = pPage->GetObj( i ); - // Align objects to nearest grid position - SyncForGrid( pObj ); - } + SdrObject* pObj = pPage->GetObj( i ); + // Align objects to nearest grid position + SyncForGrid( pObj ); } } } @@ -623,26 +623,26 @@ void ScDrawView::ModelHasChanged() void ScDrawView::UpdateUserViewOptions() { - if (pViewData) - { - const ScViewOptions& rOpt = pViewData->GetOptions(); - const ScGridOptions& rGrid = rOpt.GetGridOptions(); + if (!pViewData) + return; - SetDragStripes( rOpt.GetOption( VOPT_HELPLINES ) ); - SetMarkHdlSizePixel( SC_HANDLESIZE_BIG ); + const ScViewOptions& rOpt = pViewData->GetOptions(); + const ScGridOptions& rGrid = rOpt.GetGridOptions(); - SetGridVisible( rGrid.GetGridVisible() ); - SetSnapEnabled( rGrid.GetUseGridSnap() ); - SetGridSnap( rGrid.GetUseGridSnap() ); + SetDragStripes( rOpt.GetOption( VOPT_HELPLINES ) ); + SetMarkHdlSizePixel( SC_HANDLESIZE_BIG ); - Fraction aFractX( rGrid.GetFieldDrawX(), rGrid.GetFieldDivisionX() + 1 ); - Fraction aFractY( rGrid.GetFieldDrawY(), rGrid.GetFieldDivisionY() + 1 ); - SetSnapGridWidth( aFractX, aFractY ); + SetGridVisible( rGrid.GetGridVisible() ); + SetSnapEnabled( rGrid.GetUseGridSnap() ); + SetGridSnap( rGrid.GetUseGridSnap() ); - SetGridCoarse( Size( rGrid.GetFieldDrawX(), rGrid.GetFieldDrawY() ) ); - SetGridFine( Size( rGrid.GetFieldDrawX() / (rGrid.GetFieldDivisionX() + 1), - rGrid.GetFieldDrawY() / (rGrid.GetFieldDivisionY() + 1) ) ); - } + Fraction aFractX( rGrid.GetFieldDrawX(), rGrid.GetFieldDivisionX() + 1 ); + Fraction aFractY( rGrid.GetFieldDrawY(), rGrid.GetFieldDivisionY() + 1 ); + SetSnapGridWidth( aFractX, aFractY ); + + SetGridCoarse( Size( rGrid.GetFieldDrawX(), rGrid.GetFieldDrawY() ) ); + SetGridFine( Size( rGrid.GetFieldDrawX() / (rGrid.GetFieldDivisionX() + 1), + rGrid.GetFieldDrawY() / (rGrid.GetFieldDivisionY() + 1) ) ); } SdrObject* ScDrawView::GetObjectByName(const OUString& rName) @@ -705,26 +705,26 @@ void ScDrawView::SelectCurrentViewObject( const OUString& rName ) } } } - if ( pFound ) + if ( !pFound ) + return; + + ScTabView* pView = pViewData->GetView(); + if ( nObjectTab != nTab ) // switch sheet + pView->SetTabNo( nObjectTab ); + DBG_ASSERT( nTab == nObjectTab, "Switching sheets did not work" ); + pView->ScrollToObject( pFound ); + if ( pFound->GetLayer() == SC_LAYER_BACK && + !pViewData->GetViewShell()->IsDrawSelMode() && + !pDoc->IsTabProtected( nTab ) && + !pViewData->GetSfxDocShell()->IsReadOnly() ) { - ScTabView* pView = pViewData->GetView(); - if ( nObjectTab != nTab ) // switch sheet - pView->SetTabNo( nObjectTab ); - DBG_ASSERT( nTab == nObjectTab, "Switching sheets did not work" ); - pView->ScrollToObject( pFound ); - if ( pFound->GetLayer() == SC_LAYER_BACK && - !pViewData->GetViewShell()->IsDrawSelMode() && - !pDoc->IsTabProtected( nTab ) && - !pViewData->GetSfxDocShell()->IsReadOnly() ) - { - SdrLayer* pLayer = GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_BACK); - if (pLayer) - SetLayerLocked( pLayer->GetName(), false ); - } - SdrPageView* pPV = GetSdrPageView(); - const bool bUnMark = IsObjMarked(pFound); - MarkObj( pFound, pPV, bUnMark); + SdrLayer* pLayer = GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_BACK); + if (pLayer) + SetLayerLocked( pLayer->GetName(), false ); } + SdrPageView* pPV = GetSdrPageView(); + const bool bUnMark = IsObjMarked(pFound); + MarkObj( pFound, pPV, bUnMark); } bool ScDrawView::SelectObject( const OUString& rName ) @@ -933,61 +933,61 @@ void ScDrawView::SyncForGrid( SdrObject* pObj ) ScSplitPos eWhich = pViewData->GetActivePart(); ScGridWindow* pGridWin = pViewData->GetActiveWin(); ScDrawObjData* pData = ScDrawLayer::GetObjData( pObj ); - if ( pGridWin ) + if ( !pGridWin ) + return; + + ScAddress aOldStt; + if( pData && pData->maStart.IsValid()) { - ScAddress aOldStt; - if( pData && pData->maStart.IsValid()) - { - aOldStt = pData->maStart; - } - else - { - // Page anchored object so... - // synthesise an anchor ( but don't attach it to - // the object as we want to maintain page anchoring ) - ScDrawObjData aAnchor; - const tools::Rectangle aObjRect(pObj->GetLogicRect()); - ScDrawLayer::GetCellAnchorFromPosition( - aObjRect, - aAnchor, - *pDoc, - GetTab()); - aOldStt = aAnchor.maStart; - } - MapMode aDrawMode = pGridWin->GetDrawMapMode(); - // find pos anchor position - Point aOldPos( pDoc->GetColOffset( aOldStt.Col(), aOldStt.Tab() ), pDoc->GetRowOffset( aOldStt.Row(), aOldStt.Tab() ) ); - aOldPos.setX( sc::TwipsToHMM( aOldPos.X() ) ); - aOldPos.setY( sc::TwipsToHMM( aOldPos.Y() ) ); - // find position of same point on the screen ( e.g. grid ) - Point aCurPos = pViewData->GetScrPos( aOldStt.Col(), aOldStt.Row(), eWhich, true ); - Point aCurPosHmm = pGridWin->PixelToLogic(aCurPos, aDrawMode ); - Point aGridOff = aCurPosHmm - aOldPos; - // fdo#63878 Fix the X position for RTL Sheet - if( pDoc->IsNegativePage( GetTab() ) ) - aGridOff.setX( aCurPosHmm.getX() + aOldPos.getX() ); + aOldStt = pData->maStart; } + else + { + // Page anchored object so... + // synthesise an anchor ( but don't attach it to + // the object as we want to maintain page anchoring ) + ScDrawObjData aAnchor; + const tools::Rectangle aObjRect(pObj->GetLogicRect()); + ScDrawLayer::GetCellAnchorFromPosition( + aObjRect, + aAnchor, + *pDoc, + GetTab()); + aOldStt = aAnchor.maStart; + } + MapMode aDrawMode = pGridWin->GetDrawMapMode(); + // find pos anchor position + Point aOldPos( pDoc->GetColOffset( aOldStt.Col(), aOldStt.Tab() ), pDoc->GetRowOffset( aOldStt.Row(), aOldStt.Tab() ) ); + aOldPos.setX( sc::TwipsToHMM( aOldPos.X() ) ); + aOldPos.setY( sc::TwipsToHMM( aOldPos.Y() ) ); + // find position of same point on the screen ( e.g. grid ) + Point aCurPos = pViewData->GetScrPos( aOldStt.Col(), aOldStt.Row(), eWhich, true ); + Point aCurPosHmm = pGridWin->PixelToLogic(aCurPos, aDrawMode ); + Point aGridOff = aCurPosHmm - aOldPos; + // fdo#63878 Fix the X position for RTL Sheet + if( pDoc->IsNegativePage( GetTab() ) ) + aGridOff.setX( aCurPosHmm.getX() + aOldPos.getX() ); } void ScDrawView::resetGridOffsetsForAllSdrPageViews() { SdrPageView* pPageView(GetSdrPageView()); - if(nullptr != pPageView) + if(nullptr == pPageView) + return; + + for(sal_uInt32 a(0); a < pPageView->PageWindowCount(); a++) { - for(sal_uInt32 a(0); a < pPageView->PageWindowCount(); a++) + SdrPageWindow* pPageWindow(pPageView->GetPageWindow(a)); + assert(pPageWindow && "SdrView::SetMasterPagePaintCaching: Corrupt SdrPageWindow list (!)"); + + if(nullptr != pPageWindow) { - SdrPageWindow* pPageWindow(pPageView->GetPageWindow(a)); - assert(pPageWindow && "SdrView::SetMasterPagePaintCaching: Corrupt SdrPageWindow list (!)"); + sdr::contact::ObjectContact& rObjectContact(pPageWindow->GetObjectContact()); - if(nullptr != pPageWindow) + if(rObjectContact.supportsGridOffsets()) { - sdr::contact::ObjectContact& rObjectContact(pPageWindow->GetObjectContact()); - - if(rObjectContact.supportsGridOffsets()) - { - rObjectContact.resetAllGridOffsets(); - } + rObjectContact.resetAllGridOffsets(); } } } diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index 8460a59fb79d..11a100da976c 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -1330,23 +1330,23 @@ void ScEditShell::GetUndoState(SfxItemSet &rSet) void ScEditShell::ExecuteTrans( const SfxRequest& rReq ) { TransliterationFlags nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() ); - if ( nType != TransliterationFlags::NONE ) - { - ScInputHandler* pHdl = GetMyInputHdl(); - assert(pHdl && "no ScInputHandler"); + if ( nType == TransliterationFlags::NONE ) + return; - EditView* pTopView = pHdl->GetTopView(); - EditView* pTableView = pHdl->GetTableView(); - assert(pTableView && "no EditView"); + ScInputHandler* pHdl = GetMyInputHdl(); + assert(pHdl && "no ScInputHandler"); + + EditView* pTopView = pHdl->GetTopView(); + EditView* pTableView = pHdl->GetTableView(); + assert(pTableView && "no EditView"); - pHdl->DataChanging(); + pHdl->DataChanging(); - pTableView->TransliterateText( nType ); - if (pTopView) - pTopView->TransliterateText( nType ); + pTableView->TransliterateText( nType ); + if (pTopView) + pTopView->TransliterateText( nType ); - pHdl->DataChanged(); - } + pHdl->DataChanged(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/gridmerg.cxx b/sc/source/ui/view/gridmerg.cxx index 5ab7ef8e266d..a07937207dc4 100644 --- a/sc/source/ui/view/gridmerg.cxx +++ b/sc/source/ui/view/gridmerg.cxx @@ -183,45 +183,45 @@ void ScGridMerger::AddVerLine(bool bWorksInPixels, long nX, long nY1, long nY2, void ScGridMerger::Flush() { - if (nCount) + if (!nCount) + return; + + if (bVertical) { - if (bVertical) + if ( nCount == 1 ) + pDev->DrawLine( Point( nVarStart, nFixStart ), Point( nVarStart, nFixEnd ) ); + else { - if ( nCount == 1 ) - pDev->DrawLine( Point( nVarStart, nFixStart ), Point( nVarStart, nFixEnd ) ); - else + long nVarEnd = nVarStart + ( nCount - 1 ) * nVarDiff; + if ( nVarDiff < 0 ) { - long nVarEnd = nVarStart + ( nCount - 1 ) * nVarDiff; - if ( nVarDiff < 0 ) - { - // nVarDiff is negative in RTL layout mode - // Change the positions so DrawGrid is called with a positive distance - // (nVarStart / nVarDiff can be modified, aren't used after Flush) - - nVarDiff = -nVarDiff; - long nTemp = nVarStart; - nVarStart = nVarEnd; - nVarEnd = nTemp; - } - pDev->DrawGrid( tools::Rectangle( nVarStart, nFixStart, nVarEnd, nFixEnd ), - Size( nVarDiff, nFixEnd - nFixStart ), - DrawGridFlags::VertLines ); + // nVarDiff is negative in RTL layout mode + // Change the positions so DrawGrid is called with a positive distance + // (nVarStart / nVarDiff can be modified, aren't used after Flush) + + nVarDiff = -nVarDiff; + long nTemp = nVarStart; + nVarStart = nVarEnd; + nVarEnd = nTemp; } + pDev->DrawGrid( tools::Rectangle( nVarStart, nFixStart, nVarEnd, nFixEnd ), + Size( nVarDiff, nFixEnd - nFixStart ), + DrawGridFlags::VertLines ); } + } + else + { + if ( nCount == 1 ) + pDev->DrawLine( Point( nFixStart, nVarStart ), Point( nFixEnd, nVarStart ) ); else { - if ( nCount == 1 ) - pDev->DrawLine( Point( nFixStart, nVarStart ), Point( nFixEnd, nVarStart ) ); - else - { - long nVarEnd = nVarStart + ( nCount - 1 ) * nVarDiff; - pDev->DrawGrid( tools::Rectangle( nFixStart, nVarStart, nFixEnd, nVarEnd ), - Size( nFixEnd - nFixStart, nVarDiff ), - DrawGridFlags::HorzLines ); - } + long nVarEnd = nVarStart + ( nCount - 1 ) * nVarDiff; + pDev->DrawGrid( tools::Rectangle( nFixStart, nVarStart, nFixEnd, nVarEnd ), + Size( nFixEnd - nFixStart, nVarDiff ), + DrawGridFlags::HorzLines ); } - nCount = 0; } + nCount = 0; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 0b07934fb0f6..887903286ca3 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -1832,26 +1832,26 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta // Gridwin - Selection Engine - if ( rMEvt.IsLeft() ) - { - ScViewSelectionEngine* pSelEng = pViewData->GetView()->GetSelEngine(); - pSelEng->SetWindow(this); - pSelEng->SetWhich(eWhich); - pSelEng->SetVisibleArea( tools::Rectangle(Point(), GetOutputSizePixel()) ); + if ( !rMEvt.IsLeft() ) + return; - // SelMouseButtonDown on the View is still setting the bMoveIsShift flag - if ( pViewData->GetView()->SelMouseButtonDown( rMEvt ) ) + ScViewSelectionEngine* pSelEng = pViewData->GetView()->GetSelEngine(); + pSelEng->SetWindow(this); + pSelEng->SetWhich(eWhich); + pSelEng->SetVisibleArea( tools::Rectangle(Point(), GetOutputSizePixel()) ); + + // SelMouseButtonDown on the View is still setting the bMoveIsShift flag + if ( pViewData->GetView()->SelMouseButtonDown( rMEvt ) ) + { + if (IsMouseCaptured()) { - if (IsMouseCaptured()) - { - // Tracking instead of CaptureMouse, so it can be canceled cleanly - //! Someday SelectionEngine should call StartTracking on its own!?! - ReleaseMouse(); - StartTracking(); - } - pViewData->GetMarkData().SetMarking(true); - return; + // Tracking instead of CaptureMouse, so it can be canceled cleanly + //! Someday SelectionEngine should call StartTracking on its own!?! + ReleaseMouse(); + StartTracking(); } + pViewData->GetMarkData().SetMarking(true); + return; } } @@ -2315,57 +2315,57 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) // SelMouseButtonDown is called only for left button, but SelMouseButtonUp would return // sal_True for any call, so IsLeft must be checked here, too. - if ( rMEvt.IsLeft() && pViewData->GetView()->GetSelEngine()->SelMouseButtonUp( rMEvt ) ) - { - pViewData->GetView()->SelectionChanged(); + if ( !(rMEvt.IsLeft() && pViewData->GetView()->GetSelEngine()->SelMouseButtonUp( rMEvt )) ) + return; - SfxDispatcher* pDisp = pViewData->GetViewShell()->GetDispatcher(); - bool bFormulaMode = pScMod->IsFormulaMode(); - OSL_ENSURE( pDisp || bFormulaMode, "Cursor moved on inactive View ?" ); + pViewData->GetView()->SelectionChanged(); - // #i14927# execute SID_CURRENTCELL (for macro recording) only if there is no - // multiple selection, so the argument string completely describes the selection, - // and executing the slot won't change the existing selection (executing the slot - // here and from a recorded macro is treated equally) - if ( pDisp && !bFormulaMode && !rMark.IsMultiMarked() ) - { - OUString aAddr; // CurrentCell - if( rMark.IsMarked() ) - { - ScRange aScRange; - rMark.GetMarkArea( aScRange ); - aAddr = aScRange.Format(*pDoc, ScRefFlags::RANGE_ABS); - if ( aScRange.aStart == aScRange.aEnd ) - { - // make sure there is a range selection string even for a single cell - aAddr += ":" + aAddr; - } + SfxDispatcher* pDisp = pViewData->GetViewShell()->GetDispatcher(); + bool bFormulaMode = pScMod->IsFormulaMode(); + OSL_ENSURE( pDisp || bFormulaMode, "Cursor moved on inactive View ?" ); - //! SID_MARKAREA does not exist anymore ??? - //! What happens when selecting with the cursor ??? - } - else // only move cursor + // #i14927# execute SID_CURRENTCELL (for macro recording) only if there is no + // multiple selection, so the argument string completely describes the selection, + // and executing the slot won't change the existing selection (executing the slot + // here and from a recorded macro is treated equally) + if ( pDisp && !bFormulaMode && !rMark.IsMultiMarked() ) + { + OUString aAddr; // CurrentCell + if( rMark.IsMarked() ) + { + ScRange aScRange; + rMark.GetMarkArea( aScRange ); + aAddr = aScRange.Format(*pDoc, ScRefFlags::RANGE_ABS); + if ( aScRange.aStart == aScRange.aEnd ) { - ScAddress aScAddress( pViewData->GetCurX(), pViewData->GetCurY(), 0 ); - aAddr = aScAddress.Format(ScRefFlags::ADDR_ABS); + // make sure there is a range selection string even for a single cell + aAddr += ":" + aAddr; } - SfxStringItem aPosItem( SID_CURRENTCELL, aAddr ); - // We don't want to align to the cursor position because if the - // cell cursor isn't visible after making selection, it would jump - // back to the origin of the selection where the cell cursor is. - SfxBoolItem aAlignCursorItem( FN_PARAM_2, false ); - pDisp->ExecuteList(SID_CURRENTCELL, - SfxCallMode::SLOT | SfxCallMode::RECORD, - { &aPosItem, &aAlignCursorItem }); + //! SID_MARKAREA does not exist anymore ??? + //! What happens when selecting with the cursor ??? + } + else // only move cursor + { + ScAddress aScAddress( pViewData->GetCurX(), pViewData->GetCurY(), 0 ); + aAddr = aScAddress.Format(ScRefFlags::ADDR_ABS); + } - pViewData->GetView()->InvalidateAttribs(); + SfxStringItem aPosItem( SID_CURRENTCELL, aAddr ); + // We don't want to align to the cursor position because if the + // cell cursor isn't visible after making selection, it would jump + // back to the origin of the selection where the cell cursor is. + SfxBoolItem aAlignCursorItem( FN_PARAM_2, false ); + pDisp->ExecuteList(SID_CURRENTCELL, + SfxCallMode::SLOT | SfxCallMode::RECORD, + { &aPosItem, &aAlignCursorItem }); - } - pViewData->GetViewShell()->SelectionChanged(); + pViewData->GetView()->InvalidateAttribs(); - return; } + pViewData->GetViewShell()->SelectionChanged(); + + return; } void ScGridWindow::FakeButtonUp() @@ -2877,174 +2877,174 @@ void ScGridWindow::Command( const CommandEvent& rCEvt ) if (bDisable) return; - if ( nCmd == CommandEventId::ContextMenu && !SC_MOD()->GetIsWaterCan() ) - { - bool bMouse = rCEvt.IsMouseEvent(); - if ( bMouse && nMouseStatus == SC_GM_IGNORE ) - return; + if (nCmd != CommandEventId::ContextMenu || SC_MOD()->GetIsWaterCan()) + return; - if (pViewData->IsAnyFillMode()) - { - pViewData->GetView()->StopRefMode(); - pViewData->ResetFillMode(); - } - ReleaseMouse(); - StopMarking(); + bool bMouse = rCEvt.IsMouseEvent(); + if ( bMouse && nMouseStatus == SC_GM_IGNORE ) + return; + + if (pViewData->IsAnyFillMode()) + { + pViewData->GetView()->StopRefMode(); + pViewData->ResetFillMode(); + } + ReleaseMouse(); + StopMarking(); - Point aPosPixel = rCEvt.GetMousePosPixel(); - Point aMenuPos = aPosPixel; + Point aPosPixel = rCEvt.GetMousePosPixel(); + Point aMenuPos = aPosPixel; - SCCOL nCellX = -1; - SCROW nCellY = -1; - pViewData->GetPosFromPixel(aPosPixel.X(), aPosPixel.Y(), eWhich, nCellX, nCellY); + SCCOL nCellX = -1; + SCROW nCellY = -1; + pViewData->GetPosFromPixel(aPosPixel.X(), aPosPixel.Y(), eWhich, nCellX, nCellY); - bool bSpellError = false; - SCCOL nColSpellError = nCellX; + bool bSpellError = false; + SCCOL nColSpellError = nCellX; - if ( bMouse ) + if ( bMouse ) + { + ScDocument* pDoc = pViewData->GetDocument(); + SCTAB nTab = pViewData->GetTabNo(); + const ScTableProtection* pProtect = pDoc->GetTabProtection(nTab); + bool bSelectAllowed = true; + if ( pProtect && pProtect->isProtected() ) { - ScDocument* pDoc = pViewData->GetDocument(); - SCTAB nTab = pViewData->GetTabNo(); - const ScTableProtection* pProtect = pDoc->GetTabProtection(nTab); - bool bSelectAllowed = true; - if ( pProtect && pProtect->isProtected() ) - { - // This sheet is protected. Check if a context menu is allowed on this cell. - bool bCellProtected = pDoc->HasAttrib(nCellX, nCellY, nTab, nCellX, nCellY, nTab, HasAttrFlags::Protected); - bool bSelProtected = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); - bool bSelUnprotected = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS); + // This sheet is protected. Check if a context menu is allowed on this cell. + bool bCellProtected = pDoc->HasAttrib(nCellX, nCellY, nTab, nCellX, nCellY, nTab, HasAttrFlags::Protected); + bool bSelProtected = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); + bool bSelUnprotected = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS); - if (bCellProtected) - bSelectAllowed = bSelProtected; - else - bSelectAllowed = bSelUnprotected; - } - if (!bSelectAllowed) - // Selecting this cell is not allowed, neither is context menu. - return; + if (bCellProtected) + bSelectAllowed = bSelProtected; + else + bSelectAllowed = bSelUnprotected; + } + if (!bSelectAllowed) + // Selecting this cell is not allowed, neither is context menu. + return; - if (mpSpellCheckCxt) + if (mpSpellCheckCxt) + { + // Find the first string to the left for spell checking in case the current cell is empty. + ScAddress aPos(nCellX, nCellY, nTab); + ScRefCellValue aSpellCheckCell(*pDoc, aPos); + while (aSpellCheckCell.meType == CELLTYPE_NONE) { - // Find the first string to the left for spell checking in case the current cell is empty. - ScAddress aPos(nCellX, nCellY, nTab); - ScRefCellValue aSpellCheckCell(*pDoc, aPos); - while (aSpellCheckCell.meType == CELLTYPE_NONE) - { - // Loop until we get the first non-empty cell in the row. - aPos.IncCol(-1); - if (aPos.Col() < 0) - break; + // Loop until we get the first non-empty cell in the row. + aPos.IncCol(-1); + if (aPos.Col() < 0) + break; - aSpellCheckCell.assign(*pDoc, aPos); - } + aSpellCheckCell.assign(*pDoc, aPos); + } - if (aPos.Col() >= 0 && (aSpellCheckCell.meType == CELLTYPE_STRING || aSpellCheckCell.meType == CELLTYPE_EDIT)) - nColSpellError = aPos.Col(); + if (aPos.Col() >= 0 && (aSpellCheckCell.meType == CELLTYPE_STRING || aSpellCheckCell.meType == CELLTYPE_EDIT)) + nColSpellError = aPos.Col(); - bSpellError = (mpSpellCheckCxt->isMisspelled(nColSpellError, nCellY)); - if (bSpellError) - { - // Check and see if a misspelled word is under the mouse pointer. - bSpellError = IsSpellErrorAtPos(aPosPixel, nColSpellError, nCellY); - } + bSpellError = (mpSpellCheckCxt->isMisspelled(nColSpellError, nCellY)); + if (bSpellError) + { + // Check and see if a misspelled word is under the mouse pointer. + bSpellError = IsSpellErrorAtPos(aPosPixel, nColSpellError, nCellY); } - - // #i18735# First select the item under the mouse pointer. - // This can change the selection, and the view state (edit mode, etc). - SelectForContextMenu(aPosPixel, bSpellError ? nColSpellError : nCellX, nCellY); } - bool bDone = false; - bool bEdit = pViewData->HasEditView(eWhich); + // #i18735# First select the item under the mouse pointer. + // This can change the selection, and the view state (edit mode, etc). + SelectForContextMenu(aPosPixel, bSpellError ? nColSpellError : nCellX, nCellY); + } - if ( !bEdit ) + bool bDone = false; + bool bEdit = pViewData->HasEditView(eWhich); + + if ( !bEdit ) + { + // Edit cell with spelling errors ? + if (bMouse && (GetEditUrl(aPosPixel) || bSpellError)) { - // Edit cell with spelling errors ? - if (bMouse && (GetEditUrl(aPosPixel) || bSpellError)) - { - // GetEditUrlOrError has already moved the Cursor + // GetEditUrlOrError has already moved the Cursor - pScMod->SetInputMode( SC_INPUT_TABLE ); - bEdit = pViewData->HasEditView(eWhich); // Did it work? + pScMod->SetInputMode( SC_INPUT_TABLE ); + bEdit = pViewData->HasEditView(eWhich); // Did it work? - OSL_ENSURE( bEdit, "Can not be switched in edit mode" ); - } + OSL_ENSURE( bEdit, "Can not be switched in edit mode" ); } - if ( bEdit ) - { - EditView* pEditView = pViewData->GetEditView( eWhich ); // is then not 0 + } + if ( bEdit ) + { + EditView* pEditView = pViewData->GetEditView( eWhich ); // is then not 0 - if ( !bMouse ) + if ( !bMouse ) + { + vcl::Cursor* pCur = pEditView->GetCursor(); + if ( pCur ) { - vcl::Cursor* pCur = pEditView->GetCursor(); - if ( pCur ) - { - Point aLogicPos = pCur->GetPos(); - // use the position right of the cursor (spell popup is opened if - // the cursor is before the word, but not if behind it) - aLogicPos.AdjustX(pCur->GetWidth() ); - aLogicPos.AdjustY(pCur->GetHeight() / 2 ); // center vertically - aMenuPos = LogicToPixel( aLogicPos ); - } + Point aLogicPos = pCur->GetPos(); + // use the position right of the cursor (spell popup is opened if + // the cursor is before the word, but not if behind it) + aLogicPos.AdjustX(pCur->GetWidth() ); + aLogicPos.AdjustY(pCur->GetHeight() / 2 ); // center vertically + aMenuPos = LogicToPixel( aLogicPos ); } + } - // if edit mode was just started above, online spelling may be incomplete - pEditView->GetEditEngine()->CompleteOnlineSpelling(); + // if edit mode was just started above, online spelling may be incomplete + pEditView->GetEditEngine()->CompleteOnlineSpelling(); - // IsCursorAtWrongSpelledWord could be used for !bMouse - // if there was a corresponding ExecuteSpellPopup call + // IsCursorAtWrongSpelledWord could be used for !bMouse + // if there was a corresponding ExecuteSpellPopup call - if (bSpellError) - { - // On OS/2 when clicking next to the Popup menu, the MouseButtonDown - // comes before the end of menu execute, thus the SetModified has to - // be done prior to this (Bug #40968#) - ScInputHandler* pHdl = pScMod->GetInputHdl(); - if (pHdl) - pHdl->SetModified(); + if (bSpellError) + { + // On OS/2 when clicking next to the Popup menu, the MouseButtonDown + // comes before the end of menu execute, thus the SetModified has to + // be done prior to this (Bug #40968#) + ScInputHandler* pHdl = pScMod->GetInputHdl(); + if (pHdl) + pHdl->SetModified(); - Link aLink = LINK( this, ScGridWindow, PopupSpellingHdl ); - pEditView->ExecuteSpellPopup( aMenuPos, &aLink ); + Link aLink = LINK( this, ScGridWindow, PopupSpellingHdl ); + pEditView->ExecuteSpellPopup( aMenuPos, &aLink ); - bDone = true; - } + bDone = true; } - else if ( !bMouse ) - { - // non-edit menu by keyboard -> use lower right of cell cursor position - ScDocument* aDoc = pViewData->GetDocument(); - SCTAB nTabNo = pViewData->GetTabNo(); - bool bLayoutIsRTL = aDoc->IsLayoutRTL(nTabNo); + } + else if ( !bMouse ) + { + // non-edit menu by keyboard -> use lower right of cell cursor position + ScDocument* aDoc = pViewData->GetDocument(); + SCTAB nTabNo = pViewData->GetTabNo(); + bool bLayoutIsRTL = aDoc->IsLayoutRTL(nTabNo); - SCCOL nCurX = pViewData->GetCurX(); - SCROW nCurY = pViewData->GetCurY(); - aMenuPos = pViewData->GetScrPos( nCurX, nCurY, eWhich, true ); - long nSizeXPix; - long nSizeYPix; - pViewData->GetMergeSizePixel( nCurX, nCurY, nSizeXPix, nSizeYPix ); - // fdo#55432 take the correct position for RTL sheet - aMenuPos.AdjustX(bLayoutIsRTL ? -nSizeXPix : nSizeXPix ); - aMenuPos.AdjustY(nSizeYPix ); + SCCOL nCurX = pViewData->GetCurX(); + SCROW nCurY = pViewData->GetCurY(); + aMenuPos = pViewData->GetScrPos( nCurX, nCurY, eWhich, true ); + long nSizeXPix; + long nSizeYPix; + pViewData->GetMergeSizePixel( nCurX, nCurY, nSizeXPix, nSizeYPix ); + // fdo#55432 take the correct position for RTL sheet + aMenuPos.AdjustX(bLayoutIsRTL ? -nSizeXPix : nSizeXPix ); + aMenuPos.AdjustY(nSizeYPix ); - ScTabViewShell* pViewSh = pViewData->GetViewShell(); - if (pViewSh) - { - // Is a draw object selected? + ScTabViewShell* pViewSh = pViewData->GetViewShell(); + if (pViewSh) + { + // Is a draw object selected? - SdrView* pDrawView = pViewSh->GetScDrawView(); - if (pDrawView && pDrawView->AreObjectsMarked()) - { - // #100442#; the context menu should open in the middle of the selected objects - tools::Rectangle aSelectRect(LogicToPixel(pDrawView->GetAllMarkedBoundRect())); - aMenuPos = aSelectRect.Center(); - } + SdrView* pDrawView = pViewSh->GetScDrawView(); + if (pDrawView && pDrawView->AreObjectsMarked()) + { + // #100442#; the context menu should open in the middle of the selected objects + tools::Rectangle aSelectRect(LogicToPixel(pDrawView->GetAllMarkedBoundRect())); + aMenuPos = aSelectRect.Center(); } } + } - if (!bDone) - { - SfxDispatcher::ExecutePopup( this, &aMenuPos ); - } + if (!bDone) + { + SfxDispatcher::ExecutePopup( this, &aMenuPos ); } } @@ -3178,26 +3178,26 @@ void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCCOL nCellX, S // select drawing object or move cell cursor - if ( !bHitSelected ) + if ( bHitSelected ) + return; + + bool bWasDraw = ( pDrawView && pDrawView->AreObjectsMarked() ); + bool bHitDraw = false; + if ( pDrawView ) { - bool bWasDraw = ( pDrawView && pDrawView->AreObjectsMarked() ); - bool bHitDraw = false; - if ( pDrawView ) - { - pDrawView->UnmarkAllObj(); - // Unlock the Internal Layer in order to activate the context menu. - // re-lock in ScDrawView::MarkListHasChanged() - lcl_UnLockComment( pDrawView, aLogicPos ,pViewData); - bHitDraw = pDrawView->MarkObj( aLogicPos ); - // draw shell is activated in MarkListHasChanged - } - if ( !bHitDraw ) - { - pView->Unmark(); - pView->SetCursor(nCellX, nCellY); - if ( bWasDraw ) - pViewData->GetViewShell()->SetDrawShell( false ); // switch shells - } + pDrawView->UnmarkAllObj(); + // Unlock the Internal Layer in order to activate the context menu. + // re-lock in ScDrawView::MarkListHasChanged() + lcl_UnLockComment( pDrawView, aLogicPos ,pViewData); + bHitDraw = pDrawView->MarkObj( aLogicPos ); + // draw shell is activated in MarkListHasChanged + } + if ( !bHitDraw ) + { + pView->Unmark(); + pView->SetCursor(nCellX, nCellY); + if ( bWasDraw ) + pViewData->GetViewShell()->SetDrawShell( false ); // switch shells } } @@ -4524,55 +4524,55 @@ void ScGridWindow::PasteSelection( const Point& rPosPixel ) void ScGridWindow::UpdateEditViewPos() { - if (pViewData->HasEditView(eWhich)) - { - EditView* pView; - SCCOL nCol; - SCROW nRow; - pViewData->GetEditView( eWhich, pView, nCol, nRow ); - SCCOL nEndCol = pViewData->GetEditEndCol(); - SCROW nEndRow = pViewData->GetEditEndRow(); + if (!pViewData->HasEditView(eWhich)) + return; + + EditView* pView; + SCCOL nCol; + SCROW nRow; + pViewData->GetEditView( eWhich, pView, nCol, nRow ); + SCCOL nEndCol = pViewData->GetEditEndCol(); + SCROW nEndRow = pViewData->GetEditEndRow(); + + // hide EditView? - // hide EditView? + bool bHide = ( nEndColGetPosX(eHWhich) || nEndRowGetPosY(eVWhich) ); + if ( SC_MOD()->IsFormulaMode() ) + if ( pViewData->GetTabNo() != pViewData->GetRefTabNo() ) + bHide = true; - bool bHide = ( nEndColGetPosX(eHWhich) || nEndRowGetPosY(eVWhich) ); - if ( SC_MOD()->IsFormulaMode() ) - if ( pViewData->GetTabNo() != pViewData->GetRefTabNo() ) - bHide = true; + if (bHide) + { + tools::Rectangle aRect = pView->GetOutputArea(); + long nHeight = aRect.Bottom() - aRect.Top(); + aRect.SetTop( PixelToLogic(GetOutputSizePixel(), pViewData->GetLogicMode()). + Height() * 2 ); + aRect.SetBottom( aRect.Top() + nHeight ); + pView->SetOutputArea( aRect ); + pView->HideCursor(); + } + else + { + // bForceToTop = sal_True for editing + tools::Rectangle aPixRect = pViewData->GetEditArea( eWhich, nCol, nRow, this, nullptr, true ); - if (bHide) + if (comphelper::LibreOfficeKit::isActive() && + comphelper::LibreOfficeKit::isCompatFlagSet( + comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs)) { - tools::Rectangle aRect = pView->GetOutputArea(); - long nHeight = aRect.Bottom() - aRect.Top(); - aRect.SetTop( PixelToLogic(GetOutputSizePixel(), pViewData->GetLogicMode()). - Height() * 2 ); - aRect.SetBottom( aRect.Top() + nHeight ); - pView->SetOutputArea( aRect ); - pView->HideCursor(); + tools::Rectangle aPTwipsRect = pViewData->GetEditArea(eWhich, nCol, nRow, this, nullptr, + true, true /* bInPrintTwips */); + tools::Rectangle aOutputAreaPTwips = pView->GetLOKSpecialOutputArea(); + aOutputAreaPTwips.SetPos(aPTwipsRect.TopLeft()); + pView->SetLOKSpecialOutputArea(aOutputAreaPTwips); } - else - { - // bForceToTop = sal_True for editing - tools::Rectangle aPixRect = pViewData->GetEditArea( eWhich, nCol, nRow, this, nullptr, true ); - - if (comphelper::LibreOfficeKit::isActive() && - comphelper::LibreOfficeKit::isCompatFlagSet( - comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs)) - { - tools::Rectangle aPTwipsRect = pViewData->GetEditArea(eWhich, nCol, nRow, this, nullptr, - true, true /* bInPrintTwips */); - tools::Rectangle aOutputAreaPTwips = pView->GetLOKSpecialOutputArea(); - aOutputAreaPTwips.SetPos(aPTwipsRect.TopLeft()); - pView->SetLOKSpecialOutputArea(aOutputAreaPTwips); - } - Point aScrPos = PixelToLogic( aPixRect.TopLeft(), pViewData->GetLogicMode() ); + Point aScrPos = PixelToLogic( aPixRect.TopLeft(), pViewData->GetLogicMode() ); - tools::Rectangle aRect = pView->GetOutputArea(); - aRect.SetPos( aScrPos ); - pView->SetOutputArea( aRect ); - pView->ShowCursor(); - } + tools::Rectangle aRect = pView->GetOutputArea(); + aRect.SetPos( aScrPos ); + pView->SetOutputArea( aRect ); + pView->ShowCursor(); } } @@ -4734,19 +4734,19 @@ void ScGridWindow::UpdateListValPos( bool bVisible, const ScAddress& rPos ) } } } - if ( bOldButton ) + if ( !bOldButton ) + return; + + if ( !bListValButton || aListValPos != aOldPos ) { - if ( !bListValButton || aListValPos != aOldPos ) + // paint area of old button + if ( comphelper::LibreOfficeKit::isActive() ) { - // paint area of old button - if ( comphelper::LibreOfficeKit::isActive() ) - { - updateLOKValListButton( false, aOldPos ); - } - else - { - Invalidate( PixelToLogic( GetListValButtonRect( aOldPos ) ) ); - } + updateLOKValListButton( false, aOldPos ); + } + else + { + Invalidate( PixelToLogic( GetListValButtonRect( aOldPos ) ) ); } } } @@ -6417,78 +6417,78 @@ void ScGridWindow::UpdateAutoFillOverlay() // get the AutoFill handle rectangle in pixels - if ( bAutoMarkVisible && aAutoMarkPos.Tab() == pViewData->GetTabNo() && - !pViewData->HasEditView(eWhich) && pViewData->IsActive() ) - { - SCCOL nX = aAutoMarkPos.Col(); - SCROW nY = aAutoMarkPos.Row(); + if ( !(bAutoMarkVisible && aAutoMarkPos.Tab() == pViewData->GetTabNo() && + !pViewData->HasEditView(eWhich) && pViewData->IsActive()) ) + return; - if (!maVisibleRange.isInside(nX, nY) && !comphelper::LibreOfficeKit::isActive()) - { - // Autofill mark is not visible. Bail out. - return; - } + SCCOL nX = aAutoMarkPos.Col(); + SCROW nY = aAutoMarkPos.Row(); - SCTAB nTab = pViewData->GetTabNo(); - ScDocument* pDoc = pViewData->GetDocument(); - bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); + if (!maVisibleRange.isInside(nX, nY) && !comphelper::LibreOfficeKit::isActive()) + { + // Autofill mark is not visible. Bail out. + return; + } - float fScaleFactor = GetDPIScaleFactor(); - // Size should be even - Size aFillHandleSize(6 * fScaleFactor, 6 * fScaleFactor); + SCTAB nTab = pViewData->GetTabNo(); + ScDocument* pDoc = pViewData->GetDocument(); + bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); - Point aFillPos = pViewData->GetScrPos( nX, nY, eWhich, true ); - long nSizeXPix; - long nSizeYPix; - pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix ); + float fScaleFactor = GetDPIScaleFactor(); + // Size should be even + Size aFillHandleSize(6 * fScaleFactor, 6 * fScaleFactor); - if (bLayoutRTL) - aFillPos.AdjustX( -(nSizeXPix - 2 + (aFillHandleSize.Width() / 2)) ); - else - aFillPos.AdjustX(nSizeXPix - (aFillHandleSize.Width() / 2) ); + Point aFillPos = pViewData->GetScrPos( nX, nY, eWhich, true ); + long nSizeXPix; + long nSizeYPix; + pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix ); - aFillPos.AdjustY(nSizeYPix ); - aFillPos.AdjustY( -(aFillHandleSize.Height() / 2) ); + if (bLayoutRTL) + aFillPos.AdjustX( -(nSizeXPix - 2 + (aFillHandleSize.Width() / 2)) ); + else + aFillPos.AdjustX(nSizeXPix - (aFillHandleSize.Width() / 2) ); - tools::Rectangle aFillRect(aFillPos, aFillHandleSize); + aFillPos.AdjustY(nSizeYPix ); + aFillPos.AdjustY( -(aFillHandleSize.Height() / 2) ); - // expand rect to increase hit area - mpAutoFillRect = aFillRect; - mpAutoFillRect->expand(fScaleFactor); + tools::Rectangle aFillRect(aFillPos, aFillHandleSize); - // #i70788# get the OverlayManager safely - rtl::Reference xOverlayManager = getOverlayManager(); - if (comphelper::LibreOfficeKit::isActive()) // notify the LibreOfficeKit - { - updateLibreOfficeKitAutoFill(pViewData, aFillRect); - } - else if (xOverlayManager.is()) - { - Color aHandleColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor ); - if (pViewData->GetActivePart() != eWhich) - // non-active pane uses a different color. - aHandleColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCPAGEBREAKAUTOMATIC).nColor; - std::vector< basegfx::B2DRange > aRanges; - const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation()); - basegfx::B2DRange aRB = vcl::unotools::b2DRectangleFromRectangle(aFillRect); + // expand rect to increase hit area + mpAutoFillRect = aFillRect; + mpAutoFillRect->expand(fScaleFactor); - aRB.transform(aTransform); - aRanges.push_back(aRB); + // #i70788# get the OverlayManager safely + rtl::Reference xOverlayManager = getOverlayManager(); + if (comphelper::LibreOfficeKit::isActive()) // notify the LibreOfficeKit + { + updateLibreOfficeKitAutoFill(pViewData, aFillRect); + } + else if (xOverlayManager.is()) + { + Color aHandleColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor ); + if (pViewData->GetActivePart() != eWhich) + // non-active pane uses a different color. + aHandleColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCPAGEBREAKAUTOMATIC).nColor; + std::vector< basegfx::B2DRange > aRanges; + const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation()); + basegfx::B2DRange aRB = vcl::unotools::b2DRectangleFromRectangle(aFillRect); - std::unique_ptr pOverlay(new sdr::overlay::OverlaySelection( - sdr::overlay::OverlayType::Solid, - aHandleColor, - aRanges, - false)); + aRB.transform(aTransform); + aRanges.push_back(aRB); - xOverlayManager->add(*pOverlay); - mpOOAutoFill.reset(new sdr::overlay::OverlayObjectList); - mpOOAutoFill->append(std::move(pOverlay)); - } + std::unique_ptr pOverlay(new sdr::overlay::OverlaySelection( + sdr::overlay::OverlayType::Solid, + aHandleColor, + aRanges, + false)); - if ( aOldMode != aDrawMode ) - SetMapMode( aOldMode ); + xOverlayManager->add(*pOverlay); + mpOOAutoFill.reset(new sdr::overlay::OverlayObjectList); + mpOOAutoFill->append(std::move(pOverlay)); } + + if ( aOldMode != aDrawMode ) + SetMapMode( aOldMode ); } void ScGridWindow::DeleteDragRectOverlay() diff --git a/sc/source/ui/view/gridwin3.cxx b/sc/source/ui/view/gridwin3.cxx index fbb1bee09641..7c80764221a5 100644 --- a/sc/source/ui/view/gridwin3.cxx +++ b/sc/source/ui/view/gridwin3.cxx @@ -209,20 +209,20 @@ void ScGridWindow::DrawRedraw( ScOutputData& rOutputData, SdrLayerID nLayer ) const bool bDrawChart(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_CHART)); const bool bDrawDraw(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_DRAW)); - if(bDrawOle || bDrawChart || bDrawDraw) - { - ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + if(!(bDrawOle || bDrawChart || bDrawDraw)) + return; - if(pDrView) - { - pDrView->setHideOle(!bDrawOle); - pDrView->setHideChart(!bDrawChart); - pDrView->setHideDraw(!bDrawDraw); - pDrView->setHideFormControl(!bDrawDraw); - } + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); - rOutputData.DrawSelectiveObjects(nLayer); + if(pDrView) + { + pDrView->setHideOle(!bDrawOle); + pDrView->setHideChart(!bDrawChart); + pDrView->setHideDraw(!bDrawDraw); + pDrView->setHideFormControl(!bDrawDraw); } + + rOutputData.DrawSelectiveObjects(nLayer); } void ScGridWindow::DrawSdrGrid( const tools::Rectangle& rDrawingRect, OutputDevice* pContentDev ) diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index f31de4542bb6..1ebdf95b60c5 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -190,71 +190,71 @@ static void lcl_DrawScenarioFrames( OutputDevice* pDev, ScViewData* pViewData, S ScDocument* pDoc = pViewData->GetDocument(); SCTAB nTab = pViewData->GetTabNo(); SCTAB nTabCount = pDoc->GetTableCount(); - if ( nTab+1IsScenario(nTab+1) && !pDoc->IsScenario(nTab) ) - { - if ( nX1 > 0 ) --nX1; - if ( nY1>=2 ) nY1 -= 2; // Hack: Header row affects two cells - else if ( nY1 > 0 ) --nY1; - if ( nX2 < pDoc->MaxCol() ) ++nX2; - if ( nY2 < pDoc->MaxRow()-1 ) nY2 += 2; // Hack: Header row affects two cells - else if ( nY2 < pDoc->MaxRow() ) ++nY2; - ScRange aViewRange( nX1,nY1,nTab, nX2,nY2,nTab ); - - //! cache the ranges in table!!!! - - ScMarkData aMarks(pDoc->GetSheetLimits()); - for (SCTAB i=nTab+1; iIsScenario(i); i++) - pDoc->MarkScenario( i, nTab, aMarks, false, ScScenarioFlags::ShowFrame ); - ScRangeListRef xRanges = new ScRangeList; - aMarks.FillRangeListWithMarks( xRanges.get(), false ); - - bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); - long nLayoutSign = bLayoutRTL ? -1 : 1; + if ( nTab+1 >= nTabCount || !pDoc->IsScenario(nTab+1) || pDoc->IsScenario(nTab) ) + return; - for (size_t j = 0, n = xRanges->size(); j < n; ++j) - { - ScRange aRange = (*xRanges)[j]; - // Always extend scenario frame to merged cells where no new non-covered cells - // are framed - pDoc->ExtendTotalMerge( aRange ); + if ( nX1 > 0 ) --nX1; + if ( nY1>=2 ) nY1 -= 2; // Hack: Header row affects two cells + else if ( nY1 > 0 ) --nY1; + if ( nX2 < pDoc->MaxCol() ) ++nX2; + if ( nY2 < pDoc->MaxRow()-1 ) nY2 += 2; // Hack: Header row affects two cells + else if ( nY2 < pDoc->MaxRow() ) ++nY2; + ScRange aViewRange( nX1,nY1,nTab, nX2,nY2,nTab ); - //! -> Extend repaint when merging !!! + //! cache the ranges in table!!!! - if ( aRange.Intersects( aViewRange ) ) //! Space for Text/Button? - { - Point aStartPos = pViewData->GetScrPos( - aRange.aStart.Col(), aRange.aStart.Row(), eWhich, true ); - Point aEndPos = pViewData->GetScrPos( - aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, eWhich, true ); - // on the grid: - aStartPos.AdjustX( -nLayoutSign ); - aStartPos.AdjustY( -1 ); - aEndPos.AdjustX( -nLayoutSign ); - aEndPos.AdjustY( -1 ); - - bool bTextBelow = ( aRange.aStart.Row() == 0 ); - - OUString aCurrent; - Color aColor( COL_LIGHTGRAY ); - for (SCTAB nAct=nTab+1; nActIsScenario(nAct); nAct++) - if ( pDoc->IsActiveScenario(nAct) && pDoc->HasScenarioRange(nAct,aRange) ) - { - OUString aDummyComment; - ScScenarioFlags nDummyFlags; - pDoc->GetName( nAct, aCurrent ); - pDoc->GetScenarioData( nAct, aDummyComment, aColor, nDummyFlags ); - } + ScMarkData aMarks(pDoc->GetSheetLimits()); + for (SCTAB i=nTab+1; iIsScenario(i); i++) + pDoc->MarkScenario( i, nTab, aMarks, false, ScScenarioFlags::ShowFrame ); + ScRangeListRef xRanges = new ScRangeList; + aMarks.FillRangeListWithMarks( xRanges.get(), false ); + + bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); + long nLayoutSign = bLayoutRTL ? -1 : 1; - if (aCurrent.isEmpty()) - aCurrent = ScResId( STR_EMPTYDATA ); + for (size_t j = 0, n = xRanges->size(); j < n; ++j) + { + ScRange aRange = (*xRanges)[j]; + // Always extend scenario frame to merged cells where no new non-covered cells + // are framed + pDoc->ExtendTotalMerge( aRange ); - //! Own text "(None)" instead of "(Empty)" ??? + //! -> Extend repaint when merging !!! - lcl_DrawOneFrame( pDev, tools::Rectangle( aStartPos, aEndPos ), - aCurrent, aColor, bTextBelow, - pViewData->GetPPTX(), pViewData->GetPPTY(), pViewData->GetZoomY(), - pDoc, pViewData, bLayoutRTL ); - } + if ( aRange.Intersects( aViewRange ) ) //! Space for Text/Button? + { + Point aStartPos = pViewData->GetScrPos( + aRange.aStart.Col(), aRange.aStart.Row(), eWhich, true ); + Point aEndPos = pViewData->GetScrPos( + aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, eWhich, true ); + // on the grid: + aStartPos.AdjustX( -nLayoutSign ); + aStartPos.AdjustY( -1 ); + aEndPos.AdjustX( -nLayoutSign ); + aEndPos.AdjustY( -1 ); + + bool bTextBelow = ( aRange.aStart.Row() == 0 ); + + OUString aCurrent; + Color aColor( COL_LIGHTGRAY ); + for (SCTAB nAct=nTab+1; nActIsScenario(nAct); nAct++) + if ( pDoc->IsActiveScenario(nAct) && pDoc->HasScenarioRange(nAct,aRange) ) + { + OUString aDummyComment; + ScScenarioFlags nDummyFlags; + pDoc->GetName( nAct, aCurrent ); + pDoc->GetScenarioData( nAct, aDummyComment, aColor, nDummyFlags ); + } + + if (aCurrent.isEmpty()) + aCurrent = ScResId( STR_EMPTYDATA ); + + //! Own text "(None)" instead of "(Empty)" ??? + + lcl_DrawOneFrame( pDev, tools::Rectangle( aStartPos, aEndPos ), + aCurrent, aColor, bTextBelow, + pViewData->GetPPTX(), pViewData->GetPPTY(), pViewData->GetZoomY(), + pDoc, pViewData, bLayoutRTL ); } } } @@ -1561,219 +1561,219 @@ void ScGridWindow::CheckNeedsRepaint() { // called at the end of painting, and from timer after background text width calculation - if (bNeedsRepaint) - { - bNeedsRepaint = false; - if (aRepaintPixel.IsEmpty()) - Invalidate(); - else - Invalidate(PixelToLogic(aRepaintPixel)); - aRepaintPixel = tools::Rectangle(); - - // selection function in status bar might also be invalid - SfxBindings& rBindings = pViewData->GetBindings(); - rBindings.Invalidate( SID_STATUS_SUM ); - rBindings.Invalidate( SID_ATTR_SIZE ); - rBindings.Invalidate( SID_TABLE_CELL ); - } + if (!bNeedsRepaint) + return; + + bNeedsRepaint = false; + if (aRepaintPixel.IsEmpty()) + Invalidate(); + else + Invalidate(PixelToLogic(aRepaintPixel)); + aRepaintPixel = tools::Rectangle(); + + // selection function in status bar might also be invalid + SfxBindings& rBindings = pViewData->GetBindings(); + rBindings.Invalidate( SID_STATUS_SUM ); + rBindings.Invalidate( SID_ATTR_SIZE ); + rBindings.Invalidate( SID_TABLE_CELL ); } void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, vcl::RenderContext& rRenderContext) { ScPageBreakData* pPageData = pViewData->GetView()->GetPageBreakData(); - if (pPageData) + if (!pPageData) + return; + + ScDocument* pDoc = pViewData->GetDocument(); + SCTAB nTab = pViewData->GetTabNo(); + Size aWinSize = GetOutputSizePixel(); + const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig(); + Color aManual( rColorCfg.GetColorValue(svtools::CALCPAGEBREAKMANUAL).nColor ); + Color aAutomatic( rColorCfg.GetColorValue(svtools::CALCPAGEBREAK).nColor ); + + OUString aPageStr = ScResId( STR_PGNUM ); + if ( nPageScript == SvtScriptType::NONE ) { - ScDocument* pDoc = pViewData->GetDocument(); - SCTAB nTab = pViewData->GetTabNo(); - Size aWinSize = GetOutputSizePixel(); - const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig(); - Color aManual( rColorCfg.GetColorValue(svtools::CALCPAGEBREAKMANUAL).nColor ); - Color aAutomatic( rColorCfg.GetColorValue(svtools::CALCPAGEBREAK).nColor ); + // get script type of translated "Page" string only once + nPageScript = pDoc->GetStringScriptType( aPageStr ); + if (nPageScript == SvtScriptType::NONE) + nPageScript = ScGlobal::GetDefaultScriptType(); + } - OUString aPageStr = ScResId( STR_PGNUM ); - if ( nPageScript == SvtScriptType::NONE ) - { - // get script type of translated "Page" string only once - nPageScript = pDoc->GetStringScriptType( aPageStr ); - if (nPageScript == SvtScriptType::NONE) - nPageScript = ScGlobal::GetDefaultScriptType(); - } + vcl::Font aFont; + std::unique_ptr pEditEng; + const ScPatternAttr& rDefPattern = pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN); + if ( nPageScript == SvtScriptType::LATIN ) + { + // use single font and call DrawText directly + rDefPattern.GetFont( aFont, SC_AUTOCOL_BLACK ); + aFont.SetColor( COL_LIGHTGRAY ); + // font size is set as needed + } + else + { + // use EditEngine to draw mixed-script string + pEditEng.reset(new ScEditEngineDefaulter( EditEngine::CreatePool(), true )); + pEditEng->SetRefMapMode(rRenderContext.GetMapMode()); + auto pEditDefaults = std::make_unique( pEditEng->GetEmptyItemSet() ); + rDefPattern.FillEditItemSet( pEditDefaults.get() ); + pEditDefaults->Put( SvxColorItem( COL_LIGHTGRAY, EE_CHAR_COLOR ) ); + pEditEng->SetDefaults( std::move(pEditDefaults) ); + } - vcl::Font aFont; - std::unique_ptr pEditEng; - const ScPatternAttr& rDefPattern = pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN); - if ( nPageScript == SvtScriptType::LATIN ) - { - // use single font and call DrawText directly - rDefPattern.GetFont( aFont, SC_AUTOCOL_BLACK ); - aFont.SetColor( COL_LIGHTGRAY ); - // font size is set as needed - } - else + sal_uInt16 nCount = sal::static_int_cast( pPageData->GetCount() ); + for (sal_uInt16 nPos=0; nPosGetData(nPos); + ScRange aRange = rData.GetPrintRange(); + if ( aRange.aStart.Col() <= nX2+1 && aRange.aEnd.Col()+1 >= nX1 && + aRange.aStart.Row() <= nY2+1 && aRange.aEnd.Row()+1 >= nY1 ) { - // use EditEngine to draw mixed-script string - pEditEng.reset(new ScEditEngineDefaulter( EditEngine::CreatePool(), true )); - pEditEng->SetRefMapMode(rRenderContext.GetMapMode()); - auto pEditDefaults = std::make_unique( pEditEng->GetEmptyItemSet() ); - rDefPattern.FillEditItemSet( pEditDefaults.get() ); - pEditDefaults->Put( SvxColorItem( COL_LIGHTGRAY, EE_CHAR_COLOR ) ); - pEditEng->SetDefaults( std::move(pEditDefaults) ); - } + // 3 pixel frame around the print area + // (middle pixel on the grid lines) - sal_uInt16 nCount = sal::static_int_cast( pPageData->GetCount() ); - for (sal_uInt16 nPos=0; nPosGetData(nPos); - ScRange aRange = rData.GetPrintRange(); - if ( aRange.aStart.Col() <= nX2+1 && aRange.aEnd.Col()+1 >= nX1 && - aRange.aStart.Row() <= nY2+1 && aRange.aEnd.Row()+1 >= nY1 ) + rRenderContext.SetLineColor(); + if (rData.IsAutomatic()) + rRenderContext.SetFillColor( aAutomatic ); + else + rRenderContext.SetFillColor( aManual ); + + Point aStart = pViewData->GetScrPos( + aRange.aStart.Col(), aRange.aStart.Row(), eWhich, true ); + Point aEnd = pViewData->GetScrPos( + aRange.aEnd.Col() + 1, aRange.aEnd.Row() + 1, eWhich, true ); + aStart.AdjustX( -2 ); + aStart.AdjustY( -2 ); + + // Prevent overflows: + if ( aStart.X() < -10 ) aStart.setX( -10 ); + if ( aStart.Y() < -10 ) aStart.setY( -10 ); + if ( aEnd.X() > aWinSize.Width() + 10 ) + aEnd.setX( aWinSize.Width() + 10 ); + if ( aEnd.Y() > aWinSize.Height() + 10 ) + aEnd.setY( aWinSize.Height() + 10 ); + + rRenderContext.DrawRect( tools::Rectangle( aStart, Point(aEnd.X(),aStart.Y()+2) ) ); + rRenderContext.DrawRect( tools::Rectangle( aStart, Point(aStart.X()+2,aEnd.Y()) ) ); + rRenderContext.DrawRect( tools::Rectangle( Point(aStart.X(),aEnd.Y()-2), aEnd ) ); + rRenderContext.DrawRect( tools::Rectangle( Point(aEnd.X()-2,aStart.Y()), aEnd ) ); + + // Page breaks + //! Display differently (dashed ????) + + size_t nColBreaks = rData.GetPagesX(); + const SCCOL* pColEnd = rData.GetPageEndX(); + size_t nColPos; + for (nColPos=0; nColPos+1GetScrPos( - aRange.aStart.Col(), aRange.aStart.Row(), eWhich, true ); - Point aEnd = pViewData->GetScrPos( - aRange.aEnd.Col() + 1, aRange.aEnd.Row() + 1, eWhich, true ); - aStart.AdjustX( -2 ); - aStart.AdjustY( -2 ); - - // Prevent overflows: - if ( aStart.X() < -10 ) aStart.setX( -10 ); - if ( aStart.Y() < -10 ) aStart.setY( -10 ); - if ( aEnd.X() > aWinSize.Width() + 10 ) - aEnd.setX( aWinSize.Width() + 10 ); - if ( aEnd.Y() > aWinSize.Height() + 10 ) - aEnd.setY( aWinSize.Height() + 10 ); - - rRenderContext.DrawRect( tools::Rectangle( aStart, Point(aEnd.X(),aStart.Y()+2) ) ); - rRenderContext.DrawRect( tools::Rectangle( aStart, Point(aStart.X()+2,aEnd.Y()) ) ); - rRenderContext.DrawRect( tools::Rectangle( Point(aStart.X(),aEnd.Y()-2), aEnd ) ); - rRenderContext.DrawRect( tools::Rectangle( Point(aEnd.X()-2,aStart.Y()), aEnd ) ); - - // Page breaks - //! Display differently (dashed ????) - - size_t nColBreaks = rData.GetPagesX(); - const SCCOL* pColEnd = rData.GetPageEndX(); - size_t nColPos; - for (nColPos=0; nColPos+1= nX1 && nBreak <= nX2+1 ) { - SCCOL nBreak = pColEnd[nColPos]+1; - if ( nBreak >= nX1 && nBreak <= nX2+1 ) - { - //! Search for hidden - if (pDoc->HasColBreak(nBreak, nTab) & ScBreakType::Manual) - rRenderContext.SetFillColor( aManual ); - else - rRenderContext.SetFillColor( aAutomatic ); - Point aBreak = pViewData->GetScrPos( - nBreak, aRange.aStart.Row(), eWhich, true ); - rRenderContext.DrawRect( tools::Rectangle( aBreak.X()-1, aStart.Y(), aBreak.X(), aEnd.Y() ) ); - } + //! Search for hidden + if (pDoc->HasColBreak(nBreak, nTab) & ScBreakType::Manual) + rRenderContext.SetFillColor( aManual ); + else + rRenderContext.SetFillColor( aAutomatic ); + Point aBreak = pViewData->GetScrPos( + nBreak, aRange.aStart.Row(), eWhich, true ); + rRenderContext.DrawRect( tools::Rectangle( aBreak.X()-1, aStart.Y(), aBreak.X(), aEnd.Y() ) ); } + } - size_t nRowBreaks = rData.GetPagesY(); - const SCROW* pRowEnd = rData.GetPageEndY(); - size_t nRowPos; - for (nRowPos=0; nRowPos+1= nY1 && nBreak <= nY2+1 ) { - SCROW nBreak = pRowEnd[nRowPos]+1; - if ( nBreak >= nY1 && nBreak <= nY2+1 ) - { - //! Search for hidden - if (pDoc->HasRowBreak(nBreak, nTab) & ScBreakType::Manual) - rRenderContext.SetFillColor( aManual ); - else - rRenderContext.SetFillColor( aAutomatic ); - Point aBreak = pViewData->GetScrPos( - aRange.aStart.Col(), nBreak, eWhich, true ); - rRenderContext.DrawRect( tools::Rectangle( aStart.X(), aBreak.Y()-1, aEnd.X(), aBreak.Y() ) ); - } + //! Search for hidden + if (pDoc->HasRowBreak(nBreak, nTab) & ScBreakType::Manual) + rRenderContext.SetFillColor( aManual ); + else + rRenderContext.SetFillColor( aAutomatic ); + Point aBreak = pViewData->GetScrPos( + aRange.aStart.Col(), nBreak, eWhich, true ); + rRenderContext.DrawRect( tools::Rectangle( aStart.X(), aBreak.Y()-1, aEnd.X(), aBreak.Y() ) ); } + } - // Page numbers + // Page numbers - SCROW nPrStartY = aRange.aStart.Row(); - for (nRowPos=0; nRowPos= nY1 && nPrStartY <= nY2 ) { - SCROW nPrEndY = pRowEnd[nRowPos]; - if ( nPrEndY >= nY1 && nPrStartY <= nY2 ) + SCCOL nPrStartX = aRange.aStart.Col(); + for (nColPos=0; nColPos= nX1 && nPrStartX <= nX2 ) { - SCCOL nPrEndX = pColEnd[nColPos]; - if ( nPrEndX >= nX1 && nPrStartX <= nX2 ) - { - Point aPageStart = pViewData->GetScrPos( - nPrStartX, nPrStartY, eWhich, true ); - Point aPageEnd = pViewData->GetScrPos( - nPrEndX+1,nPrEndY+1, eWhich, true ); + Point aPageStart = pViewData->GetScrPos( + nPrStartX, nPrStartY, eWhich, true ); + Point aPageEnd = pViewData->GetScrPos( + nPrEndX+1,nPrEndY+1, eWhich, true ); - long nPageNo = rData.GetFirstPage(); - if ( rData.IsTopDown() ) - nPageNo += static_cast(nColPos)*nRowBreaks+nRowPos; - else - nPageNo += static_cast(nRowPos)*nColBreaks+nColPos; + long nPageNo = rData.GetFirstPage(); + if ( rData.IsTopDown() ) + nPageNo += static_cast(nColPos)*nRowBreaks+nRowPos; + else + nPageNo += static_cast(nRowPos)*nColBreaks+nColPos; - OUString aThisPageStr = aPageStr.replaceFirst("%1", OUString::number(nPageNo)); + OUString aThisPageStr = aPageStr.replaceFirst("%1", OUString::number(nPageNo)); - if ( pEditEng ) - { - // find right font size with EditEngine - long nHeight = 100; - pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) ); - pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) ); - pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) ); - pEditEng->SetTextCurrentDefaults( aThisPageStr ); - Size aSize100( pEditEng->CalcTextWidth(), pEditEng->GetTextHeight() ); - - // 40% of width or 60% of height - long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / aSize100.Width(); - long nSizeY = 60 * ( aPageEnd.Y() - aPageStart.Y() ) / aSize100.Height(); - nHeight = std::min(nSizeX,nSizeY); - pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) ); - pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) ); - pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) ); - - // centered output with EditEngine - Size aTextSize( pEditEng->CalcTextWidth(), pEditEng->GetTextHeight() ); - Point aPos( (aPageStart.X()+aPageEnd.X()-aTextSize.Width())/2, - (aPageStart.Y()+aPageEnd.Y()-aTextSize.Height())/2 ); - pEditEng->Draw( &rRenderContext, aPos ); - } - else - { - // find right font size for DrawText - aFont.SetFontSize( Size( 0,100 ) ); - rRenderContext.SetFont( aFont ); - Size aSize100(rRenderContext.GetTextWidth( aThisPageStr ), rRenderContext.GetTextHeight() ); - - // 40% of width or 60% of height - long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / aSize100.Width(); - long nSizeY = 60 * ( aPageEnd.Y() - aPageStart.Y() ) / aSize100.Height(); - aFont.SetFontSize( Size( 0,std::min(nSizeX,nSizeY) ) ); - rRenderContext.SetFont( aFont ); - - // centered output with DrawText - Size aTextSize(rRenderContext.GetTextWidth( aThisPageStr ), rRenderContext.GetTextHeight() ); - Point aPos( (aPageStart.X()+aPageEnd.X()-aTextSize.Width())/2, - (aPageStart.Y()+aPageEnd.Y()-aTextSize.Height())/2 ); - rRenderContext.DrawText( aPos, aThisPageStr ); - } + if ( pEditEng ) + { + // find right font size with EditEngine + long nHeight = 100; + pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) ); + pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) ); + pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) ); + pEditEng->SetTextCurrentDefaults( aThisPageStr ); + Size aSize100( pEditEng->CalcTextWidth(), pEditEng->GetTextHeight() ); + + // 40% of width or 60% of height + long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / aSize100.Width(); + long nSizeY = 60 * ( aPageEnd.Y() - aPageStart.Y() ) / aSize100.Height(); + nHeight = std::min(nSizeX,nSizeY); + pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) ); + pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) ); + pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) ); + + // centered output with EditEngine + Size aTextSize( pEditEng->CalcTextWidth(), pEditEng->GetTextHeight() ); + Point aPos( (aPageStart.X()+aPageEnd.X()-aTextSize.Width())/2, + (aPageStart.Y()+aPageEnd.Y()-aTextSize.Height())/2 ); + pEditEng->Draw( &rRenderContext, aPos ); + } + else + { + // find right font size for DrawText + aFont.SetFontSize( Size( 0,100 ) ); + rRenderContext.SetFont( aFont ); + Size aSize100(rRenderContext.GetTextWidth( aThisPageStr ), rRenderContext.GetTextHeight() ); + + // 40% of width or 60% of height + long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / aSize100.Width(); + long nSizeY = 60 * ( aPageEnd.Y() - aPageStart.Y() ) / aSize100.Height(); + aFont.SetFontSize( Size( 0,std::min(nSizeX,nSizeY) ) ); + rRenderContext.SetFont( aFont ); + + // centered output with DrawText + Size aTextSize(rRenderContext.GetTextWidth( aThisPageStr ), rRenderContext.GetTextHeight() ); + Point aPos( (aPageStart.X()+aPageEnd.X()-aTextSize.Width())/2, + (aPageStart.Y()+aPageEnd.Y()-aTextSize.Height())/2 ); + rRenderContext.DrawText( aPos, aThisPageStr ); } - nPrStartX = nPrEndX + 1; } + nPrStartX = nPrEndX + 1; } - nPrStartY = nPrEndY + 1; } + nPrStartY = nPrEndY + 1; } } } @@ -2229,42 +2229,42 @@ void ScGridWindow::DataChanged( const DataChangedEvent& rDCEvt ) { Window::DataChanged(rDCEvt); - if ( (rDCEvt.GetType() == DataChangedEventType::PRINTER) || + if ( !((rDCEvt.GetType() == DataChangedEventType::PRINTER) || (rDCEvt.GetType() == DataChangedEventType::DISPLAY) || (rDCEvt.GetType() == DataChangedEventType::FONTS) || (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) || ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && - (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) ) - { - if ( rDCEvt.GetType() == DataChangedEventType::FONTS && eWhich == pViewData->GetActivePart() ) - pViewData->GetDocShell()->UpdateFontList(); + (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))) ) + return; - if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) && - (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) ) + if ( rDCEvt.GetType() == DataChangedEventType::FONTS && eWhich == pViewData->GetActivePart() ) + pViewData->GetDocShell()->UpdateFontList(); + + if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) && + (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) ) + { + if ( eWhich == pViewData->GetActivePart() ) // only once for the view { - if ( eWhich == pViewData->GetActivePart() ) // only once for the view - { - ScTabView* pView = pViewData->GetView(); + ScTabView* pView = pViewData->GetView(); - pView->RecalcPPT(); + pView->RecalcPPT(); - // RepeatResize in case scroll bar sizes have changed - pView->RepeatResize(); - pView->UpdateAllOverlays(); + // RepeatResize in case scroll bar sizes have changed + pView->RepeatResize(); + pView->UpdateAllOverlays(); - // invalidate cell attribs in input handler, in case the - // EditEngine BackgroundColor has to be changed - if ( pViewData->IsActive() ) - { - ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); - if (pHdl) - pHdl->ForgetLastPattern(); - } + // invalidate cell attribs in input handler, in case the + // EditEngine BackgroundColor has to be changed + if ( pViewData->IsActive() ) + { + ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); + if (pHdl) + pHdl->ForgetLastPattern(); } } - - Invalidate(); } + + Invalidate(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/gridwin_dbgutil.cxx b/sc/source/ui/view/gridwin_dbgutil.cxx index 9f372381c25c..1b2e2eb12023 100644 --- a/sc/source/ui/view/gridwin_dbgutil.cxx +++ b/sc/source/ui/view/gridwin_dbgutil.cxx @@ -128,25 +128,25 @@ void ScGridWindow::dumpGraphicInformation() { ScDocument* pDoc = pViewData->GetDocument(); ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); - if (pDrawLayer) + if (!pDrawLayer) + return; + + sal_uInt16 nPageCount = pDrawLayer->GetPageCount(); + for (sal_uInt16 nPage = 0; nPage < nPageCount; ++nPage) { - sal_uInt16 nPageCount = pDrawLayer->GetPageCount(); - for (sal_uInt16 nPage = 0; nPage < nPageCount; ++nPage) + SdrPage* pPage = pDrawLayer->GetPage(nPage); + size_t nObjCount = pPage->GetObjCount(); + for (size_t nObj = 0; nObj < nObjCount; ++nObj) { - SdrPage* pPage = pDrawLayer->GetPage(nPage); - size_t nObjCount = pPage->GetObjCount(); - for (size_t nObj = 0; nObj < nObjCount; ++nObj) - { - SdrObject* pObj = pPage->GetObj(nObj); - std::cout << "Graphic Object" << std::endl; - ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pObj); - if (pObjData) - dumpScDrawObjData(*this, *pObjData, pDrawLayer->GetScaleUnit()); - - const tools::Rectangle& rRect = pObj->GetSnapRect(); - tools::Rectangle aRect = LogicToPixel(rRect, MapMode(pDrawLayer->GetScaleUnit())); - std::cout << "Snap Rectangle (in pixel): " << aRect << std::endl; - } + SdrObject* pObj = pPage->GetObj(nObj); + std::cout << "Graphic Object" << std::endl; + ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pObj); + if (pObjData) + dumpScDrawObjData(*this, *pObjData, pDrawLayer->GetScaleUnit()); + + const tools::Rectangle& rRect = pObj->GetSnapRect(); + tools::Rectangle aRect = LogicToPixel(rRect, MapMode(pDrawLayer->GetScaleUnit())); + std::cout << "Snap Rectangle (in pixel): " << aRect << std::endl; } } } diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx index a8aeb47f9f88..6ef5f6e98104 100644 --- a/sc/source/ui/view/hdrcont.cxx +++ b/sc/source/ui/view/hdrcont.cxx @@ -904,43 +904,43 @@ void ScHeaderControl::StopMarking() void ScHeaderControl::ShowDragHelp() { - if (Help::IsQuickHelpEnabled()) - { - long nScrPos = GetScrPos( nDragNo ); - bool bLayoutRTL = IsLayoutRTL(); - long nVal = bLayoutRTL ? ( nScrPos - nDragPos + 1 ) - : ( nDragPos + 2 - nScrPos ); + if (!Help::IsQuickHelpEnabled()) + return; - OUString aHelpStr = GetDragHelp( nVal ); - Point aPos = OutputToScreenPixel( Point(0,0) ); - Size aSize = GetSizePixel(); + long nScrPos = GetScrPos( nDragNo ); + bool bLayoutRTL = IsLayoutRTL(); + long nVal = bLayoutRTL ? ( nScrPos - nDragPos + 1 ) + : ( nDragPos + 2 - nScrPos ); - Point aMousePos = OutputToScreenPixel(GetPointerPosPixel()); + OUString aHelpStr = GetDragHelp( nVal ); + Point aPos = OutputToScreenPixel( Point(0,0) ); + Size aSize = GetSizePixel(); - tools::Rectangle aRect; - QuickHelpFlags nAlign; - if (!bVertical) - { - // above - aRect.SetLeft( aMousePos.X() ); - aRect.SetTop( aPos.Y() - 4 ); - nAlign = QuickHelpFlags::Bottom|QuickHelpFlags::Center; - } - else - { - // top right - aRect.SetLeft( aPos.X() + aSize.Width() + 8 ); - aRect.SetTop( aMousePos.Y() - 2 ); - nAlign = QuickHelpFlags::Left|QuickHelpFlags::Bottom; - } + Point aMousePos = OutputToScreenPixel(GetPointerPosPixel()); - aRect.SetRight( aRect.Left() ); - aRect.SetBottom( aRect.Top() ); - - if (nTipVisible) - Help::HidePopover(this, nTipVisible); - nTipVisible = Help::ShowPopover(this, aRect, aHelpStr, nAlign); + tools::Rectangle aRect; + QuickHelpFlags nAlign; + if (!bVertical) + { + // above + aRect.SetLeft( aMousePos.X() ); + aRect.SetTop( aPos.Y() - 4 ); + nAlign = QuickHelpFlags::Bottom|QuickHelpFlags::Center; } + else + { + // top right + aRect.SetLeft( aPos.X() + aSize.Width() + 8 ); + aRect.SetTop( aMousePos.Y() - 2 ); + nAlign = QuickHelpFlags::Left|QuickHelpFlags::Bottom; + } + + aRect.SetRight( aRect.Left() ); + aRect.SetBottom( aRect.Top() ); + + if (nTipVisible) + Help::HidePopover(this, nTipVisible); + nTipVisible = Help::ShowPopover(this, aRect, aHelpStr, nAlign); } void ScHeaderControl::RequestHelp( const HelpEvent& rHEvt ) diff --git a/sc/source/ui/view/invmerge.cxx b/sc/source/ui/view/invmerge.cxx index 528092012ae7..a08222197793 100644 --- a/sc/source/ui/view/invmerge.cxx +++ b/sc/source/ui/view/invmerge.cxx @@ -39,46 +39,45 @@ void ScInvertMerger::Flush() OSL_ENSURE( aLineRect.IsEmpty() && aTotalRect.IsEmpty(), "Flush: not empty" ); - if ( pRects ) - { + if ( !pRects ) + return; - // also join vertically if there are non-adjacent columns involved + // also join vertically if there are non-adjacent columns involved - size_t nComparePos = 0; - while ( nComparePos < pRects->size() ) - { - tools::Rectangle aCompRect = (*pRects)[nComparePos]; - sal_Int32 nBottom = aCompRect.Bottom(); - size_t nOtherPos = nComparePos + 1; + size_t nComparePos = 0; + while ( nComparePos < pRects->size() ) + { + tools::Rectangle aCompRect = (*pRects)[nComparePos]; + sal_Int32 nBottom = aCompRect.Bottom(); + size_t nOtherPos = nComparePos + 1; - while ( nOtherPos < pRects->size() ) + while ( nOtherPos < pRects->size() ) + { + tools::Rectangle aOtherRect = (*pRects)[nOtherPos]; + if ( aOtherRect.Top() > nBottom + 1 ) { - tools::Rectangle aOtherRect = (*pRects)[nOtherPos]; - if ( aOtherRect.Top() > nBottom + 1 ) - { - // rectangles are sorted, so we can stop searching - break; - } - if ( aOtherRect.Top() == nBottom + 1 && - aOtherRect.Left() == aCompRect.Left() && - aOtherRect.Right() == aCompRect.Right() ) - { - // extend first rectangle - nBottom = aOtherRect.Bottom(); - aCompRect.SetBottom( nBottom ); - (*pRects)[nComparePos].SetBottom( nBottom ); - - // remove second rectangle - pRects->erase( pRects->begin() + nOtherPos ); - - // continue at unmodified nOtherPos - } - else - ++nOtherPos; + // rectangles are sorted, so we can stop searching + break; } + if ( aOtherRect.Top() == nBottom + 1 && + aOtherRect.Left() == aCompRect.Left() && + aOtherRect.Right() == aCompRect.Right() ) + { + // extend first rectangle + nBottom = aOtherRect.Bottom(); + aCompRect.SetBottom( nBottom ); + (*pRects)[nComparePos].SetBottom( nBottom ); + + // remove second rectangle + pRects->erase( pRects->begin() + nOtherPos ); - ++nComparePos; + // continue at unmodified nOtherPos + } + else + ++nOtherPos; } + + ++nComparePos; } } diff --git a/sc/source/ui/view/notemark.cxx b/sc/source/ui/view/notemark.cxx index 689340797c62..9a6417856b24 100644 --- a/sc/source/ui/view/notemark.cxx +++ b/sc/source/ui/view/notemark.cxx @@ -146,57 +146,57 @@ static MapMode lcl_MoveMapMode( const MapMode& rMap, const Size& rMove ) void ScNoteMarker::Draw() { - if ( m_xObject && m_bVisible ) - { - lcl_DrawWin( m_xObject.get(), m_pWindow, m_aMapMode ); + if ( !(m_xObject && m_bVisible) ) + return; - if ( m_pRightWin || m_pBottomWin ) - { - Size aWinSize = m_pWindow->PixelToLogic( m_pWindow->GetOutputSizePixel(), m_aMapMode ); - if ( m_pRightWin ) - lcl_DrawWin( m_xObject.get(), m_pRightWin, - lcl_MoveMapMode( m_aMapMode, Size( aWinSize.Width(), 0 ) ) ); - if ( m_pBottomWin ) - lcl_DrawWin( m_xObject.get(), m_pBottomWin, - lcl_MoveMapMode( m_aMapMode, Size( 0, aWinSize.Height() ) ) ); - if ( m_pDiagWin ) - lcl_DrawWin( m_xObject.get(), m_pDiagWin, lcl_MoveMapMode( m_aMapMode, aWinSize ) ); - } + lcl_DrawWin( m_xObject.get(), m_pWindow, m_aMapMode ); + + if ( m_pRightWin || m_pBottomWin ) + { + Size aWinSize = m_pWindow->PixelToLogic( m_pWindow->GetOutputSizePixel(), m_aMapMode ); + if ( m_pRightWin ) + lcl_DrawWin( m_xObject.get(), m_pRightWin, + lcl_MoveMapMode( m_aMapMode, Size( aWinSize.Width(), 0 ) ) ); + if ( m_pBottomWin ) + lcl_DrawWin( m_xObject.get(), m_pBottomWin, + lcl_MoveMapMode( m_aMapMode, Size( 0, aWinSize.Height() ) ) ); + if ( m_pDiagWin ) + lcl_DrawWin( m_xObject.get(), m_pDiagWin, lcl_MoveMapMode( m_aMapMode, aWinSize ) ); } } void ScNoteMarker::InvalidateWin() { - if (m_bVisible) - { - // Extend the invalidated rectangle by 1 pixel in each direction in case AA would slightly - // paint outside the nominal area. - tools::Rectangle aRect(m_aRect); - const Size aPixelSize = m_pWindow->PixelToLogic(Size(1, 1)); - aRect.AdjustLeft(-aPixelSize.getWidth()); - aRect.AdjustTop(-aPixelSize.getHeight()); - aRect.AdjustRight(aPixelSize.getWidth()); - aRect.AdjustBottom(aPixelSize.getHeight()); - - m_pWindow->Invalidate( OutputDevice::LogicToLogic(aRect, m_aMapMode, m_pWindow->GetMapMode()) ); - - if ( m_pRightWin || m_pBottomWin ) - { - Size aWinSize = m_pWindow->PixelToLogic( m_pWindow->GetOutputSizePixel(), m_aMapMode ); - if ( m_pRightWin ) - m_pRightWin->Invalidate( OutputDevice::LogicToLogic(aRect, - lcl_MoveMapMode( m_aMapMode, Size( aWinSize.Width(), 0 ) ), - m_pRightWin->GetMapMode()) ); - if ( m_pBottomWin ) - m_pBottomWin->Invalidate( OutputDevice::LogicToLogic(aRect, - lcl_MoveMapMode( m_aMapMode, Size( 0, aWinSize.Height() ) ), - m_pBottomWin->GetMapMode()) ); - if ( m_pDiagWin ) - m_pDiagWin->Invalidate( OutputDevice::LogicToLogic(aRect, - lcl_MoveMapMode( m_aMapMode, aWinSize ), - m_pDiagWin->GetMapMode()) ); - } - } + if (!m_bVisible) + return; + + // Extend the invalidated rectangle by 1 pixel in each direction in case AA would slightly + // paint outside the nominal area. + tools::Rectangle aRect(m_aRect); + const Size aPixelSize = m_pWindow->PixelToLogic(Size(1, 1)); + aRect.AdjustLeft(-aPixelSize.getWidth()); + aRect.AdjustTop(-aPixelSize.getHeight()); + aRect.AdjustRight(aPixelSize.getWidth()); + aRect.AdjustBottom(aPixelSize.getHeight()); + + m_pWindow->Invalidate( OutputDevice::LogicToLogic(aRect, m_aMapMode, m_pWindow->GetMapMode()) ); + + if ( !(m_pRightWin || m_pBottomWin) ) + return; + + Size aWinSize = m_pWindow->PixelToLogic( m_pWindow->GetOutputSizePixel(), m_aMapMode ); + if ( m_pRightWin ) + m_pRightWin->Invalidate( OutputDevice::LogicToLogic(aRect, + lcl_MoveMapMode( m_aMapMode, Size( aWinSize.Width(), 0 ) ), + m_pRightWin->GetMapMode()) ); + if ( m_pBottomWin ) + m_pBottomWin->Invalidate( OutputDevice::LogicToLogic(aRect, + lcl_MoveMapMode( m_aMapMode, Size( 0, aWinSize.Height() ) ), + m_pBottomWin->GetMapMode()) ); + if ( m_pDiagWin ) + m_pDiagWin->Invalidate( OutputDevice::LogicToLogic(aRect, + lcl_MoveMapMode( m_aMapMode, aWinSize ), + m_pDiagWin->GetMapMode()) ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/olinewin.cxx b/sc/source/ui/view/olinewin.cxx index 867e309c08b9..b497d5353d8d 100644 --- a/sc/source/ui/view/olinewin.cxx +++ b/sc/source/ui/view/olinewin.cxx @@ -560,26 +560,26 @@ void ScOutlineWindow::DrawBorderRel( size_t nLevel, size_t nEntry, bool bPressed void ScOutlineWindow::ShowFocus() { - if ( HasFocus() ) - { - // first move to a visible position - ImplMoveFocusToVisible( true ); + if ( !HasFocus() ) + return; - if ( IsFocusButtonVisible() ) - { - Point aPos; - if ( GetImagePos( mnFocusLevel, mnFocusEntry, aPos ) ) - { - aPos += Point( 1, 1 ); - maFocusRect = tools::Rectangle( aPos, Size( SC_OL_BITMAPSIZE - 2, SC_OL_BITMAPSIZE - 2 ) ); - bool bClip = (mnFocusEntry != SC_OL_HEADERENTRY); - if ( bClip ) - SetEntryAreaClipRegion(); - InvertTracking( maFocusRect, ShowTrackFlags::Small | ShowTrackFlags::TrackWindow ); - if ( bClip ) - SetClipRegion(); - } - } + // first move to a visible position + ImplMoveFocusToVisible( true ); + + if ( !IsFocusButtonVisible() ) + return; + + Point aPos; + if ( GetImagePos( mnFocusLevel, mnFocusEntry, aPos ) ) + { + aPos += Point( 1, 1 ); + maFocusRect = tools::Rectangle( aPos, Size( SC_OL_BITMAPSIZE - 2, SC_OL_BITMAPSIZE - 2 ) ); + bool bClip = (mnFocusEntry != SC_OL_HEADERENTRY); + if ( bClip ) + SetEntryAreaClipRegion(); + InvertTracking( maFocusRect, ShowTrackFlags::Small | ShowTrackFlags::TrackWindow ); + if ( bClip ) + SetClipRegion(); } } diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 4e1e53abc397..1a73ffb7169e 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -877,20 +877,20 @@ void drawDataBars(vcl::RenderContext& rRenderContext, const ScDataBarInfo* pOldD } //draw axis - if(pOldDataBarInfo->mnZero && pOldDataBarInfo->mnZero != 100) - { - Point aPoint1(nPosZero, rRect.Top()); - Point aPoint2(nPosZero, rRect.Bottom()); - LineInfo aLineInfo(LineStyle::Dash, 1); - aLineInfo.SetDashCount( 4 ); - aLineInfo.SetDistance( 3 ); - aLineInfo.SetDashLen( 3 ); - rRenderContext.SetFillColor(pOldDataBarInfo->maAxisColor); - rRenderContext.SetLineColor(pOldDataBarInfo->maAxisColor); - rRenderContext.DrawLine(aPoint1, aPoint2, aLineInfo); - rRenderContext.SetLineColor(); - rRenderContext.SetFillColor(); - } + if(!(pOldDataBarInfo->mnZero && pOldDataBarInfo->mnZero != 100)) + return; + + Point aPoint1(nPosZero, rRect.Top()); + Point aPoint2(nPosZero, rRect.Bottom()); + LineInfo aLineInfo(LineStyle::Dash, 1); + aLineInfo.SetDashCount( 4 ); + aLineInfo.SetDistance( 3 ); + aLineInfo.SetDashLen( 3 ); + rRenderContext.SetFillColor(pOldDataBarInfo->maAxisColor); + rRenderContext.SetLineColor(pOldDataBarInfo->maAxisColor); + rRenderContext.DrawLine(aPoint1, aPoint2, aLineInfo); + rRenderContext.SetLineColor(); + rRenderContext.SetFillColor(); } const BitmapEx& getIcon(sc::IconSetBitmapMap & rIconSetBitmapMap, ScIconSetType eType, sal_Int32 nIndex) @@ -1981,122 +1981,121 @@ void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY, if ( nRefStartX == nRefEndX && nRefStartY == nRefEndY ) mpDoc->ExtendMerge( nRefStartX, nRefStartY, nRefEndX, nRefEndY, nTab ); - if ( nRefStartX <= nVisX2 && nRefEndX >= nVisX1 && - nRefStartY <= nVisY2 && nRefEndY >= nVisY1 ) + if ( !(nRefStartX <= nVisX2 && nRefEndX >= nVisX1 && + nRefStartY <= nVisY2 && nRefEndY >= nVisY1) ) + return; + + long nMinX = nScrX; + long nMinY = nScrY; + long nMaxX = nScrX + nScrW - 1; + long nMaxY = nScrY + nScrH - 1; + if ( bLayoutRTL ) { - long nMinX = nScrX; - long nMinY = nScrY; - long nMaxX = nScrX + nScrW - 1; - long nMaxY = nScrY + nScrH - 1; - if ( bLayoutRTL ) - { - long nTemp = nMinX; - nMinX = nMaxX; - nMaxX = nTemp; - } - long nLayoutSign = bLayoutRTL ? -1 : 1; + long nTemp = nMinX; + nMinX = nMaxX; + nMaxX = nTemp; + } + long nLayoutSign = bLayoutRTL ? -1 : 1; - bool bTop = false; - bool bBottom = false; - bool bLeft = false; - bool bRight = false; + bool bTop = false; + bool bBottom = false; + bool bLeft = false; + bool bRight = false; - long nPosY = nScrY; - bool bNoStartY = ( nY1 < nRefStartY ); - bool bNoEndY = false; - for (SCSIZE nArrY=1; nArrYnRefStartY && bNoStartY) ) - { - nMinY = nPosY; - bTop = true; - } - if ( nY==nRefEndY ) - { - nMaxY = nPosY + pRowInfo[nArrY].nHeight - 2; - bBottom = true; - } - if ( nY>nRefEndY && bNoEndY ) - { - nMaxY = nPosY-2; - bBottom = true; - } - bNoStartY = ( nY < nRefStartY ); - bNoEndY = ( nY < nRefEndY ); - nPosY += pRowInfo[nArrY].nHeight; + if ( nY==nRefStartY || (nY>nRefStartY && bNoStartY) ) + { + nMinY = nPosY; + bTop = true; + } + if ( nY==nRefEndY ) + { + nMaxY = nPosY + pRowInfo[nArrY].nHeight - 2; + bBottom = true; } + if ( nY>nRefEndY && bNoEndY ) + { + nMaxY = nPosY-2; + bBottom = true; + } + bNoStartY = ( nY < nRefStartY ); + bNoEndY = ( nY < nRefEndY ); + nPosY += pRowInfo[nArrY].nHeight; + } - long nPosX = nScrX; - if ( bLayoutRTL ) - nPosX += nMirrorW - 1; // always in pixels + long nPosX = nScrX; + if ( bLayoutRTL ) + nPosX += nMirrorW - 1; // always in pixels - for (SCCOL nX=nX1; nX<=nX2; nX++) + for (SCCOL nX=nX1; nX<=nX2; nX++) + { + if ( nX==nRefStartX ) { - if ( nX==nRefStartX ) - { - nMinX = nPosX; - bLeft = true; - } - if ( nX==nRefEndX ) - { - nMaxX = nPosX + ( pRowInfo[0].pCellInfo[nX+1].nWidth - 2 ) * nLayoutSign; - bRight = true; - } - nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign; + nMinX = nPosX; + bLeft = true; } - - if ( nMaxX * nLayoutSign >= nMinX * nLayoutSign && - nMaxY >= nMinY ) + if ( nX==nRefEndX ) { - mpDev->SetLineColor( rColor ); - if (bTop && bBottom && bLeft && bRight && !comphelper::LibreOfficeKit::isActive() ) - { - mpDev->SetFillColor(); - mpDev->DrawRect( tools::Rectangle( nMinX, nMinY, nMaxX, nMaxY ) ); - } - else if ( !comphelper::LibreOfficeKit::isActive() ) - { - if (bTop) - mpDev->DrawLine( Point( nMinX, nMinY ), Point( nMaxX, nMinY ) ); - if (bBottom) - mpDev->DrawLine( Point( nMinX, nMaxY ), Point( nMaxX, nMaxY ) ); - if (bLeft) - mpDev->DrawLine( Point( nMinX, nMinY ), Point( nMinX, nMaxY ) ); - if (bRight) - mpDev->DrawLine( Point( nMaxX, nMinY ), Point( nMaxX, nMaxY ) ); - } - if ( bHandle && bRight && bBottom && !comphelper::LibreOfficeKit::isActive() ) - { - mpDev->SetLineColor( rColor ); - mpDev->SetFillColor( rColor ); - - const sal_Int32 aRadius = 4; - - sal_Int32 aRectMaxX1 = nMaxX - nLayoutSign * aRadius; - sal_Int32 aRectMaxX2 = nMaxX + nLayoutSign; - sal_Int32 aRectMinX1 = nMinX - nLayoutSign; - sal_Int32 aRectMinX2 = nMinX + nLayoutSign * aRadius; - - sal_Int32 aRectMaxY1 = nMaxY - aRadius; - sal_Int32 aRectMaxY2 = nMaxY + 1; - sal_Int32 aRectMinY1 = nMinY - 1; - sal_Int32 aRectMinY2 = nMinY + aRadius; - - // Draw corner rectangles - tools::Rectangle aLowerRight( aRectMaxX1, aRectMaxY1, aRectMaxX2, aRectMaxY2 ); - tools::Rectangle aUpperLeft ( aRectMinX1, aRectMinY1, aRectMinX2, aRectMinY2 ); - tools::Rectangle aLowerLeft ( aRectMinX1, aRectMaxY1, aRectMinX2, aRectMaxY2 ); - tools::Rectangle aUpperRight( aRectMaxX1, aRectMinY1, aRectMaxX2, aRectMinY2 ); - - mpDev->DrawTransparent( tools::PolyPolygon( tools::Polygon( aLowerRight ) ), lclCornerRectTransparency ); - mpDev->DrawTransparent( tools::PolyPolygon( tools::Polygon( aUpperLeft ) ), lclCornerRectTransparency ); - mpDev->DrawTransparent( tools::PolyPolygon( tools::Polygon( aLowerLeft ) ), lclCornerRectTransparency ); - mpDev->DrawTransparent( tools::PolyPolygon( tools::Polygon( aUpperRight ) ), lclCornerRectTransparency ); - } + nMaxX = nPosX + ( pRowInfo[0].pCellInfo[nX+1].nWidth - 2 ) * nLayoutSign; + bRight = true; } + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign; } + + if ( nMaxX * nLayoutSign < nMinX * nLayoutSign || nMaxY < nMinY ) + return; + + mpDev->SetLineColor( rColor ); + if (bTop && bBottom && bLeft && bRight && !comphelper::LibreOfficeKit::isActive() ) + { + mpDev->SetFillColor(); + mpDev->DrawRect( tools::Rectangle( nMinX, nMinY, nMaxX, nMaxY ) ); + } + else if ( !comphelper::LibreOfficeKit::isActive() ) + { + if (bTop) + mpDev->DrawLine( Point( nMinX, nMinY ), Point( nMaxX, nMinY ) ); + if (bBottom) + mpDev->DrawLine( Point( nMinX, nMaxY ), Point( nMaxX, nMaxY ) ); + if (bLeft) + mpDev->DrawLine( Point( nMinX, nMinY ), Point( nMinX, nMaxY ) ); + if (bRight) + mpDev->DrawLine( Point( nMaxX, nMinY ), Point( nMaxX, nMaxY ) ); + } + if ( !(bHandle && bRight && bBottom && !comphelper::LibreOfficeKit::isActive()) ) + return; + + mpDev->SetLineColor( rColor ); + mpDev->SetFillColor( rColor ); + + const sal_Int32 aRadius = 4; + + sal_Int32 aRectMaxX1 = nMaxX - nLayoutSign * aRadius; + sal_Int32 aRectMaxX2 = nMaxX + nLayoutSign; + sal_Int32 aRectMinX1 = nMinX - nLayoutSign; + sal_Int32 aRectMinX2 = nMinX + nLayoutSign * aRadius; + + sal_Int32 aRectMaxY1 = nMaxY - aRadius; + sal_Int32 aRectMaxY2 = nMaxY + 1; + sal_Int32 aRectMinY1 = nMinY - 1; + sal_Int32 aRectMinY2 = nMinY + aRadius; + + // Draw corner rectangles + tools::Rectangle aLowerRight( aRectMaxX1, aRectMaxY1, aRectMaxX2, aRectMaxY2 ); + tools::Rectangle aUpperLeft ( aRectMinX1, aRectMinY1, aRectMinX2, aRectMinY2 ); + tools::Rectangle aLowerLeft ( aRectMinX1, aRectMaxY1, aRectMinX2, aRectMaxY2 ); + tools::Rectangle aUpperRight( aRectMaxX1, aRectMinY1, aRectMaxX2, aRectMinY2 ); + + mpDev->DrawTransparent( tools::PolyPolygon( tools::Polygon( aLowerRight ) ), lclCornerRectTransparency ); + mpDev->DrawTransparent( tools::PolyPolygon( tools::Polygon( aUpperLeft ) ), lclCornerRectTransparency ); + mpDev->DrawTransparent( tools::PolyPolygon( tools::Polygon( aLowerLeft ) ), lclCornerRectTransparency ); + mpDev->DrawTransparent( tools::PolyPolygon( tools::Polygon( aUpperRight ) ), lclCornerRectTransparency ); } void ScOutputData::DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY, @@ -2109,112 +2108,111 @@ void ScOutputData::DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY, if ( nRefStartX == nRefEndX && nRefStartY == nRefEndY ) mpDoc->ExtendMerge( nRefStartX, nRefStartY, nRefEndX, nRefEndY, nTab ); - if ( nRefStartX <= nVisX2 + 1 && nRefEndX >= nVisX1 && - nRefStartY <= nVisY2 + 1 && nRefEndY >= nVisY1 ) // +1 because it touches next cells left/top + if ( !(nRefStartX <= nVisX2 + 1 && nRefEndX >= nVisX1 && + nRefStartY <= nVisY2 + 1 && nRefEndY >= nVisY1) ) // +1 because it touches next cells left/top + return; + + long nMinX = nScrX; + long nMinY = nScrY; + long nMaxX = nScrX+nScrW-1; + long nMaxY = nScrY+nScrH-1; + if ( bLayoutRTL ) { - long nMinX = nScrX; - long nMinY = nScrY; - long nMaxX = nScrX+nScrW-1; - long nMaxY = nScrY+nScrH-1; - if ( bLayoutRTL ) - { - long nTemp = nMinX; - nMinX = nMaxX; - nMaxX = nTemp; - } - long nLayoutSign = bLayoutRTL ? -1 : 1; + long nTemp = nMinX; + nMinX = nMaxX; + nMaxX = nTemp; + } + long nLayoutSign = bLayoutRTL ? -1 : 1; - bool bTop = false; - bool bBottom = false; - bool bLeft = false; - bool bRight = false; + bool bTop = false; + bool bBottom = false; + bool bLeft = false; + bool bRight = false; - long nPosY = nScrY; - bool bNoStartY = ( nY1 < nRefStartY ); - bool bNoEndY = false; - for (SCSIZE nArrY=1; nArrYnRefStartY && bNoStartY) ) - { - nMinY = nPosY - 1; - bTop = true; - } - if ( nY==nRefEndY ) - { - nMaxY = nPosY + pRowInfo[nArrY].nHeight - 1; - bBottom = true; - } - if ( nY>nRefEndY && bNoEndY ) - { - nMaxY = nPosY - 1; - bBottom = true; - } - bNoStartY = ( nY < nRefStartY ); - bNoEndY = ( nY < nRefEndY ); - nPosY += pRowInfo[nArrY].nHeight; + if ( nY==nRefStartY || (nY>nRefStartY && bNoStartY) ) + { + nMinY = nPosY - 1; + bTop = true; } + if ( nY==nRefEndY ) + { + nMaxY = nPosY + pRowInfo[nArrY].nHeight - 1; + bBottom = true; + } + if ( nY>nRefEndY && bNoEndY ) + { + nMaxY = nPosY - 1; + bBottom = true; + } + bNoStartY = ( nY < nRefStartY ); + bNoEndY = ( nY < nRefEndY ); + nPosY += pRowInfo[nArrY].nHeight; + } - long nPosX = nScrX; - if ( bLayoutRTL ) - nPosX += nMirrorW - 1; // always in pixels + long nPosX = nScrX; + if ( bLayoutRTL ) + nPosX += nMirrorW - 1; // always in pixels - for (SCCOL nX=nX1; nX<=nX2+1; nX++) + for (SCCOL nX=nX1; nX<=nX2+1; nX++) + { + if ( nX==nRefStartX ) { - if ( nX==nRefStartX ) - { - nMinX = nPosX - nLayoutSign; - bLeft = true; - } - if ( nX==nRefEndX ) - { - nMaxX = nPosX + ( pRowInfo[0].pCellInfo[nX+1].nWidth - 1 ) * nLayoutSign; - bRight = true; - } - nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign; + nMinX = nPosX - nLayoutSign; + bLeft = true; } + if ( nX==nRefEndX ) + { + nMaxX = nPosX + ( pRowInfo[0].pCellInfo[nX+1].nWidth - 1 ) * nLayoutSign; + bRight = true; + } + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign; + } - if ( nMaxX * nLayoutSign >= nMinX * nLayoutSign && - nMaxY >= nMinY ) + if ( nMaxX * nLayoutSign < nMinX * nLayoutSign || nMaxY < nMinY ) + return; + + if ( nType == SC_CAT_DELETE_ROWS ) + bLeft = bRight = bBottom = false; //! thick lines??? + else if ( nType == SC_CAT_DELETE_COLS ) + bTop = bBottom = bRight = false; //! thick lines??? + + mpDev->SetLineColor( rColor ); + if (bTop && bBottom && bLeft && bRight) + { + mpDev->SetFillColor(); + mpDev->DrawRect( tools::Rectangle( nMinX, nMinY, nMaxX, nMaxY ) ); + } + else + { + if (bTop) { + mpDev->DrawLine( Point( nMinX,nMinY ), Point( nMaxX,nMinY ) ); if ( nType == SC_CAT_DELETE_ROWS ) - bLeft = bRight = bBottom = false; //! thick lines??? - else if ( nType == SC_CAT_DELETE_COLS ) - bTop = bBottom = bRight = false; //! thick lines??? - - mpDev->SetLineColor( rColor ); - if (bTop && bBottom && bLeft && bRight) - { - mpDev->SetFillColor(); - mpDev->DrawRect( tools::Rectangle( nMinX, nMinY, nMaxX, nMaxY ) ); - } - else - { - if (bTop) - { - mpDev->DrawLine( Point( nMinX,nMinY ), Point( nMaxX,nMinY ) ); - if ( nType == SC_CAT_DELETE_ROWS ) - mpDev->DrawLine( Point( nMinX,nMinY+1 ), Point( nMaxX,nMinY+1 ) ); - } - if (bBottom) - mpDev->DrawLine( Point( nMinX,nMaxY ), Point( nMaxX,nMaxY ) ); - if (bLeft) - { - mpDev->DrawLine( Point( nMinX,nMinY ), Point( nMinX,nMaxY ) ); - if ( nType == SC_CAT_DELETE_COLS ) - mpDev->DrawLine( Point( nMinX+nLayoutSign,nMinY ), Point( nMinX+nLayoutSign,nMaxY ) ); - } - if (bRight) - mpDev->DrawLine( Point( nMaxX,nMinY ), Point( nMaxX,nMaxY ) ); - } - if ( bLeft && bTop ) - { - mpDev->SetLineColor(); - mpDev->SetFillColor( rColor ); - mpDev->DrawRect( tools::Rectangle( nMinX+nLayoutSign, nMinY+1, nMinX+3*nLayoutSign, nMinY+3 ) ); - } + mpDev->DrawLine( Point( nMinX,nMinY+1 ), Point( nMaxX,nMinY+1 ) ); + } + if (bBottom) + mpDev->DrawLine( Point( nMinX,nMaxY ), Point( nMaxX,nMaxY ) ); + if (bLeft) + { + mpDev->DrawLine( Point( nMinX,nMinY ), Point( nMinX,nMaxY ) ); + if ( nType == SC_CAT_DELETE_COLS ) + mpDev->DrawLine( Point( nMinX+nLayoutSign,nMinY ), Point( nMinX+nLayoutSign,nMaxY ) ); } + if (bRight) + mpDev->DrawLine( Point( nMaxX,nMinY ), Point( nMaxX,nMaxY ) ); + } + if ( bLeft && bTop ) + { + mpDev->SetLineColor(); + mpDev->SetFillColor( rColor ); + mpDev->DrawRect( tools::Rectangle( nMinX+nLayoutSign, nMinY+1, nMinX+3*nLayoutSign, nMinY+3 ) ); } } diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 9644497c0e8a..c4aaca82ca16 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -2550,25 +2550,25 @@ void ScOutputData::DrawEditParam::calcStartPosForVertical( if (mbPixelToLogic) rLogicStart = pRefDevice->PixelToLogic(rLogicStart); - if (mbBreak) - { - // vertical adjustment is within the EditEngine - if (mbPixelToLogic) - rLogicStart.AdjustY(pRefDevice->PixelToLogic(Size(0,nTopM)).Height() ); - else - rLogicStart.AdjustY(nTopM ); + if (!mbBreak) + return; - switch (meHorJustResult) - { - case SvxCellHorJustify::Center: - rLogicStart.AdjustX((nCellWidth - nEngineWidth) / 2 ); - break; - case SvxCellHorJustify::Right: - rLogicStart.AdjustX(nCellWidth - nEngineWidth ); - break; - default: - ; // do nothing - } + // vertical adjustment is within the EditEngine + if (mbPixelToLogic) + rLogicStart.AdjustY(pRefDevice->PixelToLogic(Size(0,nTopM)).Height() ); + else + rLogicStart.AdjustY(nTopM ); + + switch (meHorJustResult) + { + case SvxCellHorJustify::Center: + rLogicStart.AdjustX((nCellWidth - nEngineWidth) / 2 ); + break; + case SvxCellHorJustify::Right: + rLogicStart.AdjustX(nCellWidth - nEngineWidth ); + break; + default: + ; // do nothing } } @@ -2759,20 +2759,20 @@ public: const VclPtr& pDev, bool bMetaFile ) :mbMetaFile(bMetaFile) { - if (bClip || bSimClip) + if (!(bClip || bSimClip)) + return; + + maRect = rRect; + if (bClip) // for bSimClip only initialize aClipRect { - maRect = rRect; - if (bClip) // for bSimClip only initialize aClipRect + mpDev.reset(pDev); + if (mbMetaFile) { - mpDev.reset(pDev); - if (mbMetaFile) - { - mpDev->Push(); - mpDev->IntersectClipRegion(maRect); - } - else - mpDev->SetClipRegion(vcl::Region(maRect)); + mpDev->Push(); + mpDev->IntersectClipRegion(maRect); } + else + mpDev->SetClipRegion(vcl::Region(maRect)); } } @@ -3165,27 +3165,27 @@ void ScOutputData::ShowClipMarks( DrawEditParam& rParam, long nEngineHeight, con // with the default right position of the text. // Only with automatic line breaks, to avoid having to find // the cells with the horizontal end of the text again. - if ( nEngineHeight - aCellSize.Height() > 100 && + if ( !(nEngineHeight - aCellSize.Height() > 100 && rParam.mbBreak && bMarkClipped && - ( rParam.mpEngine->GetParagraphCount() > 1 || rParam.mpEngine->GetLineCount(0) > 1 ) ) + ( rParam.mpEngine->GetParagraphCount() > 1 || rParam.mpEngine->GetLineCount(0) > 1 )) ) + return; + + CellInfo* pClipMarkCell = nullptr; + if ( bMerged ) { - CellInfo* pClipMarkCell = nullptr; - if ( bMerged ) - { - // anywhere in the merged area... - SCCOL nClipX = ( rParam.mnX < nX1 ) ? nX1 : rParam.mnX; - pClipMarkCell = &pRowInfo[(rParam.mnArrY != 0) ? rParam.mnArrY : 1].pCellInfo[nClipX+1]; - } - else - pClipMarkCell = &rParam.mpThisRowInfo->pCellInfo[rParam.mnX+1]; + // anywhere in the merged area... + SCCOL nClipX = ( rParam.mnX < nX1 ) ? nX1 : rParam.mnX; + pClipMarkCell = &pRowInfo[(rParam.mnArrY != 0) ? rParam.mnArrY : 1].pCellInfo[nClipX+1]; + } + else + pClipMarkCell = &rParam.mpThisRowInfo->pCellInfo[rParam.mnX+1]; - pClipMarkCell->nClipMark |= ScClipMark::Right; //! also allow left? - bAnyClipped = true; + pClipMarkCell->nClipMark |= ScClipMark::Right; //! also allow left? + bAnyClipped = true; - const long nMarkPixel = static_cast( SC_CLIPMARK_SIZE * mnPPTX ); - if ( aAreaParam.maClipRect.Right() - nMarkPixel > aAreaParam.maClipRect.Left() ) - aAreaParam.maClipRect.AdjustRight( -nMarkPixel ); - } + const long nMarkPixel = static_cast( SC_CLIPMARK_SIZE * mnPPTX ); + if ( aAreaParam.maClipRect.Right() - nMarkPixel > aAreaParam.maClipRect.Left() ) + aAreaParam.maClipRect.AdjustRight( -nMarkPixel ); } ClearableClipRegionPtr ScOutputData::Clip( DrawEditParam& rParam, const Size& aCellSize, diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx index cf0add6a8b18..09f3da645d41 100644 --- a/sc/source/ui/view/preview.cxx +++ b/sc/source/ui/view/preview.cxx @@ -176,35 +176,35 @@ void ScPreview::UpdateDrawView() // nTab must be right void ScPreview::TestLastPage() { - if (nPageNo >= nTotalPages) + if (nPageNo < nTotalPages) + return; + + if (nTotalPages) { - if (nTotalPages) - { - nPageNo = nTotalPages - 1; - nTab = static_cast(nPages.size()) -1; - while (nTab > 0 && !nPages[nTab]) // not the last empty Table - --nTab; - OSL_ENSURE(0 < static_cast(nPages.size()),"are all tables empty?"); - nTabPage = nPages[nTab] - 1; - nTabStart = 0; - for (sal_uInt16 i=0; i(nPages.size()) -1; + while (nTab > 0 && !nPages[nTab]) // not the last empty Table + --nTab; + OSL_ENSURE(0 < static_cast(nPages.size()),"are all tables empty?"); + nTabPage = nPages[nTab] - 1; + nTabStart = 0; + for (sal_uInt16 i=0; iGetDocument(); - nDisplayStart = lcl_GetDisplayStart( nTab, &rDoc, nPages ); - } - else // empty Document - { - nTab = 0; - nPageNo = nTabPage = nTabStart = nDisplayStart = 0; - aState.nPrintTab = 0; - aState.nStartCol = aState.nEndCol = 0; - aState.nStartRow = aState.nEndRow = 0; - aState.nZoom = 0; - aState.nPagesX = aState.nPagesY = 0; - aState.nTabPages = aState.nTotalPages = - aState.nPageStart = aState.nDocPages = 0; - } + ScDocument& rDoc = pDocShell->GetDocument(); + nDisplayStart = lcl_GetDisplayStart( nTab, &rDoc, nPages ); + } + else // empty Document + { + nTab = 0; + nPageNo = nTabPage = nTabStart = nDisplayStart = 0; + aState.nPrintTab = 0; + aState.nStartCol = aState.nEndCol = 0; + aState.nStartRow = aState.nEndRow = 0; + aState.nZoom = 0; + aState.nPagesX = aState.nPagesY = 0; + aState.nTabPages = aState.nTotalPages = + aState.nPageStart = aState.nDocPages = 0; } } @@ -471,146 +471,146 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation ) } } - if ( bDoPrint ) - { - long nPageEndX = aLocalPageSize.Width() - aOffset.X(); - long nPageEndY = aLocalPageSize.Height() - aOffset.Y(); - if ( !bValidPage ) - nPageEndX = nPageEndY = 0; + if ( !bDoPrint ) + return; - Size aWinSize = GetOutputSize(); - Point aWinEnd( aWinSize.Width(), aWinSize.Height() ); - bool bRight = nPageEndX <= aWinEnd.X(); - bool bBottom = nPageEndY <= aWinEnd.Y(); + long nPageEndX = aLocalPageSize.Width() - aOffset.X(); + long nPageEndY = aLocalPageSize.Height() - aOffset.Y(); + if ( !bValidPage ) + nPageEndX = nPageEndY = 0; - if (!nTotalPages) - { - // There is no data to print. Print a friendly warning message and - // bail out. + Size aWinSize = GetOutputSize(); + Point aWinEnd( aWinSize.Width(), aWinSize.Height() ); + bool bRight = nPageEndX <= aWinEnd.X(); + bool bBottom = nPageEndY <= aWinEnd.Y(); + + if (!nTotalPages) + { + // There is no data to print. Print a friendly warning message and + // bail out. + + SetMapMode(aMMMode); - SetMapMode(aMMMode); + // Draw background first. + SetLineColor(); + SetFillColor(aBackColor); + DrawRect(tools::Rectangle(0, 0, aWinEnd.X(), aWinEnd.Y())); - // Draw background first. - SetLineColor(); - SetFillColor(aBackColor); - DrawRect(tools::Rectangle(0, 0, aWinEnd.X(), aWinEnd.Y())); + const ScPatternAttr& rDefPattern = + rDoc.GetPool()->GetDefaultItem(ATTR_PATTERN); - const ScPatternAttr& rDefPattern = - rDoc.GetPool()->GetDefaultItem(ATTR_PATTERN); + std::unique_ptr pEditEng( + new ScEditEngineDefaulter(EditEngine::CreatePool(), true)); - std::unique_ptr pEditEng( - new ScEditEngineDefaulter(EditEngine::CreatePool(), true)); + pEditEng->SetRefMapMode(aMMMode); + auto pEditDefaults = std::make_unique( pEditEng->GetEmptyItemSet() ); + rDefPattern.FillEditItemSet(pEditDefaults.get()); + pEditDefaults->Put(SvxColorItem(COL_LIGHTGRAY, EE_CHAR_COLOR)); + pEditEng->SetDefaults(std::move(pEditDefaults)); - pEditEng->SetRefMapMode(aMMMode); - auto pEditDefaults = std::make_unique( pEditEng->GetEmptyItemSet() ); - rDefPattern.FillEditItemSet(pEditDefaults.get()); - pEditDefaults->Put(SvxColorItem(COL_LIGHTGRAY, EE_CHAR_COLOR)); - pEditEng->SetDefaults(std::move(pEditDefaults)); + OUString aEmptyMsg; + if (mbHasEmptyRangeTable) + aEmptyMsg = ScResId(STR_PRINT_PREVIEW_EMPTY_RANGE); + else + aEmptyMsg = ScResId(STR_PRINT_PREVIEW_NODATA); - OUString aEmptyMsg; - if (mbHasEmptyRangeTable) - aEmptyMsg = ScResId(STR_PRINT_PREVIEW_EMPTY_RANGE); - else - aEmptyMsg = ScResId(STR_PRINT_PREVIEW_NODATA); + long nHeight = 3000; + pEditEng->SetDefaultItem(SvxFontHeightItem(nHeight, 100, EE_CHAR_FONTHEIGHT)); + pEditEng->SetDefaultItem(SvxFontHeightItem(nHeight, 100, EE_CHAR_FONTHEIGHT_CJK)); + pEditEng->SetDefaultItem(SvxFontHeightItem(nHeight, 100, EE_CHAR_FONTHEIGHT_CTL)); - long nHeight = 3000; - pEditEng->SetDefaultItem(SvxFontHeightItem(nHeight, 100, EE_CHAR_FONTHEIGHT)); - pEditEng->SetDefaultItem(SvxFontHeightItem(nHeight, 100, EE_CHAR_FONTHEIGHT_CJK)); - pEditEng->SetDefaultItem(SvxFontHeightItem(nHeight, 100, EE_CHAR_FONTHEIGHT_CTL)); + pEditEng->SetTextCurrentDefaults(aEmptyMsg); - pEditEng->SetTextCurrentDefaults(aEmptyMsg); + Point aCenter( + (aWinEnd.X() - pEditEng->CalcTextWidth())/2, + (aWinEnd.Y() - pEditEng->GetTextHeight())/2); - Point aCenter( - (aWinEnd.X() - pEditEng->CalcTextWidth())/2, - (aWinEnd.Y() - pEditEng->GetTextHeight())/2); + pEditEng->Draw(this, aCenter); - pEditEng->Draw(this, aCenter); + return; + } - return; + if( bPageMargin && bValidPage ) + { + SetMapMode(aMMMode); + SetLineColor( COL_BLACK ); + DrawInvert( static_cast( nTopMargin - aOffset.Y() ), PointerStyle::VSizeBar ); + DrawInvert( static_cast(nPageEndY - nBottomMargin ), PointerStyle::VSizeBar ); + DrawInvert( static_cast( nLeftMargin - aOffset.X() ), PointerStyle::HSizeBar ); + DrawInvert( static_cast( nPageEndX - nRightMargin ) , PointerStyle::HSizeBar ); + if( bHeaderOn ) + { + DrawInvert( nHeaderHeight - aOffset.Y(), PointerStyle::VSizeBar ); + } + if( bFooterOn ) + { + DrawInvert( nPageEndY - nFooterHeight, PointerStyle::VSizeBar ); } - if( bPageMargin && bValidPage ) + SetMapMode( MapMode( MapUnit::MapPixel ) ); + for( int i= aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ ) { - SetMapMode(aMMMode); + Point aColumnTop = LogicToPixel( Point( 0, -aOffset.Y() ) ,aMMMode ); SetLineColor( COL_BLACK ); - DrawInvert( static_cast( nTopMargin - aOffset.Y() ), PointerStyle::VSizeBar ); - DrawInvert( static_cast(nPageEndY - nBottomMargin ), PointerStyle::VSizeBar ); - DrawInvert( static_cast( nLeftMargin - aOffset.X() ), PointerStyle::HSizeBar ); - DrawInvert( static_cast( nPageEndX - nRightMargin ) , PointerStyle::HSizeBar ); - if( bHeaderOn ) - { - DrawInvert( nHeaderHeight - aOffset.Y(), PointerStyle::VSizeBar ); - } - if( bFooterOn ) - { - DrawInvert( nPageEndY - nFooterHeight, PointerStyle::VSizeBar ); - } - - SetMapMode( MapMode( MapUnit::MapPixel ) ); - for( int i= aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ ) - { - Point aColumnTop = LogicToPixel( Point( 0, -aOffset.Y() ) ,aMMMode ); - SetLineColor( COL_BLACK ); - SetFillColor( COL_BLACK ); - DrawRect( tools::Rectangle( Point( mvRight[i] - 2, aColumnTop.Y() ),Point( mvRight[i] + 2 , 4 + aColumnTop.Y()) )); - DrawLine( Point( mvRight[i], aColumnTop.Y() ), Point( mvRight[i], 10 + aColumnTop.Y()) ); - } - SetMapMode( aMMMode ); + SetFillColor( COL_BLACK ); + DrawRect( tools::Rectangle( Point( mvRight[i] - 2, aColumnTop.Y() ),Point( mvRight[i] + 2 , 4 + aColumnTop.Y()) )); + DrawLine( Point( mvRight[i], aColumnTop.Y() ), Point( mvRight[i], 10 + aColumnTop.Y()) ); } + SetMapMode( aMMMode ); + } - if (bRight || bBottom) + if (bRight || bBottom) + { + SetMapMode(aMMMode); + SetLineColor(); + SetFillColor(aBackColor); + if (bRight) + DrawRect(tools::Rectangle(nPageEndX,0, aWinEnd.X(),aWinEnd.Y())); + if (bBottom) { - SetMapMode(aMMMode); - SetLineColor(); - SetFillColor(aBackColor); if (bRight) - DrawRect(tools::Rectangle(nPageEndX,0, aWinEnd.X(),aWinEnd.Y())); - if (bBottom) - { - if (bRight) - DrawRect(tools::Rectangle(0,nPageEndY, nPageEndX,aWinEnd.Y())); // Corner not duplicated - else - DrawRect(tools::Rectangle(0,nPageEndY, aWinEnd.X(),aWinEnd.Y())); - } + DrawRect(tools::Rectangle(0,nPageEndY, nPageEndX,aWinEnd.Y())); // Corner not duplicated + else + DrawRect(tools::Rectangle(0,nPageEndY, aWinEnd.X(),aWinEnd.Y())); } + } - if ( bValidPage ) - { - Color aBorderColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor ); + if ( !bValidPage ) + return; - // draw border + Color aBorderColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor ); - if ( aOffset.X() <= 0 || aOffset.Y() <= 0 || bRight || bBottom ) - { - SetLineColor( aBorderColor ); - SetFillColor(); + // draw border - tools::Rectangle aPixel( LogicToPixel( tools::Rectangle( -aOffset.X(), -aOffset.Y(), nPageEndX, nPageEndY ) ) ); - aPixel.AdjustRight( -1 ); - aPixel.AdjustBottom( -1 ); - DrawRect( PixelToLogic( aPixel ) ); - } + if ( aOffset.X() <= 0 || aOffset.Y() <= 0 || bRight || bBottom ) + { + SetLineColor( aBorderColor ); + SetFillColor(); - // draw shadow + tools::Rectangle aPixel( LogicToPixel( tools::Rectangle( -aOffset.X(), -aOffset.Y(), nPageEndX, nPageEndY ) ) ); + aPixel.AdjustRight( -1 ); + aPixel.AdjustBottom( -1 ); + DrawRect( PixelToLogic( aPixel ) ); + } - SetLineColor(); - SetFillColor( aBorderColor ); + // draw shadow - tools::Rectangle aPixel; + SetLineColor(); + SetFillColor( aBorderColor ); - aPixel = LogicToPixel( tools::Rectangle( nPageEndX, -aOffset.Y(), nPageEndX, nPageEndY ) ); - aPixel.AdjustTop(SC_PREVIEW_SHADOWSIZE ); - aPixel.AdjustRight(SC_PREVIEW_SHADOWSIZE - 1 ); - aPixel.AdjustBottom(SC_PREVIEW_SHADOWSIZE - 1 ); - DrawRect( PixelToLogic( aPixel ) ); + tools::Rectangle aPixel; - aPixel = LogicToPixel( tools::Rectangle( -aOffset.X(), nPageEndY, nPageEndX, nPageEndY ) ); - aPixel.AdjustLeft(SC_PREVIEW_SHADOWSIZE ); - aPixel.AdjustRight(SC_PREVIEW_SHADOWSIZE - 1 ); - aPixel.AdjustBottom(SC_PREVIEW_SHADOWSIZE - 1 ); - DrawRect( PixelToLogic( aPixel ) ); - } - } + aPixel = LogicToPixel( tools::Rectangle( nPageEndX, -aOffset.Y(), nPageEndX, nPageEndY ) ); + aPixel.AdjustTop(SC_PREVIEW_SHADOWSIZE ); + aPixel.AdjustRight(SC_PREVIEW_SHADOWSIZE - 1 ); + aPixel.AdjustBottom(SC_PREVIEW_SHADOWSIZE - 1 ); + DrawRect( PixelToLogic( aPixel ) ); + + aPixel = LogicToPixel( tools::Rectangle( -aOffset.X(), nPageEndY, nPageEndX, nPageEndY ) ); + aPixel.AdjustLeft(SC_PREVIEW_SHADOWSIZE ); + aPixel.AdjustRight(SC_PREVIEW_SHADOWSIZE - 1 ); + aPixel.AdjustBottom(SC_PREVIEW_SHADOWSIZE - 1 ); + DrawRect( PixelToLogic( aPixel ) ); } void ScPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& /* rRect */ ) @@ -718,26 +718,26 @@ void ScPreview::SetZoom(sal_uInt16 nNewZoom) nNewZoom = 20; if (nNewZoom > 400) nNewZoom = 400; - if (nNewZoom != nZoom) - { - nZoom = nNewZoom; + if (nNewZoom == nZoom) + return; - // apply new MapMode and call UpdateScrollBars to update aOffset + nZoom = nNewZoom; - Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( static_cast( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); - MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom ); - SetMapMode( aMMMode ); + // apply new MapMode and call UpdateScrollBars to update aOffset - bInSetZoom = true; // don't scroll during SetYOffset in UpdateScrollBars - pViewShell->UpdateNeededScrollBars(true); - bInSetZoom = false; + Fraction aPreviewZoom( nZoom, 100 ); + Fraction aHorPrevZoom( static_cast( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom ); + SetMapMode( aMMMode ); - bStateValid = false; - InvalidateLocationData( SfxHintId::ScAccVisAreaChanged ); - DoInvalidate(); - Invalidate(); - } + bInSetZoom = true; // don't scroll during SetYOffset in UpdateScrollBars + pViewShell->UpdateNeededScrollBars(true); + bInSetZoom = false; + + bStateValid = false; + InvalidateLocationData( SfxHintId::ScAccVisAreaChanged ); + DoInvalidate(); + Invalidate(); } void ScPreview::SetPageNo( long nPage ) @@ -924,29 +924,29 @@ void ScPreview::DataChanged( const DataChangedEvent& rDCEvt ) { Window::DataChanged(rDCEvt); - if ( (rDCEvt.GetType() == DataChangedEventType::PRINTER) || + if ( !((rDCEvt.GetType() == DataChangedEventType::PRINTER) || (rDCEvt.GetType() == DataChangedEventType::DISPLAY) || (rDCEvt.GetType() == DataChangedEventType::FONTS) || (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) || ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && - (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) ) - { - if ( rDCEvt.GetType() == DataChangedEventType::FONTS ) - pDocShell->UpdateFontList(); + (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))) ) + return; + + if ( rDCEvt.GetType() == DataChangedEventType::FONTS ) + pDocShell->UpdateFontList(); - // #i114518# Paint of form controls may modify the window's settings. - // Ignore the event if it is called from within Paint. - if ( !bInPaint ) + // #i114518# Paint of form controls may modify the window's settings. + // Ignore the event if it is called from within Paint. + if ( !bInPaint ) + { + if ( rDCEvt.GetType() == DataChangedEventType::SETTINGS && + (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) ) { - if ( rDCEvt.GetType() == DataChangedEventType::SETTINGS && - (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) ) - { - // scroll bar size may have changed - pViewShell->InvalidateBorder(); // calls OuterResizePixel - } - Invalidate(); - InvalidateLocationData( SfxHintId::ScDataChanged ); + // scroll bar size may have changed + pViewShell->InvalidateBorder(); // calls OuterResizePixel } + Invalidate(); + InvalidateLocationData( SfxHintId::ScDataChanged ); } } @@ -1007,30 +1007,30 @@ void ScPreview::MouseButtonDown( const MouseEvent& rMEvt ) } } - if( rMEvt.IsLeft() && GetPointer() == PointerStyle::HSplit ) + if( !(rMEvt.IsLeft() && GetPointer() == PointerStyle::HSplit) ) + return; + + Point aNowPt = rMEvt.GetPosPixel(); + SCCOL i = 0; + for( i = aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ ) { - Point aNowPt = rMEvt.GetPosPixel(); - SCCOL i = 0; - for( i = aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ ) + if( aNowPt.X() < mvRight[i] + 2 && aNowPt.X() > mvRight[i] - 2 ) { - if( aNowPt.X() < mvRight[i] + 2 && aNowPt.X() > mvRight[i] - 2 ) - { - nColNumberButttonDown = i; - break; - } + nColNumberButttonDown = i; + break; } - if( i == aPageArea.aEnd.Col()+1 ) - return; + } + if( i == aPageArea.aEnd.Col()+1 ) + return; - SetMapMode( aMMMode ); - if( nColNumberButttonDown == aPageArea.aStart.Col() ) - DrawInvert( PixelToLogic( Point( nLeftPosition, 0 ),aMMMode ).X() ,PointerStyle::HSplit ); - else - DrawInvert( PixelToLogic( Point( mvRight[ nColNumberButttonDown-1 ], 0 ),aMMMode ).X() ,PointerStyle::HSplit ); + SetMapMode( aMMMode ); + if( nColNumberButttonDown == aPageArea.aStart.Col() ) + DrawInvert( PixelToLogic( Point( nLeftPosition, 0 ),aMMMode ).X() ,PointerStyle::HSplit ); + else + DrawInvert( PixelToLogic( Point( mvRight[ nColNumberButttonDown-1 ], 0 ),aMMMode ).X() ,PointerStyle::HSplit ); - DrawInvert( aButtonDownChangePoint.X(), PointerStyle::HSplit ); - bColRulerMove = true; - } + DrawInvert( aButtonDownChangePoint.X(), PointerStyle::HSplit ); + bColRulerMove = true; } void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) @@ -1393,91 +1393,91 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt ) bFooterRulerChange = true; } - if( bPageMargin ) + if( !bPageMargin ) + return; + + if(( (aPixPt.X() < ( aLeftTop.X() + 2 ) && aPixPt.X() > ( aLeftTop.X() - 2 )) || bLeftRulerMove || + ( aPixPt.X() < ( aRightTop.X() + 2 ) && aPixPt.X() > ( aRightTop.X() - 2 ) ) || bRightRulerMove || bOnColRulerChange || bColRulerMove ) + && aPixPt.Y() > aLeftTop.Y() && aPixPt.Y() < aLeftBottom.Y() ) { - if(( (aPixPt.X() < ( aLeftTop.X() + 2 ) && aPixPt.X() > ( aLeftTop.X() - 2 )) || bLeftRulerMove || - ( aPixPt.X() < ( aRightTop.X() + 2 ) && aPixPt.X() > ( aRightTop.X() - 2 ) ) || bRightRulerMove || bOnColRulerChange || bColRulerMove ) - && aPixPt.Y() > aLeftTop.Y() && aPixPt.Y() < aLeftBottom.Y() ) + if( bOnColRulerChange || bColRulerMove ) { - if( bOnColRulerChange || bColRulerMove ) + SetPointer( PointerStyle::HSplit ); + if( bColRulerMove ) { - SetPointer( PointerStyle::HSplit ); - if( bColRulerMove ) - { - if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() ) - DragMove( aMouseMovePoint.X(), PointerStyle::HSplit ); - } + if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() ) + DragMove( aMouseMovePoint.X(), PointerStyle::HSplit ); } - else + } + else + { + if( bLeftRulerChange && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove ) { - if( bLeftRulerChange && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove ) + SetPointer( PointerStyle::HSizeBar ); + if( bLeftRulerMove ) { - SetPointer( PointerStyle::HSizeBar ); - if( bLeftRulerMove ) - { - if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() ) - DragMove( aMouseMovePoint.X(), PointerStyle::HSizeBar ); - } + if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() ) + DragMove( aMouseMovePoint.X(), PointerStyle::HSizeBar ); } - else if( bRightRulerChange && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove ) + } + else if( bRightRulerChange && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove ) + { + SetPointer( PointerStyle::HSizeBar ); + if( bRightRulerMove ) { - SetPointer( PointerStyle::HSizeBar ); - if( bRightRulerMove ) - { - if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() ) - DragMove( aMouseMovePoint.X(), PointerStyle::HSizeBar ); - } + if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() ) + DragMove( aMouseMovePoint.X(), PointerStyle::HSizeBar ); } } } - else + } + else + { + if( ( ( aPixPt.Y() < ( aTopLeft.Y() + 2 ) && aPixPt.Y() > ( aTopLeft.Y() - 2 ) ) || bTopRulerMove || + ( aPixPt.Y() < ( aBottomLeft.Y() + 2 ) && aPixPt.Y() > ( aBottomLeft.Y() - 2 ) ) || bBottomRulerMove || + ( aPixPt.Y() < ( aHeaderLeft.Y() + 2 ) && aPixPt.Y() > ( aHeaderLeft.Y() - 2 ) ) || bHeaderRulerMove || + ( aPixPt.Y() < ( aFooderLeft.Y() + 2 ) && aPixPt.Y() > ( aFooderLeft.Y() - 2 ) ) || bFooterRulerMove ) + && aPixPt.X() > aTopLeft.X() && aPixPt.X() < aTopRight.X() ) { - if( ( ( aPixPt.Y() < ( aTopLeft.Y() + 2 ) && aPixPt.Y() > ( aTopLeft.Y() - 2 ) ) || bTopRulerMove || - ( aPixPt.Y() < ( aBottomLeft.Y() + 2 ) && aPixPt.Y() > ( aBottomLeft.Y() - 2 ) ) || bBottomRulerMove || - ( aPixPt.Y() < ( aHeaderLeft.Y() + 2 ) && aPixPt.Y() > ( aHeaderLeft.Y() - 2 ) ) || bHeaderRulerMove || - ( aPixPt.Y() < ( aFooderLeft.Y() + 2 ) && aPixPt.Y() > ( aFooderLeft.Y() - 2 ) ) || bFooterRulerMove ) - && aPixPt.X() > aTopLeft.X() && aPixPt.X() < aTopRight.X() ) + if( bTopRulerChange ) { - if( bTopRulerChange ) + SetPointer( PointerStyle::VSizeBar ); + if( bTopRulerMove ) { - SetPointer( PointerStyle::VSizeBar ); - if( bTopRulerMove ) - { - if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() ) - DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar ); - } + if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() ) + DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar ); } - else if( bBottomRulerChange ) + } + else if( bBottomRulerChange ) + { + SetPointer( PointerStyle::VSizeBar ); + if( bBottomRulerMove ) { - SetPointer( PointerStyle::VSizeBar ); - if( bBottomRulerMove ) - { - if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() ) - DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar ); - } + if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() ) + DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar ); } - else if( bHeaderRulerChange ) + } + else if( bHeaderRulerChange ) + { + SetPointer( PointerStyle::VSizeBar ); + if( bHeaderRulerMove ) { - SetPointer( PointerStyle::VSizeBar ); - if( bHeaderRulerMove ) - { - if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() ) - DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar ); - } + if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() ) + DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar ); } - else if( bFooterRulerChange ) + } + else if( bFooterRulerChange ) + { + SetPointer( PointerStyle::VSizeBar ); + if( bFooterRulerMove ) { - SetPointer( PointerStyle::VSizeBar ); - if( bFooterRulerMove ) - { - if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() ) - DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar ); - } + if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() ) + DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar ); } } - else - SetPointer( PointerStyle::Arrow ); } + else + SetPointer( PointerStyle::Arrow ); } } diff --git a/sc/source/ui/view/prevloc.cxx b/sc/source/ui/view/prevloc.cxx index e96d3bd79452..668903ed0448 100644 --- a/sc/source/ui/view/prevloc.cxx +++ b/sc/source/ui/view/prevloc.cxx @@ -116,32 +116,32 @@ void ScPreviewTableInfo::LimitToArea( const tools::Rectangle& rPixelArea ) } } - if ( pRowInfo ) - { - // cells completely above the visible area - SCROW nStart = 0; - while ( nStart < nRows && pRowInfo[nStart].nPixelEnd < rPixelArea.Top() ) - ++nStart; + if ( !pRowInfo ) + return; - // cells completely below the visible area - SCROW nEnd = nRows; - while ( nEnd > 0 && pRowInfo[nEnd-1].nPixelStart > rPixelArea.Bottom() ) - --nEnd; + // cells completely above the visible area + SCROW nStart = 0; + while ( nStart < nRows && pRowInfo[nStart].nPixelEnd < rPixelArea.Top() ) + ++nStart; - if ( nStart > 0 || nEnd < nRows ) - { - if ( nEnd > nStart ) - { - SCROW nNewCount = nEnd - nStart; - ScPreviewColRowInfo* pNewInfo = new ScPreviewColRowInfo[nNewCount]; - for (SCROW i=0; i 0 && pRowInfo[nEnd-1].nPixelStart > rPixelArea.Bottom() ) + --nEnd; + + if ( nStart <= 0 && nEnd >= nRows ) + return; + + if ( nEnd > nStart ) + { + SCROW nNewCount = nEnd - nStart; + ScPreviewColRowInfo* pNewInfo = new ScPreviewColRowInfo[nNewCount]; + for (SCROW i=0; i= SC_PREVIEW_MAXRANGES ) + return; - if (bRepCol) - { - if (bRepRow) - aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_EDGE; - else - aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPCOL; - } - else - { - if (bRepRow) - aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPROW; - else - aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_TAB; - } + aDrawRectangle[nDrawRanges] = aPixelRect; + aDrawMapMode[nDrawRanges] = rDrawMap; - ++nDrawRanges; + if (bRepCol) + { + if (bRepRow) + aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_EDGE; + else + aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPCOL; } + else + { + if (bRepRow) + aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPROW; + else + aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_TAB; + } + + ++nDrawRanges; } void ScPreviewLocationData::AddColHeaders( const tools::Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol ) diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index c5d0f14e6ca1..1ebc28bc0f1c 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -380,39 +380,39 @@ void ScPreviewShell::UpdateScrollBars() pHorScroll->SetThumbPos( aOfs.X() ); } - if( pVerScroll ) + if( !pVerScroll ) + return; + + long nPageNo = pPreview->GetPageNo(); + long nTotalPages = pPreview->GetTotalPages(); + + nMaxVertPos = aPageSize.Height() - aWindowSize.Height(); + pVerScroll->SetLineSize( aWindowSize.Height() / 16 ); + pVerScroll->SetPageSize( aWindowSize.Height() ); + pVerScroll->SetVisibleSize( aWindowSize.Height() ); + if ( nMaxVertPos < 0 ) { - long nPageNo = pPreview->GetPageNo(); - long nTotalPages = pPreview->GetTotalPages(); - - nMaxVertPos = aPageSize.Height() - aWindowSize.Height(); - pVerScroll->SetLineSize( aWindowSize.Height() / 16 ); - pVerScroll->SetPageSize( aWindowSize.Height() ); - pVerScroll->SetVisibleSize( aWindowSize.Height() ); - if ( nMaxVertPos < 0 ) - { - // page smaller than window -> center (but put scrollbar to 0) - aOfs.setY( 0 ); - pPreview->SetYOffset( nMaxVertPos / 2 ); - pVerScroll->SetThumbPos( nPageNo * aWindowSize.Height() ); - pVerScroll->SetRange( Range( 0, aWindowSize.Height() * nTotalPages )); - } - else if (aOfs.Y() < 0) - { - // page larger than window -> never use negative offset - pVerScroll->SetRange( Range( 0, aPageSize.Height() ) ); - aOfs.setY( 0 ); - pPreview->SetYOffset( 0 ); - pVerScroll->SetThumbPos( aOfs.Y() ); - } - else if (aOfs.Y() > nMaxVertPos ) - { - // limit offset to align with window bottom - pVerScroll->SetRange( Range( 0, aPageSize.Height() ) ); - aOfs.setY( nMaxVertPos ); - pPreview->SetYOffset( nMaxVertPos ); - pVerScroll->SetThumbPos( aOfs.Y() ); - } + // page smaller than window -> center (but put scrollbar to 0) + aOfs.setY( 0 ); + pPreview->SetYOffset( nMaxVertPos / 2 ); + pVerScroll->SetThumbPos( nPageNo * aWindowSize.Height() ); + pVerScroll->SetRange( Range( 0, aWindowSize.Height() * nTotalPages )); + } + else if (aOfs.Y() < 0) + { + // page larger than window -> never use negative offset + pVerScroll->SetRange( Range( 0, aPageSize.Height() ) ); + aOfs.setY( 0 ); + pPreview->SetYOffset( 0 ); + pVerScroll->SetThumbPos( aOfs.Y() ); + } + else if (aOfs.Y() > nMaxVertPos ) + { + // limit offset to align with window bottom + pVerScroll->SetRange( Range( 0, aPageSize.Height() ) ); + aOfs.setY( nMaxVertPos ); + pPreview->SetYOffset( nMaxVertPos ); + pVerScroll->SetThumbPos( aOfs.Y() ); } } diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 799f5fa3ae0c..5b368d17023d 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -362,38 +362,38 @@ bool ScPrintFunc::GetLastSourceRange( ScRange& rRange ) const void ScPrintFunc::FillPageData() { - if (pPageData) - { - sal_uInt16 nCount = sal::static_int_cast( pPageData->GetCount() ); - ScPrintRangeData& rData = pPageData->GetData(nCount); // count up + if (!pPageData) + return; - assert( bPrintAreaValid ); - rData.SetPrintRange( ScRange( nStartCol, nStartRow, nPrintTab, - nEndCol, nEndRow, nPrintTab ) ); - // #i123672# - if(m_aRanges.m_aPageEndX.empty()) - { - OSL_ENSURE(false, "vector access error for maPageEndX (!)"); - } - else - { - rData.SetPagesX( m_aRanges.m_nPagesX, m_aRanges.m_aPageEndX.data()); - } + sal_uInt16 nCount = sal::static_int_cast( pPageData->GetCount() ); + ScPrintRangeData& rData = pPageData->GetData(nCount); // count up - // #i123672# - if(m_aRanges.m_aPageEndY.empty()) - { - OSL_ENSURE(false, "vector access error for maPageEndY (!)"); - } - else - { - rData.SetPagesY( m_aRanges.m_nTotalY, m_aRanges.m_aPageEndY.data()); - } + assert( bPrintAreaValid ); + rData.SetPrintRange( ScRange( nStartCol, nStartRow, nPrintTab, + nEndCol, nEndRow, nPrintTab ) ); + // #i123672# + if(m_aRanges.m_aPageEndX.empty()) + { + OSL_ENSURE(false, "vector access error for maPageEndX (!)"); + } + else + { + rData.SetPagesX( m_aRanges.m_nPagesX, m_aRanges.m_aPageEndX.data()); + } - // Settings - rData.SetTopDown( aTableParam.bTopDown ); - rData.SetAutomatic( !aAreaParam.bPrintArea ); + // #i123672# + if(m_aRanges.m_aPageEndY.empty()) + { + OSL_ENSURE(false, "vector access error for maPageEndY (!)"); } + else + { + rData.SetPagesY( m_aRanges.m_nTotalY, m_aRanges.m_aPageEndY.data()); + } + + // Settings + rData.SetTopDown( aTableParam.bTopDown ); + rData.SetAutomatic( !aAreaParam.bPrintArea ); } ScPrintFunc::~ScPrintFunc() @@ -777,52 +777,52 @@ void ScPrintFunc::UpdateHFHeight( ScPrintHFParam& rParam ) { OSL_ENSURE( aPageSize.Width(), "UpdateHFHeight without aPageSize"); - if (rParam.bEnable && rParam.bDynamic) - { - // calculate nHeight from content + if (!(rParam.bEnable && rParam.bDynamic)) + return; - MakeEditEngine(); - long nPaperWidth = ( aPageSize.Width() - nLeftMargin - nRightMargin - - rParam.nLeft - rParam.nRight ) * 100 / nZoom; - if (rParam.pBorder) - nPaperWidth -= ( rParam.pBorder->GetDistance(SvxBoxItemLine::LEFT) + - rParam.pBorder->GetDistance(SvxBoxItemLine::RIGHT) + - lcl_LineTotal(rParam.pBorder->GetLeft()) + - lcl_LineTotal(rParam.pBorder->GetRight()) ) * 100 / nZoom; + // calculate nHeight from content - if (rParam.pShadow && rParam.pShadow->GetLocation() != SvxShadowLocation::NONE) - nPaperWidth -= ( rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::LEFT) + - rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::RIGHT) ) * 100 / nZoom; - - pEditEngine->SetPaperSize( Size( nPaperWidth, 10000 ) ); + MakeEditEngine(); + long nPaperWidth = ( aPageSize.Width() - nLeftMargin - nRightMargin - + rParam.nLeft - rParam.nRight ) * 100 / nZoom; + if (rParam.pBorder) + nPaperWidth -= ( rParam.pBorder->GetDistance(SvxBoxItemLine::LEFT) + + rParam.pBorder->GetDistance(SvxBoxItemLine::RIGHT) + + lcl_LineTotal(rParam.pBorder->GetLeft()) + + lcl_LineTotal(rParam.pBorder->GetRight()) ) * 100 / nZoom; - long nMaxHeight = 0; - if ( rParam.pLeft ) - { - nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pLeft->GetLeftArea() ) ); - nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pLeft->GetCenterArea() ) ); - nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pLeft->GetRightArea() ) ); - } - if ( rParam.pRight ) - { - nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pRight->GetLeftArea() ) ); - nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pRight->GetCenterArea() ) ); - nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pRight->GetRightArea() ) ); - } + if (rParam.pShadow && rParam.pShadow->GetLocation() != SvxShadowLocation::NONE) + nPaperWidth -= ( rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::LEFT) + + rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::RIGHT) ) * 100 / nZoom; - rParam.nHeight = nMaxHeight + rParam.nDistance; - if (rParam.pBorder) - rParam.nHeight += rParam.pBorder->GetDistance(SvxBoxItemLine::TOP) + - rParam.pBorder->GetDistance(SvxBoxItemLine::BOTTOM) + - lcl_LineTotal( rParam.pBorder->GetTop() ) + - lcl_LineTotal( rParam.pBorder->GetBottom() ); - if (rParam.pShadow && rParam.pShadow->GetLocation() != SvxShadowLocation::NONE) - rParam.nHeight += rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::TOP) + - rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::BOTTOM); + pEditEngine->SetPaperSize( Size( nPaperWidth, 10000 ) ); - if (rParam.nHeight < rParam.nManHeight) - rParam.nHeight = rParam.nManHeight; // configured minimum + long nMaxHeight = 0; + if ( rParam.pLeft ) + { + nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pLeft->GetLeftArea() ) ); + nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pLeft->GetCenterArea() ) ); + nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pLeft->GetRightArea() ) ); } + if ( rParam.pRight ) + { + nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pRight->GetLeftArea() ) ); + nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pRight->GetCenterArea() ) ); + nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pRight->GetRightArea() ) ); + } + + rParam.nHeight = nMaxHeight + rParam.nDistance; + if (rParam.pBorder) + rParam.nHeight += rParam.pBorder->GetDistance(SvxBoxItemLine::TOP) + + rParam.pBorder->GetDistance(SvxBoxItemLine::BOTTOM) + + lcl_LineTotal( rParam.pBorder->GetTop() ) + + lcl_LineTotal( rParam.pBorder->GetBottom() ); + if (rParam.pShadow && rParam.pShadow->GetLocation() != SvxShadowLocation::NONE) + rParam.nHeight += rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::TOP) + + rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::BOTTOM); + + if (rParam.nHeight < rParam.nManHeight) + rParam.nHeight = rParam.nManHeight; // configured minimum } void ScPrintFunc::InitParam( const ScPrintOptions* pOptions ) @@ -1363,27 +1363,27 @@ void ScPrintFunc::DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH, } } - if (pBorderData) - { - ScDocumentUniquePtr pBorderDoc(new ScDocument( SCDOCMODE_UNDO )); - pBorderDoc->InitUndo( pDoc, 0,0, true,true ); - pBorderDoc->ApplyAttr( 0,0,0, *pBorderData ); + if (!pBorderData) + return; - ScTableInfo aTabInfo; - pBorderDoc->FillInfo( aTabInfo, 0,0, 0,0, 0, - nScaleX, nScaleY, false, false ); - OSL_ENSURE(aTabInfo.mnArrCount,"nArrCount == 0"); + ScDocumentUniquePtr pBorderDoc(new ScDocument( SCDOCMODE_UNDO )); + pBorderDoc->InitUndo( pDoc, 0,0, true,true ); + pBorderDoc->ApplyAttr( 0,0,0, *pBorderData ); - aTabInfo.mpRowInfo[1].nHeight = static_cast(nEffHeight); - aTabInfo.mpRowInfo[0].pCellInfo[1].nWidth = - aTabInfo.mpRowInfo[1].pCellInfo[1].nWidth = static_cast(nEffWidth); + ScTableInfo aTabInfo; + pBorderDoc->FillInfo( aTabInfo, 0,0, 0,0, 0, + nScaleX, nScaleY, false, false ); + OSL_ENSURE(aTabInfo.mnArrCount,"nArrCount == 0"); - ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pBorderDoc.get(), 0, - nScrX+nLeft, nScrY+nTop, 0,0, 0,0, nScaleX, nScaleY ); - aOutputData.SetUseStyleColor( bUseStyleColor ); + aTabInfo.mpRowInfo[1].nHeight = static_cast(nEffHeight); + aTabInfo.mpRowInfo[0].pCellInfo[1].nWidth = + aTabInfo.mpRowInfo[1].pCellInfo[1].nWidth = static_cast(nEffWidth); - aOutputData.DrawFrame(*pDev); - } + ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pBorderDoc.get(), 0, + nScrX+nLeft, nScrY+nTop, 0,0, 0,0, nScaleX, nScaleY ); + aOutputData.SetUseStyleColor( bUseStyleColor ); + + aOutputData.DrawFrame(*pDev); } void ScPrintFunc::PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY ) @@ -2593,38 +2593,37 @@ void ScPrintFunc::InitModes() // set MapModes from nZoom etc. void ScPrintFunc::ApplyPrintSettings() { - if ( pPrinter ) - { - - // Configure Printer to Printing + if ( !pPrinter ) + return; - Size aEnumSize = aPageSize; + // Configure Printer to Printing - pPrinter->SetOrientation( bLandscape ? Orientation::Landscape : Orientation::Portrait ); - if ( bLandscape ) - { - // landscape is always interpreted as a rotation by 90 degrees ! - // this leads to non WYSIWIG but at least it prints! - // #i21775# - long nTemp = aEnumSize.Width(); - aEnumSize.setWidth( aEnumSize.Height() ); - aEnumSize.setHeight( nTemp ); - } - Paper ePaper = SvxPaperInfo::GetSvxPaper( aEnumSize, MapUnit::MapTwip ); - sal_uInt16 nPaperBin = pParamSet->Get(ATTR_PAGE_PAPERBIN).GetValue(); + Size aEnumSize = aPageSize; - pPrinter->SetPaper( ePaper ); - if ( PAPER_USER == ePaper ) - { - MapMode aPrinterMode = pPrinter->GetMapMode(); - MapMode aLocalMode( MapUnit::MapTwip ); - pPrinter->SetMapMode( aLocalMode ); - pPrinter->SetPaperSizeUser( aEnumSize ); - pPrinter->SetMapMode( aPrinterMode ); - } + pPrinter->SetOrientation( bLandscape ? Orientation::Landscape : Orientation::Portrait ); + if ( bLandscape ) + { + // landscape is always interpreted as a rotation by 90 degrees ! + // this leads to non WYSIWIG but at least it prints! + // #i21775# + long nTemp = aEnumSize.Width(); + aEnumSize.setWidth( aEnumSize.Height() ); + aEnumSize.setHeight( nTemp ); + } + Paper ePaper = SvxPaperInfo::GetSvxPaper( aEnumSize, MapUnit::MapTwip ); + sal_uInt16 nPaperBin = pParamSet->Get(ATTR_PAGE_PAPERBIN).GetValue(); - pPrinter->SetPaperBin( nPaperBin ); + pPrinter->SetPaper( ePaper ); + if ( PAPER_USER == ePaper ) + { + MapMode aPrinterMode = pPrinter->GetMapMode(); + MapMode aLocalMode( MapUnit::MapTwip ); + pPrinter->SetMapMode( aLocalMode ); + pPrinter->SetPaperSizeUser( aEnumSize ); + pPrinter->SetMapMode( aPrinterMode ); } + + pPrinter->SetPaperBin( nPaperBin ); } // rPageRanges = range for all tables @@ -3181,22 +3180,22 @@ void PrintPageRanges::calculate(ScDocument* pDoc, nRow = nLastRow; } - if (bVisRow) - { - OSL_ENSURE(m_nTotalY < m_aPageEndY.size(), "vector access error for maPageEndY"); - m_aPageEndY[m_nTotalY] = nEndRow; - ++m_nTotalY; + if (!bVisRow) + return; - if (!bSkipEmpty || !pDoc->IsPrintEmpty(nPrintTab, nStartCol, nPageStartRow, nEndCol, nEndRow)) - { - OSL_ENSURE(m_nPagesY < m_aPageRows.size(), "vector access error for maPageRows"); - m_aPageRows[m_nPagesY].SetStartRow(nPageStartRow); - m_aPageRows[m_nPagesY].SetEndRow(nEndRow); - m_aPageRows[m_nPagesY].SetPagesX(m_nPagesX); - if (bSkipEmpty) - lcl_SetHidden(pDoc, nPrintTab, m_aPageRows[m_nPagesY], nStartCol, m_aPageEndX); - ++m_nPagesY; - } + OSL_ENSURE(m_nTotalY < m_aPageEndY.size(), "vector access error for maPageEndY"); + m_aPageEndY[m_nTotalY] = nEndRow; + ++m_nTotalY; + + if (!bSkipEmpty || !pDoc->IsPrintEmpty(nPrintTab, nStartCol, nPageStartRow, nEndCol, nEndRow)) + { + OSL_ENSURE(m_nPagesY < m_aPageRows.size(), "vector access error for maPageRows"); + m_aPageRows[m_nPagesY].SetStartRow(nPageStartRow); + m_aPageRows[m_nPagesY].SetEndRow(nEndRow); + m_aPageRows[m_nPagesY].SetPagesX(m_nPagesX); + if (bSkipEmpty) + lcl_SetHidden(pDoc, nPrintTab, m_aPageRows[m_nPagesY], nStartCol, m_aPageEndX); + ++m_nPagesY; } } diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx index e532e07bd518..e1463ccebf53 100644 --- a/sc/source/ui/view/select.cxx +++ b/sc/source/ui/view/select.cxx @@ -159,54 +159,54 @@ void ScViewFunctionSet::BeginDrag() ScModule* pScMod = SC_MOD(); bool bRefMode = pScMod->IsFormulaMode(); - if (!bRefMode) - { - pViewData->GetView()->FakeButtonUp( GetWhich() ); // ButtonUp is swallowed + if (bRefMode) + return; - ScMarkData& rMark = pViewData->GetMarkData(); - rMark.MarkToSimple(); - if ( rMark.IsMarked() && !rMark.IsMultiMarked() ) - { - ScDocumentUniquePtr pClipDoc(new ScDocument( SCDOCMODE_CLIP )); - // bApi = TRUE -> no error messages - bool bCopied = pViewData->GetView()->CopyToClip( pClipDoc.get(), false, true ); - if ( bCopied ) - { - sal_Int8 nDragActions = pViewData->GetView()->SelectionEditable() ? - ( DND_ACTION_COPYMOVE | DND_ACTION_LINK ) : - ( DND_ACTION_COPY | DND_ACTION_LINK ); - - ScDocShell* pDocSh = pViewData->GetDocShell(); - TransferableObjectDescriptor aObjDesc; - pDocSh->FillTransferableObjectDescriptor( aObjDesc ); - aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); - // maSize is set in ScTransferObj ctor - - rtl::Reference pTransferObj = new ScTransferObj( std::move(pClipDoc), aObjDesc ); - - // set position of dragged cell within range - ScRange aMarkRange = pTransferObj->GetRange(); - SCCOL nStartX = aMarkRange.aStart.Col(); - SCROW nStartY = aMarkRange.aStart.Row(); - SCCOL nHandleX = (nPosX >= nStartX) ? nPosX - nStartX : 0; - SCROW nHandleY = (nPosY >= nStartY) ? nPosY - nStartY : 0; - pTransferObj->SetDragHandlePos( nHandleX, nHandleY ); - pTransferObj->SetSourceCursorPos( pViewData->GetCurX(), pViewData->GetCurY() ); - pTransferObj->SetVisibleTab( nTab ); - - pTransferObj->SetDragSource( pDocSh, rMark ); - - vcl::Window* pWindow = pViewData->GetActiveWin(); - if ( pWindow->IsTracking() ) - pWindow->EndTracking( TrackingEventFlags::Cancel ); // abort selecting - - SC_MOD()->SetDragObject( pTransferObj.get(), nullptr ); // for internal D&D - pTransferObj->StartDrag( pWindow, nDragActions ); - - return; // dragging started - } - } - } + pViewData->GetView()->FakeButtonUp( GetWhich() ); // ButtonUp is swallowed + + ScMarkData& rMark = pViewData->GetMarkData(); + rMark.MarkToSimple(); + if ( !(rMark.IsMarked() && !rMark.IsMultiMarked()) ) + return; + + ScDocumentUniquePtr pClipDoc(new ScDocument( SCDOCMODE_CLIP )); + // bApi = TRUE -> no error messages + bool bCopied = pViewData->GetView()->CopyToClip( pClipDoc.get(), false, true ); + if ( !bCopied ) + return; + + sal_Int8 nDragActions = pViewData->GetView()->SelectionEditable() ? + ( DND_ACTION_COPYMOVE | DND_ACTION_LINK ) : + ( DND_ACTION_COPY | DND_ACTION_LINK ); + + ScDocShell* pDocSh = pViewData->GetDocShell(); + TransferableObjectDescriptor aObjDesc; + pDocSh->FillTransferableObjectDescriptor( aObjDesc ); + aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); + // maSize is set in ScTransferObj ctor + + rtl::Reference pTransferObj = new ScTransferObj( std::move(pClipDoc), aObjDesc ); + + // set position of dragged cell within range + ScRange aMarkRange = pTransferObj->GetRange(); + SCCOL nStartX = aMarkRange.aStart.Col(); + SCROW nStartY = aMarkRange.aStart.Row(); + SCCOL nHandleX = (nPosX >= nStartX) ? nPosX - nStartX : 0; + SCROW nHandleY = (nPosY >= nStartY) ? nPosY - nStartY : 0; + pTransferObj->SetDragHandlePos( nHandleX, nHandleY ); + pTransferObj->SetSourceCursorPos( pViewData->GetCurX(), pViewData->GetCurY() ); + pTransferObj->SetVisibleTab( nTab ); + + pTransferObj->SetDragSource( pDocSh, rMark ); + + vcl::Window* pWindow = pViewData->GetActiveWin(); + if ( pWindow->IsTracking() ) + pWindow->EndTracking( TrackingEventFlags::Cancel ); // abort selecting + + SC_MOD()->SetDragObject( pTransferObj.get(), nullptr ); // for internal D&D + pTransferObj->StartDrag( pWindow, nDragActions ); + + return; // dragging started } diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx index 61e570bd2bbc..7e42a16d1a13 100644 --- a/sc/source/ui/view/tabcont.cxx +++ b/sc/source/ui/view/tabcont.cxx @@ -408,28 +408,28 @@ void ScTabControl::SetSheetLayoutRTL( bool bSheetRTL ) void ScTabControl::SwitchToPageId(sal_uInt16 nId) { - if (nId) - { - bool bAlreadySelected = IsPageSelected( nId ); - //make the clicked page the current one - SetCurPageId( nId ); - //change the selection when the current one is not already - //selected or part of a multi selection - if(!bAlreadySelected) - { - sal_uInt16 nCount = GetMaxId(); + if (!nId) + return; + + bool bAlreadySelected = IsPageSelected( nId ); + //make the clicked page the current one + SetCurPageId( nId ); + //change the selection when the current one is not already + //selected or part of a multi selection + if(bAlreadySelected) + return; - for (sal_uInt16 i=1; i<=nCount; i++) - SelectPage( i, i==nId ); - Select(); + sal_uInt16 nCount = GetMaxId(); - if (comphelper::LibreOfficeKit::isActive()) - { - // notify LibreOfficeKit about changed page - OString aPayload = OString::number(nId - 1); - pViewData->GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, aPayload.getStr()); - } - } + for (sal_uInt16 i=1; i<=nCount; i++) + SelectPage( i, i==nId ); + Select(); + + if (comphelper::LibreOfficeKit::isActive()) + { + // notify LibreOfficeKit about changed page + OString aPayload = OString::number(nId - 1); + pViewData->GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, aPayload.getStr()); } } @@ -442,21 +442,21 @@ void ScTabControl::Command( const CommandEvent& rCEvt ) // first activate ViewFrame (Bug 19493): pViewSh->SetActive(); - if ( rCEvt.GetCommand() == CommandEventId::ContextMenu && !bDisable) - { - // #i18735# select the page that is under the mouse cursor - // if multiple tables are selected and the one under the cursor - // is not part of them then unselect them - sal_uInt16 nId = GetPageId( rCEvt.GetMousePosPixel() ); - SwitchToPageId(nId); - - // #i52073# OLE inplace editing has to be stopped before showing the sheet tab context menu - pViewSh->DeactivateOle(); - - // Popup-Menu: - // get Dispatcher from ViewData (ViewFrame) instead of Shell (Frame), so it can't be null - pViewData->GetDispatcher().ExecutePopup( "sheettab" ); - } + if (rCEvt.GetCommand() != CommandEventId::ContextMenu || bDisable) + return; + + // #i18735# select the page that is under the mouse cursor + // if multiple tables are selected and the one under the cursor + // is not part of them then unselect them + sal_uInt16 nId = GetPageId( rCEvt.GetMousePosPixel() ); + SwitchToPageId(nId); + + // #i52073# OLE inplace editing has to be stopped before showing the sheet tab context menu + pViewSh->DeactivateOle(); + + // Popup-Menu: + // get Dispatcher from ViewData (ViewFrame) instead of Shell (Frame), so it can't be null + pViewData->GetDispatcher().ExecutePopup( "sheettab" ); } void ScTabControl::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel ) diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 5e334cb79522..c177248846e6 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -730,26 +730,26 @@ void ScTabView::UpdateVarZoom() // update variable zoom types SvxZoomType eZoomType = GetZoomType(); - if ( eZoomType != SvxZoomType::PERCENT && !bInZoomUpdate ) - { - bInZoomUpdate = true; - const Fraction& rOldX = GetViewData().GetZoomX(); - const Fraction& rOldY = GetViewData().GetZoomY(); - long nOldPercent = long(rOldY * 100); - sal_uInt16 nNewZoom = CalcZoom( eZoomType, static_cast(nOldPercent) ); - Fraction aNew( nNewZoom, 100 ); + if (eZoomType == SvxZoomType::PERCENT || bInZoomUpdate) + return; - if ( aNew != rOldX || aNew != rOldY ) - { - SetZoom( aNew, aNew, false ); // always separately per sheet - PaintGrid(); - PaintTop(); - PaintLeft(); - aViewData.GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM ); - aViewData.GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); - } - bInZoomUpdate = false; + bInZoomUpdate = true; + const Fraction& rOldX = GetViewData().GetZoomX(); + const Fraction& rOldY = GetViewData().GetZoomY(); + long nOldPercent = long(rOldY * 100); + sal_uInt16 nNewZoom = CalcZoom( eZoomType, static_cast(nOldPercent) ); + Fraction aNew( nNewZoom, 100 ); + + if ( aNew != rOldX || aNew != rOldY ) + { + SetZoom( aNew, aNew, false ); // always separately per sheet + PaintGrid(); + PaintTop(); + PaintLeft(); + aViewData.GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM ); + aViewData.GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); } + bInZoomUpdate = false; } void ScTabView::UpdateFixPos() @@ -824,26 +824,26 @@ void ScTabView::GetBorderSize( SvBorder& rBorder, const Size& /* rSize */ ) IMPL_LINK_NOARG(ScTabView, TabBarResize, TabBar*, void) { - if (aViewData.IsHScrollMode()) - { - const long nOverlap = 0; // ScrollBar::GetWindowOverlapPixel(); - long nSize = pTabControl->GetSplitSize(); + if (!aViewData.IsHScrollMode()) + return; - if (aViewData.GetHSplitMode() != SC_SPLIT_FIX) - { - long nMax = pHSplitter->GetPosPixel().X(); - if( pTabControl->IsEffectiveRTL() ) - nMax = pFrameWin->GetSizePixel().Width() - nMax; - --nMax; - if (nSize>nMax) nSize = nMax; - } + const long nOverlap = 0; // ScrollBar::GetWindowOverlapPixel(); + long nSize = pTabControl->GetSplitSize(); - if ( nSize != pTabControl->GetSizePixel().Width() ) - { - pTabControl->SetSizePixel( Size( nSize+nOverlap, - pTabControl->GetSizePixel().Height() ) ); - RepeatResize(); - } + if (aViewData.GetHSplitMode() != SC_SPLIT_FIX) + { + long nMax = pHSplitter->GetPosPixel().X(); + if( pTabControl->IsEffectiveRTL() ) + nMax = pFrameWin->GetSizePixel().Width() - nMax; + --nMax; + if (nSize>nMax) nSize = nMax; + } + + if ( nSize != pTabControl->GetSizePixel().Width() ) + { + pTabControl->SetSizePixel( Size( nSize+nOverlap, + pTabControl->GetSizePixel().Height() ) ); + RepeatResize(); } } @@ -1384,21 +1384,21 @@ void ScTabView::UpdateHeaderWidth( const ScVSplitPos* pWhich, const SCROW* pPosY nEndPos = 1; long nWidth = nBig - ( 10000 - nEndPos ) * nDiff / 10000; - if ( nWidth != pRowBar[SC_SPLIT_BOTTOM]->GetWidth() && !bInUpdateHeader ) - { - bInUpdateHeader = true; + if (nWidth == pRowBar[SC_SPLIT_BOTTOM]->GetWidth() || bInUpdateHeader) + return; - pRowBar[SC_SPLIT_BOTTOM]->SetWidth( nWidth ); - if (pRowBar[SC_SPLIT_TOP]) - pRowBar[SC_SPLIT_TOP]->SetWidth( nWidth ); + bInUpdateHeader = true; - RepeatResize(); + pRowBar[SC_SPLIT_BOTTOM]->SetWidth( nWidth ); + if (pRowBar[SC_SPLIT_TOP]) + pRowBar[SC_SPLIT_TOP]->SetWidth( nWidth ); + + RepeatResize(); - // on VCL there are endless updates (each Update is valid for all windows) - //aCornerButton->Update(); // otherwise this never gets an Update + // on VCL there are endless updates (each Update is valid for all windows) + //aCornerButton->Update(); // otherwise this never gets an Update - bInUpdateHeader = false; - } + bInUpdateHeader = false; } static void ShowHide( vcl::Window* pWin, bool bShow ) @@ -1547,48 +1547,48 @@ void ScTabView::DoHSplit(long nSplitPos) aViewData.SetHSplitMode( aNewMode ); - if ( aNewMode != aOldMode ) - { - UpdateShow(); // before ActivatePart !! + if ( aNewMode == aOldMode ) + return; - if ( aNewMode == SC_SPLIT_NONE ) - { - if (aViewData.GetActivePart() == SC_SPLIT_TOPRIGHT) - ActivatePart( SC_SPLIT_TOPLEFT ); - if (aViewData.GetActivePart() == SC_SPLIT_BOTTOMRIGHT) - ActivatePart( SC_SPLIT_BOTTOMLEFT ); - } + UpdateShow(); // before ActivatePart !! + + if ( aNewMode == SC_SPLIT_NONE ) + { + if (aViewData.GetActivePart() == SC_SPLIT_TOPRIGHT) + ActivatePart( SC_SPLIT_TOPLEFT ); + if (aViewData.GetActivePart() == SC_SPLIT_BOTTOMRIGHT) + ActivatePart( SC_SPLIT_BOTTOMLEFT ); + } + else + { + nOldDelta = aViewData.GetPosX( SC_SPLIT_LEFT ); + long nLeftWidth = nSplitPos - pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width(); + if ( nLeftWidth < 0 ) nLeftWidth = 0; + nNewDelta = nOldDelta + aViewData.CellsAtX( nOldDelta, 1, SC_SPLIT_LEFT, + static_cast(nLeftWidth) ); + ScDocument* pDoc = aViewData.GetDocument(); + if ( nNewDelta > pDoc->MaxCol() ) + nNewDelta = pDoc->MaxCol(); + aViewData.SetPosX( SC_SPLIT_RIGHT, nNewDelta ); + if ( nNewDelta > aViewData.GetCurX() ) + ActivatePart( (WhichV(aViewData.GetActivePart()) == SC_SPLIT_BOTTOM) ? + SC_SPLIT_BOTTOMLEFT : SC_SPLIT_TOPLEFT ); else - { - nOldDelta = aViewData.GetPosX( SC_SPLIT_LEFT ); - long nLeftWidth = nSplitPos - pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width(); - if ( nLeftWidth < 0 ) nLeftWidth = 0; - nNewDelta = nOldDelta + aViewData.CellsAtX( nOldDelta, 1, SC_SPLIT_LEFT, - static_cast(nLeftWidth) ); - ScDocument* pDoc = aViewData.GetDocument(); - if ( nNewDelta > pDoc->MaxCol() ) - nNewDelta = pDoc->MaxCol(); - aViewData.SetPosX( SC_SPLIT_RIGHT, nNewDelta ); - if ( nNewDelta > aViewData.GetCurX() ) - ActivatePart( (WhichV(aViewData.GetActivePart()) == SC_SPLIT_BOTTOM) ? - SC_SPLIT_BOTTOMLEFT : SC_SPLIT_TOPLEFT ); - else - ActivatePart( (WhichV(aViewData.GetActivePart()) == SC_SPLIT_BOTTOM) ? - SC_SPLIT_BOTTOMRIGHT : SC_SPLIT_TOPRIGHT ); - } + ActivatePart( (WhichV(aViewData.GetActivePart()) == SC_SPLIT_BOTTOM) ? + SC_SPLIT_BOTTOMRIGHT : SC_SPLIT_TOPRIGHT ); + } - // Form Layer needs to know the visible part of all windows - // that is why MapMode must already be correct here - for (VclPtr & pWin : pGridWin) - if (pWin) - pWin->SetMapMode( pWin->GetDrawMapMode() ); - SetNewVisArea(); + // Form Layer needs to know the visible part of all windows + // that is why MapMode must already be correct here + for (VclPtr & pWin : pGridWin) + if (pWin) + pWin->SetMapMode( pWin->GetDrawMapMode() ); + SetNewVisArea(); - PaintGrid(); - PaintTop(); + PaintGrid(); + PaintTop(); - InvalidateSplit(); - } + InvalidateSplit(); } void ScTabView::DoVSplit(long nSplitPos) @@ -1612,56 +1612,56 @@ void ScTabView::DoVSplit(long nSplitPos) aViewData.SetVSplitMode( aNewMode ); - if ( aNewMode != aOldMode ) + if ( aNewMode == aOldMode ) + return; + + UpdateShow(); // before ActivatePart !! + + if ( aNewMode == SC_SPLIT_NONE ) { - UpdateShow(); // before ActivatePart !! + nOldDelta = aViewData.GetPosY( SC_SPLIT_TOP ); + aViewData.SetPosY( SC_SPLIT_BOTTOM, nOldDelta ); - if ( aNewMode == SC_SPLIT_NONE ) - { + if (aViewData.GetActivePart() == SC_SPLIT_TOPLEFT) + ActivatePart( SC_SPLIT_BOTTOMLEFT ); + if (aViewData.GetActivePart() == SC_SPLIT_TOPRIGHT) + ActivatePart( SC_SPLIT_BOTTOMRIGHT ); + } + else + { + if ( aOldMode == SC_SPLIT_NONE ) + nOldDelta = aViewData.GetPosY( SC_SPLIT_BOTTOM ); + else nOldDelta = aViewData.GetPosY( SC_SPLIT_TOP ); - aViewData.SetPosY( SC_SPLIT_BOTTOM, nOldDelta ); - if (aViewData.GetActivePart() == SC_SPLIT_TOPLEFT) - ActivatePart( SC_SPLIT_BOTTOMLEFT ); - if (aViewData.GetActivePart() == SC_SPLIT_TOPRIGHT) - ActivatePart( SC_SPLIT_BOTTOMRIGHT ); - } + aViewData.SetPosY( SC_SPLIT_TOP, nOldDelta ); + long nTopHeight = nSplitPos - pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height(); + if ( nTopHeight < 0 ) nTopHeight = 0; + nNewDelta = nOldDelta + aViewData.CellsAtY( nOldDelta, 1, SC_SPLIT_TOP, + static_cast(nTopHeight) ); + ScDocument* pDoc = aViewData.GetDocument(); + if ( nNewDelta > pDoc->MaxRow() ) + nNewDelta = pDoc->MaxRow(); + aViewData.SetPosY( SC_SPLIT_BOTTOM, nNewDelta ); + if ( nNewDelta > aViewData.GetCurY() ) + ActivatePart( (WhichH(aViewData.GetActivePart()) == SC_SPLIT_LEFT) ? + SC_SPLIT_TOPLEFT : SC_SPLIT_TOPRIGHT ); else - { - if ( aOldMode == SC_SPLIT_NONE ) - nOldDelta = aViewData.GetPosY( SC_SPLIT_BOTTOM ); - else - nOldDelta = aViewData.GetPosY( SC_SPLIT_TOP ); - - aViewData.SetPosY( SC_SPLIT_TOP, nOldDelta ); - long nTopHeight = nSplitPos - pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height(); - if ( nTopHeight < 0 ) nTopHeight = 0; - nNewDelta = nOldDelta + aViewData.CellsAtY( nOldDelta, 1, SC_SPLIT_TOP, - static_cast(nTopHeight) ); - ScDocument* pDoc = aViewData.GetDocument(); - if ( nNewDelta > pDoc->MaxRow() ) - nNewDelta = pDoc->MaxRow(); - aViewData.SetPosY( SC_SPLIT_BOTTOM, nNewDelta ); - if ( nNewDelta > aViewData.GetCurY() ) - ActivatePart( (WhichH(aViewData.GetActivePart()) == SC_SPLIT_LEFT) ? - SC_SPLIT_TOPLEFT : SC_SPLIT_TOPRIGHT ); - else - ActivatePart( (WhichH(aViewData.GetActivePart()) == SC_SPLIT_LEFT) ? - SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT ); - } + ActivatePart( (WhichH(aViewData.GetActivePart()) == SC_SPLIT_LEFT) ? + SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT ); + } - // Form Layer needs to know the visible part of all windows - // that is why MapMode must already be correct here - for (VclPtr & pWin : pGridWin) - if (pWin) - pWin->SetMapMode( pWin->GetDrawMapMode() ); - SetNewVisArea(); + // Form Layer needs to know the visible part of all windows + // that is why MapMode must already be correct here + for (VclPtr & pWin : pGridWin) + if (pWin) + pWin->SetMapMode( pWin->GetDrawMapMode() ); + SetNewVisArea(); - PaintGrid(); - PaintLeft(); + PaintGrid(); + PaintLeft(); - InvalidateSplit(); - } + InvalidateSplit(); } Point ScTabView::GetInsertPos() const diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index 16d626dc397d..99eb33fa9670 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -273,27 +273,27 @@ void moveCursorByMergedCell( --rRow; } } - if (nMovY < 0) + if (nMovY >= 0) + return; + + SCROW nOld = rRow; + if (bOriginMerged) { - SCROW nOld = rRow; - if (bOriginMerged) - { - if (nOrigY > 0 && nOrigY <= rRow && rRow < nOrigY + nRowSpan - 1) - // Block end is still within the merged region. Push it outside. - rRow = nOrigY - 1; - } - else - { - pDoc->SkipOverlapped(rCol, rRow, nTab); - } + if (nOrigY > 0 && nOrigY <= rRow && rRow < nOrigY + nRowSpan - 1) + // Block end is still within the merged region. Push it outside. + rRow = nOrigY - 1; + } + else + { + pDoc->SkipOverlapped(rCol, rRow, nTab); + } - if (nOld > rRow) - { - // The block end has moved. Check the protection setting and move back if needed. - checkBoundary(pDoc, rCol, rRow); - if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked)) - ++rRow; - } + if (nOld > rRow) + { + // The block end has moved. Check the protection setting and move back if needed. + checkBoundary(pDoc, rCol, rRow); + if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked)) + ++rRow; } } @@ -330,79 +330,79 @@ bool ScTabView::IsMarking( SCCOL nCol, SCROW nRow, SCTAB nTab ) const void ScTabView::InitOwnBlockMode() { - if (!IsBlockMode()) - { - // when there is no (old) selection anymore, delete anchor in SelectionEngine: - ScMarkData& rMark = aViewData.GetMarkData(); - if (!rMark.IsMarked() && !rMark.IsMultiMarked()) - GetSelEngine()->CursorPosChanging( false, false ); - - meBlockMode = Own; - nBlockStartX = 0; - nBlockStartY = 0; - nBlockStartZ = 0; - nBlockEndX = 0; - nBlockEndY = 0; - nBlockEndZ = 0; - - SelectionChanged(); // status is checked with mark set - } + if (IsBlockMode()) + return; + + // when there is no (old) selection anymore, delete anchor in SelectionEngine: + ScMarkData& rMark = aViewData.GetMarkData(); + if (!rMark.IsMarked() && !rMark.IsMultiMarked()) + GetSelEngine()->CursorPosChanging( false, false ); + + meBlockMode = Own; + nBlockStartX = 0; + nBlockStartY = 0; + nBlockStartZ = 0; + nBlockEndX = 0; + nBlockEndY = 0; + nBlockEndZ = 0; + + SelectionChanged(); // status is checked with mark set } void ScTabView::InitBlockMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, bool bTestNeg, bool bCols, bool bRows, bool bForceNeg ) { - if (!IsBlockMode()) - { - auto pDoc = aViewData.GetDocument(); - if (!pDoc->ValidCol(nCurX)) nCurX = pDoc->MaxCol(); - if (!pDoc->ValidRow(nCurY)) nCurY = pDoc->MaxRow(); + if (IsBlockMode()) + return; - ScMarkData& rMark = aViewData.GetMarkData(); - SCTAB nTab = aViewData.GetTabNo(); + auto pDoc = aViewData.GetDocument(); + if (!pDoc->ValidCol(nCurX)) nCurX = pDoc->MaxCol(); + if (!pDoc->ValidRow(nCurY)) nCurY = pDoc->MaxRow(); - // unmark part? - if (bForceNeg) - bBlockNeg = true; - else if (bTestNeg) - { - if ( bCols ) - bBlockNeg = rMark.IsColumnMarked( nCurX ); - else if ( bRows ) - bBlockNeg = rMark.IsRowMarked( nCurY ); - else - bBlockNeg = rMark.IsCellMarked( nCurX, nCurY ); - } + ScMarkData& rMark = aViewData.GetMarkData(); + SCTAB nTab = aViewData.GetTabNo(); + + // unmark part? + if (bForceNeg) + bBlockNeg = true; + else if (bTestNeg) + { + if ( bCols ) + bBlockNeg = rMark.IsColumnMarked( nCurX ); + else if ( bRows ) + bBlockNeg = rMark.IsRowMarked( nCurY ); else - bBlockNeg = false; - rMark.SetMarkNegative(bBlockNeg); - - meBlockMode = Normal; - bBlockCols = bCols; - bBlockRows = bRows; - nBlockStartX = nBlockStartXOrig = nCurX; - nBlockStartY = nBlockStartYOrig = nCurY; - nBlockStartZ = nCurZ; - nBlockEndX = nOldCurX = nBlockStartX; - nBlockEndY = nOldCurY = nBlockStartY; - nBlockEndZ = nBlockStartZ; - - if (bBlockCols) - { - nBlockStartY = nBlockStartYOrig = 0; - nBlockEndY = pDoc->MaxRow(); - } + bBlockNeg = rMark.IsCellMarked( nCurX, nCurY ); + } + else + bBlockNeg = false; + rMark.SetMarkNegative(bBlockNeg); + + meBlockMode = Normal; + bBlockCols = bCols; + bBlockRows = bRows; + nBlockStartX = nBlockStartXOrig = nCurX; + nBlockStartY = nBlockStartYOrig = nCurY; + nBlockStartZ = nCurZ; + nBlockEndX = nOldCurX = nBlockStartX; + nBlockEndY = nOldCurY = nBlockStartY; + nBlockEndZ = nBlockStartZ; + + if (bBlockCols) + { + nBlockStartY = nBlockStartYOrig = 0; + nBlockEndY = pDoc->MaxRow(); + } - if (bBlockRows) - { - nBlockStartX = nBlockStartXOrig = 0; - nBlockEndX = pDoc->MaxCol(); - } + if (bBlockRows) + { + nBlockStartX = nBlockStartXOrig = 0; + nBlockEndX = pDoc->MaxCol(); + } - rMark.SetMarkArea( ScRange( nBlockStartX,nBlockStartY, nTab, nBlockEndX,nBlockEndY, nTab ) ); + rMark.SetMarkArea( ScRange( nBlockStartX,nBlockStartY, nTab, nBlockEndX,nBlockEndY, nTab ) ); - UpdateSelectionOverlay(); - } + UpdateSelectionOverlay(); } void ScTabView::DoneBlockMode( bool bContinue ) @@ -411,33 +411,33 @@ void ScTabView::DoneBlockMode( bool bContinue ) // because the other engine does not have any anchor. // bMoveIsShift prevents the selection to be canceled. - if (IsBlockMode() && !bMoveIsShift) - { - ScMarkData& rMark = aViewData.GetMarkData(); - bool bFlag = rMark.GetMarkingFlag(); - rMark.SetMarking(false); + if (!(IsBlockMode() && !bMoveIsShift)) + return; - if (bBlockNeg && !bContinue) - rMark.MarkToMulti(); + ScMarkData& rMark = aViewData.GetMarkData(); + bool bFlag = rMark.GetMarkingFlag(); + rMark.SetMarking(false); - if (bContinue) - rMark.MarkToMulti(); - else - { - // the sheet may be invalid at this point because DoneBlockMode from SetTabNo is - // called (for example, when the current sheet is closed from another View) - SCTAB nTab = aViewData.GetTabNo(); - ScDocument* pDoc = aViewData.GetDocument(); - if ( pDoc->HasTable(nTab) ) - PaintBlock( true ); // true -> delete block - else - rMark.ResetMark(); - } - meBlockMode = None; + if (bBlockNeg && !bContinue) + rMark.MarkToMulti(); - rMark.SetMarking(bFlag); - rMark.SetMarkNegative(false); + if (bContinue) + rMark.MarkToMulti(); + else + { + // the sheet may be invalid at this point because DoneBlockMode from SetTabNo is + // called (for example, when the current sheet is closed from another View) + SCTAB nTab = aViewData.GetTabNo(); + ScDocument* pDoc = aViewData.GetDocument(); + if ( pDoc->HasTable(nTab) ) + PaintBlock( true ); // true -> delete block + else + rMark.ResetMark(); } + meBlockMode = None; + + rMark.SetMarking(bFlag); + rMark.SetMarkNegative(false); } bool ScTabView::IsBlockMode() const @@ -1012,52 +1012,52 @@ void ScTabView::PaintBlock( bool bReset ) ScMarkData& rMark = aViewData.GetMarkData(); SCTAB nTab = aViewData.GetTabNo(); bool bMulti = rMark.IsMultiMarked(); - if (rMark.IsMarked() || bMulti) + if (!(rMark.IsMarked() || bMulti)) + return; + + ScRange aMarkRange; + HideAllCursors(); + if (bMulti) { - ScRange aMarkRange; - HideAllCursors(); - if (bMulti) - { - bool bFlag = rMark.GetMarkingFlag(); - rMark.SetMarking(false); - rMark.MarkToMulti(); - rMark.GetMultiMarkArea(aMarkRange); - rMark.MarkToSimple(); - rMark.SetMarking(bFlag); - } - else - rMark.GetMarkArea(aMarkRange); + bool bFlag = rMark.GetMarkingFlag(); + rMark.SetMarking(false); + rMark.MarkToMulti(); + rMark.GetMultiMarkArea(aMarkRange); + rMark.MarkToSimple(); + rMark.SetMarking(bFlag); + } + else + rMark.GetMarkArea(aMarkRange); - nBlockStartX = aMarkRange.aStart.Col(); - nBlockStartY = aMarkRange.aStart.Row(); - nBlockStartZ = aMarkRange.aStart.Tab(); - nBlockEndX = aMarkRange.aEnd.Col(); - nBlockEndY = aMarkRange.aEnd.Row(); - nBlockEndZ = aMarkRange.aEnd.Tab(); + nBlockStartX = aMarkRange.aStart.Col(); + nBlockStartY = aMarkRange.aStart.Row(); + nBlockStartZ = aMarkRange.aStart.Tab(); + nBlockEndX = aMarkRange.aEnd.Col(); + nBlockEndY = aMarkRange.aEnd.Row(); + nBlockEndZ = aMarkRange.aEnd.Tab(); - bool bDidReset = false; + bool bDidReset = false; - if ( nTab>=nBlockStartZ && nTab<=nBlockEndZ ) + if ( nTab>=nBlockStartZ && nTab<=nBlockEndZ ) + { + if ( bReset ) { - if ( bReset ) + // Inverting when deleting only on active View + if ( aViewData.IsActive() ) { - // Inverting when deleting only on active View - if ( aViewData.IsActive() ) - { - rMark.ResetMark(); - UpdateSelectionOverlay(); - bDidReset = true; - } + rMark.ResetMark(); + UpdateSelectionOverlay(); + bDidReset = true; } - else - PaintMarks( nBlockStartX, nBlockStartY, nBlockEndX, nBlockEndY ); } + else + PaintMarks( nBlockStartX, nBlockStartY, nBlockEndX, nBlockEndY ); + } - if ( bReset && !bDidReset ) - rMark.ResetMark(); + if ( bReset && !bDidReset ) + rMark.ResetMark(); - ShowAllCursors(); - } + ShowAllCursors(); } void ScTabView::SelectAll( bool bContinue ) @@ -1392,19 +1392,19 @@ void ScTabView::HideNoteMarker() void ScTabView::MakeDrawLayer() { - if (!pDrawView) - { - aViewData.GetDocShell()->MakeDrawLayer(); + if (pDrawView) + return; + + aViewData.GetDocShell()->MakeDrawLayer(); - // pDrawView is set per Notify - OSL_ENSURE(pDrawView,"ScTabView::MakeDrawLayer does not work"); + // pDrawView is set per Notify + OSL_ENSURE(pDrawView,"ScTabView::MakeDrawLayer does not work"); - for(VclPtr & pWin : pGridWin) + for(VclPtr & pWin : pGridWin) + { + if(pWin) { - if(pWin) - { - pWin->DrawLayerCreated(); - } + pWin->DrawLayerCreated(); } } } diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index cfff46935dad..8fcda5a25f0f 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -114,19 +114,19 @@ template void ScExtraEditViewManager::Apply(SfxViewShell* pViewShell, ScSplitPos eWhich) { ScTabViewShell* pOtherViewShell = dynamic_cast(pViewShell); - if (pOtherViewShell != nullptr && pOtherViewShell != mpThisViewShell) + if (pOtherViewShell == nullptr || pOtherViewShell == mpThisViewShell) + return; + + mpOtherEditView = pOtherViewShell->GetViewData().GetEditView(eWhich); + if (mpOtherEditView != nullptr) { - mpOtherEditView = pOtherViewShell->GetViewData().GetEditView(eWhich); - if (mpOtherEditView != nullptr) + DBG_ASSERT(mpOtherEditView->GetEditEngine(), "Edit view has no valid engine."); + for (int i = 0; i < 4; ++i) { - DBG_ASSERT(mpOtherEditView->GetEditEngine(), "Edit view has no valid engine."); - for (int i = 0; i < 4; ++i) + ScGridWindow* pWin = mpGridWin[i].get(); + if (pWin != nullptr) { - ScGridWindow* pWin = mpGridWin[i].get(); - if (pWin != nullptr) - { - Modifier(pWin); - } + Modifier(pWin); } } } @@ -368,80 +368,80 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew ) if (comphelper::LibreOfficeKit::isActive()) nPosY = std::min(nPosY, MAXTILEDROW); - if ( nPosX != nOldX || nPosY != nOldY || bNew ) + if ( !(nPosX != nOldX || nPosY != nOldY || bNew) ) + return; + + ScTabViewShell* pViewShell = aViewData.GetViewShell(); + bool bRefMode = pViewShell && pViewShell->IsRefInputMode(); + if ( aViewData.HasEditView( aViewData.GetActivePart() ) && !bRefMode ) // 23259 or so { - ScTabViewShell* pViewShell = aViewData.GetViewShell(); - bool bRefMode = pViewShell && pViewShell->IsRefInputMode(); - if ( aViewData.HasEditView( aViewData.GetActivePart() ) && !bRefMode ) // 23259 or so - { - UpdateInputLine(); - } + UpdateInputLine(); + } - HideAllCursors(); + HideAllCursors(); - aViewData.SetCurX( nPosX ); - aViewData.SetCurY( nPosY ); + aViewData.SetCurX( nPosX ); + aViewData.SetCurY( nPosY ); - ShowAllCursors(); + ShowAllCursors(); - CursorPosChanged(); + CursorPosChanged(); - OUString aCurrAddress = ScAddress(nPosX,nPosY,0).GetColRowString(); - collectUIInformation({{"CELL", aCurrAddress}}); + OUString aCurrAddress = ScAddress(nPosX,nPosY,0).GetColRowString(); + collectUIInformation({{"CELL", aCurrAddress}}); - if (comphelper::LibreOfficeKit::isActive()) - { - if (nPosX > aViewData.GetMaxTiledCol() - 10 || nPosY > aViewData.GetMaxTiledRow() - 25) - { - ScDocument* pDoc = aViewData.GetDocument(); - ScDocShell* pDocSh = aViewData.GetDocShell(); - ScModelObj* pModelObj = pDocSh ? comphelper::getUnoTunnelImplementation( pDocSh->GetModel() ) : nullptr; - Size aOldSize(0, 0); - if (pModelObj) - aOldSize = pModelObj->getDocumentSize(); + if (!comphelper::LibreOfficeKit::isActive()) + return; - if (nPosX > aViewData.GetMaxTiledCol() - 10) - aViewData.SetMaxTiledCol(std::min(std::max(nPosX, aViewData.GetMaxTiledCol()) + 10, pDoc->MaxCol())); + if (nPosX <= aViewData.GetMaxTiledCol() - 10 && nPosY <= aViewData.GetMaxTiledRow() - 25) + return; - if (nPosY > aViewData.GetMaxTiledRow() - 25) - aViewData.SetMaxTiledRow(std::min(std::max(nPosY, aViewData.GetMaxTiledRow()) + 25, MAXTILEDROW)); + ScDocument* pDoc = aViewData.GetDocument(); + ScDocShell* pDocSh = aViewData.GetDocShell(); + ScModelObj* pModelObj = pDocSh ? comphelper::getUnoTunnelImplementation( pDocSh->GetModel() ) : nullptr; + Size aOldSize(0, 0); + if (pModelObj) + aOldSize = pModelObj->getDocumentSize(); - Size aNewSize(0, 0); - if (pModelObj) - aNewSize = pModelObj->getDocumentSize(); + if (nPosX > aViewData.GetMaxTiledCol() - 10) + aViewData.SetMaxTiledCol(std::min(std::max(nPosX, aViewData.GetMaxTiledCol()) + 10, pDoc->MaxCol())); - if (pDocSh) - { - // New area extended to the right of the sheet after last column - // including overlapping area with aNewRowArea - tools::Rectangle aNewColArea(aOldSize.getWidth(), 0, aNewSize.getWidth(), aNewSize.getHeight()); - // New area extended to the bottom of the sheet after last row - // excluding overlapping area with aNewColArea - tools::Rectangle aNewRowArea(0, aOldSize.getHeight(), aOldSize.getWidth(), aNewSize.getHeight()); - - // Only invalidate if spreadsheet extended to the right - if (aNewColArea.getWidth()) - { - SfxLokHelper::notifyInvalidation(aViewData.GetViewShell(), aNewColArea.toString()); - } + if (nPosY > aViewData.GetMaxTiledRow() - 25) + aViewData.SetMaxTiledRow(std::min(std::max(nPosY, aViewData.GetMaxTiledRow()) + 25, MAXTILEDROW)); - // Only invalidate if spreadsheet extended to the bottom - if (aNewRowArea.getHeight()) - { - SfxLokHelper::notifyInvalidation(aViewData.GetViewShell(), aNewRowArea.toString()); - } + Size aNewSize(0, 0); + if (pModelObj) + aNewSize = pModelObj->getDocumentSize(); - // Provide size in the payload, so clients don't have to - // call lok::Document::getDocumentSize(). - std::stringstream ss; - ss << aNewSize.Width() << ", " << aNewSize.Height(); - OString sSize = ss.str().c_str(); - ScModelObj* pModel = comphelper::getUnoTunnelImplementation(aViewData.GetViewShell()->GetCurrentDocument()); - SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel, false); - } - } - } + if (!pDocSh) + return; + + // New area extended to the right of the sheet after last column + // including overlapping area with aNewRowArea + tools::Rectangle aNewColArea(aOldSize.getWidth(), 0, aNewSize.getWidth(), aNewSize.getHeight()); + // New area extended to the bottom of the sheet after last row + // excluding overlapping area with aNewColArea + tools::Rectangle aNewRowArea(0, aOldSize.getHeight(), aOldSize.getWidth(), aNewSize.getHeight()); + + // Only invalidate if spreadsheet extended to the right + if (aNewColArea.getWidth()) + { + SfxLokHelper::notifyInvalidation(aViewData.GetViewShell(), aNewColArea.toString()); } + + // Only invalidate if spreadsheet extended to the bottom + if (aNewRowArea.getHeight()) + { + SfxLokHelper::notifyInvalidation(aViewData.GetViewShell(), aNewRowArea.toString()); + } + + // Provide size in the payload, so clients don't have to + // call lok::Document::getDocumentSize(). + std::stringstream ss; + ss << aNewSize.Width() << ", " << aNewSize.Height(); + OString sSize = ss.str().c_str(); + ScModelObj* pModel = comphelper::getUnoTunnelImplementation(aViewData.GetViewShell()->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel, false); } static bool lcl_IsScSimpleRefDlgOpen(SfxViewFrame* pViewFrm) @@ -462,37 +462,37 @@ static bool lcl_IsScSimpleRefDlgOpen(SfxViewFrame* pViewFrm) void ScTabView::CheckSelectionTransfer() { - if ( aViewData.IsActive() ) // only for active view - { - ScModule* pScMod = SC_MOD(); - ScSelectionTransferObj* pOld = pScMod->GetSelectionTransfer(); - rtl::Reference pNew = ScSelectionTransferObj::CreateFromView( this ); - if ( pNew ) - { - // create new selection + if ( !aViewData.IsActive() ) // only for active view + return; - if (pOld) - pOld->ForgetView(); + ScModule* pScMod = SC_MOD(); + ScSelectionTransferObj* pOld = pScMod->GetSelectionTransfer(); + rtl::Reference pNew = ScSelectionTransferObj::CreateFromView( this ); + if ( !pNew ) + return; - pScMod->SetSelectionTransfer( pNew.get() ); + // create new selection - // tdf#124975 changing the calc selection can trigger removal of the - // selection of an open ScSimpleRefDlg dialog, so don't inform the - // desktop clipboard of the changed selection if that dialog is open - if (!lcl_IsScSimpleRefDlgOpen(aViewData.GetViewShell()->GetViewFrame())) - pNew->CopyToSelection( GetActiveWin() ); // may delete pOld + if (pOld) + pOld->ForgetView(); - // Log the selection change - ScMarkData& rMark = aViewData.GetMarkData(); - if (rMark.IsMarked()) - { - ScRange aMarkRange; - rMark.GetMarkArea( aMarkRange ); - OUString aStartAddress = aMarkRange.aStart.GetColRowString(); - OUString aEndAddress = aMarkRange.aEnd.GetColRowString(); - collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}); - } - } + pScMod->SetSelectionTransfer( pNew.get() ); + + // tdf#124975 changing the calc selection can trigger removal of the + // selection of an open ScSimpleRefDlg dialog, so don't inform the + // desktop clipboard of the changed selection if that dialog is open + if (!lcl_IsScSimpleRefDlgOpen(aViewData.GetViewShell()->GetViewFrame())) + pNew->CopyToSelection( GetActiveWin() ); // may delete pOld + + // Log the selection change + ScMarkData& rMark = aViewData.GetMarkData(); + if (rMark.IsMarked()) + { + ScRange aMarkRange; + rMark.GetMarkArea( aMarkRange ); + OUString aStartAddress = aMarkRange.aStart.GetColRowString(); + OUString aEndAddress = aMarkRange.aEnd.GetColRowString(); + collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}); } } @@ -1791,234 +1791,234 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa return; } - if ( nTab != aViewData.GetTabNo() || bNew ) + if ( !(nTab != aViewData.GetTabNo() || bNew) ) + return; + + // FormShell would like to be informed before the switch + FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell(); + if (pFormSh) { - // FormShell would like to be informed before the switch - FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell(); - if (pFormSh) + bool bAllowed = pFormSh->PrepareClose(); + if (!bAllowed) { - bool bAllowed = pFormSh->PrepareClose(); - if (!bAllowed) - { - //! error message? or does FormShell do it? - //! return error flag and cancel actions + //! error message? or does FormShell do it? + //! return error flag and cancel actions - return; // FormShell says that it can not be switched - } + return; // FormShell says that it can not be switched } + } - // not InputEnterHandler due to reference input + // not InputEnterHandler due to reference input - ScDocument* pDoc = aViewData.GetDocument(); + ScDocument* pDoc = aViewData.GetDocument(); - pDoc->MakeTable( nTab ); + pDoc->MakeTable( nTab ); - // Update pending row heights before switching the sheet, so Reschedule from the progress bar - // doesn't paint the new sheet with old heights - aViewData.GetDocShell()->UpdatePendingRowHeights( nTab ); + // Update pending row heights before switching the sheet, so Reschedule from the progress bar + // doesn't paint the new sheet with old heights + aViewData.GetDocShell()->UpdatePendingRowHeights( nTab ); - SCTAB nTabCount = pDoc->GetTableCount(); - SCTAB nOldPos = nTab; - while (!pDoc->IsVisible(nTab)) // search for next visible + SCTAB nTabCount = pDoc->GetTableCount(); + SCTAB nOldPos = nTab; + while (!pDoc->IsVisible(nTab)) // search for next visible + { + bool bUp = (nTab>=nOldPos); + if (bUp) { - bool bUp = (nTab>=nOldPos); - if (bUp) + ++nTab; + if (nTab>=nTabCount) { - ++nTab; - if (nTab>=nTabCount) - { - nTab = nOldPos; - bUp = false; - } + nTab = nOldPos; + bUp = false; } + } - if (!bUp) + if (!bUp) + { + if (nTab != 0) + --nTab; + else { - if (nTab != 0) - --nTab; - else - { - OSL_FAIL("no visible sheets"); - pDoc->SetVisible( 0, true ); - } + OSL_FAIL("no visible sheets"); + pDoc->SetVisible( 0, true ); } } + } - // #i71490# Deselect drawing objects before changing the sheet number in view data, - // so the handling of notes still has the sheet selected on which the notes are. - DrawDeselectAll(); + // #i71490# Deselect drawing objects before changing the sheet number in view data, + // so the handling of notes still has the sheet selected on which the notes are. + DrawDeselectAll(); - ScModule* pScMod = SC_MOD(); - bool bRefMode = pScMod->IsFormulaMode(); - if ( !bRefMode ) // query, so that RefMode works when switching sheet - { - DoneBlockMode(); - pSelEngine->Reset(); // reset all flags, including locked modifiers - aViewData.SetRefTabNo( nTab ); - } + ScModule* pScMod = SC_MOD(); + bool bRefMode = pScMod->IsFormulaMode(); + if ( !bRefMode ) // query, so that RefMode works when switching sheet + { + DoneBlockMode(); + pSelEngine->Reset(); // reset all flags, including locked modifiers + aViewData.SetRefTabNo( nTab ); + } - ScSplitPos eOldActive = aViewData.GetActivePart(); // before switching - bool bFocus = pGridWin[eOldActive] && pGridWin[eOldActive]->HasFocus(); + ScSplitPos eOldActive = aViewData.GetActivePart(); // before switching + bool bFocus = pGridWin[eOldActive] && pGridWin[eOldActive]->HasFocus(); - aViewData.SetTabNo( nTab ); - // UpdateShow before SetCursor, so that UpdateAutoFillMark finds the correct - // window (is called from SetCursor) - UpdateShow(); + aViewData.SetTabNo( nTab ); + // UpdateShow before SetCursor, so that UpdateAutoFillMark finds the correct + // window (is called from SetCursor) + UpdateShow(); - SfxBindings& rBindings = aViewData.GetBindings(); - ScMarkData& rMark = aViewData.GetMarkData(); + SfxBindings& rBindings = aViewData.GetBindings(); + ScMarkData& rMark = aViewData.GetMarkData(); - bool bAllSelected = true; - for (SCTAB nSelTab = 0; nSelTab < nTabCount; ++nSelTab) + bool bAllSelected = true; + for (SCTAB nSelTab = 0; nSelTab < nTabCount; ++nSelTab) + { + if (!pDoc->IsVisible(nSelTab) || rMark.GetTableSelect(nSelTab)) { - if (!pDoc->IsVisible(nSelTab) || rMark.GetTableSelect(nSelTab)) - { - if (nTab == nSelTab) - // This tab is already in selection. Keep the current - // selection. - bExtendSelection = true; - } - else - { - bAllSelected = false; - if (bExtendSelection) - // We got what we need. No need to stay in the loop. - break; - } + if (nTab == nSelTab) + // This tab is already in selection. Keep the current + // selection. + bExtendSelection = true; } - if (bAllSelected && !bNew) - // #i6327# if all tables are selected, a selection event (#i6330#) will deselect all - // (not if called with bNew to update settings) - bExtendSelection = false; - - if (bExtendSelection) - rMark.SelectTable( nTab, true ); else { - rMark.SelectOneTable( nTab ); - rBindings.Invalidate( FID_FILL_TAB ); - rBindings.Invalidate( FID_TAB_DESELECTALL ); + bAllSelected = false; + if (bExtendSelection) + // We got what we need. No need to stay in the loop. + break; } + } + if (bAllSelected && !bNew) + // #i6327# if all tables are selected, a selection event (#i6330#) will deselect all + // (not if called with bNew to update settings) + bExtendSelection = false; - bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF; + if (bExtendSelection) + rMark.SelectTable( nTab, true ); + else + { + rMark.SelectOneTable( nTab ); + rBindings.Invalidate( FID_FILL_TAB ); + rBindings.Invalidate( FID_TAB_DESELECTALL ); + } + + bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF; - // recalc zoom-dependent values (before TabChanged, before UpdateEditViewPos) - RefreshZoom(); - UpdateVarZoom(); + // recalc zoom-dependent values (before TabChanged, before UpdateEditViewPos) + RefreshZoom(); + UpdateVarZoom(); - if ( bRefMode ) // hide EditView if necessary (after aViewData.SetTabNo !) + if ( bRefMode ) // hide EditView if necessary (after aViewData.SetTabNo !) + { + for (VclPtr & pWin : pGridWin) { - for (VclPtr & pWin : pGridWin) - { - if (pWin && pWin->IsVisible()) - pWin->UpdateEditViewPos(); - } + if (pWin && pWin->IsVisible()) + pWin->UpdateEditViewPos(); } + } - TabChanged(bSameTabButMoved); // DrawView - collectUIInformation({{"TABLE", OUString::number(nTab)}}); - UpdateVisibleRange(); + TabChanged(bSameTabButMoved); // DrawView + collectUIInformation({{"TABLE", OUString::number(nTab)}}); + UpdateVisibleRange(); - aViewData.GetViewShell()->WindowChanged(); // if the active window has changed - aViewData.ResetOldCursor(); - SetCursor( aViewData.GetCurX(), aViewData.GetCurY(), true ); + aViewData.GetViewShell()->WindowChanged(); // if the active window has changed + aViewData.ResetOldCursor(); + SetCursor( aViewData.GetCurX(), aViewData.GetCurY(), true ); - if ( !bUnoRefDialog ) - aViewData.GetViewShell()->DisconnectAllClients(); // important for floating frames - else + if ( !bUnoRefDialog ) + aViewData.GetViewShell()->DisconnectAllClients(); // important for floating frames + else + { + // hide / show inplace client + ScClient* pClient = static_cast(aViewData.GetViewShell()->GetIPClient()); + if ( pClient && pClient->IsObjectInPlaceActive() ) { - // hide / show inplace client - ScClient* pClient = static_cast(aViewData.GetViewShell()->GetIPClient()); - if ( pClient && pClient->IsObjectInPlaceActive() ) + tools::Rectangle aObjArea = pClient->GetObjArea(); + if ( nTab == aViewData.GetRefTabNo() ) { - tools::Rectangle aObjArea = pClient->GetObjArea(); - if ( nTab == aViewData.GetRefTabNo() ) - { - // move to its original position + // move to its original position - SdrOle2Obj* pDrawObj = pClient->GetDrawObj(); - if ( pDrawObj ) - { - tools::Rectangle aRect = pDrawObj->GetLogicRect(); - MapMode aMapMode( MapUnit::Map100thMM ); - Size aOleSize = pDrawObj->GetOrigObjSize( &aMapMode ); - aRect.SetSize( aOleSize ); - aObjArea = aRect; - } - } - else + SdrOle2Obj* pDrawObj = pClient->GetDrawObj(); + if ( pDrawObj ) { - // move to an invisible position - - aObjArea.SetPos( Point( 0, -2*aObjArea.GetHeight() ) ); + tools::Rectangle aRect = pDrawObj->GetLogicRect(); + MapMode aMapMode( MapUnit::Map100thMM ); + Size aOleSize = pDrawObj->GetOrigObjSize( &aMapMode ); + aRect.SetSize( aOleSize ); + aObjArea = aRect; } - pClient->SetObjArea( aObjArea ); } + else + { + // move to an invisible position + + aObjArea.SetPos( Point( 0, -2*aObjArea.GetHeight() ) ); + } + pClient->SetObjArea( aObjArea ); } + } - if ( bFocus && aViewData.GetActivePart() != eOldActive && !bRefMode ) - ActiveGrabFocus(); // grab focus to the pane that's active now + if ( bFocus && aViewData.GetActivePart() != eOldActive && !bRefMode ) + ActiveGrabFocus(); // grab focus to the pane that's active now - // freeze + // freeze - bool bResize = false; - if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX ) - if (aViewData.UpdateFixX()) - bResize = true; - if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX ) - if (aViewData.UpdateFixY()) - bResize = true; - if (bResize) - RepeatResize(); - InvalidateSplit(); + bool bResize = false; + if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX ) + if (aViewData.UpdateFixX()) + bResize = true; + if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX ) + if (aViewData.UpdateFixY()) + bResize = true; + if (bResize) + RepeatResize(); + InvalidateSplit(); - if ( aViewData.IsPagebreakMode() ) - UpdatePageBreakData(); //! asynchronously ?? + if ( aViewData.IsPagebreakMode() ) + UpdatePageBreakData(); //! asynchronously ?? - // Form Layer must know the visible area of the new sheet - // that is why MapMode must already be correct here - for (VclPtr & pWin : pGridWin) - { - if (pWin) - pWin->SetMapMode(pWin->GetDrawMapMode()); - } - SetNewVisArea(); + // Form Layer must know the visible area of the new sheet + // that is why MapMode must already be correct here + for (VclPtr & pWin : pGridWin) + { + if (pWin) + pWin->SetMapMode(pWin->GetDrawMapMode()); + } + SetNewVisArea(); - PaintGrid(); - PaintTop(); - PaintLeft(); - PaintExtras(); - - DoResize( aBorderPos, aFrameSize ); - rBindings.Invalidate( SID_DELETE_PRINTAREA ); // Menu - rBindings.Invalidate( FID_DEL_MANUALBREAKS ); - rBindings.Invalidate( FID_RESET_PRINTZOOM ); - rBindings.Invalidate( SID_STATUS_DOCPOS ); // Status bar - rBindings.Invalidate( SID_ROWCOL_SELCOUNT ); // Status bar - rBindings.Invalidate( SID_STATUS_PAGESTYLE ); // Status bar - rBindings.Invalidate( SID_CURRENTTAB ); // Navigator - rBindings.Invalidate( SID_STYLE_FAMILY2 ); // Designer - rBindings.Invalidate( SID_STYLE_FAMILY4 ); // Designer - rBindings.Invalidate( SID_TABLES_COUNT ); - - if (pScMod->IsRefDialogOpen()) + PaintGrid(); + PaintTop(); + PaintLeft(); + PaintExtras(); + + DoResize( aBorderPos, aFrameSize ); + rBindings.Invalidate( SID_DELETE_PRINTAREA ); // Menu + rBindings.Invalidate( FID_DEL_MANUALBREAKS ); + rBindings.Invalidate( FID_RESET_PRINTZOOM ); + rBindings.Invalidate( SID_STATUS_DOCPOS ); // Status bar + rBindings.Invalidate( SID_ROWCOL_SELCOUNT ); // Status bar + rBindings.Invalidate( SID_STATUS_PAGESTYLE ); // Status bar + rBindings.Invalidate( SID_CURRENTTAB ); // Navigator + rBindings.Invalidate( SID_STYLE_FAMILY2 ); // Designer + rBindings.Invalidate( SID_STYLE_FAMILY4 ); // Designer + rBindings.Invalidate( SID_TABLES_COUNT ); + + if (pScMod->IsRefDialogOpen()) + { + sal_uInt16 nCurRefDlgId=pScMod->GetCurRefDlgId(); + SfxViewFrame* pViewFrm = aViewData.GetViewShell()->GetViewFrame(); + SfxChildWindow* pChildWnd = pViewFrm->GetChildWindow( nCurRefDlgId ); + if (pChildWnd) { - sal_uInt16 nCurRefDlgId=pScMod->GetCurRefDlgId(); - SfxViewFrame* pViewFrm = aViewData.GetViewShell()->GetViewFrame(); - SfxChildWindow* pChildWnd = pViewFrm->GetChildWindow( nCurRefDlgId ); - if (pChildWnd) + if (pChildWnd->GetController()) { - if (pChildWnd->GetController()) - { - IAnyRefDialog* pRefDlg = dynamic_cast(pChildWnd->GetController().get()); - if (pRefDlg) - pRefDlg->ViewShellChanged(); - } + IAnyRefDialog* pRefDlg = dynamic_cast(pChildWnd->GetController().get()); + if (pRefDlg) + pRefDlg->ViewShellChanged(); } } - - OnLibreOfficeKitTabChanged(); } + + OnLibreOfficeKitTabChanged(); } void ScTabView::AddWindowToForeignEditView(SfxViewShell* pViewShell, ScSplitPos eWhich) @@ -2033,43 +2033,43 @@ void ScTabView::RemoveWindowFromForeignEditView(SfxViewShell* pViewShell, ScSpli void ScTabView::OnLibreOfficeKitTabChanged() { - if (comphelper::LibreOfficeKit::isActive()) + if (!comphelper::LibreOfficeKit::isActive()) + return; + + ScTabViewShell* pThisViewShell = aViewData.GetViewShell(); + SCTAB nThisTabNo = pThisViewShell->GetViewData().GetTabNo(); + auto lTabSwitch = [pThisViewShell, nThisTabNo] (ScTabViewShell* pOtherViewShell) { - ScTabViewShell* pThisViewShell = aViewData.GetViewShell(); - SCTAB nThisTabNo = pThisViewShell->GetViewData().GetTabNo(); - auto lTabSwitch = [pThisViewShell, nThisTabNo] (ScTabViewShell* pOtherViewShell) + ScViewData& rOtherViewData = pOtherViewShell->GetViewData(); + SCTAB nOtherTabNo = rOtherViewData.GetTabNo(); + if (nThisTabNo == nOtherTabNo) { - ScViewData& rOtherViewData = pOtherViewShell->GetViewData(); - SCTAB nOtherTabNo = rOtherViewData.GetTabNo(); - if (nThisTabNo == nOtherTabNo) + for (int i = 0; i < 4; ++i) { - for (int i = 0; i < 4; ++i) + if (rOtherViewData.HasEditView(ScSplitPos(i))) { - if (rOtherViewData.HasEditView(ScSplitPos(i))) - { - pThisViewShell->AddWindowToForeignEditView(pOtherViewShell, ScSplitPos(i)); - } + pThisViewShell->AddWindowToForeignEditView(pOtherViewShell, ScSplitPos(i)); } } - else + } + else + { + for (int i = 0; i < 4; ++i) { - for (int i = 0; i < 4; ++i) + if (rOtherViewData.HasEditView(ScSplitPos(i))) { - if (rOtherViewData.HasEditView(ScSplitPos(i))) - { - pThisViewShell->RemoveWindowFromForeignEditView(pOtherViewShell, ScSplitPos(i)); - } + pThisViewShell->RemoveWindowFromForeignEditView(pOtherViewShell, ScSplitPos(i)); } } - }; + } + }; - SfxLokHelper::forEachOtherView(pThisViewShell, lTabSwitch); + SfxLokHelper::forEachOtherView(pThisViewShell, lTabSwitch); - pThisViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_HEADER, "all"); + pThisViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_HEADER, "all"); - if (pThisViewShell->GetInputHandler()) - pThisViewShell->GetInputHandler()->UpdateLokReferenceMarks(); - } + if (pThisViewShell->GetInputHandler()) + pThisViewShell->GetInputHandler()->UpdateLokReferenceMarks(); } // paint functions - only for this View @@ -2425,82 +2425,82 @@ void ScTabView::PaintRangeFinderEntry (const ScRangeFindData* pData, const SCTAB if ( aRef.aStart == aRef.aEnd ) //! ignore sheet? aViewData.GetDocument()->ExtendMerge(aRef); - if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab ) - { - SCCOL nCol1 = aRef.aStart.Col(); - SCROW nRow1 = aRef.aStart.Row(); - SCCOL nCol2 = aRef.aEnd.Col(); - SCROW nRow2 = aRef.aEnd.Row(); + if (aRef.aStart.Tab() < nTab || aRef.aEnd.Tab() > nTab) + return; - // remove -> repaint - // ScUpdateMode::Marks: Invalidate, nothing until end of row + SCCOL nCol1 = aRef.aStart.Col(); + SCROW nRow1 = aRef.aStart.Row(); + SCCOL nCol2 = aRef.aEnd.Col(); + SCROW nRow2 = aRef.aEnd.Row(); - bool bHiddenEdge = false; - SCROW nTmp; - ScDocument* pDoc = aViewData.GetDocument(); - while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab) ) - { - --nCol1; - bHiddenEdge = true; - } - while ( nCol2 < pDoc->MaxCol() && pDoc->ColHidden(nCol2, nTab) ) - { - ++nCol2; - bHiddenEdge = true; - } - nTmp = pDoc->LastVisibleRow(0, nRow1, nTab); - if (!pDoc->ValidRow(nTmp)) - nTmp = 0; - if (nTmp < nRow1) - { - nRow1 = nTmp; - bHiddenEdge = true; - } - nTmp = pDoc->FirstVisibleRow(nRow2, pDoc->MaxRow(), nTab); - if (!pDoc->ValidRow(nTmp)) - nTmp = pDoc->MaxRow(); - if (nTmp > nRow2) - { - nRow2 = nTmp; - bHiddenEdge = true; - } + // remove -> repaint + // ScUpdateMode::Marks: Invalidate, nothing until end of row - if ( nCol2 - nCol1 > 1 && nRow2 - nRow1 > 1 && !bHiddenEdge ) - { - // only along the edges - PaintArea( nCol1, nRow1, nCol2, nRow1, ScUpdateMode::Marks ); - PaintArea( nCol1, nRow1+1, nCol1, nRow2-1, ScUpdateMode::Marks ); - PaintArea( nCol2, nRow1+1, nCol2, nRow2-1, ScUpdateMode::Marks ); - PaintArea( nCol1, nRow2, nCol2, nRow2, ScUpdateMode::Marks ); - } - else // all in one - PaintArea( nCol1, nRow1, nCol2, nRow2, ScUpdateMode::Marks ); + bool bHiddenEdge = false; + SCROW nTmp; + ScDocument* pDoc = aViewData.GetDocument(); + while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab) ) + { + --nCol1; + bHiddenEdge = true; + } + while ( nCol2 < pDoc->MaxCol() && pDoc->ColHidden(nCol2, nTab) ) + { + ++nCol2; + bHiddenEdge = true; + } + nTmp = pDoc->LastVisibleRow(0, nRow1, nTab); + if (!pDoc->ValidRow(nTmp)) + nTmp = 0; + if (nTmp < nRow1) + { + nRow1 = nTmp; + bHiddenEdge = true; + } + nTmp = pDoc->FirstVisibleRow(nRow2, pDoc->MaxRow(), nTab); + if (!pDoc->ValidRow(nTmp)) + nTmp = pDoc->MaxRow(); + if (nTmp > nRow2) + { + nRow2 = nTmp; + bHiddenEdge = true; } + + if ( nCol2 - nCol1 > 1 && nRow2 - nRow1 > 1 && !bHiddenEdge ) + { + // only along the edges + PaintArea( nCol1, nRow1, nCol2, nRow1, ScUpdateMode::Marks ); + PaintArea( nCol1, nRow1+1, nCol1, nRow2-1, ScUpdateMode::Marks ); + PaintArea( nCol2, nRow1+1, nCol2, nRow2-1, ScUpdateMode::Marks ); + PaintArea( nCol1, nRow2, nCol2, nRow2, ScUpdateMode::Marks ); + } + else // all in one + PaintArea( nCol1, nRow1, nCol2, nRow2, ScUpdateMode::Marks ); } void ScTabView::PaintRangeFinder( long nNumber ) { ScInputHandler* pHdl = SC_MOD()->GetInputHdl( aViewData.GetViewShell() ); - if (pHdl) - { - ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList(); - if ( pRangeFinder && pRangeFinder->GetDocName() == aViewData.GetDocShell()->GetTitle() ) - { - SCTAB nTab = aViewData.GetTabNo(); - sal_uInt16 nCount = static_cast(pRangeFinder->Count()); + if (!pHdl) + return; - if (nNumber < 0) - { - for (sal_uInt16 i=0; iGetObject(i),nTab); - } - else - { - sal_uInt16 idx = nNumber; - if (idx < nCount) - PaintRangeFinderEntry(&pRangeFinder->GetObject(idx),nTab); - } - } + ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList(); + if ( !(pRangeFinder && pRangeFinder->GetDocName() == aViewData.GetDocShell()->GetTitle()) ) + return; + + SCTAB nTab = aViewData.GetTabNo(); + sal_uInt16 nCount = static_cast(pRangeFinder->Count()); + + if (nNumber < 0) + { + for (sal_uInt16 i=0; iGetObject(i),nTab); + } + else + { + sal_uInt16 idx = nNumber; + if (idx < nCount) + PaintRangeFinderEntry(&pRangeFinder->GetObject(idx),nTab); } } @@ -2765,21 +2765,21 @@ void ScTabView::RecalcPPT() bool bChangedX = ( aViewData.GetPPTX() != nOldX ); bool bChangedY = ( aViewData.GetPPTY() != nOldY ); - if ( bChangedX || bChangedY ) - { - // call view SetZoom (including draw scale, split update etc) - // and paint only if values changed + if ( !(bChangedX || bChangedY) ) + return; - Fraction aZoomX = aViewData.GetZoomX(); - Fraction aZoomY = aViewData.GetZoomY(); - SetZoom( aZoomX, aZoomY, false ); + // call view SetZoom (including draw scale, split update etc) + // and paint only if values changed - PaintGrid(); - if (bChangedX) - PaintTop(); - if (bChangedY) - PaintLeft(); - } + Fraction aZoomX = aViewData.GetZoomX(); + Fraction aZoomY = aViewData.GetZoomY(); + SetZoom( aZoomX, aZoomY, false ); + + PaintGrid(); + if (bChangedX) + PaintTop(); + if (bChangedY) + PaintLeft(); } void ScTabView::ActivateView( bool bActivate, bool bFirst ) @@ -2861,90 +2861,90 @@ void ScTabView::ActivateView( bool bActivate, bool bFirst ) void ScTabView::ActivatePart( ScSplitPos eWhich ) { ScSplitPos eOld = aViewData.GetActivePart(); - if ( eOld != eWhich ) - { - bInActivatePart = true; + if ( eOld == eWhich ) + return; - bool bRefMode = SC_MOD()->IsFormulaMode(); + bInActivatePart = true; - // the HasEditView call during SetCursor would fail otherwise - if ( aViewData.HasEditView(eOld) && !bRefMode ) - UpdateInputLine(); + bool bRefMode = SC_MOD()->IsFormulaMode(); - ScHSplitPos eOldH = WhichH(eOld); - ScVSplitPos eOldV = WhichV(eOld); - ScHSplitPos eNewH = WhichH(eWhich); - ScVSplitPos eNewV = WhichV(eWhich); - bool bTopCap = pColBar[eOldH] && pColBar[eOldH]->IsMouseCaptured(); - bool bLeftCap = pRowBar[eOldV] && pRowBar[eOldV]->IsMouseCaptured(); + // the HasEditView call during SetCursor would fail otherwise + if ( aViewData.HasEditView(eOld) && !bRefMode ) + UpdateInputLine(); - bool bFocus = pGridWin[eOld]->HasFocus(); - bool bCapture = pGridWin[eOld]->IsMouseCaptured(); - if (bCapture) - pGridWin[eOld]->ReleaseMouse(); - pGridWin[eOld]->ClickExtern(); - pGridWin[eOld]->HideCursor(); - pGridWin[eWhich]->HideCursor(); - aViewData.SetActivePart( eWhich ); + ScHSplitPos eOldH = WhichH(eOld); + ScVSplitPos eOldV = WhichV(eOld); + ScHSplitPos eNewH = WhichH(eWhich); + ScVSplitPos eNewV = WhichV(eWhich); + bool bTopCap = pColBar[eOldH] && pColBar[eOldH]->IsMouseCaptured(); + bool bLeftCap = pRowBar[eOldV] && pRowBar[eOldV]->IsMouseCaptured(); - ScTabViewShell* pShell = aViewData.GetViewShell(); - pShell->WindowChanged(); + bool bFocus = pGridWin[eOld]->HasFocus(); + bool bCapture = pGridWin[eOld]->IsMouseCaptured(); + if (bCapture) + pGridWin[eOld]->ReleaseMouse(); + pGridWin[eOld]->ClickExtern(); + pGridWin[eOld]->HideCursor(); + pGridWin[eWhich]->HideCursor(); + aViewData.SetActivePart( eWhich ); - pSelEngine->SetWindow(pGridWin[eWhich]); - pSelEngine->SetWhich(eWhich); - pSelEngine->SetVisibleArea( tools::Rectangle(Point(), pGridWin[eWhich]->GetOutputSizePixel()) ); + ScTabViewShell* pShell = aViewData.GetViewShell(); + pShell->WindowChanged(); - pGridWin[eOld]->MoveMouseStatus(*pGridWin[eWhich]); + pSelEngine->SetWindow(pGridWin[eWhich]); + pSelEngine->SetWhich(eWhich); + pSelEngine->SetVisibleArea( tools::Rectangle(Point(), pGridWin[eWhich]->GetOutputSizePixel()) ); - if ( bCapture || pGridWin[eWhich]->IsMouseCaptured() ) - { - // tracking instead of CaptureMouse, so it can be cancelled cleanly - // (SelectionEngine calls CaptureMouse for SetWindow) - //! someday SelectionEngine itself should call StartTracking!?! - pGridWin[eWhich]->ReleaseMouse(); - pGridWin[eWhich]->StartTracking(); - } + pGridWin[eOld]->MoveMouseStatus(*pGridWin[eWhich]); - if ( bTopCap && pColBar[eNewH] ) - { - pColBar[eOldH]->SetIgnoreMove(true); - pColBar[eNewH]->SetIgnoreMove(false); - pHdrSelEng->SetWindow( pColBar[eNewH] ); - long nWidth = pColBar[eNewH]->GetOutputSizePixel().Width(); - pHdrSelEng->SetVisibleArea( tools::Rectangle( 0, LONG_MIN, nWidth-1, LONG_MAX ) ); - pColBar[eNewH]->CaptureMouse(); - } - if ( bLeftCap && pRowBar[eNewV] ) - { - pRowBar[eOldV]->SetIgnoreMove(true); - pRowBar[eNewV]->SetIgnoreMove(false); - pHdrSelEng->SetWindow( pRowBar[eNewV] ); - long nHeight = pRowBar[eNewV]->GetOutputSizePixel().Height(); - pHdrSelEng->SetVisibleArea( tools::Rectangle( LONG_MIN, 0, LONG_MAX, nHeight-1 ) ); - pRowBar[eNewV]->CaptureMouse(); - } - aHdrFunc.SetWhich(eWhich); + if ( bCapture || pGridWin[eWhich]->IsMouseCaptured() ) + { + // tracking instead of CaptureMouse, so it can be cancelled cleanly + // (SelectionEngine calls CaptureMouse for SetWindow) + //! someday SelectionEngine itself should call StartTracking!?! + pGridWin[eWhich]->ReleaseMouse(); + pGridWin[eWhich]->StartTracking(); + } - pGridWin[eOld]->ShowCursor(); - pGridWin[eWhich]->ShowCursor(); + if ( bTopCap && pColBar[eNewH] ) + { + pColBar[eOldH]->SetIgnoreMove(true); + pColBar[eNewH]->SetIgnoreMove(false); + pHdrSelEng->SetWindow( pColBar[eNewH] ); + long nWidth = pColBar[eNewH]->GetOutputSizePixel().Width(); + pHdrSelEng->SetVisibleArea( tools::Rectangle( 0, LONG_MIN, nWidth-1, LONG_MAX ) ); + pColBar[eNewH]->CaptureMouse(); + } + if ( bLeftCap && pRowBar[eNewV] ) + { + pRowBar[eOldV]->SetIgnoreMove(true); + pRowBar[eNewV]->SetIgnoreMove(false); + pHdrSelEng->SetWindow( pRowBar[eNewV] ); + long nHeight = pRowBar[eNewV]->GetOutputSizePixel().Height(); + pHdrSelEng->SetVisibleArea( tools::Rectangle( LONG_MIN, 0, LONG_MAX, nHeight-1 ) ); + pRowBar[eNewV]->CaptureMouse(); + } + aHdrFunc.SetWhich(eWhich); - SfxInPlaceClient* pClient = aViewData.GetViewShell()->GetIPClient(); - bool bOleActive = ( pClient && pClient->IsObjectInPlaceActive() ); + pGridWin[eOld]->ShowCursor(); + pGridWin[eWhich]->ShowCursor(); - // don't switch ViewShell's active window during RefInput, because the focus - // might change, and subsequent SetReference calls wouldn't find the right EditView - if ( !bRefMode && !bOleActive ) - aViewData.GetViewShell()->SetWindow( pGridWin[eWhich] ); + SfxInPlaceClient* pClient = aViewData.GetViewShell()->GetIPClient(); + bool bOleActive = ( pClient && pClient->IsObjectInPlaceActive() ); - if ( bFocus && !aViewData.IsAnyFillMode() && !bRefMode ) - { - // GrabFocus only if previously the other GridWindow had the focus - // (for instance due to search and replace) - pGridWin[eWhich]->GrabFocus(); - } + // don't switch ViewShell's active window during RefInput, because the focus + // might change, and subsequent SetReference calls wouldn't find the right EditView + if ( !bRefMode && !bOleActive ) + aViewData.GetViewShell()->SetWindow( pGridWin[eWhich] ); - bInActivatePart = false; + if ( bFocus && !aViewData.IsAnyFillMode() && !bRefMode ) + { + // GrabFocus only if previously the other GridWindow had the focus + // (for instance due to search and replace) + pGridWin[eWhich]->GrabFocus(); } + + bInActivatePart = false; } void ScTabView::HideListBox() diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx index 910d097d890e..960f47752479 100644 --- a/sc/source/ui/view/tabview4.cxx +++ b/sc/source/ui/view/tabview4.cxx @@ -259,52 +259,52 @@ void ScTabView::UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ ) } // autocomplete for Auto-Fill - if ( aViewData.GetRefType() == SC_REFTYPE_FILL && Help::IsQuickHelpEnabled() ) + if ( !(aViewData.GetRefType() == SC_REFTYPE_FILL && Help::IsQuickHelpEnabled()) ) + return; + + vcl::Window* pWin = GetActiveWin(); + if ( !pWin ) + return; + + OUString aHelpStr; + ScRange aMarkRange; + aViewData.GetSimpleArea( aMarkRange ); + SCCOL nEndX = aViewData.GetRefEndX(); + SCROW nEndY = aViewData.GetRefEndY(); + ScRange aDelRange; + if ( aViewData.GetFillMode() == ScFillMode::MATRIX && !(nScFillModeMouseModifier & KEY_MOD1) ) { - vcl::Window* pWin = GetActiveWin(); - if ( pWin ) - { - OUString aHelpStr; - ScRange aMarkRange; - aViewData.GetSimpleArea( aMarkRange ); - SCCOL nEndX = aViewData.GetRefEndX(); - SCROW nEndY = aViewData.GetRefEndY(); - ScRange aDelRange; - if ( aViewData.GetFillMode() == ScFillMode::MATRIX && !(nScFillModeMouseModifier & KEY_MOD1) ) - { - aHelpStr = ScResId( STR_TIP_RESIZEMATRIX ); - SCCOL nCols = nEndX + 1 - aViewData.GetRefStartX(); // order is right - SCROW nRows = nEndY + 1 - aViewData.GetRefStartY(); - aHelpStr = aHelpStr.replaceFirst("%1", OUString::number(nRows) ); - aHelpStr = aHelpStr.replaceFirst("%2", OUString::number(nCols) ); - } - else if ( aViewData.GetDelMark( aDelRange ) ) - aHelpStr = ScResId( STR_QUICKHELP_DELETE ); - else if ( nEndX != aMarkRange.aEnd.Col() || nEndY != aMarkRange.aEnd.Row() ) - aHelpStr = pDoc->GetAutoFillPreview( aMarkRange, nEndX, nEndY ); + aHelpStr = ScResId( STR_TIP_RESIZEMATRIX ); + SCCOL nCols = nEndX + 1 - aViewData.GetRefStartX(); // order is right + SCROW nRows = nEndY + 1 - aViewData.GetRefStartY(); + aHelpStr = aHelpStr.replaceFirst("%1", OUString::number(nRows) ); + aHelpStr = aHelpStr.replaceFirst("%2", OUString::number(nCols) ); + } + else if ( aViewData.GetDelMark( aDelRange ) ) + aHelpStr = ScResId( STR_QUICKHELP_DELETE ); + else if ( nEndX != aMarkRange.aEnd.Col() || nEndY != aMarkRange.aEnd.Row() ) + aHelpStr = pDoc->GetAutoFillPreview( aMarkRange, nEndX, nEndY ); - if (aHelpStr.getLength()) - { - // depending on direction the upper or lower corner - SCCOL nAddX = ( nEndX >= aMarkRange.aEnd.Col() ) ? 1 : 0; - SCROW nAddY = ( nEndY >= aMarkRange.aEnd.Row() ) ? 1 : 0; - Point aPos = aViewData.GetScrPos( nEndX+nAddX, nEndY+nAddY, aViewData.GetActivePart() ); - aPos.AdjustX(8 ); - aPos.AdjustY(4 ); - aPos = pWin->OutputToScreenPixel( aPos ); - tools::Rectangle aRect( aPos, aPos ); - QuickHelpFlags nAlign = QuickHelpFlags::Left|QuickHelpFlags::Top; - if (!nTipVisible || nAlign != nTipAlign || aRect != aTipRectangle || sTipString != aHelpStr || sTopParent != pWin) - { - HideTip(); - nTipVisible = Help::ShowPopover(pWin, aRect, aHelpStr, nAlign); - aTipRectangle = aRect; - nTipAlign = nAlign; - sTipString = aHelpStr; - sTopParent = pWin; - } - } - } + if (!aHelpStr.getLength()) + return; + + // depending on direction the upper or lower corner + SCCOL nAddX = ( nEndX >= aMarkRange.aEnd.Col() ) ? 1 : 0; + SCROW nAddY = ( nEndY >= aMarkRange.aEnd.Row() ) ? 1 : 0; + Point aPos = aViewData.GetScrPos( nEndX+nAddX, nEndY+nAddY, aViewData.GetActivePart() ); + aPos.AdjustX(8 ); + aPos.AdjustY(4 ); + aPos = pWin->OutputToScreenPixel( aPos ); + tools::Rectangle aRect( aPos, aPos ); + QuickHelpFlags nAlign = QuickHelpFlags::Left|QuickHelpFlags::Top; + if (!nTipVisible || nAlign != nTipAlign || aRect != aTipRectangle || sTipString != aHelpStr || sTopParent != pWin) + { + HideTip(); + nTipVisible = Help::ShowPopover(pWin, aRect, aHelpStr, nAlign); + aTipRectangle = aRect; + nTipAlign = nAlign; + sTipString = aHelpStr; + sTopParent = pWin; } } @@ -312,33 +312,33 @@ void ScTabView::InitRefMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScRefType eT { ScDocument* pDoc = aViewData.GetDocument(); ScMarkData& rMark = aViewData.GetMarkData(); - if (!aViewData.IsRefMode()) - { - aViewData.SetRefMode( true, eType ); - aViewData.SetRefStart( nCurX, nCurY, nCurZ ); - aViewData.SetRefEnd( nCurX, nCurY, nCurZ ); + if (aViewData.IsRefMode()) + return; - if (nCurZ == aViewData.GetTabNo()) - { - SCCOL nStartX = nCurX; - SCROW nStartY = nCurY; - SCCOL nEndX = nCurX; - SCROW nEndY = nCurY; - pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, aViewData.GetTabNo() ); + aViewData.SetRefMode( true, eType ); + aViewData.SetRefStart( nCurX, nCurY, nCurZ ); + aViewData.SetRefEnd( nCurX, nCurY, nCurZ ); - //! draw only markings over content! - PaintArea( nStartX,nStartY,nEndX,nEndY, ScUpdateMode::Marks ); + if (nCurZ == aViewData.GetTabNo()) + { + SCCOL nStartX = nCurX; + SCROW nStartY = nCurY; + SCCOL nEndX = nCurX; + SCROW nEndY = nCurY; + pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, aViewData.GetTabNo() ); - // SetReference without Merge-Adjustment - ScRange aRef( nCurX,nCurY,nCurZ, nCurX,nCurY,nCurZ ); - SC_MOD()->SetReference( aRef, *pDoc, &rMark ); - } + //! draw only markings over content! + PaintArea( nStartX,nStartY,nEndX,nEndY, ScUpdateMode::Marks ); - ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl(); - if (pInputHandler) - { - pInputHandler->UpdateLokReferenceMarks(); - } + // SetReference without Merge-Adjustment + ScRange aRef( nCurX,nCurY,nCurZ, nCurX,nCurY,nCurZ ); + SC_MOD()->SetReference( aRef, *pDoc, &rMark ); + } + + ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl(); + if (pInputHandler) + { + pInputHandler->UpdateLokReferenceMarks(); } } diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index 55eeb35c7f73..5966443db5d8 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -222,46 +222,45 @@ ScTabView::~ScTabView() void ScTabView::MakeDrawView( TriState nForceDesignMode ) { - if (!pDrawView) - { - ScDrawLayer* pLayer = aViewData.GetDocument()->GetDrawLayer(); - OSL_ENSURE(pLayer, "Where is the Draw Layer ??"); + if (pDrawView) + return; - sal_uInt16 i; - pDrawView.reset( new ScDrawView( pGridWin[SC_SPLIT_BOTTOMLEFT], &aViewData ) ); - for (i=0; i<4; i++) - if (pGridWin[i]) - { - if ( SC_SPLIT_BOTTOMLEFT != static_cast(i) ) - pDrawView->AddWindowToPaintView(pGridWin[i], nullptr); - } - pDrawView->RecalcScale(); - for (i=0; i<4; i++) - if (pGridWin[i]) - { - pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode()); + ScDrawLayer* pLayer = aViewData.GetDocument()->GetDrawLayer(); + OSL_ENSURE(pLayer, "Where is the Draw Layer ??"); - pGridWin[i]->PaintImmediately(); // because of Invalidate in DrawView ctor (ShowPage), - // so that immediately can be drawn - } - SfxRequest aSfxRequest(SID_OBJECT_SELECT, SfxCallMode::SLOT, aViewData.GetViewShell()->GetPool()); - SetDrawFuncPtr(new FuSelection(*aViewData.GetViewShell(), GetActiveWin(), pDrawView.get(), - pLayer,aSfxRequest)); + sal_uInt16 i; + pDrawView.reset( new ScDrawView( pGridWin[SC_SPLIT_BOTTOMLEFT], &aViewData ) ); + for (i=0; i<4; i++) + if (pGridWin[i]) + { + if ( SC_SPLIT_BOTTOMLEFT != static_cast(i) ) + pDrawView->AddWindowToPaintView(pGridWin[i], nullptr); + } + pDrawView->RecalcScale(); + for (i=0; i<4; i++) + if (pGridWin[i]) + { + pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode()); - // used when switching back from page preview: restore saved design mode state - // (otherwise, keep the default from the draw view ctor) - if ( nForceDesignMode != TRISTATE_INDET ) - pDrawView->SetDesignMode( nForceDesignMode != TRISTATE_FALSE ); + pGridWin[i]->PaintImmediately(); // because of Invalidate in DrawView ctor (ShowPage), + // so that immediately can be drawn + } + SfxRequest aSfxRequest(SID_OBJECT_SELECT, SfxCallMode::SLOT, aViewData.GetViewShell()->GetPool()); + SetDrawFuncPtr(new FuSelection(*aViewData.GetViewShell(), GetActiveWin(), pDrawView.get(), + pLayer,aSfxRequest)); - // register at FormShell - FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell(); - if (pFormSh) - pFormSh->SetView(pDrawView.get()); + // used when switching back from page preview: restore saved design mode state + // (otherwise, keep the default from the draw view ctor) + if ( nForceDesignMode != TRISTATE_INDET ) + pDrawView->SetDesignMode( nForceDesignMode != TRISTATE_FALSE ); - if (aViewData.GetViewShell()->HasAccessibilityObjects()) - aViewData.GetViewShell()->BroadcastAccessibility(SfxHint(SfxHintId::ScAccMakeDrawLayer)); + // register at FormShell + FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell(); + if (pFormSh) + pFormSh->SetView(pDrawView.get()); - } + if (aViewData.GetViewShell()->HasAccessibilityObjects()) + aViewData.GetViewShell()->BroadcastAccessibility(SfxHint(SfxHintId::ScAccMakeDrawLayer)); } void ScTabView::DoAddWin( ScGridWindow* pWin ) @@ -315,82 +314,82 @@ void ScTabView::TabChanged( bool bSameTabButMoved ) } } - if (comphelper::LibreOfficeKit::isActive()) - { - ScDocShell* pDocSh = GetViewData().GetDocShell(); - ScModelObj* pModelObj = pDocSh ? comphelper::getUnoTunnelImplementation( pDocSh->GetModel()) : nullptr; + if (!comphelper::LibreOfficeKit::isActive()) + return; - if (pModelObj && GetViewData().GetDocument()) - { - Size aDocSize = pModelObj->getDocumentSize(); - std::stringstream ss; - ss << aDocSize.Width() << ", " << aDocSize.Height(); - OString sRect = ss.str().c_str(); - ScTabViewShell* pViewShell = aViewData.GetViewShell(); - - // Invalidate first - tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000); - OString sPayload = aRectangle.toString() + ", " + OString::number(aViewData.GetTabNo()); - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sPayload.getStr()); - - ScModelObj* pModel = comphelper::getUnoTunnelImplementation(pViewShell->GetCurrentDocument()); - SfxLokHelper::notifyDocumentSizeChanged(pViewShell, sRect, pModel, false); - } - } + ScDocShell* pDocSh = GetViewData().GetDocShell(); + ScModelObj* pModelObj = pDocSh ? comphelper::getUnoTunnelImplementation( pDocSh->GetModel()) : nullptr; + + if (!(pModelObj && GetViewData().GetDocument())) + return; + + Size aDocSize = pModelObj->getDocumentSize(); + std::stringstream ss; + ss << aDocSize.Width() << ", " << aDocSize.Height(); + OString sRect = ss.str().c_str(); + ScTabViewShell* pViewShell = aViewData.GetViewShell(); + + // Invalidate first + tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000); + OString sPayload = aRectangle.toString() + ", " + OString::number(aViewData.GetTabNo()); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sPayload.getStr()); + + ScModelObj* pModel = comphelper::getUnoTunnelImplementation(pViewShell->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(pViewShell, sRect, pModel, false); } void ScTabView::UpdateLayerLocks() { - if (pDrawView) + if (!pDrawView) + return; + + SCTAB nTab = aViewData.GetTabNo(); + bool bEx = aViewData.GetViewShell()->IsDrawSelMode(); + bool bProt = aViewData.GetDocument()->IsTabProtected( nTab ) || + aViewData.GetSfxDocShell()->IsReadOnly(); + bool bShared = aViewData.GetDocShell()->IsDocShared(); + + SdrLayer* pLayer; + SdrLayerAdmin& rAdmin = pDrawView->GetModel()->GetLayerAdmin(); + pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK); + if (pLayer) + pDrawView->SetLayerLocked( pLayer->GetName(), bProt || !bEx || bShared ); + pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN); + if (pLayer) + pDrawView->SetLayerLocked( pLayer->GetName() ); + pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT); + if (pLayer) + pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared ); + pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS); + if (pLayer) + pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared ); + pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN); + if (pLayer) { - SCTAB nTab = aViewData.GetTabNo(); - bool bEx = aViewData.GetViewShell()->IsDrawSelMode(); - bool bProt = aViewData.GetDocument()->IsTabProtected( nTab ) || - aViewData.GetSfxDocShell()->IsReadOnly(); - bool bShared = aViewData.GetDocShell()->IsDocShared(); - - SdrLayer* pLayer; - SdrLayerAdmin& rAdmin = pDrawView->GetModel()->GetLayerAdmin(); - pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK); - if (pLayer) - pDrawView->SetLayerLocked( pLayer->GetName(), bProt || !bEx || bShared ); - pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN); - if (pLayer) - pDrawView->SetLayerLocked( pLayer->GetName() ); - pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT); - if (pLayer) - pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared ); - pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS); - if (pLayer) - pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared ); - pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN); - if (pLayer) - { - pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared ); - pDrawView->SetLayerVisible( pLayer->GetName(), false); - } + pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared ); + pDrawView->SetLayerVisible( pLayer->GetName(), false); } } void ScTabView::DrawDeselectAll() { - if (pDrawView) + if (!pDrawView) + return; + + ScTabViewShell* pViewSh = aViewData.GetViewShell(); + if ( pDrawActual && + ( pViewSh->IsDrawTextShell() || pDrawActual->GetSlotID() == SID_DRAW_NOTEEDIT ) ) { - ScTabViewShell* pViewSh = aViewData.GetViewShell(); - if ( pDrawActual && - ( pViewSh->IsDrawTextShell() || pDrawActual->GetSlotID() == SID_DRAW_NOTEEDIT ) ) - { - // end text edit (as if escape pressed, in FuDraw) - aViewData.GetDispatcher().Execute( pDrawActual->GetSlotID(), - SfxCallMode::SLOT | SfxCallMode::RECORD ); - } + // end text edit (as if escape pressed, in FuDraw) + aViewData.GetDispatcher().Execute( pDrawActual->GetSlotID(), + SfxCallMode::SLOT | SfxCallMode::RECORD ); + } - pDrawView->ScEndTextEdit(); - pDrawView->UnmarkAll(); + pDrawView->ScEndTextEdit(); + pDrawView->UnmarkAll(); - if (!pViewSh->IsDrawSelMode()) - pViewSh->SetDrawShell( false ); - } + if (!pViewSh->IsDrawSelMode()) + pViewSh->SetDrawShell( false ); } bool ScTabView::IsDrawTextEdit() const @@ -491,28 +490,28 @@ void ScTabView::UpdateIMap( SdrObject* pObj ) void ScTabView::DrawEnableAnim(bool bSet) { sal_uInt16 i; - if ( pDrawView ) + if ( !pDrawView ) + return; + + // don't start animations if display of graphics is disabled + // graphics are controlled by VOBJ_TYPE_OLE + if ( bSet && aViewData.GetOptions().GetObjMode(VOBJ_TYPE_OLE) == VOBJ_MODE_SHOW ) { - // don't start animations if display of graphics is disabled - // graphics are controlled by VOBJ_TYPE_OLE - if ( bSet && aViewData.GetOptions().GetObjMode(VOBJ_TYPE_OLE) == VOBJ_MODE_SHOW ) + if ( !pDrawView->IsAnimationEnabled() ) { - if ( !pDrawView->IsAnimationEnabled() ) - { - pDrawView->SetAnimationEnabled(); + pDrawView->SetAnimationEnabled(); - // animated GIFs must be restarted: - ScDocument* pDoc = aViewData.GetDocument(); - for (i=0; i<4; i++) - if ( pGridWin[i] && pGridWin[i]->IsVisible() ) - pDoc->StartAnimations( aViewData.GetTabNo() ); - } - } - else - { - pDrawView->SetAnimationEnabled(false); + // animated GIFs must be restarted: + ScDocument* pDoc = aViewData.GetDocument(); + for (i=0; i<4; i++) + if ( pGridWin[i] && pGridWin[i]->IsVisible() ) + pDoc->StartAnimations( aViewData.GetTabNo() ); } } + else + { + pDrawView->SetAnimationEnabled(false); + } } void ScTabView::UpdateDrawTextOutliner() @@ -570,52 +569,52 @@ void ScTabView::MakeVisible( const tools::Rectangle& rHMMRect ) if ( aRect.Top() < 0 ) // top out nScrollY = aRect.Top(); // top border visible - if (nScrollX || nScrollY) - { - ScDocument* pDoc = aViewData.GetDocument(); - if ( pDoc->IsNegativePage( nTab ) ) - nScrollX = -nScrollX; + if (!(nScrollX || nScrollY)) + return; - double nPPTX = aViewData.GetPPTX(); - double nPPTY = aViewData.GetPPTY(); - ScSplitPos eWhich = aViewData.GetActivePart(); - SCCOL nPosX = aViewData.GetPosX(WhichH(eWhich)); - SCROW nPosY = aViewData.GetPosY(WhichV(eWhich)); + ScDocument* pDoc = aViewData.GetDocument(); + if ( pDoc->IsNegativePage( nTab ) ) + nScrollX = -nScrollX; - long nLinesX=0, nLinesY=0; // columns/rows - scroll at least nScrollX/Y + double nPPTX = aViewData.GetPPTX(); + double nPPTY = aViewData.GetPPTY(); + ScSplitPos eWhich = aViewData.GetActivePart(); + SCCOL nPosX = aViewData.GetPosX(WhichH(eWhich)); + SCROW nPosY = aViewData.GetPosY(WhichV(eWhich)); - if (nScrollX > 0) - while (nScrollX > 0 && nPosX < pDoc->MaxCol()) - { - nScrollX -= static_cast( pDoc->GetColWidth(nPosX, nTab) * nPPTX ); - ++nPosX; - ++nLinesX; - } - else if (nScrollX < 0) - while (nScrollX < 0 && nPosX > 0) - { - --nPosX; - nScrollX += static_cast( pDoc->GetColWidth(nPosX, nTab) * nPPTX ); - --nLinesX; - } + long nLinesX=0, nLinesY=0; // columns/rows - scroll at least nScrollX/Y - if (nScrollY > 0) - while (nScrollY > 0 && nPosY < pDoc->MaxRow()) - { - nScrollY -= static_cast( pDoc->GetRowHeight(nPosY, nTab) * nPPTY ); - ++nPosY; - ++nLinesY; - } - else if (nScrollY < 0) - while (nScrollY < 0 && nPosY > 0) - { - --nPosY; - nScrollY += static_cast( pDoc->GetRowHeight(nPosY, nTab) * nPPTY ); - --nLinesY; - } + if (nScrollX > 0) + while (nScrollX > 0 && nPosX < pDoc->MaxCol()) + { + nScrollX -= static_cast( pDoc->GetColWidth(nPosX, nTab) * nPPTX ); + ++nPosX; + ++nLinesX; + } + else if (nScrollX < 0) + while (nScrollX < 0 && nPosX > 0) + { + --nPosX; + nScrollX += static_cast( pDoc->GetColWidth(nPosX, nTab) * nPPTX ); + --nLinesX; + } - ScrollLines( nLinesX, nLinesY ); // execute - } + if (nScrollY > 0) + while (nScrollY > 0 && nPosY < pDoc->MaxRow()) + { + nScrollY -= static_cast( pDoc->GetRowHeight(nPosY, nTab) * nPPTY ); + ++nPosY; + ++nLinesY; + } + else if (nScrollY < 0) + while (nScrollY < 0 && nPosY > 0) + { + --nPosY; + nScrollY += static_cast( pDoc->GetRowHeight(nPosY, nTab) * nPPTY ); + --nLinesY; + } + + ScrollLines( nLinesX, nLinesY ); // execute } void ScTabView::SetBrushDocument( ScDocumentUniquePtr pNew, bool bLock ) diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx index d2efc23d5559..0883ea333e2a 100644 --- a/sc/source/ui/view/tabvwsh2.cxx +++ b/sc/source/ui/view/tabvwsh2.cxx @@ -311,67 +311,67 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) // with qualifier construct directly FuPoor* pFuActual = GetDrawFuncPtr(); - if(pFuActual && ((rReq.GetModifier() & KEY_MOD1) || bCreateDirectly)) + if(!(pFuActual && ((rReq.GetModifier() & KEY_MOD1) || bCreateDirectly))) + return; + + // Create default drawing objects via keyboard + const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions(); + sal_uInt32 nDefaultObjectSizeWidth = rAppOpt.GetDefaultObjectSizeWidth(); + sal_uInt32 nDefaultObjectSizeHeight = rAppOpt.GetDefaultObjectSizeHeight(); + + // calc position and size + bool bLOKIsActive = comphelper::LibreOfficeKit::isActive(); + Point aInsertPos; + if(!bLOKIsActive) { - // Create default drawing objects via keyboard - const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions(); - sal_uInt32 nDefaultObjectSizeWidth = rAppOpt.GetDefaultObjectSizeWidth(); - sal_uInt32 nDefaultObjectSizeHeight = rAppOpt.GetDefaultObjectSizeHeight(); - - // calc position and size - bool bLOKIsActive = comphelper::LibreOfficeKit::isActive(); - Point aInsertPos; - if(!bLOKIsActive) - { - tools::Rectangle aVisArea = pWin->PixelToLogic(tools::Rectangle(Point(0,0), pWin->GetOutputSizePixel())); - aInsertPos = aVisArea.Center(); - aInsertPos.AdjustX( -sal_Int32(nDefaultObjectSizeWidth / 2) ); - aInsertPos.AdjustY( -sal_Int32(nDefaultObjectSizeHeight / 2) ); - } - else - { - ScViewData& rViewData = GetViewData(); - aInsertPos = rViewData.getLOKVisibleArea().Center(); - if (comphelper::LibreOfficeKit::isCompatFlagSet( - comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs)) - aInsertPos = rViewData.GetPrintTwipsPosFromTileTwips(aInsertPos); + tools::Rectangle aVisArea = pWin->PixelToLogic(tools::Rectangle(Point(0,0), pWin->GetOutputSizePixel())); + aInsertPos = aVisArea.Center(); + aInsertPos.AdjustX( -sal_Int32(nDefaultObjectSizeWidth / 2) ); + aInsertPos.AdjustY( -sal_Int32(nDefaultObjectSizeHeight / 2) ); + } + else + { + ScViewData& rViewData = GetViewData(); + aInsertPos = rViewData.getLOKVisibleArea().Center(); + if (comphelper::LibreOfficeKit::isCompatFlagSet( + comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs)) + aInsertPos = rViewData.GetPrintTwipsPosFromTileTwips(aInsertPos); - aInsertPos.setX(sc::TwipsToHMM(aInsertPos.X())); - aInsertPos.setY(sc::TwipsToHMM(aInsertPos.Y())); + aInsertPos.setX(sc::TwipsToHMM(aInsertPos.X())); + aInsertPos.setY(sc::TwipsToHMM(aInsertPos.Y())); - aInsertPos.AdjustX( -sal_Int32(nDefaultObjectSizeWidth / 2) ); - aInsertPos.AdjustY( -sal_Int32(nDefaultObjectSizeHeight / 2) ); - } + aInsertPos.AdjustX( -sal_Int32(nDefaultObjectSizeWidth / 2) ); + aInsertPos.AdjustY( -sal_Int32(nDefaultObjectSizeHeight / 2) ); + } + + tools::Rectangle aNewObjectRectangle(aInsertPos, Size(nDefaultObjectSizeWidth, nDefaultObjectSizeHeight)); - tools::Rectangle aNewObjectRectangle(aInsertPos, Size(nDefaultObjectSizeWidth, nDefaultObjectSizeHeight)); + ScDrawView* pDrView = GetScDrawView(); - ScDrawView* pDrView = GetScDrawView(); + if(!pDrView) + return; - if(pDrView) - { - SdrPageView* pPageView = pDrView->GetSdrPageView(); + SdrPageView* pPageView = pDrView->GetSdrPageView(); - if(pPageView) - { - // create the default object - SdrObjectUniquePtr pObj = pFuActual->CreateDefaultObject(nNewId, aNewObjectRectangle); + if(!pPageView) + return; - if(pObj) - { - // insert into page - pView->InsertObjectAtView(pObj.release(), *pPageView); + // create the default object + SdrObjectUniquePtr pObj = pFuActual->CreateDefaultObject(nNewId, aNewObjectRectangle); - if ( nNewId == SID_DRAW_CAPTION || nNewId == SID_DRAW_CAPTION_VERTICAL ) - { - // use KeyInput to start edit mode (FuText is created). - // For FuText objects, edit mode is handled within CreateDefaultObject. - // KEY_F2 is handled in FuDraw::KeyInput. + if(!pObj) + return; - pFuActual->KeyInput( KeyEvent( 0, vcl::KeyCode( KEY_F2 ) ) ); - } - } - } - } + // insert into page + pView->InsertObjectAtView(pObj.release(), *pPageView); + + if ( nNewId == SID_DRAW_CAPTION || nNewId == SID_DRAW_CAPTION_VERTICAL ) + { + // use KeyInput to start edit mode (FuText is created). + // For FuText objects, edit mode is handled within CreateDefaultObject. + // KEY_F2 is handled in FuDraw::KeyInput. + + pFuActual->KeyInput( KeyEvent( 0, vcl::KeyCode( KEY_F2 ) ) ); } } diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 60d1573f6dd6..8f8036b19cfb 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -658,21 +658,21 @@ void ScTabViewShell::SetPivotShell( bool bActive ) // SetPivotShell is called from CursorPosChanged every time // -> don't change anything except switching between cell and pivot shell - if ( eCurOST == OST_Pivot || eCurOST == OST_Cell ) + if (eCurOST != OST_Pivot && eCurOST != OST_Cell) + return; + + if ( bActive ) { - if ( bActive ) - { - bActiveDrawTextSh = bActiveDrawSh = false; - bActiveDrawFormSh=false; - bActiveGraphicSh=false; - bActiveMediaSh=false; - bActiveOleObjectSh=false; - bActiveChartSh=false; - SetCurSubShell(OST_Pivot); - } - else - SetCurSubShell(OST_Cell); + bActiveDrawTextSh = bActiveDrawSh = false; + bActiveDrawFormSh=false; + bActiveGraphicSh=false; + bActiveMediaSh=false; + bActiveOleObjectSh=false; + bActiveChartSh=false; + SetCurSubShell(OST_Pivot); } + else + SetCurSubShell(OST_Cell); } void ScTabViewShell::SetAuditShell( bool bActive ) @@ -771,181 +771,181 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce) pPageBreakShell->SetRepeatTarget( &aTarget ); } - if ( eOST!=eCurOST || bForce ) - { - bool bCellBrush = false; // "format paint brush" allowed for cells - bool bDrawBrush = false; // "format paint brush" allowed for drawing objects + if ( !(eOST!=eCurOST || bForce) ) + return; + + bool bCellBrush = false; // "format paint brush" allowed for cells + bool bDrawBrush = false; // "format paint brush" allowed for drawing objects - if(eCurOST!=OST_NONE) RemoveSubShell(); + if(eCurOST!=OST_NONE) RemoveSubShell(); - if (pFormShell && !bFormShellAtTop) - AddSubShell(*pFormShell); // add below own subshells + if (pFormShell && !bFormShellAtTop) + AddSubShell(*pFormShell); // add below own subshells - switch(eOST) + switch(eOST) + { + case OST_Cell: + { + AddSubShell(*pCellShell); + if(bPgBrk) AddSubShell(*pPageBreakShell); + bCellBrush = true; + } + break; + case OST_Editing: { - case OST_Cell: + AddSubShell(*pCellShell); + if(bPgBrk) AddSubShell(*pPageBreakShell); + + if(pEditShell) { - AddSubShell(*pCellShell); - if(bPgBrk) AddSubShell(*pPageBreakShell); - bCellBrush = true; + AddSubShell(*pEditShell); } - break; - case OST_Editing: + } + break; + case OST_DrawText: + { + if ( !pDrawTextShell ) { - AddSubShell(*pCellShell); - if(bPgBrk) AddSubShell(*pPageBreakShell); - - if(pEditShell) - { - AddSubShell(*pEditShell); - } + pDocSh->MakeDrawLayer(); + pDrawTextShell.reset( new ScDrawTextObjectBar( &GetViewData() ) ); } - break; - case OST_DrawText: - { - if ( !pDrawTextShell ) - { - pDocSh->MakeDrawLayer(); - pDrawTextShell.reset( new ScDrawTextObjectBar( &GetViewData() ) ); - } - AddSubShell(*pDrawTextShell); + AddSubShell(*pDrawTextShell); + } + break; + case OST_Drawing: + { + if (svx::checkForSelectedCustomShapes( + GetScDrawView(), true /* bOnlyExtruded */ )) { + if (pExtrusionBarShell == nullptr) + pExtrusionBarShell.reset( new svx::ExtrusionBar(this) ); + AddSubShell( *pExtrusionBarShell ); } - break; - case OST_Drawing: - { - if (svx::checkForSelectedCustomShapes( - GetScDrawView(), true /* bOnlyExtruded */ )) { - if (pExtrusionBarShell == nullptr) - pExtrusionBarShell.reset( new svx::ExtrusionBar(this) ); - AddSubShell( *pExtrusionBarShell ); - } - sal_uInt32 nCheckStatus = 0; - if (svx::checkForSelectedFontWork( - GetScDrawView(), nCheckStatus )) { - if (pFontworkBarShell == nullptr) - pFontworkBarShell.reset( new svx::FontworkBar(this) ); - AddSubShell( *pFontworkBarShell ); - } - - if ( !pDrawShell ) - { - pDocSh->MakeDrawLayer(); - pDrawShell.reset( new ScDrawShell( &GetViewData() ) ); - pDrawShell->SetRepeatTarget( &aTarget ); - } - AddSubShell(*pDrawShell); - bDrawBrush = true; + sal_uInt32 nCheckStatus = 0; + if (svx::checkForSelectedFontWork( + GetScDrawView(), nCheckStatus )) { + if (pFontworkBarShell == nullptr) + pFontworkBarShell.reset( new svx::FontworkBar(this) ); + AddSubShell( *pFontworkBarShell ); } - break; - case OST_DrawForm: + if ( !pDrawShell ) { - if ( !pDrawFormShell ) - { - pDocSh->MakeDrawLayer(); - pDrawFormShell.reset( new ScDrawFormShell( &GetViewData() ) ); - pDrawFormShell->SetRepeatTarget( &aTarget ); - } - AddSubShell(*pDrawFormShell); - bDrawBrush = true; + pDocSh->MakeDrawLayer(); + pDrawShell.reset( new ScDrawShell( &GetViewData() ) ); + pDrawShell->SetRepeatTarget( &aTarget ); } - break; + AddSubShell(*pDrawShell); + bDrawBrush = true; + } + break; - case OST_Chart: + case OST_DrawForm: + { + if ( !pDrawFormShell ) { - if ( !pChartShell ) - { - pDocSh->MakeDrawLayer(); - pChartShell.reset( new ScChartShell( &GetViewData() ) ); - pChartShell->SetRepeatTarget( &aTarget ); - } - AddSubShell(*pChartShell); - bDrawBrush = true; + pDocSh->MakeDrawLayer(); + pDrawFormShell.reset( new ScDrawFormShell( &GetViewData() ) ); + pDrawFormShell->SetRepeatTarget( &aTarget ); } - break; + AddSubShell(*pDrawFormShell); + bDrawBrush = true; + } + break; - case OST_OleObject: + case OST_Chart: + { + if ( !pChartShell ) { - if ( !pOleObjectShell ) - { - pDocSh->MakeDrawLayer(); - pOleObjectShell.reset( new ScOleObjectShell( &GetViewData() ) ); - pOleObjectShell->SetRepeatTarget( &aTarget ); - } - AddSubShell(*pOleObjectShell); - bDrawBrush = true; + pDocSh->MakeDrawLayer(); + pChartShell.reset( new ScChartShell( &GetViewData() ) ); + pChartShell->SetRepeatTarget( &aTarget ); } - break; + AddSubShell(*pChartShell); + bDrawBrush = true; + } + break; - case OST_Graphic: + case OST_OleObject: + { + if ( !pOleObjectShell ) { - if ( !pGraphicShell) - { - pDocSh->MakeDrawLayer(); - pGraphicShell.reset( new ScGraphicShell( &GetViewData() ) ); - pGraphicShell->SetRepeatTarget( &aTarget ); - } - AddSubShell(*pGraphicShell); - bDrawBrush = true; + pDocSh->MakeDrawLayer(); + pOleObjectShell.reset( new ScOleObjectShell( &GetViewData() ) ); + pOleObjectShell->SetRepeatTarget( &aTarget ); } - break; + AddSubShell(*pOleObjectShell); + bDrawBrush = true; + } + break; - case OST_Media: + case OST_Graphic: + { + if ( !pGraphicShell) { - if ( !pMediaShell) - { - pDocSh->MakeDrawLayer(); - pMediaShell.reset( new ScMediaShell( &GetViewData() ) ); - pMediaShell->SetRepeatTarget( &aTarget ); - } - AddSubShell(*pMediaShell); + pDocSh->MakeDrawLayer(); + pGraphicShell.reset( new ScGraphicShell( &GetViewData() ) ); + pGraphicShell->SetRepeatTarget( &aTarget ); } - break; + AddSubShell(*pGraphicShell); + bDrawBrush = true; + } + break; - case OST_Pivot: + case OST_Media: + { + if ( !pMediaShell) { - AddSubShell(*pCellShell); - if(bPgBrk) AddSubShell(*pPageBreakShell); - - if ( !pPivotShell ) - { - pPivotShell.reset( new ScPivotShell( this ) ); - pPivotShell->SetRepeatTarget( &aTarget ); - } - AddSubShell(*pPivotShell); - bCellBrush = true; + pDocSh->MakeDrawLayer(); + pMediaShell.reset( new ScMediaShell( &GetViewData() ) ); + pMediaShell->SetRepeatTarget( &aTarget ); } - break; - case OST_Auditing: + AddSubShell(*pMediaShell); + } + break; + + case OST_Pivot: + { + AddSubShell(*pCellShell); + if(bPgBrk) AddSubShell(*pPageBreakShell); + + if ( !pPivotShell ) { - AddSubShell(*pCellShell); - if(bPgBrk) AddSubShell(*pPageBreakShell); + pPivotShell.reset( new ScPivotShell( this ) ); + pPivotShell->SetRepeatTarget( &aTarget ); + } + AddSubShell(*pPivotShell); + bCellBrush = true; + } + break; + case OST_Auditing: + { + AddSubShell(*pCellShell); + if(bPgBrk) AddSubShell(*pPageBreakShell); - if ( !pAuditingShell ) - { - pDocSh->MakeDrawLayer(); // the waiting time rather now as on the click + if ( !pAuditingShell ) + { + pDocSh->MakeDrawLayer(); // the waiting time rather now as on the click - pAuditingShell.reset( new ScAuditingShell( &GetViewData() ) ); - pAuditingShell->SetRepeatTarget( &aTarget ); - } - AddSubShell(*pAuditingShell); - bCellBrush = true; + pAuditingShell.reset( new ScAuditingShell( &GetViewData() ) ); + pAuditingShell->SetRepeatTarget( &aTarget ); } - break; - default: - OSL_FAIL("wrong shell requested"); - break; + AddSubShell(*pAuditingShell); + bCellBrush = true; } + break; + default: + OSL_FAIL("wrong shell requested"); + break; + } - if (pFormShell && bFormShellAtTop) - AddSubShell(*pFormShell); // add on top of own subshells + if (pFormShell && bFormShellAtTop) + AddSubShell(*pFormShell); // add on top of own subshells - eCurOST=eOST; + eCurOST=eOST; - // abort "format paint brush" when switching to an incompatible shell - if ( ( GetBrushDocument() && !bCellBrush ) || ( GetDrawBrushSet() && !bDrawBrush ) ) - ResetBrushDocument(); - } + // abort "format paint brush" when switching to an incompatible shell + if ( ( GetBrushDocument() && !bCellBrush ) || ( GetDrawBrushSet() && !bDrawBrush ) ) + ResetBrushDocument(); } void ScTabViewShell::SetFormShellAtTop( bool bSet ) @@ -1129,19 +1129,19 @@ void ScTabViewShell::StartSimpleRefDialog( SC_MOD()->SetRefDialog( nId, true, pViewFrm ); ScSimpleRefDlgWrapper* pWnd = static_cast(pViewFrm->GetChildWindow( nId )); - if (pWnd) - { - pWnd->SetCloseHdl( LINK( this, ScTabViewShell, SimpleRefClose ) ); - pWnd->SetUnoLinks( LINK( this, ScTabViewShell, SimpleRefDone ), - LINK( this, ScTabViewShell, SimpleRefAborted ), - LINK( this, ScTabViewShell, SimpleRefChange ) ); - pWnd->SetRefString( rInitVal ); - pWnd->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection ); - ScSimpleRefDlgWrapper::SetAutoReOpen( false ); - if (auto xWin = pWnd->GetController()) - xWin->set_title(rTitle); - pWnd->StartRefInput(); - } + if (!pWnd) + return; + + pWnd->SetCloseHdl( LINK( this, ScTabViewShell, SimpleRefClose ) ); + pWnd->SetUnoLinks( LINK( this, ScTabViewShell, SimpleRefDone ), + LINK( this, ScTabViewShell, SimpleRefAborted ), + LINK( this, ScTabViewShell, SimpleRefChange ) ); + pWnd->SetRefString( rInitVal ); + pWnd->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection ); + ScSimpleRefDlgWrapper::SetAutoReOpen( false ); + if (auto xWin = pWnd->GetController()) + xWin->set_title(rTitle); + pWnd->StartRefInput(); } void ScTabViewShell::StopSimpleRefDialog() @@ -1711,31 +1711,31 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame, // formula mode in online is not usable in collaborative mode, // this is a workaround for disabling formula mode in online // when there is more than a single view - if (comphelper::LibreOfficeKit::isActive()) + if (!comphelper::LibreOfficeKit::isActive()) + return; + + SfxViewShell* pViewShell = SfxViewShell::GetFirst(); + // have we already one view ? + if (!pViewShell) + return; + + // this view is not yet visible at this stage, so we look for not visible views, too, for this same document + SfxViewShell* pViewShell2 = pViewShell; + do + { + pViewShell2 = SfxViewShell::GetNext(*pViewShell2, /*only visible shells*/ false); + } while (pViewShell2 && pViewShell2->GetDocId() != pViewShell->GetDocId()); + // if the second view is not this one, it means that there is + // already more than one active view and so the formula mode + // has already been disabled + if (pViewShell2 && pViewShell2 == this) { - SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - // have we already one view ? - if (pViewShell) + ScTabViewShell* pTabViewShell = dynamic_cast(pViewShell); + assert(pTabViewShell); + ScInputHandler* pInputHdl = pTabViewShell->GetInputHandler(); + if (pInputHdl && pInputHdl->IsFormulaMode()) { - // this view is not yet visible at this stage, so we look for not visible views, too, for this same document - SfxViewShell* pViewShell2 = pViewShell; - do - { - pViewShell2 = SfxViewShell::GetNext(*pViewShell2, /*only visible shells*/ false); - } while (pViewShell2 && pViewShell2->GetDocId() != pViewShell->GetDocId()); - // if the second view is not this one, it means that there is - // already more than one active view and so the formula mode - // has already been disabled - if (pViewShell2 && pViewShell2 == this) - { - ScTabViewShell* pTabViewShell = dynamic_cast(pViewShell); - assert(pTabViewShell); - ScInputHandler* pInputHdl = pTabViewShell->GetInputHandler(); - if (pInputHdl && pInputHdl->IsFormulaMode()) - { - pInputHdl->SetMode(SC_INPUT_NONE); - } - } + pInputHdl->SetMode(SC_INPUT_NONE); } } } diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx index 7f0542420d39..d697e7b5934f 100644 --- a/sc/source/ui/view/tabvwshb.cxx +++ b/sc/source/ui/view/tabvwshb.cxx @@ -75,25 +75,25 @@ void ScTabViewShell::ConnectObject( const SdrOle2Obj* pObj ) // when already connected do not execute SetObjArea/SetSizeScale again SfxInPlaceClient* pClient = FindIPClient( xObj, pWin ); - if ( !pClient ) - { - pClient = new ScClient( this, pWin, GetScDrawView()->GetModel(), pObj ); - tools::Rectangle aRect = pObj->GetLogicRect(); - Size aDrawSize = aRect.GetSize(); - - Size aOleSize = pObj->GetOrigObjSize(); - - Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() ); - Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() ); - aScaleWidth.ReduceInaccurate(10); // compatible with SdrOle2Obj - aScaleHeight.ReduceInaccurate(10); - pClient->SetSizeScale(aScaleWidth,aScaleHeight); - - // visible section is only changed inplace! - // the object area must be set after the scaling since it triggers the resizing - aRect.SetSize( aOleSize ); - pClient->SetObjArea( aRect ); - } + if ( pClient ) + return; + + pClient = new ScClient( this, pWin, GetScDrawView()->GetModel(), pObj ); + tools::Rectangle aRect = pObj->GetLogicRect(); + Size aDrawSize = aRect.GetSize(); + + Size aOleSize = pObj->GetOrigObjSize(); + + Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() ); + Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() ); + aScaleWidth.ReduceInaccurate(10); // compatible with SdrOle2Obj + aScaleHeight.ReduceInaccurate(10); + pClient->SetSizeScale(aScaleWidth,aScaleHeight); + + // visible section is only changed inplace! + // the object area must be set after the scaling since it triggers the resizing + aRect.SetSize( aOleSize ); + pClient->SetObjArea( aRect ); } namespace { @@ -113,29 +113,29 @@ public: virtual void SAL_CALL notify(const css::uno::Any& aData) override { uno::Sequence aProperties; - if (aData >>= aProperties) - { - awt::Rectangle xRectangle; - sal_Int32 dimensionIndex = 0; - OUString sPivotTableName("DataPilot1"); + if (!(aData >>= aProperties)) + return; - for (beans::PropertyValue const & rProperty : std::as_const(aProperties)) - { - if (rProperty.Name == "Rectangle") - rProperty.Value >>= xRectangle; - if (rProperty.Name == "DimensionIndex") - rProperty.Value >>= dimensionIndex; - if (rProperty.Name == "PivotTableName") - rProperty.Value >>= sPivotTableName; - } + awt::Rectangle xRectangle; + sal_Int32 dimensionIndex = 0; + OUString sPivotTableName("DataPilot1"); + + for (beans::PropertyValue const & rProperty : std::as_const(aProperties)) + { + if (rProperty.Name == "Rectangle") + rProperty.Value >>= xRectangle; + if (rProperty.Name == "DimensionIndex") + rProperty.Value >>= dimensionIndex; + if (rProperty.Name == "PivotTableName") + rProperty.Value >>= sPivotTableName; + } - tools::Rectangle aChartRect = m_pObject->GetLogicRect(); + tools::Rectangle aChartRect = m_pObject->GetLogicRect(); - Point aPoint(xRectangle.X + aChartRect.Left(), xRectangle.Y + aChartRect.Top()); - Size aSize(xRectangle.Width, xRectangle.Height); + Point aPoint(xRectangle.X + aChartRect.Left(), xRectangle.Y + aChartRect.Top()); + Size aSize(xRectangle.Width, xRectangle.Height); - m_pViewShell->DoDPFieldPopup(sPivotTableName, dimensionIndex, aPoint, aSize); - } + m_pViewShell->DoDPFieldPopup(sPivotTableName, dimensionIndex, aPoint, aSize); } }; diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index 18292cc5fc66..0a1f0feb41af 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -498,33 +498,33 @@ css::uno::Reference ScTabViewShell::GetClipDa void ScTabViewShell::notifyAllViewsHeaderInvalidation(SfxViewShell* pForViewShell, HeaderType eHeaderType, SCTAB nCurrentTabIndex) { - if (comphelper::LibreOfficeKit::isActive()) + if (!comphelper::LibreOfficeKit::isActive()) + return; + + OString aPayload; + switch (eHeaderType) { - OString aPayload; - switch (eHeaderType) - { - case COLUMN_HEADER: - aPayload = "column"; - break; - case ROW_HEADER: - aPayload = "row"; - break; - case BOTH_HEADERS: - default: - aPayload = "all"; - break; - } + case COLUMN_HEADER: + aPayload = "column"; + break; + case ROW_HEADER: + aPayload = "row"; + break; + case BOTH_HEADERS: + default: + aPayload = "all"; + break; + } - SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - while (pViewShell) + SfxViewShell* pViewShell = SfxViewShell::GetFirst(); + while (pViewShell) + { + ScTabViewShell* pTabViewShell = dynamic_cast(pViewShell); + if (pTabViewShell && pViewShell->GetDocId() == pForViewShell->GetDocId() && (nCurrentTabIndex == -1 || pTabViewShell->getPart() == nCurrentTabIndex)) { - ScTabViewShell* pTabViewShell = dynamic_cast(pViewShell); - if (pTabViewShell && pViewShell->GetDocId() == pForViewShell->GetDocId() && (nCurrentTabIndex == -1 || pTabViewShell->getPart() == nCurrentTabIndex)) - { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_HEADER, aPayload.getStr()); - } - pViewShell = SfxViewShell::GetNext(*pViewShell); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_HEADER, aPayload.getStr()); } + pViewShell = SfxViewShell::GetNext(*pViewShell); } } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 1fa386526444..630dc61d2752 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -1986,95 +1986,95 @@ void ScViewData::EditGrowX() } } - if (bChanged) + if (!bChanged) + return; + + if ( bMoveArea || bGrowCentered || bGrowBackwards || bLayoutRTL ) { - if ( bMoveArea || bGrowCentered || bGrowBackwards || bLayoutRTL ) - { - tools::Rectangle aVis = pCurView->GetVisArea(); - tools::Rectangle aVisPTwips; - if (bLOKPrintTwips) - aVisPTwips = pCurView->GetLOKSpecialVisArea(); + tools::Rectangle aVis = pCurView->GetVisArea(); + tools::Rectangle aVisPTwips; + if (bLOKPrintTwips) + aVisPTwips = pCurView->GetLOKSpecialVisArea(); - if ( bGrowCentered ) - { - // switch to center-aligned (undo?) and reset VisArea to center + if ( bGrowCentered ) + { + // switch to center-aligned (undo?) and reset VisArea to center - pEngine->SetDefaultItem( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) ); + pEngine->SetDefaultItem( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) ); - long nCenter = aSize.Width() / 2; - long nVisSize = aArea.GetWidth(); - aVis.SetLeft( nCenter - nVisSize / 2 ); - aVis.SetRight( aVis.Left() + nVisSize - 1 ); + long nCenter = aSize.Width() / 2; + long nVisSize = aArea.GetWidth(); + aVis.SetLeft( nCenter - nVisSize / 2 ); + aVis.SetRight( aVis.Left() + nVisSize - 1 ); - if (bLOKPrintTwips) - { - long nCenterPTwips = aSizePTwips.Width() / 2; - long nVisSizePTwips = aAreaPTwips.GetWidth(); - aVisPTwips.SetLeft( nCenterPTwips - nVisSizePTwips / 2 ); - aVisPTwips.SetRight( aVisPTwips.Left() + nVisSizePTwips - 1 ); - } - } - else if ( bGrowToLeft ) + if (bLOKPrintTwips) { - // switch to right-aligned (undo?) and reset VisArea to the right + long nCenterPTwips = aSizePTwips.Width() / 2; + long nVisSizePTwips = aAreaPTwips.GetWidth(); + aVisPTwips.SetLeft( nCenterPTwips - nVisSizePTwips / 2 ); + aVisPTwips.SetRight( aVisPTwips.Left() + nVisSizePTwips - 1 ); + } + } + else if ( bGrowToLeft ) + { + // switch to right-aligned (undo?) and reset VisArea to the right - pEngine->SetDefaultItem( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) ); + pEngine->SetDefaultItem( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) ); - aVis.SetRight( aSize.Width() - 1 ); - aVis.SetLeft( aSize.Width() - aArea.GetWidth() ); // with the new, increased area + aVis.SetRight( aSize.Width() - 1 ); + aVis.SetLeft( aSize.Width() - aArea.GetWidth() ); // with the new, increased area - if (bLOKPrintTwips) - { - aVisPTwips.SetRight( aSizePTwips.Width() - 1 ); - aVisPTwips.SetLeft( aSizePTwips.Width() - aAreaPTwips.GetWidth() ); // with the new, increased area - } - } - else + if (bLOKPrintTwips) { - // switch to left-aligned (undo?) and reset VisArea to the left - - pEngine->SetDefaultItem( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) ); + aVisPTwips.SetRight( aSizePTwips.Width() - 1 ); + aVisPTwips.SetLeft( aSizePTwips.Width() - aAreaPTwips.GetWidth() ); // with the new, increased area + } + } + else + { + // switch to left-aligned (undo?) and reset VisArea to the left - long nMove = aVis.Left(); - aVis.SetLeft( 0 ); - aVis.AdjustRight( -nMove ); + pEngine->SetDefaultItem( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) ); - if (bLOKPrintTwips) - { - long nMovePTwips = aVisPTwips.Left(); - aVisPTwips.SetLeft( 0 ); - aVisPTwips.AdjustRight( -nMovePTwips ); - } - } + long nMove = aVis.Left(); + aVis.SetLeft( 0 ); + aVis.AdjustRight( -nMove ); - pCurView->SetVisArea( aVis ); if (bLOKPrintTwips) - pCurView->SetLOKSpecialVisArea( aVisPTwips ); - - bMoveArea = false; + { + long nMovePTwips = aVisPTwips.Left(); + aVisPTwips.SetLeft( 0 ); + aVisPTwips.AdjustRight( -nMovePTwips ); + } } + pCurView->SetVisArea( aVis ); if (bLOKPrintTwips) - pCurView->SetLOKSpecialOutputArea(aAreaPTwips); + pCurView->SetLOKSpecialVisArea( aVisPTwips ); - pCurView->SetOutputArea(aArea); + bMoveArea = false; + } - // In vertical mode, the whole text is moved to the next cell (right-aligned), - // so everything must be repainted. Otherwise, paint only the new area. - // If growing in centered alignment, if the cells left and right have different sizes, - // the whole text will move, and may not even obscure all of the original display. - if ( bUnevenGrow ) - { - aArea.SetLeft( pWin->PixelToLogic( Point(0,0) ).X() ); - aArea.SetRight( pWin->PixelToLogic( aScrSize ).Width() ); - } - else if ( !bAsianVertical && !bGrowToLeft && !bGrowCentered ) - aArea.SetLeft( nOldRight ); - pWin->Invalidate(aArea); + if (bLOKPrintTwips) + pCurView->SetLOKSpecialOutputArea(aAreaPTwips); + + pCurView->SetOutputArea(aArea); - // invalidate other views - pCurView->InvalidateOtherViewWindows(aArea); + // In vertical mode, the whole text is moved to the next cell (right-aligned), + // so everything must be repainted. Otherwise, paint only the new area. + // If growing in centered alignment, if the cells left and right have different sizes, + // the whole text will move, and may not even obscure all of the original display. + if ( bUnevenGrow ) + { + aArea.SetLeft( pWin->PixelToLogic( Point(0,0) ).X() ); + aArea.SetRight( pWin->PixelToLogic( aScrSize ).Width() ); } + else if ( !bAsianVertical && !bGrowToLeft && !bGrowCentered ) + aArea.SetLeft( nOldRight ); + pWin->Invalidate(aArea); + + // invalidate other views + pCurView->InvalidateOtherViewWindows(aArea); } void ScViewData::EditGrowY( bool bInitial ) @@ -2165,25 +2165,25 @@ void ScViewData::EditGrowY( bool bInitial ) nAllowedExtra = SC_GROWY_SMALL_EXTRA; // larger value is only for first row } - if (bChanged) - { - if (bLOKPrintTwips) - pCurView->SetLOKSpecialOutputArea(aAreaPTwips); - - pCurView->SetOutputArea(aArea); + if (!bChanged) + return; - if (nEditEndRow >= nBottom || bMaxReached) - { - if (!(nControl & EVControlBits::AUTOSCROLL)) - pCurView->SetControlWord( nControl | EVControlBits::AUTOSCROLL ); - } + if (bLOKPrintTwips) + pCurView->SetLOKSpecialOutputArea(aAreaPTwips); - aArea.SetTop( nOldBottom ); - pWin->Invalidate(aArea); + pCurView->SetOutputArea(aArea); - // invalidate other views - pCurView->InvalidateOtherViewWindows(aArea); + if (nEditEndRow >= nBottom || bMaxReached) + { + if (!(nControl & EVControlBits::AUTOSCROLL)) + pCurView->SetControlWord( nControl | EVControlBits::AUTOSCROLL ); } + + aArea.SetTop( nOldBottom ); + pWin->Invalidate(aArea); + + // invalidate other views + pCurView->InvalidateOtherViewWindows(aArea); } void ScViewData::ResetEditView() @@ -2782,31 +2782,31 @@ void ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich, if (rPosY<0) rPosY=0; if (rPosY>pDoc->MaxRow()) rPosY=pDoc->MaxRow(); - if (bTestMerge && bForCurTab) + if (!(bTestMerge && bForCurTab)) + return; + + // public method to adapt position + SCCOL nOrigX = rPosX; + SCROW nOrigY = rPosY; + pDoc->SkipOverlapped(rPosX, rPosY, nTabNo); + bool bHOver = (nOrigX != rPosX); + bool bVOver = (nOrigY != rPosY); + + if ( !(bRepair && ( bHOver || bVOver )) ) + return; + + const ScMergeAttr* pMerge = pDoc->GetAttr( rPosX, rPosY, nTabNo, ATTR_MERGE ); + if ( ( bHOver && pMerge->GetColMerge() <= 1 ) || + ( bVOver && pMerge->GetRowMerge() <= 1 ) ) { - // public method to adapt position - SCCOL nOrigX = rPosX; - SCROW nOrigY = rPosY; - pDoc->SkipOverlapped(rPosX, rPosY, nTabNo); - bool bHOver = (nOrigX != rPosX); - bool bVOver = (nOrigY != rPosY); + OSL_FAIL("merge error found"); - if ( bRepair && ( bHOver || bVOver ) ) - { - const ScMergeAttr* pMerge = pDoc->GetAttr( rPosX, rPosY, nTabNo, ATTR_MERGE ); - if ( ( bHOver && pMerge->GetColMerge() <= 1 ) || - ( bVOver && pMerge->GetRowMerge() <= 1 ) ) - { - OSL_FAIL("merge error found"); - - pDoc->RemoveFlagsTab( 0,0, pDoc->MaxCol(),pDoc->MaxRow(), nTabNo, ScMF::Hor | ScMF::Ver ); - SCCOL nEndCol = pDoc->MaxCol(); - SCROW nEndRow = pDoc->MaxRow(); - pDoc->ExtendMerge( 0,0, nEndCol,nEndRow, nTabNo, true ); - if (pDocShell) - pDocShell->PostPaint( ScRange(0,0,nTabNo,pDoc->MaxCol(),pDoc->MaxRow(),nTabNo), PaintPartFlags::Grid ); - } - } + pDoc->RemoveFlagsTab( 0,0, pDoc->MaxCol(),pDoc->MaxRow(), nTabNo, ScMF::Hor | ScMF::Ver ); + SCCOL nEndCol = pDoc->MaxCol(); + SCROW nEndRow = pDoc->MaxRow(); + pDoc->ExtendMerge( 0,0, nEndCol,nEndRow, nTabNo, true ); + if (pDocShell) + pDocShell->PostPaint( ScRange(0,0,nTabNo,pDoc->MaxCol(),pDoc->MaxRow(),nTabNo), PaintPartFlags::Grid ); } } diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 44ed2045c389..638717d43184 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -917,22 +917,22 @@ void ScViewFunc::EnterBlock( const OUString& rString, const EditTextObject* pDat pInsDoc->SetClipArea( ScRange(aPos) ); // insert Block, with Undo etc. - if ( PasteFromClip( InsertDeleteFlags::CONTENTS, pInsDoc.get(), ScPasteFunc::NONE, false, false, + if ( !PasteFromClip( InsertDeleteFlags::CONTENTS, pInsDoc.get(), ScPasteFunc::NONE, false, false, false, INS_NONE, InsertDeleteFlags::ATTRIB ) ) - { - const SfxUInt32Item* pItem = pInsDoc->GetAttr( - nCol, nRow, nTab, ATTR_VALUE_FORMAT ); - if ( pItem ) - { // set number format if incompatible - // MarkData was already MarkToSimple'ed in PasteFromClip - ScRange aRange; - rMark.GetMarkArea( aRange ); - std::unique_ptr pPattern(new ScPatternAttr( pDoc->GetPool() )); - pPattern->GetItemSet().Put( *pItem ); - SvNumFormatType nNewType = pDoc->GetFormatTable()->GetType( pItem->GetValue() ); - pDoc->ApplyPatternIfNumberformatIncompatible( aRange, rMark, - *pPattern, nNewType ); - } + return; + + const SfxUInt32Item* pItem = pInsDoc->GetAttr( + nCol, nRow, nTab, ATTR_VALUE_FORMAT ); + if ( pItem ) + { // set number format if incompatible + // MarkData was already MarkToSimple'ed in PasteFromClip + ScRange aRange; + rMark.GetMarkArea( aRange ); + std::unique_ptr pPattern(new ScPatternAttr( pDoc->GetPool() )); + pPattern->GetItemSet().Put( *pItem ); + SvNumFormatType nNewType = pDoc->GetFormatTable()->GetType( pItem->GetValue() ); + pDoc->ApplyPatternIfNumberformatIncompatible( aRange, rMark, + *pPattern, nNewType ); } } @@ -1436,41 +1436,42 @@ void ScViewFunc::FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow, const ScMarkData& rMark = GetViewData().GetMarkData(); bool bSuccess = pDocSh->GetDocFunc(). FillAuto( aRange, &rMark, eDir, nCount, false ); - if (bSuccess) - { - MarkRange( aRange, false ); // aRange was modified in FillAuto - pDocSh->UpdateOle(&GetViewData()); - UpdateScrollBars(); + if (!bSuccess) + return; - bool bDoAutoSpell = pDocSh->GetDocument().GetDocOptions().IsAutoSpell(); - if ( bDoAutoSpell ) - CopyAutoSpellData(eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount); + MarkRange( aRange, false ); // aRange was modified in FillAuto + pDocSh->UpdateOle(&GetViewData()); + UpdateScrollBars(); - if (ScModelObj* pModelObj = HelperNotifyChanges::getMustPropagateChangesModel(*pDocSh)) - { - ScRangeList aChangeRanges; - ScRange aChangeRange( aRange ); - switch (eDir) - { - case FILL_TO_BOTTOM: - aChangeRange.aStart.SetRow( aSourceRange.aEnd.Row() + 1 ); - break; - case FILL_TO_TOP: - aChangeRange.aEnd.SetRow( aSourceRange.aStart.Row() - 1 ); - break; - case FILL_TO_RIGHT: - aChangeRange.aStart.SetCol( aSourceRange.aEnd.Col() + 1 ); - break; - case FILL_TO_LEFT: - aChangeRange.aEnd.SetCol( aSourceRange.aStart.Col() - 1 ); - break; - default: - break; - } - aChangeRanges.push_back( aChangeRange ); - HelperNotifyChanges::Notify(*pModelObj, aChangeRanges); - } + bool bDoAutoSpell = pDocSh->GetDocument().GetDocOptions().IsAutoSpell(); + if ( bDoAutoSpell ) + CopyAutoSpellData(eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount); + + ScModelObj* pModelObj = HelperNotifyChanges::getMustPropagateChangesModel(*pDocSh); + if (!pModelObj) + return; + + ScRangeList aChangeRanges; + ScRange aChangeRange( aRange ); + switch (eDir) + { + case FILL_TO_BOTTOM: + aChangeRange.aStart.SetRow( aSourceRange.aEnd.Row() + 1 ); + break; + case FILL_TO_TOP: + aChangeRange.aEnd.SetRow( aSourceRange.aStart.Row() - 1 ); + break; + case FILL_TO_RIGHT: + aChangeRange.aStart.SetCol( aSourceRange.aEnd.Col() + 1 ); + break; + case FILL_TO_LEFT: + aChangeRange.aEnd.SetCol( aSourceRange.aStart.Col() - 1 ); + break; + default: + break; } + aChangeRanges.push_back( aChangeRange ); + HelperNotifyChanges::Notify(*pModelObj, aChangeRanges); } void ScViewFunc::CopyAutoSpellData( FillDir eDir, SCCOL nStartCol, SCROW nStartRow, @@ -1766,34 +1767,34 @@ void ScViewFunc::FillCrossDblClick() bDataFound = (pDoc->HasData( nMovX, nStartY, nTab) && pDoc->HasData( nMovX, nStartY + 1, nTab)); } - if (bDataFound && pDoc->IsBlockEmpty( nTab, nStartX, nEndY + 1, nEndX, nEndY + 1, true)) + if (!(bDataFound && pDoc->IsBlockEmpty( nTab, nStartX, nEndY + 1, nEndX, nEndY + 1, true))) + return; + + // Get end of data left or right. + pDoc->FindAreaPos( nMovX, nMovY, nTab, SC_MOVE_DOWN); + // Find minimum end row of below empty area and data right. + for (SCCOL nX = nStartX; nX <= nEndX; ++nX) { - // Get end of data left or right. - pDoc->FindAreaPos( nMovX, nMovY, nTab, SC_MOVE_DOWN); - // Find minimum end row of below empty area and data right. - for (SCCOL nX = nStartX; nX <= nEndX; ++nX) + SCROW nY = nEndY + 1; + // Get next row with data in this column. + pDoc->FindAreaPos( nX, nY, nTab, SC_MOVE_DOWN); + if (nMovY == pDoc->MaxRow() && nY == pDoc->MaxRow()) { - SCROW nY = nEndY + 1; - // Get next row with data in this column. - pDoc->FindAreaPos( nX, nY, nTab, SC_MOVE_DOWN); - if (nMovY == pDoc->MaxRow() && nY == pDoc->MaxRow()) - { - // FindAreaPos() returns MAXROW also if there is no data at all - // from the start, so check if that contains data if the nearby - // (left or right) data ends there and increment if no data - // here, pretending the next data would be thereafter so nMovY - // will not be decremented. - if (!pDoc->HasData( nX, nY, nTab)) - ++nY; - } - if (nMovY > nY - 1) - nMovY = nY - 1; + // FindAreaPos() returns MAXROW also if there is no data at all + // from the start, so check if that contains data if the nearby + // (left or right) data ends there and increment if no data + // here, pretending the next data would be thereafter so nMovY + // will not be decremented. + if (!pDoc->HasData( nX, nY, nTab)) + ++nY; } + if (nMovY > nY - 1) + nMovY = nY - 1; + } - if (nMovY > nEndY) - { - FillAuto( FILL_TO_BOTTOM, nStartX, nStartY, nEndX, nEndY, nMovY - nEndY); - } + if (nMovY > nEndY) + { + FillAuto( FILL_TO_BOTTOM, nStartX, nStartY, nEndX, nEndY, nMovY - nEndY); } } @@ -2166,71 +2167,71 @@ void ScViewFunc::Solve( const ScSolveParam& rParam ) { ScDocument* pDoc = GetViewData().GetDocument(); - if ( pDoc ) - { - SCCOL nDestCol = rParam.aRefVariableCell.Col(); - SCROW nDestRow = rParam.aRefVariableCell.Row(); - SCTAB nDestTab = rParam.aRefVariableCell.Tab(); - - ScEditableTester aTester( pDoc, nDestTab, nDestCol,nDestRow, nDestCol,nDestRow ); - if (!aTester.IsEditable()) - { - ErrorMessage(aTester.GetMessageId()); - return; - } + if ( !pDoc ) + return; - OUString aTargetValStr; - if ( rParam.pStrTargetVal ) - aTargetValStr = *rParam.pStrTargetVal; + SCCOL nDestCol = rParam.aRefVariableCell.Col(); + SCROW nDestRow = rParam.aRefVariableCell.Row(); + SCTAB nDestTab = rParam.aRefVariableCell.Tab(); - OUString aMsgStr; - OUString aResStr; - double nSolveResult; + ScEditableTester aTester( pDoc, nDestTab, nDestCol,nDestRow, nDestCol,nDestRow ); + if (!aTester.IsEditable()) + { + ErrorMessage(aTester.GetMessageId()); + return; + } - GetFrameWin()->EnterWait(); + OUString aTargetValStr; + if ( rParam.pStrTargetVal ) + aTargetValStr = *rParam.pStrTargetVal; - bool bExact = - pDoc->Solver( - rParam.aRefFormulaCell.Col(), - rParam.aRefFormulaCell.Row(), - rParam.aRefFormulaCell.Tab(), - nDestCol, nDestRow, nDestTab, - aTargetValStr, - nSolveResult ); + OUString aMsgStr; + OUString aResStr; + double nSolveResult; - GetFrameWin()->LeaveWait(); + GetFrameWin()->EnterWait(); - SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); - sal_uLong nFormat = 0; - const ScPatternAttr* pPattern = pDoc->GetPattern( nDestCol, nDestRow, nDestTab ); - if ( pPattern ) - nFormat = pPattern->GetNumberFormat( pFormatter ); - Color* p; - pFormatter->GetOutputString( nSolveResult, nFormat, aResStr, &p ); + bool bExact = + pDoc->Solver( + rParam.aRefFormulaCell.Col(), + rParam.aRefFormulaCell.Row(), + rParam.aRefFormulaCell.Tab(), + nDestCol, nDestRow, nDestTab, + aTargetValStr, + nSolveResult ); - if ( bExact ) - { - aMsgStr += ScResId( STR_MSSG_SOLVE_0 ) + - aResStr + - ScResId( STR_MSSG_SOLVE_1 ); - } - else - { - aMsgStr = ScResId( STR_MSSG_SOLVE_2 ) + - ScResId( STR_MSSG_SOLVE_3 ) + - aResStr + - ScResId( STR_MSSG_SOLVE_4 ); - } + GetFrameWin()->LeaveWait(); - std::unique_ptr xBox(Application::CreateMessageDialog(GetViewData().GetDialogParent(), - VclMessageType::Question, VclButtonsType::YesNo, aMsgStr)); - xBox->set_title(ScResId(STR_MSSG_DOSUBTOTALS_0)); - xBox->set_default_response(RET_NO); - if (xBox->run() == RET_YES) - EnterValue( nDestCol, nDestRow, nDestTab, nSolveResult ); + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + sal_uLong nFormat = 0; + const ScPatternAttr* pPattern = pDoc->GetPattern( nDestCol, nDestRow, nDestTab ); + if ( pPattern ) + nFormat = pPattern->GetNumberFormat( pFormatter ); + Color* p; + pFormatter->GetOutputString( nSolveResult, nFormat, aResStr, &p ); - GetViewData().GetViewShell()->UpdateInputHandler( true ); + if ( bExact ) + { + aMsgStr += ScResId( STR_MSSG_SOLVE_0 ) + + aResStr + + ScResId( STR_MSSG_SOLVE_1 ); + } + else + { + aMsgStr = ScResId( STR_MSSG_SOLVE_2 ) + + ScResId( STR_MSSG_SOLVE_3 ) + + aResStr + + ScResId( STR_MSSG_SOLVE_4 ); } + + std::unique_ptr xBox(Application::CreateMessageDialog(GetViewData().GetDialogParent(), + VclMessageType::Question, VclButtonsType::YesNo, aMsgStr)); + xBox->set_title(ScResId(STR_MSSG_DOSUBTOTALS_0)); + xBox->set_default_response(RET_NO); + if (xBox->run() == RET_YES) + EnterValue( nDestCol, nDestRow, nDestTab, nSolveResult ); + + GetViewData().GetViewShell()->UpdateInputHandler( true ); } // multi operation @@ -2339,19 +2340,19 @@ void ScViewFunc::InsertTables(std::vector& aNames, SCTAB nTab, bFlag = true; } - if (bFlag) - { - if (bRecord) - pDocSh->GetUndoManager()->AddUndoAction( - std::make_unique( pDocSh, nTab, aNames)); + if (!bFlag) + return; - // Update views + if (bRecord) + pDocSh->GetUndoManager()->AddUndoAction( + std::make_unique( pDocSh, nTab, aNames)); - SetTabNo( nTab, true ); - pDocSh->PostPaintExtras(); - pDocSh->SetDocumentModified(); - SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) ); - } + // Update views + + SetTabNo( nTab, true ); + pDocSh->PostPaintExtras(); + pDocSh->SetDocumentModified(); + SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) ); } bool ScViewFunc::AppendTable( const OUString& rName, bool bRecord ) @@ -2413,32 +2414,32 @@ void ScViewFunc::DeleteTables( const SCTAB nTab, SCTAB nSheets ) while ( nNewTab > 0 && !rDoc.IsVisible( nNewTab ) ) --nNewTab; - if (rDoc.DeleteTabs(nTab, nSheets)) + if (!rDoc.DeleteTabs(nTab, nSheets)) + return; + + if( bVbaEnabled ) { - if( bVbaEnabled ) + for (SCTAB aTab = 0; aTab < nSheets; ++aTab) { - for (SCTAB aTab = 0; aTab < nSheets; ++aTab) - { - OUString sCodeName; - bool bHasCodeName = rDoc.GetCodeName( nTab + aTab, sCodeName ); - if ( bHasCodeName ) - VBA_DeleteModule( *pDocSh, sCodeName ); - } + OUString sCodeName; + bool bHasCodeName = rDoc.GetCodeName( nTab + aTab, sCodeName ); + if ( bHasCodeName ) + VBA_DeleteModule( *pDocSh, sCodeName ); } + } - pDocSh->Broadcast( ScTablesHint( SC_TABS_DELETED, nTab, nSheets ) ); - if ( nNewTab >= rDoc.GetTableCount() ) - nNewTab = rDoc.GetTableCount() - 1; - SetTabNo( nNewTab, true ); + pDocSh->Broadcast( ScTablesHint( SC_TABS_DELETED, nTab, nSheets ) ); + if ( nNewTab >= rDoc.GetTableCount() ) + nNewTab = rDoc.GetTableCount() - 1; + SetTabNo( nNewTab, true ); - pDocSh->PostPaintExtras(); - pDocSh->SetDocumentModified(); + pDocSh->PostPaintExtras(); + pDocSh->SetDocumentModified(); - SfxApplication* pSfxApp = SfxGetpApp(); // Navigator - pSfxApp->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) ); - pSfxApp->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) ); - pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) ); - } + SfxApplication* pSfxApp = SfxGetpApp(); // Navigator + pSfxApp->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) ); + pSfxApp->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) ); + pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) ); } bool ScViewFunc::DeleteTables(const vector &TheTabs, bool bRecord ) @@ -2615,29 +2616,29 @@ void ScViewFunc::InsertTableLink( const OUString& rFile, OUString aFilterName = rFilter; OUString aOpt = rOptions; ScDocumentLoader aLoader( rFile, aFilterName, aOpt ); - if (!aLoader.IsError()) + if (aLoader.IsError()) + return; + + ScDocShell* pSrcSh = aLoader.GetDocShell(); + ScDocument& rSrcDoc = pSrcSh->GetDocument(); + SCTAB nTab = MAXTAB+1; + if (rTabName.isEmpty()) // no name given -> first table + nTab = 0; + else { - ScDocShell* pSrcSh = aLoader.GetDocShell(); - ScDocument& rSrcDoc = pSrcSh->GetDocument(); - SCTAB nTab = MAXTAB+1; - if (rTabName.isEmpty()) // no name given -> first table - nTab = 0; - else + OUString aTemp; + SCTAB nCount = rSrcDoc.GetTableCount(); + for (SCTAB i=0; i nTabSelCount) - { - std::vector undoTabs; + if (nVisible <= nTabSelCount) + return; - // need to take a copy of selectedtabs since it is modified in the loop - const ScMarkData::MarkedTabsType selectedTabs = rMark.GetSelectedTabs(); - for (const SCTAB& nTab : selectedTabs) - { - if (rDoc.IsVisible( nTab )) - { - rDoc.SetVisible( nTab, false ); - // Update views - pDocSh->Broadcast( ScTablesHint( SC_TAB_HIDDEN, nTab ) ); - SetTabNo( nTab, true ); - // Store for undo - if (bUndo) - undoTabs.push_back(nTab); - } - } - if (bUndo) + std::vector undoTabs; + + // need to take a copy of selectedtabs since it is modified in the loop + const ScMarkData::MarkedTabsType selectedTabs = rMark.GetSelectedTabs(); + for (const SCTAB& nTab : selectedTabs) + { + if (rDoc.IsVisible( nTab )) { - pDocSh->GetUndoManager()->AddUndoAction( std::make_unique( pDocSh, undoTabs, false ) ); + rDoc.SetVisible( nTab, false ); + // Update views + pDocSh->Broadcast( ScTablesHint( SC_TAB_HIDDEN, nTab ) ); + SetTabNo( nTab, true ); + // Store for undo + if (bUndo) + undoTabs.push_back(nTab); } - - // Update views - SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) ); - pDocSh->PostPaint(0,0,0,rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB, PaintPartFlags::Extras); - pDocSh->SetDocumentModified(); } + if (bUndo) + { + pDocSh->GetUndoManager()->AddUndoAction( std::make_unique( pDocSh, undoTabs, false ) ); + } + + // Update views + SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) ); + pDocSh->PostPaint(0,0,0,rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB, PaintPartFlags::Extras); + pDocSh->SetDocumentModified(); } void ScViewFunc::InsertSpecialChar( const OUString& rStr, const vcl::Font& rFont ) @@ -3234,20 +3235,20 @@ void ScViewFunc::UpdateLineAttrs( SvxBorderLine& rLine, const SvxBorderLine* pSrcLine, bool bColor ) { - if ( pSrcLine && pDestLine ) + if ( !(pSrcLine && pDestLine) ) + return; + + if ( bColor ) { - if ( bColor ) - { - rLine.SetColor ( pSrcLine->GetColor() ); - rLine.SetBorderLineStyle(pDestLine->GetBorderLineStyle()); - rLine.SetWidth ( pDestLine->GetWidth() ); - } - else - { - rLine.SetColor ( pDestLine->GetColor() ); - rLine.SetBorderLineStyle(pSrcLine->GetBorderLineStyle()); - rLine.SetWidth ( pSrcLine->GetWidth() ); - } + rLine.SetColor ( pSrcLine->GetColor() ); + rLine.SetBorderLineStyle(pDestLine->GetBorderLineStyle()); + rLine.SetWidth ( pDestLine->GetWidth() ); + } + else + { + rLine.SetColor ( pDestLine->GetColor() ); + rLine.SetBorderLineStyle(pSrcLine->GetBorderLineStyle()); + rLine.SetWidth ( pSrcLine->GetWidth() ); } } @@ -3292,84 +3293,84 @@ void ScViewFunc::SetSelectionFrameLines( const SvxBorderLine* pLine, SfxItemState eBLTRState = rSelItemSet.GetItemState( ATTR_BORDER_BLTR, true, &pBLTRItem ); // any of the lines visible? - if( (eItemState != SfxItemState::DEFAULT) || (eTLBRState != SfxItemState::DEFAULT) || (eBLTRState != SfxItemState::DEFAULT) ) + if( !((eItemState != SfxItemState::DEFAULT) || (eTLBRState != SfxItemState::DEFAULT) || (eBLTRState != SfxItemState::DEFAULT)) ) + return; + + // none of the lines don't care? + if( (eItemState != SfxItemState::DONTCARE) && (eTLBRState != SfxItemState::DONTCARE) && (eBLTRState != SfxItemState::DONTCARE) ) { - // none of the lines don't care? - if( (eItemState != SfxItemState::DONTCARE) && (eTLBRState != SfxItemState::DONTCARE) && (eBLTRState != SfxItemState::DONTCARE) ) - { - std::unique_ptr pOldSet(new SfxItemSet( - *(pDoc->GetPool()), - svl::Items{} )); - std::unique_ptr pNewSet(new SfxItemSet( - *(pDoc->GetPool()), - svl::Items{} )); + std::unique_ptr pOldSet(new SfxItemSet( + *(pDoc->GetPool()), + svl::Items{} )); + std::unique_ptr pNewSet(new SfxItemSet( + *(pDoc->GetPool()), + svl::Items{} )); - SvxBorderLine aLine; + SvxBorderLine aLine; - if( pBorderAttr ) - { - const SvxBorderLine* pBoxLine = nullptr; - SvxBoxItem aBoxItem( *static_cast(pBorderAttr) ); - SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER ); - - // here pBoxLine is used - SET_LINE_ATTRIBUTES(Top,SvxBoxItemLine::TOP) - SET_LINE_ATTRIBUTES(Bottom,SvxBoxItemLine::BOTTOM) - SET_LINE_ATTRIBUTES(Left,SvxBoxItemLine::LEFT) - SET_LINE_ATTRIBUTES(Right,SvxBoxItemLine::RIGHT) - - aBoxInfoItem.SetLine( aBoxItem.GetTop(), SvxBoxInfoItemLine::HORI ); - aBoxInfoItem.SetLine( aBoxItem.GetLeft(), SvxBoxInfoItemLine::VERT ); - aBoxInfoItem.ResetFlags(); // set Lines to Valid - - pOldSet->Put( *pBorderAttr ); - pNewSet->Put( aBoxItem ); - pNewSet->Put( aBoxInfoItem ); - } + if( pBorderAttr ) + { + const SvxBorderLine* pBoxLine = nullptr; + SvxBoxItem aBoxItem( *static_cast(pBorderAttr) ); + SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER ); - if( pTLBRItem && static_cast(pTLBRItem)->GetLine() ) - { - SvxLineItem aTLBRItem( *static_cast(pTLBRItem) ); - UpdateLineAttrs( aLine, aTLBRItem.GetLine(), pLine, bColorOnly ); - aTLBRItem.SetLine( &aLine ); - pOldSet->Put( *pTLBRItem ); - pNewSet->Put( aTLBRItem ); - } + // here pBoxLine is used + SET_LINE_ATTRIBUTES(Top,SvxBoxItemLine::TOP) + SET_LINE_ATTRIBUTES(Bottom,SvxBoxItemLine::BOTTOM) + SET_LINE_ATTRIBUTES(Left,SvxBoxItemLine::LEFT) + SET_LINE_ATTRIBUTES(Right,SvxBoxItemLine::RIGHT) - if( pBLTRItem && static_cast(pBLTRItem)->GetLine() ) - { - SvxLineItem aBLTRItem( *static_cast(pBLTRItem) ); - UpdateLineAttrs( aLine, aBLTRItem.GetLine(), pLine, bColorOnly ); - aBLTRItem.SetLine( &aLine ); - pOldSet->Put( *pBLTRItem ); - pNewSet->Put( aBLTRItem ); - } + aBoxInfoItem.SetLine( aBoxItem.GetTop(), SvxBoxInfoItemLine::HORI ); + aBoxInfoItem.SetLine( aBoxItem.GetLeft(), SvxBoxInfoItemLine::VERT ); + aBoxInfoItem.ResetFlags(); // set Lines to Valid - ApplyAttributes( pNewSet.get(), pOldSet.get() ); + pOldSet->Put( *pBorderAttr ); + pNewSet->Put( aBoxItem ); + pNewSet->Put( aBoxInfoItem ); } - else // if ( eItemState == SfxItemState::DONTCARE ) + + if( pTLBRItem && static_cast(pTLBRItem)->GetLine() ) { - aFuncMark.MarkToMulti(); - pDoc->ApplySelectionLineStyle( aFuncMark, pLine, bColorOnly ); + SvxLineItem aTLBRItem( *static_cast(pTLBRItem) ); + UpdateLineAttrs( aLine, aTLBRItem.GetLine(), pLine, bColorOnly ); + aTLBRItem.SetLine( &aLine ); + pOldSet->Put( *pTLBRItem ); + pNewSet->Put( aTLBRItem ); } - ScRange aMarkRange; - aFuncMark.GetMultiMarkArea( aMarkRange ); - SCCOL nStartCol = aMarkRange.aStart.Col(); - SCROW nStartRow = aMarkRange.aStart.Row(); - SCTAB nStartTab = aMarkRange.aStart.Tab(); - SCCOL nEndCol = aMarkRange.aEnd.Col(); - SCROW nEndRow = aMarkRange.aEnd.Row(); - SCTAB nEndTab = aMarkRange.aEnd.Tab(); - pDocSh->PostPaint( nStartCol, nStartRow, nStartTab, - nEndCol, nEndRow, nEndTab, - PaintPartFlags::Grid, SC_PF_LINES | SC_PF_TESTMERGE ); + if( pBLTRItem && static_cast(pBLTRItem)->GetLine() ) + { + SvxLineItem aBLTRItem( *static_cast(pBLTRItem) ); + UpdateLineAttrs( aLine, aBLTRItem.GetLine(), pLine, bColorOnly ); + aBLTRItem.SetLine( &aLine ); + pOldSet->Put( *pBLTRItem ); + pNewSet->Put( aBLTRItem ); + } - pDocSh->UpdateOle( &GetViewData() ); - pDocSh->SetDocumentModified(); + ApplyAttributes( pNewSet.get(), pOldSet.get() ); + } + else // if ( eItemState == SfxItemState::DONTCARE ) + { + aFuncMark.MarkToMulti(); + pDoc->ApplySelectionLineStyle( aFuncMark, pLine, bColorOnly ); } + + ScRange aMarkRange; + aFuncMark.GetMultiMarkArea( aMarkRange ); + SCCOL nStartCol = aMarkRange.aStart.Col(); + SCROW nStartRow = aMarkRange.aStart.Row(); + SCTAB nStartTab = aMarkRange.aStart.Tab(); + SCCOL nEndCol = aMarkRange.aEnd.Col(); + SCROW nEndRow = aMarkRange.aEnd.Row(); + SCTAB nEndTab = aMarkRange.aEnd.Tab(); + pDocSh->PostPaint( nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab, + PaintPartFlags::Grid, SC_PF_LINES | SC_PF_TESTMERGE ); + + pDocSh->UpdateOle( &GetViewData() ); + pDocSh->SetDocumentModified(); } #undef SET_LINE_ATTRIBUTES diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 179d580e4a81..a1e3051562fb 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -1956,70 +1956,70 @@ void ScViewFunc::DataFormPutData( SCROW nCurrentRow , ScMarkData& rMark = GetViewData().GetMarkData(); ScDocShellModificator aModificator( *pDocSh ); SfxUndoManager* pUndoMgr = pDocSh->GetUndoManager(); - if ( pDoc ) - { - const bool bRecord( pDoc->IsUndoEnabled()); - ScDocumentUniquePtr pUndoDoc; - ScDocumentUniquePtr pRedoDoc; - std::unique_ptr pUndoData; - SCTAB nTab = GetViewData().GetTabNo(); - SCTAB nStartTab = nTab; - SCTAB nEndTab = nTab; + if ( !pDoc ) + return; - { - ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); - if ( pChangeTrack ) - pChangeTrack->ResetLastCut(); // no more cut-mode - } - ScRange aUserRange( nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab ); - bool bColInfo = ( nStartRow==0 && nEndRow==pDoc->MaxRow() ); - bool bRowInfo = ( nStartCol==0 && nEndCol==pDoc->MaxCol() ); - SCCOL nUndoEndCol = nStartCol+aColLength-1; - SCROW nUndoEndRow = nCurrentRow; + const bool bRecord( pDoc->IsUndoEnabled()); + ScDocumentUniquePtr pUndoDoc; + ScDocumentUniquePtr pRedoDoc; + std::unique_ptr pUndoData; + SCTAB nTab = GetViewData().GetTabNo(); + SCTAB nStartTab = nTab; + SCTAB nEndTab = nTab; - if ( bRecord ) - { - pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); - pUndoDoc->InitUndoSelected( pDoc , rMark , bColInfo , bRowInfo ); - pDoc->CopyToDocument( aUserRange , InsertDeleteFlags::VALUE , false, *pUndoDoc ); - } - sal_uInt16 nExtFlags = 0; - pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab , nEndCol, nEndRow, nEndTab ); // content before the change - pDoc->BeginDrawUndo(); + { + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->ResetLastCut(); // no more cut-mode + } + ScRange aUserRange( nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab ); + bool bColInfo = ( nStartRow==0 && nEndRow==pDoc->MaxRow() ); + bool bRowInfo = ( nStartCol==0 && nEndCol==pDoc->MaxCol() ); + SCCOL nUndoEndCol = nStartCol+aColLength-1; + SCROW nUndoEndRow = nCurrentRow; - for(sal_uInt16 i = 0; i < aColLength; i++) - { - if (rEdits[i] != nullptr) - { - OUString aFieldName = rEdits[i]->m_xEdit->get_text(); - pDoc->SetString( nStartCol + i, nCurrentRow, nTab, aFieldName ); - } - } - pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab ); // content after the change - std::unique_ptr pUndo( new ScUndoDataForm( pDocSh, - nStartCol, nCurrentRow, nStartTab, - nUndoEndCol, nUndoEndRow, nEndTab, rMark, - std::move(pUndoDoc), std::move(pRedoDoc), - std::move(pUndoData) ) ); - pUndoMgr->AddUndoAction( std::make_unique( std::move(pUndo) ), true ); - - PaintPartFlags nPaint = PaintPartFlags::Grid; - if (bColInfo) - { - nPaint |= PaintPartFlags::Top; - nUndoEndCol = pDoc->MaxCol(); // just for drawing ! - } - if (bRowInfo) + if ( bRecord ) + { + pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); + pUndoDoc->InitUndoSelected( pDoc , rMark , bColInfo , bRowInfo ); + pDoc->CopyToDocument( aUserRange , InsertDeleteFlags::VALUE , false, *pUndoDoc ); + } + sal_uInt16 nExtFlags = 0; + pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab , nEndCol, nEndRow, nEndTab ); // content before the change + pDoc->BeginDrawUndo(); + + for(sal_uInt16 i = 0; i < aColLength; i++) + { + if (rEdits[i] != nullptr) { - nPaint |= PaintPartFlags::Left; - nUndoEndRow = pDoc->MaxRow(); // just for drawing ! + OUString aFieldName = rEdits[i]->m_xEdit->get_text(); + pDoc->SetString( nStartCol + i, nCurrentRow, nTab, aFieldName ); } + } + pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab ); // content after the change + std::unique_ptr pUndo( new ScUndoDataForm( pDocSh, + nStartCol, nCurrentRow, nStartTab, + nUndoEndCol, nUndoEndRow, nEndTab, rMark, + std::move(pUndoDoc), std::move(pRedoDoc), + std::move(pUndoData) ) ); + pUndoMgr->AddUndoAction( std::make_unique( std::move(pUndo) ), true ); - pDocSh->PostPaint( - ScRange(nStartCol, nCurrentRow, nStartTab, nUndoEndCol, nUndoEndRow, nEndTab), - nPaint, nExtFlags); - pDocSh->UpdateOle(&GetViewData()); + PaintPartFlags nPaint = PaintPartFlags::Grid; + if (bColInfo) + { + nPaint |= PaintPartFlags::Top; + nUndoEndCol = pDoc->MaxCol(); // just for drawing ! + } + if (bRowInfo) + { + nPaint |= PaintPartFlags::Left; + nUndoEndRow = pDoc->MaxRow(); // just for drawing ! } + + pDocSh->PostPaint( + ScRange(nStartCol, nCurrentRow, nStartTab, nUndoEndCol, nUndoEndRow, nEndTab), + nPaint, nExtFlags); + pDocSh->UpdateOle(&GetViewData()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx index 16a85889656e..d9c664ee3e23 100644 --- a/sc/source/ui/view/viewfun6.cxx +++ b/sc/source/ui/view/viewfun6.cxx @@ -487,36 +487,38 @@ void ScViewFunc::EditNote() // generated undo action is processed in FuText::StopEditMode // get existing note or create a new note (including caption drawing object) - if( ScPostIt* pNote = rDoc.GetOrCreateNote( aPos ) ) + ScPostIt* pNote = rDoc.GetOrCreateNote( aPos ); + if(!pNote) + return; + + // hide temporary note caption + HideNoteMarker(); + // show caption object without changing internal visibility state + pNote->ShowCaptionTemp( aPos ); + + /* Drawing object has been created in ScDocument::GetOrCreateNote() or + in ScPostIt::ShowCaptionTemp(), so ScPostIt::GetCaption() should + return a caption object. */ + SdrCaptionObj* pCaption = pNote->GetCaption(); + if( !pCaption ) + return; + + if ( ScDrawView* pScDrawView = GetScDrawView() ) + pScDrawView->SyncForGrid( pCaption ); + // #i33764# enable the resize handles before starting edit mode + if( FuPoor* pDraw = GetDrawFuncPtr() ) + static_cast< FuSelection* >( pDraw )->ActivateNoteHandles( pCaption ); + + // activate object (as in FuSelection::TestComment) + GetViewData().GetDispatcher().Execute( SID_DRAW_NOTEEDIT, SfxCallMode::SYNCHRON | SfxCallMode::RECORD ); + // now get the created FuText and set into EditMode + FuText* pFuText = dynamic_cast(GetDrawFuncPtr()); + if (pFuText) { - // hide temporary note caption - HideNoteMarker(); - // show caption object without changing internal visibility state - pNote->ShowCaptionTemp( aPos ); + ScrollToObject( pCaption ); // make object fully visible + pFuText->SetInEditMode( pCaption ); - /* Drawing object has been created in ScDocument::GetOrCreateNote() or - in ScPostIt::ShowCaptionTemp(), so ScPostIt::GetCaption() should - return a caption object. */ - if( SdrCaptionObj* pCaption = pNote->GetCaption() ) - { - if ( ScDrawView* pScDrawView = GetScDrawView() ) - pScDrawView->SyncForGrid( pCaption ); - // #i33764# enable the resize handles before starting edit mode - if( FuPoor* pDraw = GetDrawFuncPtr() ) - static_cast< FuSelection* >( pDraw )->ActivateNoteHandles( pCaption ); - - // activate object (as in FuSelection::TestComment) - GetViewData().GetDispatcher().Execute( SID_DRAW_NOTEEDIT, SfxCallMode::SYNCHRON | SfxCallMode::RECORD ); - // now get the created FuText and set into EditMode - FuText* pFuText = dynamic_cast(GetDrawFuncPtr()); - if (pFuText) - { - ScrollToObject( pCaption ); // make object fully visible - pFuText->SetInEditMode( pCaption ); - - ScTabView::OnLOKNoteStateChanged( pNote ); - } - } + ScTabView::OnLOKNoteStateChanged( pNote ); } } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index bf9d926acd97..1dd68e6aadff 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -596,35 +596,35 @@ void ScViewFunc::EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& r ScDocument* pDoc = GetViewData().GetDocument(); ScDocShell* pDocSh = GetViewData().GetDocShell(); - if ( pDoc && pDocSh ) - { - bool bUndo(pDoc->IsUndoEnabled()); - ScDocShellModificator aModificator( *pDocSh ); + if ( !(pDoc && pDocSh) ) + return; - ScEditableTester aTester( pDoc, nTab, nCol,nRow, nCol,nRow ); - if (aTester.IsEditable()) - { - ScAddress aPos( nCol, nRow, nTab ); - ScCellValue aUndoCell; - if (bUndo) - aUndoCell.assign(*pDoc, aPos); + bool bUndo(pDoc->IsUndoEnabled()); + ScDocShellModificator aModificator( *pDocSh ); - pDoc->SetValue( nCol, nRow, nTab, rValue ); + ScEditableTester aTester( pDoc, nTab, nCol,nRow, nCol,nRow ); + if (aTester.IsEditable()) + { + ScAddress aPos( nCol, nRow, nTab ); + ScCellValue aUndoCell; + if (bUndo) + aUndoCell.assign(*pDoc, aPos); - // because of ChangeTrack after change in document - if (bUndo) - { - pDocSh->GetUndoManager()->AddUndoAction( - std::make_unique(pDocSh, aPos, aUndoCell, rValue)); - } + pDoc->SetValue( nCol, nRow, nTab, rValue ); - pDocSh->PostPaintCell( aPos ); - pDocSh->UpdateOle(&GetViewData()); - aModificator.SetDocumentModified(); + // because of ChangeTrack after change in document + if (bUndo) + { + pDocSh->GetUndoManager()->AddUndoAction( + std::make_unique(pDocSh, aPos, aUndoCell, rValue)); } - else - ErrorMessage(aTester.GetMessageId()); + + pDocSh->PostPaintCell( aPos ); + pDocSh->UpdateOle(&GetViewData()); + aModificator.SetDocumentModified(); } + else + ErrorMessage(aTester.GetMessageId()); } void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, @@ -2301,26 +2301,27 @@ void ScViewFunc::SetWidthOrHeight( aModificator.SetDocumentModified(); } - if ( bWidth ) + if ( !bWidth ) + return; + + ScModelObj* pModelObj = HelperNotifyChanges::getMustPropagateChangesModel(*pDocSh); + if (!pModelObj) + return; + + ScRangeList aChangeRanges; + for (const SCTAB& nTab : aMarkData) { - if (ScModelObj* pModelObj = HelperNotifyChanges::getMustPropagateChangesModel(*pDocSh)) + for (const sc::ColRowSpan & rRange : rRanges) { - ScRangeList aChangeRanges; - for (const SCTAB& nTab : aMarkData) + SCCOL nStartCol = rRange.mnStart; + SCCOL nEndCol = rRange.mnEnd; + for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol ) { - for (const sc::ColRowSpan & rRange : rRanges) - { - SCCOL nStartCol = rRange.mnStart; - SCCOL nEndCol = rRange.mnEnd; - for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol ) - { - aChangeRanges.push_back( ScRange( nCol, 0, nTab ) ); - } - } + aChangeRanges.push_back( ScRange( nCol, 0, nTab ) ); } - HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "column-resize"); } } + HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "column-resize"); } // column width/row height (via marked range) -- cgit