Kaydet (Commit) 42148901 authored tarafından Frank Meies's avatar Frank Meies

#101285# New: Sequence Input Checking for CTL

üst 8618cf01
/*************************************************************************
*
* $RCSfile: checkit.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: fme $ $Date: 2002-08-20 11:39:19 $
*
* 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): _______________________________________
*
*
************************************************************************/
#ifndef _CHECKIT_HXX
#define _CHECKIT_HXX
#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
#include <com/sun/star/uno/Reference.h>
#endif
#ifndef _DRAFTS_COM_SUN_STAR_I18N_XINPUTSEQUENCECHECKER_HPP_
#include <drafts/com/sun/star/i18n/XInputSequenceChecker.hpp>
#endif
/*************************************************************************
* Input strings with length > MAX_SEQUENCE_CHECK_LEN are not checked.
*************************************************************************/
#define MAX_SEQUENCE_CHECK_LEN 5
/*************************************************************************
* class SwCheckIt
*
* Wrapper for the XInputSequenceChecker
*************************************************************************/
class SwCheckIt
{
public:
com::sun::star::uno::Reference < drafts::com::sun::star::i18n::XInputSequenceChecker > xCheck;
SwCheckIt();
};
extern SwCheckIt* pCheckIt;
#endif
/*************************************************************************
*
* $RCSfile: checkit.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: fme $ $Date: 2002-08-20 11:40:32 $
*
* 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): _______________________________________
*
*
************************************************************************/
#ifdef PRECOMPILED
#include "core_pch.hxx"
#endif
#pragma hdrstop
#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 _CHECKIT_HXX
#include <checkit.hxx>
#endif
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace drafts::com::sun::star::i18n;
SwCheckIt::SwCheckIt()
{
Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
Reference < XInterface > xI = xMSF->createInstance(
::rtl::OUString::createFromAscii( "com.sun.star.i18n.InputSequenceChecker" ) );
if ( xI.is() )
{
Any x = xI->queryInterface( ::getCppuType((const Reference< XInputSequenceChecker >*)0) );
x >>= xCheck;
}
}
......@@ -2,9 +2,9 @@
*
* $RCSfile: init.cxx,v $
*
* $Revision: 1.33 $
* $Revision: 1.34 $
*
* last change: $Author: fme $ $Date: 2002-08-05 10:52:20 $
* last change: $Author: fme $ $Date: 2002-08-20 11:44:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -360,6 +360,10 @@
#ifndef _BREAKIT_HXX
#include <breakit.hxx>
#endif
#ifndef _CHECKIT_HXX
#include <checkit.hxx>
#endif
#ifndef _SWCALWRP_HXX
#include <swcalwrp.hxx>
#endif
......@@ -642,6 +646,7 @@ SvPtrarr *pGlobalOLEExcludeList = 0;
SwAutoCompleteWord* SwDoc::pACmpltWords = 0;
SwBreakIt* pBreakIt = 0;
SwCheckIt* pCheckIt = 0;
CharClass* pAppCharClass = 0;
SwCalendarWrapper* pCalendarWrapper = 0;
CollatorWrapper* pCollator = 0, *pCaseCollator = 0;
......@@ -935,6 +940,7 @@ void _InitCore()
pBreakIt = new SwBreakIt;
const ::com::sun::star::lang::Locale& rLcl = pBreakIt->GetLocale(
(LanguageType)GetAppLanguage() );
pCheckIt = NULL;
::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory > xMSF =
::comphelper::getProcessServiceFactory();
......@@ -968,6 +974,7 @@ void _FinitCore()
_TextFinit();
delete pBreakIt;
delete pCheckIt;
delete pAppCharClass;
delete pCalendarWrapper;
delete pCollator;
......
......@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1.1.1 $
# $Revision: 1.2 $
#
# last change: $Author: hr $ $Date: 2000-09-19 00:08:16 $
# last change: $Author: fme $ $Date: 2002-08-20 11:41:10 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
......@@ -83,6 +83,7 @@ CXXFILES = \
bparr.cxx \
breakit.cxx \
calc.cxx \
checkit.cxx \
index.cxx \
init.cxx \
ring.cxx \
......@@ -96,6 +97,7 @@ SLOFILES = \
$(SLO)$/bparr.obj \
$(SLO)$/breakit.obj \
$(SLO)$/calc.obj \
$(SLO)$/checkit.obj \
$(SLO)$/index.obj \
$(SLO)$/init.obj \
$(SLO)$/ring.obj \
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: ndtxt.cxx,v $
*
* $Revision: 1.10 $
* $Revision: 1.11 $
*
* last change: $Author: mib $ $Date: 2002-05-23 14:54:03 $
* last change: $Author: fme $ $Date: 2002-08-20 11:42:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -67,6 +67,12 @@
#include <hintids.hxx>
#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_
#include <com/sun/star/i18n/ScriptType.hdl>
#endif
#ifndef _DRAFTS_COM_SUN_STAR_I18N_XINPUTSEQUENCECHECKER_HPP_
#include <drafts/com/sun/star/i18n/InputSequenceCheckMode.hpp>
#endif
#ifndef _SVX_FONTITEM_HXX //autogen
#include <svx/fontitem.hxx>
#endif
......@@ -82,6 +88,9 @@
#ifndef SVTOOLS_URIHELPER_HXX
#include <svtools/urihelper.hxx>
#endif
#ifndef _SVTOOLS_LANGUAGEOPTIONS_HXX
#include <svtools/languageoptions.hxx>
#endif
#ifndef _TXTFLD_HXX //autogen
#include <txtfld.hxx>
......@@ -206,7 +215,12 @@
#ifndef _BOOKMRK_HXX
#include <bookmrk.hxx>
#endif
#ifndef _BREAKIT_HXX
#include <breakit.hxx>
#endif
#ifndef _CHECKIT_HXX
#include <checkit.hxx>
#endif
SV_DECL_PTRARR( TmpHints, SwTxtAttr*, 0, 4 )
......@@ -1596,9 +1610,51 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr,
ASSERT( rIdx <= aText.Len(), "Array ueberindiziert." );
ASSERT( (ULONG)aText.Len() + (ULONG)rStr.Len() <= STRING_LEN,
"STRING_LEN ueberschritten." );
xub_StrLen aPos = rIdx.GetIndex();
xub_StrLen nLen = aText.Len() - aPos;
aText.Insert( rStr, aPos );
// sequence input checking
sal_Bool bInputChecked = sal_False;
// We check only buffers which contain less than MAX_SEQUENCE_CHECK_LEN
// characters. This is for performance reasons, because a "copy and paste"
// can give us a really big input string.
SvtLanguageOptions aLangOptions;
if ( aLangOptions.IsCTLFontEnabled() &&
aLangOptions.IsCTLSequenceChecking() && aPos &&
rStr.Len() < MAX_SEQUENCE_CHECK_LEN && pBreakIt->xBreak.is() &&
::com::sun::star::i18n::ScriptType::COMPLEX ==
pBreakIt->xBreak->getScriptType( rStr, 0 ) )
{
// generate new sequence input checker if not already done
if ( ! pCheckIt )
pCheckIt = new SwCheckIt;
if ( pCheckIt->xCheck.is() )
{
xub_StrLen nI = 0;
xub_StrLen nTmpPos = aPos;
xub_Unicode cChar;
while ( nI < rStr.Len() )
{
cChar = rStr.GetChar( nI++ );
if ( pCheckIt->xCheck->checkInputSequence(
aText, nTmpPos - 1, cChar,
::drafts::com::sun::star::i18n::InputSequenceCheckMode::BASIC ) )
{
// character can be inserted
aText.Insert( cChar, nTmpPos++ );
}
}
bInputChecked = sal_True;
}
}
if ( ! bInputChecked )
aText.Insert( rStr, aPos );
nLen = aText.Len() - aPos - nLen;
if( !nLen ) // String nicht gewachsen ??
return *this;
......@@ -1612,7 +1668,7 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr,
if( pSwpHints )
{
for( i = 0; i < pSwpHints->Count() &&
for( i = 0; i < pSwpHints->Count() &&
rIdx >= *(*pSwpHints)[i]->GetStart(); ++i )
{
SwTxtAttr *pHt = pSwpHints->GetHt( i );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment