summaryrefslogtreecommitdiff
path: root/avmedia
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-05-22 19:19:02 +0200
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-05-22 19:41:01 +0200
commitb40ca0935d72a3aff8a2beeabec156850c3417ba (patch)
tree762d986ab8803b721c239107c39fef723d96f8ad /avmedia
parentfe2b8ef18b11b226fddd1cf3fc7f9133426a1b1a (diff)
glTF: download *.dae and *.kmz files to the temp folder before conversion
Copy them to the same folder where the conversion output is written. Change-Id: I38b93bf3fc427974cff7d6975151451a253b1cce
Diffstat (limited to 'avmedia')
-rw-r--r--avmedia/source/framework/modeltools.cxx41
1 files changed, 33 insertions, 8 deletions
diff --git a/avmedia/source/framework/modeltools.cxx b/avmedia/source/framework/modeltools.cxx
index a7237d585c5f..7de35f7855ab 100644
--- a/avmedia/source/framework/modeltools.cxx
+++ b/avmedia/source/framework/modeltools.cxx
@@ -153,12 +153,43 @@ bool Embed3DModel( const uno::Reference<frame::XModel>& xModel,
if (bIsDAE || bIsKMZ)
{
std::shared_ptr <GLTF::GLTFAsset> asset(new GLTF::GLTFAsset());
- asset->setInputFilePath(OUStringToOString( rSourceURL, RTL_TEXTENCODING_UTF8 ).getStr());
+
+ OUString sOutput;
+ ::utl::LocalFileHelper::ConvertPhysicalNameToURL(::utl::TempFile::CreateTempName(), sOutput);
+ // remove .tmp extension
+ sOutput = sOutput.copy(0, sOutput.getLength()-4);
+ asset->setBundleOutputPath(OUStringToOString( sOutput, RTL_TEXTENCODING_UTF8 ).getStr());
+
+ const INetURLObject aSourceURLObj(sSource);
+ // If *.dae or *.kmz file is not in the local file system, then copy them to a temp folder for the conversion
+ if(aSourceURLObj.GetProtocol() != INET_PROT_FILE )
+ {
+ try
+ {
+ ::ucbhelper::Content aSourceContent(sSource,
+ uno::Reference<ucb::XCommandEnvironment>(),
+ comphelper::getProcessComponentContext());
+
+ const OUString sTarget = sOutput + GetFilename(sSource);
+ ::ucbhelper::Content aTempContent(sTarget,
+ uno::Reference<ucb::XCommandEnvironment>(),
+ comphelper::getProcessComponentContext());
+
+ aTempContent.writeStream(aSourceContent.openStream(), true);
+ sSource = sTarget;
+ }
+ catch (const uno::Exception&)
+ {
+ SAL_WARN("avmedia.opengl", "Exception while trying to copy source file to the temp folder for conversion:\n" << sSource);
+ return false;
+ }
+ }
+
+ asset->setInputFilePath(OUStringToOString( sSource, RTL_TEXTENCODING_UTF8 ).getStr());
if (bIsKMZ)
{
// KMZ converter needs a system path
- const INetURLObject aSourceURLObj(rSourceURL);
const std::string sSourcePath =
OUStringToOString( aSourceURLObj.getFSysPath(INetURLObject::FSYS_DETECT), RTL_TEXTENCODING_UTF8 ).getStr();
const std::string strDaeFilePath = GLTF::Kmz2Collada()(sSourcePath);
@@ -172,12 +203,6 @@ bool Embed3DModel( const uno::Reference<frame::XModel>& xModel,
asset->setInputFilePath(OUStringToOString( sDaeFilePath, RTL_TEXTENCODING_UTF8 ).getStr());
}
- OUString sOutput;
- ::utl::LocalFileHelper::ConvertPhysicalNameToURL(::utl::TempFile::CreateTempName(), sOutput);
- // remove .tmp extension
- sOutput = sOutput.copy(0, sOutput.getLength()-4);
- asset->setBundleOutputPath(OUStringToOString( sOutput, RTL_TEXTENCODING_UTF8 ).getStr());
-
GLTF::COLLADA2GLTFWriter writer(asset);
writer.write();
// Path to the .json file created by COLLADA2GLTFWriter