diff options
author | Dennis Francis <dennis.francis@collabora.com> | 2020-07-15 15:55:45 +0530 |
---|---|---|
committer | Dennis Francis <dennis.francis@collabora.com> | 2020-07-24 15:21:31 +0200 |
commit | 15856609795c57861dc950b93250fab953c3cb92 (patch) | |
tree | f1e46eb2ccce4534328aefcba67f89a35011fe82 /sc/source/ui/view/viewdata.cxx | |
parent | 1e96228637bd547636fb9084f938c1f822965c19 (diff) |
lok-freezepanes: Generalize FreezePanes* uno-commands...
to allow an integer parameter as the row/column index of the freeze and
use them to set/get freeze indices (row/column) from the lok clients.
The behaviour of the exisiting freeze/split-panes controls in desktop
Calc is not affected, but new menu/notebookbar options can be added for
freezing on a specific row/column in a follow-up commit.
For now, the freeze-panes are shared between all views for each tab of
the spreadsheet. "Private" freeze-panes support can also be added
without much difficulty (for this we need another uno command for the
private/shared flag, but that can be in a separate commit).
Notes regarding compatibility:
Since Online-Calc has support only for the freeze-panes functionality
presently, any pre-exisiting 'real splits' in the spreadsheet (created
using the native-desktop Calc or alternatives) are converted to
equivalent 'freezes' on import, but on export, such 'freezes' are
re-converted and written as 'real splits'. In case the spreadsheet has
'freezes' on import, they are used/exported as such. In short, the type
of sheet-window splits in the document is preserved.
Change-Id: Ia990616f5cedfb2b5db820770c17ec7e209f0e48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99352
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'sc/source/ui/view/viewdata.cxx')
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 289 |
1 files changed, 246 insertions, 43 deletions
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 6632e51ee918..8fd1d557c441 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -520,29 +520,43 @@ void ScViewDataTable::InitData(ScDocument *pDoc) aHeightHelper.setDocument(pDoc, false); } -void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings, const ScViewData& rViewData) const +void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings, const ScViewData& rViewData, SCTAB nTab) const { rSettings.realloc(SC_TABLE_VIEWSETTINGS_COUNT); beans::PropertyValue* pSettings = rSettings.getArray(); + ScSplitMode eExHSplitMode = eHSplitMode; + ScSplitMode eExVSplitMode = eVSplitMode; + SCCOL nExFixPosX = nFixPosX; + SCROW nExFixPosY = nFixPosY; + long nExHSplitPos = nHSplitPos; + long nExVSplitPos = nVSplitPos; + + if (comphelper::LibreOfficeKit::isActive()) + { + rViewData.OverrideWithLOKFreeze(eExHSplitMode, eExVSplitMode, + nExFixPosX, nExFixPosY, + nExHSplitPos, nExVSplitPos, nTab); + } + pSettings[SC_CURSOR_X].Name = SC_CURSORPOSITIONX; pSettings[SC_CURSOR_X].Value <<= sal_Int32(nCurX); pSettings[SC_CURSOR_Y].Name = SC_CURSORPOSITIONY; pSettings[SC_CURSOR_Y].Value <<= sal_Int32(nCurY); pSettings[SC_HORIZONTAL_SPLIT_MODE].Name = SC_HORIZONTALSPLITMODE; - pSettings[SC_HORIZONTAL_SPLIT_MODE].Value <<= sal_Int16(eHSplitMode); + pSettings[SC_HORIZONTAL_SPLIT_MODE].Value <<= sal_Int16(eExHSplitMode); pSettings[SC_VERTICAL_SPLIT_MODE].Name = SC_VERTICALSPLITMODE; - pSettings[SC_VERTICAL_SPLIT_MODE].Value <<= sal_Int16(eVSplitMode); + pSettings[SC_VERTICAL_SPLIT_MODE].Value <<= sal_Int16(eExVSplitMode); pSettings[SC_HORIZONTAL_SPLIT_POSITION].Name = SC_HORIZONTALSPLITPOSITION; - if (eHSplitMode == SC_SPLIT_FIX) - pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nFixPosX); + if (eExHSplitMode == SC_SPLIT_FIX) + pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nExFixPosX); else - pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nHSplitPos); + pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nExHSplitPos); pSettings[SC_VERTICAL_SPLIT_POSITION].Name = SC_VERTICALSPLITPOSITION; - if (eVSplitMode == SC_SPLIT_FIX) - pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nFixPosY); + if (eExVSplitMode == SC_SPLIT_FIX) + pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nExFixPosY); else - pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nVSplitPos); + pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nExVSplitPos); // Prevent writing odd settings that would make crash versions that // don't apply SanitizeWhichActive() when reading the settings. // See tdf#117093 @@ -1325,14 +1339,32 @@ void ScViewData::ResetOldCursor() pThisTab->mbOldCursorValid = false; } -SCCOL ScViewData::GetPosX( ScHSplitPos eWhich ) const +SCCOL ScViewData::GetPosX( ScHSplitPos eWhich, SCTAB nForTab ) const { - return comphelper::LibreOfficeKit::isActive() ? 0 : pThisTab->nPosX[eWhich]; + if (comphelper::LibreOfficeKit::isActive()) + return 0; + + if (nForTab == -1) + return pThisTab->nPosX[eWhich]; + + if (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size()))) + return -1; + + return maTabData[nForTab]->nPosX[eWhich]; } -SCROW ScViewData::GetPosY( ScVSplitPos eWhich ) const +SCROW ScViewData::GetPosY( ScVSplitPos eWhich, SCTAB nForTab ) const { - return comphelper::LibreOfficeKit::isActive() ? 0 : pThisTab->nPosY[eWhich]; + if (comphelper::LibreOfficeKit::isActive()) + return 0; + + if (nForTab == -1) + return pThisTab->nPosY[eWhich]; + + if (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size()))) + return -1; + + return maTabData[nForTab]->nPosY[eWhich]; } SCCOL ScViewData::GetCurXForTab( SCTAB nTabIndex ) const @@ -2283,7 +2315,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScVSplitPos eWhich ) } Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, - bool bAllowNeg ) const + bool bAllowNeg, SCTAB nForTab ) const { ScHSplitPos eWhichX = SC_SPLIT_LEFT; ScVSplitPos eWhichY = SC_SPLIT_BOTTOM; @@ -2307,6 +2339,18 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, break; } + if (nForTab == -1) + nForTab = nTabNo; + bool bForCurTab = (nForTab == nTabNo); + if (!bForCurTab && (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size())))) + { + SAL_WARN("sc.viewdata", "ScViewData::GetScrPos : invalid nForTab = " << nForTab); + nForTab = nTabNo; + bForCurTab = true; + } + + ScViewDataTable* pViewTable = bForCurTab ? pThisTab : maTabData[nForTab].get(); + if (pView) { const_cast<ScViewData*>(this)->aScrSize.setWidth( pView->GetGridWidth(eWhichX) ); @@ -2317,7 +2361,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive(); - SCCOL nPosX = GetPosX(eWhichX); + SCCOL nPosX = GetPosX(eWhichX, nForTab); long nScrPosX = 0; if (bAllowNeg || nWhereX >= nPosX) @@ -2326,7 +2370,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, if (bIsTiledRendering) { OSL_ENSURE(nPosX == 0, "Unsupported case."); - const auto& rNearest = pThisTab->aWidthHelper.getNearestByIndex(nWhereX - 1); + const auto& rNearest = pViewTable->aWidthHelper.getNearestByIndex(nWhereX - 1); nStartPosX = rNearest.first + 1; nScrPosX = rNearest.second; } @@ -2339,7 +2383,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, nScrPosX = 0x7FFFFFFF; else { - nTSize = pDoc->GetColWidth( nX, nTabNo ); + nTSize = pDoc->GetColWidth( nX, nForTab ); if (nTSize) { long nSizeXPix = ToPixel( nTSize, nPPTX ); @@ -2353,7 +2397,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, for (SCCOL nX = nStartPosX; nX > nWhereX;) { --nX; - nTSize = pDoc->GetColWidth( nX, nTabNo ); + nTSize = pDoc->GetColWidth( nX, nForTab ); if (nTSize) { long nSizeXPix = ToPixel( nTSize, nPPTX ); @@ -2365,7 +2409,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, } - SCROW nPosY = GetPosY(eWhichY); + SCROW nPosY = GetPosY(eWhichY, nForTab); long nScrPosY = 0; if (bAllowNeg || nWhereY >= nPosY) @@ -2374,7 +2418,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, if (bIsTiledRendering) { OSL_ENSURE(nPosY == 0, "Unsupported case."); - const auto& rNearest = pThisTab->aHeightHelper.getNearestByIndex(nWhereY - 1); + const auto& rNearest = pViewTable->aHeightHelper.getNearestByIndex(nWhereY - 1); nStartPosY = rNearest.first + 1; nScrPosY = rNearest.second; } @@ -2387,13 +2431,13 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, nScrPosY = 0x7FFFFFFF; else if (bAllowNeg || bIsTiledRendering) { - sal_uLong nSizeYPix = pDoc->GetScaledRowHeight( nStartPosY, nWhereY-1, nTabNo, nPPTY ); + sal_uLong nSizeYPix = pDoc->GetScaledRowHeight( nStartPosY, nWhereY-1, nForTab, nPPTY ); nScrPosY += nSizeYPix; } else { sal_uLong nMaxHeight = aScrSize.getHeight() - nScrPosY; - sal_uLong nSizeYPix = pDoc->GetScaledRowHeight( nStartPosY, nWhereY-1, nTabNo, nPPTY, &nMaxHeight ); + sal_uLong nSizeYPix = pDoc->GetScaledRowHeight( nStartPosY, nWhereY-1, nForTab, nPPTY, &nMaxHeight ); nScrPosY += nSizeYPix; } } @@ -2403,7 +2447,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, for (SCROW nY = nStartPosY; nY > nWhereY;) { --nY; - nTSize = pDoc->GetRowHeight( nY, nTabNo ); + nTSize = pDoc->GetRowHeight( nY, nForTab ); if (nTSize) { long nSizeYPix = ToPixel( nTSize, nPPTY ); @@ -2413,7 +2457,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, } } - if ( pDoc->IsLayoutRTL( nTabNo ) ) + if ( pDoc->IsLayoutRTL( nForTab ) ) { // mirror horizontal position nScrPosX = aScrSize.Width() - 1 - nScrPosX; @@ -2653,14 +2697,24 @@ bool ScViewData::GetMergeSizePrintTwips(SCCOL nX, SCROW nY, long& rSizeXTwips, l void ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich, SCCOL& rPosX, SCROW& rPosY, - bool bTestMerge, bool bRepair ) + bool bTestMerge, bool bRepair, SCTAB nForTab ) { // special handling of 0 is now in ScViewFunctionSet::SetCursorAtPoint + if (nForTab == -1) + nForTab = nTabNo; + bool bForCurTab = (nForTab == nTabNo); + if (!bForCurTab && (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size())))) + { + SAL_WARN("sc.viewdata", "ScViewData::GetPosFromPixel : invalid nForTab = " << nForTab); + nForTab = nTabNo; + bForCurTab = true; + } + ScHSplitPos eHWhich = WhichH(eWhich); ScVSplitPos eVWhich = WhichV(eWhich); - if ( pDoc->IsLayoutRTL( nTabNo ) ) + if ( pDoc->IsLayoutRTL( nForTab ) ) { // mirror horizontal position if (pView) @@ -2668,8 +2722,8 @@ void ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich, nClickX = aScrSize.Width() - 1 - nClickX; } - SCCOL nStartPosX = GetPosX(eHWhich); - SCROW nStartPosY = GetPosY(eVWhich); + SCCOL nStartPosX = GetPosX(eHWhich, nForTab); + SCROW nStartPosY = GetPosY(eVWhich, nForTab); rPosX = nStartPosX; rPosY = nStartPosY; long nScrX = 0; @@ -2679,7 +2733,7 @@ void ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich, { while ( rPosX<=pDoc->MaxCol() && nClickX >= nScrX ) { - nScrX += ToPixel( pDoc->GetColWidth( rPosX, nTabNo ), nPPTX ); + nScrX += ToPixel( pDoc->GetColWidth( rPosX, nForTab ), nPPTX ); ++rPosX; } --rPosX; @@ -2689,19 +2743,19 @@ void ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich, while ( rPosX>0 && nClickX < nScrX ) { --rPosX; - nScrX -= ToPixel( pDoc->GetColWidth( rPosX, nTabNo ), nPPTX ); + nScrX -= ToPixel( pDoc->GetColWidth( rPosX, nForTab ), nPPTX ); } } if (nClickY > 0) - AddPixelsWhile( nScrY, nClickY, rPosY, pDoc->MaxRow(), nPPTY, pDoc, nTabNo ); + AddPixelsWhile( nScrY, nClickY, rPosY, pDoc->MaxRow(), nPPTY, pDoc, nForTab ); else { /* TODO: could need some "SubPixelsWhileBackward" method */ while ( rPosY>0 && nClickY < nScrY ) { --rPosY; - nScrY -= ToPixel( pDoc->GetRowHeight( rPosY, nTabNo ), nPPTY ); + nScrY -= ToPixel( pDoc->GetRowHeight( rPosY, nForTab ), nPPTY ); } } @@ -2726,7 +2780,7 @@ void ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich, if (rPosY<0) rPosY=0; if (rPosY>pDoc->MaxRow()) rPosY=pDoc->MaxRow(); - if (bTestMerge) + if (bTestMerge && bForCurTab) { // public method to adapt position SCCOL nOrigX = rPosX; @@ -3283,6 +3337,8 @@ void ScViewData::WriteExtOptions( ScExtDocOptions& rDocOpt ) const if( rDocSett.mfTabBarWidth < 0.0 ) rDocSett.mfTabBarWidth = ScTabView::GetRelTabBarWidth(); + bool bLOKActive = comphelper::LibreOfficeKit::isActive(); + // sheet settings for( SCTAB nTab = 0; nTab < static_cast<SCTAB>(maTabData.size()); ++nTab ) { @@ -3291,12 +3347,24 @@ void ScViewData::WriteExtOptions( ScExtDocOptions& rDocOpt ) const ScExtTabSettings& rTabSett = rDocOpt.GetOrCreateTabSettings( nTab ); // split mode - ScSplitMode eHSplit = pViewTab->eHSplitMode; - ScSplitMode eVSplit = pViewTab->eVSplitMode; - bool bHSplit = eHSplit != SC_SPLIT_NONE; - bool bVSplit = eVSplit != SC_SPLIT_NONE; - bool bRealSplit = (eHSplit == SC_SPLIT_NORMAL) || (eVSplit == SC_SPLIT_NORMAL); - bool bFrozen = (eHSplit == SC_SPLIT_FIX) || (eVSplit == SC_SPLIT_FIX); + ScSplitMode eExHSplit = pViewTab->eHSplitMode; + ScSplitMode eExVSplit = pViewTab->eVSplitMode; + SCCOL nExFixPosX = pViewTab->nFixPosX; + SCROW nExFixPosY = pViewTab->nFixPosY; + long nExHSplitPos = pViewTab->nHSplitPos; + long nExVSplitPos = pViewTab->nVSplitPos; + + if (bLOKActive) + { + OverrideWithLOKFreeze(eExHSplit, eExVSplit, + nExFixPosX, nExFixPosY, + nExHSplitPos, nExVSplitPos, nTab); + } + + bool bHSplit = eExHSplit != SC_SPLIT_NONE; + bool bVSplit = eExVSplit != SC_SPLIT_NONE; + bool bRealSplit = (eExHSplit == SC_SPLIT_NORMAL) || (eExVSplit == SC_SPLIT_NORMAL); + bool bFrozen = (eExHSplit == SC_SPLIT_FIX) || (eExVSplit == SC_SPLIT_FIX); OSL_ENSURE( !bRealSplit || !bFrozen, "ScViewData::WriteExtOptions - split and freeze in same sheet" ); rTabSett.mbFrozenPanes = !bRealSplit && bFrozen; @@ -3306,15 +3374,15 @@ void ScViewData::WriteExtOptions( ScExtDocOptions& rDocOpt ) const if( bRealSplit ) { Point& rSplitPos = rTabSett.maSplitPos; - rSplitPos = Point( bHSplit ? pViewTab->nHSplitPos : 0, bVSplit ? pViewTab->nVSplitPos : 0 ); + rSplitPos = Point( bHSplit ? nExHSplitPos : 0, bVSplit ? nExVSplitPos : 0 ); rSplitPos = Application::GetDefaultDevice()->PixelToLogic( rSplitPos, MapMode( MapUnit::MapTwip ) ); if( pDocShell ) rSplitPos.setX( static_cast<long>(static_cast<double>(rSplitPos.X()) / pDocShell->GetOutputFactor()) ); } else if( bFrozen ) { - if( bHSplit ) rTabSett.maFreezePos.SetCol( pViewTab->nFixPosX ); - if( bVSplit ) rTabSett.maFreezePos.SetRow( pViewTab->nFixPosY ); + if( bHSplit ) rTabSett.maFreezePos.SetCol( nExFixPosX ); + if( bVSplit ) rTabSett.maFreezePos.SetRow( nExFixPosY ); } // first visible cell in top-left and additional panes @@ -3533,6 +3601,9 @@ void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt ) } } + if (comphelper::LibreOfficeKit::isActive()) + DeriveLOKFreezeAllSheets(); + // RecalcPixPos or so - also nMPos - also for ReadUserData ??!?! } @@ -3553,7 +3624,7 @@ void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSe if (maTabData[nTab]) { uno::Sequence <beans::PropertyValue> aTableViewSettings; - maTabData[nTab]->WriteUserDataSequence(aTableViewSettings, *this); + maTabData[nTab]->WriteUserDataSequence(aTableViewSettings, *this, nTab); OUString sTabName; GetDocument()->GetName( nTab, sTabName ); try @@ -3805,6 +3876,9 @@ void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue> // #i47426# write view options to document, needed e.g. for Excel export pDoc->SetViewOptions( *pOptions ); + + if (comphelper::LibreOfficeKit::isActive()) + DeriveLOKFreezeAllSheets(); } void ScViewData::SetOptions( const ScViewOptions& rOpt ) @@ -4036,4 +4110,133 @@ void ScViewData::AddPixelsWhileBackward( long & rScrY, long nEndPixels, rPosY = nRow; } +SCCOLROW ScViewData::GetLOKSheetFreezeIndex(bool bIsCol) const +{ + SCCOLROW nFreezeIndex = bIsCol ? pDoc->GetLOKFreezeCol(nTabNo) : pDoc->GetLOKFreezeRow(nTabNo); + return nFreezeIndex >= 0 ? nFreezeIndex : 0; +} + +bool ScViewData::SetLOKSheetFreezeIndex(const SCCOLROW nFreezeIndex, bool bIsCol, SCTAB nForTab) +{ + if (nForTab == -1) + { + nForTab = nTabNo; + } + else if (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size()))) + { + SAL_WARN("sc.viewdata", "ScViewData::SetLOKSheetFreezeIndex : invalid nForTab = " << nForTab); + return false; + } + + return bIsCol ? + pDoc->SetLOKFreezeCol(static_cast<SCCOL>(nFreezeIndex), nForTab) : + pDoc->SetLOKFreezeRow(static_cast<SCROW>(nFreezeIndex), nForTab); +} + +void ScViewData::DeriveLOKFreezeAllSheets() +{ + SCTAB nMaxTab = static_cast<SCTAB>(maTabData.size()) - 1; + for (SCTAB nTab = 0; nTab <= nMaxTab; ++nTab) + DeriveLOKFreezeIfNeeded(nTab); +} + +void ScViewData::DeriveLOKFreezeIfNeeded(SCTAB nForTab) +{ + if (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size()))) + { + SAL_WARN("sc.viewdata", "ScViewData::DeriveLOKFreezeIfNeeded : invalid nForTab = " << nForTab); + return; + } + + ScViewDataTable* pViewTable = maTabData[nForTab].get(); + assert(pViewTable); + + bool bConvertToFreezeX = false; + bool bConvertToFreezeY = false; + SCCOL nFreezeCol = pDoc->GetLOKFreezeCol(nForTab); + SCROW nFreezeRow = pDoc->GetLOKFreezeRow(nForTab); + + if (nFreezeCol == -1) + { + ScSplitMode eSplitMode = pViewTable->eHSplitMode; + if (eSplitMode == SC_SPLIT_FIX) + nFreezeCol = pViewTable->nFixPosX; + else if (eSplitMode == SC_SPLIT_NORMAL) + bConvertToFreezeX = true; + else + nFreezeCol = 0; + } + + if (nFreezeRow == -1) + { + ScSplitMode eSplitMode = pViewTable->eVSplitMode; + if (eSplitMode == SC_SPLIT_FIX) + nFreezeRow = pViewTable->nFixPosY; + else if (eSplitMode == SC_SPLIT_NORMAL) + bConvertToFreezeY = true; + else + nFreezeRow = 0; + } + + if (bConvertToFreezeX || bConvertToFreezeY) + { + SCCOL nCol; + SCROW nRow; + GetPosFromPixel(bConvertToFreezeX ? pViewTable->nHSplitPos : 0, + bConvertToFreezeY ? pViewTable->nVSplitPos : 0, + SC_SPLIT_BOTTOMLEFT, nCol, nRow, + false /* bTestMerge */, false /* bRepair */, + nForTab); + if (bConvertToFreezeX) + nFreezeCol = nCol; + if (bConvertToFreezeY) + nFreezeRow = nRow; + } + + pDoc->SetLOKFreezeCol(nFreezeCol, nForTab); + pDoc->SetLOKFreezeRow(nFreezeRow, nForTab); +} + +void ScViewData::OverrideWithLOKFreeze(ScSplitMode& eExHSplitMode, ScSplitMode& eExVSplitMode, + SCCOL& nExFixPosX, SCROW& nExFixPosY, + long& nExHSplitPos, long& nExVSplitPos, SCTAB nForTab) const +{ + SCCOL nFreezeCol = pDoc->GetLOKFreezeCol(nForTab); + SCROW nFreezeRow = pDoc->GetLOKFreezeRow(nForTab); + + bool bConvertToScrPosX = false; + bool bConvertToScrPosY = false; + + if (nFreezeCol >= 0) + { + if (eExHSplitMode == SC_SPLIT_NONE) + eExHSplitMode = SC_SPLIT_FIX; + + if (eExHSplitMode == SC_SPLIT_FIX) + nExFixPosX = nFreezeCol; + else + bConvertToScrPosX = true; + } + + if (nFreezeRow >= 0) + { + if (eExVSplitMode == SC_SPLIT_NONE) + eExVSplitMode = SC_SPLIT_FIX; + + if (eExVSplitMode == SC_SPLIT_FIX) + nExFixPosY = nFreezeRow; + else + bConvertToScrPosY = true; + } + + if (bConvertToScrPosX || bConvertToScrPosY) + { + Point aExSplitPos = GetScrPos(nFreezeCol, nFreezeRow, SC_SPLIT_BOTTOMLEFT, true, nForTab); + if (bConvertToScrPosX) + nExHSplitPos = aExSplitPos.X(); + if (bConvertToScrPosY) + nExVSplitPos = aExSplitPos.Y(); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |