2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
19 * @file FUi_ClipboardItem.cpp
20 * @brief This is the implementation file for the _ClipboardItem class.
24 #include <FBaseString.h>
25 #include <FGrpBitmap.h>
26 #include <FBaseResult.h>
27 #include <FBaseSysLog.h>
28 #include "FUi_ClipboardItem.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Graphics;
33 namespace Tizen { namespace Ui
36 _ClipboardItem::CreateInstanceN(ClipboardDataType type, const Object& data)
38 _ClipboardItem* pItem = new (std::nothrow) _ClipboardItem(type, data);
39 SysTryReturn(NID_UI, pItem, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
41 result r = GetLastResult();
42 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
44 SetLastResult(E_SUCCESS);
53 _ClipboardItem::~_ClipboardItem(void)
69 _ClipboardItem::GetDataType(void) const
75 _ClipboardItem::GetData(void) const
77 if (__type == CLIPBOARD_DATA_TYPE_IMAGE)
87 _ClipboardItem::_ClipboardItem(ClipboardDataType type, const Object& data)
92 SysTryReturnVoidResult(NID_UI,
93 (CLIPBOARD_DATA_TYPE_TEXT & type) ||
94 (CLIPBOARD_DATA_TYPE_HTML & type) ||
95 (CLIPBOARD_DATA_TYPE_IMAGE & type) ||
96 (CLIPBOARD_DATA_TYPE_VIDEO & type) ||
97 (CLIPBOARD_DATA_TYPE_AUDIO & type)
98 , E_INVALID_ARG, "[E_INVALID_ARG] The data type is invalid.");
100 if (type == CLIPBOARD_DATA_TYPE_IMAGE)
102 const Bitmap* pBitmap = dynamic_cast<const Bitmap*>(&data);
103 SysTryReturnVoidResult(NID_UI, pBitmap, E_INVALID_ARG, "[E_INVALID_ARG] The data is invalid.");
105 __pBitmap = new (std::nothrow) Bitmap;
106 SysTryReturnVoidResult(NID_UI, __pBitmap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
108 result r = __pBitmap->Construct(*pBitmap, Rectangle(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()));
109 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
113 const String* pString = dynamic_cast<const String*>(&data);
114 SysTryReturnVoidResult(NID_UI, pString, E_INVALID_ARG, "[E_INVALID_ARG] The data is invalid.");
116 __pString = new (std::nothrow) String(*pString);
117 SysTryReturnVoidResult(NID_UI, __pString, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
120 SetLastResult(E_SUCCESS);