fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / dlg / SpellDialogChildWindow.cxx
blob8e46db6117663bf5797b9af191f495ef830ac651
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "SpellDialogChildWindow.hxx"
22 #include <svx/svxids.hrc>
23 #include <sfx2/app.hxx>
24 #include <sfx2/bindings.hxx>
25 #include <sfx2/dispatch.hxx>
27 namespace sd{
29 SFX_IMPL_CHILDWINDOW_WITHID(SpellDialogChildWindow, SID_SPELL_DIALOG)
32 #include "ViewShell.hxx"
33 #include "ViewShellBase.hxx"
34 #include "DrawViewShell.hxx"
35 #include "OutlineViewShell.hxx"
36 #include <Outliner.hxx>
37 #include "drawdoc.hxx"
40 namespace sd {
42 SpellDialogChildWindow::SpellDialogChildWindow (
43 ::Window* _pParent,
44 sal_uInt16 nId,
45 SfxBindings* pBindings,
46 SfxChildWinInfo* pInfo)
47 : ::svx::SpellDialogChildWindow (_pParent, nId, pBindings, pInfo),
48 mpSdOutliner (NULL),
49 mbOwnOutliner (false)
51 ProvideOutliner();
57 SpellDialogChildWindow::~SpellDialogChildWindow (void)
59 if (mpSdOutliner != NULL)
60 mpSdOutliner->EndSpelling();
62 if (mbOwnOutliner)
63 delete mpSdOutliner;
73 SfxChildWinInfo SpellDialogChildWindow::GetInfo (void) const
75 return ::svx::SpellDialogChildWindow::GetInfo();
81 void SpellDialogChildWindow::InvalidateSpellDialog (void)
83 ::svx::SpellDialogChildWindow::InvalidateSpellDialog();
89 ::svx::SpellPortions SpellDialogChildWindow::GetNextWrongSentence( bool /*bRecheck*/ )
91 ::svx::SpellPortions aResult;
93 if (mpSdOutliner != NULL)
95 ProvideOutliner();
96 aResult = mpSdOutliner->GetNextSpellSentence();
99 // Close the spell check dialog when there are no more sentences to
100 // check.
101 if (aResult.empty())
103 SfxBoolItem aItem (SID_SPELL_DIALOG, sal_False);
104 GetBindings().GetDispatcher()->Execute(
105 SID_SPELL_DIALOG,
106 SFX_CALLMODE_ASYNCHRON,
107 &aItem,
108 0L);
111 return aResult;
117 void SpellDialogChildWindow::ApplyChangedSentence (
118 const ::svx::SpellPortions& rChanged, bool bRecheck )
120 if (mpSdOutliner != NULL)
122 OutlinerView* pOutlinerView = mpSdOutliner->GetView(0);
123 if (pOutlinerView != NULL)
124 mpSdOutliner->ApplyChangedSentence (
125 pOutlinerView->GetEditView(),
126 rChanged, bRecheck);
133 void SpellDialogChildWindow::GetFocus (void)
135 // In order to detect a cursor movement we could compare the
136 // currently selected text shape with the one that was selected
137 // when LoseFocus() was called the last time.
138 // For the time being we instead rely on the DetectChange() method
139 // in the SdOutliner class.
145 void SpellDialogChildWindow::LoseFocus()
152 void SpellDialogChildWindow::ProvideOutliner (void)
154 ViewShellBase* pViewShellBase = PTR_CAST (ViewShellBase, SfxViewShell::Current());
156 if (pViewShellBase != NULL)
158 ViewShell* pViewShell = pViewShellBase->GetMainViewShell().get();
159 // If there already exists an outliner that has been created
160 // for another view shell then destroy it first.
161 if (mpSdOutliner != NULL)
162 if ((pViewShell->ISA(DrawViewShell) && ! mbOwnOutliner)
163 || (pViewShell->ISA(OutlineViewShell) && mbOwnOutliner))
165 mpSdOutliner->EndSpelling();
166 if (mbOwnOutliner)
167 delete mpSdOutliner;
168 mpSdOutliner = NULL;
171 // Now create/get an outliner if none is present.
172 if (mpSdOutliner == NULL)
174 if (pViewShell->ISA(DrawViewShell))
176 // We need an outliner for the spell check so we have
177 // to create one.
178 mbOwnOutliner = true;
179 mpSdOutliner = new Outliner (
180 pViewShell->GetDoc(),
181 OUTLINERMODE_TEXTOBJECT);
183 else if (pViewShell->ISA(OutlineViewShell))
185 // An outline view is already visible. The SdOutliner
186 // will use it instead of creating its own.
187 mbOwnOutliner = false;
188 mpSdOutliner = pViewShell->GetDoc()->GetOutliner();
191 // Initialize spelling.
192 if (mpSdOutliner != NULL)
194 mpSdOutliner->PrepareSpelling();
195 mpSdOutliner->StartSpelling();
203 } // end of namespace ::sd
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */