LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - futext3.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 58 0.0 %
Date: 2012-08-25 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 154 0.0 %

           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 <editeng/editeng.hxx>
      31                 :            : #include <editeng/outlobj.hxx>
      32                 :            : #include <svx/svdocapt.hxx>
      33                 :            : #include <svx/svdpage.hxx>
      34                 :            : #include <svx/svdundo.hxx>
      35                 :            : #include <svx/svdview.hxx>
      36                 :            : #include <editeng/editobj.hxx>
      37                 :            : #include <vcl/cursor.hxx>
      38                 :            : #include <sfx2/objsh.hxx>
      39                 :            : #include <editeng/writingmodeitem.hxx>
      40                 :            : 
      41                 :            : #include "global.hxx"
      42                 :            : #include "drwlayer.hxx"
      43                 :            : #include "userdat.hxx"
      44                 :            : #include "tabvwsh.hxx"          // oder GetDocument irgendwo
      45                 :            : #include "document.hxx"
      46                 :            : #include "editutil.hxx"
      47                 :            : #include "futext.hxx"
      48                 :            : #include "docsh.hxx"
      49                 :            : #include "postit.hxx"
      50                 :            : #include "globstr.hrc"
      51                 :            : #include "attrib.hxx"
      52                 :            : #include "scitems.hxx"
      53                 :            : #include "drawview.hxx"
      54                 :            : #include "undocell.hxx"
      55                 :            : 
      56                 :            : // ------------------------------------------------------------------------------------
      57                 :            : //  Editieren von Notiz-Legendenobjekten muss immer ueber StopEditMode beendet werden,
      58                 :            : //  damit die Aenderungen ins Dokument uebernommen werden!
      59                 :            : //  (Fontwork-Execute in drawsh und drtxtob passiert nicht fuer Legendenobjekte)
      60                 :            : //  bTextDirection=sal_True means that this function is called from SID_TEXTDIRECTION_XXX(drtxtob.cxx).
      61                 :            : // ------------------------------------------------------------------------------------
      62                 :            : 
      63                 :          0 : void FuText::StopEditMode(sal_Bool /*bTextDirection*/)
      64                 :            : {
      65         [ #  # ]:          0 :     SdrObject* pObject = pView->GetTextEditObject();
      66         [ #  # ]:          0 :     if( !pObject ) return;
      67                 :            : 
      68                 :            :     // relock the internal layer that has been unlocked in FuText::SetInEditMode()
      69 [ #  # ][ #  # ]:          0 :     if ( pObject->GetLayer() == SC_LAYER_INTERN )
      70         [ #  # ]:          0 :         pView->LockInternalLayer();
      71                 :            : 
      72                 :          0 :     ScViewData& rViewData = *pViewShell->GetViewData();
      73         [ #  # ]:          0 :     ScDocument& rDoc = *rViewData.GetDocument();
      74         [ #  # ]:          0 :     ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
      75                 :            :     OSL_ENSURE( pDrawLayer && (pDrawLayer == pDrDoc), "FuText::StopEditMode - missing or different drawing layers" );
      76                 :            : 
      77                 :          0 :     ScAddress aNotePos;
      78                 :          0 :     ScPostIt* pNote = 0;
      79 [ #  # ][ #  # ]:          0 :     if( const ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObject, rViewData.GetTabNo() ) )
      80                 :            :     {
      81                 :          0 :         aNotePos = pCaptData->maStart;
      82 [ #  # ][ #  # ]:          0 :         pNote = rDoc.GetNotes( aNotePos.Tab() )->findByAddress( aNotePos );
      83                 :            :         OSL_ENSURE( pNote && (pNote->GetCaption() == pObject), "FuText::StopEditMode - missing or invalid cell note" );
      84                 :            :     }
      85                 :            : 
      86                 :          0 :     ScDocShell* pDocShell = rViewData.GetDocShell();
      87 [ #  # ][ #  # ]:          0 :     ::svl::IUndoManager* pUndoMgr = rDoc.IsUndoEnabled() ? pDocShell->GetUndoManager() : 0;
      88                 :          0 :     bool bNewNote = false;
      89 [ #  # ][ #  # ]:          0 :     if( pNote && pUndoMgr )
      90                 :            :     {
      91                 :            :         /*  Put all undo actions already collected (e.g. create caption object)
      92                 :            :             and all following undo actions (text changed) together into a ListAction. */
      93 [ #  # ][ #  # ]:          0 :         String aUndoStr = ScGlobal::GetRscString( STR_UNDO_EDITNOTE );
      94         [ #  # ]:          0 :         pUndoMgr->EnterListAction( aUndoStr, aUndoStr );
      95 [ #  # ][ #  # ]:          0 :         if( SdrUndoGroup* pCalcUndo = pDrawLayer->GetCalcUndo() )
      96                 :            :         {
      97                 :            :             /*  Note has been created before editing, if first undo action is
      98                 :            :                 an insert action. Needed below to decide whether to drop the
      99                 :            :                 undo if editing a new note has been cancelled. */
     100 [ #  # ][ #  # ]:          0 :             bNewNote = (pCalcUndo->GetActionCount() > 0) && pCalcUndo->GetAction( 0 )->ISA( SdrUndoNewObj );
         [ #  # ][ #  # ]
                 [ #  # ]
     101                 :            :             // create a "insert note" undo action if needed
     102         [ #  # ]:          0 :             if( bNewNote )
     103 [ #  # ][ #  # ]:          0 :                 pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, pNote->GetNoteData(), true, pCalcUndo ) );
                 [ #  # ]
     104                 :            :             else
     105         [ #  # ]:          0 :                 pUndoMgr->AddUndoAction( pCalcUndo );
     106         [ #  # ]:          0 :         }
     107                 :            :     }
     108                 :            : 
     109         [ #  # ]:          0 :     if( pNote )
     110         [ #  # ]:          0 :         rDoc.LockStreamValid(true);     // only the affected sheet is invalidated below
     111                 :            : 
     112                 :            :     /*  SdrObjEditView::SdrEndTextEdit() may try to delete the entire drawing
     113                 :            :         object, if it does not contain text and has invisible border and fill.
     114                 :            :         This must not happen for note caption objects. They will be removed
     115                 :            :         below together with the cell note if the text is empty (independent of
     116                 :            :         border and area formatting). It is possible to prevent automatic
     117                 :            :         deletion by passing sal_True to this function. The return value changes
     118                 :            :         from SDRENDTEXTEDIT_DELETED to SDRENDTEXTEDIT_SHOULDBEDELETED in this
     119                 :            :         case. */
     120         [ #  # ]:          0 :     /*SdrEndTextEditKind eResult =*/ pView->SdrEndTextEdit( pNote != 0 );
     121                 :            : 
     122                 :            :     // or ScEndTextEdit (with drawview.hxx)
     123         [ #  # ]:          0 :     pViewShell->SetDrawTextUndo( 0 );
     124                 :            : 
     125         [ #  # ]:          0 :     Cursor* pCur = pWindow->GetCursor();
     126 [ #  # ][ #  # ]:          0 :     if( pCur && pCur->IsVisible() )
                 [ #  # ]
     127         [ #  # ]:          0 :         pCur->Hide();
     128                 :            : 
     129         [ #  # ]:          0 :     if( pNote )
     130                 :            :     {
     131                 :            :         // hide the caption object if it is in hidden state
     132         [ #  # ]:          0 :         pNote->ShowCaptionTemp( aNotePos, false );
     133                 :            : 
     134                 :            :         // update author and date
     135         [ #  # ]:          0 :         pNote->AutoStamp();
     136                 :            : 
     137                 :            :         /*  If the entire text has been cleared, the cell note and its caption
     138                 :            :             object have to be removed. */
     139         [ #  # ]:          0 :         SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >( pObject );
     140 [ #  # ][ #  # ]:          0 :         bool bDeleteNote = !pTextObject || !pTextObject->HasText();
                 [ #  # ]
     141         [ #  # ]:          0 :         if( bDeleteNote )
     142                 :            :         {
     143         [ #  # ]:          0 :             if( pUndoMgr )
     144                 :            :             {
     145                 :            :                 // collect the "remove object" drawing undo action created by DeleteNote()
     146         [ #  # ]:          0 :                 pDrawLayer->BeginCalcUndo();
     147                 :            :                 // rescue note data before deletion
     148         [ #  # ]:          0 :                 ScNoteData aNoteData( pNote->GetNoteData() );
     149                 :            :                 // delete note from document (removes caption, but does not delete it)
     150 [ #  # ][ #  # ]:          0 :                 rDoc.GetNotes( aNotePos.Tab() )->erase( aNotePos );
     151                 :            :                 // create undo action for removed note
     152 [ #  # ][ #  # ]:          0 :                 pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     153                 :            :             }
     154                 :            :             else
     155                 :            :             {
     156 [ #  # ][ #  # ]:          0 :                 rDoc.GetNotes( aNotePos.Tab() )->erase( aNotePos );
     157                 :            :             }
     158                 :            :             // ScDocument::DeleteNote has deleted the note that pNote points to
     159                 :          0 :             pNote = 0;
     160                 :            :         }
     161                 :            : 
     162                 :            :         // finalize the undo list action
     163         [ #  # ]:          0 :         if( pUndoMgr )
     164                 :            :         {
     165         [ #  # ]:          0 :             pUndoMgr->LeaveListAction();
     166                 :            : 
     167                 :            :             /*  #i94039# Update the default name "Edit Note" of the undo action
     168                 :            :                 if the note has been created before editing or is deleted due
     169                 :            :                 to deleted text. If the note has been created *and* is deleted,
     170                 :            :                 the last undo action can be removed completely. Note: The
     171                 :            :                 function LeaveListAction() removes the last action by itself,
     172                 :            :                 if it is empty (when result is SDRENDTEXTEDIT_UNCHANGED). */
     173 [ #  # ][ #  # ]:          0 :             if( bNewNote && bDeleteNote )
     174                 :            :             {
     175         [ #  # ]:          0 :                 pUndoMgr->RemoveLastUndoAction();
     176                 :            :             }
     177 [ #  # ][ #  # ]:          0 :             else if( bNewNote || bDeleteNote )
     178                 :            :             {
     179 [ #  # ][ #  # ]:          0 :                 SfxListUndoAction* pAction = dynamic_cast< SfxListUndoAction* >( pUndoMgr->GetUndoAction() );
     180                 :            :                 OSL_ENSURE( pAction, "FuText::StopEditMode - list undo action expected" );
     181         [ #  # ]:          0 :                 if( pAction )
     182 [ #  # ][ #  # ]:          0 :                     pAction->SetComment( ScGlobal::GetRscString( bNewNote ? STR_UNDO_INSERTNOTE : STR_UNDO_DELETENOTE ) );
                 [ #  # ]
     183                 :            :             }
     184                 :            :         }
     185                 :            : 
     186                 :            :         // invalidate stream positions only for the affected sheet
     187         [ #  # ]:          0 :         rDoc.LockStreamValid(false);
     188 [ #  # ][ #  # ]:          0 :         if (rDoc.IsStreamValid(aNotePos.Tab()))
     189         [ #  # ]:          0 :             rDoc.SetStreamValid(aNotePos.Tab(), false);
     190                 :            :     }
     191                 :            : }
     192                 :            : 
     193                 :            : // Called following an EndDragObj() to update the new note rectangle position
     194                 :          0 : void FuText::StopDragMode(SdrObject* /*pObject*/)
     195                 :            : {
     196                 :          0 : }
     197                 :            : 
     198                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10