00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "CClipboard.h"
00016
00017
00018
00019
00020
00021 CClipboard::CClipboard() :
00022 m_open(false),
00023 m_owner(false)
00024 {
00025 open(0);
00026 empty();
00027 close();
00028 }
00029
00030 CClipboard::~CClipboard()
00031 {
00032
00033 }
00034
00035 bool
00036 CClipboard::empty()
00037 {
00038 assert(m_open);
00039
00040
00041 for (SInt32 index = 0; index < kNumFormats; ++index) {
00042 m_data[index] = "";
00043 m_added[index] = false;
00044 }
00045
00046
00047 m_timeOwned = m_time;
00048
00049
00050 m_owner = true;
00051
00052 return true;
00053 }
00054
00055 void
00056 CClipboard::add(EFormat format, const CString& data)
00057 {
00058 assert(m_open);
00059 assert(m_owner);
00060
00061 m_data[format] = data;
00062 m_added[format] = true;
00063 }
00064
00065 bool
00066 CClipboard::open(Time time) const
00067 {
00068 assert(!m_open);
00069
00070 m_open = true;
00071 m_time = time;
00072
00073 return true;
00074 }
00075
00076 void
00077 CClipboard::close() const
00078 {
00079 assert(m_open);
00080
00081 m_open = false;
00082 }
00083
00084 CClipboard::Time
00085 CClipboard::getTime() const
00086 {
00087 return m_timeOwned;
00088 }
00089
00090 bool
00091 CClipboard::has(EFormat format) const
00092 {
00093 assert(m_open);
00094 return m_added[format];
00095 }
00096
00097 CString
00098 CClipboard::get(EFormat format) const
00099 {
00100 assert(m_open);
00101 return m_data[format];
00102 }
00103
00104 void
00105 CClipboard::unmarshall(const CString& data, Time time)
00106 {
00107 IClipboard::unmarshall(this, data, time);
00108 }
00109
00110 CString
00111 CClipboard::marshall() const
00112 {
00113 return IClipboard::marshall(this);
00114 }