tdf#95883 Select Unprotected Cells in Calc

Change-Id: I20a71f66154675de9c2c47ff32e859c899fe9103
Signed-off-by: Gulsah Kose <gulsah.1004@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/37424
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
This commit is contained in:
Gulsah Kose 2017-05-06 04:47:46 +03:00 committed by Eike Rathke
parent 7260bb7160
commit ed715a4602
13 changed files with 74 additions and 1 deletions

View file

@ -483,6 +483,11 @@
<value xml:lang="en-US">Select Row</value>
</prop>
</node>
<node oor:name=".uno:SelectUnprotectedCells" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Select Unprotected Cells</value>
</prop>
</node>
<node oor:name=".uno:ConditionalFormatMenu" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">C~onditional Formatting</value>

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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; ]

View file

@ -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
()

View file

@ -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<const ScProtectionAttr&>(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<const ScProtectionAttr&>(pPattern->GetItem(ATTR_PROTECTION)).GetProtection();
if (!bTmpProtection)
rRangeList.Join(ScRange( nCol, nTmpStartRow, nTab, nCol, nTmpEndRow, nTab));
}
}
namespace {
class RecompileByOpcodeHandler

View file

@ -6645,6 +6645,11 @@ void ScDocument::GetNotesInRange( const ScRangeList& rRange, std::vector<sc::Not
}
}
void ScDocument::GetUnprotectedCells( ScRangeList& rRangeList, SCTAB nTab ) const
{
maTabs[nTab]->GetUnprotectedCells( rRangeList );
}
bool ScDocument::ContainsNotesInRange( const ScRangeList& rRange ) const
{
for( size_t i = 0; i < rRange.size(); ++i)

View file

@ -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();

View file

@ -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;

View file

@ -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));

View file

@ -103,6 +103,7 @@
<menu:menuitem menu:id=".uno:SelectRow"/>
<menu:menuitem menu:id=".uno:SelectColumn"/>
<menu:menuitem menu:id=".uno:SelectData"/>
<menu:menuitem menu:id=".uno:SelectUnprotectedCells"/>
</menu:menupopup>
</menu:menu>
<menu:menuseparator/>