1 /* 2 * Copyright (c) 2021-2022 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 "core/components/text_span/text_span_component.h" 17 18 #include "core/components/text_span/render_text_span.h" 19 #include "core/components/text_span/text_span_element.h" 20 21 namespace OHOS::Ace { 22 TextSpanComponent(const std::string & spanData)23TextSpanComponent::TextSpanComponent(const std::string& spanData) : ComponentGroup(std::list<RefPtr<Component>>()) 24 { 25 if (!declaration_) { 26 declaration_ = AceType::MakeRefPtr<SpanDeclaration>(); 27 declaration_->Init(); 28 } 29 SetSpanData(spanData); 30 } 31 CreateElement()32RefPtr<Element> TextSpanComponent::CreateElement() 33 { 34 return AceType::MakeRefPtr<TextSpanElement>(); 35 } 36 CreateRenderNode()37RefPtr<RenderNode> TextSpanComponent::CreateRenderNode() 38 { 39 return RenderTextSpan::Create(); 40 } 41 GetSpanData() const42const std::string& TextSpanComponent::GetSpanData() const 43 { 44 return declaration_->GetSpanData(); 45 } 46 SetSpanData(const std::string & data)47void TextSpanComponent::SetSpanData(const std::string& data) 48 { 49 declaration_->SetSpanData(data); 50 } 51 GetTextStyle() const52const TextStyle& TextSpanComponent::GetTextStyle() const 53 { 54 return declaration_->GetSpanStyle(); 55 } 56 SetTextStyle(const TextStyle & spanStyle)57void TextSpanComponent::SetTextStyle(const TextStyle& spanStyle) 58 { 59 declaration_->SetTextStyle(spanStyle); 60 hasNewStyle_ = true; 61 } 62 IsShow() const63bool TextSpanComponent::IsShow() const 64 { 65 return declaration_->IsShow(); 66 } 67 SetIsShow(bool isShow)68void TextSpanComponent::SetIsShow(bool isShow) 69 { 70 declaration_->SetIsShow(isShow); 71 } 72 SetOnClick(const EventMarker & onClick)73void TextSpanComponent::SetOnClick(const EventMarker& onClick) 74 { 75 declaration_->SetClickEvent(onClick); 76 } 77 SetRemoteMessageEventId(const EventMarker & eventId)78void TextSpanComponent::SetRemoteMessageEventId(const EventMarker& eventId) 79 { 80 declaration_->SetRemoteMessageEvent(eventId); 81 } 82 SetDeclaration(const RefPtr<SpanDeclaration> & declaration)83void TextSpanComponent::SetDeclaration(const RefPtr<SpanDeclaration>& declaration) 84 { 85 if (declaration) { 86 declaration_ = declaration; 87 } 88 } 89 GetDeclaration() const90const RefPtr<SpanDeclaration>& TextSpanComponent::GetDeclaration() const 91 { 92 return declaration_; 93 } 94 95 } // namespace OHOS::Ace