LCOV - code coverage report
Current view: top level - sc/source/ui/inc - spelleng.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 4 0.0 %
Date: 2012-08-25 Functions: 0 6 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 6 0.0 %

           Branch data     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 SC_SPELLENG_HXX
      20                 :            : #define SC_SPELLENG_HXX
      21                 :            : 
      22                 :            : #include "editutil.hxx"
      23                 :            : #include "selectionstate.hxx"
      24                 :            : #include "spellparam.hxx"
      25                 :            : 
      26                 :            : class ScViewData;
      27                 :            : class ScDocShell;
      28                 :            : class ScDocument;
      29                 :            : class SfxItemPool;
      30                 :            : 
      31                 :            : // ============================================================================
      32                 :            : 
      33                 :            : /** Base class for special type of edit engines, i.e. for spell checker and text conversion. */
      34                 :            : class ScConversionEngineBase : public ScEditEngineDefaulter
      35                 :            : {
      36                 :            : public:
      37                 :            :     explicit            ScConversionEngineBase(
      38                 :            :                             SfxItemPool* pEnginePool, ScViewData& rViewData,
      39                 :            :                             ScDocument* pUndoDoc, ScDocument* pRedoDoc );
      40                 :            : 
      41                 :            :     virtual             ~ScConversionEngineBase();
      42                 :            : 
      43                 :            :     /** Derived classes implement to convert all cells in the selection or sheet. */
      44                 :            :     virtual void        ConvertAll( EditView& rEditView ) = 0;
      45                 :            : 
      46                 :            :     /** Returns true, if at least one cell has been modified. */
      47                 :          0 :     inline bool         IsAnyModified() const { return mbIsAnyModified; }
      48                 :            :     /** Returns true, if the entire document/selection has been finished. */
      49                 :          0 :     inline bool         IsFinished() const { return mbFinished; }
      50                 :            : 
      51                 :            : protected:
      52                 :            :     /** Implementation of cell iteration. Finds a cell that needs conversion.
      53                 :            :         @return  true = Current cell needs conversion (i.e. spelling error found). */
      54                 :            :     bool                FindNextConversionCell();
      55                 :            :     /** Restores the initial cursor position. */
      56                 :            :     void                RestoreCursorPos();
      57                 :            : 
      58                 :            :     /** Derived classes return, if the current text needs conversion (i.e. spelling error found).
      59                 :            :         @return  true = Current edit text needs conversion. */
      60                 :            :     virtual bool        NeedsConversion() = 0;
      61                 :            : 
      62                 :            :     /** Derived classes may show a query box that asks whether to restart at top of the sheet.
      63                 :            :         @descr  Default here is no dialog and restart always.
      64                 :            :         @return  true = Restart at top, false = Stop the conversion. */
      65                 :            :     virtual bool        ShowTableWrapDialog();
      66                 :            :     /** Derived classes may show a message box stating that the conversion is finished.
      67                 :            :         @descr  Default here is no dialog. */
      68                 :            :     virtual void        ShowFinishDialog();
      69                 :            : 
      70                 :            : private:
      71                 :            :     /** Fills the edit engine from a document cell. */
      72                 :            :     void                FillFromCell( SCCOL nCol, SCROW nRow, SCTAB nTab );
      73                 :            : 
      74                 :            : protected:  // for usage in derived classes
      75                 :            :     ScViewData&         mrViewData;
      76                 :            :     ScDocShell&         mrDocShell;
      77                 :            :     ScDocument&         mrDoc;
      78                 :            : 
      79                 :            : private:
      80                 :            :     ScSelectionState    maSelState;         /// Selection data of the document.
      81                 :            :     ScDocument*         mpUndoDoc;          /// Document stores all old cells for UNDO action.
      82                 :            :     ScDocument*         mpRedoDoc;          /// Document stores all new cells for REDO action.
      83                 :            :     LanguageType        meCurrLang;         /// Current cell language.
      84                 :            :     SCCOL               mnStartCol;         /// Initial column index.
      85                 :            :     SCROW               mnStartRow;         /// Initial row index.
      86                 :            :     SCTAB               mnStartTab;         /// Initial sheet index.
      87                 :            :     SCCOL               mnCurrCol;          /// Current column index.
      88                 :            :     SCROW               mnCurrRow;          /// Current row index.
      89                 :            :     bool                mbIsAnyModified;    /// true = At least one cell has been changed.
      90                 :            :     bool                mbInitialState;     /// true = Not searched for a cell yet.
      91                 :            :     bool                mbWrappedInTable;   /// true = Already restarted at top of the sheet.
      92                 :            :     bool                mbFinished;         /// true = Entire document/selection finished.
      93                 :            : };
      94                 :            : 
      95                 :            : // ============================================================================
      96                 :            : 
      97                 :            : /** Edit engine for spell checking. */
      98         [ #  # ]:          0 : class ScSpellingEngine : public ScConversionEngineBase
      99                 :            : {
     100                 :            : public:
     101                 :            :     typedef ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellChecker1 > XSpellCheckerRef;
     102                 :            : 
     103                 :            :     explicit            ScSpellingEngine(
     104                 :            :                             SfxItemPool* pEnginePool,
     105                 :            :                             ScViewData& rViewData,
     106                 :            :                             ScDocument* pUndoDoc,
     107                 :            :                             ScDocument* pRedoDoc,
     108                 :            :                             XSpellCheckerRef xSpeller );
     109                 :            : 
     110                 :            :     /** Checks spelling of all cells in the selection or sheet. */
     111                 :            :     virtual void        ConvertAll( EditView& rEditView );
     112                 :            : 
     113                 :            : protected:
     114                 :            :     /** Callback from edit engine to check the next cell. */
     115                 :            :     virtual sal_Bool        SpellNextDocument();
     116                 :            : 
     117                 :            :     /** Returns true, if the current text contains a spelling error. */
     118                 :            :     virtual bool        NeedsConversion();
     119                 :            : 
     120                 :            :     /** Show a query box that asks whether to restart at top of the sheet.
     121                 :            :         @return  true = Restart at top, false = Stop the conversion. */
     122                 :            :     virtual bool        ShowTableWrapDialog();
     123                 :            :     /** Show a message box stating that spell checking is finished. */
     124                 :            :     virtual void        ShowFinishDialog();
     125                 :            : 
     126                 :            : private:
     127                 :            :     /** Returns the spelling dialog if it is open. */
     128                 :            :     Window*             GetDialogParent();
     129                 :            : };
     130                 :            : 
     131                 :            : // ============================================================================
     132                 :            : 
     133                 :            : /** Edit engine for text conversion. */
     134 [ #  # ][ #  # ]:          0 : class ScTextConversionEngine : public ScConversionEngineBase
     135                 :            : {
     136                 :            : public:
     137                 :            :     explicit            ScTextConversionEngine(
     138                 :            :                             SfxItemPool* pEnginePool,
     139                 :            :                             ScViewData& rViewData,
     140                 :            :                             const ScConversionParam& rConvParam,
     141                 :            :                             ScDocument* pUndoDoc,
     142                 :            :                             ScDocument* pRedoDoc );
     143                 :            : 
     144                 :            :     /** Converts all cells in the selection or sheet according to set language. */
     145                 :            :     virtual void        ConvertAll( EditView& rEditView );
     146                 :            : 
     147                 :            : protected:
     148                 :            :     /** Callback from edit engine to convert the next cell. */
     149                 :            :     virtual sal_Bool        ConvertNextDocument();
     150                 :            : 
     151                 :            :     /** Returns true, if the current text contains text to convert. */
     152                 :            :     virtual bool        NeedsConversion();
     153                 :            : 
     154                 :            : private:
     155                 :            :     ScConversionParam   maConvParam;        /// Conversion parameters.
     156                 :            : };
     157                 :            : 
     158                 :            : // ============================================================================
     159                 :            : 
     160                 :            : #endif
     161                 :            : 
     162                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10