Mini Kabibi Habibi
PK
��rI � chrome/SD� ��Uqcd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�121001la`ie�`��(� V � b3�@��l���R��᱓��BF�>�+� h�J!;Av0I0� )d�a� itq UT
~�/X`�/X`�/XPK
v�rI � chrome/content/SD� ��Uqcd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�121001la`ie�`��(� V � b3�@��l���R��᱓��BF�>�+� h�J!;Av0I0� )d�a� itq UT
`�/X`�/X`�/XPK
��rI�
�
�
� chrome/content/browser_status.jsSDk � ��R�cd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�1210010���J0�g�g ���P �E � aV!0��c'��J!��� UT
~�/X~�/X~�/X/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2016 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
/*
Progress Listeners for Document Download to Enable\Disable ConvertButton should be added
to this file if Enable\Disable is to be supported. Look at Perforce History of this file
for cleanedup code.
Currently the event listener for context menu to show appropriate context menu options is registered.
*/
window.addEventListener("load",registerMyContextMenuListener,false);
function registerMyContextMenuListener()
{
try
{
if(document.getElementById("contentAreaContextMenu"))
{
document.getElementById("contentAreaContextMenu").addEventListener("popupshowing",web2pdf_OnContextMenuPopup,false);
}
}
catch(err)
{
//alert("err =" + err);
}
}
function registerMyCutomizableToolBarButton()
{
try
{
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
var prefs = prefService.getBranch("");
var prefValue = prefs.getBoolPref("extensions.web2pdf.pref_create_toolbar_button_in_nav-bar");
if(prefValue == true)
{
var myCutomizableToolBarButton = "acro_web2pdf_ConvertButton";
var navBar = document.getElementById("nav-bar");
if (navBar)
{
var curSet = navBar.currentSet.split(",");
if (curSet.indexOf(myCutomizableToolBarButton) == -1)
{
var pos = curSet.length;
var set = curSet.slice(0, pos).concat(myCutomizableToolBarButton).concat(curSet.slice(pos));
navBar.setAttribute("currentset", set.join(","));
navBar.currentSet = set.join(",");
document.persist(navBar.id, "currentset");
prefs.setBoolPref("extensions.web2pdf.pref_create_toolbar_button_in_nav-bar", !prefValue);
prefService.savePrefFile(null);
try
{
BrowserToolboxCustomizeDone(true);
}
catch (e) {}
}
}
}
}
catch(err)
{
//alert("err =" + err);
}
}
//Firefox >= 4, Add ToolBar button in Navigation Bar
if(!(Application.extensions))
registerMyCutomizableToolBarButton();PK
��rI�od�� � � chrome/content/overlay_next.xulSDk � ��R�cd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�1210010���J0�g�g ���P �E � aV!0��c'��J!��� UT
~�/X`�/X`�/X<?xml version="1.0"?>
<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/browser.css" type="text/css"?>
<?xml-stylesheet href="chrome://web2pdfextension/skin/web2pdf.css" type="text/css"?>
<!DOCTYPE overlay SYSTEM "chrome://web2pdfextension/locale/web2pdf.dtd">
<overlay
id="acro_web2pdf_Overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
<stringbundleset >
<stringbundle id="acro_web2pdf_JavaStrings"
src="chrome://web2pdfextension/locale/web2pdf.properties" />
</stringbundleset>
<script type="application/x-javascript"
src="chrome://web2pdfextension/content/web2pdf_utils.js" />
<script type="application/x-javascript"
src="chrome://web2pdfextension/content/web2pdf_prefs.js" />
<script type="application/x-javascript"
src="chrome://web2pdfextension/content/web2pdf_new.js" />
<script type="application/x-javascript"
src="chrome://web2pdfextension/content/web2pdf_conversion.js" />
<script type="application/x-javascript"
src="chrome://web2pdfextension/content/browser_status.js" />
<popup id="contentAreaContextMenu">
<menuseparator id="acro_web2pdf_ContextMenuSeparatorStart"/>
<menuitem id="acro_web2pdf_ConvertContextMenu_SelectedLink" label="&web2pdf.menu.Convert_To_PDF_SelectedLink;"
oncommand="web2pdf_ConvertToPDF(web2pdfCaller.MENU,web2pdfType.CONVERT,web2pdfContext.LINK); event.stopPropagation();"/>
<menuitem id="acro_web2pdf_AppendContextMenu_SelectedLink" label="&web2pdf.menu.Add_To_Existing_SelectedLink;"
oncommand="web2pdf_ConvertToPDF(web2pdfCaller.MENU,web2pdfType.APPEND,web2pdfContext.LINK); event.stopPropagation();"/>
<menuitem id="acro_web2pdf_ConvertContextMenu" label="&web2pdf.menu.Convert_To_PDF;"
oncommand="web2pdf_ConvertToPDF(web2pdfCaller.MENU,web2pdfType.CONVERT,web2pdfContext.PAGE); event.stopPropagation();"/>
<menuitem id="acro_web2pdf_AppendContextMenu" label="&web2pdf.menu.Add_To_Existing;"
oncommand="web2pdf_ConvertToPDF(web2pdfCaller.MENU,web2pdfType.APPEND,web2pdfContext.PAGE); event.stopPropagation();"/>
<menuitem id="acro_web2pdf_ConvertContextMenu_Selection" label="&web2pdf.menu.ConvertSelection;"
oncommand="web2pdf_ConvertToPDF(web2pdfCaller.MENU,web2pdfType.CONVERT,web2pdfContext.SELECTION); event.stopPropagation();"/>
<menuitem id="acro_web2pdf_AppendContextMenu_Selection" label="&web2pdf.menu.AppendSelection;"
oncommand="web2pdf_ConvertToPDF(web2pdfCaller.MENU,web2pdfType.APPEND,web2pdfContext.SELECTION); event.stopPropagation();"/>
</popup>
<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="acro_web2pdf_ConvertButton" image="chrome://web2pdfextension/skin/AX_WebCap_ConvertButton_Sm_N.png"
label="&web2pdf.ConvertButtonText;" type="menu-button" tooltiptext="&web2pdf.menu.ToolTipText;"
class='toolbarbutton-1 chromeclass-toolbar-additional'
oncommand="web2pdf_ConvertToPDF(web2pdfCaller.TOOLBAR,web2pdfType.CONVERT,web2pdfContext.PAGE);" ConversionId="100" orient="horizontal">
<menupopup onpopupshowing="web2pdf_InitPrefs(); event.stopPropagation();" oncommand="event.stopPropagation();">
<menuitem id="acro_web2pdf_ConvertToPDF" image="chrome://web2pdfextension/skin/AX_WebCap_Converted_Sm_N.png"
label="&web2pdf.menu.Convert_To_PDF;" class="menuitem-iconic"
oncommand="web2pdf_ConvertToPDF(web2pdfCaller.TOOLBAR,web2pdfType.CONVERT,web2pdfContext.PAGE); event.stopPropagation();" />
<menuitem id="acro_web2pdf_AddToExisting" image="chrome://web2pdfextension/skin/AX_Append_Sm_N.png"
label="&web2pdf.menu.Add_To_Existing;" class="menuitem-iconic"
oncommand="web2pdf_ConvertToPDF(web2pdfCaller.TOOLBAR,web2pdfType.APPEND,web2pdfContext.PAGE); event.stopPropagation();" />
<menuitem id="acro_web2pdf_PrintWebPage" image="chrome://web2pdfextension/skin/AX_PrintWebPage_Sm_N.png"
label="&web2pdf.menu.Print_Web_Page;" class="menuitem-iconic"
oncommand="web2pdf_ConvertToPDF(web2pdfCaller.TOOLBAR,web2pdfType.CONVERT,web2pdfContext.PRINT); event.stopPropagation();" />
<menuitem id="acro_web2pdf_ConvertAndEmail" image="chrome://web2pdfextension/skin/AX_ConvertWebEmail_Sm_N.png"
label="&web2pdf.menu.Convert_and_Email;" class="menuitem-iconic"
oncommand="web2pdf_ConvertToPDF(web2pdfCaller.TOOLBAR,web2pdfType.CONVERT,web2pdfContext.EMAIL); event.stopPropagation();" />
<menuseparator />
<menuitem id="acro_web2pdf_ViewResultInAcrobat"
label="&web2pdf.menu.View_Result_In_Acrobat;" prefstring="extensions.web2pdf.pref_open_in_acrobat"
class="menuitem-iconic" type="checkbox" autoCheck="false" checked="false"
oncommand="web2pdf_SavePrefs(event); event.stopPropagation();" />
<menuitem id="acro_web2pdf_Prefrences" label="&web2pdf.menu.Prefrences;" class="menuitem-iconic"
oncommand="web2pdf_ShowConversionSettingsDialog(); event.stopPropagation();" />
</menupopup>
</toolbarbutton>
</toolbarpalette>
</overlay>
PK
��rIFpQ� � chrome/content/statusdlg.jsSDk � ��R�cd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�1210010���J0�g�g ���P �E � aV!0��c'��J!��� UT
~�/X`�/X`�/X/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2011 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
// Global variables to keep track of various timers.
const CONVERSION_ANIMATION_TIMER = 100;
// Constants to identify events.
const UPDATE_LIST_ITEMS = 0;
onmessage = function(event){
var web2pdf_doWait = event.data;
if(web2pdf_doWait)
setTimeout(function(){ UpdateStatusDlg(); }, CONVERSION_ANIMATION_TIMER);
else
UpdateStatusDlg();
};
function UpdateStatusDlg()
{
postMessage(UPDATE_LIST_ITEMS);
}
// Called when Close button is pressed.
function web2pdf_CloseStatusDialog()
{
window.close();
}
PK
��rI�^zV� � � chrome/content/statusdlg_new.xulSDk � ��R�cd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�1210010���J0�g�g ���P �E � aV!0��c'��J!��� UT
~�/X`�/X`�/X<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xml-stylesheet href="chrome://web2pdfextension/skin/web2pdf.css" type="text/css"?>
<!DOCTYPE dialog SYSTEM "chrome://web2pdfextension/locale/web2pdf.dtd">
<dialog id="acro_web2pdf_StatusDialog"
title="&web2pdf.status_dlg.title;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
ondialogcancel="web2pdf_CloseStatusDialog();"
buttons="&web2pdf.status_dlg.CloseButtonText;">
<script type="application/x-javascript"
src="chrome://web2pdfextension/content/statusdlg.js">
</script>
<stringbundleset >
<stringbundle id="acro_web2pdf_JavaStrings"
src="chrome://web2pdfextension/locale/web2pdf.properties" />
</stringbundleset>
<listbox id="acro_web2pdf_StatusListBox" rows="7" style="overflow: auto" overflow="auto">
<listitem id="acro_web2pdf_StatusListItem">
<hbox align="center">
<image src="chrome://web2pdfextension/skin/AX_WebCap_Converted_Sm_N.png"/>
<label value=""/>
<image src="chrome://web2pdfextension/skin/AX_ProgressSpin_Sm_01_N.png"/>
<label value=" " style="max-width: 10em"/>
<label value="-"/>
<label value=" "/>
</hbox>
</listitem>
</listbox>
<hbox>
<spacer flex="1"/>
<button
id="acro_web2pdf_StatusCloseButton"
class="dialog"
label="&web2pdf.status_dlg.CloseButtonText;"
oncommand="web2pdf_CloseStatusDialog();"/>
</hbox>
</dialog>
PK
��rI�1&�D �D $ � chrome/content/web2pdf_conversion.jsSDk � ��R�cd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�1210010���J0�g�g ���P �E � aV!0��c'��J!��� UT
~�/X`�/X`�/X/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2011 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
var web2pdf_xpcomPath = null;
const PlatformSpecificPtr = ctypes.StructType("WCFFPlatformSpecific").ptr;
var SetStateCallbackType = ctypes.FunctionType(ctypes.default_abi, ctypes.void_t, [ctypes.int, ctypes.int]);
var DoneCallbackType = ctypes.FunctionType(ctypes.default_abi, ctypes.void_t, [ctypes.int, ctypes.int]);
var SetStateCallback;
var DoneCallback;
/************************************************************************************************
* web2pdf_Conversion()
* ----------------------------------------------------------------------------------------------
* This function initializes web2pdf_Conversion object.
* REQUIRES: Nothing.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_Conversion()
{
//enums for conversion settings
//if any change is made in these, then the enum in the C++ code must also be changed.
this.UNSET = 0;
this.OPEN_IN_ACROBAT = 1;
this.APPEND = 1<<1;
this.CONVERT_PAGE = 1<<2;
this.CONVERT_LINK = 1<<3;
this.CONVERT_SELECTION = 1<<4;
this.PRINT = 1<<5;
this.EMAIL = 1<<6;
this.CALLER_TOOLBAR = 1<<7;
this.CLEAN_FILE_ON_FAILURE = 1<<8;
//enums for reporting conversion status
//if any change is made in these, then the enum in the C++ code must also be changed.
this.STATUS_WAITING = 10000;
this.STATUS_DOWNLOADING = 10001;
this.STATUS_CONVERTING = 10002;
this.STATUS_SUCCESS = 10003;
this.STATUS_ERROR = 10004;
this.STATUS_NOINSTANCE = 10005;
this.STATUS_FILELOCKED = 10006;
this.STATUS_MISSINGLIB = 10007;
//member variables
this.m_conversionID = 0;
this.m_conversionSettings = 0;
this.m_currentState = this.STATUS_DOWNLOADING;
this.m_url = null;
this.m_domData = null;
this.m_charSet = null;
this.m_outFilePath = "";
this.m_platformSpecific = null;
}
/************************************************************************************************
* InitPlatformSpecificData()
* ----------------------------------------------------------------------------------------------
* This function initializes the conversion progress dialog via dll calls.
* REQUIRES: Nothing.
* RETURNS: Nothing.
* **********************************************************************************************/
web2pdf_Conversion.prototype.InitPlatformSpecificData = function(){
if(web2pdf_FFExtnLib === null)
web2pdf_openLib();
if(web2pdf_FFExtnLib === null)
return;
try{
var InitPlatformSpecificData = web2pdf_FFExtnLib.declare("_C_InitPlatformSpecificData", ctypes.default_abi, PlatformSpecificPtr);
this.m_platformSpecific = InitPlatformSpecificData();
if(this.m_platformSpecific.isNull())
this.m_platformSpecific = null;
}
catch(err)
{
this.m_platformSpecific = null;
alert(err);
}
};
/************************************************************************************************
* ConvertToPDF()
* ----------------------------------------------------------------------------------------------
* This function sends all the data to the Firefox dlls. If fails, then dismissed the dialog and
* shows the error alert.
* REQUIRES: request: Conversion data object.
* RETURNS: null
* **********************************************************************************************/
web2pdf_Conversion.prototype.ConvertToPDF = function(request){
if(web2pdf_FFExtnLib === null)
web2pdf_openLib();
if(web2pdf_FFExtnLib === null)
{
this.Done(this.STATUS_MISSINGLIB);
return null;
}
// Initialize Platform Specific Data
this.InitPlatformSpecificData();
if(this.m_platformSpecific === null)
{
this.Done(this.STATUS_MISSINGLIB);
return null;
}
this.m_currentState = this.STATUS_DOWNLOADING;
this.m_url = request.url;
// If we have encountered some error then throw the alert dialog after the conversion.
// The main reason is that, background content process cannot throw alert dialog, so we
// have to propagate the error string generated for an error caused while paring the
// dom content to chrome process and throw from here.
if ((typeof request.errorString !== 'undefined') && request.errorString !== "")
alert(request.errorString);
var domData = "";
if(this.m_conversionSettings & this.CONVERT_SELECTION)
{
//A selection needs to be converted, get the selected content from the domWindow.
domData = request.domData;
}
else if(this.m_conversionSettings & this.CONVERT_LINK)
{
//A link needs to be converted, there is no need to gather any domData.
//We pass domData initialised to 0.
}
else //if((this.m_conversionSettings) & (this.CONVERT_PAGE|PRINT|EMAIL) )
{
//The whole page needs to be converted, get the dom content from the domWindow.
domData = request.domData;
}
this.m_domData = domData;
this.m_charSet = request.charSet;
if(web2pdf_NumberOfConversionsPreceding(this.m_conversionID) <= 0)
this.SendForConversion();
else
this.m_currentState = this.STATUS_WAITING;
return null;
};
/************************************************************************************************
* SendForConversion()
* ----------------------------------------------------------------------------------------------
* This function sends all the data to the Firefox dlls. If fails, then dismissed the dialog and
* shows the error alert.
* REQUIRES: Nothing.
* RETURNS: Nothing.
* **********************************************************************************************/
web2pdf_Conversion.prototype.SendForConversion = function(){
this.m_currentState = this.STATUS_CONVERTING;
try{
var ConversionCall;
if(this.m_conversionSettings & this.APPEND)
{
ConversionCall = "_C_AppendToExistingPDF";
}
else
{
ConversionCall = "_C_ConvertToNewPDF";
}
SetStateCallback = SetStateCallbackType.ptr(web2pdf_SetState, this);
DoneCallback = DoneCallbackType.ptr(web2pdf_ConversionDone, this);
var ConvertToPDF = web2pdf_FFExtnLib.declare(ConversionCall,
ctypes.default_abi,
ctypes.int,
PlatformSpecificPtr,
ctypes.char.ptr,
ctypes.int,
ctypes.char.ptr,
ctypes.char.ptr,
ctypes.char.ptr,
ctypes.char.ptr,
ctypes.int,
SetStateCallbackType.ptr,
DoneCallbackType.ptr);
var result = ConvertToPDF(this.m_platformSpecific,
this.m_url,
this.m_conversionSettings,
this.m_domData,
this.m_outFilePath,
this.m_charSet,
web2pdf_GetXpcomPath(),
this.m_conversionID,
SetStateCallback,
DoneCallback);
if(!result)
{
var ReleasePlatformSpecificData = web2pdf_FFExtnLib.declare("_C_ReleasePlatformSpecificData", ctypes.default_abi, ctypes.int, PlatformSpecificPtr);
var refCount = ReleasePlatformSpecificData(this.m_platformSpecific);
if(refCount <= 0)
this.m_platformSpecific = null;
this.Done(this.STATUS_ERROR);
}
}
catch(err)
{
var ReleasePlatformSpecificData = web2pdf_FFExtnLib.declare("_C_ReleasePlatformSpecificData", ctypes.default_abi, ctypes.int, PlatformSpecificPtr);
var refCount = ReleasePlatformSpecificData(this.m_platformSpecific);
if(refCount <= 0)
this.m_platformSpecific = null;
this.Done(this.STATUS_ERROR);
//alert(err);
}
};
/************************************************************************************************
* EmbedHTTPSResourcesFromList()
* ----------------------------------------------------------------------------------------------
* This function fetches both image data and CSS data. It dumps the image data and appends the file
* name in the resources strings and appends the corresponding CSS data in the resource string.
* REQUIRES: httpsImgSrcList: Image resources data links.
* httpsCSSHrefList: CSS data links.
* characterSet: Charset for CSS data.
* RETURNS: Data resource string combining image and CSS strings with special Acrobat markers.
* **********************************************************************************************/
web2pdf_Conversion.prototype.EmbedHTTPSResourcesFromList = function(httpsImgSrcList, httpsCSSHrefList, characterSet){
var httpsResourcesString = "";
if(httpsImgSrcList.length) {
while(httpsImgSrcList.length) {
var imgSrc = httpsImgSrcList.shift();
if(imgSrc && imgSrc.length > 0 && imgSrc.search(/https:\/\//i) != -1) {
var tempPath = "";
tempPath = this.WriteImageToTempFile(imgSrc);
if(tempPath.length > 0)
{
httpsResourcesString += "<AcroexchangeDownloadSeprator AcroexchangeDownloadUrl=";
httpsResourcesString += imgSrc;
httpsResourcesString += "><FILEPATH>";
httpsResourcesString += tempPath;
httpsResourcesString += "</FILEPATH></AcroexchangeDownloadSeprator>";
}
}
}
}
// Now get CSS.
if(httpsCSSHrefList.length) {
while(httpsCSSHrefList.length) {
var cssHref = httpsCSSHrefList.shift();
if(cssHref && cssHref.length > 0 && cssHref.search(/https:\/\//i) !== -1) {
var cssData = this.GetDataFromURL(cssHref, characterSet);
if(cssData.length > 0) {
httpsResourcesString += "<AcroexchangeDownloadSeprator AcroexchangeDownloadUrl=";
httpsResourcesString += cssHref;
httpsResourcesString += ">";
httpsResourcesString += cssData;
httpsResourcesString += "</AcroexchangeDownloadSeprator>";
}
}
}
}
return httpsResourcesString;
};
/************************************************************************************************
* GetDataFromURL()
* ----------------------------------------------------------------------------------------------
* This function fetches the whole data from a particular aURL and writes it back to local temporary
* storage.
* REQUIRES: aURL: URL of the data.
* RETURNS: The file path of the newly created file.
* **********************************************************************************************/
web2pdf_Conversion.prototype.WriteImageToTempFile = function(aURL)
{
var tempFile = null;
var tempPath = "";
var urlC = aURL;
const ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
const directory = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
const fileOutput = Cc["@mozilla.org/network/file-output-stream;1"].getService(Ci.nsIFileOutputStream);
if(ioService && directory && fileOutput)
{
tempFile = directory.get("TmpD", Ci.nsIFile);
if(tempFile)
{
tempFile.append("FFImages.tmp");
tempFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600);
var channel = ioService.newChannel(urlC, null, null);
if(channel !== null)
{
var count = 0;
var inputStream = channel.open();
if(inputStream === null)
return "";
var bstream = Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIBinaryInputStream);
bstream.setInputStream(inputStream);
var bytes = "";
while(bstream.available() > 0)
bytes += bstream.readBytes(bstream.available());
fileOutput.init(tempFile, -1, -1, 0); //open in default mode: write | create | truncate, with default permissions: 0664
count = fileOutput.write(bytes, bytes.length);
fileOutput.close();
inputStream.close();
bstream.close();
tempPath = tempFile.path;
}
}
}
return tempPath;
};
/************************************************************************************************
* GetDataFromURL()
* ----------------------------------------------------------------------------------------------
* This function fetches the whole data from a particular aURL and then converts it in appropriate
* data using aCharset.
* REQUIRES: aURL: URL of the data.
* aCharSet: Charset of the data.
* RETURNS: The fetched data from given URL.
* **********************************************************************************************/
web2pdf_Conversion.prototype.GetDataFromURL = function(aURL, aCharSet){
var urlC = aURL;
try{
const ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
if(ioService)
{
var channel = ioService.newChannel(urlC, null, null);
if(channel)
{
var buf = "";
var count = 0;
var css = "";
var inputStream = channel.open();
if(inputStream === null)
return "";
var cstream = Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(Ci.nsIConverterInputStream);
cstream.init(inputStream, aCharSet, -1, 0);
var str = {};
var read = 0;
do {
read = cstream.readString(0xffffffff, str); // read as much as we can and put it in str.value
css += str.value;
} while (read !== 0);
cstream.close();
return css;
}
}
}
catch(err){
//alert(err);
}
return "";
};
/************************************************************************************************
* Done()
* ----------------------------------------------------------------------------------------------
* This function marks the current state of the conversion as done and updates the global result
* cache accordingly.
* REQUIRES: state: current state of the conversion (done)
* RETURNS: Nothing.
* **********************************************************************************************/
web2pdf_Conversion.prototype.Done = function(state){
this.m_currentState = state;
web2pdf_resultCache[this.m_conversionID].done = true;
};
// Callbacks
/************************************************************************************************
* web2pdf_SetState()
* ----------------------------------------------------------------------------------------------
* Set the current conversin state.
* REQUIRES: unused: unused
* state: current state of the conversion.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_SetState(unused, state)
{
this.m_currentState = state;
}
/************************************************************************************************
* web2pdf_ConversionDone()
* ----------------------------------------------------------------------------------------------
* The function dismissed the dialog as conversion is completed.
* REQUIRES: unused: unused
* state: done state of the conversion.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_ConversionDone(unused, state)
{
try{
var ReleasePlatformSpecificData = web2pdf_FFExtnLib.declare("_C_ReleasePlatformSpecificData", ctypes.default_abi, ctypes.int, PlatformSpecificPtr);
var refCount = ReleasePlatformSpecificData(this.m_platformSpecific);
if(refCount <= 0)
this.m_platformSpecific = null;
this.Done(state);
} catch(err)
{
alert(err);
}
}
/************************************************************************************************
* web2pdf_GetXpcomPath()
* ----------------------------------------------------------------------------------------------
* This function returns the XPCOM path if already found. Otherwise, calculates and returns.
* REQUIRES: entry: Total entry count of the result cache.
* RETURNS: returns the number of preceeding conversions.
* **********************************************************************************************/
function web2pdf_GetXpcomPath()
{
if(typeof web2pdf_xpcomPath === 'string')
return web2pdf_xpcomPath;
// Else, get the XPCOM Path.
try{
const dirService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIDirectoryService);
var properties = dirService.QueryInterface(Ci.nsIProperties);
if (properties)
{
var file = null;
file = properties.get("CurProcD", Ci.nsIFile);
if(file)
{
var filename = "xpcom.dll";
file.append(filename);
filename = file.path;
web2pdf_xpcomPath = filename;
}
}
}catch(err)
{
alert(err);
}
return web2pdf_xpcomPath;
}
PK
��rI�H]��^ �^ % � chrome/content/web2pdf_framescript.jsSDk � ��R�cd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�1210010���J0�g�g ���P �E � aV!0��c'��J!��� UT
~�/X`�/X`�/X/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2016 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
const MAX_NUM_IMAGES_HTTPS = 20;
/*************************************************************************************************
* EnlistHTTPSResourceURLs()
* ----------------------------------------------------------------------------------------------
* This function extracts all image and css links which are being fetched from the https links.
* These links are being enqueue from this document and later on will be used by Chrome process
* to download these resources from the network.
* REQUIRES: aHtmlDocument: HTML document.
* httpsImgSrcArray: Links of all the CSS resources. (OUT)
* httpsCSSHrefArray: Links of all the CSS resources. (OUT)
* RETURNS: None.
* **********************************************************************************************/
function EnlistHTTPSResourceURLs(aHtmlDocument, httpsImgSrcArray, httpsCSSHrefArray) {
if(aHtmlDocument) {
//Populate HTTPS Image Src Array
var imageList = aHtmlDocument.images;
if(imageList && (typeof httpsImgSrcArray !== 'undefined') && httpsImgSrcArray !== null) {
var numImages = imageList.length;
var numHttpsImages = 0;
for(var index = 0; index < numImages; index++) {
var domNode = imageList.item(index);
if (domNode)
{
var imageElement = domNode.QueryInterface(Components.interfaces.nsIDOMHTMLImageElement);
if(imageElement) {
var imgSrc = imageElement.src;
if(imgSrc && imgSrc.length > 0 && imgSrc.search(/https:\/\//i) != -1) {
numHttpsImages++;
if(numHttpsImages > MAX_NUM_IMAGES_HTTPS)
break;
httpsImgSrcArray.push(new String(imgSrc));
}
}
}
}
}
//Now populate HTTPS CSS Href Array
var styleSheetList = aHtmlDocument.styleSheets;
if(styleSheetList && (typeof httpsCSSHrefArray !== 'undefined') && httpsCSSHrefArray !== null) {
var numStyleSheets = styleSheetList.length;
for(var index = 0; index < numStyleSheets; index++) {
var styleSheet = styleSheetList.item(index);
if(styleSheet) {
var href = styleSheet.href;
if(href && href.length > 0 && href.search(/https:\/\//i) !== -1) {
httpsCSSHrefArray.push(new String(href));
}
}
}
}
}
}
/*************************************************************************************************
* GetDOMContentString()
* ----------------------------------------------------------------------------------------------
* This function fetches the web content of the window and encode the string with selected parameters
* REQUIRES: aDomDocument: Document of the whole window.
* RETURNS: Web-content of the whole string.
* **********************************************************************************************/
function GetDOMContentString(aDomDocument, errorString) {
var docEncoder = null;
try{
docEncoder = Components.classes["@mozilla.org/layout/documentEncoder;1?type=text/html"];
docEncoder = docEncoder.createInstance(Components.interfaces.nsIDocumentEncoder);
if(docEncoder)
{
var encoderFlags = docEncoder.OutputAbsoluteLinks
| docEncoder.OutputPersistNBSP
| docEncoder.OutputEncodeBasicEntities
| docEncoder.OutputEncodeLatin1Entities
| docEncoder.OutputEncodeHTMLEntities;
docEncoder.init(aDomDocument, "text/html", encoderFlags);
var charset = "unicode";
charset = aDomDocument.characterSet;
docEncoder.setCharset(charset);
var contentString = docEncoder.encodeToString();
return contentString;
}
}
catch(err)
{
errorString = err;
var contentString = "<html><body></body></html>";
return contentString;
}
};
/*************************************************************************************************
* ParseDOMContent()
* ----------------------------------------------------------------------------------------------
* This function collects the DOM data from window. It collects all the web content of the whole
* page and prepare a domString of contenting all web content. All the image and css links are
* being enqueued here, as this images and links will be downloaded locally i.e. file I/O is required
* in this case. Now, Mozila recommends strongly that file I/O related calls should be peformed in
* Chrome process. So later on, these resources will be downloaded and corresponding data will be
* appended in domString.
* REQUIRES: aDomWindow: Whole window.
* httpsImgSrcList: Links of all the image resources. (OUT)
* httpsCSSHrefList: Links of all the CSS resources. (OUT)
* RETURNS: DOM string of the whole window.
* **********************************************************************************************/
function ParseDOMContent(aDomWindow, httpsImgSrcArray, httpsCSSHrefArray, errorString) {
var domDocument = aDomWindow.document;
var domContentString = "";
var domData = "";
if(domDocument)
{
// Get page data.
domData = GetDOMContentString(domDocument, errorString);
var htmlDocument = domDocument.QueryInterface(Components.interfaces.nsIDOMHTMLDocument);
var docURL = htmlDocument.URL;
var downloadString = "<AcroexchangeDownloadSeprator AcroexchangeDownloadUrl=";
downloadString += docURL;
downloadString += ">";
downloadString += domData;
downloadString += "</AcroexchangeDownloadSeprator>";
domContentString += downloadString;
// Get HTTPS resources.
if(docURL.search(/https:\/\//i) !== -1) {
EnlistHTTPSResourceURLs(htmlDocument, httpsImgSrcArray, httpsCSSHrefArray);
}
// Find frames and insert them recursively
var frames = domDocument.frames;
if(frames)
{
var numFrames = frames.length;
for(var frameIndex = 0; frameIndex < numFrames; frameIndex++) {
var frameWindow = frames.item(frameIndex);
if(!(typeof frameWindow === undefined)) {
var frameContentString = ParseDOMContent(frameWindow, null, null, errorString);
domContentString += frameContentString;
}
}
}
}
return domContentString;
};
/*************************************************************************************************
* GetEntireDOMSelectionString()
* ----------------------------------------------------------------------------------------------
* This function traverses from the dom node of the selection object to its topmost parent and
* creates the dom selection string with the help of doc encoder.
* REQUIRES: aDocEncoder: DOCEncoder to encode domElement string.
* aDomNode: DOMNode related to the object present inside the selection.
* aDomDocument: Document on which selection is being done.
* aSelectionString: Entire DOM string related from the aDomNode to top parent node.
* RETURNS: Whole selection string stating from aDomNode to top parent.
* **********************************************************************************************/
function GetEntireDOMSelectionString(aDocEncoder, aDomNode, aDomDocument, aSelectionString)
{
if( !(aDocEncoder && aDomNode) || aSelectionString.length <= 0 )
return;
var parentNode = aDomNode.parentNode;
while(parentNode)
{
var domElement;
var domRange;
var tagName;
domElement = parentNode.QueryInterface(Components.interfaces.nsIDOMElement);
if(domElement)
{
var outerHtml = "";
tagName = domElement.tagName;
if(tagName.toLowerCase() === "html")
break;
if(aDomDocument)
domRange = aDomDocument.createRange();
if(domRange)
{
domRange.selectNode(parentNode);
var collapsed = domRange.collapsed;
aDocEncoder.setRange(domRange);
outerHtml = aDocEncoder.encodeToString();
}
if(outerHtml.length > 0)
{
var offset = outerHtml.search(">");
if(offset > 0)
{
var temp = outerHtml.substr(0, offset+1);
if(temp.length > 0 && tagName.length > 0)
{
tagName = "</" + tagName + ">";
aSelectionString = temp + aSelectionString + tagName;
}
}
}
}
parentNode = parentNode.parentNode;
}
return aSelectionString;
};
/*************************************************************************************************
* web2pdf_CleanUpDOM()
* ----------------------------------------------------------------------------------------------
* This function replaces the DOM strings metadata with the Adobe's metadata tag.
* REQUIRES: aDomString: DOM string. (OUT)
* aCharset: Character Set.
* RETURNS: None.
* **********************************************************************************************/
function web2pdf_CleanUpDOM(aDomString, aCharset)
{
if(aDomString.length > 0 && aCharset.length > 0)
{
var metaTag = "<meta http-equiv=\"adobe-javascript\" content=\"disable\" charset=\"" + aCharset + "\">";
aDomString.replace(/meta[^>]*[>]/i, metaTag);
}
}
/*************************************************************************************************
* GetDOMHeadString()
* ----------------------------------------------------------------------------------------------
* This function traverses all the HTML "head" elements and appends the data of the head element
* strings to the domHeadString.
* REQUIRES: aDomWindow: DOM window whose document's head tag we are dealing with.
* aDocEncoder: DOCEncoder to encode the head element strings.
* RETURNS: Encoded "head" element string.
* **********************************************************************************************/
function GetDOMHeadString(aDomWindow, aDocEncoder)
{
var domHeadString = "";
var domDocument = aDomWindow.document;
if(domDocument)
{
var headTag = "head";
var headElementNodeList = domDocument.getElementsByTagName(headTag);
if(headElementNodeList)
{
var numHeadElements = headElementNodeList.length;
if(numHeadElements > 0)
{
var headElementNode = headElementNodeList[0];
if(headElementNode)
{
var domRange = domDocument.createRange();
if(domRange)
{
domRange.selectNode(headElementNode);
aDocEncoder.setRange(domRange);
var headString = aDocEncoder.encodeToString();
if(headString)
{
var charset = "unicode";
charset = domDocument.characterSet;
web2pdf_CleanUpDOM(headString, charset);
domHeadString += headString;
}
}
}
}
}
}
return domHeadString;
};
/*************************************************************************************************
* web2pdf_GetNumberNodes()
* ----------------------------------------------------------------------------------------------
* This function counts the depth/height relative to the parent node.
* REQUIRES: aDomNode: a dome node.
* RETURNS: height / depth of the aDomNode w.r.t top parent.
* **********************************************************************************************/
function web2pdf_GetNumberNodes(aDomNode)
{
var count = 0;
var parentNode = aDomNode.parentNode;
if(parentNode)
{
count++;
while(parentNode)
{
parentNode = parentNode.parentNode;
if(parentNode)
count++;
}
}
return count;
}
/*************************************************************************************************
* GetDOMSelectionString()
* ----------------------------------------------------------------------------------------------
* This function returns the entire DOM string of the selected window.
* REQUIRES: aDomWindow: Selection window.
* errorString: Error occured during parsing. (OUT)
* RETURNS: Entire DOM string of the selection window.
* **********************************************************************************************/
function GetDOMSelectionString(aDomWindow, errorString) {
var domSelectionString = "";
try{
var domDocument = aDomWindow.document;
if(domDocument)
{
var selectionObj = aDomWindow.getSelection();
var selectionRangeCount = 0;
if(selectionObj)
{
selectionRangeCount = selectionObj.rangeCount;
var selectionOuterHTML = "";
var docEncoder = Components.classes["@mozilla.org/layout/documentEncoder;1?type=text/html"];
docEncoder = docEncoder.createInstance(Components.interfaces.nsIDocumentEncoder);
if(docEncoder)
{
var encoderFlags = docEncoder.OutputAbsoluteLinks
| docEncoder.OutputPersistNBSP
| docEncoder.OutputEncodeBasicEntities
| docEncoder.OutputEncodeLatin1Entities
| docEncoder.OutputEncodeHTMLEntities;
docEncoder.init(domDocument, "text/html", encoderFlags);
if(selectionRangeCount > 0)
{
docEncoder.setSelection(selectionObj);
var selectionString = docEncoder.encodeToString();
if(selectionString.length > 0)
{
var domNodeStart = selectionObj.anchorNode;
var domNodeEnd = selectionObj.focusNode;
var domNode = (web2pdf_GetNumberNodes(domNodeStart) > web2pdf_GetNumberNodes(domNodeEnd)) ? domNodeEnd : domNodeStart;
if(domNode)
{
selectionString = GetEntireDOMSelectionString(docEncoder, domNode, domDocument, selectionString);
}
var headHtml = GetDOMHeadString(aDomWindow, docEncoder);
domSelectionString += headHtml + selectionString;
}
}
}
}
}
}
catch(err)
{
errorString = err;
content.console.log(err);
}
return domSelectionString;
};
/*************************************************************************************************
* ParseDOMSelection()
* ----------------------------------------------------------------------------------------------
* This function collects the DOM data from a selection of a window. It collects all the web content
* from selection and prepare a domString of them. All the image and css links are being enqueued here,
* as this images and links will be downloaded locally i.e. file I/O is required in this case. Now,
* Mozila recommends strongly that file I/O related calls should be peformed in Chrome process. So
* later on, these resources will be downloaded and corresponding data will be appended in domString.
* REQUIRES: aDomWindow: Window containing the selection.
* httpsImgSrcList: Links of all the image resources.
* httpsCSSHrefList: Links of all the CSS resources.
* errorString: Error occured during parsing. (OUT)
* RETURNS: DOM string of the selected window.
* **********************************************************************************************/
function ParseDOMSelection (aDomWindow, httpsImgSrcList, httpsCSSHrefList, errorString) {
var domDocument = aDomWindow.document;
var domSelectionString = "";
if(domDocument)
{
var selectionObj = aDomWindow.getSelection();
var selectionRangeCount = 0;
if(selectionObj)
{
var selectionOuterHTML = GetDOMSelectionString(aDomWindow, errorString);
var selectionHTMLString = "<html>" + selectionOuterHTML + "</html>"
var compatModeStr = "";
var domHTMLDocument = domDocument.QueryInterface(Components.interfaces.nsIDOMHTMLDocument);
if(domHTMLDocument)
{
var compatStr = domHTMLDocument.compatMode;
if( compatStr.toLowerCase == "css1compat")
compatModeStr += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML Strict//EN\">\n";
}
var docURL = domHTMLDocument.URL;
if(docURL)
{
var selectionString = "<AcroexchangeDownloadSeprator AcroexchangeDownloadUrl=" + docURL + ">";
selectionString += compatModeStr;
selectionString += selectionHTMLString;
selectionString += "</AcroexchangeDownloadSeprator>";
domSelectionString += selectionString;
// Collect the image and CSS resource links..
if(docURL.search(/https:\/\//i) !== -1)
EnlistHTTPSResourceURLs(domHTMLDocument, httpsImgSrcList, httpsCSSHrefList);
}
}
}
return domSelectionString;
};
/*************************************************************************************************
* IsSelectionMade()
* ----------------------------------------------------------------------------------------------
* This function checks whether any selection is made on the page content or not.
* REQUIRES: nothing.
* RETURNS: true -> if a selection is made. false -> if there is no selection.
* **********************************************************************************************/
function IsSelectionMade()
{
var selection = content.getSelection();
var cnt = 0;
if(selection.isCollapsed)
{
var frames = content.frames;
if(typeof frames != 'undefined')
{
for(cnt=0;cnt<frames.length;cnt++)
if((frames[cnt].getSelection()!==null) && (!frames[cnt].getSelection().isCollapsed))
return true;
}
}
else return true;
return false;
}
/* With Electrolysis on, Multiprocess firefox window is enabled by default. So, Firefox UI process i.e.
* browser process cannot interact with web contect directly anymore and the UI remains responsive all
* the time. In order to achieve this, frame script is written which works in the background. Chrome and
* content process script can communicate with each other via message manager asynchronously.
*
* Here, we have maintained a basic protocol that we will listen only those messages having messageName
* as 'web2pdfextension:MessageFromChrome'. And in reply, framescript will send the messages with name
* 'web2pdfextension:MessageFromContent'. We are using, Browser message manager here, so message passing
* is limited to one separate tab only. https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Message_Manager
*/
addMessageListener("web2pdfextension:MessageFromChrome", function(message) {
// The functionality name asked by the Chrome Process script via browser message manager.
var askedFunction = message.data.FunctionName;
if (askedFunction == "TellIfSelectionIsMade") {
var isSelctionMade=IsSelectionMade();
sendAsyncMessage("web2pdfextension:MessageFromContent", {
reply:"TellIfSelectionIsMadeReply", /* Unique reply command */
replyWithSlection: isSelctionMade
});
}
// Get the document title, for the file picker dialog..
else if (askedFunction == "InitWithDocTitleAndArgs") {
var documentTitle = "";
if (content.document && content.document.title)
documentTitle = content.document.title;
sendAsyncMessage("web2pdfextension:MessageFromContent", {
reply:"InitWithDocTitleAndArgsReply", /* Unique reply command */
replyWithDocTitle: documentTitle, /* Document title */
replyWithConversionCaller: message.data.ConversionCaller, /* Conversion Caller */
replyWithConversionType: message.data.ConversionType, /* Conversion Type */
replyWithConversionContext: message.data.ConversionContext /* Conversion Context */
});
}
// Get the page data for all the invocation points other than selection..
else if (askedFunction == "GetPageData") {
var charSet = "unicode";
if (content.document && content.document.characterSet != null)
charSet = content.document.characterSet;
var documentTitle = "";
if (content.document && content.document.title)
documentTitle = content.document.title;
//The whole page needs to be converted, build the dom content by extracting data from the window.
var httpsImgSrcList = new Array();
var httpsCSSHrefList = new Array();
var domData = "";
var errorString = "";
// For functionlity like "Link" (convert/append), page DOM data is not required.
if (message.data.DomDataRequired)
domData = ParseDOMContent(content, httpsImgSrcList, httpsCSSHrefList, errorString);
sendAsyncMessage("web2pdfextension:MessageFromContent", {
reply:"GetPageDataReply", /* Unique reply command */
replyWithDocTitle: documentTitle, /* Document title */
replyWithConversionCaller: message.data.ConversionCaller, /* Conversion Caller: MENU, TOOLBAR */
replyWithConversionType: message.data.ConversionType, /* Conversion Type: CONVERT, APPEND */
replyWithConversionContext: message.data.ConversionContext, /* Conversion Context: PAGE, LINK, SELECTION, PRINT, EMAIL*/
replyWithFilePath: message.data.TheFilePath, /* File Path, chosen via file picker dialog */
replyWithDOMData: domData, /* DOM data of entire page */
replyWithCharacterSet: charSet, /* Charset of the document */
replyWithImageSourceList: httpsImgSrcList, /* Links of HTTPS image resources */
replyWithCSSHrefList: httpsCSSHrefList, /* Links of HTTPS CSS resources */
replyWithError: errorString /* Error occured during parsing */
});
}
// Get the DOM data of the selected portion of the page..
else if (askedFunction == "GetSelectionData") {
var charSet = "unicode";
if (content.document && content.document.characterSet != null)
charSet = content.document.characterSet;
var documentTitle = "";
if (content.document && content.document.title)
documentTitle = content.document.title;
// find the right window which actually has the selection
var domWindow = content;
var url = message.data.URL;
if(content.getSelection().isCollapsed) {
var frames = content.frames;
if(typeof frames !== 'undefined')
{
for(var count = 0; count < frames.length; count++)
{
if(!frames[count].getSelection().isCollapsed) // Check if selection is in this frame.
{
domWindow = frames[count];
url = domWindow.document.QueryInterface(Components.interfaces.nsIDOMHTMLDocument).URL;
break;
}
}
}
}
//The whole page needs to be converted, build the dom content by extracting data from the window.
var httpsImgSrcList = new Array();
var httpsCSSHrefList = new Array();
var errorString = "";
var domData = ParseDOMSelection(domWindow, httpsImgSrcList, httpsCSSHrefList, errorString);
sendAsyncMessage("web2pdfextension:MessageFromContent", {
reply:"GetSelectionDataReply", /* Unique reply command */
replyWithDocTitle: documentTitle, /* Document title */
replyWithConversionCaller: message.data.ConversionCaller, /* Conversion Caller */
replyWithConversionType: message.data.ConversionType, /* Conversion Type */
replyWithConversionContext: message.data.ConversionContext, /* Conversion Context */
replyWithFilePath: message.data.TheFilePath, /* File Path, chosen via file picker dialog */
replyWithDOMData: domData, /* DOM data of entire selection */
replyWithURL: url, /* URL of the selected DOM window */
replyWithCharacterSet: charSet, /* Charset of the document */
replyWithImageSourceList: httpsImgSrcList, /* Links of HTTPS image resources */
replyWithCSSHrefList: httpsCSSHrefList, /* Links of HTTPS CSS resources */
replyWithError: errorString /* Error occured during parsing */
});
}
});PK
��rIO�ԏ_� _� � chrome/content/web2pdf_new.jsSDk � ��R�cd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�1210010���J0�g�g ���P �E � aV!0��c'��J!��� UT
~�/X`�/X`�/X/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2011 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
/* Load JS Ctypes Javascript module */
Components.utils.import("resource://gre/modules/ctypes.jsm");
/* Global var for DLL. */
var web2pdf_FFExtnLib = null;
/* Global var for KeepAlive method. */
var web2pdf_KeepLibAlive = null;
//---------------------------------------------------------------------------------------------------------------------
// Functions to handle opening and closing of DLL.
/*************************************************************************************************
* web2pdf_openLib()
* ----------------------------------------------------------------------------------------------
* Function to handle the opening of DLL if not already opened.
* REQUIRES: Nothing.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_openLib()
{
if( web2pdf_FFExtnLib === null)
{
try
{
const ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var uri = ioService.newURI('resource://WCFirefoxExtnLib', null, null);
if (uri instanceof Components.interfaces.nsIFileURL)
{
web2pdf_FFExtnLib = ctypes.open(uri.file.path);
// Declare the KeepAlive method to keep the lib alive.
web2pdf_KeepLibAlive = web2pdf_FFExtnLib.declare("_C_KeepAlive", ctypes.default_abi, ctypes.void_t);
}
}
catch(err)
{
web2pdf_KeepLibAlive = null;
if(web2pdf_FFExtnLib)
web2pdf_FFExtnLib.close();
web2pdf_FFExtnLib = null;
}
}
}
/*************************************************************************************************
* web2pdf_closeLib()
* ----------------------------------------------------------------------------------------------
* Function to handle the opening of DLL if not closed already.
* REQUIRES: Nothing.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_closeLib()
{
if(web2pdf_FFExtnLib !== null)
{
web2pdf_KeepLibAlive = null;
web2pdf_FFExtnLib.close();
web2pdf_FFExtnLib = null;
}
}
//GLOBALS-------------------------------------------------------------------------------------------
//Global variables to keep track of various timers
var CONVERSION_ANIMATION_FIRE_TIMER = 10;
var CONVERSION_ANIMATION_STOP_TIMER = 10;
var CONVERSION_ANIMATION_TIMER = 800;
var CONVERT2PDF_INTERNAL_TIMER = 100;
var CONVERT2PDF_FIRE_TIMER = 500;
var STATUS_CLEAN_TIMER = 500;
var FEAT_QUIT_TIMER = 2000;
var CONVERSION_TIMEOUT = 200000;
// Constants to identify events.
const UPDATE_LIST_ITEMS = 0;
//Global to keep the selected link url on which right click is done.
var web2pdf_selectedLinkURL = null;
//Global enums to used to pass conversion settings
var web2pdfCaller = { MENU:0, TOOLBAR:1 };
var web2pdfType = { CONVERT:0, APPEND:1 };
var web2pdfContext = { PAGE:0, LINK:1, SELECTION:2, PRINT:3, EMAIL:4 };
/*************************************************************************************************
* web2pdf_StatusCache()
* ----------------------------------------------------------------------------------------------
* Status Cache object used to keep track of the conversion progress and update status dialog.
* REQUIRES: conversion: web2pdf_Conversion object
* docTitle: document title
* errString: error string
* runningFEAT: whether object is created for FEAT
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_StatusCache(conversion,docTitle,errString,runningFEAT) // Status Cache Object Constructor
{
this.conversion = conversion;
this.docTitle = docTitle;
this.errString = errString;
this.runningFEAT = runningFEAT;
// Following 2 flags ae important:
// If shown and not done, then conversion is active.
// If shown and done, then conversion is done, due to be removed.
// If hidden and done, then conversion timed out and was hidden, but it completed and is due to be removed.
// If hidden and not done, then conversion is done and removed. Or conversion timed out and still active.
this.show = true;
this.done = false;
//
this.timeStarted = 0;
this.timeElapsed = 0;
}
var web2pdf_statusDlg; //To hold the common status dialog for all conversions.
var web2pdf_resultCache = new Array(); //Array to store Status Cache for conversions.
var web2pdf_statusDlgWorker = null; // To hold the status dialog worker.
var browserWeakMap = new WeakMap(); // A week browser map, which has already loaded the framescript..
//GLOBALS--------------------------------end------------------------------------------------------------
//---------------------------------------Functions called from main Overlay------------------------------
/*************************************************************************************************
* web2pdf_ShowConversionSettingsDialog()
* ----------------------------------------------------------------------------------------------
* Shows the conversion settings dialog.
* REQUIRES: Nothing.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_ShowConversionSettingsDialog()
{
if(web2pdf_FFExtnLib === null)
web2pdf_openLib();
if(web2pdf_FFExtnLib === null)
return;
var ShowConversionSettingsDialog = web2pdf_FFExtnLib.declare("_C_ShowConversionSettingsDialog",
ctypes.default_abi,
ctypes.int32_t); // return type
ShowConversionSettingsDialog();
}
/*************************************************************************************************
* web2pdf_alert()
* ----------------------------------------------------------------------------------------------
* Shows alert during the conversion process.
* REQUIRES: Nothing.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_alert(msg)
{
alert(msg);
}
/*************************************************************************************************
* web2pdf_ConvertToPDF()
* ----------------------------------------------------------------------------------------------
* Common invocation point for all the major workflows except the preference window.
* REQUIRES: conversionCaller: Invocation points -> MENU, TOOLBAR
* conversionType: Conversion types -> CONVERT, APPEND
* conversionContext: Context of the conversion -> PAGE, LINK, SELECTION, PRINT, EMAIL
* RETURNS: 0 to exit normally.
* **********************************************************************************************/
function web2pdf_ConvertToPDF(conversionCaller, conversionType, conversionContext)
{
// load the frame script via browser message manager i.e. the script will load only once per browser.
var BrowserObj = gBrowser.selectedBrowser;
var BrowserMessageManager = BrowserObj.messageManager;
if (!browserWeakMap.has(BrowserObj) || !browserWeakMap.get(BrowserObj)) {
BrowserMessageManager.loadFrameScript("chrome://web2pdfextension/content/web2pdf_framescript.js", true);
browserWeakMap.set(BrowserObj, true);
}
BrowserMessageManager.addMessageListener("web2pdfextension:MessageFromContent", handleContentScriptMessage);
BrowserMessageManager.sendAsyncMessage("web2pdfextension:MessageFromChrome", {
FunctionName: "InitWithDocTitleAndArgs", /* Unique functionality command */
ConversionCaller: conversionCaller, /* Conversion Caller */
ConversionType: conversionType, /* Conversion Type */
ConversionContext: conversionContext /* Conversion Context */
});
return 0;
}
/*************************************************************************************************
* web2pdf_InvokeConvertToPDFInternal()
* ----------------------------------------------------------------------------------------------
* This function receives the DOM data and all related conversion parameters via message manager and
* determines which URL to proceed with and starts a times for conversion.
* REQUIRES: requestObj: Objects containing all the required parameters for conversion.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_InvokeConvertToPDFInternal(requestObj) {
var browser = parent.getBrowser();
var url = browser.currentURI.spec;
if(requestObj.conversionContext === web2pdfContext.LINK) { //link is right clicked
url = web2pdf_selectedLinkURL;
}
// If a selection is being converted to PDF which is invoked via menu, then message manager will basically provide the
// correct URL associated with that selection window.
else if(requestObj.conversionCaller === web2pdfCaller.MENU && requestObj.conversionContext === web2pdfContext.SELECTION) {
url = requestObj.url;
}
setTimeout((function(){web2pdf_ConvertToPDFInternal({
url: url, /* URL of the DOM window */
theFilePath: requestObj.theFilePath, /* File Path, chosen via file picker dialog */
conversionCaller: requestObj.conversionCaller, /* Conversion Caller */
conversionType: requestObj.conversionType, /* Conversion Type */
conversionContext: requestObj.conversionContext, /* Conversion Context */
contentTitle: requestObj.contentTitle, /* Document title */
domData: requestObj.domData, /* DOM data */
characterSet: requestObj.characterSet, /* Charset of the document */
httpsImgSrcList: requestObj.httpsImgSrcList, /* Links of HTTPS image resources */
httpsCSSHrefList: requestObj.httpsCSSHrefList, /* Links of HTTPS CSS resources */
errorString: requestObj.errorString /* Error occured during parsing */
}); }),CONVERT2PDF_INTERNAL_TIMER);
return 0;
}
/*************************************************************************************************
* web2pdf_LoadFunctionalityWithContentTitle()
* ----------------------------------------------------------------------------------------------
* This function receives the document title via message manager and throws the File picker dialog
* depending upon the conversion context. It picks up the file and askes the content process script
* to provide the required DOM data depending upon the conversion caller and context.
* REQUIRES: requestObj: Objects containing all the required parameters for conversion.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_LoadFunctionalityWithContentTitle(requestObj)
{
var theFile = null;
if(requestObj.conversionContext !== web2pdfContext.PRINT)
{
if(requestObj.conversionType === web2pdfType.APPEND) {
theFile = web2pdf_FileOpenSaveDialog(false, requestObj.sanitizedContentTitle); //open the "File Open" dialog
}
else {
theFile = web2pdf_FileOpenSaveDialog(true, requestObj.sanitizedContentTitle); //open the "File Save" dialog
}
if(theFile === null) { //cancel was pressed
return 0;
}
}
var theFilePath = "";
if (theFile && theFile.path)
theFilePath = theFile.path;
// Message manager is already loaded, so just send the message to content process script via message manager..
var BrowserMessageManager = gBrowser.selectedBrowser.messageManager;
BrowserMessageManager.addMessageListener("web2pdfextension:MessageFromContent", handleContentScriptMessage);
// Check whether the user wants to convert the whole page or just selection..
if(requestObj.conversionCaller === web2pdfCaller.MENU && requestObj.conversionContext === web2pdfContext.SELECTION) {
BrowserMessageManager.sendAsyncMessage("web2pdfextension:MessageFromChrome", {
FunctionName: "GetSelectionData", /* Unique functionality command */
ConversionCaller: requestObj.conversionCaller, /* Conversion Caller */
ConversionType: requestObj.conversionType, /* Conversion Type */
ConversionContext: requestObj.conversionContext, /* Conversion Context */
TheFilePath: theFilePath, /* File Path, chosen via file picker dialog */
URL: parent.getBrowser().currentURI.spec // URL of the whole window, in case we don't
// find any proper selection window, we need to return the same URL..
});
}
else {
BrowserMessageManager.sendAsyncMessage("web2pdfextension:MessageFromChrome", {
FunctionName: "GetPageData", /* Unique functionality command */
ConversionCaller: requestObj.conversionCaller, /* Conversion Caller */
ConversionType: requestObj.conversionType, /* Conversion Type */
ConversionContext: requestObj.conversionContext, /* Conversion Context */
TheFilePath: theFilePath, /* File Path, chosen via file picker dialog */
DomDataRequired: ((requestObj.conversionContext != web2pdfContext.LINK) ? true : false)
// If we convert the link then, DOM string of the entire window is not required.
});
}
}
//Functions called from main Overlay-------------END-----------------------------
//Functions called locally from this file-------BEGIN----------------------------
/*************************************************************************************************
* web2pdf_NumberOfConversionsPreceding()
* ----------------------------------------------------------------------------------------------
* It checks the total number of preceeding conversions.
* REQUIRES: entry: Total entry count of the result cache.
* RETURNS: returns the number of preceeding conversions.
* **********************************************************************************************/
function web2pdf_NumberOfConversionsPreceding(entry)
{
var resultCount = 0;
var resultCacheSize = web2pdf_resultCache.length;
if(resultCacheSize > 0)
{
var i = 0;
for( i = entry-1; i >= 0; i--)
{
if ((typeof web2pdf_resultCache[i] !== 'undefined') && web2pdf_resultCache[i].show===true)
resultCount++;
}
}
return resultCount;
}
/*************************************************************************************************
* web2pdf_SanitizeFileName()
* ----------------------------------------------------------------------------------------------
* This function receives a file name then replaces the unwanted characters with '_'
* REQUIRES: fileName: A file name.
* RETURNS: A sanitized filename.
* **********************************************************************************************/
function web2pdf_SanitizeFileName(fileName)
{
var sanitizedFileName = "";
var len = fileName.length;
var indx = 0;
var count = 0;
var prevChar = "";
var ch = "";
while( indx < len && count < 80 )
{
ch = fileName.charAt(indx);
if( ch != "<" && ch != ">" && ch != ":" && ch != '"' && ch != "/" && ch != "\\" && ch != "|" && ch != "?" && ch != "*" )
{
prevChar = ch;
sanitizedFileName = sanitizedFileName + ch;
count = count + 1;
}
else
{
if(prevChar != "_")
{
sanitizedFileName = sanitizedFileName + "_";
prevChar = "_";
count = count + 1;
}
}
indx = indx + 1;
}
return sanitizedFileName;
}
/*************************************************************************************************
* web2pdf_FileOpenSaveDialog()
* ----------------------------------------------------------------------------------------------
* This function opens a file "save" or "open" dialog depending upon the parameters and returns the
* file handle.
* REQUIRES: save: True for "File Save" dialog, false for "File open dialog"..
* theDefaultFileName
* RETURNS: returns the file.
* **********************************************************************************************/
function web2pdf_FileOpenSaveDialog(save, theDefaultFileName)
{
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var theFile=null;
var len = 0;
try
{
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
var javaStrings = document.getElementById("acro_web2pdf_JavaStrings");
fp.defaultExtension="pdf";
if(save===true)
fp.init(window, javaStrings.getString('web2pdf.SaveTitle'), nsIFilePicker.modeSave);
else
fp.init(window, javaStrings.getString('web2pdf.OpenTitle'), nsIFilePicker.modeOpen);
fp.appendFilter("Adobe PDF","*.pdf");
fp.defaultExtension = "pdf";
if(save === true) {
// If theDefaultFileName is not valid, then pick the proper name from the resources..
if ((typeof theDefaultFileName === 'undefined') || theDefaultFileName === "")
theDefaultFileName = javaStrings.getString('web2pdf.UntitledFileName');
fp.defaultString = theDefaultFileName;
}
var res = fp.show();
if((res == nsIFilePicker.returnOK || res == nsIFilePicker.returnReplace) && fp.file && fp.file.path)
{
if(save)
{
var filePath = new String(fp.file.path);
len = filePath.length;
var ext = filePath.substring(len-4,len+1);
if(ext != ".pdf")
filePath = filePath + ".pdf" ;
theFile=Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
theFile.initWithPath(filePath);
if(ext!=".pdf" && theFile.exists())
{
var replaceWarning = javaStrings.getString('web2pdf.ReplaceWarning');
var answer = confirm(theFile.path + " " + replaceWarning);
if(!answer)
theFile = web2pdf_FileOpenSaveDialog(save, theDefaultFileName);
}
}
else
theFile = fp.file;
}
if(theFile && !save)
{
if(!(theFile.isReadable() && theFile.isWritable()))
{
alert(javaStrings.getString('web2pdf.NoWritePermissionOnSelectedFile'));
theFile = web2pdf_FileOpenSaveDialog(save, theDefaultFileName);
}
}
}
catch(err)
{
}
return theFile;
}
/*************************************************************************************************
* web2pdf_doStatusDlgEvent()
* ----------------------------------------------------------------------------------------------
* This function updates the status of the conversion dialog.
* REQUIRES: eventData: event data for which the progress bar should be updated.
* RETURNS: nothing.
* **********************************************************************************************/
function web2pdf_doStatusDlgEvent(eventData)
{
if(eventData === UPDATE_LIST_ITEMS)
{
if (typeof web2pdf_statusDlg !== 'undefined')
web2pdf_DoConversionAnimation();
}
}
/*************************************************************************************************
* web2pdf_ConvertToPDFInternal()
* ----------------------------------------------------------------------------------------------
* This function receives the conversion parameter object, then creates a new conversion object and
* fires the conversion with a conversion dialog.
* REQUIRES: requestObj: holds the conversion settings.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_ConvertToPDFInternal(requestObj)
{
var url = requestObj.url;
var httpsImgSrcList = requestObj.httpsImgSrcList;
var httpsCSSHrefList = requestObj.httpsCSSHrefList;
// Make new conversion instance.
var newConversion = new web2pdf_Conversion();
// Prepare the conversion DOM string -> (Page Content + HTTPS resources)
var htmlResourceString = newConversion.EmbedHTTPSResourcesFromList(httpsImgSrcList, httpsCSSHrefList, requestObj.characterSet);
var domData = requestObj.domData + htmlResourceString;
// Set Conversion Settings.
try
{
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
if(prefs)
{
var isChecked = prefs.getBoolPref("extensions.web2pdf.pref_open_in_acrobat");
if( isChecked === true )
newConversion.m_conversionSettings |= newConversion.OPEN_IN_ACROBAT;
}
}
catch(err)
{
}
// Set the conversion settings as per ConversionCaller, ConversionContext & ConversionType..
if(requestObj.conversionType === web2pdfType.APPEND)
newConversion.m_conversionSettings |= newConversion.APPEND;
else
newConversion.m_conversionSettings |= newConversion.CLEAN_FILE_ON_FAILURE;
if(requestObj.conversionContext === web2pdfContext.PAGE)
newConversion.m_conversionSettings |= newConversion.CONVERT_PAGE;
if(requestObj.conversionCaller === web2pdfCaller.TOOLBAR)
{
newConversion.m_conversionSettings |= newConversion.CALLER_TOOLBAR;
if(requestObj.conversionContext === web2pdfContext.PRINT)
newConversion.m_conversionSettings |= newConversion.PRINT;
if(requestObj.conversionContext === web2pdfContext.EMAIL)
newConversion.m_conversionSettings |= newConversion.EMAIL;
}
else if(requestObj.conversionCaller === web2pdfCaller.MENU)
{
if(requestObj.conversionContext === web2pdfContext.LINK)
newConversion.m_conversionSettings |= newConversion.CONVERT_LINK;
if(requestObj.conversionContext === web2pdfContext.SELECTION)
newConversion.m_conversionSettings |= newConversion.CONVERT_SELECTION;
}
// Set the proper out-file path..
if( (typeof requestObj.theFilePath !== 'undefined') && requestObj.theFilePath !== null)
newConversion.m_outFilePath = requestObj.theFilePath;
else
newConversion.m_outFilePath = "";
// Set the document title of the output PDF..
var docTitle = null;
if(typeof requestObj.contentTitle !== 'undefined' && requestObj.contentTitle != null)
docTitle = "" + requestObj.contentTitle;
if(web2pdf_statusDlgWorker === null)
{
web2pdf_statusDlgWorker = new ChromeWorker("chrome://web2pdfextension/content/statusdlg.js");
web2pdf_statusDlgWorker.onmessage = function(event) {
web2pdf_doStatusDlgEvent(event.data);
};
web2pdf_statusDlgWorker.onerror = function(error) {
alert(error.message);
};
}
if(web2pdf_statusDlgWorker && (typeof web2pdf_statusDlgWorker !== 'undefined'))
{
web2pdf_AddStatusCache(newConversion, docTitle, false);
if ((typeof web2pdf_statusDlg === 'undefined') || web2pdf_statusDlg.closed)
web2pdf_statusDlg = window.openDialog("chrome://web2pdfextension/content/statusdlg_new.xul","","chrome,width=550,height=220,resizable=yes");
else
web2pdf_statusDlg.focus();
// Get the worker going.
web2pdf_statusDlgWorker.postMessage(false);
setTimeout((function(){newConversion.ConvertToPDF({
url:url, /* URL of the selected window */
domData:domData, /* DOM data string */
charSet:requestObj.characterSet, /* Character Set */
errorString: requestObj.errorString}); /* Error String */
}), CONVERT2PDF_FIRE_TIMER);
}
return 0;
}
/*************************************************************************************************
* web2pdf_AddStatusCache()
* ----------------------------------------------------------------------------------------------
* Adds current conversion to the result status cache. The conversion will be picked up one by one
* sequentially.
* REQUIRES: conversion: web2pdf_Conversion object
* docTitle: document title
* runningFEAT: whether object is created for FEAT
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_AddStatusCache(conversion, docTitle, runningFEAT)
{
var errString = "";
var newStatusCache = new web2pdf_StatusCache(conversion,docTitle,errString,runningFEAT);
var newLength = web2pdf_resultCache.push(newStatusCache);
web2pdf_resultCache[newLength - 1].conversion.m_conversionID = newLength - 1;
if(web2pdf_NumberOfConversionsPreceding(newLength - 1) <= 0)
newStatusCache.timeStarted = new Date().getTime();
}
//Functions called locally from this file--------END-----------------------------
//Functions for Status Dialog-----------BEGIN----------------------------
/*************************************************************************************************
* web2pdf_CloseStatusDialog()
* ----------------------------------------------------------------------------------------------
* Close the status dialog.
* REQUIRES: Nothing.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_CloseStatusDialog()
{
web2pdf_statusDlgWorker.terminate();
web2pdf_statusDlgWorker = null;
web2pdf_statusDlg.close();
}
/*************************************************************************************************
* web2pdf_GetFileNameFromFilePath()
* ----------------------------------------------------------------------------------------------
* Get the file name from the file path.
* REQUIRES: filePath: file path.
* RETURNS: file name of the file present on this file path.
* **********************************************************************************************/
function web2pdf_GetFileNameFromFilePath(filePath)
{
var fileName = filePath;
try
{
var theFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
if(theFile)
{
theFile.initWithPath(filePath);
fileName = theFile.leafName;
}
}catch(err)
{
}
return fileName;
}
/*************************************************************************************************
* web2pdf_FindNextWaitingConversionID()
* ----------------------------------------------------------------------------------------------
* Get the next conversion settings from the status queue.
* REQUIRES: entry: current conversion id, so check for the next element from the status cache.
* RETURNS: -1
* **********************************************************************************************/
function web2pdf_FindNextWaitingConversionID(entry)
{
var resultCache = web2pdf_resultCache;
var resultCacheSize = resultCache.length;
for( var nextEntry = entry + 1; nextEntry < resultCacheSize; nextEntry++)
{
if ((typeof resultCache[nextEntry] !== 'undefined') && resultCache[nextEntry].show===true && resultCache[nextEntry].done === false)
return nextEntry;
}
return -1;
}
/*************************************************************************************************
* web2pdf_RemoveFromList()
* ----------------------------------------------------------------------------------------------
* Marks the conversion's show entry as false - it signifies that conversion is removed.
* REQUIRES: entry: item to be removed.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_RemoveFromList(entry)
{
var cacheEntry = web2pdf_resultCache[entry];
cacheEntry.show=false;
cacheEntry.done=false;
cacheEntry.conversion=0;
cacheEntry.docTitle=0;
if(cacheEntry.runningFEAT)
{
setTimeout((function(){web2pdf_QuitFirefox(false);}),FEAT_QUIT_TIMER);
}
}
/*************************************************************************************************
* web2pdf_StartNextConversion()
* ----------------------------------------------------------------------------------------------
* Find and invoke the next conversion.
* REQUIRES: entry: Index of current process item.
* RETURNS: nothing.
* **********************************************************************************************/
function web2pdf_StartNextConversion(entry)
{
var nextConversionId = web2pdf_FindNextWaitingConversionID(entry);
if(nextConversionId >= 0)
{
var nextCacheEntry = web2pdf_resultCache[nextConversionId];
if(nextCacheEntry.conversion)
{
nextCacheEntry.timeStarted = new Date().getTime();
nextCacheEntry.conversion.SendForConversion();
}
}
}
/*************************************************************************************************
* web2pdf_incrProgressSpinCount()
* ----------------------------------------------------------------------------------------------
* Increase progress spin count.
* REQUIRES: nothing.
* RETURNS: Get the filepath of the image source.
* **********************************************************************************************/
var web2pdf_ProgressSpinCount = 1;
function web2pdf_incrProgressSpinCount()
{
++web2pdf_ProgressSpinCount;
if(web2pdf_ProgressSpinCount > 12)
web2pdf_ProgressSpinCount = 1;
}
/*************************************************************************************************
* web2pdf_getProgressSpinIcon()
* ----------------------------------------------------------------------------------------------
* Get the spinner icon.
* REQUIRES: nothing.
* RETURNS: Get the filepath of the image source.
* **********************************************************************************************/
function web2pdf_getProgressSpinIcon()
{
if(web2pdf_ProgressSpinCount < 10)
return "chrome://web2pdfextension/skin/AX_ProgressSpin_Sm_0" + web2pdf_ProgressSpinCount + "_N.png";
else
return "chrome://web2pdfextension/skin/AX_ProgressSpin_Sm_" + web2pdf_ProgressSpinCount + "_N.png";
}
/*************************************************************************************************
* web2pdf_SetNewListItem()
* ----------------------------------------------------------------------------------------------
* This function adds, Removes entries from the status list. Also does some animation.
* REQUIRES: newListItem: item list to be inserted in the status list.
* entry: position of the new item in the status list.
* RETURNS: nothing.
* **********************************************************************************************/
function web2pdf_SetNewListItem(newListItem, entry)
{
var cacheEntry = web2pdf_resultCache[entry];
var conversionStatus = cacheEntry.conversion.m_currentState;
var conversionSettings = cacheEntry.conversion.m_conversionSettings;
var javaStrings = document.getElementById("acro_web2pdf_JavaStrings");
// set the list item row values
if(conversionSettings & cacheEntry.conversion.PRINT)
newListItem.firstChild.childNodes[0].src = "chrome://web2pdfextension/skin/AX_PrintWebPage_Sm_N.png";
else if(conversionSettings & cacheEntry.conversion.EMAIL)
newListItem.firstChild.childNodes[0].src = "chrome://web2pdfextension/skin/AX_ConvertWebEmail_Sm_N.png";
else if(conversionSettings & cacheEntry.conversion.APPEND)
newListItem.firstChild.childNodes[0].src = "chrome://web2pdfextension/skin/AX_Append_Sm_N.png";
else
newListItem.firstChild.childNodes[0].src = "chrome://web2pdfextension/skin/AX_WebCap_Converted_Sm_N.png";
if(conversionSettings & cacheEntry.conversion.PRINT)
{
if(cacheEntry.docTitle)
newListItem.firstChild.childNodes[5].value = cacheEntry.docTitle;
else
newListItem.firstChild.childNodes[5].value = cacheEntry.conversion.m_url;
}
else
newListItem.firstChild.childNodes[5].value = web2pdf_GetFileNameFromFilePath(cacheEntry.conversion.m_outFilePath);
if(conversionStatus === cacheEntry.conversion.STATUS_WAITING) //waiting for conversion
{
newListItem.firstChild.childNodes[3].value = javaStrings.getString('web2pdf.Status_Waiting');
newListItem.firstChild.childNodes[2].src = web2pdf_getProgressSpinIcon();
}
else if(conversionStatus === cacheEntry.conversion.STATUS_DOWNLOADING) //downloading
{
newListItem.firstChild.childNodes[3].value = javaStrings.getString('web2pdf.Status_Downloading');
newListItem.firstChild.childNodes[2].src = "chrome://web2pdfextension/skin/AX_State_Downloading_Sm_N.png";
}
else if(conversionStatus === cacheEntry.conversion.STATUS_CONVERTING) //converting
{
newListItem.firstChild.childNodes[3].value = javaStrings.getString('web2pdf.Status_Converting');
newListItem.firstChild.childNodes[2].src = web2pdf_getProgressSpinIcon();
}
else
{
if(conversionStatus === cacheEntry.conversion.STATUS_SUCCESS) //success
{
newListItem.firstChild.childNodes[3].value = javaStrings.getString('web2pdf.Status_Success');
newListItem.firstChild.childNodes[2].src = "chrome://web2pdfextension/skin/AX_State_Done_Success_Sm_N.png";
}
else //error condition
{
newListItem.firstChild.childNodes[3].value = javaStrings.getString('web2pdf.Status_Error');
if(conversionStatus === cacheEntry.conversion.STATUS_ERROR) //error in conversion
{
if(cacheEntry.errString && cacheEntry.errString.length > 0)
{
newListItem.firstChild.childNodes[3].value += " - "+cacheEntry.errString;
setTimeout((function(){web2pdf_alert(cacheEntry.errString);}),STATUS_CLEAN_TIMER/10);
}
else
{
setTimeout((function(){web2pdf_alert(javaStrings.getString('web2pdf.Unknown_Error'));}),STATUS_CLEAN_TIMER/10);
}
}
else if(conversionStatus === cacheEntry.conversion.STATUS_FILELOCKED) //file is locked
{
setTimeout((function(){web2pdf_alert(javaStrings.getString('web2pdf.File_Locked_Error'));}),STATUS_CLEAN_TIMER/10);
}
else if(conversionStatus === cacheEntry.conversion.STATUS_MISSINGLIB) //a library could not be loaded.
{
// Do nothing.
}
else //(conversionStatus === cacheEntry.conversion.STATUS_NOINSTANCE) //conversion instance/status for this conversion not found
{
setTimeout((function(){web2pdf_alert(javaStrings.getString('web2pdf.Unknown_Error'));}),STATUS_CLEAN_TIMER/10);
}
newListItem.firstChild.childNodes[2].src = "chrome://web2pdfextension/skin/AX_State_Done_Error_Sm_N.png";
}
web2pdf_RemoveFromList(entry);
web2pdf_StartNextConversion(entry);
}
}
/*************************************************************************************************
* web2pdf_DoConversionAnimation()
* ----------------------------------------------------------------------------------------------
* This function adds, Removes entries from the status list. Also does some animation.
* REQUIRES: nothing.
* RETURNS: nothing.
* **********************************************************************************************/
function web2pdf_DoConversionAnimation()
{
var listBox = web2pdf_statusDlg.document.getElementById("acro_web2pdf_StatusListBox");
var listItem = 0;
var newListItem = 0;
var i = 0;
var j = 0;
var flag=false;
var entriesToShow = new Array();
var listBoxNumRows = listBox.getRowCount();
if(listBoxNumRows<=0)
{
setTimeout("web2pdf_CloseStatusDialog()",CONVERSION_ANIMATION_STOP_TIMER);
return 0;
}
else
{
flag=false;
for(i=0; i < web2pdf_resultCache.length; i++)
{
if ((typeof web2pdf_resultCache[i] !== 'undefined') && web2pdf_resultCache[i].show===true)
{
entriesToShow[j++]=i;
if(flag===false)
{
web2pdf_resultCache[i].timeElapsed = new Date().getTime() - web2pdf_resultCache[i].timeStarted;
if(web2pdf_resultCache[i].timeElapsed > CONVERSION_TIMEOUT)
{
var javaStrings=document.getElementById("acro_web2pdf_JavaStrings");
web2pdf_resultCache[i].show=false;
setTimeout((function(){web2pdf_alert(javaStrings.getString('web2pdf.Unknown_Error'));}),STATUS_CLEAN_TIMER/10);
web2pdf_StartNextConversion(i);
}
flag=true;
}
}
else if(web2pdf_resultCache[i].done === true && web2pdf_resultCache[i].show === false)
{
// Conversion timed out earlier, but somehow got completed. Delete the conversion.
web2pdf_RemoveFromList(i);
}
}
//get the copy of first item
listItem = listBox.firstChild.cloneNode(true);
//remove all entries from list box.
while (listBox.firstChild) {
listBox.removeChild(listBox.firstChild);
}
//insert the entries
for(i=0;i<j;i++)
{
newListItem = listItem.cloneNode(true);
listBox.appendChild(newListItem);
web2pdf_SetNewListItem(newListItem,entriesToShow[i]);
}
web2pdf_incrProgressSpinCount();
web2pdf_statusDlgWorker.postMessage(true);
}
return 0;
}
//Functions for Status Dialog------------END-----------------------------
//Functions to identify the context type--------BEGIN----------------------------
/*************************************************************************************************
* web2pdf_GetLinkURLIfClicked()
* ----------------------------------------------------------------------------------------------
* This function checks whether user (right) clicks on a url or not.
* REQUIRES: Nothing.
* RETURNS: Link URL where user right clicks.
* **********************************************************************************************/
function web2pdf_GetLinkURLIfClicked()
{
var linkURL = null;
if(gContextMenu.onLink) {
linkURL = gContextMenu.linkURL;
}
return linkURL;
}
/*************************************************************************************************
* web2pdf_OnContextMenuPopup()
* ----------------------------------------------------------------------------------------------
* This function appends the elements in the right-click context menu of the firefox.
* REQUIRES: Nothing.
* RETURNS: Nothing.
* **********************************************************************************************/
function web2pdf_OnContextMenuPopup() // gets called when context menu is opened.
{
var BrowserObj = gBrowser.selectedBrowser;
var BrowserMessageManager = BrowserObj.messageManager;
if (!browserWeakMap.has(BrowserObj) || !browserWeakMap.get(BrowserObj)) {
BrowserMessageManager.loadFrameScript("chrome://web2pdfextension/content/web2pdf_framescript.js", true);
browserWeakMap.set(BrowserObj, true);
}
BrowserMessageManager.addMessageListener("web2pdfextension:MessageFromContent", handleContentScriptMessage);
BrowserMessageManager.sendAsyncMessage("web2pdfextension:MessageFromChrome", {
FunctionName: "TellIfSelectionIsMade" /* Unique functionality command */
});
}
function web2pdf_AddContextMenuItems(isSelectionMade)
{
var menu1 = document.getElementById("acro_web2pdf_ConvertContextMenu_SelectedLink");
var menu2 = document.getElementById("acro_web2pdf_AppendContextMenu_SelectedLink");
var menu3 = document.getElementById("acro_web2pdf_ConvertContextMenu");
var menu4 = document.getElementById("acro_web2pdf_AppendContextMenu");
var menu5 = document.getElementById("acro_web2pdf_ConvertContextMenu_Selection");
var menu6 = document.getElementById("acro_web2pdf_AppendContextMenu_Selection");
menu1.hidden=true;
menu2.hidden=true;
menu3.hidden=true;
menu4.hidden=true;
menu5.hidden=true;
menu6.hidden=true;
if(isSelectionMade===true)
{
//selection is made
menu5.hidden=false;
menu6.hidden=false;
}
else
{
web2pdf_selectedLinkURL = web2pdf_GetLinkURLIfClicked();
if(web2pdf_selectedLinkURL!==null)
{
//link is right clicked
menu1.hidden=false;
menu2.hidden=false;
}
else
{
//nothing special, page is right clicked
menu3.hidden=false;
menu4.hidden=false;
}
}
}
//Functions to identify the context type---------END-----------------------------
/*************************************************************************************************
* handleContentScriptMessage()
* ----------------------------------------------------------------------------------------------
* This function handles all the incoming messages from the background Content Process script.
* REQUIRES: message: a message, sent by content process script.
* Content of message:
* name -> String containing the message name.
* sync -> Boolean declaring whether the message was send synchronously or aynchronously.
* data -> The JSON object passed as the second parameter to sendAsyncMessage().
* target -> The XUL <browser> element from which this message was sent.
* objects -> An object whose properties are any CPOWs exposed by the sender as the third argument to sendAsyncMessage()
*
* RETURNS: Nothing.
* **********************************************************************************************/
function handleContentScriptMessage(message) {
var BrowserMessageManager = gBrowser.selectedBrowser.messageManager;
BrowserMessageManager.removeMessageListener("web2pdfextension:MessageFromContent", handleContentScriptMessage);
if (message.data.reply == "TellIfSelectionIsMadeReply") { // Unique reply code for 'TellIfSelectionIsMade'
web2pdf_AddContextMenuItems(message.data.replyWithSlection);
}
else if (message.data.reply == "InitWithDocTitleAndArgsReply") { // Unique reply code for 'InitWithDocTitleAndArgs'
var javaStrings = document.getElementById("acro_web2pdf_JavaStrings");
var documentDeafultTitle = javaStrings.getString('web2pdf.UntitledFileName');
var docTitleViaMM = message.data.replyWithDocTitle;
if ((typeof docTitleViaMM !== 'undefined') && docTitleViaMM !== "") {
var fileName = new String(docTitleViaMM);
var sanitizedfileName = web2pdf_SanitizeFileName(fileName);
documentDeafultTitle = sanitizedfileName;
}
web2pdf_LoadFunctionalityWithContentTitle({ sanitizedContentTitle: documentDeafultTitle, /* Sanitized document title */
conversionCaller: message.data.replyWithConversionCaller, /* Conversion Caller */
conversionType: message.data.replyWithConversionType, /* Conversion Type */
conversionContext: message.data.replyWithConversionContext }); /* Conversion Context */
}
else if (message.data.reply == "GetPageDataReply") { // Unique reply code for 'GetPageData'
web2pdf_InvokeConvertToPDFInternal({theFilePath: message.data.replyWithFilePath, /* File Path, chosen via file picker dialog */
conversionCaller: message.data.replyWithConversionCaller, /* Conversion Caller */
conversionType: message.data.replyWithConversionType, /* Conversion Type */
conversionContext: message.data.replyWithConversionContext, /* Conversion Context */
contentTitle: message.data.replyWithDocTitle, /* Document title */
domData: message.data.replyWithDOMData, /* DOM data of entire selection */
characterSet: message.data.replyWithCharacterSet, /* Charset of the document */
httpsImgSrcList: message.data.replyWithImageSourceList, /* Links of HTTPS image resources */
httpsCSSHrefList: message.data.replyWithCSSHrefList, /* Links of HTTPS CSS resources */
errorString: message.data.replyWithError}); /* Error occured during parsing */
}
else if (message.data.reply == "GetSelectionDataReply") { // Unique reply code for 'GetSelectionData'
web2pdf_InvokeConvertToPDFInternal({theFilePath: message.data.replyWithFilePath, /* File Path, chosen via file picker dialog */
conversionCaller: message.data.replyWithConversionCaller, /* Conversion Caller */
conversionType: message.data.replyWithConversionType, /* Conversion Type */
conversionContext: message.data.replyWithConversionContext, /* Conversion Context */
contentTitle: message.data.replyWithDocTitle, /* Document title */
domData: message.data.replyWithDOMData, /* DOM data of entire selection */
url: message.data.replyWithURL, /* URL of the selected DOM window */
characterSet: message.data.replyWithCharacterSet, /* Charset of the document */
httpsImgSrcList: message.data.replyWithImageSourceList, /* Links of HTTPS image resources */
httpsCSSHrefList: message.data.replyWithCSSHrefList, /* Links of HTTPS CSS resources */
errorString: message.data.replyWithError}); /* Error occured during parsing */
}
else {
// Unwanted reply. Skip!
}
}PK
��rI|н�" " � chrome/content/web2pdf_prefs.jsSDk � ��R�cd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�1210010���J0�g�g ���P �E � aV!0��c'��J!��� UT
~�/X`�/X`�/X/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2016 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
// initPrefs
// Initializes the preferences panel to the current values
function web2pdf_InitPrefs(event) {
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
var prefs = prefService.getBranch("");
var element = document.getElementById("acro_web2pdf_ViewResultInAcrobat");
if (!element)
return true;
var attrValue = element.getAttribute("prefstring");
var isChecked = prefs.getBoolPref(attrValue);
if( isChecked == true )
element.setAttribute("checked","true");
else
element.setAttribute("checked","false");
return true;
}
function web2pdf_SavePrefs(event)
{
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
var prefs = prefService.getBranch("");
var element = document.getElementById("acro_web2pdf_ViewResultInAcrobat");
if (!element)
return;
var attrValue = element.getAttribute("prefstring");
var isChecked = prefs.getBoolPref(attrValue);
isChecked = !isChecked;
prefs.setBoolPref(attrValue, isChecked);
prefService.savePrefFile(null);
if( isChecked == true )
element.setAttribute("checked","true");
else
element.setAttribute("checked","false");
return;
}
PK
��rIR��* � chrome/content/web2pdf_utils.jsSDk � ��R�cd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�1210010���J0�g�g ���P �E � aV!0��c'��J!��� UT
~�/X`�/X`�/X/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2016 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
function web2pdf_GetFeatSavePath()
{
var tempFilePath = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("TmpD", Components.interfaces.nsIFile);
tempFilePath.append("savetopdfpath.txt");
return tempFilePath;
}
function web2pdf_GetXPCOMPath()
{
var tempFilePath = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("CurProcD", Components.interfaces.nsIFile);
tempFilePath.append("xpcom.dll");
return tempFilePath;
}
function web2pdf_QuitFirefox(aForceQuit)
{
var appStartup = Components.classes['@mozilla.org/toolkit/app-startup;1'].getService(Components.interfaces.nsIAppStartup);
// eAttemptQuit, 0x02 will try to close each XUL window, but the XUL window can cancel the quit
// process if there is unsaved data.
//eForceQuit, 0x03 will quit no matter what.
var quitSeverity = 0x02;
if(aForceQuit)
quitSeverity = 0x03;
appStartup.quit(quitSeverity);
}
PK
w�rI � chrome/locale/SD� ��Uqcd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�121001la`ie�`��(� V � b3�@��l���R��᱓��BF�>�+� h�J!;Av0I0� )d�a� itq UT
a�/Xa�/X`�/XPK
v�rI � chrome/locale/ar_AE/SD� ��Uqcd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�121001la`ie�`��(� V � b3�@��l���R��᱓��BF�>�+� h�J!;Av0I0� )d�a� itq UT
`�/X`�/X`�/XPK
�rI��x� � � chrome/locale/ar_AE/web2pdf.dtdSDk � ��R�cd`ia``0 b�bFV0�UH��5r}�Ӱ@y�e_�q�1210010���J0�g�g ���P �E � aV!0��c'��J!��� UT
��/X��/X��/X<!ENTITY web2pdf.label "Adobe Acrobat - Create PDF">
<!ENTITY web2pdf.AppName "Adobe Acrobat - Create PDF">
<!ENTITY web2pdf.ConvertButtonText "Convert">
<!ENTITY web2pdf.prefstree.label "web2pdf">
<!ENTITY web2pdf.status_dlg.title "Conversion to PDF Progress">
<!ENTITY web2pdf.menu.Convert_To_PDF_SelectedLink "Convert Link Target to Adobe PDF">
<!ENTITY web2pdf.menu.Add_To_Existing_SelectedLink "Append Link Target to Existing PDF">
<!ENTITY web2pdf.menu.ConvertSelection "Convert Selection to Adobe PDF">
<!ENTITY web2pdf.menu.AppendSelection "Append Selection to Existing PDF">
<!ENTITY web2pdf.menu.Convert_To_PDF "Convert Web Page to Adobe PDF...">
<!ENTITY web2pdf.menu.Add_To_Existing "Add Web Page to Existing PDF...">
<!ENTITY web2pdf.menu.Print_Web_Page "Print Web Page...">
<!ENTITY web2pdf.menu.Convert_and_Email "Convert Web Page and Email...">
<!ENTITY web2pdf.menu.View_Result_In_Acrobat "View Adobe PDF Result">
<!ENTITY web2pdf.menu.Prefrences "Preferences...">
<!ENTITY web2pdf.menu.ToolTipText "Convert current web page to an Adobe PDF file">
<!ENTITY web2pdf.status_dlg.CloseButtonText "Close">
PK
�rI���R R &