Files
libreoffice/svx/source/options/optlingu.cxx

2026 lines
70 KiB
C++
Raw Normal View History

2000-09-18 16:07:07 +00:00
/*************************************************************************
*
* $RCSfile: optlingu.cxx,v $
*
2001-03-28 11:58:59 +00:00
* $Revision: 1.25 $
2000-09-18 16:07:07 +00:00
*
2001-03-28 11:58:59 +00:00
* last change: $Author: jp $ $Date: 2001-03-28 12:58:59 $
2000-09-18 16:07:07 +00:00
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (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.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#pragma hdrstop
// include ---------------------------------------------------------------
#define _SVSTDARR_STRINGSDTOR
#define _SVSTDARR_USHORTS
#ifndef _SVSTDARR_HXX
#include <svtools/svstdarr.hxx>
#endif
2000-09-18 16:07:07 +00:00
#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SV_FIELD_HXX
#include <vcl/field.hxx>
#endif
2001-03-28 11:58:59 +00:00
#ifndef _SV_FIXED_HXX
#include <vcl/fixed.hxx>
#endif
2000-09-18 16:07:07 +00:00
#ifndef _SHL_HXX
#include <tools/shl.hxx>
#endif
#ifndef _SVARRAY_HXX //autogen
#include <svtools/svarray.hxx>
#endif
#ifndef _SVTOOLS_LINGUCFG_HXX_
#include <svtools/lingucfg.hxx>
#endif
2000-09-18 16:07:07 +00:00
#ifndef _UNO_LINGU_HXX
#include <unolingu.hxx>
#endif
#ifndef _SVX_DLGUTIL_HXX
#include <dlgutil.hxx>
#endif
2000-11-27 19:41:26 +00:00
#ifndef _LINGUISTIC_LNGPROPS_HHX_
#include <linguistic/lngprops.hxx>
#endif
#ifndef _UNO_LINGU_HXX
#include <svx/unolingu.hxx>
#endif
2000-09-18 16:07:07 +00:00
#ifndef _SFX_SFXUNO_HXX
#include <sfx2/sfxuno.hxx>
#endif
#ifndef _SFXDISPATCH_HXX
#include <sfx2/dispatch.hxx>
#endif
#ifndef _URLOBJ_HXX
#include <tools/urlobj.hxx>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif
#ifndef _COM_SUN_STAR_LINGUISTIC2_XSPELLCHECKER_HPP_
#include <com/sun/star/linguistic2/XSpellChecker.hpp>
#endif
#ifndef _COM_SUN_STAR_LINGUISTIC2_XHYPHENATOR_HPP_
#include <com/sun/star/linguistic2/XHyphenator.hpp>
#endif
#ifndef _COM_SUN_STAR_LINGUISTIC2_XTHESAURUS_HPP_
#include <com/sun/star/linguistic2/XThesaurus.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEDISPLAYNAME_HPP_
#include <com/sun/star/lang/XServiceDisplayName.hpp>
#endif
2000-10-27 09:45:26 +00:00
#ifndef _COM_SUN_STAR_LINGUISTIC2_DICTIONARYLISTEVENTFLAGS_HPP_
#include <com/sun/star/linguistic2/DictionaryListEventFlags.hpp>
2000-09-18 16:07:07 +00:00
#endif
2000-10-27 09:45:26 +00:00
#ifndef _COM_SUN_STAR_LINGUISTIC2_DICTIONARYLISTEVENT_HPP_
#include <com/sun/star/linguistic2/DictionaryListEvent.hpp>
2000-09-18 16:07:07 +00:00
#endif
2000-10-27 09:45:26 +00:00
#ifndef _COM_SUN_STAR_LINGUISTIC2_XDICTIONARYLISTEVENTLISTENER_HPP_
#include <com/sun/star/linguistic2/XDictionaryListEventListener.hpp>
2000-09-18 16:07:07 +00:00
#endif
2000-10-27 09:45:26 +00:00
#ifndef _COM_SUN_STAR_LINGUISTIC2_XDICTIONARYLIST_HPP_
#include <com/sun/star/linguistic2/XDictionaryList.hpp>
2000-09-18 16:07:07 +00:00
#endif
2000-10-27 09:45:26 +00:00
#ifndef _COM_SUN_STAR_LINGUISTIC2_XOTHERLINGU_HPP_
#include <com/sun/star/linguistic2/XOtherLingu.hpp>
2000-09-18 16:07:07 +00:00
#endif
#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_
#include <com/sun/star/frame/XStorable.hpp>
#endif
#ifndef _COM_SUN_STAR_UCB_COMMANDABORTEDEXCEPTION_HPP_
#include <com/sun/star/ucb/CommandAbortedException.hpp>
#endif
#ifndef _SVLBOX_HXX
#include <svtools/svlbox.hxx>
#endif
2000-09-18 16:07:07 +00:00
#ifndef _SFXENUMITEM_HXX //autogen
#include <svtools/eitem.hxx>
#endif
#ifndef _SFXINTITEM_HXX //autogen
#include <svtools/intitem.hxx>
#endif
#include <sfx2/viewfrm.hxx>
#define _SVX_OPTLINGU_CXX
#include "optlingu.hrc"
#define ITEMID_SPELLCHECK 0
#define ITEMID_HYPHENREGION 0
#include "optdict.hxx"
#include "optitems.hxx"
#include "optlingu.hxx"
#include "dialmgr.hxx"
#include "dialogs.hrc"
#include "helpid.hrc"
#include <ucbhelper/content.hxx>
using namespace ::ucb;
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
2000-09-18 16:07:07 +00:00
using namespace ::com::sun::star::uno;
2000-10-27 09:45:26 +00:00
using namespace ::com::sun::star::linguistic2;
2000-09-18 16:07:07 +00:00
using namespace ::com::sun::star::beans;
#define C2U(cChar) OUString::createFromAscii(cChar)
#define SVX_MAX_USERDICTS 20
#define CBCOL_FIRST 0
#define CBCOL_SECOND 1
#define CBCOL_BOTH 2
static const sal_Char cSpell[] = "com.sun.star.linguistic2.SpellChecker";
static const sal_Char cHyph[] = "com.sun.star.linguistic2.Hyphenator";
static const sal_Char cThes[] = "com.sun.star.linguistic2.Thesaurus";
2000-09-18 16:07:07 +00:00
// static ----------------------------------------------------------------
2001-01-18 14:19:25 +00:00
static BOOL lcl_SeqHasEntry(
const Sequence< OUString > &rSeq, const OUString &rEntry )
{
INT32 i;
INT32 nLen = rSeq.getLength();
const OUString *pItem = rSeq.getConstArray();
for (i = 0; i < nLen; ++i)
{
if (rEntry == pItem[i])
break;
}
return i < nLen ? TRUE : FALSE;
}
/*--------------------------------------------------
--------------------------------------------------*/
2000-09-18 16:07:07 +00:00
static const sal_uInt16 nNameLen = 8;
static sal_uInt16 pRanges[] =
{
SID_ATTR_SPELL,
SID_ATTR_SPELL,
0
};
sal_Bool KillFile_Impl( const String& rURL )
{
sal_Bool bRet = sal_True;
try
{
Content aCnt( rURL, Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
aCnt.executeCommand( OUString::createFromAscii( "delete" ), makeAny( sal_Bool( sal_True ) ) );
}
catch( ::com::sun::star::ucb::CommandAbortedException& )
{
DBG_ERRORFILE( "KillFile: CommandAbortedException" );
bRet = sal_False;
}
catch( ... )
{
DBG_ERRORFILE( "KillFile: Any other exception" );
bRet = sal_False;
}
return bRet;
}
2000-11-27 19:41:26 +00:00
/* -----------------------------27.11.00 14:07--------------------------------
---------------------------------------------------------------------------*/
// 0x 0p 0t 0c nn
// p: 1 -> parent
// t: 1 -> spell, 2 -> hyph, 3 -> thes
// c: 1 -> checked 0 -> unchecked
// n: index
#define TYPE_SPELL 1
#define TYPE_HYPH 2
#define TYPE_THES 3
class ModuleUserData_Impl
{
2000-11-28 01:36:08 +00:00
BOOL bParent;
BOOL bIsChecked;
BYTE nType;
BYTE nIndex;
2000-11-27 19:41:26 +00:00
String sImplName;
2000-11-27 19:41:26 +00:00
public:
2000-11-28 01:36:08 +00:00
ModuleUserData_Impl( String sImpName, BOOL bIsParent, BOOL bChecked, BYTE nSetType, BYTE nSetIndex ) :
bParent(bIsParent),
bIsChecked(bChecked),
nType(nSetType),
nIndex(nSetIndex),
2000-11-27 19:41:26 +00:00
sImplName(sImpName)
{
}
2000-11-28 01:36:08 +00:00
BOOL IsParent() const {return bParent;}
BYTE GetType() const {return nType;}
BOOL IsChecked() const {return bIsChecked;}
BYTE GetIndex() const {return nIndex;}
void SetIndex(BYTE nSet) {nIndex = nSet;}
const String& GetImplName() const {return sImplName;}
2000-11-27 19:41:26 +00:00
};
2000-11-27 19:41:26 +00:00
/*--------------------------------------------------
--------------------------------------------------*/
class DicUserData
{
ULONG nVal;
public:
DicUserData( ULONG nUserData ) : nVal( nUserData ) {}
DicUserData( USHORT nEID,
BOOL bChecked, BOOL bEditable, BOOL bDeletable );
ULONG GetUserData() const { return nVal; }
USHORT GetEntryId() const { return (USHORT)(nVal >> 16); }
BOOL IsChecked() const { return (BOOL)(nVal >> 8) & 0x01; }
BOOL IsEditable() const { return (BOOL)(nVal >> 9) & 0x01; }
BOOL IsDeletable() const { return (BOOL)(nVal >> 10) & 0x01; }
void SetChecked( BOOL bVal );
};
DicUserData::DicUserData(
USHORT nEID,
BOOL bChecked, BOOL bEditable, BOOL bDeletable )
{
DBG_ASSERT( nEID < 65000, "Entry Id out of range" );
nVal = ((ULONG)(0xFFFF & nEID) << 16) |
((ULONG)(bChecked ? 1 : 0) << 8) |
((ULONG)(bEditable ? 1 : 0) << 9) |
((ULONG)(bDeletable ? 1 : 0) << 10);
}
void DicUserData::SetChecked( BOOL bVal )
{
nVal &= ~(1UL << 8);
nVal |= (ULONG)(bVal ? 1 : 0) << 8;
}
// class BrwString_Impl -------------------------------------------------
void lcl_SetCheckButton( SvLBoxEntry* pEntry, BOOL bCheck )
{
SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
DBG_ASSERT(pItem,"SetCheckButton:Item not found")
if (((SvLBoxItem*)pItem)->IsA() == SV_ITEM_ID_LBOXBUTTON)
{
if (bCheck)
pItem->SetStateChecked();
else
pItem->SetStateUnchecked();
//InvalidateEntry( pEntry );
}
}
class BrwStringDic_Impl : public SvLBoxString
{
public:
BrwStringDic_Impl( SvLBoxEntry* pEntry, USHORT nFlags,
const String& rStr ) : SvLBoxString( pEntry, nFlags, rStr ) {}
virtual void Paint( const Point& rPos, SvLBox& rDev, USHORT nFlags,
SvLBoxEntry* pEntry);
};
void BrwStringDic_Impl::Paint( const Point& rPos, SvLBox& rDev, USHORT nFlags,
SvLBoxEntry* pEntry )
{
2000-11-27 19:41:26 +00:00
ModuleUserData_Impl* pData = (ModuleUserData_Impl*)pEntry->GetUserData();
Point aPos(rPos);
2000-11-27 19:41:26 +00:00
Font aOldFont( rDev.GetFont());
if(pData->IsParent())
{
Font aFont( aOldFont );
aFont.SetWeight( WEIGHT_BOLD );
rDev.SetFont( aFont );
aPos.X() = 0;
}
else
aPos.X() += 5;
rDev.DrawText( aPos, GetText() );
2000-11-27 19:41:26 +00:00
rDev.SetFont( aOldFont );
}
2000-11-27 19:41:26 +00:00
/*--------------------------------------------------
--------------------------------------------------*/
2000-11-27 19:41:26 +00:00
class OptionsBreakSet : public ModalDialog
{
2000-11-27 19:41:26 +00:00
OKButton aOKPB;
CancelButton aCancelPB;
2001-03-28 11:58:59 +00:00
FixedLine aValGB;
2000-11-27 19:41:26 +00:00
NumericField aValNF;
2000-11-27 19:41:26 +00:00
public:
2000-12-07 08:15:28 +00:00
OptionsBreakSet(Window* pParent, int nRID) :
2000-11-27 19:41:26 +00:00
ModalDialog(pParent, ResId(RID_SVXDLG_LNG_ED_NUM_PREBREAK, DIALOG_MGR() )),
aOKPB (this, ResId(BT_OK_PREBREAK)),
aCancelPB (this, ResId(BT_CANCEL_PREBREAK)),
aValGB (this, ResId(GB_NUMVAL_PREBREAK)),
aValNF (this, ResId(ED_PREBREAK))
{
2000-12-07 08:15:28 +00:00
DBG_ASSERT( STR_NUM_PRE_BREAK_DLG == nRID ||
STR_NUM_POST_BREAK_DLG == nRID ||
STR_NUM_MIN_WORDLEN_DLG == nRID, "unexpected RID" );
if (nRID != -1)
aValGB.SetText( String( ResId(nRID) ) );
2000-11-27 19:41:26 +00:00
FreeResource();
}
2000-11-27 19:41:26 +00:00
NumericField& GetNumericFld() { return aValNF; }
};
2000-11-27 19:41:26 +00:00
/*--------------------------------------------------
Entry IDs for options listbox of dialog
--------------------------------------------------*/
2000-11-27 19:41:26 +00:00
enum EID_OPTIONS
{
2000-11-27 19:41:26 +00:00
EID_CAPITAL_WORDS,
EID_WORDS_WITH_DIGITS,
EID_CAPITALIZATION,
EID_SPELL_SPECIAL,
EID_ALL_LANGUAGES,
EID_SPELL_AUTO,
EID_HIDE_MARKINGS,
EID_OLD_GERMAN,
2000-12-07 08:15:28 +00:00
EID_NUM_MIN_WORDLEN,
2000-11-27 19:41:26 +00:00
EID_NUM_PRE_BREAK,
EID_NUM_POST_BREAK,
EID_HYPH_AUTO,
EID_HYPH_SPECIAL
};
2000-11-27 19:41:26 +00:00
//! this array must have an entry for every value of EID_OPTIONS.
// It is used to get the respective property name.
static const char * aEidToPropName[] =
{
"IsSpellUpperCase", // EID_CAPITAL_WORDS
"IsSpellWithDigits", // EID_WORDS_WITH_DIGITS
"IsSpellCapitalization", // EID_CAPITALIZATION
"IsSpellSpecial", // EID_SPELL_SPECIAL
"IsSpellInAllLanguages", // EID_ALL_LANGUAGES
"IsSpellAuto", // EID_SPELL_AUTO
"IsSpellHide", // EID_HIDE_MARKINGS
"IsGermanPreReform", // EID_OLD_GERMAN
2000-12-07 08:15:28 +00:00
"HyphMinWordLength", // EID_NUM_MIN_WORDLEN,
2000-11-27 19:41:26 +00:00
"HyphMinLeading", // EID_NUM_PRE_BREAK
"HyphMinTrailing", // EID_NUM_POST_BREAK
"IsHyphAuto", // EID_HYPH_AUTO
"IsHyphSpecial" // EID_HYPH_SPECIAL
};
2000-11-27 19:41:26 +00:00
static inline String lcl_GetPropertyName( EID_OPTIONS eEntryId )
{
DBG_ASSERT( (int) eEntryId < sizeof(aEidToPropName) / sizeof(aEidToPropName[0]),
"index out of range" );
return String::CreateFromAscii( aEidToPropName[ (int) eEntryId ] );
}
2000-11-27 19:41:26 +00:00
// class OptionsUserData -------------------------------------------------
class OptionsUserData
{
2000-11-27 19:41:26 +00:00
ULONG nVal;
2000-11-27 19:41:26 +00:00
void SetModified();
2000-11-27 19:41:26 +00:00
public:
OptionsUserData( ULONG nUserData ) : nVal( nUserData ) {}
OptionsUserData( USHORT nEID,
BOOL bHasNV, USHORT nNumVal,
BOOL bCheckable, BOOL bChecked );
2000-11-27 19:41:26 +00:00
ULONG GetUserData() const { return nVal; }
USHORT GetEntryId() const { return (USHORT)(nVal >> 16); }
BOOL HasNumericValue() const { return (BOOL)(nVal >> 10) & 0x01; }
USHORT GetNumericValue() const { return (USHORT)(nVal & 0xFF); }
BOOL IsChecked() const { return (BOOL)(nVal >> 8) & 0x01; }
BOOL IsCheckable() const { return (BOOL)(nVal >> 9) & 0x01; }
BOOL IsModified() const { return (BOOL)(nVal >> 11) & 0x01; }
2000-11-27 19:41:26 +00:00
void SetChecked( BOOL bVal );
void SetNumericValue( BYTE nNumVal );
};
2000-11-27 19:41:26 +00:00
OptionsUserData::OptionsUserData( USHORT nEID,
BOOL bHasNV, USHORT nNumVal,
BOOL bCheckable, BOOL bChecked )
{
DBG_ASSERT( nEID < 65000, "Entry Id out of range" );
DBG_ASSERT( nNumVal < 256, "value out of range" );
nVal = ((ULONG)(0xFFFF & nEID) << 16) |
((ULONG)(bHasNV ? 1 : 0) << 10) |
((ULONG)(bCheckable ? 1 : 0) << 9) |
((ULONG)(bChecked ? 1 : 0) << 8) |
((ULONG)(0xFF & nNumVal));
}
2000-11-27 19:41:26 +00:00
void OptionsUserData::SetChecked( BOOL bVal )
{
if (IsCheckable() && (IsChecked() != bVal))
{
2000-11-27 19:41:26 +00:00
nVal &= ~(1UL << 8);
nVal |= (ULONG)(bVal ? 1 : 0) << 8;
SetModified();
}
2000-11-27 19:41:26 +00:00
}
void OptionsUserData::SetNumericValue( BYTE nNumVal )
{
DBG_ASSERT( nNumVal < 256, "value out of range" );
if (HasNumericValue() && (GetNumericValue() != nNumVal))
{
2000-11-27 19:41:26 +00:00
nVal &= 0xffffff00;
nVal |= (nNumVal);
SetModified();
}
2000-11-27 19:41:26 +00:00
}
2000-11-27 19:41:26 +00:00
void OptionsUserData::SetModified()
{
nVal |= (ULONG)1 << 11;
}
2000-11-27 19:41:26 +00:00
// class BrwString_Impl -------------------------------------------------
2000-09-18 16:07:07 +00:00
2000-11-27 19:41:26 +00:00
class BrwString_Impl : public SvLBoxString
{
2000-11-27 19:41:26 +00:00
public:
2000-11-27 19:41:26 +00:00
BrwString_Impl( SvLBoxEntry* pEntry, USHORT nFlags,
const String& rStr ) : SvLBoxString( pEntry, nFlags, rStr ) {}
2000-11-27 19:41:26 +00:00
virtual void Paint( const Point& rPos, SvLBox& rDev, USHORT nFlags,
SvLBoxEntry* pEntry);
};
2000-11-27 19:41:26 +00:00
void BrwString_Impl::Paint( const Point& rPos, SvLBox& rDev, USHORT nFlags,
SvLBoxEntry* pEntry )
{
2000-11-27 19:41:26 +00:00
Point aPos(rPos);
aPos.X() += 20;
rDev.DrawText( aPos, GetText() );
if(pEntry->GetUserData())
{
2000-11-27 19:41:26 +00:00
Point aNewPos(aPos);
aNewPos.X() += rDev.GetTextWidth(GetText());
Font aOldFont( rDev.GetFont());
Font aFont( aOldFont );
aFont.SetWeight( WEIGHT_BOLD );
2000-11-27 19:41:26 +00:00
BOOL bFett = TRUE;
USHORT nPos = 0;
//??? das untere byte aus dem user data in string wandeln
OptionsUserData aData( (ULONG) pEntry->GetUserData() );
if(aData.HasNumericValue())
{
String sTxt( ' ' );
sTxt += String::CreateFromInt32( aData.GetNumericValue() );
rDev.SetFont( aFont );
rDev.DrawText( aNewPos, sTxt );
}
2000-11-27 19:41:26 +00:00
// if( STRING_NOTFOUND != nPos )
// aNewPos.X() += rDev.GetTextWidth( sTxt );
rDev.SetFont( aOldFont );
}
2000-11-27 19:41:26 +00:00
}
2000-11-27 19:41:26 +00:00
// SvxLinguData_Impl ----------------------------------------------------
2000-11-27 19:41:26 +00:00
struct ServiceInfo_Impl
{
OUString sDisplayName;
OUString sSpellImplName;
OUString sHyphImplName;
OUString sThesImplName;
Sequence <Locale> aSuppLocales;
Reference <XSpellChecker> xSpell;
Reference <XHyphenator> xHyph;
Reference <XThesaurus> xThes;
BOOL bConfigured;
ServiceInfo_Impl() :
bConfigured(sal_False){}
};
2000-11-28 12:03:40 +00:00
typedef ServiceInfo_Impl* ServiceInfo_ImplPtr;
SV_DECL_PTRARR_DEL(ServiceInfoArr, ServiceInfo_ImplPtr, 2, 2);
2000-11-27 19:41:26 +00:00
SV_IMPL_PTRARR(ServiceInfoArr, ServiceInfo_Impl*);
class SvxLinguData_Impl
{
Reference< XMultiServiceFactory > xMSF;
Reference<XLinguServiceManager> xLinguSrvcMgr;
ServiceInfoArr aAvailSpellInfoArr;
ServiceInfoArr aAvailHyphInfoArr;
ServiceInfoArr aAvailThesInfoArr;
Sequence<OUString> aAvailSrvcDisplayNames;
Sequence<OUString> aAvailSrvcNames;
// Sequence<sal_Bool> aAvailSrvcConfigured;
Sequence<Locale> aAllServiceLocales;
//contains services an implementation names sorted by implementation names
ServiceInfoArr aDisplayServiceArr;
public:
SvxLinguData_Impl();
~SvxLinguData_Impl();
Reference<XLinguServiceManager>& GetManager() {return xLinguSrvcMgr;}
void AddServiceName(const ServiceInfo_Impl*);
void SetChecked(const Sequence<OUString>& rConfiguredServices);
void Reconfigure(const Sequence<OUString>& aRemove, const Sequence<OUString>& aInsert);
const Sequence<OUString>& GetAvailSrvcDisplayNames(){return aAvailSrvcDisplayNames;}
const Sequence<OUString>& GetAvailSrvcNames() {return aAvailSrvcNames;}
// const Sequence<sal_Bool>& GetAvailSrvcConfigured(){return aAvailSrvcConfigured;}
const Sequence<Locale>& GetAllSupportedLocales(){return aAllServiceLocales;}
const ServiceInfoArr& GetDisplayServiceArray() const {return aDisplayServiceArr;}
};
//-----------------------------------------------------------------------------
void lcl_MergeLocales(Sequence<Locale>& aAllLocales, const Sequence<Locale>& rAdd)
{
const Locale* pAdd = rAdd.getConstArray();
Sequence<Locale> aLocToAdd(rAdd.getLength());
const Locale* pAllLocales = aAllLocales.getConstArray();
Locale* pLocToAdd = aLocToAdd.getArray();
sal_Int32 nFound = 0;
sal_Int32 i;
for(i = 0; i < rAdd.getLength(); i++)
{
sal_Bool bFound = sal_False;
for(sal_Int32 j = 0; j < aAllLocales.getLength() && !bFound; j++)
{
2000-11-27 19:41:26 +00:00
bFound = pAdd[i].Language == pAllLocales[j].Language &&
pAdd[i].Country == pAllLocales[j].Country;
}
2000-11-27 19:41:26 +00:00
if(!bFound)
{
2000-11-27 19:41:26 +00:00
pLocToAdd[nFound++] = pAdd[i];
}
}
2000-11-27 19:41:26 +00:00
sal_Int32 nLength = aAllLocales.getLength();
aAllLocales.realloc( nLength + nFound);
Locale* pAllLocales2 = aAllLocales.getArray();
for(i = 0; i < nFound; i++)
pAllLocales2[nLength++] = pLocToAdd[i];
}
/* -----------------------------27.11.00 16:48--------------------------------
2000-11-27 19:41:26 +00:00
---------------------------------------------------------------------------*/
void lcl_MergeDisplayArray(ServiceInfoArr& rDisplayServiceArr, const ServiceInfo_Impl* pToAdd)
{
for(int i = 0; i < rDisplayServiceArr.Count(); i++)
{
ServiceInfo_Impl* pEntry = rDisplayServiceArr[i];
if(pEntry->sDisplayName == pToAdd->sDisplayName)
{
2000-11-27 19:41:26 +00:00
if(pToAdd->xSpell.is())
{
2000-11-27 19:41:26 +00:00
pEntry->sSpellImplName = pToAdd->sSpellImplName;
pEntry->xSpell = pToAdd->xSpell;
}
if(pToAdd->xHyph.is())
{
pEntry->sHyphImplName = pToAdd->sHyphImplName;
pEntry->xHyph = pToAdd->xHyph;
}
2000-11-27 19:41:26 +00:00
if(pToAdd->xThes.is())
{
pEntry->sThesImplName = pToAdd->sThesImplName;
pEntry->xThes = pToAdd->xThes;
}
lcl_MergeLocales(pEntry->aSuppLocales, pToAdd->aSuppLocales);
return ;
}
}
2000-11-27 19:41:26 +00:00
ServiceInfo_Impl* pInsert = new ServiceInfo_Impl(*pToAdd);
rDisplayServiceArr.Insert(pInsert, rDisplayServiceArr.Count());
}
2000-11-27 19:41:26 +00:00
/* -----------------------------26.11.00 18:07--------------------------------
2000-11-27 19:41:26 +00:00
---------------------------------------------------------------------------*/
SvxLinguData_Impl::SvxLinguData_Impl()
{
2000-11-27 19:41:26 +00:00
xMSF = ::comphelper::getProcessServiceFactory();
Reference < XInterface > xI = xMSF->createInstance(
C2U( "com.sun.star.linguistic2.LinguServiceManager" ) );
xLinguSrvcMgr = Reference<XLinguServiceManager>(xI, UNO_QUERY);
DBG_ASSERT(xLinguSrvcMgr.is(), "No linguistic service available!")
if(xLinguSrvcMgr.is())
{
2000-11-27 19:41:26 +00:00
Locale aCurrentLocale;
LanguageType eLang = Application::GetAppInternational().GetLanguage();
if(LANGUAGE_SYSTEM == eLang)
{
eLang = GetSystemLanguage();
}
SvxLanguageToLocale(aCurrentLocale, eLang);
Sequence<Any> aArgs(2);//second arguments has to be empty!
aArgs.getArray()[0] <<= SvxGetLinguPropertySet();
2000-11-27 19:41:26 +00:00
//read spell checker
Sequence< OUString > aSpellNames = xLinguSrvcMgr->getAvailableServices(
C2U(cSpell), Locale() );
const OUString* pSpellNames = aSpellNames.getConstArray();
2000-11-27 19:41:26 +00:00
sal_Int32 nIdx;
for(nIdx = 0; nIdx < aSpellNames.getLength(); nIdx++)
{
ServiceInfo_Impl* pInfo = new ServiceInfo_Impl;
pInfo->sSpellImplName = pSpellNames[nIdx];
pInfo->xSpell = Reference<XSpellChecker>(
xMSF->createInstanceWithArguments(pInfo->sSpellImplName, aArgs), UNO_QUERY);
Reference<XServiceDisplayName> xDispName(pInfo->xSpell, UNO_QUERY);
if(xDispName.is())
{
pInfo->sDisplayName = xDispName->getServiceDisplayName(
aCurrentLocale );
pInfo->aSuppLocales = pInfo->xSpell->getLocales();
lcl_MergeLocales(aAllServiceLocales, pInfo->aSuppLocales);
}
2000-11-27 11:25:46 +00:00
2000-11-27 19:41:26 +00:00
aAvailSpellInfoArr.Insert(pInfo, aAvailSpellInfoArr.Count());
2000-11-27 11:25:46 +00:00
2000-11-27 19:41:26 +00:00
AddServiceName(pInfo);
}
2000-11-27 11:25:46 +00:00
2000-11-27 19:41:26 +00:00
//read hyphenator
Sequence< OUString > aHyphNames = xLinguSrvcMgr->getAvailableServices(
C2U(cHyph), Locale() );
const OUString* pHyphNames = aHyphNames.getConstArray();
for(nIdx = 0; nIdx < aHyphNames.getLength(); nIdx++)
{
ServiceInfo_Impl* pInfo = new ServiceInfo_Impl;
pInfo->sHyphImplName = pHyphNames[nIdx];
pInfo->xHyph = Reference<XHyphenator>(
xMSF->createInstanceWithArguments(pInfo->sHyphImplName, aArgs), UNO_QUERY);
Reference<XServiceDisplayName> xDispName(pInfo->xHyph, UNO_QUERY);
if(xDispName.is())
{
pInfo->sDisplayName = xDispName->getServiceDisplayName(
aCurrentLocale );
pInfo->aSuppLocales = pInfo->xHyph->getLocales();
lcl_MergeLocales(aAllServiceLocales, pInfo->aSuppLocales);
}
2000-11-27 19:41:26 +00:00
aAvailHyphInfoArr.Insert(pInfo, aAvailHyphInfoArr.Count());
AddServiceName(pInfo);
}
2000-11-27 19:41:26 +00:00
//read thesauri
Sequence< OUString > aThesNames = xLinguSrvcMgr->getAvailableServices(
C2U(cThes), Locale() );
const OUString* pThesNames = aThesNames.getConstArray();
for(nIdx = 0; nIdx < aThesNames.getLength(); nIdx++)
{
ServiceInfo_Impl* pInfo = new ServiceInfo_Impl;
pInfo->sThesImplName = pThesNames[nIdx];
pInfo->xThes = Reference<XThesaurus>(
xMSF->createInstanceWithArguments(pInfo->sThesImplName, aArgs), UNO_QUERY);
Reference<XServiceDisplayName> xDispName(pInfo->xThes, UNO_QUERY);
if(xDispName.is())
{
pInfo->sDisplayName = xDispName->getServiceDisplayName(
aCurrentLocale );
pInfo->aSuppLocales = pInfo->xThes->getLocales();
//collect all supported locales
lcl_MergeLocales(aAllServiceLocales, pInfo->aSuppLocales);
}
2000-11-27 19:41:26 +00:00
aAvailThesInfoArr.Insert(pInfo, aAvailThesInfoArr.Count());
AddServiceName(pInfo);
}
2000-11-27 19:41:26 +00:00
const Locale* pAllLocales = aAllServiceLocales.getConstArray();
for(sal_Int32 nLocale = 0; nLocale < aAllServiceLocales.getLength(); nLocale++)
{
SetChecked(xLinguSrvcMgr->getConfiguredServices(C2U(cSpell), pAllLocales[nLocale]));
SetChecked(xLinguSrvcMgr->getConfiguredServices(C2U(cHyph), pAllLocales[nLocale]));
SetChecked(xLinguSrvcMgr->getConfiguredServices(C2U(cThes), pAllLocales[nLocale]));
}
}
}
/* -----------------------------26.11.00 18:08--------------------------------
2000-11-27 19:41:26 +00:00
---------------------------------------------------------------------------*/
SvxLinguData_Impl::~SvxLinguData_Impl()
{
}
2000-11-27 19:41:26 +00:00
/* -----------------------------26.11.00 20:19--------------------------------
2000-11-27 19:41:26 +00:00
---------------------------------------------------------------------------*/
void SvxLinguData_Impl::AddServiceName(const ServiceInfo_Impl* pInfo)
{
2000-11-27 19:41:26 +00:00
lcl_MergeDisplayArray(aDisplayServiceArr, pInfo);
const OUString* pAvailSrvcDisplayNames = aAvailSrvcDisplayNames.getConstArray();
sal_Bool bFound = sal_False;
OUString sImpl = pInfo->sSpellImplName.getLength() ? pInfo->sSpellImplName :
pInfo->sHyphImplName.getLength() ? pInfo->sHyphImplName :
pInfo->sThesImplName;
for(sal_Int32 nAll = 0; nAll < aAvailSrvcDisplayNames.getLength() && !bFound; nAll++)
{
2000-11-27 19:41:26 +00:00
bFound = pAvailSrvcDisplayNames[nAll] == sImpl;
}
2000-11-27 19:41:26 +00:00
if(!bFound)
{
2000-11-27 19:41:26 +00:00
aAvailSrvcNames.realloc(aAvailSrvcNames.getLength() + 1);
aAvailSrvcDisplayNames.realloc(aAvailSrvcDisplayNames.getLength() + 1);
OUString* pAvailSrvcNames = aAvailSrvcNames.getArray();
OUString* pAvailSrvcDisplayNames = aAvailSrvcDisplayNames.getArray();
pAvailSrvcNames[aAvailSrvcNames.getLength() - 1] = sImpl;
pAvailSrvcDisplayNames[aAvailSrvcDisplayNames.getLength() - 1] = pInfo->sDisplayName;
}
}
2000-11-27 19:41:26 +00:00
/* -----------------------------26.11.00 19:42--------------------------------
2000-11-27 19:41:26 +00:00
---------------------------------------------------------------------------*/
void SvxLinguData_Impl::SetChecked(const Sequence<OUString>& rConfiguredServices)
{
2000-11-27 19:41:26 +00:00
const OUString* pConfiguredServices = rConfiguredServices.getConstArray();
2000-11-28 01:36:08 +00:00
for(sal_Int32 n = 0; n < rConfiguredServices.getLength(); n++)
2000-11-27 19:41:26 +00:00
{
for(int i = 0; i < aDisplayServiceArr.Count(); i++)
{
ServiceInfo_Impl* pEntry = aDisplayServiceArr[i];
2001-01-18 14:19:25 +00:00
// if(pEntry->sDisplayName == pConfiguredServices[n])
if (pEntry->sSpellImplName == pConfiguredServices[n] ||
pEntry->sHyphImplName == pConfiguredServices[n] ||
pEntry->sThesImplName == pConfiguredServices[n])
2000-11-27 19:41:26 +00:00
{
pEntry->bConfigured = sal_True;
break;
}
}
}
2000-11-27 19:41:26 +00:00
/* if(aAvailSrvcConfigured.getLength() != aAvailSrvcNames.getLength())
{
aAvailSrvcConfigured.realloc(aAvailSrvcDisplayNames.getLength());
sal_Bool* pBool = aAvailSrvcConfigured.getArray();
for(sal_Int32 nInit = 0; nInit < aAvailSrvcDisplayNames.getLength(); nInit++)
pBool[nInit] = sal_False;
}
const OUString* pAvailSrvcNames = aAvailSrvcNames.getConstArray();
sal_Bool* pIsConfigured = aAvailSrvcConfigured.getArray();
const OUString* pConfiguredServices = rConfiguredServices.getConstArray();
for(sal_Int32 n = 0; n < aAvailSrvcNames.getLength(); n++)
{
if(!pIsConfigured[n])
{
for(sal_Int32 nFind = 0; nFind < rConfiguredServices.getLength(); nFind++)
{
if(pConfiguredServices[nFind] == pAvailSrvcNames[n])
{
pIsConfigured[n] = sal_True;
break;
}
}
}
}
*/}
/* -----------------------------26.11.00 20:43--------------------------------
2000-11-27 19:41:26 +00:00
---------------------------------------------------------------------------*/
sal_Bool lcl_AddRemove(Sequence<OUString>& rConfigured,
const OUString* pRemove, const sal_Int32 nRemove,
const OUString* pInsert, const sal_Int32 nInsert)
{
2000-11-27 19:41:26 +00:00
sal_Bool bRet = sal_False;
sal_Int32 nConfigured = rConfigured.getLength();
rConfigured.realloc(rConfigured.getLength() + nInsert);
OUString* pConfigured = rConfigured.getArray();
sal_Int32 i, j;
for(j = 0; j < nConfigured; j++)
{
2000-11-27 19:41:26 +00:00
for(i = 0; i < nRemove; i++)
{
2000-11-27 19:41:26 +00:00
if(pConfigured[j] == pRemove[i])
{
pConfigured[j] = OUString();
bRet = sal_True;
break;
}
}
}
sal_Int32 nAppend = nConfigured;
for(i = 0; i < nInsert; i++)
{
sal_Bool bFound = sal_False;
for(j = 0; j < nConfigured && !bFound; j++)
{
if(pConfigured[j] == pInsert[i])
bFound = sal_True;
}
if(!bFound)
{
pConfigured[nAppend++] = pInsert[i];
bRet = sal_True;
}
}
2000-11-27 19:41:26 +00:00
sal_Int32 nRealloc = 0;
for(i = 0; i < nInsert; i++)
if(pConfigured[i].getLength())
pConfigured[nRealloc++] = pConfigured[i];
rConfigured.realloc(nRealloc);
return bRet;
}
2000-11-27 19:41:26 +00:00
void SvxLinguData_Impl::Reconfigure(
const Sequence<OUString>& aRemove, const Sequence<OUString>& aInsert)
{
const OUString* pRemove = aRemove.getConstArray();
const nRemove = aRemove.getLength();
const OUString* pInsert = aInsert.getConstArray();
const nInsert = aInsert.getLength();
2000-11-27 19:41:26 +00:00
const Locale* pAllLocales = aAllServiceLocales.getConstArray();
for(sal_Int32 nLocale = 0; nLocale < aAllServiceLocales.getLength(); nLocale++)
{
Sequence<OUString> aConfigured = xLinguSrvcMgr->getConfiguredServices(C2U(cSpell), pAllLocales[nLocale]);
if(lcl_AddRemove(aConfigured, pRemove, nRemove, pInsert, nInsert))
xLinguSrvcMgr->setConfiguredServices(C2U(cSpell), pAllLocales[nLocale], aConfigured);
aConfigured = xLinguSrvcMgr->getConfiguredServices(C2U(cHyph), pAllLocales[nLocale]);
if(lcl_AddRemove(aConfigured, pRemove, nRemove, pInsert, nInsert))
xLinguSrvcMgr->setConfiguredServices(C2U(cHyph), pAllLocales[nLocale], aConfigured);
2000-11-27 19:41:26 +00:00
aConfigured = xLinguSrvcMgr->getConfiguredServices(C2U(cThes), pAllLocales[nLocale]);
if(lcl_AddRemove(aConfigured, pRemove, nRemove, pInsert, nInsert))
xLinguSrvcMgr->setConfiguredServices(C2U(cThes), pAllLocales[nLocale], aConfigured);
2000-11-27 19:41:26 +00:00
}
}
// SvxModulesData_Impl ---------------------------------------------------
struct SvxModulesData_Impl
{
2000-11-27 19:41:26 +00:00
OUString sServiceImplName;
sal_Bool bIsConfigured;
SvxModulesData_Impl(const OUString& rSrvc, sal_Bool bSet) :
sServiceImplName(rSrvc),
bIsConfigured(bSet){}
};
2000-11-27 19:41:26 +00:00
// class SvxLinguTabPage -------------------------------------------------
#define CBCOL_FIRST 0
#define CBCOL_SECOND 1
#define CBCOL_BOTH 2
SvxLinguTabPage::SvxLinguTabPage( Window* pParent,
const SfxItemSet& rSet ):
SfxTabPage( pParent, ResId( RID_SFXPAGE_LINGU, DIALOG_MGR() ), rSet ),
aLinguisticGB ( this, ResId( GB_LINGUISTIC ) ),
aLinguModulesFT ( this, ResId( FT_LINGU_MODULES ) ),
aLinguModulesCLB ( this, ResId( CLB_LINGU_MODULES ) ),
aLinguModulesEditPB ( this, ResId( PB_LINGU_MODULES_EDIT ) ),
aLinguOptionsFT ( this, ResId( FT_LINGU_OPTIONS ) ),
aLinguOptionsCLB ( this, ResId( CLB_LINGU_OPTIONS ) ),
aLinguOptionsEditPB ( this, ResId( PB_LINGU_OPTIONS_EDIT ) ),
sCapitalWords ( ResId( STR_CAPITAL_WORDS ) ),
sWordsWithDigits ( ResId( STR_WORDS_WITH_DIGITS ) ),
sCapitalization ( ResId( STR_CAPITALIZATION ) ),
sSpellSpecial ( ResId( STR_SPELL_SPECIAL ) ),
sAllLanguages ( ResId( STR_ALL_LANGUAGES ) ),
sSpellAuto ( ResId( STR_SPELL_AUTO ) ),
sHideMarkings ( ResId( STR_HIDE_MARKINGS ) ),
sOldGerman ( ResId( STR_OLD_GERMAN ) ),
2000-12-07 08:15:28 +00:00
sNumMinWordlen ( ResId( STR_NUM_MIN_WORDLEN ) ),
2000-11-27 19:41:26 +00:00
sNumPreBreak ( ResId( STR_NUM_PRE_BREAK ) ),
sNumPostBreak ( ResId( STR_NUM_POST_BREAK ) ),
sHyphAuto ( ResId( STR_HYPH_AUTO ) ),
sHyphSpecial ( ResId( STR_HYPH_SPECIAL ) ),
aChkunBmp ( ResId( BMP_CHKBUT_UNCHECKED ) ),
aChkchBmp ( ResId( BMP_CHKBUT_CHECKED ) ),
pLinguData ( NULL )
{
2000-11-27 19:41:26 +00:00
pCheckButtonData = NULL;
aLinguModulesCLB.SetWindowBits( WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
aLinguOptionsCLB.SetWindowBits( WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
aLinguModulesCLB.SetHighlightRange();
aLinguOptionsCLB.SetHighlightRange();
aLinguModulesCLB.SetHelpId(HID_CLB_LINGU_MODULES );
aLinguOptionsCLB.SetHelpId(HID_CLB_LINGU_OPTIONS );
2000-11-27 19:41:26 +00:00
xProp = Reference< XPropertySet >( SvxGetLinguPropertySet(), UNO_QUERY );
2000-11-27 19:41:26 +00:00
aLinguModulesCLB.SetSelectHdl( LINK( this, SvxLinguTabPage, SelectHdl_Impl ));
aLinguOptionsCLB.SetSelectHdl( LINK( this, SvxLinguTabPage, SelectHdl_Impl ));
aLinguModulesEditPB.SetClickHdl( LINK( this, SvxLinguTabPage, ClickHdl_Impl ));
aLinguOptionsEditPB.SetClickHdl( LINK( this, SvxLinguTabPage, ClickHdl_Impl ));
aLinguOptionsCLB.SetDoubleClickHdl(LINK(this, SvxLinguTabPage, DoubleClickHdl_Impl));
aLinguModulesCLB.SetDoubleClickHdl(LINK(this, SvxLinguTabPage, DoubleClickHdl_Impl));
2000-11-27 19:41:26 +00:00
const SfxSpellCheckItem* pItem = 0;
SfxItemState eItemState = SFX_ITEM_UNKNOWN;
2000-11-27 19:41:26 +00:00
eItemState = rSet.GetItemState( GetWhich( SID_ATTR_SPELL ),
sal_False, (const SfxPoolItem**)&pItem );
// handelt es sich um ein Default-Item?
if ( eItemState == SFX_ITEM_DEFAULT )
pItem = (const SfxSpellCheckItem*)&(rSet.Get( GetWhich( SID_ATTR_SPELL ) ) );
else if ( eItemState == SFX_ITEM_DONTCARE )
pItem = NULL;
2000-11-27 19:41:26 +00:00
FreeResource();
}
2000-11-27 19:41:26 +00:00
// -----------------------------------------------------------------------
2000-11-27 19:41:26 +00:00
SvxLinguTabPage::~SvxLinguTabPage()
{
if (pLinguData)
delete pLinguData;
2000-11-27 19:41:26 +00:00
for(sal_uInt16 nEntry = 0; nEntry < aLinguModulesCLB.GetEntryCount(); nEntry++)
{
2000-11-27 19:41:26 +00:00
SvxModulesData_Impl* pData = (SvxModulesData_Impl*)aLinguModulesCLB.GetEntry(nEntry)->GetUserData();
delete pData;
}
}
2000-11-27 19:41:26 +00:00
//------------------------------------------------------------------------
2000-11-27 19:41:26 +00:00
//nicht <20>berladen wegschmeissen
sal_uInt16* SvxLinguTabPage::GetRanges()
{
2000-11-27 19:41:26 +00:00
//TL???
return pRanges;
}
//------------------------------------------------------------------------
SfxTabPage* SvxLinguTabPage::Create( Window* pParent,
const SfxItemSet& rAttrSet )
{
return ( new SvxLinguTabPage( pParent, rAttrSet ) );
}
//------------------------------------------------------------------------
2000-11-27 19:41:26 +00:00
Any lcl_Bool2Any(BOOL bVal)
{
Any aRet(&bVal, ::getBooleanCppuType());
return aRet;
}
2000-11-27 19:41:26 +00:00
sal_Bool lcl_Bool2Any(Any& rVal)
{
return *(sal_Bool*)rVal.getValue();
}
2000-11-27 19:41:26 +00:00
sal_Bool SvxLinguTabPage::FillItemSet( SfxItemSet& rCoreSet )
{
sal_Bool bModified = sal_True; // !!!!
// if not HideGroups was called with GROUP_MODULES...
if (aLinguModulesCLB.IsVisible())
{
SvStringsDtor aToRemove;
SvStringsDtor aToInsert;
for(sal_uInt16 i = 0; i < aLinguModulesCLB.GetEntryCount(); i++)
{
SvLBoxEntry* pEntry = aLinguModulesCLB.GetEntry(i);
SvxModulesData_Impl* pData = (SvxModulesData_Impl*) pEntry->GetUserData();
if(pData->bIsConfigured != aLinguModulesCLB.IsChecked( i ))
{
if(pData->bIsConfigured)
aToRemove.Insert(new String(pData->sServiceImplName), aToRemove.Count());
else if(!pData->bIsConfigured)
aToInsert.Insert(new String(pData->sServiceImplName), aToInsert.Count());
}
}
if(aToRemove.Count() || aToInsert.Count())
{
Sequence<OUString> aRemove(aToRemove.Count());
OUString* pRemove = aRemove.getArray();
USHORT i;
for(i = 0; i < aToRemove.Count(); i++)
pRemove[i] = OUString(*aToRemove[i]);
Sequence<OUString> aInsert(aToInsert.Count());
OUString* pInsert = aInsert.getArray();
for(i = 0; i < aToInsert.Count(); i++)
pInsert[i] = OUString(*aToInsert[i]);
if (!pLinguData)
pLinguData = new SvxLinguData_Impl;
pLinguData->Reconfigure(aRemove, aInsert);
}
2000-11-27 19:41:26 +00:00
}
BOOL bCheckAllLangChanged = FALSE;
SvtLinguConfig aLngCfg;
2000-11-27 19:41:26 +00:00
USHORT nEntries = (USHORT) aLinguOptionsCLB.GetEntryCount();
for (USHORT j = 0; j < nEntries; ++j)
{
SvLBoxEntry *pEntry = aLinguOptionsCLB.GetEntry( j );
2000-11-27 19:41:26 +00:00
OptionsUserData aData( (ULONG)pEntry->GetUserData() );
String aPropName( lcl_GetPropertyName( (EID_OPTIONS) aData.GetEntryId() ) );
if (EID_ALL_LANGUAGES == (EID_OPTIONS) aData.GetEntryId())
{
bCheckAllLangChanged = aData.IsChecked() != aLinguOptionsCLB.IsChecked( j );
}
2000-11-27 19:41:26 +00:00
Any aAny;
if (aData.IsCheckable())
{
2000-11-27 19:41:26 +00:00
BOOL bChecked = aLinguOptionsCLB.IsChecked( j );
aAny <<= bChecked;
}
2000-11-27 19:41:26 +00:00
else if (aData.HasNumericValue())
{
2000-11-27 19:41:26 +00:00
INT16 nVal = aData.GetNumericValue();
aAny <<= nVal;
}
if (xProp.is())
xProp->setPropertyValue( aPropName, aAny );
aLngCfg.SetProperty( aPropName, aAny );
2000-11-27 19:41:26 +00:00
}
rCoreSet.Put( SfxBoolItem( SID_SPELL_MODIFIED, bCheckAllLangChanged ) );
2000-11-27 19:41:26 +00:00
SvLBoxEntry *pPreBreakEntry = aLinguOptionsCLB.GetEntry( (USHORT) EID_NUM_PRE_BREAK );
SvLBoxEntry *pPostBreakEntry = aLinguOptionsCLB.GetEntry( (USHORT) EID_NUM_POST_BREAK );
DBG_ASSERT( pPreBreakEntry, "NULL Pointer" );
DBG_ASSERT( pPostBreakEntry, "NULL Pointer" );
if (pPreBreakEntry && pPostBreakEntry)
{
OptionsUserData aPreBreakData( (ULONG)pPreBreakEntry->GetUserData() );
OptionsUserData aPostBreakData( (ULONG)pPostBreakEntry->GetUserData() );
if ( aPreBreakData.IsModified() || aPostBreakData.IsModified() )
{
2000-11-27 19:41:26 +00:00
SfxHyphenRegionItem aHyp( GetWhich( SID_ATTR_HYPHENREGION ) );
aHyp.GetMinLead() = (UINT8) aPreBreakData.GetNumericValue();
aHyp.GetMinTrail() = (UINT8) aPostBreakData.GetNumericValue();
rCoreSet.Put( aHyp );
}
}
2000-11-27 19:41:26 +00:00
// Autom. Rechtschreibung
BOOL bNewAutoCheck = aLinguOptionsCLB.IsChecked( (USHORT) EID_SPELL_AUTO );
const SfxPoolItem* pOld = GetOldItem( rCoreSet, SID_AUTOSPELL_CHECK );
if ( !pOld || ( (SfxBoolItem*)pOld )->GetValue() != bNewAutoCheck )
{
rCoreSet.Put( SfxBoolItem( GetWhich( SID_AUTOSPELL_CHECK ),
bNewAutoCheck ) );
bModified |= sal_True;
}
// pOld ist alte Wert wenn wert ge<67>ndert mit neuen Wert ins Item Set
BOOL bNewMarkOff = aLinguOptionsCLB.IsChecked( (USHORT) EID_HIDE_MARKINGS );
pOld = GetItem( rCoreSet, SID_AUTOSPELL_MARKOFF );
if ( !pOld || ( (SfxBoolItem*)pOld )->GetValue() != bNewMarkOff )
{
rCoreSet.Put( SfxBoolItem( GetWhich( SID_AUTOSPELL_MARKOFF ),
bNewMarkOff ) );
bModified |= sal_True;
}
return bModified;
}
2000-11-27 19:41:26 +00:00
//------------------------------------------------------------------------
void SvxLinguTabPage::Reset( const SfxItemSet& rSet )
{
// if not HideGroups was called with GROUP_MODULES...
if (aLinguModulesCLB.IsVisible())
2000-11-27 19:41:26 +00:00
{
if (!pLinguData)
pLinguData = new SvxLinguData_Impl;
const ServiceInfoArr& rAllDispSrvcArr = pLinguData->GetDisplayServiceArray();
for(sal_uInt16 i = 0; i < rAllDispSrvcArr.Count(); i++)
{
ServiceInfo_Impl* pInfo = rAllDispSrvcArr[i];
aLinguModulesCLB.InsertEntry(pInfo->sDisplayName);
SvLBoxEntry* pEntry = aLinguModulesCLB.GetEntry(i);
pEntry->SetUserData( new SvxModulesData_Impl(
pInfo->sDisplayName, pInfo->bConfigured ) );
aLinguModulesCLB.CheckEntryPos( i, pInfo->bConfigured );
}
aLinguModulesEditPB.Enable( rAllDispSrvcArr.Count() > 0 );
2000-11-27 19:41:26 +00:00
}
//
// get data from configuration
//
SvtLinguConfig aLngCfg;
aLinguOptionsCLB.SetUpdateMode(FALSE);
aLinguOptionsCLB.Clear();
SvLBoxTreeList *pModel = aLinguOptionsCLB.GetModel();
SvLBoxEntry* pEntry = NULL;
INT16 nVal = 0;
BOOL bVal = FALSE;
ULONG nUserData = 0;
pEntry = CreateEntry( sCapitalWords, CBCOL_FIRST );
aLngCfg.GetProperty( C2U(UPN_IS_SPELL_UPPER_CASE) ) >>= bVal;
nUserData = OptionsUserData( EID_CAPITAL_WORDS, FALSE, 0, TRUE, bVal).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
lcl_SetCheckButton( pEntry, bVal );
pEntry = CreateEntry( sWordsWithDigits, CBCOL_FIRST );
aLngCfg.GetProperty( C2U(UPN_IS_SPELL_WITH_DIGITS) ) >>= bVal;
nUserData = OptionsUserData( EID_WORDS_WITH_DIGITS, FALSE, 0, TRUE, bVal).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
lcl_SetCheckButton( pEntry, bVal );
pEntry = CreateEntry( sCapitalization, CBCOL_FIRST );
aLngCfg.GetProperty( C2U(UPN_IS_SPELL_CAPITALIZATION) ) >>= bVal;
nUserData = OptionsUserData( EID_CAPITALIZATION, FALSE, 0, TRUE, bVal).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
lcl_SetCheckButton( pEntry, bVal );
pEntry = CreateEntry( sSpellSpecial, CBCOL_FIRST );
aLngCfg.GetProperty( C2U(UPN_IS_SPELL_SPECIAL) ) >>= bVal;
nUserData = OptionsUserData( EID_SPELL_SPECIAL, FALSE, 0, TRUE, bVal).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
lcl_SetCheckButton( pEntry, bVal );
pEntry = CreateEntry( sAllLanguages, CBCOL_FIRST );
aLngCfg.GetProperty( C2U(UPN_IS_SPELL_IN_ALL_LANGUAGES) ) >>= bVal;
nUserData = OptionsUserData( EID_ALL_LANGUAGES, FALSE, 0, TRUE, bVal).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
lcl_SetCheckButton( pEntry, bVal );
pEntry = CreateEntry( sSpellAuto, CBCOL_FIRST );
aLngCfg.GetProperty( C2U(UPN_IS_SPELL_AUTO) ) >>= bVal;
const SfxPoolItem* pItem = GetItem( rSet, SID_AUTOSPELL_CHECK );
if (pItem)
bVal = ((SfxBoolItem *) pItem)->GetValue();
nUserData = OptionsUserData( EID_SPELL_AUTO, FALSE, 0, TRUE, bVal).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
lcl_SetCheckButton( pEntry, bVal );
pEntry = CreateEntry( sHideMarkings, CBCOL_FIRST );
aLngCfg.GetProperty( C2U(UPN_IS_SPELL_HIDE) ) >>= bVal;
pItem = GetItem( rSet, SID_AUTOSPELL_MARKOFF );
if (pItem)
bVal = ((SfxBoolItem *) pItem)->GetValue();
nUserData = OptionsUserData( EID_HIDE_MARKINGS, FALSE, 0, TRUE, bVal).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
lcl_SetCheckButton( pEntry, bVal );
pEntry = CreateEntry( sOldGerman, CBCOL_FIRST );
aLngCfg.GetProperty( C2U(UPN_IS_GERMAN_PRE_REFORM) ) >>= bVal;
nUserData = OptionsUserData( EID_OLD_GERMAN, FALSE, 0, TRUE, bVal).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
lcl_SetCheckButton( pEntry, bVal );
pEntry = CreateEntry( sNumMinWordlen, CBCOL_SECOND );
aLngCfg.GetProperty( C2U(UPN_HYPH_MIN_WORD_LENGTH) ) >>= nVal;
nUserData = OptionsUserData( EID_NUM_MIN_WORDLEN, TRUE, (USHORT)nVal, FALSE, FALSE).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
const SfxHyphenRegionItem *pHyp = NULL;
USHORT nWhich = GetWhich( SID_ATTR_HYPHENREGION );
if ( rSet.GetItemState( nWhich, FALSE ) >= SFX_ITEM_AVAILABLE )
pHyp = &( (const SfxHyphenRegionItem &) rSet.Get( nWhich ) );
pEntry = CreateEntry( sNumPreBreak, CBCOL_SECOND );
aLngCfg.GetProperty( C2U(UPN_HYPH_MIN_LEADING) ) >>= nVal;
if (pHyp)
nVal = (INT16) pHyp->GetMinLead();
nUserData = OptionsUserData( EID_NUM_PRE_BREAK, TRUE, (USHORT)nVal, FALSE, FALSE).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
pEntry = CreateEntry( sNumPostBreak, CBCOL_SECOND );
aLngCfg.GetProperty( C2U(UPN_HYPH_MIN_TRAILING) ) >>= nVal;
if (pHyp)
nVal = (INT16) pHyp->GetMinTrail();
nUserData = OptionsUserData( EID_NUM_POST_BREAK, TRUE, (USHORT)nVal, FALSE, FALSE).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
pEntry = CreateEntry( sHyphAuto, CBCOL_FIRST );
aLngCfg.GetProperty( C2U(UPN_IS_HYPH_AUTO) ) >>= bVal;
nUserData = OptionsUserData( EID_HYPH_AUTO, FALSE, 0, TRUE, bVal).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
lcl_SetCheckButton( pEntry, bVal );
pEntry = CreateEntry( sHyphSpecial, CBCOL_FIRST );
aLngCfg.GetProperty( C2U(UPN_IS_HYPH_SPECIAL) ) >>= bVal;
nUserData = OptionsUserData( EID_HYPH_SPECIAL, FALSE, 0, TRUE, bVal).GetUserData();
pEntry->SetUserData( (void *)nUserData );
pModel->Insert( pEntry );
lcl_SetCheckButton( pEntry, bVal );
aLinguOptionsCLB.SetUpdateMode(TRUE);
2000-09-18 16:07:07 +00:00
}
// -----------------------------------------------------------------------
IMPL_LINK( SvxLinguTabPage, DoubleClickHdl_Impl, SvxCheckListBox *, pBox )
{
if(pBox == &aLinguOptionsCLB)
ClickHdl_Impl(&aLinguOptionsEditPB);
else
ClickHdl_Impl(&aLinguModulesEditPB);
return 0;
}
// -----------------------------------------------------------------------
IMPL_LINK( SvxLinguTabPage, ClickHdl_Impl, PushButton *, pBtn )
{
if (&aLinguModulesEditPB == pBtn)
{
if (!pLinguData)
pLinguData = new SvxLinguData_Impl;
SvxEditModulesDlg aDlg( this, *pLinguData );
aDlg.Execute();
}
else if (&aLinguOptionsEditPB == pBtn)
{
SvLBoxEntry *pEntry = aLinguOptionsCLB.GetCurEntry();
DBG_ASSERT( pEntry, "no entry selected" );
if (pEntry)
{
long nVal = -1;
OptionsUserData aData( (ULONG)pEntry->GetUserData() );
if(aData.HasNumericValue())
{
int nRID = -1;
switch (aData.GetEntryId())
{
case EID_NUM_PRE_BREAK : nRID = STR_NUM_PRE_BREAK_DLG; break;
case EID_NUM_POST_BREAK : nRID = STR_NUM_POST_BREAK_DLG; break;
case EID_NUM_MIN_WORDLEN: nRID = STR_NUM_MIN_WORDLEN_DLG; break;
default:
DBG_ERROR( "unexpected case" );
}
OptionsBreakSet aDlg( this, nRID );
if (RET_OK == aDlg.Execute() )
{
nVal = aDlg.GetNumericFld().GetValue();
if (-1 != nVal && aData.GetNumericValue() != nVal)
{
aData.SetNumericValue( (BYTE)nVal ); //! sets IsModified !
pEntry->SetUserData( (void *) aData.GetUserData() );
aLinguOptionsCLB.Invalidate();
}
}
}
}
}
else
{
DBG_ERROR( "pBtn unexpected value" );
}
return 0;
}
// -----------------------------------------------------------------------
IMPL_LINK( SvxLinguTabPage, SelectHdl_Impl, SvxCheckListBox *, pBox )
{
if (&aLinguModulesCLB == pBox)
{
}
else if (&aLinguOptionsCLB == pBox)
{
SvLBoxEntry *pEntry = pBox->GetCurEntry();
if (pEntry)
{
OptionsUserData aData( (ULONG) pEntry->GetUserData() );
aLinguOptionsEditPB.Enable( aData.HasNumericValue() );
}
}
else
{
DBG_ERROR( "pBox unexpected value" );
}
return 0;
}
// -----------------------------------------------------------------------
SvLBoxEntry* SvxLinguTabPage::CreateEntry(String& rTxt, USHORT nCol)
{
SvLBoxEntry* pEntry = new SvLBoxEntry;
if( !pCheckButtonData )
{
pCheckButtonData = new SvLBoxButtonData;
pCheckButtonData->aBmps[SV_BMP_UNCHECKED] = aChkunBmp;
pCheckButtonData->aBmps[SV_BMP_CHECKED] = aChkchBmp;
}
String sEmpty;
if (CBCOL_FIRST == nCol)
pEntry->AddItem( new SvLBoxButton( pEntry, 0, pCheckButtonData ) );
if (CBCOL_SECOND == nCol)
pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty) ); // Leerspalte
pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0)); // Sonst Puff!
pEntry->AddItem( new BrwString_Impl( pEntry, 0, rTxt ) );
return pEntry;
}
// ----------------------------------------------------------------------
#if SUPD <= 623
void SvxLinguTabPage::UpdateBox_Impl()
{
}
#endif
// -----------------------------------------------------------------------
2000-11-27 19:41:26 +00:00
void SvxLinguTabPage::HideGroups( sal_uInt16 nGrp )
2000-09-18 16:07:07 +00:00
{
if ( 0 != ( GROUP_MODULES & nGrp ) )
{
aLinguModulesFT.Hide();
aLinguModulesCLB.Hide();
aLinguModulesEditPB.Hide();
}
2000-11-27 19:41:26 +00:00
#ifdef NEVER
if ( 0 != ( GROUP_SPELLING & nGrp ) )
{
2000-11-27 19:41:26 +00:00
aCapsBtn.Hide();
aNumsBtn.Hide();
aUpLowBtn.Hide();
aAllLangBtn.Hide();
aAuditBox.Hide();
}
if ( 0 != ( GROUP_HYPHEN & nGrp ) )
{
aPreBreakText.Hide();
aPreBreakEdit.Hide();
aAfterBreakText.Hide();
aAfterBreakEdit.Hide();
aAutoBtn.Hide();
aSpecialBtn.Hide();
aRulesBox.Hide();
}
#endif
2000-09-18 16:07:07 +00:00
}
2000-11-27 19:41:26 +00:00
/*--------------------------------------------------
--------------------------------------------------*/
2000-11-27 19:41:26 +00:00
SvxEditModulesDlg::SvxEditModulesDlg(Window* pParent, SvxLinguData_Impl& rData) :
ModalDialog(pParent, ResId(RID_SVXDLG_EDIT_MODULES, DIALOG_MGR() )),
aClosePB ( this, ResId( PB_OK ) ),
aHelpPB ( this, ResId( PB_HELP ) ),
aModulesGB ( this, ResId( GB_EDIT_MODULES_OPTIONS ) ),
aLanguageFT ( this, ResId( FT_EDIT_MODULES_LANGUAGE ) ),
aLanguageLB ( this, ResId( LB_EDIT_MODULES_LANGUAGE ), FALSE ),
2000-11-27 19:41:26 +00:00
aModulesCLB ( this, ResId( CLB_EDIT_MODULES_MODULES ) ),
aPrioUpPB ( this, ResId( PB_EDIT_MODULES_PRIO_UP ) ),
aPrioDownPB ( this, ResId( PB_EDIT_MODULES_PRIO_DOWN ) ),
aBackPB ( this, ResId( PB_EDIT_MODULES_PRIO_BACK ) ),
aDicsGB ( this, ResId( GB_EDIT_MODULES_DICS ) ),
aDicsCLB ( this, ResId( CLB_EDIT_MODULES_DICS ) ),
aNewPB ( this, ResId( PB_EDIT_MODULES_NEW_DIC ) ),
aEditPB ( this, ResId( PB_EDIT_MODULES_PRIO_EDIT_DIC ) ),
aDeletePB ( this, ResId( PB_EDIT_MODULES_PRIO_DEL_DIC ) ),
aChkunBmp ( ResId( BMP_CHKBUT_UNCHECKED ) ),
aChkchBmp ( ResId( BMP_CHKBUT_CHECKED ) ),
sSpell( ResId( ST_SPELL)),
sHyph( ResId( ST_HYPH)),
sThes( ResId( ST_THES)),
rLinguData(rData)
{
2000-11-27 19:41:26 +00:00
pCheckButtonData = NULL;
FreeResource();
aModulesCLB.SetWindowBits( WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
aDicsCLB.SetWindowBits( WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
aModulesCLB.SetHighlightRange();
aDicsCLB.SetHighlightRange();
aModulesCLB.SetHelpId(HID_CLB_EDIT_MODULES_MODULES );
aDicsCLB.SetHelpId(HID_CLB_EDIT_MODULES_DICS );
aModulesCLB.SetSelectHdl( LINK( this, SvxEditModulesDlg, SelectHdl_Impl ));
aDicsCLB.SetSelectHdl( LINK( this, SvxEditModulesDlg, SelectHdl_Impl ));
aNewPB.SetClickHdl( LINK( this, SvxEditModulesDlg, ClickHdl_Impl ));
aEditPB.SetClickHdl( LINK( this, SvxEditModulesDlg, ClickHdl_Impl ));
aClosePB.SetClickHdl( LINK( this, SvxEditModulesDlg, ClickHdl_Impl ));
aDeletePB.SetClickHdl( LINK( this, SvxEditModulesDlg, ClickHdl_Impl ));
aPrioUpPB .SetClickHdl( LINK( this, SvxEditModulesDlg, UpDownHdl_Impl ));
aPrioDownPB.SetClickHdl( LINK( this, SvxEditModulesDlg, UpDownHdl_Impl ));
aBackPB.SetClickHdl(LINK( this, SvxEditModulesDlg, BackHdl_Impl));
aModulesCLB.SetCheckButtonHdl( LINK( this, SvxEditModulesDlg, CheckButtonHdl_Impl) );
2000-11-27 19:41:26 +00:00
xDicList = Reference< XDictionaryList >( SvxGetDictionaryList(), UNO_QUERY );
if (xDicList.is())
{
2000-11-27 19:41:26 +00:00
UpdateDicBox_Impl();
}
2000-11-27 19:41:26 +00:00
else
{
2000-11-27 19:41:26 +00:00
aDicsGB.Disable();
aDicsCLB.Disable();
aNewPB.Disable();
aEditPB.Disable();
aDeletePB.Disable();
}
2000-11-27 19:41:26 +00:00
//fill option CheckListBox
aLanguageLB.Clear();
const Sequence<Locale>& rLoc = rLinguData.GetAllSupportedLocales();
const Locale* pLocales = rLoc.getConstArray();
for(long i = 0; i < rLoc.getLength(); i++)
{
2000-11-27 19:41:26 +00:00
aLanguageLB.InsertLanguage( SvxLocaleToLanguage( pLocales[i] ));
}
2000-11-27 19:41:26 +00:00
LanguageType eSysLang = GetSystemLanguage();
aLanguageLB.SelectLanguage( eSysLang );
if(!aLanguageLB.IsLanguageSelected( eSysLang ) )
aLanguageLB.SelectEntryPos(0);
aLanguageLB.SetSelectHdl( LINK( this, SvxEditModulesDlg, LangSelectHdl_Impl ));
LangSelectHdl_Impl(&aLanguageLB);
2000-09-18 16:07:07 +00:00
}
2000-11-27 19:41:26 +00:00
SvxEditModulesDlg::~SvxEditModulesDlg()
{
2000-11-27 19:41:26 +00:00
}
2000-11-27 19:41:26 +00:00
SvLBoxEntry* SvxEditModulesDlg::CreateEntry( const String& rTxt, USHORT nCol )
{
SvLBoxEntry* pEntry = new SvLBoxEntry;
if( !pCheckButtonData )
{
pCheckButtonData = new SvLBoxButtonData;
pCheckButtonData->aBmps[SV_BMP_UNCHECKED] = aChkunBmp;
pCheckButtonData->aBmps[SV_BMP_CHECKED] = aChkchBmp;
}
String sEmpty;
if (CBCOL_FIRST == nCol)
pEntry->AddItem( new SvLBoxButton( pEntry, 0, pCheckButtonData ) );
if (CBCOL_SECOND == nCol)
pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty) ); // Leerspalte
pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0)); // Sonst Puff!
2000-11-27 19:41:26 +00:00
pEntry->AddItem( new BrwStringDic_Impl( pEntry, 0, rTxt ) );
return pEntry;
}
2000-11-27 19:41:26 +00:00
void SvxEditModulesDlg::UpdateDicBox_Impl()
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
aDicsCLB.SetUpdateMode(FALSE);
aDicsCLB.Clear();
2000-09-18 16:07:07 +00:00
2000-11-27 19:41:26 +00:00
SvLBoxTreeList *pModel = aDicsCLB.GetModel();
SvLBoxEntry* pEntry = NULL;
2000-09-18 16:07:07 +00:00
2000-11-27 19:41:26 +00:00
aDics = xDicList->getDictionaries();
INT32 nDics = aDics.getLength();
const Reference< XDictionary > *pDic = aDics.getConstArray();
for (INT32 i = 0; i < nDics; ++i)
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
const Reference< XDictionary > &rDic = pDic[i];
if (rDic.is())
{
Reference< frame::XStorable > xStor( rDic, UNO_QUERY );
2000-09-18 16:07:07 +00:00
2000-11-27 19:41:26 +00:00
ULONG nUserData = 0;
BOOL bChecked = rDic->isActive();
BOOL bEditable = !xStor.is() || !xStor->isReadonly();
BOOL bDeletable = bEditable;
BOOL bNegativ = rDic->getDictionaryType() == DictionaryType_NEGATIVE;
String aTxt( ::GetDicInfoStr( rDic->getName(),
SvxLocaleToLanguage( rDic->getLocale() ),
bNegativ ) );
2000-09-18 16:07:07 +00:00
2000-11-27 19:41:26 +00:00
aDicsCLB.InsertEntry(aTxt);
SvLBoxEntry* pEntry = aDicsCLB.GetEntry(i);
2000-09-18 16:07:07 +00:00
2000-11-27 19:41:26 +00:00
// pEntry = CreateEntry( aTxt, CBCOL_FIRST );
nUserData = DicUserData( (USHORT)i,
bChecked, bEditable, bDeletable ).GetUserData();
pEntry->SetUserData( (void *)nUserData );
// pModel->Insert( pEntry );
lcl_SetCheckButton( pEntry, bChecked );
}
}
2000-09-18 16:07:07 +00:00
2000-11-27 19:41:26 +00:00
aDicsCLB.SetUpdateMode(TRUE);
2000-09-18 16:07:07 +00:00
}
2000-11-27 19:41:26 +00:00
/* ---------------------------------------------------------------------------
2000-09-18 16:07:07 +00:00
---------------------------------------------------------------------------*/
2000-11-27 19:41:26 +00:00
IMPL_LINK( SvxEditModulesDlg, SelectHdl_Impl, SvxCheckListBox *, pBox )
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
if (&aModulesCLB == pBox)
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
sal_Bool bDisableUp = sal_True;
sal_Bool bDisableDown = sal_True;
SvLBoxEntry *pEntry = pBox->GetCurEntry();
if (pEntry)
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
ModuleUserData_Impl* pData = (ModuleUserData_Impl*)pEntry->GetUserData();
if(!pData->IsParent() && pData->GetType() != TYPE_HYPH)
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
USHORT nCurPos = pBox->GetSelectEntryPos();
if(nCurPos < pBox->GetEntryCount() - 1)
2000-11-27 19:41:26 +00:00
{
bDisableDown = ((ModuleUserData_Impl*)pBox->
GetEntry(nCurPos + 1)->GetUserData())->IsParent();
2000-11-27 19:41:26 +00:00
}
if(nCurPos > 1)
{
bDisableUp = ((ModuleUserData_Impl*)pBox->
GetEntry(nCurPos - 1)->GetUserData())->IsParent();
2000-11-27 19:41:26 +00:00
}
2000-09-18 16:07:07 +00:00
}
2000-11-27 19:41:26 +00:00
aPrioUpPB.Enable(!bDisableUp);
aPrioDownPB.Enable(!bDisableDown);
}
}
else if (&aDicsCLB == pBox)
{
SvLBoxEntry *pEntry = pBox->GetCurEntry();
if (pEntry)
{
DicUserData aData( (ULONG) pEntry->GetUserData() );
aEditPB .Enable( aData.IsEditable() );
aDeletePB.Enable( aData.IsDeletable() );
2000-09-18 16:07:07 +00:00
}
}
else
{
2000-11-27 19:41:26 +00:00
DBG_ERROR( "pBox unexpected value" );
2000-09-18 16:07:07 +00:00
}
2000-11-27 19:41:26 +00:00
return 0;
2000-09-18 16:07:07 +00:00
}
/* -----------------------------30.01.01 10:50--------------------------------
---------------------------------------------------------------------------*/
IMPL_LINK( SvxEditModulesDlg, CheckButtonHdl_Impl, SvTreeListBox *, pBox )
{
if (pBox == &aModulesCLB)
{
SvLBoxEntry *pCurEntry = pBox->GetCurEntry();
if (pCurEntry)
{
ModuleUserData_Impl* pData = (ModuleUserData_Impl *)
pCurEntry->GetUserData();
if (!pData->IsParent() && pData->GetType() == TYPE_HYPH)
{
// make hyphenator checkboxes function as radio-buttons
// (at most one box may be checked)
SvLBoxEntry *pEntry = pBox->First();
while (pEntry)
{
pData = (ModuleUserData_Impl *) pEntry->GetUserData();
if (!pData->IsParent() &&
pData->GetType() == TYPE_HYPH &&
pEntry != pCurEntry)
{
lcl_SetCheckButton( pEntry, FALSE );
pBox->InvalidateEntry( pEntry );
}
pEntry = pBox->Next( pEntry );
}
}
}
}
return 0;
}
2000-11-27 19:41:26 +00:00
/* -----------------------------27.11.00 14:00--------------------------------
2000-09-18 16:07:07 +00:00
2000-11-27 19:41:26 +00:00
---------------------------------------------------------------------------*/
OUString lcl_GetServiceName(BYTE nType)
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
switch(nType)
{
case TYPE_SPELL: return C2U(cSpell);
case TYPE_HYPH: return C2U(cHyph);
case TYPE_THES: return C2U(cThes);
}
return OUString();
2000-09-18 16:07:07 +00:00
}
2000-11-27 19:41:26 +00:00
IMPL_LINK( SvxEditModulesDlg, LangSelectHdl_Impl, ListBox *, pBox )
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
LanguageType eCurLanguage = aLanguageLB.GetSelectLanguage();
static Locale aLastLocale;
Locale aCurLocale;
SvxLanguageToLocale(aCurLocale, eCurLanguage);
SvLBoxTreeList *pModel = aModulesCLB.GetModel();
Reference<XLinguServiceManager>& xMgr = rLinguData.GetManager();
if(pBox)
2000-09-18 16:07:07 +00:00
{
2000-11-28 01:36:08 +00:00
sal_Int32 nStart = 0, nLocalIndex = 0;
2000-11-27 19:41:26 +00:00
Sequence<OUString> aChange;
sal_Bool bChanged = FALSE;
2000-12-07 08:15:28 +00:00
for(USHORT i = 0; i < aModulesCLB.GetEntryCount(); i++)
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
SvLBoxEntry *pEntry = aModulesCLB.GetEntry(i);
ModuleUserData_Impl* pData = (ModuleUserData_Impl*)pEntry->GetUserData();
if(pData->IsParent())
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
if(bChanged)
{
aChange.realloc(nStart);
xMgr->setConfiguredServices(
2000-11-28 01:36:08 +00:00
lcl_GetServiceName(pData->GetType() - 1), aLastLocale, aChange);
2000-11-27 19:41:26 +00:00
}
2000-11-28 01:36:08 +00:00
nLocalIndex = nStart = 0;
2000-11-27 19:41:26 +00:00
aChange.realloc(aModulesCLB.GetEntryCount());
bChanged = FALSE;
}
else
{
OUString* pChange = aChange.getArray();
pChange[nStart] = pData->GetImplName();
2000-11-28 01:36:08 +00:00
bChanged |= pData->GetIndex() != nLocalIndex ||
2000-11-27 19:41:26 +00:00
pData->IsChecked() != aModulesCLB.IsChecked(i);
if(aModulesCLB.IsChecked(i))
nStart++;
2000-11-28 01:36:08 +00:00
++nLocalIndex;
2000-09-18 16:07:07 +00:00
}
}
2000-11-27 19:41:26 +00:00
if(bChanged)
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
aChange.realloc(nStart);
xMgr->setConfiguredServices(lcl_GetServiceName(TYPE_THES), aLastLocale, aChange);
2000-09-18 16:07:07 +00:00
}
2000-11-27 19:41:26 +00:00
}
2000-09-18 16:07:07 +00:00
2000-11-27 19:41:26 +00:00
for(ULONG i = 0; i < aModulesCLB.GetEntryCount(); i++)
delete (ModuleUserData_Impl*)aModulesCLB.GetEntry(i)->GetUserData();
aModulesCLB.Clear();
if(LANGUAGE_DONTKNOW != eCurLanguage)
{
2001-01-18 14:19:25 +00:00
sal_Int32 nEntryPos = 1;
sal_uInt16 n;
2000-11-27 19:41:26 +00:00
SvLBoxEntry* pEntry = CreateEntry( sSpell, CBCOL_SECOND );
2001-01-18 14:19:25 +00:00
ModuleUserData_Impl* pUserData = new ModuleUserData_Impl( String(), TRUE, FALSE, TYPE_SPELL, 0 );
2000-11-27 19:41:26 +00:00
pEntry->SetUserData( (void *)pUserData );
pModel->Insert( pEntry );
const ServiceInfoArr& rAllDispSrvcArr = rLinguData.GetDisplayServiceArray();
Sequence<OUString> aSpellSrvc = xMgr->getConfiguredServices(C2U(cSpell), aCurLocale);
2001-01-18 14:19:25 +00:00
sal_Int32 nLocalIndex = 0; // index relative to parent
2000-11-27 19:41:26 +00:00
for(n = 0; n < rAllDispSrvcArr.Count(); n++)
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
ServiceInfo_Impl* pInfo = rAllDispSrvcArr[n];
2001-01-18 14:19:25 +00:00
const OUString &rImplName = pInfo->sSpellImplName;
if (rImplName.getLength())
{
SvLBoxEntry* pEntry = CreateEntry( pInfo->sDisplayName, CBCOL_FIRST );
BOOL bChecked = lcl_SeqHasEntry( aSpellSrvc, rImplName );
lcl_SetCheckButton( pEntry, bChecked );
pUserData = new ModuleUserData_Impl( rImplName, FALSE,
bChecked, TYPE_SPELL, nLocalIndex++ );
pEntry->SetUserData( (void *)pUserData );
pModel->Insert( pEntry );
}
2000-09-18 16:07:07 +00:00
}
2000-11-27 19:41:26 +00:00
pEntry = CreateEntry( sHyph, CBCOL_SECOND );
pUserData = new ModuleUserData_Impl( String(), TRUE, FALSE, TYPE_HYPH, 0 );
pEntry->SetUserData( (void *)pUserData );
pModel->Insert( pEntry );
Sequence<OUString> aHyphSrvc = xMgr->getConfiguredServices(C2U(cHyph), aCurLocale);
2001-01-18 14:19:25 +00:00
nLocalIndex = 0;
2000-11-27 19:41:26 +00:00
for(n = 0; n < rAllDispSrvcArr.Count(); n++)
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
ServiceInfo_Impl* pInfo = rAllDispSrvcArr[n];
2001-01-18 14:19:25 +00:00
const OUString &rImplName = pInfo->sHyphImplName;
if (rImplName.getLength())
{
SvLBoxEntry* pEntry = CreateEntry( pInfo->sDisplayName, CBCOL_FIRST );
BOOL bChecked = lcl_SeqHasEntry( aHyphSrvc, rImplName );
lcl_SetCheckButton( pEntry, bChecked );
pUserData = new ModuleUserData_Impl( rImplName, FALSE,
bChecked, TYPE_HYPH, nLocalIndex++ );
pEntry->SetUserData( (void *)pUserData );
pModel->Insert( pEntry );
}
2000-09-18 16:07:07 +00:00
}
2000-11-27 19:41:26 +00:00
pEntry = CreateEntry( sThes, CBCOL_SECOND );
pUserData = new ModuleUserData_Impl( String(), TRUE, FALSE, TYPE_THES, 0 );
pEntry->SetUserData( (void *)pUserData );
pModel->Insert( pEntry );
2000-09-18 16:07:07 +00:00
2000-11-27 19:41:26 +00:00
Sequence<OUString> aThesSrvc = xMgr->getConfiguredServices(C2U(cThes), aCurLocale);
2001-01-18 14:19:25 +00:00
nLocalIndex = 0;
2000-11-27 19:41:26 +00:00
for(n = 0; n < rAllDispSrvcArr.Count(); n++)
{
ServiceInfo_Impl* pInfo = rAllDispSrvcArr[n];
2000-09-18 16:07:07 +00:00
2001-01-18 14:19:25 +00:00
const OUString &rImplName = pInfo->sThesImplName;
if (rImplName.getLength())
{
SvLBoxEntry* pEntry = CreateEntry( pInfo->sDisplayName, CBCOL_FIRST );
BOOL bChecked = lcl_SeqHasEntry( aThesSrvc, rImplName );
lcl_SetCheckButton( pEntry, bChecked );
pUserData = new ModuleUserData_Impl( rImplName, FALSE,
bChecked, TYPE_THES, nLocalIndex++ );
pEntry->SetUserData( (void *)pUserData );
pModel->Insert( pEntry );
}
2000-11-27 19:41:26 +00:00
}
}
aLastLocale.Language = aCurLocale.Language;
aLastLocale.Country = aCurLocale.Country;
return 0;
2000-09-18 16:07:07 +00:00
}
2000-11-27 19:41:26 +00:00
/* -----------------------------27.11.00 19:50--------------------------------
2000-09-18 16:07:07 +00:00
2000-11-27 19:41:26 +00:00
---------------------------------------------------------------------------*/
IMPL_LINK( SvxEditModulesDlg, UpDownHdl_Impl, PushButton *, pBtn )
2000-09-18 16:07:07 +00:00
{
2000-11-28 01:36:08 +00:00
aModulesCLB.SetUpdateMode(FALSE);
2000-11-27 19:41:26 +00:00
sal_Bool bUp = &aPrioUpPB == pBtn;
USHORT nCurPos = aModulesCLB.GetSelectEntryPos();
SvLBoxEntry* pEntry = aModulesCLB.GetEntry(nCurPos);
SvLBoxTreeList *pModel = aModulesCLB.GetModel();
ModuleUserData_Impl* pData = (ModuleUserData_Impl*)pEntry->GetUserData();
SvLBoxEntry* pToInsert = CreateEntry( aModulesCLB.GetEntryText(pEntry), CBCOL_FIRST );
pToInsert->SetUserData( (void *)pData);
2000-11-28 01:36:08 +00:00
BOOL bIsChecked = aModulesCLB.IsChecked(nCurPos);
2000-11-27 19:41:26 +00:00
pModel->Remove(pEntry);
2000-11-28 01:36:08 +00:00
USHORT nDestPos = bUp ? nCurPos - 1 : nCurPos + 1;
pModel->Insert(pToInsert, nDestPos);
aModulesCLB.CheckEntryPos(nDestPos, bIsChecked );
aModulesCLB.SelectEntryPos(nDestPos );
aModulesCLB.SetUpdateMode(TRUE);
SelectHdl_Impl(&aModulesCLB);
2000-11-28 12:03:40 +00:00
2000-11-27 19:41:26 +00:00
return 0;
2000-09-18 16:07:07 +00:00
}
2000-11-27 19:41:26 +00:00
/* ---------------------------------------------------------------------------
2000-09-18 16:07:07 +00:00
---------------------------------------------------------------------------*/
2000-11-27 19:41:26 +00:00
IMPL_LINK( SvxEditModulesDlg, ClickHdl_Impl, PushButton *, pBtn )
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
if (&aClosePB == pBtn)
{
// store language config
LangSelectHdl_Impl(&aLanguageLB);
2000-09-18 16:07:07 +00:00
Sequence< OUString > aActiveDics;
INT32 nActiveDics = 0;
2000-11-27 19:41:26 +00:00
// activate dictionaries according to checkbox state
ULONG nEntries = aDicsCLB.GetEntryCount();
for (ULONG i = 0; i < nEntries; ++i)
{
INT32 nDics = aDics.getLength();
const Reference< XDictionary > *pDic = aDics.getConstArray();
2000-09-18 16:07:07 +00:00
aActiveDics.realloc( nDics );
OUString *pActiveDic = aActiveDics.getArray();
2000-11-27 19:41:26 +00:00
SvLBoxEntry *pEntry = aDicsCLB.GetEntry( i );
if (pEntry)
{
DicUserData aData( (ULONG)pEntry->GetUserData() );
if (aData.GetEntryId() < nDics)
{
BOOL bChecked = aDicsCLB.IsChecked( (USHORT) i );
Reference< XDictionary > xDic( aDics.getConstArray()[ i ] );
if (xDic.is())
{
if (SvxGetIgnoreAllList() == xDic)
bChecked = TRUE;
xDic->setActive( bChecked );
if (bChecked)
{
String aDicName( xDic->getName() );
pActiveDic[ nActiveDics++ ] = aDicName;
}
2000-11-27 19:41:26 +00:00
}
}
}
}
aActiveDics.realloc( nActiveDics );
Any aTmp;
aTmp <<= aActiveDics;
SvtLinguConfig aLngCfg;
aLngCfg.SetProperty( UPH_ACTIVE_DICTIONARIES, aTmp );
2000-11-27 19:41:26 +00:00
EndDialog( RET_OK );
}
else if (&aNewPB == pBtn)
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
SvxNewDictionaryDialog aDlg( this, Reference< XSpellChecker1 >() );
Reference< XDictionary1 > xNewDic;
if ( aDlg.Execute() == RET_OK )
xNewDic = aDlg.GetNewDictionary();
if ( xNewDic.is() )
{
UpdateDicBox_Impl();
}
}
else if (&aEditPB == pBtn)
{
SvLBoxEntry *pEntry = aDicsCLB.GetCurEntry();
if (pEntry)
{
DicUserData aData( (ULONG) pEntry->GetUserData() );
USHORT nDicPos = aData.GetEntryId();
INT32 nDics = aDics.getLength();
if (nDicPos < nDics)
{
Reference< XDictionary > xDic;
xDic = aDics.getConstArray()[ nDicPos ];
if (xDic.is())
{
SvxEditDictionaryDialog aDlg( this,
xDic->getName(), Reference< XSpellChecker1 >() );
aDlg.Execute();
USHORT nOldPos = aDicsCLB.GetSelectEntryPos();
UpdateDicBox_Impl();
aDicsCLB.SelectEntryPos( nOldPos );
}
}
}
}
else if (&aDeletePB == pBtn)
{
if ( RET_NO ==
QueryBox( this, ResId( RID_SFXQB_DELDICT, DIALOG_MGR() ) ).Execute() )
return 0;
SvLBoxEntry *pEntry = aDicsCLB.GetCurEntry();
if (pEntry)
{
DicUserData aData( (ULONG) pEntry->GetUserData() );
USHORT nDicPos = aData.GetEntryId();
INT32 nDics = aDics.getLength();
if (nDicPos < nDics)
{
Reference< XDictionary > xDic;
xDic = aDics.getConstArray()[ nDicPos ];
if (xDic.is())
{
if (SvxGetIgnoreAllList() == xDic)
xDic->clear();
else
{
if (xDicList.is())
xDicList->removeDictionary( xDic );
Reference< frame::XStorable > xStor( xDic, UNO_QUERY );
if ( xStor->hasLocation() && !xStor->isReadonly() )
{
String sURL = xStor->getLocation();
INetURLObject aObj(sURL);
DBG_ASSERT( aObj.GetProtocol() == INET_PROT_FILE,
"non-file URLs cannot be deleted" );
if ( aObj.GetProtocol() == INET_PROT_FILE )
{
KillFile_Impl( aObj.GetMainURL() );
}
}
UpdateDicBox_Impl();
}
}
}
}
2000-09-18 16:07:07 +00:00
}
else
{
2000-11-27 19:41:26 +00:00
DBG_ERROR( "pBtn unexpected value" );
2000-09-18 16:07:07 +00:00
}
2000-11-27 19:41:26 +00:00
2000-09-18 16:07:07 +00:00
return 0;
}
2000-11-27 19:41:26 +00:00
/* -----------------------------27.11.00 20:31--------------------------------
2000-09-18 16:07:07 +00:00
---------------------------------------------------------------------------*/
2000-11-27 19:41:26 +00:00
IMPL_LINK( SvxEditModulesDlg, BackHdl_Impl, PushButton *, pBtn )
2000-09-18 16:07:07 +00:00
{
2000-11-27 19:41:26 +00:00
LangSelectHdl_Impl(0);
2000-09-18 16:07:07 +00:00
return 0;
}