NDK C-API fix TDD

Signed-off-by: liyi0309<liyi58@huawei.com>

Change-Id: I76b62ab3f88dbbc160c93c783821c14eeb7daab3
This commit is contained in:
firminly 2024-08-08 19:10:07 +08:00
parent f939c27d3b
commit 80e3453fc5
5 changed files with 37 additions and 3 deletions

View File

@ -429,4 +429,12 @@ std::vector<Shadow> SpanModelNG::GetTextShadow(UINode* uiNode)
CHECK_NULL_RETURN(uiNode, defaultShadow);
return spanNode->GetTextShadow().value_or(defaultShadow);
}
std::vector<std::string> SpanModelNG::GetSpanFontFamily(UINode* uiNode)
{
auto spanNode = AceType::DynamicCast<SpanNode>(uiNode);
std::vector<std::string> value;
CHECK_NULL_RETURN(spanNode, value);
return spanNode->GetFontFamily().value_or(value);
}
} // namespace OHOS::Ace::NG

View File

@ -82,6 +82,7 @@ public:
static std::vector<Shadow> GetTextShadow(UINode* uiNode);
static void SetOnClick(UINode* uiNode, GestureEventFunc&& click);
static void ClearOnClick(UINode* uiNode);
static std::vector<std::string> GetSpanFontFamily(UINode* uiNode);
#ifdef USE_GRAPHIC_TEXT_GINE
// impl in render/adapter/span_model_adapter.cpp
static RefPtr<SpanItem> CreateSpanItem(ArkUI_SpanItem* item);

View File

@ -3983,6 +3983,7 @@ struct ArkUISpanModifier {
void (*setTextShadow)(ArkUINodeHandle node, struct ArkUITextShadowStruct* shadows, ArkUI_Uint32 length);
void (*resetTextShadow)(ArkUINodeHandle node);
void (*getTextShadows)(ArkUINodeHandle node, ArkUITextShadowStruct* textShadow, ArkUI_Uint32 size);
ArkUI_CharPtr (*getSpanFontFamily)(ArkUINodeHandle node);
};
struct ArkUISelectModifier {

View File

@ -443,6 +443,25 @@ void ResetTextTextShadow(ArkUINodeHandle node)
shadow.SetOffsetY(0.0);
SpanModelNG::SetTextShadow(frameNode, std::vector<Shadow> { shadow });
}
ArkUI_CharPtr GetSpanFontFamily(ArkUINodeHandle node)
{
auto* frameNode = reinterpret_cast<UINode*>(node);
CHECK_NULL_RETURN(frameNode, nullptr);
std::vector<std::string> fontFamilies = SpanModelNG::GetSpanFontFamily(frameNode);
std::string families;
//set index start
uint32_t index = 0;
for (auto& family : fontFamilies) {
families += family;
if (index != fontFamilies.size() - 1) {
families += ",";
}
index++;
}
g_strValue = families;
return g_strValue.c_str();
}
} // namespace
namespace NodeModifier {
const ArkUISpanModifier* GetSpanModifier()
@ -455,7 +474,7 @@ const ArkUISpanModifier* GetSpanModifier()
SetSpanFontWeightStr, GetSpanContent, GetSpanDecoration, GetSpanFontColor, GetSpanFontSize, GetSpanFontStyle,
GetSpanFontWeight, GetSpanLineHeight, GetSpanTextCase, GetSpanLetterSpacing, GetSpanBaselineOffset,
SetSpanTextBackgroundStyle, ResetSpanTextBackgroundStyle, GetSpanTextBackgroundStyle, SetTextTextShadow,
ResetTextTextShadow, GetTextShadow };
ResetTextTextShadow, GetTextShadow, GetSpanFontFamily };
return &modifier;
}
} // namespace NodeModifier

View File

@ -7356,8 +7356,13 @@ int32_t SetTextFontFamily(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item
const ArkUI_AttributeItem* GetTextFontFamily(ArkUI_NodeHandle node)
{
auto resultValue = GetFullImpl()->getNodeModifiers()->getTextModifier()->getFontFamily(node->uiNodeHandle);
g_attributeItem.string = resultValue;
if (node->type == ARKUI_NODE_SPAN) {
auto resultValue = GetFullImpl()->getNodeModifiers()->getSpanModifier()->getSpanFontFamily(node->uiNodeHandle);
g_attributeItem.string = resultValue;
} else {
auto resultValue = GetFullImpl()->getNodeModifiers()->getTextModifier()->getFontFamily(node->uiNodeHandle);
g_attributeItem.string = resultValue;
}
g_attributeItem.size = 0;
return &g_attributeItem;
}