• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "html.h"
17 
18 namespace OHOS {
19 namespace UDMF {
Html()20 Html::Html()
21 {
22     this->dataType_ = HTML;
23 }
24 
Html(const std::string & htmlContent,const std::string & plainContent)25 Html::Html(const std::string &htmlContent, const std::string &plainContent)
26 {
27     if (plainContent.length() >= MAX_TEXT_LEN || htmlContent.length() >= MAX_TEXT_LEN) {
28         return;
29     }
30     this->dataType_ = HTML;
31     this->htmlContent_ = htmlContent;
32     this->plainContent_ = plainContent;
33 }
34 
GetSize()35 int64_t Html::GetSize()
36 {
37     return UnifiedDataUtils::GetDetailsSize(this->details_) + this->htmlContent_.size() + this->plainContent_.size();
38 }
39 
GetHtmlContent() const40 std::string Html::GetHtmlContent() const
41 {
42     return this->htmlContent_;
43 }
44 
SetHtmlContent(const std::string & htmlContent)45 void Html::SetHtmlContent(const std::string &htmlContent)
46 {
47     if (htmlContent.length() >= MAX_TEXT_LEN) {
48         return;
49     }
50     this->htmlContent_ = htmlContent;
51 }
52 
GetPlainContent() const53 std::string Html::GetPlainContent() const
54 {
55     return this->plainContent_;
56 }
57 
SetPlainContent(const std::string & plainContent)58 void Html::SetPlainContent(const std::string &plainContent)
59 {
60     if (plainContent.length() >= MAX_TEXT_LEN) {
61         return;
62     }
63     this->plainContent_ = plainContent;
64 }
65 } // namespace UDMF
66 } // namespace OHOS