diff options
Diffstat (limited to 'sw/source/uibase/docvw/SidebarTxtControl.cxx')
-rw-r--r-- | sw/source/uibase/docvw/SidebarTxtControl.cxx | 106 |
1 files changed, 58 insertions, 48 deletions
diff --git a/sw/source/uibase/docvw/SidebarTxtControl.cxx b/sw/source/uibase/docvw/SidebarTxtControl.cxx index e9ce19243225..c1490856028a 100644 --- a/sw/source/uibase/docvw/SidebarTxtControl.cxx +++ b/sw/source/uibase/docvw/SidebarTxtControl.cxx @@ -17,13 +17,14 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <config_wasm_strip.h> + #include "SidebarTxtControl.hxx" #include <docsh.hxx> #include <doc.hxx> #include <PostItMgr.hxx> -#include <edtwin.hxx> #include <cmdid.h> #include <strings.hrc> @@ -37,8 +38,9 @@ #include <sfx2/sfxhelp.hxx> #include <vcl/commandevent.hxx> +#include <vcl/event.hxx> +#include <vcl/ptrstyle.hxx> #include <vcl/svapp.hxx> -#include <vcl/help.hxx> #include <vcl/weld.hxx> #include <vcl/gradient.hxx> #include <vcl/settings.hxx> @@ -47,13 +49,12 @@ #include <editeng/editeng.hxx> #include <editeng/editview.hxx> #include <editeng/flditem.hxx> -#include <comphelper/lok.hxx> -#include <sfx2/lokhelper.hxx> #include <uitool.hxx> #include <view.hxx> #include <wrtsh.hxx> #include <AnnotationWin.hxx> +#include <IDocumentDeviceAccess.hxx> #include <redline.hxx> #include <memory> @@ -82,7 +83,7 @@ EditEngine* SidebarTextControl::GetEditEngine() const OutlinerView* pOutlinerView = mrSidebarWin.GetOutlinerView(); if (!pOutlinerView) return nullptr; - return pOutlinerView->GetEditView().GetEditEngine(); + return &pOutlinerView->GetEditView().getEditEngine(); } void SidebarTextControl::SetDrawingArea(weld::DrawingArea* pDrawingArea) @@ -105,22 +106,27 @@ void SidebarTextControl::SetDrawingArea(weld::DrawingArea* pDrawingArea) rDevice.SetBackground(aBgColor); Size aOutputSize(rDevice.PixelToLogic(aSize)); - aSize = aOutputSize; - aSize.setHeight(aSize.Height()); EditView* pEditView = GetEditView(); pEditView->setEditViewCallbacks(this); - EditEngine* pEditEngine = GetEditEngine(); - pEditEngine->SetPaperSize(aSize); - pEditEngine->SetRefDevice(&rDevice); + EditEngine& rEditEngine = pEditView->getEditEngine(); + // For tdf#143443 note we want an 'infinite' height initially (which is the + // editengines default). For tdf#144686 it is helpful if the initial width + // is the "SidebarWidth" so the calculated text height is always meaningful + // for layout in the sidebar. + Size aPaperSize(mrPostItMgr.GetSidebarWidth(), rEditEngine.GetPaperSize().Height()); + rEditEngine.SetPaperSize(aPaperSize); + rEditEngine.SetRefDevice(mrDocView.GetWrtShell().getIDocumentDeviceAccess().getReferenceDevice(false)); pEditView->SetOutputArea(tools::Rectangle(Point(0, 0), aOutputSize)); pEditView->SetBackgroundColor(aBgColor); pDrawingArea->set_cursor(PointerStyle::Text); +#if !ENABLE_WASM_STRIP_ACCESSIBILITY InitAccessible(); +#endif } void SidebarTextControl::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark) @@ -147,6 +153,8 @@ void SidebarTextControl::LoseFocus() { Invalidate(); } + // set false for autoscroll to typing location + mrSidebarWin.LockView(false); } OUString SidebarTextControl::RequestHelp(tools::Rectangle& rHelpRect) @@ -170,12 +178,12 @@ OUString SidebarTextControl::RequestHelp(tools::Rectangle& rHelpRect) } } - const char* pResId = nullptr; + TranslateId pResId; switch( mrSidebarWin.GetLayoutStatus() ) { case SwPostItHelper::INSERTED: pResId = STR_REDLINE_INSERT; break; case SwPostItHelper::DELETED: pResId = STR_REDLINE_DELETE; break; - default: pResId = nullptr; + default: break; } SwContentAtPos aContentAtPos( IsAttrAtPos::Redline ); @@ -204,13 +212,13 @@ void SidebarTextControl::DrawForPage(OutputDevice* pDev, const Point& rPt) if (OutlinerView* pOutlinerView = mrSidebarWin.GetOutlinerView()) { - pOutlinerView->GetOutliner()->Draw(pDev, tools::Rectangle(rPt, aSize)); + pOutlinerView->GetOutliner()->Draw(*pDev, tools::Rectangle(rPt, aSize)); } if ( mrSidebarWin.GetLayoutStatus()!=SwPostItHelper::DELETED ) return; - pDev->Push(PushFlags::LINECOLOR); + pDev->Push(vcl::PushFlags::LINECOLOR); pDev->SetLineColor(mrSidebarWin.GetChangeColor()); Point aBottomRight(rPt); @@ -238,34 +246,34 @@ void SidebarTextControl::Paint(vcl::RenderContext& rRenderContext, const tools:: if (mrSidebarWin.IsMouseOverSidebarWin() || HasFocus()) { rRenderContext.DrawGradient(tools::Rectangle(aPos, rRenderContext.PixelToLogic(aSize)), - Gradient(GradientStyle::Linear, mrSidebarWin.ColorDark(), mrSidebarWin.ColorDark())); + Gradient(css::awt::GradientStyle_LINEAR, mrSidebarWin.ColorDark(), mrSidebarWin.ColorDark())); } else { rRenderContext.DrawGradient(tools::Rectangle(aPos, rRenderContext.PixelToLogic(aSize)), - Gradient(GradientStyle::Linear, mrSidebarWin.ColorLight(), mrSidebarWin.ColorDark())); + Gradient(css::awt::GradientStyle_LINEAR, mrSidebarWin.ColorLight(), mrSidebarWin.ColorDark())); } } DoPaint(rRenderContext, rRect); - if (mrSidebarWin.GetLayoutStatus() == SwPostItHelper::DELETED) - { - const AntialiasingFlags nFormerAntialiasing( rRenderContext.GetAntialiasing() ); - const bool bIsAntiAliasing = officecfg::Office::Common::Drawinglayer::AntiAliasing::get(); - if ( bIsAntiAliasing ) - rRenderContext.SetAntialiasing(AntialiasingFlags::Enable); - rRenderContext.SetLineColor(mrSidebarWin.GetChangeColor()); - rRenderContext.DrawLine(rRenderContext.PixelToLogic(aPos), - rRenderContext.PixelToLogic(aPos + Point(aSize.Width(), - aSize.Height() * 0.95))); - rRenderContext.DrawLine(rRenderContext.PixelToLogic(aPos + Point(aSize.Width(), - 0)), - rRenderContext.PixelToLogic(aPos + Point(0, - aSize.Height() * 0.95))); - if ( bIsAntiAliasing ) - rRenderContext.SetAntialiasing(nFormerAntialiasing); - } + if (mrSidebarWin.GetLayoutStatus() != SwPostItHelper::DELETED) + return; + + const AntialiasingFlags nFormerAntialiasing( rRenderContext.GetAntialiasing() ); + const bool bIsAntiAliasing = officecfg::Office::Common::Drawinglayer::AntiAliasing::get(); + if ( bIsAntiAliasing ) + rRenderContext.SetAntialiasing(AntialiasingFlags::Enable); + rRenderContext.SetLineColor(mrSidebarWin.GetChangeColor()); + rRenderContext.DrawLine(rRenderContext.PixelToLogic(aPos), + rRenderContext.PixelToLogic(aPos + Point(aSize.Width(), + aSize.Height() * 0.95))); + rRenderContext.DrawLine(rRenderContext.PixelToLogic(aPos + Point(aSize.Width(), + 0)), + rRenderContext.PixelToLogic(aPos + Point(0, + aSize.Height() * 0.95))); + if ( bIsAntiAliasing ) + rRenderContext.SetAntialiasing(nFormerAntialiasing); } void SidebarTextControl::MakeVisible() @@ -276,7 +284,9 @@ void SidebarTextControl::MakeVisible() bool SidebarTextControl::KeyInput( const KeyEvent& rKeyEvt ) { - if (getenv("SW_DEBUG") && rKeyEvt.GetKeyCode().GetCode() == KEY_F12) + const vcl::KeyCode& rKeyCode = rKeyEvt.GetKeyCode(); + const sal_uInt16 nKey = rKeyCode.GetCode(); + if (nKey == KEY_F12 && getenv("SW_DEBUG")) { if (rKeyEvt.GetKeyCode().IsShift()) { @@ -287,8 +297,6 @@ bool SidebarTextControl::KeyInput( const KeyEvent& rKeyEvt ) bool bDone = false; - const vcl::KeyCode& rKeyCode = rKeyEvt.GetKeyCode(); - sal_uInt16 nKey = rKeyCode.GetCode(); if ( ( rKeyCode.IsMod1() && rKeyCode.IsMod2() ) && ( (nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN) ) ) { @@ -317,18 +325,14 @@ bool SidebarTextControl::KeyInput( const KeyEvent& rKeyEvt ) /// HACK: need to switch off processing of Undo/Redo in Outliner if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) ) { - bool bIsProtected = mrSidebarWin.IsProtected(); + bool bIsProtected = mrSidebarWin.IsReadOnlyOrProtected(); if ( !bIsProtected || !EditEngine::DoesKeyChangeText(rKeyEvt) ) { EditView* pEditView = GetEditView(); bDone = pEditView && pEditView->PostKeyEvent(rKeyEvt); } else - { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetDrawingArea(), "modules/swriter/ui/inforeadonlydialog.ui")); - std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("InfoReadonlyDialog")); - xQuery->run(); - } + mrDocView.GetWrtShell().InfoReadOnlyDialog(false); } if (bDone) mrSidebarWin.ResizeIfNecessary( aOldHeight, mrSidebarWin.GetPostItTextHeight() ); @@ -341,7 +345,7 @@ bool SidebarTextControl::KeyInput( const KeyEvent& rKeyEvt ) } } - mrDocView.GetViewFrame()->GetBindings().InvalidateAll(false); + mrDocView.GetViewFrame().GetBindings().InvalidateAll(false); return bDone; } @@ -350,8 +354,7 @@ bool SidebarTextControl::MouseButtonDown(const MouseEvent& rMEvt) { if (EditView* pEditView = GetEditView()) { - SvtSecurityOptions aSecOpts; - bool bExecuteMod = aSecOpts.IsOptionSet( SvtSecurityOptions::EOption::CtrlClickHyperlink); + bool bExecuteMod = SvtSecurityOptions::IsOptionSet( SvtSecurityOptions::EOption::CtrlClickHyperlink); if ( !bExecuteMod || (rMEvt.GetModifier() == KEY_MOD1)) { @@ -379,7 +382,7 @@ bool SidebarTextControl::MouseButtonDown(const MouseEvent& rMEvt) bool bRet = WeldEditView::MouseButtonDown(rMEvt); - mrDocView.GetViewFrame()->GetBindings().InvalidateAll(false); + mrDocView.GetViewFrame().GetBindings().InvalidateAll(false); return bRet; } @@ -397,11 +400,18 @@ bool SidebarTextControl::MouseButtonUp(const MouseEvent& rMEvt) return bRet; } +bool SidebarTextControl::MouseMove(const MouseEvent& rMEvt) +{ + if (rMEvt.IsEnterWindow()) + GetDrawingArea()->set_cursor(PointerStyle::Text); + return WeldEditView::MouseMove(rMEvt); +} + IMPL_LINK( SidebarTextControl, OnlineSpellCallback, SpellCallbackInfo&, rInfo, void ) { if ( rInfo.nCommand == SpellCallbackCommand::STARTSPELLDLG ) { - mrDocView.GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SfxCallMode::ASYNCHRON); + mrDocView.GetViewFrame().GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SfxCallMode::ASYNCHRON); } } @@ -413,7 +423,7 @@ bool SidebarTextControl::Command( const CommandEvent& rCEvt ) { if (IsMouseCaptured()) ReleaseMouse(); - if ( !mrSidebarWin.IsProtected() && + if ( !mrSidebarWin.IsReadOnlyOrProtected() && pEditView && pEditView->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(), true )) { |