mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
commit
b4bcc2c968
@ -572,7 +572,7 @@ void ClipboardImpl::GetDataAsync(const std::function<void(const std::string&, bo
|
||||
}
|
||||
|
||||
void ClipboardImpl::GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback, bool syncMode)
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback, bool syncMode)
|
||||
{
|
||||
#ifdef SYSTEM_CLIPBOARD_SUPPORTED
|
||||
if (!taskExecutor_ || !callback) {
|
||||
@ -584,7 +584,7 @@ void ClipboardImpl::GetSpanStringData(
|
||||
}
|
||||
|
||||
void ClipboardImpl::GetSpanStringDataHelper(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback, bool syncMode)
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback, bool syncMode)
|
||||
{
|
||||
auto task = [callback, weakExecutor = WeakClaim(RawPtr(taskExecutor_)), weak = WeakClaim(this)]() {
|
||||
auto clip = weak.Upgrade();
|
||||
@ -598,14 +598,15 @@ void ClipboardImpl::GetSpanStringDataHelper(
|
||||
CHECK_NULL_VOID(getDataRes);
|
||||
std::vector<std::vector<uint8_t>> arrays;
|
||||
std::string text;
|
||||
clip->ProcessSpanStringData(arrays, pasteData, text);
|
||||
bool isMultiTypeRecord = false;
|
||||
clip->ProcessSpanStringData(arrays, pasteData, text, isMultiTypeRecord);
|
||||
auto textData = pasteData.GetPrimaryText();
|
||||
if (textData && text.empty()) {
|
||||
text.append(*textData);
|
||||
}
|
||||
auto result = text;
|
||||
taskExecutor->PostTask(
|
||||
[callback, arrays, result]() mutable { callback(arrays, result); },
|
||||
[callback, arrays, result, isMultiTypeRecord]() mutable { callback(arrays, result, isMultiTypeRecord); },
|
||||
TaskExecutor::TaskType::UI, "ArkUIClipboardGetSpanStringDataCallback");
|
||||
};
|
||||
if (syncMode) {
|
||||
@ -615,8 +616,8 @@ void ClipboardImpl::GetSpanStringDataHelper(
|
||||
}
|
||||
}
|
||||
|
||||
void ClipboardImpl::ProcessSpanStringData(
|
||||
std::vector<std::vector<uint8_t>>& arrays, const OHOS::MiscServices::PasteData& pasteData, std::string& text)
|
||||
void ClipboardImpl::ProcessSpanStringData(std::vector<std::vector<uint8_t>>& arrays,
|
||||
const OHOS::MiscServices::PasteData& pasteData, std::string& text, bool& isMultiTypeRecord)
|
||||
{
|
||||
for (const auto& pasteDataRecord : pasteData.AllRecords()) {
|
||||
if (pasteDataRecord == nullptr) {
|
||||
@ -644,6 +645,7 @@ void ClipboardImpl::ProcessSpanStringData(
|
||||
if (pasteDataRecord->GetPlainText() != nullptr) {
|
||||
auto textData = pasteDataRecord->GetPlainText();
|
||||
text.append(*textData);
|
||||
isMultiTypeRecord = !(*textData).empty() && hasSpanString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ public:
|
||||
void HasDataType(
|
||||
const std::function<void(bool hasData)>& callback, const std::vector<std::string>& mimeTypes) override;
|
||||
void Clear() override;
|
||||
void GetSpanStringData(const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback,
|
||||
void GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback,
|
||||
bool syncMode = false) override;
|
||||
|
||||
#ifdef SYSTEM_CLIPBOARD_SUPPORTED
|
||||
@ -69,10 +70,10 @@ private:
|
||||
void GetPixelMapDataSync(const std::function<void(const RefPtr<PixelMap>&)>& callback);
|
||||
void GetPixelMapDataAsync(const std::function<void(const RefPtr<PixelMap>&)>& callback);
|
||||
void GetSpanStringDataHelper(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback,
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback,
|
||||
bool syncMode = false);
|
||||
void ProcessSpanStringData(
|
||||
std::vector<std::vector<uint8_t>>& arrays, const OHOS::MiscServices::PasteData& pasteData, std::string& text);
|
||||
void ProcessSpanStringData(std::vector<std::vector<uint8_t>>& arrays,
|
||||
const OHOS::MiscServices::PasteData& pasteData, std::string& text, bool& isMultiTypeRecord);
|
||||
const std::string GetMimeType(
|
||||
std::map<std::string, std::shared_ptr<OHOS::MiscServices::EntryValue>> multiTypeDataMap);
|
||||
#endif
|
||||
|
@ -32,7 +32,7 @@ void ClipboardImpl::GetData(const std::function<void(const std::string&, bool is
|
||||
const std::function<void(const std::string&, bool isLastRecord)>& urlCallback, bool syncMode)
|
||||
{}
|
||||
void ClipboardImpl::GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback, bool syncMode)
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback, bool syncMode)
|
||||
{}
|
||||
|
||||
RefPtr<PasteDataMix> ClipboardImpl::CreatePasteDataMix()
|
||||
|
@ -56,7 +56,8 @@ public:
|
||||
void GetData(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 syncMode = false) override;
|
||||
void GetSpanStringData(const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback,
|
||||
void GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback,
|
||||
bool syncMode = false) override;
|
||||
RefPtr<PasteDataMix> CreatePasteDataMix() override;
|
||||
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
virtual RefPtr<PasteDataMix> CreatePasteDataMix() = 0;
|
||||
virtual void Clear() = 0;
|
||||
virtual void GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback,
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback,
|
||||
bool syncMode = false) = 0;
|
||||
|
||||
protected:
|
||||
|
@ -7313,15 +7313,18 @@ void RichEditorPattern::HandleOnPaste()
|
||||
clipboard_->GetData(pasteCallback);
|
||||
#else
|
||||
auto isSpanStringMode = isSpanStringMode_;
|
||||
auto pasteCallback = [weak = WeakClaim(this), isSpanStringMode](std::vector<std::vector<uint8_t>>& arrs, const std::string& text) {
|
||||
TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "pasteCallback callback");
|
||||
auto pasteCallback = [weak = WeakClaim(this), isSpanStringMode](std::vector<std::vector<uint8_t>>& arrs,
|
||||
const std::string& text, bool& isMulitiTypeRecord) {
|
||||
TAG_LOGI(AceLogTag::ACE_RICH_TEXT,
|
||||
"pasteCallback callback, isMulitiTypeRecord : [%{public}d], isSpanStringMode : [%{public}d]",
|
||||
isMulitiTypeRecord, isSpanStringMode);
|
||||
auto richEditor = weak.Upgrade();
|
||||
CHECK_NULL_VOID(richEditor);
|
||||
std::list<RefPtr<SpanString>> spanStrings;
|
||||
for (auto arr : arrs) {
|
||||
spanStrings.push_back(SpanString::DecodeTlv(arr));
|
||||
}
|
||||
if (!spanStrings.empty() && isSpanStringMode) {
|
||||
if (!spanStrings.empty() && !isMulitiTypeRecord) {
|
||||
for (auto spanString : spanStrings) {
|
||||
richEditor->AddSpanByPasteData(spanString);
|
||||
richEditor->RequestKeyboardToEdit();
|
||||
|
@ -87,7 +87,7 @@ void MockClipBoard::GetData(const std::function<void(const std::string&, bool is
|
||||
const std::function<void(const std::string&, bool isLastRecord)>& urlCallback, bool syncMode)
|
||||
{}
|
||||
void MockClipBoard::GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback, bool syncMode)
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback, bool syncMode)
|
||||
{}
|
||||
|
||||
RefPtr<PasteDataMix> MockClipBoard::CreatePasteDataMix()
|
||||
|
@ -45,7 +45,8 @@ public:
|
||||
void GetData(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 syncMode = false) override;
|
||||
void GetSpanStringData(const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback,
|
||||
void GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback,
|
||||
bool syncMode = false) override;
|
||||
RefPtr<PasteDataMix> CreatePasteDataMix() override;
|
||||
|
||||
|
@ -53,7 +53,8 @@ public:
|
||||
const std::function<void(const RefPtr<PixelMap>&, bool isLastRecord)>& pixelMapCallback,
|
||||
const std::function<void(const std::string&, bool isLastRecord)>& urlCallback,
|
||||
bool syncMode = false) override {};
|
||||
void GetSpanStringData(const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback,
|
||||
void GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback,
|
||||
bool syncMode = false) override {};
|
||||
RefPtr<PasteDataMix> CreatePasteDataMix()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user