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 #ifndef ARK_WEB_DRAG_DATA_WRAPPER_H_
17 #define ARK_WEB_DRAG_DATA_WRAPPER_H_
18 #pragma once
19 
20 #include "include/nweb_drag_data.h"
21 #include "ohos_nweb/include/ark_web_drag_data.h"
22 
23 namespace OHOS::ArkWeb {
24 
25 class ArkWebDragDataWrapper : public OHOS::NWeb::NWebDragData {
26 public:
27     ArkWebDragDataWrapper(ArkWebRefPtr<ArkWebDragData> ark_web_drag_data);
28     ~ArkWebDragDataWrapper() = default;
29 
30     /**
31      * @brief set the image file name that is being dragged.
32      */
33     bool SetFileUri(const std::string& uri) override;
34 
35     /**
36      * @brief get the link URL that is being dragged.
37      */
38     std::string GetLinkURL() override;
39 
40     /**
41      * @brief set the link URL that is being dragged.
42      */
43     bool SetLinkURL(const std::string& url) override;
44 
45     /**
46      * @brief get the title associated with the link that is being dragged.
47      */
48     std::string GetLinkTitle() override;
49 
50     /**
51      * @brief set the title associated with the link that is being dragged.
52      */
53     bool SetLinkTitle(const std::string& title) override;
54 
55     /**
56      * @brief get the plain text that is being dragged.
57      */
58     std::string GetFragmentText() override;
59 
60     /**
61      * @brief set the plain text that is being dragged.
62      */
63     bool SetFragmentText(const std::string& text) override;
64 
65     /**
66      * @brief get the text/html fragment that is being dragged.
67      */
68     std::string GetFragmentHtml() override;
69 
70     /**
71      * @brief set the text/html fragment that is being dragged.
72      */
73     bool SetFragmentHtml(const std::string& html) override;
74 
75     /**
76      * @brief get the image file name that is being dragged.
77      */
78     std::string GetImageFileName() override;
79 
80     /**
81      * @brief get the image representation data that is beging dragged.
82      */
83     bool GetPixelMapSetting(const void** data, size_t& len, int& width, int& height) override;
84 
85     /**
86      * @brief set the image representation data that is beging dragged.
87      */
88     bool SetPixelMapSetting(const void* data, size_t len, int width, int height) override;
89 
90     /**
91      * @brief clear the exist image file names.
92      */
93     void ClearImageFileNames() override;
94 
95     /**
96      * @brief is single image that is being dragged.
97      */
98     bool IsSingleImageContent() override;
99 
100     /**
101      * @brief get the positon point that is beging dragged.
102      */
103     void GetDragStartPosition(int& x, int& y) override;
104 
105     /**
106      * @brief is drag new style.
107      */
108     bool IsDragNewStyle() override;
109 
110 private:
111     ArkWebRefPtr<ArkWebDragData> ark_web_drag_data_;
112 };
113 
114 } // namespace OHOS::ArkWeb
115 
116 #endif // ARK_WEB_DRAG_DATA_WRAPPER_H_
117