diff options
-rw-r--r-- | filter/Configuration_filter.mk | 2 | ||||
-rw-r--r-- | filter/source/config/fragments/filters/DosWord.xcu | 28 | ||||
-rw-r--r-- | filter/source/config/fragments/types/writer_DosWord.xcu | 22 | ||||
-rw-r--r-- | writerperfect/source/writer/MSWorksImportFilter.cxx | 45 |
4 files changed, 80 insertions, 17 deletions
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk index 38c67feab1a4..5dd20f7f12f7 100644 --- a/filter/Configuration_filter.mk +++ b/filter/Configuration_filter.mk @@ -324,6 +324,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_writer_types.xcu writer_WordPerfect_Document \ writer_MS_Works_Document \ writer_MS_Write \ + writer_DosWord \ writer_ClarisWorks \ writer_Mac_Word \ writer_Mac_Works \ @@ -367,6 +368,7 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_writer_filters WordPerfect \ MS_Works \ MS_Write \ + DosWord \ ClarisWorks \ Mac_Word \ Mac_Works \ diff --git a/filter/source/config/fragments/filters/DosWord.xcu b/filter/source/config/fragments/filters/DosWord.xcu new file mode 100644 index 000000000000..697032c91e4e --- /dev/null +++ b/filter/source/config/fragments/filters/DosWord.xcu @@ -0,0 +1,28 @@ +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. +--> + +<node oor:name="DosWord" oor:op="replace"> + <prop oor:name="Flags"> + <value>IMPORT ALIEN 3RDPARTYFILTER</value> + </prop> + <prop oor:name="FilterService"> + <value>com.sun.star.comp.Writer.MSWorksImportFilter</value> + </prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">Microsoft Word for DOS</value> + </prop> + <prop oor:name="FileFormatVersion"> + <value>0</value> + </prop> + <prop oor:name="Type"> + <value>writer_DosWord</value> + </prop> + <prop oor:name="DocumentService"> + <value>com.sun.star.text.TextDocument</value> + </prop> +</node> diff --git a/filter/source/config/fragments/types/writer_DosWord.xcu b/filter/source/config/fragments/types/writer_DosWord.xcu new file mode 100644 index 000000000000..37333886a17c --- /dev/null +++ b/filter/source/config/fragments/types/writer_DosWord.xcu @@ -0,0 +1,22 @@ +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. +--> + +<node oor:name="writer_DosWord" oor:op="replace"> + <prop oor:name="DetectService"> + <value>com.sun.star.comp.Writer.MSWorksImportFilter</value> + </prop> + <prop oor:name="Extensions"> + <value>doc</value> + </prop> + <prop oor:name="PreferredFilter"> + <value>DosWord</value> + </prop> + <prop oor:name="UIName"> + <value>Microsoft Word for DOS</value> + </prop> +</node> diff --git a/writerperfect/source/writer/MSWorksImportFilter.cxx b/writerperfect/source/writer/MSWorksImportFilter.cxx index b08ddb3c08dd..f8a03c8ecd15 100644 --- a/writerperfect/source/writer/MSWorksImportFilter.cxx +++ b/writerperfect/source/writer/MSWorksImportFilter.cxx @@ -42,23 +42,31 @@ bool MSWorksImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, std::string fileEncoding(""); try { - if ((kind == libwps::WPS_TEXT) && (creator == libwps::WPS_MSWORKS) && (confidence == libwps::WPS_CONFIDENCE_EXCELLENT) && needEncoding) + if ((kind == libwps::WPS_TEXT) && (confidence == libwps::WPS_CONFIDENCE_EXCELLENT) && needEncoding) { - const ScopedVclPtrInstance<writerperfect::WPFTEncodingDialog> pDlg( - "Import MsWorks files(libwps)", "CP850"); - if (pDlg->Execute() == RET_OK) + OUString title, encoding; + + switch (creator) { - if (!pDlg->GetEncoding().isEmpty()) - fileEncoding=pDlg->GetEncoding().toUtf8().getStr(); + case libwps::WPS_MSWORKS: + title = "Import MsWorks files(libwps)"; + encoding = "CP850"; + break; + case libwps::WPS_RESERVED_0: // MS Write + title = "Import MsWrite files(libwps)"; + encoding = "CP1251"; + break; + case libwps::WPS_RESERVED_1: // DosWord + title = "Import DosWord files(libwps)"; + encoding = "CP850"; + break; + default: + title = "Import files(libwps)"; + encoding = "CP850"; + break; } - // we can fail because we are in headless mode, the user has cancelled conversion, ... - else if (pDlg->hasUserCalledCancel()) - return false; - } - else if ((kind == libwps::WPS_TEXT) && (creator == libwps::WPS_RESERVED_0) && (confidence == libwps::WPS_CONFIDENCE_EXCELLENT) && needEncoding) - { - const ScopedVclPtrInstance<writerperfect::WPFTEncodingDialog> pDlg( - "Import MsWrite files(libwps)", "CP1252"); + + const ScopedVclPtrInstance<writerperfect::WPFTEncodingDialog> pDlg(title, encoding); if (pDlg->Execute() == RET_OK) { if (!pDlg->GetEncoding().isEmpty()) @@ -68,7 +76,6 @@ bool MSWorksImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, else if (pDlg->hasUserCalledCancel()) return false; } - } catch (css::uno::Exception &e) { @@ -90,11 +97,15 @@ bool MSWorksImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OU { rTypeName = "writer_MS_Works_Document"; } - else + else if (creator == libwps::WPS_RESERVED_0) { - // NOTE: this handles MS Word for DOS too ATM rTypeName = "writer_MS_Write"; } + else + { + rTypeName = "writer_DosWord"; + } + return true; } |