1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_INC_DETFUNC_HXX
21 #define INCLUDED_SC_INC_DETFUNC_HXX
23 #include "address.hxx"
24 #include <tools/gen.hxx>
25 #include <tools/color.hxx>
32 class ScDetectiveData
;
35 #define SC_DET_MAXCIRCLE 1000
37 enum class ScDetectiveDelete
{ Detective
, Circles
, Arrows
};
39 enum ScDetectiveObjType
43 SC_DETOBJ_FROMOTHERTAB
,
49 class SC_DLLPUBLIC ScDetectiveFunc
51 static Color nArrowColor
;
52 static Color nErrorColor
;
53 static Color nCommentColor
;
54 static bool bColorsInitialized
;
59 enum class DrawPosMode
61 TopLeft
, ///< Top-left edge of the cell.
62 BottomRight
, ///< Bottom-right edge of the cell.
63 DetectiveArrow
, ///< Position inside cell for detective arrows.
66 /** @return a drawing layer position for the passed cell address. */
67 Point
GetDrawPos( SCCOL nCol
, SCROW nRow
, DrawPosMode eMode
) const;
69 /** @return the drawing layer rectangle for the passed cell range. */
70 tools::Rectangle
GetDrawRect( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
) const;
72 /** @return the drawing layer rectangle for the passed cell address. */
73 tools::Rectangle
GetDrawRect( SCCOL nCol
, SCROW nRow
) const;
75 bool HasArrow( const ScAddress
& rStart
,
76 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nEndTab
);
78 void DeleteArrowsAt( SCCOL nCol
, SCROW nRow
, bool bDestPnt
);
79 void DeleteBox( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
);
81 bool HasError( const ScRange
& rRange
, ScAddress
& rErrPos
);
83 /// called from DrawEntry/DrawAlienEntry and InsertObject
84 void InsertArrow( SCCOL nCol
, SCROW nRow
,
85 SCCOL nRefStartCol
, SCROW nRefStartRow
,
86 SCCOL nRefEndCol
, SCROW nRefEndRow
,
87 bool bFromOtherTab
, bool bRed
,
88 ScDetectiveData
& rData
);
89 void InsertToOtherTab( SCCOL nStartCol
, SCROW nStartRow
,
90 SCCOL nEndCol
, SCROW nEndRow
, bool bRed
,
91 ScDetectiveData
& rData
);
93 /// DrawEntry / DrawAlienEntry check for existing arrows and errors
94 bool DrawEntry( SCCOL nCol
, SCROW nRow
, const ScRange
& rRef
,
95 ScDetectiveData
& rData
);
96 bool DrawAlienEntry( const ScRange
& rRef
,
97 ScDetectiveData
& rData
);
99 void DrawCircle( SCCOL nCol
, SCROW nRow
, ScDetectiveData
& rData
);
101 sal_uInt16
InsertPredLevel( SCCOL nCol
, SCROW nRow
, ScDetectiveData
& rData
, sal_uInt16 nLevel
);
102 sal_uInt16
InsertPredLevelArea( const ScRange
& rRef
,
103 ScDetectiveData
& rData
, sal_uInt16 nLevel
);
104 sal_uInt16
FindPredLevel( SCCOL nCol
, SCROW nRow
, sal_uInt16 nLevel
, sal_uInt16 nDeleteLevel
);
105 sal_uInt16
FindPredLevelArea( const ScRange
& rRef
,
106 sal_uInt16 nLevel
, sal_uInt16 nDeleteLevel
);
108 sal_uInt16
InsertErrorLevel( SCCOL nCol
, SCROW nRow
, ScDetectiveData
& rData
, sal_uInt16 nLevel
);
110 sal_uInt16
InsertSuccLevel( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
111 ScDetectiveData
& rData
, sal_uInt16 nLevel
);
112 sal_uInt16
FindSuccLevel( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
113 sal_uInt16 nLevel
, sal_uInt16 nDeleteLevel
);
115 void FindFrameForObject( const SdrObject
* pObject
, ScRange
& rRange
);
120 ScDetectiveFunc(ScDocument
& rDocument
, SCTAB nTable
) : rDoc(rDocument
),nTab(nTable
) {}
122 bool ShowSucc( SCCOL nCol
, SCROW nRow
);
123 bool ShowPred( SCCOL nCol
, SCROW nRow
);
124 bool ShowError( SCCOL nCol
, SCROW nRow
);
126 bool DeleteSucc( SCCOL nCol
, SCROW nRow
);
127 bool DeletePred( SCCOL nCol
, SCROW nRow
);
128 bool DeleteAll( ScDetectiveDelete eWhat
);
129 bool DeleteCirclesAt( SCCOL nCol
, SCROW nRow
);
131 bool MarkInvalid(bool& rOverflow
);
133 void GetAllPreds(SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
, ::std::vector
<ScTokenRef
>& rRefTokens
);
134 void GetAllSuccs(SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
, ::std::vector
<ScTokenRef
>& rRefTokens
);
136 static void UpdateAllComments( ScDocument
& rDoc
); ///< on all tables
137 void UpdateAllArrowColors(); ///< on all tables
139 static bool IsNonAlienArrow( const SdrObject
* pObject
);
141 ScDetectiveObjType
GetDetectiveObjectType( SdrObject
* pObject
, SCTAB nObjTab
,
142 ScAddress
& rPosition
, ScRange
& rSource
, bool& rRedLine
);
143 void InsertObject( ScDetectiveObjType eType
, const ScAddress
& rPosition
,
144 const ScRange
& rSource
, bool bRedLine
);
146 static Color
GetArrowColor();
147 static Color
GetErrorColor();
148 static Color
GetCommentColor();
149 static void InitializeColors();
150 static bool IsColorsInitialized();
151 static void AppendChangTrackNoteSeparator(OUString
&str
);
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */