48#include <osl/diagnose.h>
56#include <document.hxx>
156 const OUString
aName;
192 return nEndCol1 >= nStartCol2 && nEndCol2 >= nStartCol1 &&
193 nEndRow1 >= nStartRow2 && nEndRow2 >= nStartRow1;
202 for (
bool bHasCell = aIter.
first(); bHasCell; bHasCell = aIter.
next())
208 if (nError != FormulaError::NONE)
212 return (nError != FormulaError::NONE);
217 OSL_ENSURE(
rDoc.
ValidColRow( nCol, nRow ),
"ScDetectiveFunc::GetDrawPos - invalid cell address" );
245 aPos.
setX( aPos.
X() * -1 );
267 if(1 == rPolyPolygon.
count())
285 bool bStartAlien = ( rStart.
Tab() !=
nTab );
286 bool bEndAlien = ( nEndTab !=
nTab );
288 if (bStartAlien && bEndAlien)
290 OSL_FAIL(
"bStartAlien && bEndAlien");
303 OSL_ENSURE(pPage,
"Page ?");
315 bool bObjStartAlien =
320 bool bStartHit = bStartAlien ? bObjStartAlien :
322 bool bEndHit = bEndAlien ? bObjEndAlien :
325 if ( bStartHit && bEndHit )
341 bool bObjStartAlien =
346 return !bObjStartAlien && !bObjEndAlien;
357 bool bFromOtherTab,
bool bRed,
363 bool bArea = ( nRefStartCol != nRefEndCol || nRefStartRow != nRefEndRow );
364 if (bArea && !bFromOtherTab)
373 pBox->NbcSetStyleSheet(
nullptr,
true);
374 pBox->SetMergedItemSetAndBroadcast(rData.
GetBoxSet());
378 pModel->
AddCalcUndo( std::make_unique<SdrUndoInsertObj>( *pBox ) );
381 pData->maStart.Set( nRefStartCol, nRefStartRow,
nTab);
382 pData->maEnd.Set( nRefEndCol, nRefEndRow,
nTab);
393 aStartPos =
Point( aEndPos.
X() - 1000 * nPageSign, aEndPos.
Y() - 1000 );
394 if (aStartPos.
X() * nPageSign < 0)
395 aStartPos.
AdjustX(2000 * nPageSign );
396 if (aStartPos.
Y() < 0)
402 if (bArea && !bFromOtherTab)
417 pArrow->NbcSetStyleSheet(
nullptr,
true);
419 pArrow->SetMergedItemSetAndBroadcast(rAttrSet);
423 pModel->
AddCalcUndo( std::make_unique<SdrUndoInsertObj>( *pArrow ) );
427 pData->maStart.SetInvalid();
429 pData->maStart.Set( nRefStartCol, nRefStartRow,
nTab);
444 bool bArea = ( nStartCol != nEndCol || nStartRow != nEndRow );
452 pBox->NbcSetStyleSheet(
nullptr,
true);
453 pBox->SetMergedItemSetAndBroadcast(rData.
GetBoxSet());
457 pModel->
AddCalcUndo( std::make_unique<SdrUndoInsertObj>( *pBox ) );
460 pData->maStart.Set( nStartCol, nStartRow,
nTab);
461 pData->maEnd.Set( nEndCol, nEndRow,
nTab);
468 Point aEndPos( aStartPos.
X() + 1000 * nPageSign, aStartPos.
Y() - 1000 );
488 pArrow->NbcSetStyleSheet(
nullptr,
true);
491 pArrow->SetMergedItemSetAndBroadcast(rAttrSet);
495 pModel->
AddCalcUndo( std::make_unique<SdrUndoInsertObj>( *pArrow ) );
498 pData->maStart.Set( nStartCol, nStartRow,
nTab);
499 pData->maEnd.SetInvalid();
519 bool bError =
HasError( rRef, aErrorPos );
525 bAlien, bError, rData );
536 bool bError =
HasError( rRef, aErrorPos );
561 pCircle->NbcSetStyleSheet(
nullptr,
true);
562 pCircle->SetMergedItemSetAndBroadcast(rAttrSet);
566 pModel->
AddCalcUndo( std::make_unique<SdrUndoInsertObj>( *pCircle ) );
570 pData->maEnd.SetInvalid();
582 OSL_ENSURE(pPage,
"Page ?");
590 size_t nDelCount = 0;
591 std::unique_ptr<SdrObject*[]> ppObj(
new SdrObject*[nObjCount]);
611 for (
size_t i=1;
i<=nDelCount; ++
i)
612 pModel->
AddCalcUndo(std::make_unique<SdrUndoDelObj>(*ppObj[nDelCount-
i]));
615 for (
size_t i=1;
i<=nDelCount; ++
i)
628#define SC_DET_TOLERANCE 50
642#undef SC_DET_TOLERANCE
653 OSL_ENSURE(pPage,
"Page ?");
661 size_t nDelCount = 0;
662 std::unique_ptr<SdrObject*[]> ppObj(
new SdrObject*[nObjCount]);
671 aObjRect = pSdrRectObj->GetLogicRect();
673 if (
RectIsPoints( aObjRect, aStartCorner, aEndCorner ) )
680 for (
size_t i=1;
i<=nDelCount; ++
i)
681 pModel->
AddCalcUndo( std::make_unique<SdrUndoRemoveObj>( *ppObj[nDelCount-
i] ) );
683 for (
size_t i=1;
i<=nDelCount; ++
i)
694 sal_uInt16 nResult = DET_INS_EMPTY;
697 for (
bool bHasCell = aIter.
first(); bHasCell; bHasCell = aIter.
next())
705 case DET_INS_INSERTED:
706 nResult = DET_INS_INSERTED;
708 case DET_INS_CONTINUE:
709 if (nResult != DET_INS_INSERTED)
710 nResult = DET_INS_CONTINUE;
712 case DET_INS_CIRCULAR:
713 if (nResult == DET_INS_EMPTY)
714 nResult = DET_INS_CIRCULAR;
729 return DET_INS_EMPTY;
733 return DET_INS_CIRCULAR;
739 sal_uInt16 nResult = DET_INS_EMPTY;
745 if (
DrawEntry( nCol, nRow, aRef, rData ))
747 nResult = DET_INS_INSERTED;
755 sal_uInt16 nSubResult;
765 case DET_INS_INSERTED:
766 nResult = DET_INS_INSERTED;
768 case DET_INS_CONTINUE:
769 if (nResult != DET_INS_INSERTED)
770 nResult = DET_INS_CONTINUE;
772 case DET_INS_CIRCULAR:
773 if (nResult == DET_INS_EMPTY)
774 nResult = DET_INS_CIRCULAR;
780 if (nResult != DET_INS_INSERTED)
781 nResult = DET_INS_CONTINUE;
791 sal_uInt16 nLevel, sal_uInt16 nDeleteLevel )
793 sal_uInt16 nResult = nLevel;
796 for (
bool bHasCell = aCellIter.
first(); bHasCell; bHasCell = aCellIter.
next())
813 OSL_ENSURE( nLevel<1000,
"Level" );
827 sal_uInt16 nResult = nLevel;
828 bool bDelete = ( nDeleteLevel && nLevel == nDeleteLevel-1 );
857 nLevel+1, nDeleteLevel );
874 return DET_INS_EMPTY;
878 return DET_INS_CIRCULAR;
884 sal_uInt16 nResult = DET_INS_EMPTY;
889 bool bHasError =
false;
896 nResult = DET_INS_INSERTED;
901 rData, nLevel+1 ) == DET_INS_INSERTED)
902 nResult = DET_INS_INSERTED;
912 nResult = DET_INS_INSERTED;
922 sal_uInt16 nResult = DET_INS_EMPTY;
924 for (
bool bHas = aCellIter.
first(); bHas; bHas = aCellIter.
next())
955 nResult = DET_INS_INSERTED;
961 if (nResult == DET_INS_EMPTY)
962 nResult = DET_INS_CIRCULAR;
975 case DET_INS_INSERTED:
976 nResult = DET_INS_INSERTED;
978 case DET_INS_CONTINUE:
979 if (nResult != DET_INS_INSERTED)
980 nResult = DET_INS_CONTINUE;
982 case DET_INS_CIRCULAR:
983 if (nResult == DET_INS_EMPTY)
984 nResult = DET_INS_CIRCULAR;
990 if (nResult != DET_INS_INSERTED)
991 nResult = DET_INS_CONTINUE;
1004 sal_uInt16 nLevel, sal_uInt16 nDeleteLevel )
1006 OSL_ENSURE( nLevel<1000,
"Level" );
1008 sal_uInt16 nResult = nLevel;
1009 bool bDelete = ( nDeleteLevel && nLevel == nDeleteLevel-1 );
1012 for (
bool bHas = aCellIter.
first(); bHas; bHas = aCellIter.
next())
1043 else if ( !bRunning &&
1049 nLevel+1, nDeleteLevel );
1050 if (nTemp > nResult)
1071 sal_uInt16 nMaxLevel = 0;
1072 sal_uInt16 nResult = DET_INS_CONTINUE;
1073 while (nResult == DET_INS_CONTINUE && nMaxLevel < 1000)
1075 aData.SetMaxLevel( nMaxLevel );
1080 return ( nResult == DET_INS_INSERTED );
1091 sal_uInt16 nMaxLevel = 0;
1092 sal_uInt16 nResult = DET_INS_CONTINUE;
1093 while (nResult == DET_INS_CONTINUE && nMaxLevel < 1000)
1095 aData.SetMaxLevel( nMaxLevel );
1100 return ( nResult == DET_INS_INSERTED );
1116 aData.SetMaxLevel( 1000 );
1119 return ( nResult == DET_INS_INSERTED );
1128 sal_uInt16 nLevelCount =
FindSuccLevel( nCol, nRow, nCol, nRow, 0, 0 );
1132 return ( nLevelCount != 0 );
1145 return ( nLevelCount != 0 );
1164 OSL_ENSURE(pPage,
"Page ?");
1169 size_t nDelCount = 0;
1172 std::unique_ptr<SdrObject*[]> ppObj(
new SdrObject*[nObjCount]);
1189 for (
size_t i = 1;
i <= nDelCount; ++
i)
1190 pModel->
AddCalcUndo(std::make_unique<SdrUndoRemoveObj>(*ppObj[nDelCount -
i]));
1192 for (
size_t i = 1;
i <= nDelCount; ++
i)
1200 return (nDelCount != 0);
1210 OSL_ENSURE(pPage,
"Page ?");
1214 size_t nDelCount = 0;
1218 std::unique_ptr<SdrObject*[]> ppObj(
new SdrObject*[nObjCount]);
1226 bool bDoThis =
true;
1230 bDoThis = !bCaption;
1234 bDoThis = !bCaption && !bCircle;
1246 for (
size_t i=1;
i<=nDelCount; ++
i)
1247 pModel->
AddCalcUndo( std::make_unique<SdrUndoRemoveObj>( *ppObj[nDelCount-
i] ) );
1249 for (
size_t i=1;
i<=nDelCount; ++
i)
1257 return ( nDelCount != 0 );
1288 bool bMarkEmpty = !
pData->IsIgnoreBlank();
1289 SCROW nNextRow = nRow1;
1296 for ( nRow = nNextRow; nRow < nCellRow && nInsCount <
SC_DET_MAXCIRCLE; nRow++ )
1303 if (!
pData->IsDataValid(aCell, aCellIter.
GetPos()))
1309 nNextRow = nCellRow + 1;
1312 for ( nRow = nNextRow; nRow <= nRow2 && nInsCount <
SC_DET_MAXCIRCLE; nRow++ )
1321 pPattern = aAttrIter.
GetNext( nCol, nRow1, nRow2 );
1327 return ( bDeleted || nInsCount != 0 );
1331 vector<ScTokenRef>& rRefTokens)
1334 for (
bool bHas = aIter.
first(); bHas; bHas = aIter.
next())
1350 vector<ScTokenRef>& rRefTokens)
1352 vector<ScTokenRef> aSrcRange;
1353 aSrcRange.push_back(
1357 for (
bool bHas = aIter.
first(); bHas; bHas = aIter.
next())
1391 auto&
rSet = pStyleSheet->GetItemSet();
1400 std::make_unique<ScUndoModifyStyle>(pDocSh, pStyleSheet->GetFamily(), aOldData, aNewData));
1413 SdrPage* pPage = pModel->
GetPage(
static_cast< sal_uInt16
>( nObjTab ) );
1414 OSL_ENSURE( pPage,
"Page ?" );
1422 bool bArrow =
false;
1423 bool bError =
false;
1434 if (
HasError( aSource, aErrPos ) )
1467 if ( bArrow || bError )
1487 if (!pModel)
return;
1490 OSL_ENSURE(pPage,
"Page ?");
1494 if( !(
pObject &&
pObject->getSdrPageFromSdrObject() && (
pObject->getSdrPageFromSdrObject() ==
pObject->getParentSdrObjListFromSdrObject()->getSdrPageFromSdrObjList())) )
1498 const size_t nOrdNum =
pObject->GetOrdNum();
1526 bool bValidStart =
pData->maStart.IsValid();
1527 bool bValidEnd =
pData->maEnd.IsValid();
1535 else if ( bValidEnd )
1539 rSource =
pData->maStart;
1541 rPosition =
pData->maEnd;
1559 rPosition =
pData->maStart;
1568 rPosition =
pData->maStart;
1583 if (!pModel)
return;
1650 rDisplay +=
"\n--------\n";
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
Walk through all cells in an area.
ScFormulaCell * getFormulaCell()
const ScAddress & GetPos() const
const ScRefCellValue & getRefCellValue() const
ScDetectiveData(SdrModel *pModel)
sal_uInt16 GetMaxLevel() const
SfxItemSet & GetToTabSet()
SfxItemSet & GetCircleSet()
SfxItemSet & GetFromTabSet()
void SetMaxLevel(sal_uInt16 nVal)
SfxItemSet & GetArrowSet()
bool DrawAlienEntry(const ScRange &rRef, ScDetectiveData &rData)
static void InitializeColors()
sal_uInt16 FindPredLevelArea(const ScRange &rRef, sal_uInt16 nLevel, sal_uInt16 nDeleteLevel)
bool DeleteSucc(SCCOL nCol, SCROW nRow)
bool ShowError(SCCOL nCol, SCROW nRow)
bool ShowPred(SCCOL nCol, SCROW nRow)
void DrawCircle(SCCOL nCol, SCROW nRow, ScDetectiveData &rData)
bool HasError(const ScRange &rRange, ScAddress &rErrPos)
static void UpdateAllComments(ScDocument &rDoc)
on all tables
void DeleteArrowsAt(SCCOL nCol, SCROW nRow, bool bDestPnt)
static Color GetArrowColor()
static bool IsColorsInitialized()
void UpdateAllArrowColors()
on all tables
sal_uInt16 FindSuccLevel(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sal_uInt16 nLevel, sal_uInt16 nDeleteLevel)
tools::Rectangle GetDrawRect(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
sal_uInt16 InsertErrorLevel(SCCOL nCol, SCROW nRow, ScDetectiveData &rData, sal_uInt16 nLevel)
bool DeletePred(SCCOL nCol, SCROW nRow)
bool DeleteAll(ScDetectiveDelete eWhat)
bool HasArrow(const ScAddress &rStart, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab)
void FindFrameForObject(const SdrObject *pObject, ScRange &rRange)
static bool IsNonAlienArrow(const SdrObject *pObject)
static void AppendChangTrackNoteSeparator(OUString &str)
sal_uInt16 FindPredLevel(SCCOL nCol, SCROW nRow, sal_uInt16 nLevel, sal_uInt16 nDeleteLevel)
bool DrawEntry(SCCOL nCol, SCROW nRow, const ScRange &rRef, ScDetectiveData &rData)
DrawEntry / DrawAlienEntry check for existing arrows and errors.
void InsertArrow(SCCOL nCol, SCROW nRow, SCCOL nRefStartCol, SCROW nRefStartRow, SCCOL nRefEndCol, SCROW nRefEndRow, bool bFromOtherTab, bool bRed, ScDetectiveData &rData)
called from DrawEntry/DrawAlienEntry and InsertObject
void InsertObject(ScDetectiveObjType eType, const ScAddress &rPosition, const ScRange &rSource, bool bRedLine)
void GetAllSuccs(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ::std::vector< ScTokenRef > &rRefTokens)
bool MarkInvalid(bool &rOverflow)
bool ShowSucc(SCCOL nCol, SCROW nRow)
sal_uInt16 InsertPredLevel(SCCOL nCol, SCROW nRow, ScDetectiveData &rData, sal_uInt16 nLevel)
void GetAllPreds(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ::std::vector< ScTokenRef > &rRefTokens)
void DeleteBox(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
void InsertToOtherTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bRed, ScDetectiveData &rData)
@ BottomRight
Bottom-right edge of the cell.
@ TopLeft
Top-left edge of the cell.
@ DetectiveArrow
Position inside cell for detective arrows.
ScDetectiveObjType GetDetectiveObjectType(SdrObject *pObject, SCTAB nObjTab, ScAddress &rPosition, ScRange &rSource, bool &rRedLine)
static Color GetErrorColor()
static Color nCommentColor
Point GetDrawPos(SCCOL nCol, SCROW nRow, DrawPosMode eMode) const
static bool bColorsInitialized
sal_uInt16 InsertSuccLevel(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScDetectiveData &rData, sal_uInt16 nLevel)
sal_uInt16 InsertPredLevelArea(const ScRange &rRef, ScDetectiveData &rData, sal_uInt16 nLevel)
bool DeleteCirclesAt(SCCOL nCol, SCROW nRow)
static Color GetCommentColor()
Iterator for references in a formula cell.
bool GetNextRef(ScRange &rRange)
formula::FormulaToken * GetNextRefToken()
const ScPatternAttr * GetNext(SCCOL &rCol, SCROW &rRow1, SCROW &rRow2)
virtual SfxUndoManager * GetUndoManager() override
SCROW SanitizeRow(SCROW nRow) const
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC const ScValidationData * GetValidationEntry(sal_uInt32 nIndex) const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
void SetStreamValid(SCTAB nTab, bool bSet, bool bIgnoreLock=false)
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
SfxObjectShell * GetDocumentShell() const
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
SCCOL SanitizeCol(SCCOL nCol) const
SC_DLLPUBLIC SCTAB GetTableCount() const
bool ValidColRow(SCCOL nCol, SCROW nRow) const
static ScDrawObjData * GetObjDataTab(SdrObject *pObj, SCTAB nTab)
static tools::Rectangle GetCellRect(const ScDocument &rDoc, const ScAddress &rPos, bool bMergedCell)
Returns the rectangle for the passed cell address in 1/100 mm.
static ScDrawObjData * GetObjData(SdrObject *pObj, bool bCreate=false)
static bool IsNoteCaption(SdrObject *pObj)
Returns true, if the passed object is the caption of a cell note.
void AddCalcUndo(std::unique_ptr< SdrUndoAction > pUndo)
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
void InitFromStyle(const SfxStyleSheetBase *pSource)
const SdrPage * GetPage(sal_uInt16 nPgNum) const
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
virtual rtl::Reference< SdrObject > RemoveObject(size_t nObjNum)
const SfxPoolItem & GetMergedItem(const sal_uInt16 nWhich) const
virtual SdrLayerID GetLayer() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
bool areControlPointsUsed() const
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void setClosed(bool bNew)
static bool lcl_HasThickLine(const SdrObject &rObj)
static bool lcl_IsOtherTab(const basegfx::B2DPolyPolygon &rPolyPolygon)
static bool Intersect(SCCOL nStartCol1, SCROW nStartRow1, SCCOL nEndCol1, SCROW nEndRow1, SCCOL nStartCol2, SCROW nStartRow2, SCCOL nEndCol2, SCROW nEndRow2)
static bool RectIsPoints(const tools::Rectangle &rRect, const Point &rStart, const Point &rEnd)
EmbeddedObjectRef * pObject
constexpr SdrLayerID SC_LAYER_INTERN(2)
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
ScTokenRef createRefToken(const ScDocument &rDoc, const ScAddress &rAddr)
bool SC_DLLPUBLIC intersects(const ScDocument *pDoc, const ::std::vector< ScTokenRef > &rTokens, const ScTokenRef &pToken, const ScAddress &rPos)
void SC_DLLPUBLIC join(const ScDocument *pDoc, ::std::vector< ScTokenRef > &rTokens, const ScTokenRef &pToken, const ScAddress &rPos)
B2DPolygon createPolygonFromEllipse(const B2DPoint &rCenter, double fRadiusX, double fRadiusY, sal_uInt32 nStartQuadrant=0)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
These need to be in global namespace just like their respective types are.
OUString ScResId(TranslateId aId)
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALIDDATA(153)
This is very similar to ScCellValue, except that it references the original value instead of copying ...
ScFormulaCell * getFormula() const
constexpr sal_uInt16 SDRATTR_START(XATTR_START)
constexpr sal_uInt16 SDRATTR_END(SDRATTR_WRITINGMODE2_LAST)
::boost::intrusive_ptr< formula::FormulaToken > ScTokenRef
constexpr TypedWhichId< XLineColorItem > XATTR_LINECOLOR(XATTR_LINE_FIRST+3)
constexpr TypedWhichId< XLineWidthItem > XATTR_LINEWIDTH(XATTR_LINE_FIRST+2)
constexpr TypedWhichId< XLineEndItem > XATTR_LINEEND(XATTR_LINE_FIRST+5)
constexpr TypedWhichId< XLineStartItem > XATTR_LINESTART(XATTR_LINE_FIRST+4)