Kaydet (Commit) aa637365 authored tarafından Rodolfo Ribeiro Gomes's avatar Rodolfo Ribeiro Gomes Kaydeden (comit) Eike Rathke

fdo#39454 Allow (show/hide) comments for selected cells (cell range)

Change-Id: I1a4caea70ef8e2fc177a966e7e267ca4df139864
Reviewed-on: https://gerrit.libreoffice.org/1412Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarEike Rathke <erack@redhat.com>
üst 37f23883
......@@ -711,7 +711,17 @@
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Show Comment</value>
</prop>
</node>
</node>
<node oor:name=".uno:ShowNote" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Show Comment</value>
</prop>
</node>
<node oor:name=".uno:HideNote" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Hide Comment</value>
</prop>
</node>
<node oor:name=".uno:InsertAnnotation" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Comm~ent</value>
......
......@@ -639,6 +639,9 @@
#define SID_INSERT_FIELD_TITLE (SID_NEW_SLOTS+98)
#define SID_INSERT_FIELD_DATE_VAR (SID_NEW_SLOTS+99)
#define FID_SHOW_NOTE (SID_NEW_SLOTS+100)
#define FID_HIDE_NOTE (SID_NEW_SLOTS+101)
// idl parameter
#define SID_SORT_BYROW (SC_PARAM_START)
......
......@@ -66,6 +66,8 @@
#define CMD_FID_TAB_MOVE ".uno:Move"
#define CMD_SID_PREVIEW_NEXT ".uno:NextPage"
#define CMD_FID_NOTE_VISIBLE ".uno:NoteVisible"
#define CMD_FID_SHOW_NOTE ".uno:ShowNote"
#define CMD_FID_HIDE_NOTE ".uno:HideNote"
#define CMD_SID_DELETE_NOTE ".uno:DeleteNote"
#define CMD_SID_MIRROR_HORIZONTAL ".uno:ObjectMirrorHorizontal"
#define CMD_SID_MIRROR_VERTICAL ".uno:ObjectMirrorVertical"
......
......@@ -187,6 +187,8 @@ interface CellSelection
SID_COLORSCALE [ ExecMethod = ExecuteEdit; ]
SID_DATABAR [ ExecMethod = ExecuteEdit; ]
FID_NOTE_VISIBLE [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
FID_HIDE_NOTE [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
FID_SHOW_NOTE [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
SID_DELETE_NOTE [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
SID_DEC_INDENT [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
SID_INC_INDENT [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
......
......@@ -4506,6 +4506,60 @@ SfxBoolItem NoteVisible FID_NOTE_VISIBLE
GroupId = GID_VIEW;
]
//--------------------------------------------------------------------------
SfxBoolItem ShowNote FID_SHOW_NOTE
[
/* flags: */
AutoUpdate = FALSE,
Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
ReadOnlyDoc = TRUE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
Synchron;
Readonly = FALSE,
/* config: */
AccelConfig = TRUE,
MenuConfig = TRUE,
StatusBarConfig = FALSE,
ToolBoxConfig = TRUE,
GroupId = GID_VIEW;
]
//--------------------------------------------------------------------------
SfxBoolItem HideNote FID_HIDE_NOTE
[
/* flags: */
AutoUpdate = FALSE,
Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
ReadOnlyDoc = TRUE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
Synchron;
Readonly = FALSE,
/* config: */
AccelConfig = TRUE,
MenuConfig = TRUE,
StatusBarConfig = FALSE,
ToolBoxConfig = TRUE,
GroupId = GID_VIEW;
]
//--------------------------------------------------------------------------
SfxVoidItem DeleteNote SID_DELETE_NOTE
()
......
......@@ -96,9 +96,15 @@ Menu RID_POPUP_CELLS
};
MenuItem
{
Identifier = FID_NOTE_VISIBLE ;
HelpId = CMD_FID_NOTE_VISIBLE ;
Identifier = FID_SHOW_NOTE ;
HelpId = CMD_FID_SHOW_NOTE ;
Text [ en-US ] = "Sho~w Comment" ;
};
MenuItem
{
Identifier = FID_HIDE_NOTE ;
HelpId = CMD_FID_HIDE_NOTE ;
Text [ en-US ] = "~Hide Comment" ;
};
//------------------------------
MenuItem { Separator = TRUE ; };
......@@ -614,9 +620,15 @@ Menu RID_POPUP_PAGEBREAK
//------------------------------
MenuItem
{
Identifier = FID_NOTE_VISIBLE ;
HelpId = CMD_FID_NOTE_VISIBLE ;
Identifier = FID_SHOW_NOTE ;
HelpId = CMD_FID_SHOW_NOTE ;
Text [ en-US ] = "Sho~w Comment" ;
};
MenuItem
{
Identifier = FID_HIDE_NOTE ;
HelpId = CMD_FID_HIDE_NOTE ;
Text [ en-US ] = "~Hide Comment" ;
};
};
};
......@@ -908,6 +908,82 @@ void ScCellShell::GetState(SfxItemSet &rSet)
}
break;
case FID_HIDE_NOTE:
case FID_SHOW_NOTE:
{
bool bEnable = false;
bool bSearchForHidden = nWhich == FID_SHOW_NOTE;
if (!rMark.IsMarked() && !rMark.IsMultiMarked())
{
// Check current cell
const ScPostIt* pNote = pDoc->GetNotes(nTab)->findByAddress(nPosX, nPosY);
if ( pNote && pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) )
if ( pNote->IsCaptionShown() != bSearchForHidden)
bEnable = 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 && !bEnable; ++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 );
const ScNotes *pNotes = pDoc->GetNotes(nRangeTab);
if ( nCellNumber < pNotes->size() )
{
// Check by each cell
for ( SCROW nRow = nRow0; nRow <= nRow1 && !bEnable; ++nRow )
{
for ( SCCOL nCol = nCol0; nCol <= nCol1; ++nCol )
{
const ScPostIt* pNote = pNotes->findByAddress(nCol, nRow);
if ( pNote && pDoc->IsBlockEditable( nRangeTab, nCol,nRow, nCol,nRow ) )
{
if ( pNote->IsCaptionShown() != bSearchForHidden)
{
bEnable = true;
break;
}
}
}
}
}
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 )
{
if ( itr->second->IsCaptionShown() != bSearchForHidden)
{
bEnable = true; //note found
break;
}
}
}
}
}
}
if ( !bEnable )
rSet.DisableItem( nWhich );
}
break;
case SID_DELETE_NOTE:
{
bool bEnable = false;
......
......@@ -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();
......
......@@ -364,6 +364,8 @@ void ScTabView::SelectionChanged()
rBindings.Invalidate( SID_CURRENTCELL ); // -> Navigator
rBindings.Invalidate( SID_AUTO_FILTER ); // -> Menue
rBindings.Invalidate( FID_NOTE_VISIBLE );
rBindings.Invalidate( FID_SHOW_NOTE );
rBindings.Invalidate( FID_HIDE_NOTE );
rBindings.Invalidate( SID_DELETE_NOTE );
// Funktionen, die evtl disabled werden muessen
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment