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 
20 #pragma once
21 
22 #include <memory>
23 #include <svx/SpellDialogChildWindow.hxx>
24 #include <document.hxx>
25 
26 class ScConversionEngineBase;
27 class ScSelectionState;
28 class ScTabViewShell;
29 class ScViewData;
30 class ScRangeList;
31 
32 /** Specialized spell check dialog child window for Calc.
33 
34     This derivation of the svx::SpellDialogChildWindow base class provides
35     Calc specific implementations of the virtual functions GetNextWrongSentence()
36     and ApplyChangedSentence().
37  */
38 class ScSpellDialogChildWindow : public svx::SpellDialogChildWindow
39 {
40 public:
41     SFX_DECL_CHILDWINDOW_WITHID( ScSpellDialogChildWindow );
42 
43     explicit            ScSpellDialogChildWindow( vcl::Window* pParent, sal_uInt16 nId,
44                             SfxBindings* pBindings, SfxChildWinInfo* pInfo );
45     virtual             ~ScSpellDialogChildWindow() override;
46 
47     /** This method makes the one from the base class public so that
48         it can be called from the view shell when one is created.
49     */
50     void        InvalidateSpellDialog();
51 
52 protected:
53     /** Iterate over the sentences in all text shapes and stop at the
54         next sentence with spelling errors. While doing so the view
55         mode may be changed and text shapes are set into edit mode.
56     */
57     virtual svx::SpellPortions GetNextWrongSentence( bool bRecheck ) override;
58 
59     /** This method is responsible for merging corrections made in the
60         spelling dialog back into the document.
61     */
62     virtual void        ApplyChangedSentence( const svx::SpellPortions& rChanged, bool bRecheck ) override;
63     virtual void        GetFocus() override;
64     virtual void        LoseFocus() override;
65 
66 private:
67     void                Reset();
68     void                Init();
69 
70     bool                IsSelectionChanged();
71 
72 private:
73     typedef ::std::unique_ptr< ScConversionEngineBase >   ScConvEnginePtr;
74     typedef ::std::unique_ptr< ScSelectionState >         ScSelectionStatePtr;
75 
76     ScConvEnginePtr     mxEngine;
77     ScDocumentUniquePtr mxUndoDoc;
78     ScDocumentUniquePtr mxRedoDoc;
79     ScSelectionStatePtr mxOldSel;           /// For cursor position in selection
80     tools::SvRef< ScRangeList >
81                         mxOldRangeList;     /// Original selection range for comparison.
82     ScTabViewShell*     mpViewShell;
83     ScViewData*         mpViewData;
84     ScDocShell*         mpDocShell;
85     ScDocument*         mpDoc;
86     bool                mbNeedNextObj;
87     bool                mbOldIdleEnabled;
88 };
89 
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
91