summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-06-20 00:20:52 +0200
committerMichael Stahl <mstahl@redhat.com>2013-06-20 00:50:11 +0200
commitc5423c79efc8f225d63419ebe71da5a4a009bc64 (patch)
tree392325f6e1d4bc93e659548cf0018eef0bfd7de0 /sw
parentd526b76c1dc0b3de564bc083821d512d41d5ab06 (diff)
fdo#62536: sw: fix AutoCorrect bold/underline on existing AUTOFMT
With the native AUTOFMT in Writer the SETATTR_DONTEXPAND does no longer work reliably: if there is an existing AUTOFMT at the position then it will be modified and no new hint with DontExpand will be inserted. Work around this deficiency by inserting a no-length hint with the preivous formatting at the end of the range. (similar fix to the i#75891 problem in SwTextShell::InsertSymbol) (commit 062eaeffe7cb986255063bb9b0a5f3fb3fc8e34c did not introduce the problem but made it far more annoying) Change-Id: I58ece7f5bd5a786b22a066e5902f1784dafa5dce (cherry picked from commit fe444d1f74abe417962be0bcd3340f40f2446b58)
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/swtypes.hxx2
-rw-r--r--sw/source/core/doc/docfmt.cxx24
2 files changed, 26 insertions, 0 deletions
diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx
index f5ba633310ab..d3c668818495 100644
--- a/sw/inc/swtypes.hxx
+++ b/sw/inc/swtypes.hxx
@@ -188,6 +188,8 @@ typedef sal_uInt16 SetAttrMode;
namespace nsSetAttrMode
{
const SetAttrMode SETATTR_DEFAULT = 0x0000; // Default.
+ /// @attention: DONTEXPAND does not work very well for CHARATR
+ /// because it can expand only the whole AUTOFMT or nothing
const SetAttrMode SETATTR_DONTEXPAND = 0x0001; // Don't expand text attribute any further.
const SetAttrMode SETATTR_DONTREPLACE = 0x0002; // Don't replace another text attribute.
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 748b5b28ca5b..c94b913f104a 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -2475,7 +2475,31 @@ void SwDoc::SetFmtItemByAutoFmt( const SwPaM& rPam, const SfxItemSet& rSet )
SetRedlineMode_intern( (RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
}
+ xub_StrLen const nEnd(rPam.End()->nContent.GetIndex());
+ std::vector<sal_uInt16> whichIds;
+ SfxItemIter iter(rSet);
+ for (SfxPoolItem const* pItem = iter.FirstItem();
+ pItem; pItem = iter.NextItem())
+ {
+ whichIds.push_back(pItem->Which());
+ whichIds.push_back(pItem->Which());
+ }
+ whichIds.push_back(0);
+ SfxItemSet currentSet(GetAttrPool(), &whichIds[0]);
+ pTNd->GetAttr(currentSet, nEnd, nEnd, false, true, false);
+ for (size_t i = 0; whichIds[i]; i += 2)
+ { // yuk - want to explicitly set the pool defaults too :-/
+ currentSet.Put(currentSet.Get(whichIds[i], true));
+ }
+
InsertItemSet( rPam, rSet, nsSetAttrMode::SETATTR_DONTEXPAND );
+
+ // fdo#62536: DONTEXPAND does not work when there is already an AUTOFMT
+ // here, so insert the old attributes as an empty hint to stop expand
+ SwPaM endPam(*pTNd, nEnd);
+ endPam.SetMark();
+ InsertItemSet(endPam, currentSet, nsSetAttrMode::SETATTR_DEFAULT);
+
SetRedlineMode_intern( eOld );
}