[Libreoffice-commits] core.git: Branch 'feature/sc-notes-storage' - sc/inc sc/source
Laurent Godard
lgodard.libre at laposte.net
Tue Sep 17 03:42:12 PDT 2013
sc/inc/clipcontext.hxx | 2 +
sc/inc/column.hxx | 30 +++++++--------
sc/inc/mtvelements.hxx | 3 +
sc/source/core/data/clipcontext.cxx | 10 ++++-
sc/source/core/data/column.cxx | 48 ++++++++++++++++++++----
sc/source/core/data/column3.cxx | 70 ++++++++++++++++++++++++++++++++++++
sc/source/core/data/table2.cxx | 45 ++++++++++-------------
7 files changed, 159 insertions(+), 49 deletions(-)
New commits:
commit 01b9b4e09fdd9b306d617cdb37d82f48df6d60fe
Author: Laurent Godard <lgodard.libre at laposte.net>
Date: Tue Sep 17 12:40:47 2013 +0200
notes & clipboard
still not working at this stage, at least it builds
Change-Id: Ic2deabe2e35ff9e09146a75396f1dda76929864b
diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index 8a847bd..dd63ba6 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -46,6 +46,7 @@ class CopyFromClipContext : public ClipContextBase
sal_uInt16 mnInsertFlag;
bool mbAsLink:1;
bool mbSkipAttrForEmptyCells:1;
+ bool mbCloneNotes;
CopyFromClipContext(); // disabled
@@ -66,6 +67,7 @@ public:
sal_uInt16 getInsertFlag() const;
bool isAsLink() const;
bool isSkipAttrForEmptyCells() const;
+ bool isCloneNotes() const;
};
class CopyToClipContext : public ClipContextBase
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 75270d6..6c01bb2 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -208,22 +208,20 @@ public:
bool IsAllAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW nEndRow ) const;
bool TestInsertCol( SCROW nStartRow, SCROW nEndRow) const;
- bool TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const;
- void InsertRow( SCROW nStartRow, SCSIZE nSize );
- void DeleteRow( SCROW nStartRow, SCSIZE nSize );
- void DeleteArea(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nDelFlag );
- void CopyToClip(
- sc::CopyToClipContext& rCxt, SCROW nRow1, SCROW nRow2, ScColumn& rColumn ) const;
- void CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol);
- void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDestCol );
- bool InitBlockPosition( sc::ColumnBlockPosition& rBlockPos );
- bool InitBlockPosition( sc::ColumnBlockConstPosition& rBlockPos ) const;
- void CopyFromClip(
- sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, long nDy, ScColumn& rColumn );
-
- void StartListeningInArea( sc::StartListeningContext& rCxt, SCROW nRow1, SCROW nRow2 );
-
- void RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow );
+ bool TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const;
+ void InsertRow( SCROW nStartRow, SCSIZE nSize );
+ void DeleteRow( SCROW nStartRow, SCSIZE nSize );
+ void DeleteArea(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nDelFlag );
+ void CopyToClip( sc::CopyToClipContext& rCxt, SCROW nRow1, SCROW nRow2, ScColumn& rColumn ) const;
+ void CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol);
+ void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDestCol );
+ bool InitBlockPosition( sc::ColumnBlockPosition& rBlockPos );
+ bool InitBlockPosition( sc::ColumnBlockConstPosition& rBlockPos ) const;
+ void CopyFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, long nDy, ScColumn& rColumn );
+
+ void StartListeningInArea( sc::StartListeningContext& rCxt, SCROW nRow1, SCROW nRow2 );
+
+ void RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow );
// Selection (?) of this document
void MixMarked(
diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx
index f7dd3cb..818be1b 100644
--- a/sc/inc/mtvelements.hxx
+++ b/sc/inc/mtvelements.hxx
@@ -118,6 +118,7 @@ struct ColumnBlockPosition
CellStoreType::iterator miCellPos;
ColumnBlockPosition(): miCellPos() {}
+
};
struct ColumnBlockConstPosition
@@ -128,6 +129,7 @@ struct ColumnBlockConstPosition
CellStoreType::const_iterator miCellPos;
ColumnBlockConstPosition(): miCellPos() {}
+
};
class ColumnBlockPositionSet
@@ -142,6 +144,7 @@ public:
ColumnBlockPositionSet(ScDocument& rDoc);
ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
+
};
}
diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx
index 782c0f9..8013684 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -29,7 +29,10 @@ CopyFromClipContext::CopyFromClipContext(ScDocument& rDoc,
ClipContextBase(rDoc),
mnTabStart(-1), mnTabEnd(-1),
mpRefUndoDoc(pRefUndoDoc), mpClipDoc(pClipDoc), mnInsertFlag(nInsertFlag),
- mbAsLink(bAsLink), mbSkipAttrForEmptyCells(bSkipAttrForEmptyCells) {}
+ mbAsLink(bAsLink), mbSkipAttrForEmptyCells(bSkipAttrForEmptyCells),
+ mbCloneNotes (mnInsertFlag & (IDF_NOTE|IDF_ADDNOTES) )
+{
+}
CopyFromClipContext::~CopyFromClipContext()
{
@@ -76,6 +79,11 @@ bool CopyFromClipContext::isSkipAttrForEmptyCells() const
return mbSkipAttrForEmptyCells;
}
+bool CopyFromClipContext::isCloneNotes() const
+{
+ return mbCloneNotes;
+}
+
CopyToClipContext::CopyToClipContext(
ScDocument& rDoc, bool bKeepScenarioFlags, bool bCloneNotes) :
ClipContextBase(rDoc), mbKeepScenarioFlags(bKeepScenarioFlags), mbCloneNotes(bCloneNotes) {}
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 3018747..1ade76b 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1263,6 +1263,7 @@ class CopyToClipHandler
ScColumn& mrDestCol;
sc::ColumnBlockPosition maDestPos;
sc::ColumnBlockPosition* mpDestPos;
+ bool mbCopyNotes;
void setDefaultAttrsToDest(size_t nRow, size_t nSize)
{
@@ -1302,8 +1303,8 @@ class CopyToClipHandler
}
public:
- CopyToClipHandler(const ScColumn& rSrcCol, ScColumn& rDestCol, sc::ColumnBlockPosition* pDestPos) :
- mrSrcCol(rSrcCol), mrDestCol(rDestCol), mpDestPos(pDestPos)
+ CopyToClipHandler(const ScColumn& rSrcCol, ScColumn& rDestCol, sc::ColumnBlockPosition* pDestPos, bool bCopyNotes) :
+ mrSrcCol(rSrcCol), mrDestCol(rDestCol), mpDestPos(pDestPos), mbCopyNotes(bCopyNotes)
{
if (mpDestPos)
maDestPos = *mpDestPos;
@@ -1321,6 +1322,8 @@ public:
{
size_t nTopRow = aNode.position + nOffset;
+ bool isSupportedNodeType = false;
+
switch (aNode.type)
{
case sc::element_type_numeric:
@@ -1330,7 +1333,9 @@ public:
sc::numeric_block::const_iterator itEnd = it;
std::advance(itEnd, nDataSize);
maDestPos.miCellPos = mrDestCol.GetCellStore().set(maDestPos.miCellPos, nTopRow, it, itEnd);
- setDefaultAttrsToDest(nTopRow, nDataSize);
+
+ isSupportedNodeType = true;
+
}
break;
case sc::element_type_string:
@@ -1340,7 +1345,9 @@ public:
sc::string_block::const_iterator itEnd = it;
std::advance(itEnd, nDataSize);
maDestPos.miCellPos = mrDestCol.GetCellStore().set(maDestPos.miCellPos, nTopRow, it, itEnd);
- setDefaultAttrsToDest(nTopRow, nDataSize);
+
+ isSupportedNodeType = true;
+
}
break;
case sc::element_type_edittext:
@@ -1358,7 +1365,8 @@ public:
maDestPos.miCellPos = mrDestCol.GetCellStore().set(
maDestPos.miCellPos, nTopRow, aCloned.begin(), aCloned.end());
- setDefaultAttrsToDest(nTopRow, nDataSize);
+ isSupportedNodeType = true;
+
}
break;
case sc::element_type_formula:
@@ -1400,12 +1408,34 @@ public:
sc::SharedFormulaUtil::joinFormulaCellAbove(aPos);
}
- setDefaultAttrsToDest(nTopRow, nDataSize);
+ isSupportedNodeType = true;
+
}
break;
default:
;
}
+
+ if (isSupportedNodeType)
+ {
+ setDefaultAttrsToDest(nTopRow, nDataSize);
+
+ if (mbCopyNotes)
+ {
+ //maDestPos.miCellNotePos = mrDestCol.GetCellNoteStore().set(maDestPos.miCellNotePos, nTopRow, it, itEnd);
+ sc::CellNoteStoreType maSrcCellNotes = mrSrcCol.GetCellNoteStore();
+ sc::CellNoteStoreType::position_type aPosNotes = maSrcCellNotes.position(nTopRow);
+ sc::CellNoteStoreType::iterator itNotes = aPosNotes.first;
+ if (itNotes->type == sc::element_type_cellnote)
+ {
+ ScPostIt* pSrcNote = maSrcCellNotes.get<ScPostIt*>(nTopRow);
+ if (pSrcNote)
+ pSrcNote->Clone( ScAddress(mrSrcCol.GetCol(), nTopRow, mrSrcCol.GetTab() ),
+ mrDestCol.GetDoc(),
+ ScAddress(mrDestCol.GetCol(), nTopRow, mrDestCol.GetTab()), true );
+ }
+ }
+ }
}
};
@@ -1417,8 +1447,9 @@ void ScColumn::CopyToClip(
pAttrArray->CopyArea( nRow1, nRow2, 0, *rColumn.pAttrArray,
rCxt.isKeepScenarioFlags() ? (SC_MF_ALL & ~SC_MF_SCENARIO) : SC_MF_ALL );
- CopyToClipHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol));
+ CopyToClipHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), rCxt.isCloneNotes());
sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
+
rColumn.CellStorageModified();
}
@@ -2021,7 +2052,8 @@ void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const
sc::SingleColumnSpanSet::SpansType aRanges;
aRangeSet.getSpans(aRanges);
- CopyToClipHandler aFunc(*this, rDestCol, NULL);
+ bool bCopyNotes = true;
+ CopyToClipHandler aFunc(*this, rDestCol, NULL, bCopyNotes);
sc::CellStoreType::const_iterator itPos = maCells.begin();
sc::SingleColumnSpanSet::SpansType::const_iterator it = aRanges.begin(), itEnd = aRanges.end();
for (; it != itEnd; ++it)
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 78f2dc9..d7a6014 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -668,6 +668,8 @@ class CopyCellsFromClipHandler
ScColumn& mrDestCol;
SCTAB mnTab;
SCCOL mnCol;
+ SCTAB mnSrcTab;
+ SCCOL mnSrcCol;
long mnRowOffset;
sc::ColumnBlockPosition maDestBlockPos;
sc::ColumnBlockPosition* mpDestBlockPos; // to save it for next iteration.
@@ -702,6 +704,8 @@ public:
mrDestCol(rDestCol),
mnTab(nDestTab),
mnCol(nDestCol),
+ mnSrcTab(rSrcCol.GetTab()),
+ mnSrcCol(rSrcCol.GetCol()),
mnRowOffset(nRowOffset),
mpDestBlockPos(mrCxt.getBlockPosition(nDestTab, nDestCol))
{
@@ -734,6 +738,8 @@ public:
bool bAsLink = mrCxt.isAsLink();
+ bool bCopyCellNotes = mrCxt.isCloneNotes();
+
switch (node.type)
{
case sc::element_type_numeric:
@@ -753,6 +759,22 @@ public:
insertRefCell(nSrcRow, nSrcRow + mnRowOffset);
else
mrDestCol.SetValue(maDestBlockPos, nSrcRow + mnRowOffset, *it);
+
+ if (bCopyCellNotes)
+ {
+ sc::CellNoteStoreType& maCellNotesSrc = mrSrcCol.GetCellNoteStore();
+ sc::CellNoteStoreType::position_type aPos = maCellNotesSrc.position(nSrcRow);
+ sc::CellNoteStoreType::iterator itNotes = aPos.first;
+ if (itNotes->type == sc::element_type_cellnote)
+ {
+ ScPostIt* pSrcNote = maCellNotesSrc.get<ScPostIt*>(nSrcRow);
+ if (pSrcNote)
+ pSrcNote->Clone( ScAddress(mnSrcCol, nSrcRow, mnSrcTab ),
+ mrDestCol.GetDoc(),
+ ScAddress(mnCol , nSrcRow, mnTab),
+ true );
+ }
+ }
}
}
break;
@@ -771,6 +793,22 @@ public:
insertRefCell(nSrcRow, nSrcRow + mnRowOffset);
else
mrDestCol.SetRawString(maDestBlockPos, nSrcRow + mnRowOffset, *it);
+
+ if (bCopyCellNotes)
+ {
+ sc::CellNoteStoreType& maCellNotesSrc = mrSrcCol.GetCellNoteStore();
+ sc::CellNoteStoreType::position_type aPos = maCellNotesSrc.position(nSrcRow);
+ sc::CellNoteStoreType::iterator itNotes = aPos.first;
+ if (itNotes->type == sc::element_type_cellnote)
+ {
+ ScPostIt* pSrcNote = maCellNotesSrc.get<ScPostIt*>(nSrcRow);
+ if (pSrcNote)
+ pSrcNote->Clone( ScAddress(mnSrcCol, nSrcRow, mnSrcTab ),
+ mrDestCol.GetDoc(),
+ ScAddress(mnCol , nSrcRow, mnTab),
+ true );
+ }
+ }
}
}
break;
@@ -790,6 +828,22 @@ public:
insertRefCell(nSrcRow, nSrcRow + mnRowOffset);
else
mrDestCol.SetEditText(maDestBlockPos, nSrcRow + mnRowOffset, **it);
+
+ if (bCopyCellNotes)
+ {
+ sc::CellNoteStoreType& maCellNotesSrc = mrSrcCol.GetCellNoteStore();
+ sc::CellNoteStoreType::position_type aPos = maCellNotesSrc.position(nSrcRow);
+ sc::CellNoteStoreType::iterator itNotes = aPos.first;
+ if (itNotes->type == sc::element_type_cellnote)
+ {
+ ScPostIt* pSrcNote = maCellNotesSrc.get<ScPostIt*>(nSrcRow);
+ if (pSrcNote)
+ pSrcNote->Clone( ScAddress(mnSrcCol, nSrcRow, mnSrcTab ),
+ mrDestCol.GetDoc(),
+ ScAddress(mnCol , nSrcRow, mnTab),
+ true );
+ }
+ }
}
}
break;
@@ -881,6 +935,22 @@ public:
mrDestCol.SetRawString(maDestBlockPos, nSrcRow + mnRowOffset, aStr);
}
}
+
+ if (bCopyCellNotes)
+ {
+ sc::CellNoteStoreType& maCellNotesSrc = mrSrcCol.GetCellNoteStore();
+ sc::CellNoteStoreType::position_type aPos = maCellNotesSrc.position(nSrcRow);
+ sc::CellNoteStoreType::iterator itNotes = aPos.first;
+ if (itNotes->type == sc::element_type_cellnote)
+ {
+ ScPostIt* pSrcNote = maCellNotesSrc.get<ScPostIt*>(nSrcRow);
+ if (pSrcNote)
+ pSrcNote->Clone( ScAddress(mnSrcCol, nSrcRow, mnSrcTab ),
+ mrDestCol.GetDoc(),
+ ScAddress(mnCol , nSrcRow, mnTab),
+ true );
+ }
+ }
}
}
break;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index e5b128c..1ac668b 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -446,11 +446,6 @@ void ScTable::DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sal
mpCondFormatList->DeleteArea( nCol1, nRow1, nCol2, nRow2 );
}
-/* moved at column level
- if (nDelFlag & IDF_NOTE)
- maNotes.erase( nCol1, nRow1, nCol2, nRow2 );
-*/
-
if (IsStreamValid())
// TODO: In the future we may want to check if the table has been
// really modified before setting the stream invalid.
@@ -472,12 +467,6 @@ void ScTable::DeleteSelection( sal_uInt16 nDelFlag, const ScMarkData& rMark )
for (size_t i = 0; i < aRangeList.size(); ++i)
{
ScRange* pRange = aRangeList[i];
- /* moved at column level
- if (nDelFlag & IDF_NOTE && pRange)
- {
- maNotes.erase(pRange->aStart.Col(), pRange->aStart.Row(), pRange->aEnd.Col(), pRange->aEnd.Row(), nDelFlag & IDF_NOCAPTIONS);
- }
- */
if((nDelFlag & IDF_ATTRIB) && pRange && pRange->aStart.Tab() == nTab)
mpCondFormatList->DeleteArea( pRange->aStart.Col(), pRange->aStart.Row(), pRange->aEnd.Col(), pRange->aEnd.Row() );
@@ -958,9 +947,29 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
}
}
}
+
+ // Cell Notes - fdo#68381 paste cell notes on Transpose
+ bool bCloneCaption = true;
+ if ( pDestDoc->HasColNotes(nCol, nTab) )
+ {
+ sc::CellNoteStoreType& maCellNotes = pDestDoc->GetColNotes(nCol, nTab);
+ for (nRow=nRow1; nRow <= nRow2; nRow++) // TODO : notes suboptimal ?
+ {
+ sc::CellNoteStoreType::position_type aPos = maCellNotes.position(nRow);
+ sc::CellNoteStoreType::iterator it = aPos.first;
+ ScPostIt* pNote = maCellNotes.get<ScPostIt*>(nRow);
+
+ ScAddress aDestPos( static_cast<SCCOL>(nRow-nRow1), static_cast<SCROW>(nCol-nCol1), pTransClip->nTab );
+ ScPostIt* pClonedNote = pNote->Clone( ScAddress(nCol, nRow, nTab), *pTransClip->pDocument, aDestPos, bCloneCaption );
+
+ pTransClip->pDocument->ReleaseNote(aDestPos);
+ pTransClip->pDocument->SetNote(aDestPos, pClonedNote);
+ }
+ }
}
-/* TODO : notes clipboard
+/*
+// TODO : notes clipboard
// fdo#68381 paste cell notes on Transpose
bool bCloneCaption = true;
for (ScNotes::const_iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
@@ -1204,18 +1213,6 @@ void ScTable::CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const
{
for (SCCOL i=0; i<=MAXCOL; i++)
aCol[i].CopyUpdated( pPosTab->aCol[i], pDestTab->aCol[i] );
-
-/* TODO : notes clipboard
- // insert notes with captions
- for(ScNotes::iterator itr = pDestTab->maNotes.begin(); itr != pDestTab->maNotes.end(); ++itr)
- {
- SCCOL nCol = itr->first.first;
- SCROW nRow = itr->first.second;
- ScPostIt* pPostIt = itr->second;
-
- pDestTab->maNotes.insert(nCol, nRow, pPostIt->Clone( ScAddress(nCol, nRow, nTab),*pDestTab->pDocument, ScAddress(nCol, nRow, pDestTab->nTab), true ));
- }
-*/
}
void ScTable::InvalidateTableArea()
More information about the Libreoffice-commits
mailing list