std::unique_ptr -> std::optional
Change-Id: I15779eca607f27a758575f4f095910277aa85eda Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116377 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include <com/sun/star/drawing/XDrawPage.hpp>
|
||||
#include <svx/svdobj.hxx>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -228,7 +229,7 @@ public:
|
||||
private:
|
||||
/// This list, if it exists, defines the navigation order. If it does
|
||||
/// not exist then maList defines the navigation order.
|
||||
std::unique_ptr<std::vector<tools::WeakReference<SdrObject>>> mxNavigationOrder;
|
||||
std::optional<std::vector<tools::WeakReference<SdrObject>>> mxNavigationOrder;
|
||||
|
||||
/// This flag is <TRUE/> when the mpNavigation list has been changed but
|
||||
/// the indices of the referenced SdrObjects still have their old values.
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include <tools/stream.hxx>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
enum class SvXMLEmbeddedObjectHelperMode
|
||||
{
|
||||
@@ -57,8 +58,8 @@ class SVXCORE_DLLPUBLIC SvXMLEmbeddedObjectHelper final :
|
||||
css::uno::Reference < css::embed::XStorage > mxTempStorage; // package
|
||||
// objects
|
||||
SvXMLEmbeddedObjectHelperMode meCreateMode;
|
||||
std::unique_ptr<std::map< OUString, rtl::Reference<OutputStorageWrapper_Impl> >>
|
||||
mpStreamMap;
|
||||
std::optional<std::map< OUString, rtl::Reference<OutputStorageWrapper_Impl> >>
|
||||
mxStreamMap;
|
||||
|
||||
SVX_DLLPRIVATE bool ImplGetStorageNames(
|
||||
const OUString& rURLStr,
|
||||
|
@@ -38,6 +38,7 @@
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
@@ -151,7 +152,7 @@ class LocationBrowseNode :
|
||||
public ::cppu::WeakImplHelper< browse::XBrowseNode >
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<std::unordered_map< OUString, Reference< browse::XBrowseNode > >> m_hBNA;
|
||||
std::optional<std::unordered_map< OUString, Reference< browse::XBrowseNode > >> m_hBNA;
|
||||
std::vector< OUString > m_vStr;
|
||||
OUString m_sNodeName;
|
||||
Reference< browse::XBrowseNode > m_origNode;
|
||||
@@ -175,7 +176,7 @@ public:
|
||||
virtual Sequence< Reference< browse::XBrowseNode > > SAL_CALL
|
||||
getChildNodes() override
|
||||
{
|
||||
if ( m_hBNA == nullptr )
|
||||
if ( !m_hBNA )
|
||||
{
|
||||
loadChildNodes();
|
||||
}
|
||||
@@ -206,7 +207,7 @@ private:
|
||||
|
||||
void loadChildNodes()
|
||||
{
|
||||
m_hBNA.reset( new std::unordered_map< OUString, Reference< browse::XBrowseNode > > );
|
||||
m_hBNA.emplace();
|
||||
|
||||
const Sequence< Reference< browse::XBrowseNode > > langNodes =
|
||||
m_origNode->getChildNodes();
|
||||
|
@@ -836,7 +836,7 @@ void SdrObjList::UnGroupObj( size_t nObjNum )
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SdrObjList::HasObjectNavigationOrder() const { return mxNavigationOrder != nullptr; }
|
||||
bool SdrObjList::HasObjectNavigationOrder() const { return bool(mxNavigationOrder); }
|
||||
|
||||
void SdrObjList::SetObjectNavigationPosition (
|
||||
SdrObject& rObject,
|
||||
@@ -845,12 +845,11 @@ void SdrObjList::SetObjectNavigationPosition (
|
||||
// When the navigation order container has not yet been created then
|
||||
// create one now. It is initialized with the z-order taken from
|
||||
// maList.
|
||||
if (mxNavigationOrder == nullptr)
|
||||
if (!mxNavigationOrder)
|
||||
{
|
||||
mxNavigationOrder.reset(new std::vector<tools::WeakReference<SdrObject>>(maList.begin(),
|
||||
maList.end()));
|
||||
mxNavigationOrder.emplace(maList.begin(), maList.end());
|
||||
}
|
||||
OSL_ASSERT(mxNavigationOrder != nullptr);
|
||||
OSL_ASSERT(bool(mxNavigationOrder));
|
||||
OSL_ASSERT( mxNavigationOrder->size() == maList.size());
|
||||
|
||||
tools::WeakReference<SdrObject> aReference (&rObject);
|
||||
@@ -927,7 +926,7 @@ bool SdrObjList::RecalcNavigationPositions()
|
||||
{
|
||||
if (mbIsNavigationOrderDirty)
|
||||
{
|
||||
if (mxNavigationOrder != nullptr)
|
||||
if (mxNavigationOrder)
|
||||
{
|
||||
mbIsNavigationOrderDirty = false;
|
||||
|
||||
@@ -940,7 +939,7 @@ bool SdrObjList::RecalcNavigationPositions()
|
||||
}
|
||||
}
|
||||
|
||||
return mxNavigationOrder != nullptr;
|
||||
return bool(mxNavigationOrder);
|
||||
}
|
||||
|
||||
|
||||
@@ -952,8 +951,8 @@ void SdrObjList::SetNavigationOrder (const uno::Reference<container::XIndexAcces
|
||||
if (static_cast<sal_uInt32>(nCount) != maList.size())
|
||||
return;
|
||||
|
||||
if (mxNavigationOrder == nullptr)
|
||||
mxNavigationOrder.reset(new std::vector<tools::WeakReference<SdrObject>>(nCount));
|
||||
if (!mxNavigationOrder)
|
||||
mxNavigationOrder = std::vector<tools::WeakReference<SdrObject>>(nCount);
|
||||
|
||||
for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
|
||||
{
|
||||
|
@@ -430,10 +430,10 @@ OUString SvXMLEmbeddedObjectHelper::ImplInsertEmbeddedObjectURL(
|
||||
OutputStorageWrapper_Impl *pOut = nullptr;
|
||||
std::map< OUString, rtl::Reference<OutputStorageWrapper_Impl> >::iterator aIter;
|
||||
|
||||
if( mpStreamMap )
|
||||
if( mxStreamMap )
|
||||
{
|
||||
aIter = mpStreamMap->find( rURLStr );
|
||||
if( aIter != mpStreamMap->end() && aIter->second.is() )
|
||||
aIter = mxStreamMap->find( rURLStr );
|
||||
if( aIter != mxStreamMap->end() && aIter->second.is() )
|
||||
pOut = aIter->second.get();
|
||||
}
|
||||
|
||||
@@ -450,7 +450,7 @@ OUString SvXMLEmbeddedObjectHelper::ImplInsertEmbeddedObjectURL(
|
||||
|
||||
if( pOut )
|
||||
{
|
||||
mpStreamMap->erase( aIter );
|
||||
mxStreamMap->erase( aIter );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -576,18 +576,18 @@ Any SAL_CALL SvXMLEmbeddedObjectHelper::getByName(
|
||||
if( SvXMLEmbeddedObjectHelperMode::Read == meCreateMode )
|
||||
{
|
||||
Reference < XOutputStream > xStrm;
|
||||
if( mpStreamMap )
|
||||
if( mxStreamMap )
|
||||
{
|
||||
auto aIter = mpStreamMap->find( rURLStr );
|
||||
if( aIter != mpStreamMap->end() && aIter->second.is() )
|
||||
auto aIter = mxStreamMap->find( rURLStr );
|
||||
if( aIter != mxStreamMap->end() && aIter->second.is() )
|
||||
xStrm = aIter->second.get();
|
||||
}
|
||||
if( !xStrm.is() )
|
||||
{
|
||||
rtl::Reference<OutputStorageWrapper_Impl> xOut = new OutputStorageWrapper_Impl;
|
||||
if( !mpStreamMap )
|
||||
mpStreamMap.reset( new std::map< OUString, rtl::Reference<OutputStorageWrapper_Impl> > );
|
||||
(*mpStreamMap)[rURLStr] = xOut;
|
||||
if( !mxStreamMap )
|
||||
mxStreamMap.emplace();
|
||||
(*mxStreamMap)[rURLStr] = xOut;
|
||||
xStrm = xOut.get();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user