LCOV - code coverage report
Current view: top level - sw/source/core/edit - edws.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 57 136 41.9 %
Date: 2012-08-25 Functions: 17 34 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 12 72 16.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <vcl/window.hxx>
      31                 :            : 
      32                 :            : #include <editsh.hxx>
      33                 :            : #include <doc.hxx>
      34                 :            : #include <IDocumentUndoRedo.hxx>
      35                 :            : #include <pam.hxx>
      36                 :            : #include <docary.hxx>
      37                 :            : #include <acorrect.hxx>
      38                 :            : #include <swtable.hxx>
      39                 :            : #include <ndtxt.hxx>
      40                 :            : #include <swundo.hxx>
      41                 :            : #include <SwRewriter.hxx>
      42                 :            : 
      43                 :            : /********************************************************
      44                 :            :  * Ctor/Dtor
      45                 :            :  ********************************************************/
      46                 :            : // verkleideter Copy-Constructor
      47                 :            : 
      48                 :            : 
      49                 :          0 : SwEditShell::SwEditShell( SwEditShell& rEdSH, Window *pWindow )
      50                 :          0 :     : SwCrsrShell( rEdSH, pWindow )
      51                 :            : {
      52                 :          0 : }
      53                 :            : 
      54                 :            : // ctor/dtor
      55                 :            : 
      56                 :            : 
      57                 :       1318 : SwEditShell::SwEditShell( SwDoc& rDoc, Window *pWindow, const SwViewOption *pOptions )
      58                 :       1318 :     : SwCrsrShell( rDoc, pWindow, pOptions )
      59                 :            : {
      60 [ +  - ][ +  - ]:       1318 :     GetDoc()->GetIDocumentUndoRedo().DoUndo(true);
      61                 :       1318 : }
      62                 :            : 
      63                 :            : 
      64                 :       1231 : SwEditShell::~SwEditShell() // USED
      65                 :            : {
      66         [ -  + ]:       1231 : }
      67                 :            : 
      68                 :            : /******************************************************************************
      69                 :            :  *                  sal_Bool SwEditShell::IsModified() const
      70                 :            :  ******************************************************************************/
      71                 :            : 
      72                 :            : 
      73                 :          0 : sal_Bool SwEditShell::IsModified() const
      74                 :            : {
      75                 :          0 :     return GetDoc()->IsModified();
      76                 :            : }
      77                 :            : /******************************************************************************
      78                 :            :  *                    void SwEditShell::SetModified()
      79                 :            :  ******************************************************************************/
      80                 :            : 
      81                 :            : 
      82                 :          2 : void SwEditShell::SetModified()
      83                 :            : {
      84                 :          2 :     GetDoc()->SetModified();
      85                 :          2 : }
      86                 :            : /******************************************************************************
      87                 :            :  *                   void SwEditShell::ResetModified()
      88                 :            :  ******************************************************************************/
      89                 :            : 
      90                 :            : 
      91                 :       1322 : void SwEditShell::ResetModified()
      92                 :            : {
      93                 :       1322 :     GetDoc()->ResetModified();
      94                 :       1322 : }
      95                 :            : 
      96                 :          0 : void SwEditShell::SetUndoNoResetModified()
      97                 :            : {
      98                 :          0 :     GetDoc()->SetModified();
      99                 :          0 :     GetDoc()->GetIDocumentUndoRedo().SetUndoNoResetModified();
     100                 :          0 : }
     101                 :            : 
     102                 :            : /******************************************************************************
     103                 :            :  *                 void SwEditShell::StartAllAction()
     104                 :            :  ******************************************************************************/
     105                 :            : 
     106                 :            : 
     107                 :      16375 : void SwEditShell::StartAllAction()
     108                 :            : {
     109                 :      16375 :     ViewShell *pSh = this;
     110         [ -  + ]:      16375 :     do {
     111         [ +  - ]:      16375 :         if( pSh->IsA( TYPE( SwEditShell ) ) )
     112                 :      16375 :             ((SwEditShell*)pSh)->StartAction();
     113                 :            :         else
     114                 :          0 :             pSh->StartAction();
     115                 :      16375 :         pSh = (ViewShell *)pSh->GetNext();
     116                 :            :     } while(pSh != this);
     117                 :      16375 : }
     118                 :            : /******************************************************************************
     119                 :            :  *                  void SwEditShell::EndAllAction()
     120                 :            :  ******************************************************************************/
     121                 :            : 
     122                 :            : 
     123                 :      16375 : void SwEditShell::EndAllAction()
     124                 :            : {
     125                 :      16375 :     ViewShell *pSh = this;
     126         [ -  + ]:      16375 :     do {
     127         [ +  - ]:      16375 :         if( pSh->IsA( TYPE( SwEditShell ) ) )
     128                 :      16375 :             ((SwEditShell*)pSh)->EndAction();
     129                 :            :         else
     130                 :          0 :             pSh->EndAction();
     131                 :      16375 :         pSh = (ViewShell *)pSh->GetNext();
     132                 :            :     } while(pSh != this);
     133                 :      16375 : }
     134                 :            : 
     135                 :            : /******************************************************************************
     136                 :            :  *                  void SwEditShell::CalcLayout()
     137                 :            :  ******************************************************************************/
     138                 :            : 
     139                 :            : 
     140                 :          0 : void SwEditShell::CalcLayout()
     141                 :            : {
     142                 :          0 :     StartAllAction();
     143                 :          0 :     ViewShell::CalcLayout();
     144                 :            : 
     145                 :          0 :     ViewShell *pSh = this;
     146         [ #  # ]:          0 :     do
     147                 :            :     {
     148         [ #  # ]:          0 :         if ( pSh->GetWin() )
     149                 :          0 :             pSh->GetWin()->Invalidate();
     150                 :          0 :         pSh = (ViewShell*)pSh->GetNext();
     151                 :            : 
     152                 :            :     } while ( pSh != this );
     153                 :            : 
     154                 :          0 :     EndAllAction();
     155                 :          0 : }
     156                 :            : 
     157                 :            : /******************************************************************************
     158                 :            :  *                      Inhaltsform bestimmen, holen
     159                 :            :  ******************************************************************************/
     160                 :            : // OPT: wird fuer jedes Attribut gerufen?
     161                 :            : 
     162                 :            : 
     163                 :      24279 : sal_uInt16 SwEditShell::GetCntType() const
     164                 :            : {
     165                 :            :     // nur noch am SPoint ist der Inhalt interessant
     166                 :      24279 :     sal_uInt16 nRet = 0;
     167         [ +  + ]:      24279 :     if( IsTableMode() )
     168                 :         34 :         nRet = CNT_TXT;
     169                 :            :     else
     170   [ +  -  -  - ]:      24245 :         switch( GetCrsr()->GetNode()->GetNodeType() )
     171                 :            :         {
     172                 :      24245 :         case ND_TEXTNODE:   nRet = CNT_TXT; break;
     173                 :          0 :         case ND_GRFNODE:    nRet = CNT_GRF; break;
     174                 :          0 :         case ND_OLENODE:    nRet = CNT_OLE; break;
     175                 :            :         }
     176                 :            : 
     177                 :            :     OSL_ASSERT( nRet );
     178                 :      24279 :     return nRet;
     179                 :            : }
     180                 :            : 
     181                 :            : //------------------------------------------------------------------------------
     182                 :            : 
     183                 :            : 
     184                 :          0 : sal_Bool SwEditShell::HasOtherCnt() const
     185                 :            : 
     186                 :            : {
     187         [ #  # ]:          0 :     if ( !GetDoc()->GetSpzFrmFmts()->empty() )
     188                 :          0 :         return sal_True;
     189                 :            : 
     190                 :          0 :     const SwNodes &rNds = GetDoc()->GetNodes();
     191                 :            :     const SwNode *pNd;
     192                 :            : 
     193                 :          0 :     pNd = &rNds.GetEndOfInserts();
     194         [ #  # ]:          0 :     if ( 1 != (pNd->GetIndex() - pNd->StartOfSectionIndex()) )
     195                 :          0 :         return sal_True;
     196                 :            : 
     197                 :          0 :     pNd = &rNds.GetEndOfAutotext();
     198         [ #  # ]:          0 :     if ( 1 != (pNd->GetIndex() - pNd->StartOfSectionIndex()) )
     199                 :          0 :         return sal_True;
     200                 :            : 
     201                 :          0 :     return sal_False;
     202                 :            : }
     203                 :            : 
     204                 :            : /******************************************************************************
     205                 :            :  *              Zugriffsfunktionen fuer Filename-Behandlung
     206                 :            :  ******************************************************************************/
     207                 :            : 
     208                 :            : 
     209                 :        179 : SwActKontext::SwActKontext(SwEditShell *pShell)
     210                 :        179 :     : pSh(pShell)
     211                 :            : {
     212                 :        179 :     pSh->StartAction();
     213                 :        179 : }
     214                 :            : 
     215                 :            : 
     216                 :        179 : SwActKontext::~SwActKontext()
     217                 :            : {
     218                 :        179 :     pSh->EndAction();
     219                 :        179 : }
     220                 :            : 
     221                 :            : /******************************************************************************
     222                 :            :  *          Klasse fuer den automatisierten Aufruf von Start- und
     223                 :            :  *                              EndCrsrMove();
     224                 :            :  ******************************************************************************/
     225                 :            : 
     226                 :            : 
     227                 :          0 : SwMvKontext::SwMvKontext(SwEditShell *pShell ) : pSh(pShell)
     228                 :            : {
     229                 :          0 :     pSh->SttCrsrMove();
     230                 :          0 : }
     231                 :            : 
     232                 :            : 
     233                 :          0 : SwMvKontext::~SwMvKontext()
     234                 :            : {
     235                 :          0 :     pSh->EndCrsrMove();
     236                 :          0 : }
     237                 :            : 
     238                 :            : 
     239                 :      25024 : SwFrmFmt *SwEditShell::GetTableFmt()    // OPT: schnellster Test auf Tabelle?
     240                 :            : {
     241                 :      25024 :     const SwTableNode* pTblNd = IsCrsrInTbl();
     242         [ +  + ]:      25024 :     return pTblNd ? (SwFrmFmt*)pTblNd->GetTable().GetFrmFmt() : 0;
     243                 :            : }
     244                 :            : 
     245                 :            : // OPT: wieso 3x beim neuen Dokument
     246                 :            : 
     247                 :            : 
     248                 :          0 : sal_uInt16 SwEditShell::GetTOXTypeCount(TOXTypes eTyp) const
     249                 :            : {
     250                 :          0 :     return pDoc->GetTOXTypeCount(eTyp);
     251                 :            : }
     252                 :            : 
     253                 :            : 
     254                 :          0 : void SwEditShell::InsertTOXType(const SwTOXType& rTyp)
     255                 :            : {
     256                 :          0 :     pDoc->InsertTOXType(rTyp);
     257                 :          0 : }
     258                 :            : 
     259                 :            : 
     260                 :            : 
     261                 :       1346 : void SwEditShell::DoUndo( sal_Bool bOn )
     262                 :       1346 : { GetDoc()->GetIDocumentUndoRedo().DoUndo( bOn ); }
     263                 :            : 
     264                 :            : 
     265                 :         56 : sal_Bool SwEditShell::DoesUndo() const
     266                 :         56 : { return GetDoc()->GetIDocumentUndoRedo().DoesUndo(); }
     267                 :            : 
     268                 :            : 
     269                 :          0 : void SwEditShell::DoGroupUndo( sal_Bool bOn )
     270                 :          0 : { GetDoc()->GetIDocumentUndoRedo().DoGroupUndo( bOn ); }
     271                 :            : 
     272                 :            : 
     273                 :          0 : sal_Bool SwEditShell::DoesGroupUndo() const
     274                 :          0 : { return GetDoc()->GetIDocumentUndoRedo().DoesGroupUndo(); }
     275                 :            : 
     276                 :            : 
     277                 :          0 : void SwEditShell::DelAllUndoObj()
     278                 :            : {
     279                 :          0 :     GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
     280                 :          0 : }
     281                 :            : 
     282                 :            : // Zusammenfassen von Kontinuierlichen Insert/Delete/Overwrite von
     283                 :            : // Charaktern. Default ist sdbcx::Group-Undo.
     284                 :            : 
     285                 :            : // setzt Undoklammerung auf, liefert nUndoId der Klammerung
     286                 :            : 
     287                 :            : 
     288                 :         21 : SwUndoId SwEditShell::StartUndo( SwUndoId eUndoId,
     289                 :            :                                    const SwRewriter *pRewriter )
     290                 :         21 : { return GetDoc()->GetIDocumentUndoRedo().StartUndo( eUndoId, pRewriter ); }
     291                 :            : 
     292                 :            : // schliesst Klammerung der nUndoId, nicht vom UI benutzt
     293                 :            : 
     294                 :            : 
     295                 :         21 : SwUndoId SwEditShell::EndUndo(SwUndoId eUndoId,
     296                 :            :                                 const SwRewriter *pRewriter)
     297                 :         21 : { return GetDoc()->GetIDocumentUndoRedo().EndUndo(eUndoId, pRewriter); }
     298                 :            : 
     299                 :            : 
     300                 :       2099 : bool     SwEditShell::GetLastUndoInfo(::rtl::OUString *const o_pStr,
     301                 :            :                                       SwUndoId *const o_pId) const
     302                 :       2099 : { return GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(o_pStr, o_pId); }
     303                 :            : 
     304                 :       1371 : bool     SwEditShell::GetFirstRedoInfo(::rtl::OUString *const o_pStr) const
     305                 :       1371 : { return GetDoc()->GetIDocumentUndoRedo().GetFirstRedoInfo(o_pStr); }
     306                 :            : 
     307                 :         14 : SwUndoId SwEditShell::GetRepeatInfo(::rtl::OUString *const o_pStr) const
     308                 :         14 : { return GetDoc()->GetIDocumentUndoRedo().GetRepeatInfo(o_pStr); }
     309                 :            : 
     310                 :            : 
     311                 :            : 
     312                 :            : // AutoKorrektur - JP 27.01.94
     313                 :          0 : void SwEditShell::AutoCorrect( SvxAutoCorrect& rACorr, sal_Bool bInsert,
     314                 :            :                                 sal_Unicode cChar )
     315                 :            : {
     316         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     317                 :            : 
     318         [ #  # ]:          0 :     StartAllAction();
     319                 :            : 
     320 [ #  # ][ #  # ]:          0 :     SwPaM* pCrsr = getShellCrsr( true );
     321                 :          0 :     SwTxtNode* pTNd = pCrsr->GetNode()->GetTxtNode();
     322                 :            : 
     323         [ #  # ]:          0 :     SwAutoCorrDoc aSwAutoCorrDoc( *this, *pCrsr, cChar );
     324                 :            :     rACorr.AutoCorrect( aSwAutoCorrDoc,
     325                 :          0 :                     pTNd->GetTxt(), pCrsr->GetPoint()->nContent.GetIndex(),
     326         [ #  # ]:          0 :                     cChar, bInsert, GetWin() );
     327         [ #  # ]:          0 :     if( cChar )
     328         [ #  # ]:          0 :         SaveTblBoxCntnt( pCrsr->GetPoint() );
     329 [ #  # ][ #  # ]:          0 :     EndAllAction();
                 [ #  # ]
     330                 :          0 : }
     331                 :            : 
     332                 :            : 
     333                 :          0 : void SwEditShell::SetNewDoc(sal_Bool bNew)
     334                 :            : {
     335                 :          0 :     GetDoc()->SetNewDoc(bNew);
     336                 :          0 : }
     337                 :            : 
     338                 :            : 
     339                 :          0 : sal_Bool SwEditShell::GetPrevAutoCorrWord( SvxAutoCorrect& rACorr, String& rWord )
     340                 :            : {
     341         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     342                 :            : 
     343                 :            :     sal_Bool bRet;
     344 [ #  # ][ #  # ]:          0 :     SwPaM* pCrsr = getShellCrsr( true );
     345                 :          0 :     xub_StrLen nPos = pCrsr->GetPoint()->nContent.GetIndex();
     346                 :          0 :     SwTxtNode* pTNd = pCrsr->GetNode()->GetTxtNode();
     347 [ #  # ][ #  # ]:          0 :     if( pTNd && nPos )
     348                 :            :     {
     349         [ #  # ]:          0 :         SwAutoCorrDoc aSwAutoCorrDoc( *this, *pCrsr, 0 );
     350                 :            :         bRet = rACorr.GetPrevAutoCorrWord( aSwAutoCorrDoc,
     351 [ #  # ][ #  # ]:          0 :                                             pTNd->GetTxt(), nPos, rWord );
     352                 :            :     }
     353                 :            :     else
     354                 :          0 :         bRet = sal_False;
     355         [ #  # ]:          0 :     return bRet;
     356                 :            : }
     357                 :            : 
     358                 :          0 : SwAutoCompleteWord& SwEditShell::GetAutoCompleteWords()
     359                 :            : {
     360                 :          0 :     return SwDoc::GetAutoCompleteWords();
     361                 :            : }
     362                 :            : 
     363                 :            : 
     364                 :            : 
     365                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10