summaryrefslogtreecommitdiff
path: root/svx/source/gallery2
diff options
context:
space:
mode:
authorAditya <adityasahu1511@gmail.com>2020-07-30 15:04:27 +0530
committerTomaž Vajngerl <quikee@gmail.com>2020-07-31 19:02:41 +0200
commit6e717f4552aa937cd2609a79199a5b40b38789a4 (patch)
tree8ad965abe938efa688996fae062a28116ac491ff /svx/source/gallery2
parent3295afc91226ef1c395fd1eb289fa588a9a8c6d5 (diff)
svx:Move functions from GalleryTheme that belong to GalleryObjectCollection
Move 3 functions from ImplGetObjectURL(sal_uInt32 nPos), ImplGetObjectURL(const INetURLObject& rURL) and ImplGetObjectPos(const GalleryObject* pObj) to GalleryObjectCollection as they deal with the m_aObjectList directly, and rename them respectively. Change-Id: I1e02b345d706c57db8801441fc955af9157cf565 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99789 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx/source/gallery2')
-rw-r--r--svx/source/gallery2/galleryobjectcollection.cxx25
-rw-r--r--svx/source/gallery2/galtheme.cxx20
2 files changed, 31 insertions, 14 deletions
diff --git a/svx/source/gallery2/galleryobjectcollection.cxx b/svx/source/gallery2/galleryobjectcollection.cxx
index 0ab69de1a0a4..5080ed334916 100644
--- a/svx/source/gallery2/galleryobjectcollection.cxx
+++ b/svx/source/gallery2/galleryobjectcollection.cxx
@@ -20,6 +20,31 @@
#include <galobj.hxx>
#include <svx/galleryobjectcollection.hxx>
+GalleryObjectCollection::GalleryObjectCollection() {}
+
void GalleryObjectCollection::clear() { m_aObjectList.clear(); }
+const GalleryObject* GalleryObjectCollection::searchObjectWithURL(const INetURLObject& rURL)
+{
+ for (auto const& i : m_aObjectList)
+ if (i->aURL == rURL)
+ return i.get();
+ return nullptr;
+}
+
+sal_uInt32 GalleryObjectCollection::searchPosWithObject(const GalleryObject* pObj)
+{
+ for (sal_uInt32 i = 0, n = size(); i < n; ++i)
+ if (pObj == get(i).get())
+ return i;
+ return SAL_MAX_UINT32;
+}
+
+const GalleryObject* GalleryObjectCollection::getForPosition(sal_uInt32 nPos) const
+{
+ if (nPos < size())
+ return get(nPos).get();
+ return nullptr;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index 3c2bb6cc78c0..2bb71540cf29 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -94,14 +94,6 @@ std::unique_ptr<GalleryBinaryEngine> GalleryTheme::createGalleryBinaryEngine(boo
return pGalleryBinaryEngine;
}
-const GalleryObject* GalleryTheme::ImplGetGalleryObject(const INetURLObject& rURL)
-{
- for (auto const& i : maGalleryObjectCollection.getObjectList())
- if (i->aURL == rURL)
- return i.get();
- return nullptr;
-}
-
void GalleryTheme::ImplBroadcast(sal_uInt32 nUpdatePos)
{
if( !IsBroadcasterLocked() )
@@ -162,7 +154,7 @@ bool GalleryTheme::InsertObject(const SgaObject& rObj, sal_uInt32 nInsertPos)
std::unique_ptr<SgaObject> GalleryTheme::AcquireObject(sal_uInt32 nPos)
{
- return mpGalleryBinaryEngine->implReadSgaObject(ImplGetGalleryObject(nPos));
+ return mpGalleryBinaryEngine->implReadSgaObject(maGalleryObjectCollection.getForPosition(nPos));
}
void GalleryTheme::GetPreviewBitmapExAndStrings(sal_uInt32 nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath)
@@ -335,7 +327,7 @@ bool GalleryTheme::GetThumb(sal_uInt32 nPos, BitmapEx& rBmp)
bool GalleryTheme::GetGraphic(sal_uInt32 nPos, Graphic& rGraphic)
{
- const GalleryObject* pObject = ImplGetGalleryObject( nPos );
+ const GalleryObject* pObject = maGalleryObjectCollection.getForPosition( nPos );
bool bRet = false;
if( pObject )
@@ -460,7 +452,7 @@ bool GalleryTheme::InsertGraphic(const Graphic& rGraphic, sal_uInt32 nInsertPos)
bool GalleryTheme::GetModel(sal_uInt32 nPos, SdrModel& rModel)
{
- const GalleryObject* pObject = ImplGetGalleryObject( nPos );
+ const GalleryObject* pObject = maGalleryObjectCollection.getForPosition( nPos );
bool bRet = false;
if( pObject && ( SgaObjKind::SvDraw == pObject->eObjKind ) )
@@ -482,7 +474,7 @@ bool GalleryTheme::InsertModel(const FmFormModel& rModel, sal_uInt32 nInsertPos)
bool GalleryTheme::GetModelStream(sal_uInt32 nPos, tools::SvRef<SotStorageStream> const & rxModelStream)
{
- const GalleryObject* pObject = ImplGetGalleryObject( nPos );
+ const GalleryObject* pObject = maGalleryObjectCollection.getForPosition( nPos );
bool bRet = false;
if( pObject && ( SgaObjKind::SvDraw == pObject->eObjKind ) )
@@ -506,7 +498,7 @@ bool GalleryTheme::InsertModelStream(const tools::SvRef<SotStorageStream>& rxMod
bool GalleryTheme::GetURL(sal_uInt32 nPos, INetURLObject& rURL)
{
- const GalleryObject* pObject = ImplGetGalleryObject( nPos );
+ const GalleryObject* pObject = maGalleryObjectCollection.getForPosition( nPos );
bool bRet = false;
if( pObject )
@@ -671,7 +663,7 @@ SvStream& GalleryTheme::WriteData( SvStream& rOStm ) const
for( sal_uInt32 i = 0; i < nCount; i++ )
{
- const GalleryObject* pObj = ImplGetGalleryObject( i );
+ const GalleryObject* pObj = maGalleryObjectCollection.getForPosition( i );
OUString aPath;
if( SgaObjKind::SvDraw == pObj->eObjKind )