summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir.extern@allotropia.de>2024-04-16 17:09:28 +0200
committerSarper Akdemir <sarper.akdemir.extern@allotropia.de>2024-04-18 13:48:28 +0200
commitefef507cfd480cc6f1efc964ac2f9e033e18ad87 (patch)
tree66cc908f948b20ddb6439db9ce407d56b4717727
parent91f41cd463d8c5801f3da84c25d1cd058a1adb2a (diff)
tdf#33603: make the notes pane handle placeholder text on focus
Change-Id: Id2bca2b8a8bafa9da44a5f97a8e763b512078ef7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166152 Tested-by: Jenkins Reviewed-by: Sarper Akdemir <sarper.akdemir.extern@allotropia.de>
-rw-r--r--sd/source/ui/inc/NotesPanelView.hxx3
-rw-r--r--sd/source/ui/inc/NotesPanelViewShell.hxx2
-rw-r--r--sd/source/ui/inc/ViewShell.hxx14
-rw-r--r--sd/source/ui/view/NotesPanelView.cxx34
-rw-r--r--sd/source/ui/view/NotesPanelViewShell.cxx4
-rw-r--r--sd/source/ui/view/sdwindow.cxx2
6 files changed, 59 insertions, 0 deletions
diff --git a/sd/source/ui/inc/NotesPanelView.hxx b/sd/source/ui/inc/NotesPanelView.hxx
index 810cddd6af71..9f2b71523c09 100644
--- a/sd/source/ui/inc/NotesPanelView.hxx
+++ b/sd/source/ui/inc/NotesPanelView.hxx
@@ -39,6 +39,7 @@ class NotesPanelView final : public ::sd::SimpleOutlinerView
SdrTextObj* mpTextObj = nullptr;
bool mbIgnoreNotifications = false;
+ bool mbInFocus = false;
/** stores the last used document color.
this is changed in onUpdateStyleSettings()
@@ -61,6 +62,8 @@ public:
void Paint(const ::tools::Rectangle& rRect, ::sd::Window const* pWin);
void onResize();
+ void onGrabFocus();
+ void onLoseFocus();
OutlinerView* GetOutlinerView();
OutlinerView* GetViewByWindow(vcl::Window const* pWin) const override;
diff --git a/sd/source/ui/inc/NotesPanelViewShell.hxx b/sd/source/ui/inc/NotesPanelViewShell.hxx
index e79ac899fe30..39901d6e4faa 100644
--- a/sd/source/ui/inc/NotesPanelViewShell.hxx
+++ b/sd/source/ui/inc/NotesPanelViewShell.hxx
@@ -49,6 +49,8 @@ public:
virtual void Activate(bool IsMDIActivate) override;
/** this method is called when the visible area of the view from this viewshell is changed */
virtual void VisAreaChanged(const ::tools::Rectangle& rRect) override;
+ virtual void onGrabFocus() override;
+ virtual void onLoseFocus() override;
virtual void ArrangeGUIElements() override;
virtual SdPage* GetActualPage() override;
diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx
index 85bc43e86c09..6ee126db9027 100644
--- a/sd/source/ui/inc/ViewShell.hxx
+++ b/sd/source/ui/inc/ViewShell.hxx
@@ -412,6 +412,20 @@ public:
SdPage* pPage,
const sal_Int32 nInsertPosition = -1);
+ /** Called by sd::Window::LoseFocus to enable sd::ViewShell to take action
+ when focus is lost.
+
+ e.g. overriden by NotesPanelViewShell
+ */
+ virtual void onLoseFocus(){};
+
+ /** Called by sd::Window::GrabFocus to enable sd::ViewShell to take action
+ when focus is grabbed.
+
+ e.g. overriden by NotesPanelViewShell
+ */
+ virtual void onGrabFocus(){};
+
/// Allows adjusting the point or mark of the selection to a document coordinate.
void SetCursorMm100Position(const Point& rPosition, bool bPoint, bool bClearMark);
/// Gets the current selection
diff --git a/sd/source/ui/view/NotesPanelView.cxx b/sd/source/ui/view/NotesPanelView.cxx
index 2822a8df4c02..a2ae58e48331 100644
--- a/sd/source/ui/view/NotesPanelView.cxx
+++ b/sd/source/ui/view/NotesPanelView.cxx
@@ -224,6 +224,40 @@ void NotesPanelView::onResize()
}
}
+void NotesPanelView::onGrabFocus()
+{
+ if (mbInFocus)
+ return;
+ mbInFocus = true;
+
+ if (mpTextObj && mpTextObj->IsEmptyPresObj())
+ {
+ // clear the "Click to add Notes" text on entering the window.
+ maOutliner.SetToEmptyText();
+ }
+}
+
+void NotesPanelView::onLoseFocus()
+{
+ if (!mbInFocus)
+ return;
+ mbInFocus = false;
+
+ aModifyIdle.Stop();
+ if (mpTextObj)
+ {
+ if (maOutliner.GetEditEngine().GetText().getLength() == 0)
+ {
+ // if the notes are empty restore the placeholder text and state.
+ SdPage* pPage = dynamic_cast<SdPage*>(mpTextObj->getSdrPageFromSdrObject());
+ if (pPage)
+ pPage->RestoreDefaultText(mpTextObj);
+ }
+ else
+ setNotesToDoc();
+ }
+}
+
/**
* Handler for StatusEvents
*/
diff --git a/sd/source/ui/view/NotesPanelViewShell.cxx b/sd/source/ui/view/NotesPanelViewShell.cxx
index d4dd078dfc4d..82f3133dad75 100644
--- a/sd/source/ui/view/NotesPanelViewShell.cxx
+++ b/sd/source/ui/view/NotesPanelViewShell.cxx
@@ -233,6 +233,10 @@ void NotesPanelViewShell::VisAreaChanged(const ::tools::Rectangle& rRect)
GetViewShellBase().GetDrawController()->FireVisAreaChanged(rRect);
}
+void NotesPanelViewShell::onGrabFocus() { mpNotesPanelView->onGrabFocus(); }
+
+void NotesPanelViewShell::onLoseFocus() { mpNotesPanelView->onLoseFocus(); }
+
void NotesPanelViewShell::ArrangeGUIElements()
{
// Retrieve the current size (thickness) of the scroll bars. That is
diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx
index c684bee2caa8..d409aeec1304 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -742,6 +742,7 @@ void Window::LoseFocus()
{
mnTicks = 0;
vcl::Window::LoseFocus ();
+ GetViewShell()->onLoseFocus();
}
/**
@@ -751,6 +752,7 @@ void Window::GrabFocus()
{
mnTicks = 0;
vcl::Window::GrabFocus ();
+ GetViewShell()->onGrabFocus();
}
void Window::DataChanged( const DataChangedEvent& rDCEvt )