1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: detfunc.hxx,v $
10 * $Revision: 1.11.128.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_DETFUNC_HXX
32 #define SC_DETFUNC_HXX
34 #include "address.hxx"
35 #include <tools/gen.hxx>
36 #include <tools/color.hxx>
48 class ScDetectiveData
;
54 #define SC_DET_MAXCIRCLE 1000
56 enum ScDetectiveDelete
{ SC_DET_ALL
, SC_DET_DETECTIVE
, SC_DET_CIRCLES
, SC_DET_ARROWS
};
58 enum ScDetectiveObjType
62 SC_DETOBJ_FROMOTHERTAB
,
67 class SC_DLLPUBLIC ScDetectiveFunc
69 static ColorData nArrowColor
;
70 static ColorData nErrorColor
;
71 static ColorData nCommentColor
;
72 static BOOL bColorsInitialized
;
79 DRAWPOS_TOPLEFT
, /// Top-left edge of the cell.
80 DRAWPOS_BOTTOMRIGHT
, /// Bottom-right edge of the cell.
81 DRAWPOS_DETARROW
, /// Position inside cell for detective arrows.
82 DRAWPOS_CAPTIONLEFT
, /// Top-left edge of the cell for captions.
83 DRAWPOS_CAPTIONRIGHT
/// Top-right edge of the cell for captions (incl. merged cells).
86 /** Returns a drawing layer position for the passed cell address. */
87 Point
GetDrawPos( SCCOL nCol
, SCROW nRow
, DrawPosMode eMode
) const;
89 /** Returns the drawing layer rectangle for the passed cell range. */
90 Rectangle
GetDrawRect( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
) const;
92 /** Returns the drawing layer rectangle for the passed cell address. */
93 Rectangle
GetDrawRect( SCCOL nCol
, SCROW nRow
) const;
95 BOOL
HasArrow( const ScAddress
& rStart
,
96 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nEndTab
);
98 void DeleteArrowsAt( SCCOL nCol
, SCROW nRow
, BOOL bDestPnt
);
99 void DeleteBox( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
);
101 BOOL
HasError( const ScRange
& rRange
, ScAddress
& rErrPos
);
103 void FillAttributes( ScDetectiveData
& rData
);
105 // called from DrawEntry/DrawAlienEntry and InsertObject
106 BOOL
InsertArrow( SCCOL nCol
, SCROW nRow
,
107 SCCOL nRefStartCol
, SCROW nRefStartRow
,
108 SCCOL nRefEndCol
, SCROW nRefEndRow
,
109 BOOL bFromOtherTab
, BOOL bRed
,
110 ScDetectiveData
& rData
);
111 BOOL
InsertToOtherTab( SCCOL nStartCol
, SCROW nStartRow
,
112 SCCOL nEndCol
, SCROW nEndRow
, BOOL bRed
,
113 ScDetectiveData
& rData
);
115 // DrawEntry / DrawAlienEntry check for existing arrows and errors
116 BOOL
DrawEntry( SCCOL nCol
, SCROW nRow
, const ScRange
& rRef
,
117 ScDetectiveData
& rData
);
118 BOOL
DrawAlienEntry( const ScRange
& rRef
,
119 ScDetectiveData
& rData
);
121 void DrawCircle( SCCOL nCol
, SCROW nRow
, ScDetectiveData
& rData
);
123 USHORT
InsertPredLevel( SCCOL nCol
, SCROW nRow
, ScDetectiveData
& rData
, USHORT nLevel
);
124 USHORT
InsertPredLevelArea( const ScRange
& rRef
,
125 ScDetectiveData
& rData
, USHORT nLevel
);
126 USHORT
FindPredLevel( SCCOL nCol
, SCROW nRow
, USHORT nLevel
, USHORT nDeleteLevel
);
127 USHORT
FindPredLevelArea( const ScRange
& rRef
,
128 USHORT nLevel
, USHORT nDeleteLevel
);
130 USHORT
InsertErrorLevel( SCCOL nCol
, SCROW nRow
, ScDetectiveData
& rData
, USHORT nLevel
);
132 USHORT
InsertSuccLevel( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
133 ScDetectiveData
& rData
, USHORT nLevel
);
134 USHORT
FindSuccLevel( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
135 USHORT nLevel
, USHORT nDeleteLevel
);
137 BOOL
FindFrameForObject( SdrObject
* pObject
, ScRange
& rRange
);
142 ScDetectiveFunc(ScDocument
* pDocument
, SCTAB nTable
) : pDoc(pDocument
),nTab(nTable
) {}
144 BOOL
ShowSucc( SCCOL nCol
, SCROW nRow
);
145 BOOL
ShowPred( SCCOL nCol
, SCROW nRow
);
146 BOOL
ShowError( SCCOL nCol
, SCROW nRow
);
148 BOOL
DeleteSucc( SCCOL nCol
, SCROW nRow
);
149 BOOL
DeletePred( SCCOL nCol
, SCROW nRow
);
150 BOOL
DeleteAll( ScDetectiveDelete eWhat
);
152 BOOL
MarkInvalid(BOOL
& rOverflow
);
154 void GetAllPreds(SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
, ::std::vector
<ScSharedTokenRef
>& rRefTokens
);
155 void GetAllSuccs(SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
, ::std::vector
<ScSharedTokenRef
>& rRefTokens
);
157 static void UpdateAllComments( ScDocument
& rDoc
); // on all tables
158 void UpdateAllArrowColors(); // on all tables
160 static BOOL
IsNonAlienArrow( SdrObject
* pObject
);
162 ScDetectiveObjType
GetDetectiveObjectType( SdrObject
* pObject
, SCTAB nObjTab
,
163 ScAddress
& rPosition
, ScRange
& rSource
, BOOL
& rRedLine
);
164 void InsertObject( ScDetectiveObjType eType
, const ScAddress
& rPosition
,
165 const ScRange
& rSource
, BOOL bRedLine
);
167 static ColorData
GetArrowColor();
168 static ColorData
GetErrorColor();
169 static ColorData
GetCommentColor();
170 static void InitializeColors();
171 static BOOL
IsColorsInitialized();