[Libreoffice-commits] core.git: include/svx svx/source
Aditya (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 31 17:00:36 UTC 2020
include/svx/gallerybinaryengine.hxx | 2 +
svx/source/gallery2/gallerybinaryengine.cxx | 46 ++++++++++++++++++++++++++++
svx/source/gallery2/galtheme.cxx | 40 +-----------------------
3 files changed, 51 insertions(+), 37 deletions(-)
New commits:
commit 3295afc91226ef1c395fd1eb289fa588a9a8c6d5
Author: Aditya <adityasahu1511 at gmail.com>
AuthorDate: Mon Jul 27 17:03:52 2020 +0530
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Fri Jul 31 19:00:00 2020 +0200
svx: Refactor GalleryTheme's insertFileOrDirURL function
Change-Id: I8784022851e3481d94a1b23c72e59dedf739e507
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99479
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/svx/gallerybinaryengine.hxx b/include/svx/gallerybinaryengine.hxx
index b878200a12e5..cf56b98c8c47 100644
--- a/include/svx/gallerybinaryengine.hxx
+++ b/include/svx/gallerybinaryengine.hxx
@@ -88,6 +88,8 @@ public:
SgaObjectSvDraw updateSvDrawObject(GalleryObject* pEntry);
void updateTheme();
+ static void insertFileOrDirURL(const INetURLObject& rFileOrDirURL,
+ std::vector<INetURLObject>& rURLVector);
};
SvStream& WriteGalleryTheme(SvStream& rOut, const GalleryTheme& rTheme);
diff --git a/svx/source/gallery2/gallerybinaryengine.cxx b/svx/source/gallery2/gallerybinaryengine.cxx
index 9a3cc550198a..f5ddc213000e 100644
--- a/svx/source/gallery2/gallerybinaryengine.cxx
+++ b/svx/source/gallery2/gallerybinaryengine.cxx
@@ -30,13 +30,17 @@
#include <sal/log.hxx>
#include <com/sun/star/ucb/ContentCreationException.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
#include <comphelper/fileformat.h>
#include <comphelper/graphicmimetype.hxx>
+#include <comphelper/processfactory.hxx>
#include <tools/urlobj.hxx>
#include <tools/diagnose_ex.h>
#include <unotools/ucbstreamhelper.hxx>
#include <unotools/streamwrap.hxx>
#include <unotools/tempfile.hxx>
+#include <ucbhelper/content.hxx>
#include <tools/urlobj.hxx>
#include <tools/vcompat.hxx>
@@ -614,6 +618,48 @@ void GalleryBinaryEngine::updateTheme()
KillFile(aTmpURL);
}
+void GalleryBinaryEngine::insertFileOrDirURL(const INetURLObject& rFileOrDirURL,
+ std::vector<INetURLObject>& rURLVector)
+{
+ INetURLObject aURL;
+ try
+ {
+ ::ucbhelper::Content aCnt(rFileOrDirURL.GetMainURL(INetURLObject::DecodeMechanism::NONE),
+ uno::Reference<ucb::XCommandEnvironment>(),
+ comphelper::getProcessComponentContext());
+ bool bFolder = false;
+
+ aCnt.getPropertyValue("IsFolder") >>= bFolder;
+
+ if (bFolder)
+ {
+ uno::Sequence<OUString> aProps{ "Url" };
+ uno::Reference<sdbc::XResultSet> xResultSet(
+ aCnt.createCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY));
+ uno::Reference<ucb::XContentAccess> xContentAccess(xResultSet, uno::UNO_QUERY);
+ if (xContentAccess.is())
+ {
+ while (xResultSet->next())
+ {
+ aURL.SetSmartURL(xContentAccess->queryContentIdentifierString());
+ rURLVector.push_back(aURL);
+ }
+ }
+ }
+ else
+ rURLVector.push_back(rFileOrDirURL);
+ }
+ catch (const ucb::ContentCreationException&)
+ {
+ }
+ catch (const uno::RuntimeException&)
+ {
+ }
+ catch (const uno::Exception&)
+ {
+ }
+}
+
SvStream& WriteGalleryTheme(SvStream& rOut, const GalleryTheme& rTheme)
{
return rTheme.WriteData(rOut);
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index 557fbca1406a..3c2bb6cc78c0 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -545,43 +545,9 @@ bool GalleryTheme::InsertURL(const INetURLObject& rURL, sal_uInt32 nInsertPos)
bool GalleryTheme::InsertFileOrDirURL(const INetURLObject& rFileOrDirURL, sal_uInt32 nInsertPos)
{
- INetURLObject aURL;
- ::std::vector< INetURLObject > aURLVector;
- bool bRet = false;
-
- try
- {
- ::ucbhelper::Content aCnt( rFileOrDirURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), uno::Reference< ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
- bool bFolder = false;
-
- aCnt.getPropertyValue("IsFolder") >>= bFolder;
-
- if( bFolder )
- {
- uno::Sequence<OUString> aProps { "Url" };
- uno::Reference< sdbc::XResultSet > xResultSet( aCnt.createCursor( aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) );
- uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
- if( xContentAccess.is() )
- {
- while( xResultSet->next() )
- {
- aURL.SetSmartURL( xContentAccess->queryContentIdentifierString() );
- aURLVector.push_back( aURL );
- }
- }
- }
- else
- aURLVector.push_back( rFileOrDirURL );
- }
- catch( const ucb::ContentCreationException& )
- {
- }
- catch( const uno::RuntimeException& )
- {
- }
- catch( const uno::Exception& )
- {
- }
+ bool bRet = false;
+ std::vector< INetURLObject > aURLVector;
+ GalleryBinaryEngine::insertFileOrDirURL(rFileOrDirURL, aURLVector);
for( const auto& rURL : aURLVector )
bRet = bRet || InsertURL( rURL, nInsertPos );
More information about the Libreoffice-commits
mailing list