Bug 53412 - FILEOPEN RTF: Silent fail on RTFD file open attempt
Summary: FILEOPEN RTF: Silent fail on RTFD file open attempt
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.5.2 release
Hardware: Other All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:rtf
Depends on: 154387
Blocks: RTF
  Show dependency treegraph
 
Reported: 2012-08-12 15:21 UTC by Matt Rosin
Modified: 2023-03-25 14:29 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
A simple RTFD sample file (compressed as ZIP archive to allow me to attach it) (24.50 KB, application/zip)
2012-08-19 10:16 UTC, Roman Eisele
Details
RTFD created in Bean with small formatted image (16.44 KB, application/zip)
2012-08-20 04:33 UTC, Matt Rosin
Details
Apple’s RTF Extensions (35.48 KB, application/pdf)
2014-09-01 16:02 UTC, Dennis Roczek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Rosin 2012-08-12 15:21:42 UTC
LibreOffice cannot open RTFD files (RTF With File Attachments).
It silently fails when you try to do so.
I discovered this by making a file with Bean (a nice mac editor).
When you just copy and paste, bullets are not preserved.
By opening the rtfd file in TextEdit (mac standard editor) and saving as rtf, LibreOffice is able to open it.
TextEdit also makes RTFD files, it is needed whenever you paste a photo into a document. Since this is really, really basic operations on a mac, using the fundamental editor that comes with the mac (TextEdit) I think it is a critical bug.
I have tested this also by making a simple rtfd file with TextEdit. Unfortunately Google Chrome refuses to allow me to upload an rtfd file in the Attachment area! Arrgh.
Comment 1 Roman Eisele 2012-08-19 10:16:04 UTC
Created attachment 65764 [details]
A simple RTFD sample file (compressed as ZIP archive to allow me to attach it)

REPRODUCIBLE with LibreOffice 3.6.1.1 (Build ID: 4db6344), German langpack installed, on MacOS X 10.6.8 (Intel).

When you try to open a .rtfd file, LibreOffice shows in in the file selection dialog (suggesting that it is able to open that file!), but if you click "OK" nothing happens.

IMHO we would need an enhancement request for the ability to open .rtfd files (there is no guarantee that LibO can open them, so it is not a bug that it can’t do so ;-); but it is a *bug* that LibreOffice just fails silently on any attempt to open them -- therefore I leave this as bug report.

To find out more about .rtfd files, see
   http://en.wikipedia.org/wiki/RTFD

A .rtfd file ("Rich Text Format Directory") is not a simple file, but a "bundle", i.e. a special kind of directory, which contains both the main RTF data (in a file called "TXT.rtf") and all images, just as image files. Insofar .rtfd files are similar to .odt files, just that they are not compressed and are based on RTF, not on XML.

Matt Rosin is right that .rtfd files are common on MacOS X, and therefore it would be nice if LibreOffice could handle them.

I see three possible stages of .rtfd support:
a) Give a meaninful error message on attempts to open .rtfd files, instead of
   failing silently. This is a really important bug fix.
b) First enhacement level:
   On attempts to open .rtfd files, just open the "TXT.rtf" file inside of
   them, to recover at least the text and formatting.
   This should be rather easy to implement.
c) Second enhancement level:
   Open the "TXT.rtf" file inside of the .rtfd file AND insert all images from
   the .rtfd file directly into the resulting document (embedding images instead
   of linking them).
Comment 2 Roman Eisele 2012-08-19 10:18:19 UTC Comment hidden (obsolete)
Comment 3 Roman Eisele 2012-08-19 10:33:05 UTC
@Thorsten Behrens:
This is an interesting MacOS-related bug report. Please take a look at it.

It could be considered as an enhancement request, but I agree with the original reporter that at least the _silent_ fail on any attempt to open an .rtfd file is a bug and should be fixed; we should either not allow to open .rtfd files at all (disabling them in the file open dialog) or display a meaningful error message. It would be even better, of course, to actually open the .rtfd file, at least the simple "TXT.rtf" file inside of it ...

Please consider:
Maybe we could make the first step (displaying a meaningful error message) into an Easy Hack?

Thank you!
Comment 4 Matt Rosin 2012-08-20 04:31:26 UTC
Thank you very much for your attention to this bug.
I would like to add some notes. i find it very interesting if true, that Windows still is unable to open rtfd! This is a significant opportunity for LibreOffice.

1) Other embedded file types
You can also embed a PDF or other file like a mail attachment in an rtfd on the Mac.
For example you can drag a PDF from the finder into the TextEdit window.
When saved, zipped (via Finder context menu) and then unzipped (with unzip from Terminal unix shell) I found the PDF file to be there next to the rtf file.
A post from 2005: http://arstechnica.com/civis/viewtopic.php?f=19&t=429565

2) Formatting
The graphic in your test rtfd file is very wide so it may not be obvious, but embedded images can be paragraph formatted (centered/right justified) too in TextEdit and Bean. Bean allows formatting and also allows you to doubleclick and resize an image inline (a resizing widget pops up at the cursor position). I note this because (I have not confirmed it but) I have read that while you can open the text.rtf file in WordPad or Word in Windows it does not preserve formatting. A 2008 post: https://discussions.apple.com/thread/1501548?start=0&tstart=0

3) Opportunity for LibreOffice.
The above linked wikipedia article and other posts I have found from early 2000s says Windows cannot handle bundles, hence rtfd is not supported, so the choice is to save as a PDF or zip it and wade through the zipped folder while losing formatting and positional information.
  It would be eminently useful to Windows users if a Mac user could send them an rtfd (or a zipped rtfd) by email and have LibreOffice open it one Windows and offer to save as .odf or .doc. This would make LibreOffice the answer to the question of how to open rtfd on Windows.

4) Attachment.
FWIW I have attached a zip of an rtfd file created in Bean and zipped from the Mac OS X Finder (via the context menu which is the standard way of doing things). Unlike zipping from the unix shell, this creates a zip file that includes Mac specific resources which may be confusing but LibreOffice would have to deal with (ignore) those folders.
Comment 5 Matt Rosin 2012-08-20 04:33:25 UTC
Created attachment 65816 [details]
RTFD created in Bean with small formatted image

FYI it says Voltage in Japanese. ;) --Matt
Comment 6 Mike Kaganski 2012-09-15 04:48:25 UTC
Apple’s RTF Extensions are listed here:

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/AttributedStrings/Tasks/RTFAndAttrStrings.html

Note that MS RTF format allows for custom extensions by design (its specification requires that readers must ignore the unknown control words). MS itself has introduced extensions used in MAPI (Outlook) to store the original mail body. So this extension should be considered conforming, and its support may be trivial (just include processing of those new control words into the import filter; no need to create any new format) taking into account that the referenced files must reside in the same directory as the TXT.rtf is.

I agree with Matt Rosin that this could be a good opportunity for LO.
Comment 7 Thorsten Behrens (allotropia) 2012-10-26 20:35:30 UTC
Miklos, 'interesting' rtf issue - cycles left to have a look?
Comment 8 Miklos Vajna 2012-10-31 16:39:48 UTC
Hmm, can you guys point out an existing application on Windows or Linux that supports (preferable not only can read, but can also create) this format? That would make adding support for this much easier.
Comment 9 Matt Rosin 2012-11-01 05:19:28 UTC
I have not used it, but the answer seems to be textutil(1).

Here is a bsd man page, it is originally a Mac OS X command line tool that can convert between txt, html, rtf, rtfd, doc, docx, wordml, odt, or webarchive

http://www.unix.com/man-page/All/1/TEXTUTIL/
Comment 10 Matt Rosin 2012-11-01 05:31:01 UTC
p.s. I have seen info on the web that RTFD (rich text file directory) bundles are displayed as folders in Windows, but that editing their content destroys it. Someone with windows should confirm does the OS even allow you to have a flat rtfd file? Else would have to always be zipped..
Comment 11 Dennis Roczek 2012-12-18 20:56:16 UTC
(In reply to comment #10)
> p.s. I have seen info on the web that RTFD (rich text file directory)
> bundles are displayed as folders in Windows, but that editing their content
> destroys it. Someone with windows should confirm does the OS even allow you
> to have a flat rtfd file? Else would have to always be zipped..


Indeed I can confirm that Windows 7 64bit is able to open the folder, the images which are included in the rtfd and moreover to open the rtf file. The images aren't included in the rtf.

An private example created by a Mac Book 10.6 contains following line:

\cf3 {{\NeXTGraphic sabine_seite1 001.jpg \width12240 \height16833
}¬}}

which results in  LO 3.6.4.3 in:
sabine_seite1 001.jpg ¬
as text and not as the file which is within the rtfd file (in the folder).

Actually saving and editing results in:

\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af9\langfe2052\dbch\af7\afs24\alang1081\loch\f0\fs24\lang1031\ql{\cf1\b0\rtlch \ltrch\fs32\loch\f5
\~}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af9\langfe2052\dbch\af7\afs24\alang1081\loch\f0\fs24\lang1031\ql{\cf1\b0\rtlch \ltrch\loch\fs24\loch\f5
sabine_seite2 001.jpg \u172\'ac}{{\*\bkmkstart __DdeLink__13_1092900117}\cf1\b0\rtlch \ltrch\loch\fs24\loch\f5{\*\bkmkend __DdeLink__13_1092900117}
sabine_seite1 001.jpg \u172\'ac}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af9\langfe2052\dbch\af7\afs24\alang1081\loch\f0\fs24\lang1031\ql\rtlch \ltrch\loch

So yes, reading the file isn't really a problem. (I will check 4.0beta later)
Comment 12 Miklos Vajna 2013-08-18 15:28:31 UTC
No mac here, reset back assignee to the default.
Comment 13 Mike Kaganski 2013-08-19 01:16:53 UTC
As far as I can tell, here are a number of issues:

1. LO behaves incorrectly on Mac: it doesn't show a warning when user tries to open an RTFD bundle. This may be solved in two ways: one is to emit a message (and not open the bundle), another is to "teach" LO how to open it. Anyway, a Mac developer is needed to do it, at minimum because this task requires correct operation with Mac "Bundles" API (http://en.wikipedia.org/wiki/Bundle_(Mac_OS_X)).

2. LO is unable to handle the Apple's extensions to RTF syntax (the documentation link is in comment 6). This issue is essential to fix the first issue by "teaching", and also enables reading this format in other OSes, thus essential to consistent operation between platforms.

I suppose that the problem #2 could be solved first, with the help of affected users providing reference RTFDs and corresponding PDFs, so that a developer without a Mac could use the PDFs as the reference.

As a side note, there is a GNUStep project that includes the TextEdit app, and it may be installed under a Linux (though personally I didn't text it). This app is the "originator" of the format, and the GNUStep does support "bundles", so maybe this environment could assist a developer with this issue.
Comment 14 Dennis Roczek 2014-09-01 16:02:05 UTC
Created attachment 105567 [details]
Apple’s RTF Extensions

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/AttributedStrings/Tasks/RTFAndAttrStrings.html printed as PDF. Apples documentation pages "sometimes" went into nirvana (search for their spec about iWork's Pages 2005) and thus saving them for reference
Comment 15 QA Administrators 2015-12-20 16:12:02 UTC Comment hidden (obsolete)
Comment 16 Dennis Roczek 2015-12-20 16:53:23 UTC
no change with 
Version: 5.0.4.1 (x64)
Build-ID: 2def61bcbb29a7a8611b833682fe1291910b11ad
Gebietsschema: de-DE (de_DE)