LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - SpellDialogChildWindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 59 1.7 %
Date: 2012-12-27 Functions: 2 13 15.4 %
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             : 
      21             : #include "SpellDialogChildWindow.hxx"
      22             : #include <svx/svxids.hrc>
      23             : #include <sfx2/app.hxx>
      24             : #include <sfx2/bindings.hxx>
      25             : #include <sfx2/dispatch.hxx>
      26             : 
      27             : namespace sd{
      28             : 
      29          12 : SFX_IMPL_CHILDWINDOW_WITHID(SpellDialogChildWindow, SID_SPELL_DIALOG)
      30             : }
      31             : 
      32             : #include "ViewShell.hxx"
      33             : #include "ViewShellBase.hxx"
      34             : #include "DrawViewShell.hxx"
      35             : #include "OutlineViewShell.hxx"
      36             : #include <Outliner.hxx>
      37             : #include "drawdoc.hxx"
      38             : 
      39             : 
      40             : namespace sd {
      41             : 
      42           0 : 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           0 :       mbOwnOutliner (false)
      50             : {
      51           0 :     ProvideOutliner();
      52           0 : }
      53             : 
      54             : 
      55             : 
      56             : 
      57           0 : SpellDialogChildWindow::~SpellDialogChildWindow (void)
      58             : {
      59           0 :     if (mpSdOutliner != NULL)
      60           0 :         mpSdOutliner->EndSpelling();
      61             : 
      62           0 :     if (mbOwnOutliner)
      63           0 :         delete mpSdOutliner;
      64           0 : }
      65             : 
      66             : 
      67             : 
      68             : 
      69             : 
      70             : 
      71             : 
      72             : 
      73           0 : SfxChildWinInfo SpellDialogChildWindow::GetInfo (void) const
      74             : {
      75           0 :     return ::svx::SpellDialogChildWindow::GetInfo();
      76             : }
      77             : 
      78             : 
      79             : 
      80             : 
      81           0 : void SpellDialogChildWindow::InvalidateSpellDialog (void)
      82             : {
      83           0 :     ::svx::SpellDialogChildWindow::InvalidateSpellDialog();
      84           0 : }
      85             : 
      86             : 
      87             : 
      88             : 
      89           0 : ::svx::SpellPortions SpellDialogChildWindow::GetNextWrongSentence( bool /*bRecheck*/ )
      90             : {
      91           0 :     ::svx::SpellPortions aResult;
      92             : 
      93           0 :     if (mpSdOutliner != NULL)
      94             :     {
      95           0 :         ProvideOutliner();
      96           0 :         aResult = mpSdOutliner->GetNextSpellSentence();
      97             :     }
      98             : 
      99             :     // Close the spell check dialog when there are no more sentences to
     100             :     // check.
     101           0 :     if (aResult.empty())
     102             :     {
     103           0 :         SfxBoolItem aItem (SID_SPELL_DIALOG, sal_False);
     104           0 :         GetBindings().GetDispatcher()->Execute(
     105             :             SID_SPELL_DIALOG,
     106             :             SFX_CALLMODE_ASYNCHRON,
     107             :             &aItem,
     108           0 :             0L);
     109             :     }
     110             : 
     111           0 :     return aResult;
     112             : }
     113             : 
     114             : 
     115             : 
     116             : 
     117           0 : void SpellDialogChildWindow::ApplyChangedSentence (
     118             :     const ::svx::SpellPortions& rChanged, bool bRecheck )
     119             : {
     120           0 :     if (mpSdOutliner != NULL)
     121             :     {
     122           0 :         OutlinerView* pOutlinerView = mpSdOutliner->GetView(0);
     123           0 :         if (pOutlinerView != NULL)
     124             :             mpSdOutliner->ApplyChangedSentence (
     125           0 :                 pOutlinerView->GetEditView(),
     126           0 :                 rChanged, bRecheck);
     127             :     }
     128           0 : }
     129             : 
     130             : 
     131             : 
     132             : 
     133           0 : void SpellDialogChildWindow::GetFocus (void)
     134             : {
     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.
     140           0 : }
     141             : 
     142             : 
     143             : 
     144             : 
     145           0 : void SpellDialogChildWindow::LoseFocus()
     146             : {
     147           0 : }
     148             : 
     149             : 
     150             : 
     151             : 
     152           0 : void SpellDialogChildWindow::ProvideOutliner (void)
     153             : {
     154           0 :     ViewShellBase* pViewShellBase = PTR_CAST (ViewShellBase, SfxViewShell::Current());
     155             : 
     156           0 :     if (pViewShellBase != NULL)
     157             :     {
     158           0 :         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           0 :         if (mpSdOutliner != NULL)
     162           0 :             if ((pViewShell->ISA(DrawViewShell) && ! mbOwnOutliner)
     163           0 :                 || (pViewShell->ISA(OutlineViewShell) && mbOwnOutliner))
     164             :             {
     165           0 :                 mpSdOutliner->EndSpelling();
     166           0 :                 if (mbOwnOutliner)
     167           0 :                     delete mpSdOutliner;
     168           0 :                 mpSdOutliner = NULL;
     169             :             }
     170             : 
     171             :         // Now create/get an outliner if none is present.
     172           0 :         if (mpSdOutliner == NULL)
     173             :         {
     174           0 :             if (pViewShell->ISA(DrawViewShell))
     175             :             {
     176             :                 // We need an outliner for the spell check so we have
     177             :                 // to create one.
     178           0 :                 mbOwnOutliner = true;
     179             :                 mpSdOutliner = new Outliner (
     180             :                     pViewShell->GetDoc(),
     181           0 :                     OUTLINERMODE_TEXTOBJECT);
     182             :             }
     183           0 :             else if (pViewShell->ISA(OutlineViewShell))
     184             :             {
     185             :                 // An outline view is already visible. The SdOutliner
     186             :                 // will use it instead of creating its own.
     187           0 :                 mbOwnOutliner = false;
     188           0 :                 mpSdOutliner = pViewShell->GetDoc()->GetOutliner();
     189             :             }
     190             : 
     191             :             // Initialize spelling.
     192           0 :             if (mpSdOutliner != NULL)
     193             :             {
     194           0 :                 mpSdOutliner->PrepareSpelling();
     195           0 :                 mpSdOutliner->StartSpelling();
     196             :             }
     197             :         }
     198             :     }
     199           0 : }
     200             : 
     201             : 
     202             : 
     203             : } // end of namespace ::sd
     204             : 
     205             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10