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

Generated by: LCOV version 1.11