LCOV - code coverage report
Current view: top level - svx/source/dialog - srchdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1297 0.1 %
Date: 2012-08-25 Functions: 2 63 3.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 2637 0.1 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <sal/macros.h>
      31                 :            : #include <vcl/wrkwin.hxx>
      32                 :            : #include <vcl/morebtn.hxx>
      33                 :            : #include <vcl/msgbox.hxx>
      34                 :            : #include <svl/slstitm.hxx>
      35                 :            : #include <svl/itemiter.hxx>
      36                 :            : #include <svl/style.hxx>
      37                 :            : #include <unotools/searchopt.hxx>
      38                 :            : #include <sfx2/dispatch.hxx>
      39                 :            : #include <sfx2/objsh.hxx>
      40                 :            : #include <sfx2/module.hxx>
      41                 :            : #include <sfx2/viewsh.hxx>
      42                 :            : #include <sfx2/basedlgs.hxx>
      43                 :            : #include <svl/cjkoptions.hxx>
      44                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      45                 :            : #include <com/sun/star/i18n/TransliterationModules.hpp>
      46                 :            : #include <com/sun/star/frame/XDispatch.hpp>
      47                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      48                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      49                 :            : #include <com/sun/star/frame/XModuleManager.hpp>
      50                 :            : #include <comphelper/processfactory.hxx>
      51                 :            : #include <svl/itempool.hxx>
      52                 :            : #include <svl/intitem.hxx>
      53                 :            : 
      54                 :            : #include <sfx2/app.hxx>
      55                 :            : #include <toolkit/unohlp.hxx>
      56                 :            : 
      57                 :            : #define _SVX_SRCHDLG_CXX
      58                 :            : #include "svx/srchdlg.hxx"
      59                 :            : 
      60                 :            : #include <svx/dialogs.hrc>
      61                 :            : #include <svx/svxitems.hrc>
      62                 :            : #include "srchdlg.hrc"
      63                 :            : 
      64                 :            : 
      65                 :            : #define ITEMID_SETITEM      0
      66                 :            : 
      67                 :            : #include <svl/srchitem.hxx>
      68                 :            : #include <svx/pageitem.hxx>
      69                 :            : #include "srchctrl.hxx"
      70                 :            : #include <svx/dialmgr.hxx>
      71                 :            : #include "svx/dlgutil.hxx"
      72                 :            : #include <editeng/brshitem.hxx>
      73                 :            : #include <tools/resary.hxx>
      74                 :            : #include <svx/svxdlg.hxx>
      75                 :            : 
      76                 :            : using namespace com::sun::star::i18n;
      77                 :            : using namespace com::sun::star;
      78                 :            : using namespace comphelper;
      79                 :            : 
      80                 :            : // -----------------------------------------------------------------------
      81                 :            : 
      82                 :            : #define REMEMBER_SIZE       10
      83                 :            : 
      84                 :            : #define MODIFY_SEARCH       0x00000001
      85                 :            : #define MODIFY_REPLACE      0x00000002
      86                 :            : #define MODIFY_WORD         0x00000004
      87                 :            : #define MODIFY_EXACT        0x00000008
      88                 :            : #define MODIFY_BACKWARDS    0x00000010
      89                 :            : #define MODIFY_SELECTION    0x00000020
      90                 :            : #define MODIFY_REGEXP       0x00000040
      91                 :            : #define MODIFY_LAYOUT       0x00000080
      92                 :            : #define MODIFY_SIMILARITY   0x00000100
      93                 :            : #define MODIFY_FORMULAS     0x00000200
      94                 :            : #define MODIFY_VALUES       0x00000400
      95                 :            : #define MODIFY_CALC_NOTES   0x00000800
      96                 :            : #define MODIFY_ROWS         0x00001000
      97                 :            : #define MODIFY_COLUMNS      0x00002000
      98                 :            : #define MODIFY_ALLTABLES    0x00004000
      99                 :            : #define MODIFY_NOTES        0x00008000
     100                 :            : 
     101                 :            : #define GetCheckBoxValue( rBox )                                \
     102                 :            :     rBox.IsEnabled() ? rBox.IsChecked() : sal_False
     103                 :            : 
     104                 :            : struct SearchDlg_Impl
     105                 :            : {
     106                 :            :     FixedText   aSearchFormats;
     107                 :            :     FixedText   aReplaceFormats;
     108                 :            : 
     109                 :            :     sal_Bool        bMultiLineEdit   : 1,
     110                 :            :                 bSaveToModule    : 1,
     111                 :            :                 bFocusOnSearch   : 1,
     112                 :            :                 bDeltaCalculated : 1;
     113                 :            :     sal_uInt16*     pRanges;
     114                 :            :     Timer       aSelectionTimer;
     115                 :            : 
     116                 :            :     uno::Reference< frame::XDispatch > xCommand1Dispatch;
     117                 :            :     uno::Reference< frame::XDispatch > xCommand2Dispatch;
     118                 :            :     util::URL   aCommand1URL;
     119                 :            :     util::URL   aCommand2URL;
     120                 :            : 
     121                 :          0 :         SearchDlg_Impl( Window* pParent ) :
     122                 :          0 :         aSearchFormats  ( pParent, SVX_RES( FT_SEARCH_FORMATS ) ),
     123         [ #  # ]:          0 :         aReplaceFormats ( pParent, SVX_RES( FT_REPLACE_FORMATS ) ),
     124                 :            :         bMultiLineEdit  ( sal_False ),
     125                 :            :         bSaveToModule   ( sal_True ),
     126                 :            :         bFocusOnSearch  ( sal_True ),
     127                 :            :         bDeltaCalculated( sal_False ),
     128 [ #  # ][ #  # ]:          0 :         pRanges         ( NULL )
                 [ #  # ]
     129                 :            :         {
     130                 :          0 :             aCommand1URL.Complete = aCommand1URL.Main = rtl::OUString("vnd.sun.search:SearchViaComponent1");
     131                 :          0 :             aCommand1URL.Protocol = rtl::OUString("vnd.sun.search:");
     132                 :          0 :             aCommand1URL.Path = rtl::OUString("SearchViaComponent1");
     133                 :          0 :             aCommand2URL.Complete = aCommand2URL.Main = rtl::OUString("vnd.sun.search:SearchViaComponent2");
     134                 :          0 :             aCommand2URL.Protocol = rtl::OUString("vnd.sun.search:");
     135                 :          0 :             aCommand2URL.Path = rtl::OUString("SearchViaComponent2");
     136                 :          0 :         }
     137 [ #  # ][ #  # ]:          0 :     ~SearchDlg_Impl() { delete[] pRanges; }
                 [ #  # ]
     138                 :            : };
     139                 :            : 
     140                 :          0 : void ListToStrArr_Impl( sal_uInt16 nId, std::vector<rtl::OUString>& rStrLst, ComboBox& rCBox )
     141                 :            : {
     142                 :            :     SfxStringListItem* pSrchItem =
     143                 :          0 :         (SfxStringListItem*)SFX_APP()->GetItem( nId );
     144                 :            : 
     145         [ #  # ]:          0 :     if (pSrchItem)
     146                 :            :     {
     147 [ #  # ][ #  # ]:          0 :         std::vector<String> aLst = pSrchItem->GetList();
     148                 :            : 
     149         [ #  # ]:          0 :         for ( sal_uInt16 i = 0; i < aLst.size(); ++i )
     150                 :            :         {
     151 [ #  # ][ #  # ]:          0 :             rStrLst.push_back(aLst[i]);
                 [ #  # ]
     152 [ #  # ][ #  # ]:          0 :             rCBox.InsertEntry(aLst[i]);
     153                 :          0 :         }
     154                 :            :     }
     155                 :          0 : }
     156                 :            : 
     157                 :          0 : void StrArrToList_Impl( sal_uInt16 nId, const std::vector<rtl::OUString>& rStrLst )
     158                 :            : {
     159                 :            :     DBG_ASSERT( !rStrLst.empty(), "check in advance");
     160         [ #  # ]:          0 :     std::vector<String> aLst;
     161                 :            : 
     162 [ #  # ][ #  # ]:          0 :     for (std::vector<rtl::OUString>::const_iterator i = rStrLst.begin(); i != rStrLst.end(); ++i)
     163 [ #  # ][ #  # ]:          0 :         aLst.push_back(String(*i));
                 [ #  # ]
     164                 :            : 
     165 [ #  # ][ #  # ]:          0 :     SFX_APP()->PutItem( SfxStringListItem( nId, &aLst ) );
         [ #  # ][ #  # ]
     166                 :          0 : }
     167                 :            : 
     168                 :            : // class SearchAttrItemList ----------------------------------------------
     169                 :            : 
     170                 :          0 : SearchAttrItemList::SearchAttrItemList( const SearchAttrItemList& rList ) :
     171                 :          0 :     SrchAttrItemList(rList)
     172                 :            : {
     173         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < size(); ++i )
     174 [ #  # ][ #  # ]:          0 :         if ( !IsInvalidItem( (*this)[i].pItem ) )
     175 [ #  # ][ #  # ]:          0 :             (*this)[i].pItem = (*this)[i].pItem->Clone();
                 [ #  # ]
     176                 :          0 : }
     177                 :            : 
     178                 :            : // -----------------------------------------------------------------------
     179                 :            : 
     180                 :          0 : SearchAttrItemList::~SearchAttrItemList()
     181                 :            : {
     182         [ #  # ]:          0 :     Clear();
     183                 :          0 : }
     184                 :            : 
     185                 :            : // -----------------------------------------------------------------------
     186                 :            : 
     187                 :          0 : void SearchAttrItemList::Put( const SfxItemSet& rSet )
     188                 :            : {
     189         [ #  # ]:          0 :     if ( !rSet.Count() )
     190                 :          0 :         return;
     191                 :            : 
     192                 :          0 :     SfxItemPool* pPool = rSet.GetPool();
     193         [ #  # ]:          0 :     SfxItemIter aIter( rSet );
     194                 :            :     SearchAttrItem aItem;
     195                 :          0 :     const SfxPoolItem* pItem = aIter.GetCurItem();
     196                 :            :     sal_uInt16 nWhich;
     197                 :            : 
     198                 :          0 :     while ( sal_True )
     199                 :            :     {
     200                 :            :         // only test that it is available?
     201         [ #  # ]:          0 :         if( IsInvalidItem( pItem ) )
     202                 :            :         {
     203         [ #  # ]:          0 :             nWhich = rSet.GetWhichByPos( aIter.GetCurPos() );
     204                 :          0 :             aItem.pItem = (SfxPoolItem*)pItem;
     205                 :            :         }
     206                 :            :         else
     207                 :            :         {
     208                 :          0 :             nWhich = pItem->Which();
     209         [ #  # ]:          0 :             aItem.pItem = pItem->Clone();
     210                 :            :         }
     211                 :            : 
     212         [ #  # ]:          0 :         aItem.nSlot = pPool->GetSlotId( nWhich );
     213         [ #  # ]:          0 :         Insert( aItem );
     214                 :            : 
     215         [ #  # ]:          0 :         if ( aIter.IsAtEnd() )
     216                 :          0 :             break;
     217         [ #  # ]:          0 :         pItem = aIter.NextItem();
     218         [ #  # ]:          0 :     }
     219                 :            : }
     220                 :            : 
     221                 :            : // -----------------------------------------------------------------------
     222                 :            : 
     223                 :          0 : SfxItemSet& SearchAttrItemList::Get( SfxItemSet& rSet )
     224                 :            : {
     225                 :          0 :     SfxItemPool* pPool = rSet.GetPool();
     226                 :            : 
     227         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < size(); ++i )
     228         [ #  # ]:          0 :         if ( IsInvalidItem( (*this)[i].pItem ) )
     229                 :          0 :             rSet.InvalidateItem( pPool->GetWhich( (*this)[i].nSlot ) );
     230                 :            :         else
     231                 :          0 :             rSet.Put( *(*this)[i].pItem );
     232                 :          0 :     return rSet;
     233                 :            : }
     234                 :            : 
     235                 :            : // -----------------------------------------------------------------------
     236                 :            : 
     237                 :          0 : void SearchAttrItemList::Clear()
     238                 :            : {
     239         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < size(); ++i )
     240         [ #  # ]:          0 :         if ( !IsInvalidItem( (*this)[i].pItem ) )
     241         [ #  # ]:          0 :             delete (*this)[i].pItem;
     242                 :          0 :     SrchAttrItemList::clear();
     243                 :          0 : }
     244                 :            : 
     245                 :            : // -----------------------------------------------------------------------
     246                 :            : 
     247                 :            : // Deletes the pointer to the items
     248                 :          0 : void SearchAttrItemList::Remove(size_t nPos, size_t nLen)
     249                 :            : {
     250         [ #  # ]:          0 :     if ( nPos + nLen > size() )
     251                 :          0 :         nLen = size() - nPos;
     252                 :            : 
     253         [ #  # ]:          0 :     for ( sal_uInt16 i = nPos; i < nPos + nLen; ++i )
     254         [ #  # ]:          0 :         if ( !IsInvalidItem( (*this)[i].pItem ) )
     255         [ #  # ]:          0 :             delete (*this)[i].pItem;
     256                 :            : 
     257 [ #  # ][ #  # ]:          0 :     SrchAttrItemList::erase( begin() + nPos, begin() + nPos + nLen );
         [ #  # ][ #  # ]
     258                 :          0 : }
     259                 :            : 
     260                 :            : #undef INI_LIST
     261                 :            : #define INI_LIST() \
     262                 :            :     aSearchText     ( this, SVX_RES( FT_SEARCH ) ),                         \
     263                 :            :     aSearchLB       ( this, SVX_RES( ED_SEARCH ) ),                         \
     264                 :            :     aSearchTmplLB   ( this, SVX_RES( LB_SEARCH ) ),                         \
     265                 :            :     aSearchAttrText ( this, SVX_RES( FT_SEARCH_ATTR ) ),                        \
     266                 :            :     aReplaceText    ( this, SVX_RES( FT_REPLACE ) ),                            \
     267                 :            :     aReplaceLB      ( this, SVX_RES( ED_REPLACE ) ),                            \
     268                 :            :     aReplaceTmplLB  ( this, SVX_RES( LB_REPLACE ) ),                            \
     269                 :            :     aReplaceAttrText( this, SVX_RES( FT_REPLACE_ATTR ) ),                       \
     270                 :            :     aSearchBtn      ( this, SVX_RES( BTN_SEARCH ) ),                          \
     271                 :            :     aSearchAllBtn   ( this, SVX_RES( BTN_SEARCH_ALL ) ),                        \
     272                 :            :     aSearchCmdLine  ( this, SVX_RES( FL_SEARCH_COMMAND ) ),                   \
     273                 :            :     aReplaceBtn     ( this, SVX_RES( BTN_REPLACE ) ),                         \
     274                 :            :     aReplaceAllBtn  ( this, SVX_RES( BTN_REPLACE_ALL ) ),                     \
     275                 :            :     aSearchComponentFL( this, SVX_RES( FL_SEARCH_COMPONENT ) ), \
     276                 :            :     aSearchComponent1PB( this, SVX_RES( BTN_COMPONENT_1 ) ), \
     277                 :            :     aSearchComponent2PB( this, SVX_RES( BTN_COMPONENT_2 ) ), \
     278                 :            :     aMatchCaseCB    ( this, SVX_RES( CB_MATCH_CASE ) ),                       \
     279                 :            :     aWordBtn        ( this, SVX_RES( CB_WHOLE_WORDS ) ),                      \
     280                 :            :     aButtonsFL      ( this, SVX_RES( FL_BUTTONS ) ),                          \
     281                 :            :     pMoreBtn        ( new MoreButton( this, SVX_RES( BTN_MORE ) ) ),          \
     282                 :            :     aHelpBtn        ( this, SVX_RES( BTN_HELP ) ),                            \
     283                 :            :     aCloseBtn       ( this, SVX_RES( BTN_CLOSE ) ),                           \
     284                 :            :     aOptionsFL      ( this, SVX_RES( FL_OPTIONS ) ),                          \
     285                 :            :     aSelectionBtn   ( this, SVX_RES( CB_SELECTIONS ) ),                       \
     286                 :            :     aBackwardsBtn   ( this, SVX_RES( CB_BACKWARDS ) ),                        \
     287                 :            :     aRegExpBtn      ( this, SVX_RES( CB_REGEXP ) ),                           \
     288                 :            :     aSimilarityBox  ( this, SVX_RES( CB_SIMILARITY) ),                        \
     289                 :            :     aSimilarityBtn  ( this, SVX_RES( PB_SIMILARITY) ),                        \
     290                 :            :     aLayoutBtn      ( this, SVX_RES( CB_LAYOUTS ) ),                          \
     291                 :            :     aNotesBtn       ( this, SVX_RES( CB_COMMENTS ) ),                            \
     292                 :            :     aJapMatchFullHalfWidthCB( this, SVX_RES( CB_JAP_MATCH_FULL_HALF_WIDTH ) ),\
     293                 :            :     aJapOptionsCB   ( this, SVX_RES( CB_JAP_SOUNDS_LIKE ) ),                  \
     294                 :            :     aJapOptionsBtn  ( this, SVX_RES( PB_JAP_OPTIONS ) ),                      \
     295                 :            :     aAttributeBtn   ( this, SVX_RES( BTN_ATTRIBUTE ) ),                       \
     296                 :            :     aFormatBtn      ( this, SVX_RES( BTN_FORMAT ) ),                            \
     297                 :            :     aNoFormatBtn    ( this, SVX_RES( BTN_NOFORMAT ) ),                      \
     298                 :            :     aCalcFL         ( this, SVX_RES( FL_CALC ) ),                             \
     299                 :            :     aCalcSearchInFT ( this, SVX_RES( FT_CALC_SEARCHIN ) ),                    \
     300                 :            :     aCalcSearchInLB ( this, SVX_RES( LB_CALC_SEARCHIN ) ),                    \
     301                 :            :     aCalcSearchDirFT( this, SVX_RES( FT_CALC_SEARCHDIR ) ),                   \
     302                 :            :     aRowsBtn        ( this, SVX_RES( RB_CALC_ROWS ) ),                        \
     303                 :            :     aColumnsBtn     ( this, SVX_RES( RB_CALC_COLUMNS ) ),                     \
     304                 :            :     aAllSheetsCB    ( this, SVX_RES( CB_ALL_SHEETS ) ),                       \
     305                 :            :     rBindings       ( rBind ),                                              \
     306                 :            :     bWriter         ( sal_False ),                                              \
     307                 :            :     bSearch         ( sal_True ),                                               \
     308                 :            :     bFormat         ( sal_False ),                                              \
     309                 :            :     nOptions        ( USHRT_MAX ),                                          \
     310                 :            :     bSet            ( sal_False ),                                              \
     311                 :            :     bReadOnly       ( sal_False ),                                              \
     312                 :            :     bConstruct      ( sal_True ),                                               \
     313                 :            :     nModifyFlag     ( 0 ),                                                  \
     314                 :            :     aCalcStr        ( SVX_RES( STR_WORDCALC ) ),                       \
     315                 :            :     pImpl           ( NULL ),                                               \
     316                 :            :     pSearchList     ( NULL ),                                               \
     317                 :            :     pReplaceList    ( new SearchAttrItemList ),                             \
     318                 :            :     pSearchItem     ( NULL ),                                               \
     319                 :            :     pSearchController       ( NULL ),                                       \
     320                 :            :     pOptionsController      ( NULL ),                                       \
     321                 :            :     pFamilyController       ( NULL ),                                       \
     322                 :            :     pSearchSetController    ( NULL ),                                       \
     323                 :            :     pReplaceSetController   ( NULL ),                                       \
     324                 :            :     nTransliterationFlags   ( 0x00000000 )
     325                 :            : 
     326                 :            : // class SvxSearchDialog -------------------------------------------------
     327                 :            : 
     328                 :          0 : SvxSearchDialog::SvxSearchDialog( Window* pParent, SfxChildWindow* pChildWin, SfxBindings& rBind ) :
     329                 :            : 
     330                 :          0 :     SfxModelessDialog( &rBind, pChildWin, pParent, SVX_RES( RID_SVXDLG_SEARCH ) ),
     331                 :            : 
     332 [ #  # ][ #  # ]:          0 :     INI_LIST()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     333                 :            : 
     334                 :            : {
     335         [ #  # ]:          0 :     Construct_Impl();
     336                 :          0 : }
     337                 :            : 
     338                 :            : #undef INI_LIST
     339                 :            : 
     340                 :            : // -----------------------------------------------------------------------
     341                 :            : 
     342 [ #  # ][ #  # ]:          0 : SvxSearchDialog::~SvxSearchDialog()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     343                 :            : {
     344         [ #  # ]:          0 :     Hide();
     345                 :            : 
     346         [ #  # ]:          0 :     rBindings.EnterRegistrations();
     347 [ #  # ][ #  # ]:          0 :     delete pSearchController;
     348 [ #  # ][ #  # ]:          0 :     delete pOptionsController;
     349 [ #  # ][ #  # ]:          0 :     delete pFamilyController;
     350 [ #  # ][ #  # ]:          0 :     delete pSearchSetController;
     351 [ #  # ][ #  # ]:          0 :     delete pReplaceSetController;
     352         [ #  # ]:          0 :     rBindings.LeaveRegistrations();
     353                 :            : 
     354 [ #  # ][ #  # ]:          0 :     delete pSearchItem;
     355 [ #  # ][ #  # ]:          0 :     delete pImpl;
     356 [ #  # ][ #  # ]:          0 :     delete pSearchList;
     357 [ #  # ][ #  # ]:          0 :     delete pReplaceList;
     358 [ #  # ][ #  # ]:          0 :     delete pMoreBtn;
     359         [ #  # ]:          0 : }
     360                 :            : 
     361                 :          0 : void lcl_MoveDown( Window& rWindow, sal_Int32 nOffset )
     362                 :            : {
     363         [ #  # ]:          0 :     Point aPos(rWindow.GetPosPixel());
     364                 :          0 :     aPos.Y() += nOffset;
     365         [ #  # ]:          0 :     rWindow.SetPosPixel(aPos);
     366                 :          0 : }
     367                 :            : 
     368                 :          0 : void SvxSearchDialog::Construct_Impl()
     369                 :            : {
     370                 :            :     // temporary to avoid incompatibility
     371 [ #  # ][ #  # ]:          0 :     pImpl = new SearchDlg_Impl( this );
     372         [ #  # ]:          0 :     pImpl->aSelectionTimer.SetTimeout( 500 );
     373                 :            :     pImpl->aSelectionTimer.SetTimeoutHdl(
     374         [ #  # ]:          0 :         LINK( this, SvxSearchDialog, TimeoutHdl_Impl ) );
     375         [ #  # ]:          0 :     EnableControls_Impl( 0 );
     376                 :            : 
     377                 :            :     // Store old Text from aWordBtn
     378         [ #  # ]:          0 :     aCalcStr += sal_Unicode('#');
     379 [ #  # ][ #  # ]:          0 :     aCalcStr += aWordBtn.GetText();
                 [ #  # ]
     380                 :            : 
     381 [ #  # ][ #  # ]:          0 :     aLayoutStr = SVX_RESSTR( RID_SVXSTR_SEARCH_STYLES );
                 [ #  # ]
     382 [ #  # ][ #  # ]:          0 :     aStylesStr = aLayoutBtn.GetText();
                 [ #  # ]
     383                 :            : 
     384                 :            :     // Get stored search-strings from the application
     385                 :            :     ListToStrArr_Impl( SID_SEARCHDLG_SEARCHSTRINGS,
     386         [ #  # ]:          0 :                        aSearchStrings, aSearchLB    );
     387                 :            :     ListToStrArr_Impl( SID_SEARCHDLG_REPLACESTRINGS,
     388         [ #  # ]:          0 :                        aReplaceStrings, aReplaceLB  );
     389                 :            : 
     390 [ #  # ][ #  # ]:          0 :     pMoreBtn->SetMoreText( String( SVX_RES( STR_MORE_BTN ) ) );
         [ #  # ][ #  # ]
     391 [ #  # ][ #  # ]:          0 :     pMoreBtn->SetLessText( String( SVX_RES( STR_LESS_BTN ) ) );
         [ #  # ][ #  # ]
     392                 :            : 
     393         [ #  # ]:          0 :     FreeResource();
     394         [ #  # ]:          0 :     InitControls_Impl();
     395                 :            : 
     396                 :            :     // Get attribut sets only once in construtor()
     397                 :          0 :     const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
     398                 :            :     const SvxSetItem* pSrchSetItem =
     399         [ #  # ]:          0 :         (const SvxSetItem*) rBindings.GetDispatcher()->Execute( FID_SEARCH_SEARCHSET, SFX_CALLMODE_SLOT, ppArgs );
     400                 :            : 
     401         [ #  # ]:          0 :     if ( pSrchSetItem )
     402         [ #  # ]:          0 :         InitAttrList_Impl( &pSrchSetItem->GetItemSet(), 0 );
     403                 :            : 
     404                 :            :     const SvxSetItem* pReplSetItem =
     405         [ #  # ]:          0 :         (const SvxSetItem*)rBindings.GetDispatcher()->Execute( FID_SEARCH_REPLACESET, SFX_CALLMODE_SLOT, ppArgs );
     406                 :            : 
     407         [ #  # ]:          0 :     if ( pReplSetItem )
     408         [ #  # ]:          0 :         InitAttrList_Impl( 0, &pReplSetItem->GetItemSet() );
     409                 :            : 
     410                 :            :     // Create controller and update at once
     411         [ #  # ]:          0 :     rBindings.EnterRegistrations();
     412                 :            :     pSearchController =
     413 [ #  # ][ #  # ]:          0 :         new SvxSearchController( SID_SEARCH_ITEM, rBindings, *this );
     414                 :            :     pOptionsController =
     415 [ #  # ][ #  # ]:          0 :         new SvxSearchController( SID_SEARCH_OPTIONS, rBindings, *this );
     416         [ #  # ]:          0 :     rBindings.LeaveRegistrations();
     417         [ #  # ]:          0 :     rBindings.GetDispatcher()->Execute( FID_SEARCH_ON, SFX_CALLMODE_SLOT, ppArgs );
     418         [ #  # ]:          0 :     pImpl->aSelectionTimer.Start();
     419                 :            : 
     420                 :            : 
     421         [ #  # ]:          0 :     SvtCJKOptions aCJKOptions;
     422 [ #  # ][ #  # ]:          0 :     if(!aCJKOptions.IsJapaneseFindEnabled())
     423                 :            :     {
     424         [ #  # ]:          0 :         aJapOptionsCB.Check( sal_False );
     425         [ #  # ]:          0 :         aJapOptionsCB.Hide();
     426         [ #  # ]:          0 :         aJapOptionsBtn.Hide();
     427                 :            :     }
     428 [ #  # ][ #  # ]:          0 :     if(!aCJKOptions.IsCJKFontEnabled())
     429                 :            :     {
     430         [ #  # ]:          0 :         aJapMatchFullHalfWidthCB.Hide();
     431                 :            :     }
     432                 :            : 
     433         [ #  # ]:          0 :     aSimilarityBtn.SetAccessibleRelationLabeledBy(&aSimilarityBox);
     434         [ #  # ]:          0 :     aSimilarityBtn.SetAccessibleRelationMemberOf(&aOptionsFL);
     435         [ #  # ]:          0 :     aJapOptionsBtn.SetAccessibleRelationLabeledBy(&aJapOptionsCB);
     436         [ #  # ]:          0 :     aJapOptionsBtn.SetAccessibleRelationMemberOf(&aOptionsFL);
     437         [ #  # ]:          0 :     aRowsBtn.SetAccessibleRelationMemberOf(&aCalcSearchDirFT);
     438         [ #  # ]:          0 :     aColumnsBtn.SetAccessibleRelationMemberOf(&aCalcSearchDirFT);
     439                 :            : 
     440                 :            :     //component extension - show component search buttons if the commands
     441                 :            :     // vnd.sun.star::SearchViaComponent1 and 2 are supported
     442         [ #  # ]:          0 :     const uno::Reference< frame::XFrame >xFrame = rBindings.GetActiveFrame();
     443         [ #  # ]:          0 :     const uno::Reference< frame::XDispatchProvider > xDispatchProv(xFrame, uno::UNO_QUERY);
     444                 :          0 :     rtl::OUString sTarget("_self");
     445                 :            : 
     446                 :          0 :     bool bSearchComponent1 = false;
     447                 :          0 :     bool bSearchComponent2 = false;
     448         [ #  # ]:          0 :     if(xDispatchProv.is() &&
           [ #  #  #  # ]
     449 [ #  # ][ #  # ]:          0 :             (pImpl->xCommand1Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand1URL, sTarget, 0)).is())
         [ #  # ][ #  # ]
                 [ #  # ]
     450                 :            :     {
     451                 :          0 :         bSearchComponent1 = true;
     452                 :            :     }
     453   [ #  #  #  # ]:          0 :     if(xDispatchProv.is() &&
                 [ #  # ]
     454 [ #  # ][ #  # ]:          0 :             (pImpl->xCommand2Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand2URL, sTarget, 0)).is())
         [ #  # ][ #  # ]
                 [ #  # ]
     455                 :            :     {
     456                 :          0 :         bSearchComponent2 = true;
     457                 :            :     }
     458                 :            : 
     459 [ #  # ][ #  # ]:          0 :     if( bSearchComponent1 || bSearchComponent2 )
     460                 :            :     {
     461                 :            :         try
     462                 :            :         {
     463         [ #  # ]:          0 :             uno::Reference< lang::XMultiServiceFactory >  xMgr = getProcessServiceFactory();
     464         [ #  # ]:          0 :             uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider(xMgr->createInstance(
     465                 :          0 :                     ::rtl::OUString(  "com.sun.star.configuration.ConfigurationProvider")),
     466 [ #  # ][ #  # ]:          0 :                     uno::UNO_QUERY);
     467         [ #  # ]:          0 :             uno::Sequence< uno::Any > aArgs(1);
     468                 :          0 :             ::rtl::OUString sPath( "/org.openoffice.Office.Common/SearchOptions/");
     469 [ #  # ][ #  # ]:          0 :             aArgs[0] <<= sPath;
     470                 :            : 
     471         [ #  # ]:          0 :             uno::Reference< uno::XInterface > xIFace = xConfigurationProvider->createInstanceWithArguments(
     472                 :            :                         ::rtl::OUString( "com.sun.star.configuration.ConfigurationUpdateAccess"),
     473         [ #  # ]:          0 :                         aArgs);
     474         [ #  # ]:          0 :             uno::Reference< container::XNameAccess> xDirectAccess(xIFace, uno::UNO_QUERY);
     475         [ #  # ]:          0 :             if(xDirectAccess.is())
     476                 :            :             {
     477                 :          0 :                 ::rtl::OUString sTemp;
     478                 :          0 :                 ::rtl::OUString sProperty( "ComponentSearchGroupLabel");
     479 [ #  # ][ #  # ]:          0 :                 uno::Any aRet = xDirectAccess->getByName(sProperty);
     480                 :          0 :                 aRet >>= sTemp;
     481 [ #  # ][ #  # ]:          0 :                 aSearchComponentFL.SetText( sTemp );
                 [ #  # ]
     482 [ #  # ][ #  # ]:          0 :                 aRet = xDirectAccess->getByName(::rtl::OUString( "ComponentSearchCommandLabel1"));
     483                 :          0 :                 aRet >>= sTemp;
     484 [ #  # ][ #  # ]:          0 :                 aSearchComponent1PB.SetText( sTemp );
                 [ #  # ]
     485 [ #  # ][ #  # ]:          0 :                 aRet = xDirectAccess->getByName(::rtl::OUString( "ComponentSearchCommandLabel2"));
     486                 :          0 :                 aRet >>= sTemp;
     487 [ #  # ][ #  # ]:          0 :                 aSearchComponent2PB.SetText( sTemp );
                 [ #  # ]
     488 [ #  # ][ #  # ]:          0 :             }
     489                 :            :         }
     490         [ #  # ]:          0 :         catch(uno::Exception&){}
     491                 :            : 
     492 [ #  # ][ #  # ]:          0 :         if(aSearchComponent1PB.GetText().Len() && bSearchComponent1 )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     493                 :            :         {
     494         [ #  # ]:          0 :             aSearchComponentFL.Show();
     495         [ #  # ]:          0 :             aSearchComponent1PB.Show();
     496                 :            :         }
     497 [ #  # ][ #  # ]:          0 :         if( aSearchComponent2PB.GetText().Len() )
                 [ #  # ]
     498                 :            :         {
     499 [ #  # ][ #  # ]:          0 :             if(!aSearchComponent1PB.IsVisible())
     500                 :            :             {
     501 [ #  # ][ #  # ]:          0 :                 aSearchComponent2PB.SetPosPixel(aSearchComponent1PB.GetPosPixel());
     502                 :            :             }
     503         [ #  # ]:          0 :             aSearchComponentFL.Show();
     504         [ #  # ]:          0 :             aSearchComponent2PB.Show();
     505                 :            :         }
     506 [ #  # ][ #  # ]:          0 :         if( aSearchComponentFL.IsVisible() && aSearchComponent1PB.IsVisible() )
         [ #  # ][ #  # ]
                 [ #  # ]
     507                 :            :         {
     508                 :            : 
     509                 :            :             //dialog must be resized
     510         [ #  # ]:          0 :             Size aDlgSize(GetSizePixel());
     511 [ #  # ][ #  # ]:          0 :             sal_Int32 nOffset = aSearchCmdLine.GetPosPixel().Y() - aSearchAllBtn.GetPosPixel().Y()
     512 [ #  # ][ #  # ]:          0 :                 - aButtonsFL.GetPosPixel().Y() + aSearchComponent2PB.GetPosPixel().Y();
     513                 :            : 
     514                 :          0 :             aDlgSize.Height() += nOffset;
     515                 :            :             Window* aWindows[] =
     516                 :            :             {
     517                 :            :                 &aOptionsFL,
     518                 :            :                 &aSelectionBtn,
     519                 :            :                 &aBackwardsBtn,
     520                 :            :                 &aRegExpBtn,
     521                 :            :                 &aSimilarityBox,
     522                 :            :                 &aSimilarityBtn,
     523                 :            :                 &aLayoutBtn,
     524                 :            :                 &aNotesBtn,
     525                 :            :                 &aJapMatchFullHalfWidthCB,
     526                 :            :                 &aJapOptionsCB,
     527                 :            :                 &aJapOptionsBtn,
     528                 :            :                 &aAttributeBtn,
     529                 :            :                 &aFormatBtn,
     530                 :            :                 &aNoFormatBtn,
     531                 :            :                 &aCalcFL,
     532                 :            :                 &aCalcSearchInFT,
     533                 :            :                 &aCalcSearchInLB,
     534                 :            :                 &aCalcSearchDirFT,
     535                 :            :                 &aRowsBtn,
     536                 :            :                 &aColumnsBtn,
     537                 :            :                 &aAllSheetsCB,
     538                 :            :                 &aButtonsFL,
     539                 :            :                 &aHelpBtn,
     540                 :            :                 &aCloseBtn,
     541                 :            :                 pMoreBtn,
     542                 :            :                 0
     543                 :          0 :             };
     544                 :          0 :             sal_Int32 nWindow = 0;
     545         [ #  # ]:          0 :             do
     546                 :            :             {
     547         [ #  # ]:          0 :                 lcl_MoveDown( *aWindows[nWindow], nOffset );
     548                 :            :             }
     549                 :          0 :             while(aWindows[++nWindow]);
     550                 :            : 
     551         [ #  # ]:          0 :             SetSizePixel(aDlgSize);
     552                 :            :         }
     553         [ #  # ]:          0 :     }
     554                 :          0 : }
     555                 :            : 
     556                 :            : // -----------------------------------------------------------------------
     557                 :            : 
     558                 :          0 : sal_Bool SvxSearchDialog::Close()
     559                 :            : {
     560                 :            :     // remember strings speichern
     561         [ #  # ]:          0 :     if (!aSearchStrings.empty())
     562         [ #  # ]:          0 :         StrArrToList_Impl( SID_SEARCHDLG_SEARCHSTRINGS, aSearchStrings );
     563                 :            : 
     564         [ #  # ]:          0 :     if (!aReplaceStrings.empty())
     565         [ #  # ]:          0 :         StrArrToList_Impl( SID_SEARCHDLG_REPLACESTRINGS, aReplaceStrings );
     566                 :            : 
     567                 :            :     // save settings to configuration
     568         [ #  # ]:          0 :     SvtSearchOptions aOpt;
     569 [ #  # ][ #  # ]:          0 :     aOpt.SetWholeWordsOnly          ( aWordBtn                .IsChecked() );
     570 [ #  # ][ #  # ]:          0 :     aOpt.SetBackwards               ( aBackwardsBtn           .IsChecked() );
     571 [ #  # ][ #  # ]:          0 :     aOpt.SetUseRegularExpression    ( aRegExpBtn              .IsChecked() );
     572 [ #  # ][ #  # ]:          0 :     aOpt.SetSearchForStyles         ( aLayoutBtn              .IsChecked() );
     573 [ #  # ][ #  # ]:          0 :     aOpt.SetSimilaritySearch        ( aSimilarityBox          .IsChecked() );
     574 [ #  # ][ #  # ]:          0 :     aOpt.SetUseAsianOptions         ( aJapOptionsCB           .IsChecked() );
     575 [ #  # ][ #  # ]:          0 :         aOpt.SetNotes                   ( aNotesBtn               .IsChecked() );
     576                 :            : 
     577                 :          0 :     const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
     578         [ #  # ]:          0 :     rBindings.GetDispatcher()->Execute( FID_SEARCH_OFF, SFX_CALLMODE_SLOT, ppArgs );
     579         [ #  # ]:          0 :     rBindings.Execute( SID_SEARCH_DLG );
     580                 :            : 
     581         [ #  # ]:          0 :     return sal_True;
     582                 :            : }
     583                 :            : 
     584                 :            : // -----------------------------------------------------------------------
     585                 :            : 
     586                 :          0 : sal_Int32 SvxSearchDialog::GetTransliterationFlags() const
     587                 :            : {
     588         [ #  # ]:          0 :     if (!aMatchCaseCB.IsChecked())
     589                 :          0 :         nTransliterationFlags |=  TransliterationModules_IGNORE_CASE;
     590                 :            :     else
     591                 :          0 :         nTransliterationFlags &= ~TransliterationModules_IGNORE_CASE;
     592         [ #  # ]:          0 :     if ( !aJapMatchFullHalfWidthCB.IsChecked())
     593                 :          0 :         nTransliterationFlags |=  TransliterationModules_IGNORE_WIDTH;
     594                 :            :     else
     595                 :          0 :         nTransliterationFlags &= ~TransliterationModules_IGNORE_WIDTH;
     596                 :          0 :     return nTransliterationFlags;
     597                 :            : }
     598                 :            : 
     599                 :          0 : void SvxSearchDialog::SetSaveToModule(bool b)
     600                 :            : {
     601                 :          0 :     pImpl->bSaveToModule = b;
     602                 :          0 : }
     603                 :            : 
     604                 :            : // -----------------------------------------------------------------------
     605                 :            : 
     606                 :          0 : void SvxSearchDialog::ApplyTransliterationFlags_Impl( sal_Int32 nSettings )
     607                 :            : {
     608                 :          0 :     nTransliterationFlags = nSettings;
     609                 :          0 :     sal_Bool bVal = 0 != (nSettings & TransliterationModules_IGNORE_CASE);
     610                 :          0 :     aMatchCaseCB            .Check(!bVal );
     611                 :          0 :     bVal = 0 != (nSettings & TransliterationModules_IGNORE_WIDTH);
     612                 :          0 :     aJapMatchFullHalfWidthCB.Check( !bVal );
     613                 :          0 : }
     614                 :            : 
     615                 :            : // -----------------------------------------------------------------------
     616                 :            : 
     617                 :          0 : void SvxSearchDialog::Activate()
     618                 :            : {
     619                 :            :     // apply possible transliteration changes of the SvxSearchItem member
     620                 :            :     DBG_ASSERT( pSearchItem, "SearchItem missing" );
     621         [ #  # ]:          0 :     if (pSearchItem)
     622                 :            :     {
     623                 :          0 :         aMatchCaseCB            .Check( pSearchItem->GetExact() );
     624                 :          0 :         aJapMatchFullHalfWidthCB.Check( !pSearchItem->IsMatchFullHalfWidthForms() );
     625                 :            :     }
     626                 :          0 : }
     627                 :            : 
     628                 :            : // -----------------------------------------------------------------------
     629                 :            : 
     630                 :          0 : void SvxSearchDialog::InitControls_Impl()
     631                 :            : {
     632                 :            :     // CaseSensitives AutoComplete
     633         [ #  # ]:          0 :     aSearchLB.EnableAutocomplete( sal_True, sal_True );
     634         [ #  # ]:          0 :     aSearchLB.Show();
     635         [ #  # ]:          0 :     aReplaceLB.EnableAutocomplete( sal_True, sal_True );
     636         [ #  # ]:          0 :     aReplaceLB.Show();
     637                 :            : 
     638         [ #  # ]:          0 :     aFormatBtn.Disable();
     639         [ #  # ]:          0 :     aAttributeBtn.Disable();
     640                 :            : 
     641         [ #  # ]:          0 :     aSearchLB.SetModifyHdl( LINK( this, SvxSearchDialog, ModifyHdl_Impl ) );
     642         [ #  # ]:          0 :     aReplaceLB.SetModifyHdl( LINK( this, SvxSearchDialog, ModifyHdl_Impl ) );
     643                 :            : 
     644         [ #  # ]:          0 :     Link aLink = LINK( this, SvxSearchDialog, FocusHdl_Impl );
     645                 :          0 :     aSearchLB.SetGetFocusHdl( aLink );
     646                 :          0 :     pImpl->aSearchFormats.SetGetFocusHdl( aLink );
     647                 :            : 
     648                 :          0 :     aReplaceLB.SetGetFocusHdl( aLink );
     649                 :          0 :     pImpl->aReplaceFormats.SetGetFocusHdl( aLink );
     650                 :            : 
     651         [ #  # ]:          0 :     aLink = LINK( this, SvxSearchDialog, LoseFocusHdl_Impl );
     652                 :          0 :     aSearchLB.SetLoseFocusHdl( aLink );
     653                 :          0 :     aReplaceLB.SetLoseFocusHdl( aLink );
     654                 :            : 
     655                 :          0 :     aSearchTmplLB.SetLoseFocusHdl( aLink );
     656                 :          0 :     aReplaceTmplLB.SetLoseFocusHdl( aLink );
     657                 :            : 
     658         [ #  # ]:          0 :     aLink = LINK( this, SvxSearchDialog, CommandHdl_Impl );
     659                 :          0 :     aSearchBtn.SetClickHdl( aLink );
     660                 :          0 :     aSearchAllBtn.SetClickHdl( aLink );
     661                 :          0 :     aReplaceBtn.SetClickHdl( aLink );
     662                 :          0 :     aReplaceAllBtn.SetClickHdl( aLink );
     663                 :          0 :     aCloseBtn.SetClickHdl( aLink );
     664                 :          0 :     aSimilarityBtn.SetClickHdl( aLink );
     665                 :          0 :     aJapOptionsBtn.SetClickHdl( aLink );
     666                 :          0 :     aSearchComponent1PB.SetClickHdl( aLink );
     667                 :          0 :     aSearchComponent2PB.SetClickHdl( aLink );
     668                 :            : 
     669         [ #  # ]:          0 :     aLink = LINK( this, SvxSearchDialog, FlagHdl_Impl );
     670                 :          0 :     aWordBtn.SetClickHdl( aLink );
     671                 :          0 :     aSelectionBtn.SetClickHdl( aLink );
     672                 :          0 :     aMatchCaseCB.SetClickHdl( aLink );
     673                 :          0 :     aRegExpBtn.SetClickHdl( aLink );
     674                 :          0 :     aBackwardsBtn.SetClickHdl( aLink );
     675                 :          0 :     aNotesBtn.SetClickHdl( aLink );
     676                 :          0 :     aSimilarityBox.SetClickHdl( aLink );
     677                 :          0 :     aJapOptionsCB.SetClickHdl( aLink );
     678                 :          0 :     aJapMatchFullHalfWidthCB.SetClickHdl( aLink );
     679                 :            : 
     680         [ #  # ]:          0 :     aLayoutBtn.SetClickHdl( LINK( this, SvxSearchDialog, TemplateHdl_Impl ) );
     681         [ #  # ]:          0 :     aFormatBtn.SetClickHdl( LINK( this, SvxSearchDialog, FormatHdl_Impl ) );
     682                 :            :     aNoFormatBtn.SetClickHdl(
     683         [ #  # ]:          0 :         LINK( this, SvxSearchDialog, NoFormatHdl_Impl ) );
     684                 :            :     aAttributeBtn.SetClickHdl(
     685         [ #  # ]:          0 :         LINK( this, SvxSearchDialog, AttributeHdl_Impl ) );
     686                 :            : 
     687                 :            :     // check if buttontext is to wide
     688                 :            :     long nTxtW = Max( pMoreBtn->GetCtrlTextWidth( pMoreBtn->GetMoreText() ),
     689 [ #  # ][ #  # ]:          0 :                       pMoreBtn->GetCtrlTextWidth( pMoreBtn->GetLessText() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     690         [ #  # ]:          0 :     nTxtW += ( pMoreBtn->GetTextHeight() * 2 ); // add image size + offset
     691         [ #  # ]:          0 :     long nBtnW = pMoreBtn->GetSizePixel().Width();
     692         [ #  # ]:          0 :     if ( nTxtW > nBtnW )
     693                 :            :     {
     694                 :            :         // broaden the button
     695                 :          0 :         const long nMinDelta = 10;
     696                 :          0 :         long nDelta = Max( nTxtW - nBtnW, nMinDelta );
     697         [ #  # ]:          0 :         Size aNewSize = pMoreBtn->GetSizePixel();
     698                 :          0 :         aNewSize.Width() += nDelta;
     699         [ #  # ]:          0 :         pMoreBtn->SetSizePixel( aNewSize );
     700                 :            :     }
     701                 :          0 : }
     702                 :            : 
     703                 :            : // -----------------------------------------------------------------------
     704                 :            : 
     705                 :          0 : void SvxSearchDialog::CalculateDelta_Impl()
     706                 :            : {
     707                 :            :     DBG_ASSERT( pSearchItem, "no search item" );
     708                 :            : 
     709                 :          0 :     bool bDrawApp = false;
     710                 :          0 :     bool bCalcApp = false;
     711                 :          0 :     bool bWriterApp = false;
     712                 :          0 :     bool bImpressApp = false;
     713         [ #  # ]:          0 :     const uno::Reference< frame::XFrame > xFrame = rBindings.GetActiveFrame();
     714                 :            :     uno::Reference< frame::XModuleManager > xModuleManager(
     715 [ #  # ][ #  # ]:          0 :         ::comphelper::getProcessServiceFactory()->createInstance(
                 [ #  # ]
     716 [ #  # ][ #  # ]:          0 :             DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), uno::UNO_QUERY );
         [ #  # ][ #  # ]
                 [ #  # ]
     717         [ #  # ]:          0 :     if ( xModuleManager.is() )
     718                 :            :     {
     719                 :            :         try
     720                 :            :         {
     721 [ #  # ][ #  # ]:          0 :             ::rtl::OUString aModuleIdentifier = xModuleManager->identify( xFrame );
     722                 :          0 :             bCalcApp = aModuleIdentifier == "com.sun.star.sheet.SpreadsheetDocument";
     723                 :          0 :             bDrawApp = aModuleIdentifier == "com.sun.star.drawing.DrawingDocument";
     724                 :          0 :             bImpressApp = aModuleIdentifier == "com.sun.star.presentation.PresentationDocument";
     725                 :          0 :             bWriterApp = aModuleIdentifier == "com.sun.star.text.TextDocument";
     726                 :            :         }
     727         [ #  # ]:          0 :         catch ( uno::Exception& )
     728                 :            :         {
     729                 :            :         }
     730                 :            :     }
     731                 :            : 
     732         [ #  # ]:          0 :     if ( pImpl->bDeltaCalculated )
     733                 :          0 :         return;
     734                 :            :     else
     735                 :          0 :         pImpl->bDeltaCalculated = sal_True;
     736                 :            : 
     737                 :          0 :     sal_uIntPtr nDelta = 187, nOffset = 0;
     738         [ #  # ]:          0 :     SvtCJKOptions aCJKOptions;
     739                 :            : 
     740         [ #  # ]:          0 :     pMoreBtn->AddWindow( &aOptionsFL );
     741         [ #  # ]:          0 :     if ( !bDrawApp )
     742         [ #  # ]:          0 :         pMoreBtn->AddWindow( &aLayoutBtn );
     743         [ #  # ]:          0 :     if ( bWriterApp )
     744         [ #  # ]:          0 :         pMoreBtn->AddWindow( &aNotesBtn );
     745                 :            :     else
     746                 :            :     {
     747         [ #  # ]:          0 :         aNotesBtn.Hide();
     748         [ #  # ]:          0 :         nOffset = !bDrawApp ? 13 : 0;
     749                 :            :     }
     750         [ #  # ]:          0 :     pMoreBtn->AddWindow( &aBackwardsBtn );
     751         [ #  # ]:          0 :     if ( !bDrawApp )
     752         [ #  # ]:          0 :         pMoreBtn->AddWindow( &aRegExpBtn );
     753         [ #  # ]:          0 :     pMoreBtn->AddWindow( &aSimilarityBox );
     754         [ #  # ]:          0 :     pMoreBtn->AddWindow( &aSimilarityBtn );
     755         [ #  # ]:          0 :     pMoreBtn->AddWindow( &aSelectionBtn );
     756                 :            : 
     757 [ #  # ][ #  # ]:          0 :     if ( aCJKOptions.IsCJKFontEnabled() )
     758         [ #  # ]:          0 :         pMoreBtn->AddWindow( &aJapMatchFullHalfWidthCB );
     759                 :            :     else
     760                 :          0 :         nOffset += 13;
     761 [ #  # ][ #  # ]:          0 :     if ( aCJKOptions.IsJapaneseFindEnabled() )
     762                 :            :     {
     763         [ #  # ]:          0 :         pMoreBtn->AddWindow( &aJapOptionsCB );
     764         [ #  # ]:          0 :         pMoreBtn->AddWindow( &aJapOptionsBtn );
     765                 :            :     }
     766                 :            :     else
     767                 :          0 :         nOffset += 17;
     768                 :            : 
     769         [ #  # ]:          0 :     if ( bWriter )
     770                 :            :     {
     771         [ #  # ]:          0 :         pMoreBtn->AddWindow( &aAttributeBtn );
     772         [ #  # ]:          0 :         pMoreBtn->AddWindow( &aFormatBtn );
     773         [ #  # ]:          0 :         pMoreBtn->AddWindow( &aNoFormatBtn );
     774                 :            :     }
     775                 :            : 
     776 [ #  # ][ #  # ]:          0 :     if (bDrawApp || bImpressApp)
     777                 :            :     {
     778                 :            :         // "Find All" button is hidden--align "Find" vertically to the
     779                 :            :         // search listbox
     780         [ #  # ]:          0 :         Point aNewPt(aSearchBtn.GetPosPixel());
     781         [ #  # ]:          0 :         const Size aBtnSz(aSearchBtn.GetSizePixel());
     782         [ #  # ]:          0 :         const Size aLBSz(aSearchLB.GetSizePixel());
     783                 :          0 :         const int nOff((aLBSz.Height() - aBtnSz.Height()) / 2);
     784         [ #  # ]:          0 :         aNewPt.Y() = aSearchLB.GetPosPixel().Y() + nOff;
     785         [ #  # ]:          0 :         aSearchBtn.SetPosPixel(aNewPt);
     786                 :            :     }
     787                 :            : 
     788         [ #  # ]:          0 :     if ( bDrawApp )
     789                 :            :     {
     790                 :            :         // Draw App: "Regular expressions" and "Search for Styles" check boxes are hidden
     791                 :            :         // so align the other buttons
     792                 :          0 :         const long nAppFontHeight = 13; // checkbox height + space between in APPFONT
     793 [ #  # ][ #  # ]:          0 :         long nH = LogicToPixel( Size( 0, nAppFontHeight ), MAP_APPFONT ).Height();
                 [ #  # ]
     794                 :            : 
     795         [ #  # ]:          0 :         Point aNewPos = aSimilarityBox.GetPosPixel();
     796                 :          0 :         aNewPos.Y() -= nH;
     797         [ #  # ]:          0 :         aSimilarityBox.SetPosPixel( aNewPos );
     798         [ #  # ]:          0 :         aNewPos = aSimilarityBtn.GetPosPixel();
     799                 :          0 :         aNewPos.Y() -= nH;
     800         [ #  # ]:          0 :         aSimilarityBtn.SetPosPixel( aNewPos );
     801                 :          0 :         nH *= 3;
     802                 :          0 :         nOffset += ( 3 * nAppFontHeight );
     803 [ #  # ][ #  # ]:          0 :         if ( aCJKOptions.IsCJKFontEnabled() )
     804                 :            :         {
     805         [ #  # ]:          0 :             aNewPos = aJapMatchFullHalfWidthCB.GetPosPixel();
     806                 :          0 :             aNewPos.Y() -= nH;
     807         [ #  # ]:          0 :             aJapMatchFullHalfWidthCB.SetPosPixel( aNewPos );
     808                 :            :         }
     809 [ #  # ][ #  # ]:          0 :         if ( aCJKOptions.IsJapaneseFindEnabled() )
     810                 :            :         {
     811         [ #  # ]:          0 :             aNewPos = aJapOptionsCB.GetPosPixel();
     812                 :          0 :             aNewPos.Y() -= nH;
     813         [ #  # ]:          0 :             aJapOptionsCB.SetPosPixel( aNewPos );
     814         [ #  # ]:          0 :             aNewPos = aJapOptionsBtn.GetPosPixel();
     815                 :          0 :             aNewPos.Y() -= nH;
     816         [ #  # ]:          0 :             aJapOptionsBtn.SetPosPixel( aNewPos );
     817                 :            :         }
     818                 :            :     }
     819                 :            : 
     820 [ #  # ][ #  # ]:          0 :     if ( bCalcApp || bImpressApp )
     821                 :            :     {
     822                 :            :         Window* pWins[] =
     823                 :            :         {
     824                 :            :             &aCalcFL, &aCalcSearchInFT, &aCalcSearchInLB, &aCalcSearchDirFT,
     825                 :            :             &aRowsBtn, &aColumnsBtn, &aAllSheetsCB, &aJapMatchFullHalfWidthCB,
     826                 :            :             &aJapOptionsCB, &aJapOptionsBtn
     827                 :          0 :         };
     828                 :          0 :         Window** pCurrent = pWins;
     829                 :          0 :         sal_uInt32 i = 0;
     830                 :          0 :         const sal_uInt32 nCalcCtrlCount = 7;
     831         [ #  # ]:          0 :         if ( nOffset > 0 )
     832                 :            :         {
     833 [ #  # ][ #  # ]:          0 :             long nH = LogicToPixel( Size( 0, nOffset ), MAP_APPFONT ).Height();
                 [ #  # ]
     834         [ #  # ]:          0 :             for ( i = 0; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent )
     835                 :            :             {
     836 [ #  # ][ #  # ]:          0 :                 if ( ( bCalcApp && i < nCalcCtrlCount )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     837         [ #  # ]:          0 :                     || ( i == nCalcCtrlCount && aCJKOptions.IsCJKFontEnabled() )
     838         [ #  # ]:          0 :                     || ( i > nCalcCtrlCount && aCJKOptions.IsJapaneseFindEnabled() ) )
     839                 :            :                 {
     840         [ #  # ]:          0 :                     Point aNewPos = (*pCurrent)->GetPosPixel();
     841                 :          0 :                     aNewPos.Y() -= nH;
     842         [ #  # ]:          0 :                     (*pCurrent)->SetPosPixel( aNewPos );
     843                 :            :                 }
     844                 :            :             }
     845                 :            :         }
     846                 :            : 
     847         [ #  # ]:          0 :         if ( bCalcApp)
     848                 :            :         {
     849                 :          0 :             pCurrent = pWins;
     850         [ #  # ]:          0 :             for ( i = 0; i < nCalcCtrlCount; ++i, ++pCurrent )
     851         [ #  # ]:          0 :                 pMoreBtn->AddWindow( *pCurrent );
     852                 :            :         }
     853                 :            :         else
     854                 :          0 :             nOffset += 64;
     855                 :            :     }
     856                 :            :     else
     857                 :          0 :         nOffset += 64;
     858                 :            : 
     859                 :          0 :     pMoreBtn->SetDelta( nDelta - nOffset );
     860         [ #  # ]:          0 :     pMoreBtn->Show();
     861 [ #  # ][ #  # ]:          0 :     pMoreBtn->Enable();
         [ #  # ][ #  # ]
     862                 :            : }
     863                 :            : 
     864                 :            : // -----------------------------------------------------------------------
     865                 :            : 
     866                 :            : namespace {
     867                 :            : 
     868                 :            : class ToggleSaveToModule
     869                 :            : {
     870                 :            : public:
     871                 :          0 :     ToggleSaveToModule(SvxSearchDialog& rDialog, bool bValue) :
     872                 :          0 :         mrDialog(rDialog), mbValue(bValue)
     873                 :            :     {
     874                 :          0 :         mrDialog.SetSaveToModule(mbValue);
     875                 :          0 :     }
     876                 :            : 
     877                 :          0 :     ~ToggleSaveToModule()
     878                 :            :     {
     879                 :          0 :         mrDialog.SetSaveToModule(!mbValue);
     880                 :          0 :     }
     881                 :            : private:
     882                 :            :     SvxSearchDialog& mrDialog;
     883                 :            :     bool mbValue;
     884                 :            : };
     885                 :            : 
     886                 :            : }
     887                 :            : 
     888                 :          0 : void SvxSearchDialog::Init_Impl( int bSearchPattern )
     889                 :            : {
     890                 :            :     DBG_ASSERT( pSearchItem, "SearchItem == 0" );
     891                 :            : 
     892                 :            :     // We don't want to save any intermediate state to the module while the
     893                 :            :     // dialog is being initialized.
     894                 :          0 :     ToggleSaveToModule aNoModuleSave(*this, false);
     895                 :            : 
     896                 :          0 :     bWriter = ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_WRITER );
     897                 :            : 
     898                 :          0 :     pImpl->bMultiLineEdit = sal_False;
     899                 :            : 
     900         [ #  # ]:          0 :     if ( !pImpl->bMultiLineEdit )
     901                 :            :     {
     902         [ #  # ]:          0 :         pImpl->aSearchFormats.Hide();
     903         [ #  # ]:          0 :         aSearchAttrText.Show();
     904         [ #  # ]:          0 :         pImpl->aReplaceFormats.Hide();
     905         [ #  # ]:          0 :         aReplaceAttrText.Show();
     906                 :            :     }
     907                 :            :     else
     908                 :            :     {
     909         [ #  # ]:          0 :         String aText = aSearchAttrText.GetText();
     910         [ #  # ]:          0 :         aSearchAttrText.Hide();
     911                 :            : 
     912         [ #  # ]:          0 :         if ( aText.Len() )
     913         [ #  # ]:          0 :             pImpl->aSearchFormats.SetText( aText );
     914         [ #  # ]:          0 :         pImpl->aSearchFormats.Show();
     915 [ #  # ][ #  # ]:          0 :         aText = aReplaceAttrText.GetText();
                 [ #  # ]
     916         [ #  # ]:          0 :         aReplaceAttrText.Hide();
     917                 :            : 
     918         [ #  # ]:          0 :         if ( aText.Len() )
     919         [ #  # ]:          0 :             pImpl->aReplaceFormats.SetText( aText );
     920 [ #  # ][ #  # ]:          0 :         pImpl->aReplaceFormats.Show();
     921                 :            :     }
     922                 :            : 
     923         [ #  # ]:          0 :     if ( ( nModifyFlag & MODIFY_WORD ) == 0 )
     924         [ #  # ]:          0 :          aWordBtn.Check( pSearchItem->GetWordOnly() );
     925         [ #  # ]:          0 :     if ( ( nModifyFlag & MODIFY_EXACT ) == 0 )
     926         [ #  # ]:          0 :         aMatchCaseCB.Check( pSearchItem->GetExact() );
     927         [ #  # ]:          0 :     if ( ( nModifyFlag & MODIFY_BACKWARDS ) == 0 )
     928         [ #  # ]:          0 :         aBackwardsBtn.Check( pSearchItem->GetBackward() );
     929         [ #  # ]:          0 :     if ( ( nModifyFlag & MODIFY_NOTES ) == 0 )
     930         [ #  # ]:          0 :         aNotesBtn.Check( pSearchItem->GetNotes() );
     931         [ #  # ]:          0 :     if ( ( nModifyFlag & MODIFY_SELECTION ) == 0 )
     932         [ #  # ]:          0 :         aSelectionBtn.Check( pSearchItem->GetSelection() );
     933         [ #  # ]:          0 :     if ( ( nModifyFlag & MODIFY_REGEXP ) == 0 )
     934         [ #  # ]:          0 :         aRegExpBtn.Check( pSearchItem->GetRegExp() );
     935         [ #  # ]:          0 :     if ( ( nModifyFlag & MODIFY_LAYOUT ) == 0 )
     936         [ #  # ]:          0 :         aLayoutBtn.Check( pSearchItem->GetPattern() );
     937 [ #  # ][ #  # ]:          0 :     if (aNotesBtn.IsChecked())
     938         [ #  # ]:          0 :         aLayoutBtn.Disable();
     939         [ #  # ]:          0 :     aSimilarityBox.Check( pSearchItem->IsLevenshtein() );
     940 [ #  # ][ #  # ]:          0 :     if( aJapOptionsCB.IsVisible() )
     941         [ #  # ]:          0 :         aJapOptionsCB.Check( pSearchItem->IsUseAsianOptions() );
     942         [ #  # ]:          0 :     ApplyTransliterationFlags_Impl( pSearchItem->GetTransliterationFlags() );
     943                 :            : 
     944         [ #  # ]:          0 :     CalculateDelta_Impl();
     945                 :            : 
     946                 :          0 :     bool bDraw = false;
     947         [ #  # ]:          0 :     if ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_CALC )
     948                 :            :     {
     949         [ #  # ]:          0 :         Link aLink = LINK( this, SvxSearchDialog, FlagHdl_Impl );
     950                 :          0 :         aCalcSearchInLB.SetSelectHdl( aLink );
     951                 :          0 :         aRowsBtn.SetClickHdl( aLink );
     952                 :          0 :         aColumnsBtn.SetClickHdl( aLink );
     953                 :          0 :         aAllSheetsCB.SetClickHdl( aLink );
     954                 :            : 
     955   [ #  #  #  # ]:          0 :         switch ( pSearchItem->GetCellType() )
     956                 :            :         {
     957                 :            :             case SVX_SEARCHIN_FORMULA:
     958         [ #  # ]:          0 :                 if ( ( nModifyFlag & MODIFY_FORMULAS ) == 0 )
     959         [ #  # ]:          0 :                     aCalcSearchInLB.SelectEntryPos( SVX_SEARCHIN_FORMULA );
     960                 :          0 :                 break;
     961                 :            : 
     962                 :            :             case SVX_SEARCHIN_VALUE:
     963         [ #  # ]:          0 :                 if ( ( nModifyFlag & MODIFY_VALUES ) == 0 )
     964         [ #  # ]:          0 :                     aCalcSearchInLB.SelectEntryPos( SVX_SEARCHIN_VALUE );
     965                 :          0 :                 break;
     966                 :            : 
     967                 :            :             case SVX_SEARCHIN_NOTE:
     968         [ #  # ]:          0 :                 if ( ( nModifyFlag & MODIFY_CALC_NOTES ) == 0 )
     969         [ #  # ]:          0 :                     aCalcSearchInLB.SelectEntryPos( SVX_SEARCHIN_NOTE );
     970                 :          0 :                 break;
     971                 :            :         }
     972 [ #  # ][ #  # ]:          0 :         aWordBtn.SetText( aCalcStr.GetToken( 0, '#' ) );
                 [ #  # ]
     973                 :            : 
     974 [ #  # ][ #  # ]:          0 :         if ( pSearchItem->GetRowDirection() &&
                 [ #  # ]
     975                 :            :              ( nModifyFlag & MODIFY_ROWS ) == 0 )
     976         [ #  # ]:          0 :             aRowsBtn.Check();
     977 [ #  # ][ #  # ]:          0 :         else if ( !pSearchItem->GetRowDirection() &&
                 [ #  # ]
     978                 :            :                   ( nModifyFlag & MODIFY_COLUMNS ) == 0 )
     979         [ #  # ]:          0 :             aColumnsBtn.Check();
     980                 :            : 
     981         [ #  # ]:          0 :         if ( ( nModifyFlag & MODIFY_ALLTABLES ) == 0 )
     982         [ #  # ]:          0 :             aAllSheetsCB.Check( pSearchItem->IsAllTables() );
     983                 :            : 
     984                 :            :         // only look for formatting in Writer
     985         [ #  # ]:          0 :         aFormatBtn.Hide();
     986         [ #  # ]:          0 :         aNoFormatBtn.Hide();
     987         [ #  # ]:          0 :         aAttributeBtn.Hide();
     988                 :            :     }
     989                 :            :     else
     990                 :            :     {
     991 [ #  # ][ #  # ]:          0 :         aWordBtn.SetText( aCalcStr.GetToken( 1, '#' ) );
                 [ #  # ]
     992                 :            : 
     993         [ #  # ]:          0 :         if ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_DRAW )
     994                 :            :         {
     995         [ #  # ]:          0 :             aSearchAllBtn.Hide();
     996                 :            : 
     997         [ #  # ]:          0 :             aRegExpBtn.Hide();
     998         [ #  # ]:          0 :             aLayoutBtn.Hide();
     999                 :            : 
    1000                 :            :             // only look for formatting in Writer
    1001         [ #  # ]:          0 :             aFormatBtn.Hide();
    1002         [ #  # ]:          0 :             aNoFormatBtn.Hide();
    1003         [ #  # ]:          0 :             aAttributeBtn.Hide();
    1004                 :          0 :             bDraw = sal_True;
    1005                 :            :         }
    1006                 :            :         else
    1007                 :            :         {
    1008         [ #  # ]:          0 :             if ( !pSearchList )
    1009                 :            :             {
    1010                 :            :                 // Get attribute sets, if it not has been done already
    1011                 :          0 :                 const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
    1012                 :            :                 const SvxSetItem* pSrchSetItem =
    1013         [ #  # ]:          0 :                 (const SvxSetItem*)rBindings.GetDispatcher()->Execute( FID_SEARCH_SEARCHSET, SFX_CALLMODE_SLOT, ppArgs );
    1014                 :            : 
    1015         [ #  # ]:          0 :                 if ( pSrchSetItem )
    1016         [ #  # ]:          0 :                     InitAttrList_Impl( &pSrchSetItem->GetItemSet(), 0 );
    1017                 :            : 
    1018                 :            :                 const SvxSetItem* pReplSetItem =
    1019         [ #  # ]:          0 :                 (const SvxSetItem*)rBindings.GetDispatcher()->Execute( FID_SEARCH_REPLACESET, SFX_CALLMODE_SLOT, ppArgs );
    1020                 :            : 
    1021         [ #  # ]:          0 :                 if ( pReplSetItem )
    1022         [ #  # ]:          0 :                     InitAttrList_Impl( 0, &pReplSetItem->GetItemSet() );
    1023                 :            :             }
    1024                 :            :         }
    1025                 :            :     }
    1026                 :            : 
    1027                 :            :     if ( 0 && !bDraw ) //!!!!!
    1028                 :            :     {
    1029                 :            :         aRegExpBtn.Show();
    1030                 :            :         aLayoutBtn.Show();
    1031                 :            :     }
    1032                 :            : 
    1033                 :            :     // similarity search?
    1034         [ #  # ]:          0 :     if ( ( nModifyFlag & MODIFY_SIMILARITY ) == 0 )
    1035         [ #  # ]:          0 :         aSimilarityBox.Check( pSearchItem->IsLevenshtein() );
    1036                 :          0 :     bSet = sal_True;
    1037                 :            : 
    1038         [ #  # ]:          0 :     FlagHdl_Impl( &aSimilarityBox );
    1039         [ #  # ]:          0 :     FlagHdl_Impl( &aJapOptionsCB );
    1040                 :            : 
    1041                 :          0 :     bool bDisableSearch = false;
    1042         [ #  # ]:          0 :     SfxViewShell* pViewShell = SfxViewShell::Current();
    1043                 :            : 
    1044         [ #  # ]:          0 :     if ( pViewShell )
    1045                 :            :     {
    1046                 :          0 :         sal_Bool bText = !bSearchPattern;
    1047                 :            : 
    1048 [ #  # ][ #  # ]:          0 :         if ( pViewShell->HasSelection( bText ) )
    1049         [ #  # ]:          0 :             EnableControl_Impl( &aSelectionBtn );
    1050                 :            :         else
    1051                 :            :         {
    1052         [ #  # ]:          0 :             aSelectionBtn.Check( sal_False );
    1053         [ #  # ]:          0 :             aSelectionBtn.Disable();
    1054                 :            :         }
    1055                 :            :     }
    1056                 :            : 
    1057                 :            :     // Pattern Search and there were no AttrSets given
    1058         [ #  # ]:          0 :     if ( bSearchPattern )
    1059                 :            :     {
    1060         [ #  # ]:          0 :         SfxObjectShell* pShell = SfxObjectShell::Current();
    1061                 :            : 
    1062 [ #  # ][ #  # ]:          0 :         if ( pShell && pShell->GetStyleSheetPool() )
         [ #  # ][ #  # ]
    1063                 :            :         {
    1064                 :            :             // Templates designed
    1065         [ #  # ]:          0 :             aSearchTmplLB .Clear();
    1066         [ #  # ]:          0 :             aReplaceTmplLB.Clear();
    1067         [ #  # ]:          0 :             SfxStyleSheetBasePool* pStylePool = pShell->GetStyleSheetPool();
    1068                 :            :             pStylePool->SetSearchMask( pSearchItem->GetFamily(),
    1069         [ #  # ]:          0 :                                        SFXSTYLEBIT_ALL );
    1070         [ #  # ]:          0 :             SfxStyleSheetBase* pBase = pStylePool->First();
    1071                 :            : 
    1072         [ #  # ]:          0 :             while ( pBase )
    1073                 :            :             {
    1074 [ #  # ][ #  # ]:          0 :                 if ( pBase->IsUsed() )
    1075 [ #  # ][ #  # ]:          0 :                     aSearchTmplLB.InsertEntry( pBase->GetName() );
    1076 [ #  # ][ #  # ]:          0 :                 aReplaceTmplLB.InsertEntry( pBase->GetName() );
    1077         [ #  # ]:          0 :                 pBase = pStylePool->Next();
    1078                 :            :             }
    1079 [ #  # ][ #  # ]:          0 :             aSearchTmplLB.SelectEntry( pSearchItem->GetSearchString() );
                 [ #  # ]
    1080 [ #  # ][ #  # ]:          0 :             aReplaceTmplLB.SelectEntry( pSearchItem->GetReplaceString() );
                 [ #  # ]
    1081                 :            : 
    1082                 :            :         }
    1083         [ #  # ]:          0 :         aSearchTmplLB.Show();
    1084                 :            : 
    1085         [ #  # ]:          0 :         if ( bConstruct )
    1086                 :            :             // Grab focus only after creating
    1087         [ #  # ]:          0 :             aSearchTmplLB.GrabFocus();
    1088         [ #  # ]:          0 :         aReplaceTmplLB.Show();
    1089         [ #  # ]:          0 :         aSearchLB.Hide();
    1090         [ #  # ]:          0 :         aReplaceLB.Hide();
    1091                 :            : 
    1092         [ #  # ]:          0 :         aWordBtn.Disable();
    1093         [ #  # ]:          0 :         aRegExpBtn.Disable();
    1094         [ #  # ]:          0 :         aMatchCaseCB.Disable();
    1095                 :            : 
    1096         [ #  # ]:          0 :         bDisableSearch = !aSearchTmplLB.GetEntryCount();
    1097                 :            :     }
    1098                 :            :     else
    1099                 :            :     {
    1100                 :          0 :         bool bSetSearch = ( ( nModifyFlag & MODIFY_SEARCH ) == 0 );
    1101                 :          0 :         bool bSetReplace = ( ( nModifyFlag & MODIFY_REPLACE ) == 0 );
    1102                 :            : 
    1103 [ #  # ][ #  # ]:          0 :         if ( pSearchItem->GetSearchString().Len() && bSetSearch )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1104 [ #  # ][ #  # ]:          0 :             aSearchLB.SetText( pSearchItem->GetSearchString() );
                 [ #  # ]
    1105         [ #  # ]:          0 :         else if (!aSearchStrings.empty())
    1106                 :            :         {
    1107                 :            :             bool bAttributes =
    1108                 :          0 :                 ( ( pSearchList && pSearchList->Count() ) ||
    1109   [ #  #  #  # ]:          0 :                   ( pReplaceList && pReplaceList->Count() ) );
         [ #  # ][ #  # ]
    1110                 :            : 
    1111 [ #  # ][ #  # ]:          0 :             if ( bSetSearch && !bAttributes )
    1112 [ #  # ][ #  # ]:          0 :                 aSearchLB.SetText(aSearchStrings[0]);
                 [ #  # ]
    1113                 :            : 
    1114         [ #  # ]:          0 :             String aReplaceTxt = pSearchItem->GetReplaceString();
    1115                 :            : 
    1116         [ #  # ]:          0 :             if (!aReplaceStrings.empty())
    1117         [ #  # ]:          0 :                 aReplaceTxt = aReplaceStrings[0];
    1118                 :            : 
    1119 [ #  # ][ #  # ]:          0 :             if ( bSetReplace && !bAttributes )
    1120 [ #  # ][ #  # ]:          0 :                 aReplaceLB.SetText( aReplaceTxt );
    1121                 :            :         }
    1122         [ #  # ]:          0 :         aSearchLB.Show();
    1123                 :            : 
    1124         [ #  # ]:          0 :         if ( bConstruct )
    1125                 :            :             // Grab focus only after creating
    1126         [ #  # ]:          0 :             aSearchLB.GrabFocus();
    1127         [ #  # ]:          0 :         aReplaceLB.Show();
    1128         [ #  # ]:          0 :         aSearchTmplLB.Hide();
    1129         [ #  # ]:          0 :         aReplaceTmplLB.Hide();
    1130                 :            : 
    1131         [ #  # ]:          0 :         EnableControl_Impl( &aRegExpBtn );
    1132         [ #  # ]:          0 :         EnableControl_Impl( &aMatchCaseCB );
    1133                 :            : 
    1134 [ #  # ][ #  # ]:          0 :         if ( aRegExpBtn.IsChecked() )
    1135         [ #  # ]:          0 :             aWordBtn.Disable();
    1136                 :            :         else
    1137         [ #  # ]:          0 :             EnableControl_Impl( &aWordBtn );
    1138                 :            : 
    1139         [ #  # ]:          0 :         String aSrchAttrTxt;
    1140                 :            : 
    1141         [ #  # ]:          0 :         if ( pImpl->bMultiLineEdit )
    1142 [ #  # ][ #  # ]:          0 :             aSrchAttrTxt = pImpl->aSearchFormats.GetText();
                 [ #  # ]
    1143                 :            :         else
    1144 [ #  # ][ #  # ]:          0 :             aSrchAttrTxt = aSearchAttrText.GetText();
                 [ #  # ]
    1145                 :            : 
    1146 [ #  # ][ #  # ]:          0 :         bDisableSearch = !aSearchLB.GetText().Len() && !aSrchAttrTxt.Len();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1147                 :            :     }
    1148         [ #  # ]:          0 :     FocusHdl_Impl( &aSearchLB );
    1149                 :            : 
    1150         [ #  # ]:          0 :     if ( bDisableSearch )
    1151                 :            :     {
    1152         [ #  # ]:          0 :         aSearchBtn.Disable();
    1153         [ #  # ]:          0 :         aSearchAllBtn.Disable();
    1154         [ #  # ]:          0 :         aReplaceBtn.Disable();
    1155         [ #  # ]:          0 :         aReplaceAllBtn.Disable();
    1156         [ #  # ]:          0 :         aSearchComponentFL.Enable(sal_False);
    1157         [ #  # ]:          0 :         aSearchComponent1PB.Enable(sal_False);
    1158         [ #  # ]:          0 :         aSearchComponent2PB.Enable(sal_False);
    1159                 :            :     }
    1160                 :            :     else
    1161                 :            :     {
    1162         [ #  # ]:          0 :         EnableControl_Impl( &aSearchBtn );
    1163         [ #  # ]:          0 :         EnableControl_Impl( &aReplaceBtn );
    1164 [ #  # ][ #  # ]:          0 :         if (!bWriter || (bWriter && !aNotesBtn.IsChecked()))
         [ #  # ][ #  # ]
                 [ #  # ]
    1165                 :            :         {
    1166         [ #  # ]:          0 :             EnableControl_Impl( &aSearchAllBtn );
    1167         [ #  # ]:          0 :             EnableControl_Impl( &aReplaceAllBtn );
    1168                 :            :         }
    1169 [ #  # ][ #  # ]:          0 :         if (bWriter && pSearchItem->GetNotes())
                 [ #  # ]
    1170                 :            :         {
    1171         [ #  # ]:          0 :             aSearchAllBtn.Disable();
    1172         [ #  # ]:          0 :             aReplaceAllBtn.Disable();
    1173                 :            :         }
    1174                 :            :     }
    1175                 :            : 
    1176 [ #  # ][ #  # ]:          0 :     if ( ( !pImpl->bMultiLineEdit && aSearchAttrText.GetText().Len() ) ||
                 [ #  # ]
           [ #  #  #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1177 [ #  # ][ #  # ]:          0 :             ( pImpl->bMultiLineEdit && pImpl->aSearchFormats.GetText().Len() ) )
         [ #  # ][ #  # ]
    1178         [ #  # ]:          0 :         EnableControl_Impl( &aNoFormatBtn );
    1179                 :            :     else
    1180         [ #  # ]:          0 :         aNoFormatBtn.Disable();
    1181                 :            : 
    1182         [ #  # ]:          0 :     if ( !pSearchList )
    1183                 :            :     {
    1184         [ #  # ]:          0 :         aAttributeBtn.Disable();
    1185         [ #  # ]:          0 :         aFormatBtn.Disable();
    1186                 :            :     }
    1187                 :            : 
    1188 [ #  # ][ #  # ]:          0 :     if ( aLayoutBtn.IsChecked() )
    1189                 :            :     {
    1190                 :          0 :         pImpl->bSaveToModule = sal_False;
    1191         [ #  # ]:          0 :         TemplateHdl_Impl( &aLayoutBtn );
    1192                 :          0 :         pImpl->bSaveToModule = sal_True;
    1193                 :          0 :     }
    1194                 :          0 : }
    1195                 :            : 
    1196                 :            : // -----------------------------------------------------------------------
    1197                 :            : 
    1198                 :          0 : void SvxSearchDialog::InitAttrList_Impl( const SfxItemSet* pSSet,
    1199                 :            :                                          const SfxItemSet* pRSet )
    1200                 :            : {
    1201 [ #  # ][ #  # ]:          0 :     if ( !pSSet && !pRSet )
    1202                 :          0 :         return;
    1203                 :            : 
    1204 [ #  # ][ #  # ]:          0 :     if ( !pImpl->pRanges && pSSet )
    1205                 :            :     {
    1206                 :          0 :         sal_sSize nCnt = 0;
    1207                 :          0 :         const sal_uInt16* pPtr = pSSet->GetRanges();
    1208                 :          0 :         const sal_uInt16* pTmp = pPtr;
    1209                 :            : 
    1210         [ #  # ]:          0 :         while( *pPtr )
    1211                 :            :         {
    1212                 :          0 :             nCnt += ( *(pPtr+1) - *pPtr ) + 1;
    1213                 :          0 :             pPtr += 2;
    1214                 :            :         }
    1215                 :          0 :         nCnt = pPtr - pTmp + 1;
    1216         [ #  # ]:          0 :         pImpl->pRanges = new sal_uInt16[nCnt];
    1217                 :          0 :         memcpy( pImpl->pRanges, pTmp, sizeof(sal_uInt16) * nCnt );
    1218                 :            :     }
    1219                 :            : 
    1220                 :            :     // See to it that are the texts of the attributes are correct
    1221         [ #  # ]:          0 :     String aDesc;
    1222                 :            : 
    1223         [ #  # ]:          0 :     if ( pSSet )
    1224                 :            :     {
    1225 [ #  # ][ #  # ]:          0 :         delete pSearchList;
    1226 [ #  # ][ #  # ]:          0 :         pSearchList = new SearchAttrItemList;
    1227                 :            : 
    1228         [ #  # ]:          0 :         if ( pSSet->Count() )
    1229                 :            :         {
    1230         [ #  # ]:          0 :             pSearchList->Put( *pSSet );
    1231                 :            : 
    1232         [ #  # ]:          0 :             if ( !pImpl->bMultiLineEdit )
    1233 [ #  # ][ #  # ]:          0 :                 aSearchAttrText.SetText( BuildAttrText_Impl( aDesc, sal_True ) );
    1234                 :            :             else
    1235 [ #  # ][ #  # ]:          0 :                 pImpl->aSearchFormats.SetText( BuildAttrText_Impl( aDesc, sal_True ) );
    1236                 :            : 
    1237         [ #  # ]:          0 :             if ( aDesc.Len() )
    1238                 :          0 :                 bFormat |= sal_True;
    1239                 :            :         }
    1240                 :            :     }
    1241                 :            : 
    1242         [ #  # ]:          0 :     if ( pRSet )
    1243                 :            :     {
    1244 [ #  # ][ #  # ]:          0 :         delete pReplaceList;
    1245 [ #  # ][ #  # ]:          0 :         pReplaceList = new SearchAttrItemList;
    1246                 :            : 
    1247         [ #  # ]:          0 :         if ( pRSet->Count() )
    1248                 :            :         {
    1249         [ #  # ]:          0 :             pReplaceList->Put( *pRSet );
    1250                 :            : 
    1251         [ #  # ]:          0 :             if ( !pImpl->bMultiLineEdit )
    1252 [ #  # ][ #  # ]:          0 :                 aReplaceAttrText.SetText( BuildAttrText_Impl( aDesc, sal_False ) );
    1253                 :            :             else
    1254 [ #  # ][ #  # ]:          0 :                 pImpl->aReplaceFormats.SetText( BuildAttrText_Impl( aDesc, sal_False ) );
    1255                 :            : 
    1256         [ #  # ]:          0 :             if ( aDesc.Len() )
    1257                 :          0 :                 bFormat |= sal_True;
    1258                 :            :         }
    1259         [ #  # ]:          0 :     }
    1260                 :            : }
    1261                 :            : 
    1262                 :            : // -----------------------------------------------------------------------
    1263                 :            : 
    1264                 :          0 : IMPL_LINK( SvxSearchDialog, FlagHdl_Impl, Control *, pCtrl )
    1265                 :            : {
    1266 [ #  # ][ #  # ]:          0 :     if ( pCtrl && !bSet )
    1267                 :          0 :         SetModifyFlag_Impl( pCtrl );
    1268                 :            :     else
    1269                 :          0 :         bSet = sal_False;
    1270                 :            : 
    1271         [ #  # ]:          0 :     if ( pCtrl == &aSimilarityBox )
    1272                 :            :     {
    1273                 :          0 :         sal_Bool bIsChecked = aSimilarityBox.IsChecked();
    1274                 :            : 
    1275         [ #  # ]:          0 :         if ( bIsChecked )
    1276                 :            :         {
    1277                 :          0 :             aSimilarityBtn.Enable();
    1278                 :          0 :             aRegExpBtn.Check( sal_False );
    1279                 :          0 :             aRegExpBtn.Disable();
    1280                 :          0 :             EnableControl_Impl( &aWordBtn );
    1281                 :            : 
    1282         [ #  # ]:          0 :             if ( aLayoutBtn.IsChecked() )
    1283                 :            :             {
    1284                 :          0 :                 EnableControl_Impl( &aMatchCaseCB );
    1285                 :          0 :                 aLayoutBtn.Check( sal_False );
    1286                 :            :             }
    1287                 :          0 :             aRegExpBtn.Disable();
    1288                 :          0 :             aLayoutBtn.Disable();
    1289                 :          0 :             aFormatBtn.Disable();
    1290                 :          0 :             aNoFormatBtn.Disable();
    1291                 :          0 :             aAttributeBtn.Disable();
    1292                 :            :         }
    1293                 :            :         else
    1294                 :            :         {
    1295                 :          0 :             EnableControl_Impl( &aRegExpBtn );
    1296         [ #  # ]:          0 :             if (!aNotesBtn.IsChecked())
    1297                 :          0 :                 EnableControl_Impl( &aLayoutBtn );
    1298                 :          0 :             EnableControl_Impl( &aFormatBtn );
    1299                 :          0 :             EnableControl_Impl( &aAttributeBtn );
    1300                 :          0 :             aSimilarityBtn.Disable();
    1301                 :            :         }
    1302                 :          0 :         pSearchItem->SetLevenshtein( bIsChecked );
    1303                 :            :     }
    1304                 :            :     else
    1305         [ #  # ]:          0 :     if ( pCtrl == &aNotesBtn)
    1306                 :            :     {
    1307         [ #  # ]:          0 :         if (aNotesBtn.IsChecked())
    1308                 :            :         {
    1309                 :          0 :             aLayoutBtn.Disable();
    1310                 :          0 :             aSearchAllBtn.Disable();
    1311                 :          0 :             aReplaceAllBtn.Disable();
    1312                 :            :         }
    1313                 :            :         else
    1314                 :            :         {
    1315                 :          0 :             EnableControl_Impl( &aLayoutBtn );
    1316                 :          0 :             ModifyHdl_Impl( &aSearchLB );
    1317                 :            :         }
    1318                 :            :     }
    1319                 :            :     else
    1320                 :            :     {
    1321 [ #  # ][ #  # ]:          0 :         if ( aLayoutBtn.IsChecked() && !bFormat )
                 [ #  # ]
    1322                 :            :         {
    1323                 :          0 :             aWordBtn.Check( sal_False );
    1324                 :          0 :             aWordBtn.Disable();
    1325                 :          0 :             aRegExpBtn.Check( sal_False );
    1326                 :          0 :             aRegExpBtn.Disable();
    1327                 :          0 :             aMatchCaseCB.Check( sal_False );
    1328                 :          0 :             aMatchCaseCB.Disable();
    1329                 :          0 :             aNotesBtn.Disable();
    1330                 :            : 
    1331         [ #  # ]:          0 :             if ( aSearchTmplLB.GetEntryCount() )
    1332                 :            :             {
    1333                 :          0 :                 EnableControl_Impl( &aSearchBtn );
    1334                 :          0 :                 EnableControl_Impl( &aSearchAllBtn );
    1335                 :          0 :                 EnableControl_Impl( &aReplaceBtn );
    1336                 :          0 :                 EnableControl_Impl( &aReplaceAllBtn );
    1337                 :            :             }
    1338                 :            :         }
    1339                 :            :         else
    1340                 :            :         {
    1341                 :          0 :             EnableControl_Impl( &aRegExpBtn );
    1342                 :          0 :             EnableControl_Impl( &aMatchCaseCB );
    1343                 :          0 :             EnableControl_Impl( &aNotesBtn );
    1344                 :            : 
    1345         [ #  # ]:          0 :             if ( aRegExpBtn.IsChecked() )
    1346                 :            :             {
    1347                 :          0 :                 aWordBtn.Check( sal_False );
    1348                 :          0 :                 aWordBtn.Disable();
    1349                 :          0 :                 aSimilarityBox.Disable();
    1350                 :          0 :                 aSimilarityBtn.Disable();
    1351                 :            :             }
    1352                 :            :             else
    1353                 :            :             {
    1354                 :          0 :                 EnableControl_Impl( &aWordBtn );
    1355                 :          0 :                 EnableControl_Impl( &aSimilarityBox );
    1356                 :            :             }
    1357                 :            : 
    1358                 :            :             // Search-string in place? then enable Buttons
    1359                 :          0 :             bSet = sal_True;
    1360                 :          0 :             ModifyHdl_Impl( &aSearchLB );
    1361                 :            :         }
    1362                 :            :     }
    1363                 :            : 
    1364         [ #  # ]:          0 :     if ( &aAllSheetsCB == pCtrl )
    1365                 :            :     {
    1366         [ #  # ]:          0 :         if ( aAllSheetsCB.IsChecked() )
    1367                 :          0 :             aSearchAllBtn.Disable();
    1368                 :            :         else
    1369                 :            :         {
    1370                 :          0 :             bSet = sal_True;
    1371                 :          0 :             ModifyHdl_Impl( &aSearchLB );
    1372                 :            :         }
    1373                 :            :     }
    1374                 :            : 
    1375         [ #  # ]:          0 :     if ( &aJapOptionsCB == pCtrl )
    1376                 :            :     {
    1377                 :          0 :         sal_Bool bEnableJapOpt = aJapOptionsCB.IsChecked();
    1378                 :          0 :         aMatchCaseCB            .Enable(!bEnableJapOpt );
    1379                 :          0 :         aJapMatchFullHalfWidthCB.Enable(!bEnableJapOpt );
    1380                 :          0 :         aJapOptionsBtn          .Enable( bEnableJapOpt );
    1381                 :            :     }
    1382                 :            : 
    1383         [ #  # ]:          0 :     if ( pImpl->bSaveToModule )
    1384                 :          0 :         SaveToModule_Impl();
    1385                 :          0 :     return 0;
    1386                 :            : }
    1387                 :            : 
    1388                 :            : // -----------------------------------------------------------------------
    1389                 :            : 
    1390                 :          0 : IMPL_LINK( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn )
    1391                 :            : {
    1392         [ #  # ]:          0 :     bool bInclusive = ( aLayoutBtn.GetText() == aLayoutStr );
    1393                 :            : 
    1394 [ #  # ][ #  # ]:          0 :     if ( ( pBtn == &aSearchBtn )    ||
         [ #  # ][ #  # ]
    1395                 :            :          ( pBtn == &aSearchAllBtn ) ||
    1396                 :            :          ( pBtn == &aReplaceBtn )   ||
    1397                 :            :          ( pBtn == &aReplaceAllBtn ) )
    1398                 :            :     {
    1399 [ #  # ][ #  # ]:          0 :         if ( aLayoutBtn.IsChecked() && !bInclusive )
         [ #  # ][ #  # ]
    1400                 :            :         {
    1401 [ #  # ][ #  # ]:          0 :             pSearchItem->SetSearchString ( aSearchTmplLB.GetSelectEntry() );
                 [ #  # ]
    1402 [ #  # ][ #  # ]:          0 :             pSearchItem->SetReplaceString( aReplaceTmplLB.GetSelectEntry() );
                 [ #  # ]
    1403                 :            :         }
    1404                 :            :         else
    1405                 :            :         {
    1406 [ #  # ][ #  # ]:          0 :             pSearchItem->SetSearchString ( aSearchLB.GetText() );
                 [ #  # ]
    1407 [ #  # ][ #  # ]:          0 :             pSearchItem->SetReplaceString( aReplaceLB.GetText() );
                 [ #  # ]
    1408                 :            : 
    1409         [ #  # ]:          0 :             if ( pBtn == &aReplaceBtn )
    1410 [ #  # ][ #  # ]:          0 :                 Remember_Impl( aReplaceLB.GetText(), sal_False );
                 [ #  # ]
    1411                 :            :             else
    1412                 :            :             {
    1413 [ #  # ][ #  # ]:          0 :                 Remember_Impl( aSearchLB.GetText(), sal_True );
                 [ #  # ]
    1414                 :            : 
    1415         [ #  # ]:          0 :                 if ( pBtn == &aReplaceAllBtn )
    1416 [ #  # ][ #  # ]:          0 :                     Remember_Impl( aReplaceLB.GetText(), sal_False );
                 [ #  # ]
    1417                 :            :             }
    1418                 :            :         }
    1419                 :            : 
    1420         [ #  # ]:          0 :         pSearchItem->SetRegExp( sal_False );
    1421         [ #  # ]:          0 :         pSearchItem->SetLevenshtein( sal_False );
    1422 [ #  # ][ #  # ]:          0 :         if (GetCheckBoxValue( aRegExpBtn ))
         [ #  # ][ #  # ]
                 [ #  # ]
    1423         [ #  # ]:          0 :             pSearchItem->SetRegExp( sal_True );
    1424 [ #  # ][ #  # ]:          0 :         else if (GetCheckBoxValue( aSimilarityBox ))
         [ #  # ][ #  # ]
                 [ #  # ]
    1425         [ #  # ]:          0 :             pSearchItem->SetLevenshtein( sal_True );
    1426                 :            : 
    1427 [ #  # ][ #  # ]:          0 :         pSearchItem->SetWordOnly( GetCheckBoxValue( aWordBtn ) );
         [ #  # ][ #  # ]
    1428 [ #  # ][ #  # ]:          0 :         pSearchItem->SetBackward( GetCheckBoxValue( aBackwardsBtn ) );
                 [ #  # ]
    1429 [ #  # ][ #  # ]:          0 :         pSearchItem->SetNotes( GetCheckBoxValue( aNotesBtn ) );
                 [ #  # ]
    1430 [ #  # ][ #  # ]:          0 :         pSearchItem->SetPattern( GetCheckBoxValue( aLayoutBtn ) );
                 [ #  # ]
    1431 [ #  # ][ #  # ]:          0 :         pSearchItem->SetSelection( GetCheckBoxValue( aSelectionBtn ) );
         [ #  # ][ #  # ]
    1432                 :            : 
    1433 [ #  # ][ #  # ]:          0 :         pSearchItem->SetUseAsianOptions( GetCheckBoxValue( aJapOptionsCB ) );
                 [ #  # ]
    1434         [ #  # ]:          0 :         sal_Int32 nFlags = GetTransliterationFlags();
    1435         [ #  # ]:          0 :         if( !pSearchItem->IsUseAsianOptions())
    1436                 :            :             nFlags &= (TransliterationModules_IGNORE_CASE |
    1437                 :          0 :                        TransliterationModules_IGNORE_WIDTH );
    1438         [ #  # ]:          0 :         pSearchItem->SetTransliterationFlags( nFlags );
    1439                 :            : 
    1440         [ #  # ]:          0 :         if ( !bWriter )
    1441                 :            :         {
    1442 [ #  # ][ #  # ]:          0 :             if ( aCalcSearchInLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
    1443         [ #  # ]:          0 :                 pSearchItem->SetCellType( aCalcSearchInLB.GetSelectEntryPos() );
    1444                 :            : 
    1445                 :          0 :             pSearchItem->SetRowDirection( aRowsBtn.IsChecked() );
    1446         [ #  # ]:          0 :             pSearchItem->SetAllTables( aAllSheetsCB.IsChecked() );
    1447                 :            :         }
    1448                 :            : 
    1449         [ #  # ]:          0 :         if ( pBtn == &aSearchBtn )
    1450                 :          0 :             pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
    1451         [ #  # ]:          0 :         else if ( pBtn == &aSearchAllBtn )
    1452                 :          0 :             pSearchItem->SetCommand( SVX_SEARCHCMD_FIND_ALL );
    1453         [ #  # ]:          0 :         else if ( pBtn == &aReplaceBtn )
    1454                 :          0 :             pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE );
    1455         [ #  # ]:          0 :         else if ( pBtn == &aReplaceAllBtn )
    1456                 :          0 :             pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE_ALL );
    1457                 :            : 
    1458                 :            :         // when looking for templates, delete format lists
    1459 [ #  # ][ #  # ]:          0 :         if ( !bFormat && pSearchItem->GetPattern() )
                 [ #  # ]
    1460                 :            :         {
    1461         [ #  # ]:          0 :             if ( pSearchList )
    1462         [ #  # ]:          0 :                 pSearchList->Clear();
    1463                 :            : 
    1464         [ #  # ]:          0 :             if ( pReplaceList )
    1465         [ #  # ]:          0 :                 pReplaceList->Clear();
    1466                 :            :         }
    1467                 :          0 :         nModifyFlag = 0;
    1468                 :          0 :         const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
    1469         [ #  # ]:          0 :         rBindings.ExecuteSynchron( FID_SEARCH_NOW, ppArgs, 0L );
    1470                 :            :     }
    1471         [ #  # ]:          0 :     else if ( pBtn == &aCloseBtn )
    1472                 :            :     {
    1473 [ #  # ][ #  # ]:          0 :         if ( !aLayoutBtn.IsChecked() || bInclusive )
                 [ #  # ]
    1474                 :            :         {
    1475         [ #  # ]:          0 :             String aStr( aSearchLB.GetText() );
    1476                 :            : 
    1477         [ #  # ]:          0 :             if ( aStr.Len() )
    1478         [ #  # ]:          0 :                 Remember_Impl( aStr, sal_True );
    1479 [ #  # ][ #  # ]:          0 :             aStr = aReplaceLB.GetText();
                 [ #  # ]
    1480                 :            : 
    1481         [ #  # ]:          0 :             if ( aStr.Len() )
    1482 [ #  # ][ #  # ]:          0 :                 Remember_Impl( aStr, sal_False );
    1483                 :            :         }
    1484                 :          0 :         SaveToModule_Impl();
    1485                 :          0 :         Close();
    1486                 :            :     }
    1487         [ #  # ]:          0 :     else if ( pBtn == &aSimilarityBtn )
    1488                 :            :     {
    1489                 :          0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    1490         [ #  # ]:          0 :         if(pFact)
    1491                 :            :         {
    1492                 :            :             AbstractSvxSearchSimilarityDialog* pDlg = pFact->CreateSvxSearchSimilarityDialog( this,
    1493                 :          0 :                                                                         pSearchItem->IsLEVRelaxed(),
    1494                 :          0 :                                                                         pSearchItem->GetLEVOther(),
    1495                 :          0 :                                                                         pSearchItem->GetLEVShorter(),
    1496                 :          0 :                                                                         pSearchItem->GetLEVLonger() );
    1497                 :            :             DBG_ASSERT(pDlg, "Dialogdiet fail!");
    1498 [ #  # ][ #  # ]:          0 :             if ( pDlg && pDlg->Execute() == RET_OK )
                 [ #  # ]
    1499                 :            :             {
    1500                 :          0 :                 pSearchItem->SetLEVRelaxed( pDlg->IsRelaxed() );
    1501                 :          0 :                 pSearchItem->SetLEVOther( pDlg->GetOther() );
    1502                 :          0 :                 pSearchItem->SetLEVShorter( pDlg->GetShorter() );
    1503                 :          0 :                 pSearchItem->SetLEVLonger( pDlg->GetLonger() );
    1504                 :          0 :                 SaveToModule_Impl();
    1505                 :            :             }
    1506         [ #  # ]:          0 :             delete pDlg;
    1507                 :            :         }
    1508                 :            :     }
    1509         [ #  # ]:          0 :     else if ( pBtn == &aJapOptionsBtn )
    1510                 :            :     {
    1511 [ #  # ][ #  # ]:          0 :         SfxItemSet aSet( SFX_APP()->GetPool() );
    1512 [ #  # ][ #  # ]:          0 :         pSearchItem->SetTransliterationFlags( GetTransliterationFlags() );
    1513         [ #  # ]:          0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    1514         [ #  # ]:          0 :         if(pFact)
    1515                 :            :         {
    1516                 :            :             AbstractSvxJSearchOptionsDialog* aDlg = pFact->CreateSvxJSearchOptionsDialog( this, aSet,
    1517         [ #  # ]:          0 :                     pSearchItem->GetTransliterationFlags() );
    1518                 :            :             DBG_ASSERT(aDlg, "Dialogdiet fail!");
    1519         [ #  # ]:          0 :             int nRet = aDlg->Execute();
    1520         [ #  # ]:          0 :             if (RET_OK == nRet) //! true only if FillItemSet of SvxJSearchOptionsPage returns true
    1521                 :            :             {
    1522         [ #  # ]:          0 :                 sal_Int32 nFlags = aDlg->GetTransliterationFlags();
    1523         [ #  # ]:          0 :                 pSearchItem->SetTransliterationFlags( nFlags );
    1524         [ #  # ]:          0 :                 ApplyTransliterationFlags_Impl( nFlags );
    1525                 :            :             }
    1526 [ #  # ][ #  # ]:          0 :             delete aDlg;
    1527         [ #  # ]:          0 :         }
    1528                 :            :     }
    1529 [ #  # ][ #  # ]:          0 :     else if(pBtn == &aSearchComponent1PB || pBtn == &aSearchComponent2PB )
    1530                 :            :     {
    1531         [ #  # ]:          0 :         uno::Sequence < beans::PropertyValue > aArgs(2);
    1532         [ #  # ]:          0 :         beans::PropertyValue* pArgs = aArgs.getArray();
    1533                 :          0 :         pArgs[0].Name = ::rtl::OUString("SearchString");
    1534 [ #  # ][ #  # ]:          0 :         pArgs[0].Value <<= ::rtl::OUString(aSearchLB.GetText());
         [ #  # ][ #  # ]
    1535                 :          0 :         pArgs[1].Name = ::rtl::OUString("ParentWindow");
    1536 [ #  # ][ #  # ]:          0 :         pArgs[1].Value <<= VCLUnoHelper::GetInterface( this );
    1537         [ #  # ]:          0 :         if(pBtn == &aSearchComponent1PB)
    1538                 :            :         {
    1539         [ #  # ]:          0 :             if ( pImpl->xCommand1Dispatch.is() )
    1540 [ #  # ][ #  # ]:          0 :                 pImpl->xCommand1Dispatch->dispatch(pImpl->aCommand1URL, aArgs);
    1541                 :            :         }
    1542                 :            :         else
    1543                 :            :         {
    1544         [ #  # ]:          0 :             if ( pImpl->xCommand2Dispatch.is() )
    1545 [ #  # ][ #  # ]:          0 :                 pImpl->xCommand2Dispatch->dispatch(pImpl->aCommand2URL, aArgs);
    1546         [ #  # ]:          0 :         }
    1547                 :            :     }
    1548                 :            : 
    1549                 :          0 :     return 0;
    1550                 :            : }
    1551                 :            : 
    1552                 :            : // -----------------------------------------------------------------------
    1553                 :            : 
    1554                 :          0 : IMPL_LINK( SvxSearchDialog, ModifyHdl_Impl, ComboBox *, pEd )
    1555                 :            : {
    1556         [ #  # ]:          0 :     if ( !bSet )
    1557                 :          0 :         SetModifyFlag_Impl( pEd );
    1558                 :            :     else
    1559                 :          0 :         bSet = sal_False;
    1560                 :            : 
    1561                 :            :     // Calc allows searching for empty cells.
    1562                 :          0 :     bool bAllowEmptySearch = (pSearchItem->GetAppFlag() == SVX_SEARCHAPP_CALC);
    1563                 :            : 
    1564 [ #  # ][ #  # ]:          0 :     if ( pEd == &aSearchLB || pEd == &aReplaceLB )
    1565                 :            :     {
    1566                 :          0 :         xub_StrLen nSrchTxtLen = aSearchLB.GetText().Len();
    1567                 :          0 :         xub_StrLen nReplTxtLen = 0;
    1568         [ #  # ]:          0 :         if (bAllowEmptySearch)
    1569                 :          0 :             nReplTxtLen = aReplaceLB.GetText().Len();
    1570                 :          0 :         xub_StrLen nAttrTxtLen = 0;
    1571                 :            : 
    1572         [ #  # ]:          0 :         if ( !pImpl->bMultiLineEdit )
    1573                 :          0 :            nAttrTxtLen = aSearchAttrText.GetText().Len();
    1574                 :            :         else
    1575                 :          0 :             nAttrTxtLen = pImpl->aSearchFormats.GetText().Len();
    1576                 :            : 
    1577 [ #  # ][ #  # ]:          0 :         if (nSrchTxtLen || nReplTxtLen || nAttrTxtLen)
                 [ #  # ]
    1578                 :            :         {
    1579                 :          0 :             EnableControl_Impl( &aSearchBtn );
    1580                 :          0 :             EnableControl_Impl( &aReplaceBtn );
    1581 [ #  # ][ #  # ]:          0 :             if (!bWriter || (bWriter && !aNotesBtn.IsChecked()))
         [ #  # ][ #  # ]
    1582                 :            :             {
    1583                 :          0 :                 EnableControl_Impl( &aSearchAllBtn );
    1584                 :          0 :                 EnableControl_Impl( &aReplaceAllBtn );
    1585                 :            :             }
    1586                 :            :         }
    1587                 :            :         else
    1588                 :            :         {
    1589                 :          0 :             aSearchComponentFL.Enable(sal_False);
    1590                 :          0 :             aSearchComponent1PB.Enable(sal_False);
    1591                 :          0 :             aSearchComponent2PB.Enable(sal_False);
    1592                 :          0 :             aSearchBtn.Disable();
    1593                 :          0 :             aSearchAllBtn.Disable();
    1594                 :          0 :             aReplaceBtn.Disable();
    1595                 :          0 :             aReplaceAllBtn.Disable();
    1596                 :            :         }
    1597                 :            :     }
    1598                 :          0 :     return 0;
    1599                 :            : }
    1600                 :            : 
    1601                 :            : // -----------------------------------------------------------------------
    1602                 :            : 
    1603                 :          0 : IMPL_LINK_NOARG(SvxSearchDialog, TemplateHdl_Impl)
    1604                 :            : {
    1605         [ #  # ]:          0 :     if ( pImpl->bSaveToModule )
    1606         [ #  # ]:          0 :         SaveToModule_Impl();
    1607                 :            : 
    1608         [ #  # ]:          0 :     if ( bFormat )
    1609                 :          0 :         return 0;
    1610         [ #  # ]:          0 :     String sDesc;
    1611                 :            : 
    1612 [ #  # ][ #  # ]:          0 :     if ( aLayoutBtn.IsChecked() )
    1613                 :            :     {
    1614         [ #  # ]:          0 :         if ( !pFamilyController )
    1615                 :            :         {
    1616                 :          0 :             sal_uInt16 nId = 0;
    1617                 :            : 
    1618                 :            :             // Enable templates controller
    1619   [ #  #  #  #  :          0 :             switch ( pSearchItem->GetFamily() )
                   #  # ]
    1620                 :            :             {
    1621                 :            :                 case SFX_STYLE_FAMILY_CHAR:
    1622                 :          0 :                     nId = SID_STYLE_FAMILY1; break;
    1623                 :            : 
    1624                 :            :                 case SFX_STYLE_FAMILY_PARA:
    1625                 :          0 :                     nId = SID_STYLE_FAMILY2; break;
    1626                 :            : 
    1627                 :            :                 case SFX_STYLE_FAMILY_FRAME:
    1628                 :          0 :                     nId = SID_STYLE_FAMILY3; break;
    1629                 :            : 
    1630                 :            :                 case SFX_STYLE_FAMILY_PAGE:
    1631                 :          0 :                     nId = SID_STYLE_FAMILY4; break;
    1632                 :            : 
    1633                 :            :                 case SFX_STYLE_FAMILY_ALL:
    1634                 :          0 :                     break;
    1635                 :            : 
    1636                 :            :                 default:
    1637                 :            :                     OSL_FAIL( "StyleSheetFamily was changed?" );
    1638                 :            :             }
    1639                 :            : 
    1640         [ #  # ]:          0 :             rBindings.EnterRegistrations();
    1641                 :            :             pFamilyController =
    1642 [ #  # ][ #  # ]:          0 :                 new SvxSearchController( nId, rBindings, *this );
    1643         [ #  # ]:          0 :             rBindings.LeaveRegistrations();
    1644         [ #  # ]:          0 :             aSearchTmplLB.Clear();
    1645         [ #  # ]:          0 :             aReplaceTmplLB.Clear();
    1646                 :            : 
    1647         [ #  # ]:          0 :             aSearchTmplLB.Show();
    1648         [ #  # ]:          0 :             aReplaceTmplLB.Show();
    1649         [ #  # ]:          0 :             aSearchLB.Hide();
    1650         [ #  # ]:          0 :             aReplaceLB.Hide();
    1651                 :            : 
    1652         [ #  # ]:          0 :             if ( !pImpl->bMultiLineEdit )
    1653                 :            :             {
    1654         [ #  # ]:          0 :                 aSearchAttrText.SetText( sDesc );
    1655         [ #  # ]:          0 :                 aReplaceAttrText.SetText( sDesc );
    1656                 :            :             }
    1657                 :            :             else
    1658                 :            :             {
    1659         [ #  # ]:          0 :                 pImpl->aSearchFormats.SetText( sDesc );
    1660         [ #  # ]:          0 :                 pImpl->aReplaceFormats.SetText( sDesc );
    1661                 :            :             }
    1662                 :            :         }
    1663         [ #  # ]:          0 :         aFormatBtn.Disable();
    1664         [ #  # ]:          0 :         aNoFormatBtn.Disable();
    1665         [ #  # ]:          0 :         aAttributeBtn.Disable();
    1666         [ #  # ]:          0 :         aSimilarityBox.Disable();
    1667         [ #  # ]:          0 :         aSimilarityBtn.Disable();
    1668                 :            :     }
    1669                 :            :     else
    1670                 :            :     {
    1671                 :            :         // Disable templates controller
    1672         [ #  # ]:          0 :         rBindings.EnterRegistrations();
    1673 [ #  # ][ #  # ]:          0 :         DELETEZ( pFamilyController );
    1674         [ #  # ]:          0 :         rBindings.LeaveRegistrations();
    1675                 :            : 
    1676         [ #  # ]:          0 :         aSearchLB.Show();
    1677         [ #  # ]:          0 :         aReplaceLB.Show();
    1678         [ #  # ]:          0 :         aSearchTmplLB.Hide();
    1679         [ #  # ]:          0 :         aReplaceTmplLB.Hide();
    1680                 :            : 
    1681         [ #  # ]:          0 :         if ( !pImpl->bMultiLineEdit )
    1682                 :            :         {
    1683 [ #  # ][ #  # ]:          0 :             aSearchAttrText.SetText( BuildAttrText_Impl( sDesc, sal_True ) );
    1684 [ #  # ][ #  # ]:          0 :             aReplaceAttrText.SetText( BuildAttrText_Impl( sDesc, sal_False ) );
    1685                 :            :         }
    1686                 :            :         else
    1687                 :            :         {
    1688 [ #  # ][ #  # ]:          0 :             pImpl->aSearchFormats.SetText( BuildAttrText_Impl( sDesc, sal_True ) );
    1689 [ #  # ][ #  # ]:          0 :             pImpl->aReplaceFormats.SetText( BuildAttrText_Impl( sDesc, sal_False ) );
    1690                 :            :         }
    1691                 :            : 
    1692         [ #  # ]:          0 :         EnableControl_Impl( &aFormatBtn );
    1693         [ #  # ]:          0 :         EnableControl_Impl( &aAttributeBtn );
    1694         [ #  # ]:          0 :         EnableControl_Impl( &aSimilarityBox );
    1695                 :            : 
    1696 [ #  # ][ #  # ]:          0 :         FocusHdl_Impl( bSearch ? &aSearchLB : &aReplaceLB );
    1697                 :            :     }
    1698                 :          0 :     bSet = sal_True;
    1699                 :          0 :     pImpl->bSaveToModule = sal_False;
    1700         [ #  # ]:          0 :     FlagHdl_Impl( &aLayoutBtn );
    1701                 :          0 :     pImpl->bSaveToModule = sal_True;
    1702         [ #  # ]:          0 :     return 0;
    1703                 :            : }
    1704                 :            : 
    1705                 :            : // -----------------------------------------------------------------------
    1706                 :            : 
    1707                 :          0 : void SvxSearchDialog::Remember_Impl( const String &rStr,sal_Bool _bSearch )
    1708                 :            : {
    1709         [ #  # ]:          0 :     if ( !rStr.Len() )
    1710                 :          0 :         return;
    1711                 :            : 
    1712         [ #  # ]:          0 :     std::vector<rtl::OUString>* pArr = _bSearch ? &aSearchStrings : &aReplaceStrings;
    1713         [ #  # ]:          0 :     ComboBox* pListBox = _bSearch ? &aSearchLB : &aReplaceLB;
    1714                 :            : 
    1715                 :            :     // ignore identical strings
    1716 [ #  # ][ #  # ]:          0 :     for (std::vector<rtl::OUString>::const_iterator i = pArr->begin(); i != pArr->end(); ++i)
                 [ #  # ]
    1717                 :            :     {
    1718 [ #  # ][ #  # ]:          0 :         if ((*i).equals(rStr))
    1719                 :            :             return;
    1720                 :            :     }
    1721                 :            : 
    1722                 :            :     // delete oldest entry at maximum occupancy (ListBox and Array)
    1723         [ #  # ]:          0 :     if(REMEMBER_SIZE < pArr->size())
    1724                 :            :     {
    1725                 :          0 :         pListBox->RemoveEntry( sal_uInt16(REMEMBER_SIZE - 1) );
    1726                 :          0 :         (*pArr)[REMEMBER_SIZE - 1] = rStr;
    1727 [ #  # ][ #  # ]:          0 :         pArr->erase(pArr->begin() + REMEMBER_SIZE - 1);
                 [ #  # ]
    1728                 :            :     }
    1729                 :            : 
    1730         [ #  # ]:          0 :     pArr->insert(pArr->begin(), rStr);
    1731                 :          0 :     pListBox->InsertEntry(rStr, 0);
    1732                 :            : }
    1733                 :            : 
    1734                 :            : // -----------------------------------------------------------------------
    1735                 :            : 
    1736                 :          0 : void SvxSearchDialog::TemplatesChanged_Impl( SfxStyleSheetBasePool& rPool )
    1737                 :            : {
    1738         [ #  # ]:          0 :     String aOldSrch( aSearchTmplLB .GetSelectEntry() );
    1739         [ #  # ]:          0 :     String aOldRepl( aReplaceTmplLB.GetSelectEntry() );
    1740         [ #  # ]:          0 :     aSearchTmplLB .Clear();
    1741         [ #  # ]:          0 :     aReplaceTmplLB.Clear();
    1742         [ #  # ]:          0 :     rPool.SetSearchMask( pSearchItem->GetFamily(), SFXSTYLEBIT_ALL );
    1743         [ #  # ]:          0 :     aSearchTmplLB.SetUpdateMode( sal_False );
    1744         [ #  # ]:          0 :     aReplaceTmplLB.SetUpdateMode( sal_False );
    1745         [ #  # ]:          0 :     SfxStyleSheetBase* pBase = rPool.First();
    1746                 :            : 
    1747         [ #  # ]:          0 :     while ( pBase )
    1748                 :            :     {
    1749 [ #  # ][ #  # ]:          0 :         if ( pBase->IsUsed() )
    1750 [ #  # ][ #  # ]:          0 :             aSearchTmplLB.InsertEntry( pBase->GetName() );
    1751 [ #  # ][ #  # ]:          0 :         aReplaceTmplLB.InsertEntry( pBase->GetName() );
    1752         [ #  # ]:          0 :         pBase = rPool.Next();
    1753                 :            :     }
    1754         [ #  # ]:          0 :     aSearchTmplLB.SetUpdateMode( sal_True );
    1755         [ #  # ]:          0 :     aReplaceTmplLB.SetUpdateMode( sal_True );
    1756         [ #  # ]:          0 :     aSearchTmplLB.SelectEntryPos(0);
    1757                 :            : 
    1758         [ #  # ]:          0 :     if ( aOldSrch.Len() )
    1759         [ #  # ]:          0 :         aSearchTmplLB .SelectEntry( aOldSrch );
    1760         [ #  # ]:          0 :     aReplaceTmplLB.SelectEntryPos(0);
    1761                 :            : 
    1762         [ #  # ]:          0 :     if ( aOldRepl.Len() )
    1763         [ #  # ]:          0 :         aReplaceTmplLB.SelectEntry( aOldRepl );
    1764                 :            : 
    1765 [ #  # ][ #  # ]:          0 :     if ( aSearchTmplLB.GetEntryCount() )
    1766                 :            :     {
    1767         [ #  # ]:          0 :         EnableControl_Impl( &aSearchBtn );
    1768         [ #  # ]:          0 :         EnableControl_Impl( &aSearchAllBtn );
    1769         [ #  # ]:          0 :         EnableControl_Impl( &aReplaceBtn );
    1770         [ #  # ]:          0 :         EnableControl_Impl( &aReplaceAllBtn );
    1771 [ #  # ][ #  # ]:          0 :     }
    1772                 :          0 : }
    1773                 :            : 
    1774                 :            : // -----------------------------------------------------------------------
    1775                 :            : 
    1776                 :          0 : void SvxSearchDialog::EnableControls_Impl( const sal_uInt16 nFlags )
    1777                 :            : {
    1778         [ #  # ]:          0 :     if ( nFlags == nOptions )
    1779                 :          0 :         return;
    1780                 :            :     else
    1781                 :          0 :         nOptions = nFlags;
    1782                 :            : 
    1783         [ #  # ]:          0 :     if ( !nOptions )
    1784                 :            :     {
    1785         [ #  # ]:          0 :         if ( IsVisible() )
    1786                 :            :         {
    1787                 :          0 :             Hide();
    1788                 :          0 :             return;
    1789                 :            :         }
    1790                 :            :     }
    1791         [ #  # ]:          0 :     else if ( !IsVisible() )
    1792                 :          0 :         Show();
    1793                 :          0 :     bool bNoSearch = true;
    1794                 :            : 
    1795                 :          0 :     sal_Bool bEnableSearch = ( SEARCH_OPTIONS_SEARCH & nOptions ) != 0;
    1796                 :          0 :     aSearchBtn.Enable(bEnableSearch);
    1797                 :            : 
    1798         [ #  # ]:          0 :     if( bEnableSearch )
    1799                 :          0 :         bNoSearch = false;
    1800                 :            : 
    1801                 :            : 
    1802         [ #  # ]:          0 :     if ( ( SEARCH_OPTIONS_SEARCH_ALL & nOptions ) != 0 )
    1803                 :            :     {
    1804                 :          0 :         aSearchAllBtn.Enable();
    1805                 :          0 :         bNoSearch = false;
    1806                 :            :     }
    1807                 :            :     else
    1808                 :          0 :         aSearchAllBtn.Disable();
    1809         [ #  # ]:          0 :     if ( ( SEARCH_OPTIONS_REPLACE & nOptions ) != 0 )
    1810                 :            :     {
    1811                 :          0 :         aReplaceBtn.Enable();
    1812                 :          0 :         aReplaceText.Enable();
    1813                 :          0 :         aReplaceLB.Enable();
    1814                 :          0 :         aReplaceTmplLB.Enable();
    1815                 :          0 :         bNoSearch = false;
    1816                 :            :     }
    1817                 :            :     else
    1818                 :            :     {
    1819                 :          0 :         aReplaceBtn.Disable();
    1820                 :          0 :         aReplaceText.Disable();
    1821                 :          0 :         aReplaceLB.Disable();
    1822                 :          0 :         aReplaceTmplLB.Disable();
    1823                 :            :     }
    1824         [ #  # ]:          0 :     if ( ( SEARCH_OPTIONS_REPLACE_ALL & nOptions ) != 0 )
    1825                 :            :     {
    1826                 :          0 :         aReplaceAllBtn.Enable();
    1827                 :          0 :         bNoSearch = false;
    1828                 :            :     }
    1829                 :            :     else
    1830                 :          0 :         aReplaceAllBtn.Disable();
    1831                 :          0 :     aSearchComponentFL.Enable(!bNoSearch);
    1832                 :          0 :     aSearchComponent1PB.Enable(!bNoSearch);
    1833                 :          0 :     aSearchComponent2PB.Enable(!bNoSearch);
    1834                 :          0 :     aSearchBtn.Enable( !bNoSearch );
    1835                 :          0 :     aSearchText.Enable( !bNoSearch );
    1836                 :          0 :     aSearchLB.Enable( !bNoSearch );
    1837                 :            : 
    1838         [ #  # ]:          0 :     if ( ( SEARCH_OPTIONS_WHOLE_WORDS & nOptions ) != 0 )
    1839                 :          0 :         aWordBtn.Enable();
    1840                 :            :     else
    1841                 :          0 :         aWordBtn.Disable();
    1842         [ #  # ]:          0 :     if ( ( SEARCH_OPTIONS_BACKWARDS & nOptions ) != 0 )
    1843                 :          0 :         aBackwardsBtn.Enable();
    1844                 :            :     else
    1845                 :          0 :         aBackwardsBtn.Disable();
    1846                 :          0 :         aNotesBtn.Enable();
    1847         [ #  # ]:          0 :     if ( ( SEARCH_OPTIONS_REG_EXP & nOptions ) != 0 )
    1848                 :          0 :         aRegExpBtn.Enable();
    1849                 :            :     else
    1850                 :          0 :         aRegExpBtn.Disable();
    1851         [ #  # ]:          0 :     if ( ( SEARCH_OPTIONS_EXACT & nOptions ) != 0 )
    1852                 :          0 :         aMatchCaseCB.Enable();
    1853                 :            :     else
    1854                 :          0 :         aMatchCaseCB.Disable();
    1855         [ #  # ]:          0 :     if ( ( SEARCH_OPTIONS_SELECTION & nOptions ) != 0 )
    1856                 :          0 :         aSelectionBtn.Enable();
    1857                 :            :     else
    1858                 :          0 :         aSelectionBtn.Disable();
    1859         [ #  # ]:          0 :     if ( ( SEARCH_OPTIONS_FAMILIES & nOptions ) != 0 )
    1860                 :          0 :         aLayoutBtn.Enable();
    1861                 :            :     else
    1862                 :          0 :         aLayoutBtn.Disable();
    1863         [ #  # ]:          0 :     if ( ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0 )
    1864                 :            :     {
    1865                 :          0 :         aAttributeBtn.Enable();
    1866                 :          0 :         aFormatBtn.Enable();
    1867                 :          0 :         aNoFormatBtn.Enable();
    1868                 :            :     }
    1869                 :            :     else
    1870                 :            :     {
    1871                 :          0 :         aAttributeBtn.Disable();
    1872                 :          0 :         aFormatBtn.Disable();
    1873                 :          0 :         aNoFormatBtn.Disable();
    1874                 :            :     }
    1875                 :            : 
    1876         [ #  # ]:          0 :     if ( ( SEARCH_OPTIONS_SIMILARITY & nOptions ) != 0 )
    1877                 :            :     {
    1878                 :          0 :         aSimilarityBox.Enable();
    1879                 :          0 :         aSimilarityBtn.Enable();
    1880                 :            :     }
    1881                 :            :     else
    1882                 :            :     {
    1883                 :          0 :         aSimilarityBox.Disable();
    1884                 :          0 :         aSimilarityBtn.Disable();
    1885                 :            :     }
    1886                 :            : 
    1887         [ #  # ]:          0 :     if ( pSearchItem )
    1888                 :          0 :         Init_Impl( pSearchItem->GetPattern() &&
    1889 [ #  # ][ #  # ]:          0 :                    ( !pSearchList || !pSearchList->Count() ) );
                 [ #  # ]
    1890                 :            : }
    1891                 :            : 
    1892                 :            : // -----------------------------------------------------------------------
    1893                 :            : 
    1894                 :          0 : void SvxSearchDialog::EnableControl_Impl( Control* pCtrl )
    1895                 :            : {
    1896 [ #  # ][ #  # ]:          0 :     if ( &aSearchBtn == pCtrl && ( SEARCH_OPTIONS_SEARCH & nOptions ) != 0 )
    1897                 :            :     {
    1898                 :          0 :         aSearchComponentFL.Enable();
    1899                 :          0 :         aSearchComponent1PB.Enable();
    1900                 :          0 :         aSearchComponent2PB.Enable();
    1901                 :          0 :         aSearchBtn.Enable();
    1902                 :          0 :         return;
    1903                 :            :     }
    1904 [ #  # ][ #  # ]:          0 :     if ( &aSearchAllBtn == pCtrl &&
    1905                 :            :          ( SEARCH_OPTIONS_SEARCH_ALL & nOptions ) != 0 )
    1906                 :            :     {
    1907 [ #  # ][ #  # ]:          0 :         aSearchAllBtn.Enable( ( bWriter || !aAllSheetsCB.IsChecked() ) );
    1908                 :          0 :         return;
    1909                 :            :     }
    1910 [ #  # ][ #  # ]:          0 :     if ( &aReplaceBtn == pCtrl && ( SEARCH_OPTIONS_REPLACE & nOptions ) != 0 )
    1911                 :            :     {
    1912                 :          0 :         aReplaceBtn.Enable();
    1913                 :          0 :         return;
    1914                 :            :     }
    1915 [ #  # ][ #  # ]:          0 :     if ( &aReplaceAllBtn == pCtrl &&
    1916                 :            :          ( SEARCH_OPTIONS_REPLACE_ALL & nOptions ) != 0 )
    1917                 :            :     {
    1918                 :          0 :         aReplaceAllBtn.Enable();
    1919                 :          0 :         return;
    1920                 :            :     }
    1921 [ #  # ][ #  # ]:          0 :     if ( &aWordBtn == pCtrl && ( SEARCH_OPTIONS_WHOLE_WORDS & nOptions ) != 0 )
    1922                 :            :     {
    1923                 :          0 :         aWordBtn.Enable();
    1924                 :          0 :         return;
    1925                 :            :     }
    1926 [ #  # ][ #  # ]:          0 :     if ( &aBackwardsBtn == pCtrl && ( SEARCH_OPTIONS_BACKWARDS & nOptions ) != 0 )
    1927                 :            :     {
    1928                 :          0 :         aBackwardsBtn.Enable();
    1929                 :          0 :         return;
    1930                 :            :     }
    1931         [ #  # ]:          0 :     if ( &aNotesBtn == pCtrl )
    1932                 :            :     {
    1933                 :          0 :         aNotesBtn.Enable();
    1934                 :          0 :         return;
    1935                 :            :     }
    1936         [ #  # ]:          0 :     if ( &aRegExpBtn == pCtrl && ( SEARCH_OPTIONS_REG_EXP & nOptions ) != 0
           [ #  #  #  # ]
                 [ #  # ]
    1937                 :          0 :         && !aSimilarityBox.IsChecked())
    1938                 :            :     {
    1939                 :          0 :         aRegExpBtn.Enable();
    1940                 :          0 :         return;
    1941                 :            :     }
    1942 [ #  # ][ #  # ]:          0 :     if ( &aMatchCaseCB == pCtrl && ( SEARCH_OPTIONS_EXACT & nOptions ) != 0 )
    1943                 :            :     {
    1944         [ #  # ]:          0 :         if (!aJapOptionsCB.IsChecked())
    1945                 :          0 :             aMatchCaseCB.Enable();
    1946                 :          0 :         return;
    1947                 :            :     }
    1948 [ #  # ][ #  # ]:          0 :     if ( &aSelectionBtn == pCtrl && ( SEARCH_OPTIONS_SELECTION & nOptions ) != 0 )
    1949                 :            :     {
    1950                 :          0 :         aSelectionBtn.Enable();
    1951                 :          0 :         return;
    1952                 :            :     }
    1953 [ #  # ][ #  # ]:          0 :     if ( &aLayoutBtn == pCtrl && ( SEARCH_OPTIONS_FAMILIES & nOptions ) != 0 )
    1954                 :            :     {
    1955                 :          0 :         aLayoutBtn.Enable();
    1956                 :          0 :         return;
    1957                 :            :     }
    1958 [ #  # ][ #  # ]:          0 :     if (    &aAttributeBtn == pCtrl
                 [ #  # ]
    1959                 :            :          && ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0
    1960                 :            :          && pSearchList )
    1961                 :            :     {
    1962                 :          0 :         aAttributeBtn.Enable( pImpl->bFocusOnSearch );
    1963                 :            :     }
    1964 [ #  # ][ #  # ]:          0 :     if ( &aFormatBtn == pCtrl && ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0 )
    1965                 :            :     {
    1966                 :          0 :         aFormatBtn.Enable();
    1967                 :          0 :         return;
    1968                 :            :     }
    1969 [ #  # ][ #  # ]:          0 :     if ( &aNoFormatBtn == pCtrl && ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0 )
    1970                 :            :     {
    1971                 :          0 :         aNoFormatBtn.Enable();
    1972                 :          0 :         return;
    1973                 :            :     }
    1974 [ #  # ][ #  # ]:          0 :     if ( &aSimilarityBox == pCtrl &&
    1975                 :            :          ( SEARCH_OPTIONS_SIMILARITY & nOptions ) != 0 )
    1976                 :            :     {
    1977                 :          0 :         aSimilarityBox.Enable();
    1978                 :            : 
    1979         [ #  # ]:          0 :         if ( aSimilarityBox.IsChecked() )
    1980                 :          0 :             aSimilarityBtn.Enable();
    1981                 :            :     }
    1982                 :            : }
    1983                 :            : 
    1984                 :            : // -----------------------------------------------------------------------
    1985                 :            : 
    1986                 :          0 : void SvxSearchDialog::SetItem_Impl( const SvxSearchItem* pItem )
    1987                 :            : {
    1988         [ #  # ]:          0 :     if ( pItem )
    1989                 :            :     {
    1990         [ #  # ]:          0 :         delete pSearchItem;
    1991                 :          0 :         pSearchItem = (SvxSearchItem*)pItem->Clone();
    1992                 :          0 :         Init_Impl( pSearchItem->GetPattern() &&
    1993 [ #  # ][ #  # ]:          0 :                    ( !pSearchList || !pSearchList->Count() ) );
                 [ #  # ]
    1994                 :            :     }
    1995                 :          0 : }
    1996                 :            : 
    1997                 :            : // -----------------------------------------------------------------------
    1998                 :            : 
    1999                 :          0 : IMPL_LINK( SvxSearchDialog, FocusHdl_Impl, Control *, pCtrl )
    2000                 :            : {
    2001                 :            :     xub_StrLen nTxtLen;
    2002                 :            : 
    2003         [ #  # ]:          0 :     if ( !pImpl->bMultiLineEdit )
    2004                 :          0 :         nTxtLen = aSearchAttrText.GetText().Len();
    2005                 :            :     else
    2006                 :          0 :         nTxtLen = pImpl->aSearchFormats.GetText().Len();
    2007                 :            : 
    2008 [ #  # ][ #  # ]:          0 :     if ( pCtrl == &aSearchLB || pCtrl == &pImpl->aSearchFormats )
    2009                 :            :     {
    2010         [ #  # ]:          0 :         if ( pCtrl->HasChildPathFocus() )
    2011                 :          0 :             pImpl->bFocusOnSearch = sal_True;
    2012                 :          0 :         pCtrl = &aSearchLB;
    2013                 :          0 :         bSearch = sal_True;
    2014                 :            : 
    2015         [ #  # ]:          0 :         if( nTxtLen )
    2016                 :          0 :             EnableControl_Impl( &aNoFormatBtn );
    2017                 :            :         else
    2018                 :          0 :             aNoFormatBtn.Disable();
    2019                 :          0 :         EnableControl_Impl( &aAttributeBtn );
    2020                 :            :     }
    2021                 :            :     else
    2022                 :            :     {
    2023                 :          0 :         pImpl->bFocusOnSearch = sal_False;
    2024                 :          0 :         pCtrl = &aReplaceLB;
    2025                 :          0 :         bSearch = sal_False;
    2026                 :            : 
    2027 [ #  # ][ #  # ]:          0 :         if ( ( !pImpl->bMultiLineEdit && aReplaceAttrText.GetText().Len() ) ||
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    2028 [ #  # ][ #  # ]:          0 :                 ( pImpl->bMultiLineEdit && pImpl->aReplaceFormats.GetText().Len() ) )
         [ #  # ][ #  # ]
    2029                 :          0 :             EnableControl_Impl( &aNoFormatBtn );
    2030                 :            :         else
    2031                 :          0 :             aNoFormatBtn.Disable();
    2032                 :          0 :         aAttributeBtn.Disable();
    2033                 :            :     }
    2034                 :          0 :     bSet = sal_True;
    2035                 :            : 
    2036         [ #  # ]:          0 :     aSearchLB.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
    2037                 :            : 
    2038                 :          0 :     ModifyHdl_Impl( (ComboBox*)pCtrl );
    2039                 :            : 
    2040 [ #  # ][ #  # ]:          0 :     aLayoutBtn.SetText( bFormat && nTxtLen ? aLayoutStr : aStylesStr );
    2041                 :          0 :     return 0;
    2042                 :            : }
    2043                 :            : 
    2044                 :            : // -----------------------------------------------------------------------
    2045                 :            : 
    2046                 :          0 : IMPL_LINK_NOARG(SvxSearchDialog, LoseFocusHdl_Impl)
    2047                 :            : {
    2048                 :          0 :     SaveToModule_Impl();
    2049                 :          0 :     return 0;
    2050                 :            : }
    2051                 :            : 
    2052                 :            : // -----------------------------------------------------------------------
    2053                 :            : 
    2054                 :          0 : IMPL_LINK_NOARG(SvxSearchDialog, FormatHdl_Impl)
    2055                 :            : {
    2056         [ #  # ]:          0 :     SfxObjectShell* pSh = SfxObjectShell::Current();
    2057                 :            : 
    2058                 :            :     DBG_ASSERT( pSh, "no DocShell" );
    2059                 :            : 
    2060 [ #  # ][ #  # ]:          0 :     if ( !pSh || !pImpl->pRanges )
    2061                 :          0 :         return 0;
    2062                 :            : 
    2063                 :          0 :     sal_sSize nCnt = 0;
    2064                 :          0 :     const sal_uInt16* pPtr = pImpl->pRanges;
    2065                 :          0 :     const sal_uInt16* pTmp = pPtr;
    2066                 :            : 
    2067         [ #  # ]:          0 :     while( *pTmp )
    2068                 :          0 :         pTmp++;
    2069                 :          0 :     nCnt = pTmp - pPtr + 7;
    2070         [ #  # ]:          0 :     sal_uInt16* pWhRanges = new sal_uInt16[nCnt];
    2071                 :          0 :     sal_uInt16 nPos = 0;
    2072                 :            : 
    2073         [ #  # ]:          0 :     while( *pPtr )
    2074                 :            :     {
    2075                 :          0 :         pWhRanges[nPos++] = *pPtr++;
    2076                 :            :     }
    2077                 :            : 
    2078                 :          0 :     pWhRanges[nPos++] = SID_ATTR_PARA_MODEL;
    2079                 :          0 :     pWhRanges[nPos++] = SID_ATTR_PARA_MODEL;
    2080                 :            : 
    2081         [ #  # ]:          0 :     sal_uInt16 nBrushWhich = pSh->GetPool().GetWhich(SID_ATTR_BRUSH);
    2082                 :          0 :     pWhRanges[nPos++] = nBrushWhich;
    2083                 :          0 :     pWhRanges[nPos++] = nBrushWhich;
    2084                 :          0 :     pWhRanges[nPos++] = SID_PARA_BACKGRND_DESTINATION;
    2085                 :          0 :     pWhRanges[nPos++] = SID_PARA_BACKGRND_DESTINATION;
    2086                 :          0 :     pWhRanges[nPos] = 0;
    2087                 :          0 :     SfxItemPool& rPool = pSh->GetPool();
    2088         [ #  # ]:          0 :     SfxItemSet aSet( rPool, pWhRanges );
    2089         [ #  # ]:          0 :     String aTxt;
    2090                 :            : 
    2091         [ #  # ]:          0 :     aSet.InvalidateAllItems();
    2092 [ #  # ][ #  # ]:          0 :     aSet.Put(SvxBrushItem(nBrushWhich));
                 [ #  # ]
    2093 [ #  # ][ #  # ]:          0 :     aSet.Put(SfxUInt16Item(SID_PARA_BACKGRND_DESTINATION, PARA_DEST_CHAR));
                 [ #  # ]
    2094                 :            : 
    2095         [ #  # ]:          0 :     if ( bSearch )
    2096                 :            :     {
    2097 [ #  # ][ #  # ]:          0 :         aTxt = SVX_RESSTR( RID_SVXSTR_SEARCH );
                 [ #  # ]
    2098         [ #  # ]:          0 :         pSearchList->Get( aSet );
    2099                 :            :     }
    2100                 :            :     else
    2101                 :            :     {
    2102 [ #  # ][ #  # ]:          0 :         aTxt = SVX_RESSTR( RID_SVXSTR_REPLACE );
                 [ #  # ]
    2103         [ #  # ]:          0 :         pReplaceList->Get( aSet );
    2104                 :            :     }
    2105         [ #  # ]:          0 :     aSet.DisableItem(SID_ATTR_PARA_MODEL);
    2106 [ #  # ][ #  # ]:          0 :     aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_PAGEBREAK));
    2107 [ #  # ][ #  # ]:          0 :     aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_KEEP));
    2108                 :            : 
    2109                 :            : 
    2110         [ #  # ]:          0 :     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    2111         [ #  # ]:          0 :     if(pFact)
    2112                 :            :     {
    2113         [ #  # ]:          0 :         SfxAbstractTabDialog* pDlg = pFact->CreateTabItemDialog( this, aSet, RID_SVXDLG_SEARCHFORMAT );
    2114                 :            :         DBG_ASSERT(pDlg, "Dialogdiet fail!");
    2115 [ #  # ][ #  # ]:          0 :         aTxt.Insert( pDlg->GetText(), 0 );
                 [ #  # ]
    2116         [ #  # ]:          0 :         pDlg->SetText( aTxt );
    2117                 :            : 
    2118 [ #  # ][ #  # ]:          0 :         if ( pDlg->Execute() == RET_OK )
    2119                 :            :         {
    2120                 :            :             DBG_ASSERT( pDlg->GetOutputItemSet(), "invalid Output-Set" );
    2121 [ #  # ][ #  # ]:          0 :             SfxItemSet aOutSet( *pDlg->GetOutputItemSet() );
    2122                 :            : 
    2123         [ #  # ]:          0 :             SearchAttrItemList* pList = bSearch ? pSearchList : pReplaceList;
    2124                 :            : 
    2125                 :            :             SearchAttrItem* pAItem;
    2126                 :            :             const SfxPoolItem* pItem;
    2127         [ #  # ]:          0 :             for( sal_uInt16 n = 0; n < pList->Count(); ++n )
    2128 [ #  # ][ #  # ]:          0 :                 if( !IsInvalidItem( (pAItem = &pList->GetObject(n))->pItem ) &&
         [ #  # ][ #  # ]
    2129                 :            :                     SFX_ITEM_SET == aOutSet.GetItemState(
    2130         [ #  # ]:          0 :                         pAItem->pItem->Which(), sal_False, &pItem ) )
    2131                 :            :                 {
    2132 [ #  # ][ #  # ]:          0 :                     delete pAItem->pItem;
    2133         [ #  # ]:          0 :                     pAItem->pItem = pItem->Clone();
    2134         [ #  # ]:          0 :                     aOutSet.ClearItem( pAItem->pItem->Which() );
    2135                 :            :                 }
    2136                 :            : 
    2137         [ #  # ]:          0 :             if( aOutSet.Count() )
    2138         [ #  # ]:          0 :                 pList->Put( aOutSet );
    2139                 :            : 
    2140 [ #  # ][ #  # ]:          0 :             PaintAttrText_Impl(); // Set AttributText in GroupBox
    2141                 :            :         }
    2142 [ #  # ][ #  # ]:          0 :         delete pDlg;
    2143                 :            :     }
    2144         [ #  # ]:          0 :     delete[] pWhRanges;
    2145 [ #  # ][ #  # ]:          0 :     return 0;
    2146                 :            : }
    2147                 :            : 
    2148                 :            : // -----------------------------------------------------------------------
    2149                 :            : 
    2150                 :          0 : IMPL_LINK_NOARG(SvxSearchDialog, NoFormatHdl_Impl)
    2151                 :            : {
    2152                 :          0 :     aLayoutBtn.SetText( aStylesStr );
    2153                 :          0 :     bFormat = sal_False;
    2154                 :          0 :     aLayoutBtn.Check( sal_False );
    2155                 :            : 
    2156         [ #  # ]:          0 :     if ( bSearch )
    2157                 :            :     {
    2158         [ #  # ]:          0 :         if ( !pImpl->bMultiLineEdit )
    2159         [ #  # ]:          0 :             aSearchAttrText.SetText( String() );
    2160                 :            :         else
    2161         [ #  # ]:          0 :             pImpl->aSearchFormats.SetText( String() );
    2162                 :          0 :         pSearchList->Clear();
    2163                 :            :     }
    2164                 :            :     else
    2165                 :            :     {
    2166         [ #  # ]:          0 :         if ( !pImpl->bMultiLineEdit )
    2167         [ #  # ]:          0 :             aReplaceAttrText.SetText( String() );
    2168                 :            :         else
    2169         [ #  # ]:          0 :             pImpl->aReplaceFormats.SetText( String() );
    2170                 :          0 :         pReplaceList->Clear();
    2171                 :            :     }
    2172                 :          0 :     pImpl->bSaveToModule = sal_False;
    2173                 :          0 :     TemplateHdl_Impl( &aLayoutBtn );
    2174                 :          0 :     pImpl->bSaveToModule = sal_True;
    2175                 :          0 :     aNoFormatBtn.Disable();
    2176                 :          0 :     return 0;
    2177                 :            : }
    2178                 :            : 
    2179                 :            : // -----------------------------------------------------------------------
    2180                 :            : 
    2181                 :          0 : IMPL_LINK_NOARG(SvxSearchDialog, AttributeHdl_Impl)
    2182                 :            : {
    2183 [ #  # ][ #  # ]:          0 :     if ( !pSearchList || !pImpl->pRanges )
    2184                 :          0 :         return 0;
    2185                 :            : 
    2186                 :          0 :     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    2187         [ #  # ]:          0 :     if(pFact)
    2188                 :            :     {
    2189                 :          0 :         VclAbstractDialog* pDlg = pFact->CreateSvxSearchAttributeDialog( this, *pSearchList, pImpl->pRanges );
    2190                 :            :         DBG_ASSERT(pDlg, "Dialogdiet fail!");
    2191                 :          0 :         pDlg->Execute();
    2192         [ #  # ]:          0 :         delete pDlg;
    2193                 :            :     }
    2194                 :          0 :     PaintAttrText_Impl();
    2195                 :          0 :     return 0;
    2196                 :            : }
    2197                 :            : 
    2198                 :            : // -----------------------------------------------------------------------
    2199                 :            : 
    2200                 :          0 : IMPL_LINK( SvxSearchDialog, TimeoutHdl_Impl, Timer *, pTimer )
    2201                 :            : {
    2202                 :          0 :     SfxViewShell* pViewShell = SfxViewShell::Current();
    2203                 :            : 
    2204         [ #  # ]:          0 :     if ( pViewShell )
    2205                 :            :     {
    2206         [ #  # ]:          0 :         if ( pViewShell->HasSelection( aSearchLB.IsVisible() ) )
    2207                 :          0 :             EnableControl_Impl( &aSelectionBtn );
    2208                 :            :         else
    2209                 :            :         {
    2210                 :          0 :             aSelectionBtn.Check( sal_False );
    2211                 :          0 :             aSelectionBtn.Disable();
    2212                 :            :         }
    2213                 :            :     }
    2214                 :            : 
    2215                 :          0 :     pTimer->Start();
    2216                 :          0 :     return 0;
    2217                 :            : }
    2218                 :            : 
    2219                 :            : // -----------------------------------------------------------------------
    2220                 :            : 
    2221                 :          0 : String& SvxSearchDialog::BuildAttrText_Impl( String& rStr,
    2222                 :            :                                              sal_Bool bSrchFlag ) const
    2223                 :            : {
    2224         [ #  # ]:          0 :     if ( rStr.Len() )
    2225         [ #  # ]:          0 :         rStr.Erase();
    2226                 :            : 
    2227         [ #  # ]:          0 :     SfxObjectShell* pSh = SfxObjectShell::Current();
    2228                 :            :     DBG_ASSERT( pSh, "no DocShell" );
    2229                 :            : 
    2230         [ #  # ]:          0 :     if ( !pSh )
    2231                 :          0 :         return rStr;
    2232                 :            : 
    2233                 :          0 :     SfxItemPool& rPool = pSh->GetPool();
    2234         [ #  # ]:          0 :     SearchAttrItemList* pList = bSrchFlag ? pSearchList : pReplaceList;
    2235                 :            : 
    2236         [ #  # ]:          0 :     if ( !pList )
    2237                 :          0 :         return rStr;
    2238                 :            : 
    2239                 :            :     // Metric query
    2240                 :          0 :     SfxMapUnit eMapUnit = SFX_MAPUNIT_CM;
    2241 [ #  # ][ #  # ]:          0 :     FieldUnit eFieldUnit = pSh->GetModule()->GetFieldUnit();
    2242   [ #  #  #  #  :          0 :     switch ( eFieldUnit )
                #  #  # ]
    2243                 :            :     {
    2244                 :          0 :         case FUNIT_MM:          eMapUnit = SFX_MAPUNIT_MM; break;
    2245                 :            :         case FUNIT_CM:
    2246                 :            :         case FUNIT_M:
    2247                 :          0 :         case FUNIT_KM:          eMapUnit = SFX_MAPUNIT_CM; break;
    2248                 :          0 :         case FUNIT_TWIP:        eMapUnit = SFX_MAPUNIT_TWIP; break;
    2249                 :            :         case FUNIT_POINT:
    2250                 :          0 :         case FUNIT_PICA:        eMapUnit = SFX_MAPUNIT_POINT; break;
    2251                 :            :         case FUNIT_INCH:
    2252                 :            :         case FUNIT_FOOT:
    2253                 :          0 :         case FUNIT_MILE:        eMapUnit = SFX_MAPUNIT_INCH; break;
    2254                 :          0 :         case FUNIT_100TH_MM:    eMapUnit = SFX_MAPUNIT_100TH_MM; break;
    2255                 :            :         default: ;//prevent warning
    2256                 :            :     }
    2257                 :            : 
    2258 [ #  # ][ #  # ]:          0 :     ResStringArray aAttrNames( SVX_RES( RID_ATTR_NAMES ) );
    2259                 :            : 
    2260         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < pList->Count(); ++i )
    2261                 :            :     {
    2262         [ #  # ]:          0 :         const SearchAttrItem& rItem = pList->GetObject(i);
    2263                 :            : 
    2264         [ #  # ]:          0 :         if ( rStr.Len() )
    2265         [ #  # ]:          0 :             rStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
    2266                 :            : 
    2267         [ #  # ]:          0 :         if ( !IsInvalidItem( rItem.pItem ) )
    2268                 :            :         {
    2269         [ #  # ]:          0 :             String aStr;
    2270                 :            :             rPool.GetPresentation( *rItem.pItem,
    2271                 :            :                                     SFX_ITEM_PRESENTATION_COMPLETE,
    2272         [ #  # ]:          0 :                                     eMapUnit, aStr );
    2273 [ #  # ][ #  # ]:          0 :             rStr += aStr;
    2274                 :            :         }
    2275         [ #  # ]:          0 :         else if ( rItem.nSlot == SID_ATTR_BRUSH_CHAR )
    2276                 :            :         {
    2277                 :            :             // Special treatment for text background
    2278 [ #  # ][ #  # ]:          0 :             rStr += SVX_RESSTR( RID_SVXITEMS_BRUSH_CHAR );
                 [ #  # ]
    2279                 :            :         }
    2280                 :            :         else
    2281                 :            :         {
    2282         [ #  # ]:          0 :             sal_uInt32 nId  = aAttrNames.FindIndex( rItem.nSlot );
    2283         [ #  # ]:          0 :             if ( RESARRAY_INDEX_NOTFOUND != nId )
    2284 [ #  # ][ #  # ]:          0 :                 rStr += aAttrNames.GetString( nId );
    2285                 :            :         }
    2286                 :            :     }
    2287         [ #  # ]:          0 :     return rStr;
    2288                 :            : }
    2289                 :            : 
    2290                 :            : // -----------------------------------------------------------------------
    2291                 :            : 
    2292                 :          0 : void SvxSearchDialog::PaintAttrText_Impl()
    2293                 :            : {
    2294         [ #  # ]:          0 :     String aDesc;
    2295         [ #  # ]:          0 :     BuildAttrText_Impl( aDesc, bSearch );
    2296                 :            : 
    2297 [ #  # ][ #  # ]:          0 :     if ( !bFormat && aDesc.Len() )
                 [ #  # ]
    2298                 :          0 :         bFormat = sal_True;
    2299                 :            : 
    2300         [ #  # ]:          0 :     if ( bSearch )
    2301                 :            :     {
    2302         [ #  # ]:          0 :         if ( !pImpl->bMultiLineEdit )
    2303         [ #  # ]:          0 :             aSearchAttrText.SetText( aDesc );
    2304                 :            :         else
    2305         [ #  # ]:          0 :             pImpl->aSearchFormats.SetText( aDesc );
    2306         [ #  # ]:          0 :         FocusHdl_Impl( &aSearchLB );
    2307                 :            :     }
    2308                 :            :     else
    2309                 :            :     {
    2310         [ #  # ]:          0 :         if ( !pImpl->bMultiLineEdit )
    2311         [ #  # ]:          0 :             aReplaceAttrText.SetText( aDesc );
    2312                 :            :         else
    2313         [ #  # ]:          0 :             pImpl->aReplaceFormats.SetText( aDesc );
    2314         [ #  # ]:          0 :         FocusHdl_Impl( &aReplaceLB );
    2315         [ #  # ]:          0 :     }
    2316                 :          0 : }
    2317                 :            : 
    2318                 :            : // -----------------------------------------------------------------------
    2319                 :            : 
    2320                 :          0 : void SvxSearchDialog::SetModifyFlag_Impl( const Control* pCtrl )
    2321                 :            : {
    2322         [ #  # ]:          0 :     if ( &aSearchLB == (ComboBox*)pCtrl )
    2323                 :          0 :         nModifyFlag |= MODIFY_SEARCH;
    2324         [ #  # ]:          0 :     else if ( &aReplaceLB == (ComboBox*)pCtrl )
    2325                 :          0 :         nModifyFlag |= MODIFY_REPLACE;
    2326         [ #  # ]:          0 :     else if ( &aWordBtn == (CheckBox*)pCtrl )
    2327                 :          0 :         nModifyFlag |= MODIFY_WORD;
    2328         [ #  # ]:          0 :     else if ( &aMatchCaseCB == (CheckBox*)pCtrl )
    2329                 :          0 :         nModifyFlag |= MODIFY_EXACT;
    2330         [ #  # ]:          0 :     else if ( &aBackwardsBtn == (CheckBox*)pCtrl )
    2331                 :          0 :         nModifyFlag |= MODIFY_BACKWARDS;
    2332         [ #  # ]:          0 :     else if ( &aNotesBtn == (CheckBox*)pCtrl )
    2333                 :          0 :         nModifyFlag |= MODIFY_NOTES;
    2334         [ #  # ]:          0 :     else if ( &aSelectionBtn == (CheckBox*)pCtrl )
    2335                 :          0 :         nModifyFlag |= MODIFY_SELECTION;
    2336         [ #  # ]:          0 :     else if ( &aRegExpBtn == (CheckBox*)pCtrl )
    2337                 :          0 :         nModifyFlag |= MODIFY_REGEXP;
    2338         [ #  # ]:          0 :     else if ( &aLayoutBtn == (CheckBox*)pCtrl )
    2339                 :          0 :         nModifyFlag |= MODIFY_LAYOUT;
    2340         [ #  # ]:          0 :     else if ( &aSimilarityBox == (CheckBox*)pCtrl )
    2341                 :          0 :         nModifyFlag |= MODIFY_SIMILARITY;
    2342         [ #  # ]:          0 :     else if ( &aCalcSearchInLB == (ListBox*)pCtrl )
    2343                 :            :     {
    2344                 :          0 :         nModifyFlag |= MODIFY_FORMULAS;
    2345                 :          0 :         nModifyFlag |= MODIFY_VALUES;
    2346                 :          0 :         nModifyFlag |= MODIFY_CALC_NOTES;
    2347                 :            :     }
    2348         [ #  # ]:          0 :     else if ( &aRowsBtn == (RadioButton*)pCtrl )
    2349                 :          0 :         nModifyFlag |= MODIFY_ROWS;
    2350         [ #  # ]:          0 :     else if ( &aColumnsBtn == (RadioButton*)pCtrl )
    2351                 :          0 :         nModifyFlag |= MODIFY_COLUMNS;
    2352         [ #  # ]:          0 :     else if ( &aAllSheetsCB == (CheckBox*)pCtrl )
    2353                 :          0 :         nModifyFlag |= MODIFY_ALLTABLES;
    2354                 :          0 : }
    2355                 :            : 
    2356                 :            : // -----------------------------------------------------------------------
    2357                 :            : 
    2358                 :          0 : void SvxSearchDialog::SaveToModule_Impl()
    2359                 :            : {
    2360         [ #  # ]:          0 :     if ( !pSearchItem )
    2361                 :          0 :         return;
    2362                 :            : 
    2363 [ #  # ][ #  # ]:          0 :     if ( aLayoutBtn.IsChecked() )
    2364                 :            :     {
    2365 [ #  # ][ #  # ]:          0 :         pSearchItem->SetSearchString ( aSearchTmplLB.GetSelectEntry() );
                 [ #  # ]
    2366 [ #  # ][ #  # ]:          0 :         pSearchItem->SetReplaceString( aReplaceTmplLB.GetSelectEntry() );
                 [ #  # ]
    2367                 :            :     }
    2368                 :            :     else
    2369                 :            :     {
    2370 [ #  # ][ #  # ]:          0 :         pSearchItem->SetSearchString ( aSearchLB.GetText() );
                 [ #  # ]
    2371 [ #  # ][ #  # ]:          0 :         pSearchItem->SetReplaceString( aReplaceLB.GetText() );
                 [ #  # ]
    2372 [ #  # ][ #  # ]:          0 :         Remember_Impl( aSearchLB.GetText(), sal_True );
                 [ #  # ]
    2373                 :            :     }
    2374                 :            : 
    2375         [ #  # ]:          0 :     pSearchItem->SetRegExp( sal_False );
    2376         [ #  # ]:          0 :     pSearchItem->SetLevenshtein( sal_False );
    2377 [ #  # ][ #  # ]:          0 :     if (GetCheckBoxValue( aRegExpBtn ))
         [ #  # ][ #  # ]
                 [ #  # ]
    2378         [ #  # ]:          0 :         pSearchItem->SetRegExp( sal_True );
    2379 [ #  # ][ #  # ]:          0 :     else if (GetCheckBoxValue( aSimilarityBox ))
         [ #  # ][ #  # ]
                 [ #  # ]
    2380         [ #  # ]:          0 :         pSearchItem->SetLevenshtein( sal_True );
    2381                 :            : 
    2382 [ #  # ][ #  # ]:          0 :     pSearchItem->SetWordOnly( GetCheckBoxValue( aWordBtn ) );
         [ #  # ][ #  # ]
    2383 [ #  # ][ #  # ]:          0 :     pSearchItem->SetBackward( GetCheckBoxValue( aBackwardsBtn ) );
                 [ #  # ]
    2384 [ #  # ][ #  # ]:          0 :     pSearchItem->SetNotes( GetCheckBoxValue( aNotesBtn ) );
                 [ #  # ]
    2385 [ #  # ][ #  # ]:          0 :     pSearchItem->SetPattern( GetCheckBoxValue( aLayoutBtn ) );
                 [ #  # ]
    2386 [ #  # ][ #  # ]:          0 :     pSearchItem->SetSelection( GetCheckBoxValue( aSelectionBtn ) );
         [ #  # ][ #  # ]
    2387                 :            : 
    2388 [ #  # ][ #  # ]:          0 :     pSearchItem->SetUseAsianOptions( GetCheckBoxValue( aJapOptionsCB ) );
                 [ #  # ]
    2389         [ #  # ]:          0 :     sal_Int32 nFlags = GetTransliterationFlags();
    2390         [ #  # ]:          0 :     if( !pSearchItem->IsUseAsianOptions())
    2391                 :            :         nFlags &= (TransliterationModules_IGNORE_CASE |
    2392                 :          0 :                    TransliterationModules_IGNORE_WIDTH );
    2393         [ #  # ]:          0 :     pSearchItem->SetTransliterationFlags( nFlags );
    2394                 :            : 
    2395         [ #  # ]:          0 :     if ( !bWriter )
    2396                 :            :     {
    2397 [ #  # ][ #  # ]:          0 :         if ( aCalcSearchInLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
    2398         [ #  # ]:          0 :             pSearchItem->SetCellType( aCalcSearchInLB.GetSelectEntryPos() );
    2399                 :            : 
    2400                 :          0 :         pSearchItem->SetRowDirection( aRowsBtn.IsChecked() );
    2401         [ #  # ]:          0 :         pSearchItem->SetAllTables( aAllSheetsCB.IsChecked() );
    2402                 :            :     }
    2403                 :            : 
    2404                 :          0 :     pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
    2405                 :          0 :     nModifyFlag = 0;
    2406                 :          0 :     const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
    2407         [ #  # ]:          0 :     rBindings.GetDispatcher()->Execute( SID_SEARCH_ITEM, SFX_CALLMODE_SLOT, ppArgs );
    2408                 :            : }
    2409                 :            : 
    2410                 :            : // class SvxSearchDialogWrapper ------------------------------------------
    2411                 :            : 
    2412 [ +  - ][ #  # ]:      30259 : SFX_IMPL_CHILDWINDOW_WITHID(SvxSearchDialogWrapper, SID_SEARCH_DLG);
    2413                 :            : 
    2414                 :            : // -----------------------------------------------------------------------
    2415                 :            : 
    2416                 :          0 : SvxSearchDialogWrapper::SvxSearchDialogWrapper( Window* _pParent, sal_uInt16 nId,
    2417                 :            :                                                 SfxBindings* pBindings,
    2418                 :            :                                                 SfxChildWinInfo* pInfo )
    2419                 :            :     : SfxChildWindow( _pParent, nId )
    2420 [ #  # ][ #  # ]:          0 :     , dialog (new SvxSearchDialog (_pParent, this, *pBindings))
    2421                 :            : {
    2422                 :          0 :     pWindow = dialog;
    2423         [ #  # ]:          0 :     dialog->Initialize( pInfo );
    2424                 :            : 
    2425         [ #  # ]:          0 :     pBindings->Update( SID_SEARCH_ITEM );
    2426         [ #  # ]:          0 :     pBindings->Update( SID_SEARCH_OPTIONS );
    2427         [ #  # ]:          0 :     pBindings->Update( SID_SEARCH_SEARCHSET );
    2428         [ #  # ]:          0 :     pBindings->Update( SID_SEARCH_REPLACESET );
    2429                 :          0 :     eChildAlignment = SFX_ALIGN_NOALIGNMENT;
    2430                 :          0 :     dialog->bConstruct = sal_False;
    2431                 :          0 : }
    2432                 :            : 
    2433                 :          0 : SvxSearchDialogWrapper::~SvxSearchDialogWrapper ()
    2434                 :            : {
    2435         [ #  # ]:          0 : }
    2436                 :            : 
    2437                 :          0 : SvxSearchDialog *SvxSearchDialogWrapper::getDialog ()
    2438                 :            : {
    2439                 :          0 :     return dialog;
    2440                 :            : }
    2441                 :            : 
    2442                 :            : // -----------------------------------------------------------------------
    2443                 :            : 
    2444                 :          0 : SfxChildWinInfo SvxSearchDialogWrapper::GetInfo() const
    2445                 :            : {
    2446                 :          0 :     SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
    2447                 :          0 :     aInfo.bVisible = sal_False;
    2448                 :          0 :     return aInfo;
    2449                 :            : }
    2450                 :            : 
    2451                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10