diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-06-20 00:20:52 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-06-20 00:34:39 +0200 |
commit | fe444d1f74abe417962be0bcd3340f40f2446b58 (patch) | |
tree | 5698d2b3f92c6e18779310f84ec6e94108d58203 /sw | |
parent | 6db39dbd7378351f6476f6db25eb7110c9cfb291 (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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/swtypes.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docfmt.cxx | 24 |
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 ); } |