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 : : #include <editeng/eeitem.hxx>
30 : :
31 : : #include <editeng/flditem.hxx>
32 : :
33 : : #include <editeng/editview.hxx>
34 : : #include <svx/svdobj.hxx>
35 : : #include <svx/svdpagv.hxx>
36 : : #include <svtools/imapobj.hxx>
37 : : #include <vcl/cursor.hxx>
38 : : #include <vcl/help.hxx>
39 : : #include <tools/urlobj.hxx>
40 : : #include <sfx2/viewfrm.hxx>
41 : :
42 : : #include <unotools/localedatawrapper.hxx>
43 : :
44 : : #include "viewuno.hxx"
45 : : #include "AccessibleDocument.hxx"
46 : : #include <com/sun/star/accessibility/XAccessible.hpp>
47 : :
48 : : #include "gridwin.hxx"
49 : : #include "viewdata.hxx"
50 : : #include "drawview.hxx"
51 : : #include "drwlayer.hxx"
52 : : #include "drawpage.hxx"
53 : : #include "document.hxx"
54 : : #include "notemark.hxx"
55 : : #include "chgtrack.hxx"
56 : : #include "chgviset.hxx"
57 : : #include "dbfunc.hxx"
58 : : #include "tabvwsh.hxx"
59 : : #include "userdat.hxx"
60 : : #include "postit.hxx"
61 : :
62 : : // -----------------------------------------------------------------------
63 : :
64 : 0 : bool ScGridWindow::ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, bool bKeyboard )
65 : : {
66 : 0 : bool bDone = false;
67 : :
68 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
69 : 0 : SCTAB nTab = pViewData->GetTabNo();
70 : 0 : ScAddress aCellPos( nPosX, nPosY, nTab );
71 : :
72 [ # # ]: 0 : String aTrackText;
73 : 0 : bool bLeftEdge = false;
74 : :
75 : : // Change-Tracking
76 : :
77 : 0 : ScChangeTrack* pTrack = pDoc->GetChangeTrack();
78 : 0 : ScChangeViewSettings* pSettings = pDoc->GetChangeViewSettings();
79 [ # # ][ # # ]: 0 : if ( pTrack && pTrack->GetFirst() && pSettings && pSettings->ShowChanges())
[ # # ][ # # ]
[ # # ]
80 : : {
81 : 0 : const ScChangeAction* pFound = NULL;
82 : 0 : const ScChangeAction* pFoundContent = NULL;
83 : 0 : const ScChangeAction* pFoundMove = NULL;
84 : 0 : long nModified = 0;
85 : 0 : const ScChangeAction* pAction = pTrack->GetFirst();
86 [ # # ]: 0 : while (pAction)
87 : : {
88 [ # # ][ # # ]: 0 : if ( pAction->IsVisible() &&
[ # # ][ # # ]
89 [ # # ]: 0 : ScViewUtil::IsActionShown( *pAction, *pSettings, *pDoc ) )
90 : : {
91 : 0 : ScChangeActionType eType = pAction->GetType();
92 : 0 : const ScBigRange& rBig = pAction->GetBigRange();
93 [ # # ]: 0 : if ( rBig.aStart.Tab() == nTab )
94 : : {
95 : 0 : ScRange aRange = rBig.MakeRange();
96 : :
97 [ # # ]: 0 : if ( eType == SC_CAT_DELETE_ROWS )
98 : 0 : aRange.aEnd.SetRow( aRange.aStart.Row() );
99 [ # # ]: 0 : else if ( eType == SC_CAT_DELETE_COLS )
100 : 0 : aRange.aEnd.SetCol( aRange.aStart.Col() );
101 : :
102 [ # # ]: 0 : if ( aRange.In( aCellPos ) )
103 : : {
104 : 0 : pFound = pAction; // der letzte gewinnt
105 [ # # # ]: 0 : switch ( eType )
106 : : {
107 : : case SC_CAT_CONTENT :
108 : 0 : pFoundContent = pAction;
109 : 0 : break;
110 : : case SC_CAT_MOVE :
111 : 0 : pFoundMove = pAction;
112 : 0 : break;
113 : : default:
114 : : {
115 : : // added to avoid warnings
116 : : }
117 : : }
118 : 0 : ++nModified;
119 : : }
120 : : }
121 [ # # ]: 0 : if ( eType == SC_CAT_MOVE )
122 : : {
123 : : ScRange aRange =
124 : : ((const ScChangeActionMove*)pAction)->
125 : 0 : GetFromRange().MakeRange();
126 [ # # ]: 0 : if ( aRange.In( aCellPos ) )
127 : : {
128 : 0 : pFound = pAction;
129 : 0 : ++nModified;
130 : : }
131 : : }
132 : : }
133 : 0 : pAction = pAction->GetNext();
134 : : }
135 : :
136 [ # # ]: 0 : if ( pFound )
137 : : {
138 [ # # ][ # # ]: 0 : if ( pFoundContent && pFound->GetType() != SC_CAT_CONTENT )
[ # # ]
139 : 0 : pFound = pFoundContent; // Content gewinnt
140 [ # # ]: 0 : if ( pFoundMove && pFound->GetType() != SC_CAT_MOVE &&
[ # # # # ]
[ # # ]
141 : 0 : pFoundMove->GetActionNumber() >
142 : 0 : pFound->GetActionNumber() )
143 : 0 : pFound = pFoundMove; // Move gewinnt
144 : :
145 : : // bei geloeschten Spalten: Pfeil auf die linke Seite der Zelle
146 [ # # ]: 0 : if ( pFound->GetType() == SC_CAT_DELETE_COLS )
147 : 0 : bLeftEdge = true;
148 : :
149 [ # # ]: 0 : DateTime aDT = pFound->GetDateTime();
150 [ # # ][ # # ]: 0 : aTrackText = pFound->GetUser();
151 [ # # ]: 0 : aTrackText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ", " ));
152 [ # # ][ # # ]: 0 : aTrackText += ScGlobal::pLocaleData->getDate(aDT);
153 [ # # ]: 0 : aTrackText += ' ';
154 [ # # ][ # # ]: 0 : aTrackText += ScGlobal::pLocaleData->getTime(aDT);
155 [ # # ]: 0 : aTrackText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ":\n" ));
156 [ # # ][ # # ]: 0 : String aComStr=pFound->GetComment();
157 [ # # ]: 0 : if(aComStr.Len()>0)
158 : : {
159 [ # # ]: 0 : aTrackText += aComStr;
160 [ # # ]: 0 : aTrackText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "\n( " ));
161 : : }
162 : 0 : rtl::OUString aTmp;
163 [ # # ]: 0 : pFound->GetDescription(aTmp, pDoc);
164 [ # # ][ # # ]: 0 : aTrackText += String(aTmp);
[ # # ]
165 [ # # ]: 0 : if(aComStr.Len()>0)
166 : : {
167 [ # # ]: 0 : aTrackText +=')';
168 [ # # ]: 0 : }
169 : : }
170 : : }
171 : :
172 : : // Notiz nur, wenn sie nicht schon auf dem Drawing-Layer angezeigt wird:
173 [ # # ][ # # ]: 0 : const ScPostIt* pNote = pDoc->GetNotes( aCellPos.Tab() )->findByAddress( aCellPos );
174 [ # # ][ # # ]: 0 : if ( (aTrackText.Len() > 0) || (pNote && !pNote->IsCaptionShown()) )
[ # # ][ # # ]
175 : : {
176 : 0 : bool bNew = true;
177 : 0 : bool bFast = false;
178 [ # # ]: 0 : if ( pNoteMarker ) // schon eine Notiz angezeigt
179 : : {
180 [ # # ]: 0 : if ( pNoteMarker->GetDocPos() == aCellPos ) // dieselbe
181 : 0 : bNew = false; // dann stehenlassen
182 : : else
183 : 0 : bFast = true; // sonst sofort
184 : :
185 : : // marker which was shown for ctrl-F1 isn't removed by mouse events
186 [ # # ][ # # ]: 0 : if ( pNoteMarker->IsByKeyboard() && !bKeyboard )
[ # # ]
187 : 0 : bNew = false;
188 : : }
189 [ # # ]: 0 : if ( bNew )
190 : : {
191 [ # # ]: 0 : if ( bKeyboard )
192 : 0 : bFast = true; // keyboard also shows the marker immediately
193 : :
194 [ # # ][ # # ]: 0 : delete pNoteMarker;
195 : :
196 : 0 : bool bHSplit = pViewData->GetHSplitMode() != SC_SPLIT_NONE;
197 : 0 : bool bVSplit = pViewData->GetVSplitMode() != SC_SPLIT_NONE;
198 : :
199 [ # # ][ # # ]: 0 : Window* pLeft = pViewData->GetView()->GetWindowByPos( bVSplit ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT );
200 [ # # ][ # # ]: 0 : Window* pRight = bHSplit ? pViewData->GetView()->GetWindowByPos( bVSplit ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT ) : 0;
[ # # ]
201 [ # # ][ # # ]: 0 : Window* pBottom = bVSplit ? pViewData->GetView()->GetWindowByPos( SC_SPLIT_BOTTOMLEFT ) : 0;
202 [ # # ][ # # ]: 0 : Window* pDiagonal = (bHSplit && bVSplit) ? pViewData->GetView()->GetWindowByPos( SC_SPLIT_BOTTOMRIGHT ) : 0;
[ # # ]
203 : : OSL_ENSURE( pLeft, "ScGridWindow::ShowNoteMarker - missing top-left grid window" );
204 : :
205 : : /* If caption is shown from right or bottom windows, adjust
206 : : mapmode to include size of top-left window. */
207 [ # # ]: 0 : MapMode aMapMode = GetDrawMapMode( true );
208 [ # # ]: 0 : Size aLeftSize = pLeft->PixelToLogic( pLeft->GetOutputSizePixel(), aMapMode );
209 : 0 : Point aOrigin = aMapMode.GetOrigin();
210 [ # # ][ # # ]: 0 : if( (this == pRight) || (this == pDiagonal) )
211 : 0 : aOrigin.X() += aLeftSize.Width();
212 [ # # ][ # # ]: 0 : if( (this == pBottom) || (this == pDiagonal) )
213 : 0 : aOrigin.Y() += aLeftSize.Height();
214 [ # # ]: 0 : aMapMode.SetOrigin( aOrigin );
215 : :
216 : : pNoteMarker = new ScNoteMarker( pLeft, pRight, pBottom, pDiagonal,
217 : : pDoc, aCellPos, aTrackText,
218 [ # # ][ # # ]: 0 : aMapMode, bLeftEdge, bFast, bKeyboard );
[ # # ]
219 : : }
220 : :
221 : 0 : bDone = true; // something is shown (old or new)
222 : : }
223 : :
224 [ # # ]: 0 : return bDone;
225 : : }
226 : :
227 : : // -----------------------------------------------------------------------
228 : :
229 : 0 : void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
230 : : {
231 : 0 : sal_Bool bDone = false;
232 : 0 : sal_Bool bHelpEnabled = ( rHEvt.GetMode() & ( HELPMODE_BALLOON | HELPMODE_QUICK ) ) != 0;
233 : 0 : SdrView* pDrView = pViewData->GetScDrawView();
234 : :
235 : 0 : sal_Bool bDrawTextEdit = false;
236 [ # # ]: 0 : if (pDrView)
237 : 0 : bDrawTextEdit = pDrView->IsTextEdit();
238 : :
239 : : // notes or change tracking
240 : :
241 [ # # ][ # # ]: 0 : if ( bHelpEnabled && !bDrawTextEdit )
242 : : {
243 [ # # ][ # # ]: 0 : Point aPosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
244 : : SCsCOL nPosX;
245 : : SCsROW nPosY;
246 [ # # ]: 0 : pViewData->GetPosFromPixel( aPosPixel.X(), aPosPixel.Y(), eWhich, nPosX, nPosY );
247 : :
248 [ # # ][ # # ]: 0 : if ( ShowNoteMarker( nPosX, nPosY, false ) )
249 : : {
250 [ # # ]: 0 : Window::RequestHelp( rHEvt ); // alte Tip/Balloon ausschalten
251 : 0 : bDone = sal_True;
252 : : }
253 : : }
254 : :
255 [ # # ][ # # ]: 0 : if ( !bDone && pNoteMarker )
256 : : {
257 [ # # ]: 0 : if ( pNoteMarker->IsByKeyboard() )
258 : : {
259 : : // marker which was shown for ctrl-F1 isn't removed by mouse events
260 : : }
261 : : else
262 [ # # ]: 0 : DELETEZ(pNoteMarker);
263 : : }
264 : :
265 : : // Image-Map / Text-URL
266 : :
267 [ # # ][ # # ]: 0 : if ( bHelpEnabled && !bDone && !nButtonDown ) // nur ohne gedrueckten Button
[ # # ]
268 : : {
269 [ # # ]: 0 : String aHelpText;
270 [ # # ]: 0 : Rectangle aPixRect;
271 [ # # ][ # # ]: 0 : Point aPosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
272 : :
273 [ # # ]: 0 : if ( pDrView ) // URL / Image-Map
274 : : {
275 [ # # ]: 0 : SdrViewEvent aVEvt;
276 [ # # ]: 0 : MouseEvent aMEvt( aPosPixel, 1, 0, MOUSE_LEFT );
277 [ # # ]: 0 : SdrHitKind eHit = pDrView->PickAnything( aMEvt, SDRMOUSEBUTTONDOWN, aVEvt );
278 : :
279 [ # # ][ # # ]: 0 : if ( eHit != SDRHIT_NONE && aVEvt.pObj != NULL )
280 : : {
281 : : // URL fuer IMapObject unter Pointer ist Hilfetext
282 [ # # ][ # # ]: 0 : if ( ScDrawLayer::GetIMapInfo( aVEvt.pObj ) )
283 : : {
284 [ # # ]: 0 : Point aLogicPos = PixelToLogic( aPosPixel );
285 : : IMapObject* pIMapObj = ScDrawLayer::GetHitIMapObject(
286 [ # # ]: 0 : aVEvt.pObj, aLogicPos, *this );
287 : :
288 [ # # ]: 0 : if ( pIMapObj )
289 : : {
290 : : // Bei ImageMaps die Description anzeigen, wenn vorhanden
291 [ # # ]: 0 : aHelpText = pIMapObj->GetAltText();
292 [ # # ]: 0 : if (!aHelpText.Len())
293 [ # # ]: 0 : aHelpText = pIMapObj->GetURL();
294 [ # # ][ # # ]: 0 : aPixRect = LogicToPixel(aVEvt.pObj->GetLogicRect());
295 : : }
296 : : }
297 : : // URL in shape text or at shape itself (URL in text overrides object URL)
298 [ # # ]: 0 : if ( aHelpText.Len() == 0 )
299 : : {
300 [ # # ]: 0 : if( aVEvt.eEvent == SDREVENT_EXECUTEURL )
301 : : {
302 [ # # ]: 0 : aHelpText = aVEvt.pURLField->GetURL();
303 [ # # ][ # # ]: 0 : aPixRect = LogicToPixel(aVEvt.pObj->GetLogicRect());
304 : : }
305 : : else
306 : : {
307 : 0 : SdrObject* pObj = 0;
308 : 0 : SdrPageView* pPV = 0;
309 [ # # ]: 0 : Point aMDPos = PixelToLogic( aPosPixel );
310 [ # # ][ # # ]: 0 : if ( pDrView->PickObj(aMDPos, pDrView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER) )
311 : : {
312 [ # # ][ # # ]: 0 : if ( pObj->IsGroupObject() )
313 : : {
314 : 0 : SdrObject* pHit = 0;
315 [ # # ][ # # ]: 0 : if ( pDrView->PickObj(aMDPos, pDrView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) )
316 : 0 : pObj = pHit;
317 : : }
318 [ # # ]: 0 : ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
319 [ # # ][ # # ]: 0 : if ( pInfo && (pInfo->GetHlink().getLength() > 0) )
[ # # ]
320 : : {
321 [ # # ][ # # ]: 0 : aPixRect = LogicToPixel(aVEvt.pObj->GetLogicRect());
322 [ # # ]: 0 : aHelpText = pInfo->GetHlink();
323 : : }
324 : : }
325 : : }
326 : : }
327 [ # # ]: 0 : }
328 : : }
329 : :
330 [ # # ]: 0 : if ( !aHelpText.Len() ) // Text-URL
331 : : {
332 [ # # ]: 0 : String aUrl;
333 [ # # ][ # # ]: 0 : if ( GetEditUrl( aPosPixel, NULL, &aUrl, NULL ) )
334 : : {
335 : : aHelpText = INetURLObject::decode( aUrl, INET_HEX_ESCAPE,
336 [ # # ][ # # ]: 0 : INetURLObject::DECODE_UNAMBIGUOUS );
[ # # ]
337 : :
338 [ # # ]: 0 : ScDocument* pDoc = pViewData->GetDocument();
339 : : SCsCOL nPosX;
340 : : SCsROW nPosY;
341 : 0 : SCTAB nTab = pViewData->GetTabNo();
342 [ # # ]: 0 : pViewData->GetPosFromPixel( aPosPixel.X(), aPosPixel.Y(), eWhich, nPosX, nPosY );
343 [ # # ]: 0 : const ScPatternAttr* pPattern = pDoc->GetPattern( nPosX, nPosY, nTab );
344 : :
345 : : // bForceToTop = sal_False, use the cell's real position
346 [ # # ]: 0 : aPixRect = pViewData->GetEditArea( eWhich, nPosX, nPosY, this, pPattern, false );
347 [ # # ]: 0 : }
348 : : }
349 : :
350 [ # # ]: 0 : if ( aHelpText.Len() )
351 : : {
352 : 0 : Rectangle aScreenRect(OutputToScreenPixel(aPixRect.TopLeft()),
353 [ # # ]: 0 : OutputToScreenPixel(aPixRect.BottomRight()));
[ # # # # ]
[ # # ]
354 : :
355 [ # # ]: 0 : if ( rHEvt.GetMode() & HELPMODE_BALLOON )
356 [ # # ][ # # ]: 0 : Help::ShowBalloon(this,rHEvt.GetMousePosPixel(), aScreenRect, aHelpText);
357 [ # # ]: 0 : else if ( rHEvt.GetMode() & HELPMODE_QUICK )
358 [ # # ]: 0 : Help::ShowQuickHelp(this,aScreenRect, aHelpText);
359 : :
360 : 0 : bDone = sal_True;
361 [ # # ]: 0 : }
362 : : }
363 : :
364 : : // Basic-Controls
365 : :
366 [ # # ][ # # ]: 0 : if ( pDrView && bHelpEnabled && !bDone )
[ # # ]
367 : : {
368 : 0 : SdrPageView* pPV = pDrView->GetSdrPageView();
369 : : OSL_ENSURE( pPV, "SdrPageView* ist NULL" );
370 [ # # ]: 0 : if (pPV)
371 : 0 : bDone = ((ScDrawPage*)pPV->GetPage())->RequestHelp( this, pDrView, rHEvt );
372 : : }
373 : :
374 : : // Wenn QuickHelp fuer AutoFill angezeigt wird, nicht wieder wegnehmen lassen
375 : :
376 [ # # ]: 0 : if ( nMouseStatus == SC_GM_TABDOWN && pViewData->GetRefType() == SC_REFTYPE_FILL &&
[ # # # # ]
[ # # ]
377 : 0 : Help::IsQuickHelpEnabled() )
378 : 0 : bDone = sal_True;
379 : :
380 [ # # ]: 0 : if (!bDone)
381 : 0 : Window::RequestHelp( rHEvt );
382 : 0 : }
383 : :
384 : 0 : bool ScGridWindow::IsMyModel(SdrEditView* pSdrView)
385 : : {
386 : : return pSdrView &&
387 [ # # ][ # # ]: 0 : pSdrView->GetModel() == pViewData->GetDocument()->GetDrawLayer();
388 : : }
389 : :
390 : 4204 : void ScGridWindow::HideNoteMarker()
391 : : {
392 [ - + ]: 4204 : DELETEZ(pNoteMarker);
393 : 4204 : }
394 : :
395 : : com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
396 : 5 : ScGridWindow::CreateAccessible()
397 : : {
398 : : ScAccessibleDocument* pAccessibleDocument =
399 : : new ScAccessibleDocument(GetAccessibleParentWindow()->GetAccessible(),
400 [ + - ]: 5 : pViewData->GetViewShell(), eWhich);
401 : :
402 [ + - ]: 5 : com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > xAccessible = pAccessibleDocument;
403 : :
404 [ + - ]: 5 : pAccessibleDocument->Init();
405 : :
406 : 5 : return xAccessible;
407 : : }
408 : :
409 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|