summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorjp <jp@openoffice.org>2001-03-27 20:47:24 +0000
committerjp <jp@openoffice.org>2001-03-27 20:47:24 +0000
commit9c1da174507048998107482857b1fc1b60ca0197 (patch)
treed0b618bae018f0ae2eaa9f82adb3f799585c1979 /sw
parentff9e2454368c148cdd5c0580bf19ec14f51d4593 (diff)
optimize SeachOption initialisation
Diffstat (limited to 'sw')
-rw-r--r--sw/source/ui/index/idxmrk.cxx59
-rw-r--r--sw/source/ui/uiview/srcview.cxx110
-rw-r--r--sw/source/ui/uiview/view2.cxx39
-rw-r--r--sw/source/ui/uiview/viewsrch.cxx138
4 files changed, 91 insertions, 255 deletions
diff --git a/sw/source/ui/index/idxmrk.cxx b/sw/source/ui/index/idxmrk.cxx
index 41cea27463ae..3ce7417a2150 100644
--- a/sw/source/ui/index/idxmrk.cxx
+++ b/sw/source/ui/index/idxmrk.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: idxmrk.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: tl $ $Date: 2001-03-19 15:59:00 $
+ * last change: $Author: jp $ $Date: 2001-03-27 21:47:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,6 +68,11 @@
#ifndef _HINTIDS_HXX
#include <hintids.hxx>
#endif
+#ifndef _HELPID_H
+#include <helpid.h>
+#endif
+#define _SVSTDARR_STRINGSSORT
+#include <svtools/svstdarr.hxx>
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
@@ -94,10 +99,6 @@
#include <com/sun/star/lang/Locale.hpp>
#endif
-#include "helpid.h"
-#define _SVSTDARR_STRINGSSORT
-#include <svtools/svstdarr.hxx>
-
#ifndef _SFXSTRITEM_HXX //autogen
#include <svtools/stritem.hxx>
#endif
@@ -182,6 +183,7 @@ using namespace com::sun::star;
using namespace com::sun::star::i18n;
using namespace com::sun::star::lang;
using namespace com::sun::star::util;
+using namespace com::sun::star::i18n;
using namespace ::rtl;
using namespace ::comphelper;
using namespace ::com::sun::star;
@@ -471,43 +473,15 @@ void lcl_SelectSameStrings(SwWrtShell& rSh, BOOL bWordOnly, BOOL bCaseSensitive)
{
rSh.Push();
-// utl::SearchParam aParam( rSh.GetSelTxt(), utl::SearchParam::SRCH_NORMAL,
-// TRUE, FALSE, FALSE );
-
-// aParam.SetCaseSensitive( bCaseSensitive );
-// aParam.SetSrchWordOnly( bWordOnly );
-
- //SearchAlgorithms eSrchType = SearchAlgorithms_ABSOLUTE;
- //OUString aSrchStr = rText;
- //BOOL bCaseSensitive = TRUE;
- //BOOL bWordOnly = FALSE;
- BOOL bSrchInSel = FALSE;
- BOOL bLEV_Relaxed = TRUE;
- INT32 nLEV_Other = 2; // -> changedChars;
- INT32 nLEV_Longer = 3; //! -> deletedChars;
- INT32 nLEV_Shorter = 1; //! -> insertedChars;
- INT32 nTransliterationFlags = 0;
- //
- INT32 nSrchFlags = 0;
- if (!bCaseSensitive)
- {
- //nSrchFlags |= SearchFlags::ALL_IGNORE_CASE;
- nTransliterationFlags |= TransliterationModules_IGNORE_CASE;
- }
- if ( bWordOnly)
- nSrchFlags |= SearchFlags::NORM_WORD_ONLY;
- if ( bLEV_Relaxed)
- nSrchFlags |= SearchFlags::LEV_RELAXED;
- if ( bSrchInSel)
- nSrchFlags |= (SearchFlags::REG_NOT_BEGINOFLINE |
- SearchFlags::REG_NOT_ENDOFLINE );
- //
SearchOptions aSearchOpt(
- SearchAlgorithms_ABSOLUTE, nSrchFlags,
+ SearchAlgorithms_ABSOLUTE,
+ ( bWordOnly ? SearchFlags::NORM_WORD_ONLY : 0 ),
rSh.GetSelTxt(), OUString(),
- CreateLocale( LANGUAGE_SYSTEM ),
- nLEV_Other, nLEV_Longer, nLEV_Shorter,
- nTransliterationFlags );
+ CreateLocale( GetAppLanguage() ),
+ 0, 0, 0,
+ (bCaseSensitive
+ ? 0
+ : TransliterationModules_IGNORE_CASE) );
rSh.ClearMark();
ULONG nRet = rSh.Find( aSearchOpt, DOCPOS_START, DOCPOS_END,
@@ -1810,6 +1784,9 @@ void SwAuthMarkModalDlg::Apply()
/*------------------------------------------------------------------------
$Log: not supported by cvs2svn $
+ Revision 1.7 2001/03/19 15:59:00 tl
+ use TransliterationModules_IGNORE_CASE now
+
Revision 1.6 2001/03/12 08:17:20 tl
SearcParam => SearchOptions and implied changes
diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx
index e253b568c128..36d543f294d0 100644
--- a/sw/source/ui/uiview/srcview.cxx
+++ b/sw/source/ui/uiview/srcview.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: srcview.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: jp $ $Date: 2001-03-23 15:54:23 $
+ * last change: $Author: jp $ $Date: 2001-03-27 21:43:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -245,6 +245,7 @@ using namespace com::sun::star::i18n;
using namespace com::sun::star::lang;
using namespace com::sun::star::util;
using namespace com::sun::star::uno;
+using namespace com::sun::star::i18n;
#define C2S(cChar) UniString::CreateFromAscii(cChar)
@@ -831,90 +832,40 @@ USHORT SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem,
{
ExtTextView* pTextView = aEditWin.GetTextView();
TextSelection aSel;
+ TextPaM aPaM;
+
BOOL bForward = !rSearchItem.GetBackward();
- BOOL bAtStart = pTextView->GetSelection() == TextSelection( TextPaM( 0x0, 0x0 ), TextPaM( 0x0, 0x0 ) );
- if ( bFromStart )
+ BOOL bAtStart = pTextView->GetSelection() == TextSelection( aPaM, aPaM );
+
+ if( !bForward )
+ aPaM = TextPaM( (ULONG)-1, (USHORT)-1 );
+
+ if( bFromStart )
{
aSel = pTextView->GetSelection();
- if ( !rSearchItem.GetBackward() )
- pTextView->SetSelection( TextSelection( TextPaM( 0x0, 0x0 ), TextPaM( 0x0, 0x0 ) ) );
- else
- pTextView->SetSelection( TextSelection( TextPaM( 0xFFFFFFFF, 0xFFFF ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) );
+ pTextView->SetSelection( TextSelection( aPaM, aPaM ));
}
-#ifdef NEVER
- utl::SearchParam aSearchParam( rSearchItem.GetSearchString(),
- utl::SearchParam::SRCH_NORMAL, rSearchItem.GetExact(),
- rSearchItem.GetWordOnly(), rSearchItem.GetSelection() );
- if ( rSearchItem.GetRegExp() )
- aSearchParam.SetSrchType( utl::SearchParam::SRCH_REGEXP );
- else if ( rSearchItem.IsLevenshtein() )
- {
- aSearchParam.SetSrchType( utl::SearchParam::SRCH_LEVDIST );
- aSearchParam.SetSrchRelaxed( rSearchItem.IsLEVRelaxed() ? TRUE : FALSE );
- aSearchParam.SetLEVOther( rSearchItem.GetLEVOther() );
- aSearchParam.SetLEVShorter( rSearchItem.GetLEVShorter() );
- aSearchParam.SetLEVLonger( rSearchItem.GetLEVLonger() );
- }
-#endif
+ SearchOptions aSearchOpt( rSearchItem.GetSearchOptions() );
+ aSearchOpt.Locale = CreateLocale( GetAppLanguage() );
- SearchAlgorithms eSrchType = SearchAlgorithms_ABSOLUTE;
- //OUString aSrchStr = rText;
- BOOL bCaseSensitive = rSearchItem.GetExact();
- BOOL bWordOnly = rSearchItem.GetWordOnly();
- BOOL bSrchInSel = rSearchItem.GetSelection();
- BOOL bLEV_Relaxed = TRUE;
- INT32 nLEV_Other = 2; // -> changedChars;
- INT32 nLEV_Longer = 3; //! -> deletedChars;
- INT32 nLEV_Shorter = 1; //! -> insertedChars;
- INT32 nTransliterationFlags = 0;
- //
- if ( rSearchItem.GetRegExp() )
- eSrchType = SearchAlgorithms_REGEXP;
- else if ( rSearchItem.IsLevenshtein() )
- {
- eSrchType = SearchAlgorithms_APPROXIMATE;
- bLEV_Relaxed = rSearchItem.IsLEVRelaxed();
- nLEV_Other = rSearchItem.GetLEVOther();
- nLEV_Longer = rSearchItem.GetLEVLonger();
- nLEV_Shorter = rSearchItem.GetLEVShorter();
- }
- //
- INT32 nSrchFlags = 0;
- if (!bCaseSensitive)
- {
- //nSrchFlags |= SearchFlags::ALL_IGNORE_CASE;
- nTransliterationFlags |= TransliterationModules_IGNORE_CASE;
- }
- if ( bWordOnly)
- nSrchFlags |= SearchFlags::NORM_WORD_ONLY;
- if ( bLEV_Relaxed)
- nSrchFlags |= SearchFlags::LEV_RELAXED;
- if ( bSrchInSel)
- nSrchFlags |= (SearchFlags::REG_NOT_BEGINOFLINE |
- SearchFlags::REG_NOT_ENDOFLINE );
- //
- SearchOptions aSearchOpt(
- eSrchType, nSrchFlags,
- rSearchItem.GetSearchString(), rtl::OUString(),
- CreateLocale( LANGUAGE_SYSTEM ),
- nLEV_Other, nLEV_Longer, nLEV_Shorter,
- nTransliterationFlags );
-
- USHORT nFound = 0;
- if ( ( rSearchItem.GetCommand() == SVX_SEARCHCMD_FIND ) ||
- ( rSearchItem.GetCommand() == SVX_SEARCHCMD_FIND_ALL ) )
+ USHORT nFound;
+ BOOL bAll = FALSE;
+ switch( rSearchItem.GetCommand() )
{
+ case SVX_SEARCHCMD_FIND:
+ case SVX_SEARCHCMD_FIND_ALL:
nFound = pTextView->Search( aSearchOpt, bForward );
- }
- else if ( ( rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE ) ||
- ( rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL ) )
- {
- aSearchOpt.replaceString = rSearchItem.GetReplaceString();
- BOOL bAll = rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL;
+ break;
+
+ case SVX_SEARCHCMD_REPLACE_ALL: bAll = TRUE;
+ case SVX_SEARCHCMD_REPLACE:
nFound = pTextView->Replace( aSearchOpt, bAll, bForward );
+ default:
+ nFound = 0;
}
- if(!nFound)
+
+ if( !nFound )
{
BOOL bNotFoundMessage = FALSE;
if(!bRecursive)
@@ -944,11 +895,8 @@ USHORT SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem,
QueryBox(0, SW_RES( bForward ? MSG_SEARCH_END
: MSG_SEARCH_START)).Execute())
{
- if ( bForward )
- pTextView->SetSelection( TextSelection( TextPaM( 0x0, 0x0 ), TextPaM( 0x0, 0x0 ) ) );
- else
- pTextView->SetSelection( TextSelection( TextPaM( 0xFFFFFFFF, 0xFFFF ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) );
- StartSearchAndReplace(rSearchItem, FALSE, FALSE, TRUE);
+ pTextView->SetSelection( TextSelection( aPaM, aPaM ) );
+ StartSearchAndReplace( rSearchItem, FALSE, FALSE, TRUE );
}
}
return nFound;
diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx
index 1eccabd0efda..4a9fe2ed40bd 100644
--- a/sw/source/ui/uiview/view2.cxx
+++ b/sw/source/ui/uiview/view2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: view2.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: tl $ $Date: 2001-03-19 16:00:27 $
+ * last change: $Author: jp $ $Date: 2001-03-27 21:43:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -294,6 +294,7 @@ using namespace com::sun::star::util;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::scanner;
+using namespace ::com::sun::star::i18n;
/*---------------------------------------------------------------------------
Beschreibung: String fuer die Seitenanzeige in der Statusbar basteln.
@@ -1187,40 +1188,12 @@ BOOL SwView::JumpToSwMark( const String& rMark )
// Normale Textsuche
pWrtShell->EnterStdMode();
-// utl::SearchParam aParam( sName, utl::SearchParam::SRCH_NORMAL,
-// TRUE, FALSE, FALSE );
-
- //SearchAlgorithms eSrchType = SearchAlgorithms_ABSOLUTE;
- //OUString aSrchStr = rText;
- BOOL bCaseSensitive = TRUE;
- BOOL bWordOnly = FALSE;
- BOOL bSrchInSel = FALSE;
- BOOL bLEV_Relaxed = TRUE;
- INT32 nLEV_Other = 2; // -> changedChars;
- INT32 nLEV_Longer = 3; //! -> deletedChars;
- INT32 nLEV_Shorter = 1; //! -> insertedChars;
- INT32 nTransliterationFlags = 0;
- //
- INT32 nSrchFlags = 0;
- if (!bCaseSensitive)
- {
- //nSrchFlags |= SearchFlags::ALL_IGNORE_CASE;
- nTransliterationFlags |= TransliterationModules_IGNORE_CASE;
- }
- if ( bWordOnly)
- nSrchFlags |= SearchFlags::NORM_WORD_ONLY;
- if ( bLEV_Relaxed)
- nSrchFlags |= SearchFlags::LEV_RELAXED;
- if ( bSrchInSel)
- nSrchFlags |= (SearchFlags::REG_NOT_BEGINOFLINE |
- SearchFlags::REG_NOT_ENDOFLINE );
- //
SearchOptions aSearchOpt(
- SearchAlgorithms_ABSOLUTE, nSrchFlags,
+ SearchAlgorithms_ABSOLUTE, 0,
sName, rtl::OUString(),
CreateLocale( LANGUAGE_SYSTEM ),
- nLEV_Other, nLEV_Longer, nLEV_Shorter,
- nTransliterationFlags );
+ 0,0,0,
+ TransliterationModules_IGNORE_CASE );
if( pWrtShell->SearchPattern( aSearchOpt, DOCPOS_START, DOCPOS_END ))
{
diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx
index 037b67963355..6014e5181540 100644
--- a/sw/source/ui/uiview/viewsrch.cxx
+++ b/sw/source/ui/uiview/viewsrch.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: viewsrch.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: tl $ $Date: 2001-03-19 16:00:48 $
+ * last change: $Author: jp $ $Date: 2001-03-27 21:43:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,18 +67,16 @@
#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
-#include "hintids.hxx"
-#include "uiparam.hxx"
+#ifndef _HINTIDS_HXX
+#include <hintids.hxx>
+#endif
+#ifndef _UIPARAM_HXX
+#include <uiparam.hxx>
+#endif
#ifndef _COM_SUN_STAR_UTIL_SEARCHOPTIONS_HPP_
#include <com/sun/star/util/SearchOptions.hpp>
#endif
-#ifndef _COM_SUN_STAR_UTIL_SEARCHFLAGS_HPP_
-#include <com/sun/star/util/SearchFlags.hpp>
-#endif
-#ifndef _COM_SUN_STAR_I18N_TRANSLITERATIONMODULES_HPP_
-#include <com/sun/star/i18n/TransliterationModules.hpp>
-#endif
#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
#include <com/sun/star/lang/Locale.hpp>
#endif
@@ -129,20 +127,37 @@
#ifndef _SWWAIT_HXX
#include <swwait.hxx>
#endif
-#include "workctrl.hxx"
-#include "view.hxx"
-#include "wrtsh.hxx"
-#include "swundo.hxx" // fuer Undo-Ids
-#include "uitool.hxx"
-#include "cmdid.h"
-#include "docsh.hxx"
+#ifndef _WORKCTRL_HXX
+#include <workctrl.hxx>
+#endif
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#ifndef _WRTSH_HXX
+#include <wrtsh.hxx>
+#endif
+#ifndef _SWUNDO_HXX
+#include <swundo.hxx> // fuer Undo-Ids
+#endif
+#ifndef _UITOOL_HXX
+#include <uitool.hxx>
+#endif
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
-#include "view.hrc"
+#ifndef _VIEW_HRC
+#include <view.hrc>
+#endif
using namespace com::sun::star;
using namespace com::sun::star::i18n;
using namespace com::sun::star::lang;
using namespace com::sun::star::util;
+using namespace com::sun::star::i18n;
#define SRCH_ATTR_OFF 0
#define SRCH_ATTR_ON 1
@@ -683,72 +698,12 @@ ULONG SwView::FUNC_Search( const SwSearchOptions& rOptions )
//
// build SearchOptions to be used
//
- SearchAlgorithms eSrchType = SearchAlgorithms_ABSOLUTE;
- rtl::OUString aSrchStr = pSrchItem->GetSearchString();
- rtl::OUString aRplcStr;
- BOOL bCaseSensitive = pSrchItem->GetExact();
- BOOL bWordOnly = pSrchItem->GetWordOnly();
- BOOL bSrchInSel = pSrchItem->GetSelection();
- BOOL bLEV_Relaxed = pSrchItem->IsLEVRelaxed();
- INT32 nLEV_Other = pSrchItem->GetLEVOther(); // -> changedChars;
- INT32 nLEV_Longer = pSrchItem->GetLEVLonger(); //! -> deletedChars;
- INT32 nLEV_Shorter = pSrchItem->GetLEVShorter(); //! -> insertedChars;
- INT32 nTransliterationFlags = 0;
- //
- if (bDoReplace)
- aRplcStr = pSrchItem->GetReplaceString();
- if (pSrchItem->IsLevenshtein())
- eSrchType = SearchAlgorithms_APPROXIMATE;
- if (pSrchItem->GetRegExp())
- eSrchType = SearchAlgorithms_REGEXP;
- //
- INT32 nSrchFlags = 0;
- if (!bCaseSensitive)
- {
- //nSrchFlags |= SearchFlags::ALL_IGNORE_CASE;
- nTransliterationFlags |= TransliterationModules_IGNORE_CASE;
- }
- if ( bWordOnly)
- nSrchFlags |= SearchFlags::NORM_WORD_ONLY;
- if ( bLEV_Relaxed)
- nSrchFlags |= SearchFlags::LEV_RELAXED;
- if ( bSrchInSel)
- nSrchFlags |= (SearchFlags::REG_NOT_BEGINOFLINE |
- SearchFlags::REG_NOT_ENDOFLINE );
- //
- SearchOptions aSearchOpt(
- eSrchType, nSrchFlags,
- aSrchStr, aRplcStr,
- CreateLocale( LANGUAGE_SYSTEM ),
- nLEV_Other, nLEV_Longer, nLEV_Shorter,
- nTransliterationFlags );
+ SearchOptions aSearchOpt( pSrchItem->GetSearchOptions() );
+ aSearchOpt.Locale = CreateLocale( GetAppLanguage() );
ULONG nFound;
if( aSrchSet.Count() || ( pReplSet && pReplSet->Count() ))
{
-#ifdef NEVER
- // Suche nach Attributen
- utl::SearchParam aPar( pSrchItem->GetSearchString() );
- if( aPar.GetSrchStr().Len() )
- {
- if( bDoReplace )
- aPar.SetReplaceStr( pSrchItem->GetReplaceString() );
- aPar.SetSrchType( pSrchItem->GetRegExp()
- ? utl::SearchParam::SRCH_REGEXP :
- pSrchItem->IsLevenshtein() ?
- utl::SearchParam::SRCH_LEVDIST :
- utl::SearchParam::SRCH_NORMAL );
- aPar.SetCaseSensitive( pSrchItem->GetExact() );
- aPar.SetSrchInSelection( pSrchItem->GetSelection() );
- aPar.SetSrchWordOnly( pSrchItem->GetWordOnly() );
-
- aPar.SetSrchRelaxed( pSrchItem->IsLEVRelaxed() );
- aPar.SetLEVOther( pSrchItem->GetLEVOther());
- aPar.SetLEVShorter( pSrchItem->GetLEVShorter());
- aPar.SetLEVLonger( pSrchItem->GetLEVLonger());
- }
-#endif
-
nFound = pWrtShell->SearchAttr(
aSrchSet,
!pSrchItem->GetPattern(),
@@ -770,26 +725,6 @@ ULONG SwView::FUNC_Search( const SwSearchOptions& rOptions )
else
{
// Normale Suche
-
-#ifdef NEVER
- utl::SearchParam aParam( pSrchItem->GetSearchString(),
- pSrchItem->GetRegExp()
- ? utl::SearchParam::SRCH_REGEXP :
- pSrchItem->IsLevenshtein() ?
- utl::SearchParam::SRCH_LEVDIST :
- utl::SearchParam::SRCH_NORMAL,
- pSrchItem->GetExact(),
- pSrchItem->GetWordOnly(),
- pSrchItem->GetSelection() );
- aParam.SetSrchRelaxed( pSrchItem->IsLEVRelaxed() );
- aParam.SetLEVOther( pSrchItem->GetLEVOther());
- aParam.SetLEVShorter( pSrchItem->GetLEVShorter());
- aParam.SetLEVLonger( pSrchItem->GetLEVLonger());
-
- if (bDoReplace)
- aParam.SetReplaceStr(pSrchItem->GetReplaceString());
-#endif
-
nFound = pWrtShell->SearchPattern(aSearchOpt,
rOptions.eStart,
rOptions.eEnd,
@@ -898,6 +833,9 @@ void SwView::StateSearch(SfxItemSet &rSet)
/*------------------------------------------------------------------------
$Log: not supported by cvs2svn $
+ Revision 1.5 2001/03/19 16:00:48 tl
+ use TransliterationModules_IGNORE_CASE now
+
Revision 1.4 2001/03/12 08:12:45 tl
SearcParam => SearchOptions and implied changes