[File] [PATCH] of Magdir/wordprocessors for Star-, Open-, Libre-Office Gallery *.thm

Jörg Jenderek joerg.jen.der.ek at gmx.net
Fri Oct 25 13:28:13 UTC 2019


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,
some days ago i run file command inside LibreOffice directories. In
sub directory gallery there files of Office Galleries are stored.

Apparently a gallery consist of some files. For every gallery beside
the SDG file there seems to exist files with same main name but with
extension sdv, thm and sometimes str. I will handle here only
THM files and the other files in a future session.

The samples with file name extension thm are described by file command
version 5.37 only as data.

The same gallery format is already used in old StarOffice 5.2 dated
about May 2000. And the format is still used in actual LibreOffice
with version 6.3.2.2. The gallery is also used in OpenOffice.

So i add comment line to Magdir/wordprocessors like
# URL:		https://en.wikipedia.org/wiki/StarOffice

Unfortunately i find no file format specification for such THM parts.
So i rely on my own observations.

All THM examples start with the same 2 byte sequence. This is used as
first test by line
 0		ubeshort	0x0400

Afterwards the name of Gallery theme is stored as Pascal string. This
information is later shown by line
 >>2		pstring/h	x		%s

Unfortunately the  first test is not unique enough. This matches also
bad example file2147.chk. There bytes 3 and 4 are null. Lowest found
value was 2 for sg16.thm with name "3D". So skip this bad example by
looking for positive theme name length by magic line
 >2		uleshort	>0	StarOffice Gallery theme

Some sites on the net call the THM samples like "OpenOffice.org
configuration", but such files are already used in predecessor
software StarOffice. Furthermore the THM files only occur in the
context of a Gallery and contain the theme name of the gallery.
Therefore i choose describing text "StarOffice Gallery theme".
This also a reasonable for abbreviation thm for theme. This
abbreviation is used as file name extension, which is shown by magic
line
 !:ext		thm
Using other StarOffice mime types mentioned on OpenOffice site as
guide line i choose a user defined mime type by line
 !:mime		application/x-stargallery-thm

These 2 magic tests are sufficient for my examples, but i try to look
for more possible tests. In all THM samples the ASCII keyword GALRESRV
appears near the end. So this can be used by line like
 >>0		search/8415	GALRESRV
This matches big THM example
"C:\Program Files (x86)\StarOffice6.0\share\gallery\sg27.thm"
But if i create a bigger gallery with "neues thema6.thm" the above
test does not fit, so i must raise search limit and the magic test now
becomes like
 >>0		search/19299	GALRESRV
Furthermore a high search range is a performance killer. So i do not
use this as additional test.

After the theme names some bytes are stored. For many of them i do not
know what this mean. But one byte in my inspected samples was always
null. So maybe this can be used as additional line like
 >>(2.s+9)	ubyte		0
But for me this seems to be a lucky event. So i do not use this as
additional test.

After the theme name the number of gallery objects is stored. A
Gallery can be empty. In this case it contains 0 objects. This is
displayed by lines
 >>(2.s+4)	ulelong		x		\b, %u object
 >>(2.s+4)	ulelong		!1		\bs

Three bytes behind the object number the name of the first object
name is stored as Pascal string. This can be an "internal" name like
d2194, an URL like file:///P:/Pictures/1999_1024_23_Tikal.jpg, a
partial file name like /sounds/apert2.wav or RESRV for empty
galleries. So i display first object name for non empty gallery by lin
es
 >>(2.s+4)	ulelong		>0
 >>>(2.s+11)	pstring/h	x		\b, 1st %s

After applying the above mentioned modifications by patch
file-5.37-wordprocessors-thm.diff then i get a describing output like

file2147.chk:     data
neues thema6.thm: StarOffice Gallery theme
      		  MorePictures,
		  315 objects,
		  1st file:///C:/Users/user1/Pictures/
		  1999_1024_23_Tikal.jpg
neues thema7.thm: StarOffice Gallery theme
      		  LongGalleryName___________________________
		  0 objects
sg16.thm:         StarOffice Gallery theme
		  3D,
		  12 objects,
		  1st dd2066
sg25.thm:         StarOffice Gallery theme
		  private://gallery/hidden/HtmlExportButtons,
		  49 objects,
		  1st /htmlexpo/sologo.gif
sg27.thm:         StarOffice Gallery theme
		  Navigation,
		  238 objects,
		  1st /navi%2D2d/wh%5Fup.gif
sg33.thm:         StarOffice Gallery theme
		  Probleml\303\266sungen,
		  72 objects,
		  1st /troubleshooting/question-mark_blue.wmf
sounds.thm:       StarOffice Gallery theme
		  sounds,
		  35 objects,
		  1st /sounds/apert2.wav

I hope my diff file can be applied in future version of
file utility.

With best wishes
Jörg Jenderek
- --
Jörg Jenderek
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCXbL4VgAKCRCv8rHJQhrU
1vMAAJsF9RS0Wo142mAHCor3T0XP+G/KmQCeLlIe04vOT0lw9JNyoDtn954yzYY=
=Tubs
-----END PGP SIGNATURE-----
-------------- next part --------------
--- file-5.37/magic/Magdir/wordprocessors.old	2019-04-19 00:42:27 +0000
+++ file-5.37/magic/Magdir/wordprocessors	2019-10-25 13:15:34 +0000
@@ -261,2 +261,32 @@
 # markups page=0x04,label=0x12, followed by strings like "opt" or "main" and title=0x14
 0	ulelong&0x8080FFFF	0x00001204	gfxboot compiled html help file
+
+# From:		Joerg Jenderek
+# URL:		https://en.wikipedia.org/wiki/StarOffice
+# Note:		used in Star-, Open- and Libre-Office
+# named as soffice.StarConfigFile.6 or OpenOffice.org configuration by others
+0		ubeshort	0x0400
+#>(2.s+8)	ubequad		x		\b, gap 0x%16.16llx
+# test for null value in gap after theme name maybe unreliable
+#>(2.s+9)	ubyte		0		\b, 0-byte
+# look for keyword GALRESRV near the end
+# "C:\Program Files (x86)\StarOffice6.0\share\gallery\sg27.thm" Navigation, 238 objects
+#>0		search/8415	GALRESRV	\b, GALRESRV found
+# "neues thema6.thm" MorePictures, 315 objects
+#>0		search/19299	GALRESRV	\b, GALRESRV FOUND
+#>2		uleshort	x		\b, name length %u
+# skip file2147.chk by check for positive name length like for sg16.thm "3D"
+>2		uleshort	>0		StarOffice Gallery theme
+!:mime		application/x-stargallery-thm
+!:ext		thm
+# gallery name
+>>2		pstring/h	x		%s
+# number of objects
+>>(2.s+4)	ulelong		x		\b, %u object
+# plural s
+>>(2.s+4)	ulelong		!1		\bs
+# if available then display first object name 
+>>(2.s+4)	ulelong		>0
+# partial file name, URL or internal name like "dd2*" of 1st object or RESRV
+>>>(2.s+11)	pstring/h	x		\b, 1st %s
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.37-wordprocessors-thm.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20191025/f1673168/attachment.obj>


More information about the File mailing list