|
/* -------------------------------------------------------------------------
//MyCell Library - MyCell version 1.0
//
// This file is a part of the MyCell Library.
// The use and distribution terms for this software are covered by the
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file CPL.txt at this distribution. By using
// this software in any fashion, you are agreeing to be bound by the terms
// of this license. You must not remove this notice, or any other, from
// this software.
//
// Creator: yanxueming
// Email: xueming.yan@gmail.com
//Yanxm 2008��1��16�� 18:01:25
// -----------------------------------------------------------------------*/
#pragma once
#include <utility>
#include "base.h"
#include "StyleDesc.h"
#include "StyleStore.h"
using mycell::style::StyleDesc;
using namespace std;
namespace mycell{
//class ColStylesMgr;
class CellStore
{
StyleID_t nStyleID; //��Ԫ��ķ��ID
USHORT cellType; //cellType���ͱ���ECellType�Լ��û��Զ�������
CComVariant cellVal; //��Ԫ���ֵ
public:
//CellStore()
//{
//}
CellStore(const CellStore* prhs=NULL)
{
if(prhs){
*this=*prhs;
}else{
clear();
}
}
CellStore& operator=(const CellStore& rhs)
{
nStyleID=rhs.nStyleID;
cellVal=rhs.cellVal;
cellType=rhs.cellType;
return *this;
}
StyleID_t GetStyleID()const
{
return nStyleID;
}
ECellType GetCellType()const
{
return (ECellType)cellType;
}
const CComVariant& GetData()const
{
return cellVal;
}
CComVariant& GetData()
{
return cellVal;
}
StyleID_t SetStyle(StyleStore& ss,StyleDesc style)
{
ss.DecrementRefCount(nStyleID);
return nStyleID=ss.add_style(style);
}
void ClearStyle(StyleStore& ss)
{
ss.DecrementRefCount(nStyleID);
nStyleID=0;
}
void SetCellType(ECellType ct)
{
cellType=ct;
}
void SetData(const VARIANT& val)
{
cellVal=val;
}
void Attach(CellStore& rhs)
{
CComVariant val;
rhs.cellVal.Detach(&val);
*this=rhs;
cellVal.Attach(&val);
}
/*
BOOL IsNull()const
{
return !nStyleID && (VT_NULL==cellVal.vt||VT_EMPTY==cellVal.vt);
}
*/
BOOL IsEmpty()const
{
return !nStyleID && !cellType && VT_EMPTY==cellVal.vt;
}
void clear()
{
nStyleID=0;
cellType=0;
cellVal.Clear();
}
};
struct StylePack
{
StyleID_t nStyleID;
ECellStorePosition eStorePos;
//bool fValid;
//StylePack():fValid(false)
//{}
};
struct CellTypePack
{
BYTE cellType;//ECellType
ECellStorePosition eStorePos;
//bool fValid;
//CellTypePack():fValid(false)
//{}
};
struct CellValPack
{
const CComVariant* pVal;
ECellStorePosition eStorePos;
};
class Worksheet;
enum ECellStoreMask
{
ECSM_CELLDATA_VALID=0,
ECSM_STYLE_VALID=1<<0,
ECSM_CELLTYPE_VALID=1<<1
};
class CMergeCell;
class CellStorePack
{
StylePack stylePack;
CellTypePack cellTypePack;
CellValPack cellValPack;
const CMergeCell* pMerge;
public:
//const CCell cell;
//const pair<const CellStore*,ECellStorePosition> csPack;
public:
CellStorePack():pMerge(NULL)
{
stylePack.nStyleID=0;
cellTypePack.cellType=0;
}
//mMaskΪECellStoreMask��λ���
CellStorePack(const Worksheet* pSheet,const CMergeCell* pMergeCell,CCell cell,const CellStore& cs,ECellStorePosition esp,UINT nMask=0);
CellStorePack(const CellStorePack& rhs):stylePack(rhs.stylePack)
,cellTypePack(rhs.cellTypePack),cellValPack(rhs.cellValPack),pMerge(rhs.pMerge)
{
}
//const CellStore& CellStore()const
//{
// return *csPack.first;
//}
//ECellStorePosition StorePos()const
//{
// return csPack.second;
//}
const CMergeCell* GetMerge()const
{
return pMerge;
}
CellValPack GetCellValPack()const
{
return cellValPack;
}
//ȡ�����տ��õķ��
StylePack GetStylePack()const
{
return stylePack;
}
StyleID_t GetStyleID()const
{
return stylePack.nStyleID;
}
template<class TWorksheet>
const StyleDesc& GetStyle(const TWorksheet* pSheet)const
{
return pSheet->Style_GetStyleByID(stylePack.nStyleID);
}
CellTypePack GetCellTypePack()const
{
return cellTypePack;
}
ECellType GetCellType()const
{
return (ECellType)cellTypePack.cellType;
}
//private:
// void CalcStyle(const Worksheet* pSheet,CCell cell);
// void CalcCellType(const Worksheet* pSheet,CCell cell);
};
}//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.
My name is Yanxueming,i live in Chengdu China.Graduated from UESTC in 1999.