[Libreoffice-commits] core.git: sw/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sat Aug 1 11:29:33 UTC 2020
sw/source/core/SwNumberTree/SwNodeNum.cxx | 40 -
sw/source/core/SwNumberTree/SwNumberTree.cxx | 206 +++----
sw/source/core/access/AccessibilityCheck.cxx | 367 ++++++------
sw/source/core/access/acccontext.cxx | 129 ++--
sw/source/core/access/accframebase.cxx | 62 +-
sw/source/core/access/accmap.cxx | 792 +++++++++++++--------------
sw/source/core/access/accpage.cxx | 20
sw/source/core/access/accpara.cxx | 36 -
sw/source/core/access/accselectionhelper.cxx | 26
9 files changed, 835 insertions(+), 843 deletions(-)
New commits:
commit a27236b9071d3cf09adbb5bc4fea9edebe96d145
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jul 30 10:32:56 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Aug 1 13:28:56 2020 +0200
loplugin:flatten in sw/core/access
Change-Id: I0116fe288b97d22c3f170f139fe95cfd06d89d8f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99935
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/core/SwNumberTree/SwNodeNum.cxx b/sw/source/core/SwNumberTree/SwNodeNum.cxx
index f77b002a67ff..38c00087bd52 100644
--- a/sw/source/core/SwNumberTree/SwNodeNum.cxx
+++ b/sw/source/core/SwNumberTree/SwNodeNum.cxx
@@ -328,26 +328,26 @@ void SwNodeNum::UnregisterMeAndChildrenDueToRootDelete( SwNodeNum& rNodeNum )
UnregisterMeAndChildrenDueToRootDelete( *pChildNode );
}
- if ( !bIsPhantom )
- {
- SwTextNode* pTextNode( rNodeNum.GetTextNode() );
- if ( pTextNode )
- {
- pTextNode->RemoveFromList();
- // --> clear all list attributes and the list style
- std::set<sal_uInt16> aResetAttrsArray;
- aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_ID );
- aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_LEVEL );
- aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_ISRESTART );
- aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_RESTARTVALUE );
- aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_ISCOUNTED );
- aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_NUMRULE );
- SwPaM aPam( *pTextNode );
- pTextNode->GetDoc()->ResetAttrs( aPam, false,
- aResetAttrsArray,
- false );
- }
- }
+ if ( bIsPhantom )
+ return;
+
+ SwTextNode* pTextNode( rNodeNum.GetTextNode() );
+ if ( !pTextNode )
+ return;
+
+ pTextNode->RemoveFromList();
+ // --> clear all list attributes and the list style
+ std::set<sal_uInt16> aResetAttrsArray;
+ aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_ID );
+ aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_LEVEL );
+ aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_ISRESTART );
+ aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_RESTARTVALUE );
+ aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_ISCOUNTED );
+ aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_NUMRULE );
+ SwPaM aPam( *pTextNode );
+ pTextNode->GetDoc()->ResetAttrs( aPam, false,
+ aResetAttrsArray,
+ false );
}
// #i81002#
diff --git a/sw/source/core/SwNumberTree/SwNumberTree.cxx b/sw/source/core/SwNumberTree/SwNumberTree.cxx
index 2b2ab634b518..ab78733da94c 100644
--- a/sw/source/core/SwNumberTree/SwNumberTree.cxx
+++ b/sw/source/core/SwNumberTree/SwNumberTree.cxx
@@ -107,21 +107,21 @@ void SwNumberTreeNode::ClearObsoletePhantoms()
{
tSwNumberTreeChildren::iterator aIt = mChildren.begin();
- if (aIt != mChildren.end() && (*aIt)->IsPhantom())
- {
- (*aIt)->ClearObsoletePhantoms();
+ if (!(aIt != mChildren.end() && (*aIt)->IsPhantom()))
+ return;
- if ((*aIt)->mChildren.empty())
- {
- // #i60652#
- // Because <mChildren.erase(aIt)> could destroy the element, which
- // is referenced by <mItLastValid>, it's needed to adjust
- // <mItLastValid> before erasing <aIt>.
- SetLastValid(mChildren.end());
+ (*aIt)->ClearObsoletePhantoms();
- delete *aIt;
- mChildren.erase(aIt);
- }
+ if ((*aIt)->mChildren.empty())
+ {
+ // #i60652#
+ // Because <mChildren.erase(aIt)> could destroy the element, which
+ // is referenced by <mItLastValid>, it's needed to adjust
+ // <mItLastValid> before erasing <aIt>.
+ SetLastValid(mChildren.end());
+
+ delete *aIt;
+ mChildren.erase(aIt);
}
}
@@ -130,102 +130,102 @@ void SwNumberTreeNode::ValidateHierarchical(const SwNumberTreeNode * pNode) cons
tSwNumberTreeChildren::const_iterator aValidateIt =
GetIterator(pNode);
- if (aValidateIt != mChildren.end())
- {
- OSL_ENSURE((*aValidateIt)->mpParent == this, "wrong parent");
+ if (aValidateIt == mChildren.end())
+ return;
- tSwNumberTreeChildren::const_iterator aIt = mItLastValid;
+ OSL_ENSURE((*aValidateIt)->mpParent == this, "wrong parent");
- // -->
- // improvement:
- // - Only one time checked for <mChildren.end()>.
- // - Less checks for each loop run.
- // correction:
- // - consider case that current node isn't counted and isn't the first
- // child of its parent. In this case the number of last counted child
- // of the previous node determines the start value for the following
- // children loop, if all children have to be validated and the first
- // one doesn't restart the counting.
- SwNumberTree::tSwNumTreeNumber nTmpNumber( 0 );
- if (aIt != mChildren.end())
- nTmpNumber = (*aIt)->mnNumber;
- else
- {
- aIt = mChildren.begin();
- (*aIt)->mbContinueingPreviousSubTree = false;
+ tSwNumberTreeChildren::const_iterator aIt = mItLastValid;
- // determine default start value
- // consider the case that the first child isn't counted.
- nTmpNumber = (*aIt)->GetStartValue();
- if ( !(*aIt)->IsCounted() &&
- ( !(*aIt)->HasCountedChildren() || (*aIt)->IsPhantom() ) )
- {
- --nTmpNumber;
- }
+ // -->
+ // improvement:
+ // - Only one time checked for <mChildren.end()>.
+ // - Less checks for each loop run.
+ // correction:
+ // - consider case that current node isn't counted and isn't the first
+ // child of its parent. In this case the number of last counted child
+ // of the previous node determines the start value for the following
+ // children loop, if all children have to be validated and the first
+ // one doesn't restart the counting.
+ SwNumberTree::tSwNumTreeNumber nTmpNumber( 0 );
+ if (aIt != mChildren.end())
+ nTmpNumber = (*aIt)->mnNumber;
+ else
+ {
+ aIt = mChildren.begin();
+ (*aIt)->mbContinueingPreviousSubTree = false;
+
+ // determine default start value
+ // consider the case that the first child isn't counted.
+ nTmpNumber = (*aIt)->GetStartValue();
+ if ( !(*aIt)->IsCounted() &&
+ ( !(*aIt)->HasCountedChildren() || (*aIt)->IsPhantom() ) )
+ {
+ --nTmpNumber;
+ }
- // determine special start value for the case that first child
- // doesn't restart the numbering and the parent node isn't counted
- // and isn't the first child.
- const bool bParentCounted( IsCounted() &&
- ( !IsPhantom() ||
- HasPhantomCountedParent() ) );
- if ( !(*aIt)->IsRestart() &&
- GetParent() && !bParentCounted )
+ // determine special start value for the case that first child
+ // doesn't restart the numbering and the parent node isn't counted
+ // and isn't the first child.
+ const bool bParentCounted( IsCounted() &&
+ ( !IsPhantom() ||
+ HasPhantomCountedParent() ) );
+ if ( !(*aIt)->IsRestart() &&
+ GetParent() && !bParentCounted )
+ {
+ tSwNumberTreeChildren::const_iterator aParentChildIt =
+ GetParent()->GetIterator( this );
+ while ( aParentChildIt != GetParent()->mChildren.begin() )
{
- tSwNumberTreeChildren::const_iterator aParentChildIt =
- GetParent()->GetIterator( this );
- while ( aParentChildIt != GetParent()->mChildren.begin() )
+ --aParentChildIt;
+ SwNumberTreeNode* pPrevNode( *aParentChildIt );
+ if ( pPrevNode->GetChildCount() > 0 )
{
- --aParentChildIt;
- SwNumberTreeNode* pPrevNode( *aParentChildIt );
- if ( pPrevNode->GetChildCount() > 0 )
- {
- (*aIt)->mbContinueingPreviousSubTree = true;
- nTmpNumber = (*(pPrevNode->mChildren.rbegin()))->GetNumber();
- if ( (*aIt)->IsCounted() &&
- ( !(*aIt)->IsPhantom() ||
- (*aIt)->HasPhantomCountedParent() ) )
- {
- ++nTmpNumber;
- }
- break;
- }
- else if ( pPrevNode->IsCounted() )
+ (*aIt)->mbContinueingPreviousSubTree = true;
+ nTmpNumber = (*(pPrevNode->mChildren.rbegin()))->GetNumber();
+ if ( (*aIt)->IsCounted() &&
+ ( !(*aIt)->IsPhantom() ||
+ (*aIt)->HasPhantomCountedParent() ) )
{
- break;
- }
- else
- {
- // Previous node has no children and is not counted.
- // Thus, next turn and check for the previous node.
+ ++nTmpNumber;
}
+ break;
+ }
+ else if ( pPrevNode->IsCounted() )
+ {
+ break;
+ }
+ else
+ {
+ // Previous node has no children and is not counted.
+ // Thus, next turn and check for the previous node.
}
}
-
- (*aIt)->mnNumber = nTmpNumber;
}
- while (aIt != aValidateIt)
- {
- ++aIt;
- (*aIt)->mbContinueingPreviousSubTree = false;
+ (*aIt)->mnNumber = nTmpNumber;
+ }
- // --> only for counted nodes the number
- // has to be adjusted, compared to the previous node.
- // this condition is hold also for nodes, which restart the numbering.
- if ( (*aIt)->IsCounted() )
- {
- if ((*aIt)->IsRestart())
- nTmpNumber = (*aIt)->GetStartValue();
- else
- ++nTmpNumber;
- }
+ while (aIt != aValidateIt)
+ {
+ ++aIt;
+ (*aIt)->mbContinueingPreviousSubTree = false;
- (*aIt)->mnNumber = nTmpNumber;
+ // --> only for counted nodes the number
+ // has to be adjusted, compared to the previous node.
+ // this condition is hold also for nodes, which restart the numbering.
+ if ( (*aIt)->IsCounted() )
+ {
+ if ((*aIt)->IsRestart())
+ nTmpNumber = (*aIt)->GetStartValue();
+ else
+ ++nTmpNumber;
}
- SetLastValid(aIt, true);
+ (*aIt)->mnNumber = nTmpNumber;
}
+
+ SetLastValid(aIt, true);
}
void SwNumberTreeNode::ValidateContinuous(const SwNumberTreeNode * pNode) const
@@ -640,23 +640,23 @@ void SwNumberTreeNode::RemoveChild(SwNumberTreeNode * pChild)
void SwNumberTreeNode::RemoveMe()
{
- if (mpParent)
- {
- SwNumberTreeNode * pSavedParent = mpParent;
+ if (!mpParent)
+ return;
- pSavedParent->RemoveChild(this);
+ SwNumberTreeNode * pSavedParent = mpParent;
- while (pSavedParent && pSavedParent->IsPhantom() &&
- pSavedParent->HasOnlyPhantoms())
- pSavedParent = pSavedParent->GetParent();
+ pSavedParent->RemoveChild(this);
- if (pSavedParent)
- pSavedParent->ClearObsoletePhantoms();
+ while (pSavedParent && pSavedParent->IsPhantom() &&
+ pSavedParent->HasOnlyPhantoms())
+ pSavedParent = pSavedParent->GetParent();
+
+ if (pSavedParent)
+ pSavedParent->ClearObsoletePhantoms();
#ifdef DBG_UTIL
- IsSane(false);
+ IsSane(false);
#endif
- }
}
bool SwNumberTreeNode::IsValid() const
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index b59596da9a6b..b3bb024df39b 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -80,28 +80,28 @@ class NoTextNodeAltTextCheck : public NodeCheck
return;
OUString sAlternative = pNoTextNode->GetTitle();
- if (sAlternative.isEmpty())
- {
- OUString sName = pNoTextNode->GetFlyFormat()->GetName();
+ if (!sAlternative.isEmpty())
+ return;
- OUString sIssueText = SwResId(STR_NO_ALT).replaceAll("%OBJECT_NAME%", sName);
+ OUString sName = pNoTextNode->GetFlyFormat()->GetName();
- if (pNoTextNode->IsOLENode())
- {
- auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText,
- sfx::AccessibilityIssueID::NO_ALT_OLE);
- pIssue->setDoc(pNoTextNode->GetDoc());
- pIssue->setIssueObject(IssueObject::OLE);
- pIssue->setObjectID(pNoTextNode->GetFlyFormat()->GetName());
- }
- else if (pNoTextNode->IsGrfNode())
- {
- auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText,
- sfx::AccessibilityIssueID::NO_ALT_GRAPHIC);
- pIssue->setDoc(pNoTextNode->GetDoc());
- pIssue->setIssueObject(IssueObject::GRAPHIC);
- pIssue->setObjectID(pNoTextNode->GetFlyFormat()->GetName());
- }
+ OUString sIssueText = SwResId(STR_NO_ALT).replaceAll("%OBJECT_NAME%", sName);
+
+ if (pNoTextNode->IsOLENode())
+ {
+ auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText,
+ sfx::AccessibilityIssueID::NO_ALT_OLE);
+ pIssue->setDoc(pNoTextNode->GetDoc());
+ pIssue->setIssueObject(IssueObject::OLE);
+ pIssue->setObjectID(pNoTextNode->GetFlyFormat()->GetName());
+ }
+ else if (pNoTextNode->IsGrfNode())
+ {
+ auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText,
+ sfx::AccessibilityIssueID::NO_ALT_GRAPHIC);
+ pIssue->setDoc(pNoTextNode->GetDoc());
+ pIssue->setIssueObject(IssueObject::GRAPHIC);
+ pIssue->setObjectID(pNoTextNode->GetFlyFormat()->GetName());
}
}
@@ -225,24 +225,24 @@ public:
void check(SwNode* pCurrent) override
{
- if (pCurrent->IsTextNode())
+ if (!pCurrent->IsTextNode())
+ return;
+
+ if (m_pPreviousTextNode)
{
- if (m_pPreviousTextNode)
+ for (auto& rPair : m_aNumberingCombinations)
{
- for (auto& rPair : m_aNumberingCombinations)
+ if (pCurrent->GetTextNode()->GetText().startsWith(rPair.second)
+ && m_pPreviousTextNode->GetText().startsWith(rPair.first))
{
- if (pCurrent->GetTextNode()->GetText().startsWith(rPair.second)
- && m_pPreviousTextNode->GetText().startsWith(rPair.first))
- {
- OUString sNumbering = rPair.first + " " + rPair.second + "...";
- OUString sIssueText
- = SwResId(STR_FAKE_NUMBERING).replaceAll("%NUMBERING%", sNumbering);
- lclAddIssue(m_rIssueCollection, sIssueText);
- }
+ OUString sNumbering = rPair.first + " " + rPair.second + "...";
+ OUString sIssueText
+ = SwResId(STR_FAKE_NUMBERING).replaceAll("%NUMBERING%", sNumbering);
+ lclAddIssue(m_rIssueCollection, sIssueText);
}
}
- m_pPreviousTextNode = pCurrent->GetTextNode();
}
+ m_pPreviousTextNode = pCurrent->GetTextNode();
}
};
@@ -252,19 +252,19 @@ private:
void checkTextRange(uno::Reference<text::XTextRange> const& xTextRange)
{
uno::Reference<beans::XPropertySet> xProperties(xTextRange, uno::UNO_QUERY);
- if (xProperties->getPropertySetInfo()->hasPropertyByName("HyperLinkURL"))
+ if (!xProperties->getPropertySetInfo()->hasPropertyByName("HyperLinkURL"))
+ return;
+
+ OUString sHyperlink;
+ xProperties->getPropertyValue("HyperLinkURL") >>= sHyperlink;
+ if (!sHyperlink.isEmpty())
{
- OUString sHyperlink;
- xProperties->getPropertyValue("HyperLinkURL") >>= sHyperlink;
- if (!sHyperlink.isEmpty())
+ OUString sText = xTextRange->getString();
+ if (INetURLObject(sText) == INetURLObject(sHyperlink))
{
- OUString sText = xTextRange->getString();
- if (INetURLObject(sText) == INetURLObject(sHyperlink))
- {
- OUString sIssueText
- = SwResId(STR_HYPERLINK_TEXT_IS_LINK).replaceFirst("%LINK%", sHyperlink);
- lclAddIssue(m_rIssueCollection, sIssueText);
- }
+ OUString sIssueText
+ = SwResId(STR_HYPERLINK_TEXT_IS_LINK).replaceFirst("%LINK%", sHyperlink);
+ lclAddIssue(m_rIssueCollection, sIssueText);
}
}
}
@@ -277,25 +277,23 @@ public:
void check(SwNode* pCurrent) override
{
- if (pCurrent->IsTextNode())
+ if (!pCurrent->IsTextNode())
+ return;
+
+ SwTextNode* pTextNode = pCurrent->GetTextNode();
+ uno::Reference<text::XTextContent> xParagraph
+ = SwXParagraph::CreateXParagraph(*pTextNode->GetDoc(), pTextNode);
+ if (!xParagraph.is())
+ return;
+
+ uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+ while (xRunEnum->hasMoreElements())
{
- SwTextNode* pTextNode = pCurrent->GetTextNode();
- uno::Reference<text::XTextContent> xParagraph
- = SwXParagraph::CreateXParagraph(*pTextNode->GetDoc(), pTextNode);
- if (xParagraph.is())
+ uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+ if (xRun.is())
{
- uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph,
- uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> xRunEnum
- = xRunEnumAccess->createEnumeration();
- while (xRunEnum->hasMoreElements())
- {
- uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
- if (xRun.is())
- {
- checkTextRange(xRun);
- }
- }
+ checkTextRange(xRun);
}
}
}
@@ -349,62 +347,62 @@ private:
}
uno::Reference<beans::XPropertySet> xProperties(xTextRange, uno::UNO_QUERY);
- if (xProperties.is())
- {
- // Foreground color
- sal_Int32 nCharColor = {}; // spurious -Werror=maybe-uninitialized
- if (!(xProperties->getPropertyValue("CharColor") >>= nCharColor))
- { // not sure this is impossible, can the default be void?
- SAL_WARN("sw.a11y", "CharColor void");
- return;
- }
- Color aForegroundColor(nCharColor);
- if (aForegroundColor == COL_AUTO)
- return;
+ if (!xProperties.is())
+ return;
- const SwPageDesc* pPageDescription = pTextNode->FindPageDesc();
- const SwFrameFormat& rPageFormat = pPageDescription->GetMaster();
- const SwAttrSet& rPageSet = rPageFormat.GetAttrSet();
+ // Foreground color
+ sal_Int32 nCharColor = {}; // spurious -Werror=maybe-uninitialized
+ if (!(xProperties->getPropertyValue("CharColor") >>= nCharColor))
+ { // not sure this is impossible, can the default be void?
+ SAL_WARN("sw.a11y", "CharColor void");
+ return;
+ }
+ Color aForegroundColor(nCharColor);
+ if (aForegroundColor == COL_AUTO)
+ return;
- const XFillStyleItem* pXFillStyleItem(
- rPageSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE, false));
- Color aPageBackground;
+ const SwPageDesc* pPageDescription = pTextNode->FindPageDesc();
+ const SwFrameFormat& rPageFormat = pPageDescription->GetMaster();
+ const SwAttrSet& rPageSet = rPageFormat.GetAttrSet();
- if (pXFillStyleItem && pXFillStyleItem->GetValue() == css::drawing::FillStyle_SOLID)
- {
- const XFillColorItem* rXFillColorItem
- = rPageSet.GetItem<XFillColorItem>(XATTR_FILLCOLOR, false);
- aPageBackground = rXFillColorItem->GetColorValue();
- }
+ const XFillStyleItem* pXFillStyleItem(
+ rPageSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE, false));
+ Color aPageBackground;
- sal_Int32 nCharBackColor = {}; // spurious -Werror=maybe-uninitialized
+ if (pXFillStyleItem && pXFillStyleItem->GetValue() == css::drawing::FillStyle_SOLID)
+ {
+ const XFillColorItem* rXFillColorItem
+ = rPageSet.GetItem<XFillColorItem>(XATTR_FILLCOLOR, false);
+ aPageBackground = rXFillColorItem->GetColorValue();
+ }
- if (!(xProperties->getPropertyValue("CharBackColor") >>= nCharBackColor))
- {
- SAL_WARN("sw.a11y", "CharBackColor void");
- return;
- }
- // Determine the background color
- // Try Character background (highlight)
- Color aBackgroundColor(nCharBackColor);
+ sal_Int32 nCharBackColor = {}; // spurious -Werror=maybe-uninitialized
- // If not character background color, try paragraph background color
- if (aBackgroundColor == COL_AUTO)
- aBackgroundColor = Color(nParaBackColor);
+ if (!(xProperties->getPropertyValue("CharBackColor") >>= nCharBackColor))
+ {
+ SAL_WARN("sw.a11y", "CharBackColor void");
+ return;
+ }
+ // Determine the background color
+ // Try Character background (highlight)
+ Color aBackgroundColor(nCharBackColor);
- // If not paragraph background color, try page color
- if (aBackgroundColor == COL_AUTO)
- aBackgroundColor = aPageBackground;
+ // If not character background color, try paragraph background color
+ if (aBackgroundColor == COL_AUTO)
+ aBackgroundColor = Color(nParaBackColor);
- // If not page color, assume white background color
- if (aBackgroundColor == COL_AUTO)
- aBackgroundColor = COL_WHITE;
+ // If not paragraph background color, try page color
+ if (aBackgroundColor == COL_AUTO)
+ aBackgroundColor = aPageBackground;
- double fContrastRatio = calculateContrastRatio(aForegroundColor, aBackgroundColor);
- if (fContrastRatio < 4.5)
- {
- lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_CONTRAST));
- }
+ // If not page color, assume white background color
+ if (aBackgroundColor == COL_AUTO)
+ aBackgroundColor = COL_WHITE;
+
+ double fContrastRatio = calculateContrastRatio(aForegroundColor, aBackgroundColor);
+ if (fContrastRatio < 4.5)
+ {
+ lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_CONTRAST));
}
}
@@ -416,24 +414,22 @@ public:
void check(SwNode* pCurrent) override
{
- if (pCurrent->IsTextNode())
+ if (!pCurrent->IsTextNode())
+ return;
+
+ SwTextNode* pTextNode = pCurrent->GetTextNode();
+ uno::Reference<text::XTextContent> xParagraph;
+ xParagraph = SwXParagraph::CreateXParagraph(*pTextNode->GetDoc(), pTextNode);
+ if (!xParagraph.is())
+ return;
+
+ uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+ while (xRunEnum->hasMoreElements())
{
- SwTextNode* pTextNode = pCurrent->GetTextNode();
- uno::Reference<text::XTextContent> xParagraph;
- xParagraph = SwXParagraph::CreateXParagraph(*pTextNode->GetDoc(), pTextNode);
- if (xParagraph.is())
- {
- uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph,
- uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> xRunEnum
- = xRunEnumAccess->createEnumeration();
- while (xRunEnum->hasMoreElements())
- {
- uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
- if (xRun.is())
- checkTextRange(xRun, xParagraph, pTextNode);
- }
- }
+ uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+ if (xRun.is())
+ checkTextRange(xRun, xParagraph, pTextNode);
}
}
};
@@ -519,35 +515,34 @@ public:
aFormattings.push_back(sFormattingType);
pItem = aItemIter.NextItem();
}
- if (!aFormattings.empty())
- {
- o3tl::remove_duplicates(aFormattings);
- auto pIssue
- = lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_FORMATTING_CONVEYS_MEANING),
- sfx::AccessibilityIssueID::TEXT_FORMATTING);
- pIssue->setIssueObject(IssueObject::TEXT);
- pIssue->setNode(pTextNode);
- SwDoc* pDocument = pTextNode->GetDoc();
- pIssue->setDoc(pDocument);
- pIssue->setStart(pTextAttr->GetStart());
- pIssue->setEnd(pTextAttr->GetAnyEnd());
- }
+ if (aFormattings.empty())
+ return;
+
+ o3tl::remove_duplicates(aFormattings);
+ auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_FORMATTING_CONVEYS_MEANING),
+ sfx::AccessibilityIssueID::TEXT_FORMATTING);
+ pIssue->setIssueObject(IssueObject::TEXT);
+ pIssue->setNode(pTextNode);
+ SwDoc* pDocument = pTextNode->GetDoc();
+ pIssue->setDoc(pDocument);
+ pIssue->setStart(pTextAttr->GetStart());
+ pIssue->setEnd(pTextAttr->GetAnyEnd());
}
void check(SwNode* pCurrent) override
{
- if (pCurrent->IsTextNode())
+ if (!pCurrent->IsTextNode())
+ return;
+
+ SwTextNode* pTextNode = pCurrent->GetTextNode();
+ if (pTextNode->HasHints())
{
- SwTextNode* pTextNode = pCurrent->GetTextNode();
- if (pTextNode->HasHints())
+ SwpHints& rHints = pTextNode->GetSwpHints();
+ for (size_t i = 0; i < rHints.Count(); ++i)
{
- SwpHints& rHints = pTextNode->GetSwpHints();
- for (size_t i = 0; i < rHints.Count(); ++i)
+ const SwTextAttr* pTextAttr = rHints.Get(i);
+ if (pTextAttr->Which() == RES_TXTATR_AUTOFMT)
{
- const SwTextAttr* pTextAttr = rHints.Get(i);
- if (pTextAttr->Which() == RES_TXTATR_AUTOFMT)
- {
- checkAutoFormat(pTextNode, pTextAttr);
- }
+ checkAutoFormat(pTextNode, pTextAttr);
}
}
}
@@ -580,24 +575,22 @@ public:
void check(SwNode* pCurrent) override
{
- if (pCurrent->IsTextNode())
+ if (!pCurrent->IsTextNode())
+ return;
+
+ SwTextNode* pTextNode = pCurrent->GetTextNode();
+ uno::Reference<text::XTextContent> xParagraph;
+ xParagraph = SwXParagraph::CreateXParagraph(*pTextNode->GetDoc(), pTextNode);
+ if (!xParagraph.is())
+ return;
+
+ uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+ while (xRunEnum->hasMoreElements())
{
- SwTextNode* pTextNode = pCurrent->GetTextNode();
- uno::Reference<text::XTextContent> xParagraph;
- xParagraph = SwXParagraph::CreateXParagraph(*pTextNode->GetDoc(), pTextNode);
- if (xParagraph.is())
- {
- uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph,
- uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> xRunEnum
- = xRunEnumAccess->createEnumeration();
- while (xRunEnum->hasMoreElements())
- {
- uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
- if (xRun.is())
- checkTextRange(xRun);
- }
- }
+ uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+ if (xRun.is())
+ checkTextRange(xRun);
}
}
};
@@ -616,20 +609,20 @@ public:
void check(SwNode* pCurrent) override
{
- if (pCurrent->IsTextNode())
- {
- SwTextNode* pTextNode = pCurrent->GetTextNode();
- SwTextFormatColl* pCollection = pTextNode->GetTextColl();
- int nLevel = pCollection->GetAssignedOutlineStyleLevel();
- if (nLevel < 0)
- return;
+ if (!pCurrent->IsTextNode())
+ return;
- if (nLevel > m_nPreviousLevel && std::abs(nLevel - m_nPreviousLevel) > 1)
- {
- lclAddIssue(m_rIssueCollection, SwResId(STR_HEADINGS_NOT_IN_ORDER));
- }
- m_nPreviousLevel = nLevel;
+ SwTextNode* pTextNode = pCurrent->GetTextNode();
+ SwTextFormatColl* pCollection = pTextNode->GetTextColl();
+ int nLevel = pCollection->GetAssignedOutlineStyleLevel();
+ if (nLevel < 0)
+ return;
+
+ if (nLevel > m_nPreviousLevel && std::abs(nLevel - m_nPreviousLevel) > 1)
+ {
+ lclAddIssue(m_rIssueCollection, SwResId(STR_HEADINGS_NOT_IN_ORDER));
}
+ m_nPreviousLevel = nLevel;
}
};
@@ -692,18 +685,18 @@ public:
void check(SwDoc* pDoc) override
{
SwDocShell* pShell = pDoc->GetDocShell();
- if (pShell)
+ if (!pShell)
+ return;
+
+ const uno::Reference<document::XDocumentPropertiesSupplier> xDPS(pShell->GetModel(),
+ uno::UNO_QUERY_THROW);
+ const uno::Reference<document::XDocumentProperties> xDocumentProperties(
+ xDPS->getDocumentProperties());
+ OUString sTitle = xDocumentProperties->getTitle();
+ if (sTitle.isEmpty())
{
- const uno::Reference<document::XDocumentPropertiesSupplier> xDPS(pShell->GetModel(),
- uno::UNO_QUERY_THROW);
- const uno::Reference<document::XDocumentProperties> xDocumentProperties(
- xDPS->getDocumentProperties());
- OUString sTitle = xDocumentProperties->getTitle();
- if (sTitle.isEmpty())
- {
- lclAddIssue(m_rIssueCollection, SwResId(STR_DOCUMENT_TITLE),
- sfx::AccessibilityIssueID::DOCUMENT_TITLE);
- }
+ lclAddIssue(m_rIssueCollection, SwResId(STR_DOCUMENT_TITLE),
+ sfx::AccessibilityIssueID::DOCUMENT_TITLE);
}
}
};
diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx
index 3b9f0f1e61cc..14c76002e73a 100644
--- a/sw/source/core/access/acccontext.cxx
+++ b/sw/source/core/access/acccontext.cxx
@@ -302,25 +302,24 @@ void SwAccessibleContext::ScrolledIn()
::rtl::Reference< SwAccessibleContext > xParentImpl(
GetMap()->GetContextImpl( pParent, false ) );
uno::Reference < XAccessibleContext > xThis( this );
- if( xParentImpl.is() )
- {
- SetParent( xParentImpl.get() );
+ if( !xParentImpl.is() )
+ return;
- AccessibleEventObject aEvent;
- aEvent.EventId = AccessibleEventId::CHILD;
- aEvent.NewValue <<= xThis;
+ SetParent( xParentImpl.get() );
- xParentImpl->FireAccessibleEvent( aEvent );
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.NewValue <<= xThis;
- if( HasCursor() )
+ xParentImpl->FireAccessibleEvent( aEvent );
+
+ if( HasCursor() )
+ {
+ vcl::Window *pWin = GetWindow();
+ if( pWin && pWin->HasFocus() )
{
- vcl::Window *pWin = GetWindow();
- if( pWin && pWin->HasFocus() )
- {
- FireStateChangedEvent( AccessibleStateType::FOCUSED, true );
- }
+ FireStateChangedEvent( AccessibleStateType::FOCUSED, true );
}
-
}
}
@@ -775,19 +774,19 @@ void SAL_CALL SwAccessibleContext::addAccessibleEventListener(
void SAL_CALL SwAccessibleContext::removeAccessibleEventListener(
const uno::Reference< XAccessibleEventListener >& xListener )
{
- if (xListener.is() && m_nClientId)
+ if (!(xListener.is() && m_nClientId))
+ return;
+
+ SolarMutexGuard aGuard;
+ sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
+ if ( !nListenerCount )
{
- SolarMutexGuard aGuard;
- sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
- if ( !nListenerCount )
- {
- // no listeners anymore
- // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
- // and at least to us not firing any events anymore, in case somebody calls
- // NotifyAccessibleEvent, again
- comphelper::AccessibleEventNotifier::revokeClient( m_nClientId );
- m_nClientId = 0;
- }
+ // no listeners anymore
+ // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
+ // and at least to us not firing any events anymore, in case somebody calls
+ // NotifyAccessibleEvent, again
+ comphelper::AccessibleEventNotifier::revokeClient( m_nClientId );
+ m_nClientId = 0;
}
}
@@ -1044,18 +1043,18 @@ void SwAccessibleContext::ScrolledInShape( ::accessibility::AccessibleShape *pAc
aEvent.NewValue <<= xAcc;
FireAccessibleEvent( aEvent );
- if( pAccImpl->GetState( AccessibleStateType::FOCUSED ) )
+ if( !pAccImpl->GetState( AccessibleStateType::FOCUSED ) )
+ return;
+
+ vcl::Window *pWin = GetWindow();
+ if( pWin && pWin->HasFocus() )
{
- vcl::Window *pWin = GetWindow();
- if( pWin && pWin->HasFocus() )
- {
- AccessibleEventObject aStateChangedEvent;
- aStateChangedEvent.EventId = AccessibleEventId::STATE_CHANGED;
- aStateChangedEvent.NewValue <<= AccessibleStateType::FOCUSED;
- aStateChangedEvent.Source = xAcc;
+ AccessibleEventObject aStateChangedEvent;
+ aStateChangedEvent.EventId = AccessibleEventId::STATE_CHANGED;
+ aStateChangedEvent.NewValue <<= AccessibleStateType::FOCUSED;
+ aStateChangedEvent.Source = xAcc;
- FireAccessibleEvent( aStateChangedEvent );
- }
+ FireAccessibleEvent( aStateChangedEvent );
}
}
@@ -1310,43 +1309,43 @@ void SwAccessibleContext::InvalidateFocus()
// #i27301# - use new type definition for <_nStates>
void SwAccessibleContext::InvalidateStates( AccessibleStates _nStates )
{
- if( GetMap() )
+ if( !GetMap() )
+ return;
+
+ SwViewShell *pVSh = GetMap()->GetShell();
+ if( pVSh )
{
- SwViewShell *pVSh = GetMap()->GetShell();
- if( pVSh )
+ if( _nStates & AccessibleStates::EDITABLE )
{
- if( _nStates & AccessibleStates::EDITABLE )
+ bool bIsOldEditableState;
+ bool bIsNewEditableState = IsEditable( pVSh );
{
- bool bIsOldEditableState;
- bool bIsNewEditableState = IsEditable( pVSh );
- {
- osl::MutexGuard aGuard( m_Mutex );
- bIsOldEditableState = m_isEditableState;
- m_isEditableState = bIsNewEditableState;
- }
-
- if( bIsOldEditableState != bIsNewEditableState )
- FireStateChangedEvent( AccessibleStateType::EDITABLE,
- bIsNewEditableState );
+ osl::MutexGuard aGuard( m_Mutex );
+ bIsOldEditableState = m_isEditableState;
+ m_isEditableState = bIsNewEditableState;
}
- if( _nStates & AccessibleStates::OPAQUE )
- {
- bool bIsOldOpaqueState;
- bool bIsNewOpaqueState = IsOpaque( pVSh );
- {
- osl::MutexGuard aGuard( m_Mutex );
- bIsOldOpaqueState = m_isOpaqueState;
- m_isOpaqueState = bIsNewOpaqueState;
- }
- if( bIsOldOpaqueState != bIsNewOpaqueState )
- FireStateChangedEvent( AccessibleStateType::OPAQUE,
- bIsNewOpaqueState );
- }
+ if( bIsOldEditableState != bIsNewEditableState )
+ FireStateChangedEvent( AccessibleStateType::EDITABLE,
+ bIsNewEditableState );
}
+ if( _nStates & AccessibleStates::OPAQUE )
+ {
+ bool bIsOldOpaqueState;
+ bool bIsNewOpaqueState = IsOpaque( pVSh );
+ {
+ osl::MutexGuard aGuard( m_Mutex );
+ bIsOldOpaqueState = m_isOpaqueState;
+ m_isOpaqueState = bIsNewOpaqueState;
+ }
- InvalidateChildrenStates( GetFrame(), _nStates );
+ if( bIsOldOpaqueState != bIsNewOpaqueState )
+ FireStateChangedEvent( AccessibleStateType::OPAQUE,
+ bIsNewOpaqueState );
+ }
}
+
+ InvalidateChildrenStates( GetFrame(), _nStates );
}
void SwAccessibleContext::InvalidateRelation( sal_uInt16 nType )
diff --git a/sw/source/core/access/accframebase.cxx b/sw/source/core/access/accframebase.cxx
index cfbfe9ecf678..a0d3aeacf73a 100644
--- a/sw/source/core/access/accframebase.cxx
+++ b/sw/source/core/access/accframebase.cxx
@@ -154,47 +154,47 @@ void SwAccessibleFrameBase::InvalidateCursorPos_()
GetMap()->SetCursorContext( xThis );
}
- if( bOldSelected != bNewSelected )
- {
- vcl::Window *pWin = GetWindow();
- if( pWin && pWin->HasFocus() && bNewSelected )
- FireStateChangedEvent( AccessibleStateType::FOCUSED, bNewSelected );
- if( pWin && pWin->HasFocus() && !bNewSelected )
- FireStateChangedEvent( AccessibleStateType::FOCUSED, bNewSelected );
- if(bNewSelected)
- {
- uno::Reference< XAccessible > xParent( GetWeakParent() );
- if( xParent.is() )
- {
- SwAccessibleContext *pAcc =
- static_cast <SwAccessibleContext *>( xParent.get() );
+ if( bOldSelected == bNewSelected )
+ return;
- AccessibleEventObject aEvent;
- aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
- uno::Reference< XAccessible > xChild(this);
- aEvent.NewValue <<= xChild;
- pAcc->FireAccessibleEvent( aEvent );
- }
- }
+ vcl::Window *pWin = GetWindow();
+ if( pWin && pWin->HasFocus() && bNewSelected )
+ FireStateChangedEvent( AccessibleStateType::FOCUSED, bNewSelected );
+ if( pWin && pWin->HasFocus() && !bNewSelected )
+ FireStateChangedEvent( AccessibleStateType::FOCUSED, bNewSelected );
+ if(!bNewSelected)
+ return;
+
+ uno::Reference< XAccessible > xParent( GetWeakParent() );
+ if( xParent.is() )
+ {
+ SwAccessibleContext *pAcc =
+ static_cast <SwAccessibleContext *>( xParent.get() );
+
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
+ uno::Reference< XAccessible > xChild(this);
+ aEvent.NewValue <<= xChild;
+ pAcc->FireAccessibleEvent( aEvent );
}
}
void SwAccessibleFrameBase::InvalidateFocus_()
{
vcl::Window *pWin = GetWindow();
- if( pWin )
- {
- bool bSelected;
+ if( !pWin )
+ return;
- {
- osl::MutexGuard aGuard( m_Mutex );
- bSelected = m_bIsSelected;
- }
- assert(bSelected && "focus object should be selected");
+ bool bSelected;
- FireStateChangedEvent( AccessibleStateType::FOCUSED,
- pWin->HasFocus() && bSelected );
+ {
+ osl::MutexGuard aGuard( m_Mutex );
+ bSelected = m_bIsSelected;
}
+ assert(bSelected && "focus object should be selected");
+
+ FireStateChangedEvent( AccessibleStateType::FOCUSED,
+ pWin->HasFocus() && bSelected );
}
bool SwAccessibleFrameBase::HasCursor()
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index fe2c2e1b0426..ce88aa618665 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -1470,25 +1470,25 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
}
mapTemp.clear();
- if( bMarkChanged && mpFrameMap)
+ if( !(bMarkChanged && mpFrameMap))
+ return;
+
+ for (SwAccessibleContext* pAccPara : vecAdd)
{
- for (SwAccessibleContext* pAccPara : vecAdd)
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
+ if (pAccPara)
{
- AccessibleEventObject aEvent;
- aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
- if (pAccPara)
- {
- pAccPara->FireAccessibleEvent( aEvent );
- }
+ pAccPara->FireAccessibleEvent( aEvent );
}
- for (SwAccessibleContext* pAccPara : vecRemove)
+ }
+ for (SwAccessibleContext* pAccPara : vecRemove)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
+ if (pAccPara)
{
- AccessibleEventObject aEvent;
- aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
- if (pAccPara)
- {
- pAccPara->FireAccessibleEvent( aEvent );
- }
+ pAccPara->FireAccessibleEvent( aEvent );
}
}
}
@@ -2103,39 +2103,39 @@ void SwAccessibleMap::RemoveGroupContext(const SdrObject *pParentObj)
void SwAccessibleMap::AddGroupContext(const SdrObject *pParentObj, uno::Reference < XAccessible > const & xAccParent)
{
osl::MutexGuard aGuard( maMutex );
- if( mpShapeMap )
+ if( !mpShapeMap )
+ return;
+
+ //here get all the sub list.
+ if (!pParentObj->IsGroupObject())
+ return;
+
+ if (!xAccParent.is())
+ return;
+
+ uno::Reference < XAccessibleContext > xContext = xAccParent->getAccessibleContext();
+ if (!xContext.is())
+ return;
+
+ sal_Int32 nChildren = xContext->getAccessibleChildCount();
+ for(sal_Int32 i = 0; i<nChildren; i++)
{
- //here get all the sub list.
- if (pParentObj->IsGroupObject())
+ uno::Reference < XAccessible > xChild = xContext->getAccessibleChild(i);
+ if (xChild.is())
{
- if (xAccParent.is())
+ uno::Reference < XAccessibleContext > xChildContext = xChild->getAccessibleContext();
+ if (xChildContext.is())
{
- uno::Reference < XAccessibleContext > xContext = xAccParent->getAccessibleContext();
- if (xContext.is())
+ short nRole = xChildContext->getAccessibleRole();
+ if (nRole == AccessibleRole::SHAPE)
{
- sal_Int32 nChildren = xContext->getAccessibleChildCount();
- for(sal_Int32 i = 0; i<nChildren; i++)
+ ::accessibility::AccessibleShape* pAccShape = static_cast < ::accessibility::AccessibleShape* >( xChild.get());
+ uno::Reference < drawing::XShape > xShape = pAccShape->GetXShape();
+ if (xShape.is())
{
- uno::Reference < XAccessible > xChild = xContext->getAccessibleChild(i);
- if (xChild.is())
- {
- uno::Reference < XAccessibleContext > xChildContext = xChild->getAccessibleContext();
- if (xChildContext.is())
- {
- short nRole = xChildContext->getAccessibleRole();
- if (nRole == AccessibleRole::SHAPE)
- {
- ::accessibility::AccessibleShape* pAccShape = static_cast < ::accessibility::AccessibleShape* >( xChild.get());
- uno::Reference < drawing::XShape > xShape = pAccShape->GetXShape();
- if (xShape.is())
- {
- SdrObject* pObj = GetSdrObjectFromXShape(xShape);
- AddShapeContext(pObj, xChild);
- AddGroupContext(pObj,xChild);
- }
- }
- }
- }
+ SdrObject* pObj = GetSdrObjectFromXShape(xShape);
+ AddShapeContext(pObj, xChild);
+ AddGroupContext(pObj,xChild);
}
}
}
@@ -2160,59 +2160,59 @@ void SwAccessibleMap::RemoveContext( const SwFrame *pFrame )
{
osl::MutexGuard aGuard( maMutex );
- if( mpFrameMap )
- {
- SwAccessibleContextMap_Impl::iterator aIter =
- mpFrameMap->find( pFrame );
- if( aIter != mpFrameMap->end() )
- {
- mpFrameMap->erase( aIter );
+ if( !mpFrameMap )
+ return;
- // Remove reference to old caret object. Though mxCursorContext
- // is a weak reference and cleared automatically, clearing it
- // directly makes sure to not keep a non-functional object.
- uno::Reference < XAccessible > xOldAcc( mxCursorContext );
- if( xOldAcc.is() )
- {
- SwAccessibleContext *pOldAccImpl =
- static_cast< SwAccessibleContext *>( xOldAcc.get() );
- OSL_ENSURE( pOldAccImpl->GetFrame(), "old caret context is disposed" );
- if( pOldAccImpl->GetFrame() == pFrame )
- {
- xOldAcc.clear(); // get an empty ref
- mxCursorContext = xOldAcc;
- }
- }
+ SwAccessibleContextMap_Impl::iterator aIter =
+ mpFrameMap->find( pFrame );
+ if( aIter == mpFrameMap->end() )
+ return;
- if( mpFrameMap->empty() )
- {
- mpFrameMap.reset();
- }
+ mpFrameMap->erase( aIter );
+
+ // Remove reference to old caret object. Though mxCursorContext
+ // is a weak reference and cleared automatically, clearing it
+ // directly makes sure to not keep a non-functional object.
+ uno::Reference < XAccessible > xOldAcc( mxCursorContext );
+ if( xOldAcc.is() )
+ {
+ SwAccessibleContext *pOldAccImpl =
+ static_cast< SwAccessibleContext *>( xOldAcc.get() );
+ OSL_ENSURE( pOldAccImpl->GetFrame(), "old caret context is disposed" );
+ if( pOldAccImpl->GetFrame() == pFrame )
+ {
+ xOldAcc.clear(); // get an empty ref
+ mxCursorContext = xOldAcc;
}
}
+
+ if( mpFrameMap->empty() )
+ {
+ mpFrameMap.reset();
+ }
}
void SwAccessibleMap::RemoveContext( const SdrObject *pObj )
{
osl::MutexGuard aGuard( maMutex );
- if( mpShapeMap )
- {
- SwAccessibleShapeMap_Impl::iterator aIter = mpShapeMap->find( pObj );
- if( aIter != mpShapeMap->end() )
- {
- uno::Reference < XAccessible > xTempHold( (*aIter).second );
- mpShapeMap->erase( aIter );
- RemoveGroupContext(pObj);
- // The shape selection flag is not cleared, but one might do
- // so but has to make sure that the removed context is the one
- // that is selected.
+ if( !mpShapeMap )
+ return;
- if( mpShapeMap && mpShapeMap->empty() )
- {
- mpShapeMap.reset();
- }
- }
+ SwAccessibleShapeMap_Impl::iterator aIter = mpShapeMap->find( pObj );
+ if( aIter == mpShapeMap->end() )
+ return;
+
+ uno::Reference < XAccessible > xTempHold( (*aIter).second );
+ mpShapeMap->erase( aIter );
+ RemoveGroupContext(pObj);
+ // The shape selection flag is not cleared, but one might do
+ // so but has to make sure that the removed context is the one
+ // that is selected.
+
+ if( mpShapeMap && mpShapeMap->empty() )
+ {
+ mpShapeMap.reset();
}
}
@@ -2236,115 +2236,115 @@ void SwAccessibleMap::A11yDispose( const SwFrame *pFrame,
OSL_ENSURE( !aFrameOrObj.GetSwFrame() || aFrameOrObj.GetSwFrame()->IsAccessibleFrame(),
"non accessible frame should be disposed" );
- if (aFrameOrObj.IsAccessible(GetShell()->IsPreview())
+ if (!(aFrameOrObj.IsAccessible(GetShell()->IsPreview())
// fdo#87199 dispose the darn thing if it ever was accessible
- || Contains(pFrame))
+ || Contains(pFrame)))
+ return;
+
+ ::rtl::Reference< SwAccessibleContext > xAccImpl;
+ ::rtl::Reference< SwAccessibleContext > xParentAccImpl;
+ ::rtl::Reference< ::accessibility::AccessibleShape > xShapeAccImpl;
+ // get accessible context for frame
{
- ::rtl::Reference< SwAccessibleContext > xAccImpl;
- ::rtl::Reference< SwAccessibleContext > xParentAccImpl;
- ::rtl::Reference< ::accessibility::AccessibleShape > xShapeAccImpl;
- // get accessible context for frame
- {
- osl::MutexGuard aGuard( maMutex );
+ osl::MutexGuard aGuard( maMutex );
- // First of all look for an accessible context for a frame
- if( aFrameOrObj.GetSwFrame() && mpFrameMap )
+ // First of all look for an accessible context for a frame
+ if( aFrameOrObj.GetSwFrame() && mpFrameMap )
+ {
+ SwAccessibleContextMap_Impl::iterator aIter =
+ mpFrameMap->find( aFrameOrObj.GetSwFrame() );
+ if( aIter != mpFrameMap->end() )
{
- SwAccessibleContextMap_Impl::iterator aIter =
- mpFrameMap->find( aFrameOrObj.GetSwFrame() );
- if( aIter != mpFrameMap->end() )
- {
- uno::Reference < XAccessible > xAcc( (*aIter).second );
- xAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() );
- }
+ uno::Reference < XAccessible > xAcc( (*aIter).second );
+ xAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() );
}
- if( !xAccImpl.is() && mpFrameMap )
- {
- // If there is none, look if the parent is accessible.
- const SwFrame *pParent =
- SwAccessibleFrame::GetParent( aFrameOrObj,
- GetShell()->IsPreview());
+ }
+ if( !xAccImpl.is() && mpFrameMap )
+ {
+ // If there is none, look if the parent is accessible.
+ const SwFrame *pParent =
+ SwAccessibleFrame::GetParent( aFrameOrObj,
+ GetShell()->IsPreview());
- if( pParent )
- {
- SwAccessibleContextMap_Impl::iterator aIter =
- mpFrameMap->find( pParent );
- if( aIter != mpFrameMap->end() )
- {
- uno::Reference < XAccessible > xAcc( (*aIter).second );
- xParentAccImpl =
- static_cast< SwAccessibleContext *>( xAcc.get() );
- }
- }
- }
- if( !xParentAccImpl.is() && !aFrameOrObj.GetSwFrame() && mpShapeMap )
+ if( pParent )
{
- SwAccessibleShapeMap_Impl::iterator aIter =
- mpShapeMap->find( aFrameOrObj.GetDrawObject() );
- if( aIter != mpShapeMap->end() )
+ SwAccessibleContextMap_Impl::iterator aIter =
+ mpFrameMap->find( pParent );
+ if( aIter != mpFrameMap->end() )
{
uno::Reference < XAccessible > xAcc( (*aIter).second );
- xShapeAccImpl =
- static_cast< ::accessibility::AccessibleShape *>( xAcc.get() );
+ xParentAccImpl =
+ static_cast< SwAccessibleContext *>( xAcc.get() );
}
}
- if( pObj && GetShell()->ActionPend() &&
- (xParentAccImpl.is() || xShapeAccImpl.is()) )
+ }
+ if( !xParentAccImpl.is() && !aFrameOrObj.GetSwFrame() && mpShapeMap )
+ {
+ SwAccessibleShapeMap_Impl::iterator aIter =
+ mpShapeMap->find( aFrameOrObj.GetDrawObject() );
+ if( aIter != mpShapeMap->end() )
{
- // Keep a reference to the XShape to avoid that it
- // is deleted with a SwFrameFormat::Modify.
- uno::Reference < drawing::XShape > xShape(
- const_cast< SdrObject * >( pObj )->getUnoShape(),
- uno::UNO_QUERY );
- if( xShape.is() )
- {
- mvShapes.push_back( xShape );
- }
+ uno::Reference < XAccessible > xAcc( (*aIter).second );
+ xShapeAccImpl =
+ static_cast< ::accessibility::AccessibleShape *>( xAcc.get() );
}
}
-
- // remove events stored for the frame
+ if( pObj && GetShell()->ActionPend() &&
+ (xParentAccImpl.is() || xShapeAccImpl.is()) )
{
- osl::MutexGuard aGuard( maEventMutex );
- if( mpEvents )
+ // Keep a reference to the XShape to avoid that it
+ // is deleted with a SwFrameFormat::Modify.
+ uno::Reference < drawing::XShape > xShape(
+ const_cast< SdrObject * >( pObj )->getUnoShape(),
+ uno::UNO_QUERY );
+ if( xShape.is() )
{
- SwAccessibleEventMap_Impl::iterator aIter =
- mpEventMap->find( aFrameOrObj );
- if( aIter != mpEventMap->end() )
- {
- SwAccessibleEvent_Impl aEvent(
- SwAccessibleEvent_Impl::DISPOSE, aFrameOrObj );
- AppendEvent( aEvent );
- }
+ mvShapes.push_back( xShape );
}
}
+ }
- // If the frame is accessible and there is a context for it, dispose
- // the frame. If the frame is no context for it but disposing should
- // take place recursive, the frame's children have to be disposed
- // anyway, so we have to create the context then.
- if( xAccImpl.is() )
+ // remove events stored for the frame
+ {
+ osl::MutexGuard aGuard( maEventMutex );
+ if( mpEvents )
{
- xAccImpl->Dispose( bRecursive );
+ SwAccessibleEventMap_Impl::iterator aIter =
+ mpEventMap->find( aFrameOrObj );
+ if( aIter != mpEventMap->end() )
+ {
+ SwAccessibleEvent_Impl aEvent(
+ SwAccessibleEvent_Impl::DISPOSE, aFrameOrObj );
+ AppendEvent( aEvent );
+ }
}
- else if( xParentAccImpl.is() )
- {
- // If the frame is a cell frame, the table must be notified.
- // If we are in an action, a table model change event will
- // be broadcasted at the end of the action to give the table
- // a chance to generate a single table change event.
+ }
- xParentAccImpl->DisposeChild( aFrameOrObj, bRecursive, bCanSkipInvisible );
- }
- else if( xShapeAccImpl.is() )
- {
- RemoveContext( aFrameOrObj.GetDrawObject() );
- xShapeAccImpl->dispose();
- }
+ // If the frame is accessible and there is a context for it, dispose
+ // the frame. If the frame is no context for it but disposing should
+ // take place recursive, the frame's children have to be disposed
+ // anyway, so we have to create the context then.
+ if( xAccImpl.is() )
+ {
+ xAccImpl->Dispose( bRecursive );
+ }
+ else if( xParentAccImpl.is() )
+ {
+ // If the frame is a cell frame, the table must be notified.
+ // If we are in an action, a table model change event will
+ // be broadcasted at the end of the action to give the table
+ // a chance to generate a single table change event.
- if( mpPreview && pFrame && pFrame->IsPageFrame() )
- mpPreview->DisposePage( static_cast< const SwPageFrame *>( pFrame ) );
+ xParentAccImpl->DisposeChild( aFrameOrObj, bRecursive, bCanSkipInvisible );
}
+ else if( xShapeAccImpl.is() )
+ {
+ RemoveContext( aFrameOrObj.GetDrawObject() );
+ xShapeAccImpl->dispose();
+ }
+
+ if( mpPreview && pFrame && pFrame->IsPageFrame() )
+ mpPreview->DisposePage( static_cast< const SwPageFrame *>( pFrame ) );
}
void SwAccessibleMap::InvalidatePosOrSize( const SwFrame *pFrame,
@@ -2353,95 +2353,96 @@ void SwAccessibleMap::InvalidatePosOrSize( const SwFrame *pFrame,
const SwRect& rOldBox )
{
SwAccessibleChild aFrameOrObj( pFrame, pObj, pWindow );
- if( aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
+ if( !aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
+ return;
+
+ ::rtl::Reference< SwAccessibleContext > xAccImpl;
+ ::rtl::Reference< SwAccessibleContext > xParentAccImpl;
+ const SwFrame *pParent =nullptr;
{
- ::rtl::Reference< SwAccessibleContext > xAccImpl;
- ::rtl::Reference< SwAccessibleContext > xParentAccImpl;
- const SwFrame *pParent =nullptr;
- {
- osl::MutexGuard aGuard( maMutex );
+ osl::MutexGuard aGuard( maMutex );
- if( mpFrameMap )
+ if( mpFrameMap )
+ {
+ if( aFrameOrObj.GetSwFrame() )
{
- if( aFrameOrObj.GetSwFrame() )
+ SwAccessibleContextMap_Impl::iterator aIter =
+ mpFrameMap->find( aFrameOrObj.GetSwFrame() );
+ if( aIter != mpFrameMap->end() )
+ {
+ // If there is an accessible object already it is
+ // notified directly.
+ uno::Reference < XAccessible > xAcc( (*aIter).second );
+ xAccImpl =
+ static_cast< SwAccessibleContext *>( xAcc.get() );
+ }
+ }
+ if( !xAccImpl.is() )
+ {
+ // Otherwise we look if the parent is accessible.
+ // If not, there is nothing to do.
+ pParent =
+ SwAccessibleFrame::GetParent( aFrameOrObj,
+ GetShell()->IsPreview());
+
+ if( pParent )
{
SwAccessibleContextMap_Impl::iterator aIter =
- mpFrameMap->find( aFrameOrObj.GetSwFrame() );
+ mpFrameMap->find( pParent );
if( aIter != mpFrameMap->end() )
{
- // If there is an accessible object already it is
- // notified directly.
uno::Reference < XAccessible > xAcc( (*aIter).second );
- xAccImpl =
+ xParentAccImpl =
static_cast< SwAccessibleContext *>( xAcc.get() );
}
}
- if( !xAccImpl.is() )
- {
- // Otherwise we look if the parent is accessible.
- // If not, there is nothing to do.
- pParent =
- SwAccessibleFrame::GetParent( aFrameOrObj,
- GetShell()->IsPreview());
-
- if( pParent )
- {
- SwAccessibleContextMap_Impl::iterator aIter =
- mpFrameMap->find( pParent );
- if( aIter != mpFrameMap->end() )
- {
- uno::Reference < XAccessible > xAcc( (*aIter).second );
- xParentAccImpl =
- static_cast< SwAccessibleContext *>( xAcc.get() );
- }
- }
- }
}
}
+ }
- if( xAccImpl.is() )
+ if( xAccImpl.is() )
+ {
+ if( GetShell()->ActionPend() )
{
- if( GetShell()->ActionPend() )
- {
- SwAccessibleEvent_Impl aEvent(
- SwAccessibleEvent_Impl::POS_CHANGED, xAccImpl.get(),
- aFrameOrObj, rOldBox );
- AppendEvent( aEvent );
- }
- else
- {
- FireEvents();
- if (xAccImpl->GetFrame()) // not if disposed by FireEvents()
- {
- xAccImpl->InvalidatePosOrSize(rOldBox);
- }
- }
+ SwAccessibleEvent_Impl aEvent(
+ SwAccessibleEvent_Impl::POS_CHANGED, xAccImpl.get(),
+ aFrameOrObj, rOldBox );
+ AppendEvent( aEvent );
}
- else if( xParentAccImpl.is() )
+ else
{
- if( GetShell()->ActionPend() )
+ FireEvents();
+ if (xAccImpl->GetFrame()) // not if disposed by FireEvents()
{
- assert(pParent);
- // tdf#99722 faster not to buffer events that won't be sent
- if (!SwAccessibleChild(pParent).IsVisibleChildrenOnly()
- || xParentAccImpl->IsShowing(rOldBox)
- || xParentAccImpl->IsShowing(*this, aFrameOrObj))
- {
- SwAccessibleEvent_Impl aEvent(
- SwAccessibleEvent_Impl::CHILD_POS_CHANGED,
- xParentAccImpl.get(), aFrameOrObj, rOldBox );
- AppendEvent( aEvent );
- }
+ xAccImpl->InvalidatePosOrSize(rOldBox);
}
- else
+ }
+ }
+ else if( xParentAccImpl.is() )
+ {
+ if( GetShell()->ActionPend() )
+ {
+ assert(pParent);
+ // tdf#99722 faster not to buffer events that won't be sent
+ if (!SwAccessibleChild(pParent).IsVisibleChildrenOnly()
+ || xParentAccImpl->IsShowing(rOldBox)
+ || xParentAccImpl->IsShowing(*this, aFrameOrObj))
{
- FireEvents();
- xParentAccImpl->InvalidateChildPosOrSize( aFrameOrObj,
- rOldBox );
+ SwAccessibleEvent_Impl aEvent(
+ SwAccessibleEvent_Impl::CHILD_POS_CHANGED,
+ xParentAccImpl.get(), aFrameOrObj, rOldBox );
+ AppendEvent( aEvent );
}
}
- else if(pParent)
+ else
{
+ FireEvents();
+ xParentAccImpl->InvalidateChildPosOrSize( aFrameOrObj,
+ rOldBox );
+ }
+ }
+ else if(pParent)
+ {
/*
For child graphic and its parent paragraph,if split 2 graphic to 2 paragraph,
will delete one graphic swfrm and new create 1 graphic swfrm ,
@@ -2450,114 +2451,113 @@ but when add graphic SwFrame ,the accessible of the new Paragraph is not created
so the new graphic accessible 'parent is NULL,
so run here: save the parent's SwFrame not the accessible object parent,
*/
- bool bIsValidFrame = false;
- bool bIsTextParent = false;
- if (aFrameOrObj.GetSwFrame())
- {
- if (SwFrameType::Fly == pFrame->GetType())
- {
- bIsValidFrame =true;
- }
- }
- else if(pObj)
- {
- if (SwFrameType::Txt == pParent->GetType())
- {
- bIsTextParent =true;
- }
- }
- if( bIsValidFrame || bIsTextParent )
+ bool bIsValidFrame = false;
+ bool bIsTextParent = false;
+ if (aFrameOrObj.GetSwFrame())
+ {
+ if (SwFrameType::Fly == pFrame->GetType())
{
- if( GetShell()->ActionPend() )
- {
- SwAccessibleEvent_Impl aEvent(
- SwAccessibleEvent_Impl::CHILD_POS_CHANGED,
- pParent, aFrameOrObj, rOldBox );
- AppendEvent( aEvent );
- }
- else
- {
- OSL_ENSURE(false,"");
- }
+ bIsValidFrame =true;
}
}
- }
-}
-
-void SwAccessibleMap::InvalidateContent( const SwFrame *pFrame )
-{
- SwAccessibleChild aFrameOrObj( pFrame );
- if( aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
- {
- uno::Reference < XAccessible > xAcc;
+ else if(pObj)
{
- osl::MutexGuard aGuard( maMutex );
-
- if( mpFrameMap )
+ if (SwFrameType::Txt == pParent->GetType())
{
- SwAccessibleContextMap_Impl::iterator aIter =
- mpFrameMap->find( aFrameOrObj.GetSwFrame() );
- if( aIter != mpFrameMap->end() )
- xAcc = (*aIter).second;
+ bIsTextParent =true;
}
}
-
- if( xAcc.is() )
+ if( bIsValidFrame || bIsTextParent )
{
- SwAccessibleContext *pAccImpl =
- static_cast< SwAccessibleContext *>( xAcc.get() );
if( GetShell()->ActionPend() )
{
SwAccessibleEvent_Impl aEvent(
- SwAccessibleEvent_Impl::INVALID_CONTENT, pAccImpl,
- aFrameOrObj );
+ SwAccessibleEvent_Impl::CHILD_POS_CHANGED,
+ pParent, aFrameOrObj, rOldBox );
AppendEvent( aEvent );
}
else
{
- FireEvents();
- pAccImpl->InvalidateContent();
+ OSL_ENSURE(false,"");
}
}
}
}
-void SwAccessibleMap::InvalidateAttr( const SwTextFrame& rTextFrame )
+void SwAccessibleMap::InvalidateContent( const SwFrame *pFrame )
{
- SwAccessibleChild aFrameOrObj( &rTextFrame );
- if( aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
+ SwAccessibleChild aFrameOrObj( pFrame );
+ if( !aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
+ return;
+
+ uno::Reference < XAccessible > xAcc;
{
- uno::Reference < XAccessible > xAcc;
- {
- osl::MutexGuard aGuard( maMutex );
+ osl::MutexGuard aGuard( maMutex );
- if( mpFrameMap )
- {
- SwAccessibleContextMap_Impl::iterator aIter =
- mpFrameMap->find( aFrameOrObj.GetSwFrame() );
- if( aIter != mpFrameMap->end() )
- xAcc = (*aIter).second;
- }
+ if( mpFrameMap )
+ {
+ SwAccessibleContextMap_Impl::iterator aIter =
+ mpFrameMap->find( aFrameOrObj.GetSwFrame() );
+ if( aIter != mpFrameMap->end() )
+ xAcc = (*aIter).second;
}
+ }
- if( xAcc.is() )
+ if( !xAcc.is() )
+ return;
+
+ SwAccessibleContext *pAccImpl =
+ static_cast< SwAccessibleContext *>( xAcc.get() );
+ if( GetShell()->ActionPend() )
+ {
+ SwAccessibleEvent_Impl aEvent(
+ SwAccessibleEvent_Impl::INVALID_CONTENT, pAccImpl,
+ aFrameOrObj );
+ AppendEvent( aEvent );
+ }
+ else
+ {
+ FireEvents();
+ pAccImpl->InvalidateContent();
+ }
+}
+
+void SwAccessibleMap::InvalidateAttr( const SwTextFrame& rTextFrame )
+{
+ SwAccessibleChild aFrameOrObj( &rTextFrame );
+ if( !aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
+ return;
+
+ uno::Reference < XAccessible > xAcc;
+ {
+ osl::MutexGuard aGuard( maMutex );
+
+ if( mpFrameMap )
{
- SwAccessibleContext *pAccImpl =
- static_cast< SwAccessibleContext *>( xAcc.get() );
- if( GetShell()->ActionPend() )
- {
- SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::INVALID_ATTR,
- pAccImpl, aFrameOrObj );
- aEvent.SetStates( AccessibleStates::TEXT_ATTRIBUTE_CHANGED );
- AppendEvent( aEvent );
- }
- else
- {
- FireEvents();
- pAccImpl->InvalidateAttr();
- }
+ SwAccessibleContextMap_Impl::iterator aIter =
+ mpFrameMap->find( aFrameOrObj.GetSwFrame() );
+ if( aIter != mpFrameMap->end() )
+ xAcc = (*aIter).second;
}
}
+
+ if( !xAcc.is() )
+ return;
+
+ SwAccessibleContext *pAccImpl =
+ static_cast< SwAccessibleContext *>( xAcc.get() );
+ if( GetShell()->ActionPend() )
+ {
+ SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::INVALID_ATTR,
+ pAccImpl, aFrameOrObj );
+ aEvent.SetStates( AccessibleStates::TEXT_ATTRIBUTE_CHANGED );
+ AppendEvent( aEvent );
+ }
+ else
+ {
+ FireEvents();
+ pAccImpl->InvalidateAttr();
+ }
}
void SwAccessibleMap::InvalidateCursorPosition( const SwFrame *pFrame )
@@ -2843,46 +2843,46 @@ void SwAccessibleMap::InvalidateRelationSet_( const SwFrame* pFrame,
{
// first, see if this frame is accessible, and if so, get the respective
SwAccessibleChild aFrameOrObj( pFrame );
- if( aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
- {
- uno::Reference < XAccessible > xAcc;
- {
- osl::MutexGuard aGuard( maMutex );
+ if( !aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
+ return;
- if( mpFrameMap )
- {
- SwAccessibleContextMap_Impl::iterator aIter =
- mpFrameMap->find( aFrameOrObj.GetSwFrame() );
- if( aIter != mpFrameMap->end() )
- {
- xAcc = (*aIter).second;
- }
- }
- }
+ uno::Reference < XAccessible > xAcc;
+ {
+ osl::MutexGuard aGuard( maMutex );
- // deliver event directly, or queue event
- if( xAcc.is() )
+ if( mpFrameMap )
{
- SwAccessibleContext *pAccImpl =
- static_cast< SwAccessibleContext *>( xAcc.get() );
- if( GetShell()->ActionPend() )
- {
- SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES,
- pAccImpl, SwAccessibleChild(pFrame),
- ( bFrom
- ? AccessibleStates::RELATION_FROM
- : AccessibleStates::RELATION_TO ) );
- AppendEvent( aEvent );
- }
- else
+ SwAccessibleContextMap_Impl::iterator aIter =
+ mpFrameMap->find( aFrameOrObj.GetSwFrame() );
+ if( aIter != mpFrameMap->end() )
{
- FireEvents();
- pAccImpl->InvalidateRelation( bFrom
- ? AccessibleEventId::CONTENT_FLOWS_FROM_RELATION_CHANGED
- : AccessibleEventId::CONTENT_FLOWS_TO_RELATION_CHANGED );
+ xAcc = (*aIter).second;
}
}
}
+
+ // deliver event directly, or queue event
+ if( !xAcc.is() )
+ return;
+
+ SwAccessibleContext *pAccImpl =
+ static_cast< SwAccessibleContext *>( xAcc.get() );
+ if( GetShell()->ActionPend() )
+ {
+ SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES,
+ pAccImpl, SwAccessibleChild(pFrame),
+ ( bFrom
+ ? AccessibleStates::RELATION_FROM
+ : AccessibleStates::RELATION_TO ) );
+ AppendEvent( aEvent );
+ }
+ else
+ {
+ FireEvents();
+ pAccImpl->InvalidateRelation( bFrom
+ ? AccessibleEventId::CONTENT_FLOWS_FROM_RELATION_CHANGED
+ : AccessibleEventId::CONTENT_FLOWS_TO_RELATION_CHANGED );
+ }
}
void SwAccessibleMap::InvalidateRelationSet( const SwFrame* pMaster,
@@ -2904,44 +2904,44 @@ void SwAccessibleMap::InvalidateParaTextSelection( const SwTextFrame& _rTextFram
{
// first, see if this frame is accessible, and if so, get the respective
SwAccessibleChild aFrameOrObj( &_rTextFrame );
- if( aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
- {
- uno::Reference < XAccessible > xAcc;
- {
- osl::MutexGuard aGuard( maMutex );
+ if( !aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
+ return;
- if( mpFrameMap )
- {
- SwAccessibleContextMap_Impl::iterator aIter =
- mpFrameMap->find( aFrameOrObj.GetSwFrame() );
- if( aIter != mpFrameMap->end() )
- {
- xAcc = (*aIter).second;
- }
- }
- }
+ uno::Reference < XAccessible > xAcc;
+ {
+ osl::MutexGuard aGuard( maMutex );
- // deliver event directly, or queue event
- if( xAcc.is() )
+ if( mpFrameMap )
{
- SwAccessibleContext *pAccImpl =
- static_cast< SwAccessibleContext *>( xAcc.get() );
- if( GetShell()->ActionPend() )
- {
- SwAccessibleEvent_Impl aEvent(
- SwAccessibleEvent_Impl::CARET_OR_STATES,
- pAccImpl,
- SwAccessibleChild( &_rTextFrame ),
- AccessibleStates::TEXT_SELECTION_CHANGED );
- AppendEvent( aEvent );
- }
- else
+ SwAccessibleContextMap_Impl::iterator aIter =
+ mpFrameMap->find( aFrameOrObj.GetSwFrame() );
+ if( aIter != mpFrameMap->end() )
{
- FireEvents();
- pAccImpl->InvalidateTextSelection();
+ xAcc = (*aIter).second;
}
}
}
+
+ // deliver event directly, or queue event
+ if( !xAcc.is() )
+ return;
+
+ SwAccessibleContext *pAccImpl =
+ static_cast< SwAccessibleContext *>( xAcc.get() );
+ if( GetShell()->ActionPend() )
+ {
+ SwAccessibleEvent_Impl aEvent(
+ SwAccessibleEvent_Impl::CARET_OR_STATES,
+ pAccImpl,
+ SwAccessibleChild( &_rTextFrame ),
+ AccessibleStates::TEXT_SELECTION_CHANGED );
+ AppendEvent( aEvent );
+ }
+ else
+ {
+ FireEvents();
+ pAccImpl->InvalidateTextSelection();
+ }
}
sal_Int32 SwAccessibleMap::GetChildIndex( const SwFrame& rParentFrame,
@@ -3484,26 +3484,26 @@ void SwAccessibleMap::InvalidateTextSelectionOfAllParas()
// second, handle previous selections - after the first step the data
// structure of the previously known only contains the 'old' selections
- if ( pPrevSelectedParas )
+ if ( !pPrevSelectedParas )
+ return;
+
+ SwAccessibleSelectedParas_Impl::iterator aIter = pPrevSelectedParas->begin();
+ for ( ; aIter != pPrevSelectedParas->end(); ++aIter )
{
- SwAccessibleSelectedParas_Impl::iterator aIter = pPrevSelectedParas->begin();
- for ( ; aIter != pPrevSelectedParas->end(); ++aIter )
+ uno::Reference < XAccessible > xAcc( (*aIter).first );
+ if ( xAcc.is() )
{
- uno::Reference < XAccessible > xAcc( (*aIter).first );
- if ( xAcc.is() )
+ ::rtl::Reference < SwAccessibleContext > xAccImpl(
+ static_cast<SwAccessibleContext*>( xAcc.get() ) );
+ if ( xAccImpl.is() && xAccImpl->GetFrame() )
{
- ::rtl::Reference < SwAccessibleContext > xAccImpl(
- static_cast<SwAccessibleContext*>( xAcc.get() ) );
- if ( xAccImpl.is() && xAccImpl->GetFrame() )
+ const SwTextFrame* pTextFrame(
+ dynamic_cast<const SwTextFrame*>(xAccImpl->GetFrame()) );
+ OSL_ENSURE( pTextFrame,
+ "<SwAccessibleMap::_SubmitTextSelectionChangedEvents()> - unexpected type of frame" );
+ if ( pTextFrame )
{
- const SwTextFrame* pTextFrame(
- dynamic_cast<const SwTextFrame*>(xAccImpl->GetFrame()) );
- OSL_ENSURE( pTextFrame,
- "<SwAccessibleMap::_SubmitTextSelectionChangedEvents()> - unexpected type of frame" );
- if ( pTextFrame )
- {
- InvalidateParaTextSelection( *pTextFrame );
- }
+ InvalidateParaTextSelection( *pTextFrame );
}
}
}
diff --git a/sw/source/core/access/accpage.cxx b/sw/source/core/access/accpage.cxx
index 39cf02b4b88f..e8ea905d7368 100644
--- a/sw/source/core/access/accpage.cxx
+++ b/sw/source/core/access/accpage.cxx
@@ -90,19 +90,19 @@ void SwAccessiblePage::InvalidateCursorPos_()
void SwAccessiblePage::InvalidateFocus_()
{
vcl::Window *pWin = GetWindow();
- if( pWin )
- {
- bool bSelected;
+ if( !pWin )
+ return;
- {
- osl::MutexGuard aGuard( m_Mutex );
- bSelected = m_bIsSelected;
- }
- OSL_ENSURE( bSelected, "focus object should be selected" );
+ bool bSelected;
- FireStateChangedEvent( AccessibleStateType::FOCUSED,
- pWin->HasFocus() && bSelected );
+ {
+ osl::MutexGuard aGuard( m_Mutex );
+ bSelected = m_bIsSelected;
}
+ OSL_ENSURE( bSelected, "focus object should be selected" );
+
+ FireStateChangedEvent( AccessibleStateType::FOCUSED,
+ pWin->HasFocus() && bSelected );
}
SwAccessiblePage::SwAccessiblePage(std::shared_ptr<SwAccessibleMap> const& pInitMap,
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 4119275a75bc..b39f4c9439ef 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -303,27 +303,27 @@ void SwAccessibleParagraph::InvalidateContent_( bool bVisibleDataFired )
FireAccessibleEvent( aEvent );
}
- if( rText != sOldText )
+ if( rText == sOldText )
+ return;
+
+ OUString sNewDesc( GetDescription() );
+ OUString sOldDesc;
{
- OUString sNewDesc( GetDescription() );
- OUString sOldDesc;
- {
- osl::MutexGuard aGuard( m_Mutex );
- sOldDesc = m_sDesc;
- if( m_sDesc != sNewDesc )
- m_sDesc = sNewDesc;
- }
+ osl::MutexGuard aGuard( m_Mutex );
+ sOldDesc = m_sDesc;
+ if( m_sDesc != sNewDesc )
+ m_sDesc = sNewDesc;
+ }
- if( sNewDesc != sOldDesc )
- {
- // The text is changed
- AccessibleEventObject aEvent;
- aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED;
- aEvent.OldValue <<= sOldDesc;
- aEvent.NewValue <<= sNewDesc;
+ if( sNewDesc != sOldDesc )
+ {
+ // The text is changed
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED;
+ aEvent.OldValue <<= sOldDesc;
+ aEvent.NewValue <<= sNewDesc;
- FireAccessibleEvent( aEvent );
- }
+ FireAccessibleEvent( aEvent );
}
}
diff --git a/sw/source/core/access/accselectionhelper.cxx b/sw/source/core/access/accselectionhelper.cxx
index be92d4a2c5aa..9bcec4e19cd5 100644
--- a/sw/source/core/access/accselectionhelper.cxx
+++ b/sw/source/core/access/accselectionhelper.cxx
@@ -175,21 +175,21 @@ void SwAccessibleSelectionHelper::selectAllAccessibleChildren( )
// the first we can select, and select it.
SwFEShell* pFEShell = GetFEShell();
- if( pFEShell )
- {
- std::list< SwAccessibleChild > aChildren;
- m_rContext.GetChildren( *(m_rContext.GetMap()), aChildren );
+ if( !pFEShell )
+ return;
- for( const SwAccessibleChild& rChild : aChildren )
+ std::list< SwAccessibleChild > aChildren;
+ m_rContext.GetChildren( *(m_rContext.GetMap()), aChildren );
+
+ for( const SwAccessibleChild& rChild : aChildren )
+ {
+ const SdrObject* pObj = rChild.GetDrawObject();
+ const SwFrame* pFrame = rChild.GetSwFrame();
+ if( pObj && !(pFrame != nullptr && pFEShell->IsObjSelected()) )
{
- const SdrObject* pObj = rChild.GetDrawObject();
- const SwFrame* pFrame = rChild.GetSwFrame();
- if( pObj && !(pFrame != nullptr && pFEShell->IsObjSelected()) )
- {
- m_rContext.Select( const_cast< SdrObject *>( pObj ), nullptr==pFrame );
- if( pFrame )
- break;
- }
+ m_rContext.Select( const_cast< SdrObject *>( pObj ), nullptr==pFrame );
+ if( pFrame )
+ break;
}
}
}
More information about the Libreoffice-commits
mailing list