CAPI属性字符串转HTML为空

Signed-off-by: zyx0121 <zhangyingxiang2@huawei.com>
This commit is contained in:
zyx0121 2024-10-16 14:35:32 +08:00
parent f6c19c34f1
commit 243867ae41
4 changed files with 12 additions and 11 deletions

View File

@ -619,11 +619,12 @@ void ClipboardImpl::ProcessSpanStringData(
continue;
}
auto hasSpanString = false;
if (pasteDataRecord->GetCustomData() != nullptr) {
auto itemData = pasteDataRecord->GetCustomData()->GetItemData();
if (itemData.find(SPAN_STRING_TAG) != itemData.end()) {
arrays.emplace_back(itemData[SPAN_STRING_TAG]);
}
auto entryPtr = pasteDataRecord->GetEntryByMimeType(SPAN_STRING_TAG);
if (entryPtr) {
// entryValue InstanceOf OHOS::MiscServices::EntryValue.
auto entryValue = entryPtr->GetValue();
auto spanStringBuffer = std::get_if<std::vector<uint8_t>>(&entryValue);
arrays.emplace_back(*spanStringBuffer);
hasSpanString = true;
}
if (pasteDataRecord->GetHtmlText() != nullptr && hasSpanString) {

View File

@ -4191,6 +4191,7 @@ void RichEditorPattern::InsertStyledStringByPaste(const RefPtr<SpanString>& span
if (changeLength > 0) {
DeleteForwardInStyledString(changeLength, false);
}
ResetSelection();
styledString_->InsertSpanString(changeStart, spanString);
SetCaretPosition(caretPosition_ + spanString->GetLength());
AfterStyledStringChange(changeStart, changeLength, spanString->GetString());

View File

@ -2111,7 +2111,6 @@ ArkUI_Int32 UnmarshallStyledStringDescriptor(
{
TAG_LOGI(OHOS::Ace::AceLogTag::ACE_NATIVE_NODE, "UnmarshallStyledStringDescriptor");
CHECK_NULL_RETURN(buffer && descriptor && bufferSize > 0, ARKUI_ERROR_CODE_PARAM_INVALID);
CHECK_NULL_RETURN(descriptor->spanString, ARKUI_ERROR_CODE_INVALID_STYLED_STRING);
std::vector<uint8_t> vec(buffer, buffer + bufferSize);
SpanString* spanString = new SpanString("");
spanString->DecodeTlvExt(vec, spanString);

View File

@ -23,13 +23,13 @@ extern "C" {
ArkUI_StyledString_Descriptor* OH_ArkUI_StyledString_Descriptor_Create()
{
CHECK_NULL_RETURN(OHOS::Ace::NodeModel::GetFullImpl() && OHOS::Ace::NodeModel::InitialFullImpl(), nullptr);
CHECK_NULL_RETURN(OHOS::Ace::NodeModel::GetFullImpl() || OHOS::Ace::NodeModel::InitialFullImpl(), nullptr);
return OHOS::Ace::NodeModel::GetFullImpl()->getStyledStringAPI()->createArkUIStyledStringDescriptor();
}
void OH_ArkUI_StyledString_Descriptor_Destroy(ArkUI_StyledString_Descriptor* descriptor)
{
CHECK_NULL_VOID(OHOS::Ace::NodeModel::GetFullImpl() && OHOS::Ace::NodeModel::InitialFullImpl());
CHECK_NULL_VOID(OHOS::Ace::NodeModel::GetFullImpl() || OHOS::Ace::NodeModel::InitialFullImpl());
OHOS::Ace::NodeModel::GetFullImpl()->getStyledStringAPI()->destroyArkUIStyledStringDescriptor(descriptor);
}
@ -37,7 +37,7 @@ int32_t OH_ArkUI_UnmarshallStyledStringDescriptor(
uint8_t* buffer, size_t bufferSize, ArkUI_StyledString_Descriptor* descriptor)
{
CHECK_NULL_RETURN(
OHOS::Ace::NodeModel::GetFullImpl() && OHOS::Ace::NodeModel::InitialFullImpl(), ARKUI_ERROR_CODE_PARAM_INVALID);
OHOS::Ace::NodeModel::GetFullImpl() || OHOS::Ace::NodeModel::InitialFullImpl(), ARKUI_ERROR_CODE_PARAM_INVALID);
return OHOS::Ace::NodeModel::GetFullImpl()->getStyledStringAPI()->unmarshallStyledStringDescriptor(
buffer, bufferSize, descriptor);
}
@ -46,7 +46,7 @@ int32_t OH_ArkUI_MarshallStyledStringDescriptor(
uint8_t* buffer, size_t bufferSize, ArkUI_StyledString_Descriptor* descriptor, size_t* resultSize)
{
CHECK_NULL_RETURN(
OHOS::Ace::NodeModel::GetFullImpl() && OHOS::Ace::NodeModel::InitialFullImpl(), ARKUI_ERROR_CODE_PARAM_INVALID);
OHOS::Ace::NodeModel::GetFullImpl() || OHOS::Ace::NodeModel::InitialFullImpl(), ARKUI_ERROR_CODE_PARAM_INVALID);
return OHOS::Ace::NodeModel::GetFullImpl()->getStyledStringAPI()->marshallStyledStringDescriptor(
buffer, bufferSize, descriptor, resultSize);
}
@ -54,7 +54,7 @@ int32_t OH_ArkUI_MarshallStyledStringDescriptor(
const char* OH_ArkUI_ConvertToHtml(ArkUI_StyledString_Descriptor* descriptor)
{
CHECK_NULL_RETURN(
OHOS::Ace::NodeModel::GetFullImpl() && OHOS::Ace::NodeModel::InitialFullImpl(), "");
OHOS::Ace::NodeModel::GetFullImpl() || OHOS::Ace::NodeModel::InitialFullImpl(), "");
return OHOS::Ace::NodeModel::GetFullImpl()->getStyledStringAPI()->convertToHtml(descriptor);
}