ElyTable: a new chart lands beside its data (R2.10)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 04:02:32 -04:00
1 parent efe5d4fc5d
commit b591aa8625
3 files changed
+48

No files matched your search

+1
View File
@@ -266,3 +266,4 @@ cargo run -p ely-doc 启动一个应用(ElyDoc 先 cargo build -p ely
- 2026-10-09:ElyTable 的自动筛选(R2.9)。内核会重新推算未命名的自动筛选区:每次打开筛选列表时向下扩到紧邻的数据行(`ExtendDataArea`、`ExtendBackColorArea`,为接上后来追加的行),命令从单格找到它时按连续数据区重算(`ScDocShell::GetDBData`:应用条件、关闭筛选及其撤销);选区下方紧邻的合计行因此进了列表、随数据一起被隐藏,存后重开的筛选区同样会扩。补丁 `0040-lok-calc-autofilter-keeps-its-rows.patch`:LOK 下已有的自动筛选区保持设定时的行(同 Excel),不再隐式扩展(光标在区内时;光标在同表另一块数据里即按那一块);单格开筛选时仍取整个数据区。代价:紧贴在筛选区下方追加的行不自动并入,需重新选定后再开筛选。
- 2026-10-09:ElyTree 的差异按文件类型着色(R2.12)。组件库 7f2ac3e:`DiffViewer` 按路径的扩展名判定散文与纯文本(md、markdown、txt、rst、adoc、org、csv、tsv、log 等,无扩展名同),这些文件不按代码着色(原先一律套通用的代码词法,Markdown 的 `#`、引号等被当作代码上色)。同批带入上游的块编辑器跨块选择、浮层滚轮、输入法候选框位置、插入点按设备像素对齐与格式修正。
- 2026-10-09:ElyMark 的表格(R2.13)。表格的空格与分隔行写法有许多种(`|a|b|`、`|---|`、对齐空格),逐字重现做不到,原先凡写不回原样的表格都成了原文块。现在表格按单元格比较:把原文这一段单独解析,与编辑器里的表格节点相同即为可视块(`preserve.js` 的 `kept`);未改的表格照旧逐字写回,改过的表格按文档多数表格的写法重写(`style.js` 投票:单元格两侧有无空格、是否按列对齐,经 remark-gfm 的 `tableCellPadding` 与 `tablePipeAlign`;原先投票的解析器不认 GFM,表格从未计票)。改过的表格分隔行按此写法重写(如 `|---|` 成 `| - |`)。
- 2026-10-09:ElyTable 新插图表的位置(R2.10)。内核按“定位区域”把图表放在其旁的空处;带参数的请求(Ely 经 `FN_PARAM_5` 给区域)原把定位区域取为光标格,图表紧贴光标、压在数据上。补丁 `0041-lok-calc-chart-beside-its-data.patch`:定位区域取请求里的数据区域(多段取并集),同对话框路径取所选单元格。
@@ -3,6 +3,8 @@ use super::sheet::open_book;
use super::*;
use crate::sheet::{self, Layout, Look};
const SETTLE: std::time::Duration = std::time::Duration::from_secs(3);
/// Region, Year, Sales; four rows.
fn data() -> String {
let rows: String = [
@@ -331,3 +333,21 @@ fn undoing_a_new_kind_brings_the_whole_chart_back() {
"the stacking came back"
);
}
#[test]
fn a_new_chart_lands_beside_its_data() {
if skip() {
return;
}
let (_dir, mut worker, doc) = open_book(&data());
let all = written(&mut worker, &doc, "A1:C5");
let base = poll_until(&mut worker, &doc, &Events::default(), SETTLE, |_| false);
worker.run(&doc, "cell.goto", &["C5"]).expect("C5");
let corner = poll_until(&mut worker, &doc, &base, SETTLE, |seen| seen.cell.cursor.is_some() && seen.cell.cursor != base.cell.cursor);
let (x, y, w, h) = corner.cell.cursor.expect("the last data cell");
worker.run(&doc, "cell.goto", &["A1"]).expect("A1");
worker.run(&doc, "chart.insert", &[&all, "false", &Look { kind: "column".into(), ..Look::default() }.to_json()]).expect("inserts");
let framed = poll_until(&mut worker, &doc, &corner, SETTLE, |seen| seen.graphic.is_some());
let (left, top, _, _) = framed.graphic.expect("the chart is selected");
assert!(left >= x + w || top >= y + h, "the chart at {left},{top} covers data ending {},{}", x + w, y + h);
}
@@ -0,0 +1,27 @@
LOK Calc: a new chart lands beside its data
FuInsertChart positions a chart away from aPositionRange. With request
arguments (a kit client gives the range in FN_PARAM_5) that range was
the cursor cell alone, so the chart went right next to the cursor and
over the data it charts. Position it from the requested data range,
as the dialog path does with the marked cells.
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index b0169d0..0a4e3dc 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -452,6 +452,14 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
aRangeString = static_cast<const SfxStringItem*>(pItem)->GetValue();
aPositionRange = rViewSh.GetViewData().GetCurPos();
+ // The chart goes beside its data, not over it.
+ if (pRange)
+ {
+ const ScRangeList aData = *sctools::chartRanges(rViewSh.GetViewData().GetDocument(), pRange->GetValue());
+ aPositionRange = aData[0];
+ for (size_t i = 1; i < aData.size(); ++i)
+ aPositionRange.ExtendTo(aData[i]);
+ }
}
else
{