diff options
author | Oliver-Rainer Wittmann <orw@apache.org> | 2014-02-20 11:01:04 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-02-22 19:51:33 +0000 |
commit | 961315f0838197e71e9bd49169afe673466e5eb8 (patch) | |
tree | bd5075f2db9910f45821e5c1217ded37fd4bb7cb | |
parent | 148905281d830dedb0e1a7bbe9142eaf40bd3cfb (diff) |
Resolves: #i124243# allow in-place editing of Input Fields...
in protected areas (e.g. protected sections)
(cherry picked from commit 1708b9bee77ab0e8762bbb6886b778b93428a2b0)
Conflicts:
sw/inc/pam.hxx
sw/source/core/crsr/crsrsh.cxx
sw/source/core/crsr/pam.cxx
sw/source/core/edit/edfcol.cxx
sw/source/core/edit/ednumber.cxx
sw/source/ui/docvw/edtwin.cxx
Change-Id: Iedcb31a824a9147bccb14314608749121c70d952
-rw-r--r-- | sw/inc/editsh.hxx | 2 | ||||
-rw-r--r-- | sw/sdi/_basesh.sdi | 2 | ||||
-rw-r--r-- | sw/sdi/_textsh.sdi | 3 | ||||
-rw-r--r-- | sw/source/core/crsr/crsrsh.cxx | 19 | ||||
-rw-r--r-- | sw/source/core/crsr/pam.cxx | 77 | ||||
-rw-r--r-- | sw/source/core/edit/eddel.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/edit/edfcol.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/edit/ednumber.cxx | 35 | ||||
-rw-r--r-- | sw/source/ui/docvw/edtwin.cxx | 88 | ||||
-rw-r--r-- | sw/source/ui/shells/basesh.cxx | 7 | ||||
-rw-r--r-- | sw/source/ui/shells/textsh1.cxx | 10 |
11 files changed, 148 insertions, 103 deletions
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index 58bf231075ec..b90c626bd561 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -487,7 +487,7 @@ public: bool MoveNumParas( bool bUpperLower, bool bUpperLeft ); /// Switch on/off of numbering via Delete/Backspace. - bool NumOrNoNum( sal_Bool bDelete = sal_False, bool bChkStart = true); + bool NumOrNoNum(bool bDelete = false, bool bChkStart = true); // #i23726# // #i90078# diff --git a/sw/sdi/_basesh.sdi b/sw/sdi/_basesh.sdi index 060ec160605a..66ab3fb9608c 100644 --- a/sw/sdi/_basesh.sdi +++ b/sw/sdi/_basesh.sdi @@ -32,7 +32,6 @@ interface BaseTextSelection ExecMethod = ExecDelete ; StateMethod = GetState ; FastCall = FALSE ; - DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] FN_BACKSPACE // status(final|play) @@ -40,7 +39,6 @@ interface BaseTextSelection ExecMethod = ExecDelete ; StateMethod = GetState ; FastCall = FALSE ; - DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] FN_SHIFT_BACKSPACE // status() diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index 0fb5cdb057f4..d799209faa49 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -235,12 +235,13 @@ interface BaseText StateMethod = GetState ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + FN_INSERT_BREAK // status(final|play) [ ExecMethod = ExecInsert ; StateMethod = GetState ; - DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + FN_INSERT_PAGEBREAK // status(final|play) [ ExecMethod = ExecInsert ; diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index e24ea01c13ff..8103f11c447b 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -2977,19 +2977,26 @@ void SwCrsrShell::SetReadOnlyAvailable( sal_Bool bFlag ) sal_Bool SwCrsrShell::HasReadonlySel(bool bAnnotationMode) const { sal_Bool bRet = sal_False; - if( IsReadOnlyAvailable() || GetViewOptions()->IsFormView() ) + if ( IsReadOnlyAvailable() || GetViewOptions()->IsFormView() ) { - if( m_pTblCrsr ) - bRet = m_pTblCrsr->HasReadOnlyBoxSel() || - m_pTblCrsr->HasReadonlySel( GetViewOptions()->IsFormView() ); + if ( m_pTblCrsr != NULL ) + { + bRet = m_pTblCrsr->HasReadOnlyBoxSel() + || m_pTblCrsr->HasReadonlySel( GetViewOptions()->IsFormView() ); + } else { const SwPaM* pCrsr = m_pCurCrsr; - do { + do + { if( pCrsr->HasReadonlySel( GetViewOptions()->IsFormView(), bAnnotationMode ) ) + { bRet = sal_True; - } while( !bRet && m_pCurCrsr != ( pCrsr = (SwPaM*)pCrsr->GetNext() )); + } + + pCrsr = (SwPaM*)pCrsr->GetNext(); + } while ( !bRet && pCrsr != m_pCurCrsr ); } } return bRet; diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 59e2dbcf5c69..09e8ea771ee1 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -572,57 +572,77 @@ static const SwFrm* lcl_FindEditInReadonlyFrm( const SwFrm& rFrm ) bool SwPaM::HasReadonlySel( bool bFormView, bool bAnnotationMode ) const { bool bRet = false; - Point aTmpPt; - const SwCntntNode *pNd; - const SwCntntFrm *pFrm; - if( 0 != ( pNd = GetPoint()->nNode.GetNode().GetCntntNode() )) - pFrm = pNd->getLayoutFrm( pNd->GetDoc()->GetCurrentLayout(), &aTmpPt, GetPoint(), sal_False ); - else - pFrm = 0; - - // Will be set if point/mark are inside edit-in-readonly environment - const SwFrm* pSttEIRFrm = 0; - const SwFrm* pEndEIRFrm = 0; + const SwCntntNode* pNd = GetPoint()->nNode.GetNode().GetCntntNode(); + const SwCntntFrm *pFrm = NULL; + if ( pNd != NULL ) + { + Point aTmpPt; + pFrm = pNd->getLayoutFrm( pNd->GetDoc()->GetCurrentLayout(), &aTmpPt, GetPoint(), false ); + } - if( pFrm && ( pFrm->IsProtected() || - ( bFormView && 0 == ( pSttEIRFrm = lcl_FindEditInReadonlyFrm( *pFrm ) ) ) ) ) + // Will be set if point are inside edit-in-readonly environment + const SwFrm* pPointEditInReadonlyFrm = NULL; + if ( pFrm != NULL + && ( pFrm->IsProtected() + || ( bFormView + && 0 == ( pPointEditInReadonlyFrm = lcl_FindEditInReadonlyFrm( *pFrm ) ) ) ) ) + { bRet = true; - else if( pNd ) + } + else if( pNd != NULL ) { const SwSectionNode* pSNd = pNd->GetSectionNode(); - if( pSNd && ( pSNd->GetSection().IsProtectFlag() || - (bFormView && !pSNd->GetSection().IsEditInReadonlyFlag()) ) ) + if ( pSNd != NULL + && ( pSNd->GetSection().IsProtectFlag() + || ( bFormView + && !pSNd->GetSection().IsEditInReadonlyFlag()) ) ) + { bRet = true; + } } - if( !bRet && HasMark() && GetPoint()->nNode != GetMark()->nNode ) + if ( !bRet + && HasMark() + && GetPoint()->nNode != GetMark()->nNode ) { - if( 0 != ( pNd = GetMark()->nNode.GetNode().GetCntntNode() )) - pFrm = pNd->getLayoutFrm( pNd->GetDoc()->GetCurrentLayout(), &aTmpPt, GetMark(), sal_False ); - else - pFrm = 0; + pNd = GetMark()->nNode.GetNode().GetCntntNode(); + pFrm = NULL; + if ( pNd != NULL ) + { + Point aTmpPt; + pFrm = pNd->getLayoutFrm( pNd->GetDoc()->GetCurrentLayout(), &aTmpPt, GetMark(), false ); + } - if( pFrm && ( pFrm->IsProtected() || - ( bFormView && 0 == ( pEndEIRFrm = lcl_FindEditInReadonlyFrm( *pFrm ) ) ) ) ) + const SwFrm* pMarkEditInReadonlyFrm = NULL; + if ( pFrm != NULL + && ( pFrm->IsProtected() + || ( bFormView + && 0 == ( pMarkEditInReadonlyFrm = lcl_FindEditInReadonlyFrm( *pFrm ) ) ) ) ) + { bRet = true; - else if( pNd ) + } + else if( pNd != NULL ) { const SwSectionNode* pSNd = pNd->GetSectionNode(); - if( pSNd && ( pSNd->GetSection().IsProtectFlag() || - (bFormView && !pSNd->GetSection().IsEditInReadonlyFlag()) ) ) + if ( pSNd != NULL + && ( pSNd->GetSection().IsProtectFlag() + || ( bFormView + && !pSNd->GetSection().IsEditInReadonlyFlag()) ) ) + { bRet = true; + } } if ( !bRet && bFormView ) { // Check if start and end frame are inside the _same_ // edit-in-readonly-environment. Otherwise we better return 'true' - if ( pSttEIRFrm != pEndEIRFrm ) + if ( pPointEditInReadonlyFrm != pMarkEditInReadonlyFrm ) bRet = true; } - // protected section in selection + // check for protected section inside the selection if( !bRet ) { sal_uLong nSttIdx = GetMark()->nNode.GetIndex(), @@ -659,6 +679,7 @@ bool SwPaM::HasReadonlySel( bool bFormView, bool bAnnotationMode ) const } } } + //FIXME FieldBk // TODO: Form Protection when Enhanced Fields are enabled const SwDoc *pDoc = GetDoc(); diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx index a5d7904ae8b5..9f90348dea00 100644 --- a/sw/source/core/edit/eddel.cxx +++ b/sw/source/core/edit/eddel.cxx @@ -102,7 +102,7 @@ long SwEditShell::Delete() { SET_CURR_SHELL( this ); long nRet = 0; - if( !HasReadonlySel() ) + if ( !HasReadonlySel() || CrsrInsideInputFld() ) { StartAllAction(); diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 3ca8e6778b11..0bc3fd85257f 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -60,10 +60,10 @@ void SwEditShell::SetTxtFmtColl( SwTxtFmtColl *pFmt, GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_SETFMTCOLL, &aRewriter); FOREACHPAM_START(GetCrsr()) - if( !PCURCRSR->HasReadonlySel( - // Formular view - GetViewOptions()->IsFormView() ) ) + if ( !PCURCRSR->HasReadonlySel( GetViewOptions()->IsFormView() ) ) + { GetDoc()->SetTxtFmtColl( *PCURCRSR, pLocal, true, bResetListAttrs ); + } FOREACHPAM_END() GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_SETFMTCOLL, &aRewriter); diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index da1f030e14f2..c3c002e862a7 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -647,34 +647,37 @@ sal_Bool SwEditShell::IsOutlineCopyable( sal_uInt16 nIdx ) const return lcl_IsOutlineMoveAndCopyable( GetDoc(), nIdx, true ); } -bool SwEditShell::NumOrNoNum( sal_Bool bNumOn, bool bChkStart ) +bool SwEditShell::NumOrNoNum( + bool bNumOn, + bool bChkStart ) { bool bRet = false; - SwPaM* pCrsr = GetCrsr(); - if( pCrsr->GetNext() == pCrsr && !pCrsr->HasMark() && - ( !bChkStart || !pCrsr->GetPoint()->nContent.GetIndex()) ) + + if ( !IsMultiSelection() + && !HasSelection() + && ( !bChkStart || IsSttPara() ) ) { - StartAllAction(); // Klammern fuers Updaten !! - bRet = GetDoc()->NumOrNoNum( pCrsr->GetPoint()->nNode, !bNumOn ); // #i29560# + StartAllAction(); + bRet = GetDoc()->NumOrNoNum( GetCrsr()->GetPoint()->nNode, !bNumOn ); EndAllAction(); } return bRet; } + sal_Bool SwEditShell::IsNoNum( sal_Bool bChkStart ) const { // a Backspace in the paragraph without number becomes a Delete sal_Bool bResult = sal_False; - SwPaM* pCrsr = GetCrsr(); - if (pCrsr->GetNext() == pCrsr && !pCrsr->HasMark() && - (!bChkStart || !pCrsr->GetPoint()->nContent.GetIndex())) + if ( !IsMultiSelection() + && !HasSelection() + && ( !bChkStart || IsSttPara() ) ) { - const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode(); - - if (pTxtNd) + const SwTxtNode* pTxtNd = GetCrsr()->GetNode()->GetTxtNode(); + if ( pTxtNd != NULL ) { - bResult = ! pTxtNd->IsCountedInList(); + bResult = !pTxtNd->IsCountedInList(); } } @@ -690,11 +693,11 @@ sal_uInt8 SwEditShell::GetNumLevel() const const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode(); OSL_ENSURE( pTxtNd, "GetNumLevel() without text node" ); - if ( !pTxtNd ) + if ( pTxtNd == NULL ) return nLevel; const SwNumRule* pRule = pTxtNd->GetNumRule(); - if(pRule) + if ( pRule != NULL ) { const int nListLevelOfTxtNode( pTxtNd->GetActualListLevel() ); if ( nListLevelOfTxtNode >= 0 ) @@ -721,7 +724,7 @@ void SwEditShell::SetCurNumRule( const SwNumRule& rRule, GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwPaM* pCrsr = GetCrsr(); - if( pCrsr->GetNext() != pCrsr ) // multiple selection ? + if( IsMultiSelection() ) { SwPamRanges aRangeArr( *pCrsr ); SwPaM aPam( *pCrsr->GetPoint() ); diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 1d2aa2cbd16d..d52a9af40c15 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -329,7 +329,7 @@ void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier ) if( m_pApplyTempl ) { PointerStyle eStyle = POINTER_FILL; - if( rSh.IsOverReadOnlyPos( rLPt )) + if ( rSh.IsOverReadOnlyPos( rLPt ) ) { delete m_pUserMarker; m_pUserMarker = 0L; @@ -1896,7 +1896,8 @@ KEYINPUT_CHECKTABLE_INSDEL: break; case KEY_BACKSPACE: case KEY_BACKSPACE | KEY_SHIFT: - if( !rSh.HasReadonlySel() ) + if ( !rSh.HasReadonlySel() + && !rSh.CrsrInsideInputFld() ) { bool bDone = false; // try to add comment for code snip: @@ -1906,12 +1907,11 @@ KEYINPUT_CHECKTABLE_INSDEL: // Also try to remove indent, if current paragraph // has numbering rule, but isn't counted and only // key <backspace> is hit. - const bool bOnlyBackspaceKey( - KEY_BACKSPACE == rKeyCode.GetFullCode() ); - if ( rSh.IsSttPara() && - !rSh.HasSelection() && - ( NULL == rSh.GetCurNumRule() || - ( rSh.IsNoNum() && bOnlyBackspaceKey ) ) ) + const bool bOnlyBackspaceKey( KEY_BACKSPACE == rKeyCode.GetFullCode() ); + if ( rSh.IsSttPara() + && !rSh.HasSelection() + && ( rSh.GetCurNumRule() == NULL + || ( rSh.IsNoNum() && bOnlyBackspaceKey ) ) ) { bDone = rSh.TryRemoveIndent(); } @@ -1920,8 +1920,7 @@ KEYINPUT_CHECKTABLE_INSDEL: eKeyState = KS_End; else { - if (rSh.IsSttPara() && - ! rSh.IsNoNum()) + if ( rSh.IsSttPara() && !rSh.IsNoNum() ) { if (m_nKS_NUMDOWN_Count > 0 && 0 < rSh.GetNumLevel()) @@ -1939,7 +1938,7 @@ KEYINPUT_CHECKTABLE_INSDEL: } // If the cursor is in an empty paragraph, which has - // a numbering, but not the oultine numbering, and + // a numbering, but not the outline numbering, and // there is no selection, the numbering has to be // deleted on key <Backspace>. // Otherwise method <SwEditShell::NumOrNoNum(..)> @@ -1949,35 +1948,34 @@ KEYINPUT_CHECKTABLE_INSDEL: // on <shift-backspace> it is set to <true>. // Thus, assure that method <SwEditShell::NumOrNum(..)> // is only called for the intended purpose. - bool bCallNumOrNoNum( false ); + if ( !bDone && rSh.IsSttPara() ) { - if ( !bDone ) + bool bCallNumOrNoNum( false ); + if ( bOnlyBackspaceKey && !rSh.IsNoNum() ) { - if ( bOnlyBackspaceKey && !rSh.IsNoNum() ) - { - bCallNumOrNoNum = true; - } - else if ( !bOnlyBackspaceKey && rSh.IsNoNum() ) + bCallNumOrNoNum = true; + } + else if ( !bOnlyBackspaceKey && rSh.IsNoNum() ) + { + bCallNumOrNoNum = true; + } + else if ( bOnlyBackspaceKey + && rSh.IsSttPara() + && rSh.IsEndPara() + && !rSh.HasSelection() ) + { + const SwNumRule* pCurrNumRule( rSh.GetCurNumRule() ); + if ( pCurrNumRule != NULL + && pCurrNumRule != rSh.GetOutlineNumRule() ) { bCallNumOrNoNum = true; } - else if ( bOnlyBackspaceKey && - rSh.IsSttPara() && rSh.IsEndPara() && - !rSh.HasSelection() ) - { - const SwNumRule* pCurrNumRule( rSh.GetCurNumRule() ); - if ( pCurrNumRule && - pCurrNumRule != rSh.GetOutlineNumRule() ) - { - bCallNumOrNoNum = true; - } - } } - } - if ( bCallNumOrNoNum && - rSh.NumOrNoNum( !bOnlyBackspaceKey, true ) ) - { - eKeyState = KS_NumOrNoNum; + if ( bCallNumOrNoNum + && rSh.NumOrNoNum( !bOnlyBackspaceKey, sal_True ) ) + { + eKeyState = KS_NumOrNoNum; + } } } } @@ -2009,9 +2007,9 @@ KEYINPUT_CHECKTABLE_INSDEL: GetView().GetViewFrame()->GetDispatcher()->Execute( FN_GOTO_NEXT_INPUTFLD ); eKeyState = KS_End; } - else - if( rSh.GetCurNumRule() && rSh.IsSttOfPara() && - !rSh.HasReadonlySel() ) + else if( rSh.GetCurNumRule() + && rSh.IsSttOfPara() + && !rSh.HasReadonlySel() ) { if ( rSh.IsFirstOfNumRule() && numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() ) @@ -2060,8 +2058,9 @@ KEYINPUT_CHECKTABLE_INSDEL: GetView().GetViewFrame()->GetDispatcher()->Execute( FN_GOTO_PREV_INPUTFLD ); eKeyState = KS_End; } - else if( rSh.GetCurNumRule() && rSh.IsSttOfPara() && - !rSh.HasReadonlySel() ) + else if( rSh.GetCurNumRule() + && rSh.IsSttOfPara() + && !rSh.HasReadonlySel() ) { if ( rSh.IsFirstOfNumRule() && @@ -2353,10 +2352,11 @@ KEYINPUT_CHECKTABLE_INSDEL: } eKeyState = KS_End; } - else if(!rSh.HasReadonlySel()) + else if ( !rSh.HasReadonlySel() + || rSh.CrsrInsideInputFld() ) { - sal_Bool bIsNormalChar = GetAppCharClass().isLetterNumeric( - OUString( aCh ), 0 ); + const sal_Bool bIsNormalChar = + GetAppCharClass().isLetterNumeric( OUString( aCh ), 0 ); if( bAppendSpace && bIsNormalChar && (!m_aInBuffer.isEmpty() || !rSh.IsSttPara() || !rSh.IsEndPara() )) { @@ -2365,8 +2365,8 @@ KEYINPUT_CHECKTABLE_INSDEL: m_aInBuffer += " "; } - sal_Bool bIsAutoCorrectChar = SvxAutoCorrect::IsAutoCorrectChar( aCh ); - bool bRunNext = pACorr && pACorr->HasRunNext(); + const sal_Bool bIsAutoCorrectChar = SvxAutoCorrect::IsAutoCorrectChar( aCh ); + const bool bRunNext = pACorr != NULL && pACorr->HasRunNext(); if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || bRunNext ) && pACfg->IsAutoFmtByInput() && (( pACorr->IsAutoCorrFlag( ChgWeightUnderl ) && diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx index c50b5944fa7e..75b25a3c39e0 100644 --- a/sw/source/ui/shells/basesh.cxx +++ b/sw/source/ui/shells/basesh.cxx @@ -1462,11 +1462,16 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) rSet.Put(SfxBoolItem(nWhich, bDisable)); } break; + case FN_BACKSPACE: case SID_DELETE: - if (rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0) + if ( ( rSh.HasReadonlySel() && !rSh.CrsrInsideInputFld() ) + || rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0 ) + { rSet.DisableItem( nWhich ); + } break; + case SID_CONTOUR_DLG: { sal_Bool bParentCntProt = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT ); diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx index 59df37ecd9ab..20107080d00d 100644 --- a/sw/source/ui/shells/textsh1.cxx +++ b/sw/source/ui/shells/textsh1.cxx @@ -1568,6 +1568,16 @@ void SwTextShell::GetState( SfxItemSet &rSet ) } break; + + case FN_INSERT_BREAK: + if ( rSh.HasReadonlySel() + && !rSh.CrsrInsideInputFld() ) + { + rSet.DisableItem( nWhich ); + } + break; + + case FN_INSERT_BREAK_DLG: case FN_INSERT_COLUMN_BREAK: case FN_INSERT_PAGEBREAK: |