xref: /trunk/main/sc/inc/detfunc.hxx (revision 4d7c9de0)
138d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
338d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
438d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
538d50f7bSAndrew Rist  * distributed with this work for additional information
638d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
738d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
838d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
938d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
1038d50f7bSAndrew Rist  *
1138d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1238d50f7bSAndrew Rist  *
1338d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1438d50f7bSAndrew Rist  * software distributed under the License is distributed on an
1538d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1638d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
1738d50f7bSAndrew Rist  * specific language governing permissions and limitations
1838d50f7bSAndrew Rist  * under the License.
1938d50f7bSAndrew Rist  *
2038d50f7bSAndrew Rist  *************************************************************/
2138d50f7bSAndrew Rist 
2238d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_DETFUNC_HXX
25cdf0e10cSrcweir #define SC_DETFUNC_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "address.hxx"
28cdf0e10cSrcweir #include <tools/gen.hxx>
29cdf0e10cSrcweir #include <tools/color.hxx>
30cdf0e10cSrcweir #include "scdllapi.h"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir class SdrObject;
33cdf0e10cSrcweir class SdrPage;
34cdf0e10cSrcweir class String;
35cdf0e10cSrcweir 
36cdf0e10cSrcweir class ScPostIt;
37cdf0e10cSrcweir class ScCommentData;
38cdf0e10cSrcweir class ScDetectiveData;
39cdf0e10cSrcweir class ScDocument;
40cdf0e10cSrcweir class ScAddress;
41cdf0e10cSrcweir class ScRange;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #define SC_DET_MAXCIRCLE	1000
44cdf0e10cSrcweir 
45cdf0e10cSrcweir enum ScDetectiveDelete { SC_DET_ALL, SC_DET_DETECTIVE, SC_DET_CIRCLES, SC_DET_ARROWS };
46cdf0e10cSrcweir 
47cdf0e10cSrcweir enum ScDetectiveObjType
48cdf0e10cSrcweir {
49cdf0e10cSrcweir 	SC_DETOBJ_NONE,
50cdf0e10cSrcweir 	SC_DETOBJ_ARROW,
51cdf0e10cSrcweir 	SC_DETOBJ_FROMOTHERTAB,
52cdf0e10cSrcweir 	SC_DETOBJ_TOOTHERTAB,
53cdf0e10cSrcweir 	SC_DETOBJ_CIRCLE
54cdf0e10cSrcweir };
55cdf0e10cSrcweir 
56cdf0e10cSrcweir class SC_DLLPUBLIC ScDetectiveFunc
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	static ColorData nArrowColor;
59cdf0e10cSrcweir 	static ColorData nErrorColor;
60cdf0e10cSrcweir 	static ColorData nCommentColor;
61cdf0e10cSrcweir 	static sal_Bool		 bColorsInitialized;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	ScDocument*		pDoc;
64cdf0e10cSrcweir 	SCTAB			nTab;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     enum DrawPosMode
67cdf0e10cSrcweir     {
68cdf0e10cSrcweir         DRAWPOS_TOPLEFT,        /// Top-left edge of the cell.
69cdf0e10cSrcweir         DRAWPOS_BOTTOMRIGHT,    /// Bottom-right edge of the cell.
70cdf0e10cSrcweir         DRAWPOS_DETARROW,       /// Position inside cell for detective arrows.
71cdf0e10cSrcweir         DRAWPOS_CAPTIONLEFT,    /// Top-left edge of the cell for captions.
72cdf0e10cSrcweir         DRAWPOS_CAPTIONRIGHT    /// Top-right edge of the cell for captions (incl. merged cells).
73cdf0e10cSrcweir     };
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     /** Returns a drawing layer position for the passed cell address. */
76cdf0e10cSrcweir     Point       GetDrawPos( SCCOL nCol, SCROW nRow, DrawPosMode eMode ) const;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     /** Returns the drawing layer rectangle for the passed cell range. */
79cdf0e10cSrcweir     Rectangle   GetDrawRect( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     /** Returns the drawing layer rectangle for the passed cell address. */
82cdf0e10cSrcweir     Rectangle   GetDrawRect( SCCOL nCol, SCROW nRow ) const;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	sal_Bool		HasArrow( const ScAddress& rStart,
85cdf0e10cSrcweir 							SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	void		DeleteArrowsAt( SCCOL nCol, SCROW nRow, sal_Bool bDestPnt );
88cdf0e10cSrcweir 	void		DeleteBox( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	sal_Bool		HasError( const ScRange& rRange, ScAddress& rErrPos );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	void		FillAttributes( ScDetectiveData& rData );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 				// called from DrawEntry/DrawAlienEntry and InsertObject
95cdf0e10cSrcweir 	sal_Bool		InsertArrow( SCCOL nCol, SCROW nRow,
96cdf0e10cSrcweir 								SCCOL nRefStartCol, SCROW nRefStartRow,
97cdf0e10cSrcweir 								SCCOL nRefEndCol, SCROW nRefEndRow,
98cdf0e10cSrcweir 								sal_Bool bFromOtherTab, sal_Bool bRed,
99cdf0e10cSrcweir 								ScDetectiveData& rData );
100cdf0e10cSrcweir 	sal_Bool		InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow,
101cdf0e10cSrcweir 								SCCOL nEndCol, SCROW nEndRow, sal_Bool bRed,
102cdf0e10cSrcweir 								ScDetectiveData& rData );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 				// DrawEntry / DrawAlienEntry check for existing arrows and errors
105cdf0e10cSrcweir 	sal_Bool		DrawEntry( SCCOL nCol, SCROW nRow, const ScRange& rRef,
106cdf0e10cSrcweir 								ScDetectiveData& rData );
107cdf0e10cSrcweir 	sal_Bool		DrawAlienEntry( const ScRange& rRef,
108cdf0e10cSrcweir 								ScDetectiveData& rData );
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	void		DrawCircle( SCCOL nCol, SCROW nRow, ScDetectiveData& rData );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	sal_uInt16		InsertPredLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel );
113cdf0e10cSrcweir 	sal_uInt16		InsertPredLevelArea( const ScRange& rRef,
114cdf0e10cSrcweir 										ScDetectiveData& rData, sal_uInt16 nLevel );
115cdf0e10cSrcweir 	sal_uInt16		FindPredLevel( SCCOL nCol, SCROW nRow, sal_uInt16 nLevel, sal_uInt16 nDeleteLevel );
116cdf0e10cSrcweir 	sal_uInt16		FindPredLevelArea( const ScRange& rRef,
117cdf0e10cSrcweir 									sal_uInt16 nLevel, sal_uInt16 nDeleteLevel );
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	sal_uInt16		InsertErrorLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	sal_uInt16		InsertSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
122cdf0e10cSrcweir 										ScDetectiveData& rData, sal_uInt16 nLevel );
123cdf0e10cSrcweir 	sal_uInt16		FindSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
124cdf0e10cSrcweir 								sal_uInt16 nLevel, sal_uInt16 nDeleteLevel );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	sal_Bool		FindFrameForObject( SdrObject* pObject, ScRange& rRange );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     void        Modified();
129cdf0e10cSrcweir 
130cdf0e10cSrcweir public:
ScDetectiveFunc(ScDocument * pDocument,SCTAB nTable)131cdf0e10cSrcweir 				ScDetectiveFunc(ScDocument* pDocument, SCTAB nTable) : pDoc(pDocument),nTab(nTable) {}
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	sal_Bool		ShowSucc( SCCOL nCol, SCROW nRow );
134cdf0e10cSrcweir 	sal_Bool		ShowPred( SCCOL nCol, SCROW nRow );
135cdf0e10cSrcweir 	sal_Bool		ShowError( SCCOL nCol, SCROW nRow );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	sal_Bool		DeleteSucc( SCCOL nCol, SCROW nRow );
138cdf0e10cSrcweir 	sal_Bool		DeletePred( SCCOL nCol, SCROW nRow );
139cdf0e10cSrcweir 	sal_Bool		DeleteAll( ScDetectiveDelete eWhat );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	sal_Bool		MarkInvalid(sal_Bool& rOverflow);
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     static void UpdateAllComments( ScDocument& rDoc );        // on all tables
144cdf0e10cSrcweir 	void		UpdateAllArrowColors();		// on all tables
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	static sal_Bool	IsNonAlienArrow( SdrObject* pObject );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	ScDetectiveObjType GetDetectiveObjectType( SdrObject* pObject, SCTAB nObjTab,
149cdf0e10cSrcweir 								ScAddress& rPosition, ScRange& rSource, sal_Bool& rRedLine );
150cdf0e10cSrcweir 	void		InsertObject( ScDetectiveObjType eType, const ScAddress& rPosition,
151cdf0e10cSrcweir 								const ScRange& rSource, sal_Bool bRedLine );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	static ColorData GetArrowColor();
154cdf0e10cSrcweir 	static ColorData GetErrorColor();
155cdf0e10cSrcweir 	static ColorData GetCommentColor();
156cdf0e10cSrcweir 	static void InitializeColors();
157cdf0e10cSrcweir 	static sal_Bool	IsColorsInitialized();
158*0deba7fbSSteve Yin 	static void AppendChangTrackNoteSeparator(String &str);
159cdf0e10cSrcweir };
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 
163cdf0e10cSrcweir #endif
164