Kaydet (Commit) 6d6ed164 authored tarafından Noel Grandin's avatar Noel Grandin

remove unnecessary separate function objects

which just makes the code harder to read

Change-Id: Id9269554b4e29a2562cbdd06f42a143c2f028795
Reviewed-on: https://gerrit.libreoffice.org/71360
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst f48aa15c
...@@ -81,7 +81,6 @@ ...@@ -81,7 +81,6 @@
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::accessibility; using namespace ::com::sun::star::accessibility;
using ::std::for_each;
//===== internal ======================================================== //===== internal ========================================================
...@@ -188,45 +187,6 @@ struct ScShapeDataLess ...@@ -188,45 +187,6 @@ struct ScShapeDataLess
} }
}; };
struct DeselectShape
{
void operator() (const ScAccessibleShapeData* pAccShapeData) const
{
if (pAccShapeData)
{
pAccShapeData->bSelected = false;
if (pAccShapeData->pAccShape.is())
pAccShapeData->pAccShape->ResetState(AccessibleStateType::SELECTED);
}
}
};
struct SelectShape
{
uno::Reference < drawing::XShapes > xShapes;
explicit SelectShape(const uno::Reference<drawing::XShapes>& xTemp) : xShapes(xTemp) {}
void operator() (const ScAccessibleShapeData* pAccShapeData) const
{
if (pAccShapeData && pAccShapeData->bSelectable)
{
pAccShapeData->bSelected = true;
if (pAccShapeData->pAccShape.is())
pAccShapeData->pAccShape->SetState(AccessibleStateType::SELECTED);
if (xShapes.is())
xShapes->add(pAccShapeData->xShape);
}
}
};
struct Destroy
{
void operator() (ScAccessibleShapeData* pData)
{
if (pData)
DELETEZ(pData);
}
};
class ScChildrenShapes : public SfxListener, class ScChildrenShapes : public SfxListener,
public ::accessibility::IAccessibleParent public ::accessibility::IAccessibleParent
{ {
...@@ -364,7 +324,8 @@ ScChildrenShapes::ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, Sc ...@@ -364,7 +324,8 @@ ScChildrenShapes::ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, Sc
ScChildrenShapes::~ScChildrenShapes() ScChildrenShapes::~ScChildrenShapes()
{ {
std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), Destroy()); for (ScAccessibleShapeData* pShapeData : maZOrderedShapes)
delete pShapeData;
if (mpViewShell) if (mpViewShell)
{ {
SfxBroadcaster* pDrawBC = mpViewShell->GetViewData().GetDocument()->GetDrawBroadcaster(); SfxBroadcaster* pDrawBC = mpViewShell->GetViewData().GetDocument()->GetDrawBroadcaster();
...@@ -729,8 +690,15 @@ void ScChildrenShapes::DeselectAll() ...@@ -729,8 +690,15 @@ void ScChildrenShapes::DeselectAll()
} }
if (bSomethingSelected) if (bSomethingSelected)
std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), DeselectShape()); for (const ScAccessibleShapeData* pAccShapeData : maZOrderedShapes)
} if (pAccShapeData)
{
pAccShapeData->bSelected = false;
if (pAccShapeData->pAccShape.is())
pAccShapeData->pAccShape->ResetState(AccessibleStateType::SELECTED);
}
};
void ScChildrenShapes::SelectAll() void ScChildrenShapes::SelectAll()
{ {
...@@ -747,7 +715,17 @@ void ScChildrenShapes::SelectAll() ...@@ -747,7 +715,17 @@ void ScChildrenShapes::SelectAll()
try try
{ {
std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), SelectShape(xShapes)); for (const ScAccessibleShapeData* pAccShapeData : maZOrderedShapes)
{
if (pAccShapeData && pAccShapeData->bSelectable)
{
pAccShapeData->bSelected = true;
if (pAccShapeData->pAccShape.is())
pAccShapeData->pAccShape->SetState(AccessibleStateType::SELECTED);
if (xShapes.is())
xShapes->add(pAccShapeData->xShape);
}
}
xSelectionSupplier->select(uno::makeAny(xShapes)); xSelectionSupplier->select(uno::makeAny(xShapes));
} }
catch (lang::IllegalArgumentException&) catch (lang::IllegalArgumentException&)
...@@ -870,42 +848,27 @@ SdrPage* ScChildrenShapes::GetDrawPage() const ...@@ -870,42 +848,27 @@ SdrPage* ScChildrenShapes::GetDrawPage() const
return pDrawPage; return pDrawPage;
} }
struct SetRelation utl::AccessibleRelationSetHelper* ScChildrenShapes::GetRelationSet(const ScAddress* pAddress) const
{ {
const ScChildrenShapes* mpChildrenShapes; utl::AccessibleRelationSetHelper* pRelationSet = nullptr;
mutable utl::AccessibleRelationSetHelper* mpRelationSet; for (const ScAccessibleShapeData* pAccShapeData : maZOrderedShapes)
const ScAddress* mpAddress;
SetRelation(const ScChildrenShapes* pChildrenShapes, const ScAddress* pAddress)
:
mpChildrenShapes(pChildrenShapes),
mpRelationSet(nullptr),
mpAddress(pAddress)
{
}
void operator() (const ScAccessibleShapeData* pAccShapeData) const
{ {
if (pAccShapeData && if (pAccShapeData &&
((!pAccShapeData->xRelationCell && !mpAddress) || ((!pAccShapeData->xRelationCell && !pAddress) ||
(pAccShapeData->xRelationCell && mpAddress && (*(pAccShapeData->xRelationCell) == *mpAddress)))) (pAccShapeData->xRelationCell && pAddress && (*(pAccShapeData->xRelationCell) == *pAddress))))
{ {
if (!mpRelationSet) if (!pRelationSet)
mpRelationSet = new utl::AccessibleRelationSetHelper(); pRelationSet = new utl::AccessibleRelationSetHelper();
AccessibleRelation aRelation; AccessibleRelation aRelation;
aRelation.TargetSet.realloc(1); aRelation.TargetSet.realloc(1);
aRelation.TargetSet[0] = mpChildrenShapes->Get(pAccShapeData); aRelation.TargetSet[0] = Get(pAccShapeData);
aRelation.RelationType = AccessibleRelationType::CONTROLLER_FOR; aRelation.RelationType = AccessibleRelationType::CONTROLLER_FOR;
mpRelationSet->AddRelation(aRelation); pRelationSet->AddRelation(aRelation);
} }
} }
}; return pRelationSet;
utl::AccessibleRelationSetHelper* ScChildrenShapes::GetRelationSet(const ScAddress* pAddress) const
{
SetRelation aSetRelation(this, pAddress);
::std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), aSetRelation);
return aSetRelation.mpRelationSet;
} }
bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::XShapes>& xShapes) const bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::XShapes>& xShapes) const
...@@ -1111,8 +1074,11 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X ...@@ -1111,8 +1074,11 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X
aEvent.NewValue <<= xChild; aEvent.NewValue <<= xChild;
mpAccessibleDocument->CommitChange(aEvent); mpAccessibleDocument->CommitChange(aEvent);
} }
std::for_each(aShapesList.begin(), aShapesList.end(), Destroy()); for(ScAccessibleShapeData*& pShapeData : aShapesList)
{
delete pShapeData;
pShapeData = nullptr;
}
return bResult; return bResult;
} }
...@@ -1309,25 +1275,11 @@ sal_Int8 ScChildrenShapes::Compare(const ScAccessibleShapeData* pData1, ...@@ -1309,25 +1275,11 @@ sal_Int8 ScChildrenShapes::Compare(const ScAccessibleShapeData* pData1,
return nResult; return nResult;
} }
namespace
{
struct ScVisAreaChanged
{
explicit ScVisAreaChanged() {}
void operator() (const ScAccessibleShapeData* pAccShapeData) const
{
if (pAccShapeData && pAccShapeData->pAccShape.is())
{
pAccShapeData->pAccShape->ViewForwarderChanged();
}
}
};
}
void ScChildrenShapes::VisAreaChanged() const void ScChildrenShapes::VisAreaChanged() const
{ {
ScVisAreaChanged aVisAreaChanged; for (const ScAccessibleShapeData* pAccShapeData: maZOrderedShapes)
std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), aVisAreaChanged); if (pAccShapeData && pAccShapeData->pAccShape.is())
pAccShapeData->pAccShape->ViewForwarderChanged();
} }
ScAccessibleDocument::ScAccessibleDocument( ScAccessibleDocument::ScAccessibleDocument(
......
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