/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include #include #include #include #include using namespace osl; using namespace com::sun::star; using namespace com::sun::star::beans; using namespace com::sun::star::lang; using namespace com::sun::star::uno; using namespace com::sun::star::linguistic2; namespace linguistic { #define MAX_PROPOSALS 40 static bool SeqHasEntry( const std::vector< OUString > &rSeq, const OUString &rTxt) { bool bRes = false; sal_Int32 nLen = rSeq.size(); for (sal_Int32 i = 0; i < nLen && !bRes; ++i) { if (rTxt == rSeq[i]) bRes = true; } return bRes; } void SearchSimilarText( const OUString &rText, LanguageType nLanguage, Reference< XSearchableDictionaryList > const &xDicList, std::vector< OUString > & rDicListProps ) { if (!xDicList.is()) return; const uno::Sequence< Reference< XDictionary > > aDics( xDicList->getDictionaries() ); const Reference< XDictionary > *pDic = aDics.getConstArray(); sal_Int32 nDics = xDicList->getCount(); for (sal_Int32 i = 0; i < nDics; i++) { Reference< XDictionary > xDic = pDic[i]; LanguageType nLang = LinguLocaleToLanguage( xDic->getLocale() ); if ( xDic.is() && xDic->isActive() && (nLang == nLanguage || LinguIsUnspecified( nLang)) ) { #if OSL_DEBUG_LEVEL > 0 DictionaryType eType = xDic->getDictionaryType(); (void) eType; assert( eType != DictionaryType_MIXED && "unexpected dictionary type" ); #endif const Sequence< Reference< XDictionaryEntry > > aEntries = xDic->getEntries(); for (const Reference& rEntry : aEntries) { OUString aEntryTxt; if (rEntry.is()) { // remove characters used to determine hyphenation positions aEntryTxt = rEntry->getDictionaryWord().replaceAll("=", ""); } if (!aEntryTxt.isEmpty() && aEntryTxt.getLength() > 1 && LevDistance( rText, aEntryTxt ) <= 2) rDicListProps.push_back( aEntryTxt ); } } } } void SeqRemoveNegEntries( std::vector< OUString > &rSeq, Reference< XSearchableDictionaryList > const &rxDicList, LanguageType nLanguage ) { bool bSthRemoved = false; sal_Int32 nLen = rSeq.size(); for (sal_Int32 i = 0; i < nLen; ++i) { Reference< XDictionaryEntry > xNegEntry( SearchDicList( rxDicList, rSeq[i], nLanguage, false, true ) ); if (xNegEntry.is()) { rSeq[i].clear(); bSthRemoved = true; } } if (bSthRemoved) { std::vector< OUString > aNew; // merge sequence without duplicates and empty strings in new empty sequence rSeq = MergeProposalSeqs( aNew, rSeq ); } } std::vector< OUString > MergeProposalSeqs( std::vector< OUString > &rAlt1, std::vector< OUString > &rAlt2 ) { std::vector< OUString > aMerged; size_t nAltCount1 = rAlt1.size(); size_t nAltCount2 = rAlt2.size(); sal_Int32 nCountNew = std::min( nAltCount1 + nAltCount2, sal_Int32(MAX_PROPOSALS) ); aMerged.resize( nCountNew ); sal_Int32 nIndex = 0; sal_Int32 i = 0; for (int j = 0; j < 2; j++) { sal_Int32 nCount = j == 0 ? nAltCount1 : nAltCount2; std::vector< OUString >& rAlt = j == 0 ? rAlt1 : rAlt2; for (i = 0; i < nCount && nIndex < MAX_PROPOSALS; i++) { if (!rAlt[i].isEmpty() && !SeqHasEntry(aMerged, rAlt[i] )) aMerged[ nIndex++ ] = rAlt[ i ]; } } aMerged.resize( nIndex ); return aMerged; } SpellAlternatives::SpellAlternatives() { nLanguage = LANGUAGE_NONE; nType = SpellFailure::IS_NEGATIVE_WORD; } SpellAlternatives::SpellAlternatives( const OUString &rWord, LanguageType nLang, const Sequence< OUString > &rAlternatives ) : aAlt (rAlternatives), aWord (rWord), nType (SpellFailure::IS_NEGATIVE_WORD), nLanguage (nLang) { } SpellAlternatives::~SpellAlternatives() { } OUString SAL_CALL SpellAlternatives::getWord() { MutexGuard aGuard( GetLinguMutex() ); return aWord; } Locale SAL_CALL SpellAlternatives::getLocale() { MutexGuard aGuard( GetLinguMutex() ); return LanguageTag::convertToLocale( nLanguage ); } sal_Int16 SAL_CALL SpellAlternatives::getFailureType() { MutexGuard aGuard( GetLinguMutex() ); return nType; } sal_Int16 SAL_CALL SpellAlternatives::getAlternativesCount() { MutexGuard aGuard( GetLinguMutex() ); return static_cast(aAlt.getLength()); } Sequence< OUString > SAL_CALL SpellAlternatives::getAlternatives() { MutexGuard aGuard( GetLinguMutex() ); return aAlt; } void SAL_CALL SpellAlternatives::setAlternatives( const uno::Sequence< OUString >& rAlternatives ) { MutexGuard aGuard( GetLinguMutex() ); aAlt = rAlternatives; } void SAL_CALL SpellAlternatives::setFailureType( sal_Int16 nFailureType ) { MutexGuard aGuard( GetLinguMutex() ); nType = nFailureType; } void SpellAlternatives::SetWordLanguage(const OUString &rWord, LanguageType nLang) { MutexGuard aGuard( GetLinguMutex() ); aWord = rWord; nLanguage = nLang; } void SpellAlternatives::SetFailureType(sal_Int16 nTypeP) { MutexGuard aGuard( GetLinguMutex() ); nType = nTypeP; } void SpellAlternatives::SetAlternatives( const Sequence< OUString > &rAlt ) { MutexGuard aGuard( GetLinguMutex() ); aAlt = rAlt; } css::uno::Reference < css::linguistic2::XSpellAlternatives > SpellAlternatives::CreateSpellAlternatives( const OUString &rWord, LanguageType nLang, sal_Int16 nTypeP, const css::uno::Sequence< OUString > &rAlt ) { SpellAlternatives* pAlt = new SpellAlternatives; pAlt->SetWordLanguage( rWord, nLang ); pAlt->SetFailureType( nTypeP ); pAlt->SetAlternatives( rAlt ); return Reference < XSpellAlternatives >(pAlt); } } // namespace linguistic /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ option value='distro/mimo/mimo-6-2'>distro/mimo/mimo-6-2 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-02-16Resolves: tdf#105229 restart in normal mode instead of quittingKatarina Behrens
Change-Id: I546629656ada6c7a8a15b4dc77a042e1f1106924 Reviewed-on: https://gerrit.libreoffice.org/33059 Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de> Tested-by: Katarina Behrens <Katarina.Behrens@cib.de> (cherry picked from commit 29b13a24cf5f0e6e58641d4a55cdfa03c83b68ac) Reviewed-on: https://gerrit.libreoffice.org/34096 Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2016-12-06SafeModeDialog: Rename widget to match labelSamuel Mehrbrodt
Change-Id: I6bb02527fa77846343e55ff73497d1b46b5e1ba8 Reviewed-on: https://gerrit.libreoffice.org/31699 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> (cherry picked from commit 6ce819eefe8dab8ba38bda160e45ccc4220c40f3) Reviewed-on: https://gerrit.libreoffice.org/31704
2016-12-06SafeModeDialog: Add option to reset bundled extension registrationSamuel Mehrbrodt
Change-Id: Ic83ada7cc76142852643cefa60b4fc9286e0756a Reviewed-on: https://gerrit.libreoffice.org/31694 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> (cherry picked from commit 4a4c4d3768eab66c14e9e444e33bca0acb60981e) Reviewed-on: https://gerrit.libreoffice.org/31703
2016-12-06SafeModeDialog: Rename to match realitySamuel Mehrbrodt
This doesn't remove shared&bundled extensions, but resets the registration database from shared extensions. Change-Id: I9f198fc7b771fd3bd31547008fd8d006a6d1b5d5 Reviewed-on: https://gerrit.libreoffice.org/31693 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> (cherry picked from commit a3597a3f370175d0c06887e6691cbfa045937ad4) Reviewed-on: https://gerrit.libreoffice.org/31702
2016-11-03SafeModeDialog: Better grouping of optionsSamuel Mehrbrodt
Disable/Deinstall extensions are mutually exclusive, so group them appropriately Change-Id: I6dc9c53ef4c18103c7521d494a769d522b0412dd Reviewed-on: https://gerrit.libreoffice.org/30522 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2016-11-03SafeModeDialog: Fix enabling/disabling of widgetsSamuel Mehrbrodt
Change-Id: I7133b64f975fa8e68550d41056b689dfc18cf172 Reviewed-on: https://gerrit.libreoffice.org/30520 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2016-11-03SafeModeDialog: Allow to create zip file from profileSamuel Mehrbrodt
Change-Id: I4296d1cf5058be359ffed46745673cf26eba3375 Reviewed-on: https://gerrit.libreoffice.org/30479 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2016-11-01SafeModeDialog: Group optionsSamuel Mehrbrodt
Change-Id: Ife0903c90f17efb2a1c6681ece8dd9af257873cd Reviewed-on: https://gerrit.libreoffice.org/30453 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2016-11-01SafeModeDialog: Add link to user profileSamuel Mehrbrodt
Change-Id: I0096b3d7db51e28eb58c7209109c30b73b382478 Reviewed-on: https://gerrit.libreoffice.org/30448 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2016-11-01safemode: Add option to disable H/W accelerationSamuel Mehrbrodt
Change-Id: Ic6751717c14d317b5a4bc64c4fd1cf2b2f5efabf Reviewed-on: https://gerrit.libreoffice.org/30112 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2016-10-21profilesafe: Added more specific optionsArmin Le Grand
For Extensions there is the possibility to not only decide enable/disable state for User ones, but also to deinstall user or all extensions, added these options to the dialog and the functionality. Also unified customization name schema to have just one source of strings to avoid errors in the future. Small fix in tryPop_extensionInfo Change-Id: I39acbe9a052ffd4cb78b496f24e5b583136c565a Reviewed-on: https://gerrit.libreoffice.org/30100 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
2016-10-20Handle link click directly in FixedHyperlinkSamuel Mehrbrodt
Change-Id: I5b5f0648b6e6432b0928351a17d285df8c9da811
2016-10-18Fix: Quit in SafeModeDialog didn't work properlySamuel Mehrbrodt
Change-Id: I4c093ff02457040ee3752ef6ae4b63cbe5bb3863 Reviewed-on: https://gerrit.libreoffice.org/30006 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2016-10-17safemode: Add hints how to get help/report a bugSamuel Mehrbrodt
Change-Id: Ie65e9706017f5f56fa4c453aa3fdb117b201096e Reviewed-on: https://gerrit.libreoffice.org/29961 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2016-10-14profilesafe: Adapted to UIArmin Le Grand
Adaptions to UI, added more modes what the user can do in SafeMode. Adapted locations to write pack information and added places where to enter SafeMode. Implemented basically all five possible user choices Change-Id: Ic5324a8f77ab434309e840949c3803e65a75c538 Reviewed-on: https://gerrit.libreoffice.org/29785 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
2016-10-12SafeModeDialog: Enable restart button only for active selectionsSamuel Mehrbrodt
Change-Id: Ic5c9d1a0001e8324aa007c3f7bc0e58e13afbbbf
2016-10-12SafeModeDialog: Handle restart button eventSamuel Mehrbrodt
Change-Id: I6b55f79ea153aaeb8b67879bdafb6774fd91455c
2016-10-12SafeModeDialog: Handle quit button eventSamuel Mehrbrodt
Change-Id: Id24e9cb526bc0143a663e8d39a5dda59f929f8bf
2016-10-12Delete the safemode flag when closing the dialogSamuel Mehrbrodt
Change-Id: I7131849cc417155b55425eba1494992f7d07fa0b
2016-10-10Show dialog when starting in safe modeSamuel Mehrbrodt
Change-Id: Ie4b5f5b7309735dfa844bbaba9cb2763a3de3dc1