22#include <officecfg/Office/Common.hxx>
36 :
SfxTabPage(pPage, pController,
"cui/ui/optfontspage.ui",
"OptFontsPage", &
rSet)
37 , m_xUseTableCB(m_xBuilder->weld_check_button(
"usetable"))
38 , m_xFont1CB(m_xBuilder->weld_combo_box(
"font1"))
39 , m_xFont2CB(m_xBuilder->weld_combo_box(
"font2"))
40 , m_xApply(m_xBuilder->weld_button(
"apply"))
41 , m_xDelete(m_xBuilder->weld_button(
"delete"))
42 , m_xCheckLB(m_xBuilder->weld_tree_view(
"checklb"))
43 , m_xFontNameLB(m_xBuilder->weld_combo_box(
"fontname"))
44 , m_xNonPropFontsOnlyCB(m_xBuilder->weld_check_button(
"nonpropfontonly"))
45 , m_xFontHeightLB(m_xBuilder->weld_combo_box(
"fontheight"))
58 m_xCheckLB->set_selection_mode(SelectionMode::Multiple);
74 m_xApply->connect_clicked(aClickLink);
80 for(nHeight = 6; nHeight <= 16; nHeight++)
82 for(nHeight = 18; nHeight <= 28; nHeight+= 2)
84 for(nHeight = 32; nHeight <= 48; nHeight+= 4)
86 for(nHeight = 54; nHeight <= 72; nHeight+= 6)
88 for(nHeight = 80; nHeight <= 96; nHeight+= 8)
94 bool bSortAtoZ = m_xCheckLB->get_sort_order();
97 if (nColumn == m_xCheckLB->get_sort_column())
99 bSortAtoZ = !bSortAtoZ;
100 m_xCheckLB->set_sort_order(bSortAtoZ);
104 m_xCheckLB->set_sort_indicator(
TRISTATE_INDET, m_xCheckLB->get_sort_column());
105 m_xCheckLB->set_sort_column(nColumn);
119 int nMax = std::max( nW1, nW2 ) + 6;
120 int nMin =
m_xCheckLB->get_checkbox_column_width();
121 nMax = std::max(nMax, nMin);
122 const int nDoubleMax = 2*nMax;
123 const int nRest = rSize.
Width() - nDoubleMax;
124 std::vector<int> aWidths { nMax, nMax, nRest/2 };
140 return std::make_unique<SvxFontSubstTabPage>(pPage, pController, *rAttrSet);
145 std::vector<SubstitutionStruct> aNewFontSubs;
153 aNewFontSubs.push_back(aAdd);
160 std::shared_ptr< comphelper::ConfigurationChanges > batch(
163 officecfg::Office::Common::Font::SourceViewFont::FontHeight::set(
164 static_cast< sal_Int16
>(
m_xFontHeightLB->get_active_text().toInt32()),
167 officecfg::Office::Common::Font::SourceViewFont::
168 NonProportionalFontsOnly::set(
174 officecfg::Office::Common::Font::SourceViewFont::FontName::set(
175 std::optional< OUString >(sFontName), batch);
193 for (sal_uInt16
i = 0;
i < nFontCount; ++
i)
206 std::unique_ptr<weld::TreeIter> xIter(
m_xCheckLB->make_iterator());
207 for (
auto const & sub: aFontSubs)
213 m_xCheckLB->set_text(*xIter, sub.sReplaceBy, 3);
226 officecfg::Office::Common::Font::SourceViewFont::
227 NonProportionalFontsOnly::get());
230 officecfg::Office::Common::Font::SourceViewFont::FontName::get().
231 value_or(OUString()));
232 if(!sFontName.isEmpty())
238 officecfg::Office::Common::Font::SourceViewFont::FontHeight::
267 int findText(
const weld::TreeView& rTreeView, std::u16string_view rCol)
269 for (
int i = 0, nEntryCount = rTreeView.
n_children(); i < nEntryCount; ++i)
271 if (rTreeView.
get_text(i, 2) == rCol)
277 bool findRow(
const weld::TreeView& rTreeView, std::u16string_view rCol1, std::u16string_view rCol2)
279 int nRow = findText(rTreeView, rCol1);
282 return rTreeView.
get_text(nRow, 3) == rCol2;
303 OUString sFont1 =
m_xFont1CB->get_active_text();
304 OUString sFont2 =
m_xFont2CB->get_active_text();
306 std::unique_ptr<weld::TreeIter> xIter(
m_xCheckLB->make_iterator());
323 const int nSelectedRowCount =
m_xCheckLB->count_selected_rows();
324 if (nSelectedRowCount == 1)
330 else if (nSelectedRowCount > 1)
343 int nSelectedRow =
m_xCheckLB->get_selected_index();
344 if (
nPos != nSelectedRow)
359 OUString sFontName = m_xFontNameLB->get_active_text();
360 bool bNonPropOnly = rBox.get_active();
361 m_xFontNameLB->clear();
363 m_xFontNameLB->append_text(m_sAutomatic);
365 for(sal_uInt16 nFont = 0; nFont < nFontCount; nFont++)
371 m_xFontNameLB->set_active_text(sFontName);
381 bool bApply = bEnableAll, bDelete = bEnableAll;
385 int nEntry =
m_xCheckLB->get_selected_index();
393 else if (nEntry != -1 &&
m_xCheckLB->count_selected_rows() != 1)
398 bDelete = nEntry != -1;
static OutputDevice * GetDefaultDevice()
size_t GetFontNameCount() const
const FontMetric & GetFontName(size_t nFont) const
constexpr tools::Long Width() const
std::unique_ptr< weld::ComboBox > m_xFontNameLB
virtual ~SvxFontSubstTabPage() override
std::unique_ptr< weld::ComboBox > m_xFontHeightLB
virtual bool FillItemSet(SfxItemSet *rSet) override
std::unique_ptr< weld::CheckButton > m_xNonPropFontsOnlyCB
std::unique_ptr< weld::CheckButton > m_xUseTableCB
std::unique_ptr< weld::Button > m_xDelete
virtual void Reset(const SfxItemSet *rSet) override
SvxFontSubstTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
std::unique_ptr< weld::ComboBox > m_xFont2CB
void setColSizes(const Size &rSize)
std::unique_ptr< weld::ComboBox > m_xFont1CB
std::unique_ptr< weld::Button > m_xApply
void SelectHdl(const weld::Widget *pWidget)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::TreeView > m_xCheckLB
static std::shared_ptr< ConfigurationChanges > create()
const OUString & GetFamilyName() const
virtual OUString get_text(int row, int col=-1) const=0
virtual int n_children() const=0
IMPL_LINK(SvxFontSubstTabPage, HeaderBarClick, int, nColumn, void)
constexpr OUStringLiteral HID_OFA_FONT_SUBST_CLB
#define LINK(Instance, Class, Member)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
bool bReplaceOnScreenOnly