COMPASSi/trunk/code/3rd/CCSReport/include/ccstemplatebase.h

143 lines
3.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef CCSTEMPLATEBASE_H
#define CCSTEMPLATEBASE_H
#include <QObject>
#include <QMargins>
#include "common_types.h"
namespace CCS_Report {
/// <summary>
/// 元素格式属性定义基类
/// </summary>
class BaseFormat:public QObject
{
public:
BaseFormat()
{
Init(0,0,0,0);
}
BaseFormat(const int left,int top,const int right,int bottom,bool newPage,CCSReportType::OrientationFlag orient)
{
Init(left,top,right,bottom);
m_bNewPage = newPage;
m_iOrientation = orient;
}
BaseFormat(const int left,int top,const int right,int bottom)
{
Init(left,top,right,bottom);
}
BaseFormat(const BaseFormat& format)
{
m_bNewPage = format.m_bNewPage;
m_iMarginLeft=format.m_iMarginLeft;
m_iMarginTop=format.m_iMarginTop;
m_iMarginBottom=format.m_iMarginBottom;
m_iMarginRight=format.m_iMarginRight;
m_iOrientation = format.m_iOrientation;
}
BaseFormat& operator= (const BaseFormat& format) {
m_bNewPage = format.m_bNewPage;
m_iMarginLeft=format.m_iMarginLeft;
m_iMarginTop=format.m_iMarginTop;
m_iMarginBottom=format.m_iMarginBottom;
m_iMarginRight=format.m_iMarginRight;
m_iOrientation = format.m_iOrientation;
}
void Init(const int left,int top,const int right,int bottom)
{
m_bNewPage = false;
m_iMarginLeft=left;
m_iMarginTop=top;
m_iMarginBottom=bottom;
m_iMarginRight=right;
m_iOrientation = CCSReportType::Portrait;
}
~BaseFormat(){}
inline void SetNewPage(const bool bNewpage) {m_bNewPage = bNewpage;}
inline bool newpage() const { return m_bNewPage;}
inline void SetLeft(const int& left ){m_iMarginLeft = left;}
inline void SetRight(const int&right){m_iMarginRight = right;}
inline void SetTop(const int& top ){m_iMarginTop = top;}
inline void SetBottom(const int&right){m_iMarginBottom = right;}
inline int marginLeft() const {return m_iMarginLeft;}
inline int marginRight() const {return m_iMarginRight;}
inline int marginTop() const {return m_iMarginTop;}
inline int marginBottom() const {return m_iMarginBottom;}
inline void SetOrient(const CCSReportType::OrientationFlag orient){m_iOrientation = orient;}
inline CCSReportType::OrientationFlag orientation() const {return m_iOrientation;}
inline void SetMargin(const int& left,const int& top,const int& right,const int& bottom)
{
m_iMarginLeft=left;
m_iMarginTop=top;
m_iMarginBottom=bottom;
m_iMarginRight=right;
}
inline QMargins margin()
{
return QMargins(m_iMarginLeft,m_iMarginTop,m_iMarginRight,m_iMarginBottom);
}
private:
bool m_bNewPage; //换页标识一般是某输出baseitem后换页或者是某个band输出后换页
int m_iMarginLeft;
int m_iMarginTop;
int m_iMarginBottom;
int m_iMarginRight;
CCSReportType::OrientationFlag m_iOrientation; //方向 =0 横向 =1 纵向
};
/// <summary>
/// 元素类的基类
/// </summary>
class BaseItem:public QObject
{
public:
enum class classtype
{
Text,
Image,
Paragraph,
Cell,
Table,
TableDynamic,
TableGroup,
BlankLine,
Page
};
public:
BaseItem(QString name=""){
m_Name = name;
m_Format = nullptr;
}
BaseItem(const BaseItem& item)
{
m_Format = nullptr;
// m_Format = new BaseFormat(item.m_Format);
m_Name = item.m_Name;
}
classtype elementType() const { return m_Type;}
virtual ~BaseItem()
{
if (m_Format != nullptr)
{
delete m_Format;
}
}
inline BaseFormat* Format() const
{
return m_Format;
}
protected:
BaseFormat* m_Format;
QString m_Name;
classtype m_Type;
};
}
#endif // CCSTEMPLATEBASE_H