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