Use std::as_const instead of const_cast
Change-Id: I5ec5708fe09b6aba6dc680f3e3f2135fb6451c88 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189810 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include <svx/svdtypes.hxx>
|
||||
#include <svx/svxdllapi.h>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
@@ -142,7 +143,7 @@ public:
|
||||
SdrLayer* GetLayer(const OUString& rName);
|
||||
const SdrLayer* GetLayer(const OUString& rName) const;
|
||||
SdrLayerID GetLayerID(const OUString& rName) const;
|
||||
SdrLayer* GetLayerPerID(SdrLayerID nID) { return const_cast<SdrLayer*>(const_cast<const SdrLayerAdmin*>(this)->GetLayerPerID(nID)); }
|
||||
SdrLayer* GetLayerPerID(SdrLayerID nID) { return const_cast<SdrLayer*>(std::as_const(*this).GetLayerPerID(nID)); }
|
||||
const SdrLayer* GetLayerPerID(SdrLayerID nID) const;
|
||||
|
||||
void SetControlLayerName(const OUString& rNewName);
|
||||
|
||||
@@ -188,7 +188,7 @@ OUStringVector ItemFormat::parse( std::u16string_view rFormatStr )
|
||||
OUStringVector aFormatVec;
|
||||
StringHelper::convertStringToStringList( aFormatVec, rFormatStr, false );
|
||||
OUStringVector::const_iterator aIt = parse( aFormatVec );
|
||||
return OUStringVector( aIt, const_cast< const OUStringVector& >( aFormatVec ).end() );
|
||||
return OUStringVector( aIt, std::as_const( aFormatVec ).end() );
|
||||
}
|
||||
|
||||
// append string to string ----------------------------------------------------
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <utility>
|
||||
|
||||
// factor from font size to optimal cell height (text width)
|
||||
#define SC_ROT_BREAK_FACTOR 6
|
||||
@@ -2226,7 +2227,7 @@ const ScPostIt* ScColumn::GetCellNote( sc::ColumnBlockConstPosition& rBlockPos,
|
||||
|
||||
ScPostIt* ScColumn::GetCellNote( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow )
|
||||
{
|
||||
return const_cast<ScPostIt*>(const_cast<const ScColumn*>(this)->GetCellNote( rBlockPos, nRow ));
|
||||
return const_cast<ScPostIt*>(std::as_const(*this).GetCellNote( rBlockPos, nRow ));
|
||||
}
|
||||
|
||||
void ScColumn::SetCellNote(SCROW nRow, std::unique_ptr<ScPostIt> pNote)
|
||||
|
||||
@@ -471,8 +471,7 @@ struct XmlIdRegistryDocument::XmlIdRegistry_Impl
|
||||
const OUString & i_rIdref)
|
||||
{
|
||||
return const_cast<XmlIdVector_t*>(
|
||||
const_cast<const XmlIdRegistry_Impl*>(this)
|
||||
->LookupElementVector(i_rStreamName, i_rIdref));
|
||||
std::as_const(*this).LookupElementVector(i_rStreamName, i_rIdref));
|
||||
}
|
||||
|
||||
XmlIdMap_t m_XmlIdMap;
|
||||
|
||||
@@ -204,7 +204,7 @@ sal_uInt16 SdrLayerAdmin::GetLayerPos(const SdrLayer* pLayer) const
|
||||
|
||||
SdrLayer* SdrLayerAdmin::GetLayer(const OUString& rName)
|
||||
{
|
||||
return const_cast<SdrLayer*>(const_cast<const SdrLayerAdmin*>(this)->GetLayer(rName));
|
||||
return const_cast<SdrLayer*>(std::as_const(*this).GetLayer(rName));
|
||||
}
|
||||
|
||||
const SdrLayer* SdrLayerAdmin::GetLayer(const OUString& rName) const
|
||||
|
||||
+3
-2
@@ -34,6 +34,8 @@
|
||||
#include "tox.hxx"
|
||||
#include "ndhints.hxx"
|
||||
|
||||
#include <utility>
|
||||
|
||||
/**
|
||||
* A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an
|
||||
* optional end.
|
||||
@@ -176,8 +178,7 @@ inline const SfxPoolItem& SwTextAttr::GetAttr() const
|
||||
|
||||
inline SfxPoolItem& SwTextAttr::GetAttr()
|
||||
{
|
||||
return const_cast<SfxPoolItem&>(
|
||||
const_cast<const SwTextAttr*>(this)->GetAttr());
|
||||
return const_cast<SfxPoolItem&>(std::as_const(*this).GetAttr());
|
||||
}
|
||||
|
||||
inline void SwTextAttr::SetDontExpand( bool bDontExpand )
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <docary.hxx>
|
||||
#include <unocrsr.hxx>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace
|
||||
{
|
||||
/// find the relevant section in which the SwUnoCursor may wander.
|
||||
@@ -371,7 +373,7 @@ SwEditShell const * SwDoc::GetEditShell() const
|
||||
|
||||
SwEditShell* SwDoc::GetEditShell()
|
||||
{
|
||||
return const_cast<SwEditShell*>( const_cast<SwDoc const *>( this )->GetEditShell() );
|
||||
return const_cast<SwEditShell*>( std::as_const( *this ).GetEditShell() );
|
||||
}
|
||||
|
||||
::sw::IShellCursorSupplier * SwDoc::GetIShellCursorSupplier()
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <hintids.hxx>
|
||||
#include <svx/svdpage.hxx>
|
||||
#include <svx/svditer.hxx>
|
||||
@@ -570,7 +571,7 @@ const SwAnchoredObject* SwFlyDrawContact::GetAnchoredObj(const SdrObject* pSdrOb
|
||||
|
||||
SwAnchoredObject* SwFlyDrawContact::GetAnchoredObj(SdrObject *const pSdrObj)
|
||||
{
|
||||
return const_cast<SwAnchoredObject *>(const_cast<SwFlyDrawContact const*>(this)->GetAnchoredObj(pSdrObj));
|
||||
return const_cast<SwAnchoredObject *>(std::as_const(*this).GetAnchoredObj(pSdrObj));
|
||||
}
|
||||
|
||||
SdrObject* SwFlyDrawContact::GetMaster()
|
||||
@@ -786,7 +787,7 @@ const SwAnchoredObject* SwDrawContact::GetAnchoredObj(const SdrObject* pSdrObj )
|
||||
|
||||
SwAnchoredObject* SwDrawContact::GetAnchoredObj(SdrObject *const pSdrObj)
|
||||
{
|
||||
return const_cast<SwAnchoredObject*>(const_cast<SwDrawContact const*>(this)->GetAnchoredObj(pSdrObj));
|
||||
return const_cast<SwAnchoredObject*>(std::as_const(*this).GetAnchoredObj(pSdrObj));
|
||||
}
|
||||
|
||||
SdrObject* SwDrawContact::GetMaster()
|
||||
@@ -817,7 +818,7 @@ const SwFrame* SwDrawContact::GetAnchorFrame( const SdrObject* _pDrawObj ) const
|
||||
|
||||
SwFrame* SwDrawContact::GetAnchorFrame(SdrObject const *const pDrawObj)
|
||||
{
|
||||
return const_cast<SwFrame *>(const_cast<SwDrawContact const*>(this)->GetAnchorFrame(pDrawObj));
|
||||
return const_cast<SwFrame *>(std::as_const(*this).GetAnchorFrame(pDrawObj));
|
||||
}
|
||||
|
||||
/** add a 'virtual' drawing object to drawing page.
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <swdtflvr.hxx>
|
||||
#include <strings.hrc>
|
||||
|
||||
#include <utility>
|
||||
|
||||
RedlineFlags SwEditShell::GetRedlineFlags() const
|
||||
{
|
||||
return GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags(this);
|
||||
@@ -71,7 +73,7 @@ const SwRangeRedline& SwEditShell::GetRedline( SwRedlineTable::size_type nPos )
|
||||
|
||||
SwRangeRedline& SwEditShell::GetRedline(SwRedlineTable::size_type nPos)
|
||||
{
|
||||
return const_cast<SwRangeRedline&>(const_cast<const SwEditShell*>(this)->GetRedline(nPos));
|
||||
return const_cast<SwRangeRedline&>(std::as_const(*this).GetRedline(nPos));
|
||||
}
|
||||
|
||||
static void lcl_InvalidateAll( SwViewShell* pSh )
|
||||
|
||||
@@ -478,10 +478,9 @@ public:
|
||||
SwTextNode const* GetTextNodeForParaProps() const;
|
||||
SwTextNode const* GetTextNodeForFirstText() const;
|
||||
SwTextNode * GetTextNodeFirst()
|
||||
{ return const_cast<SwTextNode*>(const_cast<SwTextFrame const*>(this)->GetTextNodeFirst()); };
|
||||
{ return const_cast<SwTextNode*>(std::as_const(*this).GetTextNodeFirst()); };
|
||||
SwTextNode const* GetTextNodeFirst() const;
|
||||
SwDoc & GetDoc()
|
||||
{ return const_cast<SwDoc &>(const_cast<SwTextFrame const*>(this)->GetDoc()); }
|
||||
SwDoc & GetDoc() { return const_cast<SwDoc &>(std::as_const(*this).GetDoc()); }
|
||||
SwDoc const& GetDoc() const;
|
||||
|
||||
SwTextFrame(SwTextNode * const, SwFrame*, sw::FrameMode eMode);
|
||||
|
||||
@@ -314,7 +314,7 @@ public:
|
||||
const HTMLTableCell& GetCell(sal_uInt16 nCell) const;
|
||||
HTMLTableCell& GetCell(sal_uInt16 nCell)
|
||||
{
|
||||
return const_cast<HTMLTableCell&>(const_cast<const HTMLTableRow&>(*this).GetCell(nCell));
|
||||
return const_cast<HTMLTableCell&>(std::as_const(*this).GetCell(nCell));
|
||||
}
|
||||
|
||||
void SetAdjust( SvxAdjust eAdj ) { m_eAdjust = eAdj; }
|
||||
@@ -550,7 +550,7 @@ public:
|
||||
const HTMLTableCell& GetCell(sal_uInt16 nRow, sal_uInt16 nCell) const;
|
||||
HTMLTableCell& GetCell(sal_uInt16 nRow, sal_uInt16 nCell)
|
||||
{
|
||||
return const_cast<HTMLTableCell&>(const_cast<const HTMLTable&>(*this).GetCell(nRow, nCell));
|
||||
return const_cast<HTMLTableCell&>(std::as_const(*this).GetCell(nRow, nCell));
|
||||
}
|
||||
|
||||
// set/determine caption
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
#include <osl/mutex.hxx>
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace css::uno;
|
||||
using namespace css::xml::dom;
|
||||
using namespace css::xml::dom::events;
|
||||
@@ -213,15 +215,13 @@ namespace DOM::events {
|
||||
// then bubbeling phase listeners are called in target to root
|
||||
// order
|
||||
// start at the root
|
||||
NodeVector_t::const_reverse_iterator rinode =
|
||||
const_cast<NodeVector_t const&>(captureVector).rbegin();
|
||||
if (rinode == const_cast<NodeVector_t const&>(captureVector).rend())
|
||||
auto rinode = std::as_const(captureVector).rbegin();
|
||||
if (rinode == std::as_const(captureVector).rend())
|
||||
return;
|
||||
|
||||
// capturing phase:
|
||||
pEvent->m_phase = PhaseType_CAPTURING_PHASE;
|
||||
while (rinode !=
|
||||
const_cast<NodeVector_t const&>(captureVector).rend())
|
||||
while (rinode != std::as_const(captureVector).rend())
|
||||
{
|
||||
pEvent->m_currentTarget = rinode->first;
|
||||
callListeners(captureListeners, rinode->second, aType, xEvent);
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include <sal/log.hxx>
|
||||
|
||||
#include <utility>
|
||||
|
||||
typedef unsigned char PIXBYTE;
|
||||
|
||||
namespace {
|
||||
@@ -417,7 +419,7 @@ static inline ConstScanline ImplGetScanline( const BitmapBuffer& rBuf, tools::Lo
|
||||
|
||||
static inline Scanline ImplGetScanline( BitmapBuffer& rBuf, tools::Long nY )
|
||||
{
|
||||
return const_cast<Scanline>(ImplGetScanline( const_cast<const BitmapBuffer&>(rBuf), nY ));
|
||||
return const_cast<Scanline>(ImplGetScanline( std::as_const(rBuf), nY ));
|
||||
}
|
||||
|
||||
template <ScanlineFormat DSTFMT, ScanlineFormat SRCFMT>
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
|
||||
typedef std::unordered_map<SvTreeListEntry*, std::unique_ptr<SvViewDataEntry>> SvDataTable;
|
||||
@@ -1352,7 +1353,7 @@ const SvViewDataEntry* SvListView::GetViewData( const SvTreeListEntry* pEntry )
|
||||
|
||||
SvViewDataEntry* SvListView::GetViewData( SvTreeListEntry* pEntry )
|
||||
{
|
||||
return const_cast<SvViewDataEntry*>(const_cast<const SvListView*>(this)->GetViewData(pEntry));
|
||||
return const_cast<SvViewDataEntry*>(std::as_const(*this).GetViewData(pEntry));
|
||||
}
|
||||
|
||||
sal_Int32 SvTreeList::Compare(const SvTreeListEntry* pLeft, const SvTreeListEntry* pRight) const
|
||||
|
||||
@@ -1464,7 +1464,7 @@ const vcl::Window *VclBin::get_child() const
|
||||
|
||||
vcl::Window *VclBin::get_child()
|
||||
{
|
||||
return const_cast<vcl::Window*>(const_cast<const VclBin*>(this)->get_child());
|
||||
return const_cast<vcl::Window*>(std::as_const(*this).get_child());
|
||||
}
|
||||
|
||||
Size VclBin::calculateRequisition() const
|
||||
@@ -1569,7 +1569,7 @@ const vcl::Window *VclFrame::get_label_widget() const
|
||||
|
||||
vcl::Window *VclFrame::get_label_widget()
|
||||
{
|
||||
return const_cast<vcl::Window*>(const_cast<const VclFrame*>(this)->get_label_widget());
|
||||
return const_cast<vcl::Window*>(std::as_const(*this).get_label_widget());
|
||||
}
|
||||
|
||||
const vcl::Window *VclFrame::get_child() const
|
||||
@@ -1586,7 +1586,7 @@ const vcl::Window *VclFrame::get_child() const
|
||||
|
||||
vcl::Window *VclFrame::get_child()
|
||||
{
|
||||
return const_cast<vcl::Window*>(const_cast<const VclFrame*>(this)->get_child());
|
||||
return const_cast<vcl::Window*>(std::as_const(*this).get_child());
|
||||
}
|
||||
|
||||
void VclFrame::set_label(const OUString &rLabel)
|
||||
@@ -1741,7 +1741,7 @@ const vcl::Window *VclExpander::get_child() const
|
||||
|
||||
vcl::Window *VclExpander::get_child()
|
||||
{
|
||||
return const_cast<vcl::Window*>(const_cast<const VclExpander*>(this)->get_child());
|
||||
return const_cast<vcl::Window*>(std::as_const(*this).get_child());
|
||||
}
|
||||
|
||||
Size VclExpander::calculateRequisition() const
|
||||
@@ -1854,7 +1854,7 @@ const vcl::Window *VclExpander::get_label_widget() const
|
||||
|
||||
vcl::Window *VclExpander::get_label_widget()
|
||||
{
|
||||
return const_cast<vcl::Window*>(const_cast<const VclExpander*>(this)->get_label_widget());
|
||||
return const_cast<vcl::Window*>(std::as_const(*this).get_label_widget());
|
||||
}
|
||||
|
||||
void VclExpander::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
|
||||
@@ -1952,7 +1952,7 @@ const vcl::Window *VclScrolledWindow::get_child() const
|
||||
|
||||
vcl::Window *VclScrolledWindow::get_child()
|
||||
{
|
||||
return const_cast<vcl::Window*>(const_cast<const VclScrolledWindow*>(this)->get_child());
|
||||
return const_cast<vcl::Window*>(std::as_const(*this).get_child());
|
||||
}
|
||||
|
||||
Size VclScrolledWindow::calculateRequisition() const
|
||||
@@ -2276,7 +2276,7 @@ const vcl::Window *VclEventBox::get_child() const
|
||||
|
||||
vcl::Window *VclEventBox::get_child()
|
||||
{
|
||||
return const_cast<vcl::Window*>(const_cast<const VclEventBox*>(this)->get_child());
|
||||
return const_cast<vcl::Window*>(std::as_const(*this).get_child());
|
||||
}
|
||||
|
||||
void VclEventBox::setAllocation(const Size& rAllocation)
|
||||
|
||||
Reference in New Issue
Block a user