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