sw/inc/viscrs.hxx | 10 ++++++++ sw/source/core/crsr/viscrs.cxx | 46 ++++++++++++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 7 deletions(-)
New commits: commit 9c4c40ac2c2cdcb1e634df52d15d0c6fdc833410 Author: Miklos Vajna <[email protected]> Date: Fri Feb 27 10:33:10 2015 +0100 SwSelPaintRects: add FillStartEnd() interface Previously we always assumed non-table selections in SwSelPaintRects, but that is not always true, resulting in incorrect handles for table selections. Add a FillStartEnd() interface to fill the passed SwRects with the rectangle of the start and end handle, and implement it in both SwShellCrsr and SwShellTableCrsr. This makes adjusting the end of table selections using the end selection handle work (be it shrinking or extending). Change-Id: Iba8657466b102ec60c41829f00660dfe295643ab diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx index b24bea5..7de57a2 100644 --- a/sw/inc/viscrs.hxx +++ b/sw/inc/viscrs.hxx @@ -89,6 +89,8 @@ public: virtual ~SwSelPaintRects(); virtual void FillRects() = 0; + /// Fill rStart and rEnd with a rectangle that represents the start and end for selection handles. + virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) = 0; // #i75172# in SwCrsrShell::CreateCrsr() the content of SwSelPaintRects is exchanged. To // make a complete swap access to mpCursorOverlay is needed there @@ -126,6 +128,8 @@ public: virtual ~SwShellCrsr(); virtual void FillRects() SAL_OVERRIDE; // For Table- und normal cursors. + /// @see SwSelPaintRects::FillStartEnd(), override for text selections. + virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) SAL_OVERRIDE; void Show(); // Update and display all selections. void Hide(); // Hide all selections. @@ -159,6 +163,10 @@ public: class SwShellTableCrsr : public virtual SwShellCrsr, public virtual SwTableCursor { + /// Left edge of the selection start (top left cell). + SwRect m_aStart; + /// Right edge of the selection end (bottom right cell). + SwRect m_aEnd; // The Selection has the same order as the table boxes, i.e. // if something is deleted from the one array at a certain position // it has to be deleted from the other one as well!! @@ -171,6 +179,8 @@ public: virtual ~SwShellTableCrsr(); virtual void FillRects() SAL_OVERRIDE; // For table and normal cursor. + /// @see SwSelPaintRects::FillStartEnd(), override for table selections. + virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) SAL_OVERRIDE; // Check if SPoint is within table SSelection. bool IsInside( const Point& rPt ) const; diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 89bcc28..3d0d883 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -276,6 +276,13 @@ static SwRect lcl_getLayoutRect(const Point& rPoint, const SwPosition& rPosition return aRect; } +void SwShellCrsr::FillStartEnd(SwRect& rStart, SwRect& rEnd) +{ + const SwShellCrsr* pCursor = GetShell()->getShellCrsr(false); + rStart = lcl_getLayoutRect(pCursor->GetSttPos(), *pCursor->Start()); + rEnd = lcl_getLayoutRect(pCursor->GetEndPos(), *pCursor->End()); +} + #endif void SwSelPaintRects::Show() @@ -345,13 +352,20 @@ void SwSelPaintRects::Show() // events, if there is a real selection. // This can be used to easily show selection handles on the // client side. - const SwShellCrsr* pCursor = GetShell()->getShellCrsr(false); - SwRect aStartRect = lcl_getLayoutRect(pCursor->GetSttPos(), *pCursor->Start()); - OString sRect = aStartRect.SVRect().toString(); - GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, sRect.getStr()); - SwRect aEndRect = lcl_getLayoutRect(pCursor->GetEndPos(), *pCursor->End()); - sRect = aEndRect.SVRect().toString(); - GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, sRect.getStr()); + SwRect aStartRect; + SwRect aEndRect; + FillStartEnd(aStartRect, aEndRect); + + if (aStartRect.Height()) + { + OString sRect = aStartRect.SVRect().toString(); + GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, sRect.getStr()); + } + if (aEndRect.Height()) + { + OString sRect = aEndRect.SVRect().toString(); + GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, sRect.getStr()); + } } std::stringstream ss; @@ -703,10 +717,12 @@ void SwShellTableCrsr::FillRects() if (m_SelectedBoxes.empty() || bParked || !GetPoint()->nNode.GetIndex()) return; + bool bStart = true; SwRegionRects aReg( GetShell()->VisArea() ); if (GetShell()->isTiledRendering()) aReg = GetShell()->getIDocumentLayoutAccess()->GetCurrentLayout()->Frm(); SwNodes& rNds = GetDoc()->GetNodes(); + SwFrm* pEndFrm = 0; for (size_t n = 0; n < m_SelectedBoxes.size(); ++n) { const SwStartNode* pSttNd = m_SelectedBoxes[n]->GetSttNd(); @@ -738,15 +754,31 @@ void SwShellTableCrsr::FillRects() while ( pFrm ) { if( aReg.GetOrigin().IsOver( pFrm->Frm() ) ) + { aReg -= pFrm->Frm(); + if (bStart) + { + bStart = false; + m_aStart = SwRect(pFrm->Frm().Left(), pFrm->Frm().Top(), 0, pFrm->Frm().Height()); + } + } + pEndFrm = pFrm; pFrm = pFrm->GetNextCellLeaf( MAKEPAGE_NONE ); } } + if (pEndFrm) + m_aEnd = SwRect(pEndFrm->Frm().Right(), pEndFrm->Frm().Top(), 0, pEndFrm->Frm().Height()); aReg.Invert(); insert( begin(), aReg.begin(), aReg.end() ); } +void SwShellTableCrsr::FillStartEnd(SwRect& rStart, SwRect& rEnd) +{ + rStart = m_aStart; + rEnd = m_aEnd; +} + // Check if the SPoint is within the Table-SSelection. bool SwShellTableCrsr::IsInside( const Point& rPt ) const { _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
