summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorAditya <adityasahu1511@gmail.com>2020-07-27 17:03:52 +0530
committerTomaž Vajngerl <quikee@gmail.com>2020-07-31 19:00:00 +0200
commit3295afc91226ef1c395fd1eb289fa588a9a8c6d5 (patch)
tree44b61321c044015df186b0454d9018455e444f5b /svx
parent91f0f7e5e0a55cb1dbd729a1d7de52388b1cfb15 (diff)
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@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/gallery2/gallerybinaryengine.cxx46
-rw-r--r--svx/source/gallery2/galtheme.cxx40
2 files changed, 49 insertions, 37 deletions
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 );