1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sc.hxx" 30 31 #include <svx/svdundo.hxx> 32 #include <svx/svdocapt.hxx> 33 #include <sfx2/bindings.hxx> 34 #include <sfx2/dispatch.hxx> 35 #include <vcl/msgbox.hxx> 36 #include <vcl/sound.hxx> 37 38 #include "viewfunc.hxx" 39 #include "detfunc.hxx" 40 #include "detdata.hxx" 41 #include "viewdata.hxx" 42 #include "drwlayer.hxx" 43 #include "docsh.hxx" 44 #include "undocell.hxx" 45 #include "futext.hxx" 46 #include "docfunc.hxx" 47 #include "globstr.hrc" 48 #include "sc.hrc" 49 #include "fusel.hxx" 50 51 //================================================================== 52 53 void ScViewFunc::DetectiveAddPred() 54 { 55 ScDocShell* pDocSh = GetViewData()->GetDocShell(); 56 sal_Bool bDone = pDocSh->GetDocFunc(). 57 DetectiveAddPred( GetViewData()->GetCurPos() ); 58 if (!bDone) 59 Sound::Beep(); 60 61 RecalcPPT(); //! use broadcast in DocFunc instead? 62 } 63 64 void ScViewFunc::DetectiveDelPred() 65 { 66 ScDocShell* pDocSh = GetViewData()->GetDocShell(); 67 sal_Bool bDone = pDocSh->GetDocFunc(). 68 DetectiveDelPred( GetViewData()->GetCurPos() ); 69 if (!bDone) 70 Sound::Beep(); 71 72 RecalcPPT(); 73 } 74 75 void ScViewFunc::DetectiveAddSucc() 76 { 77 ScDocShell* pDocSh = GetViewData()->GetDocShell(); 78 sal_Bool bDone = pDocSh->GetDocFunc(). 79 DetectiveAddSucc( GetViewData()->GetCurPos() ); 80 if (!bDone) 81 Sound::Beep(); 82 83 RecalcPPT(); 84 } 85 86 void ScViewFunc::DetectiveDelSucc() 87 { 88 ScDocShell* pDocSh = GetViewData()->GetDocShell(); 89 sal_Bool bDone = pDocSh->GetDocFunc(). 90 DetectiveDelSucc( GetViewData()->GetCurPos() ); 91 if (!bDone) 92 Sound::Beep(); 93 94 RecalcPPT(); 95 } 96 97 void ScViewFunc::DetectiveAddError() 98 { 99 ScDocShell* pDocSh = GetViewData()->GetDocShell(); 100 sal_Bool bDone = pDocSh->GetDocFunc(). 101 DetectiveAddError( GetViewData()->GetCurPos() ); 102 if (!bDone) 103 Sound::Beep(); 104 105 RecalcPPT(); 106 } 107 108 void ScViewFunc::DetectiveDelAll() 109 { 110 ScDocShell* pDocSh = GetViewData()->GetDocShell(); 111 sal_Bool bDone = pDocSh->GetDocFunc(). 112 DetectiveDelAll( GetViewData()->GetTabNo() ); 113 if (!bDone) 114 Sound::Beep(); 115 116 RecalcPPT(); 117 } 118 119 void ScViewFunc::DetectiveMarkInvalid() 120 { 121 ScDocShell* pDocSh = GetViewData()->GetDocShell(); 122 sal_Bool bDone = pDocSh->GetDocFunc(). 123 DetectiveMarkInvalid( GetViewData()->GetTabNo() ); 124 if (!bDone) 125 Sound::Beep(); 126 127 RecalcPPT(); 128 } 129 130 void ScViewFunc::DetectiveRefresh() 131 { 132 ScDocShell* pDocSh = GetViewData()->GetDocShell(); 133 sal_Bool bDone = pDocSh->GetDocFunc().DetectiveRefresh(); 134 if (!bDone) 135 Sound::Beep(); 136 137 RecalcPPT(); 138 } 139 140 //--------------------------------------------------------------------------- 141 142 void ScViewFunc::ShowNote( bool bShow ) 143 { 144 if( bShow ) 145 HideNoteMarker(); 146 const ScViewData& rViewData = *GetViewData(); 147 ScAddress aPos( rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo() ); 148 // show note moved to ScDocFunc, to be able to use it in notesuno.cxx 149 rViewData.GetDocShell()->GetDocFunc().ShowNote( aPos, bShow ); 150 } 151 152 void ScViewFunc::EditNote() 153 { 154 // zum Editieren einblenden und aktivieren 155 156 ScDocShell* pDocSh = GetViewData()->GetDocShell(); 157 ScDocument* pDoc = pDocSh->GetDocument(); 158 SCCOL nCol = GetViewData()->GetCurX(); 159 SCROW nRow = GetViewData()->GetCurY(); 160 SCTAB nTab = GetViewData()->GetTabNo(); 161 ScAddress aPos( nCol, nRow, nTab ); 162 163 // start drawing undo to catch undo action for insertion of the caption object 164 pDocSh->MakeDrawLayer(); 165 ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); 166 pDrawLayer->BeginCalcUndo(); 167 // generated undo action is processed in FuText::StopEditMode 168 169 // get existing note or create a new note (including caption drawing object) 170 if( ScPostIt* pNote = pDoc->GetOrCreateNote( aPos ) ) 171 { 172 // hide temporary note caption 173 HideNoteMarker(); 174 // show caption object without changing internal visibility state 175 pNote->ShowCaptionTemp( aPos ); 176 177 /* Drawing object has been created in ScDocument::GetOrCreateNote() or 178 in ScPostIt::ShowCaptionTemp(), so ScPostIt::GetCaption() should 179 return a caption object. */ 180 if( SdrCaptionObj* pCaption = pNote->GetCaption() ) 181 { 182 // #i33764# enable the resize handles before starting edit mode 183 if( FuPoor* pDraw = GetDrawFuncPtr() ) 184 static_cast< FuSelection* >( pDraw )->ActivateNoteHandles( pCaption ); 185 186 // activate object (as in FuSelection::TestComment) 187 GetViewData()->GetDispatcher().Execute( SID_DRAW_NOTEEDIT, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD ); 188 // jetzt den erzeugten FuText holen und in den EditModus setzen 189 FuPoor* pPoor = GetDrawFuncPtr(); 190 if ( pPoor && (pPoor->GetSlotID() == SID_DRAW_NOTEEDIT) ) // hat keine RTTI 191 { 192 ScrollToObject( pCaption ); // Objekt komplett sichtbar machen 193 static_cast< FuText* >( pPoor )->SetInEditMode( pCaption ); 194 } 195 } 196 } 197 } 198