[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sc/source
Dennis Francis (via logerrit)
logerrit at kemper.freedesktop.org
Sat Jul 4 17:27:30 UTC 2020
sc/source/ui/inc/gridwin.hxx | 3 +
sc/source/ui/view/gridwin.cxx | 74 +++++++++++++++++++++++++++++++----------
sc/source/ui/view/gridwin4.cxx | 34 ++++++++++++++----
3 files changed, 87 insertions(+), 24 deletions(-)
New commits:
commit b10cd973445afce7005000d77848a56be0295b23
Author: Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Mon May 25 17:55:19 2020 +0530
Commit: Dennis Francis <dennis.francis at collabora.com>
CommitDate: Sat Jul 4 19:26:57 2020 +0200
lokit: scPrintTwipsMsgs: LOK_CALLBACK_*SELECTION*
Allow print twips coordinates in the below messages:
LOK_CALLBACK_CELL_SELECTION_AREA
LOK_CALLBACK_TEXT_SELECTION
LOK_CALLBACK_TEXT_VIEW_SELECTION
Change-Id: I267a636bbeab434b305a45abe3e21cb5afc4c1e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97966
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Dennis Francis <dennis.francis at collabora.com>
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index a3b75a6a5ce9..3d0050d12212 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -298,8 +298,11 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel
void SelectForContextMenu( const Point& rPosPixel, SCCOL nCellX, SCROW nCellY );
void GetSelectionRects( ::std::vector< tools::Rectangle >& rPixelRects ) const;
+ void GetSelectionRectsPrintTwips(::std::vector< tools::Rectangle >& rRects) const;
void GetPixelRectsFor( const ScMarkData &rMarkData,
::std::vector< tools::Rectangle >& rPixelRects ) const;
+ void GetRectsAnyFor(const ScMarkData &rMarkData,
+ ::std::vector< tools::Rectangle >& rRects, bool bInPrintTwips) const;
void UpdateKitSelection(const std::vector<tools::Rectangle>& rRectangles,
std::vector<tools::Rectangle>* pLogicRects = nullptr);
bool NeedLOKCursorInvalidation(const tools::Rectangle& rCursorRect,
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index f1c9518b1772..9a612552fd14 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5994,13 +5994,24 @@ void ScGridWindow::UpdateKitSelection(const std::vector<tools::Rectangle>& rRect
if (!comphelper::LibreOfficeKit::isActive())
return;
+ // If this is true, rRectangles should already in print twips.
+ // If false, rRectangles are in pixels.
+ bool bInPrintTwips = comphelper::LibreOfficeKit::isCompatFlagSet(
+ comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
+
tools::Rectangle aBoundingBox;
- std::vector<tools::Rectangle> aLogicRects;
+ std::vector<tools::Rectangle> aConvertedRects;
- aLogicRects = convertPixelToLogical(pViewData, rRectangles, aBoundingBox);
+ if (bInPrintTwips)
+ std::for_each(rRectangles.begin(), rRectangles.end(),
+ [&aBoundingBox](const tools::Rectangle& rRect) { aBoundingBox.Union(rRect); });
+ else
+ aConvertedRects = convertPixelToLogical(pViewData, rRectangles, aBoundingBox);
+
+ const std::vector<tools::Rectangle>& rLogicRects = bInPrintTwips ? rRectangles : aConvertedRects;
if (pLogicRects)
{
- *pLogicRects = aLogicRects;
+ *pLogicRects = rLogicRects;
return;
}
@@ -6008,8 +6019,16 @@ void ScGridWindow::UpdateKitSelection(const std::vector<tools::Rectangle>& rRect
OString sBoundingBoxString = "EMPTY";
if (!aBoundingBox.IsEmpty())
sBoundingBoxString = aBoundingBox.toString();
+ OString aRectListString = rectanglesToString(rLogicRects);
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, sBoundingBoxString.getStr());
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, rectanglesToString(aLogicRects).getStr());
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, aRectListString.getStr());
+
+ if (bInPrintTwips)
+ {
+ SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_TEXT_VIEW_SELECTION,
+ "selection", aRectListString);
+ return;
+ }
for (SfxViewShell* it = SfxViewShell::GetFirst(); it;
it = SfxViewShell::GetNext(*it))
@@ -6040,6 +6059,8 @@ void ScGridWindow::UpdateKitSelection(const std::vector<tools::Rectangle>& rRect
void ScGridWindow::updateOtherKitSelections() const
{
ScTabViewShell* pViewShell = pViewData->GetViewShell();
+ bool bInPrintTwips = comphelper::LibreOfficeKit::isCompatFlagSet(
+ comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
for (SfxViewShell* it = SfxViewShell::GetFirst(); it;
it = SfxViewShell::GetNext(*it))
@@ -6053,10 +6074,19 @@ void ScGridWindow::updateOtherKitSelections() const
// Fetch pixels & convert for each view separately.
tools::Rectangle aBoundingBox;
- std::vector<tools::Rectangle> aPixelRects;
- GetPixelRectsFor(pOther->GetViewData().GetMarkData() /* theirs */, aPixelRects);
- auto aOtherLogicRects = convertPixelToLogical(&pViewShell->GetViewData(), aPixelRects, aBoundingBox);
- OString aRectsString = rectanglesToString(aOtherLogicRects);
+ std::vector<tools::Rectangle> aRects;
+ OString aRectsString;
+ GetRectsAnyFor(pOther->GetViewData().GetMarkData() /* theirs */, aRects, bInPrintTwips);
+ if (bInPrintTwips)
+ {
+ std::for_each(aRects.begin(), aRects.end(),
+ [&aBoundingBox](const tools::Rectangle& rRect) { aBoundingBox.Union(rRect); });
+ aRectsString = rectanglesToString(aRects);
+ }
+ else
+ aRectsString = rectanglesToString(
+ convertPixelToLogical(&pViewShell->GetViewData(), aRects, aBoundingBox));
+
if (it == pViewShell)
{
OString sBoundingBoxString = "EMPTY";
@@ -6068,7 +6098,7 @@ void ScGridWindow::updateOtherKitSelections() const
}
else
SfxLokHelper::notifyOtherView(it, pViewShell, LOK_CALLBACK_TEXT_VIEW_SELECTION,
- "selection", aRectsString.getStr());
+ "selection", aRectsString);
}
}
@@ -6266,9 +6296,14 @@ void ScGridWindow::UpdateCursorOverlay()
void ScGridWindow::GetCellSelection(std::vector<tools::Rectangle>& rLogicRects)
{
- std::vector<tools::Rectangle> aPixelRects;
- GetSelectionRects(aPixelRects);
- UpdateKitSelection(aPixelRects, &rLogicRects);
+ std::vector<tools::Rectangle> aRects;
+ if (comphelper::LibreOfficeKit::isActive() &&
+ comphelper::LibreOfficeKit::isCompatFlagSet(
+ comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs))
+ GetSelectionRectsPrintTwips(aRects);
+ else
+ GetSelectionRects(aRects);
+ UpdateKitSelection(aRects, &rLogicRects);
}
void ScGridWindow::DeleteSelectionOverlay()
@@ -6284,17 +6319,22 @@ void ScGridWindow::UpdateSelectionOverlay()
SetMapMode( aDrawMode );
DeleteSelectionOverlay();
- std::vector<tools::Rectangle> aPixelRects;
- GetSelectionRects( aPixelRects );
+ std::vector<tools::Rectangle> aRects;
+ if (comphelper::LibreOfficeKit::isActive() &&
+ comphelper::LibreOfficeKit::isCompatFlagSet(
+ comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs))
+ GetSelectionRectsPrintTwips(aRects);
+ else
+ GetSelectionRects(aRects);
- if (!aPixelRects.empty() && pViewData->IsActive())
+ if (!aRects.empty() && pViewData->IsActive())
{
// #i70788# get the OverlayManager safely
rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
if (comphelper::LibreOfficeKit::isActive())
{
// notify the LibreOfficeKit too
- UpdateKitSelection(aPixelRects);
+ UpdateKitSelection(aRects);
}
else if (xOverlayManager.is())
{
@@ -6304,7 +6344,7 @@ void ScGridWindow::UpdateSelectionOverlay()
SCTAB nTab = pViewData->GetTabNo();
bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
- for(const tools::Rectangle & rRA : aPixelRects)
+ for(const tools::Rectangle & rRA : aRects)
{
if (bLayoutRTL)
{
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 4f4c64769d2d..adf183b132f4 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1903,9 +1903,21 @@ void ScGridWindow::GetSelectionRects( ::std::vector< tools::Rectangle >& rPixelR
GetPixelRectsFor( pViewData->GetMarkData(), rPixelRects );
}
+void ScGridWindow::GetSelectionRectsPrintTwips(::std::vector< tools::Rectangle >& rRects) const
+{
+ GetRectsAnyFor(pViewData->GetMarkData(), rRects, true);
+}
+
/// convert rMarkData into pixel rectangles for this view
void ScGridWindow::GetPixelRectsFor( const ScMarkData &rMarkData,
::std::vector< tools::Rectangle >& rPixelRects ) const
+{
+ GetRectsAnyFor(rMarkData, rPixelRects, false);
+}
+
+void ScGridWindow::GetRectsAnyFor(const ScMarkData &rMarkData,
+ ::std::vector< tools::Rectangle >& rRects,
+ bool bInPrintTwips) const
{
ScMarkData aMultiMark( rMarkData );
aMultiMark.SetMarking( false );
@@ -1978,9 +1990,10 @@ void ScGridWindow::GetPixelRectsFor( const ScMarkData &rMarkData,
double nPPTX = pViewData->GetPPTX();
double nPPTY = pViewData->GetPPTY();
- ScInvertMerger aInvert( &rPixelRects );
+ ScInvertMerger aInvert( &rRects );
- Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
+ Point aScrPos = bInPrintTwips ? pViewData->GetPrintTwipsPos(nX1, nY1) :
+ pViewData->GetScrPos(nX1, nY1, eWhich);
long nScrY = aScrPos.Y();
bool bWasHidden = false;
for (SCROW nY=nY1; nY<=nY2; nY++)
@@ -2018,11 +2031,16 @@ void ScGridWindow::GetPixelRectsFor( const ScMarkData &rMarkData,
nLoopEndX = nX1;
}
- long nEndY = nScrY + ScViewData::ToPixel( nHeightTwips, nPPTY ) - 1;
+ const long nHeight = bInPrintTwips ?
+ nHeightTwips : ScViewData::ToPixel(nHeightTwips, nPPTY);
+ long nEndY = nScrY + nHeight - 1;
long nScrX = aScrPos.X();
for (SCCOL nX=nX1; nX<=nLoopEndX; nX++)
{
- long nWidth = ScViewData::ToPixel( pDoc->GetColWidth( nX,nTab ), nPPTX );
+ long nWidth = pDoc->GetColWidth(nX, nTab);
+ if (!bInPrintTwips)
+ nWidth = ScViewData::ToPixel(nWidth, nPPTX);
+
if ( nWidth > 0 )
{
long nEndX = nScrX + ( nWidth - 1 ) * nLayoutSign;
@@ -2060,9 +2078,11 @@ void ScGridWindow::GetPixelRectsFor( const ScMarkData &rMarkData,
const ScMergeAttr* pMerge = &pPattern->GetItem(ATTR_MERGE);
if (pMerge->GetColMerge() > 0 || pMerge->GetRowMerge() > 0)
{
- Point aEndPos = pViewData->GetScrPos(
- nThisX + pMerge->GetColMerge(),
- nThisY + pMerge->GetRowMerge(), eWhich );
+ const SCCOL nEndColMerge = nThisX + pMerge->GetColMerge();
+ const SCROW nEndRowMerge = nThisY + pMerge->GetRowMerge();
+ Point aEndPos = bInPrintTwips ?
+ pViewData->GetPrintTwipsPos(nEndColMerge, nEndRowMerge) :
+ pViewData->GetScrPos(nEndColMerge, nEndRowMerge, eWhich);
if ( aEndPos.X() * nLayoutSign > nScrX * nLayoutSign && aEndPos.Y() > nScrY )
{
aInvert.AddRect( tools::Rectangle( nScrX,nScrY,
More information about the Libreoffice-commits
mailing list