Kaydet (Commit) b40ca093 authored tarafından Zolnai Tamás's avatar Zolnai Tamás

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
üst fe2b8ef1
...@@ -153,12 +153,43 @@ bool Embed3DModel( const uno::Reference<frame::XModel>& xModel, ...@@ -153,12 +153,43 @@ bool Embed3DModel( const uno::Reference<frame::XModel>& xModel,
if (bIsDAE || bIsKMZ) if (bIsDAE || bIsKMZ)
{ {
std::shared_ptr <GLTF::GLTFAsset> asset(new GLTF::GLTFAsset()); 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) if (bIsKMZ)
{ {
// KMZ converter needs a system path // KMZ converter needs a system path
const INetURLObject aSourceURLObj(rSourceURL);
const std::string sSourcePath = const std::string sSourcePath =
OUStringToOString( aSourceURLObj.getFSysPath(INetURLObject::FSYS_DETECT), RTL_TEXTENCODING_UTF8 ).getStr(); OUStringToOString( aSourceURLObj.getFSysPath(INetURLObject::FSYS_DETECT), RTL_TEXTENCODING_UTF8 ).getStr();
const std::string strDaeFilePath = GLTF::Kmz2Collada()(sSourcePath); const std::string strDaeFilePath = GLTF::Kmz2Collada()(sSourcePath);
...@@ -172,12 +203,6 @@ bool Embed3DModel( const uno::Reference<frame::XModel>& xModel, ...@@ -172,12 +203,6 @@ bool Embed3DModel( const uno::Reference<frame::XModel>& xModel,
asset->setInputFilePath(OUStringToOString( sDaeFilePath, RTL_TEXTENCODING_UTF8 ).getStr()); 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); GLTF::COLLADA2GLTFWriter writer(asset);
writer.write(); writer.write();
// Path to the .json file created by COLLADA2GLTFWriter // Path to the .json file created by COLLADA2GLTFWriter
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment