/src/libreoffice/sc/inc/detfunc.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include "address.hxx" |
23 | | #include <tools/gen.hxx> |
24 | | #include <tools/color.hxx> |
25 | | #include "scdllapi.h" |
26 | | |
27 | | #include <vector> |
28 | | |
29 | | class SdrObject; |
30 | | |
31 | | class ScDetectiveData; |
32 | | class ScDocument; |
33 | | |
34 | 0 | #define SC_DET_MAXCIRCLE 1000 |
35 | | |
36 | | enum class ScDetectiveDelete { Detective, Circles, Arrows }; |
37 | | |
38 | | enum ScDetectiveObjType |
39 | | { |
40 | | SC_DETOBJ_NONE, |
41 | | SC_DETOBJ_ARROW, |
42 | | SC_DETOBJ_FROMOTHERTAB, |
43 | | SC_DETOBJ_TOOTHERTAB, |
44 | | SC_DETOBJ_CIRCLE, |
45 | | SC_DETOBJ_RECTANGLE |
46 | | }; |
47 | | |
48 | | class ScDetectiveFunc |
49 | | { |
50 | | static Color nArrowColor; |
51 | | static Color nErrorColor; |
52 | | static Color nCommentColor; |
53 | | static bool bColorsInitialized; |
54 | | |
55 | | ScDocument& rDoc; |
56 | | SCTAB nTab; |
57 | | |
58 | | enum class DrawPosMode |
59 | | { |
60 | | TopLeft, ///< Top-left edge of the cell. |
61 | | BottomRight, ///< Bottom-right edge of the cell. |
62 | | DetectiveArrow, ///< Position inside cell for detective arrows. |
63 | | }; |
64 | | |
65 | | /** @return a drawing layer position for the passed cell address. */ |
66 | | Point GetDrawPos( SCCOL nCol, SCROW nRow, DrawPosMode eMode ) const; |
67 | | |
68 | | /** @return the drawing layer rectangle for the passed cell range. */ |
69 | | tools::Rectangle GetDrawRect( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const; |
70 | | |
71 | | /** @return the drawing layer rectangle for the passed cell address. */ |
72 | | tools::Rectangle GetDrawRect( SCCOL nCol, SCROW nRow ) const; |
73 | | |
74 | | bool HasArrow( const ScAddress& rStart, |
75 | | SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab ); |
76 | | |
77 | | void DeleteArrowsAt( SCCOL nCol, SCROW nRow, bool bDestPnt ); |
78 | | void DeleteBox( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); |
79 | | |
80 | | bool HasError( const ScRange& rRange, ScAddress& rErrPos ); |
81 | | |
82 | | /// called from DrawEntry/DrawAlienEntry and InsertObject |
83 | | void InsertArrow( SCCOL nCol, SCROW nRow, |
84 | | SCCOL nRefStartCol, SCROW nRefStartRow, |
85 | | SCCOL nRefEndCol, SCROW nRefEndRow, |
86 | | bool bFromOtherTab, bool bRed, |
87 | | ScDetectiveData& rData ); |
88 | | void InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow, |
89 | | SCCOL nEndCol, SCROW nEndRow, bool bRed, |
90 | | ScDetectiveData& rData ); |
91 | | |
92 | | /// DrawEntry / DrawAlienEntry check for existing arrows and errors |
93 | | bool DrawEntry( SCCOL nCol, SCROW nRow, const ScRange& rRef, |
94 | | ScDetectiveData& rData ); |
95 | | bool DrawAlienEntry( const ScRange& rRef, |
96 | | ScDetectiveData& rData ); |
97 | | |
98 | | void DrawCircle( SCCOL nCol, SCROW nRow, ScDetectiveData& rData ); |
99 | | |
100 | | sal_uInt16 InsertPredLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel ); |
101 | | sal_uInt16 InsertPredLevelArea( const ScRange& rRef, |
102 | | ScDetectiveData& rData, sal_uInt16 nLevel ); |
103 | | sal_uInt16 FindPredLevel( SCCOL nCol, SCROW nRow, sal_uInt16 nLevel, sal_uInt16 nDeleteLevel ); |
104 | | sal_uInt16 FindPredLevelArea( const ScRange& rRef, |
105 | | sal_uInt16 nLevel, sal_uInt16 nDeleteLevel ); |
106 | | |
107 | | sal_uInt16 InsertErrorLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel ); |
108 | | |
109 | | sal_uInt16 InsertSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, |
110 | | ScDetectiveData& rData, sal_uInt16 nLevel ); |
111 | | sal_uInt16 FindSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, |
112 | | sal_uInt16 nLevel, sal_uInt16 nDeleteLevel ); |
113 | | |
114 | | void FindFrameForObject( const SdrObject* pObject, ScRange& rRange ); |
115 | | |
116 | | void Modified(); |
117 | | |
118 | | public: |
119 | 0 | ScDetectiveFunc(ScDocument& rDocument, SCTAB nTable) : rDoc(rDocument),nTab(nTable) {} |
120 | | |
121 | | bool ShowSucc( SCCOL nCol, SCROW nRow ); |
122 | | bool ShowPred( SCCOL nCol, SCROW nRow ); |
123 | | bool ShowError( SCCOL nCol, SCROW nRow ); |
124 | | |
125 | | bool DeleteSucc( SCCOL nCol, SCROW nRow ); |
126 | | bool DeletePred( SCCOL nCol, SCROW nRow ); |
127 | | bool DeleteAll( ScDetectiveDelete eWhat ); |
128 | | SC_DLLPUBLIC bool DeleteCirclesAt( SCCOL nCol, SCROW nRow ); |
129 | | |
130 | | SC_DLLPUBLIC bool MarkInvalid(bool& rOverflow); |
131 | | |
132 | | void GetAllPreds(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ::std::vector<ScTokenRef>& rRefTokens); |
133 | | void GetAllSuccs(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ::std::vector<ScTokenRef>& rRefTokens); |
134 | | |
135 | | static void UpdateAllComments( ScDocument& rDoc ); ///< on all tables |
136 | | void UpdateAllArrowColors(); ///< on all tables |
137 | | |
138 | | static bool IsNonAlienArrow( const SdrObject* pObject ); |
139 | | |
140 | | SC_DLLPUBLIC ScDetectiveObjType GetDetectiveObjectType( SdrObject* pObject, SCTAB nObjTab, |
141 | | ScAddress& rPosition, ScRange& rSource, bool& rRedLine ); |
142 | | void InsertObject( ScDetectiveObjType eType, const ScAddress& rPosition, |
143 | | const ScRange& rSource, bool bRedLine ); |
144 | | |
145 | | static Color GetArrowColor(); |
146 | | static Color GetErrorColor(); |
147 | | static Color GetCommentColor(); |
148 | | static void InitializeColors(); |
149 | | static bool IsColorsInitialized(); |
150 | | static void AppendChangTrackNoteSeparator(OUString &str); |
151 | | }; |
152 | | |
153 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |