Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsPrintingPromptServiceX.cpp File Reference
#include "nsPrintingPromptService.h"
#include "nsCOMPtr.h"
#include "nsIPrintingPromptService.h"
#include "nsIFactory.h"
#include "nsIDOMWindow.h"
#include "nsReadableUtils.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIServiceManager.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWindowWatcher.h"
#include "nsIPrintSettingsX.h"
#include "nsIDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAutoBuffer.h"
#include "nsCRT.h"
#include "nsPDECommon.h"
#include "nsPrintProgress.h"
#include "nsPrintProgressParams.h"
#include "nsIWebProgressListener.h"
#include <PMApplication.h>
#include <CFPlugIn.h>

Go to the source code of this file.

Functions

static nsresult LoadPDEPlugIn ()
static CFDictionaryRef ExtractCustomSettingsDict (PMPrintSettings nativePrintSettings)
static PRBool GetDictionaryStringValue (CFDictionaryRef aDictionary, CFStringRef aKey, nsAString &aResult)
static PRBool GetDictionaryBooleanValue (CFDictionaryRef aDictionary, CFStringRef aKey, PRBool &aResult)
static void SetDictionaryStringValue (CFMutableDictionaryRef aDictionary, CFStringRef aKey, const nsXPIDLString &aValue)
static void SetDictionaryBooleanvalue (CFMutableDictionaryRef aDictionary, CFStringRef aKey, PRBool aValue)

Function Documentation

static CFDictionaryRef ExtractCustomSettingsDict ( PMPrintSettings  nativePrintSettings) [static]

Definition at line 95 of file nsPrintingPromptServiceX.cpp.

{
    CFDictionaryRef resultDict = nsnull;
    UInt32 bytesNeeded;
    
    OSStatus status = ::PMGetPrintSettingsExtendedData(nativePrintSettings, kAppPrintDialogAppOnlyKey, &bytesNeeded, NULL);
    if (status == noErr) {
        nsAutoBuffer<UInt8, 512> dataBuffer;
        if (dataBuffer.EnsureElemCapacity(bytesNeeded)) {           
            status = ::PMGetPrintSettingsExtendedData(nativePrintSettings, kAppPrintDialogAppOnlyKey, &bytesNeeded, dataBuffer.get());
            if (status == noErr) {
                CFDataRef xmlData = ::CFDataCreate(kCFAllocatorDefault, dataBuffer.get(), bytesNeeded);
                if (xmlData) {
                    resultDict = (CFDictionaryRef)::CFPropertyListCreateFromXMLData(
                                                        kCFAllocatorDefault,
                                                        xmlData,
                                                        kCFPropertyListImmutable,
                                                        NULL);
                    CFRelease(xmlData);
                }
            }
        }
    }
    NS_ASSERTION(resultDict, "Failed to get custom print settings dict");
    return resultDict;
}

Here is the call graph for this function:

static PRBool GetDictionaryBooleanValue ( CFDictionaryRef  aDictionary,
CFStringRef  aKey,
PRBool aResult 
) [static]

Definition at line 144 of file nsPrintingPromptServiceX.cpp.

{
    aResult = PR_FALSE;
    CFTypeRef dictValue;
    if ((dictValue = CFDictionaryGetValue(aDictionary, aKey)) &&
        (CFGetTypeID(dictValue) == CFBooleanGetTypeID()))
    {
      aResult = CFBooleanGetValue((CFBooleanRef)dictValue);
      return PR_TRUE;
    }
    return PR_FALSE;
}
static PRBool GetDictionaryStringValue ( CFDictionaryRef  aDictionary,
CFStringRef  aKey,
nsAString &  aResult 
) [static]

Definition at line 123 of file nsPrintingPromptServiceX.cpp.

{
    aResult.Truncate();
    CFTypeRef dictValue;
    if ((dictValue = CFDictionaryGetValue(aDictionary, aKey)) &&
        (CFGetTypeID(dictValue) == CFStringGetTypeID()))
    {
        CFIndex stringLen = CFStringGetLength((CFStringRef)dictValue);

        nsAutoBuffer<UniChar, 256> stringBuffer;
        if (stringBuffer.EnsureElemCapacity(stringLen + 1)) {
            ::CFStringGetCharacters((CFStringRef)dictValue, CFRangeMake(0, stringLen), stringBuffer.get());
            aResult.Assign(stringBuffer.get(), stringLen);
            return PR_TRUE;
        }
    }
    return PR_FALSE;
}

Here is the call graph for this function:

static nsresult LoadPDEPlugIn ( ) [static]

Definition at line 73 of file nsPrintingPromptServiceX.cpp.

{
    static CFPlugInRef gPDEPlugIn = nsnull;

    if (!gPDEPlugIn) {

        CFURLRef pluginsURL = ::CFBundleCopyBuiltInPlugInsURL(CFBundleGetMainBundle());
        if (pluginsURL) {
            CFURLRef thePluginURL = ::CFURLCreateCopyAppendingPathComponent(nsnull,
                                                                          pluginsURL,
                                                                          CFSTR("PrintPDE.plugin"),
                                                                          PR_FALSE);
            if (thePluginURL) {
                gPDEPlugIn = ::CFPlugInCreate(nsnull, thePluginURL);
                ::CFRelease(thePluginURL);
            }
            ::CFRelease(pluginsURL);
        }
    }
    return gPDEPlugIn ? NS_OK : NS_ERROR_FAILURE;
}

Here is the call graph for this function:

static void SetDictionaryBooleanvalue ( CFMutableDictionaryRef  aDictionary,
CFStringRef  aKey,
PRBool  aValue 
) [static]

Definition at line 168 of file nsPrintingPromptServiceX.cpp.

{
    CFDictionaryAddValue(aDictionary, aKey, aValue ? kCFBooleanTrue : kCFBooleanFalse);
}
static void SetDictionaryStringValue ( CFMutableDictionaryRef  aDictionary,
CFStringRef  aKey,
const nsXPIDLString aValue 
) [static]

Definition at line 158 of file nsPrintingPromptServiceX.cpp.

{
    CFStringRef cfString = CFStringCreateWithCharacters(NULL, aValue.get(), aValue.Length());
    if (cfString) {
        CFDictionaryAddValue(aDictionary, aKey, cfString);
        CFRelease(cfString);
    }
}

Here is the call graph for this function: