R9.3, R9.4: AutoFilter without the header query (GitHub #4); paste on Windows
Patch 0053: under LOK, Calc takes the first row as header instead of asking asynchronously; the worker closed the query and crashed. Patch 0049 includes doc.hxx (gcc on Linux did not build it). arboard read a missing HTML clipboard format as an error on Windows; the clipboard checks the format first, and paste errors show the whole chain. ElyTable tests compare CSV and selection text the platform's way (P3-09).
This commit is contained in:
19 files changed
+118
-20
No files matched your search
@@ -152,3 +152,30 @@ fn one_cell_in_another_block_filters_that_block() {
|
||||
let entries: Vec<String> = sheet::filter_values(&json).expect("parses").entries.into_iter().map(|e| e.text).collect();
|
||||
assert_eq!(entries, ["9", "10"], "an AutoFilter from D1 is D's");
|
||||
}
|
||||
|
||||
/// A text-only column: no cell looks like a header.
|
||||
const WORDS: &str = r#"<?xml version="1.0" encoding="UTF-8"?>
|
||||
<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.spreadsheet">
|
||||
<office:body><office:spreadsheet><table:table table:name="S">
|
||||
<table:table-row><table:table-cell><text:p>Name</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row><table:table-cell><text:p>a</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row><table:table-cell><text:p>b</text:p></table:table-cell></table:table-row>
|
||||
</table:table></office:spreadsheet></office:body>
|
||||
</office:document>"#;
|
||||
|
||||
#[test]
|
||||
fn a_whole_column_without_a_clear_header_filters_from_its_first_row() {
|
||||
if install().is_none() {
|
||||
eprintln!("SKIP: no pinned LOK build");
|
||||
return;
|
||||
}
|
||||
let (_dir, mut worker, doc) = open_book(WORDS);
|
||||
worker.run(&doc, "cell.goto", &["A:A"]).expect("marks the column");
|
||||
worker.run(&doc, "data.autofilter", &[]).expect("filters without asking");
|
||||
doc.paint_tile(&mut worker, (0, 0, 3840, 3840), (256, 256))
|
||||
.expect("the buttons paint");
|
||||
// The whole column holds blanks too.
|
||||
assert_eq!(entries(&mut worker, &doc), ["", "a", "b"], "the first row heads");
|
||||
}
|
||||
@@ -82,7 +82,7 @@ pub(super) fn mark_of(html: &str) -> Option<&str> {
|
||||
|
||||
/// Pastes the system clipboard.
|
||||
pub(super) fn paste(worker: &mut Worker, doc: &Doc) -> io::Result<()> {
|
||||
let Some(clip) = clipboard::read().map_err(io::Error::other)? else {
|
||||
let Some(clip) = clipboard::read().map_err(|error| io::Error::other(format!("{error:#}")))? else {
|
||||
return Ok(());
|
||||
};
|
||||
let (mime, data) = flavor_of(clip);
|
||||
|
||||
@@ -247,6 +247,12 @@ fn the_clipboard_moves_html_tables_and_images() {
|
||||
text.contains(&"left".to_string()) && text.contains(&"right".to_string()),
|
||||
"{text:?}"
|
||||
);
|
||||
// Plain text from another app, with no HTML beside it.
|
||||
clipboard::write(&Clip::Text("outside words".into())).expect("the text writes");
|
||||
cx.update(|app| view.update(app, |view, _| view.send(crate::view::input::Input::Paste)));
|
||||
flush(&cx);
|
||||
let text = saved(&view, &mut cx);
|
||||
assert!(text.iter().any(|line| line.contains("outside words")), "{text:?}");
|
||||
|
||||
let mut png = Vec::new();
|
||||
image::RgbaImage::from_pixel(4, 4, image::Rgba([255, 0, 0, 255]))
|
||||
|
||||
@@ -38,6 +38,7 @@ objc2.workspace = true
|
||||
security-framework.workspace = true
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
clipboard-win = "5.4"
|
||||
windows-sys.workspace = true
|
||||
windows.workspace = true
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ pub fn write(clip: &Clip) -> Result<()> {
|
||||
pub fn read() -> Result<Option<Clip>> {
|
||||
with_board(|board| {
|
||||
let text = absent_ok(board.get_text())?;
|
||||
if let Some(html) = absent_ok(board.get().html())? {
|
||||
if let Some(html) = html_of(board)? {
|
||||
let text = text.unwrap_or_default();
|
||||
return Ok(Some(Clip::Html { html, text }));
|
||||
}
|
||||
@@ -76,7 +76,20 @@ pub fn read() -> Result<Option<Clip>> {
|
||||
|
||||
/// The clipboard's HTML, if any; gpui's reads omit it.
|
||||
pub fn html() -> Result<Option<String>> {
|
||||
with_board(|board| absent_ok(board.get().html()))
|
||||
with_board(html_of)
|
||||
}
|
||||
|
||||
fn html_of(board: &mut Clipboard) -> Result<Option<String>> {
|
||||
// arboard reads absent HTML on Windows as an error.
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let format = clipboard_win::register_format("HTML Format")
|
||||
.context("the HTML clipboard format registers")?;
|
||||
if !clipboard_win::is_format_avail(format.get()) {
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
absent_ok(board.get().html())
|
||||
}
|
||||
|
||||
/// Empty or other-format clipboards read as None.
|
||||
@@ -110,6 +123,7 @@ mod tests {
|
||||
let text = Clip::Text("plain 中文".into());
|
||||
write(&text).expect("text writes");
|
||||
assert_eq!(read().expect("text reads"), Some(text));
|
||||
assert_eq!(html().expect("no html reads"), None);
|
||||
let html = Clip::Html {
|
||||
html: "<table><tr><td>a</td></tr></table>".into(),
|
||||
text: "a".into(),
|
||||
|
||||
Reference in new issue
Block a user