Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / FUi_ClipboardItemImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file                FUi_ClipboardItemImpl.cpp
19  * @brief               This is the implementation file for the _ClipboardItemImpl class.
20  */
21 #include <new>
22 #include <FBaseResult.h>
23 #include <FUiClipboardItem.h>
24 #include <FBaseSysLog.h>
25 #include "FUi_ClipboardItemImpl.h"
26 #include "FUi_ClipboardItem.h"
27
28 using namespace Tizen::Base;
29
30 namespace Tizen { namespace Ui
31 {
32
33 _ClipboardItemImpl*
34 _ClipboardItemImpl::CreateInstanceN(ClipboardItem* pPublic, ClipboardDataType type, const Object& data)
35 {
36         _ClipboardItem* pItemCore = _ClipboardItem::CreateInstanceN(type, data);
37
38         _ClipboardItemImpl* pItemImpl = null;
39
40         result r = GetLastResult();
41         if ((r == E_OUT_OF_MEMORY) || (r == E_INVALID_ARG) || (r == E_SYSTEM))
42         {
43                 SysLogException(NID_UI, r, "[%s] Propagating.", GetErrorMessage(r));
44                 goto CATCH;
45         }
46         else if (r != E_SUCCESS)
47         {
48                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
49                 goto CATCH;
50         }
51
52         pItemImpl = new (std::nothrow) _ClipboardItemImpl(pPublic, pItemCore);
53         SysTryCatch(NID_UI, pItemImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
54
55         SetLastResult(E_SUCCESS);
56
57         return pItemImpl;
58
59 CATCH:
60         if (pItemCore)
61         {
62                 delete pItemCore;
63         }
64
65         return null;
66 }
67
68 ClipboardDataType
69 _ClipboardItemImpl::GetDataType(void) const
70 {
71         return GetCore().GetDataType();
72 }
73
74 Object*
75 _ClipboardItemImpl::GetData(void) const
76 {
77         return const_cast<Object*>(GetCore().GetData());
78 }
79
80 const ClipboardItem&
81 _ClipboardItemImpl::GetPublic(void) const
82 {
83         return *__pPublic;
84 }
85
86 ClipboardItem&
87 _ClipboardItemImpl::GetPublic(void)
88 {
89         return *__pPublic;
90 }
91
92 const _ClipboardItem&
93 _ClipboardItemImpl::GetCore(void) const
94 {
95         return *__pCore;
96 }
97
98 _ClipboardItem&
99 _ClipboardItemImpl::GetCore(void)
100 {
101         return *__pCore;
102 }
103
104 _ClipboardItemImpl*
105 _ClipboardItemImpl::GetInstance(ClipboardItem& clipboardItem)
106 {
107         return clipboardItem.__pImpl;
108 }
109
110 const _ClipboardItemImpl*
111 _ClipboardItemImpl::GetInstance(const ClipboardItem& clipboardItem)
112 {
113         return static_cast<const _ClipboardItemImpl*> (clipboardItem.__pImpl);
114 }
115
116 _ClipboardItemImpl::_ClipboardItemImpl(ClipboardItem* pPublic, _ClipboardItem* pCore)
117         : __pPublic(pPublic)
118         , __pCore(pCore)
119 {
120 }
121
122 _ClipboardItemImpl::~_ClipboardItemImpl(void)
123 {
124         if (__pCore)
125         {
126                 delete __pCore;
127                 __pCore = null;
128         }
129 }
130
131 }} // Tizen::Ui