From ed715a460254e4d72c78ff6eb244a9fc6692e2a6 Mon Sep 17 00:00:00 2001 From: Gulsah Kose Date: Sat, 6 May 2017 04:47:46 +0300 Subject: tdf#95883 Select Unprotected Cells in Calc Change-Id: I20a71f66154675de9c2c47ff32e859c899fe9103 Signed-off-by: Gulsah Kose Reviewed-on: https://gerrit.libreoffice.org/37424 Tested-by: Jenkins Reviewed-by: Eike Rathke --- .../data/org/openoffice/Office/UI/CalcCommands.xcu | 5 +++++ sc/inc/column.hxx | 1 + sc/inc/document.hxx | 1 + sc/inc/sc.hrc | 3 ++- sc/inc/table.hxx | 1 + sc/sdi/cellsh.sdi | 1 + sc/sdi/scalc.sdi | 16 ++++++++++++++++ sc/source/core/data/column4.cxx | 18 ++++++++++++++++++ sc/source/core/data/document.cxx | 5 +++++ sc/source/core/data/table2.cxx | 8 ++++++++ sc/source/ui/view/cellsh1.cxx | 14 ++++++++++++++ sc/source/ui/view/tabview3.cxx | 1 + sc/uiconfig/scalc/menubar/menubar.xml | 1 + 13 files changed, 74 insertions(+), 1 deletion(-) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index e084fbb73d0b..1008af5d8688 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -483,6 +483,11 @@ Select Row + + + Select Unprotected Cells + + C~onditional Formatting diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 16a2733495b7..e4700e9e6e48 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -250,6 +250,7 @@ public: bool TestInsertCol( SCROW nStartRow, SCROW nEndRow) const; bool TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const; void InsertRow( SCROW nStartRow, SCSIZE nSize ); + void GetUnprotectedCells(SCROW nStartRow, SCROW nEndRow, ScRangeList& rRangeList ) const; /** * @param nStartRow top row position diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 806a2338f289..57f06cb89fad 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1813,6 +1813,7 @@ public: SC_DLLPUBLIC ScPatternAttr* GetDefPattern() const; SC_DLLPUBLIC ScDocumentPool* GetPool(); SC_DLLPUBLIC ScStyleSheetPool* GetStyleSheetPool() const; + void GetUnprotectedCells( ScRangeList& rRange, SCTAB nTab ) const; // PageStyle: SC_DLLPUBLIC const OUString GetPageStyle( SCTAB nTab ) const; diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 2d72a4a09a76..a90facc28466 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -628,7 +628,8 @@ #define FID_SHOW_ALL_NOTES (SID_NEW_SLOTS+102) #define FID_HIDE_ALL_NOTES (SID_NEW_SLOTS+103) #define FID_DELETE_ALL_NOTES (SID_NEW_SLOTS+104) -#define SID_SCATTR_CELLPROTECTION (SID_NEW_SLOTS+105) +#define SID_SCATTR_CELLPROTECTION (SID_NEW_SLOTS+105) +#define SID_SELECT_UNPROTECTED_CELLS (SID_NEW_SLOTS+106) // idl parameter diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 8b096b1fadba..c936a38db0f4 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -350,6 +350,7 @@ public: bool IsProtected() const; void SetProtection(const ScTableProtection* pProtect); ScTableProtection* GetProtection(); + void GetUnprotectedCells( ScRangeList& rRangeList ) const; bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCCOLROW nStart, SCCOLROW nEnd ) const; diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi index 6812a2d4bd89..e85c12457988 100644 --- a/sc/sdi/cellsh.sdi +++ b/sc/sdi/cellsh.sdi @@ -216,6 +216,7 @@ interface CellSelection SID_DELETE_NOTE [ ExecMethod = ExecuteEdit; StateMethod = GetState; ] SID_DEC_INDENT [ ExecMethod = ExecuteEdit; StateMethod = GetState; ] SID_INC_INDENT [ ExecMethod = ExecuteEdit; StateMethod = GetState; ] + SID_SELECT_UNPROTECTED_CELLS [ ExecMethod = ExecuteEdit;] SID_THESAURUS [ ExecMethod = ExecuteEdit; StateMethod = GetCellState; ] SID_SPELL_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetState; ] diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index bb68273e3091..6e3c26b200b4 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -4330,6 +4330,22 @@ SfxVoidItem SelectArea SID_MARKAREA GroupId = GID_INTERN; ] +SfxVoidItem SelectUnprotectedCells SID_SELECT_UNPROTECTED_CELLS +() +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = FALSE, + MenuConfig = TRUE, + ToolBoxConfig = FALSE, + GroupId = GID_EDIT; +] SfxVoidItem SelectOLE SID_OLE_SELECT () diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index bdecb552bbc4..3541c8fced6b 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -769,6 +769,24 @@ void ScColumn::GetNotesInRange(SCROW nStartRow, SCROW nEndRow, std::for_each(it, ++itEnd, NoteEntryCollector(rNotes, nTab, nCol, nStartRow, nEndRow)); } +void ScColumn::GetUnprotectedCells(SCROW nStartRow, SCROW nEndRow, + ScRangeList& rRangeList ) const +{ + SCROW nTmpStartRow = nStartRow, nTmpEndRow = nEndRow; + const ScPatternAttr* pPattern = pAttrArray->GetPatternRange(nTmpStartRow, nTmpEndRow, nStartRow); + bool bProtection = static_cast(pPattern->GetItem(ATTR_PROTECTION)).GetProtection(); + if(!bProtection) + rRangeList.Join(ScRange( nCol, nTmpStartRow, nTab, nCol, nTmpEndRow, nTab)); + while (nEndRow > nTmpEndRow) + { + nStartRow = nTmpEndRow + 1; + pPattern = pAttrArray->GetPatternRange(nTmpStartRow, nTmpEndRow, nStartRow); + bool bTmpProtection = static_cast(pPattern->GetItem(ATTR_PROTECTION)).GetProtection(); + if (!bTmpProtection) + rRangeList.Join(ScRange( nCol, nTmpStartRow, nTab, nCol, nTmpEndRow, nTab)); + } +} + namespace { class RecompileByOpcodeHandler diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 18553d326575..33860d081b33 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -6645,6 +6645,11 @@ void ScDocument::GetNotesInRange( const ScRangeList& rRange, std::vectorGetUnprotectedCells( rRangeList ); +} + bool ScDocument::ContainsNotesInRange( const ScRangeList& rRange ) const { for( size_t i = 0; i < rRange.size(); ++i) diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 72140a83f36b..4d8ce194b3c9 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1647,6 +1647,14 @@ CommentCaptionState ScTable::GetAllNoteCaptionsState(const ScRange& rRange, std: return (bIsFirstNoteShownState) ? CommentCaptionState::ALLSHOWN : CommentCaptionState::ALLHIDDEN; } +void ScTable::GetUnprotectedCells( ScRangeList& rRangeList ) const +{ + for (SCCOL nCol = 0; nCol < MAXCOL; ++nCol) + { + aCol[nCol].GetUnprotectedCells(0, MAXROW, rRangeList); + } +} + bool ScTable::ContainsNotesInRange( const ScRange& rRange ) const { SCROW nStartRow = rRange.aStart.Row(); diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 0b3603ade2d1..90700aa3ee5f 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2734,6 +2734,20 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) } break; + case SID_SELECT_UNPROTECTED_CELLS: + { + ScViewData* pData = GetViewData(); + SCTAB aTab = pData->GetTabNo(); + ScMarkData& rMark = pData->GetMarkData(); + ScDocument* pDoc = pData->GetDocument(); + ScRangeList rRangeList; + + pDoc->GetUnprotectedCells(rRangeList, aTab); + rMark.MarkFromRangeList(rRangeList, true); + pTabViewShell->SetMarkData(rMark); + } + break; + default: OSL_FAIL("incorrect slot in ExecuteEdit"); break; diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index c2ab34842137..9d0c13329c2b 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -548,6 +548,7 @@ void ScTabView::SelectionChanged() rBindings.Invalidate( SID_TEXT_TO_COLUMNS ); rBindings.Invalidate( SID_SORT_ASCENDING ); rBindings.Invalidate( SID_SORT_DESCENDING ); + rBindings.Invalidate( SID_SELECT_UNPROTECTED_CELLS ); if (aViewData.GetViewShell()->HasAccessibilityObjects()) aViewData.GetViewShell()->BroadcastAccessibility(SfxHint(SfxHintId::ScAccCursorChanged)); diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index af234fa4d7d9..25a5d9235833 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -103,6 +103,7 @@ + -- cgit