/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace sw::sidebar
{
AccessibilityCheckEntry::AccessibilityCheckEntry(
weld::Container* pParent, std::shared_ptr<sfx::AccessibilityIssue> const& rAccessibilityIssue)
: m_xBuilder(Application::CreateBuilder(pParent, u"svx/ui/accessibilitycheckentry.ui"_ustr, false, reinterpret_cast<sal_uInt64>(SfxViewShell::Current())))
, m_xContainer(m_xBuilder->weld_container(u"accessibilityCheckEntryBox"_ustr))
, m_xLabel(m_xBuilder->weld_label(u"accessibilityCheckEntryLabel"_ustr))
, m_xGotoButton(m_xBuilder->weld_link_button(u"accessibilityCheckEntryLinkButton"_ustr))
, m_xFixButton(m_xBuilder->weld_button(u"accessibilityCheckEntryFixButton"_ustr))
, m_pAccessibilityIssue(rAccessibilityIssue)
{ // lock in the height as including the button so all rows are the same height
m_xContainer->set_size_request(-1, m_xContainer->get_preferred_size().Height());
if (m_pAccessibilityIssue->canGotoIssue())
{
m_xGotoButton->set_label(m_pAccessibilityIssue->m_aIssueText);
// tdf#156137 allow LinkButton label to wrap int nMaxWidth = m_xGotoButton->get_approximate_digit_width() * 10;
m_xGotoButton->set_label_wrap(true);
m_xGotoButton->set_size_request(nMaxWidth, -1);
// 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]);
}
}
void AccessibilityCheckLevel::removeAllEntries()
{ for (auto eGroup : o3tl::enumrange<AccessibilityCheckGroups>())
{ auto nGroupIndex = size_t(eGroup); for (autoconst& xEntry : m_aEntries[nGroupIndex])
m_xBoxes[nGroupIndex]->move(xEntry->get_widget(), nullptr); // remove the entries from the vector if (!m_aEntries[nGroupIndex].empty())
m_aEntries[nGroupIndex].clear();
}
}
SwDocShell* pDocSh = dynamic_cast<SwDocShell*>(SfxObjectShell::Current()); if (!pDocSh) return;
// Automatic a11y checking must be enabled for this panel to work properly
mbAutomaticCheckEnabled
= officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get(); if (!mbAutomaticCheckEnabled)
{
std::shared_ptr<comphelper::ConfigurationChanges> batch(
comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::set(true, batch);
batch->commit();
pBindings->Invalidate(SID_ACCESSIBILITY_CHECK_ONLINE);
}
// If LOKit is enabled, then enable the update button and don't run the accessibility check. // In desktop don't show the update button and schedule to run the accessibility check async // If LOKit is enabled, hide the Options button and its label. if (comphelper::LibreOfficeKit::isActive())
{
m_xLevelExpanders[0]->hide();
m_xLevelExpanders[1]->hide();
mxUpdateBox->show();
m_xBuilder->weld_widget(u"gridOptions"_ustr)->hide();
} else
{
m_xLevelExpanders[0]->show();
m_xLevelExpanders[1]->show();
mxUpdateBox->hide();
Application::PostUserEvent(LINK(this, A11yCheckIssuesPanel, PopulateIssuesHdl));
}
}
void A11yCheckIssuesPanel::ImplDestroy()
{ // Restore state when this panel is no longer used if (!mbAutomaticCheckEnabled)
{
std::shared_ptr<comphelper::ConfigurationChanges> batch(
comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::set(false, batch);
batch->commit();
mpBindings->Invalidate(SID_ACCESSIBILITY_CHECK_ONLINE);
}
for (auto& aLevelEntry : m_aLevelEntries)
aLevelEntry.reset();
}
for (std::shared_ptr<sfx::AccessibilityIssue> const& pIssue : m_aIssueCollection.getIssues())
{ switch (pIssue->m_eIssueID)
{ case sfx::AccessibilityIssueID::DOCUMENT_TITLE: case sfx::AccessibilityIssueID::DOCUMENT_LANGUAGE: case sfx::AccessibilityIssueID::DOCUMENT_BACKGROUND:
{ if (!pIssue->getHidden())
addEntryForGroup(AccessibilityCheckGroups::Document, nIndices, pIssue);
} break; case sfx::AccessibilityIssueID::STYLE_LANGUAGE:
{ if (!pIssue->getHidden())
addEntryForGroup(AccessibilityCheckGroups::Styles, nIndices, pIssue);
} break; case sfx::AccessibilityIssueID::LINKED_GRAPHIC:
{ if (!pIssue->getHidden())
addEntryForGroup(AccessibilityCheckGroups::Linked, nIndices, pIssue);
} break; case sfx::AccessibilityIssueID::NO_ALT_OLE: case sfx::AccessibilityIssueID::NO_ALT_GRAPHIC: case sfx::AccessibilityIssueID::NO_ALT_SHAPE:
{ if (!pIssue->getHidden())
addEntryForGroup(AccessibilityCheckGroups::NoAlt, nIndices, pIssue);
} break; case sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT:
{ if (!pIssue->getHidden())
addEntryForGroup(AccessibilityCheckGroups::Table, nIndices, pIssue);
} break; case sfx::AccessibilityIssueID::TEXT_NEW_LINES: case sfx::AccessibilityIssueID::TEXT_SPACES: case sfx::AccessibilityIssueID::TEXT_TABS: case sfx::AccessibilityIssueID::TEXT_EMPTY_NUM_PARA: case sfx::AccessibilityIssueID::TABLE_FORMATTING:
{ if (!pIssue->getHidden())
addEntryForGroup(AccessibilityCheckGroups::Formatting, nIndices, pIssue);
} break; case sfx::AccessibilityIssueID::DIRECT_FORMATTING:
{ if (!pIssue->getHidden())
{
addEntryForGroup(AccessibilityCheckGroups::DirectFormatting, nIndices, pIssue);
nDirectFormats++;
}
} break; case sfx::AccessibilityIssueID::HYPERLINK_IS_TEXT: case sfx::AccessibilityIssueID::HYPERLINK_SHORT: case sfx::AccessibilityIssueID::HYPERLINK_NO_NAME:
{ if (!pIssue->getHidden())
addEntryForGroup(AccessibilityCheckGroups::Hyperlink, nIndices, pIssue);
} break; case sfx::AccessibilityIssueID::FAKE_FOOTNOTE: case sfx::AccessibilityIssueID::FAKE_CAPTION:
{ if (!pIssue->getHidden())
addEntryForGroup(AccessibilityCheckGroups::Fakes, nIndices, pIssue);
} break; case sfx::AccessibilityIssueID::MANUAL_NUMBERING:
{ if (!pIssue->getHidden())
addEntryForGroup(AccessibilityCheckGroups::Numbering, nIndices, pIssue);
} break;
case sfx::AccessibilityIssueID::TEXT_CONTRAST: case sfx::AccessibilityIssueID::TEXT_BLINKING: case sfx::AccessibilityIssueID::HEADINGS_NOT_IN_ORDER: case sfx::AccessibilityIssueID::NON_INTERACTIVE_FORMS: case sfx::AccessibilityIssueID::FLOATING_TEXT: case sfx::AccessibilityIssueID::HEADING_IN_TABLE: case sfx::AccessibilityIssueID::HEADING_START: case sfx::AccessibilityIssueID::HEADING_ORDER: case sfx::AccessibilityIssueID::CONTENT_CONTROL: case sfx::AccessibilityIssueID::AVOID_FOOTNOTES: case sfx::AccessibilityIssueID::AVOID_ENDNOTES: case sfx::AccessibilityIssueID::FONTWORKS: case sfx::AccessibilityIssueID::LINK_IN_HEADER_FOOTER:
{ if (!pIssue->getHidden())
addEntryForGroup(AccessibilityCheckGroups::Other, nIndices, pIssue);
} break;
// add DirectFormats (if have) as last element to Formatting AccessibilityCheckGroup on the Warning level if (nDirectFormats > 0)
{
size_t nGroupFormatIndex = size_t(AccessibilityCheckGroups::Formatting); // Direct Formats are on the warning level
size_t nLevel = static_cast<size_t>(sfx::AccessibilityIssueLevel::WARNLEV);
nIndices[nLevel][nGroupFormatIndex]++;
}
for (auto eLevel : o3tl::enumrange<sfx::AccessibilityIssueLevel>())
{
size_t nGroupIndex = 0; auto nLevelIndex = size_t(eLevel); bool bHaveIssue = false; for (sal_Int32 nIndex : nIndices[nLevelIndex])
{ if (nIndex > 0)
{
m_aLevelEntries[nLevelIndex]->show(nGroupIndex); if (!bHaveIssue)
bHaveIssue = true;
} else
m_aLevelEntries[nLevelIndex]->hide(nGroupIndex);
nGroupIndex++;
} if (!bHaveIssue)
m_xLevelExpanders[nLevelIndex]->hide(); else
m_xLevelExpanders[nLevelIndex]->show();
}
if (m_xLevelExpanders[0]->is_visible() && m_xLevelExpanders[1]->is_visible())
m_xListSep->set_visible(true); else
m_xListSep->set_visible(false);
if (pWindow)
pWindow->SetPointer(PointerStyle::Arrow);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.