28#include <com/sun/star/frame/XModel.hpp>
29#include <com/sun/star/lang/Locale.hpp>
30#include <com/sun/star/lang/XMultiServiceFactory.hpp>
31#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
32#include <com/sun/star/beans/XPropertySet.hpp>
50struct SvxForbiddenChars_Impl
53 std::optional<ForbiddenCharacters> oCharacters;
66 std::map< LanguageType, SvxForbiddenChars_Impl >
89 LanguageType eLang, std::optional<ForbiddenCharacters> oForbidden)
94 SvxForbiddenChars_Impl aChar;
95 aChar.bRemoved = !oForbidden.has_value();
96 aChar.oCharacters = std::move(oForbidden);
101 itOld->second.bRemoved = !oForbidden.has_value();
102 itOld->second.oCharacters = std::move(oForbidden);
109 :
SfxTabPage(pPage, pController,
"cui/ui/optasianpage.ui",
"OptAsianPage", &
rSet)
111 , m_xCharKerningRB(m_xBuilder->weld_radio_button(
"charkerning"))
112 , m_xCharPunctKerningRB(m_xBuilder->weld_radio_button(
"charpunctkerning"))
113 , m_xNoCompressionRB(m_xBuilder->weld_radio_button(
"nocompression"))
114 , m_xPunctCompressionRB(m_xBuilder->weld_radio_button(
"punctcompression"))
115 , m_xPunctKanaCompressionRB(m_xBuilder->weld_radio_button(
"punctkanacompression"))
116 , m_xLanguageFT(m_xBuilder->weld_label(
"languageft"))
117 , m_xLanguageLB(new
SvxLanguageBox(m_xBuilder->weld_combo_box(
"language")))
118 , m_xStandardCB(m_xBuilder->weld_check_button(
"standard"))
119 , m_xStartFT(m_xBuilder->weld_label(
"startft"))
120 , m_xStartED(m_xBuilder->weld_entry(
"start"))
121 , m_xEndFT(m_xBuilder->weld_label(
"endft"))
122 , m_xEndED(m_xBuilder->weld_entry(
"end"))
123 , m_xHintFT(m_xBuilder->weld_label(
"hintft"))
132 m_xLanguageLB->SetLanguageList( SvxLanguageListFlags::FBD_CHARS,
false,
false );
141 return std::make_unique<SvxAsianLayoutPage>(pPage, pController, *rAttrSet);
150 if(
pImpl->xPrSetInfo.is() &&
pImpl->xPrSetInfo->hasPropertyByName(sPunct))
153 pImpl->xPrSet->setPropertyValue(sPunct,
Any(bVal));
162 CharCompressType::PunctuationAndKana;
163 pImpl->aConfig.SetCharDistanceCompression(nSet);
165 if(
pImpl->xPrSetInfo.is() &&
pImpl->xPrSetInfo->hasPropertyByName(sCompress))
167 pImpl->xPrSet->setPropertyValue(sCompress,
Any(
static_cast<sal_uInt16
>(nSet)));
170 pImpl->aConfig.Commit();
171 if(
pImpl->xForbidden.is())
175 for (
auto const& changedLanguage :
pImpl->aChangedLanguagesMap)
178 if(changedLanguage.second.bRemoved)
179 pImpl->xForbidden->removeForbiddenCharacters( aLocale );
180 else if(changedLanguage.second.oCharacters)
181 pImpl->xForbidden->setForbiddenCharacters( aLocale, *( changedLanguage.second.oCharacters ) );
204 pImpl->xPrSet.set(xFact->createInstance(
"com.sun.star.document.Settings"), UNO_QUERY);
206 if(
pImpl->xPrSet.is() )
207 pImpl->xPrSetInfo =
pImpl->xPrSet->getPropertySetInfo();
208 bool bKernWesternText =
pImpl->aConfig.IsKerningWesternTextOnly();
210 if(
pImpl->xPrSetInfo.is())
212 OUString sForbidden(
"ForbiddenCharacters");
213 if(
pImpl->xPrSetInfo->hasPropertyByName(sForbidden))
215 Any aForbidden =
pImpl->xPrSet->getPropertyValue(sForbidden);
216 aForbidden >>=
pImpl->xForbidden;
219 if(
pImpl->xPrSetInfo->hasPropertyByName(sCompress))
221 Any aVal =
pImpl->xPrSet->getPropertyValue(sCompress);
227 if(
pImpl->xPrSetInfo->hasPropertyByName(sPunct))
229 Any aVal =
pImpl->xPrSet->getPropertyValue(sPunct);
230 bKernWesternText = !*o3tl::doAccess<bool>(aVal);
277 LanguageType eSelectLanguage = m_xLanguageLB->get_active_id();
281 OUString sStart, sEnd;
283 if(pImpl->xForbidden.is())
285 bAvail = pImpl->hasForbiddenCharacters(eSelectLanguage);
288 SvxForbiddenChars_Impl* pElement = pImpl->getForbiddenCharacters(eSelectLanguage);
289 if(pElement->bRemoved || !pElement->oCharacters)
295 sStart = pElement->oCharacters->beginLine;
296 sEnd = pElement->oCharacters->endLine;
303 bAvail = pImpl->xForbidden->hasForbiddenCharacters(aLocale);
306 ForbiddenCharacters aForbidden = pImpl->xForbidden->getForbiddenCharacters( aLocale );
307 sStart = aForbidden.beginLine;
308 sEnd = aForbidden.endLine;
319 bAvail = pImpl->aConfig.GetStartEndChars( aLocale, sStart, sEnd );
325 sStart = aForbidden.beginLine;
326 sEnd = aForbidden.endLine;
328 m_xStandardCB->set_active(!bAvail);
329 m_xStartED->set_sensitive(bAvail);
330 m_xEndED->set_sensitive(bAvail);
331 m_xStartFT->set_sensitive(bAvail);
332 m_xEndFT->set_sensitive(bAvail);
333 m_xStartED->set_text(sStart);
334 m_xEndED->set_text(sEnd);
339 bool bCheck = rBox.get_active();
340 m_xStartED->set_sensitive(!bCheck);
341 m_xEndED->set_sensitive(!bCheck);
342 m_xStartFT->set_sensitive(!bCheck);
343 m_xEndFT->set_sensitive(!bCheck);
345 ModifyHdl(*m_xStartED);
350 LanguageType eSelectLanguage = m_xLanguageLB->get_active_id();
352 OUString sStart = m_xStartED->get_text();
353 OUString sEnd = m_xEndED->get_text();
354 bool bEnable = rEdit.get_sensitive();
355 if(pImpl->xForbidden.is())
361 ForbiddenCharacters aFCSet;
362 aFCSet.beginLine = sStart;
363 aFCSet.endLine = sEnd;
364 pImpl->addForbiddenCharacters(eSelectLanguage, std::move(aFCSet));
367 pImpl->addForbiddenCharacters(eSelectLanguage, std::nullopt);
374 pImpl->aConfig.SetStartEndChars( aLocale, bEnable ? &sStart :
nullptr, bEnable ? &sEnd :
nullptr);
const LanguageTag & GetLanguageTag() const
static const AllSettings & GetSettings()
LanguageType getLanguageType(bool bResolveSystem=true) const
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
css::i18n::ForbiddenCharacters getForbiddenCharacters() const
static bool isTraditionalChinese(LanguageType nLang)
static bool isSimplifiedChinese(LanguageType nLang)
css::uno::Reference< css::frame::XModel3 > GetModel() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
virtual SfxObjectShell * GetObjectShell() override
std::unique_ptr< weld::RadioButton > m_xCharKerningRB
std::unique_ptr< weld::Label > m_xLanguageFT
std::unique_ptr< weld::Label > m_xStartFT
std::unique_ptr< weld::Entry > m_xEndED
virtual ~SvxAsianLayoutPage() override
virtual void Reset(const SfxItemSet *rSet) override
std::unique_ptr< weld::CheckButton > m_xStandardCB
std::unique_ptr< weld::Entry > m_xStartED
std::unique_ptr< SvxLanguageBox > m_xLanguageLB
std::unique_ptr< weld::Label > m_xEndFT
static WhichRangesContainer GetRanges()
std::unique_ptr< weld::RadioButton > m_xNoCompressionRB
SvxAsianLayoutPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
std::unique_ptr< weld::RadioButton > m_xPunctKanaCompressionRB
virtual bool FillItemSet(SfxItemSet *rSet) override
std::unique_ptr< weld::RadioButton > m_xPunctCompressionRB
std::unique_ptr< SvxAsianLayoutPage_Impl > pImpl
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::Label > m_xHintFT
std::unique_ptr< weld::RadioButton > m_xCharPunctKerningRB
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define LANGUAGE_CHINESE_TRADITIONAL
#define LANGUAGE_CHINESE_SIMPLIFIED
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(SvxAsianLayoutPage, LanguageHdl, weld::ComboBox &, void)
IMPL_LINK(SvxAsianLayoutPage, ChangeStandardHdl, weld::Toggleable &, rBox, void)
constexpr OUStringLiteral cCharacterCompressionType
static LanguageType eLastUsedLanguageTypeForForbiddenCharacters(USHRT_MAX)
constexpr OUStringLiteral cIsKernAsianPunctuation
std::map< LanguageType, SvxForbiddenChars_Impl > aChangedLanguagesMap
Reference< XPropertySet > xPrSet
Reference< XForbiddenCharacters > xForbidden
SvxForbiddenChars_Impl * getForbiddenCharacters(LanguageType eLang)
void addForbiddenCharacters(LanguageType eLang, std::optional< ForbiddenCharacters > oForbidden)
SvxAsianLayoutPage_Impl()
bool hasForbiddenCharacters(LanguageType eLang)
Reference< XPropertySetInfo > xPrSetInfo
Reference< XModel > xModel