Click here to Skip to main content
15,897,371 members
Articles / Desktop Programming / WTL

A fast and lightweight cell control

Rate me:
Please Sign up or sign in to vote.
4.42/5 (31 votes)
11 Mar 2008CPOL1 min read 91.1K   4.5K   81  
A fast and lightweight cell control for displaying tabular data. The cell is a custom control derived from ATL::CWindow.
// MyCell - version 1.0
// Written by Yanxueming <yanxm2003@hotmail.com>
// Copyright (C) 2006-2006
// All rights reserved.
//
// The code and information is provided "as-is" without
// warranty of any kind, either expressed or implied.
#pragma once
#include <algorithm>
#include "base.h"
#include "MergeCellMgr.h"
#include "StyleDesc.h"
#include "msg.h"
#include "header.h"
#include "private_constants.h"
#include "mycell.h"
#include "PenFactory.h"
#include "GetBorder.h"
#include "CellTypeFactory.h"
class CRgnLight;
namespace mycell{
	using namespace style;
	class Worksheet;
	class Selections;
	//class GridRenderer
	//{
	//	Worksheet* pSheet_;
	//public:
	//	GridRenderer(Worksheet* p):pSheet_(p)
	//	{}
	//	void draw(HDC hDC,LPCRECT lprc,CRgnLight const* pRgnClip/*LPCRECT lprcClip*/);
	//private:
	//	//void get_range(LPCRECT lprcClip,CCellRange& cr);
	//	void draw_RowHeader(HDC hDC,LPCRECT lprc,LPCRECT lprcClip);
	//	void draw_ColHeader(HDC hDC,LPCRECT lprc,LPCRECT lprcClip);
	//	void draw_content(HDC,LPCRECT lprc,LPCRECT lprcClip);
	//	void draw_HeaderCorner(HDC hDC,LPCRECT lprc);
	//	void draw_cell(HDC hDC,LPCTSTR lpText,LPCRECT lprc);
	//};
	struct CellAxisInfo;
	class GridRenderer 
	{
		struct CellItem
		{
			enum {
				MASK_CELL_INCLIP=1<<16,
				MASK_CSPACK=1<<17,
			};
			//const CMergeCell* pMerge;
			//BOOL fInClip;//�Ƿ��������ཻ
			//int row,col;
			ECellBGShrinkState eShrink;
			RECT rcCell;					//��Ԫ������ķ�Χ�������Ǻϲ������
			//RECT rcRender;			//���ڻ��Ƹõ�Ԫ��ķ�Χ��Ҳ�л��Ƽ����
		private:
			RECT rcMerge;				//��Ԫ�������ϲ����ķ�Χ
			CellBorder cellBorder;
			UINT nMask;
			CellStorePack csPack;
		public:
			CellItem()
			{
				clear();
			}
			RECT get_MergeRect()const
			{
				return rcMerge;
			}
			void put_MergeRect(RECT rc)
			{
				rcMerge=rc;
			}
			void SetCSPack(const CellStorePack& cs)
			{
				csPack=cs;
				nMask|=MASK_CSPACK;
			}
			const CellStorePack& GetCSPack()const
			{
				return csPack;
			}
			BOOL IsCSPackValid()const
			{
				return nMask&MASK_CSPACK;
			}
			BOOL IsInClip()const
			{
				return MASK_CELL_INCLIP&nMask;
			}
			void SetInClip()
			{
				nMask|=MASK_CELL_INCLIP;
			}
			pair<CellBorder,UINT> GetBorder()const
			{
				return make_pair(cellBorder,nMask);
			}
			void SetLeftBorder(Border bdr)
			{
				nMask|=xlEdgeLeft;
				cellBorder.left=bdr;
			}
			void SetTopBorder(Border bdr)
			{
				nMask|=xlEdgeTop;
				cellBorder.top=bdr;
			}
			void SetRightBorder(Border bdr)
			{
				nMask|=xlEdgeRight;
				cellBorder.right=bdr;
			}
			void SetBottomBorder(Border bdr)
			{
				nMask|=xlEdgeBottom;
				cellBorder.bottom=bdr;
			}
			void clear()
			{
				eShrink=ECBSS_UNKNOWN;
				rcMerge.left=rcMerge.right=0;
				nMask=0;
			}
		};
		//-------------------------------------------------------------------------//
		//�ýṹ����BeginPaint,EndPaint֮�䣬��������Ҫ��
		//����һ���Լ���һ���鵥Ԫ�������и���Ԫ��
		//�ķ�Χ���ϲ���Χ�����Ƽ�÷�Χ������������
		//���ٲ���Ҫ���ظ����㡣
		//-------------------------------------------------------------------------//
		struct VisibleCellsSession
		{
			//typedef vector<CellItem>::value_type	CellItem;
			//struct ItemEx : public CellItem
			//{
			//	const CellStorePack& csPack;
			//	ItemEx(const CellItem& rhs,const CellStorePack& csp):csPack(csp)
			//	{
			//		pMergeCells=rhs.pMergeCells;
			//		fInClip=rhs.fInClip;//�Ƿ��������ཻ
			//		eShrink=rhs.eShrink;
			//		rcCell=rhs.rcCell;
			//		rcMerge=rhs.rcMerge;
			//	}
			//};

			void Reset(int rows,int cols,int topRow,int leftCol)
			{
				vec_.clear();
				//vec_.reserve(rows*cols);
				vec_.resize((rows+2)*(cols+2));
				rows_=rows;
				cols_=cols;
				topLeft_.set(topRow,leftCol);
			}
			//void put_cols(int cols)
			//{
			//	cols_=cols;
			//}
			int get_cols()const
			{
				return cols_;
			}
			int get_rows()const
			{
				//_ASSERT(cols_>=0);
				return rows_;
				//_ASSERT(cols_>=0);
				//if(0==cols_)
				//	return 0;
				//int rows=(int)vec_.size()/cols_;
				//if((rows*cols_)<(int)vec_.size())
				//	++rows;
				//return rows;
			}
			//void push_back(CellItem const& cell)
			//{
			//	vec_.push_back(cell);
			//}
			//CellItem& operator[](size_t i)
			//{
			//	_ASSERT(i<vec_.size());
			//	return vec_[i];
			//}
			void clear()
			{
				vec_.clear();
			}
			bool empty()const
			{
				return vec_.empty();
			}
			Border GetLeftBorder(const Worksheet* pSheet,CCell cell);
			Border GetRightBorder(const Worksheet* pSheet,CCell cell);
			Border GetTopBorder(const Worksheet* pSheet,CCell cell);
			Border GetBottomBorder(const Worksheet* pSheet,CCell cell);
			CellBorder GetCellBorder(const Worksheet* pSheet,CCell cell)
			{
				CellBorder cellBorder;
				cellBorder.left=GetLeftBorder(pSheet,cell);
				cellBorder.right=GetRightBorder(pSheet,cell);
				cellBorder.top=GetTopBorder(pSheet,cell);
				cellBorder.bottom=GetBottomBorder(pSheet,cell);
				return cellBorder;
			}
			//size_t size()const
			//{
			//	return vec_.size();
			//}
			/*
			CellItem* GetItem(CCell cell)
			{
				for(vector<CellItem>::iterator it=vec_.begin();it!=vec_.end();++it)
				{
					if(it->row==cell.row && it->col==cell.col){
						return &*it;
					}
				}
				return NULL;
			}
			*/
			/*
			CellItem* FindItem(CCell cell)
			{
				CellItem* pItem=NULL;
				if(cell.row>=topLeft_.row && cell.col>=topLeft_.col){
					const int row=cell.row-topLeft_.row;
					const int col=cell.col-topLeft_.col;
					if(row<get_rows() && col<cols_){
						pItem=&item(row,col);
					}
				}
				return pItem;
			}
			const CellItem* FindItem(CCell cell)const
			{
				const CellItem* pItem=NULL;
				if(cell.row>=topLeft_.row && cell.col>=topLeft_.col){
					const int row=cell.row-topLeft_.row;
					const int col=cell.col-topLeft_.col;
					if(row<get_rows() && col<cols_){
						pItem=&item(row,col);
					}
				}
				return pItem;
			}
			*/
			//RECT GetRenderRect(int row,int col)const
			//{
			//	for(vector<CellItem>::const_iterator it=vec_.begin();it!=vec_.end();++it)
			//	{
			//		if(it->row==row && it->col==col){
			//			return it->rcRender;
			//		}
			//	}
			//	RECT rcRender={0};
			//	return rcRender;
			//}
			CellItem& item(CCell cell)
			{
				_ASSERT(cell.row>=TopRow()-1 && cell.row<=BottomRow()+1);
				_ASSERT(cell.col>=LeftCol()-1 && cell.col<=RightCol()+1);
				const int idx=(cell.row-(TopRow()-1))*(cols_+2)+(cell.col-(LeftCol()-1));
				_ASSERT(idx<int(vec_.size()));
				return vec_[idx];	
			}
			//const CellItem& item(CCell cell)const
			//{
			//	_ASSERT(cell.row>=TopRow()-1 && cell.row<=BottomRow()+1);
			//	_ASSERT(cell.col>=LeftCol()-1 && cell.col<=RightCol()+1);
			//	const int idx=(cell.row-(TopRow()-1))*(cols_+2)+(cell.col-(LeftCol()-1));
			//	_ASSERT(idx<int(vec_.size()));
			//	return vec_[idx];
			//	//_ASSERT(j>=0 && j<cols_);
			//	//int const idx=i*cols_+j;
			//	//_ASSERT(idx<int(vec_.size()));
			//	//return vec_[idx];	
			//}
			int TopRow()const
			{
				return topLeft_.row;
			}
			int BottomRow()const
			{
				return topLeft_.row+rows_-1;
			}
			int LeftCol()const
			{
				return topLeft_.col;
			}
			int RightCol()const
			{
				return topLeft_.col+cols_-1;
			}

			//CCell TopLeft()const
			//{
			//	return topLeft_;
			//}
		private:
			CCell topLeft_;
			int rows_,cols_;
			vector<CellItem>	vec_;
		};

		/*
		struct CellStorePack
		{
			const StyleDesc*		pStyle;
			const CComVariant*	pCellVal;
			UINT	cellType;
			CellStorePack(const StyleDesc* psd,const CComVariant* pd,UINT ct)
				:pStyle(psd),pCellVal(pd),cellType(ct)
			{}
			//CellStorePack()
			//{
			//}
		};
		class MergeCellcache
		{
			map<const CMergeCell*,CellStorePack> map_;
		public:
			template<class TWorksheet>
			CellStorePack& GetCellStore(const TWorksheet* pSheet,const CMergeCell* pMerge)
			{
				_ASSERT(pMerge!=NULL);
				map<const CMergeCell*,CellStorePack>::iterator it=map_.find(pMerge);
				if(it!=map_.end()){
					return it->second;
				}else{
					map_.insert(make_pair(pMerge,CellStorePack(pSheet,pMerge->TopLeft(),pMerge->cellStore,ESP_STYLE_MERGE_OWN,ECSM_STYLE_VALID|ECSM_CELLTYPE_VALID)));
					return map_.find(pMerge)->second;
				}
			}
			void clear()
			{
				map_.clear();
			}
		};
		class CellStoreCache
		{
		public:
			template<class TWorksheet>
			CellStorePack& GetCellStore(const TWorksheet* pSheet,CCell cell)
			{
				map<CCell,CellStorePack>::iterator it=map_.find(cell);
				if(it!=map_.end()){
					return it->second;
				}else{
					map_.insert(make_pair(cell,pSheet->GetCellStore(cell,ECSM_STYLE_VALID|ECSM_CELLTYPE_VALID)));
					return map_.find(cell)->second;
					//const CellStorePack cs=pSheet->GetCellStore(cell);
					////pair<const StyleDesc*,const CComVariant*> pr;//(&pSheet->Style_GetStyleByID(pcs?(pcs->nStyleID?pcs->nStyleID:pSheet->Style_GetCellStyleID(cell).first):0),pcs?&pcs->cellVal:NULL);
					//const StyleID_t sid=cs.CellStore().nStyleID?cs.CellStore().nStyleID:pSheet->Style_GetCellStyleID(cell).first;
					////item.pStyle=&pSheet->Style_GetStyleByID(sid);
					////item.pCellVal=&cs.cellVal;
					////item.cellType=cs.cellType;
					//return CellStorePack(&pSheet->Style_GetStyleByID(sid),&cs.CellStore().cellVal,cs.CellStore().cellType);
				}
			}
			//const CComVariant* GetCellData(const Worksheet* pSheet,CCell cell)
			//{
			//	map<pair<StyleDesc*,CComVariant*> >::const_iterator it=mapStyle_.find(cell);
			//	if(it!=mapStyle_.end()){
			//		return *it->second.second;
			//	}else {
			//		const CellStore* pcs=pSheet->GetCellStore(cell);
			//		const CComVariant* pdata=pcs?&pcs->cellVal:NULL;
			//		const StyleID_t sid=pcs?pcs->nStyleID:0;
			//		const StyleDesc* pstyle=&pSheet->Style_GetStyleByID(pcs->nStyleID);
			//		mapStyle_.insert(make_pair(pstyle,pdata));
			//		return pdata;
			//	}
			//}
			void clear()
			{
				map_.clear();
			}
		private:
			map<CCell,CellStorePack> map_;
		};
		*/
	public:
		GridRenderer(CellTypeFactory& cellTypeFactory):cellTypeFactory_(cellTypeFactory),pSheet_(NULL)
		{
		}
		void Init(HWND hWndGrid);//Worksheet* pSheet);
		void draw(const Worksheet* pSheet,const CellAxisInfo* pcai,HDC hDC,LPCRECT lprcClient,const CRgnLight* pRgnClip);
		void SetDirty()
		{
			//session_.clear();
		}
		//BOOL HasSymbolRegistered(CellType cellType)const
		//{
		//	return mapSymbol_.end()!=mapSymbol_.find(cellType);
		//}
		//void RegisterSymbol(CellType cellType,ICellSymbol* pSymbol)
		//{
		//	mapSymbol_[cellType]=pSymbol;
		//}
		//bool FindSymbol(CellType cellType,ICellSymbol** ppSymbol)const
		//{
		//	map<CellType,CComPtr<ICellSymbol> >::const_iterator it=mapSymbol_.find(cellType);
		//	if(it!=mapSymbol_.end()){
		//		*ppSymbol=it->second.p;
		//		(*ppSymbol)->AddRef();
		//		return true;
		//	}
		//	return false;
		//}
		//void SetBackgroundSymbol(ICellSymbol* pSymbol)
		//{
		//	pFillSymbol_=pSymbol;
		//}
		//void OnThemeChanged(HWND hWnd);
	private:
		COLORREF GetBKColor(const Worksheet* pSheet,int row,int col,const CCellRange* pmerge,COLORREF bkColor)const;//StyleDesc const& style)const;
		//void init_theme();
		//void calc_session_borders();
		void calc_cells_session(CRgnLight const* pRgnClip,int firstCol,int firstRow,int lastCol,int lastRow,LPCRECT lprcContent,VisibleCellsSession& session)const;
		//void calc_scrollCellsSession(const RowHeader & rh,const ColHeader& ch,LPCRECT lprc);//,VisibleCellsSession& vcs/*vector<VisibleCellSession>& vec*/);
		//void calc_freezeAlthogonalSession(const RowHeader& rh,const ColHeader& ch,LPCRECT lprcContent);
		//void clearup_session(CRgnLight const* pRgnClip,vector<CellItem>& vec);
		ESelectionState SetupRowHeaderDE(const Worksheet* pSheet,const Selections* pCurSelections,int row,COLORREF& backColor)const;
		ESelectionState SetupColHeaderDE(const Worksheet* pSheet,const Selections* pCurSelections,int col,COLORREF& backColor)const;
		ECellSelectionRelations GetCellSelectionRelations(const Worksheet* pSheet,const CCellRange& cr,int row,int col)const;
	private:
		//BOOL draw_HeaderCell(CDCHandle& dc,LPCTSTR lpText,int nCount,LPCRECT lprc,COLORREF backColor)const;
		void draw_RowHeader(CDCHandle& dc,LPCRECT lprc,int firstRow,int lastRow,CRgnLight const* pRgnClip);
		void draw_ColHeader(CDCHandle& dc,LPCRECT lprc,int leftCol,int rightCol,CRgnLight const* pRgnClip);
		//void draw_content(HDC,LPCRECT lprcContent,/*vector<VisibleCellSession> const& vec,*/CRgnLight const* pRgnClip);
		void draw_session(CDCHandle& dc,VisibleCellsSession& session,EGridPart ePart,const CCellRange& activeSelection);
		//void draw_content_old(HDC hDC,LPCRECT lprc,CRgnLight const* pRgnClip);
		//void draw_content1(HDC,LPCRECT lprc,CRgnLight const* pRgnClip);
		//void draw_HeaderCorner(CDCHandle& dc,LPCRECT lprc,COLORREF backColor)const;
		//void draw_cell(HDC hDC,/*int topRow,int leftCol,*/int row,int col/*,ECellType cellType*/,LPCTSTR lpText,int nCount,LPCRECT lprc,StyleDesc styleDesc,COLORREF bkColor);
		void draw_cell(CDCHandle dc,CCell cell,CellItem& item,const CCellRange& activeSelection,const Selections* pSelections,VisibleCellsSession& session);
		void draw_cell_inner(CDCHandle& dc,const CMergeCell* merge,int row,int col,/*DrawCellStruct*/DrawCellInfo& dcs,style::StyleDesc const& style)const;
		//void draw_cell_shrink(CDCHandle& dc,int row,int col,DrawCellStruct& dcs,ECellBGShrinkState* peShrink,CMergeCell* pmerge);
		void draw_cell_shrink(const Worksheet* pSheet,int row,int col,const Selections* pCurSelections,CDCHandle& dc,const CCellRange& activeSelection,CellItem& cell,DrawCellInfo/*DrawCellStruct*/& dcs)const;//,CMergeCell* pmerge);
		//void draw_cell_shrink(CDCHandle& dc,int row,int col,CellItem& cell,DrawCellStruct& dcs);
		//void draw_merge_cell(HDC hDC,/*int topRow,int leftCol,*/int row,int col/*,ECellType cellType*/,CCellRange* pMergeCells,LPCTSTR lpText,int nCount,LPCRECT lprc,StyleDesc const& styleDesc);
		//void draw_cell_border(HDC hDC,int row,int col,CMergeCell const* pMerge,int topRow,int leftCol,LPCRECT lprc/**/);
//<<<<<<< .mine
		//void draw_border(const Worksheet* pSheet,CDCHandle& dc,int row,int col,Border left,Border top,Border right,Border bottom,LPCRECT lprc);
		void draw_cell_border(CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,CellBorder cellBorder,const CMergeCell* pmerge);
		void draw_cell_border_right(CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);
		void draw_cell_border_left(CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);
		void draw_cell_border_bottom(CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);
		void draw_cell_border_top(CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);
		void draw_cell_border_rightbottom(CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);
		void draw_cell_border_leftbottom(CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);
		void draw_cell_border_righttop(CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);
		void draw_cell_border_lefttop(CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);
		//void draw_border1(const Worksheet* pSheet,CDCHandle& dc,int row,int col,Border left,Border top,Border right,Border bottom,LPCRECT lprc);
		/*
=======
		//void draw_border(const Worksheet* pSheet,CDCHandle& dc,int row,int col,Border left,Border top,Border right,Border bottom,LPCRECT lprc);
		void draw_cell_border(const Worksheet* pSheet,CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);
		void draw_cell_border_right(const Worksheet* pSheet,CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);
		void draw_cell_border_left(const Worksheet* pSheet,CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);
		void draw_cell_border_bottom(const Worksheet* pSheet,CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);
		void draw_cell_border_top(const Worksheet* pSheet,CDCHandle& dc,CCell cell,VisibleCellsSession& session,LPCRECT lprc,const CellBorder& cellBorder);

		void draw_border1(const Worksheet* pSheet,CDCHandle& dc,int row,int col,Border left,Border top,Border right,Border bottom,LPCRECT lprc);
>>>>>>> .r91
*/
		//void draw_border(HDC hDC,CellBorder bdrs,/*Border left,Border top,Border right,Border bottom,*/LPCRECT lprc);
		//void draw_borders(HDC,/*vector<VisibleCellSession> const& vec,*/CRgnLight const* pRgnClip/**/);
		//void draw_text(CDCHandle& dc,EXlHAlign xa/*StyleDesc const& styleDesc*/,LPCTSTR lpText, int nCount,LPCRECT lprc)const;
		//void fill_merge_cell(HDC hDC,int row,int col,CCellRange* pMergeCells,LPCRECT lprc,StyleDesc const& styleDesc);
		//void get_merge_cell_fillrect_region(int row,int col,CCellRange* pMergeCells,LPCRECT lprc,StyleDesc const& styleDesc,DrawCellStruct const& dcs,/*out*/LPRECT prc,/*out*/COLORREF* pbkClr);
		//void draw_merge_selection_bound(HDC hDC,CCellRange cr,int nRows,int nCols,CRgnLight const* pRgnClip);
		void draw_cell_DragBounds(const Worksheet* pSheet,CDCHandle& dc,const CCellRange activeSelection,const CMergeCell* merge,RECT rcCell,int row,int col,int rows,int cols,COLORREF bkclr)const;
	private:
		/*
		template<class TWorksheet>
		class GetBordersPolicyCacheT
		{
			const TWorksheet* pSheet_;
			CellStoreCache& cellStoreCache_;
		public:
			GetBordersPolicyCacheT(const TWorksheet* pSheet,CellStoreCache& cellStoreCache):pSheet_(pSheet),cellStoreCache_(cellStoreCache)
			{}
			const Borders* GetBorders(CCell cell)  
			{
				const StyleID_t sid=cellStoreCache_.GetCellStore(pSheet_,cell).GetStyleID();
				return pSheet_->Style_GetStyleByID(sid).GetBorders();
				//return ->GetBorders();
				//return pSheet_->Style_GetCellStyle(cell).GetBorders();
			};
		};
		*/
		//typedef GetBordersPolicyCacheT<Worksheet> GetBordersPolicyCache;
		//template<class TWorksheet>
		//Border GetLeftBorder(const TWorksheet* pSheet,CCell cell,const CellBorder& bdrs)
		//{
		//	Border bdr=bdrs.left;
		//	if(bdr.IsNull() /*&& cell.col>0*/){
		//		/*
		//		//bdr=cellStoreCache_.GetCellStore(pSheet,CCell(cell.row,cell.col-1)).pStyle->GetBorders()->right;
		//		GetBordersPolicyCache policy(pSheet,cellStoreCache_);
		//		BorderGetter<GetBordersPolicyCache> bg(policy);
		//		return bg.GetLeftBorder(pSheet,cell);
		//		*/
		//	}
		//	return bdr;
		//}
		//template<class TWorksheet>
		//Border GetLeftBorder(const TWorksheet* pSheet,CCell cell)
		//{
		//	/*
		//	const StyleID_t sid=cellStoreCache_.GetCellStore(pSheet,cell).GetStyleID();
		//	const StyleDesc& sd=pSheet->Style_GetStyleByID(sid);
		//	return GetLeftBorder(pSheet,cell,*sd.GetBorders());
		//	*/
		//	return Border();
		//}
		//template<class TWorksheet>
		//Border GetRightBorder(const TWorksheet* pSheet,CCell cell,const CellBorder& bdrs)
		//{
		//	Border bdr=bdrs.right;
		//	if(bdr.IsNull() /*&& cell.col<pSheet->get_ColHeader().get_cols()-1*/){
		//		//bdr=cellStoreCache_.GetCellStore(pSheet,CCell(cell.row,cell.col+1)).pStyle->GetBorders()->left;
		//		/*
		//		GetBordersPolicyCache policy(pSheet,cellStoreCache_);
		//		BorderGetter<GetBordersPolicyCache> bg(policy);
		//		return bg.GetRightBorder(pSheet,cell);
		//		*/
		//	}
		//	return bdr;
		//}
		//template<class TWorksheet>
		//Border GetRightBorder(const TWorksheet* pSheet,CCell cell)
		//{
		//	/*
		//	const StyleID_t sid=cellStoreCache_.GetCellStore(pSheet,cell).GetStyleID();
		//	const StyleDesc& sd=pSheet->Style_GetStyleByID(sid);
		//	return GetRightBorder(pSheet,cell,*sd.GetBorders());
		//	*/
		//	return Border();
		//}
		//template<class TWorksheet>
		//Border GetTopBorder(const TWorksheet* pSheet,CCell cell,const CellBorder& bdrs)
		//{
		//	Border bdr=bdrs.top;
		//	if(bdr.IsNull()/* && cell.row>0*/){
		//		//bdr=cellStoreCache_.GetCellStore(pSheet,CCell(cell.row-1,cell.col)).pStyle->GetBorders()->bottom;
		//		/*
		//		GetBordersPolicyCache policy(pSheet,cellStoreCache_);
		//		BorderGetter<GetBordersPolicyCache> bg(policy);
		//		return bg.GetTopBorder(pSheet,cell);
		//		*/
		//	}
		//	return bdr;
		//}
		//template<class TWorksheet>
		//Border GetTopBorder(const TWorksheet* pSheet,CCell cell)
		//{
		//	/*
		//	const StyleID_t sid=cellStoreCache_.GetCellStore(pSheet,cell).GetStyleID();
		//	const StyleDesc& sd=pSheet->Style_GetStyleByID(sid);
		//	return GetTopBorder(pSheet,cell,*sd.GetBorders());
		//	*/
		//	return Border();
		//}
		//template<class TWorksheet>
		//Border GetBottomBorder(const TWorksheet* pSheet,CCell cell,const CellBorder& bdrs)
		//{
		//	Border bdr=bdrs.bottom;
		//	if(bdr.IsNull() /*&& cell.row<pSheet->get_RowHeader().get_rows()-1*/){
		//		//bdr=cellStoreCache_.GetCellStore(pSheet,CCell(cell.row+1,cell.col)).pStyle->GetBorders()->top;
		//		/*
		//		GetBordersPolicyCache policy(pSheet,cellStoreCache_);
		//		BorderGetter<GetBordersPolicyCache> bg(policy);
		//		return bg.GetBottomBorder(pSheet,cell);
		//		*/
		//	}
		//	return bdr;
		//}
		//template<class TWorksheet>
		//Border GetBottomBorder(const TWorksheet* pSheet,CCell cell)
		//{
		//	/*
		//	const StyleID_t sid=cellStoreCache_.GetCellStore(pSheet,cell).GetStyleID();
		//	const StyleDesc& sd=pSheet->Style_GetStyleByID(sid);
		//	return GetBottomBorder(pSheet,cell,*sd.GetBorders());
		//	*/
		//	return Border();
		//}
	private:
		CellTypeFactory& cellTypeFactory_;
		//map<CellType,CComPtr<ICellSymbol> > mapSymbol_;
		//CComPtr<ICellSymbol> pFillSymbol_;
		const Worksheet* pSheet_;
		//PenFactory penPactory;
		//CellStoreCache cellStoreCache_;
		//MergeCellcache mergeCellCache_;
	};
}//namespace mycell

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
China China
My name is Yanxueming,i live in Chengdu China.Graduated from UESTC in 1999.

Comments and Discussions