summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/crsr/crstrvl.cxx4
-rw-r--r--sw/source/core/crsr/viscrs.cxx6
-rw-r--r--sw/source/core/txtnode/attrcontentcontrol.cxx4
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx1
-rw-r--r--sw/source/core/txtnode/thints.cxx21
-rw-r--r--sw/source/core/unocore/unocontentcontrol.cxx3
-rw-r--r--sw/source/filter/ascii/ascatr.cxx3
-rw-r--r--sw/source/uibase/wrtsh/wrtsh3.cxx4
8 files changed, 31 insertions, 15 deletions
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 8e8c472ada4b..4efaab1637a4 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -879,7 +879,9 @@ bool SwCursorShell::GotoFormatContentControl(const SwFormatContentControl& rCont
sal_Int32 nStart = pTextContentControl->GetStart() + 1;
pCursor->GetPoint()->nContent.Assign(pTextNode, nStart);
pCursor->GetMark()->nNode = *pTextNode;
- pCursor->GetMark()->nContent.Assign(pTextNode, *(pTextContentControl->End()));
+ // Don't select the CH_TXTATR_BREAKWORD itself at the end.
+ sal_Int32 nEnd = *pTextContentControl->End() - 1;
+ pCursor->GetMark()->nContent.Assign(pTextNode, nEnd);
// Assume that once the placeholder is selected, the content is no longer the placeholder.
pContentControl->SetShowingPlaceHolder(false);
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index bc55c09653c7..953c20f59a57 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -648,10 +648,10 @@ void SwSelPaintRects::HighlightContentControl()
SwTextContentControl* pCurContentControlAtCursor = nullptr;
if (pTextNode)
{
- // SwTextNode::EXPAND because the LHS of the dummy character doesn't count, the RHS of
- // the start of the LHS of the end counts.
+ // SwTextNode::PARENT because this way we highlight when the user will type inside the
+ // content control, not outside of it.
SwTextAttr* pAttr = pTextNode->GetTextAttrAt(
- pStart->nContent.GetIndex(), RES_TXTATR_CONTENTCONTROL, SwTextNode::EXPAND);
+ pStart->nContent.GetIndex(), RES_TXTATR_CONTENTCONTROL, SwTextNode::PARENT);
if (pAttr)
{
pCurContentControlAtCursor = static_txtattr_cast<SwTextContentControl*>(pAttr);
diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx
index c28e686ce6fb..8704221a9a3b 100644
--- a/sw/source/core/txtnode/attrcontentcontrol.cxx
+++ b/sw/source/core/txtnode/attrcontentcontrol.cxx
@@ -318,10 +318,6 @@ SwTextContentControl::SwTextContentControl(SwFormatContentControl& rAttr, sal_In
{
rAttr.SetTextAttr(this);
SetHasDummyChar(true);
-
- // If the user types at the end of the content control, expand the text attr to the right.
- SetLockExpandFlag(false);
- SetDontExpand(false);
}
SwTextContentControl::~SwTextContentControl()
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 6c1e03c76233..97d65e48fbf0 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -3412,6 +3412,7 @@ OUString SwTextNode::GetExpandText(SwRootFrame const*const pLayout,
// remove dummy characters of Input Fields
comphelper::string::remove(aText, CH_TXT_ATR_INPUTFIELDSTART);
comphelper::string::remove(aText, CH_TXT_ATR_INPUTFIELDEND);
+ comphelper::string::remove(aText, CH_TXTATR_BREAKWORD);
if( bWithNum )
{
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index f465b65a2e39..75f04356e476 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1569,11 +1569,30 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, const SetAttrMode nMode )
}
// adjust end of hint to account for inserted CH_TXTATR
- const sal_Int32 * const pEnd(pAttr->GetEnd());
+ const sal_Int32* pEnd(pAttr->GetEnd());
if (pEnd)
{
pAttr->SetEnd(*pEnd + 1);
}
+
+ if (pAttr->Which() == RES_TXTATR_CONTENTCONTROL)
+ {
+ // Content controls have a dummy character at their end as well.
+ SwIndex aEndIdx(this, *pAttr->GetEnd());
+ OUString aEnd
+ = InsertText(OUString(GetCharOfTextAttr(*pAttr)), aEndIdx, nInsertFlags);
+ if (aEnd.isEmpty())
+ {
+ DestroyAttr(pAttr);
+ return false;
+ }
+
+ pEnd = pAttr->GetEnd();
+ if (pEnd)
+ {
+ pAttr->SetEnd(*pEnd + 1);
+ }
+ }
}
}
diff --git a/sw/source/core/unocore/unocontentcontrol.cxx b/sw/source/core/unocore/unocontentcontrol.cxx
index ae3973fc8c4f..a7aba99f2e2e 100644
--- a/sw/source/core/unocore/unocontentcontrol.cxx
+++ b/sw/source/core/unocore/unocontentcontrol.cxx
@@ -316,7 +316,8 @@ bool SwXContentControl::SetContentRange(SwTextNode*& rpNode, sal_Int32& rStart,
{
// rStart points at the first position within the content control.
rStart = pTextAttr->GetStart() + 1;
- rEnd = *pTextAttr->End();
+ // rEnd points at the last position within the content control.
+ rEnd = *pTextAttr->End() - 1;
return true;
}
}
diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx
index 805f3ba48bc1..cc2c1eaac79f 100644
--- a/sw/source/filter/ascii/ascatr.cxx
+++ b/sw/source/filter/ascii/ascatr.cxx
@@ -342,7 +342,7 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
if ( !bExportSoftHyphens )
aOutStr = aOutStr.replaceAll(OUStringChar(CHAR_SOFTHYPHEN), "");
- // all INWORD/BREAKWORD should be already removed by OutAttr
+ // all INWORD should be already removed by OutAttr
// but the field-marks are not attributes so filter those
static sal_Unicode const forbidden [] = {
CH_TXT_ATR_INPUTFIELDSTART,
@@ -351,6 +351,7 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
CH_TXT_ATR_FIELDSTART,
CH_TXT_ATR_FIELDSEP,
CH_TXT_ATR_FIELDEND,
+ CH_TXTATR_BREAKWORD,
0
};
aOutStr = comphelper::string::removeAny(aOutStr, forbidden);
diff --git a/sw/source/uibase/wrtsh/wrtsh3.cxx b/sw/source/uibase/wrtsh/wrtsh3.cxx
index aa0badb54e61..573ea4a9752d 100644
--- a/sw/source/uibase/wrtsh/wrtsh3.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh3.cxx
@@ -140,10 +140,6 @@ bool SwWrtShell::GotoContentControl(const SwFormatContentControl& rContentContro
GetIDocumentUndoRedo().StartUndo(SwUndoId::REPLACE, &aRewriter);
// Update the content.
- SwTextContentControl* pTextContentControl
- = const_cast<SwFormatContentControl&>(rContentControl).GetTextAttr();
- // If the content control is at the end of the line, then expand is false by default.
- pTextContentControl->SetDontExpand(false);
DelLeft();
pContentControl->SetSelectedListItem(std::nullopt);
Insert(aNewState);