summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/cellsh1.cxx
diff options
context:
space:
mode:
authorRodolfo Ribeiro Gomes <rodolforg@gmail.com>2012-12-20 02:47:25 +0100
committerEike Rathke <erack@redhat.com>2012-12-20 02:32:14 +0000
commitaa6373650746c261d76e61f9e00de12d521dcb75 (patch)
treef6b4f369b8e914b6f8a19dc586d98f9646012549 /sc/source/ui/view/cellsh1.cxx
parent37f238837cdd2532363efe2af1735ab24cb9a1b9 (diff)
fdo#39454 Allow (show/hide) comments for selected cells (cell range)
Change-Id: I1a4caea70ef8e2fc177a966e7e267ca4df139864 Reviewed-on: https://gerrit.libreoffice.org/1412 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/ui/view/cellsh1.cxx')
-rw-r--r--sc/source/ui/view/cellsh1.cxx86
1 files changed, 84 insertions, 2 deletions
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 0fc5dfc79e7f..f1d359483242 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -17,8 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <iostream>
-
#include <com/sun/star/i18n/TextConversionOption.hpp>
#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
@@ -2036,6 +2034,90 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
}
break;
+ case FID_HIDE_NOTE:
+ case FID_SHOW_NOTE:
+ {
+ bool bShowNote = nSlot == FID_SHOW_NOTE;
+ ScViewData* pData = GetViewData();
+ ScDocument* pDoc = pData->GetDocument();
+ ScMarkData& rMark = pData->GetMarkData();
+ bool bDone = false;
+
+ if (!rMark.IsMarked() && !rMark.IsMultiMarked())
+ {
+ // Check current cell
+ ScAddress aPos( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
+ if( pDoc->GetNotes( aPos.Tab() )->findByAddress(aPos) )
+ {
+ pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote );
+ bDone = true;
+ }
+ }
+ else
+ {
+ // Check selection range
+ ScRangeListRef aRangesRef;
+ pData->GetMultiArea(aRangesRef);
+ ScRangeList aRanges = *aRangesRef;
+ size_t nRangeSize = aRanges.size();
+
+ for ( size_t i = 0; i < nRangeSize; ++i )
+ {
+ const ScRange * pRange = aRanges[i];
+ const SCROW nRow0 = pRange->aStart.Row();
+ const SCROW nRow1 = pRange->aEnd.Row();
+ const SCCOL nCol0 = pRange->aStart.Col();
+ const SCCOL nCol1 = pRange->aEnd.Col();
+ const SCTAB nRangeTab = pRange->aStart.Tab();
+ const size_t nCellNumber = ( nRow1 - nRow0 ) * ( nCol1 - nCol0 );
+ ScNotes *pNotes = pDoc->GetNotes(nRangeTab);
+
+ if ( nCellNumber < pNotes->size() )
+ {
+ // Check by each cell
+ for ( SCROW nRow = nRow0; nRow <= nRow1; ++nRow )
+ {
+ for ( SCCOL nCol = nCol0; nCol <= nCol1; ++nCol )
+ {
+ ScPostIt* pNote = pNotes->findByAddress(nCol, nRow);
+ if ( pNote && pDoc->IsBlockEditable( nRangeTab, nCol,nRow, nCol,nRow ) )
+ {
+ ScAddress aPos( nCol, nRow, nRangeTab );
+ pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote );
+ bDone = true;
+ }
+ }
+ }
+ }
+ else
+ {
+ // Check by each document note
+ for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
+ {
+ SCCOL nCol = itr->first.first;
+ SCROW nRow = itr->first.second;
+
+ if ( nCol <= nCol1 && nRow <= nRow1 && nCol >= nCol0 && nRow >= nRow0 )
+ {
+ ScAddress aPos( nCol, nRow, nRangeTab );
+ pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote );
+ bDone = true;
+ }
+ }
+ }
+ }
+
+ if ( bDone )
+ {
+ rReq.Done();
+ rBindings.Invalidate( nSlot );
+ }
+ else
+ rReq.Ignore();
+ }
+ }
+ break;
+
case SID_DELETE_NOTE:
pTabViewShell->DeleteContents( IDF_NOTE ); // delete all notes in selection
rReq.Done();