CCCPDFExcelAddinObj Class Reference

Class for connecting to Excel and handling the Excel to PDF command. More...

#include <CCPDFExcelAddinObj.h>

List of all members.

Public Member Functions

 CCCPDFExcelAddinObj ()
 Default constructor.
STDMETHOD() InterfaceSupportsErrorInfo (REFIID riid)
 Checks if the requested interface is supported by the object.
STDMETHOD() OnConnection (IDispatch *Application, ext_ConnectMode ConnectMode, IDispatch *AddInInst, SAFEARRAY **custom)
 Called when connected to Excel.
STDMETHOD() OnDisconnection (ext_DisconnectMode RemoveMode, SAFEARRAY **custom)
 Called when disconnected from Excel.
STDMETHOD() OnAddInsUpdate (SAFEARRAY **custom)
 Called when Excel's Addins list is updated.
STDMETHOD() OnStartupComplete (SAFEARRAY **custom)
 Called when Excel's startup process is complete.
STDMETHOD() OnBeginShutdown (SAFEARRAY **custom)
 Called when Excel's shutdown process starts.
void __stdcall OnNewWorkbook (IDispatch *workbook)
 Called when a new workbook is opened in Excel.
void __stdcall OnWorkbookActivate (IDispatch *workbook)
 Called when a workbook becomes active in Excel.
void __stdcall OnWorkbookBeforeClose (IDispatch *workbook, VARIANT_BOOL *CancelDefault)
 Called before a workbook in Excel is closed.
void __stdcall OnButtonClick (IDispatch *button, VARIANT_BOOL *CancelDefault)
 Called when the user uses the Excel to PDF command (via menu item or toolbar button).

Protected Member Functions

bool EnableButtons (bool bEnable)
 Enables the toolbar buttons and menu items.
void DoPrint (HANDLE hPrinter, const std::tstring &sPrinter)
 Creates a PDF from the current worksheet.
void SetPrinterAndBreaks (const std::tstring &sPrinter)
 Updates the current printer (and sets the page breaks correctly).
bool CalculatePrintData (const struct PrintPageData &pageHorz, const PrintPageData &pageVert, struct PrintCalcData &dataHorz, PrintCalcData &dataVert, class CCPrintData &data, HANDLE hPrinter, const std::tstring &sPrinter, CComPtr< MSExcel::PageSetup > &page, CComQIPtr< MSExcel::_Worksheet > &worksheet)
 Calculates the location factors for specific print parameters for this document.
void CleanupDialog ()
 Cleans up the 'processing' dialog, if it is currently displayed.
void EnsureDialogVisible ()
 Makes sure that the 'processing' dialog is visible.

Protected Attributes

CComPtr
< Office2000::_CommandBarButton > 
m_buttonToolbar
 Reference to the command added to the toolbar.
CComPtr
< Office2000::_CommandBarButton > 
m_buttonMenu
 Reference to the command added to the menu.
CComPtr< MSExcel::_Application > m_spApp
 Reference to the Excel application.
HWND m_hDialog
 Handle of the 'processing' dialog which is displayed when calculating link data.

Static Protected Attributes

static _ATL_FUNC_INFO OnClickButtonInfo = {CC_STDCALL,VT_EMPTY,2,{VT_DISPATCH,VT_BYREF | VT_BOOL}}
 Callback information for Excel button click.
static _ATL_FUNC_INFO DocumentOpenInfo = {CC_STDCALL,VT_EMPTY, 1, {VT_DISPATCH|VT_BYREF}}
 Callback information for Excel open document.
static _ATL_FUNC_INFO DocumentNew = {CC_STDCALL,VT_EMPTY, 1, {VT_DISPATCH|VT_BYREF}}
 Callback information for Excel new document.
static _ATL_FUNC_INFO DocumentBeforeCloseInfo = {CC_STDCALL,VT_EMPTY, 2, {VT_DISPATCH|VT_BYREF, VT_BYREF|VT_BOOL}}
 Callback information for Excel closing the current workbook.

Detailed Description

Class for connecting to Excel and handling the Excel to PDF command.

Definition at line 44 of file CCPDFExcelAddinObj.h.


Member Function Documentation

void CCCPDFExcelAddinObj::DoPrint ( HANDLE  hPrinter,
const std::tstring &  sPrinter 
) [protected]
bool CCCPDFExcelAddinObj::EnableButtons ( bool  bEnable  )  [protected]

Enables the toolbar buttons and menu items.

Parameters:
bEnable true to enable the addin buttons, false to disable them
Returns:
true if all when well, false if something happened

Definition at line 561 of file CCPDFExcelAddinObj.cpp.

References m_spApp.

Referenced by OnNewWorkbook(), OnWorkbookActivate(), and OnWorkbookBeforeClose().

STDMETHODIMP CCCPDFExcelAddinObj::InterfaceSupportsErrorInfo ( REFIID  riid  ) 

Checks if the requested interface is supported by the object.

Parameters:
riid The interface to check
Returns:
S_OK if interface is supported, S_FALSE if not

Definition at line 93 of file CCPDFExcelAddinObj.cpp.

STDMETHOD() CCCPDFExcelAddinObj::OnAddInsUpdate ( SAFEARRAY **  custom  )  [inline]

Called when Excel's Addins list is updated.

Parameters:
custom Additional data (not used)

Definition at line 109 of file CCPDFExcelAddinObj.h.

STDMETHOD() CCCPDFExcelAddinObj::OnBeginShutdown ( SAFEARRAY **  custom  )  [inline]

Called when Excel's shutdown process starts.

Parameters:
custom Additional data (not used)

Definition at line 125 of file CCPDFExcelAddinObj.h.

void __stdcall CCCPDFExcelAddinObj::OnButtonClick ( IDispatch *  button,
VARIANT_BOOL *  CancelDefault 
)

Called when the user uses the Excel to PDF command (via menu item or toolbar button).

Parameters:
button Interface of the button
CancelDefault Pointer to cancel variable

Definition at line 413 of file CCPDFExcelAddinObj.cpp.

References CCPrintData::CleanSaved(), CleanupDialog(), DoPrint(), FIND_PRINTER_ERROR_MSG, CCRegistry::GetString(), m_hDialog, m_spApp, PRINTER_DRIVER_NAME, PRINTER_ERROR_TITLE, SetPrinterAndBreaks(), and tstring.

STDMETHODIMP CCCPDFExcelAddinObj::OnConnection ( IDispatch *  Application,
ext_ConnectMode  ConnectMode,
IDispatch *  AddInInst,
SAFEARRAY **  custom 
)

Called when connected to Excel.

Parameters:
Application Excel application interface object
ConnectMode Type of connection to Excel (not used)
AddInInst Addin instance interface object (not used)
custom Additional data (not used)
Returns:
S_OK if all went well, error code otherwise

Definition at line 125 of file CCPDFExcelAddinObj.cpp.

References _Module, BUTTON_TAG, m_buttonMenu, m_buttonToolbar, and m_spApp.

STDMETHODIMP CCCPDFExcelAddinObj::OnDisconnection ( ext_DisconnectMode  RemoveMode,
SAFEARRAY **  custom 
)

Called when disconnected from Excel.

Parameters:
RemoveMode Type of disconnection from Excel (not used)
custom Additional data (not used)
Returns:
S_OK if all went well, error code otherwise

Definition at line 341 of file CCPDFExcelAddinObj.cpp.

References m_buttonMenu, m_buttonToolbar, and m_spApp.

void __stdcall CCCPDFExcelAddinObj::OnNewWorkbook ( IDispatch *  workbook  ) 

Called when a new workbook is opened in Excel.

Parameters:
workbook The workbook being added

Definition at line 377 of file CCPDFExcelAddinObj.cpp.

References EnableButtons().

STDMETHOD() CCCPDFExcelAddinObj::OnStartupComplete ( SAFEARRAY **  custom  )  [inline]

Called when Excel's startup process is complete.

Parameters:
custom Additional data (not used)

Definition at line 117 of file CCPDFExcelAddinObj.h.

void __stdcall CCCPDFExcelAddinObj::OnWorkbookActivate ( IDispatch *  workbook  ) 

Called when a workbook becomes active in Excel.

Parameters:
workbook The workbook being activated

Definition at line 368 of file CCPDFExcelAddinObj.cpp.

References EnableButtons().

void __stdcall CCCPDFExcelAddinObj::OnWorkbookBeforeClose ( IDispatch *  workbook,
VARIANT_BOOL *  CancelDefault 
)

Called before a workbook in Excel is closed.

Parameters:
workbook The workbook being closed
CancelDefault Pointer to cancel variable

Definition at line 387 of file CCPDFExcelAddinObj.cpp.

References EnableButtons(), and m_spApp.

void CCCPDFExcelAddinObj::SetPrinterAndBreaks ( const std::tstring &  sPrinter  )  [protected]

Updates the current printer (and sets the page breaks correctly).

Parameters:
sPrinter Name of the printer to use

Definition at line 398 of file CCPDFExcelAddinObj.cpp.

References m_spApp.

Referenced by OnButtonClick().


Member Data Documentation

_ATL_FUNC_INFO CCCPDFExcelAddinObj::DocumentBeforeCloseInfo = {CC_STDCALL,VT_EMPTY, 2, {VT_DISPATCH|VT_BYREF, VT_BYREF|VT_BOOL}} [static, protected]

Callback information for Excel closing the current workbook.

Excel's closing document notification definition.

Definition at line 174 of file CCPDFExcelAddinObj.h.

_ATL_FUNC_INFO CCCPDFExcelAddinObj::DocumentNew = {CC_STDCALL,VT_EMPTY, 1, {VT_DISPATCH|VT_BYREF}} [static, protected]

Callback information for Excel new document.

Excel's new document notification definition.

Definition at line 172 of file CCPDFExcelAddinObj.h.

_ATL_FUNC_INFO CCCPDFExcelAddinObj::DocumentOpenInfo = {CC_STDCALL,VT_EMPTY, 1, {VT_DISPATCH|VT_BYREF}} [static, protected]

Callback information for Excel open document.

Excel's document open notification definition.

Definition at line 170 of file CCPDFExcelAddinObj.h.

_ATL_FUNC_INFO CCCPDFExcelAddinObj::OnClickButtonInfo = {CC_STDCALL,VT_EMPTY,2,{VT_DISPATCH,VT_BYREF | VT_BOOL}} [static, protected]

Callback information for Excel button click.

Excel's button click notification.

Definition at line 165 of file CCPDFExcelAddinObj.h.


The documentation for this class was generated from the following files:

Generated on Mon Jun 18 12:52:47 2012 for Excel to PDF Converter by doxygen 1.6.1