summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-01-28 12:24:20 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-01-28 12:25:31 +0000
commite9de80aa82815e823272a1d18887f8ac6a6f7880 (patch)
tree07c7c1404696d776abaaee2da1ec0cdece2ed818
parent0d19d02809d04779e4623696a5736ba91548fd9a (diff)
Related: fdo#50640 allow the cursor to enter empty vertical input fields
Change-Id: Ib7db10d59f6d1106b33558fe5bdd076e278dfbbe
-rw-r--r--sw/source/core/crsr/swcrsr.cxx38
1 files changed, 19 insertions, 19 deletions
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index 898e04a8ce28..ff3ee9348991 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -211,6 +211,17 @@ bool SwTableCursor::IsSelOvrCheck(int eFlags)
return SwCursor::IsSelOvrCheck(eFlags);
}
+namespace
+{
+ const SwTxtAttr* InputFieldAtPos(SwPosition *pPos)
+ {
+ SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode();
+ if (!pTxtNd)
+ return NULL;
+ return pTxtNd->GetTxtAttrAt(pPos->nContent.GetIndex(), RES_TXTATR_INPUTFIELD, SwTxtNode::PARENT);
+ }
+}
+
bool SwCursor::IsSelOvr( int eFlags )
{
SwDoc* pDoc = GetDoc();
@@ -325,9 +336,9 @@ bool SwCursor::IsSelOvr( int eFlags )
if( pNd->IsCntntNode() && !dynamic_cast<SwUnoCrsr*>(this) )
{
const SwCntntFrm* pFrm = static_cast<const SwCntntNode*>(pNd)->getLayoutFrm( pDoc->getIDocumentLayoutAccess().GetCurrentLayout() );
- if( pFrm && pFrm->IsValid()
- && 0 == pFrm->Frm().Height()
- && 0 != ( nsSwCursorSelOverFlags::SELOVER_CHANGEPOS & eFlags ) )
+ if ( (nsSwCursorSelOverFlags::SELOVER_CHANGEPOS & eFlags) //allowed to change position if it's a bad one
+ && pFrm && pFrm->IsValid() && !pFrm->Frm().Height() //a bad zero height position
+ && !InputFieldAtPos(GetPoint()) ) //unless it's a (vertical) input field
{
// skip to the next/prev valid paragraph with a layout
SwNodeIndex& rPtIdx = GetPoint()->nNode;
@@ -412,23 +423,10 @@ bool SwCursor::IsSelOvr( int eFlags )
return true; // we need a frame
}
- // assure that selection is only inside an InputField or contains the InputField completely
+ // ensure that selection is only inside an InputField or contains the InputField completely
{
- const SwTxtAttr* pInputFldTxtAttrAtPoint = NULL;
- SwTxtNode* pTxtNdAtPoint = GetPoint()->nNode.GetNode().GetTxtNode();
- if ( pTxtNdAtPoint != NULL )
- {
- pInputFldTxtAttrAtPoint =
- pTxtNdAtPoint->GetTxtAttrAt( GetPoint()->nContent.GetIndex(), RES_TXTATR_INPUTFIELD, SwTxtNode::PARENT );
- }
-
- const SwTxtAttr* pInputFldTxtAttrAtMark = NULL;
- SwTxtNode* pTxtNdAtMark = GetMark()->nNode.GetNode().GetTxtNode();
- if ( pTxtNdAtMark != NULL )
- {
- pInputFldTxtAttrAtMark =
- pTxtNdAtMark->GetTxtAttrAt( GetMark()->nContent.GetIndex(), RES_TXTATR_INPUTFIELD, SwTxtNode::PARENT );
- }
+ const SwTxtAttr* pInputFldTxtAttrAtPoint = InputFieldAtPos(GetPoint());
+ const SwTxtAttr* pInputFldTxtAttrAtMark = InputFieldAtPos(GetMark());
if ( pInputFldTxtAttrAtPoint != pInputFldTxtAttrAtMark )
{
@@ -449,6 +447,7 @@ bool SwCursor::IsSelOvr( int eFlags )
{
const sal_Int32 nNewPointPos =
bIsForwardSelection ? *(pInputFldTxtAttrAtPoint->End()) : pInputFldTxtAttrAtPoint->GetStart();
+ SwTxtNode* pTxtNdAtPoint = GetPoint()->nNode.GetNode().GetTxtNode();
GetPoint()->nContent.Assign( pTxtNdAtPoint, nNewPointPos );
}
@@ -456,6 +455,7 @@ bool SwCursor::IsSelOvr( int eFlags )
{
const sal_Int32 nNewMarkPos =
bIsForwardSelection ? pInputFldTxtAttrAtMark->GetStart() : *(pInputFldTxtAttrAtMark->End());
+ SwTxtNode* pTxtNdAtMark = GetMark()->nNode.GetNode().GetTxtNode();
GetMark()->nContent.Assign( pTxtNdAtMark, nNewMarkPos );
}
}