Introduce CefString and cef_string_t implementations that support string type conversions and customization of the API string type (issue #146).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@145 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2010-11-22 17:49:46 +00:00
parent 1e1c2ad8d7
commit 7d60642638
121 changed files with 2598 additions and 3209 deletions

View File

@@ -75,11 +75,11 @@ void PrintSettings::ResetRequestedPageMargins() {
void PrintSettings::Init(HDC hdc,
const DEVMODE& dev_mode,
const PageRanges& new_ranges,
const std::wstring& new_device_name,
const CefString& new_device_name,
bool print_selection_only,
bool print_to_file) {
DCHECK(hdc);
printer_name_ = dev_mode.dmDeviceName;
printer_name_ = std::wstring(dev_mode.dmDeviceName);
device_name_ = new_device_name;
ranges = new_ranges;
landscape = dev_mode.dmOrientation == DMORIENT_LANDSCAPE;

View File

@@ -84,7 +84,7 @@ class PrintSettings {
void Init(HDC hdc,
const DEVMODE& dev_mode,
const PageRanges& new_ranges,
const std::wstring& new_device_name,
const CefString& new_device_name,
bool selection_only,
bool to_file);
#endif
@@ -102,11 +102,11 @@ class PrintSettings {
// output.
bool Equals(const PrintSettings& rhs) const;
const std::wstring& printer_name() const { return printer_name_; }
void set_device_name(const std::wstring& device_name) {
const CefString& printer_name() const { return printer_name_; }
void set_device_name(const CefString& device_name) {
device_name_ = device_name;
}
const std::wstring& device_name() const { return device_name_; }
const CefString& device_name() const { return device_name_; }
int dpi() const { return dpi_; }
const PageSetup& page_setup_pixels() const { return page_setup_pixels_; }
@@ -160,10 +160,10 @@ class PrintSettings {
// Settings that can't be changed without side-effects.
// Printer name as shown to the user.
std::wstring printer_name_;
CefString printer_name_;
// Printer device name as opened by the OS.
std::wstring device_name_;
CefString device_name_;
// Page setup in pixel units, dpi adjusted.
PageSetup page_setup_pixels_;

View File

@@ -176,7 +176,7 @@ PrintingContext::Result PrintingContext::Init() {
TCHAR printername[512];
DWORD size = sizeof(printername)-1;
if(GetDefaultPrinter(printername, &size)) {
return Init(std::wstring(printername), false);
return Init(CefString(printername), false);
}
return FAILED;
}
@@ -186,13 +186,14 @@ PrintingContext::Result PrintingContext::InitWithSettings(
DCHECK(!in_print_job_);
settings_ = settings;
return Init(settings_.device_name().c_str(), true);
return Init(settings_.device_name(), true);
}
PrintingContext::Result PrintingContext::Init(const std::wstring& device_name,
PrintingContext::Result PrintingContext::Init(const CefString& device_name,
bool adjust_dev_mode) {
HANDLE printer;
if (!OpenPrinter(const_cast<wchar_t*>(device_name.c_str()),
std::wstring deviceNameStr = device_name;
if (!OpenPrinter(const_cast<wchar_t*>(deviceNameStr.c_str()),
&printer,
NULL))
return FAILED;
@@ -224,7 +225,7 @@ void PrintingContext::ResetSettings() {
}
PrintingContext::Result PrintingContext::NewDocument(
const std::wstring& document_name) {
const CefString& document_name) {
DCHECK(!in_print_job_);
if (!hdc_)
return OnError();
@@ -239,7 +240,8 @@ PrintingContext::Result PrintingContext::NewDocument(
return OnError();
DOCINFO di = { sizeof(DOCINFO) };
di.lpszDocName = document_name.c_str();
std::wstring documentNameStr = document_name;
di.lpszDocName = documentNameStr.c_str();
wchar_t szFileName[MAX_PATH] = L"";
if (settings_.to_file) {
@@ -343,7 +345,7 @@ BOOL PrintingContext::AbortProc(HDC hdc, int nCode) {
}
bool PrintingContext::InitializeSettings(const DEVMODE& dev_mode,
const std::wstring& new_device_name,
const CefString& new_device_name,
const PRINTPAGERANGE* ranges,
int number_ranges,
bool selection_only,
@@ -389,7 +391,7 @@ bool PrintingContext::InitializeSettings(const DEVMODE& dev_mode,
}
bool PrintingContext::GetPrinterSettings(HANDLE printer,
const std::wstring& device_name,
const CefString& device_name,
bool adjust_dev_mode) {
DCHECK(!in_print_job_);
scoped_array<uint8> buffer;
@@ -451,9 +453,10 @@ bool PrintingContext::GetPrinterSettings(HANDLE printer,
return false;
}
bool PrintingContext::AllocateContext(const std::wstring& printer_name,
bool PrintingContext::AllocateContext(const CefString& printer_name,
const DEVMODE* dev_mode) {
hdc_ = CreateDC(L"WINSPOOL", printer_name.c_str(), NULL, dev_mode);
std::wstring printerNameStr = printer_name;
hdc_ = CreateDC(L"WINSPOOL", printerNameStr.c_str(), NULL, dev_mode);
DCHECK(hdc_);
return hdc_ != NULL;
}

View File

@@ -53,7 +53,7 @@ class PrintingContext {
// like IPC message processing! Some printers have side-effects on this call
// like virtual printers that ask the user for the path of the saved document;
// for example a PDF printer.
Result NewDocument(const std::wstring& document_name);
Result NewDocument(const CefString& document_name);
// Starts a new page.
Result NewPage();
@@ -94,7 +94,7 @@ class PrintingContext {
// Reads the settings from the selected device context. Updates settings_ and
// its margins.
bool InitializeSettings(const DEVMODE& dev_mode,
const std::wstring& new_device_name,
const CefString& new_device_name,
const PRINTPAGERANGE* ranges,
int number_ranges,
bool selection_only,
@@ -103,18 +103,18 @@ class PrintingContext {
// Retrieves the printer's default low-level settings. hdc_ is allocated with
// this call.
bool GetPrinterSettings(HANDLE printer,
const std::wstring& device_name,
const CefString& device_name,
bool adjust_dev_mode);
// Allocates the HDC for a specific DEVMODE.
bool AllocateContext(const std::wstring& printer_name,
bool AllocateContext(const CefString& printer_name,
const DEVMODE* dev_mode);
// Updates printer dev_mode with settings_
void PrintingContext::AdjustDevMode(DEVMODE& dev_mode);
// Initializes the hdc_ either with setting_ or with just printer defaults.
Result Init(const std::wstring& device_name, bool adjust_dev_mode);
Result Init(const CefString& device_name, bool adjust_dev_mode);
// Parses the result of a PRINTDLGEX result.
Result ParseDialogResultEx(const PRINTDLGEX& dialog_options);