[Libreoffice-commits] core.git: avmedia/source
Zolnai Tamás
tamas.zolnai at collabora.com
Thu May 22 10:42:33 PDT 2014
avmedia/source/framework/modeltools.cxx | 41 +++++++++++++++++++++++++-------
1 file changed, 33 insertions(+), 8 deletions(-)
New commits:
commit b40ca0935d72a3aff8a2beeabec156850c3417ba
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Thu May 22 19:19:02 2014 +0200
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
diff --git a/avmedia/source/framework/modeltools.cxx b/avmedia/source/framework/modeltools.cxx
index a7237d5..7de35f7 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
More information about the Libreoffice-commits
mailing list