[Libreoffice-commits] core.git: sw/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Sun Jan 26 12:53:37 UTC 2020
sw/source/core/access/AccessibilityCheck.cxx | 24 ++++++++++++++++++++----
sw/source/core/access/AccessibilityIssue.cxx | 15 +++++++++++++++
sw/source/core/inc/AccessibilityIssue.hxx | 18 ++++++++++++++++++
3 files changed, 53 insertions(+), 4 deletions(-)
New commits:
commit e06760dbf2fd6a389aee2c8cf5eeb16f8a8044c2
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat Jan 25 22:10:32 2020 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sun Jan 26 13:53:01 2020 +0100
acc. check: implement goto for a range of text range in a para.
Change-Id: I847bc67f886b5dcfe8ec30d7c0bdd3aa61ba2d36
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87421
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index 2475fb3172fc..0d8c1eee4aab 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -45,6 +45,14 @@ lclAddIssue(sfx::AccessibilityIssueCollection& rIssueCollection, OUString const&
return pIssue;
}
+template <typename T> void removeDuplicates(std::vector<T>& aVector)
+{
+ std::unordered_set<T> aSet;
+ auto end = std::copy_if(aVector.begin(), aVector.end(), aVector.begin(),
+ [&aSet](T const& rElement) { return aSet.insert(rElement).second; });
+ aVector.erase(end, aVector.end());
+}
+
class BaseCheck
{
protected:
@@ -436,7 +444,7 @@ public:
{
}
- void checkAutoFormat(const SwTextAttr* pTextAttr)
+ void checkAutoFormat(SwTextNode* pTextNode, const SwTextAttr* pTextAttr)
{
const SwFormatAutoFormat& rAutoFormat = pTextAttr->GetAutoFormat();
SfxItemIter aItemIter(*rAutoFormat.GetStyleHandle());
@@ -510,8 +518,16 @@ public:
}
if (!aFormattings.empty())
{
- lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_FORMATTING_CONVEYS_MEANING),
- sfx::AccessibilityIssueID::TEXT_FORMATTING);
+ removeDuplicates(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
@@ -527,7 +543,7 @@ public:
const SwTextAttr* pTextAttr = rHints.Get(i);
if (pTextAttr->Which() == RES_TXTATR_AUTOFMT)
{
- checkAutoFormat(pTextAttr);
+ checkAutoFormat(pTextNode, pTextAttr);
}
}
}
diff --git a/sw/source/core/access/AccessibilityIssue.cxx b/sw/source/core/access/AccessibilityIssue.cxx
index a9eccf478a31..13b0a32a6b16 100644
--- a/sw/source/core/access/AccessibilityIssue.cxx
+++ b/sw/source/core/access/AccessibilityIssue.cxx
@@ -54,6 +54,21 @@ void AccessibilityIssue::gotoIssue() const
pWrtShell->GotoTable(m_sObjectID);
}
break;
+ case IssueObject::TEXT:
+ {
+ SwWrtShell* pWrtShell = m_pDoc->GetDocShell()->GetWrtShell();
+ SwContentNode* pContentNode = m_pNode->GetContentNode();
+ SwPosition aPoint(*pContentNode, m_nStart);
+ SwPosition aMark(*pContentNode, m_nEnd);
+ pWrtShell->EnterStdMode();
+ pWrtShell->StartAllAction();
+ SwPaM* pPaM = pWrtShell->GetCursor();
+ *pPaM->GetPoint() = aPoint;
+ pPaM->SetMark();
+ *pPaM->GetMark() = aMark;
+ pWrtShell->EndAllAction();
+ }
+ break;
default:
break;
}
diff --git a/sw/source/core/inc/AccessibilityIssue.hxx b/sw/source/core/inc/AccessibilityIssue.hxx
index 3d59c420708f..9d64a7e4e8e8 100644
--- a/sw/source/core/inc/AccessibilityIssue.hxx
+++ b/sw/source/core/inc/AccessibilityIssue.hxx
@@ -22,6 +22,7 @@ enum class IssueObject
GRAPHIC,
OLE,
TABLE,
+ TEXT,
};
class SW_DLLPUBLIC AccessibilityIssue final : public sfx::AccessibilityIssue
@@ -30,6 +31,11 @@ private:
IssueObject m_eIssueObject;
SwDoc* m_pDoc;
OUString m_sObjectID;
+ std::vector<OUString> m_aIssueAdditionalInfo;
+ SwNode* m_pNode;
+
+ sal_Int32 m_nStart;
+ sal_Int32 m_nEnd;
public:
AccessibilityIssue(sfx::AccessibilityIssueID eIssueID = sfx::AccessibilityIssueID::UNSPECIFIED);
@@ -37,6 +43,18 @@ public:
void setIssueObject(IssueObject eIssueObject);
void setDoc(SwDoc* pDoc);
void setObjectID(OUString const& rID);
+ void setNode(SwNode* pNode) { m_pNode = pNode; }
+
+ void setStart(sal_Int32 nStart) { m_nStart = nStart; }
+
+ void setEnd(sal_Int32 nEnd) { m_nEnd = nEnd; }
+
+ std::vector<OUString> const& getAdditionalInfo() const { return m_aIssueAdditionalInfo; }
+
+ void setAdditionalInfo(std::vector<OUString> const& rIssueAdditionalInfo)
+ {
+ m_aIssueAdditionalInfo = rIssueAdditionalInfo;
+ }
bool canGotoIssue() const override;
void gotoIssue() const override;
More information about the Libreoffice-commits
mailing list