12#include <rtl/ustrbuf.hxx>
16#include <unordered_set>
23 : GenericDialogController(pParent,
"cui/ui/fontfeaturesdialog.ui",
"FontFeaturesDialog")
24 , m_sFontName(
std::move(aFontName))
25 , m_xContentWindow(m_xBuilder->weld_scrolled_window(
"contentWindow"))
26 , m_xContentBox(m_xBuilder->weld_container(
"contentBox"))
27 , m_xContentGrid(m_xBuilder->weld_container(
"contentGrid"))
28 , m_xStylisticSetsBox(m_xBuilder->weld_container(
"stylisticSetsBox"))
29 , m_xStylisticSetsGrid(m_xBuilder->weld_container(
"stylisticSetsGrid"))
30 , m_xCharacterVariantsBox(m_xBuilder->weld_container(
"characterVariantsBox"))
31 , m_xCharacterVariantsGrid(m_xBuilder->weld_container(
"characterVariantsGrid"))
32 , m_xPreviewWindow(new
weld::CustomWeld(*m_xBuilder,
"preview", m_aPreviewWindow))
47 rNameBox.
append(OUString::number(rParameter.getCode()), rParameter.getDescription());
48 if (rParameter.getCode() == nDefault)
58 DeviceFormat::WITH_ALPHA);
61 std::unordered_set<sal_uInt32> aDoneFeatures;
62 std::vector<vcl::font::Feature> rFilteredFontFeatures;
66 sal_uInt32 nFontFeatureCode = rFontFeature.m_nCode;
67 if (!aDoneFeatures.insert(nFontFeatureCode).second)
69 rFilteredFontFeatures.push_back(rFontFeature);
72 int nRowHeight =
fillGrid(rFilteredFontFeatures);
74 auto nFeaturesHeight =
m_xContentBox->get_preferred_size().Height()
78 -1, std::min(std::max(
m_xContentWindow->get_preferred_size().Height(), nFeaturesHeight),
97 sal_Int32 nIdx, nStylisticSets(0), nCharacterVariants(0), nOtherFeatures(0);
100 sal_uInt32 nFontFeatureCode = rFontFeature.m_nCode;
103 if (rFontFeature.m_aDefinition)
104 aDefinition = rFontFeature.m_aDefinition;
106 aDefinition = { nFontFeatureCode,
"" };
108 if (rFontFeature.isStylisticSet())
110 nIdx = nStylisticSets++;
115 else if (rFontFeature.isCharacterVariant())
117 nIdx = nCharacterVariants++;
124 nIdx = nOtherFeatures++;
130 if (aExistingFeatures.find(nFontFeatureCode) != aExistingFeatures.end())
131 nValue = aExistingFeatures.at(nFontFeatureCode);
139 sal_Int32 nGridPositionX = (nIdx % 2) * 2;
140 sal_Int32 nGridPositionY = nIdx / 2;
141 aCurrentItem.
m_xContainer->set_grid_left_attach(nGridPositionX);
142 aCurrentItem.
m_xContainer->set_grid_top_attach(nGridPositionY);
156 aCurrentItem.
m_xCombo->set_active(nInit);
157 aCurrentItem.
m_xCombo->connect_changed(aComboBoxSelectHandler);
180 = std::max<int>(nRowHeight, aCurrentItem.
m_xContainer->get_preferred_size().Height());
203 m_aTriStateEnabled.ButtonToggled(rToggle);
204 m_aTriStateEnabled.bTriStateEnabled =
false;
205 m_aToggleHdl.Call(rToggle);
220 OUString sResultFontName;
221 OUStringBuffer sNameSuffix;
238 sNameSuffix.append(
"=0");
241 else if (rItem.
m_xCombo->get_visible() && rItem.
m_xText->get_visible())
243 sal_Int32 nSelection = rItem.
m_xCombo->get_active_id().toInt32();
252 + OUString::number(nSelection));
257 if (!sNameSuffix.isEmpty())
259 return sResultFontName;
264 short nResult = GenericDialogController::run();
std::vector< vcl::font::Feature > getFontFeatureList(OUString const &rFontName, VirtualDevice &rVDev)
static OutputDevice * GetDefaultDevice()
void SetFont(const SvxFont &rNormalFont, const SvxFont &rCJKFont, const SvxFont &rCTLFont)
std::unique_ptr< weld::Container > m_xContentBox
virtual short run() override
OUString m_sResultFontName
std::vector< std::unique_ptr< FontFeatureItem > > m_aFeatureItems
std::unique_ptr< weld::Container > m_xStylisticSetsGrid
std::unique_ptr< weld::ScrolledWindow > m_xContentWindow
std::unique_ptr< weld::Container > m_xStylisticSetsBox
~FontFeaturesDialog() override
FontFeaturesDialog(weld::Window *pParent, OUString aFontName)
std::unique_ptr< weld::Container > m_xCharacterVariantsGrid
std::unique_ptr< weld::Container > m_xCharacterVariantsBox
std::unique_ptr< weld::Container > m_xContentGrid
SvxFontPrevWindow m_aPreviewWindow
int fillGrid(std::vector< vcl::font::Feature > const &rFontFeatures)
OUString createFontNameWithFeatures()
void SetFamilyName(const OUString &rFamilyName)
FeatureParameterType getType() const
int32_t getDefault() const
const std::vector< FeatureParameter > & getEnumParameters() const
OUString getDescription() const
std::unordered_map< uint32_t, int32_t > getFeaturesMap() const
void append(const weld::ComboBoxEntry &rItem)
#define LINK(Instance, Class, Member)
static sal_Int32 makeEnumComboBox(weld::ComboBox &rNameBox, vcl::font::FeatureDefinition const &rFeatureDefinition, uint32_t nDefault)
IMPL_LINK_NOARG(ColorPickerDialog, ColorFieldControlModifydl, ColorFieldControl &, void)
IMPL_LINK(ColorPickerDialog, ColorModifyMetricHdl, weld::MetricSpinButton &, rEdit, void)
constexpr const char FeaturePrefix
OUString trimFontNameFeatures(OUString const &rFontName)
OUString featureCodeAsString(uint32_t nFeature)
constexpr const char FeatureSeparator
sal_uInt32 m_aFeatureCode
std::unique_ptr< weld::Widget > m_xContainer
std::unique_ptr< weld::ComboBox > m_xCombo
std::unique_ptr< weld::CheckButton > m_xCheck
weld::TriStateEnabled m_aTriStateEnabled
std::unique_ptr< weld::Label > m_xText
Link< weld::Toggleable &, void > m_aToggleHdl