#include <origin.h>
#include <GetNBox.h>
#include <xfutils.h>
//put additional include files here

//put your own support static functions here

/*------------------------------------------------------------------------------*
 * Modification Log:															*
 *	Folger 08/28/09 QA80-14228 WORKSHEET_CLEARDATA_NEEDS_ROW_OFFSET_SUPPORT		*
 *	Folger 11/18/09 QA81-14680 WCLEAR_FAILS_FOR_EXCEL_SHEET						*
 *------------------------------------------------------------------------------*/


void wclear(Worksheet& w, const int& reduce, const int& op, const int& msg, const int& r1)
{
	
	if(!w)
		XF_THROW(XFERR_INVALID_ARG); 
	
	if(msg)
	{
		///---Sim 06-19-2007 IMPROVE_WARNING_MESSAGE_POST_FUNCTION
		//if(warning_msg_box(IDWARN_CLEAR_WKS, true, true, false) == IDCANCEL)
		if(warning_msg_box(IDWARN_CLEAR_WKS, true, ' ', MB_OKCANCEL) == IDCANCEL)
		///---END IMPROVE_WARNING_MESSAGE_POST_FUNCTION
			XF_THROW(XFERR_UI_USER_CANCEL);
	}
	
	/// TD 09-06-2007 QA80-10266 CLEAR_WORKSHEET_TO_CLEAR_EMBEDDINGS
	//DWORD dwOptions = 0;
	DWORD dwOptions = CWOD_CLEAR_EMBEDDINGS;
	/// end CLEAR_WORKSHEET_TO_CLEAR_EMBEDDINGS
	if(reduce)
		dwOptions |= CWOD_SHRINK_COLS;
	if(op)
	{
		///------ Folger 11/18/09 QA81-14680 WCLEAR_FAILS_FOR_EXCEL_SHEET
		if ( EXIST_EXTERN_WKS != w.GetPage().GetType() )		/// excel will never contain operation
		///------ End WCLEAR_FAILS_FOR_EXCEL_SHEET
			dwOptions |= CWOD_CLEAR_OPERATIONS_OUTPUTS_ETC;
	}
	
	///------ Folger 08/28/09 QA80-14228 WORKSHEET_CLEARDATA_NEEDS_ROW_OFFSET_SUPPORT
	//w.ClearData(dwOptions);
	w.ClearData(dwOptions, 0, -1, r1 < 1 ? 0 : r1 - 1);
	///------ End WORKSHEET_CLEARDATA_NEEDS_ROW_OFFSET_SUPPORT		
	
}

//nEventID < 0 on event, like GETNE_ON_INIT, GETNE_ON_OK etc, >0 on change from control
//return 0 to do nothing, return PEVENT_GETN_RET_TO_CLOSE to close dialog
//dwEnables = bOKEnable, bBTN1Enable, bBTN2Enable, bBTN3Enable, , can set to false to disable OK/Apply buttons
//lpcszNodeName = the trGetN TreeNode tag name that generates the event, or is  if GETNE_ON_OK etc
//strAux = optional string for XF Wizard Bar, like DLG_NEED_CHANGE_GRID etc, it will be invalid if from internal node value change event
//strErrMsg = allowing messages to be shown
int wclear_event1(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	if( xf_is_extended_event(nEventID) )
		return wclear_event1_ex(trGetN, nRow, nEventID, dwEnables, lpcszNodeName, DynaCntrlContainer, strAux, strErrMsg);
	DECLARE_BUTTON_ENABLES
	return false;

}

int wclear_make_tree(TreeNode& tr, LPCSTR lpcszVarName)
{
	return false;
}
//nGetNDialog = 0,1,2, corresponding to the XF GetN dropdown, 0 = dialog is not used
//you can change nRet to be one of XFEVT_PROCEED (defualt), XFEVT_ABORT, XFEVT_PROCEED_NO_DLG or XFEVT_PROCEED_WITH_DLG(when nGetNDialog = 0)
//nGetNDialog = -1 when Ok on GetN dialog to allow handler to preocess <auto> etc variables
//dwCntrl is combination of bits
//LTXF_FROM_GUI_MENU, LTXF_FROM_GUI_PROMPT, LTXF_FROM_AUTO_UPDATE, LTXF_FROM_FUNCTION, LTXF_THEME_USED, LTXF_CHANGE_PARAM
void wclear_before_execute(TreeNode& trGetN, int nGetNDialog, int& nRet, int dwCntrl)
{

}
//nEventID < 0 on event, like GETNE_ON_INIT, GETNE_ON_OK etc, >0 on change from control
//return 0 to do nothing, return PEVENT_GETN_RET_TO_CLOSE to close dialog
//dwEnables = bOKEnable, bBTN1Enable, bBTN2Enable, bBTN3Enable, , can set to false to disable OK/Apply buttons
//lpcszNodeName = the trGetN TreeNode tag name that generates the event, or is  if GETNE_ON_OK etc
//strAux = optional string for XF Wizard Bar, like DLG_NEED_CHANGE_GRID etc, it will be invalid if from internal node value change event
//strErrMsg = allowing messages to be shown
int wclear_event1_ex(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	return false;
}
