mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-12 08:52:32 +00:00
* Add craft-sheet: the cell positions, values and tables the spreadsheet formats share craft-xls carried its own CellRef, Range, Value, CellError, Visibility, sheet-name quoting, built-in number format table and indexed palette. craft-xlsx and craft-ods need the same ones, so they move to a crate with no dependencies and craft-xls re-exports them: an application gets one Value and one CellRef whichever file it read. Added on the way: A1 parsing (CellRef::parse, Range::parse), Range::count and a1, CellError::parse and the newer error values SpreadsheetML stores as text, builtin_format_id for writers. * craft-xls: read data validation (DVal and Dv records) Each Dv after a DVal becomes a DataValidation in SpreadsheetML's terms: type, operator, formulas as A1 text from the top left cell of all the rule's ranges (a literal list quoted, items separated by commas), the four messages, alert style and flags. Exactly the DVal's count of rules is read, as Excel does; a rule Excel would refuse is skipped with a warning, and the rest are kept. A sheet keeps at most 65,536 rules (the count was not capped on its own). Ported from storytold/gridcraft#3636. * craft-xls: read comments, conditional formats, pictures and the AutoFilter range - Notes with their TxO text, author and visibility. - CondFmt and CF records (cell value is, formula is), formulas from the bounding range's top left cell, and the DXFN as a DifferentialFormat whose unset parts are None. - The drawing group's BLIP store (PNG, JPEG, EMF, WMF with its placeable header, DIB as BMP) and each sheet's picture shapes with their client anchors. - The AutoFilter range from AutoFilterInfo and _FilterDatabase. From the review of the source PR: picture bytes are shared by the shapes that show them, pictures, comments and rules are capped per sheet, inflated metafiles share one allowance, damaged object and CF records are skipped with a warning instead of failing the read, and CF formulas are relative to the CondFmt's bounding range. ValidationOperator is now Operator, shared with conditional formats. Ported from storytold/gridcraft#3457. * craft-xls: read workbooks encrypted with RC4, with their password A FilePass record with RC4 (version 1.1) is checked against the password through its MD5 verifier, and the record data after it is decrypted, rekeyed every 1024 bytes of the stream; record headers and the few records Excel leaves in the clear are kept. read_with_password takes the password. Without one, Excel's default password (VelvetSweatshop) is tried, as Excel opens a workbook protected only against changes, and Error::Encrypted says a password is needed. XOR obfuscation and RC4 CryptoAPI are Error::UnsupportedEncryption; a wrong password is Error::WrongPassword. Ported from storytold/gridcraft#847. * craft-xls: read workbooks encrypted with RC4 CryptoAPI What current Excel writes for an .xls saved with a password (FilePass version 2.2, 3.2 or 4.2): H0 = SHA-1(salt, UTF-16LE password), each 1024-byte block keyed by SHA-1(H0, block number) cut to the key size, a 40-bit key padded with zeros to 128 bits, and the password checked against the verifier's SHA-1. Every size in the FilePass record is checked before use; CryptoAPI with AES, another cipher or hash, an external provider or a key outside 40 to 128 bits is named as unsupported. Ported from storytold/gridcraft#3713. --------- Co-authored-by: kiwi4boy <kiwi4boy@gmail.com> Co-authored-by: BrianDo35 <haison.db35@icloud.com> Co-authored-by: Fabio Lussi <198260595+itrycodinganditsbad@users.noreply.github.com> Co-authored-by: giuseppeps <giuseppe_000@hotmail.com>