LCOV - code coverage report
Current view: top level - include/svl - srchitem.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 61 74 82.4 %
Date: 2015-06-13 12:38:46 Functions: 33 42 78.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef INCLUDED_SVL_SRCHITEM_HXX
      20             : #define INCLUDED_SVL_SRCHITEM_HXX
      21             : 
      22             : #include <sal/config.h>
      23             : #include <svl/svldllapi.h>
      24             : #include <com/sun/star/util/XSearchDescriptor.hpp>
      25             : #include <com/sun/star/util/SearchOptions.hpp>
      26             : #include <com/sun/star/util/SearchFlags.hpp>
      27             : #include <com/sun/star/i18n/TransliterationModules.hpp>
      28             : #include <unotools/configitem.hxx>
      29             : #include <rsc/rscsfx.hxx>
      30             : #include <svl/poolitem.hxx>
      31             : #include <svl/srchdefs.hxx>
      32             : 
      33             : // defines ---------------------------------------------------------------
      34             : 
      35             : // commands
      36             : enum class SvxSearchCmd
      37             : {
      38             :     FIND          = 0,
      39             :     FIND_ALL      = 1,
      40             :     REPLACE       = 2,
      41             :     REPLACE_ALL   = 3,
      42             : };
      43             : 
      44             : // search flags
      45             : enum class SvxSearchCellType
      46             : {
      47             :     FORMULA        = 0,
      48             :     VALUE          = 1,
      49             :     NOTE           = 2,
      50             : };
      51             : 
      52             : enum class SvxSearchApp
      53             : {
      54             :     WRITER        = 0,
      55             :     CALC          = 1,
      56             :     DRAW          = 2,
      57             :     BASE          = 3,
      58             : };
      59             : 
      60             : // class SvxSearchItem ---------------------------------------------------
      61             : 
      62             : class SVL_DLLPUBLIC SvxSearchItem :
      63             :         public SfxPoolItem,
      64             :         public utl::ConfigItem
      65             : {
      66             :     com::sun::star::util::SearchOptions m_aSearchOpt;
      67             : 
      68             :     SfxStyleFamily  m_eFamily;            // style family
      69             : 
      70             :     SvxSearchCmd    m_nCommand;           // command (Search, Search all, Replace, Replace all)
      71             : 
      72             :     // Calc-specific
      73             :     SvxSearchCellType m_nCellType;          // Search in Formulas/Values/Notes
      74             :     SvxSearchApp    m_nAppFlag;           // application which the dialog is for
      75             :     bool            m_bRowDirection;      // search direction: row-wise/column-wise
      76             :     bool            m_bAllTables;         // search in all sheets
      77             :     bool            m_bSearchFiltered;      // search filtered cells.
      78             : 
      79             :     // Writer-specific
      80             :     bool            m_bNotes;
      81             : 
      82             :     bool            m_bBackward;          // search backwards
      83             :     bool            m_bPattern;           // search for styles
      84             :     bool            m_bContent;           // search in content
      85             :     bool            m_bAsianOptions;      // use asian options?
      86             : 
      87             :     // Start search at this point (absolute twips).
      88             :     sal_Int32       m_nStartPointX;
      89             :     sal_Int32       m_nStartPointY;
      90             : 
      91             :     virtual void    ImplCommit() SAL_OVERRIDE;
      92             : 
      93             : public:
      94             :     TYPEINFO_OVERRIDE();
      95             : 
      96             :     explicit SvxSearchItem( const sal_uInt16 nId );
      97             :     SvxSearchItem( const SvxSearchItem& rItem );
      98             :     virtual ~SvxSearchItem();
      99             : 
     100             :     virtual bool             QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
     101             :     virtual bool             PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;
     102             :     virtual bool             operator == ( const SfxPoolItem& ) const SAL_OVERRIDE;
     103             :     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
     104             :     virtual bool GetPresentation( SfxItemPresentation ePres,
     105             :                                     SfxMapUnit eCoreMetric,
     106             :                                     SfxMapUnit ePresMetric,
     107             :                                     OUString &rText, const IntlWrapper * = 0 ) const SAL_OVERRIDE;
     108             : 
     109             :     // ConfigItem
     110             :     virtual void            Notify( const com::sun::star::uno::Sequence< OUString > &rPropertyNames ) SAL_OVERRIDE;
     111             : 
     112        3010 :             SvxSearchCmd    GetCommand() const { return m_nCommand; }
     113          80 :             void            SetCommand(SvxSearchCmd nNewCommand) { m_nCommand = nNewCommand; }
     114             : 
     115             :     inline  const OUString  GetSearchString() const;
     116             :     inline  void            SetSearchString(const OUString& rNewString);
     117             : 
     118             :     inline  const OUString  GetReplaceString() const;
     119             :     inline  void            SetReplaceString(const OUString& rNewString);
     120             : 
     121             :     inline  bool            GetWordOnly() const;
     122             :             void            SetWordOnly(bool bNewWordOnly);
     123             : 
     124             :     inline  bool            GetExact() const;
     125             :             void            SetExact(bool bNewExact);
     126             : 
     127        4800 :             bool            GetBackward() const { return m_bBackward; }
     128         131 :             void            SetBackward(bool bNewBackward) { m_bBackward = bNewBackward; }
     129             : 
     130             :     inline  bool            GetSelection() const;
     131             :             void            SetSelection(bool bNewSelection);
     132             : 
     133             :     inline  bool            GetRegExp() const;
     134             :             void            SetRegExp( bool bVal );
     135             : 
     136         138 :             bool            GetPattern() const { return m_bPattern; }
     137          43 :             void            SetPattern(bool bNewPattern) { m_bPattern = bNewPattern; }
     138             : 
     139             :             bool            IsContent() const { return m_bContent; }
     140             :             void            SetContent( bool bNew ) { m_bContent = bNew; }
     141             : 
     142           0 :             SfxStyleFamily  GetFamily() const { return m_eFamily; }
     143           0 :             void            SetFamily( SfxStyleFamily eNewFamily )
     144           0 :                                 { m_eFamily = eNewFamily; }
     145             : 
     146          95 :             bool            GetRowDirection() const { return m_bRowDirection; }
     147          84 :             void            SetRowDirection(bool bNewRowDirection) { m_bRowDirection = bNewRowDirection; }
     148             : 
     149           0 :             bool            IsAllTables() const { return m_bAllTables; }
     150           0 :             void            SetAllTables(bool bNew) { m_bAllTables = bNew; }
     151             : 
     152         645 :             bool            IsSearchFiltered() const { return m_bSearchFiltered; }
     153           0 :             void            SetSearchFiltered(bool b) { m_bSearchFiltered = b; }
     154             : 
     155        1028 :             SvxSearchCellType GetCellType() const { return m_nCellType; }
     156          50 :             void            SetCellType(SvxSearchCellType nNewCellType) { m_nCellType = nNewCellType; }
     157             : 
     158          14 :             bool            GetNotes() const { return m_bNotes; }
     159           0 :             void            SetNotes(bool bNew) { m_bNotes = bNew; }
     160             : 
     161           0 :             SvxSearchApp    GetAppFlag() const { return m_nAppFlag; }
     162          44 :             void            SetAppFlag(SvxSearchApp nNewAppFlag) { m_nAppFlag = nNewAppFlag; }
     163             : 
     164             :     inline  bool            IsLevenshtein() const;
     165             :             void            SetLevenshtein( bool bVal );
     166             : 
     167             :     inline  bool            IsLEVRelaxed() const;
     168             :             void            SetLEVRelaxed(bool bSet);
     169             : 
     170             :     inline  sal_uInt16      GetLEVOther() const;
     171             :     inline  void            SetLEVOther(sal_uInt16 nSet);
     172             : 
     173             :     inline  sal_uInt16      GetLEVShorter() const;
     174             :     inline  void            SetLEVShorter(sal_uInt16 nSet);
     175             : 
     176             :     inline  sal_uInt16      GetLEVLonger() const;
     177             :     inline  void            SetLEVLonger(sal_uInt16 nSet);
     178             : 
     179             :     inline const com::sun::star::util::SearchOptions &
     180             :                 GetSearchOptions() const;
     181             :     inline void SetSearchOptions( const com::sun::star::util::SearchOptions &rOpt );
     182             : 
     183             :     inline  sal_Int32       GetTransliterationFlags() const;
     184             :             void            SetTransliterationFlags( sal_Int32 nFlags );
     185             : 
     186             :     inline  bool            IsMatchFullHalfWidthForms() const;
     187             :     void                    SetMatchFullHalfWidthForms( bool bVal );
     188             : 
     189          80 :     inline  bool            IsUseAsianOptions() const           { return m_bAsianOptions; }
     190          40 :     inline  void            SetUseAsianOptions( bool bVal ) { m_bAsianOptions = bVal; }
     191             : 
     192             :     sal_Int32 GetStartPointX() const;
     193             :     sal_Int32 GetStartPointY() const;
     194             :     /// Either x or y start point is set.
     195             :     bool HasStartPoint() const;
     196             : };
     197             : 
     198           4 : const OUString SvxSearchItem::GetSearchString() const
     199             : {
     200           4 :     return m_aSearchOpt.searchString;
     201             : }
     202             : 
     203          51 : void SvxSearchItem::SetSearchString(const OUString& rNewString)
     204             : {
     205          51 :     m_aSearchOpt.searchString = rNewString;
     206          51 : }
     207             : 
     208         304 : const OUString SvxSearchItem::GetReplaceString() const
     209             : {
     210         304 :     return m_aSearchOpt.replaceString;
     211             : }
     212             : 
     213          27 : void SvxSearchItem::SetReplaceString(const OUString& rNewString)
     214             : {
     215          27 :     m_aSearchOpt.replaceString = rNewString;
     216          27 : }
     217             : 
     218        1000 : bool SvxSearchItem::GetWordOnly() const
     219             : {
     220        1000 :     return 0 != (m_aSearchOpt.searchFlag &
     221        1000 :                         com::sun::star::util::SearchFlags::NORM_WORD_ONLY);
     222             : }
     223             : 
     224           7 : bool SvxSearchItem::GetExact() const
     225             : {
     226           7 :     return 0 == (m_aSearchOpt.transliterateFlags &
     227           7 :                         com::sun::star::i18n::TransliterationModules_IGNORE_CASE);
     228             : }
     229             : 
     230        4706 : bool SvxSearchItem::GetSelection() const
     231             : {
     232        4706 :     return 0 != (m_aSearchOpt.searchFlag &
     233        4706 :                         com::sun::star::util::SearchFlags::REG_NOT_BEGINOFLINE);
     234             : }
     235             : 
     236         292 : bool SvxSearchItem::GetRegExp() const
     237             : {
     238         292 :     return m_aSearchOpt.algorithmType == com::sun::star::util::SearchAlgorithms_REGEXP ;
     239             : }
     240             : 
     241           7 : bool SvxSearchItem::IsLEVRelaxed() const
     242             : {
     243           7 :     return 0 != (m_aSearchOpt.searchFlag &
     244           7 :                         com::sun::star::util::SearchFlags::LEV_RELAXED);
     245             : }
     246             : 
     247           7 : sal_uInt16 SvxSearchItem::GetLEVOther() const
     248             : {
     249           7 :     return (sal_Int16) m_aSearchOpt.changedChars;
     250             : }
     251             : 
     252          43 : void SvxSearchItem::SetLEVOther( sal_uInt16 nVal )
     253             : {
     254          43 :     m_aSearchOpt.changedChars = nVal;
     255          43 : }
     256             : 
     257           7 : sal_uInt16 SvxSearchItem::GetLEVShorter() const
     258             : {
     259           7 :     return (sal_Int16) m_aSearchOpt.insertedChars;
     260             : }
     261             : 
     262          43 : void SvxSearchItem::SetLEVShorter( sal_uInt16 nVal )
     263             : {
     264          43 :     m_aSearchOpt.insertedChars = nVal;
     265          43 : }
     266             : 
     267           7 : sal_uInt16 SvxSearchItem::GetLEVLonger() const
     268             : {
     269           7 :     return (sal_Int16) m_aSearchOpt.deletedChars;
     270             : }
     271             : 
     272          43 : void SvxSearchItem::SetLEVLonger( sal_uInt16 nVal )
     273             : {
     274          43 :     m_aSearchOpt.deletedChars = nVal;
     275          43 : }
     276             : 
     277           7 : bool SvxSearchItem::IsLevenshtein() const
     278             : {
     279           7 :     return m_aSearchOpt.algorithmType == com::sun::star::util::SearchAlgorithms_APPROXIMATE;
     280             : }
     281             : 
     282         139 : const com::sun::star::util::SearchOptions & SvxSearchItem::GetSearchOptions() const
     283             : {
     284         139 :     return m_aSearchOpt;
     285             : }
     286             : 
     287          47 : void SvxSearchItem::SetSearchOptions( const com::sun::star::util::SearchOptions &rOpt )
     288             : {
     289          47 :     m_aSearchOpt = rOpt;
     290          47 : }
     291             : 
     292           0 : sal_Int32 SvxSearchItem::GetTransliterationFlags() const
     293             : {
     294           0 :     return m_aSearchOpt.transliterateFlags;
     295             : }
     296             : 
     297           0 : bool SvxSearchItem::IsMatchFullHalfWidthForms() const
     298             : {
     299           0 :     return 0 != (m_aSearchOpt.transliterateFlags &
     300           0 :                         com::sun::star::i18n::TransliterationModules_IGNORE_WIDTH);
     301             : }
     302             : 
     303             : #endif
     304             : 
     305             : 
     306             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11