xref: /aoo4110/main/sc/inc/detfunc.hxx (revision b1cdbd2c)
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 
23 
24 #ifndef SC_DETFUNC_HXX
25 #define SC_DETFUNC_HXX
26 
27 #include "address.hxx"
28 #include <tools/gen.hxx>
29 #include <tools/color.hxx>
30 #include "scdllapi.h"
31 
32 class SdrObject;
33 class SdrPage;
34 class String;
35 
36 class ScPostIt;
37 class ScCommentData;
38 class ScDetectiveData;
39 class ScDocument;
40 class ScAddress;
41 class ScRange;
42 
43 #define SC_DET_MAXCIRCLE	1000
44 
45 enum ScDetectiveDelete { SC_DET_ALL, SC_DET_DETECTIVE, SC_DET_CIRCLES, SC_DET_ARROWS };
46 
47 enum ScDetectiveObjType
48 {
49 	SC_DETOBJ_NONE,
50 	SC_DETOBJ_ARROW,
51 	SC_DETOBJ_FROMOTHERTAB,
52 	SC_DETOBJ_TOOTHERTAB,
53 	SC_DETOBJ_CIRCLE
54 };
55 
56 class SC_DLLPUBLIC ScDetectiveFunc
57 {
58 	static ColorData nArrowColor;
59 	static ColorData nErrorColor;
60 	static ColorData nCommentColor;
61 	static sal_Bool		 bColorsInitialized;
62 
63 	ScDocument*		pDoc;
64 	SCTAB			nTab;
65 
66     enum DrawPosMode
67     {
68         DRAWPOS_TOPLEFT,        /// Top-left edge of the cell.
69         DRAWPOS_BOTTOMRIGHT,    /// Bottom-right edge of the cell.
70         DRAWPOS_DETARROW,       /// Position inside cell for detective arrows.
71         DRAWPOS_CAPTIONLEFT,    /// Top-left edge of the cell for captions.
72         DRAWPOS_CAPTIONRIGHT    /// Top-right edge of the cell for captions (incl. merged cells).
73     };
74 
75     /** Returns a drawing layer position for the passed cell address. */
76     Point       GetDrawPos( SCCOL nCol, SCROW nRow, DrawPosMode eMode ) const;
77 
78     /** Returns the drawing layer rectangle for the passed cell range. */
79     Rectangle   GetDrawRect( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
80 
81     /** Returns the drawing layer rectangle for the passed cell address. */
82     Rectangle   GetDrawRect( SCCOL nCol, SCROW nRow ) const;
83 
84 	sal_Bool		HasArrow( const ScAddress& rStart,
85 							SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab );
86 
87 	void		DeleteArrowsAt( SCCOL nCol, SCROW nRow, sal_Bool bDestPnt );
88 	void		DeleteBox( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
89 
90 	sal_Bool		HasError( const ScRange& rRange, ScAddress& rErrPos );
91 
92 	void		FillAttributes( ScDetectiveData& rData );
93 
94 				// called from DrawEntry/DrawAlienEntry and InsertObject
95 	sal_Bool		InsertArrow( SCCOL nCol, SCROW nRow,
96 								SCCOL nRefStartCol, SCROW nRefStartRow,
97 								SCCOL nRefEndCol, SCROW nRefEndRow,
98 								sal_Bool bFromOtherTab, sal_Bool bRed,
99 								ScDetectiveData& rData );
100 	sal_Bool		InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow,
101 								SCCOL nEndCol, SCROW nEndRow, sal_Bool bRed,
102 								ScDetectiveData& rData );
103 
104 				// DrawEntry / DrawAlienEntry check for existing arrows and errors
105 	sal_Bool		DrawEntry( SCCOL nCol, SCROW nRow, const ScRange& rRef,
106 								ScDetectiveData& rData );
107 	sal_Bool		DrawAlienEntry( const ScRange& rRef,
108 								ScDetectiveData& rData );
109 
110 	void		DrawCircle( SCCOL nCol, SCROW nRow, ScDetectiveData& rData );
111 
112 	sal_uInt16		InsertPredLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel );
113 	sal_uInt16		InsertPredLevelArea( const ScRange& rRef,
114 										ScDetectiveData& rData, sal_uInt16 nLevel );
115 	sal_uInt16		FindPredLevel( SCCOL nCol, SCROW nRow, sal_uInt16 nLevel, sal_uInt16 nDeleteLevel );
116 	sal_uInt16		FindPredLevelArea( const ScRange& rRef,
117 									sal_uInt16 nLevel, sal_uInt16 nDeleteLevel );
118 
119 	sal_uInt16		InsertErrorLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel );
120 
121 	sal_uInt16		InsertSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
122 										ScDetectiveData& rData, sal_uInt16 nLevel );
123 	sal_uInt16		FindSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
124 								sal_uInt16 nLevel, sal_uInt16 nDeleteLevel );
125 
126 	sal_Bool		FindFrameForObject( SdrObject* pObject, ScRange& rRange );
127 
128     void        Modified();
129 
130 public:
ScDetectiveFunc(ScDocument * pDocument,SCTAB nTable)131 				ScDetectiveFunc(ScDocument* pDocument, SCTAB nTable) : pDoc(pDocument),nTab(nTable) {}
132 
133 	sal_Bool		ShowSucc( SCCOL nCol, SCROW nRow );
134 	sal_Bool		ShowPred( SCCOL nCol, SCROW nRow );
135 	sal_Bool		ShowError( SCCOL nCol, SCROW nRow );
136 
137 	sal_Bool		DeleteSucc( SCCOL nCol, SCROW nRow );
138 	sal_Bool		DeletePred( SCCOL nCol, SCROW nRow );
139 	sal_Bool		DeleteAll( ScDetectiveDelete eWhat );
140 
141 	sal_Bool		MarkInvalid(sal_Bool& rOverflow);
142 
143     static void UpdateAllComments( ScDocument& rDoc );        // on all tables
144 	void		UpdateAllArrowColors();		// on all tables
145 
146 	static sal_Bool	IsNonAlienArrow( SdrObject* pObject );
147 
148 	ScDetectiveObjType GetDetectiveObjectType( SdrObject* pObject, SCTAB nObjTab,
149 								ScAddress& rPosition, ScRange& rSource, sal_Bool& rRedLine );
150 	void		InsertObject( ScDetectiveObjType eType, const ScAddress& rPosition,
151 								const ScRange& rSource, sal_Bool bRedLine );
152 
153 	static ColorData GetArrowColor();
154 	static ColorData GetErrorColor();
155 	static ColorData GetCommentColor();
156 	static void InitializeColors();
157 	static sal_Bool	IsColorsInitialized();
158 	static void AppendChangTrackNoteSeparator(String &str);
159 };
160 
161 
162 
163 #endif
164