summaryrefslogtreecommitdiff
path: root/vcl/source/treelist
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2024-06-27 11:11:13 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2024-07-09 07:50:31 +0200
commitfcad7309358bc66dd37f37b64d30be841bd61832 (patch)
treef2862c58c1d2771db7ddb0ca67759e1c4a406b5b /vcl/source/treelist
parent2e25618fe7370e9f378da0b03bca8fac471f01f3 (diff)
jsdialog: support on demand rendering for icon view
- rename action: rendered_combobox_entry -> rendered_entry - change generic get json property callback to more specialized image getter as it wasn't used anywhere apart of that and we need image enceded as base64 only not JSON - add to the full update of icon view "ondemand" property to the entries with images so LOK client will know it has to download the render - it will be possible to support HiDPI renders in the future: added TODO Signed-off-by: Szymon Kłos <szymon.klos@collabora.com> Change-Id: I83a6e91133f8f9cb03e0bc794b51e1947435fa90 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169622 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170160 Tested-by: Jenkins
Diffstat (limited to 'vcl/source/treelist')
-rw-r--r--vcl/source/treelist/iconview.cxx40
1 files changed, 29 insertions, 11 deletions
diff --git a/vcl/source/treelist/iconview.cxx b/vcl/source/treelist/iconview.cxx
index cc3ac778f8a7..da222bc27f0b 100644
--- a/vcl/source/treelist/iconview.cxx
+++ b/vcl/source/treelist/iconview.cxx
@@ -278,6 +278,30 @@ static OString extractPngString(const SvLBoxContextBmp* pBmpItem)
return ""_ostr;
}
+OUString IconView::renderEntry(int pos, int /*dpix*/, int /*dpiy*/) const
+{
+ // TODO: support various DPI
+ SvTreeListEntry* pEntry = GetEntry(pos);
+ if (!pEntry)
+ return "";
+
+ OUString sResult;
+ const bool bHandled
+ = maDumpImageHdl.IsSet() && maDumpImageHdl.Call(encoded_image_query(sResult, pEntry));
+
+ if (!bHandled)
+ {
+ if (const SvLBoxItem* pIt = pEntry->GetFirstItem(SvLBoxItemType::ContextBmp))
+ {
+ const SvLBoxContextBmp* pBmpItem = static_cast<const SvLBoxContextBmp*>(pIt);
+ if (pBmpItem)
+ return OStringToOUString(extractPngString(pBmpItem), RTL_TEXTENCODING_ASCII_US);
+ }
+ }
+
+ return sResult;
+}
+
void IconView::DumpEntryAndSiblings(tools::JsonWriter& rJsonWriter, SvTreeListEntry* pEntry)
{
while (pEntry)
@@ -289,18 +313,12 @@ void IconView::DumpEntryAndSiblings(tools::JsonWriter& rJsonWriter, SvTreeListEn
if (pIt)
rJsonWriter.put("text", static_cast<const SvLBoxString*>(pIt)->GetText());
- const bool bHandled
- = maDumpElemToPropertyTreeHdl.IsSet()
- && maDumpElemToPropertyTreeHdl.Call(json_prop_query(rJsonWriter, pEntry, "image"));
- if (!bHandled)
+ pIt = pEntry->GetFirstItem(SvLBoxItemType::ContextBmp);
+ if (pIt)
{
- pIt = pEntry->GetFirstItem(SvLBoxItemType::ContextBmp);
- if (pIt)
- {
- const SvLBoxContextBmp* pBmpItem = static_cast<const SvLBoxContextBmp*>(pIt);
- if (pBmpItem)
- rJsonWriter.put("image", extractPngString(pBmpItem));
- }
+ const SvLBoxContextBmp* pBmpItem = static_cast<const SvLBoxContextBmp*>(pIt);
+ if (pBmpItem)
+ rJsonWriter.put("ondemand", true);
}
if (const OUString tooltip = GetEntryTooltip(pEntry); !tooltip.isEmpty())