1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ohos_nweb/bridge/ark_web_drag_data_wrapper.h"
17
18 #include "base/bridge/ark_web_bridge_macros.h"
19
20 namespace OHOS::ArkWeb {
21
ArkWebDragDataWrapper(ArkWebRefPtr<ArkWebDragData> ark_web_drag_data)22 ArkWebDragDataWrapper::ArkWebDragDataWrapper(ArkWebRefPtr<ArkWebDragData> ark_web_drag_data)
23 : ark_web_drag_data_(ark_web_drag_data)
24 {}
25
SetFileUri(const std::string & uri)26 bool ArkWebDragDataWrapper::SetFileUri(const std::string& uri)
27 {
28 ArkWebString stUrl = ArkWebStringClassToStruct(uri);
29
30 bool flag = ark_web_drag_data_->SetFileUri(stUrl);
31
32 ArkWebStringStructRelease(stUrl);
33 return flag;
34 }
35
GetLinkURL()36 std::string ArkWebDragDataWrapper::GetLinkURL()
37 {
38 ArkWebString stUrl = ark_web_drag_data_->GetLinkURL();
39
40 std::string objUrl = ArkWebStringStructToClass(stUrl);
41 ArkWebStringStructRelease(stUrl);
42 return objUrl;
43 }
44
SetLinkURL(const std::string & url)45 bool ArkWebDragDataWrapper::SetLinkURL(const std::string& url)
46 {
47 ArkWebString stUrl = ArkWebStringClassToStruct(url);
48
49 bool flag = ark_web_drag_data_->SetLinkURL(stUrl);
50
51 ArkWebStringStructRelease(stUrl);
52 return flag;
53 }
54
GetLinkTitle()55 std::string ArkWebDragDataWrapper::GetLinkTitle()
56 {
57 ArkWebString stTitle = ark_web_drag_data_->GetLinkTitle();
58
59 std::string objTitle = ArkWebStringStructToClass(stTitle);
60 ArkWebStringStructRelease(stTitle);
61 return objTitle;
62 }
63
SetLinkTitle(const std::string & title)64 bool ArkWebDragDataWrapper::SetLinkTitle(const std::string& title)
65 {
66 ArkWebString stTitle = ArkWebStringClassToStruct(title);
67
68 bool flag = ark_web_drag_data_->SetLinkTitle(stTitle);
69
70 ArkWebStringStructRelease(stTitle);
71 return flag;
72 }
73
GetFragmentText()74 std::string ArkWebDragDataWrapper::GetFragmentText()
75 {
76 ArkWebString stText = ark_web_drag_data_->GetFragmentText();
77
78 std::string objText = ArkWebStringStructToClass(stText);
79 ArkWebStringStructRelease(stText);
80 return objText;
81 }
82
SetFragmentText(const std::string & text)83 bool ArkWebDragDataWrapper::SetFragmentText(const std::string& text)
84 {
85 ArkWebString stText = ArkWebStringClassToStruct(text);
86
87 bool flag = ark_web_drag_data_->SetFragmentText(stText);
88
89 ArkWebStringStructRelease(stText);
90 return flag;
91 }
92
GetFragmentHtml()93 std::string ArkWebDragDataWrapper::GetFragmentHtml()
94 {
95 ArkWebString stHtml = ark_web_drag_data_->GetFragmentHtml();
96
97 std::string objHtml = ArkWebStringStructToClass(stHtml);
98 ArkWebStringStructRelease(stHtml);
99 return objHtml;
100 }
101
SetFragmentHtml(const std::string & html)102 bool ArkWebDragDataWrapper::SetFragmentHtml(const std::string& html)
103 {
104 ArkWebString stHtml = ArkWebStringClassToStruct(html);
105
106 bool flag = ark_web_drag_data_->SetFragmentHtml(stHtml);
107
108 ArkWebStringStructRelease(stHtml);
109 return flag;
110 }
111
GetImageFileName()112 std::string ArkWebDragDataWrapper::GetImageFileName()
113 {
114 ArkWebString stName = ark_web_drag_data_->GetImageFileName();
115
116 std::string objName = ArkWebStringStructToClass(stName);
117 ArkWebStringStructRelease(stName);
118 return objName;
119 }
120
GetPixelMapSetting(const void ** data,size_t & len,int & width,int & height)121 bool ArkWebDragDataWrapper::GetPixelMapSetting(const void** data, size_t& len, int& width, int& height)
122 {
123 return ark_web_drag_data_->GetPixelMapSetting(data, len, width, height);
124 }
125
SetPixelMapSetting(const void * data,size_t len,int width,int height)126 bool ArkWebDragDataWrapper::SetPixelMapSetting(const void* data, size_t len, int width, int height)
127 {
128 return ark_web_drag_data_->SetPixelMapSetting(data, len, width, height);
129 }
130
ClearImageFileNames()131 void ArkWebDragDataWrapper::ClearImageFileNames()
132 {
133 ark_web_drag_data_->ClearImageFileNames();
134 }
135
IsSingleImageContent()136 bool ArkWebDragDataWrapper::IsSingleImageContent()
137 {
138 return ark_web_drag_data_->IsSingleImageContent();
139 }
140
GetDragStartPosition(int & x,int & y)141 void ArkWebDragDataWrapper::GetDragStartPosition(int& x, int& y)
142 {
143 ark_web_drag_data_->GetDragStartPosition(x, y);
144 }
145
IsDragNewStyle()146 bool ArkWebDragDataWrapper::IsDragNewStyle()
147 {
148 return ark_web_drag_data_->IsDragNewStyle();
149 }
150
151 } // namespace OHOS::ArkWeb
152