XTPReportControl.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:134k
- // XTPReportControl.cpp : implementation of the CXTPReportControl class.
- //
- // This file is a part of the XTREME REPORTCONTROL MFC class library.
- // (c)1998-2008 Codejock Software, All Rights Reserved.
- //
- // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
- // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
- // CONSENT OF CODEJOCK SOFTWARE.
- //
- // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
- // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
- // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
- // SINGLE COMPUTER.
- //
- // CONTACT INFORMATION:
- // support@codejock.com
- // http://www.codejock.com
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Resource.h"
- #include "Common/XTPDrawHelpers.h"
- #include "Common/XTPSystemHelpers.h"
- #include "Common/XTPImageManager.h"
- #include "Common/XTPVC80Helpers.h"
- #include "Common/XTPVC50Helpers.h"
- #include "Common/XTPPropExchange.h"
- #include "Common/XTPToolTipContext.h"
- #include "Common/XTPResourceManager.h"
- #include "XTPReportRecordItem.h"
- #include "XTPReportRecordItemText.h"
- #include "XTPReportRecord.h"
- #include "XTPReportRecords.h"
- #include "XTPReportHeader.h"
- #include "XTPReportColumn.h"
- #include "XTPReportColumns.h"
- #include "XTPReportRow.h"
- #include "XTPReportRows.h"
- #include "XTPReportControl.h"
- #include "XTPReportPaintManager.h"
- #include "XTPReportNavigator.h"
- #include "XTPReportFilterEditControl.h"
- #include "XTPReportSubListControl.h"
- #include "XTPReportGroupRow.h"
- #include "XTPReportInplaceControls.h"
- #include <locale.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #define XTP_REPORT_HSCROLL_STEP 7
- #define XTP_REPORT_AUTO_SCROLL_TIMER_ID 7
- #define XTP_REPORT_AUTO_SCROLL_TIMER_RESOLUTION_MS 200
- #define XTP_REPORT_CB_RECORDS_DATA_VER 1
- #define ASSERT_DBG_REMOVE_RECORD_EX
- //#define XTP_DBG_REMOVE_RECORD_EX_ASSERT ASSERT
- //////////////////////////////////////////////////////////////////////////
- XTP_IMPLEMENT_HEAP_ALLOCATOR(CXTPReportDataAllocator, FALSE)
- XTP_IMPLEMENT_HEAP_ALLOCATOR(CXTPReportRowAllocator, FALSE)
- // to allocate in app default heap
- XTP_IMPLEMENT_HEAP_ALLOCATOR(CXTPReportAllocatorDefault, FALSE)
- class CXTPReportRow_Batch : public CXTPBatchAllocObjT<CXTPReportRow, CXTPReportRow_BatchData> {};
- class CXTPReportGroupRow_Batch : public CXTPBatchAllocObjT<CXTPReportGroupRow, CXTPReportGroupRow_BatchData> {};
- XTP_IMPLEMENT_BATCH_ALLOC_OBJ_DATA(CXTPReportRow_BatchData, CXTPReportRow_Batch, FALSE)
- XTP_IMPLEMENT_BATCH_ALLOC_OBJ_DATA(CXTPReportGroupRow_BatchData, CXTPReportGroupRow_Batch, FALSE)
- //===========================================================================
- BOOL CXTPReportControl::UseReportCustomHeap()
- {
- ASSERT(CXTPReportDataAllocator::ms_dwRefs == 0 || CXTPReportDataAllocator::ms_bUseCustomHeap);
- ASSERT(CXTPReportRowAllocator::ms_dwRefs == 0 || CXTPReportRowAllocator::ms_bUseCustomHeap);
- if (CXTPReportDataAllocator::ms_dwRefs == 0)
- CXTPReportDataAllocator::ms_bUseCustomHeap = TRUE;
- if (CXTPReportRowAllocator::ms_dwRefs == 0)
- CXTPReportRowAllocator::ms_bUseCustomHeap = TRUE;
- return CXTPReportDataAllocator::ms_bUseCustomHeap &&
- CXTPReportRowAllocator::ms_bUseCustomHeap;
- }
- BOOL CXTPReportControl::UseRowBatchAllocation()
- {
- ASSERT(CXTPReportRow_BatchData::IsDataEmpty() || CXTPReportRow_BatchData::m_bBatchAllocationEnabled);
- ASSERT(CXTPReportGroupRow_BatchData::IsDataEmpty() || CXTPReportGroupRow_BatchData::m_bBatchAllocationEnabled);
- if (CXTPReportRow_BatchData::IsDataEmpty())
- CXTPReportRow_BatchData::m_bBatchAllocationEnabled = TRUE;
- if (CXTPReportGroupRow_BatchData::IsDataEmpty())
- CXTPReportGroupRow_BatchData::m_bBatchAllocationEnabled = TRUE;
- return CXTPReportRow_BatchData::m_bBatchAllocationEnabled &&
- CXTPReportGroupRow_BatchData::m_bBatchAllocationEnabled;
- }
- void CXTPReportControl::FreeRowBatchExtraData()
- {
- CXTPReportRow_Batch::FreeExtraData();
- CXTPReportGroupRow_Batch::FreeExtraData();
- }
- //////////////////////////////////////////////////////////////////////////
- BOOL CXTPReportControlLocale::s_bUseResourceFileLocale = FALSE;
- CArray<CXTPReportControlLocale::XTP_TIMESPEC, CXTPReportControlLocale::XTP_TIMESPEC&>
- CXTPReportControlLocale::s_arMappedSpecs;
- //===========================================================================
- BOOL CXTPReportControlLocale::IsUseResourceFileLocale()
- {
- return s_bUseResourceFileLocale;
- }
- void CXTPReportControlLocale::SetUseResourceFileLocale(BOOL bUseResourceFileLocale)
- {
- s_bUseResourceFileLocale = bUseResourceFileLocale;
- }
- LCID CXTPReportControlLocale::GetActiveLCID()
- {
- LCID lcidCurr = LOCALE_USER_DEFAULT;
- if (s_bUseResourceFileLocale)
- lcidCurr = MAKELCID(XTPResourceManager()->GetResourcesLangID(), SORT_DEFAULT);
- return lcidCurr;
- }
- BOOL AFX_CDECL CXTPReportControlLocale::VariantChangeTypeEx(VARIANT& rVarValue, VARTYPE vartype, BOOL bThrowError)
- {
- if (vartype != rVarValue.vt)
- {
- LCID lcID = GetActiveLCID();
- HRESULT hr = ::VariantChangeTypeEx(&rVarValue, &rVarValue, lcID, 0, vartype);
- if (bThrowError && FAILED(hr))
- {
- if (hr == E_OUTOFMEMORY)
- AfxThrowMemoryException();
- else
- AfxThrowOleException(hr);
- }
- return SUCCEEDED(hr);
- }
- return TRUE;
- }
- CString AFX_CDECL CXTPReportControlLocale::FormatDateTime(const COleDateTime& dt, LPCTSTR lpcszFormatString)
- {
- return _FormatDateTime(dt, lpcszFormatString, GetActiveLCID());
- }
- CString CXTPReportControlLocale::_FormatDateTime(const COleDateTime& dt, LPCTSTR lpcszFormatString, LCID lcLocaleID)
- {
- if (dt.GetStatus() != COleDateTime::valid)
- {
- ASSERT(dt.GetStatus() == COleDateTime::null);
- return _T("");
- }
- CString strDT = lpcszFormatString;
- SYSTEMTIME sysTime;
- if (!GETASSYSTEMTIME_DT(dt, sysTime))
- {
- ASSERT(FALSE);
- return _T("");
- }
- // %% Percent sign
- REPLACE_S(strDT, _T("%%"), _T("