diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-07-27 11:32:49 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-07-27 11:52:27 +0100 |
commit | 7c84a219e3cc8d623826343f547ba8adacca6d56 (patch) | |
tree | a26537cf7380fc55d8c7c919c94711e6f863c041 /sc | |
parent | cb4787c36a300d6783da28540da737dbad951070 (diff) |
Resolves: tdf#65334 cannot search in cell notes
regression since...
commit c06dbbe7594c2a0b5a5b19f8e183d9c421e6e094
Author: Markus Mohrhard <markus.mohrhard@googlemail.com>
Date: Thu Feb 23 23:36:49 2012 +0100
remove mpNote from ScBaseCell
and requires restoring some code subsequently removed in
commit a1a1131c16227327d17bcf5ad2a5209ddc0f01a1
Date: Sun Mar 4 15:27:27 2012 +0800
Remove unused code
Change-Id: If931c3162cacaeb126e730e3e79c1c47be4ce434
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/postit.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/postit.cxx | 9 | ||||
-rw-r--r-- | sc/source/core/data/table6.cxx | 23 |
3 files changed, 30 insertions, 4 deletions
diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx index 8a7dec86a792..fb962442a1cb 100644 --- a/sc/inc/postit.hxx +++ b/sc/inc/postit.hxx @@ -118,6 +118,8 @@ public: /** Returns the caption text of this note. */ OUString GetText() const; + /** Returns true, if the caption text of this note contains line breaks. */ + bool HasMultiLineText() const; /** Changes the caption text of this note. All text formatting will be lost. */ void SetText( const ScAddress& rPos, const OUString& rText ); diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index 8eb8331ac227..64f47a5a3b76 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -562,6 +562,15 @@ OUString ScPostIt::GetText() const return OUString(); } +bool ScPostIt::HasMultiLineText() const +{ + if( const EditTextObject* pEditObj = GetEditTextObject() ) + return pEditObj->GetParagraphCount() > 1; + if( maNoteData.mxInitData.get() ) + return maNoteData.mxInitData->maSimpleText.indexOf( '\n' ) >= 0; + return false; +} + void ScPostIt::SetText( const ScAddress& rPos, const OUString& rText ) { CreateCaptionFromInitData( rPos ); diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index 2c63ed46a8ec..b5a4499fb7fc 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -73,6 +73,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo return false; bool bMultiLine = false; + ScPostIt* pNote = nullptr; CellType eCellType = aCell.meType; switch (rSearchItem.GetCellType()) { @@ -89,8 +90,8 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo else aCol[nCol].GetString( nRow, aString ); } + break; } - break; case SvxSearchCellType::VALUE: if ( eCellType == CELLTYPE_EDIT ) bMultiLine = lcl_GetTextWithBreaks(*aCell.mpEditText, pDocument, aString); @@ -103,7 +104,15 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo } break; case SvxSearchCellType::NOTE: - break; // don't search this case here + { + pNote = aCol[nCol].GetCellNote(nRow); + if (pNote) + { + aString = pNote->GetText(); + bMultiLine = pNote->HasMultiLineText(); + } + break; + } default: break; } @@ -212,8 +221,14 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo } } while (bRepeat); - - if ( cMatrixFlag != MM_NONE ) + if (rSearchItem.GetCellType() == SvxSearchCellType::NOTE) + { + // NB: rich text format is lost. + // This is also true of Cells. + if (pNote) + pNote->SetText( ScAddress( nCol, nRow, nTab ), aString ); + } + else if ( cMatrixFlag != MM_NONE ) { // don't split Matrix if ( aString.getLength() > 2 ) { // remove {} here so that "{=" can be replaced by "{=..." |