xref: /aoo42x/main/sc/source/ui/view/viewfun6.cxx (revision b3f79822)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 #include <svx/svdundo.hxx>
28 #include <svx/svdocapt.hxx>
29 #include <sfx2/bindings.hxx>
30 #include <sfx2/dispatch.hxx>
31 #include <vcl/msgbox.hxx>
32 #include <vcl/sound.hxx>
33 
34 #include "viewfunc.hxx"
35 #include "detfunc.hxx"
36 #include "detdata.hxx"
37 #include "viewdata.hxx"
38 #include "drwlayer.hxx"
39 #include "docsh.hxx"
40 #include "undocell.hxx"
41 #include "futext.hxx"
42 #include "docfunc.hxx"
43 #include "globstr.hrc"
44 #include "sc.hrc"
45 #include "fusel.hxx"
46 
47 //==================================================================
48 
49 void ScViewFunc::DetectiveAddPred()
50 {
51 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
52 	sal_Bool bDone = pDocSh->GetDocFunc().
53 					DetectiveAddPred( GetViewData()->GetCurPos() );
54 	if (!bDone)
55 		Sound::Beep();
56 
57 	RecalcPPT();	//! use broadcast in DocFunc instead?
58 }
59 
60 void ScViewFunc::DetectiveDelPred()
61 {
62 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
63 	sal_Bool bDone = pDocSh->GetDocFunc().
64 					DetectiveDelPred( GetViewData()->GetCurPos() );
65 	if (!bDone)
66 		Sound::Beep();
67 
68 	RecalcPPT();
69 }
70 
71 void ScViewFunc::DetectiveAddSucc()
72 {
73 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
74 	sal_Bool bDone = pDocSh->GetDocFunc().
75 					DetectiveAddSucc( GetViewData()->GetCurPos() );
76 	if (!bDone)
77 		Sound::Beep();
78 
79 	RecalcPPT();
80 }
81 
82 void ScViewFunc::DetectiveDelSucc()
83 {
84 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
85 	sal_Bool bDone = pDocSh->GetDocFunc().
86 					DetectiveDelSucc( GetViewData()->GetCurPos() );
87 	if (!bDone)
88 		Sound::Beep();
89 
90 	RecalcPPT();
91 }
92 
93 void ScViewFunc::DetectiveAddError()
94 {
95 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
96 	sal_Bool bDone = pDocSh->GetDocFunc().
97 					DetectiveAddError( GetViewData()->GetCurPos() );
98 	if (!bDone)
99 		Sound::Beep();
100 
101 	RecalcPPT();
102 }
103 
104 void ScViewFunc::DetectiveDelAll()
105 {
106 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
107 	sal_Bool bDone = pDocSh->GetDocFunc().
108 					DetectiveDelAll( GetViewData()->GetTabNo() );
109 	if (!bDone)
110 		Sound::Beep();
111 
112 	RecalcPPT();
113 }
114 
115 void ScViewFunc::DetectiveMarkInvalid()
116 {
117 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
118 	sal_Bool bDone = pDocSh->GetDocFunc().
119 					DetectiveMarkInvalid( GetViewData()->GetTabNo() );
120 	if (!bDone)
121 		Sound::Beep();
122 
123 	RecalcPPT();
124 }
125 
126 void ScViewFunc::DetectiveRefresh()
127 {
128 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
129 	sal_Bool bDone = pDocSh->GetDocFunc().DetectiveRefresh();
130 	if (!bDone)
131 		Sound::Beep();
132 
133 	RecalcPPT();
134 }
135 
136 //---------------------------------------------------------------------------
137 
138 void ScViewFunc::ShowNote( bool bShow )
139 {
140     if( bShow )
141         HideNoteMarker();
142     const ScViewData& rViewData = *GetViewData();
143     ScAddress aPos( rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo() );
144     // show note moved to ScDocFunc, to be able to use it in notesuno.cxx
145     rViewData.GetDocShell()->GetDocFunc().ShowNote( aPos, bShow );
146 }
147 
148 void ScViewFunc::EditNote()
149 {
150 	//	zum Editieren einblenden und aktivieren
151 
152 	ScDocShell* pDocSh = GetViewData()->GetDocShell();
153 	ScDocument* pDoc = pDocSh->GetDocument();
154 	SCCOL nCol = GetViewData()->GetCurX();
155 	SCROW nRow = GetViewData()->GetCurY();
156 	SCTAB nTab = GetViewData()->GetTabNo();
157     ScAddress aPos( nCol, nRow, nTab );
158 
159     // start drawing undo to catch undo action for insertion of the caption object
160     pDocSh->MakeDrawLayer();
161     ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
162     pDrawLayer->BeginCalcUndo();
163     // generated undo action is processed in FuText::StopEditMode
164 
165     // get existing note or create a new note (including caption drawing object)
166     if( ScPostIt* pNote = pDoc->GetOrCreateNote( aPos ) )
167     {
168         // hide temporary note caption
169         HideNoteMarker();
170         // show caption object without changing internal visibility state
171         pNote->ShowCaptionTemp( aPos );
172 
173         /*  Drawing object has been created in ScDocument::GetOrCreateNote() or
174             in ScPostIt::ShowCaptionTemp(), so ScPostIt::GetCaption() should
175             return a caption object. */
176         if( SdrCaptionObj* pCaption = pNote->GetCaption() )
177 		{
178             // #i33764# enable the resize handles before starting edit mode
179 			if( FuPoor* pDraw = GetDrawFuncPtr() )
180                 static_cast< FuSelection* >( pDraw )->ActivateNoteHandles( pCaption );
181 
182 			// activate object (as in FuSelection::TestComment)
183 			GetViewData()->GetDispatcher().Execute( SID_DRAW_NOTEEDIT, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
184 			// jetzt den erzeugten FuText holen und in den EditModus setzen
185 			FuPoor* pPoor = GetDrawFuncPtr();
186 			if ( pPoor && (pPoor->GetSlotID() == SID_DRAW_NOTEEDIT) )	 //	hat keine RTTI
187 			{
188                 ScrollToObject( pCaption );         // Objekt komplett sichtbar machen
189                 static_cast< FuText* >( pPoor )->SetInEditMode( pCaption );
190 			}
191 		}
192 	}
193 }
194