Kaydet (Commit) f9568335 authored tarafından osnola's avatar osnola Kaydeden (comit) David Tardon

upload libwps 0.4.0

Change-Id: I9da61333b7c46d20cf7010553929b141ec011d84
üst fa76bbbe
......@@ -2164,7 +2164,7 @@ $(call gb_LinkTarget_set_include,$(1),\
$$(INCLUDE) \
)
$(call gb_LinkTarget_add_libs,$(1),\
-L$(call gb_UnpackedTarball_get_dir,libwps)/src/lib/.libs -lwps-0.3 \
-L$(call gb_UnpackedTarball_get_dir,libwps)/src/lib/.libs -lwps-0.4 \
)
endef
......
......@@ -145,8 +145,8 @@ export WPD_MD5SUM := 0773d79a1f240ef9f4f20242b13c5bb7
export WPD_TARBALL := libwpd-0.10.0.tar.bz2
export WPG_MD5SUM := 17da9770cb8b317b7633f9807b32b71a
export WPG_TARBALL := libwpg-0.3.0.tar.bz2
export WPS_MD5SUM := a111d9ef5a0dab564e9aec0f2cf8d218
export WPS_TARBALL := libwps-0.3.1.tar.bz2
export WPS_MD5SUM := e9162d2566421d9d71b3ad2377a68fd5
export WPS_TARBALL := libwps-0.4.0.tar.bz2
export XSLTML_TARBALL := a7983f859eafb2677d7ff386a023bc40-xsltml_2.1.2.zip
export ZLIB_MD5SUM := 44d667c142d7cda120332623eab69f40
export ZLIB_TARBALL := zlib-1.2.8.tar.gz
......
From 45a3dd5393e07340d5a63d8a8735789d73a61b17 Mon Sep 17 00:00:00 2001
From: osnola <alonso@loria.fr>
Date: Mon, 18 May 2015 08:27:59 +0200
Subject: [PATCH] QuattroPro parser: correct a mistake when reading negative
cell's position
---
src/lib/QuattroSpreadsheet.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/QuattroSpreadsheet.cpp b/src/lib/QuattroSpreadsheet.cpp
index cb0f4f5..ce5e20a 100644
--- a/src/lib/QuattroSpreadsheet.cpp
+++ b/src/lib/QuattroSpreadsheet.cpp
@@ -1668,7 +1668,7 @@ bool QuattroSpreadsheet::readCell
else
{
val &= 0x3FFF;
- if (val & 0x2000) val = val - 0x4000;
+ if (val>0x1000) val = val - 0x2000;
}
if (dim==2)
val += sheetId;
--
2.3.2 (Apple Git-55)
From 94af34d42129bad72fd7ce50dc6901287509703e Mon Sep 17 00:00:00 2001
From: David Tardon <dtardon@redhat.com>
Date: Mon, 18 May 2015 18:50:25 +0200
Subject: [PATCH] error C2065: M_PI : undeclared identifier
---
src/lib/libwps_internal.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/lib/libwps_internal.h b/src/lib/libwps_internal.h
index fb9016d..02a87bc 100644
--- a/src/lib/libwps_internal.h
+++ b/src/lib/libwps_internal.h
@@ -28,6 +28,7 @@
#include <stdio.h>
#endif
+#include <cmath>
#include <iostream>
#include <map>
#include <string>
@@ -36,6 +37,10 @@
#include <librevenge-stream/librevenge-stream.h>
#include <librevenge/librevenge.h>
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
#if defined(_MSC_VER) || defined(__DJGPP__)
typedef signed char int8_t;
typedef unsigned char uint8_t;
--
2.4.0
......@@ -12,11 +12,11 @@ $(eval $(call gb_ExternalPackage_ExternalPackage,libwps,libwps))
$(eval $(call gb_ExternalPackage_use_external_project,libwps,libwps))
ifeq ($(OS),MACOSX)
$(eval $(call gb_ExternalPackage_add_file,libwps,$(LIBO_LIB_FOLDER)/libwps-0.3.3.dylib,src/lib/.libs/libwps-0.3.3.dylib))
$(eval $(call gb_ExternalPackage_add_file,libwps,$(LIBO_LIB_FOLDER)/libwps-0.4.4.dylib,src/lib/.libs/libwps-0.4.4.dylib))
else ifeq ($(OS),WNT)
$(eval $(call gb_ExternalPackage_add_file,libwps,$(LIBO_LIB_FOLDER)/libwps-0.3.dll,src/lib/.libs/libwps-0.3.dll))
$(eval $(call gb_ExternalPackage_add_file,libwps,$(LIBO_LIB_FOLDER)/libwps-0.4.dll,src/lib/.libs/libwps-0.4.dll))
else ifeq ($(filter IOS ANDROID,$(OS)),)
$(eval $(call gb_ExternalPackage_add_file,libwps,$(LIBO_LIB_FOLDER)/libwps-0.3.so.3,src/lib/.libs/libwps-0.3.so.3.0.1))
$(eval $(call gb_ExternalPackage_add_file,libwps,$(LIBO_LIB_FOLDER)/libwps-0.4.so.4,src/lib/.libs/libwps-0.4.so.4.0.0))
endif
# vim: set noet sw=4 ts=4:
......@@ -41,7 +41,7 @@ $(call gb_ExternalProject_get_state_target,libwps,build) :
&& $(MAKE) \
$(if $(filter MACOSX,$(OS)),\
&& $(PERL) $(SRCDIR)/solenv/bin/macosx-change-install-names.pl shl OOO \
$(EXTERNAL_WORKDIR)/src/lib/.libs/libwps-0.3.3.dylib \
$(EXTERNAL_WORKDIR)/src/lib/.libs/libwps-0.4.4.dylib \
) \
)
......
......@@ -33,6 +33,12 @@ $(eval $(call gb_Library_add_defs,wps,\
$(eval $(call gb_Library_set_generated_cxx_suffix,wps,cpp))
$(eval $(call gb_Library_add_generated_exception_objects,wps,\
UnpackedTarball/libwps/src/lib/Lotus \
UnpackedTarball/libwps/src/lib/LotusGraph \
UnpackedTarball/libwps/src/lib/LotusSpreadsheet \
UnpackedTarball/libwps/src/lib/LotusStyleManager \
UnpackedTarball/libwps/src/lib/Quattro \
UnpackedTarball/libwps/src/lib/QuattroSpreadsheet \
UnpackedTarball/libwps/src/lib/WKS4 \
UnpackedTarball/libwps/src/lib/WKS4Spreadsheet \
UnpackedTarball/libwps/src/lib/WKSContentListener \
......@@ -52,6 +58,8 @@ $(eval $(call gb_Library_add_generated_exception_objects,wps,\
UnpackedTarball/libwps/src/lib/WPSDebug \
UnpackedTarball/libwps/src/lib/WPSDocument \
UnpackedTarball/libwps/src/lib/WPSFont \
UnpackedTarball/libwps/src/lib/WPSGraphicShape \
UnpackedTarball/libwps/src/lib/WPSGraphicStyle \
UnpackedTarball/libwps/src/lib/WPSHeader \
UnpackedTarball/libwps/src/lib/WPSList \
UnpackedTarball/libwps/src/lib/WPSOLEParser \
......
......@@ -11,4 +11,11 @@ $(eval $(call gb_UnpackedTarball_UnpackedTarball,libwps))
$(eval $(call gb_UnpackedTarball_set_tarball,libwps,$(WPS_TARBALL)))
$(eval $(call gb_UnpackedTarball_set_patchlevel,libwps,1))
$(eval $(call gb_UnpackedTarball_add_patches,libwps,\
external/libwps/0001-QuattroPro-parser-correct-a-mistake-when-reading-neg.patch \
external/libwps/0001-error-C2065-M_PI-undeclared-identifier.patch \
))
# vim: set noet sw=4 ts=4:
......@@ -508,6 +508,8 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_calc_types.xcu,f
calc_OOXML \
calc_OOXML_Template \
calc_MS_Works_Document \
calc_WPS_Lotus_Document \
calc_WPS_QPro_Document \
calc_Beagle_Works \
calc_ClarisWorks \
calc_Claris_Resolve \
......@@ -546,6 +548,8 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_calc_filters.x
calc_OOXML \
calc_OOXML_Template \
MS_Works_Calc \
WPS_Lotus_Calc \
WPS_QPro_Calc \
Beagle_Works_Calc \
ClarisWorks_Calc \
Claris_Resolve_Calc \
......
<!--
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="WPS_Lotus_Calc" oor:op="replace">
<prop oor:name="Flags"><value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER</value></prop>
<prop oor:name="UIComponent"/>
<prop oor:name="FilterService"><value>com.sun.star.comp.Calc.MSWorksCalcImportFilter</value></prop>
<prop oor:name="UserData"><value></value></prop>
<prop oor:name="UIName">
<value xml:lang="en-US">Lotus Document</value>
</prop>
<prop oor:name="FileFormatVersion"><value>0</value></prop>
<prop oor:name="Type"><value>calc_WPS_Lotus_Document</value></prop>
<prop oor:name="TemplateName"/>
<prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop>
</node>
<!--
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="WPS_QPro_Calc" oor:op="replace">
<prop oor:name="Flags"><value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER</value></prop>
<prop oor:name="UIComponent"/>
<prop oor:name="FilterService"><value>com.sun.star.comp.Calc.MSWorksCalcImportFilter</value></prop>
<prop oor:name="UserData"><value></value></prop>
<prop oor:name="UIName">
<value xml:lang="en-US">QuattroPro Document</value>
</prop>
<prop oor:name="FileFormatVersion"><value>0</value></prop>
<prop oor:name="Type"><value>calc_WPS_QPro_Document</value></prop>
<prop oor:name="TemplateName"/>
<prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop>
</node>
<!--
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="calc_WPS_Lotus_Document" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.comp.Calc.MSWorksCalcImportFilter</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>wk1 wk3</value></prop>
<prop oor:name="MediaType"></prop>
<prop oor:name="Preferred"><value>true</value></prop>
<prop oor:name="PreferredFilter"><value>WPS_Lotus_Calc</value></prop>
<prop oor:name="UIName">
<value>Lotus Wk1-Wk3</value>
</prop>
<prop oor:name="ClipboardFormat"/>
</node>
<!--
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="calc_WPS_QPro_Document" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.comp.Calc.MSWorksCalcImportFilter</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>wq1 wq2</value></prop>
<prop oor:name="MediaType"></prop>
<prop oor:name="Preferred"><value>true</value></prop>
<prop oor:name="PreferredFilter"><value>WPS_QPro_Calc</value></prop>
<prop oor:name="UIName">
<value>QuattroPro Document</value>
</prop>
<prop oor:name="ClipboardFormat"/>
</node>
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* MSWorksImportFilter: Sets up the filter, and calls DocumentCollector
* to do the actual filtering
*
* 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/.
*/
#ifndef INCLUDED_WRITERPERFECT_WPFTENCODINGDIALOG_HXX
#define INCLUDED_WRITERPERFECT_WPFTENCODINGDIALOG_HXX
#include <sal/types.h>
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/lstbox.hxx>
#include <writerperfect/writerperfectdllapi.h>
namespace writerperfect {
class WRITERPERFECT_DLLPUBLIC WPFTEncodingDialog : public ModalDialog
{
public:
WPFTEncodingDialog( vcl::Window* pParent,
const OUString* pStrTitle = 0,
const OUString* defEncoding = 0);
virtual ~WPFTEncodingDialog();
OUString GetEncoding( ) const;
bool hasUserCalledCancel() const {
return m_userHasCancelled;
}
private:
VclPtr<ListBox> m_pLbCharset;
VclPtr<OKButton> m_pBtnOk;
VclPtr<CancelButton> m_pBtnCancel;
bool m_userHasCancelled;
private:
DECL_LINK( DoubleClickHdl, ListBox* );
DECL_LINK(CancelHdl, void*);
WPFTEncodingDialog(WPFTEncodingDialog const &) SAL_DELETED_FUNCTION;
WPFTEncodingDialog &operator=(WPFTEncodingDialog const &) SAL_DELETED_FUNCTION;
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -290,6 +290,7 @@ UI_FILELIST(tubes, "UIConfig/tubes.filelist")
#endif
UI_FILELIST(uui, "UIConfig/uui.filelist")
UI_FILELIST(vcl, "UIConfig/vcl.filelist")
UI_FILELIST(writerperfect, "UIConfig/writerperfect.filelist")
UI_FILELIST(xmlsec, "UIConfig/xmlsec.filelist")
UI_FILELIST_ALL_LANG(basicide, modules/BasicIDE)
......
......@@ -125,6 +125,7 @@ Module gid_Module_Root
#endif
gid_File_Share_Config_Sofficecfg_uiconfig_uui,
gid_File_Share_Config_Sofficecfg_uiconfig_vcl,
gid_File_Share_Config_Sofficecfg_uiconfig_writerperfect,
gid_File_Share_Config_Sofficecfg_uiconfig_xmlsec,
gid_File_Share_Registry_Main_Xcd,
gid_File_Share_Registry_Forcedefault_Xcd,
......
......@@ -34,8 +34,10 @@ $(eval $(call gb_Library_use_libraries,wpftcalc,\
cppuhelper \
sal \
sot \
svx \
tl \
utl \
vcl \
writerperfect \
xo \
$(gb_UWINAPI) \
......
......@@ -34,8 +34,10 @@ $(eval $(call gb_Library_use_libraries,wpftdraw,\
cppuhelper \
sal \
sot \
svx \
tl \
utl \
vcl \
writerperfect \
xo \
$(gb_UWINAPI) \
......
......@@ -34,9 +34,11 @@ $(eval $(call gb_Library_use_libraries,wpftimpress,\
cppuhelper \
sal \
sot \
svx \
tl \
ucbhelper \
utl \
vcl \
writerperfect \
xo \
$(gb_UWINAPI) \
......
......@@ -36,9 +36,11 @@ $(eval $(call gb_Library_use_libraries,wpftwriter,\
sal \
sfx \
sot \
svx \
tl \
ucbhelper \
utl \
vcl \
writerperfect \
xo \
$(gb_UWINAPI) \
......
......@@ -37,9 +37,11 @@ $(eval $(call gb_Library_use_libraries,writerperfect,\
cppuhelper \
sal \
sot \
svx \
tl \
ucbhelper \
utl \
vcl \
xo \
$(gb_UWINAPI) \
))
......@@ -47,6 +49,7 @@ $(eval $(call gb_Library_use_libraries,writerperfect,\
$(eval $(call gb_Library_add_exception_objects,writerperfect,\
writerperfect/source/common/DirectoryStream \
writerperfect/source/common/DocumentHandler \
writerperfect/source/common/WPFTEncodingDialog \
writerperfect/source/common/WPXSvInputStream \
))
......
......@@ -27,6 +27,10 @@ $(eval $(call gb_Module_add_targets,writerperfect,\
Library_writerperfect \
))
$(eval $(call gb_Module_add_l10n_targets,writerperfect,\
UIConfig_writerperfect \
))
$(eval $(call gb_Module_add_check_targets,writerperfect,\
CppunitTest_writerperfect_stream \
))
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# 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/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
$(eval $(call gb_UIConfig_UIConfig,writerperfect))
$(eval $(call gb_UIConfig_add_uifiles,writerperfect,\
writerperfect/uiconfig/ui/wpftencodingdialog \
))
# vim: set noet sw=4 ts=4:
......@@ -14,6 +14,7 @@
#include <libwps/libwps.h>
#include "writerperfect/WPFTEncodingDialog.hxx"
#include "MSWorksCalcImportFilter.hxx"
using com::sun::star::uno::Sequence;
......@@ -26,18 +27,78 @@ using com::sun::star::uno::XComponentContext;
bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &)
{
return libwps::WPS_OK == libwps::WPSDocument::parse(&rInput, &rGenerator);
libwps::WPSKind kind = libwps::WPS_TEXT;
libwps::WPSCreator creator;
bool needEncoding;
const libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&rInput, kind, creator, needEncoding);
std::string fileEncoding("");
if ((kind == libwps::WPS_SPREADSHEET || kind == libwps::WPS_DATABASE) && (confidence == libwps::WPS_CONFIDENCE_EXCELLENT) && needEncoding)
{
OUString title, encoding;
if (creator == libwps::WPS_MSWORKS)
{
title="Import MsWorks files(libwps)";
encoding="CP850";
}
else if (creator == libwps::WPS_LOTUS)
{
title="Import Lotus files(libwps)";
encoding="CP437";
}
else if (creator == libwps::WPS_SYMPHONY)
{
title="Import Symphony files(libwps)";
encoding="CP437";
}
else
{
title="Import Quattro Pro files(libwps)";
encoding="CP437";
}
try
{
const ScopedVclPtrInstance<writerperfect::WPFTEncodingDialog> pDlg(nullptr, &title, &encoding);
if (pDlg->Execute() == RET_OK)
{
if (!pDlg->GetEncoding().isEmpty())
fileEncoding=pDlg->GetEncoding().toUtf8().getStr();
}
// we can fail because we are in headless mode, the user has cancelled conversion, ...
else if (pDlg->hasUserCalledCancel())
return false;
}
catch (...)
{
}
}
return libwps::WPS_OK == libwps::WPSDocument::parse(&rInput, &rGenerator, "", fileEncoding.c_str());
}
bool MSWorksCalcImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName)
{
libwps::WPSKind kind = libwps::WPS_TEXT;
const libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&rInput, kind);
libwps::WPSCreator creator;
bool needEncoding;
const libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&rInput, kind, creator, needEncoding);
if ((kind == libwps::WPS_SPREADSHEET || kind == libwps::WPS_DATABASE) && (confidence == libwps::WPS_CONFIDENCE_EXCELLENT))
if ((kind == libwps::WPS_SPREADSHEET || kind == libwps::WPS_DATABASE) && confidence == libwps::WPS_CONFIDENCE_EXCELLENT)
{
rTypeName = "calc_MS_Works_Document";
return true;
if (creator == libwps::WPS_MSWORKS)
{
rTypeName = "calc_MS_Works_Document";
return true;
}
if (creator == libwps::WPS_LOTUS || creator == libwps::WPS_SYMPHONY)
{
rTypeName = "calc_WPS_Lotus_Document";
return true;
}
if (creator == libwps::WPS_QUATTRO_PRO)
{
rTypeName = "calc_WPS_QPro_Document";
return true;
}
}
return false;
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <writerperfect/WPFTEncodingDialog.hxx>
namespace writerperfect
{
namespace
{
struct EncodingImplementation
{
static OUString const(s_encodings[]);
static int numEncodings();
static void insertEncodings(ListBox *box);
static void selectEncoding(ListBox *box, const OUString *encoding);
static OUString getEncoding(ListBox *box);
};
OUString const(EncodingImplementation::s_encodings[])=
{
"MacArabic", "Arabic (Apple Macintosh)",
"CP864", "Arabic (DOS/OS2-864)",
"CP1006", "Arabic (IBM-1006)",
"CP1256", "Arabic (Windows-1256)",
"CP775", "Baltic (DOS/OS2-775)",
"CP1257", "Baltic (Windows-1257)",
"MacCeltic", "Celtic (Apple Macintosh)",
"MacCyrillic", "Cyrillic (Apple Macintosh)",
"CP855", "Cyrillic (DOS/OS2-855)",
"CP866", "Cyrillic (DOS/OS2-866/Russian)",
"CP1251", "Cyrillic (Windows-1251)",
"MacCEurope", "Eastern Europe (Apple Macintosh)",
"MacCroatian", "Eastern Europe (Apple Macintosh/Croatian)",
"MacRomanian", "Eastern Europe (Apple Macintosh/Romanian)",
"CP852", "Eastern Europe (DOS/OS2-852)",
"CP1250", "Eastern Europe (Windows-1250/WinLatin 2)",
"MacGreek", "Greek (Apple Macintosh)",
"CP737", "Greek (DOS/OS2-737)",
"CP869", "Greek (DOS/OS2-869/Greek-2)",
"CP875", "Greek (DOS/OS2-875)",
"CP1253", "Greek (Windows-1253)",
"MacHebrew", "Hebrew (Apple Macintosh)",
"CP424", "Hebrew (DOS/OS2-424)",
"CP856", "Hebrew (DOS/OS2-856)",
"CP862", "Hebrew (DOS/OS2-862)",
"CP1255", "Hebrew (Windows-1255)",
"CP500", "International (DOS/OS2-500)",
"MacThai", "Thai (Apple Macintosh)",
"CP874", "Thai (DOS/OS2-874)",
"MacTurkish", "Turkish (Apple Macintosh)",
"CP857", "Turkish (DOS/OS2-857)",
"CP1026", "Turkish (DOS/OS2-1026)",
"CP1254", "Turkish (Windows-1254)",
"CP1258", "Vietnamese (Windows-1258)",
"MacRoman", "Western Europe (Apple Macintosh)",
"MacIceland", "Western Europe (Apple Macintosh/Icelandic)",
"CP037", "Western Europe (DOS/OS2-037/US-Canada)",
"CP437", "Western Europe (DOS/OS2-437/US)",
"CP850", "Western Europe (DOS/OS2-850)",
"CP860", "Western Europe (DOS/OS2-860/Portuguese)",
"CP861", "Western Europe (DOS/OS2-861/Icelandic)",
"CP863", "Western Europe (DOS/OS2-863/French)",
"CP865", "Western Europe (DOS/OS2-865/Nordic)",
"CP1252", "Western Europe (Windows-1252/WinLatin 1)"
};
int EncodingImplementation::numEncodings()
{
return int(sizeof(s_encodings)/(2*sizeof(const OUString *)));
}
void EncodingImplementation::insertEncodings(ListBox *box)
{
sal_IntPtr num=sal_IntPtr(numEncodings());
for (sal_IntPtr i=0; i<num; ++i)
{
sal_IntPtr nAt=box->InsertEntry(s_encodings[2*i+1]);
box->SetEntryData(nAt, reinterpret_cast<void *>(i));
}
}
void EncodingImplementation::selectEncoding(ListBox *box, const OUString *encoding)
{
if (!encoding)
return;
sal_IntPtr num=sal_IntPtr(numEncodings());
for (sal_IntPtr i=0; i<num; ++i)
{
if (*encoding!=s_encodings[2*i]) continue;
box->SelectEntryPos(i);
return;
}
}
OUString EncodingImplementation::getEncoding(ListBox *box)
{
sal_IntPtr pos=(sal_IntPtr) box->GetSelectEntryData();
if (pos<0||pos>=numEncodings())
return OUString();
return s_encodings[2*pos];
}
}
WPFTEncodingDialog::WPFTEncodingDialog(
vcl::Window *pParent,
const OUString *pStrTitle,
const OUString *encoding)
: ModalDialog(pParent, "WPFTEncodingDialog", "writerperfect/ui/WPFTEncodingDialog.ui"),
m_pLbCharset(), m_pBtnOk(), m_pBtnCancel(), m_userHasCancelled(false)
{
get(m_pLbCharset, "comboboxtext");
get(m_pBtnOk, "ok");
get(m_pBtnCancel, "cancel");
m_pBtnCancel->SetClickHdl(LINK(this, WPFTEncodingDialog, CancelHdl));
EncodingImplementation::insertEncodings(m_pLbCharset);
m_pLbCharset->SetStyle(m_pLbCharset->GetStyle() | WB_SORT);
// m_pLbCharset->set_height_request(6 * m_pLbCharset->GetTextHeight());
m_pLbCharset->SetDoubleClickHdl(LINK(this, WPFTEncodingDialog, DoubleClickHdl));
if (encoding)
EncodingImplementation::selectEncoding(m_pLbCharset, encoding);
m_pLbCharset->Show();
if (pStrTitle)
SetText(*pStrTitle);
}
WPFTEncodingDialog::~WPFTEncodingDialog()
{
}
OUString WPFTEncodingDialog::GetEncoding() const
{
return EncodingImplementation::getEncoding(m_pLbCharset);