summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2014-04-26 12:21:00 +0200
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2014-04-30 16:46:09 +0200
commitdddae1f0b950f1ce8ab4bcd24991f1917fa36aa6 (patch)
tree0b470c8c832687198bc54eff739a1e1de7f335a6
parent62f6bb72f00e30427e29b499c24432f5f980fa9f (diff)
fdo#71556: Remove unwanted a11y event on text insertion
The accessibility event text-attributes-changed was being emitted every time we typed because typing implies changing the RSID internal format attribute. This change was triggering the event but it shouldn't, as it is an invisible attribute. I had added a new member to SwUpdateAttr class to be able to indicate which format attributes are being changed (until now, it just indicated that some attribute changed with RES_TXTATR_AUTOFMT and no more details). This member is populated when an SwUpdateAttr object is being created for a RES_TXTATR_AUTOFMT. Finally, I check the contents of this list to look for relevant a11y attributes before issuing the events, if there aren't then no events are issued. Change-Id: Ieaedf888ccc1bff9c7af64a1412ca1d3b5411351
-rw-r--r--sw/inc/hints.hxx2
-rw-r--r--sw/source/core/attr/hints.cxx7
-rw-r--r--sw/source/core/text/txtfrm.cxx22
-rw-r--r--sw/source/core/txtnode/thints.cxx20
4 files changed, 43 insertions, 8 deletions
diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx
index 82eb27c8a22e..be1f1ac2fad7 100644
--- a/sw/inc/hints.hxx
+++ b/sw/inc/hints.hxx
@@ -99,7 +99,9 @@ public:
sal_Int32 nStart;
sal_Int32 nEnd;
sal_uInt16 nWhichAttr;
+ std::vector<sal_uInt16> aWhichFmtAttr; // attributes changed inside RES_TXTATR_AUTOFMT
SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW );
+ SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW, std::vector<sal_uInt16> aW );
};
/** SwRefMarkFldUpdate is sent when the referencemarks should be updated.
diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx
index 44614b8e61b5..9b0f6a60866c 100644
--- a/sw/source/core/attr/hints.cxx
+++ b/sw/source/core/attr/hints.cxx
@@ -45,7 +45,12 @@ SwDelTxt::SwDelTxt( sal_Int32 nS, sal_Int32 nL )
}
SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW )
- : SwMsgPoolItem( RES_UPDATE_ATTR ), nStart( nS ), nEnd( nE ), nWhichAttr( nW )
+ : SwMsgPoolItem( RES_UPDATE_ATTR ), nStart( nS ), nEnd( nE ), nWhichAttr( nW ), aWhichFmtAttr()
+{
+}
+
+SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW, std::vector<sal_uInt16> aW )
+ : SwMsgPoolItem( RES_UPDATE_ATTR ), nStart( nS ), nEnd( nE ), nWhichAttr( nW ), aWhichFmtAttr( aW )
{
}
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 0139fd7df136..1da7fa4e3b2e 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -845,6 +845,16 @@ static bool isA11yRelevantAttribute(MSHORT nWhich)
return nWhich != RES_CHRATR_RSID;
}
+static bool hasA11yRelevantAttribute( const std::vector<MSHORT>& nWhich )
+{
+ for( std::vector<MSHORT>::const_iterator nItr = nWhich.begin();
+ nItr < nWhich.end(); ++nItr )
+ if ( isA11yRelevantAttribute( *nItr ) )
+ return true;
+
+ return false;
+}
+
void SwTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
{
const MSHORT nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
@@ -967,11 +977,15 @@ void SwTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
}
}
- // #i104008#
- SwViewShell* pViewSh = getRootFrm() ? getRootFrm()->GetCurrShell() : 0;
- if ( pViewSh )
+ if( isA11yRelevantAttribute( ((SwUpdateAttr*)pNew)->nWhichAttr ) &&
+ hasA11yRelevantAttribute( ((SwUpdateAttr*)pNew)->aWhichFmtAttr ) )
{
- pViewSh->InvalidateAccessibleParaAttrs( *this );
+ // #i104008#
+ SwViewShell* pViewSh = getRootFrm() ? getRootFrm()->GetCurrShell() : 0;
+ if ( pViewSh )
+ {
+ pViewSh->InvalidateAccessibleParaAttrs( *this );
+ }
}
}
break;
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 60336fb18174..cae6296bf64e 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -2955,6 +2955,7 @@ bool SwpHints::TryInsertHint(
sal_Int32 *pHtEnd = pHint->GetEnd();
sal_uInt16 nWhich = pHint->Which();
+ std::vector<sal_uInt16> aWhichSublist;
switch( nWhich )
{
@@ -2972,10 +2973,9 @@ bool SwpHints::TryInsertHint(
// #i75430# Recalc hidden flags if necessary
case RES_TXTATR_AUTOFMT:
{
+ boost::shared_ptr<SfxItemSet> const pSet( pHint->GetAutoFmt().GetStyleHandle() );
if (*pHint->GetStart() == *pHint->GetEnd())
{
- boost::shared_ptr<SfxItemSet> const pSet(
- pHint->GetAutoFmt().GetStyleHandle());
if (pSet->Count() == 1 && pSet->GetItem(RES_CHRATR_RSID, false))
{ // empty range RSID-only hints could cause trouble, there's no
rNode.DestroyAttr(pHint); // need for them so don't insert
@@ -2986,6 +2986,19 @@ bool SwpHints::TryInsertHint(
const SfxPoolItem* pHiddenItem = CharFmt::GetItem( *pHint, RES_CHRATR_HIDDEN );
if ( pHiddenItem )
rNode.SetCalcHiddenCharFlags();
+
+ // fdo#71556: populate aWhichFmtAttr member of SwMsgPoolItem
+ const sal_uInt16 *pRanges = pSet->GetRanges();
+ while( (*pRanges) != 0 )
+ {
+ sal_uInt16 nBeg = (*pRanges);
+ ++pRanges;
+ sal_uInt16 nEnd = (*pRanges);
+ ++pRanges;
+ for( sal_uInt16 nSubElem = nBeg; nSubElem <= nEnd; ++nSubElem )
+ if( pSet->HasItem( nSubElem ) )
+ aWhichSublist.push_back( nSubElem );
+ }
break;
}
case RES_TXTATR_INETFMT:
@@ -3237,7 +3250,8 @@ bool SwpHints::TryInsertHint(
// ... und die Abhaengigen benachrichtigen
if ( rNode.GetDepends() )
{
- SwUpdateAttr aHint( nHtStart, nHtStart == nHintEnd ? nHintEnd + 1 : nHintEnd, nWhich );
+ SwUpdateAttr aHint( nHtStart, nHtStart == nHintEnd ? nHintEnd + 1 : nHintEnd,
+ nWhich, aWhichSublist );
rNode.ModifyNotification( 0, &aHint );
}