sc/inc/scmod.hxx | 2 sc/source/ui/app/scmod.cxx | 86 +++++++++++++++++++++++++++++++---------- sc/source/ui/app/transobj.cxx | 5 +- sc/source/ui/inc/tabvwsh.hxx | 10 ++++ sc/source/ui/view/gridwin.cxx | 60 ++++++++++++++++++++++++---- sc/source/ui/view/tabvwsh4.cxx | 38 +++++++++++++++++- 6 files changed, 171 insertions(+), 30 deletions(-)
New commits: commit beb012b5cdcc3cc9319c704b0be7863a5baa2c7b Author: Szymon Kłos <[email protected]> AuthorDate: Fri Oct 8 08:18:50 2021 +0200 Commit: Szymon Kłos <[email protected]> CommitDate: Fri Oct 8 10:19:01 2021 +0200 lok: send drag overlay Change-Id: I1e134fd99dffc4962bacbba97456365ab9347e37 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123242 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 5eba46011335..b52bd12a6fc3 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -6397,6 +6397,9 @@ void ScGridWindow::DeleteDragRectOverlay() void ScGridWindow::UpdateDragRectOverlay() { + bool bInPrintTwips = comphelper::LibreOfficeKit::isCompatFlagSet( + comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs); + MapMode aDrawMode = GetDrawMapMode(); MapMode aOldMode = GetMapMode(); if ( aOldMode != aDrawMode ) @@ -6424,7 +6427,8 @@ void ScGridWindow::UpdateDragRectOverlay() if (nY1 < nPosY) nY1 = nPosY; if (nY2 < nPosY) nY2 = nPosY; - Point aScrPos( mrViewData.GetScrPos( nX1, nY1, eWhich ) ); + Point aScrPos(bInPrintTwips ? mrViewData.GetPrintTwipsPos( nX1, nY1 ) + : mrViewData.GetScrPos( nX1, nY1, eWhich ) ); tools::Long nSizeXPix=0; tools::Long nSizeYPix=0; @@ -6435,29 +6439,42 @@ void ScGridWindow::UpdateDragRectOverlay() bool bLayoutRTL = rDoc.IsLayoutRTL( nTab ); tools::Long nLayoutSign = bLayoutRTL ? -1 : 1; + tools::Long nAdjust = comphelper::LibreOfficeKit::isActive() ? 0 : 2; if (rDoc.ValidCol(nX2) && nX2>=nX1) for (i=nX1; i<=nX2; i++) - nSizeXPix += ScViewData::ToPixel( rDoc.GetColWidth( static_cast<SCCOL>(i), nTab ), nPPTX ); + { + tools::Long nWidth = rDoc.GetColWidth( static_cast<SCCOL>(i), nTab ); + nSizeXPix += bInPrintTwips ? nWidth : ScViewData::ToPixel( nWidth, nPPTX ); + } else { aScrPos.AdjustX( -nLayoutSign ); - nSizeXPix += 2; + nSizeXPix += nAdjust; } if (rDoc.ValidRow(nY2) && nY2>=nY1) for (i=nY1; i<=nY2; i++) - nSizeYPix += ScViewData::ToPixel( rDoc.GetRowHeight( i, nTab ), nPPTY ); + { + tools::Long nHeight = rDoc.GetRowHeight( i, nTab ); + nSizeYPix += bInPrintTwips ? nHeight : ScViewData::ToPixel( nHeight, nPPTY ); + } else { aScrPos.AdjustY( -1 ); - nSizeYPix += 2; + nSizeYPix += nAdjust; + } + + if (comphelper::LibreOfficeKit::isActive()) + { + nSizeXPix -= 2; + nSizeYPix -= 2; } - aScrPos.AdjustX( -(2 * nLayoutSign) ); - aScrPos.AdjustY( -2 ); + aScrPos.AdjustX( -(nAdjust * nLayoutSign) ); + aScrPos.AdjustY( -1 * nAdjust ); tools::Rectangle aRect( aScrPos.X(), aScrPos.Y(), - aScrPos.X() + ( nSizeXPix + 2 ) * nLayoutSign, aScrPos.Y() + nSizeYPix + 2 ); + aScrPos.X() + ( nSizeXPix + nAdjust ) * nLayoutSign, aScrPos.Y() + nSizeYPix + nAdjust ); if ( bLayoutRTL ) { aRect.SetLeft( aRect.Right() ); // end position is left @@ -6511,6 +6528,33 @@ void ScGridWindow::UpdateDragRectOverlay() mpOODragRect.reset(new sdr::overlay::OverlayObjectList); mpOODragRect->append(std::move(pOverlay)); } + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (comphelper::LibreOfficeKit::isActive() && pViewShell) + { + OString aRectsString; + tools::Rectangle aBoundingBox; + + std::vector<tools::Rectangle> aRectangles; + aRectangles.push_back(aRect); + + if (bInPrintTwips) + { + aBoundingBox = aRect; + aRectsString = rectanglesToString(aRectangles); + } + else + { + aRectsString = rectanglesToString(convertPixelToLogical(pViewShell->GetViewData(), aRectangles, aBoundingBox)); + } + + OString sBoundingBoxString = "EMPTY"; + if (!aBoundingBox.IsEmpty()) + sBoundingBoxString = aBoundingBox.toString(); + + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, sBoundingBoxString.getStr()); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, aRectsString.getStr()); + } } if ( aOldMode != aDrawMode ) commit db36743d46578fb4abfaee4b6c3dc18d346d7f27 Author: Szymon Kłos <[email protected]> AuthorDate: Wed Oct 6 18:22:36 2021 +0200 Commit: Szymon Kłos <[email protected]> CommitDate: Fri Oct 8 10:18:51 2021 +0200 lok: deglobalize SetDragObject and other Drag and Drop related functions Change-Id: Idbaec91c0ed396da9888c8ed562d2eff35686cca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123209 Tested-by: Szymon Kłos <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index 20dc94e9e9e8..c139afe9244c 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -139,7 +139,7 @@ public: void AnythingChanged(); // Drag & Drop: - const ScDragData& GetDragData() const { return *m_pDragData;} + const ScDragData& GetDragData() const; void SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj ); void ResetDragObject(); void SetDragLink( diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index f0a992e774bf..54fba8044957 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -579,40 +579,88 @@ void ScModule::HideDisabledSlots( SfxItemSet& rSet ) void ScModule::ResetDragObject() { - m_pDragData->pCellTransfer = nullptr; - m_pDragData->pDrawTransfer = nullptr; - m_pDragData->pJumpLocalDoc = nullptr; - m_pDragData->aLinkDoc.clear(); - m_pDragData->aLinkTable.clear(); - m_pDragData->aLinkArea.clear(); - m_pDragData->aJumpTarget.clear(); - m_pDragData->aJumpText.clear(); + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->ResetDragObject(); + } + else + { + m_pDragData->pCellTransfer = nullptr; + m_pDragData->pDrawTransfer = nullptr; + m_pDragData->pJumpLocalDoc = nullptr; + m_pDragData->aLinkDoc.clear(); + m_pDragData->aLinkTable.clear(); + m_pDragData->aLinkArea.clear(); + m_pDragData->aJumpTarget.clear(); + m_pDragData->aJumpText.clear(); + } +} + +const ScDragData& ScModule::GetDragData() const +{ + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + assert(pViewShell); + return pViewShell->GetDragData(); + } + else + return *m_pDragData; } void ScModule::SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj ) { - ResetDragObject(); - m_pDragData->pCellTransfer = pCellObj; - m_pDragData->pDrawTransfer = pDrawObj; + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetDragObject(pCellObj, pDrawObj); + } + else + { + ResetDragObject(); + m_pDragData->pCellTransfer = pCellObj; + m_pDragData->pDrawTransfer = pDrawObj; + } } void ScModule::SetDragLink( const OUString& rDoc, const OUString& rTab, const OUString& rArea ) { - ResetDragObject(); - m_pDragData->aLinkDoc = rDoc; - m_pDragData->aLinkTable = rTab; - m_pDragData->aLinkArea = rArea; + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetDragLink(rDoc, rTab, rArea); + } + else + { + ResetDragObject(); + m_pDragData->aLinkDoc = rDoc; + m_pDragData->aLinkTable = rTab; + m_pDragData->aLinkArea = rArea; + } } void ScModule::SetDragJump( ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText ) { - ResetDragObject(); + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetDragJump(pLocalDoc, rTarget, rText); + } + else + { + ResetDragObject(); - m_pDragData->pJumpLocalDoc = pLocalDoc; - m_pDragData->aJumpTarget = rTarget; - m_pDragData->aJumpText = rText; + m_pDragData->pJumpLocalDoc = pLocalDoc; + m_pDragData->aJumpTarget = rTarget; + m_pDragData->aJumpText = rText; + } } ScDocument* ScModule::GetClipDoc() diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 1b11a56aa89c..a51d39e1919e 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -27,6 +27,7 @@ #include <unotools/tempfile.hxx> #include <unotools/ucbstreamhelper.hxx> #include <comphelper/fileformat.h> +#include <comphelper/lok.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/servicehelper.hxx> #include <sot/storage.hxx> @@ -49,6 +50,7 @@ #include <docfunc.hxx> #include <scmod.hxx> #include <dragdata.hxx> +#include <tabvwsh.hxx> #include <editeng/paperinf.hxx> #include <editeng/sizeitem.hxx> @@ -174,8 +176,9 @@ ScTransferObj::~ScTransferObj() { SolarMutexGuard aSolarGuard; + bool bIsDisposing = comphelper::LibreOfficeKit::isActive() && !ScTabViewShell::GetActiveViewShell(); ScModule* pScMod = SC_MOD(); - if (pScMod && pScMod->GetDragData().pCellTransfer == this) + if (pScMod && !bIsDisposing && pScMod->GetDragData().pCellTransfer == this) { OSL_FAIL("ScTransferObj wasn't released"); pScMod->ResetDragObject(); diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index 7a07d476eb0b..fd608a345b24 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -33,6 +33,7 @@ #include <shellids.hxx> #include <tabprotection.hxx> #include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp> +#include <dragdata.hxx> #include <memory> #include <map> @@ -60,6 +61,7 @@ class ScPageBreakShell; class ScDPObject; class ScNavigatorSettings; class ScRangeName; +class ScDrawTransferObj; struct ScHeaderFieldData; @@ -163,6 +165,8 @@ private: bool mbInSwitch; OUString maName; OUString maScope; + + std::unique_ptr<ScDragData> m_pDragData; private: void Construct( TriState nForceDesignMode ); @@ -402,6 +406,12 @@ public: ScFormEditData* GetFormEditData() { return mpFormEditData.get(); } virtual tools::Rectangle getLOKVisibleArea() const override; + + const ScDragData& GetDragData() const { return *m_pDragData; } + void SetDragObject(ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj); + void ResetDragObject(); + void SetDragLink(const OUString& rDoc, const OUString& rTab, const OUString& rArea); + void SetDragJump(ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText); }; #endif diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 0a1d2212f1fb..dfc97880f263 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1672,7 +1672,8 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame, bInPrepareClose(false), bInDispose(false), nCurRefDlgId(0), - mbInSwitch(false) + mbInSwitch(false), + m_pDragData(new ScDragData) { const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions(); @@ -1863,4 +1864,39 @@ tools::Rectangle ScTabViewShell::getLOKVisibleArea() const return GetViewData().getLOKVisibleArea(); } +void ScTabViewShell::SetDragObject(ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj) +{ + ResetDragObject(); + m_pDragData->pCellTransfer = pCellObj; + m_pDragData->pDrawTransfer = pDrawObj; +} + +void ScTabViewShell::ResetDragObject() +{ + m_pDragData->pCellTransfer = nullptr; + m_pDragData->pDrawTransfer = nullptr; + m_pDragData->pJumpLocalDoc = nullptr; + m_pDragData->aLinkDoc.clear(); + m_pDragData->aLinkTable.clear(); + m_pDragData->aLinkArea.clear(); + m_pDragData->aJumpTarget.clear(); + m_pDragData->aJumpText.clear(); +} + +void ScTabViewShell::SetDragLink(const OUString& rDoc, const OUString& rTab, const OUString& rArea) +{ + ResetDragObject(); + m_pDragData->aLinkDoc = rDoc; + m_pDragData->aLinkTable = rTab; + m_pDragData->aLinkArea = rArea; +} + +void ScTabViewShell::SetDragJump(ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText) +{ + ResetDragObject(); + m_pDragData->pJumpLocalDoc = pLocalDoc; + m_pDragData->aJumpTarget = rTarget; + m_pDragData->aJumpText = rText; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
