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 #ifndef SC_GRIDWIN_HXX 23 #define SC_GRIDWIN_HXX 24 25 #include <tools/string.hxx> 26 #include <svtools/transfer.hxx> 27 #include "viewutil.hxx" 28 #include "viewdata.hxx" 29 #include "cbutton.hxx" 30 #include <svx/sdr/overlay/overlayobject.hxx> 31 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> 32 #include <basegfx/matrix/b2dhommatrix.hxx> 33 34 #include <vector> 35 #include <memory> 36 #include <boost/shared_ptr.hpp> 37 38 // --------------------------------------------------------------------------- 39 40 struct ScTableInfo; 41 class ScViewSelectionEngine; 42 class ScDPObject; 43 class ScDPFieldPopupWindow; 44 class ScDPFieldButton; 45 class ScOutputData; 46 class ScFilterListBox; 47 class AutoFilterPopup; 48 class SdrObject; 49 class SdrEditView; 50 class ScNoteMarker; 51 class FloatingWindow; 52 class SdrHdlList; 53 class ScTransferObj; 54 struct SpellCallbackInfo; 55 56 // Maus-Status (nMouseStatus) 57 58 #define SC_GM_NONE 0 59 #define SC_GM_TABDOWN 1 60 #define SC_GM_DBLDOWN 2 61 #define SC_GM_FILTER 3 62 #define SC_GM_IGNORE 4 63 #define SC_GM_WATERUNDO 5 64 #define SC_GM_URLDOWN 6 65 66 // Page-Drag-Modus 67 68 #define SC_PD_NONE 0 69 #define SC_PD_RANGE_L 1 70 #define SC_PD_RANGE_R 2 71 #define SC_PD_RANGE_T 4 72 #define SC_PD_RANGE_B 8 73 #define SC_PD_RANGE_TL (SC_PD_RANGE_T|SC_PD_RANGE_L) 74 #define SC_PD_RANGE_TR (SC_PD_RANGE_T|SC_PD_RANGE_R) 75 #define SC_PD_RANGE_BL (SC_PD_RANGE_B|SC_PD_RANGE_L) 76 #define SC_PD_RANGE_BR (SC_PD_RANGE_B|SC_PD_RANGE_R) 77 #define SC_PD_BREAK_H 16 78 #define SC_PD_BREAK_V 32 79 80 class ScHideTextCursor 81 { 82 private: 83 ScViewData* pViewData; 84 ScSplitPos eWhich; 85 86 public: 87 ScHideTextCursor( ScViewData* pData, ScSplitPos eW ); 88 ~ScHideTextCursor(); 89 }; 90 91 // --------------------------------------------------------------------------- 92 // predefines 93 namespace sdr { namespace overlay { class OverlayObjectList; }} 94 95 class ScGridWindow : public Window, public DropTargetHelper, public DragSourceHelper 96 { 97 // ScFilterListBox wird immer für Auswahlliste benutzt 98 friend class ScFilterListBox; 99 100 private: 101 // #114409# 102 ::sdr::overlay::OverlayObjectList* mpOOCursors; 103 ::sdr::overlay::OverlayObjectList* mpOOSelection; 104 ::sdr::overlay::OverlayObjectList* mpOOAutoFill; 105 ::sdr::overlay::OverlayObjectList* mpOODragRect; 106 ::sdr::overlay::OverlayObjectList* mpOOHeader; 107 ::sdr::overlay::OverlayObjectList* mpOOShrink; 108 109 ::boost::shared_ptr<Rectangle> mpAutoFillRect; 110 111 /** 112 * Stores current visible column and row ranges, used to avoid expensive 113 * operations on objects that are outside visible area. 114 */ 115 struct VisibleRange 116 { 117 SCCOL mnCol1; 118 SCCOL mnCol2; 119 SCROW mnRow1; 120 SCROW mnRow2; 121 122 VisibleRange(); 123 124 bool isInside(SCCOL nCol, SCROW nRow) const; 125 }; 126 VisibleRange maVisibleRange; 127 128 private: 129 ScViewData* pViewData; 130 ScSplitPos eWhich; 131 ScHSplitPos eHWhich; 132 ScVSplitPos eVWhich; 133 134 ScNoteMarker* pNoteMarker; 135 136 ScFilterListBox* pFilterBox; 137 FloatingWindow* pFilterFloat; 138 ::std::auto_ptr<ScDPFieldPopupWindow> mpDPFieldPopup; 139 ::std::auto_ptr<ScDPFieldButton> mpFilterButton; 140 141 sal_uInt16 nCursorHideCount; 142 143 sal_Bool bMarking; 144 145 sal_uInt16 nButtonDown; 146 sal_Bool bEEMouse; // Edit-Engine hat Maus 147 sal_uInt8 nMouseStatus; 148 sal_uInt8 nNestedButtonState; // track nested button up/down calls 149 150 sal_Bool bDPMouse; // DataPilot-D&D (neue Pivottabellen) 151 long nDPField; 152 ScDPObject* pDragDPObj; //! name? 153 154 sal_Bool bRFMouse; // RangeFinder-Drag 155 sal_Bool bRFSize; 156 sal_uInt16 nRFIndex; 157 SCsCOL nRFAddX; 158 SCsROW nRFAddY; 159 160 sal_uInt16 nPagebreakMouse; // Pagebreak-Modus Drag 161 SCCOLROW nPagebreakBreak; 162 SCCOLROW nPagebreakPrev; 163 ScRange aPagebreakSource; 164 ScRange aPagebreakDrag; 165 sal_Bool bPagebreakDrawn; 166 167 sal_uInt8 nPageScript; 168 169 long nLastClickX; 170 long nLastClickY; 171 172 sal_Bool bDragRect; 173 SCCOL nDragStartX; 174 SCROW nDragStartY; 175 SCCOL nDragEndX; 176 SCROW nDragEndY; 177 InsCellCmd meDragInsertMode; 178 179 sal_uInt16 nCurrentPointer; 180 181 sal_Bool bIsInScroll; 182 sal_Bool bIsInPaint; 183 184 ScDDComboBoxButton aComboButton; 185 186 Point aCurMousePos; 187 188 sal_uInt16 nPaintCount; 189 Rectangle aRepaintPixel; 190 sal_Bool bNeedsRepaint; 191 192 sal_Bool bAutoMarkVisible; 193 ScAddress aAutoMarkPos; 194 195 sal_Bool bListValButton; 196 ScAddress aListValPos; 197 198 Rectangle aInvertRect; 199 200 DECL_LINK( PopupModeEndHdl, FloatingWindow* ); 201 DECL_LINK( PopupSpellingHdl, SpellCallbackInfo* ); 202 203 sal_Bool TestMouse( const MouseEvent& rMEvt, sal_Bool bAction ); 204 205 sal_Bool DoPageFieldSelection( SCCOL nCol, SCROW nRow ); 206 bool DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt ); 207 void DoPushButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt ); 208 209 void DPMouseMove( const MouseEvent& rMEvt ); 210 void DPMouseButtonUp( const MouseEvent& rMEvt ); 211 void DPTestMouse( const MouseEvent& rMEvt, sal_Bool bMove ); 212 213 /** 214 * Check if the mouse click is on a field popup button. 215 * 216 * @return bool true if the field popup menu has been launched and no 217 * further mouse event handling is necessary, false otherwise. 218 */ 219 bool DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, ScDPObject* pDPObj); 220 void DPLaunchFieldPopupMenu( 221 const Point& rScrPos, const Size& rScrSize, const ScAddress& rPos, ScDPObject* pDPObj); 222 223 void RFMouseMove( const MouseEvent& rMEvt, sal_Bool bUp ); 224 225 void PagebreakMove( const MouseEvent& rMEvt, sal_Bool bUp ); 226 227 void UpdateDragRect( sal_Bool bShowRange, const Rectangle& rPosRect ); 228 229 sal_Bool IsAutoFilterActive( SCCOL nCol, SCROW nRow, SCTAB nTab ); 230 void ExecFilter( sal_uLong nSel, SCCOL nCol, SCROW nRow, 231 const String& aValue, bool bCheckForDates ); 232 void FilterSelect( sal_uLong nSel ); 233 234 void ExecDataSelect( SCCOL nCol, SCROW nRow, const String& rStr ); 235 236 void ExecPageFieldSelect( SCCOL nCol, SCROW nRow, sal_Bool bHasSelection, const String& rStr ); 237 238 sal_Bool HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange ); 239 sal_Bool HasScenarioRange( sal_uInt16 nCol, sal_Int32 nRow, ScRange& rScenRange ); 240 sal_Bool DropScroll( const Point& rMousePos ); 241 242 sal_Int8 AcceptPrivateDrop( const AcceptDropEvent& rEvt ); 243 sal_Int8 ExecutePrivateDrop( const ExecuteDropEvent& rEvt ); 244 sal_Int8 DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPosX, SCROW nDestPosY, 245 const Point& rLogicPos, sal_Int8 nDndAction ); 246 247 void HandleMouseButtonDown( const MouseEvent& rMEvt ); 248 249 sal_Bool DrawMouseButtonDown(const MouseEvent& rMEvt); 250 sal_Bool DrawMouseButtonUp(const MouseEvent& rMEvt); 251 sal_Bool DrawMouseMove(const MouseEvent& rMEvt); 252 sal_Bool DrawKeyInput(const KeyEvent& rKEvt); 253 sal_Bool DrawCommand(const CommandEvent& rCEvt); 254 sal_Bool DrawHasMarkedObj(); 255 void DrawEndAction(); 256 void DrawMarkDropObj( SdrObject* pObj ); 257 SdrObject* GetEditObject(); 258 sal_Bool IsMyModel(SdrEditView* pSdrView); 259 //void DrawStartTimer(); 260 261 void DrawRedraw( ScOutputData& rOutputData, ScUpdateMode eMode, sal_uLong nLayer ); 262 void DrawSdrGrid( const Rectangle& rDrawingRect, OutputDevice* pContentDev ); 263 //sal_Bool DrawBeforeScroll(); 264 void DrawAfterScroll(/*sal_Bool bVal*/); 265 //void DrawMarks(); 266 //sal_Bool NeedDrawMarks(); 267 void DrawComboButton( const Point& rCellPos, 268 long nCellSizeX, 269 long nCellSizeY, 270 sal_Bool bArrowState, 271 sal_Bool bBtnIn = sal_False ); 272 Rectangle GetListValButtonRect( const ScAddress& rButtonPos ); 273 274 void DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, OutputDevice* pContentDev ); 275 276 sal_Bool GetEditUrl( const Point& rPos, 277 String* pName=0, String* pUrl=0, String* pTarget=0 ); 278 sal_Bool GetEditUrlOrError( sal_Bool bSpellErr, const Point& rPos, 279 String* pName=0, String* pUrl=0, String* pTarget=0 ); 280 281 sal_Bool HitRangeFinder( const Point& rMouse, sal_Bool& rCorner, sal_uInt16* pIndex = NULL, 282 SCsCOL* pAddX = NULL, SCsROW* pAddY = NULL ); 283 284 sal_uInt16 HitPageBreak( const Point& rMouse, ScRange* pSource = NULL, 285 SCCOLROW* pBreak = NULL, SCCOLROW* pPrev = NULL ); 286 287 void PasteSelection( const Point& rPosPixel ); 288 289 void SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY ); 290 291 void GetSelectionRects( ::std::vector< Rectangle >& rPixelRects ); 292 293 protected: 294 using Window::Resize; 295 virtual void Resize( const Size& rSize ); 296 virtual void PrePaint(); 297 virtual void Paint( const Rectangle& rRect ); 298 virtual void KeyInput(const KeyEvent& rKEvt); 299 virtual void GetFocus(); 300 virtual void LoseFocus(); 301 302 virtual void RequestHelp( const HelpEvent& rEvt ); 303 virtual void Command( const CommandEvent& rCEvt ); 304 305 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 306 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 307 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); 308 309 public: 310 ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos ); 311 ~ScGridWindow(); 312 313 // #i70788# flush and get overlay 314 ::sdr::overlay::OverlayManager* getOverlayManager(); 315 void flushOverlayManager(); 316 317 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 318 319 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 320 virtual void MouseButtonUp( const MouseEvent& rMEvt ); 321 virtual void MouseMove( const MouseEvent& rMEvt ); 322 virtual long PreNotify( NotifyEvent& rNEvt ); 323 virtual void Tracking( const TrackingEvent& rTEvt ); 324 325 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); 326 327 void FakeButtonUp(); 328 329 Point GetMousePosPixel() const; 330 void UpdateStatusPosSize(); 331 332 void ClickExtern(); 333 334 void SetPointer( const Pointer& rPointer ); 335 336 void MoveMouseStatus( ScGridWindow &rDestWin ); 337 338 void ScrollPixel( long nDifX, long nDifY ); 339 void UpdateEditViewPos(); 340 341 void UpdateFormulas(); 342 343 void DoAutoFilterMenue( SCCOL nCol, SCROW nRow, sal_Bool bDataSelect ); 344 void DoScenarioMenue( const ScRange& rScenRange ); 345 346 void LaunchPageFieldMenu( SCCOL nCol, SCROW nRow ); 347 void LaunchDPFieldMenu( SCCOL nCol, SCROW nRow ); 348 349 ::com::sun::star::sheet::DataPilotFieldOrientation GetDPFieldOrientation( SCCOL nCol, SCROW nRow ) const; 350 351 void DrawButtons( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, 352 ScTableInfo& rTabInfo, OutputDevice* pContentDev ); 353 354 using Window::Draw; 355 void Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, 356 ScUpdateMode eMode = SC_UPDATE_ALL ); 357 358 void InvertSimple( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, 359 sal_Bool bTestMerge = sal_False, sal_Bool bRepeat = sal_False ); 360 361 //UNUSED2008-05 void DrawDragRect( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 ); 362 363 void CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress); 364 365 void HideCursor(); 366 void ShowCursor(); 367 void DrawCursor(); 368 void DrawAutoFillMark(); 369 void UpdateAutoFillMark(sal_Bool bMarked, const ScRange& rMarkRange); 370 371 void UpdateListValPos( sal_Bool bVisible, const ScAddress& rPos ); 372 373 sal_Bool ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, sal_Bool bKeyboard ); 374 void HideNoteMarker(); 375 376 MapMode GetDrawMapMode( sal_Bool bForce = sal_False ); 377 378 void ContinueDrag(); 379 380 void StopMarking(); 381 void UpdateInputContext(); 382 CheckInverted()383 void CheckInverted() { if (nPaintCount) bNeedsRepaint = sal_True; } 384 385 void DoInvertRect( const Rectangle& rPixel ); 386 387 void CheckNeedsRepaint(); 388 virtual void SwitchView(); 389 390 void UpdateDPFromFieldPopupMenu(); 391 392 void UpdateVisibleRange(); 393 394 // #114409# 395 void CursorChanged(); 396 void DrawLayerCreated(); 397 398 void DeleteCursorOverlay(); 399 void UpdateCursorOverlay(); 400 void DeleteSelectionOverlay(); 401 void UpdateSelectionOverlay(); 402 void DeleteAutoFillOverlay(); 403 void UpdateAutoFillOverlay(); 404 void DeleteDragRectOverlay(); 405 void UpdateDragRectOverlay(); 406 void DeleteHeaderOverlay(); 407 void UpdateHeaderOverlay(); 408 void DeleteShrinkOverlay(); 409 void UpdateShrinkOverlay(); 410 void UpdateAllOverlays(); 411 412 protected: 413 // #114409# 414 void ImpCreateOverlayObjects(); 415 void ImpDestroyOverlayObjects(); 416 417 }; 418 419 #endif 420 421 /* vim: set noet sw=4 ts=4: */ 422