LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - SpellDialogChildWindow.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 60 3.3 %
Date: 2014-11-03 Functions: 4 15 26.7 %
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             : 
      20             : #include "SpellDialogChildWindow.hxx"
      21             : #include <svx/svxids.hrc>
      22             : #include <sfx2/app.hxx>
      23             : #include <sfx2/bindings.hxx>
      24             : #include <sfx2/dispatch.hxx>
      25             : 
      26             : namespace sd{
      27             : 
      28         482 : SFX_IMPL_CHILDWINDOW_WITHID(SpellDialogChildWindow, SID_SPELL_DIALOG)
      29             : }
      30             : 
      31             : #include "ViewShell.hxx"
      32             : #include "ViewShellBase.hxx"
      33             : #include "DrawViewShell.hxx"
      34             : #include "OutlineViewShell.hxx"
      35             : #include <Outliner.hxx>
      36             : #include "drawdoc.hxx"
      37             : 
      38             : namespace sd {
      39             : 
      40           0 : SpellDialogChildWindow::SpellDialogChildWindow (
      41             :     vcl::Window* _pParent,
      42             :     sal_uInt16 nId,
      43             :     SfxBindings* pBindings,
      44             :     SfxChildWinInfo* pInfo)
      45             :     : ::svx::SpellDialogChildWindow (_pParent, nId, pBindings, pInfo),
      46             :       mpSdOutliner (NULL),
      47           0 :       mbOwnOutliner (false)
      48             : {
      49           0 :     ProvideOutliner();
      50           0 : }
      51             : 
      52           0 : SpellDialogChildWindow::~SpellDialogChildWindow (void)
      53             : {
      54           0 :     if (mpSdOutliner != NULL)
      55           0 :         mpSdOutliner->EndSpelling();
      56             : 
      57           0 :     if (mbOwnOutliner)
      58           0 :         delete mpSdOutliner;
      59           0 : }
      60             : 
      61           0 : SfxChildWinInfo SpellDialogChildWindow::GetInfo (void) const
      62             : {
      63           0 :     return ::svx::SpellDialogChildWindow::GetInfo();
      64             : }
      65             : 
      66           0 : void SpellDialogChildWindow::InvalidateSpellDialog (void)
      67             : {
      68           0 :     ::svx::SpellDialogChildWindow::InvalidateSpellDialog();
      69           0 : }
      70             : 
      71           0 : ::svx::SpellPortions SpellDialogChildWindow::GetNextWrongSentence( bool /*bRecheck*/ )
      72             : {
      73           0 :     ::svx::SpellPortions aResult;
      74             : 
      75           0 :     if (mpSdOutliner != NULL)
      76             :     {
      77           0 :         ProvideOutliner();
      78           0 :         aResult = mpSdOutliner->GetNextSpellSentence();
      79             :     }
      80             : 
      81             :     // Close the spell check dialog when there are no more sentences to
      82             :     // check.
      83           0 :     if (aResult.empty())
      84             :     {
      85           0 :         SfxBoolItem aItem (SID_SPELL_DIALOG, false);
      86           0 :         GetBindings().GetDispatcher()->Execute(
      87             :             SID_SPELL_DIALOG,
      88             :             SfxCallMode::ASYNCHRON,
      89             :             &aItem,
      90           0 :             0L);
      91             :     }
      92             : 
      93           0 :     return aResult;
      94             : }
      95             : 
      96           0 : void SpellDialogChildWindow::ApplyChangedSentence (
      97             :     const ::svx::SpellPortions& rChanged, bool bRecheck )
      98             : {
      99           0 :     if (mpSdOutliner != NULL)
     100             :     {
     101           0 :         OutlinerView* pOutlinerView = mpSdOutliner->GetView(0);
     102           0 :         if (pOutlinerView != NULL)
     103             :             mpSdOutliner->ApplyChangedSentence (
     104           0 :                 pOutlinerView->GetEditView(),
     105           0 :                 rChanged, bRecheck);
     106             :     }
     107           0 : }
     108             : 
     109           0 : void SpellDialogChildWindow::GetFocus (void)
     110             : {
     111             :     // In order to detect a cursor movement we could compare the
     112             :     // currently selected text shape with the one that was selected
     113             :     // when LoseFocus() was called the last time.
     114             :     // For the time being we instead rely on the DetectChange() method
     115             :     // in the SdOutliner class.
     116           0 : }
     117             : 
     118           0 : void SpellDialogChildWindow::LoseFocus()
     119             : {
     120           0 : }
     121             : 
     122           0 : void SpellDialogChildWindow::ProvideOutliner (void)
     123             : {
     124           0 :     ViewShellBase* pViewShellBase = PTR_CAST (ViewShellBase, SfxViewShell::Current());
     125             : 
     126           0 :     if (pViewShellBase != NULL)
     127             :     {
     128           0 :         ViewShell* pViewShell = pViewShellBase->GetMainViewShell().get();
     129             :         // If there already exists an outliner that has been created
     130             :         // for another view shell then destroy it first.
     131           0 :         if (mpSdOutliner != NULL)
     132           0 :             if ((pViewShell->ISA(DrawViewShell) && ! mbOwnOutliner)
     133           0 :                 || (pViewShell->ISA(OutlineViewShell) && mbOwnOutliner))
     134             :             {
     135           0 :                 mpSdOutliner->EndSpelling();
     136           0 :                 if (mbOwnOutliner)
     137           0 :                     delete mpSdOutliner;
     138           0 :                 mpSdOutliner = NULL;
     139             :             }
     140             : 
     141             :         // Now create/get an outliner if none is present.
     142           0 :         if (mpSdOutliner == NULL)
     143             :         {
     144           0 :             if (pViewShell->ISA(DrawViewShell))
     145             :             {
     146             :                 // We need an outliner for the spell check so we have
     147             :                 // to create one.
     148           0 :                 mbOwnOutliner = true;
     149             :                 mpSdOutliner = new Outliner (
     150             :                     pViewShell->GetDoc(),
     151           0 :                     OUTLINERMODE_TEXTOBJECT);
     152             :             }
     153           0 :             else if (pViewShell->ISA(OutlineViewShell))
     154             :             {
     155             :                 // An outline view is already visible. The SdOutliner
     156             :                 // will use it instead of creating its own.
     157           0 :                 mbOwnOutliner = false;
     158           0 :                 mpSdOutliner = pViewShell->GetDoc()->GetOutliner();
     159             :             }
     160             : 
     161             :             // Initialize spelling.
     162           0 :             if (mpSdOutliner != NULL)
     163             :             {
     164           0 :                 mpSdOutliner->PrepareSpelling();
     165           0 :                 mpSdOutliner->StartSpelling();
     166             :             }
     167             :         }
     168             :     }
     169           0 : }
     170             : 
     171         114 : } // end of namespace ::sd
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10