1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SC_DETFUNC_HXX 29 #define SC_DETFUNC_HXX 30 31 #include "address.hxx" 32 #include <tools/gen.hxx> 33 #include <tools/color.hxx> 34 #include "scdllapi.h" 35 36 class SdrObject; 37 class SdrPage; 38 class String; 39 40 class ScPostIt; 41 class ScCommentData; 42 class ScDetectiveData; 43 class ScDocument; 44 class ScAddress; 45 class ScRange; 46 47 #define SC_DET_MAXCIRCLE 1000 48 49 enum ScDetectiveDelete { SC_DET_ALL, SC_DET_DETECTIVE, SC_DET_CIRCLES, SC_DET_ARROWS }; 50 51 enum ScDetectiveObjType 52 { 53 SC_DETOBJ_NONE, 54 SC_DETOBJ_ARROW, 55 SC_DETOBJ_FROMOTHERTAB, 56 SC_DETOBJ_TOOTHERTAB, 57 SC_DETOBJ_CIRCLE 58 }; 59 60 class SC_DLLPUBLIC ScDetectiveFunc 61 { 62 static ColorData nArrowColor; 63 static ColorData nErrorColor; 64 static ColorData nCommentColor; 65 static sal_Bool bColorsInitialized; 66 67 ScDocument* pDoc; 68 SCTAB nTab; 69 70 enum DrawPosMode 71 { 72 DRAWPOS_TOPLEFT, /// Top-left edge of the cell. 73 DRAWPOS_BOTTOMRIGHT, /// Bottom-right edge of the cell. 74 DRAWPOS_DETARROW, /// Position inside cell for detective arrows. 75 DRAWPOS_CAPTIONLEFT, /// Top-left edge of the cell for captions. 76 DRAWPOS_CAPTIONRIGHT /// Top-right edge of the cell for captions (incl. merged cells). 77 }; 78 79 /** Returns a drawing layer position for the passed cell address. */ 80 Point GetDrawPos( SCCOL nCol, SCROW nRow, DrawPosMode eMode ) const; 81 82 /** Returns the drawing layer rectangle for the passed cell range. */ 83 Rectangle GetDrawRect( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const; 84 85 /** Returns the drawing layer rectangle for the passed cell address. */ 86 Rectangle GetDrawRect( SCCOL nCol, SCROW nRow ) const; 87 88 sal_Bool HasArrow( const ScAddress& rStart, 89 SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab ); 90 91 void DeleteArrowsAt( SCCOL nCol, SCROW nRow, sal_Bool bDestPnt ); 92 void DeleteBox( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); 93 94 sal_Bool HasError( const ScRange& rRange, ScAddress& rErrPos ); 95 96 void FillAttributes( ScDetectiveData& rData ); 97 98 // called from DrawEntry/DrawAlienEntry and InsertObject 99 sal_Bool InsertArrow( SCCOL nCol, SCROW nRow, 100 SCCOL nRefStartCol, SCROW nRefStartRow, 101 SCCOL nRefEndCol, SCROW nRefEndRow, 102 sal_Bool bFromOtherTab, sal_Bool bRed, 103 ScDetectiveData& rData ); 104 sal_Bool InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow, 105 SCCOL nEndCol, SCROW nEndRow, sal_Bool bRed, 106 ScDetectiveData& rData ); 107 108 // DrawEntry / DrawAlienEntry check for existing arrows and errors 109 sal_Bool DrawEntry( SCCOL nCol, SCROW nRow, const ScRange& rRef, 110 ScDetectiveData& rData ); 111 sal_Bool DrawAlienEntry( const ScRange& rRef, 112 ScDetectiveData& rData ); 113 114 void DrawCircle( SCCOL nCol, SCROW nRow, ScDetectiveData& rData ); 115 116 sal_uInt16 InsertPredLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel ); 117 sal_uInt16 InsertPredLevelArea( const ScRange& rRef, 118 ScDetectiveData& rData, sal_uInt16 nLevel ); 119 sal_uInt16 FindPredLevel( SCCOL nCol, SCROW nRow, sal_uInt16 nLevel, sal_uInt16 nDeleteLevel ); 120 sal_uInt16 FindPredLevelArea( const ScRange& rRef, 121 sal_uInt16 nLevel, sal_uInt16 nDeleteLevel ); 122 123 sal_uInt16 InsertErrorLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel ); 124 125 sal_uInt16 InsertSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, 126 ScDetectiveData& rData, sal_uInt16 nLevel ); 127 sal_uInt16 FindSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, 128 sal_uInt16 nLevel, sal_uInt16 nDeleteLevel ); 129 130 sal_Bool FindFrameForObject( SdrObject* pObject, ScRange& rRange ); 131 132 void Modified(); 133 134 public: 135 ScDetectiveFunc(ScDocument* pDocument, SCTAB nTable) : pDoc(pDocument),nTab(nTable) {} 136 137 sal_Bool ShowSucc( SCCOL nCol, SCROW nRow ); 138 sal_Bool ShowPred( SCCOL nCol, SCROW nRow ); 139 sal_Bool ShowError( SCCOL nCol, SCROW nRow ); 140 141 sal_Bool DeleteSucc( SCCOL nCol, SCROW nRow ); 142 sal_Bool DeletePred( SCCOL nCol, SCROW nRow ); 143 sal_Bool DeleteAll( ScDetectiveDelete eWhat ); 144 145 sal_Bool MarkInvalid(sal_Bool& rOverflow); 146 147 static void UpdateAllComments( ScDocument& rDoc ); // on all tables 148 void UpdateAllArrowColors(); // on all tables 149 150 static sal_Bool IsNonAlienArrow( SdrObject* pObject ); 151 152 ScDetectiveObjType GetDetectiveObjectType( SdrObject* pObject, SCTAB nObjTab, 153 ScAddress& rPosition, ScRange& rSource, sal_Bool& rRedLine ); 154 void InsertObject( ScDetectiveObjType eType, const ScAddress& rPosition, 155 const ScRange& rSource, sal_Bool bRedLine ); 156 157 static ColorData GetArrowColor(); 158 static ColorData GetErrorColor(); 159 static ColorData GetCommentColor(); 160 static void InitializeColors(); 161 static sal_Bool IsColorsInitialized(); 162 }; 163 164 165 166 #endif 167