officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu | 12 + sc/inc/sc.hrc | 3 sc/inc/sccommands.h | 2 sc/sdi/cellsh.sdi | 2 sc/sdi/scalc.sdi | 54 ++++++ sc/source/ui/src/popup.src | 20 +- sc/source/ui/view/cellsh.cxx | 76 ++++++++ sc/source/ui/view/cellsh1.cxx | 86 +++++++++- sc/source/ui/view/tabview3.cxx | 2 9 files changed, 250 insertions(+), 7 deletions(-)
New commits: commit aa6373650746c261d76e61f9e00de12d521dcb75 Author: Rodolfo Ribeiro Gomes <[email protected]> Date: Thu Dec 20 02:47:25 2012 +0100 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 <[email protected]> Tested-by: Eike Rathke <[email protected]> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index 64ffb88..31823a1 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -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> diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 9eaf61f..fb488d2 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -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) diff --git a/sc/inc/sccommands.h b/sc/inc/sccommands.h index 8de1f7a..7133b42 100644 --- a/sc/inc/sccommands.h +++ b/sc/inc/sccommands.h @@ -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" diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi index 5d97fc1..d03e3f5 100644 --- a/sc/sdi/cellsh.sdi +++ b/sc/sdi/cellsh.sdi @@ -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; ] diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index 308eeda..ac53029 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -4507,6 +4507,60 @@ SfxBoolItem NoteVisible FID_NOTE_VISIBLE ] //-------------------------------------------------------------------------- +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 () [ diff --git a/sc/source/ui/src/popup.src b/sc/source/ui/src/popup.src index e6588f6..10829f7 100644 --- a/sc/source/ui/src/popup.src +++ b/sc/source/ui/src/popup.src @@ -96,10 +96,16 @@ 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" ; + }; }; }; diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index ade336a..790739e 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -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; diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 0fc5dfc..f1d3594 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(); diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index ecd46d7..8fcf73e 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -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 _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
