diff --git a/src/transition/UniboardSankoreTransition.cpp b/src/transition/UniboardSankoreTransition.cpp index 03502165..3bd2901c 100644 --- a/src/transition/UniboardSankoreTransition.cpp +++ b/src/transition/UniboardSankoreTransition.cpp @@ -106,11 +106,16 @@ bool UniboardSankoreTransition::checkPage(QString& sankorePagePath) sankoreDirectory = QUrl::fromLocalFile(sankoreDirectory).toString(); QString documentString(documentByteArray); - documentString.replace("xlink:href=\"videos/","xlink:href=\"" + sankoreDirectory + "/videos/"); + QRegExp videoRegExp(""); + videoRegExp.setMinimal(true); - documentString.replace("xlink:href=\"objects/","xlink:href=\"" + sankoreDirectory + "/objects/"); + documentString.replace(videoRegExp,""); - documentString.replace("xlink:href=\"audios/","xlink:href=\"" + sankoreDirectory + "/audios/"); + + QRegExp audioRegExp(""); + audioRegExp.setMinimal(true); + + documentString.replace(audioRegExp,""); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return false; @@ -133,7 +138,36 @@ bool UniboardSankoreTransition::checkWidget(QString& sankoreWidgetIndexPath) QString documentString(documentByteArray); - documentString.replace("/Uniboard/interactive content","/Sankore/interactive content"); + QRegExp swfOriginFilePathRegExp(""); + swfOriginFilePathRegExp.setMinimal(true); + swfOriginFilePathRegExp.indexIn(documentString); + QString origin = swfOriginFilePathRegExp.cap(1); + if(origin.contains("http://")){ + // an url is the source of the swf. The source is kept as is. + return true; + } + + //changing the path + QRegExp swfDataPathRegExp(""); + swfDataPathRegExp.setMinimal(true); + documentString.replace(swfDataPathRegExp,""); + + QRegExp swfMoviePathRegExp(""); + swfMoviePathRegExp.setMinimal(true); + documentString.replace(swfMoviePathRegExp,""); + + //copy the swf on the right place + QRegExp swfFileNameRegExp(""); + swfFileNameRegExp.setMinimal(true); + swfFileNameRegExp.indexIn(documentString); + QString swfFileName = swfFileNameRegExp.cap(1); + int lastDirectoryLevel = sankoreWidgetIndexPath.lastIndexOf("/"); + if (lastDirectoryLevel == -1) + lastDirectoryLevel = sankoreWidgetIndexPath.lastIndexOf("\\"); + + + QString destination(sankoreWidgetIndexPath.left(lastDirectoryLevel) + "/" + swfFileName); + QFile(origin).copy(destination); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return false; @@ -217,10 +251,6 @@ void UniboardSankoreTransition::executeTransition() UBFileSystemUtils::deleteDir(backupDestinationPath); } else{ - QString sankoreInteractiveAppPath = sankoreDocumentDirectory; - sankoreInteractiveAppPath = sankoreInteractiveAppPath.replace("document","") + "interactive content/"; - UBFileSystemUtils::copyDir(mOldSankoreDirectory + "/interactive content", sankoreInteractiveAppPath); - UBFileSystemUtils::copyDir(mUniboardSourceDirectory + "/interactive content", sankoreInteractiveAppPath); UBFileSystemUtils::deleteDir(mOldSankoreDirectory); UBFileSystemUtils::deleteDir(mUniboardSourceDirectory); }