Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef SC_DETFUNC_HXX
21 : #define SC_DETFUNC_HXX
22 :
23 : #include "address.hxx"
24 : #include <tools/gen.hxx>
25 : #include <tools/color.hxx>
26 : #include "scdllapi.h"
27 : #include "token.hxx"
28 :
29 : #include <vector>
30 :
31 : class SdrObject;
32 :
33 : class ScDetectiveData;
34 : class ScDocument;
35 : class ScAddress;
36 : class ScRange;
37 :
38 : #define SC_DET_MAXCIRCLE 1000
39 :
40 : enum ScDetectiveDelete { SC_DET_ALL, SC_DET_DETECTIVE, SC_DET_CIRCLES, SC_DET_ARROWS };
41 :
42 : enum ScDetectiveObjType
43 : {
44 : SC_DETOBJ_NONE,
45 : SC_DETOBJ_ARROW,
46 : SC_DETOBJ_FROMOTHERTAB,
47 : SC_DETOBJ_TOOTHERTAB,
48 : SC_DETOBJ_CIRCLE
49 : };
50 :
51 : class SC_DLLPUBLIC ScDetectiveFunc
52 : {
53 : static ColorData nArrowColor;
54 : static ColorData nErrorColor;
55 : static ColorData nCommentColor;
56 : static sal_Bool bColorsInitialized;
57 :
58 : ScDocument* pDoc;
59 : SCTAB nTab;
60 :
61 : enum DrawPosMode
62 : {
63 : DRAWPOS_TOPLEFT, /// Top-left edge of the cell.
64 : DRAWPOS_BOTTOMRIGHT, /// Bottom-right edge of the cell.
65 : DRAWPOS_DETARROW, /// Position inside cell for detective arrows.
66 : DRAWPOS_CAPTIONLEFT, /// Top-left edge of the cell for captions.
67 : DRAWPOS_CAPTIONRIGHT /// Top-right edge of the cell for captions (incl. merged cells).
68 : };
69 :
70 : /** Returns a drawing layer position for the passed cell address. */
71 : Point GetDrawPos( SCCOL nCol, SCROW nRow, DrawPosMode eMode ) const;
72 :
73 : /** Returns the drawing layer rectangle for the passed cell range. */
74 : Rectangle GetDrawRect( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
75 :
76 : /** Returns the drawing layer rectangle for the passed cell address. */
77 : Rectangle GetDrawRect( SCCOL nCol, SCROW nRow ) const;
78 :
79 : sal_Bool HasArrow( const ScAddress& rStart,
80 : SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab );
81 :
82 : void DeleteArrowsAt( SCCOL nCol, SCROW nRow, sal_Bool bDestPnt );
83 : void DeleteBox( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
84 :
85 : sal_Bool HasError( const ScRange& rRange, ScAddress& rErrPos );
86 :
87 : void FillAttributes( ScDetectiveData& rData );
88 :
89 : // called from DrawEntry/DrawAlienEntry and InsertObject
90 : sal_Bool InsertArrow( SCCOL nCol, SCROW nRow,
91 : SCCOL nRefStartCol, SCROW nRefStartRow,
92 : SCCOL nRefEndCol, SCROW nRefEndRow,
93 : sal_Bool bFromOtherTab, sal_Bool bRed,
94 : ScDetectiveData& rData );
95 : sal_Bool InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow,
96 : SCCOL nEndCol, SCROW nEndRow, sal_Bool bRed,
97 : ScDetectiveData& rData );
98 :
99 : // DrawEntry / DrawAlienEntry check for existing arrows and errors
100 : sal_Bool DrawEntry( SCCOL nCol, SCROW nRow, const ScRange& rRef,
101 : ScDetectiveData& rData );
102 : sal_Bool DrawAlienEntry( const ScRange& rRef,
103 : ScDetectiveData& rData );
104 :
105 : void DrawCircle( SCCOL nCol, SCROW nRow, ScDetectiveData& rData );
106 :
107 : sal_uInt16 InsertPredLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel );
108 : sal_uInt16 InsertPredLevelArea( const ScRange& rRef,
109 : ScDetectiveData& rData, sal_uInt16 nLevel );
110 : sal_uInt16 FindPredLevel( SCCOL nCol, SCROW nRow, sal_uInt16 nLevel, sal_uInt16 nDeleteLevel );
111 : sal_uInt16 FindPredLevelArea( const ScRange& rRef,
112 : sal_uInt16 nLevel, sal_uInt16 nDeleteLevel );
113 :
114 : sal_uInt16 InsertErrorLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel );
115 :
116 : sal_uInt16 InsertSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
117 : ScDetectiveData& rData, sal_uInt16 nLevel );
118 : sal_uInt16 FindSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
119 : sal_uInt16 nLevel, sal_uInt16 nDeleteLevel );
120 :
121 : sal_Bool FindFrameForObject( SdrObject* pObject, ScRange& rRange );
122 :
123 : void Modified();
124 :
125 : public:
126 3 : ScDetectiveFunc(ScDocument* pDocument, SCTAB nTable) : pDoc(pDocument),nTab(nTable) {}
127 :
128 : sal_Bool ShowSucc( SCCOL nCol, SCROW nRow );
129 : sal_Bool ShowPred( SCCOL nCol, SCROW nRow );
130 : sal_Bool ShowError( SCCOL nCol, SCROW nRow );
131 :
132 : sal_Bool DeleteSucc( SCCOL nCol, SCROW nRow );
133 : sal_Bool DeletePred( SCCOL nCol, SCROW nRow );
134 : sal_Bool DeleteAll( ScDetectiveDelete eWhat );
135 :
136 : sal_Bool MarkInvalid(sal_Bool& rOverflow);
137 :
138 : void GetAllPreds(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ::std::vector<ScTokenRef>& rRefTokens);
139 : void GetAllSuccs(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ::std::vector<ScTokenRef>& rRefTokens);
140 :
141 : static void UpdateAllComments( ScDocument& rDoc ); // on all tables
142 : void UpdateAllArrowColors(); // on all tables
143 :
144 : static sal_Bool IsNonAlienArrow( SdrObject* pObject );
145 :
146 : ScDetectiveObjType GetDetectiveObjectType( SdrObject* pObject, SCTAB nObjTab,
147 : ScAddress& rPosition, ScRange& rSource, bool& rRedLine );
148 : void InsertObject( ScDetectiveObjType eType, const ScAddress& rPosition,
149 : const ScRange& rSource, sal_Bool bRedLine );
150 :
151 : static ColorData GetArrowColor();
152 : static ColorData GetErrorColor();
153 : static ColorData GetCommentColor();
154 : static void InitializeColors();
155 : static sal_Bool IsColorsInitialized();
156 : };
157 :
158 :
159 :
160 : #endif
161 :
162 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|