26#include <officecfg/Office/Security.hxx>
31#include <sfx2/sfxsids.hrc>
37#include <com/sun/star/linguistic2/LinguServiceManager.hpp>
38#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
39#include <com/sun/star/linguistic2/XSpellChecker.hpp>
40#include <com/sun/star/linguistic2/XProofreader.hpp>
41#include <com/sun/star/linguistic2/XHyphenator.hpp>
42#include <com/sun/star/linguistic2/XThesaurus.hpp>
43#include <com/sun/star/linguistic2/XDictionary.hpp>
44#include <com/sun/star/linguistic2/XDictionaryList.hpp>
45#include <com/sun/star/linguistic2/XLinguProperties.hpp>
46#include <com/sun/star/lang/XServiceDisplayName.hpp>
47#include <com/sun/star/frame/XStorable.hpp>
52#include <osl/diagnose.h>
67using namespace css::lang;
68using namespace css::uno;
69using namespace css::linguistic2;
70using namespace css::beans;
72constexpr OUStringLiteral
cSpell(SN_SPELLCHECKER);
73constexpr OUStringLiteral
cGrammar(SN_GRAMMARCHECKER);
74constexpr OUStringLiteral
cHyph(SN_HYPHENATOR);
75constexpr OUStringLiteral
cThes(SN_THESAURUS);
83 sal_Int32 nLen = rSeq.getLength();
84 const OUString *pItem = rSeq.getConstArray();
85 for (
i = 0;
i < nLen; ++
i)
87 if (rEntry == pItem[
i])
90 return i < nLen ?
i : -1;
99 aCnt.executeCommand(
"delete",
Any(
true ) );
116#define TYPE_SPELL sal_uInt8(1)
117#define TYPE_GRAMMAR sal_uInt8(2)
118#define TYPE_HYPH sal_uInt8(3)
119#define TYPE_THES sal_uInt8(4)
123class ModuleUserData_Impl
132 ModuleUserData_Impl( OUString sImpName,
bool bIsParent,
bool bChecked,
sal_uInt8 nSetType,
sal_uInt8 nSetIndex ) :
134 bIsChecked(bChecked),
137 sImplName(std::move(sImpName))
140 bool IsParent()
const {
return bParent;}
142 bool IsChecked()
const {
return bIsChecked;}
144 const OUString& GetImplName()
const {
return sImplName;}
156 explicit DicUserData(sal_uInt32 nUserData) : nVal( nUserData ) {}
157 DicUserData( sal_uInt16 nEID,
158 bool bChecked,
bool bEditable,
bool bDeletable );
160 sal_uInt32 GetUserData()
const {
return nVal; }
161 sal_uInt16 GetEntryId()
const {
return static_cast<sal_uInt16
>(nVal >> 16); }
162 bool IsChecked()
const {
return static_cast<bool>((nVal >> 8) & 0x01); }
163 bool IsDeletable()
const {
return static_cast<bool>((nVal >> 10) & 0x01); }
168DicUserData::DicUserData(
170 bool bChecked,
bool bEditable,
bool bDeletable )
172 DBG_ASSERT( nEID < 65000,
"Entry Id out of range" );
173 nVal = (
static_cast<sal_uInt32
>(0xFFFF & nEID) << 16) |
174 (
static_cast<sal_uInt32
>(bChecked ? 1 : 0) << 8) |
175 (
static_cast<sal_uInt32
>(bEditable ? 1 : 0) << 9) |
176 (
static_cast<sal_uInt32
>(bDeletable ? 1 : 0) << 10);
190 EID_WORDS_WITH_DIGITS,
215 default: assert (
false); abort();
223 std::unique_ptr<weld::Widget> m_xBeforeFrame;
224 std::unique_ptr<weld::Widget> m_xAfterFrame;
225 std::unique_ptr<weld::Widget> m_xMinimalFrame;
226 std::unique_ptr<weld::SpinButton> m_xBreakNF;
230 : GenericDialogController(pParent,
"cui/ui/breaknumberoption.ui",
"BreakNumberOption")
231 , m_xBeforeFrame(m_xBuilder->weld_widget(
"beforeframe"))
232 , m_xAfterFrame(m_xBuilder->weld_widget(
"afterframe"))
233 , m_xMinimalFrame(m_xBuilder->weld_widget(
"miniframe"))
235 assert(EID_NUM_PRE_BREAK == nRID || EID_NUM_POST_BREAK == nRID || EID_NUM_MIN_WORDLEN == nRID);
237 if (nRID == EID_NUM_PRE_BREAK)
239 m_xBeforeFrame->show();
240 m_xBreakNF = m_xBuilder->weld_spin_button(
"beforebreak");
242 else if(nRID == EID_NUM_POST_BREAK)
244 m_xAfterFrame->show();
245 m_xBreakNF = m_xBuilder->weld_spin_button(
"afterbreak");
247 else if(nRID == EID_NUM_MIN_WORDLEN)
249 m_xMinimalFrame->show();
250 m_xBreakNF = m_xBuilder->weld_spin_button(
"wordlength");
267 explicit OptionsUserData( sal_uInt32 nUserData ) : nVal( nUserData ) {}
268 OptionsUserData( sal_uInt16 nEID,
269 bool bHasNV, sal_uInt16 nNumVal,
270 bool bCheckable,
bool bChecked );
272 sal_uInt32 GetUserData()
const {
return nVal; }
273 sal_uInt16 GetEntryId()
const {
return static_cast<sal_uInt16
>(nVal >> 16); }
274 bool HasNumericValue()
const {
return static_cast<bool>((nVal >> 10) & 0x01); }
275 sal_uInt16 GetNumericValue()
const {
return static_cast<sal_uInt16
>(nVal & 0xFF); }
276 bool IsCheckable()
const {
return static_cast<bool>((nVal >> 9) & 0x01); }
277 bool IsModified()
const {
return static_cast<bool>((nVal >> 11) & 0x01); }
279 void SetNumericValue(
sal_uInt8 nNumVal );
284OptionsUserData::OptionsUserData( sal_uInt16 nEID,
285 bool bHasNV, sal_uInt16 nNumVal,
286 bool bCheckable,
bool bChecked )
288 DBG_ASSERT( nEID < 65000,
"Entry Id out of range" );
289 DBG_ASSERT( nNumVal < 256,
"value out of range" );
290 nVal = (
static_cast<sal_uInt32
>(0xFFFF & nEID) << 16) |
291 (
static_cast<sal_uInt32
>(bHasNV ? 1 : 0) << 10) |
292 (
static_cast<sal_uInt32
>(bCheckable ? 1 : 0) << 9) |
293 (
static_cast<sal_uInt32
>(bChecked ? 1 : 0) << 8) |
294 static_cast<sal_uInt32
>(0xFF & nNumVal);
297void OptionsUserData::SetNumericValue(
sal_uInt8 nNumVal )
299 if (HasNumericValue() && (GetNumericValue() != nNumVal))
303 nVal |= sal_uInt32(1) << 11;
311struct ServiceInfo_Impl
314 OUString sSpellImplName;
315 OUString sHyphImplName;
316 OUString sThesImplName;
317 OUString sGrammarImplName;
324 ServiceInfo_Impl() : bConfigured(false) {}
350 const OUString &rImplName,
bool bAdd );
358 void Reconfigure( std::u16string_view rDisplayName,
bool bEnable );
388 sal_Int32 nLen = rSeq.getLength();
389 const OUString *pString = rSeq.getConstArray();
390 for (sal_Int32
i = 0;
i < nLen && nRes == -1; ++
i)
392 if (pString[
i] == rTxt)
412 SAL_WARN(
"cui.options",
"unknown linguistic type" );
415 if (pTable->count( nLang ))
416 aRes = (*pTable)[ nLang ];
417 sal_Int32 nIdx = aRes.getLength();
420 OUString *pRes = aRes.getArray();
429 case TYPE_SPELL : aImplName = rInfo.sSpellImplName;
break;
430 case TYPE_HYPH : aImplName = rInfo.sHyphImplName;
break;
431 case TYPE_THES : aImplName = rInfo.sThesImplName;
break;
432 case TYPE_GRAMMAR : aImplName = rInfo.sGrammarImplName;
break;
437 DBG_ASSERT( nIdx < aRes.getLength(),
"index out of range" );
438 if (nIdx < aRes.getLength())
439 pRes[ nIdx++ ] = aImplName;
445 aRes.realloc( nIdx );
455 if (rTmp.sSpellImplName == rSvcImplName ||
456 rTmp.sHyphImplName == rSvcImplName ||
457 rTmp.sThesImplName == rSvcImplName ||
458 rTmp.sGrammarImplName == rSvcImplName)
467static void lcl_MergeLocales(Sequence< Locale >& aAllLocales,
const Sequence< Locale >& rAdd)
469 Sequence<Locale> aLocToAdd(rAdd.getLength());
470 Locale* pLocToAdd = aLocToAdd.getArray();
471 sal_Int32 nFound = 0;
475 for(
const Locale& j : std::as_const(aAllLocales))
477 if (
i.Language == j.Language &&
478 i.Country == j.Country &&
479 i.Variant == j.Variant)
487 pLocToAdd[nFound++] =
i;
490 sal_Int32
nLength = aAllLocales.getLength();
491 aAllLocales.realloc(
nLength + nFound);
492 Locale* pAllLocales2 = aAllLocales.getArray();
493 for(sal_Int32
i = 0;
i < nFound;
i++)
494 pAllLocales2[
nLength++] = pLocToAdd[
i];
499 const ServiceInfo_Impl &rToAdd )
504 sal_uInt32 nEntries =
rData.GetDisplayServiceCount();
506 for (sal_uInt32
i = 0;
i < nEntries; ++
i)
508 ServiceInfo_Impl& rEntry = rSvcInfoArr[
i];
509 if (rEntry.sDisplayName == rToAdd.sDisplayName)
511 if(rToAdd.xSpell.is())
514 rEntry.sSpellImplName.isEmpty(),
516 rEntry.sSpellImplName = rToAdd.sSpellImplName;
517 rEntry.xSpell = rToAdd.xSpell;
519 if(rToAdd.xGrammar.is())
522 rEntry.sGrammarImplName.isEmpty(),
524 rEntry.sGrammarImplName = rToAdd.sGrammarImplName;
525 rEntry.xGrammar = rToAdd.xGrammar;
527 if(rToAdd.xHyph.is())
530 rEntry.sHyphImplName.isEmpty(),
532 rEntry.sHyphImplName = rToAdd.sHyphImplName;
533 rEntry.xHyph = rToAdd.xHyph;
535 if(rToAdd.xThes.is())
538 rEntry.sThesImplName.isEmpty(),
540 rEntry.sThesImplName = rToAdd.sThesImplName;
541 rEntry.xThes = rToAdd.xThes;
547 rData.GetDisplayServiceArray().push_back( rToAdd );
548 rData.SetDisplayServiceCount( nCnt + 1 );
558 Sequence<Any> aArgs(2);
565 for(
const OUString& spellName : aSpellNames)
567 ServiceInfo_Impl aInfo;
568 aInfo.sSpellImplName = spellName;
570 xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sSpellImplName, aArgs, xContext), UNO_QUERY);
574 aInfo.sDisplayName = xDispName->getServiceDisplayName( rCurrentLocale );
576 const Sequence< Locale > aLocales( aInfo.xSpell->getLocales() );
578 if (aLocales.hasElements())
588 for(
const OUString& grammarName : aGrammarNames)
590 ServiceInfo_Impl aInfo;
591 aInfo.sGrammarImplName = grammarName;
593 xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sGrammarImplName, aArgs, xContext), UNO_QUERY);
597 aInfo.sDisplayName = xDispName->getServiceDisplayName( rCurrentLocale );
599 const Sequence< Locale > aLocales( aInfo.xGrammar->getLocales() );
601 if (aLocales.hasElements())
611 for(
const OUString& hyphName : aHyphNames)
613 ServiceInfo_Impl aInfo;
614 aInfo.sHyphImplName = hyphName;
615 aInfo.xHyph.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sHyphImplName, aArgs, xContext), UNO_QUERY);
619 aInfo.sDisplayName = xDispName->getServiceDisplayName( rCurrentLocale );
621 const Sequence< Locale > aLocales( aInfo.xHyph->getLocales() );
623 if (aLocales.hasElements())
633 for(
const OUString& thesName : aThesNames)
635 ServiceInfo_Impl aInfo;
636 aInfo.sThesImplName = thesName;
637 aInfo.xThes.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sThesImplName, aArgs, xContext), UNO_QUERY);
641 aInfo.sDisplayName = xDispName->getServiceDisplayName( rCurrentLocale );
643 const Sequence< Locale > aLocales( aInfo.xThes->getLocales() );
645 if (aLocales.hasElements())
659 if (aCfgSvcs.hasElements())
664 if (aCfgSvcs.hasElements())
669 if (aCfgSvcs.hasElements())
674 if (aCfgSvcs.hasElements())
681 for(OUString
const & configService : rConfiguredServices)
686 if (!rEntry.bConfigured)
688 const OUString &rSrvcImplName = configService;
689 if (!rSrvcImplName.isEmpty() &&
690 (rEntry.sSpellImplName == rSrvcImplName ||
691 rEntry.sGrammarImplName == rSrvcImplName ||
692 rEntry.sHyphImplName == rSrvcImplName ||
693 rEntry.sThesImplName == rSrvcImplName))
695 rEntry.bConfigured =
true;
705 const OUString &rImplName,
bool bAdd )
709 sal_Int32 nEntries = rConfigured.getLength();
711 if (bAdd &&
nPos < 0)
713 rConfigured.realloc( ++nEntries );
714 OUString *pConfigured = rConfigured.getArray();
715 pConfigured[nEntries - 1] = rImplName;
718 else if (!bAdd &&
nPos >= 0)
720 OUString *pConfigured = rConfigured.getArray();
721 for (sal_Int32
i =
nPos;
i < nEntries - 1; ++
i)
722 pConfigured[
i] = pConfigured[
i + 1];
723 rConfigured.realloc(--nEntries);
733 DBG_ASSERT( !rDisplayName.empty(),
"empty DisplayName" );
735 ServiceInfo_Impl *pInfo =
nullptr;
739 if (rTmp.sDisplayName == rDisplayName)
745 DBG_ASSERT( pInfo,
"DisplayName entry not found" );
749 pInfo->bConfigured = bEnable;
751 Sequence< Locale > aLocales;
753 sal_Int32 nLocales = 0;
757 if (pInfo->xSpell.is())
759 aLocales = pInfo->xSpell->getLocales();
760 pLocale = aLocales.getConstArray();
761 nLocales = aLocales.getLength();
762 for (
i = 0;
i < nLocales; ++
i)
773 if (pInfo->xGrammar.is())
775 aLocales = pInfo->xGrammar->getLocales();
776 pLocale = aLocales.getConstArray();
777 nLocales = aLocales.getLength();
778 for (
i = 0;
i < nLocales; ++
i)
789 if (pInfo->xHyph.is())
791 aLocales = pInfo->xHyph->getLocales();
792 pLocale = aLocales.getConstArray();
793 nLocales = aLocales.getLength();
794 for (
i = 0;
i < nLocales; ++
i)
805 if (!pInfo->xThes.is())
808 aLocales = pInfo->xThes->getLocales();
809 pLocale = aLocales.getConstArray();
810 nLocales = aLocales.getLength();
811 for (
i = 0;
i < nLocales; ++
i)
825 :
SfxTabPage(pPage, pController,
"cui/ui/optlingupage.ui",
"OptLinguPage", &
rSet)
826 , sCapitalWords (
CuiResId(RID_CUISTR_CAPITAL_WORDS))
827 , sWordsWithDigits(
CuiResId(RID_CUISTR_WORDS_WITH_DIGITS))
828 , sSpellSpecial (
CuiResId(RID_CUISTR_SPELL_SPECIAL))
829 , sSpellAuto (
CuiResId(RID_CUISTR_SPELL_AUTO))
830 , sGrammarAuto (
CuiResId(RID_CUISTR_GRAMMAR_AUTO))
831 , sNumMinWordlen (
CuiResId(RID_CUISTR_NUM_MIN_WORDLEN))
832 , sNumPreBreak (
CuiResId(RID_CUISTR_NUM_PRE_BREAK))
833 , sNumPostBreak (
CuiResId(RID_CUISTR_NUM_POST_BREAK))
834 , sHyphAuto (
CuiResId(RID_CUISTR_HYPH_AUTO))
835 , sHyphSpecial (
CuiResId(RID_CUISTR_HYPH_SPECIAL))
836 , nUPN_HYPH_MIN_WORD_LENGTH(-1)
837 , nUPN_HYPH_MIN_LEADING(-1)
838 , nUPN_HYPH_MIN_TRAILING(-1)
839 , m_nDlbClickEventId(nullptr)
840 , m_xLinguModulesFT(m_xBuilder->weld_label(
"lingumodulesft"))
841 , m_xLinguModulesCLB(m_xBuilder->weld_tree_view(
"lingumodules"))
842 , m_xLinguModulesEditPB(m_xBuilder->weld_button(
"lingumodulesedit"))
843 , m_xLinguDicsFT(m_xBuilder->weld_label(
"lingudictsft"))
844 , m_xLinguDicsCLB(m_xBuilder->weld_tree_view(
"lingudicts"))
845 , m_xLinguDicsNewPB(m_xBuilder->weld_button(
"lingudictsnew"))
846 , m_xLinguDicsEditPB(m_xBuilder->weld_button(
"lingudictsedit"))
847 , m_xLinguDicsDelPB(m_xBuilder->weld_button(
"lingudictsdelete"))
848 , m_xLinguOptionsCLB(m_xBuilder->weld_tree_view(
"linguoptions"))
849 , m_xLinguOptionsEditPB(m_xBuilder->weld_button(
"linguoptionsedit"))
850 , m_xMoreDictsLink(m_xBuilder->weld_link_button(
"moredictslink"))
916 return std::make_unique<SvxLinguTabPage>( pPage, pController, *rAttrSet );
921 bool bModified =
true;
932 for (
auto const& elem : *pTable)
939 xMgr->setConfiguredServices(
cSpell, aLocale, aImplNames );
944 for (
auto const& elem : *pTable)
951 xMgr->setConfiguredServices(
cGrammar, aLocale, aImplNames );
956 for (
auto const& elem : *pTable)
963 xMgr->setConfiguredServices(
cHyph, aLocale, aImplNames );
968 for (
auto const& elem : *pTable)
975 xMgr->setConfiguredServices(
cThes, aLocale, aImplNames );
983 sal_Int32 nActiveDics = 0;
985 for (
int i = 0;
i < nEntries; ++
i)
987 sal_Int32 nDics =
aDics.getLength();
989 aActiveDics.realloc( nDics );
990 OUString *pActiveDic = aActiveDics.getArray();
993 if (
aData.GetEntryId() < nDics)
1001 xDic->setActive( bChecked );
1005 OUString aDicName( xDic->getName() );
1006 pActiveDic[ nActiveDics++ ] = aDicName;
1012 aActiveDics.realloc( nActiveDics );
1014 aTmp <<= aActiveDics;
1020 for (
int j = 0; j < nEntries; ++j)
1026 if (
aData.IsCheckable())
1031 else if (
aData.HasNumericValue())
1033 sal_Int16 nVal =
aData.GetNumericValue();
1042 OptionsUserData aPreBreakData(
m_xLinguOptionsCLB->get_id(EID_NUM_PRE_BREAK).toUInt32());
1043 OptionsUserData aPostBreakData(
m_xLinguOptionsCLB->get_id(EID_NUM_POST_BREAK).toUInt32());
1044 if ( aPreBreakData.IsModified() || aPostBreakData.IsModified() )
1049 rCoreSet->
Put( aHyp );
1057 rCoreSet->
Put(
SfxBoolItem( SID_AUTOSPELL_CHECK, bNewAutoCheck ) );
1066 sal_uInt32 nRes = 0;
1067 DBG_ASSERT( rxDic.is(),
"dictionary not supplied" );
1072 bool bChecked = rxDic->isActive();
1073 bool bEditable = !xStor.is() || !xStor->isReadonly();
1074 bool bDeletable = bEditable;
1076 nRes = DicUserData( nIdx,
1077 bChecked, bEditable, bDeletable ).GetUserData();
1089 OUString aTxt( ::GetDicInfoStr( rxDic->getName(),
1091 DictionaryType_NEGATIVE == rxDic->getDictionaryType() ) );
1107 sal_Int32 nDics =
aDics.getLength();
1109 for (sal_Int32
i = 0;
i < nDics; ++
i)
1130 const sal_uInt32 nDispSrvcCount =
pLinguData->GetDisplayServiceCount();
1134 for (sal_uInt32
i = 0;
i < nDispSrvcCount; ++
i)
1136 const ServiceInfo_Impl &rInfo = rAllDispSrvcArr[
i];
1169 sal_uInt32 nUserData = 0;
1178 nUserData = OptionsUserData( EID_SPELL_AUTO,
false, 0,
true, bVal).GetUserData();
1187 nUserData = OptionsUserData( EID_GRAMMAR_AUTO,
false, 0,
true, bVal).GetUserData();
1196 nUserData = OptionsUserData( EID_CAPITAL_WORDS,
false, 0,
true, bVal).GetUserData();
1205 nUserData = OptionsUserData( EID_WORDS_WITH_DIGITS,
false, 0,
true, bVal).GetUserData();
1214 nUserData = OptionsUserData( EID_SPELL_SPECIAL,
false, 0,
true, bVal).GetUserData();
1223 nUserData = OptionsUserData( EID_NUM_MIN_WORDLEN,
true,
static_cast<sal_uInt16
>(nVal),
false,
false).GetUserData();
1229 if (
rSet->
GetItemState( SID_ATTR_HYPHENREGION,
false ) == SfxItemState::SET )
1230 pHyp = &
rSet->
Get( SID_ATTR_HYPHENREGION );
1237 nVal =
static_cast<sal_Int16
>(pHyp->
GetMinLead());
1238 nUserData = OptionsUserData( EID_NUM_PRE_BREAK,
true,
static_cast<sal_uInt16
>(nVal),
false,
false).GetUserData();
1248 nVal =
static_cast<sal_Int16
>(pHyp->
GetMinTrail());
1249 nUserData = OptionsUserData( EID_NUM_POST_BREAK,
true,
static_cast<sal_uInt16
>(nVal),
false,
false).GetUserData();
1258 nUserData = OptionsUserData( EID_HYPH_AUTO,
false, 0,
true, bVal).GetUserData();
1267 nUserData = OptionsUserData( EID_HYPH_SPECIAL,
false, 0,
true, bVal).GetUserData();
1287 if (&rBox == m_xLinguModulesCLB.get() && !m_nDlbClickEventId)
1294 else if (&rBox == m_xLinguOptionsCLB.get())
1296 ClickHdl_Impl(*m_xLinguOptionsEditPB);
1303 m_nDlbClickEventId =
nullptr;
1304 ClickHdl_Impl(*m_xLinguModulesEditPB);
1311 pLinguData->Reconfigure(m_xLinguModulesCLB->get_text(rRowCol.first),
1312 m_xLinguModulesCLB->get_toggle(rRowCol.first) ==
TRISTATE_TRUE);
1324 if (m_xLinguModulesEditPB.get() == &rBtn)
1332 *pLinguData = aOldLinguData;
1336 for (sal_uInt32
i = 0;
i < nLen; ++
i)
1337 pLinguData->GetDisplayServiceArray()[
i].bConfigured =
false;
1338 const Locale* pAllLocales = pLinguData->GetAllSupportedLocales().getConstArray();
1339 sal_Int32 nLocales = pLinguData->GetAllSupportedLocales().getLength();
1340 for (sal_Int32 k = 0; k < nLocales; ++k)
1343 if (pLinguData->GetSpellTable().count( nLang ))
1344 pLinguData->SetChecked( pLinguData->GetSpellTable()[ nLang ] );
1345 if (pLinguData->GetGrammarTable().count( nLang ))
1346 pLinguData->SetChecked( pLinguData->GetGrammarTable()[ nLang ] );
1347 if (pLinguData->GetHyphTable().count( nLang ))
1348 pLinguData->SetChecked( pLinguData->GetHyphTable()[ nLang ] );
1349 if (pLinguData->GetThesTable().count( nLang ))
1350 pLinguData->SetChecked( pLinguData->GetThesTable()[ nLang ] );
1354 UpdateModulesBox_Impl();
1356 else if (m_xLinguDicsNewPB.get() == &rBtn)
1361 if ( aDlg->Execute() ==
RET_OK )
1362 xNewDic = aDlg->GetNewDictionary();
1366 sal_Int32 nLen = aDics.getLength();
1367 aDics.realloc( nLen + 1 );
1369 aDics.getArray()[ nLen ] = xNewDic;
1371 AddDicBoxEntry( xNewDic,
static_cast<sal_uInt16
>(nLen) );
1374 else if (m_xLinguDicsEditPB.get() == &rBtn)
1376 int nEntry = m_xLinguDicsCLB->get_selected_index();
1379 DicUserData
aData(m_xLinguDicsCLB->get_id(nEntry).toUInt32());
1380 sal_uInt16 nDicPos =
aData.GetEntryId();
1381 sal_Int32 nDics = aDics.getLength();
1382 if (nDicPos < nDics)
1394 else if (m_xLinguDicsDelPB.get() == &rBtn)
1397 std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog(
"QueryDeleteDictionaryDialog"));
1398 if (
RET_NO == xQuery->run())
1401 int nEntry = m_xLinguDicsCLB->get_selected_index();
1404 DicUserData
aData(m_xLinguDicsCLB->get_id(nEntry).toUInt32());
1405 sal_uInt16 nDicPos =
aData.GetEntryId();
1406 sal_Int32 nDics = aDics.getLength();
1407 if (nDicPos < nDics)
1417 xDicList->removeDictionary( xDic );
1420 if ( xStor->hasLocation() && !xStor->isReadonly() )
1422 OUString sURL = xStor->getLocation();
1425 "non-file URLs cannot be deleted" );
1432 aDics.getArray()[ nDicPos ] =
nullptr;
1435 int nCnt = m_xLinguDicsCLB->n_children();
1436 for (
int i = 0;
i < nCnt; ++
i)
1438 DicUserData aDicData(m_xLinguDicsCLB->get_id(
i).toUInt32());
1439 if (aDicData.GetEntryId() == nDicPos )
1441 m_xLinguDicsCLB->remove(
i);
1445 DBG_ASSERT( nCnt > m_xLinguDicsCLB->n_children(),
1452 else if (m_xLinguOptionsEditPB.get() == &rBtn)
1454 int nEntry = m_xLinguOptionsCLB->get_selected_index();
1455 DBG_ASSERT(nEntry != -1,
"no entry selected");
1458 OptionsUserData
aData(m_xLinguOptionsCLB->get_id(nEntry).toUInt32());
1459 if (
aData.HasNumericValue())
1461 sal_uInt16 nRID =
aData.GetEntryId();
1463 aDlg.GetNumericFld().set_value(
aData.GetNumericValue());
1464 if (
RET_OK == aDlg.run())
1466 int nVal = aDlg.GetNumericFld().get_value();
1467 if (-1 != nVal &&
aData.GetNumericValue() != nVal)
1470 m_xLinguOptionsCLB->set_id(nEntry, OUString::number(
aData.GetUserData()));
1471 if (nEntry == nUPN_HYPH_MIN_WORD_LENGTH)
1472 m_xLinguOptionsCLB->set_text(nEntry, sNumMinWordlen +
" " + OUString::number(nVal), 0);
1473 else if (nEntry == nUPN_HYPH_MIN_LEADING)
1474 m_xLinguOptionsCLB->set_text(nEntry, sNumPreBreak +
" " + OUString::number(nVal), 0);
1475 else if (nEntry == nUPN_HYPH_MIN_TRAILING)
1476 m_xLinguOptionsCLB->set_text(nEntry, sNumPostBreak +
" " + OUString::number(nVal), 0);
1477 m_xLinguOptionsCLB->set_id(nEntry, OUString::number(
aData.GetUserData()));
1485 OSL_FAIL(
"rBtn unexpected value" );
1491 if (m_xLinguModulesCLB.get() == &rBox)
1494 else if (m_xLinguDicsCLB.get() == &rBox)
1496 int nEntry = rBox.get_selected_index();
1499 DicUserData
aData(rBox.get_id(nEntry).toUInt32());
1502 m_xLinguDicsEditPB->set_sensitive(
true );
1503 m_xLinguDicsDelPB->set_sensitive(
aData.IsDeletable() );
1506 else if (m_xLinguOptionsCLB.get() == &rBox)
1508 int nEntry = rBox.get_selected_index();
1511 OptionsUserData
aData(rBox.get_id(nEntry).toUInt32());
1512 m_xLinguOptionsEditPB->set_sensitive(
aData.HasNumericValue() );
1517 OSL_FAIL(
"rBox unexpected value" );
1543 : GenericDialogController(pParent,
"cui/ui/editmodulesdialog.ui",
"EditModulesDialog")
1544 , sSpell(
CuiResId(RID_CUISTR_SPELL))
1547 , sGrammar(
CuiResId(RID_CUISTR_GRAMMAR))
1549 , m_xModulesCLB(m_xBuilder->weld_tree_view(
"lingudicts"))
1550 , m_xPrioUpPB(m_xBuilder->weld_button(
"up"))
1551 , m_xPrioDownPB(m_xBuilder->weld_button(
"down"))
1552 , m_xBackPB(m_xBuilder->weld_button(
"back"))
1553 , m_xMoreDictsLink(m_xBuilder->weld_link_button(
"moredictslink"))
1554 , m_xClosePB(m_xBuilder->weld_button(
"close"))
1555 , m_xLanguageLB(new
SvxLanguageBox(m_xBuilder->weld_combo_box(
"language")))
1580 m_xLanguageLB->SetLanguageList(SvxLanguageListFlags::EMPTY,
false,
false,
true);
1584 for (
Locale const & locale : rLoc)
1600 for (
int i = 0, nEntryCount =
m_xModulesCLB->n_children();
i < nEntryCount; ++
i)
1601 delete weld::fromId<ModuleUserData_Impl*>(
m_xModulesCLB->get_id(
i));
1606 int nCurPos = rBox.get_selected_index();
1610 bool bDisableUp =
true;
1611 bool bDisableDown =
true;
1612 ModuleUserData_Impl*
pData = weld::fromId<ModuleUserData_Impl*>(rBox.get_id(nCurPos));
1615 if (nCurPos < rBox.n_children() - 1)
1617 bDisableDown = weld::fromId<ModuleUserData_Impl*>(rBox.get_id(nCurPos + 1))->IsParent();
1621 bDisableUp = weld::fromId<ModuleUserData_Impl*>(rBox.get_id(nCurPos - 1))->IsParent();
1624 m_xPrioUpPB->set_sensitive(!bDisableUp);
1625 m_xPrioDownPB->set_sensitive(!bDisableDown);
1630 ModuleUserData_Impl*
pData = weld::fromId<ModuleUserData_Impl*>(m_xModulesCLB->get_id(rRowCol.first));
1636 auto nPos = m_xModulesCLB->get_iter_index_in_parent(rRowCol.first);
1637 for (
int i = 0, nEntryCount = m_xModulesCLB->n_children();
i < nEntryCount; ++
i)
1639 pData = weld::fromId<ModuleUserData_Impl*>(m_xModulesCLB->get_id(
i));
1649 LangSelectHdl_Impl(m_xLanguageLB.get());
1655 static Locale aLastLocale;
1665 sal_Int32 nStart = 0, nLocalIndex = 0;
1667 bool bChanged =
false;
1668 for (
int i = 0, nEntryCount =
m_xModulesCLB->n_children();
i < nEntryCount; ++
i)
1670 ModuleUserData_Impl*
pData = weld::fromId<ModuleUserData_Impl*>(
m_xModulesCLB->get_id(
i));
1671 if (
pData->IsParent())
1686 aChange.realloc(nStart);
1687 (*pTable)[ nLang ] = aChange;
1690 nLocalIndex = nStart = 0;
1691 aChange.realloc(nEntryCount);
1696 OUString* pChange = aChange.getArray();
1697 pChange[nStart] =
pData->GetImplName();
1698 bChanged |=
pData->GetIndex() != nLocalIndex ||
1707 aChange.realloc(nStart);
1712 for (
int i = 0, nEntryCount =
m_xModulesCLB->n_children();
i < nEntryCount; ++
i)
1713 delete weld::fromId<ModuleUserData_Impl*>(
m_xModulesCLB->get_id(
i));
1721 ServiceInfo_Impl* pInfo;
1726 ModuleUserData_Impl* pUserData =
new ModuleUserData_Impl(
1736 const OUString *
pName = aNames.getConstArray();
1737 sal_Int32 nNames = aNames.getLength();
1738 sal_Int32 nLocalIndex = 0;
1739 for (
n = 0;
n < nNames; ++
n)
1742 bool bIsSuppLang =
false;
1747 bIsSuppLang = pInfo->xSpell.is() &&
1748 pInfo->xSpell->hasLocale( aCurLocale );
1749 aImplName = pInfo->sSpellImplName;
1751 if (!aImplName.isEmpty() && bIsSuppLang)
1753 OUString aTxt( pInfo->sDisplayName );
1756 const bool bHasLang = rTable.count( eCurLanguage );
1759 SAL_INFO(
"cui.options",
"language entry missing" );
1761 const bool bCheck = bHasLang &&
lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0;
1762 pUserData =
new ModuleUserData_Impl( aImplName,
false,
1777 pUserData =
new ModuleUserData_Impl( OUString(),
true,
false,
TYPE_GRAMMAR, 0 );
1786 pName = aNames.getConstArray();
1787 nNames = aNames.getLength();
1789 for (
n = 0;
n < nNames; ++
n)
1792 bool bIsSuppLang =
false;
1797 bIsSuppLang = pInfo->xGrammar.is() &&
1798 pInfo->xGrammar->hasLocale( aCurLocale );
1799 aImplName = pInfo->sGrammarImplName;
1801 if (!aImplName.isEmpty() && bIsSuppLang)
1803 OUString aTxt( pInfo->sDisplayName );
1806 const bool bHasLang = rTable.count( eCurLanguage );
1809 SAL_INFO(
"cui.options",
"language entry missing" );
1811 const bool bCheck = bHasLang &&
lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0;
1812 pUserData =
new ModuleUserData_Impl( aImplName,
false,
1828 pUserData =
new ModuleUserData_Impl( OUString(),
true,
false,
TYPE_HYPH, 0 );
1837 pName = aNames.getConstArray();
1838 nNames = aNames.getLength();
1840 for (
n = 0;
n < nNames; ++
n)
1843 bool bIsSuppLang =
false;
1848 bIsSuppLang = pInfo->xHyph.is() &&
1849 pInfo->xHyph->hasLocale( aCurLocale );
1850 aImplName = pInfo->sHyphImplName;
1852 if (!aImplName.isEmpty() && bIsSuppLang)
1854 OUString aTxt( pInfo->sDisplayName );
1857 const bool bHasLang = rTable.count( eCurLanguage );
1860 SAL_INFO(
"cui.options",
"language entry missing" );
1862 const bool bCheck = bHasLang &&
lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0;
1863 pUserData =
new ModuleUserData_Impl( aImplName,
false,
1878 pUserData =
new ModuleUserData_Impl( OUString(),
true,
false,
TYPE_THES, 0 );
1887 pName = aNames.getConstArray();
1888 nNames = aNames.getLength();
1890 for (
n = 0;
n < nNames; ++
n)
1893 bool bIsSuppLang =
false;
1898 bIsSuppLang = pInfo->xThes.is() &&
1899 pInfo->xThes->hasLocale( aCurLocale );
1900 aImplName = pInfo->sThesImplName;
1902 if (!aImplName.isEmpty() && bIsSuppLang)
1904 OUString aTxt( pInfo->sDisplayName );
1907 const bool bHasLang = rTable.count( eCurLanguage );
1910 SAL_INFO(
"cui.options",
"language entry missing" );
1912 const bool bCheck = bHasLang &&
lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0;
1913 pUserData =
new ModuleUserData_Impl( aImplName,
false,
1926 aLastLocale = aCurLocale;
1931 bool bUp = m_xPrioUpPB.get() == &rBtn;
1932 int nCurPos = m_xModulesCLB->get_selected_index();
1936 m_xModulesCLB->freeze();
1938 OUString
sId(m_xModulesCLB->get_id(nCurPos));
1939 OUString sStr(m_xModulesCLB->get_text(nCurPos));
1940 bool bIsChecked = m_xModulesCLB->get_toggle(nCurPos);
1942 m_xModulesCLB->remove(nCurPos);
1944 int nDestPos = bUp ? nCurPos - 1 : nCurPos + 1;
1946 m_xModulesCLB->insert_text(nDestPos, sStr);
1947 m_xModulesCLB->set_id(nDestPos,
sId);
1950 m_xModulesCLB->thaw();
1952 m_xModulesCLB->select(nDestPos);
1953 SelectHdl_Impl(*m_xModulesCLB);
1959 LangSelectHdl_Impl(m_xLanguageLB.get());
1965 rLinguData = *pDefaultLinguData;
1966 LangSelectHdl_Impl(
nullptr);
Reference< XExecutableDialog > m_xDialog
const LanguageTag & GetLanguageTag() const
static const AllSettings & GetSettings()
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
INetProtocol GetProtocol() const
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)
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
static css::uno::Reference< css::linguistic2::XSearchableDictionaryList > GetDictionaryList()
static css::uno::Reference< css::linguistic2::XDictionary > GetIgnoreAllList()
static css::uno::Reference< css::linguistic2::XLinguProperties > GetLinguPropertySet()
static LanguageType getConfiguredSystemLanguage()
sal_uInt8 & GetMinTrail()
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
static const SfxPoolItem * GetItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
css::uno::Any GetProperty(std::u16string_view rPropertyName) const
bool SetProperty(std::u16string_view rPropertyName, const css::uno::Any &rValue)
virtual VclPtr< VclAbstractDialog > CreateSvxEditDictionaryDialog(weld::Window *pParent, const OUString &rName)=0
virtual VclPtr< AbstractSvxNewDictionaryDialog > CreateSvxNewDictionaryDialog(weld::Window *pParent)=0
static SvxAbstractDialogFactory * Create()
std::unique_ptr< weld::Button > m_xClosePB
std::unique_ptr< weld::Button > m_xBackPB
std::unique_ptr< SvxLanguageBox > m_xLanguageLB
SvxLinguData_Impl & rLinguData
std::unique_ptr< weld::Button > m_xPrioUpPB
std::unique_ptr< weld::Button > m_xPrioDownPB
std::unique_ptr< weld::LinkButton > m_xMoreDictsLink
std::unique_ptr< weld::TreeView > m_xModulesCLB
void LangSelectHdl_Impl(const SvxLanguageBox *pBox)
SvxEditModulesDlg(weld::Window *pParent, SvxLinguData_Impl &rData)
virtual ~SvxEditModulesDlg() override
std::unique_ptr< SvxLinguData_Impl > pDefaultLinguData
LangImplNameTable aCfgSpellTable
LangImplNameTable aCfgHyphTable
ServiceInfo_Impl * GetInfoByImplName(std::u16string_view rSvcImplName)
uno::Reference< XLinguServiceManager2 > & GetManager()
ServiceInfoArr & GetDisplayServiceArray()
LangImplNameTable & GetSpellTable()
const sal_uInt32 & GetDisplayServiceCount() const
LangImplNameTable & GetHyphTable()
ServiceInfoArr aDisplayServiceArr
static bool AddRemove(Sequence< OUString > &rConfigured, const OUString &rImplName, bool bAdd)
void Reconfigure(std::u16string_view rDisplayName, bool bEnable)
uno::Reference< XLinguServiceManager2 > xLinguSrvcMgr
sal_uInt32 nDisplayServices
LangImplNameTable & GetGrammarTable()
LangImplNameTable aCfgThesTable
void SetDisplayServiceCount(sal_uInt32 nVal)
LangImplNameTable aCfgGrammarTable
Sequence< Locale > aAllServiceLocales
const Sequence< Locale > & GetAllSupportedLocales() const
LangImplNameTable & GetThesTable()
void SetChecked(const Sequence< OUString > &rConfiguredServices)
Sequence< OUString > GetSortedImplNames(LanguageType nLang, sal_uInt8 nType)
std::unique_ptr< weld::TreeView > m_xLinguOptionsCLB
std::unique_ptr< weld::Label > m_xLinguDicsFT
int nUPN_HYPH_MIN_TRAILING
int nUPN_HYPH_MIN_WORD_LENGTH
std::unique_ptr< weld::TreeView > m_xLinguDicsCLB
OUString sWordsWithDigits
std::unique_ptr< weld::Label > m_xLinguModulesFT
std::unique_ptr< weld::Button > m_xLinguDicsNewPB
std::unique_ptr< weld::LinkButton > m_xMoreDictsLink
std::unique_ptr< weld::Button > m_xLinguModulesEditPB
css::uno::Reference< css::linguistic2::XLinguProperties > xProp
std::unique_ptr< weld::Button > m_xLinguDicsEditPB
css::uno::Sequence< css::uno::Reference< css::linguistic2::XDictionary > > aDics
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
SvxLinguTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rCoreSet)
std::unique_ptr< weld::TreeView > m_xLinguModulesCLB
css::uno::Reference< css::linguistic2::XDictionaryList > xDicList
static sal_uInt32 GetDicUserData(const css::uno::Reference< css::linguistic2::XDictionary > &rxDic, sal_uInt16 nIdx)
std::unique_ptr< weld::Button > m_xLinguOptionsEditPB
ImplSVEvent * m_nDlbClickEventId
int nUPN_HYPH_MIN_LEADING
virtual bool FillItemSet(SfxItemSet *rSet) override
std::unique_ptr< weld::Button > m_xLinguDicsDelPB
void HideGroups(sal_uInt16 nGrp)
virtual void Reset(const SfxItemSet *rSet) override
void UpdateModulesBox_Impl()
std::unique_ptr< SvxLinguData_Impl > pLinguData
void AddDicBoxEntry(const css::uno::Reference< css::linguistic2::XDictionary > &rxDic, sal_uInt16 nIdx)
virtual ~SvxLinguTabPage() override
std::pair< const TreeIter &, int > iter_col
OUString CuiResId(TranslateId aKey)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
virtual tools::Long GetValue() const override
#define LANGUAGE_DONTKNOW
constexpr OUStringLiteral UPN_IS_GRAMMAR_AUTO
#define UPH_ACTIVE_DICTIONARIES
constexpr OUStringLiteral UPN_IS_SPELL_AUTO
constexpr OUStringLiteral UPN_IS_HYPH_AUTO
constexpr OUStringLiteral UPN_IS_SPELL_UPPER_CASE
constexpr OUStringLiteral UPN_HYPH_MIN_WORD_LENGTH
constexpr OUStringLiteral UPN_HYPH_MIN_LEADING
constexpr OUStringLiteral UPN_IS_SPELL_WITH_DIGITS
constexpr OUStringLiteral UPN_IS_HYPH_SPECIAL
constexpr OUStringLiteral UPN_HYPH_MIN_TRAILING
constexpr OUStringLiteral UPN_IS_SPELL_SPECIAL
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::unique_ptr< sal_Int32[]> pData
const ContentProperties & rData
constexpr OUStringLiteral aData
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
Reference< XComponentContext > getProcessComponentContext()
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
OUString toId(const void *pValue)
IMPL_STATIC_LINK_NOARG(SvxLinguTabPage, OnLinkClick, weld::LinkButton &, bool)
static void lcl_MergeDisplayArray(SvxLinguData_Impl &rData, const ServiceInfo_Impl &rToAdd)
constexpr OUStringLiteral cHyph(SN_HYPHENATOR)
constexpr OUStringLiteral cGrammar(SN_GRAMMARCHECKER)
static sal_Int32 lcl_SeqGetIndex(const Sequence< OUString > &rSeq, std::u16string_view rTxt)
std::vector< ServiceInfo_Impl > ServiceInfoArr
IMPL_LINK_NOARG(SvxLinguTabPage, PostDblClickHdl_Impl, void *, void)
static bool KillFile_Impl(const OUString &rURL)
static void lcl_MergeLocales(Sequence< Locale > &aAllLocales, const Sequence< Locale > &rAdd)
IMPL_LINK(SvxLinguTabPage, BoxDoubleClickHdl_Impl, weld::TreeView &, rBox, bool)
static OUString lcl_GetPropertyName(EID_OPTIONS eEntryId)
constexpr OUStringLiteral cSpell(SN_SPELLCHECKER)
constexpr OUStringLiteral cThes(SN_THESAURUS)
static sal_Int32 lcl_SeqGetEntryPos(const Sequence< OUString > &rSeq, std::u16string_view rEntry)
std::map< LanguageType, Sequence< OUString > > LangImplNameTable