sc: Move all sparkline methods to Operation framework
Extract the 7 sparkline ScDocFunc methods into Operation subclasses. Pure refactoring, no behavior change. Change-Id: Id714721d0d852889b135c700da3327cf75ad641f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201457 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202095 Tested-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 28efca2b83b88983ccce02e81f442bbf3fa834d7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205531 Tested-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
committed by
Xisco Fauli
parent
c449c59e11
commit
69a243ee03
@@ -536,16 +536,22 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
|
||||
sc/source/ui/operation/ApplyAttributesOperation \
|
||||
sc/source/ui/operation/AutoFormatOperation \
|
||||
sc/source/ui/operation/ChangeIndentOperation \
|
||||
sc/source/ui/operation/ChangeSparklineGroupAttributesOperation \
|
||||
sc/source/ui/operation/ChangeSparklineOperation \
|
||||
sc/source/ui/operation/ClearItemsOperation \
|
||||
sc/source/ui/operation/ConvertFormulaToValueOperation \
|
||||
sc/source/ui/operation/DeleteCellOperation \
|
||||
sc/source/ui/operation/DeleteContentOperation \
|
||||
sc/source/ui/operation/DeleteSparklineGroupOperation \
|
||||
sc/source/ui/operation/DeleteSparklineOperation \
|
||||
sc/source/ui/operation/EnterMatrixOperation \
|
||||
sc/source/ui/operation/FillAutoOperation \
|
||||
sc/source/ui/operation/FillSeriesOperation \
|
||||
sc/source/ui/operation/FillSimpleOperation \
|
||||
sc/source/ui/operation/GroupSparklinesOperation \
|
||||
sc/source/ui/operation/InsertCellsOperation \
|
||||
sc/source/ui/operation/InsertSheetViewOperation \
|
||||
sc/source/ui/operation/InsertSparklinesOperation \
|
||||
sc/source/ui/operation/MultipleOpsOperation \
|
||||
sc/source/ui/operation/Operation \
|
||||
sc/source/ui/operation/OperationType \
|
||||
@@ -558,6 +564,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
|
||||
sc/source/ui/operation/SetValueOperation \
|
||||
sc/source/ui/operation/SortOperation \
|
||||
sc/source/ui/operation/TransliterateTextOperation \
|
||||
sc/source/ui/operation/UngroupSparklinesOperation \
|
||||
sc/source/ui/pagedlg/areasdlg \
|
||||
sc/source/ui/pagedlg/tphfedit \
|
||||
sc/source/ui/sidebar/AlignmentPropertyPanel \
|
||||
|
||||
@@ -100,20 +100,14 @@
|
||||
#include <validat.hxx>
|
||||
#include <SparklineGroup.hxx>
|
||||
#include <SparklineAttributes.hxx>
|
||||
#include <SparklineData.hxx>
|
||||
#include <undo/UndoInsertSparkline.hxx>
|
||||
#include <undo/UndoDeleteSparkline.hxx>
|
||||
#include <undo/UndoDeleteSparklineGroup.hxx>
|
||||
#include <undo/UndoEditSparklineGroup.hxx>
|
||||
#include <undo/UndoUngroupSparklines.hxx>
|
||||
#include <undo/UndoGroupSparklines.hxx>
|
||||
#include <undo/UndoEditSparkline.hxx>
|
||||
#include <SheetViewOperationsTester.hxx>
|
||||
#include <config_features.h>
|
||||
|
||||
#include <memory>
|
||||
#include <operation/OperationType.hxx>
|
||||
#include <operation/DeleteContentOperation.hxx>
|
||||
#include <operation/DeleteSparklineGroupOperation.hxx>
|
||||
#include <operation/DeleteSparklineOperation.hxx>
|
||||
#include <operation/DeleteCellOperation.hxx>
|
||||
#include <operation/SetNormalStringOperation.hxx>
|
||||
#include <operation/SetValueOperation.hxx>
|
||||
@@ -123,17 +117,22 @@
|
||||
#include <operation/ApplyAttributesOperation.hxx>
|
||||
#include <operation/AutoFormatOperation.hxx>
|
||||
#include <operation/ChangeIndentOperation.hxx>
|
||||
#include <operation/ChangeSparklineGroupAttributesOperation.hxx>
|
||||
#include <operation/ChangeSparklineOperation.hxx>
|
||||
#include <operation/ClearItemsOperation.hxx>
|
||||
#include <operation/ConvertFormulaToValueOperation.hxx>
|
||||
#include <operation/EnterMatrixOperation.hxx>
|
||||
#include <operation/FillAutoOperation.hxx>
|
||||
#include <operation/FillSeriesOperation.hxx>
|
||||
#include <operation/FillSimpleOperation.hxx>
|
||||
#include <operation/GroupSparklinesOperation.hxx>
|
||||
#include <operation/InsertCellsOperation.hxx>
|
||||
#include <operation/InsertSheetViewOperation.hxx>
|
||||
#include <operation/InsertSparklinesOperation.hxx>
|
||||
#include <operation/MultipleOpsOperation.hxx>
|
||||
#include <operation/SetNoteTextOperation.hxx>
|
||||
#include <operation/TransliterateTextOperation.hxx>
|
||||
#include <operation/UngroupSparklinesOperation.hxx>
|
||||
#include <basic/basmgr.hxx>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
@@ -3931,181 +3930,45 @@ void ScDocFunc::EndListAction()
|
||||
bool ScDocFunc::InsertSparklines(ScRange const& rDataRange, ScRange const& rSparklineRange,
|
||||
const std::shared_ptr<sc::SparklineGroup>& pSparklineGroup)
|
||||
{
|
||||
if (!CheckSheetViewProtection(sc::OperationType::SparklineInsert))
|
||||
return false;
|
||||
|
||||
std::vector<sc::SparklineData> aSparklineDataVector;
|
||||
|
||||
if (rSparklineRange.aStart.Col() == rSparklineRange.aEnd.Col())
|
||||
{
|
||||
sal_Int32 nOutputRowSize = rSparklineRange.aEnd.Row() - rSparklineRange.aStart.Row();
|
||||
|
||||
auto eInputOrientation = sc::calculateOrientation(nOutputRowSize, rDataRange);
|
||||
|
||||
if (eInputOrientation == sc::RangeOrientation::Unknown)
|
||||
return false;
|
||||
|
||||
sal_Int32 nIndex = 0;
|
||||
|
||||
for (ScAddress aAddress = rSparklineRange.aStart; aAddress.Row() <= rSparklineRange.aEnd.Row();
|
||||
aAddress.IncRow())
|
||||
{
|
||||
ScRange aInputRangeSlice = rDataRange;
|
||||
if (eInputOrientation == sc::RangeOrientation::Row)
|
||||
{
|
||||
aInputRangeSlice.aStart.SetRow(rDataRange.aStart.Row() + nIndex);
|
||||
aInputRangeSlice.aEnd.SetRow(rDataRange.aStart.Row() + nIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
aInputRangeSlice.aStart.SetCol(rDataRange.aStart.Col() + nIndex);
|
||||
aInputRangeSlice.aEnd.SetCol(rDataRange.aStart.Col() + nIndex);
|
||||
}
|
||||
|
||||
aSparklineDataVector.emplace_back(aAddress, aInputRangeSlice);
|
||||
|
||||
nIndex++;
|
||||
}
|
||||
}
|
||||
else if (rSparklineRange.aStart.Row() == rSparklineRange.aEnd.Row())
|
||||
{
|
||||
sal_Int32 nOutputColSize = rSparklineRange.aEnd.Col() - rSparklineRange.aStart.Col();
|
||||
|
||||
auto eInputOrientation = sc::calculateOrientation(nOutputColSize, rDataRange);
|
||||
|
||||
if (eInputOrientation == sc::RangeOrientation::Unknown)
|
||||
return false;
|
||||
|
||||
sal_Int32 nIndex = 0;
|
||||
|
||||
for (ScAddress aAddress = rSparklineRange.aStart; aAddress.Col() <= rSparklineRange.aEnd.Col();
|
||||
aAddress.IncCol())
|
||||
{
|
||||
ScRange aInputRangeSlice = rDataRange;
|
||||
if (eInputOrientation == sc::RangeOrientation::Row)
|
||||
{
|
||||
aInputRangeSlice.aStart.SetRow(rDataRange.aStart.Row() + nIndex);
|
||||
aInputRangeSlice.aEnd.SetRow(rDataRange.aStart.Row() + nIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
aInputRangeSlice.aStart.SetCol(rDataRange.aStart.Col() + nIndex);
|
||||
aInputRangeSlice.aEnd.SetCol(rDataRange.aStart.Col() + nIndex);
|
||||
}
|
||||
|
||||
aSparklineDataVector.emplace_back(aAddress, aInputRangeSlice);
|
||||
|
||||
nIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
if (aSparklineDataVector.empty())
|
||||
return false;
|
||||
|
||||
auto pUndoInsertSparkline = std::make_unique<sc::UndoInsertSparkline>(rDocShell, aSparklineDataVector, pSparklineGroup);
|
||||
// insert the sparkline by "redoing"
|
||||
pUndoInsertSparkline->Redo();
|
||||
rDocShell.GetUndoManager()->AddUndoAction(std::move(pUndoInsertSparkline));
|
||||
|
||||
ScDocument& rDoc = rDocShell.GetDocument();
|
||||
if (rSparklineRange.aStart == rSparklineRange.aEnd
|
||||
&& rDoc.HasAttrib(rSparklineRange, HasAttrFlags::Merged))
|
||||
{
|
||||
ScRange aExtendMergeRange(rSparklineRange);
|
||||
rDoc.ExtendMerge(aExtendMergeRange);
|
||||
rDocShell.PostPaint(aExtendMergeRange, PaintPartFlags::Grid);
|
||||
}
|
||||
|
||||
return true;
|
||||
sc::InsertSparklinesOperation aOperation(rDocShell, rDataRange, rSparklineRange, pSparklineGroup);
|
||||
return aOperation.run();
|
||||
}
|
||||
|
||||
bool ScDocFunc::DeleteSparkline(ScAddress const& rAddress)
|
||||
{
|
||||
auto& rDocument = rDocShell.GetDocument();
|
||||
|
||||
if (!rDocument.HasSparkline(rAddress))
|
||||
return false;
|
||||
|
||||
if (!CheckSheetViewProtection(sc::OperationType::SparklineDelete))
|
||||
return false;
|
||||
|
||||
|
||||
auto pUndoDeleteSparkline = std::make_unique<sc::UndoDeleteSparkline>(rDocShell, rAddress);
|
||||
// delete sparkline by "redoing"
|
||||
pUndoDeleteSparkline->Redo();
|
||||
rDocShell.GetUndoManager()->AddUndoAction(std::move(pUndoDeleteSparkline));
|
||||
|
||||
return true;
|
||||
sc::DeleteSparklineOperation aOperation(rDocShell, rAddress);
|
||||
return aOperation.run();
|
||||
}
|
||||
|
||||
bool ScDocFunc::DeleteSparklineGroup(std::shared_ptr<sc::SparklineGroup> const& pSparklineGroup, SCTAB nTab)
|
||||
{
|
||||
if (!pSparklineGroup)
|
||||
return false;
|
||||
|
||||
auto& rDocument = rDocShell.GetDocument();
|
||||
|
||||
if (!rDocument.HasTable(nTab))
|
||||
return false;
|
||||
|
||||
if (!CheckSheetViewProtection(sc::OperationType::SparklineGroupDelete))
|
||||
return false;
|
||||
|
||||
auto pUndo = std::make_unique<sc::UndoDeleteSparklineGroup>(rDocShell, pSparklineGroup, nTab);
|
||||
// delete sparkline group by "redoing"
|
||||
pUndo->Redo();
|
||||
rDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
|
||||
return true;
|
||||
sc::DeleteSparklineGroupOperation aOperation(rDocShell, pSparklineGroup, nTab);
|
||||
return aOperation.run();
|
||||
}
|
||||
|
||||
bool ScDocFunc::ChangeSparklineGroupAttributes(std::shared_ptr<sc::SparklineGroup> const& pExistingSparklineGroup,
|
||||
sc::SparklineAttributes const& rNewAttributes)
|
||||
{
|
||||
if (!CheckSheetViewProtection(sc::OperationType::SparklineGroupChange))
|
||||
return false;
|
||||
|
||||
|
||||
auto pUndo = std::make_unique<sc::UndoEditSparklneGroup>(rDocShell, pExistingSparklineGroup, rNewAttributes);
|
||||
// change sparkline group attributes by "redoing"
|
||||
pUndo->Redo();
|
||||
rDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
|
||||
return true;
|
||||
sc::ChangeSparklineGroupAttributesOperation aOperation(rDocShell, pExistingSparklineGroup, rNewAttributes);
|
||||
return aOperation.run();
|
||||
}
|
||||
|
||||
bool ScDocFunc::GroupSparklines(ScRange const& rRange, std::shared_ptr<sc::SparklineGroup> const& rpGroup)
|
||||
{
|
||||
if (!CheckSheetViewProtection(sc::OperationType::SparklineGroup))
|
||||
return false;
|
||||
|
||||
auto pUndo = std::make_unique<sc::UndoGroupSparklines>(rDocShell, rRange, rpGroup);
|
||||
// group sparklines by "redoing"
|
||||
pUndo->Redo();
|
||||
rDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
|
||||
return true;
|
||||
sc::GroupSparklinesOperation aOperation(rDocShell, rRange, rpGroup);
|
||||
return aOperation.run();
|
||||
}
|
||||
|
||||
bool ScDocFunc::UngroupSparklines(ScRange const& rRange)
|
||||
{
|
||||
if (!CheckSheetViewProtection(sc::OperationType::SparklineUngroup))
|
||||
return false;
|
||||
|
||||
auto pUndo = std::make_unique<sc::UndoUngroupSparklines>(rDocShell, rRange);
|
||||
// ungroup sparklines by "redoing"
|
||||
pUndo->Redo();
|
||||
rDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
|
||||
return true;
|
||||
sc::UngroupSparklinesOperation aOperation(rDocShell, rRange);
|
||||
return aOperation.run();
|
||||
}
|
||||
|
||||
bool ScDocFunc::ChangeSparkline(std::shared_ptr<sc::Sparkline> const& rpSparkline, SCTAB nTab, ScRangeList const& rDataRange)
|
||||
{
|
||||
if (!CheckSheetViewProtection(sc::OperationType::SparklineChange))
|
||||
return false;
|
||||
|
||||
auto pUndo = std::make_unique<sc::UndoEditSparkline>(rDocShell, rpSparkline, nTab, rDataRange);
|
||||
// change sparkline by "redoing"
|
||||
pUndo->Redo();
|
||||
rDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
|
||||
return true;
|
||||
sc::ChangeSparklineOperation aOperation(rDocShell, rpSparkline, nTab, rDataRange);
|
||||
return aOperation.run();
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Operation.hxx"
|
||||
#include <SparklineAttributes.hxx>
|
||||
#include <memory>
|
||||
|
||||
class ScDocShell;
|
||||
|
||||
namespace sc
|
||||
{
|
||||
class SparklineGroup;
|
||||
|
||||
/** Changes the sparkline's group attributes to the input one. */
|
||||
class ChangeSparklineGroupAttributesOperation : public Operation
|
||||
{
|
||||
private:
|
||||
ScDocShell& mrDocShell;
|
||||
std::shared_ptr<SparklineGroup> mpExistingSparklineGroup;
|
||||
SparklineAttributes maNewAttributes;
|
||||
|
||||
bool runImplementation() override;
|
||||
|
||||
public:
|
||||
ChangeSparklineGroupAttributesOperation(
|
||||
ScDocShell& rDocShell, std::shared_ptr<SparklineGroup> const& pExistingSparklineGroup,
|
||||
SparklineAttributes const& rNewAttributes);
|
||||
};
|
||||
} // end sc namespace
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Operation.hxx"
|
||||
#include <types.hxx>
|
||||
#include <rangelst.hxx>
|
||||
#include <memory>
|
||||
|
||||
class ScDocShell;
|
||||
|
||||
namespace sc
|
||||
{
|
||||
class Sparkline;
|
||||
|
||||
/** Changes the sparkline's input data range. */
|
||||
class ChangeSparklineOperation : public Operation
|
||||
{
|
||||
private:
|
||||
ScDocShell& mrDocShell;
|
||||
std::shared_ptr<Sparkline> mpSparkline;
|
||||
SCTAB mnTab;
|
||||
ScRangeList maDataRange;
|
||||
|
||||
bool runImplementation() override;
|
||||
|
||||
public:
|
||||
ChangeSparklineOperation(ScDocShell& rDocShell, std::shared_ptr<Sparkline> const& rpSparkline,
|
||||
SCTAB nTab, ScRangeList const& rDataRange);
|
||||
};
|
||||
} // end sc namespace
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,39 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Operation.hxx"
|
||||
#include <types.hxx>
|
||||
#include <memory>
|
||||
|
||||
class ScDocShell;
|
||||
|
||||
namespace sc
|
||||
{
|
||||
class SparklineGroup;
|
||||
|
||||
/** Deletes the whole sparkline group. */
|
||||
class DeleteSparklineGroupOperation : public Operation
|
||||
{
|
||||
private:
|
||||
ScDocShell& mrDocShell;
|
||||
std::shared_ptr<SparklineGroup> mpSparklineGroup;
|
||||
SCTAB mnTab;
|
||||
|
||||
bool runImplementation() override;
|
||||
|
||||
public:
|
||||
DeleteSparklineGroupOperation(ScDocShell& rDocShell,
|
||||
std::shared_ptr<SparklineGroup> const& pSparklineGroup,
|
||||
SCTAB nTab);
|
||||
};
|
||||
} // end sc namespace
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,33 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Operation.hxx"
|
||||
#include <address.hxx>
|
||||
|
||||
class ScDocShell;
|
||||
|
||||
namespace sc
|
||||
{
|
||||
/** Deletes one sparkline */
|
||||
class DeleteSparklineOperation : public Operation
|
||||
{
|
||||
private:
|
||||
ScDocShell& mrDocShell;
|
||||
ScAddress maAddress;
|
||||
|
||||
bool runImplementation() override;
|
||||
|
||||
public:
|
||||
DeleteSparklineOperation(ScDocShell& rDocShell, ScAddress const& rAddress);
|
||||
};
|
||||
} // end sc namespace
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Operation.hxx"
|
||||
#include <rangelst.hxx>
|
||||
#include <memory>
|
||||
|
||||
class ScDocShell;
|
||||
|
||||
namespace sc
|
||||
{
|
||||
class SparklineGroup;
|
||||
|
||||
/** Groups the sparklines in the input range together. */
|
||||
class GroupSparklinesOperation : public Operation
|
||||
{
|
||||
private:
|
||||
ScDocShell& mrDocShell;
|
||||
ScRange maRange;
|
||||
std::shared_ptr<SparklineGroup> mpGroup;
|
||||
|
||||
bool runImplementation() override;
|
||||
|
||||
public:
|
||||
GroupSparklinesOperation(ScDocShell& rDocShell, ScRange const& rRange,
|
||||
std::shared_ptr<SparklineGroup> const& rpGroup);
|
||||
};
|
||||
} // end sc namespace
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Operation.hxx"
|
||||
#include <rangelst.hxx>
|
||||
#include <memory>
|
||||
|
||||
class ScDocShell;
|
||||
|
||||
namespace sc
|
||||
{
|
||||
class SparklineGroup;
|
||||
|
||||
/** Inserts new sparklines at the input range, and add them into the input group. */
|
||||
class InsertSparklinesOperation : public Operation
|
||||
{
|
||||
private:
|
||||
ScDocShell& mrDocShell;
|
||||
ScRange maDataRange;
|
||||
ScRange maSparklineRange;
|
||||
std::shared_ptr<SparklineGroup> mpSparklineGroup;
|
||||
|
||||
bool runImplementation() override;
|
||||
|
||||
public:
|
||||
InsertSparklinesOperation(ScDocShell& rDocShell, ScRange const& rDataRange,
|
||||
ScRange const& rSparklineRange,
|
||||
std::shared_ptr<SparklineGroup> const& pSparklineGroup);
|
||||
};
|
||||
} // end sc namespace
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,33 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Operation.hxx"
|
||||
#include <rangelst.hxx>
|
||||
|
||||
class ScDocShell;
|
||||
|
||||
namespace sc
|
||||
{
|
||||
/** Ungroup all the sparklines in the input range and create a new group for each sparkline. */
|
||||
class UngroupSparklinesOperation : public Operation
|
||||
{
|
||||
private:
|
||||
ScDocShell& mrDocShell;
|
||||
ScRange maRange;
|
||||
|
||||
bool runImplementation() override;
|
||||
|
||||
public:
|
||||
UngroupSparklinesOperation(ScDocShell& rDocShell, ScRange const& rRange);
|
||||
};
|
||||
} // end sc namespace
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,42 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <operation/ChangeSparklineGroupAttributesOperation.hxx>
|
||||
|
||||
#include <docsh.hxx>
|
||||
#include <SparklineGroup.hxx>
|
||||
#include <undo/UndoEditSparklineGroup.hxx>
|
||||
|
||||
namespace sc
|
||||
{
|
||||
ChangeSparklineGroupAttributesOperation::ChangeSparklineGroupAttributesOperation(
|
||||
ScDocShell& rDocShell, std::shared_ptr<SparklineGroup> const& pExistingSparklineGroup,
|
||||
SparklineAttributes const& rNewAttributes)
|
||||
: Operation(OperationType::SparklineGroupChange, false, false)
|
||||
, mrDocShell(rDocShell)
|
||||
, mpExistingSparklineGroup(pExistingSparklineGroup)
|
||||
, maNewAttributes(rNewAttributes)
|
||||
{
|
||||
}
|
||||
|
||||
bool ChangeSparklineGroupAttributesOperation::runImplementation()
|
||||
{
|
||||
if (!checkSheetViewProtection())
|
||||
return false;
|
||||
|
||||
auto pUndo = std::make_unique<UndoEditSparklneGroup>(mrDocShell, mpExistingSparklineGroup,
|
||||
maNewAttributes);
|
||||
// change sparkline group attributes by "redoing"
|
||||
pUndo->Redo();
|
||||
mrDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,42 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <operation/ChangeSparklineOperation.hxx>
|
||||
|
||||
#include <docsh.hxx>
|
||||
#include <Sparkline.hxx>
|
||||
#include <undo/UndoEditSparkline.hxx>
|
||||
|
||||
namespace sc
|
||||
{
|
||||
ChangeSparklineOperation::ChangeSparklineOperation(ScDocShell& rDocShell,
|
||||
std::shared_ptr<Sparkline> const& rpSparkline,
|
||||
SCTAB nTab, ScRangeList const& rDataRange)
|
||||
: Operation(OperationType::SparklineChange, false, false)
|
||||
, mrDocShell(rDocShell)
|
||||
, mpSparkline(rpSparkline)
|
||||
, mnTab(nTab)
|
||||
, maDataRange(rDataRange)
|
||||
{
|
||||
}
|
||||
|
||||
bool ChangeSparklineOperation::runImplementation()
|
||||
{
|
||||
if (!checkSheetViewProtection())
|
||||
return false;
|
||||
|
||||
auto pUndo = std::make_unique<UndoEditSparkline>(mrDocShell, mpSparkline, mnTab, maDataRange);
|
||||
// change sparkline by "redoing"
|
||||
pUndo->Redo();
|
||||
mrDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <operation/DeleteSparklineGroupOperation.hxx>
|
||||
|
||||
#include <docsh.hxx>
|
||||
#include <SparklineGroup.hxx>
|
||||
#include <undo/UndoDeleteSparklineGroup.hxx>
|
||||
|
||||
namespace sc
|
||||
{
|
||||
DeleteSparklineGroupOperation::DeleteSparklineGroupOperation(
|
||||
ScDocShell& rDocShell, std::shared_ptr<SparklineGroup> const& pSparklineGroup, SCTAB nTab)
|
||||
: Operation(OperationType::SparklineGroupDelete, false, false)
|
||||
, mrDocShell(rDocShell)
|
||||
, mpSparklineGroup(pSparklineGroup)
|
||||
, mnTab(nTab)
|
||||
{
|
||||
}
|
||||
|
||||
bool DeleteSparklineGroupOperation::runImplementation()
|
||||
{
|
||||
if (!mpSparklineGroup)
|
||||
return false;
|
||||
|
||||
auto& rDocument = mrDocShell.GetDocument();
|
||||
|
||||
if (!rDocument.HasTable(mnTab))
|
||||
return false;
|
||||
|
||||
if (!checkSheetViewProtection())
|
||||
return false;
|
||||
|
||||
auto pUndo = std::make_unique<UndoDeleteSparklineGroup>(mrDocShell, mpSparklineGroup, mnTab);
|
||||
// delete sparkline group by "redoing"
|
||||
pUndo->Redo();
|
||||
mrDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,43 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <operation/DeleteSparklineOperation.hxx>
|
||||
|
||||
#include <docsh.hxx>
|
||||
#include <undo/UndoDeleteSparkline.hxx>
|
||||
|
||||
namespace sc
|
||||
{
|
||||
DeleteSparklineOperation::DeleteSparklineOperation(ScDocShell& rDocShell, ScAddress const& rAddress)
|
||||
: Operation(OperationType::SparklineDelete, false, false)
|
||||
, mrDocShell(rDocShell)
|
||||
, maAddress(rAddress)
|
||||
{
|
||||
}
|
||||
|
||||
bool DeleteSparklineOperation::runImplementation()
|
||||
{
|
||||
auto& rDocument = mrDocShell.GetDocument();
|
||||
|
||||
if (!rDocument.HasSparkline(maAddress))
|
||||
return false;
|
||||
|
||||
if (!checkSheetViewProtection())
|
||||
return false;
|
||||
|
||||
auto pUndoDeleteSparkline = std::make_unique<UndoDeleteSparkline>(mrDocShell, maAddress);
|
||||
// delete sparkline by "redoing"
|
||||
pUndoDeleteSparkline->Redo();
|
||||
mrDocShell.GetUndoManager()->AddUndoAction(std::move(pUndoDeleteSparkline));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <operation/GroupSparklinesOperation.hxx>
|
||||
|
||||
#include <docsh.hxx>
|
||||
#include <SparklineGroup.hxx>
|
||||
#include <undo/UndoGroupSparklines.hxx>
|
||||
|
||||
namespace sc
|
||||
{
|
||||
GroupSparklinesOperation::GroupSparklinesOperation(ScDocShell& rDocShell, ScRange const& rRange,
|
||||
std::shared_ptr<SparklineGroup> const& rpGroup)
|
||||
: Operation(OperationType::SparklineGroup, false, false)
|
||||
, mrDocShell(rDocShell)
|
||||
, maRange(rRange)
|
||||
, mpGroup(rpGroup)
|
||||
{
|
||||
}
|
||||
|
||||
bool GroupSparklinesOperation::runImplementation()
|
||||
{
|
||||
if (!checkSheetViewProtection())
|
||||
return false;
|
||||
|
||||
auto pUndo = std::make_unique<UndoGroupSparklines>(mrDocShell, maRange, mpGroup);
|
||||
// group sparklines by "redoing"
|
||||
pUndo->Redo();
|
||||
mrDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,113 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <operation/InsertSparklinesOperation.hxx>
|
||||
|
||||
#include <docsh.hxx>
|
||||
#include <SparklineData.hxx>
|
||||
#include <SparklineGroup.hxx>
|
||||
#include <undo/UndoInsertSparkline.hxx>
|
||||
|
||||
namespace sc
|
||||
{
|
||||
InsertSparklinesOperation::InsertSparklinesOperation(
|
||||
ScDocShell& rDocShell, ScRange const& rDataRange, ScRange const& rSparklineRange,
|
||||
std::shared_ptr<SparklineGroup> const& pSparklineGroup)
|
||||
: Operation(OperationType::SparklineInsert, false, false)
|
||||
, mrDocShell(rDocShell)
|
||||
, maDataRange(rDataRange)
|
||||
, maSparklineRange(rSparklineRange)
|
||||
, mpSparklineGroup(pSparklineGroup)
|
||||
{
|
||||
}
|
||||
|
||||
bool InsertSparklinesOperation::runImplementation()
|
||||
{
|
||||
if (!checkSheetViewProtection())
|
||||
return false;
|
||||
|
||||
std::vector<SparklineData> aSparklineDataVector;
|
||||
|
||||
if (maSparklineRange.aStart.Col() == maSparklineRange.aEnd.Col())
|
||||
{
|
||||
sal_Int32 nOutputRowSize = maSparklineRange.aEnd.Row() - maSparklineRange.aStart.Row();
|
||||
|
||||
auto eInputOrientation = calculateOrientation(nOutputRowSize, maDataRange);
|
||||
|
||||
if (eInputOrientation == RangeOrientation::Unknown)
|
||||
return false;
|
||||
|
||||
sal_Int32 nIndex = 0;
|
||||
|
||||
for (ScAddress aAddress = maSparklineRange.aStart;
|
||||
aAddress.Row() <= maSparklineRange.aEnd.Row(); aAddress.IncRow())
|
||||
{
|
||||
ScRange aInputRangeSlice = maDataRange;
|
||||
if (eInputOrientation == RangeOrientation::Row)
|
||||
{
|
||||
aInputRangeSlice.aStart.SetRow(maDataRange.aStart.Row() + nIndex);
|
||||
aInputRangeSlice.aEnd.SetRow(maDataRange.aStart.Row() + nIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
aInputRangeSlice.aStart.SetCol(maDataRange.aStart.Col() + nIndex);
|
||||
aInputRangeSlice.aEnd.SetCol(maDataRange.aStart.Col() + nIndex);
|
||||
}
|
||||
|
||||
aSparklineDataVector.emplace_back(aAddress, aInputRangeSlice);
|
||||
|
||||
nIndex++;
|
||||
}
|
||||
}
|
||||
else if (maSparklineRange.aStart.Row() == maSparklineRange.aEnd.Row())
|
||||
{
|
||||
sal_Int32 nOutputColSize = maSparklineRange.aEnd.Col() - maSparklineRange.aStart.Col();
|
||||
|
||||
auto eInputOrientation = calculateOrientation(nOutputColSize, maDataRange);
|
||||
|
||||
if (eInputOrientation == RangeOrientation::Unknown)
|
||||
return false;
|
||||
|
||||
sal_Int32 nIndex = 0;
|
||||
|
||||
for (ScAddress aAddress = maSparklineRange.aStart;
|
||||
aAddress.Col() <= maSparklineRange.aEnd.Col(); aAddress.IncCol())
|
||||
{
|
||||
ScRange aInputRangeSlice = maDataRange;
|
||||
if (eInputOrientation == RangeOrientation::Row)
|
||||
{
|
||||
aInputRangeSlice.aStart.SetRow(maDataRange.aStart.Row() + nIndex);
|
||||
aInputRangeSlice.aEnd.SetRow(maDataRange.aStart.Row() + nIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
aInputRangeSlice.aStart.SetCol(maDataRange.aStart.Col() + nIndex);
|
||||
aInputRangeSlice.aEnd.SetCol(maDataRange.aStart.Col() + nIndex);
|
||||
}
|
||||
|
||||
aSparklineDataVector.emplace_back(aAddress, aInputRangeSlice);
|
||||
|
||||
nIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
if (aSparklineDataVector.empty())
|
||||
return false;
|
||||
|
||||
auto pUndoInsertSparkline
|
||||
= std::make_unique<UndoInsertSparkline>(mrDocShell, aSparklineDataVector, mpSparklineGroup);
|
||||
// insert the sparkline by "redoing"
|
||||
pUndoInsertSparkline->Redo();
|
||||
mrDocShell.GetUndoManager()->AddUndoAction(std::move(pUndoInsertSparkline));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,37 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <operation/UngroupSparklinesOperation.hxx>
|
||||
|
||||
#include <docsh.hxx>
|
||||
#include <undo/UndoUngroupSparklines.hxx>
|
||||
|
||||
namespace sc
|
||||
{
|
||||
UngroupSparklinesOperation::UngroupSparklinesOperation(ScDocShell& rDocShell, ScRange const& rRange)
|
||||
: Operation(OperationType::SparklineUngroup, false, false)
|
||||
, mrDocShell(rDocShell)
|
||||
, maRange(rRange)
|
||||
{
|
||||
}
|
||||
|
||||
bool UngroupSparklinesOperation::runImplementation()
|
||||
{
|
||||
if (!checkSheetViewProtection())
|
||||
return false;
|
||||
|
||||
auto pUndo = std::make_unique<UndoUngroupSparklines>(mrDocShell, maRange);
|
||||
// ungroup sparklines by "redoing"
|
||||
pUndo->Redo();
|
||||
mrDocShell.GetUndoManager()->AddUndoAction(std::move(pUndo));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
Reference in New Issue
Block a user