Merge pull request #4527 from riadvice/fix-file-download

[Flash 2.1] - Use new presentationModel logic to export PDF files.
This commit is contained in:
Richard Alam 2017-10-13 17:38:28 -04:00 committed by GitHub
commit 0ecd191725
4 changed files with 21 additions and 11 deletions

View File

@ -19,6 +19,7 @@
package org.bigbluebutton.modules.present.events {
import flash.events.Event;
import org.bigbluebutton.modules.present.model.PresentationModel;
import org.bigbluebutton.modules.present.ui.views.models.SlideViewModel;
public class ExportEvent extends Event {
@ -38,6 +39,8 @@ package org.bigbluebutton.modules.present.events {
public var slideModel:SlideViewModel;
public var presentationModel:PresentationModel;
public function ExportEvent(type:String) {
super(type, true, false);
}

View File

@ -169,6 +169,7 @@ package org.bigbluebutton.modules.present.managers
exportWindow.numberOfPages = e.numberOfPages;
exportWindow.slidesUrl = e.slidesUrl;
exportWindow.slideModel = e.slideModel;
exportWindow.presentationModel = e.presentationModel;
}
}

View File

@ -39,9 +39,9 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<![CDATA[
import flash.utils.ByteArray;
import flash.utils.setTimeout;
import mx.events.FlexEvent;
import org.alivepdf.colors.RGBColor;
import org.alivepdf.display.Display;
import org.alivepdf.drawing.Caps;
@ -74,6 +74,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
public var slidesUrl:String;
public var slideModel:SlideViewModel;
public var presentationModel:PresentationModel;
private var _pdf:PDF;
@ -86,7 +88,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
private static const LOGGER:ILogger = getClassLogger(FileExportWindow);
protected function creationCompleteHandler(event:FlexEvent):void {
fileName = PresentationModel.getInstance().getCurrentPresentation().name;
fileName = presentationModel.getCurrentPresentation().name;
fileName = StringUtils.substringBeforeLast(fileName, ".");
addEventListener("pdfComplete", pdfCompleteHandler);
@ -114,12 +116,12 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
protected function nextPdfPageHandler(event:Event):void {
progressBar.label = ResourceUtil.getInstance().getString('bbb.presentationExport.converting', [PresentationModel.getInstance().getCurrentPresentation().name, _currentPage > numberOfPages ? 1 : _currentPage, numberOfPages]);
progressBar.label = ResourceUtil.getInstance().getString('bbb.presentationExport.converting', [presentationModel.getCurrentPresentation().name, _currentPage > numberOfPages ? 1 : _currentPage, numberOfPages]);
progressBar.setProgress(_currentPage > numberOfPages ? 0 : _currentPage, _currentPage > numberOfPages ? 1 : numberOfPages);
var pageLoader:Loader = new Loader();
pageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, function():void {
var pagePath:String = PresentationModel.getInstance().getCurrentPresentation().id + "/" + _currentPage;
var pagePath:String = presentationModel.getCurrentPresentation().id + "/" + _currentPage;
LOGGER.debug(_currentPage + " - Page model path: " + pagePath);
var annotations:Array = LiveMeeting.inst().whiteboardModel.getAnnotations(pagePath);

View File

@ -649,11 +649,13 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
private function openExportWindow(firstPage:int, numberOfPages:int):void {
var presentationModel:PresentationModel = PresentationPodManager.getInstance().getPod(podId);
var event:ExportEvent = new ExportEvent(ExportEvent.OPEN_EXPORT_WINDOW);
event.firstPage = firstPage;
event.numberOfPages = numberOfPages;
event.slidesUrl = StringUtils.substringBeforeLast(PresentationModel.getInstance().getCurrentPage().swfUri, "/") + "/";
event.slidesUrl = StringUtils.substringBeforeLast(presentationModel.getCurrentPage().swfUri, "/") + "/";
event.slideModel = slideView.slideModel;
event.presentationModel = presentationModel;
dispatchEvent(event);
}
@ -693,13 +695,14 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
private function setDownloadMenuData():void {
var presentationModel:PresentationModel = PresentationPodManager.getInstance().getPod(podId);
var resourceUtil:ResourceUtil = ResourceUtil.getInstance();
downloadMenuData = [];
if (PresentationModel.getInstance().getCurrentPresentation()) {
if (presentationModel.getCurrentPresentation()) {
downloadMenuData.push({label: resourceUtil.getString("bbb.presentation.downloadMenu.slideWithAnnotations"), data:"slide_annotation"});
downloadMenuData.push({label: resourceUtil.getString("bbb.presentation.downloadMenu.presentationWithAnnotations"), data:"presentation_annotation"});
}
if (PresentationModel.getInstance().getDownloadablePresentations().length > 0){
if (presentationModel.getDownloadablePresentations().length > 0){
downloadMenuData.push({label: resourceUtil.getString("bbb.presentation.downloadMenu.presentations"), data:"presentations"});
}
}
@ -813,10 +816,11 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
private function downloadMenuClickHandler(e:MenuEvent):void {
var presentationModel:PresentationModel = PresentationPodManager.getInstance().getPod(podId);
if (e.item.data == "slide_annotation") {
openExportWindow(PresentationModel.getInstance().getCurrentPage().num, 1);
openExportWindow(presentationModel.getCurrentPage().num, 1);
} else if (e.item.data == "presentation_annotation") {
openExportWindow(1, PresentationModel.getInstance().getNumberOfPages());
openExportWindow(1, presentationModel.getNumberOfPages());
} else if (e.item.data == "presentations") {
openDownloadWindow();
}
@ -931,7 +935,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
var presentationModel:PresentationModel = PresentationPodManager.getInstance().getPod(podId);
if (presentationModel != null) {
var downloadablePresentations:ArrayCollection = presentationModel.getDownloadablePresentations();
if ( presentOptions.enableDownload && (downloadablePresentations.length > 0 || PresentationModel.getInstance().getCurrentPresentation()) ) {
if ( presentOptions.enableDownload && (downloadablePresentations.length > 0 || presentationModel.getCurrentPresentation()) ) {
LOGGER.debug("Enabling download presentation button. There are {0} presentations available for downloading.", [downloadablePresentations.length]);
downloadPres.visible = true;
} else {