Bug 155371 - RTF Import: Error message should give more information
Summary: RTF Import: Error message should give more information
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.6.0.0 alpha1+
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: RTF
  Show dependency treegraph
 
Reported: 2023-05-17 13:52 UTC by Karl-Heinz Zimmer
Modified: 2023-06-05 07:34 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
This file shows the bug. (In the file a } is missing.} (173 bytes, application/rtf)
2023-05-30 07:08 UTC, Karl-Heinz Zimmer
Details
This file is NOT damaged, it has the '}' that is missing in bad_file.rtf. (160 bytes, application/rtf)
2023-05-30 07:09 UTC, Karl-Heinz Zimmer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Karl-Heinz Zimmer 2023-05-17 13:52:27 UTC
When trying to import an RTF file into Writer I run into an error, that was caused by me weak file:

The balance of { } pairs was wrong.
The importer detected this when reaching the very-last line of the file.

The error dialog told me, there is an error in the file format, and it told me the code line and source filename where the error was detected.


Bug: The dialog did _not_ tell me the reason was an unmatched {.


I am filing this (minor) issue since it might be easy to fix: The respective code knows about the reason:

Source file: rtfdocumentimpl.cxx


void RTFDocumentImpl::resolve(Stream& rMapper)
[…]
        case RTFError::OK:
            SAL_INFO("writerfilter.rtf", "RTFDocumentImpl::resolve: finished without errors");
            break;
        case RTFError::GROUP_UNDER:
            SAL_INFO("writerfilter.rtf", "RTFDocumentImpl::resolve: unmatched '}'");
            break;
        case RTFError::GROUP_OVER:
            SAL_INFO("writerfilter.rtf", "RTFDocumentImpl::resolve: unmatched '{'");
            throw io::WrongFormatException(m_pTokenizer->getPosition());
            break;
        case RTFError::UNEXPECTED_EOF:
            SAL_INFO("writerfilter.rtf", "RTFDocumentImpl::resolve: unexpected end of file");
            throw io::WrongFormatException(m_pTokenizer->getPosition());
            break;
        case RTFError::HEX_INVALID:
            SAL_INFO("writerfilter.rtf", "RTFDocumentImpl::resolve: invalid hex char");
            throw io::WrongFormatException(m_pTokenizer->getPosition());
            break;
        case RTFError::CHAR_OVER:
            SAL_INFO("writerfilter.rtf", "RTFDocumentImpl::resolve: characters after last '}'");
            break;
        case RTFError::CLASSIFICATION:
            SAL_INFO("writerfilter.rtf",
                     "RTFDocumentImpl::resolve: classification prevented paste");
            break;
Comment 1 Dieter 2023-05-28 16:46:36 UTC
Karl-Heinz, thank you for reporting the bug. Could you please attach the rtf-file, that causes the bug? Thank you.
=> NEEDINFO
Comment 2 Karl-Heinz Zimmer 2023-05-30 07:08:16 UTC
Created attachment 187599 [details]
This file shows the bug. (In the file a } is missing.}
Comment 3 Karl-Heinz Zimmer 2023-05-30 07:09:04 UTC
Created attachment 187600 [details]
This file is NOT damaged, it has the '}' that is missing in bad_file.rtf.
Comment 4 Karl-Heinz Zimmer 2023-05-30 07:13:45 UTC
Thank you for looking at this issue, I have attached two RTF files now.
Comment 5 Dieter 2023-06-03 11:10:16 UTC
I can reproduce the problem with the follwing steps

1. Open Writer
2. Open attachment 187599 [details]

Actual result
Error message "File format error found at 7,1(row,col)"

So I would treat your report as enhancement request and I've changed bug summary and added desing-team.
Comment 6 Heiko Tietze 2023-06-05 07:34:46 UTC
The error message "File format error found at $(ARG1)(row,col)" is defined four times where we probably can exclude sc and sd. But it still needs a bit of debugging to find the right place to add the human-readable information.