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>
33 class ScDetectiveData
;
38 #define SC_DET_MAXCIRCLE 1000
40 enum class ScDetectiveDelete
{ Detective
, Circles
, Arrows
};
42 enum ScDetectiveObjType
46 SC_DETOBJ_FROMOTHERTAB
,
51 class SC_DLLPUBLIC ScDetectiveFunc
53 static ColorData nArrowColor
;
54 static ColorData nErrorColor
;
55 static ColorData nCommentColor
;
56 static bool bColorsInitialized
;
61 enum class DrawPosMode
63 TopLeft
, ///< Top-left edge of the cell.
64 BottomRight
, ///< Bottom-right edge of the cell.
65 DetectiveArrow
, ///< Position inside cell for detective arrows.
68 /** @return a drawing layer position for the passed cell address. */
69 Point
GetDrawPos( SCCOL nCol
, SCROW nRow
, DrawPosMode eMode
) const;
71 /** @return the drawing layer rectangle for the passed cell range. */
72 tools::Rectangle
GetDrawRect( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
) const;
74 /** @return the drawing layer rectangle for the passed cell address. */
75 tools::Rectangle
GetDrawRect( SCCOL nCol
, SCROW nRow
) const;
77 bool HasArrow( const ScAddress
& rStart
,
78 SCCOL nEndCol
, SCROW nEndRow
, SCTAB nEndTab
);
80 void DeleteArrowsAt( SCCOL nCol
, SCROW nRow
, bool bDestPnt
);
81 void DeleteBox( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
);
83 bool HasError( const ScRange
& rRange
, ScAddress
& rErrPos
);
85 /// called from DrawEntry/DrawAlienEntry and InsertObject
86 bool InsertArrow( SCCOL nCol
, SCROW nRow
,
87 SCCOL nRefStartCol
, SCROW nRefStartRow
,
88 SCCOL nRefEndCol
, SCROW nRefEndRow
,
89 bool bFromOtherTab
, bool bRed
,
90 ScDetectiveData
& rData
);
91 bool InsertToOtherTab( SCCOL nStartCol
, SCROW nStartRow
,
92 SCCOL nEndCol
, SCROW nEndRow
, bool bRed
,
93 ScDetectiveData
& rData
);
95 /// DrawEntry / DrawAlienEntry check for existing arrows and errors
96 bool DrawEntry( SCCOL nCol
, SCROW nRow
, const ScRange
& rRef
,
97 ScDetectiveData
& rData
);
98 bool DrawAlienEntry( const ScRange
& rRef
,
99 ScDetectiveData
& rData
);
101 void DrawCircle( SCCOL nCol
, SCROW nRow
, ScDetectiveData
& rData
);
103 sal_uInt16
InsertPredLevel( SCCOL nCol
, SCROW nRow
, ScDetectiveData
& rData
, sal_uInt16 nLevel
);
104 sal_uInt16
InsertPredLevelArea( const ScRange
& rRef
,
105 ScDetectiveData
& rData
, sal_uInt16 nLevel
);
106 sal_uInt16
FindPredLevel( SCCOL nCol
, SCROW nRow
, sal_uInt16 nLevel
, sal_uInt16 nDeleteLevel
);
107 sal_uInt16
FindPredLevelArea( const ScRange
& rRef
,
108 sal_uInt16 nLevel
, sal_uInt16 nDeleteLevel
);
110 sal_uInt16
InsertErrorLevel( SCCOL nCol
, SCROW nRow
, ScDetectiveData
& rData
, sal_uInt16 nLevel
);
112 sal_uInt16
InsertSuccLevel( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
113 ScDetectiveData
& rData
, sal_uInt16 nLevel
);
114 sal_uInt16
FindSuccLevel( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
115 sal_uInt16 nLevel
, sal_uInt16 nDeleteLevel
);
117 void FindFrameForObject( const SdrObject
* pObject
, ScRange
& rRange
);
122 ScDetectiveFunc(ScDocument
* pDocument
, SCTAB nTable
) : pDoc(pDocument
),nTab(nTable
) {}
124 bool ShowSucc( SCCOL nCol
, SCROW nRow
);
125 bool ShowPred( SCCOL nCol
, SCROW nRow
);
126 bool ShowError( SCCOL nCol
, SCROW nRow
);
128 bool DeleteSucc( SCCOL nCol
, SCROW nRow
);
129 bool DeletePred( SCCOL nCol
, SCROW nRow
);
130 bool DeleteAll( ScDetectiveDelete eWhat
);
132 bool MarkInvalid(bool& rOverflow
);
134 void GetAllPreds(SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
, ::std::vector
<ScTokenRef
>& rRefTokens
);
135 void GetAllSuccs(SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
, ::std::vector
<ScTokenRef
>& rRefTokens
);
137 static void UpdateAllComments( ScDocument
& rDoc
); ///< on all tables
138 void UpdateAllArrowColors(); ///< on all tables
140 static bool IsNonAlienArrow( const SdrObject
* pObject
);
142 ScDetectiveObjType
GetDetectiveObjectType( SdrObject
* pObject
, SCTAB nObjTab
,
143 ScAddress
& rPosition
, ScRange
& rSource
, bool& rRedLine
);
144 void InsertObject( ScDetectiveObjType eType
, const ScAddress
& rPosition
,
145 const ScRange
& rSource
, bool bRedLine
);
147 static ColorData
GetArrowColor();
148 static ColorData
GetErrorColor();
149 static ColorData
GetCommentColor();
150 static void InitializeColors();
151 static bool IsColorsInitialized();
152 static void AppendChangTrackNoteSeparator(OUString
&str
);
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */