summaryrefslogtreecommitdiff
path: root/sw/source/core/txtnode/txtedt.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-05-14 11:34:33 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-05-14 11:39:16 +0200
commit3c0805e1f4f4d14e92c7e655d59c87de5c207e48 (patch)
treef83e033781b6724aa77a19537e035d3cfced524e /sw/source/core/txtnode/txtedt.cxx
parent7e9a4944e53d95f7defb1da384b665e65b2ebc55 (diff)
tdf#86639 SwEditShell: when setting para style, reset char attrs if needed
The old internal RTF filter used to call SwTxtNode::SetAttr() without setting SetAttrMode::NOFORMATATTR, so character attributes which cover the whole node got converted to paragraph attributes. The new UNO filter goes through SwXText::insertTextPortion(), which sets SetAttrMode::NOFORMATATTR, so this doesn't happen. The result of this is that when the UI sets a new paragraph style on the text node, then such character attributes are no longer removed. Given that in RTF you can't really have character properties on a paragraph, going back to the document model produced by the old internal filter doesn't sound like the good direction -- not to mention that changing SwXText::insertTextPortion() this way would be an implicit API change. Fix the problem by tweaking SwEditShell::SetTxtFmtColl() instead, so that it removes these full-text-node character attributes, too. The logic in SwTxtNode::RstTxtAttr() can be extended later if necessary to delete more attributes, but to be on the safe side, just handle the bare minimum necessary to fix the problem for now. Change-Id: I5faa3226fc0f9c18e005da185fe0830d8c393256
Diffstat (limited to 'sw/source/core/txtnode/txtedt.cxx')
-rw-r--r--sw/source/core/txtnode/txtedt.cxx22
1 files changed, 20 insertions, 2 deletions
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 9c8ea97f932c..06ebf9d4aef1 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -376,7 +376,8 @@ void SwTxtNode::RstTxtAttr(
const sal_Int32 nLen,
const sal_uInt16 nWhich,
const SfxItemSet* pSet,
- const bool bInclRefToxMark )
+ const bool bInclRefToxMark,
+ const bool bExactRange )
{
if ( !GetpSwpHints() )
return;
@@ -421,7 +422,7 @@ void SwTxtNode::RstTxtAttr(
SwTxtAttr *pHt = NULL;
while ( (i < m_pSwpHints->Count())
&& ( ( ( nAttrStart = (*m_pSwpHints)[i]->GetStart()) < nEnd )
- || nLen==0 ) )
+ || nLen==0 ) && !bExactRange)
{
pHt = m_pSwpHints->GetTextHint(i);
@@ -599,6 +600,23 @@ void SwTxtNode::RstTxtAttr(
++i;
}
+ if (bExactRange)
+ {
+ // Only delete the hints which start at nStt and end at nEnd.
+ for (i = 0; i < m_pSwpHints->Count(); ++i)
+ {
+ SwTxtAttr* pHint = m_pSwpHints->GetTextHint(i);
+ if (pHint->GetStart() != nStt)
+ continue;
+
+ const sal_Int32* pHintEnd = pHint->GetEnd();
+ if (!pHintEnd || *pHintEnd != nEnd)
+ continue;
+
+ delAttributes.push_back(pHint);
+ }
+ }
+
if (bChanged && !delAttributes.empty())
{ // Delete() calls GetStartOf() - requires sorted hints!
m_pSwpHints->Resort();