diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-04-03 12:02:13 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-04-04 10:31:58 +0200 |
commit | b9c10ee923308f336a694bbc0212396ed5317b6a (patch) | |
tree | 72bf09a9eb69802a8e09227934bdb0b6c3150023 /editeng | |
parent | c8c0292c2152df8c353aeff32896f0cfa8a53a64 (diff) |
weld ClassificationDialog
with the extra problem of hosting an EditView/EditEngine within a
weld::DrawingArea
Change-Id: Id48a57ed0dfd2d92217209c43f752edd9cf8e1bd
Reviewed-on: https://gerrit.libreoffice.org/70219
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 6 | ||||
-rw-r--r-- | editeng/source/editeng/editview.cxx | 8 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.cxx | 81 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 4 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 3 |
5 files changed, 60 insertions, 42 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index a301145d9473..6b7157215730 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -1105,8 +1105,10 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v aCurSel = pImpEditEngine->MoveCursor( rKeyEvent, pEditView ); if ( aCurSel.HasRange() ) { - Reference<css::datatransfer::clipboard::XClipboard> aSelection(pEditView->GetWindow()->GetPrimarySelection()); - pEditView->pImpEditView->CutCopy( aSelection, false ); + if (vcl::Window* pWindow = pEditView->GetWindow()) { + Reference<css::datatransfer::clipboard::XClipboard> aSelection(pWindow->GetPrimarySelection()); + pEditView->pImpEditView->CutCopy( aSelection, false ); + } } bMoved = true; diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index 5e89f4f8f565..8e02caf8fb5d 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -171,9 +171,9 @@ void EditView::setEditViewCallbacks(const EditViewCallbacks* pEditViewCallbacks) pImpEditView->setEditViewCallbacks(pEditViewCallbacks); } -bool EditView::hasEditViewCallbacks() const +const EditViewCallbacks* EditView::getEditViewCallbacks() const { - return pImpEditView->hasEditViewCallbacks(); + return pImpEditView->getEditViewCallbacks(); } ImpEditEngine* EditView::GetImpEditEngine() const @@ -204,12 +204,12 @@ tools::Rectangle EditView::GetInvalidateRect() const void EditView::InvalidateWindow(const tools::Rectangle& rClipRect) { - if (pImpEditView->hasEditViewCallbacks()) + if (const EditViewCallbacks* pEditViewCallbacks = pImpEditView->getEditViewCallbacks()) { // do not invalidate and trigger a global repaint, but forward // the need for change to the applied EditViewCallback, can e.g. // be used to visualize the active edit text in an OverlayObject - pImpEditView->mpEditViewCallbacks->EditViewInvalidate(); + pEditViewCallbacks->EditViewInvalidate(rClipRect); } else { diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index fea76c05896f..cf8a6ee5bb0b 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -189,10 +189,10 @@ static void lcl_translateTwips(vcl::Window const & rParent, vcl::Window& rChild) // change/update the Selection visualization for enhanced mechanisms void ImpEditView::SelectionChanged() { - if (hasEditViewCallbacks()) + if (getEditViewCallbacks()) { // use callback to tell about change in selection visualisation - mpEditViewCallbacks->EditViewSelectionChange(); + getEditViewCallbacks()->EditViewSelectionChange(); } } @@ -207,7 +207,7 @@ void ImpEditView::SelectionChanged() // the Region*, see GetSelectionRectangles below. void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, OutputDevice* pTargetDevice ) { - if (hasEditViewCallbacks() && !pRegion && !comphelper::LibreOfficeKit::isActive()) + if (getEditViewCallbacks() && !pRegion && !comphelper::LibreOfficeKit::isActive()) { // we are done, do *not* visualize self // CAUTION: do not use when comphelper::LibreOfficeKit::isActive() @@ -233,7 +233,11 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, if (comphelper::LibreOfficeKit::isActive() && !pRegion) pRegion = &aRegion; - OutputDevice* pTarget = pTargetDevice ? pTargetDevice : pOutWin; + OutputDevice* pTarget; + if (pTargetDevice) + pTarget = pTargetDevice; + else + pTarget = getEditViewCallbacks() ? &getEditViewCallbacks()->EditViewOutputDevice() : pOutWin; bool bClipRegion = pTarget->IsClipRegion(); vcl::Region aOldRegion = pTarget->GetClipRegion(); @@ -256,7 +260,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, aTmpOutArea.SetRight( aTmpOutArea.Left() + pEditEngine->pImpEditEngine->GetPaperSize().Width() ); pTarget->IntersectClipRegion( aTmpOutArea ); - if ( pOutWin->GetCursor() ) + if (pOutWin && pOutWin->GetCursor()) pOutWin->GetCursor()->Hide(); } else @@ -374,7 +378,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, { *pRegion = vcl::Region( *pPolyPoly ); - if (comphelper::LibreOfficeKit::isActive() && mpViewShell && !pOldRegion) + if (comphelper::LibreOfficeKit::isActive() && mpViewShell && !pOldRegion && pOutWin) { pOutWin->Push(PushFlags::MAPMODE); if (pOutWin->GetMapMode().GetMapUnit() == MapUnit::MapTwip) @@ -469,7 +473,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, } else { - if ( pOutWin->GetCursor() ) + if (pOutWin && pOutWin->GetCursor()) pOutWin->GetCursor()->Show(); if ( bClipRegion ) @@ -637,9 +641,10 @@ void ImpEditView::SetSelectionMode( EESelectionMode eNewMode ) void ImpEditView::SetOutputArea( const tools::Rectangle& rRect ) { + const OutputDevice& rOutDev = getEditViewCallbacks() ? getEditViewCallbacks()->EditViewOutputDevice() : *pOutWin; // should be better be aligned on pixels! - tools::Rectangle aNewRect( pOutWin->LogicToPixel( rRect ) ); - aNewRect = pOutWin->PixelToLogic( aNewRect ); + tools::Rectangle aNewRect(rOutDev.LogicToPixel(rRect)); + aNewRect = rOutDev.PixelToLogic(aNewRect); aOutArea = aNewRect; if ( aOutArea.Right() < aOutArea.Left() ) aOutArea.SetRight( aOutArea.Left() ); @@ -651,12 +656,12 @@ void ImpEditView::SetOutputArea( const tools::Rectangle& rRect ) void ImpEditView::InvalidateAtWindow(const tools::Rectangle& rRect) { - if (hasEditViewCallbacks()) + if (getEditViewCallbacks()) { // do not invalidate and trigger a global repaint, but forward // the need for change to the applied EditViewCallback, can e.g. // be used to visualize the active edit text in an OverlayObject - mpEditViewCallbacks->EditViewInvalidate(); + getEditViewCallbacks()->EditViewInvalidate(rRect); } else { @@ -877,8 +882,8 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) if ( pEditEngine->pImpEditEngine->IsInUndo() ) return; - if ( pOutWin->GetCursor() != GetCursor() ) - pOutWin->SetCursor( GetCursor() ); + if (pOutWin && pOutWin->GetCursor() != GetCursor()) + pOutWin->SetCursor(GetCursor()); EditPaM aPaM( aEditSelection.Max() ); @@ -1012,7 +1017,9 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) aEditCursor.SetTop( GetVisDocTop() ); } - long nOnePixel = pOutWin->PixelToLogic( Size( 1, 0 ) ).Width(); + const OutputDevice& rOutDev = getEditViewCallbacks() ? getEditViewCallbacks()->EditViewOutputDevice() : *pOutWin; + + long nOnePixel = rOutDev.PixelToLogic( Size( 1, 0 ) ).Width(); if ( ( aEditCursor.Top() + nOnePixel >= GetVisDocTop() ) && ( aEditCursor.Bottom() - nOnePixel <= GetVisDocBottom() ) && @@ -1027,8 +1034,8 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) aCursorSz.AdjustHeight( -1 ); if ( !aCursorSz.Width() || !aCursorSz.Height() ) { - long nCursorSz = pOutWin->GetSettings().GetStyleSettings().GetCursorSize(); - nCursorSz = pOutWin->PixelToLogic( Size( nCursorSz, 0 ) ).Width(); + long nCursorSz = rOutDev.GetSettings().GetStyleSettings().GetCursorSize(); + nCursorSz = rOutDev.PixelToLogic( Size( nCursorSz, 0 ) ).Width(); if ( !aCursorSz.Width() ) aCursorSz.setWidth( nCursorSz ); if ( !aCursorSz.Height() ) @@ -1052,7 +1059,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) if (comphelper::LibreOfficeKit::isActive() && mpViewShell) { Point aPos = GetCursor()->GetPos(); - if (pOutWin->IsChart()) + if (pOutWin && pOutWin->IsChart()) { const vcl::Window* pViewShellWindow = mpViewShell->GetEditWindowForActiveOLEObj(); if (pViewShellWindow && pViewShellWindow->IsAncestorOf(*pOutWin)) @@ -1066,12 +1073,12 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) tools::Rectangle aRect(aPos.getX(), aPos.getY(), aPos.getX() + GetCursor()->GetWidth(), aPos.getY() + GetCursor()->GetHeight()); // LOK output is always in twips, convert from mm100 if necessary. - if (pOutWin->GetMapMode().GetMapUnit() == MapUnit::Map100thMM) + if (rOutDev.GetMapMode().GetMapUnit() == MapUnit::Map100thMM) aRect = OutputDevice::LogicToLogic(aRect, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); - else if (pOutWin->GetMapMode().GetMapUnit() == MapUnit::MapTwip) + else if (rOutDev.GetMapMode().GetMapUnit() == MapUnit::MapTwip) { // Writer comments: they use editeng, but are separate widgets. - Point aOrigin = pOutWin->GetMapMode().GetOrigin(); + Point aOrigin = rOutDev.GetMapMode().GetOrigin(); // Move the rectangle, so that we output absolute twips. aRect.Move(aOrigin.getX(), aOrigin.getY()); } @@ -1110,8 +1117,11 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) { SvxFont aFont; pEditEngine->SeekCursor( aPaM.GetNode(), aPaM.GetIndex()+1, aFont ); - InputContextFlags const nContextFlags = InputContextFlags::Text | InputContextFlags::ExtText; - GetWindow()->SetInputContext( InputContext( aFont, nContextFlags ) ); + if (vcl::Window* pWindow = GetWindow()) + { + InputContextFlags const nContextFlags = InputContextFlags::Text | InputContextFlags::ExtText; + pWindow->SetInputContext( InputContext( aFont, nContextFlags ) ); + } } } else @@ -1308,16 +1318,19 @@ bool ImpEditView::MouseButtonUp( const MouseEvent& rMouseEvent ) nExtraCursorFlags = GetCursorFlags::NONE; bClickedInSelection = false; - if ( rMouseEvent.IsMiddle() && !bReadOnly && - ( GetWindow()->GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) ) - { - Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetPrimarySelection()); - Paste( aClipBoard ); - } - else if ( rMouseEvent.IsLeft() && GetEditSelection().HasRange() ) + if (vcl::Window* pWindow = GetWindow()) { - Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetPrimarySelection()); - CutCopy( aClipBoard, false ); + if ( rMouseEvent.IsMiddle() && !bReadOnly && + ( pWindow->GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) ) + { + Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(pWindow->GetPrimarySelection()); + Paste( aClipBoard ); + } + else if ( rMouseEvent.IsLeft() && GetEditSelection().HasRange() ) + { + Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(pWindow->GetPrimarySelection()); + CutCopy( aClipBoard, false ); + } } return pEditEngine->pImpEditEngine->MouseButtonUp( rMouseEvent, GetEditViewPtr() ); @@ -1663,7 +1676,8 @@ bool ImpEditView::IsSelectionAtPoint( const Point& rPosPixel ) Point aMousePos( rPosPixel ); // Logical units ... - aMousePos = GetWindow()->PixelToLogic( aMousePos ); + const OutputDevice& rOutDev = getEditViewCallbacks() ? getEditViewCallbacks()->EditViewOutputDevice() : *GetWindow(); + aMousePos = rOutDev.PixelToLogic(aMousePos); if ( ( !GetOutputArea().IsInside( aMousePos ) ) && !pEditEngine->pImpEditEngine->IsInSelectionMode() ) { @@ -1682,7 +1696,8 @@ bool ImpEditView::SetCursorAtPoint( const Point& rPointPixel ) Point aMousePos( rPointPixel ); // Logical units ... - aMousePos = GetWindow()->PixelToLogic( aMousePos ); + const OutputDevice& rOutDev = getEditViewCallbacks() ? getEditViewCallbacks()->EditViewOutputDevice() : *GetWindow(); + aMousePos = rOutDev.PixelToLogic( aMousePos ); if ( ( !GetOutputArea().IsInside( aMousePos ) ) && !pEditEngine->pImpEditEngine->IsInSelectionMode() ) { diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 3ff954d9bf79..9d7ea22183e3 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -270,9 +270,9 @@ private: // repaints of the EditView(s) const EditViewCallbacks* mpEditViewCallbacks; - bool hasEditViewCallbacks() const + const EditViewCallbacks* getEditViewCallbacks() const { - return nullptr != mpEditViewCallbacks; + return mpEditViewCallbacks; } void setEditViewCallbacks(const EditViewCallbacks* pEditViewCallbacks) diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index b5746f6ab2eb..1b57db5e58cf 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -582,7 +582,8 @@ bool ImpEditEngine::MouseButtonUp( const MouseEvent& rMEvt, EditView* pView ) { if ( ( rMEvt.GetClicks() == 1 ) && rMEvt.IsLeft() && !rMEvt.IsMod2() ) { - Point aLogicClick = pView->GetWindow()->PixelToLogic(rMEvt.GetPosPixel()); + const OutputDevice& rOutDev = pView->getEditViewCallbacks() ? pView->getEditViewCallbacks()->EditViewOutputDevice() : *pView->GetWindow(); + Point aLogicClick = rOutDev.PixelToLogic(rMEvt.GetPosPixel()); if (const SvxFieldItem* pFld = pView->GetField(aLogicClick)) { EditPaM aPaM( aCurSel.Max() ); |