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