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