Skip to content

Commit

Permalink
Add SHW file formats support
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalecot committed Jan 22, 2024
1 parent 8be51a9 commit c44efd8
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,16 @@ identification.

### Presentation

- Corel Presentations (SHW)
- Corel Presentations 7 (SHW)
- Microsoft PowerPoint Presentation (PPT)
- Office Open XML Presentation (PPTX)
- OpenDocument Presentation (ODP)
- OpenDocument Presentation Template (OTP)
- StarImpress (SDD)
- Sun XML Impress (SXI)
- Sun XML Impress Template (STI)
- WordPerfect Presentations (SHW)

### ROM

Expand Down
Binary file added fixtures/presentation/sample1.shw
Binary file not shown.
Binary file added fixtures/presentation/sample2.shw
Binary file not shown.
Binary file added fixtures/presentation/sample3.shw
Binary file not shown.
21 changes: 21 additions & 0 deletions src/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,20 @@ formats! {
extension = "cfb"
kind = Other

format = CorelPresentations
name = "Corel Presentations"
short_name = "SHW"
media_type = "application/x-corelpresentations"
extension = "shw"
kind = Presentation

format = CorelPresentations7
name = "Corel Presentations 7"
short_name = "SHW"
media_type = "application/x-corelpresentations"
extension = "shw"
kind = Presentation

format = Cpio
name = "cpio"
media_type = "application/x-cpio"
Expand Down Expand Up @@ -2858,6 +2872,13 @@ formats! {
extension = "wpm"
kind = Other

format = WordperfectPresentations
name = "WordPerfect Presentations"
short_name = "SHW"
media_type = "application/vnd.wordperfect"
extension = "shw"
kind = Presentation

format = XPixmap
name = "X PixMap"
short_name = "XPM"
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ identification.
* [Autodesk Inventor Drawing (IDW)](`FileFormat::AutodeskInventorDrawing`)
* [Autodesk Inventor Part (IPT)](`FileFormat::AutodeskInventorPart`)
* [Autodesk Inventor Presentation (IPN)](`FileFormat::AutodeskInventorPresentation`)
* [Corel Presentations 7 (SHW)](`FileFormat::CorelPresentations7`)
* [Microsoft Excel Spreadsheet (XLS)](`FileFormat::MicrosoftExcelSpreadsheet`)
* [Microsoft PowerPoint Presentation (PPT)](`FileFormat::MicrosoftPowerpointPresentation`)
* [Microsoft Project Plan (MPP)](`FileFormat::MicrosoftProjectPlan`)
Expand Down
1 change: 1 addition & 0 deletions src/readers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ impl crate::FileFormat {
"bbf9fdf1-52dc-11d0-8c04-0800090be8ec" => Self::AutodeskInventorDrawing,
"4d29b490-49b2-11d0-93c3-7e0706000000" => Self::AutodeskInventorPart,
"76283a80-50dd-11d3-a7e3-00c04f79d7bc" => Self::AutodeskInventorPresentation,
"402efe62-1999-101b-99ae-04021c007002" => Self::CorelPresentations7,
"00020810-0000-0000-c000-000000000046" => Self::MicrosoftExcelSpreadsheet,
"00020820-0000-0000-c000-000000000046" => Self::MicrosoftExcelSpreadsheet,
"00044851-0000-0000-c000-000000000046" => Self::MicrosoftPowerpointPresentation,
Expand Down
7 changes: 7 additions & 0 deletions src/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,10 @@ signatures! {
format = Bzip3
value = b"BZ3v1"

format = CorelPresentations
value = b"\xFFWPC", b"\x0F" offset = 9
value = b"\xFFWPC", b"\x10" offset = 9

format = EmbeddedOpentype
value = b"\x00\x00\x01" offset = 8, b"LP" offset = 34
value = b"\x01\x00\x02" offset = 8, b"LP" offset = 34
Expand Down Expand Up @@ -972,6 +976,9 @@ signatures! {
value = b"KDMV\x02"
value = b"KDMV\x03"

format = WordperfectPresentations
value = b"\xFFWPC", b"\x0A" offset = 9

// 4 bytes
format = AdaptableScalableTextureCompression
value = b"\x13\xAB\xA1\x5C"
Expand Down
20 changes: 19 additions & 1 deletion tests/presentation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
#[cfg(any(feature = "reader-cfb", feature = "reader-zip"))]
use file_format::FileFormat;

#[test]
fn test_corel_presentations() {
let fmt = FileFormat::from_file("fixtures/presentation/sample1.shw").unwrap();
assert_eq!(fmt, FileFormat::CorelPresentations);
}

#[cfg(feature = "reader-cfb")]
#[test]
fn test_corel_presentations7() {
let fmt = FileFormat::from_file("fixtures/presentation/sample2.shw").unwrap();
assert_eq!(fmt, FileFormat::CorelPresentations7);
}

#[cfg(feature = "reader-cfb")]
#[test]
fn test_microsoft_powerpoint_presentation() {
Expand Down Expand Up @@ -49,3 +61,9 @@ fn test_sun_xml_impress_template() {
let fmt = FileFormat::from_file("fixtures/presentation/sample.sti").unwrap();
assert_eq!(fmt, FileFormat::SunXmlImpressTemplate);
}

#[test]
fn test_wordperfect_presentations() {
let fmt = FileFormat::from_file("fixtures/presentation/sample3.shw").unwrap();
assert_eq!(fmt, FileFormat::WordperfectPresentations);
}

0 comments on commit c44efd8

Please sign in to comment.