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 | |
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>
24 files changed, 528 insertions, 369 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() ); diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index c80974b9b34d..783d1279ea50 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -332,14 +332,6 @@ generic-name="Text View" parent="GtkTextView" icon-name="widget-gtk-textentry"/> - <glade-widget-class title="Classifcation Text View" name="svxlo-ClassificationEditView" - generic-name="Classifcation Text View" parent="GtkTextView" - icon-name="widget-gtk-textentry"/> - - <glade-widget-class title="IntellectualPropertyPartEdit" name="svxlo-IntellectualPropertyPartEdit" - generic-name="IntellectualPropertyPartEdit" parent="GtkEntry" - icon-name="widget-gtk-textentry"/> - <glade-widget-class title="Open Document ListBox" name="dbulo-OpenDocumentListBox" generic-name="Open Document ListBox" parent="GtkComboBox" icon-name="widget-gtk-combobox"/> diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx index fbb6a614efa2..5dd839ba07f6 100644 --- a/include/editeng/editview.hxx +++ b/include/editeng/editview.hxx @@ -95,12 +95,15 @@ public: // call this when text visualization changed in any way. It // will also update selection, so no need to call this self // additionally (but will also do no harm) - virtual void EditViewInvalidate() const = 0; + virtual void EditViewInvalidate(const tools::Rectangle& rRect) const = 0; // call this when only selection is changed. Text change will // then *not* be checked and not be reacted on. Still, when // only the selection is changed, this is useful and faster virtual void EditViewSelectionChange() const = 0; + + // return the OutputDevice that the EditView will draw to + virtual OutputDevice& EditViewOutputDevice() const = 0; }; class EDITENG_DLLPUBLIC EditView final @@ -130,7 +133,7 @@ public: // set EditViewCallbacks for external handling of Repaints/Visualization void setEditViewCallbacks(const EditViewCallbacks* pEditViewCallbacks); - bool hasEditViewCallbacks() const; + const EditViewCallbacks* getEditViewCallbacks() const; void SetEditEngine( EditEngine* pEditEngine ); EditEngine* GetEditEngine() const; diff --git a/include/svx/ClassificationDialog.hxx b/include/svx/ClassificationDialog.hxx index 3efa8fbc7a8b..2aaed9d16fca 100644 --- a/include/svx/ClassificationDialog.hxx +++ b/include/svx/ClassificationDialog.hxx @@ -12,13 +12,8 @@ #define INCLUDED_SVX_CLASSIFICATIONDIALOG_HXX #include <sal/config.h> -#include <vcl/dialog.hxx> -#include <vcl/button.hxx> -#include <vcl/lstbox.hxx> -#include <vcl/toolbox.hxx> -#include <vcl/fixed.hxx> -#include <vcl/edit.hxx> -#include <vcl/layout.hxx> +#include <vcl/customweld.hxx> +#include <vcl/weld.hxx> #include <svx/svxdllapi.h> #include <svx/ClassificationEditView.hxx> #include <sfx2/classificationhelper.hxx> @@ -26,33 +21,9 @@ namespace svx { -class IntellectualPropertyPartEdit : public Edit -{ -public: - IntellectualPropertyPartEdit(vcl::Window* pParent); - -protected: - virtual void KeyInput(const KeyEvent &rKEvt) override; -}; - -class SVX_DLLPUBLIC ClassificationDialog : public ModalDialog +class SVX_DLLPUBLIC ClassificationDialog : public weld::GenericDialogController { private: - VclPtr<PushButton> m_pOkButton; - VclPtr<ClassificationEditView> m_pEditWindow; - VclPtr<PushButton> m_pSignButton; - VclPtr<ToolBox> m_pToolBox; - VclPtr<ListBox> m_pClassificationListBox; - VclPtr<ListBox> m_pRecentlyUsedListBox; - VclPtr<ListBox> m_pInternationalClassificationListBox; - VclPtr<FixedText> m_pMarkingLabel; - VclPtr<ListBox> m_pMarkingListBox; - VclPtr<ListBox> m_pIntellectualPropertyPartListBox; - VclPtr<ListBox> m_pIntellectualPropertyPartNumberListBox; - VclPtr<PushButton> m_pIntellectualPropertyPartAddButton; - VclPtr<IntellectualPropertyPartEdit> m_pIntellectualPropertyPartEdit; - VclPtr<VclExpander> m_pIntellectualPropertyExpander; - SfxClassificationHelper maHelper; SfxClassificationHelper maInternationalHelper; @@ -61,33 +32,49 @@ private: sal_Int32 m_nCurrentSelectedCategory; - DECL_LINK(ButtonClicked, Button*, void); - DECL_LINK(SelectToolboxHdl, ToolBox*, void); - DECL_LINK(SelectClassificationHdl, ListBox&, void); - DECL_LINK(SelectMarkingHdl, ListBox&, void); - DECL_LINK(SelectIPPartNumbersHdl, ListBox&, void); - DECL_LINK(SelectRecentlyUsedHdl, ListBox&, void); - DECL_LINK(SelectIPPartHdl, ListBox&, void); + std::vector<std::vector<ClassificationResult>> m_aRecentlyUsedValuesCollection; + std::vector<ClassificationResult> m_aInitialValues; + + std::unique_ptr<weld::Button> m_xOkButton; + std::unique_ptr<weld::Button> m_xSignButton; + std::unique_ptr<weld::ToggleButton> m_xToolBox; + std::unique_ptr<weld::ComboBox> m_xRecentlyUsedListBox; + std::unique_ptr<weld::ComboBox> m_xClassificationListBox; + std::unique_ptr<weld::ComboBox> m_xInternationalClassificationListBox; + std::unique_ptr<weld::Label> m_xMarkingLabel; + std::unique_ptr<weld::TreeView> m_xMarkingListBox; + std::unique_ptr<weld::TreeView> m_xIntellectualPropertyPartListBox; + std::unique_ptr<weld::TreeView> m_xIntellectualPropertyPartNumberListBox; + std::unique_ptr<weld::Button> m_xIntellectualPropertyPartAddButton; + std::unique_ptr<weld::Entry> m_xIntellectualPropertyPartEdit; + std::unique_ptr<weld::Expander> m_xIntellectualPropertyExpander; + std::unique_ptr<ClassificationEditView> m_xEditWindow; + std::unique_ptr<weld::CustomWeld> m_xEditWindowWeld; + + DECL_LINK(ButtonClicked, weld::Button&, void); + DECL_LINK(SelectToolboxHdl, weld::ToggleButton&, void); + DECL_LINK(SelectClassificationHdl, weld::ComboBox&, void); + DECL_LINK(SelectMarkingHdl, weld::TreeView&, void); + DECL_LINK(SelectIPPartNumbersHdl, weld::TreeView&, void); + DECL_LINK(SelectRecentlyUsedHdl, weld::ComboBox&, void); + DECL_LINK(SelectIPPartHdl, weld::TreeView&, void); DECL_LINK(EditWindowModifiedHdl, LinkParamNone*, void); - DECL_STATIC_LINK(ClassificationDialog, ExpandedHdl, VclExpander&, void); + DECL_STATIC_LINK(ClassificationDialog, ExpandedHdl, weld::Expander&, void); + DECL_STATIC_LINK(ClassificationDialog, KeyInput, const KeyEvent&, bool); void insertField(ClassificationType eType, OUString const & rString, OUString const & rFullString, OUString const & rIdentifier = OUString()); void insertCategoryField(sal_Int32 nID); - std::vector<std::vector<ClassificationResult>> m_aRecentlyUsedValuesCollection; - std::vector<ClassificationResult> m_aInitialValues; - void readIn(std::vector<ClassificationResult> const & rInput); void readRecentlyUsed(); void writeRecentlyUsed(); void toggleWidgetsDependingOnCategory(); public: - ClassificationDialog(vcl::Window* pParent, bool bPerParagraph, const std::function<void()>& rParagraphSignHandler = [](){}); + ClassificationDialog(weld::Window* pParent, bool bPerParagraph, const std::function<void()>& rParagraphSignHandler = [](){}); ~ClassificationDialog() override; - void dispose() override; - short Execute() override; + short run() override; std::vector<ClassificationResult> getResult(); void setupValues(std::vector<ClassificationResult> const & rInput); diff --git a/include/svx/ClassificationEditView.hxx b/include/svx/ClassificationEditView.hxx index 4f421b400243..656219c141f2 100644 --- a/include/svx/ClassificationEditView.hxx +++ b/include/svx/ClassificationEditView.hxx @@ -18,6 +18,7 @@ #include <editeng/numitem.hxx> #include <editeng/editeng.hxx> #include <editeng/editview.hxx> +#include <vcl/customweld.hxx> namespace svx { @@ -29,15 +30,14 @@ public: virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor) override; }; -class SVX_DLLPUBLIC ClassificationEditView : public Control +class SVX_DLLPUBLIC ClassificationEditView : public weld::CustomWidgetController, + public EditViewCallbacks { public: - ClassificationEditView(vcl::Window* pParent, WinBits nBits); + ClassificationEditView(); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; virtual ~ClassificationEditView() override; - using Control::SetFont; - using Control::SetText; - void SetCharAttributes(); void InsertField(const SvxFieldItem& rField); @@ -61,13 +61,30 @@ public: protected: virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; - virtual void MouseMove( const MouseEvent& rMEvt ) override; - virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; - virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; - virtual void KeyInput( const KeyEvent& rKEvt ) override; - virtual void Command( const CommandEvent& rCEvt ) override; + virtual bool MouseMove( const MouseEvent& rMEvt ) override; + virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual bool KeyInput( const KeyEvent& rKEvt ) override; virtual void GetFocus() override; virtual void Resize() override; + + + virtual void EditViewInvalidate(const tools::Rectangle& rRect) const override + { + weld::DrawingArea* pDrawingArea = GetDrawingArea(); + pDrawingArea->queue_draw_area(rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight()); + } + + virtual void EditViewSelectionChange() const override + { + weld::DrawingArea* pDrawingArea = GetDrawingArea(); + pDrawingArea->queue_draw(); + } + + virtual OutputDevice& EditViewOutputDevice() const override + { + return GetDrawingArea()->get_ref_device(); + } }; } // end svx namespace diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx index 1730e427539d..596e830f8bd3 100644 --- a/include/svx/svdedxv.hxx +++ b/include/svx/svdedxv.hxx @@ -65,8 +65,9 @@ class SVX_DLLPUBLIC SdrObjEditView : public SdrGlueEditView, public EditViewCall // Now derived from EditViewCallbacks and overriding these callbacks to // allow own EditText visualization - virtual void EditViewInvalidate() const override; + virtual void EditViewInvalidate(const tools::Rectangle& rRect) const override; virtual void EditViewSelectionChange() const override; + virtual OutputDevice& EditViewOutputDevice() const override; // The OverlayObjects used for visualizing active TextEdit (currently // using TextEditOverlayObject, but not limited to it diff --git a/include/vcl/cursor.hxx b/include/vcl/cursor.hxx index 0051a0b7df29..714d6f569e80 100644 --- a/include/vcl/cursor.hxx +++ b/include/vcl/cursor.hxx @@ -29,6 +29,7 @@ class Timer; struct ImplCursorData; +class OutputDevice; namespace vcl { class Window; } // Cursor styles @@ -95,8 +96,11 @@ public: bool operator!=( const Cursor& rCursor ) const { return !(Cursor::operator==( rCursor )); } + void DrawToDevice(OutputDevice& rRenderContext); + private: void LOKNotify( vcl::Window* pWindow, const OUString& rAction ); + bool ImplPrepForDraw(OutputDevice* pDevice, ImplCursorData& rData); void ImplRestore(); void ImplDoShow( bool bDrawDirect, bool bRestore ); bool ImplDoHide( bool bStop ); diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 83f0809ec906..a7a195a9d39d 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -1509,6 +1509,9 @@ public: virtual void queue_draw() = 0; virtual void queue_draw_area(int x, int y, int width, int height) = 0; virtual void queue_resize() = 0; + + virtual void set_text_cursor() = 0; + // use return here just to generate matching VirtualDevices virtual OutputDevice& get_ref_device() = 0; diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 6cde6563e7f0..699c2d356d1e 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -1543,18 +1543,18 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) case SID_CLASSIFICATION_DIALOG: { - ScopedVclPtr<svx::ClassificationDialog> pDialog(VclPtr<svx::ClassificationDialog>::Create(nullptr, false, [](){} )); + std::shared_ptr<svx::ClassificationDialog> xDialog(new svx::ClassificationDialog(GetFrameWeld(), false, [](){} )); ClassificationCollector aCollector(*this); aCollector.collect(); - pDialog->setupValues(aCollector.getResults()); + xDialog->setupValues(aCollector.getResults()); - if (RET_OK == pDialog->Execute()) + if (RET_OK == xDialog->run()) { ClassificationInserter aInserter(*this); - aInserter.insert(pDialog->getResult()); + aInserter.insert(xDialog->getResult()); } - pDialog.disposeAndClear(); + xDialog.reset(); Cancel(); rReq.Ignore(); diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index ee920c14c18a..0c4b8bc68aba 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -429,7 +429,6 @@ custom_widgets = [ 'ArgEdit', 'BookmarksBox', 'CategoryListBox', - 'ClassificationEditView', 'ColorConfigCtrl', 'ColumnEdit', 'ContentListBox', @@ -449,7 +448,6 @@ custom_widgets = [ 'FormulaListBox', 'IndexBox', 'IndexBox', - 'IntellectualPropertyPartEdit', 'LightButton', 'LookUpComboBox', 'ManagedMenuButton', diff --git a/solenv/sanitizers/ui/svx.suppr b/solenv/sanitizers/ui/svx.suppr index f4ea144b31f0..af8dd6975891 100644 --- a/solenv/sanitizers/ui/svx.suppr +++ b/solenv/sanitizers/ui/svx.suppr @@ -20,9 +20,8 @@ svx/uiconfig/ui/classificationdialog.ui://GtkComboBoxText[@id='recentlyUsedCB'] svx/uiconfig/ui/classificationdialog.ui:GtkDialog[@id='AdvancedDocumentClassificationDialog']/GtkBox[@id='dialog-vbox1']/GtkGrid/GtkGrid/GtkLabel orphan-label svx/uiconfig/ui/classificationdialog.ui://GtkTreeView[@id='markingLB'] no-labelled-by svx/uiconfig/ui/classificationdialog.ui:GtkDialog[@id='AdvancedDocumentClassificationDialog']/GtkBox[@id='dialog-vbox1']/GtkGrid/GtkGrid/GtkLabel orphan-label -svx/uiconfig/ui/classificationdialog.ui://svxlo-ClassificationEditView[@id='classificationEditWindow'] no-labelled-by svx/uiconfig/ui/classificationdialog.ui:GtkDialog[@id='AdvancedDocumentClassificationDialog']/GtkBox[@id='dialog-vbox1']/GtkGrid/GtkExpander[@id='intellectualPropertyExpander']/GtkGrid/GtkLabel orphan-label -svx/uiconfig/ui/classificationdialog.ui://svxlo-IntellectualPropertyPartEdit[@id='intellectualPropertyPartEntry'] no-labelled-by +svx/uiconfig/ui/classificationdialog.ui://GtkEntry[@id='intellectualPropertyPartEntry'] no-labelled-by svx/uiconfig/ui/classificationdialog.ui:GtkDialog[@id='AdvancedDocumentClassificationDialog']/GtkBox[@id='dialog-vbox1']/GtkGrid/GtkExpander[@id='intellectualPropertyExpander']/GtkGrid/GtkLabel orphan-label svx/uiconfig/ui/classificationdialog.ui://GtkTreeView[@id='intellectualPropertyPartNumberLB'] no-labelled-by svx/uiconfig/ui/classificationdialog.ui://GtkTreeView[@id='intellectualPropertyPartLB'] no-labelled-by diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx index 11349012361b..d83a6b044a54 100644 --- a/svx/source/dialog/ClassificationDialog.cxx +++ b/svx/source/dialog/ClassificationDialog.cxx @@ -24,36 +24,25 @@ #include <tools/XmlWriter.hxx> #include <tools/XmlWalker.hxx> #include <vcl/builderfactory.hxx> +#include <vcl/event.hxx> #include <sfx2/objsh.hxx> #include <officecfg/Office/Common.hxx> namespace svx { - -IntellectualPropertyPartEdit::IntellectualPropertyPartEdit(vcl::Window* pParent) - : Edit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK|WB_TABSTOP) -{ -} - -VCL_BUILDER_FACTORY(IntellectualPropertyPartEdit) - -void IntellectualPropertyPartEdit::KeyInput(const KeyEvent& rKeyEvent) +IMPL_STATIC_LINK(ClassificationDialog, KeyInput, const KeyEvent&, rKeyEvent, bool) { bool bTextIsFreeForm = officecfg::Office::Common::Classification::IntellectualPropertyTextInputIsFreeForm::get(); - if (bTextIsFreeForm) - { - Edit::KeyInput(rKeyEvent); - } - else + if (!bTextIsFreeForm) { // Ignore key combination with modifier keys if (rKeyEvent.GetKeyCode().IsMod3() || rKeyEvent.GetKeyCode().IsMod2() || rKeyEvent.GetKeyCode().IsMod1()) { - return; + return true; } switch (rKeyEvent.GetKeyCode().GetCode()) @@ -64,13 +53,15 @@ void IntellectualPropertyPartEdit::KeyInput(const KeyEvent& rKeyEvent) case KEY_DIVIDE: case KEY_SEMICOLON: case KEY_SPACE: - Edit::KeyInput(rKeyEvent); - return; + return false; // Anything else is ignored default: + return true; break; } } + + return false; } namespace { @@ -161,117 +152,98 @@ void writeResultToXml(tools::XmlWriter & rXmlWriter, } // end anonymous namespace -ClassificationDialog::ClassificationDialog(vcl::Window* pParent, const bool bPerParagraph, const std::function<void()>& rParagraphSignHandler) - : ModalDialog(pParent, "AdvancedDocumentClassificationDialog", "svx/ui/classificationdialog.ui") +ClassificationDialog::ClassificationDialog(weld::Window* pParent, const bool bPerParagraph, const std::function<void()>& rParagraphSignHandler) + : GenericDialogController(pParent, "svx/ui/classificationdialog.ui", "AdvancedDocumentClassificationDialog") , maHelper(SfxObjectShell::Current()->getDocProperties()) , maInternationalHelper(SfxObjectShell::Current()->getDocProperties(), /*bUseLocalizedPolicy*/ false) , m_bPerParagraph(bPerParagraph) , m_aParagraphSignHandler(rParagraphSignHandler) , m_nCurrentSelectedCategory(-1) + , m_xOkButton(m_xBuilder->weld_button("ok")) + , m_xSignButton(m_xBuilder->weld_button("signButton")) + , m_xToolBox(m_xBuilder->weld_toggle_button("toolbox")) + , m_xRecentlyUsedListBox(m_xBuilder->weld_combo_box("recentlyUsedCB")) + , m_xClassificationListBox(m_xBuilder->weld_combo_box("classificationCB")) + , m_xInternationalClassificationListBox(m_xBuilder->weld_combo_box("internationalClassificationCB")) + , m_xMarkingLabel(m_xBuilder->weld_label("markingLabel")) + , m_xMarkingListBox(m_xBuilder->weld_tree_view("markingLB")) + , m_xIntellectualPropertyPartListBox(m_xBuilder->weld_tree_view("intellectualPropertyPartLB")) + , m_xIntellectualPropertyPartNumberListBox(m_xBuilder->weld_tree_view("intellectualPropertyPartNumberLB")) + , m_xIntellectualPropertyPartAddButton(m_xBuilder->weld_button("intellectualPropertyPartAddButton")) + , m_xIntellectualPropertyPartEdit(m_xBuilder->weld_entry("intellectualPropertyPartEntry")) + , m_xIntellectualPropertyExpander(m_xBuilder->weld_expander("intellectualPropertyExpander")) + , m_xEditWindow(new ClassificationEditView) + , m_xEditWindowWeld(new weld::CustomWeld(*m_xBuilder, "classificationEditWindow", *m_xEditWindow)) { - get(m_pOkButton, "ok"); - get(m_pEditWindow, "classificationEditWindow"); - get(m_pSignButton, "signButton"); - get(m_pToolBox, "toolbox"); - get(m_pRecentlyUsedListBox, "recentlyUsedCB"); - get(m_pClassificationListBox, "classificationCB"); - get(m_pInternationalClassificationListBox, "internationalClassificationCB"); - get(m_pMarkingLabel, "markingLabel"); - get(m_pMarkingListBox, "markingLB"); - get(m_pIntellectualPropertyPartNumberListBox, "intellectualPropertyPartNumberLB"); - get(m_pIntellectualPropertyPartListBox, "intellectualPropertyPartLB"); - get(m_pIntellectualPropertyPartAddButton, "intellectualPropertyPartAddButton"); - get(m_pIntellectualPropertyPartEdit, "intellectualPropertyPartEntry"); - get(m_pIntellectualPropertyExpander, "intellectualPropertyExpander"); - - m_pSignButton->SetClickHdl(LINK(this, ClassificationDialog, ButtonClicked)); - m_pSignButton->Show(m_bPerParagraph); + m_xSignButton->connect_clicked(LINK(this, ClassificationDialog, ButtonClicked)); + m_xSignButton->set_visible(m_bPerParagraph); + + m_xIntellectualPropertyPartEdit->connect_key_press(LINK(this, ClassificationDialog, KeyInput)); // no need for BOLD if we do paragraph classification if (m_bPerParagraph) { - m_pToolBox->Show(false); + m_xToolBox->hide(); } else { - m_pToolBox->SetSelectHdl(LINK(this, ClassificationDialog, SelectToolboxHdl)); + m_xToolBox->connect_toggled(LINK(this, ClassificationDialog, SelectToolboxHdl)); } - m_pIntellectualPropertyPartAddButton->SetClickHdl(LINK(this, ClassificationDialog, ButtonClicked)); + m_xIntellectualPropertyPartAddButton->connect_clicked(LINK(this, ClassificationDialog, ButtonClicked)); - m_pClassificationListBox->setMaxWidthChars(20); - m_pClassificationListBox->SetSelectHdl(LINK(this, ClassificationDialog, SelectClassificationHdl)); + m_xClassificationListBox->set_size_request(m_xClassificationListBox->get_approximate_digit_width() * 20, -1); + m_xClassificationListBox->connect_changed(LINK(this, ClassificationDialog, SelectClassificationHdl)); for (const OUString& rName : maHelper.GetBACNames()) - m_pClassificationListBox->InsertEntry(rName); + m_xClassificationListBox->append_text(rName); - m_pInternationalClassificationListBox->setMaxWidthChars(20); - m_pInternationalClassificationListBox->SetSelectHdl(LINK(this, ClassificationDialog, SelectClassificationHdl)); + m_xInternationalClassificationListBox->set_size_request(m_xInternationalClassificationListBox->get_approximate_digit_width() * 20, -1); + m_xInternationalClassificationListBox->connect_changed(LINK(this, ClassificationDialog, SelectClassificationHdl)); for (const OUString& rName : maInternationalHelper.GetBACNames()) - m_pInternationalClassificationListBox->InsertEntry(rName); + m_xInternationalClassificationListBox->append_text(rName); if (!maHelper.GetMarkings().empty()) { - m_pMarkingListBox->setMaxWidthChars(10); - m_pMarkingListBox->SetDropDownLineCount(4); - m_pMarkingListBox->SetDoubleClickHdl(LINK(this, ClassificationDialog, SelectMarkingHdl)); + m_xMarkingListBox->set_size_request(m_xMarkingListBox->get_approximate_digit_width() * 10, + m_xMarkingListBox->get_height_rows(4)); + m_xMarkingListBox->connect_row_activated(LINK(this, ClassificationDialog, SelectMarkingHdl)); for (const OUString& rName : maHelper.GetMarkings()) - m_pMarkingListBox->InsertEntry(rName); + m_xMarkingListBox->append_text(rName); } else { - m_pMarkingListBox->Show(false); - m_pMarkingLabel->Show(false); + m_xMarkingListBox->hide(); + m_xMarkingLabel->hide(); } - m_pIntellectualPropertyPartNumberListBox->SetDropDownLineCount(5); - m_pIntellectualPropertyPartNumberListBox->setMaxWidthChars(10); - m_pIntellectualPropertyPartNumberListBox->SetDoubleClickHdl(LINK(this, ClassificationDialog, SelectIPPartNumbersHdl)); + m_xIntellectualPropertyPartNumberListBox->set_size_request(m_xIntellectualPropertyPartNumberListBox->get_approximate_digit_width() * 10, + m_xIntellectualPropertyPartNumberListBox->get_height_rows(5)); + m_xIntellectualPropertyPartNumberListBox->connect_row_activated(LINK(this, ClassificationDialog, SelectIPPartNumbersHdl)); for (const OUString& rName : maHelper.GetIntellectualPropertyPartNumbers()) - m_pIntellectualPropertyPartNumberListBox->InsertEntry(rName); + m_xIntellectualPropertyPartNumberListBox->append_text(rName); - m_pIntellectualPropertyPartListBox->SetDropDownLineCount(5); - m_pIntellectualPropertyPartNumberListBox->setMaxWidthChars(20); - m_pIntellectualPropertyPartListBox->SetDoubleClickHdl(LINK(this, ClassificationDialog, SelectIPPartHdl)); + m_xIntellectualPropertyPartNumberListBox->set_size_request(m_xIntellectualPropertyPartNumberListBox->get_approximate_digit_width() * 20, + m_xIntellectualPropertyPartListBox->get_height_rows(5)); + m_xIntellectualPropertyPartListBox->connect_row_activated(LINK(this, ClassificationDialog, SelectIPPartHdl)); for (const OUString& rName : maHelper.GetIntellectualPropertyParts()) - m_pIntellectualPropertyPartListBox->InsertEntry(rName); + m_xIntellectualPropertyPartListBox->append_text(rName); - m_pRecentlyUsedListBox->setMaxWidthChars(5); - m_pRecentlyUsedListBox->SetSelectHdl(LINK(this, ClassificationDialog, SelectRecentlyUsedHdl)); + m_xRecentlyUsedListBox->set_size_request(m_xRecentlyUsedListBox->get_approximate_digit_width() * 5, -1); + m_xRecentlyUsedListBox->connect_changed(LINK(this, ClassificationDialog, SelectRecentlyUsedHdl)); bool bExpand = officecfg::Office::Common::Classification::IntellectualPropertySectionExpanded::get(); - m_pIntellectualPropertyExpander->set_expanded(bExpand); - m_pIntellectualPropertyExpander->SetExpandedHdl(LINK(this, ClassificationDialog, ExpandedHdl)); + m_xIntellectualPropertyExpander->set_expanded(bExpand); + m_xIntellectualPropertyExpander->connect_expanded(LINK(this, ClassificationDialog, ExpandedHdl)); - m_pEditWindow->SetModifyHdl(LINK(this, ClassificationDialog, EditWindowModifiedHdl)); + m_xEditWindow->SetModifyHdl(LINK(this, ClassificationDialog, EditWindowModifiedHdl)); } ClassificationDialog::~ClassificationDialog() { - disposeOnce(); -} - -void ClassificationDialog::dispose() -{ - m_pOkButton.clear(); - m_pEditWindow.clear(); - m_pSignButton.clear(); - m_pToolBox.clear(); - m_pRecentlyUsedListBox.clear(); - m_pClassificationListBox.clear(); - m_pInternationalClassificationListBox.clear(); - m_pMarkingLabel.clear(); - m_pMarkingListBox.clear(); - m_pIntellectualPropertyPartListBox.clear(); - m_pIntellectualPropertyPartNumberListBox.clear(); - m_pIntellectualPropertyPartAddButton.clear(); - m_pIntellectualPropertyPartEdit.clear(); - m_pIntellectualPropertyExpander.clear(); - - ModalDialog::dispose(); } -short ClassificationDialog::Execute() +short ClassificationDialog::run() { readRecentlyUsed(); readIn(m_aInitialValues); @@ -279,7 +251,7 @@ short ClassificationDialog::Execute() int nNumber = 1; if (m_aRecentlyUsedValuesCollection.empty()) { - m_pRecentlyUsedListBox->Disable(); + m_xRecentlyUsedListBox->set_sensitive(false); } else { @@ -289,11 +261,11 @@ short ClassificationDialog::Execute() OUString rDescription = OUString::number(nNumber) + ": " + rContentRepresentation; nNumber++; - m_pRecentlyUsedListBox->InsertEntry(rDescription); + m_xRecentlyUsedListBox->append_text(rDescription); } } - short nResult = ModalDialog::Execute(); + short nResult = GenericDialogController::run(); if (nResult == RET_OK) { writeRecentlyUsed(); @@ -312,7 +284,7 @@ void ClassificationDialog::insertCategoryField(sal_Int32 nID) void ClassificationDialog::insertField(ClassificationType eType, OUString const & rString, OUString const & rFullString, OUString const & rIdentifier) { ClassificationField aField(eType, rString, rFullString, rIdentifier); - m_pEditWindow->InsertField(SvxFieldItem(aField, EE_FEATURE_FIELD)); + m_xEditWindow->InsertField(SvxFieldItem(aField, EE_FEATURE_FIELD)); } void ClassificationDialog::setupValues(std::vector<ClassificationResult> const & rInput) @@ -441,7 +413,7 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp { case svx::ClassificationType::TEXT: { - m_pEditWindow->pEdView->InsertText(rClassificationResult.msName); + m_xEditWindow->pEdView->InsertText(rClassificationResult.msName); } break; @@ -457,9 +429,9 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp if (sAbbreviatedName.isEmpty()) sAbbreviatedName = maHelper.GetAbbreviatedBACName(sName); - m_pClassificationListBox->SelectEntry(sName); - m_nCurrentSelectedCategory = m_pClassificationListBox->GetSelectedEntryPos(); - m_pInternationalClassificationListBox->SelectEntryPos(m_pClassificationListBox->GetSelectedEntryPos()); + m_xClassificationListBox->set_active_text(sName); + m_nCurrentSelectedCategory = m_xClassificationListBox->get_active(); + m_xInternationalClassificationListBox->set_active(m_xClassificationListBox->get_active()); insertField(rClassificationResult.meType, sAbbreviatedName, sName, rClassificationResult.msIdentifier); } @@ -467,7 +439,7 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp case svx::ClassificationType::MARKING: { - m_pMarkingListBox->SelectEntry(rClassificationResult.msName); + m_xMarkingListBox->select_text(rClassificationResult.msName); insertField(rClassificationResult.meType, rClassificationResult.msName, rClassificationResult.msName, rClassificationResult.msIdentifier); } break; @@ -483,13 +455,13 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp nParagraph++; if (nParagraph != 0) - m_pEditWindow->pEdView->InsertParaBreak(); + m_xEditWindow->pEdView->InsertParaBreak(); // Set paragraph font weight FontWeight eWeight = (rClassificationResult.msName == "BOLD") ? WEIGHT_BOLD : WEIGHT_NORMAL; - std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(m_pEditWindow->pEdEngine->GetParaAttribs(nParagraph))); + std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(m_xEditWindow->pEdEngine->GetParaAttribs(nParagraph))); pSet->Put(SvxWeightItem(eWeight, EE_CHAR_WEIGHT)); - m_pEditWindow->pEdEngine->SetParaAttribs(nParagraph, *pSet); + m_xEditWindow->pEdEngine->SetParaAttribs(nParagraph, *pSet); } break; @@ -502,7 +474,7 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp void ClassificationDialog::toggleWidgetsDependingOnCategory() { - const EditEngine& rEditEngine = m_pEditWindow->getEditEngine(); + const EditEngine& rEditEngine = m_xEditWindow->getEditEngine(); for (sal_Int32 nParagraph = 0; nParagraph < rEditEngine.GetParagraphCount(); ++nParagraph) { @@ -515,7 +487,7 @@ void ClassificationDialog::toggleWidgetsDependingOnCategory() const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(aFieldInfo.pFieldItem->GetField()); if (pClassificationField && pClassificationField->meType == ClassificationType::CATEGORY) { - m_pOkButton->Enable(); + m_xOkButton->set_sensitive(true); return; } } @@ -523,16 +495,16 @@ void ClassificationDialog::toggleWidgetsDependingOnCategory() } // Category field in the text edit has been deleted, so reset the list boxes - m_pOkButton->Disable(); - m_pClassificationListBox->SetNoSelection(); - m_pInternationalClassificationListBox->SetNoSelection(); + m_xOkButton->set_sensitive(false); + m_xClassificationListBox->set_active(-1); + m_xInternationalClassificationListBox->set_active(-1); } std::vector<ClassificationResult> ClassificationDialog::getResult() { std::vector<ClassificationResult> aClassificationResults; - std::unique_ptr<EditTextObject> pEditText(m_pEditWindow->pEdEngine->CreateTextObject()); + std::unique_ptr<EditTextObject> pEditText(m_xEditWindow->pEdEngine->CreateTextObject()); sal_Int32 nCurrentParagraph = -1; @@ -546,7 +518,7 @@ std::vector<ClassificationResult> ClassificationDialog::getResult() // Get Weight of current paragraph FontWeight eFontWeight = WEIGHT_NORMAL; - SfxItemSet aItemSet(m_pEditWindow->pEdEngine->GetParaAttribs(nCurrentParagraph)); + SfxItemSet aItemSet(m_xEditWindow->pEdEngine->GetParaAttribs(nCurrentParagraph)); if (const SfxPoolItem* pItem = aItemSet.GetItem(EE_CHAR_WEIGHT, false)) { const SvxWeightItem* pWeightItem = dynamic_cast<const SvxWeightItem*>(pItem); @@ -565,7 +537,7 @@ std::vector<ClassificationResult> ClassificationDialog::getResult() const SvxFieldItem* pFieldItem = findField(rSection); ESelection aSelection(rSection.mnParagraph, rSection.mnStart, rSection.mnParagraph, rSection.mnEnd); - const OUString sDisplayString = m_pEditWindow->pEdEngine->GetText(aSelection); + const OUString sDisplayString = m_xEditWindow->pEdEngine->GetText(aSelection); if (!sDisplayString.isEmpty()) { const ClassificationField* pClassificationField = pFieldItem ? dynamic_cast<const ClassificationField*>(pFieldItem->GetField()) : nullptr; @@ -585,13 +557,13 @@ std::vector<ClassificationResult> ClassificationDialog::getResult() return aClassificationResults; } -IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void) +IMPL_LINK(ClassificationDialog, SelectClassificationHdl, weld::ComboBox&, rBox, void) { - const sal_Int32 nSelected = rBox.GetSelectedEntryPos(); + const sal_Int32 nSelected = rBox.get_active(); if (nSelected < 0 || m_nCurrentSelectedCategory == nSelected) return; - std::unique_ptr<EditTextObject> pEditText(m_pEditWindow->pEdEngine->CreateTextObject()); + std::unique_ptr<EditTextObject> pEditText(m_xEditWindow->pEdEngine->CreateTextObject()); std::vector<editeng::Section> aSections; pEditText->GetAllSections(aSections); @@ -616,19 +588,19 @@ IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void) } if (bReplaceExisting) - m_pEditWindow->pEdView->SetSelection(aExistingFieldSelection); + m_xEditWindow->pEdView->SetSelection(aExistingFieldSelection); insertCategoryField(nSelected); // Change category to the new selection - m_pInternationalClassificationListBox->SelectEntryPos(nSelected); - m_pClassificationListBox->SelectEntryPos(nSelected); + m_xInternationalClassificationListBox->set_active(nSelected); + m_xClassificationListBox->set_active(nSelected); m_nCurrentSelectedCategory = nSelected; } -IMPL_LINK(ClassificationDialog, SelectMarkingHdl, ListBox&, rBox, void) +IMPL_LINK(ClassificationDialog, SelectMarkingHdl, weld::TreeView&, rBox, void) { - sal_Int32 nSelected = rBox.GetSelectedEntryPos(); + sal_Int32 nSelected = rBox.get_selected_index(); if (nSelected >= 0) { const OUString aString = maHelper.GetMarkings()[nSelected]; @@ -636,69 +608,62 @@ IMPL_LINK(ClassificationDialog, SelectMarkingHdl, ListBox&, rBox, void) } } -IMPL_LINK(ClassificationDialog, SelectIPPartNumbersHdl, ListBox&, rBox, void) +IMPL_LINK(ClassificationDialog, SelectIPPartNumbersHdl, weld::TreeView&, rBox, void) { - sal_Int32 nSelected = rBox.GetSelectedEntryPos(); + sal_Int32 nSelected = rBox.get_selected_index(); if (nSelected >= 0) { OUString sString = maHelper.GetIntellectualPropertyPartNumbers()[nSelected]; - m_pIntellectualPropertyPartEdit->ReplaceSelected(sString); - m_pIntellectualPropertyPartEdit->GrabFocus(); + m_xIntellectualPropertyPartEdit->replace_selection(sString); + m_xIntellectualPropertyPartEdit->grab_focus(); } } -IMPL_LINK(ClassificationDialog, SelectRecentlyUsedHdl, ListBox&, rBox, void) +IMPL_LINK(ClassificationDialog, SelectRecentlyUsedHdl, weld::ComboBox&, rBox, void) { - sal_Int32 nSelected = rBox.GetSelectedEntryPos(); + sal_Int32 nSelected = rBox.get_active(); if (nSelected >= 0) { - m_pEditWindow->pEdEngine->Clear(); + m_xEditWindow->pEdEngine->Clear(); readIn(m_aRecentlyUsedValuesCollection[nSelected]); } } -IMPL_LINK(ClassificationDialog, SelectIPPartHdl, ListBox&, rBox, void) +IMPL_LINK(ClassificationDialog, SelectIPPartHdl, weld::TreeView&, rBox, void) { - const sal_Int32 nSelected = rBox.GetSelectedEntryPos(); + const sal_Int32 nSelected = rBox.get_selected_index(); if (nSelected >= 0) { const OUString sString = maHelper.GetIntellectualPropertyParts()[nSelected]; - m_pIntellectualPropertyPartEdit->ReplaceSelected(sString); - m_pIntellectualPropertyPartEdit->GrabFocus(); + m_xIntellectualPropertyPartEdit->replace_selection(sString); + m_xIntellectualPropertyPartEdit->grab_focus(); } } -IMPL_LINK(ClassificationDialog, ButtonClicked, Button*, pButton, void) +IMPL_LINK(ClassificationDialog, ButtonClicked, weld::Button&, rButton, void) { - if (pButton == m_pSignButton) + if (&rButton == m_xSignButton.get()) { m_aParagraphSignHandler(); } - else if (pButton == m_pIntellectualPropertyPartAddButton) + else if (&rButton == m_xIntellectualPropertyPartAddButton.get()) { - const OUString sString = m_pIntellectualPropertyPartEdit->GetText(); + const OUString sString = m_xIntellectualPropertyPartEdit->get_text(); insertField(ClassificationType::INTELLECTUAL_PROPERTY_PART, sString, sString); } } - -IMPL_LINK_NOARG(ClassificationDialog, SelectToolboxHdl, ToolBox*, void) +IMPL_LINK_NOARG(ClassificationDialog, SelectToolboxHdl, weld::ToggleButton&, void) { - sal_uInt16 nId = m_pToolBox->GetCurItemId(); - const OUString sCommand = m_pToolBox->GetItemCommand(nId); - if (sCommand == "bold") - { - m_pEditWindow->InvertSelectionWeight(); - } + m_xEditWindow->InvertSelectionWeight(); } - IMPL_LINK_NOARG(ClassificationDialog, EditWindowModifiedHdl, LinkParamNone*, void) { toggleWidgetsDependingOnCategory(); } -IMPL_STATIC_LINK(ClassificationDialog, ExpandedHdl, VclExpander&, rExpander, void) +IMPL_STATIC_LINK(ClassificationDialog, ExpandedHdl, weld::Expander&, rExpander, void) { std::shared_ptr<comphelper::ConfigurationChanges> aConfigurationChanges(comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Classification::IntellectualPropertySectionExpanded::set(rExpander.get_expanded(), aConfigurationChanges); diff --git a/svx/source/dialog/ClassificationEditView.cxx b/svx/source/dialog/ClassificationEditView.cxx index 6ab21075b402..e428f02172b6 100644 --- a/svx/source/dialog/ClassificationEditView.cxx +++ b/svx/source/dialog/ClassificationEditView.cxx @@ -19,11 +19,8 @@ #include <svl/itemset.hxx> #include <editeng/wghtitem.hxx> #include <editeng/eeitem.hxx> - -extern "C" SAL_DLLPUBLIC_EXPORT void makeClassificationEditView(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap &) -{ - rRet = VclPtr<svx::ClassificationEditView>::Create(pParent, WB_BORDER|WB_TABSTOP); -} +#include <svx/sdr/overlay/overlaymanager.hxx> +#include <svx/sdr/overlay/overlayselection.hxx> namespace svx { @@ -43,52 +40,61 @@ OUString ClassificationEditEngine::CalcFieldValue(const SvxFieldItem& rField, sa return aString; } -ClassificationEditView::ClassificationEditView(vcl::Window* pParent, WinBits nBits) - : Control(pParent, nBits) +ClassificationEditView::ClassificationEditView() +{ +} + +void ClassificationEditView::SetDrawingArea(weld::DrawingArea* pDrawingArea) { + Size aSize(500, 100); + pDrawingArea->set_size_request(aSize.Width(), aSize.Height()); + SetOutputSizePixel(aSize); + + weld::CustomWidgetController::SetDrawingArea(pDrawingArea); + EnableRTL(false); const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); Color aBgColor = rStyleSettings.GetWindowColor(); - float fScaleFactor = GetDPIScaleFactor(); - set_width_request(500 * fScaleFactor); - set_height_request(100 * fScaleFactor); + OutputDevice& rDevice = pDrawingArea->get_ref_device(); - SetMapMode(MapMode(MapUnit::MapTwip)); - SetPointer(PointerStyle::Text); - SetBackground(aBgColor); + rDevice.SetMapMode(MapMode(MapUnit::MapTwip)); + rDevice.SetBackground(aBgColor); - Size aOutputSize(GetOutputSize()); - Size aSize(aOutputSize); + Size aOutputSize(rDevice.PixelToLogic(aSize)); + aSize = aOutputSize; aSize.setHeight( aSize.Height() * 4 ); pEdEngine.reset(new ClassificationEditEngine(EditEngine::CreatePool())); pEdEngine->SetPaperSize( aSize ); - pEdEngine->SetRefDevice( this ); + pEdEngine->SetRefDevice( &rDevice ); pEdEngine->SetControlWord(pEdEngine->GetControlWord() | EEControlBits::MARKFIELDS); - pEdView.reset(new EditView(pEdEngine.get(), this)); + pEdView.reset(new EditView(pEdEngine.get(), nullptr)); + pEdView->setEditViewCallbacks(this); pEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize)); pEdView->SetBackgroundColor(aBgColor); pEdEngine->InsertView(pEdView.get()); + + pDrawingArea->set_text_cursor(); } ClassificationEditView::~ClassificationEditView() { - disposeOnce(); } void ClassificationEditView::Resize() { - Size aOutputSize(GetOutputSize()); + OutputDevice& rDevice = GetDrawingArea()->get_ref_device(); + Size aOutputSize(rDevice.PixelToLogic(GetOutputSizePixel())); Size aSize(aOutputSize); aSize.setHeight( aSize.Height() * 4 ); pEdEngine->SetPaperSize(aSize); pEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize)); - Control::Resize(); + weld::CustomWidgetController::Resize(); } void ClassificationEditView::InsertField(const SvxFieldItem& rFieldItem) @@ -122,63 +128,80 @@ void ClassificationEditView::InvertSelectionWeight() void ClassificationEditView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) { + rRenderContext.Push(PushFlags::ALL); + rRenderContext.SetClipRegion(); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); Color aBgColor = rStyleSettings.GetWindowColor(); pEdView->SetBackgroundColor(aBgColor); - SetBackground(aBgColor); + rRenderContext.SetBackground(aBgColor); - Control::Paint(rRenderContext, rRect); - - pEdView->Paint(rRect); + tools::Rectangle aLogicRect(rRenderContext.PixelToLogic(rRect)); + pEdView->Paint(aLogicRect, &rRenderContext); if (HasFocus()) + { pEdView->ShowCursor(); + vcl::Cursor* pCursor = pEdView->GetCursor(); + pCursor->DrawToDevice(rRenderContext); + } + + std::vector<tools::Rectangle> aLogicRects; + + // get logic selection + pEdView->GetSelectionRectangles(aLogicRects); + + rRenderContext.SetLineColor(); + rRenderContext.SetFillColor(COL_BLACK); + rRenderContext.SetRasterOp(RasterOp::Invert); + + for (const auto &rSelectionRect : aLogicRects) + rRenderContext.DrawRect(rSelectionRect); + + rRenderContext.Pop(); } -void ClassificationEditView::MouseMove(const MouseEvent& rMEvt) +bool ClassificationEditView::MouseMove(const MouseEvent& rMEvt) { - pEdView->MouseMove(rMEvt); + return pEdView->MouseMove(rMEvt); } -void ClassificationEditView::MouseButtonDown(const MouseEvent& rMEvt) +bool ClassificationEditView::MouseButtonDown(const MouseEvent& rMEvt) { if (!HasFocus()) GrabFocus(); - pEdView->MouseButtonDown(rMEvt); + return pEdView->MouseButtonDown(rMEvt); } -void ClassificationEditView::MouseButtonUp(const MouseEvent& rMEvt) +bool ClassificationEditView::MouseButtonUp(const MouseEvent& rMEvt) { - pEdView->MouseButtonUp(rMEvt); + return pEdView->MouseButtonUp(rMEvt); } -void ClassificationEditView::KeyInput(const KeyEvent& rKEvt) +bool ClassificationEditView::KeyInput(const KeyEvent& rKEvt) { sal_uInt16 nKey = rKEvt.GetKeyCode().GetModifier() + rKEvt.GetKeyCode().GetCode(); if (nKey == KEY_TAB || nKey == KEY_TAB + KEY_SHIFT) { - Control::KeyInput( rKEvt ); + return false; } else if (!pEdView->PostKeyEvent(rKEvt)) { - Control::KeyInput(rKEvt); + return false; } -} -void ClassificationEditView::Command(const CommandEvent& rCEvt) -{ - pEdView->Command(rCEvt); + return true; } void ClassificationEditView::GetFocus() { pEdView->ShowCursor(); - Control::GetFocus(); + weld::CustomWidgetController::GetFocus(); } } // end sfx2 diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index 094bad2aa1cf..47cd3a0939be 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -623,7 +623,7 @@ namespace // callback from the active EditView, forward to evtl. existing instances of the // TextEditOverlayObject(s). This will additionally update the selection which // is an integral part of the text visualization -void SdrObjEditView::EditViewInvalidate() const +void SdrObjEditView::EditViewInvalidate(const tools::Rectangle&) const { if (IsTextEdit()) { @@ -663,6 +663,11 @@ void SdrObjEditView::EditViewSelectionChange() const } } +OutputDevice& SdrObjEditView::EditViewOutputDevice() const +{ + return *pTextEditWin; +} + void SdrObjEditView::TextEditDrawing(SdrPaintWindow& rPaintWindow) const { if (!comphelper::LibreOfficeKit::isActive()) @@ -670,7 +675,7 @@ void SdrObjEditView::TextEditDrawing(SdrPaintWindow& rPaintWindow) const // adapt all TextEditOverlayObject(s), so call EditViewInvalidate() // to update accordingly (will update selection, too). Suppress new // stuff when LibreOfficeKit is active - EditViewInvalidate(); + EditViewInvalidate(tools::Rectangle()); } else { diff --git a/svx/source/svdraw/svdoutl.cxx b/svx/source/svdraw/svdoutl.cxx index c2befff17c15..0387afaa5ec9 100644 --- a/svx/source/svdraw/svdoutl.cxx +++ b/svx/source/svdraw/svdoutl.cxx @@ -97,7 +97,7 @@ bool SdrOutliner::hasEditViewCallbacks() const { OutlinerView* pOutlinerView = GetView(a); - if (pOutlinerView && pOutlinerView->GetEditView().hasEditViewCallbacks()) + if (pOutlinerView && pOutlinerView->GetEditView().getEditViewCallbacks()) { return true; } diff --git a/svx/uiconfig/ui/classificationdialog.ui b/svx/uiconfig/ui/classificationdialog.ui index 47c413093d85..fb381e5d227e 100644 --- a/svx/uiconfig/ui/classificationdialog.ui +++ b/svx/uiconfig/ui/classificationdialog.ui @@ -1,13 +1,47 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.2 --> +<!-- Generated with glade 3.22.1 --> <interface domain="svx"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">cmd/lc_bold.png</property> + </object> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkTreeStore" id="liststore2"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkTreeStore" id="liststore3"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> <object class="GtkDialog" id="AdvancedDocumentClassificationDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="classificationdialog|dialogname">Classification</property> + <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -164,14 +198,36 @@ </packing> </child> <child> - <object class="GtkTreeView" id="markingLB"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="show_expanders">False</property> - <child internal-child="selection"> - <object class="GtkTreeSelection"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="markingLB"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn3"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer1"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> @@ -192,6 +248,7 @@ <property name="can_focus">False</property> <property name="hexpand">True</property> <property name="vexpand">True</property> + <property name="row_spacing">3</property> <child> <object class="GtkLabel"> <property name="visible">True</property> @@ -210,24 +267,14 @@ <property name="visible">True</property> <property name="can_focus">False</property> <child> - <object class="GtkToolbar" id="toolbox"> + <object class="GtkToggleButton" id="toolbox"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="show_arrow">False</property> - <child> - <object class="GtkToolButton" id="bold"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="action_name">bold</property> - <property name="label" translatable="yes" context="classificationdialog|boldButton">Bold</property> - <property name="use_underline">True</property> - <property name="icon_name">cmd/lc_bold.png</property> - </object> - <packing> - <property name="expand">False</property> - <property name="homogeneous">True</property> - </packing> - </child> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes" context="classificationdialog|boldButton">Bold</property> + <property name="image">image1</property> + <property name="use_underline">True</property> + <property name="always_show_image">True</property> </object> <packing> <property name="expand">False</property> @@ -255,10 +302,25 @@ </packing> </child> <child> - <object class="svxlo-ClassificationEditView" id="classificationEditWindow"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hexpand">True</property> + <property name="border_width">0</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkDrawingArea" id="classificationEditWindow"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK</property> + <property name="hexpand">True</property> + </object> + </child> + </object> + </child> </object> <packing> <property name="left_attach">0</property> @@ -296,7 +358,7 @@ </packing> </child> <child> - <object class="svxlo-IntellectualPropertyPartEdit" id="intellectualPropertyPartEntry"> + <object class="GtkEntry" id="intellectualPropertyPartEntry"> <property name="visible">True</property> <property name="can_focus">True</property> </object> @@ -333,14 +395,36 @@ </packing> </child> <child> - <object class="GtkTreeView" id="intellectualPropertyPartNumberLB"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="show_expanders">False</property> - <child internal-child="selection"> - <object class="GtkTreeSelection"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="intellectualPropertyPartNumberLB"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore2</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn4"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer5"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> @@ -349,14 +433,36 @@ </packing> </child> <child> - <object class="GtkTreeView" id="intellectualPropertyPartLB"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="show_expanders">False</property> - <child internal-child="selection"> - <object class="GtkTreeSelection"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="intellectualPropertyPartLB"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore3</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn6"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer6"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> @@ -397,8 +503,5 @@ <action-widget response="-6">cancel</action-widget> <action-widget response="-11">help</action-widget> </action-widgets> - <child> - <placeholder/> - </child> </object> </interface> diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index e140f6cad49f..0819b4022553 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -1237,32 +1237,32 @@ void SwDocShell::Execute(SfxRequest& rReq) break; case SID_CLASSIFICATION_DIALOG: { - VclPtr<svx::ClassificationDialog> pDialog(VclPtr<svx::ClassificationDialog>::Create(&GetView()->GetViewFrame()->GetWindow(), false)); + std::shared_ptr<svx::ClassificationDialog> xDialog(new svx::ClassificationDialog(GetView()->GetViewFrame()->GetWindow().GetFrameWeld(), false)); SwWrtShell* pShell = GetWrtShell(); std::vector<svx::ClassificationResult> aInput = pShell->CollectAdvancedClassification(); - pDialog->setupValues(aInput); + xDialog->setupValues(aInput); - pDialog->StartExecuteAsync([pDialog, pShell](sal_Int32 nResult){ + weld::DialogController::runAsync(xDialog, [xDialog, pShell](sal_Int32 nResult){ if (RET_OK == nResult) - pShell->ApplyAdvancedClassification(pDialog->getResult()); + pShell->ApplyAdvancedClassification(xDialog->getResult()); }); } break; case SID_PARAGRAPH_SIGN_CLASSIFY_DLG: { SwWrtShell* pShell = GetWrtShell(); - VclPtr<svx::ClassificationDialog> pDialog(VclPtr<svx::ClassificationDialog>::Create(&GetView()->GetViewFrame()->GetWindow(), true, [pShell]() + std::shared_ptr<svx::ClassificationDialog> xDialog(new svx::ClassificationDialog(GetView()->GetViewFrame()->GetWindow().GetFrameWeld(), true, [pShell]() { pShell->SignParagraph(); })); std::vector<svx::ClassificationResult> aInput = pShell->CollectParagraphClassification(); - pDialog->setupValues(aInput); + xDialog->setupValues(aInput); - pDialog->StartExecuteAsync([pDialog, pShell](sal_Int32 nResult){ + weld::DialogController::runAsync(xDialog, [xDialog, pShell](sal_Int32 nResult){ if (RET_OK == nResult) - pShell->ApplyParagraphClassification(pDialog->getResult()); + pShell->ApplyParagraphClassification(xDialog->getResult()); }); } break; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index b07ff29b08b4..5b60f02d47d4 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -48,6 +48,7 @@ #include <vcl/layout.hxx> #include <vcl/menubtn.hxx> #include <vcl/prgsbar.hxx> +#include <vcl/ptrstyle.hxx> #include <vcl/slider.hxx> #include <vcl/sysdata.hxx> #include <vcl/svlbitm.hxx> @@ -3804,6 +3805,11 @@ public: weld::Widget::connect_key_release(rLink); } + virtual void set_text_cursor() override + { + m_xDrawingArea->SetPointer(PointerStyle::Text); + } + virtual a11yref get_accessible_parent() override { vcl::Window* pParent = m_xDrawingArea->GetParent(); diff --git a/vcl/source/window/cursor.cxx b/vcl/source/window/cursor.cxx index e7ce47559b81..4839b7d56fc7 100644 --- a/vcl/source/window/cursor.cxx +++ b/vcl/source/window/cursor.cxx @@ -126,26 +126,48 @@ static void ImplCursorInvert(vcl::Window* pWindow, ImplCursorData const * pData) pGuard->SetPaintRect(pRenderContext->PixelToLogic(aPaintRect)); } -void vcl::Cursor::ImplDraw() +bool vcl::Cursor::ImplPrepForDraw(OutputDevice* pDevice, ImplCursorData& rData) { - if ( mpData && mpData->mpWindow && !mpData->mbCurVisible ) + if (pDevice && !rData.mbCurVisible) { - vcl::Window* pWindow = mpData->mpWindow; - mpData->maPixPos = pWindow->LogicToPixel( maPos ); - mpData->maPixSize = pWindow->LogicToPixel( maSize ); - mpData->mnOrientation = mnOrientation; - mpData->mnDirection = mnDirection; + rData.maPixPos = pDevice->LogicToPixel( maPos ); + rData.maPixSize = pDevice->LogicToPixel( maSize ); + rData.mnOrientation = mnOrientation; + rData.mnDirection = mnDirection; // correct the position with the offset - mpData->maPixRotOff = mpData->maPixPos; + rData.maPixRotOff = rData.maPixPos; // use width (as set in Settings) if size is 0, - if ( !mpData->maPixSize.Width() ) - mpData->maPixSize.setWidth( pWindow->GetSettings().GetStyleSettings().GetCursorSize() ); + if (!rData.maPixSize.Width()) + rData.maPixSize.setWidth(pDevice->GetSettings().GetStyleSettings().GetCursorSize()); + return true; + } + return false; +} - // calculate output area and display - ImplCursorInvert(pWindow, mpData.get()); - mpData->mbCurVisible = true; +void vcl::Cursor::ImplDraw() +{ + if (mpData && mpData->mpWindow) + { + // calculate output area + if (ImplPrepForDraw(mpData->mpWindow, *mpData)) + { + // display + ImplCursorInvert(mpData->mpWindow, mpData.get()); + mpData->mbCurVisible = true; + } + } +} + +void vcl::Cursor::DrawToDevice(OutputDevice& rRenderContext) +{ + ImplCursorData aData; + // calculate output area + if (ImplPrepForDraw(&rRenderContext, aData)) + { + // display + ImplCursorInvert(&rRenderContext, &aData); } } diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 4041202ed6cd..cdf6829d896c 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2396,6 +2396,21 @@ std::unique_ptr<weld::Container> GtkInstanceWidget::weld_parent() const return std::make_unique<GtkInstanceContainer>(GTK_CONTAINER(pParent), m_pBuilder, false); } +namespace +{ + void set_cursor(GtkWidget* pWidget, const char *pName) + { + if (!gtk_widget_get_realized(pWidget)) + gtk_widget_realize(pWidget); + GdkDisplay *pDisplay = gtk_widget_get_display(pWidget); + GdkCursor *pCursor = pName ? gdk_cursor_new_from_name(pDisplay, pName) : nullptr; + gdk_window_set_cursor(gtk_widget_get_window(pWidget), pCursor); + gdk_display_flush(pDisplay); + if (pCursor) + g_object_unref(pCursor); + } +} + class GtkInstanceWindow : public GtkInstanceContainer, public virtual weld::Window { private: @@ -2440,14 +2455,7 @@ public: virtual void set_busy_cursor(bool bBusy) override { - if (!gtk_widget_get_realized(m_pWidget)) - gtk_widget_realize(m_pWidget); - GdkDisplay *pDisplay = gtk_widget_get_display(m_pWidget); - GdkCursor *pCursor = bBusy ? gdk_cursor_new_from_name(pDisplay, "progress") : nullptr; - gdk_window_set_cursor(gtk_widget_get_window(m_pWidget), pCursor); - gdk_display_flush(pDisplay); - if (pCursor) - g_object_unref(pCursor); + set_cursor(m_pWidget, bBusy ? "progress" : nullptr); } virtual void set_modal(bool bModal) override @@ -7599,6 +7607,11 @@ public: m_xDevice->EnableRTL(bRTL); } + virtual void set_text_cursor() override + { + set_cursor(GTK_WIDGET(m_pDrawingArea), "text"); + } + virtual void queue_draw() override { gtk_widget_queue_draw(GTK_WIDGET(m_pDrawingArea)); |