tdf#43784 tdf#158114 sw accessibility: check missing linked graphic
Show missing linked graphics and their abbreviated paths, (and as tooltips, full paths) in the accessibility checker. Change-Id: Ia378f4ea3260251d1b2530fadc48aea6e0323a08 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159150 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
parent
e87937d1fa
commit
0156cba6e3
10 changed files with 146 additions and 17 deletions
|
@ -27,6 +27,7 @@ enum class AccessibilityIssueID
|
|||
DOCUMENT_LANGUAGE,
|
||||
DOCUMENT_BACKGROUND,
|
||||
STYLE_LANGUAGE,
|
||||
LINKED_GRAPHIC,
|
||||
NO_ALT_OLE,
|
||||
NO_ALT_GRAPHIC,
|
||||
NO_ALT_SHAPE,
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#define NC_(Context, String) TranslateId(Context, u8##String)
|
||||
|
||||
#define STR_NO_ALT NC_("STR_NO_ALT", "%OBJECT_NAME%")
|
||||
#define STR_LINKED_GRAPHIC NC_("STR_LINKED_GRAPHIC", "“%OBJECT_NAME%” referenced as “%LINK%”.")
|
||||
#define STR_TABLE_MERGE_SPLIT NC_("STR_TABLE_MERGE_SPLIT", "Table “%OBJECT_NAME%” contains merges or splits.")
|
||||
#define STR_FAKE_NUMBERING NC_("STR_FAKE_NUMBERING", "Simulated numbering “%NUMBERING%”.")
|
||||
#define STR_HYPERLINK_TEXT_IS_LINK NC_("STR_HYPERLINK_TEXT_IS_LINK", "Hyperlink text is the same as the link address “%LINK%”.")
|
||||
|
|
|
@ -84,6 +84,18 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckBackgroundImage)
|
|||
CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DOCUMENT_BACKGROUND, aIssues[0]->m_eIssueID);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckLinkedImage)
|
||||
{
|
||||
createSwDoc("LinkedImageTest.fodt");
|
||||
SwDoc* pDoc = getSwDoc();
|
||||
CPPUNIT_ASSERT(pDoc);
|
||||
sw::AccessibilityCheck aCheck(pDoc);
|
||||
aCheck.check();
|
||||
auto& aIssues = aCheck.getIssueCollection().getIssues();
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(4), aIssues.size());
|
||||
CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::LINKED_GRAPHIC, aIssues[1]->m_eIssueID);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckNewlineSpace)
|
||||
{
|
||||
createSwDoc("NewlineTest.odt");
|
||||
|
|
18
sw/qa/core/accessibilitycheck/data/LinkedImageTest.fodt
Normal file
18
sw/qa/core/accessibilitycheck/data/LinkedImageTest.fodt
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
|
||||
<office:body>
|
||||
<office:text>
|
||||
<text:h text:style-name="P3" text:outline-level="1">Linked graphic</text:h>
|
||||
<text:p text:style-name="P1"><draw:frame draw:style-name="fr1" draw:name="Image2" text:anchor-type="as-char" svg:width="92.3pt" svg:height="92.3pt" draw:z-index="0"><draw:image xlink:href="x2.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
|
||||
</draw:frame></text:p>
|
||||
<text:h text:style-name="P3" text:outline-level="1">Embedded graphic</text:h>
|
||||
<text:p text:style-name="P2"><draw:frame draw:style-name="fr1" draw:name="Image1" text:anchor-type="as-char" svg:width="89.89pt" svg:height="89.89pt" draw:z-index="0"><draw:image draw:mime-type="image/gif">
|
||||
<office:binary-data>R0lGODlhAgACAPABAAAAAP///yH5BAAAAAAAIf4tIFRoaXMgaXMgYW4gZXhhbXBsZSBiaXRt
|
||||
YXAgb2YgdGhlIGxldHRlciAiSiIKACH/C0ltYWdlTWFnaWNrDmdhbW1hPTAuNDU0NTQ1ACwA
|
||||
AAAAAgACAAACA0QCBQA7
|
||||
</office:binary-data>
|
||||
</draw:image>
|
||||
</draw:frame></text:p>
|
||||
</office:text>
|
||||
</office:body>
|
||||
</office:document>
|
|
@ -44,6 +44,9 @@
|
|||
#include <unotext.hxx>
|
||||
#include <svx/svdoashp.hxx>
|
||||
#include <svx/sdasitm.hxx>
|
||||
#include <ndgrf.hxx>
|
||||
#include <svl/fstathelper.hxx>
|
||||
#include <osl/file.h>
|
||||
|
||||
namespace sw
|
||||
{
|
||||
|
@ -98,13 +101,46 @@ class NoTextNodeAltTextCheck : public NodeCheck
|
|||
if (!pNoTextNode)
|
||||
return;
|
||||
|
||||
if (!pNoTextNode->GetTitle().isEmpty() || !pNoTextNode->GetDescription().isEmpty())
|
||||
return;
|
||||
|
||||
const SwFrameFormat* pFrameFormat = pNoTextNode->GetFlyFormat();
|
||||
if (!pFrameFormat)
|
||||
return;
|
||||
|
||||
// linked graphic with broken link
|
||||
if (pNoTextNode->IsGrfNode() && pNoTextNode->GetGrfNode()->IsLinkedFile())
|
||||
{
|
||||
OUString sURL(pNoTextNode->GetGrfNode()->GetGraphic().getOriginURL());
|
||||
if (!FStatHelper::IsDocument(sURL))
|
||||
{
|
||||
INetURLObject aURL(sURL);
|
||||
OUString aSystemPath = sURL;
|
||||
|
||||
// abbreviate URL
|
||||
if (aURL.GetProtocol() == INetProtocol::File)
|
||||
{
|
||||
OUString aAbbreviatedPath;
|
||||
aSystemPath = aURL.getFSysPath(FSysStyle::Detect);
|
||||
osl_abbreviateSystemPath(aSystemPath.pData, &aAbbreviatedPath.pData, 46,
|
||||
nullptr);
|
||||
sURL = aAbbreviatedPath;
|
||||
}
|
||||
|
||||
OUString sIssueText = SwResId(STR_LINKED_GRAPHIC)
|
||||
.replaceAll("%OBJECT_NAME%", pFrameFormat->GetName())
|
||||
.replaceFirst("%LINK%", sURL);
|
||||
|
||||
auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText,
|
||||
sfx::AccessibilityIssueID::LINKED_GRAPHIC);
|
||||
pIssue->setDoc(pNoTextNode->GetDoc());
|
||||
pIssue->setIssueObject(IssueObject::LINKED);
|
||||
pIssue->setObjectID(pNoTextNode->GetFlyFormat()->GetName());
|
||||
pIssue->setNode(pNoTextNode);
|
||||
pIssue->setAdditionalInfo({ aSystemPath });
|
||||
}
|
||||
}
|
||||
|
||||
if (!pNoTextNode->GetTitle().isEmpty() || !pNoTextNode->GetDescription().isEmpty())
|
||||
return;
|
||||
|
||||
OUString sIssueText
|
||||
= SwResId(STR_NO_ALT).replaceAll("%OBJECT_NAME%", pFrameFormat->GetName());
|
||||
|
||||
|
|
|
@ -78,6 +78,7 @@ void AccessibilityIssue::gotoIssue() const
|
|||
|
||||
switch (TempIssueObject.m_eIssueObject)
|
||||
{
|
||||
case IssueObject::LINKED:
|
||||
case IssueObject::GRAPHIC:
|
||||
case IssueObject::OLE:
|
||||
case IssueObject::TEXTFRAME:
|
||||
|
|
|
@ -31,6 +31,7 @@ enum class IssueObject
|
|||
LANGUAGE_NOT_SET,
|
||||
FOOTENDNOTE,
|
||||
TEXTFRAME,
|
||||
LINKED,
|
||||
};
|
||||
|
||||
class SW_DLLPUBLIC AccessibilityIssue final : public sfx::AccessibilityIssue
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <sal/config.h>
|
||||
|
||||
#include <AccessibilityCheck.hxx>
|
||||
#include <AccessibilityIssue.hxx>
|
||||
#include <cmdid.h>
|
||||
#include <doc.hxx>
|
||||
#include <docsh.hxx>
|
||||
|
@ -44,17 +45,25 @@ AccessibilityCheckEntry::AccessibilityCheckEntry(
|
|||
{
|
||||
m_xGotoButton->set_label(m_pAccessibilityIssue->m_aIssueText);
|
||||
|
||||
// int nPrefWidth(m_xGotoButton->get_preferred_size().Width());
|
||||
// tdf#156137 allow LinkButton label to wrap
|
||||
int nMaxWidth = m_xGotoButton->get_approximate_digit_width() * 10;
|
||||
// if (nPrefWidth > nMaxWidth)
|
||||
{
|
||||
// tdf#156137 allow LinkButton label to wrap
|
||||
m_xGotoButton->set_label_wrap(true);
|
||||
m_xGotoButton->set_size_request(nMaxWidth, -1);
|
||||
}
|
||||
m_xGotoButton->set_label_wrap(true);
|
||||
m_xGotoButton->set_size_request(nMaxWidth, -1);
|
||||
|
||||
m_xGotoButton->connect_activate_link(
|
||||
LINK(this, AccessibilityCheckEntry, GotoButtonClicked));
|
||||
|
||||
// add full path of linked graphic as tooltip,
|
||||
if (m_pAccessibilityIssue->m_eIssueID == sfx::AccessibilityIssueID::LINKED_GRAPHIC)
|
||||
{
|
||||
auto pSwIssue = std::static_pointer_cast<sw::AccessibilityIssue>(m_pAccessibilityIssue);
|
||||
auto aInfo = pSwIssue->getAdditionalInfo();
|
||||
if (aInfo.size() > 0)
|
||||
{
|
||||
m_xGotoButton->set_tooltip_text(aInfo[0]);
|
||||
}
|
||||
}
|
||||
|
||||
m_xLabel->set_visible(false);
|
||||
}
|
||||
else
|
||||
|
@ -93,6 +102,7 @@ A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* p
|
|||
: PanelLayout(pParent, "A11yCheckIssuesPanel", "modules/swriter/ui/a11ycheckissuespanel.ui")
|
||||
, m_xExpanderDocument(m_xBuilder->weld_expander("expand_document"))
|
||||
, m_xExpanderStyles(m_xBuilder->weld_expander("expand_styles"))
|
||||
, m_xExpanderLinked(m_xBuilder->weld_expander("expand_linked"))
|
||||
, m_xExpanderNoAlt(m_xBuilder->weld_expander("expand_no_alt"))
|
||||
, m_xExpanderTable(m_xBuilder->weld_expander("expand_table"))
|
||||
, m_xExpanderFormatting(m_xBuilder->weld_expander("expand_formatting"))
|
||||
|
@ -102,6 +112,7 @@ A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* p
|
|||
, m_xExpanderOther(m_xBuilder->weld_expander("expand_other"))
|
||||
, m_xBoxDocument(m_xBuilder->weld_box("box_document"))
|
||||
, m_xBoxStyles(m_xBuilder->weld_box("box_styles"))
|
||||
, m_xBoxLinked(m_xBuilder->weld_box("box_linked"))
|
||||
, m_xBoxNoAlt(m_xBuilder->weld_box("box_no_alt"))
|
||||
, m_xBoxTable(m_xBuilder->weld_box("box_table"))
|
||||
, m_xBoxFormatting(m_xBuilder->weld_box("box_formatting"))
|
||||
|
@ -149,6 +160,7 @@ void A11yCheckIssuesPanel::ImplDestroy()
|
|||
}
|
||||
m_xExpanderDocument.reset();
|
||||
m_xExpanderStyles.reset();
|
||||
m_xExpanderLinked.reset();
|
||||
m_xExpanderNoAlt.reset();
|
||||
m_xExpanderTable.reset();
|
||||
m_xExpanderFormatting.reset();
|
||||
|
@ -158,6 +170,7 @@ void A11yCheckIssuesPanel::ImplDestroy()
|
|||
m_xExpanderOther.reset();
|
||||
m_xBoxDocument.reset();
|
||||
m_xBoxStyles.reset();
|
||||
m_xBoxLinked.reset();
|
||||
m_xBoxNoAlt.reset();
|
||||
m_xBoxTable.reset();
|
||||
m_xBoxFormatting.reset();
|
||||
|
@ -179,6 +192,10 @@ void A11yCheckIssuesPanel::removeOldWidgets()
|
|||
m_xBoxStyles->move(xEntry->get_widget(), nullptr);
|
||||
m_xExpanderStyles->set_visible(false);
|
||||
|
||||
for (auto const& xEntry : m_aLinkedEntries)
|
||||
m_xBoxLinked->move(xEntry->get_widget(), nullptr);
|
||||
m_xExpanderLinked->set_visible(false);
|
||||
|
||||
for (auto const& xEntry : m_aNoAltEntries)
|
||||
m_xBoxNoAlt->move(xEntry->get_widget(), nullptr);
|
||||
m_xExpanderNoAlt->set_visible(false);
|
||||
|
@ -220,6 +237,7 @@ void A11yCheckIssuesPanel::populateIssues()
|
|||
|
||||
sal_Int32 iDocument = 0;
|
||||
sal_Int32 iStyles = 0;
|
||||
sal_Int32 iLinked = 0;
|
||||
sal_Int32 iNoAlt = 0;
|
||||
sal_Int32 iTable = 0;
|
||||
sal_Int32 iFormatting = 0;
|
||||
|
@ -250,6 +268,14 @@ void A11yCheckIssuesPanel::populateIssues()
|
|||
m_aStylesEntries.push_back(std::move(xEntry));
|
||||
}
|
||||
break;
|
||||
case sfx::AccessibilityIssueID::LINKED_GRAPHIC:
|
||||
{
|
||||
auto xEntry = std::make_unique<AccessibilityCheckEntry>(m_xBoxLinked.get(), pIssue);
|
||||
m_xBoxLinked->reorder_child(xEntry->get_widget(), iLinked++);
|
||||
m_xExpanderLinked->set_visible(true);
|
||||
m_aLinkedEntries.push_back(std::move(xEntry));
|
||||
}
|
||||
break;
|
||||
case sfx::AccessibilityIssueID::NO_ALT_OLE:
|
||||
case sfx::AccessibilityIssueID::NO_ALT_GRAPHIC:
|
||||
case sfx::AccessibilityIssueID::NO_ALT_SHAPE:
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
private:
|
||||
std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aDocumentEntries;
|
||||
std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aStylesEntries;
|
||||
std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aLinkedEntries;
|
||||
std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aNoAltEntries;
|
||||
std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aTableEntries;
|
||||
std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aFormattingEntries;
|
||||
|
@ -71,6 +72,7 @@ private:
|
|||
std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aOtherEntries;
|
||||
std::unique_ptr<weld::Expander> m_xExpanderDocument;
|
||||
std::unique_ptr<weld::Expander> m_xExpanderStyles;
|
||||
std::unique_ptr<weld::Expander> m_xExpanderLinked;
|
||||
std::unique_ptr<weld::Expander> m_xExpanderNoAlt;
|
||||
std::unique_ptr<weld::Expander> m_xExpanderTable;
|
||||
std::unique_ptr<weld::Expander> m_xExpanderFormatting;
|
||||
|
@ -80,6 +82,7 @@ private:
|
|||
std::unique_ptr<weld::Expander> m_xExpanderOther;
|
||||
std::unique_ptr<weld::Box> m_xBoxDocument;
|
||||
std::unique_ptr<weld::Box> m_xBoxStyles;
|
||||
std::unique_ptr<weld::Box> m_xBoxLinked;
|
||||
std::unique_ptr<weld::Box> m_xBoxNoAlt;
|
||||
std::unique_ptr<weld::Box> m_xBoxTable;
|
||||
std::unique_ptr<weld::Box> m_xBoxFormatting;
|
||||
|
|
|
@ -77,6 +77,36 @@
|
|||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkExpander" id="expand_linked">
|
||||
<property name="can-focus">True</property>
|
||||
<property name="expanded">True</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box_linked">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">6</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="expand_linked_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="a11ycheckissuespanel|expand_linked_label">Missing linked graphic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkExpander" id="expand_no_alt">
|
||||
<property name="can-focus">True</property>
|
||||
|
@ -104,7 +134,7 @@
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -133,7 +163,7 @@
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -162,7 +192,7 @@
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -191,7 +221,7 @@
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">5</property>
|
||||
<property name="position">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -220,7 +250,7 @@
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">6</property>
|
||||
<property name="position">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -249,7 +279,7 @@
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">7</property>
|
||||
<property name="position">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -278,7 +308,7 @@
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">8</property>
|
||||
<property name="position">9</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
|
Loading…
Reference in a new issue