summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorGökay Şatır <gokaysatir@gmail.com>2024-02-22 13:54:06 +0300
committerGökay ŞATIR <gokaysatir@collabora.com>2024-03-06 11:21:47 +0100
commitc60598390725cc23dc1401beec057f1386226ac8 (patch)
tree073d256e05923fde7597d3f54e1e35feb0ae63ac /sw
parent81dae2ca5187bd24aea0befb099a5b53535b5d03 (diff)
Moving parts of readonly checks from model to view.
Summary for what's done with this commit: init.cxx * Add guards for modify commands. viewsh: * Add "IsCurrentLokViewReadOnly" for ease of use. unocitm: * Add guard for modify comamnds dispatch.cxx * Implement readonlyview. objmisc: * Modify IsReadOnlyUI check for LokReadOnly view. svx.sdi: * Disable TableChangeCurrentBorderPosition command for readOnly views. sw-editwin: * Treat mouse moves as readonly when the view is LokReadOnly. gridwin: * For autofilter. impedit2, inputhdl: * For text input. svdedtc: * For sdr object dragging. Signed-off-by: Gökay Şatır <gokaysatir@gmail.com> Change-Id: I71fc353976256bce22042bbb6042ee464b65cc13 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163731 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Gökay ŞATIR <gokaysatir@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx68
-rw-r--r--sw/source/uibase/inc/edtwin.hxx2
-rw-r--r--sw/source/uibase/uiview/srcview.cxx2
3 files changed, 39 insertions, 33 deletions
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 073b6b59649e..24358cf5505a 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -433,8 +433,8 @@ void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier )
bool bPrefSdrPointer = false;
bool bHitHandle = false;
bool bCntAtPos = false;
- bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly() &&
- rSh.IsCursorReadonly();
+ bool bIsViewReadOnly = IsViewReadonly();
+
m_aActHitType = SdrHitKind::NONE;
PointerStyle eStyle = PointerStyle::Text;
if ( !pSdrView )
@@ -542,7 +542,7 @@ void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier )
}
if ( bPrefSdrPointer )
{
- if (bIsDocReadOnly || (rSh.IsObjSelected() && rSh.IsSelObjProtected(FlyProtectFlags::Content) != FlyProtectFlags::NONE))
+ if (bIsViewReadOnly || (rSh.IsObjSelected() && rSh.IsSelObjProtected(FlyProtectFlags::Content) != FlyProtectFlags::NONE))
SetPointer( PointerStyle::NotAllowed );
else
{
@@ -1433,12 +1433,11 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
// if every key event stopped and started it again.
comphelper::ScopeGuard keyInputFlushTimerStop([this]() { m_aKeyInputFlushTimer.Stop(); });
- bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly() &&
- rSh.IsCursorReadonly();
+ bool bIsViewReadOnly = IsViewReadonly();
//if the language changes the buffer must be flushed
LanguageType eNewLanguage = GetInputLanguage();
- if(!bIsDocReadOnly && m_eBufferLanguage != eNewLanguage && !m_aInBuffer.isEmpty())
+ if(!bIsViewReadOnly && m_eBufferLanguage != eNewLanguage && !m_aInBuffer.isEmpty())
{
FlushInBuffer();
}
@@ -1452,7 +1451,7 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
}
// OS:the DrawView also needs a readonly-Flag as well
- if ( !bIsDocReadOnly && rSh.GetDrawView() && rSh.GetDrawView()->KeyInput( rKEvt, this ) )
+ if ( !bIsViewReadOnly && rSh.GetDrawView() && rSh.GetDrawView()->KeyInput( rKEvt, this ) )
{
rSh.GetView().GetViewFrame().GetBindings().InvalidateAll( false );
rSh.SetModified();
@@ -1486,7 +1485,7 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
KeyEvent aKeyEvent( rKEvt );
// look for vertical mappings
- if( !bIsDocReadOnly && !rSh.IsSelFrameMode() && !rSh.IsObjSelected() )
+ if( !bIsViewReadOnly && !rSh.IsSelFrameMode() && !rSh.IsObjSelected() )
{
if( KEY_UP == nKey || KEY_DOWN == nKey ||
KEY_LEFT == nKey || KEY_RIGHT == nKey )
@@ -1700,7 +1699,7 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
GotoPrevFieldMark,
End };
- SwKeyState eKeyState = bIsDocReadOnly ? SwKeyState::CheckDocReadOnlyKeys : SwKeyState::CheckKey;
+ SwKeyState eKeyState = bIsViewReadOnly ? SwKeyState::CheckDocReadOnlyKeys : SwKeyState::CheckKey;
SwKeyState eNextKeyState = SwKeyState::End;
sal_uInt8 nDir = 0;
@@ -2407,7 +2406,7 @@ KEYINPUT_CHECKTABLE_INSDEL:
rSh.NumOrNoNum();
}
- if( !m_aInBuffer.isEmpty() && ( !bNormalChar || bIsDocReadOnly ))
+ if( !m_aInBuffer.isEmpty() && ( !bNormalChar || bIsViewReadOnly ))
FlushInBuffer();
if (rSh.HasReadonlySel()
@@ -2430,7 +2429,7 @@ KEYINPUT_CHECKTABLE_INSDEL:
if( rKeyCode.GetFunction() == KeyFuncType::COPY )
GetView().GetViewFrame().GetBindings().Execute(SID_COPY);
- if( !bIsDocReadOnly && bNormalChar )
+ if( !bIsViewReadOnly && bNormalChar )
{
const SelectionType nSelectionType = rSh.GetSelectionType();
const bool bDrawObject = (nSelectionType & SelectionType::DrawObject) &&
@@ -2969,8 +2968,8 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
bool bPageAnchored = false;
bool bOverHeaderFooterFly = IsOverHeaderFooterFly( aDocPos, eControl, bOverFly, bPageAnchored );
- bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly();
- if (bOverHeaderFooterFly && (!bIsDocReadOnly && rSh.GetCurField()))
+ bool bIsViewReadOnly = m_rView.GetDocShell()->IsReadOnly() || (rSh.GetSfxViewShell() && rSh.GetSfxViewShell()->IsLokReadOnlyView());
+ if (bOverHeaderFooterFly && (!bIsViewReadOnly && rSh.GetCurField()))
// We have a field here, that should have priority over header/footer fly.
bOverHeaderFooterFly = false;
@@ -3211,7 +3210,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
if( rSh.IsObjSelected() )
{
SdrHdl* pHdl;
- if( !bIsDocReadOnly &&
+ if( !bIsViewReadOnly &&
!m_pAnchorMarker &&
pSdrView &&
nullptr != ( pHdl = pSdrView->PickHandle(aDocPos) ) &&
@@ -3368,7 +3367,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
{
m_rView.NoRotate();
SdrHdl *pHdl;
- if( !bIsDocReadOnly && !m_pAnchorMarker && nullptr !=
+ if( !bIsViewReadOnly && !m_pAnchorMarker && nullptr !=
( pHdl = pSdrView->PickHandle(aDocPos) ) &&
( pHdl->GetKind() == SdrHdlKind::Anchor ||
pHdl->GetKind() == SdrHdlKind::Anchor_TR ) )
@@ -3434,7 +3433,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
case 2:
{
g_bFrameDrag = false;
- if (!bIsDocReadOnly && rSh.IsInsideSelectedObj(aDocPos)
+ if (!bIsViewReadOnly && rSh.IsInsideSelectedObj(aDocPos)
&& (FlyProtectFlags::NONE
== rSh.IsSelObjProtected(FlyProtectFlags::Content
| FlyProtectFlags::Parent)
@@ -3491,7 +3490,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
SwField *pField;
bool bFootnote = false;
- if( !bIsDocReadOnly &&
+ if( !bIsViewReadOnly &&
(nullptr != (pField = rSh.GetCurField(true)) ||
( bFootnote = rSh.GetCurFootnote() ) ) )
{
@@ -4144,7 +4143,7 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
m_pShadCursor.reset();
}
- bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly();
+ bool bIsViewReadOnly = m_rView.GetDocShell()->IsReadOnly() || (rSh.GetSfxViewShell() && rSh.GetSfxViewShell()->IsLokReadOnlyView());
CurrShell aCurr( &rSh );
@@ -4164,7 +4163,7 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
const SwCallMouseEvent aLastCallEvent( m_aSaveCallEvent );
m_aSaveCallEvent.Clear();
- if ( !bIsDocReadOnly && pSdrView && pSdrView->MouseMove(rMEvt,GetOutDev()) )
+ if ( !bIsViewReadOnly && pSdrView && pSdrView->MouseMove(rMEvt,GetOutDev()) )
{
SetPointer( PointerStyle::Text );
return; // evaluate SdrView's event
@@ -4256,7 +4255,7 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
}
// determine if we only change the mouse pointer and return
- if (!bIsDocReadOnly && bInsWin && !m_pApplyTempl && !rSh.IsInSelect() && changeMousePointer(aDocPt))
+ if (!bIsViewReadOnly && bInsWin && !m_pApplyTempl && !rSh.IsInSelect() && changeMousePointer(aDocPt))
{
return;
}
@@ -4398,7 +4397,7 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
}
// event processing for resizing
- if( bIsDocReadOnly )
+ if( bIsViewReadOnly )
break;
bool bResizeKeepRatio = rSh.GetSelectionType() & SelectionType::Graphic ||
@@ -4437,7 +4436,7 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
rSh.Drag( &aDocPt, rMEvt.IsShift() );
m_bIsInMove = true;
}
- else if( bIsDocReadOnly )
+ else if( bIsViewReadOnly )
break;
if ( !bInsWin )
@@ -4560,7 +4559,7 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
aLastCallEvent, true );
}
- if( bTstShdwCursor && bInsWin && !bIsDocReadOnly &&
+ if( bTstShdwCursor && bInsWin && !bIsViewReadOnly &&
!m_bInsFrame &&
!rSh.GetViewOptions()->getBrowseMode() &&
rSh.GetViewOptions()->IsShadowCursor() &&
@@ -5564,6 +5563,12 @@ void SwEditWin::LoseFocus()
s_pQuickHlpData->Stop( m_rView.GetWrtShell() );
}
+bool SwEditWin::IsViewReadonly() const
+{
+ SwWrtShell &rSh = m_rView.GetWrtShell();
+ return (m_rView.GetDocShell()->IsReadOnly() && rSh.IsCursorReadonly()) || (rSh.GetSfxViewShell() && rSh.GetSfxViewShell()->IsLokReadOnlyView());
+}
+
void SwEditWin::Command( const CommandEvent& rCEvt )
{
if (isDisposed())
@@ -5703,9 +5708,8 @@ void SwEditWin::Command( const CommandEvent& rCEvt )
case CommandEventId::StartExtTextInput:
{
- bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly() &&
- rSh.IsCursorReadonly();
- if(!bIsDocReadOnly)
+ bool bIsViewReadOnly = IsViewReadonly();
+ if(!bIsViewReadOnly)
{
if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
{
@@ -5726,9 +5730,9 @@ void SwEditWin::Command( const CommandEvent& rCEvt )
}
case CommandEventId::EndExtTextInput:
{
- bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly() &&
- rSh.IsCursorReadonly();
- if(!bIsDocReadOnly)
+ bool bIsViewReadOnly = IsViewReadonly();
+
+ if(!bIsViewReadOnly)
{
if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
{
@@ -5777,9 +5781,9 @@ void SwEditWin::Command( const CommandEvent& rCEvt )
break;
case CommandEventId::ExtTextInput:
{
- bool bIsDocReadOnly = m_rView.GetDocShell()->IsReadOnly() &&
- rSh.IsCursorReadonly();
- if (!bIsDocReadOnly && !rSh.HasReadonlySel())
+ bool bIsViewReadOnly = IsViewReadonly();
+
+ if (!bIsViewReadOnly && !rSh.HasReadonlySel())
{
if( s_pQuickHlpData->m_bIsDisplayed )
s_pQuickHlpData->Stop( rSh );
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index ceaa98657fe9..e85229546825 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -288,6 +288,8 @@ public:
/// Allows starting or ending a graphic move or resize action.
void SetGraphicTwipPosition(bool bStart, const Point& rPosition);
+ bool IsViewReadonly() const;
+
const SwTextFrame* GetSavedOutlineFrame() const { return m_pSavedOutlineFrame; }
void SetSavedOutlineFrame(SwTextFrame* pFrame) { m_pSavedOutlineFrame = pFrame; }
// bSubs set true, sets all sub level outline content to same visibility as nOutlinePos.
diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx
index 563dd0b46859..713e13b5791a 100644
--- a/sw/source/uibase/uiview/srcview.cxx
+++ b/sw/source/uibase/uiview/srcview.cxx
@@ -438,7 +438,7 @@ void SwSrcView::GetState(SfxItemSet& rSet)
SearchOptionFlags nOpt = SRC_SEARCHOPTIONS;
SwDocShell* pDocShell = GetDocShell();
assert(pDocShell);
- if (pDocShell->IsReadOnly())
+ if (pDocShell->IsReadOnly() || SfxViewShell::IsCurrentLokViewReadOnly())
nOpt &= ~SearchOptionFlags(SearchOptionFlags::REPLACE|SearchOptionFlags::REPLACE_ALL);
rSet.Put( SfxUInt16Item( SID_SEARCH_OPTIONS, static_cast<sal_uInt16>(nOpt) ) );