mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
use text/plain first instead of text/html
Signed-off-by: zhoukechen <zhoukechen2@huawei.com> Change-Id: I25bb11ada08913280dae9b7278152da87c755e34
This commit is contained in:
parent
cb2567f084
commit
756b1cc22a
@ -431,10 +431,9 @@ void ClipboardImpl::GetDataAsync(const std::function<void(const std::string&)>&
|
||||
return;
|
||||
}
|
||||
std::string resText;
|
||||
bool hasPlainRecord = false;
|
||||
for (const auto& pasteDataRecord : pasteData.AllRecords()) {
|
||||
if (clip->ProcessPasteDataRecord(pasteDataRecord, resText)) {
|
||||
break;
|
||||
}
|
||||
clip->ProcessPasteDataRecord(pasteDataRecord, resText, hasPlainRecord);
|
||||
}
|
||||
if (resText.empty()) {
|
||||
TAG_LOGW(AceLogTag::ACE_CLIPBOARD, "Get SystemKeyboardTextData fail from MiscServices");
|
||||
@ -451,13 +450,26 @@ void ClipboardImpl::GetDataAsync(const std::function<void(const std::string&)>&
|
||||
TaskExecutor::TaskType::BACKGROUND, "ArkUIClipboardGetTextDataAsync");
|
||||
}
|
||||
|
||||
bool ClipboardImpl::ProcessPasteDataRecord(const std::shared_ptr<MiscServices::PasteDataRecord>& pasteDataRecord,
|
||||
std::string& resText)
|
||||
void ClipboardImpl::ProcessPasteDataRecord(const std::shared_ptr<MiscServices::PasteDataRecord>& pasteDataRecord,
|
||||
std::string& resText, bool& hasPlainRecord)
|
||||
{
|
||||
if (pasteDataRecord == nullptr) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
TAG_LOGI(AceLogTag::ACE_CLIPBOARD, "mimeType:%{public}s", pasteDataRecord->GetMimeType().c_str());
|
||||
if (pasteDataRecord->GetPlainText() != nullptr) {
|
||||
auto textData = pasteDataRecord->GetPlainText();
|
||||
if (!hasPlainRecord) {
|
||||
resText = "";
|
||||
}
|
||||
TAG_LOGI(AceLogTag::ACE_CLIPBOARD, "textData:%{private}s, length:%{public}zu", textData->c_str(),
|
||||
textData->length());
|
||||
resText.append(*textData);
|
||||
hasPlainRecord = true;
|
||||
}
|
||||
if (hasPlainRecord) {
|
||||
return;
|
||||
}
|
||||
if (pasteDataRecord->GetHtmlText() != nullptr) {
|
||||
auto htmlText = pasteDataRecord->GetHtmlText();
|
||||
TAG_LOGI(AceLogTag::ACE_CLIPBOARD, "htmlText:%{private}s, length=%{public}zu", htmlText->c_str(),
|
||||
@ -466,7 +478,7 @@ bool ClipboardImpl::ProcessPasteDataRecord(const std::shared_ptr<MiscServices::P
|
||||
auto spanStr = toSpan.ToSpanString(*htmlText);
|
||||
if (spanStr) {
|
||||
resText = spanStr->GetString();
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (pasteDataRecord->GetCustomData() != nullptr) {
|
||||
@ -475,17 +487,10 @@ bool ClipboardImpl::ProcessPasteDataRecord(const std::shared_ptr<MiscServices::P
|
||||
auto spanStr = SpanString::DecodeTlv(itemData[SPAN_STRING_TAG]);
|
||||
if (spanStr) {
|
||||
resText = spanStr->GetString();
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pasteDataRecord->GetPlainText() != nullptr) {
|
||||
auto textData = pasteDataRecord->GetPlainText();
|
||||
TAG_LOGI(AceLogTag::ACE_CLIPBOARD, "textData:%{private}s, length:%{public}zu", textData->c_str(),
|
||||
textData->length());
|
||||
resText.append(*textData);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClipboardImpl::GetDataSync(const std::function<void(const std::string&, bool isLastRecord)>& textCallback,
|
||||
|
@ -65,8 +65,8 @@ private:
|
||||
void GetDataAsync(const std::function<void(const std::string&, bool isLastRecord)>& textCallback,
|
||||
const std::function<void(const RefPtr<PixelMap>&, bool isLastRecord)>& pixelMapCallback,
|
||||
const std::function<void(const std::string&, bool isLastRecord)>& urlCallback);
|
||||
bool ProcessPasteDataRecord(const std::shared_ptr<MiscServices::PasteDataRecord>& pasteDataRecord,
|
||||
std::string& resText);
|
||||
void ProcessPasteDataRecord(const std::shared_ptr<MiscServices::PasteDataRecord>& pasteDataRecord,
|
||||
std::string& resText, bool& hasPlainRecord);
|
||||
void GetPixelMapDataSync(const std::function<void(const RefPtr<PixelMap>&)>& callback);
|
||||
void GetPixelMapDataAsync(const std::function<void(const RefPtr<PixelMap>&)>& callback);
|
||||
void GetSpanStringDataHelper(
|
||||
|
Loading…
Reference in New Issue
Block a user