LCOV - code coverage report
Current view: top level - sw/source/core/edit - edws.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 79 141 56.0 %
Date: 2014-04-11 Functions: 21 34 61.8 %
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 <vcl/window.hxx>
      21             : 
      22             : #include <editsh.hxx>
      23             : #include <doc.hxx>
      24             : #include <IDocumentUndoRedo.hxx>
      25             : #include <pam.hxx>
      26             : #include <docary.hxx>
      27             : #include <acorrect.hxx>
      28             : #include <swtable.hxx>
      29             : #include <ndtxt.hxx>
      30             : #include <swundo.hxx>
      31             : #include <SwRewriter.hxx>
      32             : 
      33             : // masqueraded copy constructor
      34           0 : SwEditShell::SwEditShell( SwEditShell& rEdSH, Window *pWindow )
      35           0 :     : SwCrsrShell( rEdSH, pWindow )
      36             : {
      37           0 : }
      38             : 
      39        1732 : SwEditShell::SwEditShell( SwDoc& rDoc, Window *pWindow, const SwViewOption *pOptions )
      40        1732 :     : SwCrsrShell( rDoc, pWindow, pOptions )
      41             : {
      42        1732 :     GetDoc()->GetIDocumentUndoRedo().DoUndo(true);
      43        1732 : }
      44             : 
      45        1731 : SwEditShell::~SwEditShell() // USED
      46             : {
      47        1731 : }
      48             : 
      49           1 : sal_Bool SwEditShell::IsModified() const
      50             : {
      51           1 :     return GetDoc()->IsModified();
      52             : }
      53             : 
      54           1 : void SwEditShell::SetModified()
      55             : {
      56           1 :     GetDoc()->SetModified();
      57           1 : }
      58             : 
      59        1734 : void SwEditShell::ResetModified()
      60             : {
      61        1734 :     GetDoc()->ResetModified();
      62        1734 : }
      63             : 
      64           0 : void SwEditShell::SetUndoNoResetModified()
      65             : {
      66           0 :     GetDoc()->SetModified();
      67           0 :     GetDoc()->GetIDocumentUndoRedo().SetUndoNoResetModified();
      68           0 : }
      69             : 
      70       10986 : void SwEditShell::StartAllAction()
      71             : {
      72       10986 :     SwViewShell *pSh = this;
      73       10986 :     do {
      74       10986 :         if( pSh->IsA( TYPE( SwEditShell ) ) )
      75       10986 :             ((SwEditShell*)pSh)->StartAction();
      76             :         else
      77           0 :             pSh->StartAction();
      78       10986 :         pSh = (SwViewShell *)pSh->GetNext();
      79       10986 :     } while(pSh != this);
      80       10986 : }
      81             : 
      82       10984 : void SwEditShell::EndAllAction()
      83             : {
      84       10984 :     SwViewShell *pSh = this;
      85       10984 :     do {
      86       10984 :         if( pSh->IsA( TYPE( SwEditShell ) ) )
      87       10984 :             ((SwEditShell*)pSh)->EndAction();
      88             :         else
      89           0 :             pSh->EndAction();
      90       10984 :         pSh = (SwViewShell *)pSh->GetNext();
      91       10984 :     } while(pSh != this);
      92       10984 : }
      93             : 
      94          12 : void SwEditShell::CalcLayout()
      95             : {
      96          12 :     StartAllAction();
      97          12 :     SwViewShell::CalcLayout();
      98             : 
      99          12 :     SwViewShell *pSh = this;
     100          12 :     do
     101             :     {
     102          12 :         if ( pSh->GetWin() )
     103          12 :             pSh->GetWin()->Invalidate();
     104          12 :         pSh = (SwViewShell*)pSh->GetNext();
     105             : 
     106          12 :     } while ( pSh != this );
     107             : 
     108          12 :     EndAllAction();
     109          12 : }
     110             : 
     111             : /** Get the content type of a shell
     112             :  *
     113             :  * @todo Is this called for every attribute?
     114             :  */
     115       14604 : sal_uInt16 SwEditShell::GetCntType() const
     116             : {
     117       14604 :     sal_uInt16 nRet = 0;
     118       14604 :     if( IsTableMode() )
     119          21 :         nRet = CNT_TXT;
     120             :     else
     121       14583 :         switch( GetCrsr()->GetNode()->GetNodeType() )
     122             :         {
     123       14583 :         case ND_TEXTNODE:   nRet = CNT_TXT; break;
     124           0 :         case ND_GRFNODE:    nRet = CNT_GRF; break;
     125           0 :         case ND_OLENODE:    nRet = CNT_OLE; break;
     126             :         }
     127             : 
     128             :     OSL_ASSERT( nRet );
     129       14604 :     return nRet;
     130             : }
     131             : 
     132           0 : sal_Bool SwEditShell::HasOtherCnt() const
     133             : 
     134             : {
     135           0 :     if ( !GetDoc()->GetSpzFrmFmts()->empty() )
     136           0 :         return sal_True;
     137             : 
     138           0 :     const SwNodes &rNds = GetDoc()->GetNodes();
     139             :     const SwNode *pNd;
     140             : 
     141           0 :     pNd = &rNds.GetEndOfInserts();
     142           0 :     if ( 1 != (pNd->GetIndex() - pNd->StartOfSectionIndex()) )
     143           0 :         return sal_True;
     144             : 
     145           0 :     pNd = &rNds.GetEndOfAutotext();
     146           0 :     if ( 1 != (pNd->GetIndex() - pNd->StartOfSectionIndex()) )
     147           0 :         return sal_True;
     148             : 
     149           0 :     return sal_False;
     150             : }
     151             : 
     152             : // access controll functions for file name handling
     153             : 
     154         656 : SwActContext::SwActContext(SwEditShell *pShell)
     155         656 :     : pSh(pShell)
     156             : {
     157         656 :     pSh->StartAction();
     158         656 : }
     159             : 
     160         656 : SwActContext::~SwActContext()
     161             : {
     162         656 :     pSh->EndAction();
     163         656 : }
     164             : 
     165           8 : SwMvContext::SwMvContext(SwEditShell *pShell)
     166           8 :     : pSh(pShell)
     167             : {
     168           8 :     pSh->SttCrsrMove();
     169           8 : }
     170             : 
     171           8 : SwMvContext::~SwMvContext()
     172             : {
     173           8 :     pSh->EndCrsrMove();
     174           8 : }
     175             : 
     176       14883 : SwFrmFmt *SwEditShell::GetTableFmt() // fastest test on a table
     177             : {
     178       14883 :     const SwTableNode* pTblNd = IsCrsrInTbl();
     179       14883 :     return pTblNd ? (SwFrmFmt*)pTblNd->GetTable().GetFrmFmt() : 0;
     180             : }
     181             : 
     182             : // TODO: Why is this called 3x for a new document?
     183           0 : sal_uInt16 SwEditShell::GetTOXTypeCount(TOXTypes eTyp) const
     184             : {
     185           0 :     return mpDoc->GetTOXTypeCount(eTyp);
     186             : }
     187             : 
     188           0 : void SwEditShell::InsertTOXType(const SwTOXType& rTyp)
     189             : {
     190           0 :     mpDoc->InsertTOXType(rTyp);
     191           0 : }
     192             : 
     193        1748 : void SwEditShell::DoUndo( sal_Bool bOn )
     194        1748 : { GetDoc()->GetIDocumentUndoRedo().DoUndo( bOn ); }
     195             : 
     196         312 : sal_Bool SwEditShell::DoesUndo() const
     197         312 : { return GetDoc()->GetIDocumentUndoRedo().DoesUndo(); }
     198             : 
     199           0 : void SwEditShell::DoGroupUndo( sal_Bool bOn )
     200           0 : { GetDoc()->GetIDocumentUndoRedo().DoGroupUndo( bOn ); }
     201             : 
     202           0 : sal_Bool SwEditShell::DoesGroupUndo() const
     203           0 : { return GetDoc()->GetIDocumentUndoRedo().DoesGroupUndo(); }
     204             : 
     205           0 : void SwEditShell::DelAllUndoObj()
     206             : {
     207           0 :     GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
     208           0 : }
     209             : 
     210             : // Combine continuous calls of Insert/Delete/Overwrite on characters. Default: sdbcx::Group-Undo.
     211             : 
     212             : /** open undo container
     213             :  *
     214             :  * @return nUndoId ID of the container
     215             :  */
     216         154 : SwUndoId SwEditShell::StartUndo( SwUndoId eUndoId,
     217             :                                    const SwRewriter *pRewriter )
     218         154 : { return GetDoc()->GetIDocumentUndoRedo().StartUndo( eUndoId, pRewriter ); }
     219             : 
     220             : /** close undo container
     221             :  *
     222             :  * not used by UI
     223             :  *
     224             :  * @param eUndoId   ID of the undo container
     225             :  * @param pRewriter ?
     226             : */
     227         154 : SwUndoId SwEditShell::EndUndo(SwUndoId eUndoId, const SwRewriter *pRewriter)
     228         154 : { return GetDoc()->GetIDocumentUndoRedo().EndUndo(eUndoId, pRewriter); }
     229             : 
     230         990 : bool     SwEditShell::GetLastUndoInfo(OUString *const o_pStr,
     231             :                                       SwUndoId *const o_pId) const
     232         990 : { return GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(o_pStr, o_pId); }
     233             : 
     234         693 : bool     SwEditShell::GetFirstRedoInfo(OUString *const o_pStr) const
     235         693 : { return GetDoc()->GetIDocumentUndoRedo().GetFirstRedoInfo(o_pStr); }
     236             : 
     237           7 : SwUndoId SwEditShell::GetRepeatInfo(OUString *const o_pStr) const
     238           7 : { return GetDoc()->GetIDocumentUndoRedo().GetRepeatInfo(o_pStr); }
     239             : 
     240             : /** Auto correction */
     241           0 : void SwEditShell::AutoCorrect( SvxAutoCorrect& rACorr, sal_Bool bInsert,
     242             :                                 sal_Unicode cChar )
     243             : {
     244           0 :     SET_CURR_SHELL( this );
     245             : 
     246           0 :     StartAllAction();
     247             : 
     248           0 :     SwPaM* pCrsr = getShellCrsr( true );
     249           0 :     SwTxtNode* pTNd = pCrsr->GetNode()->GetTxtNode();
     250             : 
     251           0 :     SwAutoCorrDoc aSwAutoCorrDoc( *this, *pCrsr, cChar );
     252             :     // FIXME: this _must_ be called with reference to the actual node text!
     253           0 :     OUString const& rNodeText(pTNd->GetTxt());
     254             :     rACorr.DoAutoCorrect( aSwAutoCorrDoc,
     255           0 :                     rNodeText, pCrsr->GetPoint()->nContent.GetIndex(),
     256           0 :                     cChar, bInsert, GetWin() );
     257           0 :     if( cChar )
     258           0 :         SaveTblBoxCntnt( pCrsr->GetPoint() );
     259           0 :     EndAllAction();
     260           0 : }
     261             : 
     262           0 : void SwEditShell::SetNewDoc(sal_Bool bNew)
     263             : {
     264           0 :     GetDoc()->SetNewDoc(bNew);
     265           0 : }
     266             : 
     267           0 : sal_Bool SwEditShell::GetPrevAutoCorrWord( SvxAutoCorrect& rACorr, OUString& rWord )
     268             : {
     269           0 :     SET_CURR_SHELL( this );
     270             : 
     271             :     sal_Bool bRet;
     272           0 :     SwPaM* pCrsr = getShellCrsr( true );
     273           0 :     const sal_Int32 nPos = pCrsr->GetPoint()->nContent.GetIndex();
     274           0 :     SwTxtNode* pTNd = pCrsr->GetNode()->GetTxtNode();
     275           0 :     if( pTNd && nPos )
     276             :     {
     277           0 :         SwAutoCorrDoc aSwAutoCorrDoc( *this, *pCrsr, 0 );
     278             :         bRet = rACorr.GetPrevAutoCorrWord( aSwAutoCorrDoc,
     279           0 :                                             pTNd->GetTxt(), nPos, rWord );
     280             :     }
     281             :     else
     282           0 :         bRet = sal_False;
     283           0 :     return bRet;
     284             : }
     285             : 
     286           0 : SwAutoCompleteWord& SwEditShell::GetAutoCompleteWords()
     287             : {
     288           0 :     return SwDoc::GetAutoCompleteWords();
     289             : }
     290             : 
     291             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10