summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/inc/internal/basereader.hxx80
-rw-r--r--shell/inc/internal/columninfo.hxx77
-rw-r--r--shell/inc/internal/config.hxx104
-rw-r--r--shell/inc/internal/contentreader.hxx126
-rw-r--r--shell/inc/internal/dbgmacros.hxx51
-rw-r--r--shell/inc/internal/fileextensions.hxx68
-rw-r--r--shell/inc/internal/global.hxx44
-rw-r--r--shell/inc/internal/i_xml_parser_event_handler.hxx78
-rw-r--r--shell/inc/internal/infotips.hxx100
-rw-r--r--shell/inc/internal/iso8601_converter.hxx47
-rwxr-xr-xshell/inc/internal/metainforeader.hxx148
-rwxr-xr-xshell/inc/internal/propertyhdl.hxx126
-rw-r--r--shell/inc/internal/propsheets.hxx94
-rw-r--r--shell/inc/internal/registry.hxx69
-rw-r--r--shell/inc/internal/resource.h57
-rwxr-xr-xshell/inc/internal/shlxthdl.hxx55
-rwxr-xr-xshell/inc/internal/stream_helper.hxx35
-rw-r--r--shell/inc/internal/thumbviewer.hxx118
-rw-r--r--shell/inc/internal/types.hxx95
-rwxr-xr-xshell/inc/internal/utilities.hxx110
-rw-r--r--shell/inc/internal/xml_parser.hxx134
-rw-r--r--shell/inc/internal/zipfile.hxx162
-rw-r--r--shell/inc/kde_headers.h94
-rw-r--r--shell/inc/makefile.mk47
-rw-r--r--shell/inc/pch/precompiled_shell.cxx29
-rw-r--r--shell/inc/pch/precompiled_shell.hxx32
-rwxr-xr-xshell/prj/build.lst34
-rw-r--r--shell/prj/d.lst25
-rw-r--r--shell/qa/i_xml_parser_event_handler.hxx77
-rwxr-xr-xshell/qa/makefile.mk68
-rwxr-xr-xshell/qa/recent_docs.cxx224
-rwxr-xr-xshell/source/all/makefile.mk73
-rw-r--r--shell/source/all/ooofilereader/autostyletag.cxx100
-rw-r--r--shell/source/all/ooofilereader/autostyletag.hxx72
-rw-r--r--shell/source/all/ooofilereader/basereader.cxx106
-rw-r--r--shell/source/all/ooofilereader/contentreader.cxx235
-rw-r--r--shell/source/all/ooofilereader/dummytag.hxx61
-rw-r--r--shell/source/all/ooofilereader/itag.hxx52
-rw-r--r--shell/source/all/ooofilereader/keywordstag.cxx64
-rw-r--r--shell/source/all/ooofilereader/keywordstag.hxx54
-rw-r--r--shell/source/all/ooofilereader/makefile.mk89
-rw-r--r--shell/source/all/ooofilereader/metainforeader.cxx302
-rw-r--r--shell/source/all/ooofilereader/simpletag.cxx65
-rw-r--r--shell/source/all/ooofilereader/simpletag.hxx58
-rw-r--r--shell/source/all/xml_parser.cxx215
-rw-r--r--shell/source/all/zipfile/makefile.mk58
-rw-r--r--shell/source/all/zipfile/zipexcptn.cxx137
-rw-r--r--shell/source/all/zipfile/zipexcptn.hxx78
-rw-r--r--shell/source/all/zipfile/zipfile.cxx251
-rw-r--r--shell/source/backends/desktopbe/desktopbackend.cxx290
-rw-r--r--shell/source/backends/desktopbe/desktopbe1-ucd.txt6
-rw-r--r--shell/source/backends/desktopbe/makefile.mk53
-rw-r--r--shell/source/backends/gconfbe/gconfaccess.cxx849
-rw-r--r--shell/source/backends/gconfbe/gconfaccess.hxx119
-rw-r--r--shell/source/backends/gconfbe/gconfbackend.cxx239
-rw-r--r--shell/source/backends/gconfbe/gconfbe1-ucd.txt6
-rw-r--r--shell/source/backends/gconfbe/makefile.mk96
-rw-r--r--shell/source/backends/gconfbe/orbit.h39
-rw-r--r--shell/source/backends/kde4be/kde4access.cxx319
-rw-r--r--shell/source/backends/kde4be/kde4access.hxx47
-rw-r--r--shell/source/backends/kde4be/kde4backend.cxx258
-rw-r--r--shell/source/backends/kde4be/kde4be1-ucd.txt6
-rw-r--r--shell/source/backends/kde4be/makefile.mk81
-rw-r--r--shell/source/backends/kdebe/kdeaccess.cxx315
-rw-r--r--shell/source/backends/kdebe/kdeaccess.hxx47
-rw-r--r--shell/source/backends/kdebe/kdebackend.cxx258
-rw-r--r--shell/source/backends/kdebe/kdebe1-ucd.txt6
-rw-r--r--shell/source/backends/kdebe/makefile.mk81
-rw-r--r--shell/source/backends/localebe/exports.map10
-rw-r--r--shell/source/backends/localebe/localebackend.cxx367
-rw-r--r--shell/source/backends/localebe/localebackend.hxx149
-rw-r--r--shell/source/backends/localebe/localebe.xml35
-rw-r--r--shell/source/backends/localebe/localebecdef.cxx94
-rw-r--r--shell/source/backends/localebe/makefile.mk72
-rw-r--r--shell/source/backends/macbe/exports.map10
-rw-r--r--shell/source/backends/macbe/macbackend.cxx499
-rw-r--r--shell/source/backends/macbe/macbackend.hxx138
-rw-r--r--shell/source/backends/macbe/macbe.xml35
-rw-r--r--shell/source/backends/macbe/macbecdef.cxx94
-rw-r--r--shell/source/backends/macbe/makefile.mk78
-rw-r--r--shell/source/backends/wininetbe/exports.map10
-rw-r--r--shell/source/backends/wininetbe/makefile.mk68
-rw-r--r--shell/source/backends/wininetbe/wininetbackend.cxx403
-rw-r--r--shell/source/backends/wininetbe/wininetbackend.hxx157
-rw-r--r--shell/source/backends/wininetbe/wininetbe.xml35
-rw-r--r--shell/source/backends/wininetbe/wininetbecdef.cxx95
-rw-r--r--shell/source/cmdmail/cmdmail.xml47
-rwxr-xr-xshell/source/cmdmail/cmdmailentry.cxx135
-rwxr-xr-xshell/source/cmdmail/cmdmailmsg.cxx302
-rw-r--r--shell/source/cmdmail/cmdmailmsg.hxx128
-rwxr-xr-xshell/source/cmdmail/cmdmailsuppl.cxx328
-rw-r--r--shell/source/cmdmail/cmdmailsuppl.hxx95
-rw-r--r--shell/source/cmdmail/exports.dxp3
-rw-r--r--shell/source/cmdmail/exports.map10
-rw-r--r--shell/source/cmdmail/makefile.mk64
-rw-r--r--shell/source/mingw_intel.map57
-rw-r--r--shell/source/tools/lngconvex/cmdline.cxx175
-rw-r--r--shell/source/tools/lngconvex/cmdline.hxx104
-rw-r--r--shell/source/tools/lngconvex/defs.hxx14
-rw-r--r--shell/source/tools/lngconvex/lngconvex.cxx604
-rw-r--r--shell/source/tools/lngconvex/makefile.mk68
-rw-r--r--shell/source/tools/regsvrex/makefile.mk49
-rw-r--r--shell/source/tools/regsvrex/regsvrex.cxx91
-rw-r--r--shell/source/unix/exec/exports.map10
-rw-r--r--shell/source/unix/exec/makefile.mk90
-rw-r--r--shell/source/unix/exec/shellexec.cxx331
-rw-r--r--shell/source/unix/exec/shellexec.hxx79
-rw-r--r--shell/source/unix/exec/shellexecentry.cxx134
-rw-r--r--shell/source/unix/exec/syssh.xml33
-rw-r--r--shell/source/unix/exec/urltest.cxx151
-rw-r--r--shell/source/unix/exec/urltest.sh2
-rw-r--r--shell/source/unix/exec/urltest.txt11
-rwxr-xr-xshell/source/unix/misc/cde-open-url.sh13
-rw-r--r--shell/source/unix/misc/gnome-open-url.c146
-rw-r--r--shell/source/unix/misc/gnome-open-url.sh6
-rwxr-xr-xshell/source/unix/misc/kde-open-url.sh10
-rw-r--r--shell/source/unix/misc/makefile.mk90
-rw-r--r--shell/source/unix/misc/open-url.c172
-rw-r--r--shell/source/unix/misc/open-url.def1
-rwxr-xr-xshell/source/unix/misc/open-url.sh83
-rw-r--r--shell/source/unix/misc/senddoc.c204
-rw-r--r--shell/source/unix/misc/senddoc.def1
-rw-r--r--shell/source/unix/misc/senddoc.sh401
-rw-r--r--shell/source/unix/misc/uri-encode.c50
-rw-r--r--shell/source/unix/sysshell/makefile.mk75
-rw-r--r--shell/source/unix/sysshell/recently_used_file.cxx146
-rw-r--r--shell/source/unix/sysshell/recently_used_file.hxx68
-rw-r--r--shell/source/unix/sysshell/recently_used_file_handler.cxx526
-rwxr-xr-xshell/source/unix/sysshell/recfile.map6
-rw-r--r--shell/source/win32/SysShExec.cxx388
-rw-r--r--shell/source/win32/SysShExec.hxx83
-rw-r--r--shell/source/win32/SysShentry.cxx143
-rw-r--r--shell/source/win32/exports.dxp3
-rw-r--r--shell/source/win32/makefile.mk69
-rwxr-xr-xshell/source/win32/shlxthandler/classfactory.cxx171
-rw-r--r--shell/source/win32/shlxthandler/classfactory.hxx77
-rw-r--r--shell/source/win32/shlxthandler/columninfo/columninfo.cxx231
-rw-r--r--shell/source/win32/shlxthandler/columninfo/makefile.mk59
-rw-r--r--shell/source/win32/shlxthandler/exports.dxp4
-rw-r--r--shell/source/win32/shlxthandler/infotips/infotips.cxx402
-rw-r--r--shell/source/win32/shlxthandler/infotips/makefile.mk60
-rw-r--r--shell/source/win32/shlxthandler/makefile.mk158
-rw-r--r--shell/source/win32/shlxthandler/ooofilt/exports.dxp4
-rw-r--r--shell/source/win32/shlxthandler/ooofilt/makefile.mk141
-rwxr-xr-xshell/source/win32/shlxthandler/ooofilt/ooofilt.cxx1490
-rwxr-xr-xshell/source/win32/shlxthandler/ooofilt/ooofilt.hxx218
-rw-r--r--shell/source/win32/shlxthandler/ooofilt/propspec.cxx238
-rw-r--r--shell/source/win32/shlxthandler/ooofilt/propspec.hxx159
-rwxr-xr-xshell/source/win32/shlxthandler/ooofilt/stream_helper.cxx181
-rwxr-xr-xshell/source/win32/shlxthandler/prophdl/exports.dxp2
-rw-r--r--shell/source/win32/shlxthandler/prophdl/makefile.mk142
-rw-r--r--shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx463
-rw-r--r--shell/source/win32/shlxthandler/propsheets/document_statistic.cxx170
-rw-r--r--shell/source/win32/shlxthandler/propsheets/document_statistic.hxx149
-rw-r--r--shell/source/win32/shlxthandler/propsheets/listviewbuilder.cxx281
-rw-r--r--shell/source/win32/shlxthandler/propsheets/listviewbuilder.hxx115
-rw-r--r--shell/source/win32/shlxthandler/propsheets/makefile.mk65
-rwxr-xr-xshell/source/win32/shlxthandler/propsheets/propsheets.cxx366
-rw-r--r--shell/source/win32/shlxthandler/res/ctrylnglist.txt29
-rw-r--r--shell/source/win32/shlxthandler/res/makefile.mk72
-rw-r--r--shell/source/win32/shlxthandler/res/prop_img.bmpbin0 -> 958 bytes
-rw-r--r--shell/source/win32/shlxthandler/res/rcfooter.txt4
-rw-r--r--shell/source/win32/shlxthandler/res/rcheader.txt15
-rw-r--r--shell/source/win32/shlxthandler/res/rctmpl.txt71
-rw-r--r--shell/source/win32/shlxthandler/res/shlxthdl.manifest11
-rw-r--r--shell/source/win32/shlxthandler/res/shlxthdl.ulf148
-rw-r--r--shell/source/win32/shlxthandler/res/signet.pngbin0 -> 4836 bytes
-rwxr-xr-xshell/source/win32/shlxthandler/shlxthdl.cxx427
-rw-r--r--shell/source/win32/shlxthandler/thumbviewer/makefile.mk62
-rw-r--r--shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx532
-rw-r--r--shell/source/win32/shlxthandler/util/dbgmacros.cxx58
-rw-r--r--shell/source/win32/shlxthandler/util/fileextensions.cxx111
-rw-r--r--shell/source/win32/shlxthandler/util/iso8601_converter.cxx182
-rw-r--r--shell/source/win32/shlxthandler/util/makefile.mk68
-rw-r--r--shell/source/win32/shlxthandler/util/registry.cxx205
-rw-r--r--shell/source/win32/shlxthandler/util/utilities.cxx577
-rw-r--r--shell/source/win32/simplemail/exports.dxp3
-rw-r--r--shell/source/win32/simplemail/makefile.mk79
-rw-r--r--shell/source/win32/simplemail/senddoc.cxx347
-rw-r--r--shell/source/win32/simplemail/simplemapi.cxx97
-rw-r--r--shell/source/win32/simplemail/simplemapi.hxx84
-rw-r--r--shell/source/win32/simplemail/smplmail.xml37
-rw-r--r--shell/source/win32/simplemail/smplmailclient.cxx289
-rw-r--r--shell/source/win32/simplemail/smplmailclient.hxx54
-rw-r--r--shell/source/win32/simplemail/smplmailentry.cxx143
-rw-r--r--shell/source/win32/simplemail/smplmailmsg.cxx179
-rw-r--r--shell/source/win32/simplemail/smplmailmsg.hxx122
-rw-r--r--shell/source/win32/simplemail/smplmailsuppl.cxx107
-rw-r--r--shell/source/win32/simplemail/smplmailsuppl.hxx75
-rw-r--r--shell/source/win32/syssh.xml40
-rw-r--r--shell/source/win32/workbench/TestProxySet.cxx200
-rw-r--r--shell/source/win32/workbench/TestSmplMail.cxx188
-rw-r--r--shell/source/win32/workbench/TestSysShExec.cxx167
-rw-r--r--shell/source/win32/workbench/makefile.mk101
194 files changed, 26171 insertions, 0 deletions
diff --git a/shell/inc/internal/basereader.hxx b/shell/inc/internal/basereader.hxx
new file mode 100644
index 000000000000..fcdf1cdd7dff
--- /dev/null
+++ b/shell/inc/internal/basereader.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef BASEREADER_HXX_INCLUDED
+#define BASEREADER_HXX_INCLUDED
+
+#include "internal/global.hxx"
+#include "internal/types.hxx"
+#include "internal/config.hxx"
+#include "internal/utilities.hxx"
+#include "internal/i_xml_parser_event_handler.hxx"
+
+#ifndef XML_PARSER_HXX_INCLUDED
+#include "internal/xml_parser.hxx"
+#endif
+#include "internal/zipfile.hxx"
+
+class CBaseReader : public i_xml_parser_event_handler
+{
+public:
+ virtual ~CBaseReader();
+
+protected: // protected because its only an implementation relevant class
+ CBaseReader( const std::string& DocumentName );
+
+ CBaseReader( void* stream, zlib_filefunc_def* fa );
+
+ virtual void start_document();
+
+ virtual void end_document();
+
+ virtual void start_element(
+ const std::wstring& raw_name,
+ const std::wstring& local_name,
+ const XmlTagAttributes_t& attributes) = 0;
+
+ virtual void end_element(
+ const std::wstring& raw_name, const std::wstring& local_name) = 0;
+
+ virtual void characters(const std::wstring& character) = 0;
+
+ virtual void ignore_whitespace(const std::wstring& /*whitespaces*/){};
+
+ virtual void processing_instruction(
+ const std::wstring& /*target*/, const std::wstring& /*data*/){};
+
+ virtual void comment(const std::wstring& /*comment*/){};
+
+ void Initialize( const std::string& /*ContentName*/);
+
+private:
+ ZipFile m_ZipFile;
+ ZipFile::ZipContentBuffer_t m_ZipContent;
+};
+
+#endif
diff --git a/shell/inc/internal/columninfo.hxx b/shell/inc/internal/columninfo.hxx
new file mode 100644
index 000000000000..4e392dd76f4d
--- /dev/null
+++ b/shell/inc/internal/columninfo.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef COLUMNINFO_HXX_INCLUDED
+#define COLUMNINFO_HXX_INCLUDED
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable:4917)
+#endif
+#include <shlobj.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+
+class CColumnInfo : public IColumnProvider
+{
+public:
+ CColumnInfo(long RefCnt = 1);
+ virtual ~CColumnInfo();
+
+ //-----------------------------
+ // IUnknown methods
+ //-----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(
+ REFIID riid,
+ void __RPC_FAR *__RPC_FAR *ppvObject);
+
+ virtual ULONG STDMETHODCALLTYPE AddRef( void);
+
+ virtual ULONG STDMETHODCALLTYPE Release( void);
+
+ //-----------------------------
+ // IColumnProvider
+ //-----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE Initialize(LPCSHCOLUMNINIT psci);
+
+ virtual HRESULT STDMETHODCALLTYPE GetColumnInfo(DWORD dwIndex, SHCOLUMNINFO *psci);
+
+ virtual HRESULT STDMETHODCALLTYPE GetItemData(
+ LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT *pvarData);
+
+private:
+ bool IsOOFileExtension(wchar_t* Extension) const;
+
+private:
+ long m_RefCnt;
+};
+
+#endif
diff --git a/shell/inc/internal/config.hxx b/shell/inc/internal/config.hxx
new file mode 100644
index 000000000000..3c10e7db26a7
--- /dev/null
+++ b/shell/inc/internal/config.hxx
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CONFIG_HXX_INCLUDED
+#define CONFIG_HXX_INCLUDED
+
+#ifdef _MSC_VER
+#pragma warning (disable : 4786 4503 4917)
+#endif
+
+#ifndef OS2
+#include <tchar.h>
+#endif
+
+#ifdef _AMD64_
+#define MODULE_NAME TEXT("shlxthdl_x64.dll")
+#define MODULE_NAME_FILTER TEXT("ooofilt_x64.dll")
+#else
+#define MODULE_NAME TEXT("shlxthdl.dll")
+#define MODULE_NAME_FILTER TEXT("ooofilt.dll")
+#endif
+
+#define COLUMN_HANDLER_DESCRIPTIVE_NAME TEXT("OpenOffice.org Column Handler")
+#define INFOTIP_HANDLER_DESCRIPTIVE_NAME TEXT("OpenOffice.org Infotip Handler")
+#define PROPSHEET_HANDLER_DESCRIPTIVE_NAME TEXT("OpenOffice.org Property Sheet Handler")
+#define THUMBVIEWER_HANDLER_DESCRIPTIVAE_NAME TEXT("OpenOffice.org Thumbnail Viewer")
+
+#define META_CONTENT_NAME "meta.xml"
+#define DOC_CONTENT_NAME "content.xml"
+
+#define EMPTY_STRING L""
+#define SPACE L" "
+#define LF L"\n"
+#define META_INFO_TITLE L"title"
+#define META_INFO_AUTHOR L"initial-creator"
+#define META_INFO_SUBJECT L"subject"
+#define META_INFO_KEYWORDS L"keywords"
+#define META_INFO_KEYWORD L"keyword"
+#define META_INFO_DESCRIPTION L"description"
+
+#define META_INFO_PAGES L"page-count"
+#define META_INFO_TABLES L"table-count"
+#define META_INFO_DRAWS L"image-count"
+#define META_INFO_OBJECTS L"object-count"
+#define META_INFO_OLE_OBJECTS L"object-count"
+#define META_INFO_PARAGRAPHS L"paragraph-count"
+#define META_INFO_WORDS L"word-count"
+#define META_INFO_CHARACTERS L"character-count"
+#define META_INFO_ROWS L"row-count"
+#define META_INFO_CELLS L"cell-count"
+#define META_INFO_DOCUMENT_STATISTIC L"document-statistic"
+#define META_INFO_MODIFIED L"date"
+#define META_INFO_DOCUMENT_NUMBER L"editing-cycles"
+#define META_INFO_EDITING_TIME L"editing-duration"
+
+#define META_INFO_LANGUAGE L"language"
+#define META_INFO_CREATOR L"creator"
+#define META_INFO_CREATION L"creation-date"
+#define META_INFO_GENERATOR L"generator"
+
+
+#define CONTENT_TEXT_A L"a"
+#define CONTENT_TEXT_P L"p"
+#define CONTENT_TEXT_H L"h"
+#define CONTENT_TEXT_SPAN L"span"
+#define CONTENT_TEXT_SEQUENCE L"sequence"
+#define CONTENT_TEXT_BOOKMARK_REF L"bookmark-ref"
+#define CONTENT_TEXT_INDEX_TITLE_TEMPLATE L"index-title-template"
+#define CONTENT_TEXT_STYLENAME L"style-name"
+
+#define CONTENT_STYLE_STYLE L"style"
+#define CONTENT_STYLE_STYLE_NAME L"name"
+#define CONTENT_STYLE_PROPERTIES L"properties"
+#define CONTENT_TEXT_STYLE_PROPERTIES L"text-properties" // added for OASIS Open Office XML format.
+#define CONTENT_STYLE_PROPERTIES_LANGUAGE L"language"
+#define CONTENT_STYLE_PROPERTIES_COUNTRY L"country"
+#define CONTENT_STYLE_PROPERTIES_LANGUAGEASIAN L"language-asian"
+#define CONTENT_STYLE_PROPERTIES_COUNTRYASIAN L"country-asian"
+
+#endif
diff --git a/shell/inc/internal/contentreader.hxx b/shell/inc/internal/contentreader.hxx
new file mode 100644
index 000000000000..63b0c550c534
--- /dev/null
+++ b/shell/inc/internal/contentreader.hxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CONTENTREADER_HXX_INCLUDED
+#define CONTENTREADER_HXX_INCLUDED
+
+#include "internal/basereader.hxx"
+
+class ITag;
+
+class CContentReader : public CBaseReader
+{
+public:
+ virtual ~CContentReader();
+
+ //CContentReader( const std::string& DocumentName );
+ CContentReader( const std::string& DocumentName, LocaleSet_t const & DocumentLocale );
+
+ CContentReader( void* stream, LocaleSet_t const & DocumentLocale, zlib_filefunc_def* fa );
+
+
+ /** Get the chunkbuffer.
+
+ @return
+ the chunkbuffer of the document.
+ */
+ inline ChunkBuffer_t const & getChunkBuffer( ) const{ return m_ChunkBuffer; };
+
+protected: // protected because its only an implementation relevant class
+
+ /** start_element occurs when a tag is start.
+
+ @param raw_name
+ raw name of the tag.
+ @param local_name
+ local name of the tag.
+ @param attributes
+ attribute structure.
+ */
+ virtual void start_element(
+ const std::wstring& raw_name,
+ const std::wstring& local_name,
+ const XmlTagAttributes_t& attributes);
+
+ /** end_element occurs when a tag is closed
+
+ @param raw_name
+ raw name of the tag.
+ @param local_name
+ local name of the tag.
+ */
+ virtual void end_element(
+ const std::wstring& raw_name, const std::wstring& local_name);
+
+ /** characters occurs when receiving characters
+
+ @param character
+ content of the information received.
+ */
+ virtual void characters(const std::wstring& character);
+
+protected:
+ /** choose an appropriate tag reader to handle the tag.
+
+ @param tag_name
+ the name of the tag.
+ @param XmlAttributes
+ attribute structure of the tag to save in.
+ */
+ ITag* chooseTagReader(
+ const std::wstring& tag_name, const XmlTagAttributes_t& XmlAttributes );
+
+ /** Get the list of style locale pair.
+
+ @return
+ the Style-Locale map
+ */
+ inline StyleLocaleMap_t const & getStyleMap( ) const{ return m_StyleMap; };
+
+ /** get style of the current content.
+
+ @return style of the current content.
+ */
+ ::std::wstring getCurrentContentStyle( void );
+
+ /** add chunk into Chunk Buffer.
+ */
+ void addChunk( LocaleSet_t const & Locale, Content_t const & Content );
+
+ /** get a style's locale field.
+ */
+ LocaleSet_t const & getLocale( const StyleName_t Style );
+
+private:
+ std::stack<ITag*> m_TagBuilderStack;
+
+ ChunkBuffer_t m_ChunkBuffer;
+ StyleLocaleMap_t m_StyleMap;
+ LocaleSet_t m_DefaultLocale;
+};
+
+#endif
diff --git a/shell/inc/internal/dbgmacros.hxx b/shell/inc/internal/dbgmacros.hxx
new file mode 100644
index 000000000000..fbab023664ac
--- /dev/null
+++ b/shell/inc/internal/dbgmacros.hxx
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef DBGMACROS_HXX_INCLUDED
+#define DBGMACROS_HXX_INCLUDED
+
+void DbgAssert(bool condition, const char* message);
+
+#if OSL_DEBUG_LEVEL > 0
+
+ #define PRE_CONDITION(x, msg) DbgAssert(x, msg)
+
+ #define POST_CONDITION(x, msg) DbgAssert(x, msg)
+
+ #define ENSURE(x ,msg) DbgAssert(x, msg)
+
+#else // OSL_DEBUG_LEVEL == 0
+
+ #define PRE_CONDITION(x, msg) ((void)0)
+
+ #define POST_CONDITION(x, msg) ((void)0)
+
+ #define ENSURE(x, msg) ((void)0)
+
+#endif
+
+#endif
diff --git a/shell/inc/internal/fileextensions.hxx b/shell/inc/internal/fileextensions.hxx
new file mode 100644
index 000000000000..48d6f283ea1d
--- /dev/null
+++ b/shell/inc/internal/fileextensions.hxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef FILEEXTENSIONS_HXX_INCLUDED
+#define FILEEXTENSIONS_HXX_INCLUDED
+
+#include "internal/global.hxx"
+
+#include <string>
+
+// A simple table with information about the currently used OO file extensions
+// for instance ".sxw" and information about windows registry keys which are
+// necessary for properly registering of the shell extensions
+
+/** A FileExtensionEntry consists of the extension as ansi and as
+ unicode string and of the currently used registry forward key
+ for this extension
+*/
+struct FileExtensionEntry
+{
+ char* ExtensionAnsi; // e.g. ".sxw"
+ wchar_t* ExtensionUnicode; // e.g. L".sxw"
+ char* RegistryForwardKey; // e.g. "soffice.StarWriterDocument.6"
+};
+
+extern FileExtensionEntry OOFileExtensionTable[];
+
+extern size_t OOFileExtensionTableSize;
+
+//---------------------------------
+/** Return the extension of a file
+ name without the '.'
+*/
+std::string get_file_name_extension(const std::string& file_name);
+
+//---------------------------------
+/** Return the type of a file
+*/
+
+enum File_Type_t { UNKNOWN, WRITER, CALC, DRAW, IMPRESS, MATH, WEB, DATABASE };
+
+File_Type_t get_file_type(const std::string& file_name);
+
+#endif
diff --git a/shell/inc/internal/global.hxx b/shell/inc/internal/global.hxx
new file mode 100644
index 000000000000..ebf3305934bd
--- /dev/null
+++ b/shell/inc/internal/global.hxx
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef GLOBAL_HXX_INCLUDED
+#define GLOBAL_HXX_INCLUDED
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#ifndef OS2
+#include <windows.h>
+#endif
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include "internal/dbgmacros.hxx"
+
+extern long g_DllRefCnt;
+
+#endif
diff --git a/shell/inc/internal/i_xml_parser_event_handler.hxx b/shell/inc/internal/i_xml_parser_event_handler.hxx
new file mode 100644
index 000000000000..5164f2236522
--- /dev/null
+++ b/shell/inc/internal/i_xml_parser_event_handler.hxx
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef I_XML_PARSER_EVENT_HANDLER_HXX_INCLUDED
+#define I_XML_PARSER_EVENT_HANDLER_HXX_INCLUDED
+
+#include <string>
+#include <map>
+
+#if defined(XML_UNICODE) || defined(XML_UNICODE_WCHAR_T)
+ typedef std::wstring string_t;
+ typedef wchar_t char_t;
+#else
+ typedef std::string string_t;
+ typedef char char_t;
+#endif
+
+// name-value container
+typedef std::map<string_t, string_t> xml_tag_attribute_container_t;
+
+
+//#########################################
+class i_xml_parser_event_handler
+{
+public:
+ virtual ~i_xml_parser_event_handler() {};
+
+ virtual void start_document() = 0;
+
+ virtual void end_document() = 0;
+
+ virtual void start_element(
+ const string_t& raw_name,
+ const string_t& local_name,
+ const xml_tag_attribute_container_t& attributes) = 0;
+
+ virtual void end_element(
+ const string_t& raw_name,
+ const string_t& local_name) = 0;
+
+ virtual void characters(
+ const string_t& character) = 0;
+
+ virtual void ignore_whitespace(
+ const string_t& whitespaces) = 0;
+
+ virtual void processing_instruction(
+ const string_t& target, const string_t& data) = 0;
+
+ virtual void comment(const string_t& comment) = 0;
+};
+
+#endif
+
diff --git a/shell/inc/internal/infotips.hxx b/shell/inc/internal/infotips.hxx
new file mode 100644
index 000000000000..8193615a505f
--- /dev/null
+++ b/shell/inc/internal/infotips.hxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INFOTIPS_HXX_INCLUDED
+#define INFOTIPS_HXX_INCLUDED
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable:4917)
+#endif
+#include <objidl.h>
+#include <shlobj.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <string>
+
+class CInfoTip : public IQueryInfo, public IPersistFile
+{
+public:
+ CInfoTip(long RefCnt = 1);
+ virtual ~CInfoTip();
+
+ //-----------------------------
+ // IUnknown methods
+ //-----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(
+ REFIID riid,
+ void __RPC_FAR *__RPC_FAR *ppvObject);
+
+ virtual ULONG STDMETHODCALLTYPE AddRef( void);
+
+ virtual ULONG STDMETHODCALLTYPE Release( void);
+
+ //----------------------------
+ // IQueryInfo methods
+ //----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE GetInfoTip(DWORD dwFlags, wchar_t** ppwszTip);
+
+ virtual HRESULT STDMETHODCALLTYPE GetInfoFlags(DWORD *pdwFlags);
+
+ //----------------------------
+ // IPersist methods
+ //----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID* pClassID);
+
+ //----------------------------
+ // IPersistFile methods
+ //----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE IsDirty(void);
+
+ virtual HRESULT STDMETHODCALLTYPE Load(
+ /* [in] */ LPCOLESTR pszFileName,
+ /* [in] */ DWORD dwMode);
+
+ virtual HRESULT STDMETHODCALLTYPE Save(
+ /* [unique][in] */ LPCOLESTR pszFileName,
+ /* [in] */ BOOL fRemember);
+
+ virtual HRESULT STDMETHODCALLTYPE SaveCompleted(
+ /* [unique][in] */ LPCOLESTR pszFileName);
+
+ virtual HRESULT STDMETHODCALLTYPE GetCurFile(
+ /* [out] */ LPOLESTR __RPC_FAR *ppszFileName);
+
+private:
+ long m_RefCnt;
+ char m_szFileName[MAX_PATH];
+ std::wstring m_FileNameOnly;
+};
+
+#endif
diff --git a/shell/inc/internal/iso8601_converter.hxx b/shell/inc/internal/iso8601_converter.hxx
new file mode 100644
index 000000000000..f7f00bbe1c53
--- /dev/null
+++ b/shell/inc/internal/iso8601_converter.hxx
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef ISO8601_CONVERTER_HXX_INCLUDED
+#define ISO8601_CONVERTER_HXX_INCLUDED
+
+#include <string>
+
+//-----------------------------------
+/* Converts ISO 8601 conform date/time
+ represenation to the representation
+ conforming to the current locale
+*/
+std::wstring iso8601_date_to_local_date(const std::wstring& iso8601date);
+
+//------------------------------------
+/* Converts ISO 8601 conform duration
+ representation to the representation
+ conforming to the current locale
+*/
+std::wstring iso8601_duration_to_local_duration(const std::wstring& iso8601duration);
+
+#endif
diff --git a/shell/inc/internal/metainforeader.hxx b/shell/inc/internal/metainforeader.hxx
new file mode 100755
index 000000000000..ea29dff07c80
--- /dev/null
+++ b/shell/inc/internal/metainforeader.hxx
@@ -0,0 +1,148 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef METAINFOREADER_HXX_INCLUDED
+#define METAINFOREADER_HXX_INCLUDED
+
+#include "internal/basereader.hxx"
+#include "internal/types.hxx"
+
+class ITag;
+class CKeywordsTag;
+class CSimpleTag;
+class CDummyTag;
+
+class CMetaInfoReader : public CBaseReader
+{
+public:
+ virtual ~CMetaInfoReader();
+
+ CMetaInfoReader( const std::string& DocumentName );
+
+ CMetaInfoReader( void* stream, zlib_filefunc_def* fa);
+
+ /** check if the Tag is in the target meta.xml file.
+
+ @param TagName
+ the name of the tag that will be retrive.
+ */
+ bool hasTag(std::wstring TagName) const;
+
+
+ /** Get a specific tag content, compound tags will be returned as comma separated list.
+
+ @param TagName
+ the name of the tag that will be retrive.
+ */
+ std::wstring getTagData( const std::wstring& TagName);
+
+ /** check if the a tag has the specific attribute.
+
+ @param TagName
+ the name of the tag.
+ @param AttributeName
+ the name of the attribute.
+ */
+ bool hasTagAttribute( const std::wstring TagName, std::wstring AttributeName);
+
+ /** Get a specific attribute content.
+
+ @param TagName
+ the name of the tag.
+ @param AttributeName
+ the name of the attribute.
+ */
+ std::wstring getTagAttribute( const std::wstring TagName, std::wstring AttributeName);
+
+ /** Get the default language of the whole document.
+ */
+ LocaleSet_t getDefaultLocale( );
+
+protected: // protected because its only an implementation relevant class
+
+ /** start_element occurs when a tag is start.
+
+ @param raw_name
+ raw name of the tag.
+ @param local_name
+ local name of the tag.
+ @param attributes
+ attribute structure.
+ */
+ virtual void start_element(
+ const std::wstring& raw_name,
+ const std::wstring& local_name,
+ const XmlTagAttributes_t& attributes);
+
+ /** end_element occurs when a tag is closed
+
+ @param raw_name
+ raw name of the tag.
+ @param local_name
+ local name of the tag.
+ */
+ virtual void end_element(
+ const std::wstring& raw_name, const std::wstring& local_name);
+
+ /** characters occurs when receiving characters
+
+ @param character
+ content of the information received.
+ */
+ virtual void characters(const std::wstring& character);
+
+protected:
+ /** choose an appropriate tag reader to handle the tag.
+
+ @param tag_name
+ the name of the tag.
+ @param XmlAttributes
+ attribute structure of the tag to save in.
+ */
+ ITag* chooseTagReader(
+ const std::wstring& tag_name, const XmlTagAttributes_t& XmlAttributes );
+
+ /** save the received content into structure.
+
+ @param tag_name
+ the name of the tag.
+ */
+ void saveTagContent( const std::wstring& tag_name );
+
+private:
+ XmlTags_t m_AllMetaInfo;
+
+private:
+ std::stack<ITag*> m_TagBuilderStack;
+
+private:
+ CKeywordsTag* m_pKeywords_Builder;
+ CDummyTag* m_pDummy_Builder;
+ CSimpleTag* m_pSimple_Builder;
+};
+
+#endif
diff --git a/shell/inc/internal/propertyhdl.hxx b/shell/inc/internal/propertyhdl.hxx
new file mode 100755
index 000000000000..6379fdf0137b
--- /dev/null
+++ b/shell/inc/internal/propertyhdl.hxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: PropertyHdl.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef PROPERTYHDL_HXX_INCLUDED
+#define PROPERTYHDL_HXX_INCLUDED
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable:4917)
+#endif
+#include <shlobj.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+// {AE424E85-F6DF-4910-A6A9-438797986431}
+const CLSID CLSID_PROPERTY_HANDLER =
+{ 0xae424e85, 0xf6df, 0x4910, { 0xa6, 0xa9, 0x43, 0x87, 0x97, 0x98, 0x64, 0x31 } };
+
+class CMetaInfoReader;
+
+class CPropertyHdl : public IPropertyStore,
+ public IPropertyStoreCapabilities,
+ public IInitializeWithStream
+{
+public:
+ CPropertyHdl(long RefCnt = 1);
+ virtual ~CPropertyHdl();
+
+ //-----------------------------
+ // IUnknown methods
+ //-----------------------------
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(
+ REFIID riid,
+ void __RPC_FAR *__RPC_FAR *ppvObject );
+ virtual ULONG STDMETHODCALLTYPE AddRef( void );
+ virtual ULONG STDMETHODCALLTYPE Release( void );
+
+ //-----------------------------
+ // IPropertyStore
+ //-----------------------------
+ virtual HRESULT STDMETHODCALLTYPE GetCount( DWORD *pcProps );
+ virtual HRESULT STDMETHODCALLTYPE GetAt( DWORD iProp, PROPERTYKEY *pkey );
+ virtual HRESULT STDMETHODCALLTYPE GetValue( REFPROPERTYKEY key, PROPVARIANT *pPropVar );
+ virtual HRESULT STDMETHODCALLTYPE SetValue( REFPROPERTYKEY key, REFPROPVARIANT propVar );
+ virtual HRESULT STDMETHODCALLTYPE Commit();
+
+ //-----------------------------
+ // IPropertyStoreCapabilities
+ //-----------------------------
+ virtual HRESULT STDMETHODCALLTYPE IsPropertyWritable( REFPROPERTYKEY key );
+
+ //-----------------------------
+ // IInitializeWithStream
+ //-----------------------------
+ virtual HRESULT STDMETHODCALLTYPE Initialize(IStream *pStream, DWORD grfMode);
+
+private:
+ void LoadProperties( CMetaInfoReader *pMetaInfoReader );
+ HRESULT GetItemData( CMetaInfoReader *pMetaInfoReader, UINT nIndex, PROPVARIANT *pVarData );
+
+private:
+ long m_RefCnt;
+ IPropertyStoreCache* m_pCache;
+};
+
+class CClassFactory : public IClassFactory
+{
+public:
+ CClassFactory( const CLSID& clsid );
+ virtual ~CClassFactory();
+
+ //-----------------------------
+ // IUnknown methods
+ //-----------------------------
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(
+ REFIID riid,
+ void __RPC_FAR *__RPC_FAR *ppvObject);
+ virtual ULONG STDMETHODCALLTYPE AddRef( void );
+ virtual ULONG STDMETHODCALLTYPE Release( void );
+
+ //-----------------------------
+ // IClassFactory methods
+ //-----------------------------
+ virtual HRESULT STDMETHODCALLTYPE CreateInstance(
+ IUnknown __RPC_FAR *pUnkOuter,
+ REFIID riid,
+ void __RPC_FAR *__RPC_FAR *ppvObject);
+
+ virtual HRESULT STDMETHODCALLTYPE LockServer( BOOL fLock );
+ static bool IsLocked();
+
+private:
+ long m_RefCnt;
+ CLSID m_Clsid;
+ static long s_ServerLocks;
+};
+
+#endif
diff --git a/shell/inc/internal/propsheets.hxx b/shell/inc/internal/propsheets.hxx
new file mode 100644
index 000000000000..0159379e3127
--- /dev/null
+++ b/shell/inc/internal/propsheets.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef PROPSHEETS_HXX_INCLUDED
+#define PROPSHEETS_HXX_INCLUDED
+
+#include "internal/metainforeader.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <shlobj.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <string>
+#include <memory>
+
+class CPropertySheet : public IShellExtInit, public IShellPropSheetExt
+{
+public:
+ CPropertySheet(long RefCnt = 1);
+
+ virtual ~CPropertySheet();
+
+ //-----------------------------
+ // IUnknown methods
+ //-----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(
+ REFIID riid,
+ void __RPC_FAR *__RPC_FAR *ppvObject);
+
+ virtual ULONG STDMETHODCALLTYPE AddRef( void);
+
+ virtual ULONG STDMETHODCALLTYPE Release( void);
+
+ //-----------------------------
+ // IShellExtInit
+ //-----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE Initialize(
+ LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY hkeyProgID);
+
+ //-----------------------------
+ // IShellPropSheetExt
+ //-----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam);
+
+ virtual HRESULT STDMETHODCALLTYPE ReplacePage(
+ UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam);
+
+private:
+ // Windows callback functions
+ static UINT CALLBACK PropPageSummaryCallback(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp);
+ static BOOL CALLBACK PropPageSummaryProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+ static BOOL CALLBACK PropPageStatisticsProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+
+
+ // Helper functions
+ void InitPropPageSummary(HWND hwnd, LPPROPSHEETPAGE lppsp);
+ void InitPropPageStatistics(HWND hwnd, LPPROPSHEETPAGE lppsp);
+
+private:
+ long m_RefCnt;
+ char m_szFileName[MAX_PATH];
+};
+
+#endif
diff --git a/shell/inc/internal/registry.hxx b/shell/inc/internal/registry.hxx
new file mode 100644
index 000000000000..25f1749a6a3c
--- /dev/null
+++ b/shell/inc/internal/registry.hxx
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef REGISTRY_HXX_INCLUDED
+#define REGISTRY_HXX_INCLUDED
+
+//-----------------------------
+// registry helper functions
+//-----------------------------
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <objbase.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <string>
+
+/** Sets a value of the specified registry key, an empty ValueName sets the default
+ value
+ Returns true on success
+*/
+bool SetRegistryKey(HKEY RootKey, const char* KeyName, const char* ValueName, const char* Value);
+
+/** Deletes the specified registry key and all of its subkeys
+ Returns true on success
+*/
+bool DeleteRegistryKey(HKEY RootKey, const char* KeyName);
+
+/** May be used to determine if the specified registry key has subkeys
+ The function returns true on success else if an error occures false
+*/
+bool HasSubkeysRegistryKey(HKEY RootKey, const char* KeyName, bool& bResult);
+
+/** Converts a GUID to its string representation
+*/
+std::string ClsidToString(const CLSID& clsid);
+
+/** Get the content of a specific key.
+*/
+bool QueryRegistryKey(HKEY RootKey, const char* KeyName, const char* ValueName, char *pszData, DWORD dwBufLen);
+
+
+#endif
diff --git a/shell/inc/internal/resource.h b/shell/inc/internal/resource.h
new file mode 100644
index 000000000000..3685ac5f66fc
--- /dev/null
+++ b/shell/inc/internal/resource.h
@@ -0,0 +1,57 @@
+#ifndef RESOURCE_H_INCLUDED
+#define RESOURCE_H_INCLUDED
+
+#define MANIFEST_RESOURCE_ID 2
+#define IDD_PROPPAGE_STATISTICS 101
+#define IDD_PROPPAGE_SUMMARY 102
+#define IDB_PROPERTY_IMAGES 103
+#define IDC_TITLE 1000
+#define IDC_SUBJECT 1001
+#define IDC_AUTHOR 1002
+#define IDC_CREATOR 1003
+#define IDC_LANGUAGE 1004
+#define IDC_COMMENTS 1005
+#define IDC_KEYWORDS 1006
+#define IDC_EXTENDED 1009
+#define IDC_DLGSIMPLE 1012
+#define IDC_STATISTICSLIST 1013
+
+#define IDS_TITLE 1014
+#define IDS_SUBJECT 1015
+#define IDS_AUTHOR 1016
+#define IDS_KEYWORDS 1017
+#define IDS_COMMENTS 1018
+#define IDS_PAGES 1019
+#define IDS_TABLES 1020
+#define IDS_GRAPHICS 1021
+#define IDS_OLE_OBJECTS 1022
+#define IDS_PARAGRAPHS 1023
+#define IDS_WORDS 1024
+#define IDS_CHARACTERS 1025
+#define IDS_ROWS 1026
+#define IDS_ORIGIN 1027
+#define IDS_VERSION 1028
+#define IDS_SHEETS 1029
+#define IDS_CELLS 1030
+#define IDS_STATISTICS 1031
+#define IDS_PROPERTY 1032
+#define IDS_PROPERTY_VALUE 1033
+#define IDS_PROPPAGE_SUMMARY_TITLE 1034
+#define IDS_PROPPAGE_STATISTICS_TITLE 1035
+#define IDS_TITLE_COLON 1036
+#define IDS_SUBJECT_COLON 1037
+#define IDS_AUTHOR_COLON 1038
+#define IDS_OBJECTS 1039
+#define IDS_DOCUMENT_STATISTIC 1040
+#define IDS_MODIFIED 1041
+#define IDS_DOCUMENT_NUMBER 1042
+#define IDS_EDITING_TIME 1043
+#define IDS_DESCRIPTION 1044
+#define IDS_COMMENTS_COLON 1045
+#define IDS_MODIFIED_COLON 1046
+#define IDS_SIZE_COLON 1047
+#define IDS_TYPE_COLON 1048
+
+#define IDP_SIGNET 2000
+
+#endif
diff --git a/shell/inc/internal/shlxthdl.hxx b/shell/inc/internal/shlxthdl.hxx
new file mode 100755
index 000000000000..b13a142b6e2c
--- /dev/null
+++ b/shell/inc/internal/shlxthdl.hxx
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SHLXTHDL_HXX_INCLUDED
+#define SHLXTHDL_HXX_INCLUDED
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <objbase.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+// {087B3AE3-E237-4467-B8DB-5A38AB959AC9}
+const CLSID CLSID_INFOTIP_HANDLER =
+{0x87b3ae3, 0xe237, 0x4467, {0xb8, 0xdb, 0x5a, 0x38, 0xab, 0x95, 0x9a, 0xc9}};
+
+// {C52AF81D-F7A0-4aab-8E87-F80A60CCD396}
+const CLSID CLSID_COLUMN_HANDLER =
+{ 0xc52af81d, 0xf7a0, 0x4aab, { 0x8e, 0x87, 0xf8, 0xa, 0x60, 0xcc, 0xd3, 0x96 } };
+
+// {63542C48-9552-494a-84F7-73AA6A7C99C1}
+const CLSID CLSID_PROPERTYSHEET_HANDLER =
+{ 0x63542c48, 0x9552, 0x494a, { 0x84, 0xf7, 0x73, 0xaa, 0x6a, 0x7c, 0x99, 0xc1 } };
+
+// {3B092F0C-7696-40e3-A80F-68D74DA84210}
+const CLSID CLSID_THUMBVIEWER_HANDLER =
+{ 0x3b092f0c, 0x7696, 0x40e3, { 0xa8, 0xf, 0x68, 0xd7, 0x4d, 0xa8, 0x42, 0x10 } };
+
+#endif
diff --git a/shell/inc/internal/stream_helper.hxx b/shell/inc/internal/stream_helper.hxx
new file mode 100755
index 000000000000..2ef4529b54ce
--- /dev/null
+++ b/shell/inc/internal/stream_helper.hxx
@@ -0,0 +1,35 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2010 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef STREAM_HELPER_HXX_INCLUDED
+#define STREAM_HELPER_HXX_INCLUDED
+
+#include "internal/types.hxx"
+
+IStream* PrepareIStream( IStream* pStream, zlib_filefunc_def &zFileFunc );
+
+#endif
diff --git a/shell/inc/internal/thumbviewer.hxx b/shell/inc/internal/thumbviewer.hxx
new file mode 100644
index 000000000000..8c4a8979a181
--- /dev/null
+++ b/shell/inc/internal/thumbviewer.hxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef THUMBVIEWER_HXX_INCLUDED
+#define THUMBVIEWER_HXX_INCLUDED
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable:4917)
+#endif
+#include <objidl.h>
+#include <shlobj.h>
+#ifdef __MINGW32__
+#include <algorithm>
+using std::min;
+using std::max;
+#endif
+#include <gdiplus.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <string>
+
+class CThumbviewer : public IPersistFile, public IExtractImage
+{
+public:
+ CThumbviewer(long RefCnt = 1);
+ virtual ~CThumbviewer();
+
+ //-----------------------------
+ // IUnknown methods
+ //-----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(
+ REFIID riid,
+ void __RPC_FAR *__RPC_FAR *ppvObject);
+
+ virtual ULONG STDMETHODCALLTYPE AddRef( void);
+
+ virtual ULONG STDMETHODCALLTYPE Release( void);
+
+ //----------------------------
+ // IExtractImage methods
+ //----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE Extract(HBITMAP *phBmpImage);
+
+ virtual HRESULT STDMETHODCALLTYPE GetLocation(
+ LPWSTR pszPathBuffer,
+ DWORD cchMax,
+ DWORD *pdwPriority,
+ const SIZE *prgSize,
+ DWORD dwRecClrDepth,
+ DWORD *pdwFlags);
+
+ //----------------------------
+ // IPersist methods
+ //----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID* pClassID);
+
+ //----------------------------
+ // IPersistFile methods
+ //----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE IsDirty();
+
+ virtual HRESULT STDMETHODCALLTYPE Load(
+ /* [in] */ LPCOLESTR pszFileName,
+ /* [in] */ DWORD dwMode);
+
+ virtual HRESULT STDMETHODCALLTYPE Save(
+ /* [unique][in] */ LPCOLESTR pszFileName,
+ /* [in] */ BOOL fRemember);
+
+ virtual HRESULT STDMETHODCALLTYPE SaveCompleted(
+ /* [unique][in] */ LPCOLESTR pszFileName);
+
+ virtual HRESULT STDMETHODCALLTYPE GetCurFile(
+ /* [out] */ LPOLESTR __RPC_FAR *ppszFileName);
+
+private:
+ Gdiplus::Rect CalcScaledAspectRatio(Gdiplus::Rect src, Gdiplus::Rect dest);
+
+private:
+ long ref_count_;
+ std::wstring filename_;
+ SIZE thumbnail_size_;
+ DWORD color_depth_;
+ ULONG_PTR gdiplus_token_;
+ Gdiplus::Bitmap* signet_;
+};
+
+#endif
diff --git a/shell/inc/internal/types.hxx b/shell/inc/internal/types.hxx
new file mode 100644
index 000000000000..c11692912aec
--- /dev/null
+++ b/shell/inc/internal/types.hxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef TYPES_HXX_INCLUDED
+#define TYPES_HXX_INCLUDED
+
+#include <string>
+#include <map>
+#include <utility>
+#include <vector>
+#include <stack>
+#include <external/zlib/zlib.h>
+#include <external/zlib/ioapi.h>
+
+
+typedef std::vector<std::wstring> StringList_t;
+
+//+-------------------------------------------------------------------------
+//
+// Declare: XmlTagAttributes_t, xml tag attribute struct
+// XmlTag_t, xml tag including content and attributes.
+// XmlTags_t, tags defined with tag name and xml tag.
+//
+// Contents: Definitions of xml tag used in parser.
+//
+//--------------------------------------------------------------------------
+typedef std::wstring Name_t;
+typedef std::wstring Value_t;
+typedef std::wstring Characters_t;
+
+typedef std::map<Name_t, Value_t> XmlTagAttributes_t;
+typedef std::pair<Characters_t, XmlTagAttributes_t> XmlTag_t;
+typedef std::map<Name_t, XmlTag_t> XmlTags_t;
+
+const XmlTag_t EMPTY_XML_TAG = std::make_pair(std::wstring(), XmlTagAttributes_t());
+
+//+-------------------------------------------------------------------------
+//
+// Declare: Language_t, language of the Locale pair
+// Country_t, country of the Local pair
+// LocaleSet_t, Local pair
+//
+// Contents: Definitions of Chunk properties.
+//
+//--------------------------------------------------------------------------
+typedef ::std::wstring Language_t;
+typedef ::std::wstring Country_t;
+typedef ::std::pair<Language_t, Country_t > LocaleSet_t;
+
+typedef ::std::wstring Content_t;
+typedef ::std::pair<LocaleSet_t, Content_t > Chunk_t;
+typedef ::std::vector< Chunk_t > ChunkBuffer_t;
+
+const LocaleSet_t EMPTY_LOCALE = ::std::make_pair(::std::wstring(), ::std::wstring());
+const Chunk_t EMPTY_CHUNK = ::std::make_pair( EMPTY_LOCALE, ::std::wstring());
+
+//+-------------------------------------------------------------------------
+//
+// Declare: StyleName_t, style name of a style-locale pair.
+// StyleLocaleMap, the map of Styple-Locale pair.
+//
+// Contents: Definitions of Style Names.
+//
+//--------------------------------------------------------------------------
+typedef ::std::wstring StyleName_t;
+typedef ::std::pair <StyleName_t, LocaleSet_t> StyleLocalePair_t;
+typedef ::std::map<StyleName_t, LocaleSet_t> StyleLocaleMap_t;
+
+const StyleLocalePair_t EMPTY_STYLELOCALE_PAIR = ::std::make_pair(::std::wstring(), EMPTY_LOCALE );
+
+#endif
diff --git a/shell/inc/internal/utilities.hxx b/shell/inc/internal/utilities.hxx
new file mode 100755
index 000000000000..4701a2682446
--- /dev/null
+++ b/shell/inc/internal/utilities.hxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef UTILITIES_HXX_INCLUDED
+#define UTILITIES_HXX_INCLUDED
+
+#include <malloc.h>
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#ifndef OS2
+#include <windows.h>
+#endif
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <stdio.h>
+#include <fcntl.h>
+#include <io.h>
+#include "internal/types.hxx"
+
+#include <string>
+#define STRSAFE_NO_DEPRECATE
+#include <strsafe.h>
+
+//---------------------------------
+/** Convert a string to a wstring
+ using CP_ACP
+*/
+std::wstring StringToWString(const std::string& String);
+
+//---------------------------------
+/** Convert a wstring to a string
+ using CP_ACP
+*/
+std::string WStringToString(const std::wstring& String);
+
+//---------------------------------
+/** Retrieve a string from the
+ resources of this module
+*/
+std::wstring GetResString(int ResId);
+
+//---------------------------------
+/** Returns whether we are running
+ on Windows XP or not
+*/
+bool is_windows_xp_or_above();
+
+//---------------------------------
+/** helper function to judge if the string is only has spaces.
+ @returns
+ <TRUE>if the provided string contains only but at least one space
+ character else <FALSE/>.
+*/
+bool HasOnlySpaces(const std::wstring& String);
+
+/** convert LocaleSet pair into Windows LCID identifier.
+ @returns
+ Windows Locale Identifier corresponding to input LocaleSet.
+*/
+
+#ifndef OS2
+LCID LocaleSetToLCID( const LocaleSet_t & Locale );
+#endif
+
+//----------------------------------------------------------
+#ifdef DEBUG
+inline void OutputDebugStringFormat( LPCSTR pFormat, ... )
+{
+ CHAR buffer[1024];
+ va_list args;
+
+ va_start( args, pFormat );
+ StringCchVPrintfA( buffer, sizeof(buffer), pFormat, args );
+ OutputDebugStringA( buffer );
+}
+#else
+static inline void OutputDebugStringFormat( LPCSTR, ... )
+{
+}
+#endif
+//----------------------------------------------------------
+
+
+#endif
diff --git a/shell/inc/internal/xml_parser.hxx b/shell/inc/internal/xml_parser.hxx
new file mode 100644
index 000000000000..57e8a4fd6d88
--- /dev/null
+++ b/shell/inc/internal/xml_parser.hxx
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _XML_PARSER_HXX_
+#define _XML_PARSER_HXX_
+
+#include <expat.h>
+#include <stdexcept>
+
+//-----------------------------------------------------
+class xml_parser_exception : public std::runtime_error
+{
+public:
+
+ xml_parser_exception(
+ const std::string& error_msg,
+ int error_code,
+ int line_number,
+ int column_number,
+ long byte_index) :
+ std::runtime_error(error_msg),
+ error_code_(error_code),
+ line_number_(line_number),
+ column_number_(column_number),
+ byte_index_(byte_index)
+ {}
+
+ int error_code_;
+ int line_number_;
+ int column_number_;
+ long byte_index_;
+};
+
+
+//-----------------------------------------------------
+// Simple wrapper around expat, the xml parser library
+// created by James Clark
+//-----------------------------------------------------
+class i_xml_parser_event_handler;
+
+class xml_parser
+{
+public:
+ //########################################################
+ xml_parser(const XML_Char* EncodingName = 0);
+
+ //########################################################
+ ~xml_parser();
+
+ //########################################################
+ /** Parse a XML data stream
+
+ @param pXmlData
+ Pointer to a buffer containing the xml data
+
+ @param Length
+ Length of the buffer containing the xml data
+
+ @param IsFinal
+ Indicates whether these are the last xml data
+ of an xml document to parse. For very large
+ xml documents it may be usefull to read and
+ parse the document partially.
+
+ @precond XmlData must not be null
+
+ @throws SaxException
+ If the used Sax parser returns an error. The SaxException
+ contains detailed information about the error. */
+ void parse(const char* XmlData, size_t Length, bool IsFinal = true);
+
+ //########################################################
+ /** Set a document handler
+
+ @descr A document handler implements the interface i_xml_parser_event_handler.
+ The document handler receive notifications of various events
+ from the sax parser for instance "start_document".
+
+ The client is responsible for the life time management of
+ the given document handler, that means the document handler
+ instance must exist until a new one was set or until the parser
+ no longer exist.
+
+ @param SaxDocumentHandler
+ The new document handler, may be null if not interessted in
+ sax parser events.
+
+ @postcond currently used document handler == pSaxDocumentHandler */
+ void set_document_handler(i_xml_parser_event_handler* event_handler);
+
+ //########################################################
+ /** Returns the currently used document handler or null if
+ no document handler was set before. */
+ i_xml_parser_event_handler* get_document_handler() const;
+private:
+
+ void init();
+
+private:
+ i_xml_parser_event_handler* document_handler_;
+ XML_Parser xml_parser_;
+
+// prevent copy and assignment
+private:
+ xml_parser(const xml_parser&);
+ xml_parser& operator=(const xml_parser&);
+};
+
+#endif
+
diff --git a/shell/inc/internal/zipfile.hxx b/shell/inc/internal/zipfile.hxx
new file mode 100644
index 000000000000..a3e3575082c0
--- /dev/null
+++ b/shell/inc/internal/zipfile.hxx
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef ZIPFILE_HXX_INCLUDED
+#define ZIPFILE_HXX_INCLUDED
+
+#ifndef _WINDOWS
+#define _WINDOWS
+#endif
+
+
+#include <external/zlib/unzip.h>
+
+
+#include <string>
+#include <vector>
+#include <memory>
+
+/** A simple zip content provider based on the zlib
+*/
+
+class ZipFile
+{
+public:
+
+ typedef std::vector<std::string> Directory_t;
+ typedef std::auto_ptr<Directory_t> DirectoryPtr_t;
+ typedef std::vector<char> ZipContentBuffer_t;
+
+public:
+
+ /** Checks whether a file is a zip file or not
+
+ @precond The given parameter must be a string with length > 0
+ The file must exist
+ The file must be readable for the current user
+
+ @returns true if the file is a zip file
+ false if the file is not a zip file
+
+ @throws ParameterException if the given file name is empty
+ IOException if the specified file doesn't exist
+ AccessViolationException if read access to the file is denied
+ */
+ static bool IsZipFile(const std::string& FileName);
+
+ static bool IsZipFile(void* stream);
+
+
+ /** Returns wheter the version of the specified zip file may be uncompressed with the
+ currently used zlib version or not
+
+ @precond The given parameter must be a string with length > 0
+ The file must exist
+ The file must be readable for the current user
+ The file must be a valid zip file
+
+ @returns true if the file may be uncompressed with the currently used zlib
+ false if the file may not be uncompressed with the currently used zlib
+
+ @throws ParameterException if the given file name is empty
+ IOException if the specified file doesn't exist or is no zip file
+ AccessViolationException if read access to the file is denied
+ */
+ static bool IsValidZipFileVersionNumber(const std::string& FileName);
+
+ static bool IsValidZipFileVersionNumber(void* stream);
+
+public:
+
+ /** Constructs a zip file from a zip file
+
+ @precond The given parameter must be a string with length > 0
+ The file must exist
+ The file must be readable for the current user
+
+ @throws ParameterException if the given file name is empty
+ IOException if the specified file doesn't exist or is no valid zip file
+ AccessViolationException if read access to the file is denied
+ WrongZipVersionException if the zip file cannot be uncompressed
+ with the used zlib version
+ */
+ ZipFile(const std::string& FileName);
+
+ ZipFile(void* stream, zlib_filefunc_def* fa);
+
+
+ /** Destroys a zip file
+ */
+ ~ZipFile();
+
+ /** Provides an interface to read the uncompressed data of a content of the zip file
+
+ @param ContentName
+ The name of the content in the zip file
+
+ @param ppstm
+ Pointer to pointer, will receive an interface pointer
+ to IUnknown on success
+
+ @precond The specified content must exist in this file
+ ppstm must not be NULL
+
+ @throws std::bad_alloc if the necessary buffer could not be
+ allocated
+ ZipException if an zip error occurs
+ ZipContentMissException if the specified zip content
+ does not exist in this zip file
+ */
+ void GetUncompressedContent(const std::string& ContentName, /*inout*/ ZipContentBuffer_t& ContentBuffer);
+
+ /** Returns a list with the content names contained within this file
+
+ @throws ZipException if an error in the zlib happens
+ */
+ DirectoryPtr_t GetDirectory() const;
+
+ /** Convinience query function may even realized with
+ iterating over a ZipFileDirectory returned by
+ GetDirectory
+ */
+ bool HasContent(const std::string& ContentName) const;
+
+private:
+
+ /** Returns the length of the longest file name
+ in the current zip file
+
+ @throws ZipException if an zip error occurs
+ */
+ long GetFileLongestFileNameLength() const;
+
+private:
+ unzFile m_uzFile;
+};
+
+#endif
+
diff --git a/shell/inc/kde_headers.h b/shell/inc/kde_headers.h
new file mode 100644
index 000000000000..772a5382fe81
--- /dev/null
+++ b/shell/inc/kde_headers.h
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_VCL_KDE_HEADERS_H
+#define INCLUDED_VCL_KDE_HEADERS_H
+
+/* ********* Suppress warnings if needed */
+#include "sal/config.h"
+
+#if defined __GNUC__
+#pragma GCC system_header
+#endif
+
+
+/* ********* Hack, but needed because of conflicting types... */
+#define Region QtXRegion
+
+
+/* ********* Qt headers */
+#include <qaccessible.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qfont.h>
+#include <qframe.h>
+#include <qlineedit.h>
+#include <qlistview.h>
+#include <qmainwindow.h>
+#include <qmenudata.h>
+#include <qpaintdevice.h>
+#include <qpainter.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qrangecontrol.h>
+#include <qstring.h>
+#include <qtabbar.h>
+#include <qtabwidget.h>
+#include <qtoolbar.h>
+#include <qtoolbutton.h>
+#include <qwidget.h>
+#include <qprogressbar.h>
+
+/* ********* See hack on top of this file */
+#undef Region
+
+
+/* ********* KDE base headers */
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kconfig.h>
+#include <kdeversion.h>
+#include <kemailsettings.h>
+#include <kglobal.h>
+#include <kglobalsettings.h>
+#include <klocale.h>
+#include <kmainwindow.h>
+#include <kmenubar.h>
+#include <kprotocolmanager.h>
+#include <kstartupinfo.h>
+#include <kstyle.h>
+
+
+/* ********* KDE address book connectivity headers */
+#include <kabc/addressbook.h>
+#include <kabc/addressee.h>
+#include <kabc/field.h>
+#include <kabc/stdaddressbook.h>
+
+
+#endif
diff --git a/shell/inc/makefile.mk b/shell/inc/makefile.mk
new file mode 100644
index 000000000000..c297cb4f77e9
--- /dev/null
+++ b/shell/inc/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=shell
+TARGET=inc
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.IF "$(ENABLE_PCH)"!=""
+ALLTAR : \
+ $(SLO)$/precompiled.pch \
+ $(SLO)$/precompiled_ex.pch
+
+.ENDIF # "$(ENABLE_PCH)"!=""
+
diff --git a/shell/inc/pch/precompiled_shell.cxx b/shell/inc/pch/precompiled_shell.cxx
new file mode 100644
index 000000000000..778ff4e4578e
--- /dev/null
+++ b/shell/inc/pch/precompiled_shell.cxx
@@ -0,0 +1,29 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_shell.hxx"
+
diff --git a/shell/inc/pch/precompiled_shell.hxx b/shell/inc/pch/precompiled_shell.hxx
new file mode 100644
index 000000000000..a3ea4e27b4bb
--- /dev/null
+++ b/shell/inc/pch/precompiled_shell.hxx
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): Generated on 2006-09-01 17:50:00.670510
+
+#ifdef PRECOMPILED_HEADERS
+#endif
+
diff --git a/shell/prj/build.lst b/shell/prj/build.lst
new file mode 100755
index 000000000000..9a5bf35dde3f
--- /dev/null
+++ b/shell/prj/build.lst
@@ -0,0 +1,34 @@
+sl shell : l10n offuh rdbmaker tools sal EXPAT:expat NULL
+sl shell\inc nmake - all sl_inc NULL
+sl shell\source\win32 nmake - w sl_win32 sl_inc NULL
+sl shell\source\win32\simplemail nmake - w sl_win32_simplemail sl_inc NULL
+sl shell\source\unix\exec nmake - u sl_unix sl_inc NULL
+sl shell\source\unix\exec nmake - p sl_unix sl_inc NULL
+sl shell\source\unix\misc nmake - u sl_unix_misc sl_inc NULL
+sl shell\source\unix\misc nmake - p sl_unix_misc sl_inc NULL
+sl shell\source\cmdmail nmake - u sl_cmdmail sl_inc NULL
+sl shell\source\cmdmail nmake - p sl_cmdmail sl_inc NULL
+sl shell\source\all nmake - all sl_all sl_inc NULL
+sl shell\source\unix\sysshell nmake - u sl_unix_sysshell sl_all sl_inc NULL
+sl shell\source\tools\lngconvex nmake - w sl_win32_lngconv sl_inc NULL
+sl shell\source\tools\regsvrex nmake - w sl_win32_regsvrex sl_inc NULL
+sl shell\source\all\zipfile nmake - w sl_all_zipfile sl_inc NULL
+sl shell\source\all\zipfile nmake - p sl_all_zipfile sl_inc NULL
+sl shell\source\all\ooofilereader nmake - w sl_all_ooofilereader sl_all_zipfile.w sl_all sl_inc NULL
+sl shell\source\all\ooofilereader nmake - p sl_all_ooofilereader sl_all_zipfile.w sl_all sl_inc NULL
+sl shell\source\win32\shlxthandler\res nmake - w sl_win32_shlxthandler_res sl_win32_lngconv.w sl_inc NULL
+sl shell\source\win32\shlxthandler\util nmake - w sl_win32_shlxthandler_util sl_inc NULL
+sl shell\source\win32\shlxthandler\propsheets nmake - w sl_win32_shlxthandler_propsheets sl_inc NULL
+sl shell\source\win32\shlxthandler\infotips nmake - w sl_win32_shlxthandler_infotips sl_inc NULL
+sl shell\source\win32\shlxthandler\columninfo nmake - w sl_win32_shlxthandler_columninfo sl_inc NULL
+sl shell\source\win32\shlxthandler\thumbviewer nmake - w sl_win32_shlxthandler_thumbviewer sl_inc NULL
+sl shell\source\win32\shlxthandler\prophdl nmake - w sl_win32_shlxthandler_prophdl sl_win32_shlxthandler_ooofilt.w sl_inc NULL
+sl shell\source\win32\shlxthandler nmake - w sl_win32_shlxthandler sl_win32_lngconv.w sl_win32_shlxthandler_res.w sl_win32_shlxthandler_util.w sl_all_zipfile.w sl_all_ooofilereader.w sl_win32_shlxthandler_propsheets.w sl_win32_shlxthandler_infotips.w sl_win32_shlxthandler_columninfo.w sl_win32_shlxthandler_thumbviewer.w sl_win32_shlxthandler_prophdl.w sl_inc sl_win32_shlxthandler_ooofilt.w NULL
+sl shell\source\backends\localebe nmake - all sl_backends_localebe sl_inc NULL
+sl shell\source\backends\wininetbe nmake - w sl_backends_wininetbe sl_inc NULL
+sl shell\source\backends\macbe nmake - u sl_backends_macbe sl_inc NULL
+sl shell\source\backends\gconfbe nmake - u sl_backends_gconfbe sl_inc NULL
+sl shell\source\backends\kdebe nmake - u sl_backends_kdebe sl_inc NULL
+sl shell\source\backends\kde4be nmake - u sl_backends_kde4be sl_inc NULL
+sl shell\source\backends\desktopbe nmake - u sl_backends_desktopbe sl_inc NULL
+sl shell\source\win32\shlxthandler\ooofilt nmake - w sl_win32_shlxthandler_ooofilt sl_all_zipfile.w sl_all_ooofilereader.w sl_win32_shlxthandler_util.w sl_all sl_inc NULL
diff --git a/shell/prj/d.lst b/shell/prj/d.lst
new file mode 100644
index 000000000000..ea8be0bbaf04
--- /dev/null
+++ b/shell/prj/d.lst
@@ -0,0 +1,25 @@
+..\%__SRC%\slb\*.lib %_DEST%\lib%_EXT%\*.lib
+..\%__SRC%\slb\*.a %_DEST%\lib%_EXT%\*.a
+..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT%
+..\%__SRC%\lib\*.uno.so %_DEST%\lib%_EXT%\*.uno.so
+..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll
+..\%__SRC%\bin\*.exe %_DEST%\bin%_EXT%\*.exe
+..\%__SRC%\bin\x64\shlxthdl.dll %_DEST%\bin%_EXT%\shlxthdl_x64.dll
+..\%__SRC%\bin\x64\ooofiltproxy.dll %_DEST%\bin%_EXT%\ooofiltproxy_x64.dll
+..\%__SRC%\bin\x64\ooofilt.dll %_DEST%\bin%_EXT%\ooofilt_x64.dll
+..\%__SRC%\bin\x64\propertyhdl.dll %_DEST%\bin%_EXT%\propertyhdl_x64.dll
+..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
+..\%__SRC%\lib\*.a %_DEST%\lib%_EXT%\*.a
+
+..\%__SRC%\bin\open-url %_DEST%\bin%_EXT%\open-url
+..\%__SRC%\bin\cde-open-url %_DEST%\bin%_EXT%\cde-open-url
+..\%__SRC%\bin\kde-open-url %_DEST%\bin%_EXT%\kde-open-url
+..\%__SRC%\bin\gnome-open-url %_DEST%\bin%_EXT%\gnome-open-url
+..\%__SRC%\bin\gnome-open-url.bin %_DEST%\bin%_EXT%\gnome-open-url.bin
+..\%__SRC%\bin\senddoc %_DEST%\bin%_EXT%\senddoc
+..\%__SRC%\bin\uri-encode %_DEST%\bin%_EXT%\uri-encode
+
+..\%__SRC%\misc\*.xml %_DEST%\xml%_EXT%\*.xml
+
+..\%__SRC%\misc\*-ucd.txt %_DEST%\bin%_EXT%\*-ucd.txt
+..\inc\kde_headers.h %_DEST%\inc%_EXT%\shell\kde_headers.h
diff --git a/shell/qa/i_xml_parser_event_handler.hxx b/shell/qa/i_xml_parser_event_handler.hxx
new file mode 100644
index 000000000000..1758e2075b55
--- /dev/null
+++ b/shell/qa/i_xml_parser_event_handler.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _I_XML_PARSER_EVENT_HANDLER_HXX_
+#define _I_XML_PARSER_EVENT_HANDLER_HXX_
+
+#include <string>
+#include <map>
+#include <utility>
+
+#if defined(XML_UNICODE) || defined(XML_UNICODE_WCHAR_T)
+ typedef std::wstring string_t;
+#else
+ typedef std::string string_t;
+#endif
+
+// name-value container
+typedef std::map<string_t, string_t> xml_tag_attribute_container_t;
+
+
+//#########################################
+class i_xml_parser_event_handler
+{
+public:
+ virtual ~i_xml_parser_event_handler() {};
+
+ virtual void start_document() = 0;
+
+ virtual void end_document() = 0;
+
+ virtual void start_element(
+ const string_t& raw_name,
+ const string_t& local_name,
+ const xml_tag_attribute_container_t& attributes) = 0;
+
+ virtual void end_element(
+ const string_t& raw_name,
+ const string_t& local_name) = 0;
+
+ virtual void characters(
+ const string_t& character) = 0;
+
+ virtual void ignore_whitespace(
+ const string_t& whitespaces) = 0;
+
+ virtual void processing_instruction(
+ const string_t& target, const string_t& data) = 0;
+
+ virtual void comment(const string_t& comment) = 0;
+};
+
+#endif
+
diff --git a/shell/qa/makefile.mk b/shell/qa/makefile.mk
new file mode 100755
index 000000000000..a9047f97cf83
--- /dev/null
+++ b/shell/qa/makefile.mk
@@ -0,0 +1,68 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=shell
+TARGET=qa
+# this is removed at the moment because we need some enhancements
+# TESTDIR=TRUE
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# BEGIN ----------------------------------------------------------------
+# auto generated Target:testjob by codegen.pl
+
+SHL1OBJS=$(SLO)$/recent_docs.obj $(SLO)$/xml_parser.obj
+SHL1TARGET=recent_docs
+SHL1STDLIBS=$(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
+
+.IF "$(GUI)" == "UNX"
+..$/unxsols4.pro$/slb$/libsysshell.a \
+$(EXPATASCII3RDLIB)
+.ENDIF
+
+SHL1IMPLIB= i$(SHL1TARGET)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE= export.exp
+
+# END ------------------------------------------------------------------
+
+
+#------------------------------- All object files -------------------------------
+# do this here, so we get right dependencies
+
+SLOFILES=$(SHL1OBJS)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/shell/qa/recent_docs.cxx b/shell/qa/recent_docs.cxx
new file mode 100755
index 000000000000..b4408e2f7737
--- /dev/null
+++ b/shell/qa/recent_docs.cxx
@@ -0,0 +1,224 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#include <testshl/simpleheader.hxx>
+
+#include "systemshell.hxx"
+#include "osl/file.hxx"
+#include "osl/security.hxx"
+#include "rtl/ustring.hxx"
+
+#include <stdlib.h>
+#include <iostream>
+
+//########################################
+using namespace osl;
+using namespace rtl;
+
+namespace syssh = SystemShell;
+
+//########################################
+const OUString SXW_MIME_TYPE = OUString::createFromAscii("application/vnd.sun.xml.writer");
+const OUString SXC_MIME_TYPE = OUString::createFromAscii("application/vnd.sun.xml.calc");
+const OUString SXI_MIME_TYPE = OUString::createFromAscii("application/vnd.sun.xml.impress");
+const OUString SXD_MIME_TYPE = OUString::createFromAscii("application/vnd.sun.xml.draw");
+const OUString SXM_MIME_TYPE = OUString::createFromAscii("application/vnd.sun.xml.math");
+
+class Test_AddToRecentDocs : public CppUnit::TestFixture
+{
+public:
+
+ Test_AddToRecentDocs()
+ {
+ }
+
+ //------------------------------------------------
+ void test_existing_recently_used_file_with_valid_xml()
+ {
+ system("rm $HOME/.recently-used");
+ system("echo '<?xml version=\"1.0\"?>\n<RecentFiles>\n<RecentItem>\n<URI>file:///home/federico/gedit.txt</URI>\n<Mime-Type>text/plain</Mime-Type>\n<Timestamp>1046485966</Timestamp>\n<Groups>\n<Group>gedit</Group>\n</Groups>\n</RecentItem>\n</RecentFiles>' > $HOME/.recently-used");
+
+ rtl::OUString url = rtl::OUString::createFromAscii("file:///home_athene/test.sxw");
+ syssh::AddToRecentDocumentList(url, SXW_MIME_TYPE);
+
+ url = rtl::OUString::createFromAscii("file:///home_athene/test.sxc");
+ syssh::AddToRecentDocumentList(url, SXC_MIME_TYPE);
+
+ url = rtl::OUString::createFromAscii("file:///home_athene/test.sxi");
+ syssh::AddToRecentDocumentList(url, SXI_MIME_TYPE);
+
+ url = rtl::OUString::createFromAscii("file:///home_athene/test.sxd");
+ syssh::AddToRecentDocumentList(url, SXD_MIME_TYPE);
+
+ url = rtl::OUString::createFromAscii("file:///home_athene/test.sxm");
+ syssh::AddToRecentDocumentList(url, SXM_MIME_TYPE);
+ }
+
+ //------------------------------------------------
+ void test_existing_recently_used_file_with_invalid_xml()
+ {
+ system("rm $HOME/.recently-used");
+ system("echo '<?xml version=\"1.0\"?>\n<RecentFiles>\n<RecentItem>\n<URI>file:///home/federico/gedit.txt</URI>\n<Mime-Type>text/plain</Mime-Type>\n<Timestamp>1046485966</Timestamp>\n<Groups>\n<Group>gedit</Group>\n</Groups>\n<RecentItem>\n<URI>file:///home/federico/gedit2.txt</URI>\n<Mime-Type>text/plain</Mime-Type>\n<Timestamp>1046485966</Timestamp>\n<Groups>\n<Group>gedit</Group>\n</Groups>\n</RecentItem>\n</RecentFiles>' > $HOME/.recently-used");
+
+ rtl::OUString url = rtl::OUString::createFromAscii("file:///home_athene/test.sxw");
+ syssh::AddToRecentDocumentList(url, SXW_MIME_TYPE);
+ }
+
+ //------------------------------------------------
+ void test_non_existing_recently_used_file()
+ {
+ int ret = system("rm $HOME/.recently-used");
+
+ rtl::OUString url = rtl::OUString::createFromAscii("file:///home_athene/test.sxw");
+ syssh::AddToRecentDocumentList(url, SXW_MIME_TYPE);
+
+ url = rtl::OUString::createFromAscii("file:///home_athene/test.sxc");
+ syssh::AddToRecentDocumentList(url, SXC_MIME_TYPE);
+
+ url = rtl::OUString::createFromAscii("file:///home_athene/test.sxi");
+ syssh::AddToRecentDocumentList(url, SXI_MIME_TYPE);
+
+ url = rtl::OUString::createFromAscii("file:///home_athene/test.sxd");
+ syssh::AddToRecentDocumentList(url, SXD_MIME_TYPE);
+
+ url = rtl::OUString::createFromAscii("file:///home_athene/test.sxm");
+ syssh::AddToRecentDocumentList(url, SXM_MIME_TYPE);
+
+ ret = system("ls $HOME/.recently-used");
+
+ CPPUNIT_ASSERT_MESSAGE(".recently-used doesn't exist", 0 == ret);
+ }
+
+ //------------------------------------------------
+ OUString get_recently_used_url()
+ {
+ Security sec;
+ OUString recently_used_url;
+
+ CPPUNIT_ASSERT_MESSAGE("cannot get user home directory", sec.getHomeDir(recently_used_url));
+
+ if ((recently_used_url.getLength() > 0) &&
+ ('/' != recently_used_url.pData->buffer[recently_used_url.getLength() - 1]))
+ recently_used_url += rtl::OUString::createFromAscii("/");
+
+ recently_used_url += rtl::OUString::createFromAscii(".recently-used");
+ return recently_used_url;
+ }
+
+ //------------------------------------------------
+ void read_recently_used(void* buffer, size_t size)
+ {
+ File ruf(get_recently_used_url());
+ FileBase::RC rc = ruf.open(OpenFlag_Read);
+
+ CPPUNIT_ASSERT_MESSAGE("Cannot open ~/.recently-used", FileBase::E_None == rc);
+
+ sal_uInt64 read;
+ ruf.read(buffer, size, read);
+ ruf.close();
+ CPPUNIT_ASSERT_MESSAGE("Cannot read .recently-used", (read > 0));
+ }
+
+ //------------------------------------------------
+ void test_existing_recently_used_file_without_xml()
+ {
+ // remove an existing .recently-used file
+ // create a new one with non xml data
+ system("rm $HOME/.recently-used");
+ system("date > $HOME/.recently-used");
+
+ char cnt_before[128];
+ memset(cnt_before, 0, sizeof(cnt_before));
+ read_recently_used(cnt_before, sizeof(cnt_before));
+
+ OUString url = OUString::createFromAscii("file:///home_athene/test.sxw");
+ syssh::AddToRecentDocumentList(url, SXW_MIME_TYPE);
+
+ char cnt_after[128];
+ memset(cnt_after, 0, sizeof(cnt_after));
+ read_recently_used(cnt_after, sizeof(cnt_after));
+ CPPUNIT_ASSERT_MESSAGE(".recently-used unexpectly touched", (0 == strcmp(cnt_before, cnt_after)));
+ }
+
+ //------------------------------------------------
+ void test_existing_recently_used_with_unknown_xml()
+ {
+ system("rm $HOME/.recently-used");
+
+ char* xml_unknown = "<?xml version=\"1.0\"?>\n<test>test</test>";
+ char cmd[256];
+ sprintf(cmd, "echo '%s' > $HOME/.recently-used", xml_unknown);
+ system(cmd);
+
+ OUString url = OUString::createFromAscii("file:///home_athene/test.sxw");
+ syssh::AddToRecentDocumentList(url, SXW_MIME_TYPE);
+
+ char buffer[256];
+ memset(buffer, 0, sizeof(buffer));
+ read_recently_used(buffer, sizeof(buffer));
+
+ CPPUNIT_ASSERT_MESSAGE("Unexpected recently-used content", (0 == strncmp(xml_unknown, buffer, strlen(xml_unknown))));
+ }
+
+ //------------------------------------------------
+ void test_existing_empty_recently_used_file()
+ {
+ system("rm $HOME/.recently-used");
+ system("touch $HOME/.recently-used");
+
+ OUString url = OUString::createFromAscii("file:///home_athene/test.sxw");
+ syssh::AddToRecentDocumentList(url, SXW_MIME_TYPE);
+
+ char buffer[256];
+ memset(buffer, 0, sizeof(buffer));
+ read_recently_used(buffer, sizeof(buffer));
+
+ char* expected = "<?xml version=\"1.0\"?>\n<RecentFiles>";
+ CPPUNIT_ASSERT_MESSAGE("Unexpected recently-used content", (0 == strncmp(buffer, expected, strlen(expected))));
+ }
+
+ //------------------------------------------------
+ CPPUNIT_TEST_SUITE(Test_AddToRecentDocs);
+ CPPUNIT_TEST(test_existing_recently_used_file_with_valid_xml);
+ CPPUNIT_TEST(test_non_existing_recently_used_file);
+ CPPUNIT_TEST(test_existing_recently_used_file_without_xml);
+ CPPUNIT_TEST(test_existing_recently_used_with_unknown_xml);
+ CPPUNIT_TEST(test_existing_empty_recently_used_file);
+ CPPUNIT_TEST(test_existing_recently_used_file_with_invalid_xml);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+
+//#####################################
+// register test suites
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test_AddToRecentDocs, "Test_AddToRecentDocs");
+
+NOADDITIONAL;
+
diff --git a/shell/source/all/makefile.mk b/shell/source/all/makefile.mk
new file mode 100755
index 000000000000..66b185132fa6
--- /dev/null
+++ b/shell/source/all/makefile.mk
@@ -0,0 +1,73 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=shell
+TARGET=xmlparser
+ENABLE_EXCEPTIONS=TRUE
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(GUI)" == "WNT"
+CFLAGS+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS+=-D_WIN32_IE=0x501
+
+.IF "$(BUILD_X64)"!=""
+CFLAGS_X64+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS_X64+=-D_WIN32_IE=0x501
+.ENDIF # "$(BUILD_X64)"!=""
+.ENDIF
+.IF "$(GUI)" == "OS2"
+CFLAGS+=-DISOLATION_AWARE_ENABLED -DXML_UNICODE -DXML_UNICODE_WCHAR_T -DUNICODE -D_UNICODE
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+.IF "$(SYSTEM_EXPAT)" == "YES"
+CFLAGS+=-DSYSTEM_EXPAT
+.ENDIF
+
+SLOFILES=$(SLO)$/xml_parser.obj
+
+.IF "$(BUILD_X64)"!=""
+SLOFILES_X64=$(SLO_X64)$/xml_parser.obj
+.ENDIF # "$(BUILD_X64)"!=""
+
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+.IF "$(OS)" == "WNT"
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+.ENDIF
+.INCLUDE : tg_wntx64.mk
+
diff --git a/shell/source/all/ooofilereader/autostyletag.cxx b/shell/source/all/ooofilereader/autostyletag.cxx
new file mode 100644
index 000000000000..6d51259345df
--- /dev/null
+++ b/shell/source/all/ooofilereader/autostyletag.cxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "autostyletag.hxx"
+
+/*********************** CAutoStyleTag ***********************/
+
+CAutoStyleTag::CAutoStyleTag( const XmlTagAttributes_t& attributes ):
+ m_CurrentStyleLocalePair( EMPTY_STYLELOCALE_PAIR )
+{
+ addAttributes( attributes);
+};
+
+void CAutoStyleTag::startTag()
+{
+}
+
+void CAutoStyleTag::endTag()
+{
+}
+
+void CAutoStyleTag::addCharacters(const std::wstring&)
+{
+}
+
+void CAutoStyleTag::addAttributes(const XmlTagAttributes_t& attributes)
+{
+ if ( EMPTY_STYLELOCALE_PAIR == m_CurrentStyleLocalePair )
+ {
+ // the style-locale pair should be empty when entering STYLE_STYLE
+ // tag, and otherwise should be STYLE_PROPERTIES.
+
+ XmlTagAttributes_t::const_iterator iter = attributes.find(CONTENT_STYLE_STYLE_NAME);
+
+ if ( iter != attributes.end())
+ setStyle( iter->second );
+ }
+ else
+ {
+ // tag STYLE_PROPERTIES entered.
+
+ XmlTagAttributes_t::const_iterator iter_lan = attributes.find(CONTENT_STYLE_PROPERTIES_LANGUAGE);
+ XmlTagAttributes_t::const_iterator iter_con = attributes.find(CONTENT_STYLE_PROPERTIES_COUNTRY);
+ XmlTagAttributes_t::const_iterator iter_lan_asain = attributes.find(CONTENT_STYLE_PROPERTIES_LANGUAGEASIAN);
+ XmlTagAttributes_t::const_iterator iter_con_asain = attributes.find(CONTENT_STYLE_PROPERTIES_COUNTRYASIAN);
+
+ // if style:properties | fo:language or style:language-asian is exist,
+ // set the locale field, otherwise clear the style-locale pair;
+ if ( ( iter_lan!= attributes.end() ) && ( iter_con != attributes.end() ) )
+ setLocale( ::std::make_pair( iter_lan->second,iter_con->second ) );
+ else if ( ( iter_lan_asain!= attributes.end() ) && ( iter_con_asain != attributes.end() ) )
+ setLocale( ::std::make_pair( iter_lan_asain->second,iter_con_asain->second ) );
+ else
+ clearStyleLocalePair();
+ }
+
+}
+
+void CAutoStyleTag::setStyle( ::std::wstring const & Style )
+{
+ m_CurrentStyleLocalePair.first = Style;
+}
+
+void CAutoStyleTag::setLocale( LocaleSet_t Locale )
+{
+ m_CurrentStyleLocalePair.second = Locale;
+}
+
+void CAutoStyleTag::clearStyleLocalePair( )
+{
+ m_CurrentStyleLocalePair = EMPTY_STYLELOCALE_PAIR;
+}
+
+
diff --git a/shell/source/all/ooofilereader/autostyletag.hxx b/shell/source/all/ooofilereader/autostyletag.hxx
new file mode 100644
index 000000000000..3957dd1b09b8
--- /dev/null
+++ b/shell/source/all/ooofilereader/autostyletag.hxx
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef AUTOSTYLETAG_HXX_INCLUDED
+#define AUTOSTYLETAG_HXX_INCLUDED
+
+#include "itag.hxx"
+
+/*************************** CAutoStyleTag tag readers ***************************/
+
+/** Implements the ITag interface for
+ building a Style-Locale list
+
+ Usage sample:
+
+ LocaleSet_t locale = meta_info_accessor.getDefaultLocale();
+ CContentReader content( m_szFileName, locale );
+ CStyleMap map = content.getStyleMap();
+*/
+class CAutoStyleTag : public ITag
+{
+ public:
+ CAutoStyleTag():m_CurrentStyleLocalePair( EMPTY_STYLELOCALE_PAIR ){};
+ CAutoStyleTag( const XmlTagAttributes_t& attributes );
+
+ virtual void startTag();
+ virtual void endTag();
+ virtual void addCharacters(const std::wstring& characters);
+ virtual void addAttributes(const XmlTagAttributes_t& attributes);
+ virtual std::wstring getTagContent(){ return EMPTY_STRING; };
+ virtual ::std::wstring const getTagAttribute( ::std::wstring const & /*attrname*/ ){ return ::std::wstring() ; };
+
+ void setStyle( ::std::wstring const & Style );
+ void setLocale( LocaleSet_t Locale );
+ void clearStyleLocalePair( void );
+ inline StyleLocalePair_t getStyleLocalePair() const{ return m_CurrentStyleLocalePair; };
+ inline bool isFull() const
+ {
+ return (( m_CurrentStyleLocalePair.first != EMPTY_STRING )&&
+ ( m_CurrentStyleLocalePair.second != EMPTY_LOCALE));
+ };
+
+ private:
+ StyleLocalePair_t m_CurrentStyleLocalePair;
+};
+
+#endif
diff --git a/shell/source/all/ooofilereader/basereader.cxx b/shell/source/all/ooofilereader/basereader.cxx
new file mode 100644
index 000000000000..2fc4a0c79297
--- /dev/null
+++ b/shell/source/all/ooofilereader/basereader.cxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/basereader.hxx"
+
+#ifndef XML_PARSER_HXX_INCLUDED
+#include "internal/xml_parser.hxx"
+#endif
+
+#include "assert.h"
+#include <memory>
+
+/** constructor of CBaseReader.
+*/
+CBaseReader::CBaseReader(const std::string& DocumentName):
+m_ZipFile( DocumentName )
+{
+}
+
+//------------------------------
+//
+//------------------------------
+
+CBaseReader::CBaseReader(void * sw, zlib_filefunc_def* fa):
+m_ZipFile( sw , fa )
+{
+}
+
+//------------------------------
+//
+//------------------------------
+
+CBaseReader::~CBaseReader()
+{
+}
+
+//------------------------------
+//
+//------------------------------
+
+void CBaseReader::start_document()
+{
+}
+
+//------------------------------
+//
+//------------------------------
+
+void CBaseReader::end_document()
+{
+}
+
+/** Read interested tag content into respective structure then start parsing process.
+ @param ContentName
+ the xml file name in the zipped document which we interest.
+*/
+void CBaseReader::Initialize( const std::string& ContentName)
+{
+ try
+ {
+ if (m_ZipContent.empty())
+ m_ZipFile.GetUncompressedContent( ContentName, m_ZipContent );
+
+ xml_parser parser;
+ parser.set_document_handler(this); // pass current reader as reader to the sax parser
+ parser.parse(&m_ZipContent[0], m_ZipContent.size());
+ }
+ catch(std::exception&
+ #if OSL_DEBUG_LEVEL > 0
+ ex
+ #endif
+ )
+ {
+ ENSURE( false, ex.what() );
+ }
+ catch(...)
+ {
+ ENSURE(false, "Unknown error");
+ }
+}
diff --git a/shell/source/all/ooofilereader/contentreader.cxx b/shell/source/all/ooofilereader/contentreader.cxx
new file mode 100644
index 000000000000..4afb278ff2c8
--- /dev/null
+++ b/shell/source/all/ooofilereader/contentreader.cxx
@@ -0,0 +1,235 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/contentreader.hxx"
+#include "dummytag.hxx"
+#include "simpletag.hxx"
+#include "autostyletag.hxx"
+
+#include "assert.h"
+
+/** constructor.
+*/
+CContentReader::CContentReader( const std::string& DocumentName, LocaleSet_t const & DocumentLocale ):
+CBaseReader( DocumentName )
+{
+ try
+ {
+ m_DefaultLocale = DocumentLocale;
+ Initialize( DOC_CONTENT_NAME );
+ }
+ catch(xml_parser_exception&
+ #if OSL_DEBUG_LEVEL > 0
+ ex
+ #endif
+ )
+ {
+ ENSURE(false, ex.what());
+ }
+ catch(...)
+ {
+ ENSURE(false, "Unknown error");
+ }
+}
+
+CContentReader::CContentReader( void* stream, LocaleSet_t const & DocumentLocale, zlib_filefunc_def* fa ) :
+CBaseReader( stream, fa )
+{
+try
+ {
+ m_DefaultLocale = DocumentLocale;
+ Initialize( DOC_CONTENT_NAME );
+ }
+ catch(xml_parser_exception&
+ #if OSL_DEBUG_LEVEL > 0
+ ex
+ #endif
+ )
+ {
+ ENSURE(false, ex.what());
+ }
+ catch(...)
+ {
+ ENSURE(false, "Unknown error");
+ }
+}
+
+
+/** destructor.
+*/
+
+CContentReader::~CContentReader( void )
+{
+}
+
+/*********************** helper functions ***********************/
+
+/** choose an appropriate tag reader
+*/
+
+ITag* CContentReader::chooseTagReader( const std::wstring& tag_name, const XmlTagAttributes_t& XmlAttributes )
+{
+ if (( tag_name == CONTENT_TEXT_A )||( tag_name == CONTENT_TEXT_P )||
+ ( tag_name == CONTENT_TEXT_SPAN ) ||( tag_name == CONTENT_TEXT_H )||
+ ( tag_name == CONTENT_TEXT_SEQUENCE ) ||( tag_name == CONTENT_TEXT_BOOKMARK_REF )||
+ ( tag_name == CONTENT_TEXT_INDEX_TITLE_TEMPLATE ) )
+ return new CSimpleTag(XmlAttributes);
+ else if ( tag_name == CONTENT_STYLE_STYLE )
+ {
+ // if style:style | style:name is exist,, fill the style field, otherwise do nothing;
+ if ( XmlAttributes.find(CONTENT_STYLE_STYLE_NAME) != XmlAttributes.end())
+ return new CAutoStyleTag(XmlAttributes);
+ else
+ return new CDummyTag();
+ }
+ else if ( ( tag_name == CONTENT_STYLE_PROPERTIES ) || ( tag_name == CONTENT_TEXT_STYLE_PROPERTIES ) )
+ {
+ assert( !m_TagBuilderStack.empty() );
+
+ //here we presume that if CONTENT_STYLE_PROPERTIES tag is present, it just follow CONTENT_STYLE_STYLE;
+ ITag* pTagBuilder = m_TagBuilderStack.top();
+ pTagBuilder->addAttributes( XmlAttributes );
+
+ return new CDummyTag();
+ }
+ else
+ return new CDummyTag();
+}
+
+/** get style of the current content.
+*/
+::std::wstring CContentReader::getCurrentContentStyle( void )
+{
+ assert( !m_TagBuilderStack.empty() );
+ ITag* pTagBuilder = m_TagBuilderStack.top();
+
+ return ( pTagBuilder->getTagAttribute(CONTENT_TEXT_STYLENAME) );
+}
+
+/** add chunk into Chunk Buffer.
+*/
+void CContentReader::addChunk( LocaleSet_t const & Locale, Content_t const & Content )
+{
+ if ( Content == EMPTY_STRING )
+ return;
+
+ if ( ( ( m_ChunkBuffer.empty() ) || ( m_ChunkBuffer.back().first != Locale ) ) &&
+ ( ( Content != SPACE ) && ( Content != LF ) ) )
+ {
+ // if met a new locale, add a blank new chunk;
+ Chunk_t Chunk;
+ Chunk.first = Locale;
+ Chunk.second = EMPTY_STRING;
+ m_ChunkBuffer.push_back( Chunk );
+ }
+
+ if ( !m_ChunkBuffer.empty() )
+ m_ChunkBuffer.back().second += Content;
+}
+
+/** get a style's locale field.
+*/
+
+LocaleSet_t const & CContentReader::getLocale( const StyleName_t Style )
+{
+ if ( m_StyleMap.empty() )
+ return m_DefaultLocale;
+
+ StyleLocaleMap_t :: const_iterator style_Iter;
+
+ if ( ( style_Iter = m_StyleMap.find( Style ) ) == m_StyleMap.end( ) )
+ return m_DefaultLocale;
+ else
+ return style_Iter->second;
+
+}
+
+/*********************** event handler functions ***********************/
+
+//------------------------------
+// start_element occurs when a tag is start
+//------------------------------
+
+void CContentReader::start_element(
+ const std::wstring& /*raw_name*/,
+ const std::wstring& local_name,
+ const XmlTagAttributes_t& attributes)
+{
+ //get appropriate Xml Tag Builder using MetaInfoBuilderFactory;
+ ITag* pTagBuilder = chooseTagReader( local_name,attributes );
+ assert( pTagBuilder != NULL );
+ pTagBuilder->startTag( );
+ m_TagBuilderStack.push( pTagBuilder );
+
+}
+
+//------------------------------
+// end_element occurs when a tag is closed
+//------------------------------
+
+void CContentReader::end_element(const std::wstring& /*raw_name*/, const std::wstring& local_name)
+{
+ assert( !m_TagBuilderStack.empty() );
+ ITag* pTagBuilder = m_TagBuilderStack.top();
+
+ if ( local_name == CONTENT_STYLE_STYLE )
+ {
+ StyleLocalePair_t StyleLocalePair = static_cast<CAutoStyleTag * >( pTagBuilder)->getStyleLocalePair();
+ if ( ( static_cast<CAutoStyleTag * >( pTagBuilder)->isFull() ) && ( StyleLocalePair.second != m_DefaultLocale ) )
+ m_StyleMap.insert( StyleLocalePair );
+ }
+ if (( local_name == CONTENT_TEXT_A )||( local_name == CONTENT_TEXT_SPAN ) ||
+ ( local_name == CONTENT_TEXT_SEQUENCE )||( local_name == CONTENT_TEXT_BOOKMARK_REF ))
+ addChunk( getLocale( getCurrentContentStyle() ), ::std::wstring( SPACE ) );
+ if ((( local_name == CONTENT_TEXT_P )||( local_name == CONTENT_TEXT_H ) ||
+ ( local_name == CONTENT_TEXT_INDEX_TITLE_TEMPLATE ) )&&
+ ( EMPTY_STRING != pTagBuilder->getTagContent( ) ) )
+ addChunk( getLocale( getCurrentContentStyle() ), ::std::wstring( LF ) );
+
+ m_TagBuilderStack.pop();
+ pTagBuilder->endTag();
+ delete pTagBuilder;
+
+}
+
+//------------------------------
+// characters occurs when receiving characters
+//------------------------------
+
+void CContentReader::characters( const std::wstring& character )
+{
+ if ( character.length() > 0 && !HasOnlySpaces( character ) )
+ {
+ addChunk( getLocale( getCurrentContentStyle() ), ::std::wstring( character ) );
+
+ ITag* pTagBuilder = m_TagBuilderStack.top();
+ pTagBuilder->addCharacters( character );
+ }
+}
+
diff --git a/shell/source/all/ooofilereader/dummytag.hxx b/shell/source/all/ooofilereader/dummytag.hxx
new file mode 100644
index 000000000000..cbd4382e84e3
--- /dev/null
+++ b/shell/source/all/ooofilereader/dummytag.hxx
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef DUMMYTAG_HXX_INCLUDED
+#define DUMMYTAG_HXX_INCLUDED
+
+#include "itag.hxx"
+
+/*************************** dummy tag readers ***************************/
+
+/** Implements the ITag interface but does
+ nothing (Null object pattern), may be used for
+ tags we are not interessted in to avoid if-else
+ branches.
+*/
+class CDummyTag : public ITag
+{
+ public:
+ virtual void startTag(){};
+
+ virtual void endTag(){};
+
+ virtual void addCharacters(const std::wstring& /*characters*/){};
+
+ virtual void addAttributes(const XmlTagAttributes_t& /*attributes*/){};
+
+ virtual std::wstring getTagContent( void )
+ {
+ return EMPTY_STRING;
+ };
+
+ virtual ::std::wstring const getTagAttribute( ::std::wstring const & /*attrname*/ ){ return ::std::wstring(EMPTY_STRING); };
+};
+
+
+#endif
diff --git a/shell/source/all/ooofilereader/itag.hxx b/shell/source/all/ooofilereader/itag.hxx
new file mode 100644
index 000000000000..97c09ed35b32
--- /dev/null
+++ b/shell/source/all/ooofilereader/itag.hxx
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef ITAG_HXX_INCLUDED
+#define ITAG_HXX_INCLUDED
+
+#include "internal/config.hxx"
+#include "internal/types.hxx"
+
+/*************************** interface of tag readers ***************************/
+
+/** Interface for a xml tag character builder
+*/
+class ITag
+{
+ public:
+ virtual ~ITag() {};
+
+ virtual void startTag() = 0;
+ virtual void endTag() = 0;
+ virtual void addCharacters(const std::wstring& characters) = 0;
+ virtual void addAttributes(const XmlTagAttributes_t& attributes) = 0;
+ virtual ::std::wstring getTagContent( void ) = 0;
+ virtual ::std::wstring const getTagAttribute( ::std::wstring const & attrname ) = 0;
+};
+
+#endif
diff --git a/shell/source/all/ooofilereader/keywordstag.cxx b/shell/source/all/ooofilereader/keywordstag.cxx
new file mode 100644
index 000000000000..2ffccfddaff2
--- /dev/null
+++ b/shell/source/all/ooofilereader/keywordstag.cxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "keywordstag.hxx"
+
+/*********************** CKeywordsTag ***********************/
+
+void CKeywordsTag::startTag()
+{
+ m_sCurrentKeyword.clear();
+}
+
+void CKeywordsTag::endTag()
+{
+ m_slKeywords.push_back(m_sCurrentKeyword);
+}
+
+void CKeywordsTag::addCharacters(const std::wstring& characters)
+{
+ m_sCurrentKeyword += characters;
+}
+
+void CKeywordsTag::addAttributes(const XmlTagAttributes_t& /*attributes*/)
+{
+ // there are no attributes for keywords
+}
+
+std::wstring CKeywordsTag::getTagContent( )
+{
+ StringList_t::const_iterator keywords_Iter= m_slKeywords.begin( );
+ StringList_t::const_iterator keywords_Iter_end = m_slKeywords.end( );
+
+ std::wstring ret_KeyWord_String = ( keywords_Iter != keywords_Iter_end) ? *keywords_Iter++ : L"";
+ for ( ; keywords_Iter != keywords_Iter_end; ++keywords_Iter)
+ ret_KeyWord_String += L"," + *keywords_Iter;
+ return ret_KeyWord_String;
+}
+
diff --git a/shell/source/all/ooofilereader/keywordstag.hxx b/shell/source/all/ooofilereader/keywordstag.hxx
new file mode 100644
index 000000000000..634810febd31
--- /dev/null
+++ b/shell/source/all/ooofilereader/keywordstag.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef KEYWORDSTAG_HXX_INCLUDED
+#define KEYWORDSTAG_HXX_INCLUDED
+
+#include "itag.hxx"
+
+/*************************** metainfo tag readers ***************************/
+
+/** Implements the ITag interface for
+ building a keyword list
+*/
+class CKeywordsTag : public ITag
+{
+ public:
+ virtual void startTag();
+ virtual void endTag();
+ virtual void addCharacters(const std::wstring& characters);
+ virtual void addAttributes(const XmlTagAttributes_t& attributes);
+ virtual std::wstring getTagContent();
+ virtual ::std::wstring const getTagAttribute( ::std::wstring const & /*attrname*/ ){ return ::std::wstring(); };
+
+ private:
+ StringList_t m_slKeywords;
+ std::wstring m_sCurrentKeyword;
+};
+
+#endif
diff --git a/shell/source/all/ooofilereader/makefile.mk b/shell/source/all/ooofilereader/makefile.mk
new file mode 100644
index 000000000000..bf6365526eec
--- /dev/null
+++ b/shell/source/all/ooofilereader/makefile.mk
@@ -0,0 +1,89 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=shell
+TARGET=ooofilereader
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(GUI)" != "OS2"
+CFLAGS+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS+=-D_WIN32_IE=0x501
+CFLAGS_X64+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS_X64+=-D_WIN32_IE=0x501
+.ENDIF
+.IF "$(GUI)" == "OS2"
+CFLAGS+=-DISOLATION_AWARE_ENABLED -DXML_UNICODE -DXML_UNICODE_WCHAR_T -DUNICODE -D_UNICODE
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+
+SLOFILES=$(SLO)$/basereader.obj\
+ $(SLO)$/metainforeader.obj\
+ $(SLO)$/contentreader.obj\
+ $(SLO)$/simpletag.obj\
+ $(SLO)$/keywordstag.obj\
+ $(SLO)$/autostyletag.obj
+
+LIB1TARGET=$(SLB)$/$(TARGET).lib
+LIB1OBJFILES=$(SLOFILES)
+LIB1FILES=$(SLB)$/zipfile.lib\
+ $(SLB)$/xmlparser.lib
+
+.IF "$(BUILD_X64)"!=""
+SLOFILES_X64=$(SLO_X64)$/basereader.obj\
+ $(SLO_X64)$/metainforeader.obj\
+ $(SLO_X64)$/contentreader.obj\
+ $(SLO_X64)$/simpletag.obj\
+ $(SLO_X64)$/keywordstag.obj\
+ $(SLO_X64)$/autostyletag.obj
+
+LIB1TARGET_X64=$(SLB_X64)$/$(TARGET).lib
+LIB1OBJFILES_X64=$(SLOFILES_X64)
+LIB1FILES_X64=$(SLB_X64)$/zipfile.lib\
+ $(SLB_X64)$/xmlparser.lib
+.ENDIF # "$(BUILD_X64)"!=""
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+.IF "$(OS)" == "WNT"
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+.ENDIF
+.INCLUDE : tg_wntx64.mk
+
diff --git a/shell/source/all/ooofilereader/metainforeader.cxx b/shell/source/all/ooofilereader/metainforeader.cxx
new file mode 100644
index 000000000000..24e59f6845da
--- /dev/null
+++ b/shell/source/all/ooofilereader/metainforeader.cxx
@@ -0,0 +1,302 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/metainforeader.hxx"
+#include "dummytag.hxx"
+#include "simpletag.hxx"
+#include "keywordstag.hxx"
+
+#include "assert.h"
+
+/** constructor.
+*/
+CMetaInfoReader::CMetaInfoReader( const std::string& DocumentName ):
+CBaseReader( DocumentName )
+{
+ try
+ {
+ m_pKeywords_Builder = new CKeywordsTag( );
+ m_pSimple_Builder = new CSimpleTag( );
+ m_pDummy_Builder = new CDummyTag( );
+
+ //retrieve all infomation that is useful
+ m_AllMetaInfo[META_INFO_AUTHOR] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_TITLE] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_SUBJECT] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_KEYWORDS] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_DESCRIPTION] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_DOCUMENT_STATISTIC] = EMPTY_XML_TAG;
+
+ m_AllMetaInfo[META_INFO_GENERATOR] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_CREATION] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_CREATOR] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_MODIFIED] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_LANGUAGE] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_DOCUMENT_NUMBER] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_EDITING_TIME] = EMPTY_XML_TAG;
+
+ Initialize( META_CONTENT_NAME );
+ }
+ catch(xml_parser_exception&
+ #if OSL_DEBUG_LEVEL > 0
+ ex
+ #endif
+ )
+ {
+ ENSURE(false, ex.what());
+ }
+ catch(...)
+ {
+ ENSURE(false, "Unknown error");
+ }
+}
+
+CMetaInfoReader::CMetaInfoReader( void* stream, zlib_filefunc_def* fa) :
+CBaseReader( stream, fa)
+{
+try
+ {
+ m_pKeywords_Builder = new CKeywordsTag( );
+ m_pSimple_Builder = new CSimpleTag( );
+ m_pDummy_Builder = new CDummyTag( );
+
+ //retrieve all infomation that is useful
+ m_AllMetaInfo[META_INFO_AUTHOR] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_TITLE] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_SUBJECT] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_KEYWORDS] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_DESCRIPTION] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_DOCUMENT_STATISTIC] = EMPTY_XML_TAG;
+
+ m_AllMetaInfo[META_INFO_GENERATOR] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_CREATION] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_CREATOR] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_MODIFIED] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_LANGUAGE] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_DOCUMENT_NUMBER] = EMPTY_XML_TAG;
+ m_AllMetaInfo[META_INFO_EDITING_TIME] = EMPTY_XML_TAG;
+
+ Initialize( META_CONTENT_NAME );
+ }
+ catch(xml_parser_exception&
+ #if OSL_DEBUG_LEVEL > 0
+ ex
+ #endif
+ )
+ {
+ ENSURE(false, ex.what());
+ }
+ catch(...)
+ {
+ ENSURE(false, "Unknown error");
+ }
+
+}
+
+/** destructor.
+*/
+
+CMetaInfoReader::~CMetaInfoReader( void )
+{
+ delete m_pKeywords_Builder;
+ delete m_pSimple_Builder;
+ delete m_pDummy_Builder;
+}
+
+
+/*********************** export functions ***********************/
+
+/** check if the Tag is in the target meta.xml file.
+
+ @param TagName
+ the name of the tag that will be retrive.
+*/
+bool CMetaInfoReader::hasTag( std::wstring TagName ) const
+{
+ return ( m_AllMetaInfo.find(TagName) != m_AllMetaInfo.end());
+}
+
+/** Get a specific tag content, compound tags will be returned as comma separated list.
+
+ @param TagName
+ the name of the tag that will be retrive.
+*/
+std::wstring CMetaInfoReader::getTagData( const std::wstring& TagName)
+{
+ if( hasTag( TagName ) )
+ return m_AllMetaInfo[TagName].first;
+ else
+ return EMPTY_STRING;
+}
+
+/** check if the a tag has the specific attribute.
+
+ @param TagName
+ the name of the tag.
+ @param AttributeName
+ the name of the attribute.
+*/
+bool CMetaInfoReader::hasTagAttribute( const std::wstring TagName, std::wstring AttributeName)
+{
+ return ( m_AllMetaInfo[TagName].second.find( AttributeName) != m_AllMetaInfo[TagName].second.end() );
+}
+
+/** Get a specific attribute content.
+
+ @param TagName
+ the name of the tag.
+ @param AttributeName
+ the name of the attribute.
+*/
+std::wstring CMetaInfoReader::getTagAttribute( const std::wstring TagName, std::wstring AttributeName)
+{
+ if ( hasTagAttribute( TagName, AttributeName ) )
+ return m_AllMetaInfo[ TagName ].second[AttributeName];
+ else
+ return EMPTY_STRING;
+}
+
+/** helper function for getDefaultLocale().
+*/
+const LocaleSet_t EN_US_LOCALE( ::std::make_pair( ::std::wstring( L"en" ), ::std::wstring( L"US" )));
+
+bool isValidLocale ( ::std::wstring Locale )
+{
+ return ( Locale.length() == 5 );
+}
+
+/** Get the default language of the whole document, if no such field, en-US is returned.
+*/
+LocaleSet_t CMetaInfoReader::getDefaultLocale()
+{
+ if (hasTag(META_INFO_LANGUAGE))
+ {
+ ::std::wstring locale = m_AllMetaInfo[META_INFO_LANGUAGE].first;
+ return isValidLocale(locale) ? ::std::make_pair(locale.substr( 0,2), locale.substr( 3,2)) : EN_US_LOCALE;
+ }
+ else
+ return EN_US_LOCALE;
+}
+
+/*********************** tag related functions ***********************/
+
+/** choose an appropriate tag reader
+*/
+
+ITag* CMetaInfoReader::chooseTagReader( const std::wstring& tag_name, const XmlTagAttributes_t& XmlAttributes )
+{
+ if ( tag_name == META_INFO_KEYWORD )
+ {
+ m_AllMetaInfo[META_INFO_KEYWORDS].second = XmlAttributes;
+ return m_pKeywords_Builder;
+ }
+ if (( tag_name == META_INFO_TITLE )||( tag_name == META_INFO_AUTHOR )||( tag_name == META_INFO_SUBJECT )||( tag_name == META_INFO_DESCRIPTION )||
+ ( tag_name == META_INFO_DOCUMENT_STATISTIC )||( tag_name == META_INFO_GENERATOR )||( tag_name == META_INFO_CREATION )||( tag_name == META_INFO_CREATOR )||
+ ( tag_name == META_INFO_MODIFIED )||( tag_name == META_INFO_LANGUAGE )||( tag_name == META_INFO_DOCUMENT_NUMBER )||( tag_name == META_INFO_EDITING_TIME ) )
+ {
+ m_AllMetaInfo[tag_name].second = XmlAttributes;
+ return m_pSimple_Builder;
+ }
+ else
+ return m_pDummy_Builder;
+
+}
+
+//------------------------------
+// save the received content into structure.
+//------------------------------
+void CMetaInfoReader::saveTagContent( const std::wstring& tag_name )
+{
+ ITag* pTagBuilder;
+ if ( tag_name == META_INFO_KEYWORDS )
+ pTagBuilder = m_pKeywords_Builder;
+ else if ( tag_name == META_INFO_KEYWORD )
+ {
+ // added for support for OASIS xml file format.
+ m_AllMetaInfo[META_INFO_KEYWORDS].first =m_pKeywords_Builder->getTagContent( );
+ return;
+ }
+ else if (( tag_name == META_INFO_TITLE )||( tag_name == META_INFO_AUTHOR )||( tag_name == META_INFO_SUBJECT )||( tag_name == META_INFO_DESCRIPTION )||
+ ( tag_name == META_INFO_DOCUMENT_STATISTIC )||( tag_name == META_INFO_GENERATOR )||( tag_name == META_INFO_CREATION )||( tag_name == META_INFO_CREATOR )||
+ ( tag_name == META_INFO_MODIFIED )||( tag_name == META_INFO_LANGUAGE )||( tag_name == META_INFO_DOCUMENT_NUMBER )||( tag_name == META_INFO_EDITING_TIME ) )
+ pTagBuilder = m_pSimple_Builder;
+ else
+ pTagBuilder = m_pDummy_Builder;
+
+ m_AllMetaInfo[tag_name].first =pTagBuilder->getTagContent( );
+}
+
+
+/*********************** event handler functions ***********************/
+
+//------------------------------
+// start_element occurs when a tag is start
+//------------------------------
+
+void CMetaInfoReader::start_element(
+ const std::wstring& /*raw_name*/,
+ const std::wstring& local_name,
+ const XmlTagAttributes_t& attributes)
+{
+ //get appropriate Xml Tag Builder using MetaInfoBuilderFactory;
+ ITag* pTagBuilder = chooseTagReader( local_name,attributes );
+ assert( pTagBuilder!= NULL );
+ pTagBuilder->startTag( );
+ m_TagBuilderStack.push( pTagBuilder );
+
+}
+
+//------------------------------
+// end_element occurs when a tag is closed
+//------------------------------
+
+void CMetaInfoReader::end_element(const std::wstring& /*raw_name*/, const std::wstring& local_name)
+{
+ assert( !m_TagBuilderStack.empty() );
+ ITag* pTagBuilder = m_TagBuilderStack.top();
+ m_TagBuilderStack.pop();
+ pTagBuilder->endTag();
+
+ saveTagContent( local_name );
+
+}
+
+//------------------------------
+// characters occurs when receiving characters
+//------------------------------
+
+void CMetaInfoReader::characters( const std::wstring& character )
+{
+ if ( character.length() > 0 && !HasOnlySpaces( character ) )
+ {
+ ITag* pTagBuilder = m_TagBuilderStack.top();
+ pTagBuilder->addCharacters( character );
+ }
+}
+
diff --git a/shell/source/all/ooofilereader/simpletag.cxx b/shell/source/all/ooofilereader/simpletag.cxx
new file mode 100644
index 000000000000..8fad2dc618ed
--- /dev/null
+++ b/shell/source/all/ooofilereader/simpletag.cxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "simpletag.hxx"
+
+/*********************** CSimpleTag ***********************/
+void CSimpleTag::startTag()
+{
+ m_SimpleContent = L"";
+}
+
+
+void CSimpleTag::endTag()
+{
+
+}
+
+void CSimpleTag::addCharacters(const std::wstring& characters)
+{
+ m_SimpleContent += characters;
+}
+
+void CSimpleTag::addAttributes(const XmlTagAttributes_t& attributes )
+{
+ m_SimpleAttributes = attributes;
+}
+
+std::wstring CSimpleTag::getTagContent( )
+{
+ return m_SimpleContent;
+}
+
+::std::wstring const CSimpleTag::getTagAttribute( ::std::wstring const & attrname )
+{
+ if ( m_SimpleAttributes.find(attrname) != m_SimpleAttributes.end())
+ return m_SimpleAttributes[attrname];
+ else
+ return ( ::std::wstring( EMPTY_STRING ) );
+}
diff --git a/shell/source/all/ooofilereader/simpletag.hxx b/shell/source/all/ooofilereader/simpletag.hxx
new file mode 100644
index 000000000000..8e251c4329ab
--- /dev/null
+++ b/shell/source/all/ooofilereader/simpletag.hxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef SIMPLETAG_HXX_INCLUDED
+#define SIMPLETAG_HXX_INCLUDED
+
+#include "itag.hxx"
+
+/*************************** simple tag readers ***************************/
+
+/** Implements the ITag interface for
+ building a general info that is not a compound tag.
+*/
+class CSimpleTag : public ITag
+{
+ public:
+ CSimpleTag(){};
+ CSimpleTag( const XmlTagAttributes_t& attributes ):m_SimpleAttributes(attributes){};
+
+ virtual void startTag();
+ virtual void endTag();
+ virtual void addCharacters(const std::wstring& characters);
+ virtual void addAttributes(const XmlTagAttributes_t& attributes);
+ virtual std::wstring getTagContent();
+
+ virtual ::std::wstring const getTagAttribute( ::std::wstring const & attrname );
+
+ private:
+ std::wstring m_SimpleContent;
+ XmlTagAttributes_t m_SimpleAttributes;
+};
+
+#endif
diff --git a/shell/source/all/xml_parser.cxx b/shell/source/all/xml_parser.cxx
new file mode 100644
index 000000000000..b7f73d2404a8
--- /dev/null
+++ b/shell/source/all/xml_parser.cxx
@@ -0,0 +1,215 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#ifndef XML_PARSER_HXX_INCLUDED
+#include "internal/xml_parser.hxx"
+#endif
+#include "internal/i_xml_parser_event_handler.hxx"
+
+#include <assert.h>
+
+namespace /* private */
+{
+
+ //######################################################
+ /* Extracts the local part of tag without
+ namespace decoration e.g. meta:creator -> creator */
+ const XML_Char COLON = (XML_Char)':';
+
+ const XML_Char* get_local_name(const XML_Char* rawname)
+ {
+ const XML_Char* p = rawname;
+
+ // go to the end
+ while (*p) p++;
+
+ // go back until the first ':'
+ while (*p != COLON && p > rawname)
+ p--;
+
+ // if we are on a colon one step forward
+ if (*p == COLON)
+ p++;
+
+ return p;
+ }
+
+ //################################################
+ inline xml_parser* get_parser_instance(void* data)
+ {
+ return reinterpret_cast<xml_parser*>(XML_GetUserData(
+ reinterpret_cast<XML_Parser>(data)));
+ }
+
+ //################################################
+ bool has_only_whitespaces(const XML_Char* s, int len)
+ {
+ const XML_Char* p = s;
+ for (int i = 0; i < len; i++)
+ if (*p++ != ' ') return false;
+ return true;
+ }
+}
+
+//###################################################
+xml_parser::xml_parser(const XML_Char* EncodingName) :
+ document_handler_(0),
+ xml_parser_(XML_ParserCreate(EncodingName))
+{
+ init();
+}
+
+//###################################################
+xml_parser::~xml_parser()
+{
+ XML_ParserFree(xml_parser_);
+}
+
+//###################################################
+/* Callback functions will be called by the parser on
+ different events */
+
+//###################################################
+extern "C"
+{
+
+static void xml_start_element_handler(void* UserData, const XML_Char* name, const XML_Char** atts)
+{
+ assert(UserData != NULL);
+
+ xml_parser* pImpl = get_parser_instance(UserData);
+
+ i_xml_parser_event_handler* pDocHdl = pImpl->get_document_handler();
+ if (pDocHdl)
+ {
+ xml_tag_attribute_container_t attributes;
+
+ int i = 0;
+
+ while(atts[i])
+ {
+ attributes[reinterpret_cast<const char_t*>(get_local_name(atts[i]))] = reinterpret_cast<const char_t*>(atts[i+1]);
+ i += 2; // skip to next pair
+ }
+
+ pDocHdl->start_element(
+ reinterpret_cast<const char_t*>(name), reinterpret_cast<const char_t*>(get_local_name(name)), attributes);
+ }
+}
+
+//###################################################
+static void xml_end_element_handler(void* UserData, const XML_Char* name)
+{
+ assert(UserData);
+
+ xml_parser* pImpl = get_parser_instance(UserData);
+ i_xml_parser_event_handler* pDocHdl = pImpl->get_document_handler();
+ if (pDocHdl)
+ pDocHdl->end_element(reinterpret_cast<const char_t*>(name), reinterpret_cast<const char_t*>(get_local_name(name)));
+}
+
+//###################################################
+static void xml_character_data_handler(void* UserData, const XML_Char* s, int len)
+{
+ assert(UserData);
+
+ xml_parser* pImpl = get_parser_instance(UserData);
+ i_xml_parser_event_handler* pDocHdl = pImpl->get_document_handler();
+ if (pDocHdl)
+ {
+ if (has_only_whitespaces(s,len))
+ pDocHdl->ignore_whitespace(string_t(reinterpret_cast<const char_t*>(s), len));
+ else
+ pDocHdl->characters(string_t(reinterpret_cast<const char_t*>(s), len));
+ }
+}
+
+//###################################################
+static void xml_comment_handler(void* UserData, const XML_Char* Data)
+{
+ assert(UserData);
+
+ xml_parser* pImpl = get_parser_instance(UserData);
+ i_xml_parser_event_handler* pDocHdl = pImpl->get_document_handler();
+ if (pDocHdl)
+ pDocHdl->comment(reinterpret_cast<const char_t*>(Data));
+}
+
+} // extern "C"
+
+//###################################################
+void xml_parser::init()
+{
+ XML_SetUserData(xml_parser_, this);
+
+ // we use the parser as handler argument,
+ // so we could use it if necessary, the
+ // UserData are usable anyway using
+ // XML_GetUserData(...)
+ XML_UseParserAsHandlerArg(xml_parser_);
+
+ XML_SetElementHandler(
+ xml_parser_,
+ xml_start_element_handler,
+ xml_end_element_handler);
+
+ XML_SetCharacterDataHandler(
+ xml_parser_,
+ xml_character_data_handler);
+
+ XML_SetCommentHandler(
+ xml_parser_,
+ xml_comment_handler);
+}
+
+//###################################################
+void xml_parser::parse(const char* XmlData, size_t Length, bool IsFinal)
+{
+ if (0 == XML_Parse(xml_parser_, XmlData, Length, IsFinal))
+ throw xml_parser_exception(
+ (char*)XML_ErrorString(XML_GetErrorCode(xml_parser_)),
+ (int)XML_GetErrorCode(xml_parser_),
+ XML_GetCurrentLineNumber(xml_parser_),
+ XML_GetCurrentColumnNumber(xml_parser_),
+ XML_GetCurrentByteIndex(xml_parser_));
+}
+
+//###################################################
+void xml_parser::set_document_handler(
+ i_xml_parser_event_handler* event_handler)
+{
+ document_handler_ = event_handler;
+}
+
+//###################################################
+i_xml_parser_event_handler* xml_parser::get_document_handler() const
+{
+ return document_handler_;
+}
diff --git a/shell/source/all/zipfile/makefile.mk b/shell/source/all/zipfile/makefile.mk
new file mode 100644
index 000000000000..4e0af2891027
--- /dev/null
+++ b/shell/source/all/zipfile/makefile.mk
@@ -0,0 +1,58 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=shell
+TARGET=zipfile
+ENABLE_EXCEPTIONS=TRUE
+EXTERNAL_WARNINGS_NOT_ERRORS := TRUE
+
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+
+SLOFILES=$(SLO)$/zipfile.obj\
+ $(SLO)$/zipexcptn.obj
+
+SLOFILES_X64=$(SLO_X64)$/zipfile.obj\
+ $(SLO_X64)$/zipexcptn.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+.IF "$(OS)" == "WNT"
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+.ENDIF
+.INCLUDE : tg_wntx64.mk
+
diff --git a/shell/source/all/zipfile/zipexcptn.cxx b/shell/source/all/zipfile/zipexcptn.cxx
new file mode 100644
index 000000000000..fcbbf54382bf
--- /dev/null
+++ b/shell/source/all/zipfile/zipexcptn.cxx
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/global.hxx"
+#include "zipexcptn.hxx"
+
+//------------------------------------------
+/**
+*/
+RuntimeException::RuntimeException(int Error) :
+ m_Error(Error)
+{
+}
+
+//------------------------------------------
+/**
+*/
+RuntimeException::~RuntimeException() throw()
+{
+}
+
+//------------------------------------------
+/**
+*/
+int RuntimeException::GetErrorCode() const
+{
+ return m_Error;
+}
+
+//------------------------------------------
+/**
+*/
+ZipException::ZipException(int Error) :
+ RuntimeException(Error)
+{
+}
+
+//------------------------------------------
+/**
+*/
+const char* ZipException::what() const throw()
+{
+ return 0;
+}
+
+//------------------------------------------
+/**
+*/
+Win32Exception::Win32Exception(int Error) :
+ RuntimeException(Error),
+ m_MsgBuff(0)
+{
+}
+
+//------------------------------------------
+/**
+*/
+Win32Exception::~Win32Exception() throw()
+{
+#ifndef OS2
+ if (m_MsgBuff)
+ LocalFree(m_MsgBuff);
+#endif
+}
+
+//------------------------------------------
+/**
+*/
+const char* Win32Exception::what() const throw()
+{
+#ifdef OS2
+ return "Win32Exception!";
+#else
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetErrorCode(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &m_MsgBuff,
+ 0,
+ NULL);
+
+ return reinterpret_cast<char*>(m_MsgBuff);
+#endif
+}
+
+//------------------------------------------
+/**
+*/
+ZipContentMissException::ZipContentMissException(int Error) :
+ ZipException(Error)
+{
+}
+
+//------------------------------------------
+/**
+*/
+AccessViolationException::AccessViolationException(int Error) :
+ Win32Exception(Error)
+{
+}
+
+//------------------------------------------
+/**
+*/
+IOException::IOException(int Error) :
+ Win32Exception(Error)
+{
+}
diff --git a/shell/source/all/zipfile/zipexcptn.hxx b/shell/source/all/zipfile/zipexcptn.hxx
new file mode 100644
index 000000000000..b98dc6df594f
--- /dev/null
+++ b/shell/source/all/zipfile/zipexcptn.hxx
@@ -0,0 +1,78 @@
+// ZipException.h: interface for the ZipException class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef ZIPEXCPTN_HXX_INCLUDED
+#define ZIPEXCPTN_HXX_INCLUDED
+
+#include <stdexcept>
+
+//------------------------------------------
+/**
+*/
+class RuntimeException : public std::exception
+{
+public:
+ RuntimeException(int Error);
+ virtual ~RuntimeException() throw();
+
+ int GetErrorCode() const;
+
+private:
+ int m_Error;
+};
+
+//------------------------------------------
+/**
+*/
+class ZipException : public RuntimeException
+{
+public:
+ ZipException(int Error);
+
+ virtual const char* what() const throw();
+};
+
+//------------------------------------------
+/**
+*/
+class Win32Exception : public RuntimeException
+{
+public:
+ Win32Exception(int Error);
+ virtual ~Win32Exception() throw();
+
+ virtual const char* what() const throw();
+
+private:
+ void* m_MsgBuff;
+};
+
+//------------------------------------------
+/**
+*/
+class ZipContentMissException : public ZipException
+{
+public:
+ ZipContentMissException(int Error);
+};
+
+//------------------------------------------
+/**
+*/
+class AccessViolationException : public Win32Exception
+{
+public:
+ AccessViolationException(int Error);
+};
+
+//------------------------------------------
+/**
+*/
+class IOException : public Win32Exception
+{
+public:
+ IOException(int Error);
+};
+
+#endif
diff --git a/shell/source/all/zipfile/zipfile.cxx b/shell/source/all/zipfile/zipfile.cxx
new file mode 100644
index 000000000000..96dd7922ec08
--- /dev/null
+++ b/shell/source/all/zipfile/zipfile.cxx
@@ -0,0 +1,251 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "zipexcptn.hxx"
+#include "internal/zipfile.hxx"
+#include "internal/global.hxx"
+
+#include <malloc.h>
+#include <algorithm>
+#include <functional>
+
+#include <string.h>
+
+#ifdef OS2
+#include <alloca.h>
+#define _alloca alloca
+#define ERROR_NOT_ENOUGH_MEMORY 8
+#endif
+
+namespace internal
+{
+ /* for case in-sensitive string comparison */
+ struct stricmp : public std::unary_function<std::string, bool>
+ {
+ stricmp(const std::string& str) : str_(str)
+ {}
+
+ bool operator() (const std::string& other)
+ { return (0 == _stricmp(str_.c_str(), other.c_str())); }
+
+ std::string str_;
+ };
+} // namespace internal
+
+/** Checks whether a file is a zip file or not
+
+ @precond The given parameter must be a string with length > 0
+ The file must exist
+ The file must be readable for the current user
+
+ @returns true if the file is a zip file
+ false if the file is not a zip file
+
+ @throws ParameterException if the given file name is empty
+ IOException if the specified file doesn't exist
+ AccessViolationException if read access to the file is denied
+*/
+bool ZipFile::IsZipFile(const std::string& /*FileName*/)
+{
+ return true;
+}
+
+bool ZipFile::IsZipFile(void* /*stream*/)
+{
+ return true;
+}
+
+
+/** Returns wheter the version of the specified zip file may be uncompressed with the
+ currently used zlib version or not
+
+ @precond The given parameter must be a string with length > 0
+ The file must exist
+ The file must be readable for the current user
+ The file must be a valid zip file
+
+ @returns true if the file may be uncompressed with the currently used zlib
+ false if the file may not be uncompressed with the currently used zlib
+
+ @throws ParameterException if the given file name is empty
+ IOException if the specified file doesn't exist or is no zip file
+ AccessViolationException if read access to the file is denied
+*/
+bool ZipFile::IsValidZipFileVersionNumber(const std::string& /*FileName*/)
+{
+ return true;
+}
+
+bool ZipFile::IsValidZipFileVersionNumber(void* /* stream*/)
+{
+ return true;
+}
+
+
+/** Constructs a zip file from a zip file
+
+ @precond The given parameter must be a string with length > 0
+ The file must exist
+ The file must be readable for the current user
+
+ @throws ParameterException if the given file name is empty
+ IOException if the specified file doesn't exist or is no valid zip file
+ AccessViolationException if read access to the file is denied
+ WrongZipVersionException if the zip file cannot be uncompressed
+ with the used zlib version
+*/
+ZipFile::ZipFile(const std::string& FileName)
+{
+ m_uzFile = unzOpen(FileName.c_str());
+
+ if (0 == m_uzFile)
+ throw IOException(-1);
+}
+
+ZipFile::ZipFile(void* stream, zlib_filefunc_def* fa)
+{
+ fa->opaque = stream;
+ m_uzFile = unzOpen2((const char *)NULL, fa);
+
+ if (0 == m_uzFile)
+ throw IOException(-1);
+}
+
+
+/** Destroys a zip file
+*/
+ZipFile::~ZipFile()
+{
+ unzClose(m_uzFile);
+}
+
+/** Provides an interface to read the uncompressed data of a content of the zip file
+
+ @precond The specified content must exist in this file
+ ppstm must not be NULL
+*/
+void ZipFile::GetUncompressedContent(
+ const std::string& ContentName, /*inout*/ ZipContentBuffer_t& ContentBuffer)
+{
+ int rc = unzLocateFile(m_uzFile, ContentName.c_str(), 0);
+
+ if (UNZ_END_OF_LIST_OF_FILE == rc)
+ throw ZipContentMissException(rc);
+
+ unz_file_info finfo;
+ unzGetCurrentFileInfo(m_uzFile, &finfo, 0, 0, 0, 0, 0, 0);
+
+ ContentBuffer.resize(finfo.uncompressed_size);
+
+ rc = unzOpenCurrentFile(m_uzFile);
+
+ if (UNZ_OK != rc)
+ throw ZipException(rc);
+
+ rc = unzReadCurrentFile(m_uzFile, &ContentBuffer[0], finfo.uncompressed_size);
+
+ if (rc < 0)
+ throw ZipException(rc);
+
+ rc = unzCloseCurrentFile(m_uzFile);
+
+ if (rc < 0)
+ throw ZipException(rc);
+}
+
+/** Returns a list with the content names contained within this file
+
+*/
+ZipFile::DirectoryPtr_t ZipFile::GetDirectory() const
+{
+ DirectoryPtr_t dir(new Directory_t());
+
+ long lmax = GetFileLongestFileNameLength() + 1;
+ char* szFileName = reinterpret_cast<char*>(_alloca(lmax));
+
+ if (!szFileName)
+ throw ZipException(ERROR_NOT_ENOUGH_MEMORY);
+
+ int rc = unzGoToFirstFile(m_uzFile);
+
+ while (UNZ_OK == rc && UNZ_END_OF_LIST_OF_FILE != rc)
+ {
+ unzGetCurrentFileInfo(
+ m_uzFile, 0, szFileName, lmax, 0, 0, 0, 0);
+
+ dir->push_back(szFileName);
+
+ rc = unzGoToNextFile(m_uzFile);
+ }
+
+ if (UNZ_OK != rc && UNZ_END_OF_LIST_OF_FILE != rc)
+ throw ZipException(rc);
+
+ return dir;
+}
+
+/** Convinience query function may even realized with
+ iterating over a ZipFileDirectory returned by
+ GetDirectory */
+bool ZipFile::HasContent(const std::string& ContentName) const
+{
+ //#i34314# we need to compare package content names
+ //case in-sensitive as it is not defined that such
+ //names must be handled case sensitive
+ DirectoryPtr_t dir = GetDirectory();
+ Directory_t::iterator iter =
+ std::find_if(dir->begin(), dir->end(), internal::stricmp(ContentName));
+
+ return (iter != dir->end());
+}
+
+
+/** Returns the length of the longest file name
+ in the current zip file
+*/
+long ZipFile::GetFileLongestFileNameLength() const
+{
+ long lmax = 0;
+ unz_file_info finfo;
+
+ int rc = unzGoToFirstFile(m_uzFile);
+
+ while (UNZ_OK == rc && UNZ_END_OF_LIST_OF_FILE != rc)
+ {
+ unzGetCurrentFileInfo(m_uzFile, &finfo, 0, 0, 0, 0, 0, 0);
+ lmax = std::max<long>(lmax, finfo.size_filename);
+ rc = unzGoToNextFile(m_uzFile);
+ }
+
+ if (UNZ_OK != rc && UNZ_END_OF_LIST_OF_FILE != rc)
+ throw ZipException(rc);
+
+ return lmax;
+}
+
diff --git a/shell/source/backends/desktopbe/desktopbackend.cxx b/shell/source/backends/desktopbe/desktopbackend.cxx
new file mode 100644
index 000000000000..21371755b479
--- /dev/null
+++ b/shell/source/backends/desktopbe/desktopbackend.cxx
@@ -0,0 +1,290 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#include "precompiled_shell.hxx"
+#include "sal/config.h"
+
+#include "boost/noncopyable.hpp"
+#include "com/sun/star/beans/Optional.hpp"
+#include "com/sun/star/beans/PropertyVetoException.hpp"
+#include "com/sun/star/beans/UnknownPropertyException.hpp"
+#include "com/sun/star/beans/XPropertyChangeListener.hpp"
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/beans/XPropertySetInfo.hpp"
+#include "com/sun/star/beans/XVetoableChangeListener.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "com/sun/star/lang/WrappedTargetException.hpp"
+#include "com/sun/star/lang/XMultiComponentFactory.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/lang/WrappedTargetException.hpp"
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/XCurrentContext.hpp"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implbase2.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "cppuhelper/weak.hxx"
+#include "osl/diagnose.h"
+#include "rtl/string.h"
+#include "rtl/textenc.h"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "uno/current_context.hxx"
+#include "uno/lbnames.h"
+
+namespace {
+
+namespace css = com::sun::star;
+
+rtl::OUString SAL_CALL getDefaultImplementationName() {
+ return rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.configuration.backend.DesktopBackend"));
+}
+
+css::uno::Sequence< rtl::OUString > SAL_CALL getDefaultSupportedServiceNames() {
+ rtl::OUString name(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.backend.DesktopBackend"));
+ return css::uno::Sequence< rtl::OUString >(&name, 1);
+}
+
+class Default:
+ public cppu::WeakImplHelper2<
+ css::lang::XServiceInfo, css::beans::XPropertySet >,
+ private boost::noncopyable
+{
+public:
+ Default() {}
+
+private:
+ virtual ~Default() {}
+
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException)
+ { return getDefaultImplementationName(); }
+
+ virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
+ throw (css::uno::RuntimeException)
+ { return ServiceName == getSupportedServiceNames()[0]; }
+
+ virtual css::uno::Sequence< rtl::OUString > SAL_CALL
+ getSupportedServiceNames() throw (css::uno::RuntimeException)
+ { return getDefaultSupportedServiceNames(); }
+
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo() throw (css::uno::RuntimeException)
+ { return css::uno::Reference< css::beans::XPropertySetInfo >(); }
+
+ virtual void SAL_CALL setPropertyValue(
+ rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL getPropertyValue(
+ rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual void SAL_CALL addPropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removePropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL addVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removeVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+};
+
+void Default::setPropertyValue(rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ throw css::lang::IllegalArgumentException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")),
+ static_cast< cppu::OWeakObject * >(this), -1);
+}
+
+css::uno::Any Default::getPropertyValue(rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("EnableATToolSupport")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ExternalMailer")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("SourceViewFontHeight")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("SourceViewFontName")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("WorkPathVariable")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetProxyType")))
+ {
+ return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
+ }
+ throw css::beans::UnknownPropertyException(
+ PropertyName, static_cast< cppu::OWeakObject * >(this));
+}
+
+css::uno::Reference< css::uno::XInterface > createBackend(
+ css::uno::Reference< css::uno::XComponentContext > const & context,
+ rtl::OUString const & name)
+{
+ try {
+ return css::uno::Reference< css::lang::XMultiComponentFactory >(
+ context->getServiceManager(), css::uno::UNO_SET_THROW)->
+ createInstanceWithContext(name, context);
+ } catch (css::uno::RuntimeException &) {
+ // Assuming these exceptions are real errors:
+ throw;
+ } catch (css::uno::Exception & e) {
+ // Assuming these exceptions indicate that the service is not installed:
+ OSL_TRACE(
+ "createInstance(%s) failed with %s",
+ rtl::OUStringToOString(name, RTL_TEXTENCODING_UTF8).getStr(),
+ rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
+ return css::uno::Reference< css::uno::XInterface >();
+ }
+}
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(
+ css::uno::Reference< css::uno::XComponentContext > const & context)
+{
+ rtl::OUString desktop;
+ css::uno::Reference< css::uno::XCurrentContext > current(
+ css::uno::getCurrentContext());
+ if (current.is()) {
+ current->getValueByName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("system.desktop-environment"))) >>=
+ desktop;
+ }
+ // Fall back to the default if the specific backend is not available:
+ css::uno::Reference< css::uno::XInterface > backend;
+ if (desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("GNOME"))) {
+ backend = createBackend(
+ context,
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.backend.GconfBackend")));
+ } else if (desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("KDE"))) {
+ backend = createBackend(
+ context,
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.backend.KDEBackend")));
+ } else if (desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("KDE4"))) {
+ backend = createBackend(
+ context,
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.backend.KDE4Backend")));
+ }
+ return backend.is()
+ ? backend : static_cast< cppu::OWeakObject * >(new Default);
+}
+
+static cppu::ImplementationEntry const services[] = {
+ { &createInstance, &getDefaultImplementationName,
+ &getDefaultSupportedServiceNames, &cppu::createSingleComponentFactory, 0,
+ 0 },
+ { 0, 0, 0, 0, 0, 0 }
+};
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+ char const * pImplName, void * pServiceManager, void * pRegistryKey)
+{
+ return cppu::component_getFactoryHelper(
+ pImplName, pServiceManager, pRegistryKey, services);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ char const ** ppEnvTypeName, uno_Environment **)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey)
+{
+ return component_writeInfoHelper(pServiceManager, pRegistryKey, services);
+}
diff --git a/shell/source/backends/desktopbe/desktopbe1-ucd.txt b/shell/source/backends/desktopbe/desktopbe1-ucd.txt
new file mode 100644
index 000000000000..fd874a82ead5
--- /dev/null
+++ b/shell/source/backends/desktopbe/desktopbe1-ucd.txt
@@ -0,0 +1,6 @@
+[ComponentDescriptor]
+ImplementationName=com.sun.star.comp.configuration.backend.DesktopBackend
+ComponentName=desktopbe1.uno.so
+LoaderName=com.sun.star.loader.SharedLibrary
+[SupportedServices]
+com.sun.star.configuration.backend.DesktopBackend
diff --git a/shell/source/backends/desktopbe/makefile.mk b/shell/source/backends/desktopbe/makefile.mk
new file mode 100644
index 000000000000..29260821d551
--- /dev/null
+++ b/shell/source/backends/desktopbe/makefile.mk
@@ -0,0 +1,53 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#***********************************************************************/
+
+PRJ = ../../..
+PRJNAME = shell
+TARGET = desktopbe
+
+ENABLE_EXCEPTIONS = TRUE
+VISIBILITY_HIDDEN = TRUE
+
+.INCLUDE: settings.mk
+
+DLLPRE =
+
+SLOFILES = $(SLO)/desktopbackend.obj
+
+SHL1IMPLIB = i$(SHL1TARGET)
+SHL1OBJS = $(SLOFILES)
+SHL1STDLIBS = \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+SHL1TARGET = desktopbe1.uno
+SHL1USE_EXPORTS = name
+DEF1NAME = $(SHL1TARGET)
+
+UNIXTEXT = $(MISC)/desktopbe1-ucd.txt
+
+.INCLUDE: target.mk
diff --git a/shell/source/backends/gconfbe/gconfaccess.cxx b/shell/source/backends/gconfbe/gconfaccess.cxx
new file mode 100644
index 000000000000..99a5b362c161
--- /dev/null
+++ b/shell/source/backends/gconfbe/gconfaccess.cxx
@@ -0,0 +1,849 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#include "precompiled_shell.hxx"
+#include "sal/config.h"
+
+#include <string.h>
+
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "osl/file.hxx"
+#include "osl/security.hxx"
+#include "osl/thread.h"
+#include "rtl/strbuf.hxx"
+#include "rtl/ustrbuf.hxx"
+
+#include "gconfaccess.hxx"
+
+#define GCONF_PROXY_MODE_KEY "/system/proxy/mode"
+#define GCONF_AUTO_SAVE_KEY "/apps/openoffice/auto_save"
+
+namespace gconfaccess {
+
+namespace {
+
+namespace css = com::sun::star ;
+namespace uno = css::uno ;
+using namespace rtl;
+
+GConfClient* getGconfClient()
+{
+ static GConfClient* mClient= 0;
+ if (mClient == NULL)
+ {
+ /* initialize glib object type library */
+ g_type_init();
+
+ GError* aError = NULL;
+ if (!gconf_init(0, NULL, &aError))
+ {
+ rtl::OUStringBuffer msg;
+ msg.appendAscii("GconfBackend:GconfLayer: Cannot Initialize Gconf connection - " );
+ msg.appendAscii(aError->message);
+
+ g_error_free(aError);
+ aError = NULL;
+ throw uno::RuntimeException(msg.makeStringAndClear(),NULL);
+ }
+
+ mClient = gconf_client_get_default();
+ if (!mClient)
+ {
+ throw uno::RuntimeException(rtl::OUString::createFromAscii
+ ("GconfBackend:GconfLayer: Cannot Initialize Gconf connection"),NULL);
+ }
+
+ static const char * const PreloadValuesList[] =
+ {
+ "/desktop/gnome/interface",
+ "/system/proxy",
+ "/system/http_proxy/host",
+ "/desktop/gnome/url-handlers/mailto",
+#ifdef ENABLE_LOCKDOWN
+ "/apps/openoffice",
+ "/desktop/gnome/lockdown",
+ "/apps/openoffice/lockdown",
+#endif // ENABLE_LOCKDOWN
+ NULL
+ };
+ int i = 0;
+ while( PreloadValuesList[i] != NULL )
+ gconf_client_preload( mClient, PreloadValuesList[i++], GCONF_CLIENT_PRELOAD_ONELEVEL, NULL );
+ }
+
+ return mClient;
+}
+
+static OUString xdg_user_dir_lookup (const char *type)
+{
+ char *config_home;
+ char *p;
+ int relative;
+ bool bError = false;
+
+ osl::Security aSecurity;
+ oslFileHandle handle;
+ OUString aHomeDirURL;
+ OUString aDocumentsDirURL;
+ OUString aConfigFileURL;
+ OUStringBuffer aUserDirBuf;
+
+ if (!aSecurity.getHomeDir( aHomeDirURL ) )
+ {
+ osl::FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii("/tmp"), aDocumentsDirURL);
+ return aDocumentsDirURL;
+ }
+
+ config_home = getenv ("XDG_CONFIG_HOME");
+ if (config_home == NULL || config_home[0] == 0)
+ {
+ aConfigFileURL = OUString(aHomeDirURL);
+ aConfigFileURL += OUString::createFromAscii( "/.config/user-dirs.dirs" );
+ }
+ else
+ {
+ aConfigFileURL = OUString::createFromAscii(config_home);
+ aConfigFileURL += OUString::createFromAscii( "/user-dirs.dirs" );
+ }
+
+ if(osl_File_E_None == osl_openFile(aConfigFileURL.pData, &handle, osl_File_OpenFlag_Read))
+ {
+ rtl::ByteSequence seq;
+ while (osl_File_E_None == osl_readLine(handle , (sal_Sequence **)&seq))
+ {
+ /* Remove newline at end */
+ int len = seq.getLength();
+ if(len>0 && seq[len-1] == '\n')
+ seq[len-1] = 0;
+
+ p = (char *)seq.getArray();
+
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ if (strncmp (p, "XDG_", 4) != 0)
+ continue;
+ p += 4;
+ if (strncmp (p, type, strlen (type)) != 0)
+ continue;
+ p += strlen (type);
+ if (strncmp (p, "_DIR", 4) != 0)
+ continue;
+ p += 4;
+
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ if (*p != '=')
+ continue;
+ p++;
+
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ if (*p != '"')
+ continue;
+ p++;
+
+ relative = 0;
+ if (strncmp (p, "$HOME/", 6) == 0)
+ {
+ p += 6;
+ relative = 1;
+ }
+ else if (*p != '/')
+ continue;
+
+ if (relative)
+ {
+ aUserDirBuf = OUStringBuffer(aHomeDirURL);
+ aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/" ) );
+ }
+ else
+ {
+ aUserDirBuf = OUStringBuffer();
+ }
+
+ while (*p && *p != '"')
+ {
+ if ((*p == '\\') && (*(p+1) != 0))
+ p++;
+ aUserDirBuf.append((sal_Unicode)*p++);
+ }
+ }
+ osl_closeFile(handle);
+ }
+ else
+ bError = true;
+
+ if (aUserDirBuf.getLength()>0 && !bError)
+ {
+ aDocumentsDirURL = aUserDirBuf.makeStringAndClear();
+ osl::Directory aDocumentsDir( aDocumentsDirURL );
+ if( osl::FileBase::E_None == aDocumentsDir.open() )
+ return aDocumentsDirURL;
+ }
+
+ /* Special case desktop for historical compatibility */
+ if (strcmp (type, "DESKTOP") == 0)
+ {
+ aUserDirBuf = OUStringBuffer(aHomeDirURL);
+ aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Desktop" ) );
+ return aUserDirBuf.makeStringAndClear();
+ }
+ else
+ {
+ aUserDirBuf = OUStringBuffer(aHomeDirURL);
+ aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Documents" ) );
+ return aUserDirBuf.makeStringAndClear();
+ }
+}
+
+//------------------------------------------------------------------------------
+
+uno::Any makeAnyOfGconfValue( GConfValue *aGconfValue )
+{
+ switch( aGconfValue->type )
+ {
+ case GCONF_VALUE_BOOL:
+ return uno::makeAny( (sal_Bool) gconf_value_get_bool( aGconfValue ) );
+
+ case GCONF_VALUE_INT:
+ return uno::makeAny( (sal_Int32) gconf_value_get_int( aGconfValue ) );
+
+ case GCONF_VALUE_STRING:
+ return uno::makeAny( OStringToOUString( rtl::OString(
+ gconf_value_get_string(aGconfValue) ), RTL_TEXTENCODING_UTF8 ) );
+
+ default:
+ fprintf( stderr, "makeAnyOfGconfValue: Type not handled.\n" );
+ break;
+ }
+
+ return uno::Any();
+}
+
+//------------------------------------------------------------------------------
+
+static void splitFontName( GConfValue *aGconfValue, rtl::OUString &rName, sal_Int16 &rHeight)
+{
+ rtl::OString aFont( gconf_value_get_string( aGconfValue ) );
+ aFont.trim();
+ sal_Int32 nIdx = aFont.lastIndexOf( ' ' );
+ if (nIdx < 1) { // urk
+ rHeight = 12;
+ nIdx = aFont.getLength();
+ } else {
+ rtl::OString aSize = aFont.copy( nIdx + 1 );
+ rHeight = static_cast<sal_Int16>( aSize.toInt32() );
+ }
+
+ rName = rtl::OStringToOUString( aFont.copy( 0, nIdx ), RTL_TEXTENCODING_UTF8 );
+}
+
+//------------------------------------------------------------------------------
+
+uno::Any translateToOOo( const ConfigurationValue aValue, GConfValue *aGconfValue )
+{
+
+ switch( aValue.nSettingId )
+ {
+ case SETTING_PROXY_MODE:
+ {
+ rtl::OUString aProxyMode;
+ uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue );
+ aOriginalValue >>= aProxyMode;
+
+ if( aProxyMode.equals( rtl::OUString::createFromAscii( "manual" ) ) )
+ return uno::makeAny( (sal_Int32) 1 );
+ else if( aProxyMode.equals( rtl::OUString::createFromAscii( "none" ) ) )
+ return uno::makeAny( (sal_Int32) 0 );
+ }
+ break;
+
+ case SETTING_NO_PROXY_FOR:
+ {
+ rtl::OStringBuffer aBuffer;
+ if( (GCONF_VALUE_LIST == aGconfValue->type) && (GCONF_VALUE_STRING == gconf_value_get_list_type(aGconfValue)) )
+ {
+ GSList * list = gconf_value_get_list(aGconfValue);
+ for(; list; list = g_slist_next(list))
+ {
+ aBuffer.append(gconf_value_get_string((GConfValue *) list->data));
+ aBuffer.append(";");
+ }
+ // Remove trailing ";"
+ aBuffer.setLength(aBuffer.getLength()-1);
+ return uno::makeAny(rtl::OStringToOUString(aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8));
+ }
+ else
+ g_warning( "unexpected type for ignore_hosts" );
+ }
+ break;
+
+ case SETTING_MAILER_PROGRAM:
+ {
+ rtl::OUString aMailer;
+ uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue );
+ aOriginalValue >>= aMailer;
+ sal_Int32 nIndex = 0;
+ return uno::makeAny( aMailer.getToken( 0, ' ', nIndex ) );
+ }
+
+#ifdef ENABLE_LOCKDOWN
+ // "short" values need to be returned a sal_Int16
+ case SETTING_FONT_ANTI_ALIASING_MIN_PIXEL:
+ case SETTING_SYMBOL_SET:
+ {
+ sal_Int32 nShortValue;
+ uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue );
+ aOriginalValue >>= nShortValue;
+ return uno::makeAny( (sal_Int16) nShortValue );
+ }
+ break;
+#endif // ENABLE_LOCKDOWN
+
+ // "boolean" values that need a string to be returned
+ case SETTING_ENABLE_ACCESSIBILITY:
+#ifdef ENABLE_LOCKDOWN
+ case SETTING_DISABLE_PRINTING:
+#endif // ENABLE_LOCKDOWN
+ {
+ sal_Bool bBooleanValue = false;
+ uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue );
+ aOriginalValue >>= bBooleanValue;
+ return uno::makeAny( rtl::OUString::valueOf( (sal_Bool) bBooleanValue ) );
+ }
+
+ case SETTING_WORK_DIRECTORY:
+ {
+ rtl::OUString aDocumentsDirURL = xdg_user_dir_lookup("DOCUMENTS");
+
+ return uno::makeAny( aDocumentsDirURL );
+ }
+
+ case SETTING_USER_GIVENNAME:
+ {
+ rtl::OUString aCompleteName( rtl::OStringToOUString(
+ g_get_real_name(), osl_getThreadTextEncoding() ) );
+ sal_Int32 nIndex = 0;
+ rtl::OUString aGivenName;
+ do
+ aGivenName = aCompleteName.getToken( 0, ' ', nIndex );
+ while ( nIndex == 0 );
+
+ return uno::makeAny( aGivenName );
+
+ }
+
+ case SETTING_USER_SURNAME:
+ {
+ rtl::OUString aCompleteName( rtl::OStringToOUString(
+ g_get_real_name(), osl_getThreadTextEncoding() ) );
+ sal_Int32 nIndex = 0;
+ rtl::OUString aSurname;
+ do
+ aSurname = aCompleteName.getToken( 0, ' ', nIndex );
+ while ( nIndex >= 0 );
+
+ return uno::makeAny( aSurname );
+ }
+
+ case SETTING_SOURCEVIEWFONT_NAME:
+ case SETTING_SOURCEVIEWFONT_HEIGHT:
+ {
+ rtl::OUString aName;
+ sal_Int16 nHeight;
+
+ splitFontName (aGconfValue, aName, nHeight);
+ if (aValue.nSettingId == SETTING_SOURCEVIEWFONT_NAME)
+ return uno::makeAny( aName );
+ else
+ return uno::makeAny( nHeight );
+ }
+
+
+ default:
+ fprintf( stderr, "Unhandled setting to translate.\n" );
+ break;
+ }
+
+ return uno::Any();
+}
+
+//------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL isDependencySatisfied( GConfClient* aClient, const ConfigurationValue aValue )
+{
+ switch( aValue.nDependsOn )
+ {
+ case SETTING_PROXY_MODE:
+ {
+ GConfValue* aGconfValue = gconf_client_get( aClient, GCONF_PROXY_MODE_KEY, NULL );
+
+ if ( aGconfValue != NULL )
+ {
+ bool bOk = g_strcasecmp( "manual", gconf_value_get_string( aGconfValue ) ) == 0;
+ gconf_value_free( aGconfValue );
+ if (bOk) return sal_True;
+ }
+ }
+ break;
+
+ case SETTING_WORK_DIRECTORY:
+ {
+ rtl::OUString aDocumentsDirURL = xdg_user_dir_lookup("DOCUMENTS");
+ osl::Directory aDocumentsDir( aDocumentsDirURL );
+
+ if( osl::FileBase::E_None == aDocumentsDir.open() )
+ return sal_True;
+ }
+ break;
+
+ case SETTING_USER_GIVENNAME:
+ {
+ rtl::OUString aCompleteName( rtl::OStringToOUString(
+ g_get_real_name(), osl_getThreadTextEncoding() ) );
+ if( !aCompleteName.equalsAscii( "Unknown" ) )
+ return sal_True;
+ }
+ break;
+
+ case SETTING_USER_SURNAME:
+ {
+ rtl::OUString aCompleteName( rtl::OStringToOUString(
+ g_get_real_name(), osl_getThreadTextEncoding() ) );
+ if( !aCompleteName.equalsAscii( "Unknown" ) )
+ {
+ if( aCompleteName.trim().indexOf(rtl::OUString::createFromAscii(" "), 0) != -1 )
+ return sal_True;
+ }
+ }
+ break;
+
+#ifdef ENABLE_LOCKDOWN
+ case SETTING_AUTO_SAVE:
+ {
+ GConfClient* aClient = GconfBackend::getGconfClient();
+ GConfValue* aGconfValue = gconf_client_get( aClient, GCONF_AUTO_SAVE_KEY, NULL );
+
+ if( ( aGconfValue != NULL ) )
+ {
+ bool bOk = gconf_value_get_bool( aGconfValue );
+ gconf_value_free( aGconfValue );
+ if (bOk) return sal_True;
+ }
+ }
+ break;
+#endif // ENABLE_LOCKDOWN
+
+ default:
+ fprintf( stderr, "Unhandled setting to check dependency.\n" );
+ break;
+ }
+
+ return sal_False;
+}
+
+}
+
+ConfigurationValue const ConfigurationValues[] =
+{
+ {
+ SETTING_ENABLE_ACCESSIBILITY,
+ "/desktop/gnome/interface/accessibility",
+ "EnableATToolSupport",
+ sal_True,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_PROXY_MODE,
+ GCONF_PROXY_MODE_KEY,
+ "ooInetProxyType",
+ sal_True,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_PROXY_HTTP_HOST,
+ "/system/http_proxy/host",
+ "ooInetHTTPProxyName",
+ sal_False,
+ SETTING_PROXY_MODE
+ },
+
+ {
+ SETTING_PROXY_HTTP_PORT,
+ "/system/http_proxy/port",
+ "ooInetHTTPProxyPort",
+ sal_False,
+ SETTING_PROXY_MODE
+ },
+
+ {
+ SETTING_PROXY_HTTPS_HOST,
+ "/system/proxy/secure_host",
+ "ooInetHTTPSProxyName",
+ sal_False,
+ SETTING_PROXY_MODE
+ },
+
+ {
+ SETTING_PROXY_HTTPS_PORT,
+ "/system/proxy/secure_port",
+ "ooInetHTTPSProxyPort",
+ sal_False,
+ SETTING_PROXY_MODE
+ },
+
+ {
+ SETTING_PROXY_FTP_HOST,
+ "/system/proxy/ftp_host",
+ "ooInetFTPProxyName",
+ sal_False,
+ SETTING_PROXY_MODE
+ },
+
+ {
+ SETTING_PROXY_FTP_PORT,
+ "/system/proxy/ftp_port",
+ "ooInetFTPProxyPort",
+ sal_False,
+ SETTING_PROXY_MODE
+ },
+
+ {
+ SETTING_NO_PROXY_FOR,
+ "/system/http_proxy/ignore_hosts",
+ "ooInetNoProxy",
+ sal_True,
+ SETTING_PROXY_MODE
+ },
+
+ {
+ SETTING_MAILER_PROGRAM,
+ "/desktop/gnome/url-handlers/mailto/command",
+ "ExternalMailer",
+ sal_True,
+ SETTINGS_LAST
+ },
+ {
+ SETTING_SOURCEVIEWFONT_NAME,
+ "/desktop/gnome/interface/monospace_font_name",
+ "SourceViewFontName",
+ sal_True,
+ SETTINGS_LAST
+ },
+ {
+ SETTING_SOURCEVIEWFONT_HEIGHT,
+ "/desktop/gnome/interface/monospace_font_name",
+ "SourceViewFontHeight",
+ sal_True,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_WORK_DIRECTORY,
+ "/desktop/gnome/url-handlers/mailto/command", // dummy
+ "WorkPathVariable",
+ sal_True,
+ SETTING_WORK_DIRECTORY, // so that the existence of the dir can be checked
+ },
+
+#ifdef ENABLE_LOCKDOWN
+ {
+ SETTING_WRITER_DEFAULT_DOC_FORMAT,
+ "/apps/openoffice/writer_default_document_format",
+ "TextDocumentSetupFactoryDefaultFilter",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_IMPRESS_DEFAULT_DOC_FORMAT,
+ "/apps/openoffice/impress_default_document_format",
+ "PresentationDocumentSetupFactoryDefaultFilter",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_CALC_DEFAULT_DOC_FORMAT,
+ "/apps/openoffice/calc_default_document_format",
+ "SpreadsheetDocumentSetupFactoryDefaultFilter",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_AUTO_SAVE,
+ GCONF_AUTO_SAVE_KEY,
+ "AutoSaveEnabled",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_AUTO_SAVE_INTERVAL,
+ "/apps/openoffice/auto_save_interval",
+ "AutoSaveTimeIntervall",
+ sal_False,
+ SETTING_AUTO_SAVE
+ },
+
+ {
+ SETTING_USER_GIVENNAME,
+ "/desktop/gnome/url-handlers/mailto/command", // dummy
+ "givenname",
+ sal_True,
+ SETTING_USER_GIVENNAME
+ },
+
+ {
+ SETTING_USER_SURNAME,
+ "/desktop/gnome/url-handlers/mailto/command", // dummy
+ "sn",
+ sal_True,
+ SETTING_USER_SURNAME
+ },
+
+ {
+ SETTING_DISABLE_PRINTING,
+ "/desktop/gnome/lockdown/disable_printing",
+ "DisablePrinting",
+ sal_True,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_USE_SYSTEM_FILE_DIALOG,
+ "/apps/openoffice/use_system_file_dialog",
+ "UseSystemFileDialog",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_PRINTING_MODIFIES_DOCUMENT,
+ "/apps/openoffice/printing_modifies_doc",
+ "PrintingModifiesDocument",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_SHOW_ICONS_IN_MENUS,
+ "/apps/openoffice/show_menu_icons",
+ "ShowIconsInMenues",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_SHOW_INACTIVE_MENUITEMS,
+ "/apps/openoffice/show_menu_inactive_items",
+ "DontHideDisabledEntry",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_SHOW_FONT_PREVIEW,
+ "/apps/openoffice/show_font_preview",
+ "ShowFontBoxWYSIWYG",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_SHOW_FONT_HISTORY,
+ "/apps/openoffice/show_font_history",
+ "FontViewHistory",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_ENABLE_OPENGL,
+ "/apps/openoffice/use_opengl",
+ "OpenGL",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_OPTIMIZE_OPENGL,
+ "/apps/openoffice/optimize_opengl",
+ "OpenGL_Faster",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_USE_SYSTEM_FONT,
+ "/apps/openoffice/use_system_font",
+ "AccessibilityIsSystemFont",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_USE_FONT_ANTI_ALIASING,
+ "/apps/openoffice/use_font_anti_aliasing",
+ "FontAntiAliasingEnabled",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_FONT_ANTI_ALIASING_MIN_PIXEL,
+ "/apps/openoffice/font_anti_aliasing_min_pixel",
+ "FontAntiAliasingMinPixelHeight",
+ sal_True,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_WARN_CREATE_PDF,
+ "/apps/openoffice/lockdown/warn_info_create_pdf",
+ "WarnCreatePDF",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_WARN_PRINT_DOC,
+ "/apps/openoffice/lockdown/warn_info_printing",
+ "WarnPrintDoc",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_WARN_SAVEORSEND_DOC,
+ "/apps/openoffice/lockdown/warn_info_saving",
+ "WarnSaveOrSendDoc",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_WARN_SIGN_DOC,
+ "/apps/openoffice/lockdown/warn_info_signing",
+ "WarnSignDoc",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_REMOVE_PERSONAL_INFO,
+ "/apps/openoffice/lockdown/remove_personal_info_on_save",
+ "Scripting/RemovePersonalInfoOnSaving",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_RECOMMEND_PASSWORD,
+ "/apps/openoffice/lockdown/recommend_password_on_save",
+ "RecommendPasswordProtection",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_UNDO_STEPS,
+ "/apps/openoffice/undo_steps",
+ "UndoSteps",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_SYMBOL_SET,
+ "/apps/openoffice/icon_size",
+ "SymbolSet",
+ sal_True,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_MACRO_SECURITY_LEVEL,
+ "/apps/openoffice/lockdown/macro_security_level",
+ "MacroSecurityLevel",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_CREATE_BACKUP,
+ "/apps/openoffice/create_backup",
+ "CreateBackup",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+ {
+ SETTING_WARN_ALIEN_FORMAT,
+ "/apps/openoffice/warn_alien_format",
+ "WarnAlienFormat",
+ sal_False,
+ SETTINGS_LAST
+ },
+
+#endif // ENABLE_LOCKDOWN
+};
+
+std::size_t const nConfigurationValues =
+ sizeof ConfigurationValues / sizeof ConfigurationValues[0];
+
+css::beans::Optional< css::uno::Any > getValue(ConfigurationValue const & data)
+{
+ GConfClient* aClient = getGconfClient();
+ GConfValue* aGconfValue;
+ if( ( data.nDependsOn == SETTINGS_LAST ) || isDependencySatisfied( aClient, data ) )
+ {
+ aGconfValue = gconf_client_get( aClient, data.GconfItem, NULL );
+
+ if( aGconfValue != NULL )
+ {
+ css::uno::Any value;
+ if( data.bNeedsTranslation )
+ value = translateToOOo( data, aGconfValue );
+ else
+ value = makeAnyOfGconfValue( aGconfValue );
+
+ gconf_value_free( aGconfValue );
+
+ return css::beans::Optional< css::uno::Any >(true, value);
+ }
+ }
+ return css::beans::Optional< css::uno::Any >();
+}
+
+}
diff --git a/shell/source/backends/gconfbe/gconfaccess.hxx b/shell/source/backends/gconfbe/gconfaccess.hxx
new file mode 100644
index 000000000000..7fdd82ff05e7
--- /dev/null
+++ b/shell/source/backends/gconfbe/gconfaccess.hxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#ifndef INCLUDED_SHELL_SOURCE_BACKENDS_GCONFBE_GCONFACCESS_HXX
+#define INCLUDED_SHELL_SOURCE_BACKENDS_GCONFBE_GCONFACCESS_HXX
+
+#include "sal/config.h"
+
+#include <cstddef>
+
+#include "com/sun/star/beans/Optional.hpp"
+#include "gconf/gconf-client.h"
+#include "sal/types.h"
+
+namespace com { namespace sun { namespace star { namespace uno {
+ class Any;
+} } } }
+
+namespace gconfaccess {
+
+enum ConfigurationSetting
+{
+ SETTING_PROXY_MODE,
+ SETTING_PROXY_HTTP_HOST,
+ SETTING_PROXY_HTTP_PORT,
+ SETTING_PROXY_HTTPS_HOST,
+ SETTING_PROXY_HTTPS_PORT,
+ SETTING_PROXY_FTP_HOST,
+ SETTING_PROXY_FTP_PORT,
+ SETTING_NO_PROXY_FOR,
+ SETTING_ENABLE_ACCESSIBILITY,
+ SETTING_MAILER_PROGRAM,
+ SETTING_WORK_DIRECTORY,
+ SETTING_SOURCEVIEWFONT_NAME,
+ SETTING_SOURCEVIEWFONT_HEIGHT,
+ SETTING_USER_GIVENNAME,
+ SETTING_USER_SURNAME,
+
+#ifdef ENABLE_LOCKDOWN
+
+ SETTING_DISABLE_PRINTING,
+ SETTING_USE_SYSTEM_FILE_DIALOG,
+ SETTING_PRINTING_MODIFIES_DOCUMENT,
+ SETTING_SHOW_ICONS_IN_MENUS,
+ SETTING_SHOW_INACTIVE_MENUITEMS,
+ SETTING_SHOW_FONT_PREVIEW,
+ SETTING_SHOW_FONT_HISTORY,
+ SETTING_ENABLE_OPENGL,
+ SETTING_OPTIMIZE_OPENGL,
+ SETTING_SAVE_DOCUMENT_WINDOWS,
+ SETTING_SAVE_DOCUMENT_VIEW_INFO,
+ SETTING_USE_SYSTEM_FONT,
+ SETTING_USE_FONT_ANTI_ALIASING,
+ SETTING_FONT_ANTI_ALIASING_MIN_PIXEL,
+ SETTING_WARN_CREATE_PDF,
+ SETTING_WARN_PRINT_DOC,
+ SETTING_WARN_SAVEORSEND_DOC,
+ SETTING_WARN_SIGN_DOC,
+ SETTING_REMOVE_PERSONAL_INFO,
+ SETTING_RECOMMEND_PASSWORD,
+ SETTING_UNDO_STEPS,
+ SETTING_SYMBOL_SET,
+ SETTING_MACRO_SECURITY_LEVEL,
+ SETTING_CREATE_BACKUP,
+ SETTING_WARN_ALIEN_FORMAT,
+ SETTING_AUTO_SAVE,
+ SETTING_AUTO_SAVE_INTERVAL,
+ SETTING_WRITER_DEFAULT_DOC_FORMAT,
+ SETTING_IMPRESS_DEFAULT_DOC_FORMAT,
+ SETTING_CALC_DEFAULT_DOC_FORMAT,
+
+#endif // ENABLE_LOCKDOWN
+
+ SETTINGS_LAST
+};
+
+struct ConfigurationValue
+{
+ const ConfigurationSetting nSettingId;
+ const gchar *GconfItem;
+ const char *OOoConfItem;
+ const sal_Bool bNeedsTranslation;
+ const ConfigurationSetting nDependsOn;
+};
+
+extern ConfigurationValue const ConfigurationValues[];
+
+extern std::size_t const nConfigurationValues;
+
+com::sun::star::beans::Optional< com::sun::star::uno::Any > getValue(
+ ConfigurationValue const & data);
+
+}
+
+#endif
diff --git a/shell/source/backends/gconfbe/gconfbackend.cxx b/shell/source/backends/gconfbe/gconfbackend.cxx
new file mode 100644
index 000000000000..122d1cad02b3
--- /dev/null
+++ b/shell/source/backends/gconfbe/gconfbackend.cxx
@@ -0,0 +1,239 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#include "precompiled_shell.hxx"
+#include "sal/config.h"
+
+#include <cstddef>
+
+#include "boost/noncopyable.hpp"
+#include "com/sun/star/beans/Optional.hpp"
+#include "com/sun/star/beans/PropertyVetoException.hpp"
+#include "com/sun/star/beans/UnknownPropertyException.hpp"
+#include "com/sun/star/beans/XPropertyChangeListener.hpp"
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/beans/XPropertySetInfo.hpp"
+#include "com/sun/star/beans/XVetoableChangeListener.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "com/sun/star/lang/WrappedTargetException.hpp"
+#include "com/sun/star/lang/XMultiComponentFactory.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/lang/WrappedTargetException.hpp"
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/XCurrentContext.hpp"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implbase2.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "cppuhelper/weak.hxx"
+#include "rtl/string.h"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "uno/current_context.hxx"
+#include "uno/lbnames.h"
+
+#include "gconfaccess.hxx"
+#include "orbit.h"
+
+namespace {
+
+namespace css = com::sun::star;
+
+rtl::OUString SAL_CALL getServiceImplementationName() {
+ return rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.configuration.backend.GconfBackend"));
+}
+
+css::uno::Sequence< rtl::OUString > SAL_CALL getServiceSupportedServiceNames() {
+ rtl::OUString name(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.backend.GconfBackend"));
+ return css::uno::Sequence< rtl::OUString >(&name, 1);
+}
+
+class Service:
+ public cppu::WeakImplHelper2<
+ css::lang::XServiceInfo, css::beans::XPropertySet >,
+ private boost::noncopyable
+{
+public:
+ Service();
+
+private:
+ virtual ~Service() {}
+
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException)
+ { return getServiceImplementationName(); }
+
+ virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
+ throw (css::uno::RuntimeException)
+ { return ServiceName == getSupportedServiceNames()[0]; }
+
+ virtual css::uno::Sequence< rtl::OUString > SAL_CALL
+ getSupportedServiceNames() throw (css::uno::RuntimeException)
+ { return getServiceSupportedServiceNames(); }
+
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo() throw (css::uno::RuntimeException)
+ { return css::uno::Reference< css::beans::XPropertySetInfo >(); }
+
+ virtual void SAL_CALL setPropertyValue(
+ rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL getPropertyValue(
+ rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual void SAL_CALL addPropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removePropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL addVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removeVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ bool enabled_;
+};
+
+Service::Service(): enabled_(false) {
+ css::uno::Reference< css::uno::XCurrentContext > context(
+ css::uno::getCurrentContext());
+ if (context.is()) {
+ rtl::OUString desktop;
+ context->getValueByName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("system.desktop-environment"))) >>=
+ desktop;
+ enabled_ = desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("GNOME")) &&
+ ((orbit_major_version == 2 && orbit_minor_version >= 8) ||
+ orbit_major_version > 2);
+ // ORBit-2 versions < 2.8 cause a deadlock with the gtk+ VCL plugin
+ }
+}
+
+void Service::setPropertyValue(rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ throw css::lang::IllegalArgumentException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")),
+ static_cast< cppu::OWeakObject * >(this), -1);
+}
+
+css::uno::Any Service::getPropertyValue(rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ for (std::size_t i = 0; i < gconfaccess::nConfigurationValues; ++i) {
+ if (PropertyName.equalsAscii(
+ gconfaccess::ConfigurationValues[i].OOoConfItem))
+ {
+ return css::uno::makeAny(
+ enabled_
+ ? gconfaccess::getValue(gconfaccess::ConfigurationValues[i])
+ : css::beans::Optional< css::uno::Any >());
+ }
+ }
+ throw css::beans::UnknownPropertyException(
+ PropertyName, static_cast< cppu::OWeakObject * >(this));
+}
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(
+ css::uno::Reference< css::uno::XComponentContext > const &)
+{
+ return static_cast< cppu::OWeakObject * >(new Service);
+}
+
+static cppu::ImplementationEntry const services[] = {
+ { &createInstance, &getServiceImplementationName,
+ &getServiceSupportedServiceNames, &cppu::createSingleComponentFactory, 0,
+ 0 },
+ { 0, 0, 0, 0, 0, 0 }
+};
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+ char const * pImplName, void * pServiceManager, void * pRegistryKey)
+{
+ return cppu::component_getFactoryHelper(
+ pImplName, pServiceManager, pRegistryKey, services);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ char const ** ppEnvTypeName, uno_Environment **)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey)
+{
+ return component_writeInfoHelper(pServiceManager, pRegistryKey, services);
+}
diff --git a/shell/source/backends/gconfbe/gconfbe1-ucd.txt b/shell/source/backends/gconfbe/gconfbe1-ucd.txt
new file mode 100644
index 000000000000..daa5444ff0c5
--- /dev/null
+++ b/shell/source/backends/gconfbe/gconfbe1-ucd.txt
@@ -0,0 +1,6 @@
+[ComponentDescriptor]
+ImplementationName=com.sun.star.comp.configuration.backend.GconfBackend
+ComponentName=gconfbe1.uno.so
+LoaderName=com.sun.star.loader.SharedLibrary
+[SupportedServices]
+com.sun.star.configuration.backend.GconfBackend
diff --git a/shell/source/backends/gconfbe/makefile.mk b/shell/source/backends/gconfbe/makefile.mk
new file mode 100644
index 000000000000..a8d9b23aa9df
--- /dev/null
+++ b/shell/source/backends/gconfbe/makefile.mk
@@ -0,0 +1,96 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=shell
+TARGET=gconfbe
+
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# no "lib" prefix
+DLLPRE =
+UCDSRCEXT = txt
+
+.IF "$(ENABLE_LOCKDOWN)" == "YES"
+CFLAGS+=-DENABLE_LOCKDOWN
+.ENDIF
+
+.IF "$(ENABLE_GCONF)"!=""
+COMPILER_WARN_ALL=TRUE
+PKGCONFIG_MODULES=gconf-2.0 gobject-2.0 ORBit-2.0 glib-2.0
+.INCLUDE: pkg_config.mk
+
+.IF "$(OS)" == "SOLARIS"
+LINKFLAGS+=-z nodefs
+.ENDIF # "$(OS)" == "SOLARIS"
+
+.IF "$(OS)" == "LINUX"
+# hack for faked SO environment
+CFLAGS+=-gdwarf-2
+PKGCONFIG_LIBS!:=-Wl,--export-dynamic $(PKGCONFIG_LIBS)
+.ENDIF
+
+# --- Files ---
+
+
+SLOFILES=\
+ $(SLO)$/gconfaccess.obj \
+ $(SLO)$/gconfbackend.obj
+
+SHL1NOCHECK=TRUE
+SHL1TARGET=$(TARGET)1.uno
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+SHL1IMPLIB=i$(SHL1TARGET)
+SHL1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+SHL1STDLIBS+=$(PKGCONFIG_LIBS)
+
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+.ENDIF # "$(ENABLE_GCONF)"!=""
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/$(TARGET)1-ucd.txt
+
+$(MISC)/$(TARGET)1-ucd.txt : $$(@:b).$(UCDSRCEXT)
+ cat $< | tr -d "\015" > $@
+
diff --git a/shell/source/backends/gconfbe/orbit.h b/shell/source/backends/gconfbe/orbit.h
new file mode 100644
index 000000000000..2858e8100dc8
--- /dev/null
+++ b/shell/source/backends/gconfbe/orbit.h
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_SHELL_SOURCE_BACKENDS_GCONFBE_ORBIT_H
+#define INCLUDED_SHELL_SOURCE_BACKENDS_GCONFBE_ORBIT_H
+
+#include "sal/config.h"
+
+#if defined __GNUC__
+#pragma GCC system_header
+#endif
+
+#include <orbit/orbit.h>
+
+#endif
diff --git a/shell/source/backends/kde4be/kde4access.cxx b/shell/source/backends/kde4be/kde4access.cxx
new file mode 100644
index 000000000000..336d2d4a458e
--- /dev/null
+++ b/shell/source/backends/kde4be/kde4access.cxx
@@ -0,0 +1,319 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#include "precompiled_shell.hxx"
+#include "sal/config.h"
+
+#include "QFont"
+#include "QString"
+#include "kemailsettings.h"
+#include "kglobalsettings.h"
+#include "kprotocolmanager.h"
+
+#include "com/sun/star/uno/Any.hxx"
+#include "cppu/unotype.hxx"
+#include "osl/diagnose.h"
+#include "osl/file.h"
+#include "rtl/string.h"
+#include "rtl/ustring.hxx"
+
+#include "kde4access.hxx"
+
+#define SPACE ' '
+#define COMMA ','
+#define SEMI_COLON ';'
+
+namespace kde4access {
+
+namespace {
+
+namespace css = com::sun::star ;
+namespace uno = css::uno ;
+
+}
+
+css::beans::Optional< css::uno::Any > getValue(rtl::OUString const & id) {
+ if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ExternalMailer"))) {
+ KEMailSettings aEmailSettings;
+ QString aClientProgram;
+ ::rtl::OUString sClientProgram;
+
+ aClientProgram = aEmailSettings.getSetting( KEMailSettings::ClientProgram );
+ if ( aClientProgram.isEmpty() )
+ aClientProgram = "kmail";
+ else
+ aClientProgram = aClientProgram.section(SPACE, 0, 0);
+ sClientProgram = (const sal_Unicode *) aClientProgram.utf16();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sClientProgram ) );
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("SourceViewFontHeight")))
+ {
+ QFont aFixedFont;
+ short nFontHeight;
+
+ aFixedFont = KGlobalSettings::fixedFont();
+ nFontHeight = aFixedFont.pointSize();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( nFontHeight ) );
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("SourceViewFontName")))
+ {
+ QFont aFixedFont;
+ QString aFontName;
+ :: rtl::OUString sFontName;
+
+ aFixedFont = KGlobalSettings::fixedFont();
+ aFontName = aFixedFont.family();
+ sFontName = (const sal_Unicode *) aFontName.utf16();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sFontName ) );
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("EnableATToolSupport")))
+ {
+ /* does not make much sense without an accessibility bridge */
+ sal_Bool ATToolSupport = sal_False;
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( rtl::OUString::valueOf( ATToolSupport ) ) );
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("WorkPathVariable")))
+ {
+ QString aDocumentsDir( KGlobalSettings::documentPath() );
+ rtl::OUString sDocumentsDir;
+ rtl::OUString sDocumentsURL;
+ if ( aDocumentsDir.endsWith(QChar('/')) )
+ aDocumentsDir.truncate ( aDocumentsDir.length() - 1 );
+ sDocumentsDir = (const sal_Unicode *) aDocumentsDir.utf16();
+ osl_getFileURLFromSystemPath( sDocumentsDir.pData, &sDocumentsURL.pData );
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sDocumentsURL ) );
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")))
+ {
+ QString aFTPProxy;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ aFTPProxy = KProtocolManager::proxyFor( "FTP" );
+ break;
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+// In such cases, the proxy address is not stored in KDE, but determined dynamically.
+// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
+// The best we can do here is to ask the current value for a given address.
+ aFTPProxy = KProtocolManager::proxyForUrl( KUrl("ftp://ftp.openoffice.org") );
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aFTPProxy.isEmpty() )
+ {
+ KUrl aProxy(aFTPProxy);
+ ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().utf16();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sProxy ) );
+ }
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")))
+ {
+ QString aFTPProxy;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ aFTPProxy = KProtocolManager::proxyFor( "FTP" );
+ break;
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+// In such cases, the proxy address is not stored in KDE, but determined dynamically.
+// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
+// The best we can do here is to ask the current value for a given address.
+ aFTPProxy = KProtocolManager::proxyForUrl( KUrl("ftp://ftp.openoffice.org") );
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aFTPProxy.isEmpty() )
+ {
+ KUrl aProxy(aFTPProxy);
+ sal_Int32 nPort = aProxy.port();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( nPort ) );
+ }
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")))
+ {
+ QString aHTTPProxy;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ aHTTPProxy = KProtocolManager::proxyFor( "HTTP" );
+ break;
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+// In such cases, the proxy address is not stored in KDE, but determined dynamically.
+// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
+// The best we can do here is to ask the current value for a given address.
+ aHTTPProxy = KProtocolManager::proxyForUrl( KUrl("http://http.openoffice.org") );
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aHTTPProxy.isEmpty() )
+ {
+ KUrl aProxy(aHTTPProxy);
+ ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().utf16();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sProxy ) );
+ }
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")))
+ {
+ QString aHTTPProxy;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ aHTTPProxy = KProtocolManager::proxyFor( "HTTP" );
+ break;
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+// In such cases, the proxy address is not stored in KDE, but determined dynamically.
+// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
+// The best we can do here is to ask the current value for a given address.
+ aHTTPProxy = KProtocolManager::proxyForUrl( KUrl("http://http.openoffice.org") );
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aHTTPProxy.isEmpty() )
+ {
+ KUrl aProxy(aHTTPProxy);
+ sal_Int32 nPort = aProxy.port();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( nPort ) );
+ }
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")))
+ {
+ QString aHTTPSProxy;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ aHTTPSProxy = KProtocolManager::proxyFor( "HTTPS" );
+ break;
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+// In such cases, the proxy address is not stored in KDE, but determined dynamically.
+// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
+// The best we can do here is to ask the current value for a given address.
+ aHTTPSProxy = KProtocolManager::proxyForUrl( KUrl("https://https.openoffice.org") );
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aHTTPSProxy.isEmpty() )
+ {
+ KUrl aProxy(aHTTPSProxy);
+ ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().utf16();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sProxy ) );
+ }
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")))
+ {
+ QString aHTTPSProxy;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ aHTTPSProxy = KProtocolManager::proxyFor( "HTTPS" );
+ break;
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+// In such cases, the proxy address is not stored in KDE, but determined dynamically.
+// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
+// The best we can do here is to ask the current value for a given address.
+ aHTTPSProxy = KProtocolManager::proxyForUrl( KUrl("https://https.openoffice.org") );
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aHTTPSProxy.isEmpty() )
+ {
+ KUrl aProxy(aHTTPSProxy);
+ sal_Int32 nPort = aProxy.port();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( nPort ) );
+ }
+ } else if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy"))) {
+ QString aNoProxyFor;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+ aNoProxyFor = KProtocolManager::noProxyFor();
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aNoProxyFor.isEmpty() )
+ {
+ ::rtl::OUString sNoProxyFor;
+
+ aNoProxyFor = aNoProxyFor.replace( COMMA, SEMI_COLON );
+ sNoProxyFor = (const sal_Unicode *) aNoProxyFor.utf16();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sNoProxyFor ) );
+ }
+ } else if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ooInetProxyType"))) {
+ int nProxyType;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+ nProxyType = 1;
+ break;
+ default: // No proxy is used
+ nProxyType = 0;
+ }
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( (sal_Int32) nProxyType ) );
+ } else {
+ OSL_ASSERT(false); // this cannot happen
+ }
+ return css::beans::Optional< css::uno::Any >();
+}
+
+}
diff --git a/shell/source/backends/kde4be/kde4access.hxx b/shell/source/backends/kde4be/kde4access.hxx
new file mode 100644
index 000000000000..bfb7bc1ac945
--- /dev/null
+++ b/shell/source/backends/kde4be/kde4access.hxx
@@ -0,0 +1,47 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#ifndef INCLUDED_SHELL_SOURCE_BACKENDS_KDE4BE_KDE4ACCESS_HXX
+#define INCLUDED_SHELL_SOURCE_BACKENDS_KDE4BE_KDE4ACCESS_HXX
+
+#include "sal/config.h"
+
+#include "com/sun/star/beans/Optional.hpp"
+
+namespace com { namespace sun { namespace star { namespace uno {
+ class Any;
+} } } }
+namespace rtl { class OUString; }
+
+namespace kde4access {
+
+com::sun::star::beans::Optional< com::sun::star::uno::Any > getValue(
+ rtl::OUString const & id);
+
+}
+
+#endif
diff --git a/shell/source/backends/kde4be/kde4backend.cxx b/shell/source/backends/kde4be/kde4backend.cxx
new file mode 100644
index 000000000000..44ddb49bd025
--- /dev/null
+++ b/shell/source/backends/kde4be/kde4backend.cxx
@@ -0,0 +1,258 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#include "precompiled_shell.hxx"
+#include "sal/config.h"
+
+#include "kapplication.h"
+
+#include "boost/noncopyable.hpp"
+#include "com/sun/star/beans/Optional.hpp"
+#include "com/sun/star/beans/PropertyVetoException.hpp"
+#include "com/sun/star/beans/UnknownPropertyException.hpp"
+#include "com/sun/star/beans/XPropertyChangeListener.hpp"
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/beans/XPropertySetInfo.hpp"
+#include "com/sun/star/beans/XVetoableChangeListener.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "com/sun/star/lang/WrappedTargetException.hpp"
+#include "com/sun/star/lang/XMultiComponentFactory.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/lang/WrappedTargetException.hpp"
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/XCurrentContext.hpp"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implbase2.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "cppuhelper/weak.hxx"
+#include "rtl/string.h"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "uno/current_context.hxx"
+#include "uno/lbnames.h"
+
+#include "kde4access.hxx"
+
+namespace {
+
+namespace css = com::sun::star;
+
+rtl::OUString SAL_CALL getServiceImplementationName() {
+ return rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.configuration.backend.KDE4Backend"));
+}
+
+css::uno::Sequence< rtl::OUString > SAL_CALL getServiceSupportedServiceNames() {
+ rtl::OUString name(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.backend.KDE4Backend"));
+ return css::uno::Sequence< rtl::OUString >(&name, 1);
+}
+
+class Service:
+ public cppu::WeakImplHelper2<
+ css::lang::XServiceInfo, css::beans::XPropertySet >,
+ private boost::noncopyable
+{
+public:
+ Service();
+
+private:
+ virtual ~Service() {}
+
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException)
+ { return getServiceImplementationName(); }
+
+ virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
+ throw (css::uno::RuntimeException)
+ { return ServiceName == getSupportedServiceNames()[0]; }
+
+ virtual css::uno::Sequence< rtl::OUString > SAL_CALL
+ getSupportedServiceNames() throw (css::uno::RuntimeException)
+ { return getServiceSupportedServiceNames(); }
+
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo() throw (css::uno::RuntimeException)
+ { return css::uno::Reference< css::beans::XPropertySetInfo >(); }
+
+ virtual void SAL_CALL setPropertyValue(
+ rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL getPropertyValue(
+ rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual void SAL_CALL addPropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removePropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL addVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removeVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ bool enabled_;
+};
+
+Service::Service(): enabled_(false) {
+ css::uno::Reference< css::uno::XCurrentContext > context(
+ css::uno::getCurrentContext());
+ if (context.is()) {
+ rtl::OUString desktop;
+ context->getValueByName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("system.desktop-environment"))) >>=
+ desktop;
+ enabled_ = desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("KDE4")) &&
+ KApplication::kApplication() != 0;
+ }
+}
+
+void Service::setPropertyValue(rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ throw css::lang::IllegalArgumentException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")),
+ static_cast< cppu::OWeakObject * >(this), -1);
+}
+
+css::uno::Any Service::getPropertyValue(rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("EnableATToolSupport")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ExternalMailer")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("SourceViewFontHeight")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("SourceViewFontName")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("WorkPathVariable")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetProxyType")))
+ {
+ return css::uno::makeAny(
+ enabled_
+ ? kde4access::getValue(PropertyName)
+ : css::beans::Optional< css::uno::Any >());
+ }
+ throw css::beans::UnknownPropertyException(
+ PropertyName, static_cast< cppu::OWeakObject * >(this));
+}
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(
+ css::uno::Reference< css::uno::XComponentContext > const &)
+{
+ return static_cast< cppu::OWeakObject * >(new Service);
+}
+
+static cppu::ImplementationEntry const services[] = {
+ { &createInstance, &getServiceImplementationName,
+ &getServiceSupportedServiceNames, &cppu::createSingleComponentFactory, 0,
+ 0 },
+ { 0, 0, 0, 0, 0, 0 }
+};
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+ char const * pImplName, void * pServiceManager, void * pRegistryKey)
+{
+ return cppu::component_getFactoryHelper(
+ pImplName, pServiceManager, pRegistryKey, services);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ char const ** ppEnvTypeName, uno_Environment **)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey)
+{
+ return component_writeInfoHelper(pServiceManager, pRegistryKey, services);
+}
diff --git a/shell/source/backends/kde4be/kde4be1-ucd.txt b/shell/source/backends/kde4be/kde4be1-ucd.txt
new file mode 100644
index 000000000000..9671199b26e3
--- /dev/null
+++ b/shell/source/backends/kde4be/kde4be1-ucd.txt
@@ -0,0 +1,6 @@
+[ComponentDescriptor]
+ImplementationName=com.sun.star.comp.configuration.backend.KDE4Backend
+ComponentName=kde4be1.uno.so
+LoaderName=com.sun.star.loader.SharedLibrary
+[SupportedServices]
+com.sun.star.configuration.backend.KDE4Backend
diff --git a/shell/source/backends/kde4be/makefile.mk b/shell/source/backends/kde4be/makefile.mk
new file mode 100644
index 000000000000..1f9093a95aee
--- /dev/null
+++ b/shell/source/backends/kde4be/makefile.mk
@@ -0,0 +1,81 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=shell
+TARGET=kde4be
+
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# For some of the included external KDE headers, GCC complains about shadowed
+# symbols in instantiated template code only at the end of a compilation unit,
+# so the only solution is to disable that warning here:
+.IF "$(COM)" == "GCC"
+CFLAGSCXX+=-Wno-shadow
+.ENDIF
+
+UNIXTEXT=$(MISC)/$(TARGET)1-ucd.txt
+
+# no "lib" prefix
+DLLPRE =
+
+.IF "$(ENABLE_KDE4)" == "TRUE"
+
+CFLAGS+=$(KDE4_CFLAGS)
+
+# --- Files ---
+
+SLOFILES=\
+ $(SLO)$/kde4access.obj \
+ $(SLO)$/kde4backend.obj
+
+SHL1NOCHECK=TRUE
+SHL1TARGET=$(TARGET)1.uno
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+SHL1IMPLIB=i$(SHL1TARGET)
+SHL1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(KDE4_LIBS) -lkio
+
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+.ENDIF
+
+# --- Targets ---
+
+.INCLUDE : target.mk
diff --git a/shell/source/backends/kdebe/kdeaccess.cxx b/shell/source/backends/kdebe/kdeaccess.cxx
new file mode 100644
index 000000000000..618d74b5eacf
--- /dev/null
+++ b/shell/source/backends/kdebe/kdeaccess.cxx
@@ -0,0 +1,315 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#include "precompiled_shell.hxx"
+#include "sal/config.h"
+
+#include "com/sun/star/uno/Any.hxx"
+#include "cppu/unotype.hxx"
+#include "osl/diagnose.h"
+#include "osl/file.h"
+#include "rtl/string.h"
+#include "rtl/ustring.hxx"
+
+#include "kde_headers.h"
+
+#include "kdeaccess.hxx"
+
+#define SPACE ' '
+#define COMMA ','
+#define SEMI_COLON ';'
+
+namespace kdeaccess {
+
+namespace {
+
+namespace css = com::sun::star ;
+namespace uno = css::uno ;
+
+}
+
+css::beans::Optional< css::uno::Any > getValue(rtl::OUString const & id) {
+ if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ExternalMailer"))) {
+ KEMailSettings aEmailSettings;
+ QString aClientProgram;
+ ::rtl::OUString sClientProgram;
+
+ aClientProgram = aEmailSettings.getSetting( KEMailSettings::ClientProgram );
+ if ( aClientProgram.isEmpty() )
+ aClientProgram = "kmail";
+ else
+ aClientProgram = aClientProgram.section(SPACE, 0, 0);
+ sClientProgram = (const sal_Unicode *) aClientProgram.ucs2();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sClientProgram ) );
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("SourceViewFontHeight")))
+ {
+ QFont aFixedFont;
+ short nFontHeight;
+
+ aFixedFont = KGlobalSettings::fixedFont();
+ nFontHeight = aFixedFont.pointSize();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( nFontHeight ) );
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("SourceViewFontName")))
+ {
+ QFont aFixedFont;
+ QString aFontName;
+ :: rtl::OUString sFontName;
+
+ aFixedFont = KGlobalSettings::fixedFont();
+ aFontName = aFixedFont.family();
+ sFontName = (const sal_Unicode *) aFontName.ucs2();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sFontName ) );
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("EnableATToolSupport")))
+ {
+ /* does not make much sense without an accessibility bridge */
+ sal_Bool ATToolSupport = sal_False;
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( rtl::OUString::valueOf( ATToolSupport ) ) );
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("WorkPathVariable")))
+ {
+ QString aDocumentsDir( KGlobalSettings::documentPath() );
+ rtl::OUString sDocumentsDir;
+ rtl::OUString sDocumentsURL;
+ if ( aDocumentsDir.endsWith(QChar('/')) )
+ aDocumentsDir.truncate ( aDocumentsDir.length() - 1 );
+ sDocumentsDir = (const sal_Unicode *) aDocumentsDir.ucs2();
+ osl_getFileURLFromSystemPath( sDocumentsDir.pData, &sDocumentsURL.pData );
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sDocumentsURL ) );
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")))
+ {
+ QString aFTPProxy;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ aFTPProxy = KProtocolManager::proxyFor( "FTP" );
+ break;
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+// In such cases, the proxy address is not stored in KDE, but determined dynamically.
+// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
+// The best we can do here is to ask the current value for a given address.
+ aFTPProxy = KProtocolManager::proxyForURL( "ftp://ftp.openoffice.org" );
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aFTPProxy.isEmpty() )
+ {
+ KURL aProxy(aFTPProxy);
+ ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().ucs2();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sProxy ) );
+ }
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")))
+ {
+ QString aFTPProxy;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ aFTPProxy = KProtocolManager::proxyFor( "FTP" );
+ break;
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+// In such cases, the proxy address is not stored in KDE, but determined dynamically.
+// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
+// The best we can do here is to ask the current value for a given address.
+ aFTPProxy = KProtocolManager::proxyForURL( "ftp://ftp.openoffice.org" );
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aFTPProxy.isEmpty() )
+ {
+ KURL aProxy(aFTPProxy);
+ sal_Int32 nPort = aProxy.port();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( nPort ) );
+ }
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")))
+ {
+ QString aHTTPProxy;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ aHTTPProxy = KProtocolManager::proxyFor( "HTTP" );
+ break;
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+// In such cases, the proxy address is not stored in KDE, but determined dynamically.
+// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
+// The best we can do here is to ask the current value for a given address.
+ aHTTPProxy = KProtocolManager::proxyForURL( "http://http.openoffice.org" );
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aHTTPProxy.isEmpty() )
+ {
+ KURL aProxy(aHTTPProxy);
+ ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().ucs2();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sProxy ) );
+ }
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")))
+ {
+ QString aHTTPProxy;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ aHTTPProxy = KProtocolManager::proxyFor( "HTTP" );
+ break;
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+// In such cases, the proxy address is not stored in KDE, but determined dynamically.
+// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
+// The best we can do here is to ask the current value for a given address.
+ aHTTPProxy = KProtocolManager::proxyForURL( "http://http.openoffice.org" );
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aHTTPProxy.isEmpty() )
+ {
+ KURL aProxy(aHTTPProxy);
+ sal_Int32 nPort = aProxy.port();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( nPort ) );
+ }
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")))
+ {
+ QString aHTTPSProxy;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ aHTTPSProxy = KProtocolManager::proxyFor( "HTTPS" );
+ break;
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+// In such cases, the proxy address is not stored in KDE, but determined dynamically.
+// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
+// The best we can do here is to ask the current value for a given address.
+ aHTTPSProxy = KProtocolManager::proxyForURL( "https://https.openoffice.org" );
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aHTTPSProxy.isEmpty() )
+ {
+ KURL aProxy(aHTTPSProxy);
+ ::rtl::OUString sProxy = (const sal_Unicode *) aProxy.host().ucs2();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sProxy ) );
+ }
+ } else if (id.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")))
+ {
+ QString aHTTPSProxy;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ aHTTPSProxy = KProtocolManager::proxyFor( "HTTPS" );
+ break;
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+// In such cases, the proxy address is not stored in KDE, but determined dynamically.
+// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind...
+// The best we can do here is to ask the current value for a given address.
+ aHTTPSProxy = KProtocolManager::proxyForURL( "https://https.openoffice.org" );
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aHTTPSProxy.isEmpty() )
+ {
+ KURL aProxy(aHTTPSProxy);
+ sal_Int32 nPort = aProxy.port();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( nPort ) );
+ }
+ } else if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy"))) {
+ QString aNoProxyFor;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+ aNoProxyFor = KProtocolManager::noProxyFor();
+ break;
+ default: // No proxy is used
+ break;
+ }
+ if ( !aNoProxyFor.isEmpty() )
+ {
+ ::rtl::OUString sNoProxyFor;
+
+ aNoProxyFor = aNoProxyFor.replace( COMMA, SEMI_COLON );
+ sNoProxyFor = (const sal_Unicode *) aNoProxyFor.ucs2();
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( sNoProxyFor ) );
+ }
+ } else if (id.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ooInetProxyType"))) {
+ int nProxyType;
+ switch ( KProtocolManager::proxyType() )
+ {
+ case KProtocolManager::ManualProxy: // Proxies are manually configured
+ case KProtocolManager::PACProxy: // A proxy configuration URL has been given
+ case KProtocolManager::WPADProxy: // A proxy should be automatically discovered
+ case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables
+ nProxyType = 1;
+ break;
+ default: // No proxy is used
+ nProxyType = 0;
+ }
+ return css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( (sal_Int32) nProxyType ) );
+ } else {
+ OSL_ASSERT(false); // this cannot happen
+ }
+ return css::beans::Optional< css::uno::Any >();
+}
+
+}
diff --git a/shell/source/backends/kdebe/kdeaccess.hxx b/shell/source/backends/kdebe/kdeaccess.hxx
new file mode 100644
index 000000000000..36a22e23db9a
--- /dev/null
+++ b/shell/source/backends/kdebe/kdeaccess.hxx
@@ -0,0 +1,47 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#ifndef INCLUDED_SHELL_SOURCE_BACKENDS_KDEBE_KDEACCESS_HXX
+#define INCLUDED_SHELL_SOURCE_BACKENDS_KDEBE_KDEACCESS_HXX
+
+#include "sal/config.h"
+
+#include "com/sun/star/beans/Optional.hpp"
+
+namespace com { namespace sun { namespace star { namespace uno {
+ class Any;
+} } } }
+namespace rtl { class OUString; }
+
+namespace kdeaccess {
+
+com::sun::star::beans::Optional< com::sun::star::uno::Any > getValue(
+ rtl::OUString const & id);
+
+}
+
+#endif
diff --git a/shell/source/backends/kdebe/kdebackend.cxx b/shell/source/backends/kdebe/kdebackend.cxx
new file mode 100644
index 000000000000..53a00cf35987
--- /dev/null
+++ b/shell/source/backends/kdebe/kdebackend.cxx
@@ -0,0 +1,258 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#include "precompiled_shell.hxx"
+#include "sal/config.h"
+
+#include "boost/noncopyable.hpp"
+#include "com/sun/star/beans/Optional.hpp"
+#include "com/sun/star/beans/PropertyVetoException.hpp"
+#include "com/sun/star/beans/UnknownPropertyException.hpp"
+#include "com/sun/star/beans/XPropertyChangeListener.hpp"
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/beans/XPropertySetInfo.hpp"
+#include "com/sun/star/beans/XVetoableChangeListener.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "com/sun/star/lang/WrappedTargetException.hpp"
+#include "com/sun/star/lang/XMultiComponentFactory.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/lang/WrappedTargetException.hpp"
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/XCurrentContext.hpp"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implbase2.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "cppuhelper/weak.hxx"
+#include "rtl/string.h"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "uno/current_context.hxx"
+#include "uno/lbnames.h"
+
+#include "kde_headers.h"
+
+#include "kdeaccess.hxx"
+
+namespace {
+
+namespace css = com::sun::star;
+
+rtl::OUString SAL_CALL getServiceImplementationName() {
+ return rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.configuration.backend.KDEBackend"));
+}
+
+css::uno::Sequence< rtl::OUString > SAL_CALL getServiceSupportedServiceNames() {
+ rtl::OUString name(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.backend.KDEBackend"));
+ return css::uno::Sequence< rtl::OUString >(&name, 1);
+}
+
+class Service:
+ public cppu::WeakImplHelper2<
+ css::lang::XServiceInfo, css::beans::XPropertySet >,
+ private boost::noncopyable
+{
+public:
+ Service();
+
+private:
+ virtual ~Service() {}
+
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException)
+ { return getServiceImplementationName(); }
+
+ virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
+ throw (css::uno::RuntimeException)
+ { return ServiceName == getSupportedServiceNames()[0]; }
+
+ virtual css::uno::Sequence< rtl::OUString > SAL_CALL
+ getSupportedServiceNames() throw (css::uno::RuntimeException)
+ { return getServiceSupportedServiceNames(); }
+
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo() throw (css::uno::RuntimeException)
+ { return css::uno::Reference< css::beans::XPropertySetInfo >(); }
+
+ virtual void SAL_CALL setPropertyValue(
+ rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL getPropertyValue(
+ rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual void SAL_CALL addPropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removePropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL addVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removeVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ bool enabled_;
+};
+
+Service::Service(): enabled_(false) {
+ css::uno::Reference< css::uno::XCurrentContext > context(
+ css::uno::getCurrentContext());
+ if (context.is()) {
+ rtl::OUString desktop;
+ context->getValueByName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("system.desktop-environment"))) >>=
+ desktop;
+ enabled_ = desktop.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("KDE")) &&
+ KApplication::kApplication() != 0;
+ }
+}
+
+void Service::setPropertyValue(rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ throw css::lang::IllegalArgumentException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")),
+ static_cast< cppu::OWeakObject * >(this), -1);
+}
+
+css::uno::Any Service::getPropertyValue(rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("EnableATToolSupport")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ExternalMailer")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("SourceViewFontHeight")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("SourceViewFontName")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("WorkPathVariable")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy")) ||
+ PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetProxyType")))
+ {
+ return css::uno::makeAny(
+ enabled_
+ ? kdeaccess::getValue(PropertyName)
+ : css::beans::Optional< css::uno::Any >());
+ }
+ throw css::beans::UnknownPropertyException(
+ PropertyName, static_cast< cppu::OWeakObject * >(this));
+}
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(
+ css::uno::Reference< css::uno::XComponentContext > const &)
+{
+ return static_cast< cppu::OWeakObject * >(new Service);
+}
+
+static cppu::ImplementationEntry const services[] = {
+ { &createInstance, &getServiceImplementationName,
+ &getServiceSupportedServiceNames, &cppu::createSingleComponentFactory, 0,
+ 0 },
+ { 0, 0, 0, 0, 0, 0 }
+};
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+ char const * pImplName, void * pServiceManager, void * pRegistryKey)
+{
+ return cppu::component_getFactoryHelper(
+ pImplName, pServiceManager, pRegistryKey, services);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ char const ** ppEnvTypeName, uno_Environment **)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey)
+{
+ return component_writeInfoHelper(pServiceManager, pRegistryKey, services);
+}
diff --git a/shell/source/backends/kdebe/kdebe1-ucd.txt b/shell/source/backends/kdebe/kdebe1-ucd.txt
new file mode 100644
index 000000000000..adf7e17431f8
--- /dev/null
+++ b/shell/source/backends/kdebe/kdebe1-ucd.txt
@@ -0,0 +1,6 @@
+[ComponentDescriptor]
+ImplementationName=com.sun.star.comp.configuration.backend.KDEBackend
+ComponentName=kdebe1.uno.so
+LoaderName=com.sun.star.loader.SharedLibrary
+[SupportedServices]
+com.sun.star.configuration.backend.KDEBackend
diff --git a/shell/source/backends/kdebe/makefile.mk b/shell/source/backends/kdebe/makefile.mk
new file mode 100644
index 000000000000..b63e2332624f
--- /dev/null
+++ b/shell/source/backends/kdebe/makefile.mk
@@ -0,0 +1,81 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=shell
+TARGET=kdebe
+
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# For some of the included external KDE headers, GCC complains about shadowed
+# symbols in instantiated template code only at the end of a compilation unit,
+# so the only solution is to disable that warning here:
+.IF "$(COM)" == "GCC"
+CFLAGSCXX+=-Wno-shadow
+.ENDIF
+
+UNIXTEXT=$(MISC)/$(TARGET)1-ucd.txt
+
+# no "lib" prefix
+DLLPRE =
+
+.IF "$(ENABLE_KDE)" == "TRUE"
+
+CFLAGS+=$(KDE_CFLAGS)
+
+# --- Files ---
+
+SLOFILES=\
+ $(SLO)$/kdeaccess.obj \
+ $(SLO)$/kdebackend.obj
+
+SHL1NOCHECK=TRUE
+SHL1TARGET=$(TARGET)1.uno
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+SHL1IMPLIB=i$(SHL1TARGET)
+SHL1LINKFLAGS+=$(KDE_LIBS) -lkio
+SHL1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+.ENDIF # "$(ENABLE_KDE)" == "TRUE"
+
+# --- Targets ---
+
+.INCLUDE : target.mk
diff --git a/shell/source/backends/localebe/exports.map b/shell/source/backends/localebe/exports.map
new file mode 100644
index 000000000000..ba501f9ae076
--- /dev/null
+++ b/shell/source/backends/localebe/exports.map
@@ -0,0 +1,10 @@
+UDK_3_0_0 {
+ global:
+ GetVersionInfo;
+ component_getImplementationEnvironment;
+ component_getFactory;
+ component_writeInfo;
+
+ local:
+ *;
+};
diff --git a/shell/source/backends/localebe/localebackend.cxx b/shell/source/backends/localebe/localebackend.cxx
new file mode 100644
index 000000000000..1335d4a7fa50
--- /dev/null
+++ b/shell/source/backends/localebe/localebackend.cxx
@@ -0,0 +1,367 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#include "localebackend.hxx"
+#include <com/sun/star/beans/Optional.hpp>
+#include <osl/time.h>
+
+#include <stdio.h>
+
+#if defined(LINUX) || defined(SOLARIS) || defined(NETBSD) || defined(FREEBSD) || defined(OS2)
+
+#include <rtl/ustrbuf.hxx>
+#include <locale.h>
+#include <string.h>
+
+/*
+ * Note: setlocale is not at all thread safe, so is this code. It could
+ * especially interfere with the stuff VCL is doing, so make sure this
+ * is called from the main thread only.
+ */
+
+static rtl::OUString ImplGetLocale(int category)
+{
+ const char *locale = setlocale(category, "");
+
+ // Return "en-US" for C locales
+ if( (locale == NULL) || ( locale[0] == 'C' && locale[1] == '\0' ) )
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "en-US" ) );
+
+
+ const char *cp;
+ const char *uscore = NULL;
+
+ // locale string have the format lang[_ctry][.encoding][@modifier]
+ // we are only interested in the first two items, so we handle
+ // '.' and '@' as string end.
+ for (cp = locale; *cp; cp++)
+ {
+ if (*cp == '_')
+ uscore = cp;
+ if (*cp == '.' || *cp == '@')
+ break;
+ }
+
+ rtl::OUStringBuffer aLocaleBuffer;
+ if( uscore != NULL )
+ {
+ aLocaleBuffer.appendAscii(locale, uscore++ - locale);
+ aLocaleBuffer.appendAscii("-");
+ aLocaleBuffer.appendAscii(uscore, cp - uscore);
+ }
+ else
+ {
+ aLocaleBuffer.appendAscii(locale, cp - locale);
+ }
+
+ return aLocaleBuffer.makeStringAndClear();
+}
+
+#elif defined(MACOSX)
+
+#include <rtl/ustrbuf.hxx>
+#include <locale.h>
+#include <string.h>
+
+#include <premac.h>
+#include <CoreServices/CoreServices.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include <postmac.h>
+
+namespace /* private */
+{
+
+ void OUStringBufferAppendCFString(rtl::OUStringBuffer& buffer, const CFStringRef s)
+ {
+ CFIndex lstr = CFStringGetLength(s);
+ for (CFIndex i = 0; i < lstr; i++)
+ buffer.append(CFStringGetCharacterAtIndex(s, i));
+ }
+
+ template <typename T>
+ class CFGuard
+ {
+ public:
+ explicit CFGuard(T& rT) : rT_(rT) {}
+ ~CFGuard() { if (rT_) CFRelease(rT_); }
+ private:
+ T& rT_;
+ };
+
+ typedef CFGuard<CFArrayRef> CFArrayGuard;
+ typedef CFGuard<CFStringRef> CFStringGuard;
+ typedef CFGuard<CFTypeRef> CFTypeRefGuard;
+
+ /* For more information on the Apple locale concept please refer to
+ http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFLocales/Articles/CFLocaleConcepts.html
+ According to this documentation a locale identifier has the format: language[_country][_variant]*
+ e.g. es_ES_PREEURO -> spain prior Euro support
+ Note: The calling code should be able to handle locales with only language information e.g. 'en' for certain
+ UI languages just the language code will be returned.
+ */
+
+ CFStringRef ImplGetAppPreference(const char* pref)
+ {
+ CFStringRef csPref = CFStringCreateWithCString(NULL, pref, kCFStringEncodingASCII);
+ CFStringGuard csRefGuard(csPref);
+
+ CFTypeRef ref = CFPreferencesCopyAppValue(csPref, kCFPreferencesCurrentApplication);
+ CFTypeRefGuard refGuard(ref);
+
+ if (ref == NULL)
+ return NULL;
+
+ CFStringRef sref = (CFGetTypeID(ref) == CFArrayGetTypeID()) ? (CFStringRef)CFArrayGetValueAtIndex((CFArrayRef)ref, 0) : (CFStringRef)ref;
+
+ // NOTE: this API is only available with Mac OS X >=10.3. We need to use it because
+ // Apple used non-ISO values on systems <10.2 like "German" for instance but didn't
+ // upgrade those values during upgrade to newer Mac OS X versions. See also #i54337#
+ return CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorDefault, sref);
+ }
+
+ rtl::OUString ImplGetLocale(const char* pref)
+ {
+ CFStringRef sref = ImplGetAppPreference(pref);
+ CFStringGuard srefGuard(sref);
+
+ rtl::OUStringBuffer aLocaleBuffer;
+ aLocaleBuffer.appendAscii("en-US"); // initialize with fallback value
+
+ if (sref != NULL)
+ {
+ // split the string into substrings; the first two (if there are two) substrings
+ // are language and country
+ CFArrayRef subs = CFStringCreateArrayBySeparatingStrings(NULL, sref, CFSTR("_"));
+ CFArrayGuard subsGuard(subs);
+
+ if (subs != NULL)
+ {
+ aLocaleBuffer.setLength(0); // clear buffer which still contains fallback value
+
+ CFStringRef lang = (CFStringRef)CFArrayGetValueAtIndex(subs, 0);
+ OUStringBufferAppendCFString(aLocaleBuffer, lang);
+
+ // country also available? Assumption: if the array contains more than one
+ // value the second value is always the country!
+ if (CFArrayGetCount(subs) > 1)
+ {
+ aLocaleBuffer.appendAscii("-");
+ CFStringRef country = (CFStringRef)CFArrayGetValueAtIndex(subs, 1);
+ OUStringBufferAppendCFString(aLocaleBuffer, country);
+ }
+ }
+ }
+ return aLocaleBuffer.makeStringAndClear();
+ }
+
+} // namespace /* private */
+
+#endif
+
+// -------------------------------------------------------------------------------
+
+#ifdef WNT
+
+#ifdef WINVER
+#undef WINVER
+#endif
+#define WINVER 0x0501
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+rtl::OUString ImplGetLocale(LCID lcid)
+{
+ TCHAR buffer[8];
+ LPTSTR cp = buffer;
+
+ cp += GetLocaleInfo( lcid, LOCALE_SISO639LANGNAME , buffer, 4 );
+ if( cp > buffer )
+ {
+ if( 0 < GetLocaleInfo( lcid, LOCALE_SISO3166CTRYNAME, cp, buffer + 8 - cp) )
+ // #i50822# minus character must be written before cp
+ *(cp - 1) = '-';
+
+ return rtl::OUString::createFromAscii(buffer);
+ }
+
+ return rtl::OUString();
+}
+
+#endif // WNT
+
+// -------------------------------------------------------------------------------
+
+LocaleBackend::LocaleBackend()
+{
+}
+
+//------------------------------------------------------------------------------
+
+LocaleBackend::~LocaleBackend(void)
+{
+}
+
+//------------------------------------------------------------------------------
+
+LocaleBackend* LocaleBackend::createInstance()
+{
+ return new LocaleBackend;
+}
+
+// ---------------------------------------------------------------------------------------
+
+rtl::OUString LocaleBackend::getLocale(void)
+{
+#if defined(LINUX) || defined(SOLARIS) || defined(NETBSD) || defined(FREEBSD) || defined(OS2)
+ return ImplGetLocale(LC_CTYPE);
+#elif defined (MACOSX)
+ return ImplGetLocale("AppleLocale");
+#elif defined WNT
+ return ImplGetLocale( GetUserDefaultLCID() );
+#endif
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString LocaleBackend::getUILocale(void)
+{
+#if defined(LINUX) || defined(SOLARIS) || defined(NETBSD) || defined(FREEBSD) || defined(OS2)
+ return ImplGetLocale(LC_MESSAGES);
+#elif defined(MACOSX)
+ return ImplGetLocale("AppleLanguages");
+#elif defined WNT
+ return ImplGetLocale( MAKELCID(GetUserDefaultUILanguage(), SORT_DEFAULT) );
+#endif
+}
+
+// ---------------------------------------------------------------------------------------
+
+rtl::OUString LocaleBackend::getSystemLocale(void)
+{
+// note: the implementation differs from getLocale() only on Windows
+#if defined WNT
+ return ImplGetLocale( GetSystemDefaultLCID() );
+#else
+ return getLocale();
+#endif
+}
+//------------------------------------------------------------------------------
+
+void LocaleBackend::setPropertyValue(
+ rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ throw css::lang::IllegalArgumentException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")),
+ static_cast< cppu::OWeakObject * >(this), -1);
+}
+
+css::uno::Any LocaleBackend::getPropertyValue(
+ rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ if (PropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Locale"))) {
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true, css::uno::makeAny(getLocale())));
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("SystemLocale")))
+ {
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true, css::uno::makeAny(getSystemLocale())));
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("UILocale")))
+ {
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true, css::uno::makeAny(getUILocale())));
+ } else {
+ throw css::beans::UnknownPropertyException(
+ PropertyName, static_cast< cppu::OWeakObject * >(this));
+ }
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString SAL_CALL LocaleBackend::getBackendName(void) {
+ return rtl::OUString::createFromAscii("com.sun.star.comp.configuration.backend.LocaleBackend") ;
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString SAL_CALL LocaleBackend::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return getBackendName() ;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence<rtl::OUString> SAL_CALL LocaleBackend::getBackendServiceNames(void)
+{
+ uno::Sequence<rtl::OUString> aServiceNameList(1);
+ aServiceNameList[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.LocaleBackend")) ;
+ return aServiceNameList ;
+}
+
+//------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL LocaleBackend::supportsService(const rtl::OUString& aServiceName)
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< rtl::OUString > const svc = getBackendServiceNames();
+
+ for(sal_Int32 i = 0; i < svc.getLength(); ++i )
+ if(svc[i] == aServiceName)
+ return true;
+
+ return false;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence<rtl::OUString> SAL_CALL LocaleBackend::getSupportedServiceNames(void)
+ throw (uno::RuntimeException)
+{
+ return getBackendServiceNames() ;
+}
diff --git a/shell/source/backends/localebe/localebackend.hxx b/shell/source/backends/localebe/localebackend.hxx
new file mode 100644
index 000000000000..29950a3df913
--- /dev/null
+++ b/shell/source/backends/localebe/localebackend.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _FIXEDVALUEBACKEND_HXX_
+#define _FIXEDVALUEBACKEND_HXX_
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <rtl/string.hxx>
+
+
+namespace css = com::sun::star ;
+namespace uno = css::uno ;
+namespace lang = css::lang ;
+
+class LocaleBackend : public ::cppu::WeakImplHelper2 <
+ css::beans::XPropertySet,
+ lang::XServiceInfo > {
+
+ public :
+
+ static LocaleBackend* createInstance();
+
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL
+ getImplementationName( )
+ throw (uno::RuntimeException) ;
+
+ virtual sal_Bool SAL_CALL
+ supportsService( const rtl::OUString& aServiceName )
+ throw (uno::RuntimeException) ;
+
+ virtual uno::Sequence<rtl::OUString> SAL_CALL
+ getSupportedServiceNames( )
+ throw (uno::RuntimeException) ;
+
+ /**
+ Provides the implementation name.
+
+ @return implementation name
+ */
+ static rtl::OUString SAL_CALL getBackendName(void) ;
+ /**
+ Provides the supported services names
+
+ @return service names
+ */
+ static uno::Sequence<rtl::OUString> SAL_CALL getBackendServiceNames(void) ;
+
+ // XPropertySet
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo() throw (css::uno::RuntimeException)
+ { return css::uno::Reference< css::beans::XPropertySetInfo >(); }
+
+ virtual void SAL_CALL setPropertyValue(
+ rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL getPropertyValue(
+ rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual void SAL_CALL addPropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removePropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL addVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removeVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ protected:
+ /**
+ Service constructor from a service factory.
+
+ @param xContext component context
+ */
+ LocaleBackend();
+
+ /** Destructor */
+ ~LocaleBackend(void) ;
+
+ private:
+ // Returns the user locale
+ static rtl::OUString getLocale(void);
+
+ // Returns the user UI locale
+ static rtl::OUString getUILocale(void);
+
+ // Returns the system default locale
+ static rtl::OUString getSystemLocale(void);
+} ;
+
+
+#endif // _FIXEDVALUEBACKEND_HXX_
diff --git a/shell/source/backends/localebe/localebe.xml b/shell/source/backends/localebe/localebe.xml
new file mode 100644
index 000000000000..3c22a4970881
--- /dev/null
+++ b/shell/source/backends/localebe/localebe.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name>localebe1</module-name>
+ <component-description>
+ <author> Oliver Braun </author>
+ <name>com.sun.star.comp.configuration.backend.LocaleBackend</name>
+ <description> The </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.comp.configuration.backend.LocaleBackend</supported-service>
+ <service-dependency>...</service-dependency>
+ <type>com.sun.star.configuration.backend.XBackendChangesListener</type>
+ <type>com.sun.star.configuration.backend.XBackendChangesNotifier</type>
+ <type>com.sun.star.configuration.backend.XLayerHandler</type>
+ <type>com.sun.star.configuration.backend.XSingleLayerStratum</type>
+ <type>com.sun.star.lang.XMultiComponentFactory</type>
+ <type>com.sun.star.lang.XServiceInfo</type>
+ <type>com.sun.star.lang.XSingleComponentFactory</type>
+ <type>com.sun.star.lang.XTypeProvider</type>
+ <type>com.sun.star.uno.TypeClass</type>
+ <type>com.sun.star.uno.XAggregation</type>
+ <type>com.sun.star.uno.XComponentContext</type>
+ <type>com.sun.star.uno.XCurrentContext</type>
+ <type>com.sun.star.uno.XWeak</type>
+ <type>com.sun.star.registry.XRegistryKey</type>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency>
+ <runtime-module-dependency>cppu3</runtime-module-dependency>
+ <runtime-module-dependency>sal3</runtime-module-dependency>
+</module-description>
diff --git a/shell/source/backends/localebe/localebecdef.cxx b/shell/source/backends/localebe/localebecdef.cxx
new file mode 100644
index 000000000000..576501e4da9f
--- /dev/null
+++ b/shell/source/backends/localebe/localebecdef.cxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#include <localebackend.hxx>
+
+#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
+#include <cppuhelper/implementationentry.hxx>
+#endif
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+namespace css = com::sun::star ;
+namespace uno = css::uno ;
+namespace lang = css::lang ;
+
+//------------------------------------------------------------------------------
+
+static uno::Reference<uno::XInterface> SAL_CALL createLocaleBackend(
+ const uno::Reference<uno::XComponentContext>&){
+
+ return * LocaleBackend::createInstance();
+}
+
+//------------------------------------------------------------------------------
+
+static const cppu::ImplementationEntry kImplementations_entries[] =
+{
+ {
+ createLocaleBackend,
+ LocaleBackend::getBackendName,
+ LocaleBackend::getBackendServiceNames,
+ cppu::createSingleComponentFactory,
+ NULL,
+ 0
+ },
+ { NULL, NULL, NULL, NULL, NULL, 0 }
+} ;
+
+//------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **aEnvTypeName, uno_Environment ** /*aEnvironment*/) {
+
+ *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void *pRegistryKey) {
+ return cppu::component_writeInfoHelper(
+ pServiceManager, pRegistryKey, kImplementations_entries);
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" void *component_getFactory( const sal_Char *aImplementationName,
+ void *aServiceManager,
+ void *aRegistryKey) {
+
+ return cppu::component_getFactoryHelper(
+ aImplementationName,
+ aServiceManager,
+ aRegistryKey,
+ kImplementations_entries) ;
+}
+
+//------------------------------------------------------------------------------
+
diff --git a/shell/source/backends/localebe/makefile.mk b/shell/source/backends/localebe/makefile.mk
new file mode 100644
index 000000000000..8a05be4cb351
--- /dev/null
+++ b/shell/source/backends/localebe/makefile.mk
@@ -0,0 +1,72 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=shell
+TARGET=localebe
+
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+DLLPRE =
+
+# --- Files ---
+
+SLOFILES=\
+ $(SLO)$/localebecdef.obj \
+ $(SLO)$/localebackend.obj
+
+SHL1TARGET=$(TARGET)1.uno
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+SHL1IMPLIB=i$(SHL1TARGET)
+
+SHL1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+.IF "$(OS)"=="MACOSX"
+SHL1STDLIBS+= -framework CoreServices
+.ENDIF
+
+SHL1VERSIONMAP=exports.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
diff --git a/shell/source/backends/macbe/exports.map b/shell/source/backends/macbe/exports.map
new file mode 100644
index 000000000000..ba501f9ae076
--- /dev/null
+++ b/shell/source/backends/macbe/exports.map
@@ -0,0 +1,10 @@
+UDK_3_0_0 {
+ global:
+ GetVersionInfo;
+ component_getImplementationEnvironment;
+ component_getFactory;
+ component_writeInfo;
+
+ local:
+ *;
+};
diff --git a/shell/source/backends/macbe/macbackend.cxx b/shell/source/backends/macbe/macbackend.cxx
new file mode 100644
index 000000000000..b07afb2e6701
--- /dev/null
+++ b/shell/source/backends/macbe/macbackend.cxx
@@ -0,0 +1,499 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+// For MAXHOSTNAMELEN constant
+#include <sys/param.h>
+
+#include <premac.h>
+#include <SystemConfiguration/SystemConfiguration.h>
+#include <Foundation/NSPathUtilities.h>
+#include <postmac.h>
+
+#include "macbackend.hxx"
+
+#include "com/sun/star/beans/Optional.hpp"
+#include "rtl/ustrbuf.hxx"
+#include "osl/file.h"
+
+#define SPACE ' '
+#define SEMI_COLON ';'
+
+typedef struct
+{
+ rtl::OUString Server;
+ sal_Int32 Port;
+} ProxyEntry;
+
+typedef enum {
+ sHTTP,
+ sHTTPS,
+ sFTP
+} ServiceType;
+
+//------------------------------------------------------------------------
+// helper functions
+//------------------------------------------------------------------------
+
+namespace // private
+{
+
+/*
+ * Returns current proxy settings for selected service type (HTTP or
+ * FTP) as a C string (in the buffer specified by host and hostSize)
+ * and a port number.
+ */
+
+bool GetProxySetting(ServiceType sType, char *host, size_t hostSize, UInt16 *port)
+{
+ bool result;
+ CFDictionaryRef proxyDict;
+ CFNumberRef enableNum;
+ int enable;
+ CFStringRef hostStr;
+ CFNumberRef portNum;
+ int portInt;
+
+ proxyDict = SCDynamicStoreCopyProxies(NULL);
+
+ if (!proxyDict)
+ return false;
+
+ CFStringRef proxiesEnable;
+ CFStringRef proxiesProxy;
+ CFStringRef proxiesPort;
+
+ switch ( sType )
+ {
+ case sHTTP : proxiesEnable = kSCPropNetProxiesHTTPEnable;
+ proxiesProxy = kSCPropNetProxiesHTTPProxy;
+ proxiesPort = kSCPropNetProxiesHTTPPort;
+ break;
+ case sHTTPS: proxiesEnable = kSCPropNetProxiesHTTPSEnable;
+ proxiesProxy = kSCPropNetProxiesHTTPSProxy;
+ proxiesPort = kSCPropNetProxiesHTTPSPort;
+ break;
+ default: proxiesEnable = kSCPropNetProxiesFTPEnable;
+ proxiesProxy = kSCPropNetProxiesFTPProxy;
+ proxiesPort = kSCPropNetProxiesFTPPort;
+ break;
+ }
+ // Proxy enabled?
+ enableNum = (CFNumberRef) CFDictionaryGetValue( proxyDict,
+ proxiesEnable );
+
+ result = (enableNum != NULL) && (CFGetTypeID(enableNum) == CFNumberGetTypeID());
+
+ if (result)
+ result = CFNumberGetValue(enableNum, kCFNumberIntType, &enable) && (enable != 0);
+
+ // Proxy enabled -> get hostname
+ if (result)
+ {
+ hostStr = (CFStringRef) CFDictionaryGetValue( proxyDict,
+ proxiesProxy );
+
+ result = (hostStr != NULL) && (CFGetTypeID(hostStr) == CFStringGetTypeID());
+ }
+
+ if (result)
+ result = CFStringGetCString(hostStr, host, (CFIndex) hostSize, kCFStringEncodingASCII);
+
+ // Get proxy port
+ if (result)
+ {
+ portNum = (CFNumberRef) CFDictionaryGetValue( proxyDict,
+ proxiesPort );
+
+ result = (portNum != NULL) && (CFGetTypeID(portNum) == CFNumberGetTypeID());
+ }
+ else
+ {
+ CFRelease(proxyDict);
+ return false;
+ }
+
+ if (result)
+ result = CFNumberGetValue(portNum, kCFNumberIntType, &portInt);
+
+ if (result)
+ *port = (UInt16) portInt;
+
+ if (proxyDict)
+ CFRelease(proxyDict);
+
+ if (!result)
+ {
+ *host = 0;
+ *port = 0;
+ }
+
+ return result;
+}
+
+} // end private namespace
+
+//------------------------------------------------------------------------------
+
+MacOSXBackend::MacOSXBackend()
+{
+}
+
+//------------------------------------------------------------------------------
+
+MacOSXBackend::~MacOSXBackend(void)
+{
+}
+
+//------------------------------------------------------------------------------
+
+MacOSXBackend* MacOSXBackend::createInstance()
+{
+ return new MacOSXBackend;
+}
+
+// ---------------------------------------------------------------------------------------
+
+rtl::OUString CFStringToOUString(const CFStringRef sOrig) {
+ CFRetain(sOrig);
+
+ CFIndex nStringLen = CFStringGetLength(sOrig)+1;
+
+ // Allocate a c string buffer
+ char sBuffer[nStringLen];
+
+ CFStringGetCString(sOrig, sBuffer, nStringLen, kCFStringEncodingASCII);
+
+ CFRelease(sOrig);
+
+ return rtl::OUString::createFromAscii((sal_Char*)sBuffer);
+}
+
+rtl::OUString GetOUString( NSString* pStr )
+{
+ if( ! pStr )
+ return rtl::OUString();
+ int nLen = [pStr length];
+ if( nLen == 0 )
+ return rtl::OUString();
+
+ rtl::OUStringBuffer aBuf( nLen+1 );
+ aBuf.setLength( nLen );
+ [pStr getCharacters: const_cast<sal_Unicode*>(aBuf.getStr())];
+ return aBuf.makeStringAndClear();
+}
+
+void MacOSXBackend::setPropertyValue(
+ rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ throw css::lang::IllegalArgumentException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")),
+ static_cast< cppu::OWeakObject * >(this), -1);
+}
+
+css::uno::Any MacOSXBackend::getPropertyValue(
+ rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("WorkPathVariable")))
+ {
+ rtl::OUString aDocDir;
+ NSArray* pPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, true );
+ if( pPaths && [pPaths count] > 0 )
+ {
+ aDocDir = GetOUString( [pPaths objectAtIndex: 0] );
+
+ rtl::OUString aDocURL;
+ if( aDocDir.getLength() > 0 &&
+ osl_getFileURLFromSystemPath( aDocDir.pData, &aDocURL.pData ) == osl_File_E_None )
+ {
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true, css::uno::makeAny( aDocURL ) ) );
+ }
+ else
+ {
+ OSL_TRACE( "user documents list contains empty file path or conversion failed" );
+ }
+ }
+ else
+ {
+ OSL_TRACE( "Got nil or empty list of user document directories" );
+ }
+ return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")))
+ {
+ ProxyEntry aFtpProxy;
+
+ char host[MAXHOSTNAMELEN];
+ UInt16 port;
+ bool retVal;
+
+ retVal = GetProxySetting(sFTP, host, 100, &port);
+
+ if (retVal)
+ {
+ aFtpProxy.Server = rtl::OUString::createFromAscii( host );
+ }
+
+ // ftp proxy name
+ if( aFtpProxy.Server.getLength() > 0 )
+ {
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( aFtpProxy.Server ) ) );
+ }
+ return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")))
+ {
+ ProxyEntry aFtpProxy;
+
+ char host[MAXHOSTNAMELEN];
+ UInt16 port;
+ bool retVal;
+
+ retVal = GetProxySetting(sFTP, host, 100, &port);
+
+ if (retVal)
+ {
+ aFtpProxy.Port = port;
+ }
+
+ // ftp proxy port
+ if( aFtpProxy.Port > 0 )
+ {
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( aFtpProxy.Port ) ) );
+ }
+ return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")))
+ {
+ ProxyEntry aHttpProxy;
+
+ char host[MAXHOSTNAMELEN];
+ UInt16 port;
+ bool retVal;
+
+ retVal = GetProxySetting(sHTTP, host, 100, &port);
+
+ if (retVal)
+ {
+ aHttpProxy.Server = rtl::OUString::createFromAscii( host );
+ }
+
+ // http proxy name
+ if( aHttpProxy.Server.getLength() > 0 )
+ {
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( aHttpProxy.Server ) ) );
+ }
+ return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")))
+ {
+ ProxyEntry aHttpProxy;
+
+ char host[MAXHOSTNAMELEN];
+ UInt16 port;
+ bool retVal;
+
+ retVal = GetProxySetting(sHTTP, host, 100, &port);
+
+ if (retVal)
+ {
+ aHttpProxy.Port = port;
+ }
+
+ // http proxy port
+ if( aHttpProxy.Port > 0 )
+ {
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( aHttpProxy.Port ) ) );
+ }
+ return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")))
+ {
+ ProxyEntry aHttpsProxy;
+
+ char host[MAXHOSTNAMELEN];
+ UInt16 port;
+ bool retVal;
+
+ retVal = GetProxySetting(sHTTPS, host, 100, &port);
+
+ if (retVal)
+ {
+ aHttpsProxy.Server = rtl::OUString::createFromAscii( host );
+ }
+
+ // https proxy name
+ if( aHttpsProxy.Server.getLength() > 0 )
+ {
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( aHttpsProxy.Server ) ) );
+ }
+ return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")))
+ {
+ ProxyEntry aHttpsProxy;
+
+ char host[MAXHOSTNAMELEN];
+ UInt16 port;
+ bool retVal;
+
+ retVal = GetProxySetting(sHTTPS, host, 100, &port);
+
+ if (retVal)
+ {
+ aHttpsProxy.Port = port;
+ }
+
+ // https proxy port
+ if( aHttpsProxy.Port > 0 )
+ {
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( aHttpsProxy.Port ) ) );
+ }
+ return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetProxyType")))
+ {
+ // override default for ProxyType, which is "0" meaning "No proxies".
+ sal_Int32 nProperties = 1;
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true, uno::makeAny( nProperties ) ) );
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy")))
+ {
+ rtl::OUString aProxyBypassList;
+
+ CFArrayRef rExceptionsList;
+ CFDictionaryRef rProxyDict = SCDynamicStoreCopyProxies(NULL);
+
+ if (!rProxyDict)
+ rExceptionsList = false;
+ else
+ rExceptionsList = (CFArrayRef) CFDictionaryGetValue(rProxyDict, kSCPropNetProxiesExceptionsList);
+
+ if (rExceptionsList)
+ {
+ for (CFIndex idx = 0; idx < CFArrayGetCount(rExceptionsList); idx++)
+ {
+ CFStringRef rException = (CFStringRef) CFArrayGetValueAtIndex(rExceptionsList, idx);
+
+ if (idx>0)
+ aProxyBypassList += rtl::OUString::createFromAscii( ";" );
+
+ aProxyBypassList += CFStringToOUString(rException);
+ }
+ }
+
+ if (rProxyDict)
+ CFRelease(rProxyDict);
+
+ // fill proxy bypass list
+ if( aProxyBypassList.getLength() > 0 )
+ {
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true,
+ uno::makeAny( aProxyBypassList.replace( SPACE, SEMI_COLON ) ) ) );
+ }
+ return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
+ } else {
+ throw css::beans::UnknownPropertyException(
+ PropertyName, static_cast< cppu::OWeakObject * >(this));
+ }
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString SAL_CALL MacOSXBackend::getBackendName(void)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.comp.configuration.backend.MacOSXBackend");
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString SAL_CALL MacOSXBackend::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return getBackendName();
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence<rtl::OUString> SAL_CALL MacOSXBackend::getBackendServiceNames(void)
+{
+ uno::Sequence<rtl::OUString> aServiceNameList(1);
+ aServiceNameList[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.MacOSXBackend"));
+
+ return aServiceNameList;
+}
+
+//------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL MacOSXBackend::supportsService(const rtl::OUString& aServiceName)
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< rtl::OUString > const svc = getBackendServiceNames();
+
+ for(sal_Int32 i = 0; i < svc.getLength(); ++i )
+ if(svc[i] == aServiceName)
+ return true;
+
+ return false;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence<rtl::OUString> SAL_CALL MacOSXBackend::getSupportedServiceNames(void)
+ throw (uno::RuntimeException)
+{
+ return getBackendServiceNames();
+}
diff --git a/shell/source/backends/macbe/macbackend.hxx b/shell/source/backends/macbe/macbackend.hxx
new file mode 100644
index 000000000000..de4f9eee1ff6
--- /dev/null
+++ b/shell/source/backends/macbe/macbackend.hxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _MACBACKEND_HXX_
+#define _MACBACKEND_HXX_
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <rtl/string.hxx>
+
+// FIXME: stdio.h only for debugging...
+#include <stdio.h>
+
+namespace css = com::sun::star;
+namespace uno = css::uno;
+namespace lang = css::lang;
+
+class MacOSXBackend : public ::cppu::WeakImplHelper2 <css::beans::XPropertySet, lang::XServiceInfo >
+{
+
+public:
+
+ static MacOSXBackend* createInstance();
+
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw (uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& aServiceName)
+ throw (uno::RuntimeException);
+
+ virtual uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames()
+ throw (uno::RuntimeException);
+
+ /**
+ Provides the implementation name.
+
+ @return implementation name
+ */
+ static rtl::OUString SAL_CALL getBackendName(void);
+
+ /**
+ Provides the supported services names
+
+ @return service names
+ */
+ static uno::Sequence<rtl::OUString> SAL_CALL getBackendServiceNames(void);
+
+ // XPropertySet
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo() throw (css::uno::RuntimeException)
+ { return css::uno::Reference< css::beans::XPropertySetInfo >(); }
+
+ virtual void SAL_CALL setPropertyValue(
+ rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL getPropertyValue(
+ rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual void SAL_CALL addPropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removePropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL addVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removeVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+protected:
+
+ /**
+ Service constructor from a service factory.
+
+ @param xContext component context
+ */
+ MacOSXBackend();
+
+ /** Destructor */
+ ~MacOSXBackend(void);
+};
+
+#endif // _MACBACKEND_HXX_
diff --git a/shell/source/backends/macbe/macbe.xml b/shell/source/backends/macbe/macbe.xml
new file mode 100644
index 000000000000..7cee5bb14de5
--- /dev/null
+++ b/shell/source/backends/macbe/macbe.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name>macbe</module-name>
+ <component-description>
+ <author> Pavel Janík </author>
+ <name>com.sun.star.comp.configuration.backend.MacOSXBackend</name>
+ <description> The </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.comp.configuration.backend.MacOSXBackend</supported-service>
+ <service-dependency>...</service-dependency>
+ <type>com.sun.star.configuration.backend.XBackendChangesListener</type>
+ <type>com.sun.star.configuration.backend.XBackendChangesNotifier</type>
+ <type>com.sun.star.configuration.backend.XLayerHandler</type>
+ <type>com.sun.star.configuration.backend.XSingleLayerStratum</type>
+ <type>com.sun.star.lang.XMultiComponentFactory</type>
+ <type>com.sun.star.lang.XServiceInfo</type>
+ <type>com.sun.star.lang.XSingleComponentFactory</type>
+ <type>com.sun.star.lang.XTypeProvider</type>
+ <type>com.sun.star.uno.TypeClass</type>
+ <type>com.sun.star.uno.XAggregation</type>
+ <type>com.sun.star.uno.XComponentContext</type>
+ <type>com.sun.star.uno.XCurrentContext</type>
+ <type>com.sun.star.uno.XWeak</type>
+ <type>com.sun.star.registry.XRegistryKey</type>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency>
+ <runtime-module-dependency>cppu3</runtime-module-dependency>
+ <runtime-module-dependency>sal3</runtime-module-dependency>
+</module-description>
diff --git a/shell/source/backends/macbe/macbecdef.cxx b/shell/source/backends/macbe/macbecdef.cxx
new file mode 100644
index 000000000000..18cf2806c16b
--- /dev/null
+++ b/shell/source/backends/macbe/macbecdef.cxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#include "macbackend.hxx"
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
+#include <cppuhelper/implementationentry.hxx>
+#endif
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+namespace css = com::sun::star;
+namespace uno = css::uno;
+namespace lang = css::lang;
+
+//------------------------------------------------------------------------------
+
+static uno::Reference<uno::XInterface> SAL_CALL createMacOSXBackend(
+ const uno::Reference<uno::XComponentContext>&)
+{
+ return * MacOSXBackend::createInstance();
+}
+
+//------------------------------------------------------------------------------
+
+static const cppu::ImplementationEntry kImplementations_entries[] =
+{
+ {
+ createMacOSXBackend,
+ MacOSXBackend::getBackendName,
+ MacOSXBackend::getBackendServiceNames,
+ cppu::createSingleComponentFactory,
+ NULL,
+ 0
+ },
+ { NULL }
+};
+
+//------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **aEnvTypeName, uno_Environment ** /*aEnvironment*/) {
+
+ *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void *pRegistryKey) {
+ return cppu::component_writeInfoHelper(
+ pServiceManager, pRegistryKey, kImplementations_entries);
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" void *component_getFactory( const sal_Char *aImplementationName, void *aServiceManager, void *aRegistryKey)
+{
+
+ return cppu::component_getFactoryHelper(
+ aImplementationName,
+ aServiceManager,
+ aRegistryKey,
+ kImplementations_entries);
+}
+
+//------------------------------------------------------------------------------
+
diff --git a/shell/source/backends/macbe/makefile.mk b/shell/source/backends/macbe/makefile.mk
new file mode 100644
index 000000000000..7b42c8c577ce
--- /dev/null
+++ b/shell/source/backends/macbe/makefile.mk
@@ -0,0 +1,78 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=shell
+TARGET=macbe
+
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+DLLPRE =
+
+# --- Files ---
+
+.IF "$(OS)" != "MACOSX"
+
+dummy:
+ @echo "Nothing to build for OS $(OS)."
+
+.ELSE
+
+CFLAGSCXX+=$(OBJCXXFLAGS)
+
+SLOFILES= \
+ $(SLO)$/macbecdef.obj \
+ $(SLO)$/macbackend.obj
+
+SHL1TARGET=$(TARGET)1.uno
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+SHL1IMPLIB=i$(SHL1TARGET)
+SHL1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ -framework Cocoa -framework SystemConfiguration
+
+SHL1VERSIONMAP=exports.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
+.ENDIF # "$(OS)" != "MACOSX"
diff --git a/shell/source/backends/wininetbe/exports.map b/shell/source/backends/wininetbe/exports.map
new file mode 100644
index 000000000000..ba501f9ae076
--- /dev/null
+++ b/shell/source/backends/wininetbe/exports.map
@@ -0,0 +1,10 @@
+UDK_3_0_0 {
+ global:
+ GetVersionInfo;
+ component_getImplementationEnvironment;
+ component_getFactory;
+ component_writeInfo;
+
+ local:
+ *;
+};
diff --git a/shell/source/backends/wininetbe/makefile.mk b/shell/source/backends/wininetbe/makefile.mk
new file mode 100644
index 000000000000..0401cb88b7dd
--- /dev/null
+++ b/shell/source/backends/wininetbe/makefile.mk
@@ -0,0 +1,68 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=shell
+TARGET=wininetbe
+
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+DLLPRE =
+
+# --- Files ---
+
+
+SLOFILES=\
+ $(SLO)$/wininetbecdef.obj \
+ $(SLO)$/wininetbackend.obj
+
+SHL1TARGET=$(TARGET)1.uno
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+SHL1IMPLIB=i$(SHL1TARGET)
+SHL1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+SHL1VERSIONMAP=exports.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
diff --git a/shell/source/backends/wininetbe/wininetbackend.cxx b/shell/source/backends/wininetbe/wininetbackend.cxx
new file mode 100644
index 000000000000..af6f1036496d
--- /dev/null
+++ b/shell/source/backends/wininetbe/wininetbackend.cxx
@@ -0,0 +1,403 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#include "rtl/ustrbuf.hxx"
+
+#include "wininetbackend.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#include <wininet.h>
+#include <sal/alloca.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#define WININET_DLL_NAME "wininet.dll"
+#define EQUAL_SIGN '='
+#define COLON ':'
+#define SPACE ' '
+#define SEMI_COLON ';'
+
+namespace {
+
+struct Library {
+ HMODULE module;
+
+ Library(HMODULE theModule): module(theModule) {}
+
+ ~Library() { if (module) FreeLibrary(module); }
+};
+
+}
+
+typedef struct
+{
+ rtl::OUString Server;
+ rtl::OUString Port;
+} ProxyEntry;
+
+//------------------------------------------------------------------------
+// helper functions
+//------------------------------------------------------------------------
+
+namespace // private
+{
+ ProxyEntry ReadProxyEntry(const rtl::OUString& aProxy, sal_Int32& i)
+ {
+ ProxyEntry aProxyEntry;
+
+ aProxyEntry.Server = aProxy.getToken( 0, COLON, i );
+ if ( i > -1 )
+ aProxyEntry.Port = aProxy.getToken( 0, COLON, i );
+
+ return aProxyEntry;
+ }
+
+ ProxyEntry FindProxyEntry(const rtl::OUString& aProxyList, const rtl::OUString& aType)
+ {
+ sal_Int32 nIndex = 0;
+
+ do
+ {
+ // get the next token, e.g. ftp=server:port
+ rtl::OUString nextToken = aProxyList.getToken( 0, SPACE, nIndex );
+
+ // split the next token again into the parts separated
+ // through '=', e.g. ftp=server:port -> ftp and server:port
+ sal_Int32 i = 0;
+ if( nextToken.indexOf( EQUAL_SIGN ) > -1 )
+ {
+ if( aType.equals( nextToken.getToken( 0, EQUAL_SIGN, i ) ) )
+ return ReadProxyEntry(nextToken, i);
+ }
+ else if( aType.getLength() == 0)
+ return ReadProxyEntry(nextToken, i);
+
+ } while ( nIndex >= 0 );
+
+ return ProxyEntry();
+ }
+
+} // end private namespace
+
+//------------------------------------------------------------------------------
+
+WinInetBackend::WinInetBackend()
+{
+ Library hWinInetDll( LoadLibrary( WININET_DLL_NAME ) );
+ if( hWinInetDll.module )
+ {
+ typedef BOOL ( WINAPI *InternetQueryOption_Proc_T )( HINTERNET, DWORD, LPVOID, LPDWORD );
+
+ InternetQueryOption_Proc_T lpfnInternetQueryOption =
+ reinterpret_cast< InternetQueryOption_Proc_T >(
+ GetProcAddress( hWinInetDll.module, "InternetQueryOptionA" ) );
+ if (lpfnInternetQueryOption)
+ {
+ LPINTERNET_PROXY_INFO lpi = NULL;
+
+ // query for the neccessary space
+ DWORD dwLength = 0;
+ BOOL bRet = lpfnInternetQueryOption(
+ NULL,
+ INTERNET_OPTION_PROXY,
+ (LPVOID)lpi,
+ &dwLength );
+
+ // allocate sufficient space on the heap
+ // insufficient space on the heap results
+ // in a stack overflow exception, we assume
+ // this never happens, because of the relatively
+ // small amount of memory we need
+ // alloca is nice because it is fast and we don't
+ // have to free the allocated memory, it will be
+ // automatically done
+ lpi = reinterpret_cast< LPINTERNET_PROXY_INFO >(
+ alloca( dwLength ) );
+
+ bRet = lpfnInternetQueryOption(
+ NULL,
+ INTERNET_OPTION_PROXY,
+ (LPVOID)lpi,
+ &dwLength );
+
+ // if a proxy is disabled, InternetQueryOption returns
+ // an empty proxy list, so we don't have to check if
+ // proxy is enabled or not
+
+ rtl::OUString aProxyList = rtl::OUString::createFromAscii( lpi->lpszProxy );
+ rtl::OUString aProxyBypassList = rtl::OUString::createFromAscii( lpi->lpszProxyBypass );
+
+ // override default for ProxyType, which is "0" meaning "No proxies".
+ sal_Int32 nProperties = 1;
+
+ valueProxyType_.IsPresent = true;
+ valueProxyType_.Value <<= nProperties;
+
+ // fill proxy bypass list
+ if( aProxyBypassList.getLength() > 0 )
+ {
+ rtl::OUStringBuffer aReverseList;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ rtl::OUString aToken = aProxyBypassList.getToken( 0, SPACE, nIndex );
+ if ( aProxyList.indexOf( aToken ) == -1 )
+ {
+ if ( aReverseList.getLength() )
+ {
+ aReverseList.insert( 0, sal_Unicode( SEMI_COLON ) );
+ aReverseList.insert( 0, aToken );
+ }
+ else
+ aReverseList = aToken;
+ }
+ }
+ while ( nIndex >= 0 );
+
+ aProxyBypassList = aReverseList.makeStringAndClear();
+
+ valueNoProxy_.IsPresent = true;
+ valueNoProxy_.Value <<= aProxyBypassList.replace( SPACE, SEMI_COLON );
+ }
+
+ if( aProxyList.getLength() > 0 )
+ {
+ //-------------------------------------------------
+ // this implementation follows the algorithm
+ // of the internet explorer
+ // if there are type-dependent proxy settings
+ // and type independent proxy settings in the
+ // registry the internet explorer chooses the
+ // type independent proxy for all settings
+ // e.g. imagine the following registry entry
+ // ftp=server:port;http=server:port;server:port
+ // the last token server:port is type independent
+ // so the ie chooses this proxy server
+
+ // if there is no port specified for a type independent
+ // server the ie uses the port of an http server if
+ // there is one and it has a port
+ //-------------------------------------------------
+
+ ProxyEntry aTypeIndepProxy = FindProxyEntry( aProxyList, rtl::OUString());
+ ProxyEntry aHttpProxy = FindProxyEntry( aProxyList, rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "http" ) ) );
+ ProxyEntry aHttpsProxy = FindProxyEntry( aProxyList, rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "https" ) ) );
+
+ ProxyEntry aFtpProxy = FindProxyEntry( aProxyList, rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "ftp" ) ) );
+
+ if( aTypeIndepProxy.Server.getLength() )
+ {
+ aHttpProxy.Server = aTypeIndepProxy.Server;
+ aHttpsProxy.Server = aTypeIndepProxy.Server;
+ aFtpProxy.Server = aTypeIndepProxy.Server;
+
+ if( aTypeIndepProxy.Port.getLength() )
+ {
+ aHttpProxy.Port = aTypeIndepProxy.Port;
+ aHttpsProxy.Port = aTypeIndepProxy.Port;
+ aFtpProxy.Port = aTypeIndepProxy.Port;
+ }
+ else
+ {
+ aFtpProxy.Port = aHttpProxy.Port;
+ aHttpsProxy.Port = aHttpProxy.Port;
+ }
+ }
+
+ // http proxy name
+ if( aHttpProxy.Server.getLength() > 0 )
+ {
+ valueHttpProxyName_.IsPresent = true;
+ valueHttpProxyName_.Value <<= aHttpProxy.Server;
+ }
+
+ // http proxy port
+ if( aHttpProxy.Port.getLength() > 0 )
+ {
+ valueHttpProxyPort_.IsPresent = true;
+ valueHttpProxyPort_.Value <<= aHttpProxy.Port.toInt32();
+ }
+
+ // https proxy name
+ if( aHttpsProxy.Server.getLength() > 0 )
+ {
+ valueHttpsProxyName_.IsPresent = true;
+ valueHttpsProxyName_.Value <<= aHttpsProxy.Server;
+ }
+
+ // https proxy port
+ if( aHttpsProxy.Port.getLength() > 0 )
+ {
+ valueHttpsProxyPort_.IsPresent = true;
+ valueHttpsProxyPort_.Value <<= aHttpsProxy.Port.toInt32();
+ }
+
+ // ftp proxy name
+ if( aFtpProxy.Server.getLength() > 0 )
+ {
+ valueFtpProxyName_.IsPresent = true;
+ valueFtpProxyName_.Value <<= aFtpProxy.Server;
+ }
+
+ // ftp proxy port
+ if( aFtpProxy.Port.getLength() > 0 )
+ {
+ valueFtpProxyPort_.IsPresent = true;
+ valueFtpProxyPort_.Value <<= aFtpProxy.Port.toInt32();
+ }
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+
+WinInetBackend::~WinInetBackend(void)
+{
+}
+
+//------------------------------------------------------------------------------
+
+WinInetBackend* WinInetBackend::createInstance()
+{
+ return new WinInetBackend;
+}
+
+// ---------------------------------------------------------------------------------------
+
+void WinInetBackend::setPropertyValue(
+ rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ throw css::lang::IllegalArgumentException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")),
+ static_cast< cppu::OWeakObject * >(this), -1);
+}
+
+css::uno::Any WinInetBackend::getPropertyValue(
+ rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyName")))
+ {
+ return css::uno::makeAny(valueFtpProxyName_);
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetFTPProxyPort")))
+ {
+ return css::uno::makeAny(valueFtpProxyPort_);
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyName")))
+ {
+ return css::uno::makeAny(valueHttpProxyName_);
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPProxyPort")))
+ {
+ return css::uno::makeAny(valueHttpProxyPort_);
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyName")))
+ {
+ return css::uno::makeAny(valueHttpsProxyName_);
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetHTTPSProxyPort")))
+ {
+ return css::uno::makeAny(valueHttpsProxyPort_);
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetNoProxy")))
+ {
+ return css::uno::makeAny(valueNoProxy_);
+ } else if (PropertyName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("ooInetProxyType")))
+ {
+ return css::uno::makeAny(valueProxyType_);
+ } else {
+ throw css::beans::UnknownPropertyException(
+ PropertyName, static_cast< cppu::OWeakObject * >(this));
+ }
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString SAL_CALL WinInetBackend::getBackendName(void) {
+ return rtl::OUString::createFromAscii("com.sun.star.comp.configuration.backend.WinInetBackend") ;
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString SAL_CALL WinInetBackend::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return getBackendName() ;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence<rtl::OUString> SAL_CALL WinInetBackend::getBackendServiceNames(void)
+{
+ uno::Sequence<rtl::OUString> aServiceNameList(1);
+ aServiceNameList[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.WinInetBackend")) ;
+
+ return aServiceNameList ;
+}
+
+//------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL WinInetBackend::supportsService(const rtl::OUString& aServiceName)
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< rtl::OUString > const svc = getBackendServiceNames();
+
+ for(sal_Int32 i = 0; i < svc.getLength(); ++i )
+ if(svc[i] == aServiceName)
+ return true;
+
+ return false;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence<rtl::OUString> SAL_CALL WinInetBackend::getSupportedServiceNames(void)
+ throw (uno::RuntimeException)
+{
+ return getBackendServiceNames() ;
+}
diff --git a/shell/source/backends/wininetbe/wininetbackend.hxx b/shell/source/backends/wininetbe/wininetbackend.hxx
new file mode 100644
index 000000000000..5fe4d5625a9a
--- /dev/null
+++ b/shell/source/backends/wininetbe/wininetbackend.hxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _FIXEDVALUEBACKEND_HXX_
+#define _FIXEDVALUEBACKEND_HXX_
+
+#include <com/sun/star/beans/Optional.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <rtl/string.hxx>
+
+namespace css = com::sun::star ;
+namespace uno = css::uno ;
+namespace lang = css::lang ;
+
+class WinInetBackend : public ::cppu::WeakImplHelper2 <
+ css::beans::XPropertySet,
+ lang::XServiceInfo > {
+
+ public :
+
+ static WinInetBackend* createInstance();
+
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL
+ getImplementationName( )
+ throw (uno::RuntimeException) ;
+
+ virtual sal_Bool SAL_CALL
+ supportsService( const rtl::OUString& aServiceName )
+ throw (uno::RuntimeException) ;
+
+ virtual uno::Sequence<rtl::OUString> SAL_CALL
+ getSupportedServiceNames( )
+ throw (uno::RuntimeException) ;
+
+ /**
+ Provides the implementation name.
+
+ @return implementation name
+ */
+ static rtl::OUString SAL_CALL getBackendName(void) ;
+ /**
+ Provides the supported services names
+
+ @return service names
+ */
+ static uno::Sequence<rtl::OUString> SAL_CALL getBackendServiceNames(void) ;
+
+ // XPropertySet
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo() throw (css::uno::RuntimeException)
+ { return css::uno::Reference< css::beans::XPropertySetInfo >(); }
+
+ virtual void SAL_CALL setPropertyValue(
+ rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL getPropertyValue(
+ rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual void SAL_CALL addPropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removePropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL addVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removeVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ protected:
+ /**
+ Service constructor from a service factory.
+
+ @param xContext component context
+ */
+ WinInetBackend();
+
+ /** Destructor */
+ ~WinInetBackend(void) ;
+
+ private:
+ com::sun::star::beans::Optional< com::sun::star::uno::Any >
+ valueProxyType_;
+ com::sun::star::beans::Optional< com::sun::star::uno::Any >
+ valueNoProxy_;
+ com::sun::star::beans::Optional< com::sun::star::uno::Any >
+ valueHttpProxyName_;
+ com::sun::star::beans::Optional< com::sun::star::uno::Any >
+ valueHttpProxyPort_;
+ com::sun::star::beans::Optional< com::sun::star::uno::Any >
+ valueHttpsProxyName_;
+ com::sun::star::beans::Optional< com::sun::star::uno::Any >
+ valueHttpsProxyPort_;
+ com::sun::star::beans::Optional< com::sun::star::uno::Any >
+ valueFtpProxyName_;
+ com::sun::star::beans::Optional< com::sun::star::uno::Any >
+ valueFtpProxyPort_;
+} ;
+
+
+#endif // _FIXEDVALUEBACKEND_HXX_
diff --git a/shell/source/backends/wininetbe/wininetbe.xml b/shell/source/backends/wininetbe/wininetbe.xml
new file mode 100644
index 000000000000..1bf4bd2cd053
--- /dev/null
+++ b/shell/source/backends/wininetbe/wininetbe.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name>wininetbe</module-name>
+ <component-description>
+ <author> Oliver Braun </author>
+ <name>com.sun.star.comp.configuration.backend.Win32Backend</name>
+ <description> The </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.comp.configuration.backend.Win32Backend</supported-service>
+ <service-dependency>...</service-dependency>
+ <type>com.sun.star.configuration.backend.XBackendChangesListener</type>
+ <type>com.sun.star.configuration.backend.XBackendChangesNotifier</type>
+ <type>com.sun.star.configuration.backend.XLayerHandler</type>
+ <type>com.sun.star.configuration.backend.XSingleLayerStratum</type>
+ <type>com.sun.star.lang.XMultiComponentFactory</type>
+ <type>com.sun.star.lang.XServiceInfo</type>
+ <type>com.sun.star.lang.XSingleComponentFactory</type>
+ <type>com.sun.star.lang.XTypeProvider</type>
+ <type>com.sun.star.uno.TypeClass</type>
+ <type>com.sun.star.uno.XAggregation</type>
+ <type>com.sun.star.uno.XComponentContext</type>
+ <type>com.sun.star.uno.XCurrentContext</type>
+ <type>com.sun.star.uno.XWeak</type>
+ <type>com.sun.star.registry.XRegistryKey</type>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency>
+ <runtime-module-dependency>cppu3</runtime-module-dependency>
+ <runtime-module-dependency>sal3</runtime-module-dependency>
+</module-description>
diff --git a/shell/source/backends/wininetbe/wininetbecdef.cxx b/shell/source/backends/wininetbe/wininetbecdef.cxx
new file mode 100644
index 000000000000..862600009e30
--- /dev/null
+++ b/shell/source/backends/wininetbe/wininetbecdef.cxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#include <wininetbackend.hxx>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
+#include <cppuhelper/implementationentry.hxx>
+#endif
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+namespace css = com::sun::star ;
+namespace uno = css::uno ;
+namespace lang = css::lang ;
+
+//------------------------------------------------------------------------------
+
+static uno::Reference<uno::XInterface> SAL_CALL createWinInetBackend(
+ const uno::Reference<uno::XComponentContext>&){
+
+ return * WinInetBackend::createInstance();
+}
+
+//------------------------------------------------------------------------------
+
+static const cppu::ImplementationEntry kImplementations_entries[] =
+{
+ {
+ createWinInetBackend,
+ WinInetBackend::getBackendName,
+ WinInetBackend::getBackendServiceNames,
+ cppu::createSingleComponentFactory,
+ NULL,
+ 0
+ },
+ { NULL }
+} ;
+
+//------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **aEnvTypeName, uno_Environment ** /*aEnvironment*/) {
+
+ *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void *pRegistryKey) {
+ return cppu::component_writeInfoHelper(
+ pServiceManager, pRegistryKey, kImplementations_entries);
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" void *component_getFactory( const sal_Char *aImplementationName,
+ void *aServiceManager,
+ void *aRegistryKey) {
+
+ return cppu::component_getFactoryHelper(
+ aImplementationName,
+ aServiceManager,
+ aRegistryKey,
+ kImplementations_entries) ;
+}
+
+//------------------------------------------------------------------------------
+
diff --git a/shell/source/cmdmail/cmdmail.xml b/shell/source/cmdmail/cmdmail.xml
new file mode 100644
index 000000000000..51de9cc1e4da
--- /dev/null
+++ b/shell/source/cmdmail/cmdmail.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> cmdmail </module-name>
+ <component-description>
+ <author> Oliver Braun </author>
+ <name>com.sun.star.comp.system.SimpleCommandMail</name>
+ <description>
+ A generic implementation of a SimpleCommandMail service.
+ </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language> c++ </language>
+ <status value="beta"/>
+ <supported-service> com.sun.star.system.SimpleCommandMail </supported-service>
+ <service-dependency>...</service-dependency>
+ <type> com.sun.star.system.XSimpleMailClient </type>
+ <type> com.sun.star.system.XSimpleMailClientSupplier </type>
+ <type> com.sun.star.system.XSimpleMailMessage </type>
+ <type> com.sun.star.system.SimpleMailClientFlags </type>
+ <type> com.sun.star.lang.XEventListener </type>
+ <type> com.sun.star.lang.XMultiServiceFactory </type>
+ <type> com.sun.star.lang.XSingleServiceFactory </type>
+ <type> com.sun.star.lang.XSingleComponentFactory </type>
+ <type> com.sun.star.lang.XServiceInfo </type>
+ <type> com.sun.star.lang.XTypeProvider </type>
+ <type> com.sun.star.lang.IllegalArgumentException </type>
+ <type> com.sun.star.lang.XComponent </type>
+ <type> com.sun.star.uno.RuntimeException </type>
+ <type> com.sun.star.uno.TypeClass </type>
+ <type> com.sun.star.uno.XWeak </type>
+ <type> com.sun.star.uno.XAggregation </type>
+ <type> com.sun.star.uno.XComponentContext </type>
+ <type> com.sun.star.registry.XRegistryKey </type>
+ <type> com.sun.star.container.XNameAccess </type>
+ <type> com.sun.star.container.XSet </type>
+ <type> com.sun.star.beans.PropertyValue </type>
+ <type> com.sun.star.beans.XPropertySet </type>
+ <type> com.sun.star.uri.ExternalUriReferenceTranslator </type>
+ <type> com.sun.star.uri.XExternalUriReferenceTranslator </type>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <runtime-module-dependency> cppuhelper$(COM) </runtime-module-dependency>
+ <runtime-module-dependency> cppu3 </runtime-module-dependency>
+ <runtime-module-dependency> sal3 </runtime-module-dependency>
+</module-description>
diff --git a/shell/source/cmdmail/cmdmailentry.cxx b/shell/source/cmdmail/cmdmailentry.cxx
new file mode 100755
index 000000000000..aacef87396c4
--- /dev/null
+++ b/shell/source/cmdmail/cmdmailentry.cxx
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+//-----------------------------------------------------------------------
+// includes of other projects
+//-----------------------------------------------------------------------
+#include <cppuhelper/factory.hxx>
+#include <com/sun/star/container/XSet.hpp>
+#include <osl/diagnose.h>
+#include "cmdmailsuppl.hxx"
+
+//-----------------------------------------------------------------------
+// namespace directives
+//-----------------------------------------------------------------------
+
+using namespace ::rtl ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::container ;
+using namespace ::com::sun::star::lang ;
+using namespace ::com::sun::star::registry ;
+using namespace ::cppu ;
+using com::sun::star::system::XSimpleMailClientSupplier;
+
+//-----------------------------------------------------------------------
+// defines
+//-----------------------------------------------------------------------
+
+#define COMP_SERVICE_NAME "com.sun.star.system.SimpleCommandMail"
+#define COMP_IMPL_NAME "com.sun.star.comp.system.SimpleCommandMail"
+#define COMP_REGKEY_NAME "/com.sun.star.comp.system.SimpleCommandMail/UNO/SERVICES/com.sun.star.system.SimpleCommandMail"
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+
+namespace
+{
+ Reference< XInterface > SAL_CALL createInstance( const Reference< XComponentContext >& xContext )
+ {
+ return Reference< XInterface >( static_cast< XSimpleMailClientSupplier* >( new CmdMailSuppl( xContext ) ) );
+ }
+}
+
+//-----------------------------------------------------------------------
+// the 3 important functions which will be exported
+//-----------------------------------------------------------------------
+
+extern "C"
+{
+
+//----------------------------------------------------------------------
+// component_getImplementationEnvironment
+//----------------------------------------------------------------------
+
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+
+sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
+{
+ if ( pRegistryKey )
+ {
+ try
+ {
+ Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
+ pXNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( COMP_REGKEY_NAME ) ) );
+ return sal_True;
+ }
+ catch( InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "InvalidRegistryException caught");
+ }
+ }
+
+ return sal_False;
+}
+
+//----------------------------------------------------------------------
+// component_getFactory
+//----------------------------------------------------------------------
+
+void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* /*pSrvManager*/, uno_Interface* /*pRegistryKey*/ )
+{
+ Reference< XSingleComponentFactory > xFactory;
+
+ if (0 == ::rtl_str_compare( pImplName, COMP_IMPL_NAME ))
+ {
+ OUString serviceName( RTL_CONSTASCII_USTRINGPARAM(COMP_SERVICE_NAME) );
+
+ xFactory = ::cppu::createSingleComponentFactory(
+ createInstance,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(COMP_IMPL_NAME) ),
+ Sequence< OUString >( &serviceName, 1 ) );
+ }
+
+ if (xFactory.is())
+ xFactory->acquire();
+
+ return xFactory.get();
+}
+
+} // extern "C"
diff --git a/shell/source/cmdmail/cmdmailmsg.cxx b/shell/source/cmdmail/cmdmailmsg.cxx
new file mode 100755
index 000000000000..77de429ed771
--- /dev/null
+++ b/shell/source/cmdmail/cmdmailmsg.cxx
@@ -0,0 +1,302 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+#include <osl/diagnose.h>
+#include "cmdmailmsg.hxx"
+#include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp>
+#include <com/sun/star/uri/ExternalUriReferenceTranslator.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/RuntimeException.hpp>
+
+//------------------------------------------------------------------------
+// namespace directives
+//------------------------------------------------------------------------
+
+using com::sun::star::lang::IllegalArgumentException;
+using com::sun::star::lang::WrappedTargetException;
+using com::sun::star::container::NoSuchElementException;
+using com::sun::star::container::XNameAccess;
+using rtl::OUString;
+using osl::MutexGuard;
+
+using namespace cppu;
+using namespace com::sun::star::uno;
+
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+void SAL_CALL CmdMailMsg::setRecipient( const ::rtl::OUString& aRecipient )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ m_aRecipient = aRecipient;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+::rtl::OUString SAL_CALL CmdMailMsg::getRecipient( )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_aRecipient;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+void SAL_CALL CmdMailMsg::setCcRecipient( const Sequence< OUString >& aCcRecipient )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ m_CcRecipients = aCcRecipient;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+Sequence< OUString > SAL_CALL CmdMailMsg::getCcRecipient( )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_CcRecipients;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+void SAL_CALL CmdMailMsg::setBccRecipient( const Sequence< OUString >& aBccRecipient )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ m_BccRecipients = aBccRecipient;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+Sequence< OUString > SAL_CALL CmdMailMsg::getBccRecipient( )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_BccRecipients;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+void SAL_CALL CmdMailMsg::setOriginator( const OUString& aOriginator )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ m_aOriginator = aOriginator;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+OUString SAL_CALL CmdMailMsg::getOriginator( )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_aOriginator;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+void SAL_CALL CmdMailMsg::setSubject( const OUString& aSubject )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ m_aSubject = aSubject;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+OUString SAL_CALL CmdMailMsg::getSubject( )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_aSubject;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+void SAL_CALL CmdMailMsg::setAttachement( const Sequence< ::rtl::OUString >& aAttachment )
+ throw (IllegalArgumentException, RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ m_Attachments = aAttachment;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+Sequence< OUString > SAL_CALL CmdMailMsg::getAttachement( )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_Attachments;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+Any SAL_CALL CmdMailMsg::getByName( const OUString& aName )
+ throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+
+ if( 0 == aName.compareToAscii( "from" ) && m_aOriginator.getLength() )
+ return makeAny( m_aOriginator );
+
+ else if( 0 == aName.compareToAscii( "to" ) && m_aRecipient.getLength() )
+ return makeAny( m_aRecipient );
+
+ else if( 0 == aName.compareToAscii( "cc" ) && m_CcRecipients.getLength() )
+ return makeAny( m_CcRecipients );
+
+ else if( 0 == aName.compareToAscii( "bcc" ) && m_BccRecipients.getLength() )
+ return makeAny( m_BccRecipients );
+
+ else if( 0 == aName.compareToAscii( "subject" ) && m_aSubject.getLength() )
+ return makeAny( m_aSubject );
+
+ else if( 0 == aName.compareToAscii( "attachment" ) && m_Attachments.getLength() )
+ return makeAny( m_Attachments );
+
+ throw NoSuchElementException( OUString::createFromAscii( "key not found: ") + aName,
+ static_cast < XNameAccess * > (this) );
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+Sequence< OUString > SAL_CALL CmdMailMsg::getElementNames( )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+
+ sal_Int32 nItems = 0;
+ Sequence< OUString > aRet( 6 );
+
+ if( m_aOriginator.getLength() )
+ aRet[nItems++] = OUString::createFromAscii( "from" );
+
+ if( m_aRecipient.getLength() )
+ aRet[nItems++] = OUString::createFromAscii( "to" );
+
+ if( m_CcRecipients.getLength() )
+ aRet[nItems++] = OUString::createFromAscii( "cc" );
+
+ if( m_BccRecipients.getLength() )
+ aRet[nItems++] = OUString::createFromAscii( "bcc" );
+
+ if( m_aSubject.getLength() )
+ aRet[nItems++] = OUString::createFromAscii( "subject" );
+
+ if( m_Attachments.getLength() )
+ aRet[nItems++] = OUString::createFromAscii( "attachment" );
+
+ aRet.realloc( nItems );
+ return aRet;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+ sal_Bool SAL_CALL CmdMailMsg::hasByName( const ::rtl::OUString& aName )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+
+ if( 0 == aName.compareToAscii( "from" ) && m_aOriginator.getLength() )
+ return sal_True;
+
+ else if( 0 == aName.compareToAscii( "to" ) && m_aRecipient.getLength() )
+ return sal_True;
+
+ else if( 0 == aName.compareToAscii( "cc" ) && m_CcRecipients.getLength() )
+ return sal_True;
+
+ else if( 0 == aName.compareToAscii( "bcc" ) && m_BccRecipients.getLength() )
+ return sal_True;
+
+ else if( 0 == aName.compareToAscii( "subject" ) && m_aSubject.getLength() )
+ return sal_True;
+
+ else if( 0 == aName.compareToAscii( "attachment" ) && m_Attachments.getLength() )
+ return sal_True;
+
+ return sal_False;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+Type SAL_CALL CmdMailMsg::getElementType( )
+ throw (RuntimeException)
+{
+ // returning void for multi type container
+ return Type();
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+sal_Bool SAL_CALL CmdMailMsg::hasElements( )
+ throw (RuntimeException)
+{
+ return 0 != getElementNames().getLength();
+}
diff --git a/shell/source/cmdmail/cmdmailmsg.hxx b/shell/source/cmdmail/cmdmailmsg.hxx
new file mode 100644
index 000000000000..520bd0acbb56
--- /dev/null
+++ b/shell/source/cmdmail/cmdmailmsg.hxx
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CMDMAILMSG_HXX_
+#define _CMDMAILMSG_HXX_
+
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
+#include <com/sun/star/system/XSimpleMailMessage.hpp>
+#endif
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+//----------------------------------------------------------
+// class declaration
+//----------------------------------------------------------
+
+class CmdMailMsg :
+ public cppu::WeakImplHelper2<
+ ::com::sun::star::system::XSimpleMailMessage,
+ ::com::sun::star::container::XNameAccess >
+{
+ ::rtl::OUString m_aRecipient;
+ ::rtl::OUString m_aOriginator;
+ ::rtl::OUString m_aSubject;
+ ::com::sun::star::uno::Sequence< rtl::OUString > m_CcRecipients;
+ ::com::sun::star::uno::Sequence< rtl::OUString > m_BccRecipients;
+ ::com::sun::star::uno::Sequence< rtl::OUString > m_Attachments;
+
+ ::osl::Mutex m_aMutex;
+
+public:
+
+ CmdMailMsg() {};
+
+ //------------------------------------------------
+ // XSimpleMailMessage
+ //------------------------------------------------
+
+ virtual void SAL_CALL setRecipient( const ::rtl::OUString& aRecipient )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getRecipient( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL setCcRecipient( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aCcRecipient )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getCcRecipient( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL setBccRecipient( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aBccRecipient )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getBccRecipient( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL setOriginator( const ::rtl::OUString& aOriginator )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getOriginator( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL setSubject( const ::rtl::OUString& aSubject )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getSubject( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL setAttachement( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aAttachement )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAttachement( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ //------------------------------------------------
+ // XNameAccess
+ //------------------------------------------------
+
+ virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
+ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( )
+ throw (::com::sun::star::uno::RuntimeException) ;
+
+ virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ //------------------------------------------------
+ // XElementAccess
+ //------------------------------------------------
+
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL hasElements( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+};
+
+#endif
diff --git a/shell/source/cmdmail/cmdmailsuppl.cxx b/shell/source/cmdmail/cmdmailsuppl.cxx
new file mode 100755
index 000000000000..4878f8d7783f
--- /dev/null
+++ b/shell/source/cmdmail/cmdmailsuppl.cxx
@@ -0,0 +1,328 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+#include <osl/diagnose.h>
+#include <osl/thread.h>
+
+#include <rtl/bootstrap.hxx>
+
+#include <osl/file.hxx>
+#include <rtl/strbuf.hxx>
+#include "cmdmailsuppl.hxx"
+#include "cmdmailmsg.hxx"
+#include <com/sun/star/system/SimpleMailClientFlags.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+//------------------------------------------------------------------------
+// namespace directives
+//------------------------------------------------------------------------
+
+using com::sun::star::beans::PropertyValue;
+using com::sun::star::system::XSimpleMailClientSupplier;
+using com::sun::star::system::XSimpleMailClient;
+using com::sun::star::system::XSimpleMailMessage;
+using com::sun::star::container::XNameAccess;
+using com::sun::star::container::NoSuchElementException;
+using rtl::OUString;
+using rtl::OUStringToOString;
+using rtl::OString;
+using rtl::OStringBuffer;
+using osl::MutexGuard;
+using osl::FileBase;
+
+using namespace cppu;
+using namespace com::sun::star::system::SimpleMailClientFlags;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+
+//------------------------------------------------------------------------
+// defines
+//------------------------------------------------------------------------
+
+#define COMP_IMPL_NAME "com.sun.star.comp.system.SimpleCommandMail2"
+
+//------------------------------------------------------------------------
+// helper functions
+//------------------------------------------------------------------------
+
+namespace // private
+{
+ Sequence< OUString > SAL_CALL Component_getSupportedServiceNames()
+ {
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii("com.sun.star.system.SimpleCommandMail");
+ return aRet;
+ }
+
+} // end private namespace
+
+//-------------------------------------------------
+//
+//-------------------------------------------------
+
+CmdMailSuppl::CmdMailSuppl( const Reference< XComponentContext >& xContext ) :
+ WeakImplHelper3< XSimpleMailClientSupplier, XSimpleMailClient, XServiceInfo >()
+{
+ Reference< XMultiComponentFactory > xServiceManager = xContext->getServiceManager();
+
+ if ( xServiceManager.is() ) {
+ m_xConfigurationProvider = Reference< XMultiServiceFactory > (
+ xServiceManager->createInstanceWithContext(
+ OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ), xContext ),
+ UNO_QUERY );
+ }
+}
+
+//-------------------------------------------------
+// XSimpleMailClientSupplier
+//-------------------------------------------------
+
+Reference< XSimpleMailClient > SAL_CALL CmdMailSuppl::querySimpleMailClient( )
+ throw (RuntimeException)
+{
+ return static_cast < XSimpleMailClient * > (this);
+}
+
+//------------------------------------------------
+// XSimpleMailClient
+//------------------------------------------------
+
+Reference< XSimpleMailMessage > SAL_CALL CmdMailSuppl::createSimpleMailMessage( )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return Reference< XSimpleMailMessage >( new CmdMailMsg( ) );
+}
+
+//------------------------------------------------
+// XSimpleMailClient
+//------------------------------------------------
+
+void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailMessage >& xSimpleMailMessage, sal_Int32 /*aFlag*/ )
+ throw (IllegalArgumentException, Exception, RuntimeException)
+{
+ if ( ! xSimpleMailMessage.is() )
+ {
+ throw ::com::sun::star::lang::IllegalArgumentException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM( "No message specified" )),
+ static_cast < XSimpleMailClient * > (this), 1 );
+ }
+
+ if( ! m_xConfigurationProvider.is() )
+ {
+ throw ::com::sun::star::uno::Exception(
+ OUString(RTL_CONSTASCII_USTRINGPARAM( "Can not access configuration" )),
+ static_cast < XSimpleMailClient * > (this) );
+ }
+
+ OStringBuffer aBuffer;
+ aBuffer.append("\"");
+
+ OUString aProgramURL(RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/program/senddoc"));
+ rtl::Bootstrap::expandMacros(aProgramURL);
+
+ OUString aProgram;
+ if ( FileBase::E_None != FileBase::getSystemPathFromFileURL(aProgramURL, aProgram))
+ {
+ throw ::com::sun::star::uno::Exception(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("Cound not convert executable path")),
+ static_cast < XSimpleMailClient * > (this));
+ }
+
+ aBuffer.append(OUStringToOString(aProgram, osl_getThreadTextEncoding()));
+ aBuffer.append("\" ");
+
+ try
+ {
+ // Query XNameAccess interface of the org.openoffice.Office.Common/ExternalMailer
+ // configuration node to retriece the users preferred email application. This may
+ // transparently by redirected to e.g. the corresponding GConf setting in GNOME.
+ OUString aConfigRoot = OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/ExternalMailer" ) );
+
+ PropertyValue aProperty;
+ aProperty.Name = OUString::createFromAscii( "nodepath" );
+ aProperty.Value = makeAny( aConfigRoot );
+
+ Sequence< Any > aArgumentList( 1 );
+ aArgumentList[0] = makeAny( aProperty );
+
+ Reference< XNameAccess > xNameAccess =
+ Reference< XNameAccess > (
+ m_xConfigurationProvider->createInstanceWithArguments(
+ OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ),
+ aArgumentList ),
+ UNO_QUERY );
+
+ if( xNameAccess.is() )
+ {
+ OUString aMailer;
+
+ // Retrieve the value for "Program" node and append it feed senddoc with it
+ // using the (undocumented) --mailclient switch
+ xNameAccess->getByName( OUString::createFromAscii( "Program" ) ) >>= aMailer;
+
+ if( aMailer.getLength() )
+ {
+ // make sure we have a system path
+ FileBase::getSystemPathFromFileURL( aMailer, aMailer );
+
+ aBuffer.append("--mailclient ");
+ aBuffer.append(OUStringToOString( aMailer, osl_getThreadTextEncoding() ));
+ aBuffer.append(" ");
+ }
+#ifdef MACOSX
+ else
+ aBuffer.append("--mailclient Mail ");
+#endif
+ }
+
+ }
+
+ catch( RuntimeException e )
+ {
+ m_xConfigurationProvider.clear();
+ OSL_TRACE( "RuntimeException caught accessing configuration provider." );
+ OSL_TRACE( OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ throw e;
+ }
+
+ // Append originator if set in the message
+ if ( xSimpleMailMessage->getOriginator().getLength() > 0 )
+ {
+ aBuffer.append("--from \"");
+ aBuffer.append(OUStringToOString(xSimpleMailMessage->getOriginator(), osl_getThreadTextEncoding()));
+ aBuffer.append("\" ");
+ }
+
+ // Append receipient if set in the message
+ if ( xSimpleMailMessage->getRecipient().getLength() > 0 )
+ {
+ aBuffer.append("--to \"");
+ aBuffer.append(OUStringToOString(xSimpleMailMessage->getRecipient(), osl_getThreadTextEncoding()));
+ aBuffer.append("\" ");
+ }
+
+ // Append carbon copy receipients set in the message
+ Sequence< OUString > aStringList = xSimpleMailMessage->getCcRecipient();
+ sal_Int32 n, nmax = aStringList.getLength();
+ for ( n = 0; n < nmax; n++ )
+ {
+ aBuffer.append("--cc \"");
+ aBuffer.append(OUStringToOString(aStringList[n], osl_getThreadTextEncoding()));
+ aBuffer.append("\" ");
+ }
+
+ // Append blind carbon copy receipients set in the message
+ aStringList = xSimpleMailMessage->getBccRecipient();
+ nmax = aStringList.getLength();
+ for ( n = 0; n < nmax; n++ )
+ {
+ aBuffer.append("--bcc \"");
+ aBuffer.append(OUStringToOString(aStringList[n], osl_getThreadTextEncoding()));
+ aBuffer.append("\" ");
+ }
+
+ // Append subject if set in the message
+ if ( xSimpleMailMessage->getSubject().getLength() > 0 )
+ {
+ aBuffer.append("--subject \"");
+ aBuffer.append(OUStringToOString(xSimpleMailMessage->getSubject(), osl_getThreadTextEncoding()));
+ aBuffer.append("\" ");
+ }
+
+ // Append attachments set in the message
+ aStringList = xSimpleMailMessage->getAttachement();
+ nmax = aStringList.getLength();
+ for ( n = 0; n < nmax; n++ )
+ {
+ OUString aSystemPath;
+ if ( FileBase::E_None == FileBase::getSystemPathFromFileURL(aStringList[n], aSystemPath) )
+ {
+ aBuffer.append("--attach \"");
+ aBuffer.append(OUStringToOString(aSystemPath, osl_getThreadTextEncoding()));
+ aBuffer.append("\" ");
+ }
+ }
+
+ OString cmd = aBuffer.makeStringAndClear();
+ if ( 0 != pclose(popen(cmd.getStr(), "w")) )
+ {
+ throw ::com::sun::star::uno::Exception(
+ OUString(RTL_CONSTASCII_USTRINGPARAM( "No mail client configured" )),
+ static_cast < XSimpleMailClient * > (this) );
+ }
+}
+
+// -------------------------------------------------
+// XServiceInfo
+// -------------------------------------------------
+
+OUString SAL_CALL CmdMailSuppl::getImplementationName( )
+ throw( RuntimeException )
+{
+ return OUString::createFromAscii( COMP_IMPL_NAME );
+}
+
+// -------------------------------------------------
+// XServiceInfo
+// -------------------------------------------------
+
+sal_Bool SAL_CALL CmdMailSuppl::supportsService( const OUString& ServiceName )
+ throw( RuntimeException )
+{
+ Sequence < OUString > SupportedServicesNames = Component_getSupportedServiceNames();
+
+ for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
+ if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+ return sal_True;
+
+ return sal_False;
+}
+
+// -------------------------------------------------
+// XServiceInfo
+// -------------------------------------------------
+
+Sequence< OUString > SAL_CALL CmdMailSuppl::getSupportedServiceNames( )
+ throw( RuntimeException )
+{
+ return Component_getSupportedServiceNames();
+}
+
diff --git a/shell/source/cmdmail/cmdmailsuppl.hxx b/shell/source/cmdmail/cmdmailsuppl.hxx
new file mode 100644
index 000000000000..343de67cb68c
--- /dev/null
+++ b/shell/source/cmdmail/cmdmailsuppl.hxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CMDMAILSUPPL_HXX_
+#define _CMDMAILSUPPL_HXX_
+
+//----------------------------------------------------------
+// includes of other projects
+//----------------------------------------------------------
+
+#include <cppuhelper/implbase3.hxx>
+#include <osl/mutex.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
+#include <com/sun/star/system/XSimpleMailClient.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
+#include <com/sun/star/system/XSimpleMailClientSupplier.hpp>
+#endif
+
+//----------------------------------------------------------
+// class declaration
+//----------------------------------------------------------
+
+class CmdMailSuppl :
+ public cppu::WeakImplHelper3<
+ com::sun::star::system::XSimpleMailClientSupplier,
+ com::sun::star::system::XSimpleMailClient,
+ com::sun::star::lang::XServiceInfo >
+{
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigurationProvider;
+
+public:
+ CmdMailSuppl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
+
+ //------------------------------------------------
+ // XSimpleMailClientSupplier
+ //------------------------------------------------
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailClient > SAL_CALL querySimpleMailClient( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ //------------------------------------------------
+ // XSimpleMailClient
+ //------------------------------------------------
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailMessage > SAL_CALL createSimpleMailMessage( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL sendSimpleMailMessage( const ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailMessage >& xSimpleMailMessage, sal_Int32 aFlag )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ //------------------------------------------------
+ // XServiceInfo
+ //------------------------------------------------
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw(::com::sun::star::uno::RuntimeException);
+};
+
+#endif
diff --git a/shell/source/cmdmail/exports.dxp b/shell/source/cmdmail/exports.dxp
new file mode 100644
index 000000000000..028ac4175990
--- /dev/null
+++ b/shell/source/cmdmail/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/shell/source/cmdmail/exports.map b/shell/source/cmdmail/exports.map
new file mode 100644
index 000000000000..ba501f9ae076
--- /dev/null
+++ b/shell/source/cmdmail/exports.map
@@ -0,0 +1,10 @@
+UDK_3_0_0 {
+ global:
+ GetVersionInfo;
+ component_getImplementationEnvironment;
+ component_getFactory;
+ component_writeInfo;
+
+ local:
+ *;
+};
diff --git a/shell/source/cmdmail/makefile.mk b/shell/source/cmdmail/makefile.mk
new file mode 100644
index 000000000000..a7eaec1f89dd
--- /dev/null
+++ b/shell/source/cmdmail/makefile.mk
@@ -0,0 +1,64 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=shell
+TARGET=cmdmail
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+DLLPRE=
+
+SLOFILES= \
+ $(SLO)$/cmdmailsuppl.obj \
+ $(SLO)$/cmdmailmsg.obj \
+ $(SLO)$/cmdmailentry.obj
+SHL1OBJS=$(SLOFILES)
+
+SHL1TARGET=$(TARGET).uno
+SHL1IMPLIB=i$(TARGET)
+
+SHL1STDLIBS=$(CPPULIB)\
+ $(CPPUHELPERLIB)\
+ $(SALLIB)
+
+SHL1VERSIONMAP=exports.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/shell/source/mingw_intel.map b/shell/source/mingw_intel.map
new file mode 100644
index 000000000000..7713d456aba5
--- /dev/null
+++ b/shell/source/mingw_intel.map
@@ -0,0 +1,57 @@
+UDK_3_0_0 { # should have been UDK_3.0
+ global:
+ GetVersionInfo;
+ _ZN9salhelper18ORealDynamicLoader11newInstanceEPPS0_RKN3rtl8OUStringES6_;
+ _ZN9salhelper18ORealDynamicLoader7acquireEv;
+ _ZN9salhelper18ORealDynamicLoader7releaseEv;
+ _ZN9salhelper18ORealDynamicLoaderC1EPPS0_RKN3rtl8OUStringES6_PvS7_;
+ _ZN9salhelper18ORealDynamicLoaderC2EPPS0_RKN3rtl8OUStringES6_PvS7_;
+ _ZN9salhelper18ORealDynamicLoaderD0Ev;
+ _ZN9salhelper18ORealDynamicLoaderD1Ev;
+ _ZN9salhelper18ORealDynamicLoaderD2Ev;
+ _ZN9salhelper21SimpleReferenceObjectD0Ev;
+ _ZN9salhelper21SimpleReferenceObjectD1Ev;
+ _ZN9salhelper21SimpleReferenceObjectD2Ev;
+ _ZN9salhelper21SimpleReferenceObjectdlEPv;
+ _ZN9salhelper21SimpleReferenceObjectnwEj;
+ _ZNK9salhelper18ORealDynamicLoader6getApiEv;
+ # _ZTIN9salhelper18ORealDynamicLoaderE;
+ # _ZTSN9salhelper18ORealDynamicLoaderE;
+ _ZTVN9salhelper18ORealDynamicLoaderE;
+ # _ZTIN9salhelper21SimpleReferenceObjectE;
+ # _ZTSN9salhelper21SimpleReferenceObjectE;
+ _ZTVN9salhelper21SimpleReferenceObjectE;
+
+ _ZN9salhelper21SimpleReferenceObjectdlEPvRKSt9nothrow_t;
+ _ZN9salhelper21SimpleReferenceObjectnwEjRKSt9nothrow_t;
+ _ZN9salhelper9ConditionC1ERN3osl5MutexE;
+ _ZN9salhelper9ConditionC2ERN3osl5MutexE;
+ _ZN9salhelper9ConditionD0Ev;
+ _ZN9salhelper9ConditionD1Ev;
+ _ZN9salhelper9ConditionD2Ev;
+ # _ZTIN9salhelper9ConditionE;
+ # _ZTIS9salhelper9ConditionE;
+
+ _ZN9salhelper17ConditionModifierC1ERNS_9ConditionE;
+ _ZN9salhelper17ConditionModifierC2ERNS_9ConditionE;
+ _ZN9salhelper17ConditionModifierD1Ev;
+ _ZN9salhelper17ConditionModifierD2Ev;
+
+ _ZN9salhelper15ConditionWaiterC1ERNS_9ConditionE;
+ _ZN9salhelper15ConditionWaiterC1ERNS_9ConditionEm;
+ _ZN9salhelper15ConditionWaiterC2ERNS_9ConditionE;
+ _ZN9salhelper15ConditionWaiterC2ERNS_9ConditionEm;
+ _ZN9salhelper15ConditionWaiterD1Ev;
+ _ZN9salhelper15ConditionWaiterD2Ev;
+
+ _ZN9salhelper15ConditionWaiter8timedoutaSERKS1_;
+ _ZN9salhelper15ConditionWaiter8timedoutC1ERKS1_;
+ _ZN9salhelper15ConditionWaiter8timedoutC1Ev;
+ _ZN9salhelper15ConditionWaiter8timedoutC2ERKS1_;
+ _ZN9salhelper15ConditionWaiter8timedoutC2Ev;
+ _ZN9salhelper15ConditionWaiter8timedoutD0Ev;
+ _ZN9salhelper15ConditionWaiter8timedoutD1Ev;
+ _ZN9salhelper15ConditionWaiter8timedoutD2Ev;
+ # _ZTIN9salhelper15ConditionWaiter8timedoutE;
+ # _ZTSN9salhelper15ConditionWaiter8timedoutE;
+} UDK_3_0_0;
diff --git a/shell/source/tools/lngconvex/cmdline.cxx b/shell/source/tools/lngconvex/cmdline.cxx
new file mode 100644
index 000000000000..8e51e0b203e1
--- /dev/null
+++ b/shell/source/tools/lngconvex/cmdline.cxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include <stdexcept>
+#include <osl/diagnose.h>
+#include "cmdline.hxx"
+
+//---------------------------------
+/** Simple command line abstraction
+*/
+
+//################################
+// Creation
+//################################
+
+
+CommandLine::CommandLine(size_t argc, char* argv[], const std::string& ArgPrefix) :
+ m_argc(argc),
+ m_argv(argv),
+ m_argprefix(ArgPrefix)
+{
+}
+
+
+//################################
+// Query
+//################################
+
+
+/** Return the argument count
+*/
+size_t CommandLine::get_arg_count() const
+{
+ return m_argc;
+}
+
+/** Return an argument by index
+ This method doesn't skip argument
+ names if any, so if the second
+ argument is an argument name the
+ function nevertheless returns it.
+
+ @precond 0 <= Index < GetArgumentCount
+
+ @throws std::out_of_range exception
+ if the given index is to high
+*/
+std::string CommandLine::get_arg(size_t Index) const
+{
+ OSL_PRECOND(Index < m_argc, "Index out of range");
+
+ if (Index > (m_argc - 1))
+ throw std::out_of_range("Invalid index");
+
+ return m_argv[Index];
+}
+
+
+/** Returns all argument name found in the
+ command line. An argument will be identified
+ by a specified prefix. The standard prefix
+ is '-'.
+ If the are no argument names the returned
+ container is empty.
+*/
+StringListPtr_t CommandLine::get_arg_names() const
+{
+ StringListPtr_t arg_cont(new StringList_t());
+
+ for (size_t i = 0; i < m_argc; i++)
+ {
+ std::string argn = m_argv[i];
+
+ if (is_arg_name(argn))
+ arg_cont->push_back(argn);
+ }
+
+ return arg_cont;
+}
+
+/** Returns an argument by name. If there are
+ duplicate argument names in the command line,
+ the first one wins.
+ Argument name an the argument value must be separated
+ by spaces. If the argument value starts with an
+ argument prefix use quotes else the return value is
+ an empty string because the value will be interpreted
+ as the next argument name.
+ If an argument value contains spaces use quotes.
+
+ @precond GetArgumentNames() -> has element ArgumentName
+
+ @throws std::invalid_argument exception
+ if the specified argument could not be
+ found
+*/
+std::string CommandLine::get_arg(const std::string& ArgumentName) const
+{
+ std::string arg_value;
+ size_t i;
+ for ( i = 0; i < m_argc; i++)
+ {
+ std::string arg = m_argv[i];
+
+ if (ArgumentName == arg && ((i+1) < m_argc) && !is_arg_name(m_argv[i+1]))
+ {
+ arg_value = m_argv[i+1];
+ break;
+ }
+ }
+
+ if (i == m_argc)
+ throw std::invalid_argument("Invalid argument name");
+
+ return arg_value;
+}
+
+
+//################################
+// Command
+//################################
+
+
+/** Set the prefix used to identify arguments in
+ the command line.
+
+ @precond prefix is not empty
+
+ @throws std::invalid_argument exception if
+ the prefix is empty
+*/
+void CommandLine::set_arg_prefix(const std::string& Prefix)
+{
+ OSL_PRECOND(Prefix.length(), "Empty argument prefix!");
+
+ if (0 == Prefix.length())
+ throw std::invalid_argument("Empty argument prefix not allowed");
+
+ m_argprefix = Prefix;
+}
+
+
+/** Returns whether a given argument is an argument name
+*/
+bool CommandLine::is_arg_name(const std::string& Argument) const
+{
+ return (0 == Argument.compare(0, m_argprefix.length(), m_argprefix));
+}
diff --git a/shell/source/tools/lngconvex/cmdline.hxx b/shell/source/tools/lngconvex/cmdline.hxx
new file mode 100644
index 000000000000..b7c5e5453136
--- /dev/null
+++ b/shell/source/tools/lngconvex/cmdline.hxx
@@ -0,0 +1,104 @@
+#ifndef _CMDLINE_HXX_
+#define _CMDLINE_HXX_
+
+#include "defs.hxx"
+
+//---------------------------------
+/** Simple command line abstraction
+*/
+
+class CommandLine
+{
+public:
+
+ //################################
+ // Creation
+ //################################
+
+
+ CommandLine(size_t argc, char* argv[], const std::string& ArgPrefix = std::string("-"));
+
+
+ //################################
+ // Query
+ //################################
+
+
+ /** Return the argument count
+ */
+ size_t get_arg_count() const;
+
+ /** Return an argument by index
+ This method doesn't skip argument
+ names if any, so if the second
+ argument is an argument name the
+ function nevertheless returns it.
+
+ @precond 0 <= Index < GetArgumentCount
+
+ @throws std::out_of_range exception
+ if the given index is to high
+ */
+ std::string get_arg(size_t Index) const;
+
+ /** Returns all argument name found in the
+ command line. An argument will be identified
+ by a specified prefix. The standard prefix
+ is '-'.
+ If there are no argument names the returned
+ container is empty.
+ */
+ StringListPtr_t get_arg_names() const;
+
+ /** Returns an argument by name. If there are
+ duplicate argument names in the command line,
+ the first one wins.
+ Argument name an the argument value must be separated
+ by spaces. If the argument value starts with an
+ argument prefix use quotes else the return value is
+ an empty string because the value will be interpreted
+ as the next argument name.
+ If an argument value contains spaces use quotes.
+
+ @precond GetArgumentNames() -> has element ArgumentName
+
+ @throws std::invalid_argument exception
+ if the specified argument could not be
+ found
+ */
+ std::string get_arg(const std::string& ArgumentName) const;
+
+
+ //################################
+ // Command
+ //################################
+
+
+ /** Set the prefix used to identify arguments in
+ the command line.
+
+ @precond prefix is not empty
+
+ @throws std::invalid_argument exception if
+ the prefix is empty
+ */
+ void set_arg_prefix(const std::string& Prefix);
+
+private:
+
+ /** Returns whether a given argument is an argument name
+ */
+ bool is_arg_name(const std::string& Argument) const;
+
+private:
+ size_t m_argc;
+ char** m_argv;
+ std::string m_argprefix;
+
+// prevent copy and assignment
+private:
+ CommandLine(const CommandLine&);
+ CommandLine& operator=(const CommandLine&);
+};
+
+#endif
diff --git a/shell/source/tools/lngconvex/defs.hxx b/shell/source/tools/lngconvex/defs.hxx
new file mode 100644
index 000000000000..4304a434b486
--- /dev/null
+++ b/shell/source/tools/lngconvex/defs.hxx
@@ -0,0 +1,14 @@
+#ifndef _DEFS_HXX_
+#define _DEFS_HXX_
+
+#include <vector>
+#include <string>
+#include <memory>
+
+typedef std::vector<std::string> StringList_t;
+typedef std::auto_ptr<StringList_t> StringListPtr_t;
+
+typedef std::vector<int> IntegerList_t;
+typedef std::auto_ptr<IntegerList_t> IntegerListPtr_t;
+
+#endif
diff --git a/shell/source/tools/lngconvex/lngconvex.cxx b/shell/source/tools/lngconvex/lngconvex.cxx
new file mode 100644
index 000000000000..0d716d6c568d
--- /dev/null
+++ b/shell/source/tools/lngconvex/lngconvex.cxx
@@ -0,0 +1,604 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#include <tools/presys.h>
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <tools/postsys.h>
+
+#define VCL_NEED_BASETSD
+
+#include "cmdline.hxx"
+
+#include "osl/thread.h"
+#include "osl/process.h"
+#include "osl/file.hxx"
+
+#include "tools/config.hxx"
+#include "i18npool/mslangid.hxx"
+
+#include <iostream>
+#include <fstream>
+#include <map>
+#include <sstream>
+#include <iterator>
+#include <algorithm>
+#include <string>
+
+namespace /* private */
+{
+
+using rtl::OUString;
+using rtl::OString;
+
+//###########################################
+void ShowUsage()
+{
+ std::cout << "Usage: -ulf ulf_file -rc rc_output_file -rct rc_template_file -rch rch_file -rcf rcf_file" << std::endl;
+ std::cout << "-ulf Name of the ulf file" << std::endl;
+ std::cout << "-rc Name of the resulting resource file" << std::endl;
+ std::cout << "-rct Name of the resource template file" << std::endl;
+ std::cout << "-rch Name of the resource file header" << std::endl;
+ std::cout << "-rcf Name of the resource file footer" << std::endl;
+}
+
+//###########################################
+inline OUString OStringToOUString(const OString& str)
+{ return rtl::OStringToOUString(str, osl_getThreadTextEncoding()); }
+
+//###########################################
+inline OString OUStringToOString(const OUString& str)
+{ return rtl::OUStringToOString(str, osl_getThreadTextEncoding()); }
+
+//###########################################
+/** Get the directory where the module
+ is located as system directory, the
+ returned directory has a trailing '\' */
+OUString get_module_path()
+{
+ OUString cwd_url;
+ OUString module_path;
+ if (osl_Process_E_None == osl_getProcessWorkingDir(&cwd_url.pData))
+ osl::FileBase::getSystemPathFromFileURL(cwd_url, module_path);
+
+ return module_path;
+}
+
+//###########################################
+/** Make the absolute directory of a base and
+ a relative directory, if the relative
+ directory is absolute the the relative
+ directory will be returned unchanged.
+ Base and relative directory should be
+ system paths the returned directory is
+ a system path too */
+OUString get_absolute_path(
+ const OUString& BaseDir, const OUString& RelDir)
+{
+ OUString base_url;
+ OUString rel_url;
+
+ osl::FileBase::getFileURLFromSystemPath(BaseDir, base_url);
+ osl::FileBase::getFileURLFromSystemPath(RelDir, rel_url);
+
+ OUString abs_url;
+ osl::FileBase::getAbsoluteFileURL(base_url, rel_url, abs_url);
+
+ OUString abs_sys_path;
+ osl::FileBase::getSystemPathFromFileURL(abs_url, abs_sys_path);
+
+ return abs_sys_path;
+}
+
+//###########################################
+OString get_absolute_file_path(const std::string& file_name)
+{
+ OUString fp = get_absolute_path(
+ get_module_path(), OStringToOUString(file_name.c_str()));
+ return OUStringToOString(fp);
+}
+
+//###########################################
+/** A helper class, enables stream exceptions
+ on construction, restors the old exception
+ state on destruction */
+class StreamExceptionsEnabler
+{
+public:
+ explicit StreamExceptionsEnabler(
+ std::ios& iostrm,
+ std::ios::iostate NewIos = std::ios::failbit | std::ios::badbit) :
+ m_IoStrm(iostrm),
+ m_OldIos(m_IoStrm.exceptions())
+ {
+ m_IoStrm.exceptions(NewIos);
+ }
+
+ ~StreamExceptionsEnabler()
+ {
+ m_IoStrm.exceptions(m_OldIos);
+ }
+private:
+ std::ios& m_IoStrm;
+ std::ios::iostate m_OldIos;
+};
+
+typedef std::vector<std::string> string_container_t;
+
+//###########################################
+class iso_lang_identifier
+{
+public:
+ iso_lang_identifier() {};
+
+ iso_lang_identifier(const OString& str) :
+ lang_(str)
+ { init(); }
+
+ iso_lang_identifier(const std::string& str) :
+ lang_(str.c_str())
+ { init(); }
+
+ OString language() const
+ { return lang_; }
+
+ OString country() const
+ { return country_; }
+
+ OString make_OString() const
+ { return lang_ + "-" + country_; }
+
+ std::string make_std_string() const
+ {
+ OString tmp(lang_ + "-" + country_);
+ return tmp.getStr();
+ }
+
+private:
+ void init()
+ {
+ sal_Int32 idx = lang_.indexOf("-");
+
+ if (idx > -1)
+ {
+ country_ = lang_.copy(idx + 1);
+ lang_ = lang_.copy(0, idx);
+ }
+ }
+
+private:
+ OString lang_;
+ OString country_;
+};
+
+//###########################################
+/** Convert a OUString to the MS resource
+ file format string e.g.
+ OUString -> L"\x1A00\x2200\x3400" */
+std::string make_winrc_unicode_string(const OUString& str)
+{
+ std::ostringstream oss;
+ oss << "L\"";
+
+ size_t length = str.getLength();
+ const sal_Unicode* pchr = str.getStr();
+
+ for (size_t i = 0; i < length; i++)
+ oss << "\\x" << std::hex << (int)*pchr++;
+
+ oss << "\"";
+ return oss.str();
+}
+
+//###########################################
+std::string make_winrc_unicode_string(const std::string& str)
+{
+ return make_winrc_unicode_string(
+ OUString::createFromAscii(str.c_str()));
+}
+
+//################################################
+/** A replacement table contains pairs of
+ placeholders and the appropriate substitute */
+class Substitutor
+{
+private:
+ typedef std::map<std::string, std::string> replacement_table_t;
+ typedef std::map<std::string, replacement_table_t*> iso_lang_replacement_table_t;
+
+public:
+ typedef iso_lang_replacement_table_t::iterator iterator;
+ typedef iso_lang_replacement_table_t::const_iterator const_iterator;
+
+ iterator begin()
+ { return iso_lang_replacement_table_.begin(); }
+
+ iterator end()
+ { return iso_lang_replacement_table_.end(); }
+
+public:
+
+ Substitutor() {};
+
+ ~Substitutor()
+ {
+ iso_lang_replacement_table_t::iterator iter_end = iso_lang_replacement_table_.end();
+ iso_lang_replacement_table_t::iterator iter = iso_lang_replacement_table_.begin();
+
+ for( /* no init */; iter != iter_end; ++iter)
+ delete iter->second;
+
+ iso_lang_replacement_table_.clear();
+ }
+
+ void set_language(const iso_lang_identifier& iso_lang)
+ {
+ active_iso_lang_ = iso_lang;
+ }
+
+ // If Text is a placeholder substitute it with
+ //its substitute else leave it unchanged
+ void substitute(std::string& Text)
+ {
+ replacement_table_t* prt = get_replacement_table(active_iso_lang_.make_std_string());
+ OSL_ASSERT(prt);
+ replacement_table_t::iterator iter = prt->find(Text);
+ if (iter != prt->end())
+ Text = iter->second;
+ }
+
+ void add_substitution(
+ const std::string& Placeholder, const std::string& Substitute)
+ {
+ replacement_table_t* prt = get_replacement_table(active_iso_lang_.make_std_string());
+ OSL_ASSERT(prt);
+ prt->insert(std::make_pair(Placeholder, Substitute));
+ }
+
+
+private:
+ // Return the replacement table for the iso lang id
+ // create a new one if not already present
+ replacement_table_t* get_replacement_table(const std::string& iso_lang)
+ {
+ iso_lang_replacement_table_t::iterator iter =
+ iso_lang_replacement_table_.find(iso_lang);
+
+ replacement_table_t* prt = NULL;
+
+ if (iso_lang_replacement_table_.end() == iter)
+ {
+ prt = new replacement_table_t();
+ iso_lang_replacement_table_.insert(std::make_pair(iso_lang, prt));
+ }
+ else
+ {
+ prt = iter->second;
+ }
+ return prt;
+ }
+
+private:
+ iso_lang_replacement_table_t iso_lang_replacement_table_;
+ iso_lang_identifier active_iso_lang_;
+};
+
+typedef std::map< unsigned short , std::string , std::less< unsigned short > > shortmap;
+
+//###########################################
+void add_group_entries(
+ Config& aConfig,
+ const ByteString& GroupName,
+ Substitutor& Substitutor)
+{
+ OSL_ASSERT(aConfig.HasGroup(GroupName));
+
+ aConfig.SetGroup(GroupName);
+ size_t key_count = aConfig.GetKeyCount();
+ shortmap map;
+
+ for (size_t i = 0; i < key_count; i++)
+ {
+ ByteString iso_lang = aConfig.GetKeyName(sal::static_int_cast<USHORT>(i));
+ ByteString key_value_utf8 = aConfig.ReadKey(sal::static_int_cast<USHORT>(i));
+ iso_lang_identifier myiso_lang( iso_lang );
+ LanguageType ltype = MsLangId::convertIsoNamesToLanguage(myiso_lang.language(), myiso_lang.country());
+ if( ( ltype & 0x0200 ) == 0 && map[ ltype ].empty() )
+ {
+ Substitutor.set_language(iso_lang_identifier(iso_lang));
+
+ key_value_utf8.EraseLeadingAndTrailingChars('\"');
+
+ OUString key_value_utf16 =
+ rtl::OStringToOUString(key_value_utf8, RTL_TEXTENCODING_UTF8);
+
+ Substitutor.add_substitution(
+ GroupName.GetBuffer(), make_winrc_unicode_string(key_value_utf16));
+ map[ static_cast<unsigned short>(ltype) ] = std::string( iso_lang.GetBuffer() );
+ }
+ else
+ {
+ if( !map[ ltype ].empty() )
+ {
+ printf("ERROR: Duplicated ms id %d found for the languages %s and %s !!!! This does not work in microsoft resources\nPlease remove one!\n", ltype , map[ ltype ].c_str() , iso_lang.GetBuffer());
+ exit( -1 );
+ }
+ }
+ }
+}
+
+//###########################################
+void read_ulf_file(const std::string& FileName, Substitutor& Substitutor)
+{
+ // work-around for #i32420#
+
+ // as the Config class is currently not able to deal correctly with
+ // UTF8 files starting with a byte-order-mark we create a copy of the
+ // original file without the byte-order-mark
+ rtl::OUString tmpfile_url;
+ osl_createTempFile(NULL, NULL, &tmpfile_url.pData);
+
+ rtl::OUString tmpfile_sys;
+ osl::FileBase::getSystemPathFromFileURL(tmpfile_url, tmpfile_sys);
+
+ std::ifstream in(FileName.c_str());
+ std::ofstream out(OUStringToOString(tmpfile_sys).getStr());
+
+ try
+ {
+ StreamExceptionsEnabler sexc_out(out);
+ StreamExceptionsEnabler sexc_in(in);
+
+ //skip the byte-order-mark 0xEF 0xBB 0xBF, identifying UTF8 files
+ unsigned char BOM[3] = {0xEF, 0xBB, 0xBF};
+ char buff[3];
+ in.read(&buff[0], 3);
+
+ if (memcmp(buff, BOM, 3) != 0)
+ in.seekg(0);
+
+ std::string line;
+ while (std::getline(in, line))
+ out << line << std::endl;
+ }
+ catch (const std::ios::failure&)
+ {
+ if (!in.eof())
+ throw;
+ }
+
+ //Config config(OStringToOUString(FileName.c_str()).getStr());
+
+ // end work-around for #i32420#
+
+ Config config(tmpfile_url.getStr());
+ size_t grpcnt = config.GetGroupCount();
+ for (size_t i = 0; i < grpcnt; i++)
+ add_group_entries(config, config.GetGroupName(sal::static_int_cast<USHORT>(i)), Substitutor);
+}
+
+//###########################################
+void read_file(
+ const std::string& fname,
+ string_container_t& string_container)
+{
+ std::ifstream file(fname.c_str());
+ StreamExceptionsEnabler sexc(file);
+
+ try
+ {
+ std::string line;
+ while (std::getline(file, line))
+ string_container.push_back(line);
+ }
+ catch(const std::ios::failure&)
+ {
+ if (!file.eof())
+ throw;
+ }
+}
+
+//###########################################
+/** A simple helper function that appens the
+ content of one file to another one */
+void concatenate_files(std::ostream& os, std::istream& is)
+{
+ StreamExceptionsEnabler os_sexc(os);
+ StreamExceptionsEnabler is_sexc(is);
+
+ try
+ {
+ std::string line;
+ while (std::getline(is, line))
+ os << line << std::endl;
+ }
+ catch(const std::ios::failure&)
+ {
+ if (!is.eof())
+ throw;
+ }
+}
+
+//###########################################
+bool is_placeholder(const std::string& str)
+{
+ return ((str.length() > 1) &&
+ ('%' == str[0]) &&
+ ('%' == str[str.length() - 1]));
+}
+
+//###########################################
+void start_language_section(
+ std::ostream_iterator<std::string>& ostream_iter, const iso_lang_identifier& iso_lang)
+{
+ ostream_iter = std::string();
+
+ std::string lang_section("LANGUAGE ");
+
+ LanguageType ltype = MsLangId::convertIsoNamesToLanguage(iso_lang.language(), iso_lang.country());
+
+ char buff[10];
+ int primLangID = PRIMARYLANGID(ltype);
+ int subLangID = SUBLANGID(ltype);
+ // Our resources are normaly not sub language dependant.
+ // Esp. for spanish we don't want to distinguish between trad.
+ // and internatinal sorting ( which leads to two different sub languages )
+ // Setting the sub language to neutral allows us to use one
+ // stringlist for all spanish variants ( see #123126# )
+ if ( ( primLangID == LANG_SPANISH ) &&
+ ( subLangID == SUBLANG_SPANISH ) )
+ subLangID = SUBLANG_NEUTRAL;
+
+ _itoa(primLangID, buff, 16);
+ lang_section += std::string("0x") + std::string(buff);
+
+ lang_section += std::string(" , ");
+
+ _itoa(subLangID, buff, 16);
+
+ lang_section += std::string("0x") + std::string(buff);
+ ostream_iter = lang_section;
+}
+
+//###########################################
+/** Iterate all languages in the substitutor,
+ replace the all placeholder and append the
+ result to the output file */
+void inflate_rc_template_to_file(
+ std::ostream& os, const string_container_t& rctmpl, Substitutor& substitutor)
+{
+ StreamExceptionsEnabler sexc(os);
+
+ Substitutor::const_iterator iter = substitutor.begin();
+ Substitutor::const_iterator iter_end = substitutor.end();
+
+ std::ostream_iterator<std::string> oi(os, "\n");
+
+ for ( /**/ ;iter != iter_end; ++iter)
+ {
+ substitutor.set_language(iso_lang_identifier(iter->first));
+
+ string_container_t::const_iterator rct_iter = rctmpl.begin();
+ string_container_t::const_iterator rct_iter_end = rctmpl.end();
+
+ if (!rctmpl.empty())
+ start_language_section(oi, iter->first);
+
+ for ( /**/ ;rct_iter != rct_iter_end; ++rct_iter)
+ {
+ std::istringstream iss(*rct_iter);
+ std::string line;
+
+ while (iss)
+ {
+ std::string token;
+ iss >> token;
+ substitutor.substitute(token);
+
+ // #110274# HACK for partially merged
+ // *.lng files where some strings have
+ // a particular language that others
+ // don't have in order to keep the
+ // build
+ if (is_placeholder(token))
+ token = make_winrc_unicode_string(token);
+
+ line += token;
+ line += " ";
+ }
+ oi = line;
+ }
+ }
+}
+
+} // namespace /* private */
+
+//####################################################
+/* MAIN
+ The file names provided via command line should be
+ absolute or relative to the directory of this module.
+
+ Algo:
+ 1. read the ulf file and initialize the substitutor
+ 2. read the resource template file
+ 3. create the output file and append the header
+ 4. inflate the resource template to the output file
+ for every language using the substitutor
+ 5. append the footer
+*/
+#define MAKE_ABSOLUTE(s) (get_absolute_file_path((s)).getStr())
+#define ULF_FILE(c) MAKE_ABSOLUTE((c).get_arg("-ulf"))
+#define RC_TEMPLATE(c) MAKE_ABSOLUTE((c).get_arg("-rct"))
+#define RC_FILE(c) MAKE_ABSOLUTE((c).get_arg("-rc"))
+#define RC_HEADER(c) MAKE_ABSOLUTE((c).get_arg("-rch"))
+#define RC_FOOTER(c) MAKE_ABSOLUTE((c).get_arg("-rcf"))
+
+int main(int argc, char* argv[])
+{
+ try
+ {
+ CommandLine cmdline(argc, argv);
+
+ Substitutor substitutor;
+ read_ulf_file(ULF_FILE(cmdline), substitutor);
+
+ string_container_t rc_tmpl;
+ read_file(RC_TEMPLATE(cmdline), rc_tmpl);
+
+ std::ofstream rc_file(RC_FILE(cmdline));
+ std::ifstream in_header(RC_HEADER(cmdline));
+ concatenate_files(rc_file, in_header);
+
+ inflate_rc_template_to_file(rc_file, rc_tmpl, substitutor);
+
+ std::ifstream in_footer(RC_FOOTER(cmdline));
+ concatenate_files(rc_file, in_footer);
+ }
+ catch(const std::ios::failure& ex)
+ {
+ std::cout << ex.what() << std::endl;
+ }
+ catch(std::exception& ex)
+ {
+ std::cout << ex.what() << std::endl;
+ ShowUsage();
+ }
+ catch(...)
+ {
+ std::cout << "Unexpected error..." << std::endl;
+ }
+ return 0;
+}
+
diff --git a/shell/source/tools/lngconvex/makefile.mk b/shell/source/tools/lngconvex/makefile.mk
new file mode 100644
index 000000000000..da28e5ff68f4
--- /dev/null
+++ b/shell/source/tools/lngconvex/makefile.mk
@@ -0,0 +1,68 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=shell
+TARGET=lngconvex
+TARGETTYPE=CUI
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(COM)"=="GCC"
+CFLAGS+=-fno-inline -D_NTSDK
+.ELSE
+CFLAGS+=-Ob0 -D_NTSDK
+.ENDIF
+
+APP1TARGET=$(TARGET)
+APP1OBJS=$(OBJ)$/$(TARGET).obj\
+ $(OBJ)$/cmdline.obj
+
+# need msvcprt.lib for bad_cast exception
+# symbols if we compiler with exceptions
+# only valid for a tool like this
+
+APP1STDLIBS= $(SALLIB)\
+ $(TOOLSLIB)\
+ $(I18NISOLANGLIB)
+
+.IF "$(COM)"!="GCC"
+APP1STDLIBS+= $(TOOLSLIBST) \
+ msvcprt.lib
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/shell/source/tools/regsvrex/makefile.mk b/shell/source/tools/regsvrex/makefile.mk
new file mode 100644
index 000000000000..2eb8dbf48481
--- /dev/null
+++ b/shell/source/tools/regsvrex/makefile.mk
@@ -0,0 +1,49 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=shell
+TARGET=regsvrex
+TARGETTYPE=CUI
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+OBJFILES=$(OBJ)$/regsvrex.obj
+APP1TARGET=$(TARGET)
+APP1OBJS=$(OBJFILES)
+APP1STDLIBS=$(KERNEL32LIB)
+APP1DEF=$(MISC)$/$(APP1TARGET).def
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/shell/source/tools/regsvrex/regsvrex.cxx b/shell/source/tools/regsvrex/regsvrex.cxx
new file mode 100644
index 000000000000..516e386e5e06
--- /dev/null
+++ b/shell/source/tools/regsvrex/regsvrex.cxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+typedef HRESULT (__stdcall *lpfnDllRegisterServer)();
+typedef HRESULT (__stdcall *lpfnDllUnregisterServer)();
+
+/**
+*/
+bool IsUnregisterParameter(const char* Param)
+{
+ return ((0 == _stricmp(Param, "/u")) ||
+ (0 == _stricmp(Param, "-u")));
+}
+
+/**
+*/
+int main(int argc, char* argv[])
+{
+ HMODULE hmod;
+ HRESULT hr = E_FAIL;
+ lpfnDllRegisterServer lpfn_register;
+ lpfnDllUnregisterServer lpfn_unregister;
+
+ if (2 == argc)
+ {
+ hmod = LoadLibraryA(argv[1]);
+
+ if (hmod)
+ {
+ lpfn_register = (lpfnDllRegisterServer)GetProcAddress(
+ hmod, "DllRegisterServer");
+
+ if (lpfn_register)
+ hr = lpfn_register();
+
+ FreeLibrary(hmod);
+ }
+ }
+ else if (3 == argc && IsUnregisterParameter(argv[1]))
+ {
+ hmod = LoadLibraryA(argv[2]);
+
+ if (hmod)
+ {
+ lpfn_unregister = (lpfnDllUnregisterServer)GetProcAddress(
+ hmod, "DllUnregisterServer");
+
+ if (lpfn_unregister)
+ hr = lpfn_unregister();
+
+ FreeLibrary(hmod);
+ }
+ }
+
+ return 0;
+}
diff --git a/shell/source/unix/exec/exports.map b/shell/source/unix/exec/exports.map
new file mode 100644
index 000000000000..ba501f9ae076
--- /dev/null
+++ b/shell/source/unix/exec/exports.map
@@ -0,0 +1,10 @@
+UDK_3_0_0 {
+ global:
+ GetVersionInfo;
+ component_getImplementationEnvironment;
+ component_getFactory;
+ component_writeInfo;
+
+ local:
+ *;
+};
diff --git a/shell/source/unix/exec/makefile.mk b/shell/source/unix/exec/makefile.mk
new file mode 100644
index 000000000000..2d9d5d250da4
--- /dev/null
+++ b/shell/source/unix/exec/makefile.mk
@@ -0,0 +1,90 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=shell
+TARGET=exec
+
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+COMP1TYPELIST=syssh
+
+TESTAPP1=urltest
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+DLLPRE=
+
+SLOFILES=$(SLO)$/shellexec.obj\
+ $(SLO)$/shellexecentry.obj
+
+SHL1OBJS=$(SLOFILES)
+
+SHL1TARGET=syssh.uno
+.IF "$(GUI)" == "OS2"
+SHL1IMPLIB=i$(TARGET)
+.ELSE
+SHL1IMPLIB=
+.ENDIF
+
+SHL1VERSIONMAP=exports.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+SHL1STDLIBS=$(CPPULIB)\
+ $(CPPUHELPERLIB)\
+ $(SALLIB)
+SHL1LIBS=
+SHL1DEPN=
+
+.IF "$(test)" != ""
+
+APP1TARGET=$(TESTAPP1)
+APP1STDLIBS= $(SHL1STDLIBS)
+APP1OBJS= \
+ $(SLO)$/shellexec.obj \
+ $(SLO)$/$(APP1TARGET).obj
+
+.ENDIF # "$(test)" != ""
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+run_test : $(BIN)$/$(TESTAPP1).sh
+ dmake test=t
+ $(BIN)$/$(TESTAPP1) urltest.txt
+
+$(BIN)$/$(TESTAPP1).sh : $$(@:f)
+ $(COPY) $< $@
+ -chmod +x $@
diff --git a/shell/source/unix/exec/shellexec.cxx b/shell/source/unix/exec/shellexec.cxx
new file mode 100644
index 000000000000..e6aca26922da
--- /dev/null
+++ b/shell/source/unix/exec/shellexec.cxx
@@ -0,0 +1,331 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include <osl/diagnose.h>
+#include <osl/thread.h>
+#include <osl/process.h>
+#include <osl/file.hxx>
+#include <rtl/ustrbuf.hxx>
+
+#ifndef _RTL_URI_H_
+#include <rtl/uri.hxx>
+#endif
+#include "shellexec.hxx"
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+
+#include <com/sun/star/util/XMacroExpander.hpp>
+#include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp>
+#include <com/sun/star/uri/ExternalUriReferenceTranslator.hpp>
+
+#include "uno/current_context.hxx"
+
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+//------------------------------------------------------------------------
+// namespace directives
+//------------------------------------------------------------------------
+
+using com::sun::star::system::XSystemShellExecute;
+using com::sun::star::system::SystemShellExecuteException;
+
+using rtl::OString;
+using rtl::OUString;
+using rtl::OStringBuffer;
+using rtl::OUStringBuffer;
+using osl::FileBase;
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::system::SystemShellExecuteFlags;
+using namespace cppu;
+
+//------------------------------------------------------------------------
+// defines
+//------------------------------------------------------------------------
+
+#define SHELLEXEC_IMPL_NAME "com.sun.star.comp.system.SystemShellExecute2"
+
+//------------------------------------------------------------------------
+// helper functions
+//------------------------------------------------------------------------
+
+namespace // private
+{
+ Sequence< OUString > SAL_CALL ShellExec_getSupportedServiceNames()
+ {
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii("com.sun.star.sys.shell.SystemShellExecute");
+ return aRet;
+ }
+}
+
+void escapeForShell( rtl::OStringBuffer & rBuffer, const rtl::OString & rURL)
+{
+ sal_Int32 nmax = rURL.getLength();
+ for(sal_Int32 n=0; n < nmax; ++n)
+ {
+ // escape every non alpha numeric characters (excluding a few "known good") by prepending a '\'
+ sal_Char c = rURL[n];
+#ifndef OS2 // YD shell does not support escaped chars
+ if( ( c < 'A' || c > 'Z' ) && ( c < 'a' || c > 'z' ) && ( c < '0' || c > '9' ) && c != '/' && c != '.' )
+ rBuffer.append( '\\' );
+#endif
+
+ rBuffer.append( c );
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------------------
+
+ShellExec::ShellExec( const Reference< XComponentContext >& xContext ) :
+ WeakImplHelper2< XSystemShellExecute, XServiceInfo >(),
+ m_xContext(xContext)
+{
+ try {
+ Reference< XCurrentContext > xCurrentContext(getCurrentContext());
+
+ if (xCurrentContext.is())
+ {
+ Any aValue = xCurrentContext->getValueByName(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "system.desktop-environment" ) ) );
+
+ OUString aDesktopEnvironment;
+ if (aValue >>= aDesktopEnvironment)
+ {
+ m_aDesktopEnvironment = OUStringToOString(aDesktopEnvironment, RTL_TEXTENCODING_ASCII_US);
+ }
+ }
+ } catch (RuntimeException e) {
+ }
+}
+
+//-------------------------------------------------
+//
+//-------------------------------------------------
+
+void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aParameter, sal_Int32 nFlags )
+ throw (IllegalArgumentException, SystemShellExecuteException, RuntimeException)
+{
+ OStringBuffer aBuffer, aLaunchBuffer;
+
+ // DESKTOP_LAUNCH, see http://freedesktop.org/pipermail/xdg/2004-August/004489.html
+ static const char *pDesktopLaunch = getenv( "DESKTOP_LAUNCH" );
+
+ // Check wether aCommand contains a document url or not
+ sal_Int32 nIndex = aCommand.indexOf( OUString( RTL_CONSTASCII_USTRINGPARAM(":/") ) );
+
+ if( nIndex > 0 || 0 == aCommand.compareToAscii("mailto:", 7) )
+ {
+ // It seems to be a url ..
+ // We need to re-encode file urls because osl_getFileURLFromSystemPath converts
+ // to UTF-8 before encoding non ascii characters, which is not what other apps
+ // expect.
+ OUString aURL(
+ com::sun::star::uri::ExternalUriReferenceTranslator::create(
+ m_xContext)->translateToExternal(aCommand));
+ if ( aURL.getLength() == 0 && aCommand.getLength() != 0 )
+ {
+ throw RuntimeException(
+ (OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "Cannot translate URI reference to external format: "))
+ + aCommand),
+ static_cast< cppu::OWeakObject * >(this));
+ }
+
+#ifdef MACOSX
+ aBuffer.append("open");
+#else
+ // The url launchers are expected to be in the $OOO_BASE_DIR/program
+ // directory:
+ com::sun::star::uno::Reference< com::sun::star::util::XMacroExpander >
+ exp;
+ if (!(m_xContext->getValueByName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "/singletons/com.sun.star.util.theMacroExpander")))
+ >>= exp)
+ || !exp.is())
+ {
+ throw SystemShellExecuteException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "component context fails to supply singleton"
+ " com.sun.star.util.theMacroExpander of type"
+ " com.sun.star.util.XMacroExpander")),
+ static_cast< XSystemShellExecute * >(this), ENOENT);
+ }
+ OUString aProgramURL;
+ try {
+ aProgramURL = exp->expandMacros(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/program/")));
+ } catch (com::sun::star::lang::IllegalArgumentException &)
+ {
+ throw SystemShellExecuteException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("Could not expand $OOO_BASE_DIR path")),
+ static_cast < XSystemShellExecute * > (this), ENOENT );
+ }
+
+ OUString aProgram;
+ if ( FileBase::E_None != FileBase::getSystemPathFromFileURL(aProgramURL, aProgram))
+ {
+ throw SystemShellExecuteException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("Cound not convert executable path")),
+ static_cast < XSystemShellExecute * > (this), ENOENT );
+ }
+
+#ifdef OS2
+ OStringBuffer aProg = OUStringToOString(aProgram, osl_getThreadTextEncoding());
+ aProg.append("open-url.exe");
+ OString aUrl = OUStringToOString(aURL, osl_getThreadTextEncoding());
+ if ( -1 == spawnl(P_NOWAIT, aProg.getStr(), aProg.getStr(), aUrl.getStr() , NULL) )
+ {
+ int nerr = errno;
+ throw SystemShellExecuteException(OUString::createFromAscii( strerror( nerr ) ),
+ static_cast < XSystemShellExecute * > (this), nerr );
+ }
+ return;
+#endif
+
+ OString aTmp = OUStringToOString(aProgram, osl_getThreadTextEncoding());
+ escapeForShell(aBuffer, aTmp);
+
+#ifdef SOLARIS
+ if ( m_aDesktopEnvironment.getLength() == 0 )
+ m_aDesktopEnvironment = OString("GNOME");
+#endif
+
+ // Respect the desktop environment - if there is an executable named
+ // <desktop-environement-is>-open-url, pass the url to this one instead
+ // of the default "open-url" script.
+ if ( m_aDesktopEnvironment.getLength() > 0 )
+ {
+ OString aDesktopEnvironment(m_aDesktopEnvironment.toAsciiLowerCase());
+ OStringBuffer aCopy(aTmp);
+
+ aCopy.append(aDesktopEnvironment);
+ aCopy.append("-open-url");
+
+ if ( 0 == access( aCopy.getStr(), X_OK) )
+ {
+ aBuffer.append(aDesktopEnvironment);
+ aBuffer.append("-");
+
+ /* CDE requires file urls to be decoded */
+ if ( m_aDesktopEnvironment.equals("CDE") && 0 == aURL.compareToAscii("file://", 7) )
+ {
+ aURL = rtl::Uri::decode(aURL, rtl_UriDecodeWithCharset, osl_getThreadTextEncoding());
+ }
+ }
+ }
+
+ aBuffer.append("open-url");
+#endif
+ aBuffer.append(" ");
+ escapeForShell(aBuffer, OUStringToOString(aURL, osl_getThreadTextEncoding()));
+
+ if ( pDesktopLaunch && *pDesktopLaunch )
+ {
+ aLaunchBuffer.append( pDesktopLaunch );
+ aLaunchBuffer.append(" ");
+ escapeForShell(aLaunchBuffer, OUStringToOString(aURL, osl_getThreadTextEncoding()));
+ }
+ } else {
+ escapeForShell(aBuffer, OUStringToOString(aCommand, osl_getThreadTextEncoding()));
+ aBuffer.append(" ");
+ if( nFlags != 42 )
+ escapeForShell(aBuffer, OUStringToOString(aParameter, osl_getThreadTextEncoding()));
+ else
+ aBuffer.append(OUStringToOString(aParameter, osl_getThreadTextEncoding()));
+ }
+
+ // Prefer DESKTOP_LAUNCH when available
+ if ( aLaunchBuffer.getLength() > 0 )
+ {
+ FILE *pLaunch = popen( aLaunchBuffer.makeStringAndClear().getStr(), "w" );
+ if ( pLaunch != NULL )
+ {
+ if ( 0 == pclose( pLaunch ) )
+ return;
+ }
+ // Failed, do not try DESKTOP_LAUNCH any more
+ pDesktopLaunch = NULL;
+ }
+
+ OString cmd = aBuffer.makeStringAndClear();
+ if ( 0 != pclose(popen(cmd.getStr(), "w")) )
+ {
+ int nerr = errno;
+ throw SystemShellExecuteException(OUString::createFromAscii( strerror( nerr ) ),
+ static_cast < XSystemShellExecute * > (this), nerr );
+ }
+}
+
+
+// -------------------------------------------------
+// XServiceInfo
+// -------------------------------------------------
+
+OUString SAL_CALL ShellExec::getImplementationName( )
+ throw( RuntimeException )
+{
+ return OUString::createFromAscii( SHELLEXEC_IMPL_NAME );
+}
+
+// -------------------------------------------------
+// XServiceInfo
+// -------------------------------------------------
+
+sal_Bool SAL_CALL ShellExec::supportsService( const OUString& ServiceName )
+ throw( RuntimeException )
+{
+ Sequence < OUString > SupportedServicesNames = ShellExec_getSupportedServiceNames();
+
+ for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
+ if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+ return sal_True;
+
+ return sal_False;
+}
+
+// -------------------------------------------------
+// XServiceInfo
+// -------------------------------------------------
+
+Sequence< OUString > SAL_CALL ShellExec::getSupportedServiceNames( )
+ throw( RuntimeException )
+{
+ return ShellExec_getSupportedServiceNames();
+}
+
diff --git a/shell/source/unix/exec/shellexec.hxx b/shell/source/unix/exec/shellexec.hxx
new file mode 100644
index 000000000000..d7955cc135fd
--- /dev/null
+++ b/shell/source/unix/exec/shellexec.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SHELLEXEC_HXX_
+#define _SHELLEXEC_HXX_
+
+#include <cppuhelper/implbase2.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/strbuf.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
+#include <com/sun/star/system/XSystemShellExecute.hpp>
+#endif
+
+//----------------------------------------------------------
+// class declaration
+//----------------------------------------------------------
+
+class ShellExec : public ::cppu::WeakImplHelper2< com::sun::star::system::XSystemShellExecute, com::sun::star::lang::XServiceInfo >
+{
+ ::rtl::OString m_aDesktopEnvironment;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ m_xContext;
+
+public:
+ ShellExec(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext);
+
+ //------------------------------------------------
+ // XSystemShellExecute
+ //------------------------------------------------
+
+ virtual void SAL_CALL execute( const ::rtl::OUString& aCommand, const ::rtl::OUString& aParameter, sal_Int32 nFlags )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::system::SystemShellExecuteException, ::com::sun::star::uno::RuntimeException);
+
+ //------------------------------------------------
+ // XServiceInfo
+ //------------------------------------------------
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw(::com::sun::star::uno::RuntimeException);
+};
+
+
+// helper function - needed for urltest
+void escapeForShell( rtl::OStringBuffer & rBuffer, const rtl::OString & rURL);
+
+#endif
diff --git a/shell/source/unix/exec/shellexecentry.cxx b/shell/source/unix/exec/shellexecentry.cxx
new file mode 100644
index 000000000000..da5e5613f955
--- /dev/null
+++ b/shell/source/unix/exec/shellexecentry.cxx
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+//-----------------------------------------------------------------------
+// includes of other projects
+//-----------------------------------------------------------------------
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+#include "shellexec.hxx"
+
+//-----------------------------------------------------------------------
+// namespace directives
+//-----------------------------------------------------------------------
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+using namespace ::cppu;
+using com::sun::star::system::XSystemShellExecute;
+
+//-----------------------------------------------------------------------
+// defines
+//-----------------------------------------------------------------------
+
+#define SHELLEXEC_SERVICE_NAME "com.sun.star.system.SystemShellExecute"
+#define SHELLEXEC_IMPL_NAME "com.sun.star.comp.system.SystemShellExecute"
+#define SHELLEXEC_REGKEY_NAME "/com.sun.star.comp.system.SystemShellExecute/UNO/SERVICES/com.sun.star.system.SystemShellExecute"
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+
+namespace
+{
+ Reference< XInterface > SAL_CALL createInstance(const Reference< XComponentContext >& xContext)
+ {
+ return Reference< XInterface >( static_cast< XSystemShellExecute* >( new ShellExec(xContext) ) );
+ }
+}
+
+//-----------------------------------------------------------------------
+// the 3 important functions which will be exported
+//-----------------------------------------------------------------------
+
+extern "C"
+{
+
+//----------------------------------------------------------------------
+// component_getImplementationEnvironment
+//----------------------------------------------------------------------
+
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//-----------------------------------------------------------------------
+// component_writeInfo
+//-----------------------------------------------------------------------
+
+sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
+ pXNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( SHELLEXEC_REGKEY_NAME ) ) );
+ return sal_True;
+ }
+ catch( InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "InvalidRegistryException caught");
+ }
+ }
+
+ return sal_False;
+}
+
+//----------------------------------------------------------------------
+// component_getFactory
+//----------------------------------------------------------------------
+
+void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* /*pSrvManager*/, uno_Interface* /*pRegistryKey*/ )
+{
+ Reference< XSingleComponentFactory > xFactory;
+
+ if (0 == ::rtl_str_compare( pImplName, SHELLEXEC_IMPL_NAME ))
+ {
+ OUString serviceName( RTL_CONSTASCII_USTRINGPARAM(SHELLEXEC_SERVICE_NAME) );
+
+ xFactory = ::cppu::createSingleComponentFactory(
+ createInstance,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(SHELLEXEC_IMPL_NAME) ),
+ Sequence< OUString >( &serviceName, 1 ) );
+
+ }
+
+ if (xFactory.is())
+ xFactory->acquire();
+
+ return xFactory.get();
+}
+
+} // extern "C"
diff --git a/shell/source/unix/exec/syssh.xml b/shell/source/unix/exec/syssh.xml
new file mode 100644
index 000000000000..5c72befa9141
--- /dev/null
+++ b/shell/source/unix/exec/syssh.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name>syssh</module-name>
+ <component-description>
+ <author> Oliver Braun </author>
+ <name>com.sun.star.comp.system.SystemShellExecute</name>
+ <description> The unix implementation of a SystemShellExecute service. </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.system.SystemShellExecute</supported-service>
+ <service-dependency>...</service-dependency>
+ <type>com.sun.star.system.XSystemShellExecute</type>
+ <type>com.sun.star.system.SystemShellExecuteException</type>
+ <type>com.sun.star.system.SystemShellExecuteFlags</type>
+ <type>com.sun.star.lang.IllegalArgumentException</type>
+ <type>com.sun.star.lang.XServiceInfo</type>
+ <type>com.sun.star.lang.XSingleComponentFactory</type>
+ <type>com.sun.star.lang.XTypeProvider</type>
+ <type>com.sun.star.uno.TypeClass</type>
+ <type>com.sun.star.uno.XAggregation</type>
+ <type>com.sun.star.uno.XComponentContext</type>
+ <type>com.sun.star.uno.XWeak</type>
+ <type>com.sun.star.registry.XRegistryKey</type>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency>
+ <runtime-module-dependency>cppu3</runtime-module-dependency>
+ <runtime-module-dependency>sal3</runtime-module-dependency>
+</module-description>
diff --git a/shell/source/unix/exec/urltest.cxx b/shell/source/unix/exec/urltest.cxx
new file mode 100644
index 000000000000..1de12766e650
--- /dev/null
+++ b/shell/source/unix/exec/urltest.cxx
@@ -0,0 +1,151 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "shellexec.hxx"
+
+#include <osl/process.h>
+
+#include <stdio.h>
+#include <limits.h>
+#include <string.h>
+#include <strings.h>
+
+// -----------------------------------------------------------------------
+
+int main(int argc, const char *argv[])
+{
+ int ret = 0;
+
+ if( argc != 2 )
+ {
+ fprintf(stderr, "Usage: urltest <urllist>\n");
+ return -1;
+ }
+
+ FILE * fp = fopen( argv[1], "r" );
+ if( NULL == fp )
+ {
+ perror( argv[1] );
+ return -1;
+ }
+
+ // expect urltest.sh beside this binary
+ char line[LINE_MAX];
+ size_t len = strlen(argv[0]);
+ strcpy( line, argv[0] );
+ strcpy( line + len, ".sh " );
+ len += 4;
+
+ unsigned int errors = 0;
+
+ // read url(s) to test from file
+ char url[512];
+ while( NULL != fgets(url, sizeof(url), fp))
+ {
+ // remove trailing line break
+ strtok( url, "\r\n" );
+
+ printf( "Passing URL: %s\n", url );
+
+ // test the encoding functionality from shellexec.cxx
+ rtl::OString aURL( url );
+ rtl::OStringBuffer aBuffer;
+ escapeForShell(aBuffer, aURL);
+
+ // append encoded URL as (only) parameter to the script
+ strcpy( line + len, aBuffer.getStr() );
+
+ printf( "Command line: %s\n", line );
+
+ FILE * pipe = popen( line, "r" );
+ if( NULL != pipe )
+ {
+ char buffer[BUFSIZ];
+
+ // initialize buffer with '\0'
+ memset(buffer, '\0', BUFSIZ);
+
+ // read the output of the script
+ if(NULL == fgets( buffer, BUFSIZ, pipe))
+ {
+ perror("FAILED: output of script could not be read");
+ printf( "\n");
+ ++errors;
+ continue;
+ }
+
+ // remove trailing line break again
+ strtok( buffer, "\r\n" );
+
+ int n = pclose(pipe);
+ if( 0 != n )
+ {
+ printf("FAILED: fclose returned %d\n\n", n );
+ ++errors;
+ continue;
+ }
+
+ if( 0 == strcmp( url, buffer ) )
+ {
+ // strings are identical: good !
+ printf( "OK\n\n");
+ }
+ else
+ {
+ // compare failed
+ printf( "FAILED: returned string is %s\n\n", buffer);
+ ++errors;
+ }
+
+ }
+ else
+ {
+ perror( line );
+ ret = -2;
+ break;
+ }
+ }
+
+ if( ferror( fp ) )
+ {
+ perror( argv[1] );
+ ret = -1;
+ }
+
+ fclose( fp );
+
+ if( errors )
+ {
+ printf( "Number of tests failing: %d\n", errors);
+ ret = -3;
+ }
+ else
+ printf( "All tests passed OK.\n" );
+
+
+ return ret;
+}
diff --git a/shell/source/unix/exec/urltest.sh b/shell/source/unix/exec/urltest.sh
new file mode 100644
index 000000000000..ce55ee694114
--- /dev/null
+++ b/shell/source/unix/exec/urltest.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "$1" \ No newline at end of file
diff --git a/shell/source/unix/exec/urltest.txt b/shell/source/unix/exec/urltest.txt
new file mode 100644
index 000000000000..e69a8cfaf92b
--- /dev/null
+++ b/shell/source/unix/exec/urltest.txt
@@ -0,0 +1,11 @@
+http://www.openoffice.org
+http://en.wiktionary.org/wiki/harmless';CMD=lsx-lx$HOME;IFS=x;$CMD;#'
+http://en.wikipedia.org/wiki/Shell_(computers)
+http://www.google.com/search?hl=$100+bill
+http://unix.t-a-y-l-o-r.com/;clear;ls
+http://www.google.com/;exec mozilla;
+http://www.yahoo.com/<>
+http://www.yahoo.com/\
+http://www.yahoo.com/"
+http://www.yahoo.com/'
+http://www.yahoo.com/;echo 'this'; \ No newline at end of file
diff --git a/shell/source/unix/misc/cde-open-url.sh b/shell/source/unix/misc/cde-open-url.sh
new file mode 100755
index 000000000000..c0c38145d6ee
--- /dev/null
+++ b/shell/source/unix/misc/cde-open-url.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ -x /usr/bin/mktemp ]
+then
+ TMPFILE=`mktemp -t open-url.XXXXXX`
+else
+ DTTMPDIR=`xrdb -query | grep DtTmpDir`
+ TMPFILE=${DTTMPDIR:-$HOME/.dt/tmp}/open-url.$$
+fi
+
+if [ -z "$TMPFILE" ]; then exit 1; fi
+( echo "$1" > "$TMPFILE"; dtaction Open "$TMPFILE"; rm -f "$TMPFILE" ) &
+exit 0
diff --git a/shell/source/unix/misc/gnome-open-url.c b/shell/source/unix/misc/gnome-open-url.c
new file mode 100644
index 000000000000..3bd7a61e6546
--- /dev/null
+++ b/shell/source/unix/misc/gnome-open-url.c
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <dlfcn.h>
+#include <string.h>
+#include <unistd.h>
+
+typedef int gboolean;
+typedef char gchar;
+typedef struct _GError GError;
+
+struct _GError
+{
+ int domain;
+ int code;
+ char *message;
+};
+
+typedef enum {
+ GNOME_VFS_OK
+} GnomeVFSResult;
+
+
+/*
+ * HACK: avoid error messages caused by not setting a GNOME program name
+ */
+
+gchar* gnome_gconf_get_gnome_libs_settings_relative (const gchar *subkey)
+{
+ void* handle = dlopen("libglib-2.0.so.0", RTLD_LAZY);
+
+ (void)subkey; /* avoid warning due to unused parameter */
+
+ if( NULL != handle )
+ {
+ gchar* (* g_strdup)(const gchar*) = (gchar* (*)(const gchar*)) dlsym(handle, "g_strdup");
+
+ if( NULL != g_strdup)
+ return g_strdup("/apps/gnome-settings/gnome-open-url");
+ }
+
+ return NULL;
+}
+
+/*
+ * Wrapper function which extracs gnome_url_show from libgnome
+ */
+
+gboolean gnome_url_show (const char *url, GError **error)
+{
+ void* handle = dlopen("libgnomevfs-2.so.0", RTLD_LAZY);
+ gboolean ret = 0;
+
+ (void)error; /* avoid warning due to unused parameter */
+
+ if( NULL != handle )
+ {
+ gboolean (* init) (void) =
+ (gboolean (*) (void)) dlsym(handle, "gnome_vfs_init");
+
+ if( NULL != init && init() )
+ {
+ GnomeVFSResult (* func) (const char *url) =
+ (GnomeVFSResult (*) (const char *)) dlsym(handle, "gnome_vfs_url_show");
+
+ if( NULL != func )
+ ret = (GNOME_VFS_OK == func(url));
+ }
+
+ dlclose(handle);
+ }
+
+ return ret;
+}
+
+/*
+ * The intended use of this tool is to pass the argument to
+ * the gnome_show_url function of libgnome2.
+ */
+
+int main(int argc, char *argv[] )
+{
+ GError *error = NULL;
+ char *fallback;
+ char *index;
+
+ if( argc != 2 )
+ {
+ fprintf( stderr, "Usage: gnome-open-url <uri>\n" );
+ return -1;
+ }
+
+ if( gnome_url_show(argv[1], &error) )
+ {
+ return 0;
+ }
+
+ /*
+ * launch open-url command by replacing gnome-open-url from
+ * the command line. This is the fallback when running on
+ * remote machines with no GNOME installed.
+ */
+
+ fallback = strdup(argv[0]);
+ index = strstr(fallback, "gnome-open-url");
+ if ( NULL != index )
+ {
+ char *args[3];
+ strncpy(index, "open-url", 9);
+ args[0] = fallback;
+ args[1] = argv[1];
+ args[2] = NULL;
+ return execv(fallback, args);
+ }
+
+ return -1;
+}
+
+
+
diff --git a/shell/source/unix/misc/gnome-open-url.sh b/shell/source/unix/misc/gnome-open-url.sh
new file mode 100644
index 000000000000..1a52fc763783
--- /dev/null
+++ b/shell/source/unix/misc/gnome-open-url.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# use gnome-open utility coming with libgnome if available
+gnome-open "$1" 2>/dev/null || "$0.bin" $1
+
+exit 0
diff --git a/shell/source/unix/misc/kde-open-url.sh b/shell/source/unix/misc/kde-open-url.sh
new file mode 100755
index 000000000000..fa05bdecbda4
--- /dev/null
+++ b/shell/source/unix/misc/kde-open-url.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# special handling for mailto: uris
+if echo $1 | grep '^mailto:' > /dev/null; then
+ kmailservice "$1" &
+else
+ kfmclient openURL "$1" &
+fi
+
+exit 0
diff --git a/shell/source/unix/misc/makefile.mk b/shell/source/unix/misc/makefile.mk
new file mode 100644
index 000000000000..67fcc708c615
--- /dev/null
+++ b/shell/source/unix/misc/makefile.mk
@@ -0,0 +1,90 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=shell
+TARGET=misc
+
+LIBTARGET=NO
+TARGETTYPE=CUI
+NO_DEFAULT_STL=TRUE
+LIBSALCPPRT=$(0)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SCRIPTFILES = \
+ $(BIN)$/senddoc \
+ $(BIN)$/open-url \
+ $(BIN)$/cde-open-url \
+ $(BIN)$/gnome-open-url \
+ $(BIN)$/kde-open-url
+
+.IF "$(GUI)" == "OS2"
+
+APP1TARGET = open-url
+APP1OBJS = \
+ $(OBJ)$/open-url.obj \
+ open-url.def
+APP1LIBS =
+
+APP2TARGET = senddoc
+APP2OBJS = \
+ $(OBJ)$/senddoc.obj \
+ senddoc.def
+APP2LIBS =
+APP2STDLIBS =
+
+.ELSE
+
+APP1TARGET = gnome-open-url.bin
+APP1OBJS = \
+ $(OBJ)$/gnome-open-url.obj
+APP1LIBS =
+.IF "$(OS)"!="FREEBSD" && "$(OS)"!="NETBSD"
+APP1STDLIBS=-ldl
+.ENDIF
+
+APP2TARGET = uri-encode
+APP2OBJS = $(OBJ)$/uri-encode.obj
+APP2LIBS =
+APP2STDLIBS =
+
+OBJFILES = $(APP1OBJS) $(APP2OBJS)
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(SCRIPTFILES) $(AWKFILES)
+
+$(SCRIPTFILES) : $$(@:f:+".sh")
+ @tr -d "\015" < $(@:f:+".sh") > $@
diff --git a/shell/source/unix/misc/open-url.c b/shell/source/unix/misc/open-url.c
new file mode 100644
index 000000000000..91f4aeaff398
--- /dev/null
+++ b/shell/source/unix/misc/open-url.c
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <process.h>
+#include <time.h>
+
+#define INCL_DOS
+#define INCL_DOSERRORS
+#define INCL_PM
+#include <os2.h>
+
+// OOo uses popen() to start us, so we cannot show PM dialogs.
+// log message to disk.
+void logMessage( char* msg)
+{
+ PPIB pib;
+ CHAR szApplicationName[_MAX_PATH];
+ CHAR szDrive[_MAX_PATH];
+ CHAR szDir[_MAX_PATH];
+ CHAR szFileName[_MAX_PATH];
+ CHAR szExt[_MAX_PATH];
+ FILE* log;
+ time_t timeOfDay;
+ struct tm* localTime;
+
+ // get executable fullpath
+ DosGetInfoBlocks(NULL, &pib);
+ DosQueryModuleName(pib->pib_hmte, sizeof(szApplicationName), szApplicationName);
+ _splitpath( szApplicationName, szDrive, szDir, szFileName, szExt );
+ // log name
+ _makepath( szApplicationName, szDrive, szDir, szFileName, (".LOG") );
+ log = fopen( szApplicationName, "a");
+ if (!log)
+ return;
+ time( &timeOfDay);
+ localTime = localtime( &timeOfDay);
+ fprintf( log, "%04d/%02d/%02d %02d:%02d:%02d %s\n",
+ localTime->tm_year+1900, localTime->tm_mon+1, localTime->tm_mday,
+ localTime->tm_hour, localTime->tm_min, localTime->tm_sec, msg);
+ fclose( log);
+}
+
+// dump comand line arguments
+void dumpArgs( int argc, char *argv[] )
+{
+ int i;
+
+ logMessage( "Start of command line arguments dump:");
+ for( i=0; i<argc; i++)
+ logMessage( argv[i]);
+}
+
+/*
+ * The intended use of this tool is to pass the argument to
+ * the default URL exe.
+ */
+int main(int argc, char *argv[] )
+{
+ APIRET rc;
+ RESULTCODES result = {0};
+ char szAppFromINI[_MAX_PATH];
+ char szDirFromINI[_MAX_PATH];
+ char szCmdLine[1024];
+ char szFail[ _MAX_PATH];
+ ULONG ulSID;
+ PID pid;
+
+ // check parameters
+ if (argc != 2)
+ {
+ logMessage( "Usage: open-url <url>");
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // check configuration
+ rc = PrfQueryProfileString(HINI_USER, "WPURLDEFAULTSETTINGS",
+ "DefaultBrowserExe", "",
+ szAppFromINI, sizeof(szAppFromINI));
+ rc = PrfQueryProfileString(HINI_USER, "WPURLDEFAULTSETTINGS",
+ "DefaultWorkingDir", "",
+ szDirFromINI, sizeof(szDirFromINI));
+ if (*szAppFromINI == 0 || *szDirFromINI == 0)
+ {
+ logMessage( "Unable to find default url handler in USER.INI; exiting.");
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // get default parameter list
+ rc = PrfQueryProfileString(HINI_USER, "WPURLDEFAULTSETTINGS",
+ "DefaultParameters", "",
+ szCmdLine, sizeof(szCmdLine));
+ strcat( szCmdLine, " ");
+ strcat( szCmdLine, argv[1]);
+
+ // change default directory
+ _chdir( szDirFromINI);
+
+ // start default handler
+ STARTDATA SData;
+ CHAR szObjBuf[CCHMAXPATH];
+
+ SData.Length = sizeof(STARTDATA);
+ SData.Related = SSF_RELATED_INDEPENDENT;
+ SData.FgBg = (1) ? SSF_FGBG_FORE : SSF_FGBG_BACK;
+ SData.TraceOpt = SSF_TRACEOPT_NONE;
+
+ SData.PgmTitle = (PSZ)szAppFromINI;
+
+ SData.PgmName = (PSZ)szAppFromINI;
+ SData.PgmInputs = (PSZ)szCmdLine;
+
+ SData.TermQ = NULL;
+ SData.Environment = 0;
+ SData.InheritOpt = SSF_INHERTOPT_PARENT;
+ SData.SessionType = SSF_TYPE_PM;
+ SData.IconFile = 0;
+ SData.PgmHandle = 0;
+
+ SData.PgmControl = SSF_CONTROL_VISIBLE;
+
+ SData.InitXPos = 30;
+ SData.InitYPos = 40;
+ SData.InitXSize = 200;
+ SData.InitYSize = 140;
+ SData.Reserved = 0;
+ SData.ObjectBuffer = szFail;
+ SData.ObjectBuffLen = (ULONG)sizeof(szFail);
+
+ rc = DosStartSession( &SData, &ulSID, &pid);
+ // show error dialog in case of problems
+ if (rc != NO_ERROR && rc != ERROR_SMG_START_IN_BACKGROUND) {
+ char szMessage[ _MAX_PATH*2];
+ sprintf( szMessage, "Execution failed! rc: %d, failing module:%s", rc, szFail);
+ logMessage( szMessage);
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // ok
+ return 0;
+}
+
diff --git a/shell/source/unix/misc/open-url.def b/shell/source/unix/misc/open-url.def
new file mode 100644
index 000000000000..3a26831e2a65
--- /dev/null
+++ b/shell/source/unix/misc/open-url.def
@@ -0,0 +1 @@
+NAME open-url WINDOWAPI
diff --git a/shell/source/unix/misc/open-url.sh b/shell/source/unix/misc/open-url.sh
new file mode 100755
index 000000000000..5a70785f89d3
--- /dev/null
+++ b/shell/source/unix/misc/open-url.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+# tries to locate the executable specified
+# as first parameter in the user's path.
+which() {
+ if [ ! -z "$1" ]; then
+ for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
+ if [ -x "$i/$1" -a ! -d "$i/$1" ]; then
+ echo "$i/$1"
+ break;
+ fi
+ done
+ fi
+}
+
+# checks for the original mozilla start script(s)
+# and restrict the "-remote" semantics to those.
+run_mozilla() {
+ if file "$1" | grep "script" > /dev/null && grep "NPL" "$1" > /dev/null; then
+ "$1" -remote 'ping()' 2>/dev/null >/dev/null
+ if [ $? -eq 2 ]; then
+ "$1" "$2" &
+ else
+ "$1" -remote "openURL($2, new-window)" &
+ fi
+ else
+ "$1" "$2" &
+ fi
+}
+
+# checks the browser value for a %s as defined in
+# http://www.catb.org/~esr/BROWSER/index.html
+run_browser() {
+ echo "$1|$2" | awk '
+{
+ FS="|";
+ $syscmd="";
+ if (index($1,"%s") > 0) {
+ $syscmd=sprintf($1,$2);
+ } else {
+ $syscmd=sprintf("%s \"%s\"",$1,$2);
+ }
+ system($syscmd " &");
+}' > /dev/null
+}
+
+# special handling for mailto: uris
+if echo $1 | grep '^mailto:' > /dev/null; then
+ # check $MAILER variable
+ if [ ! -z "$MAILER" ]; then
+ $MAILER "$1" &
+ exit 0
+ else
+ # mozilla derivates may need -remote semantics
+ for i in thunderbird mozilla netscape; do
+ mailer=`which $i`
+ if [ ! -z "$mailer" ]; then
+ run_mozilla "$mailer" "$1"
+ exit 0
+ fi
+ done
+ # handle all non mozilla mail clients below
+ # ..
+ fi
+else
+ # check $BROWSER variable
+ if [ ! -z "$BROWSER" ]; then
+ $BROWSER "$1" &
+ exit 0
+ else
+ # mozilla derivates may need -remote semantics
+ for i in firefox mozilla netscape; do
+ browser=`which $i`
+ if [ ! -z "$browser" ]; then
+ run_mozilla "$browser" "$1"
+ exit 0
+ fi
+ done
+ # handle all non mozilla browers below
+ # ..
+ fi
+fi
+exit 1
diff --git a/shell/source/unix/misc/senddoc.c b/shell/source/unix/misc/senddoc.c
new file mode 100644
index 000000000000..5a21ef1ec50f
--- /dev/null
+++ b/shell/source/unix/misc/senddoc.c
@@ -0,0 +1,204 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <process.h>
+#include <time.h>
+
+#define INCL_DOS
+#define INCL_DOSERRORS
+#define INCL_PM
+#include <os2.h>
+
+// OOo uses popen() to start us, so we cannot show PM dialogs.
+// log message to disk.
+void logMessage( char* msg)
+{
+ PPIB pib;
+ CHAR szApplicationName[_MAX_PATH];
+ CHAR szDrive[_MAX_PATH];
+ CHAR szDir[_MAX_PATH];
+ CHAR szFileName[_MAX_PATH];
+ CHAR szExt[_MAX_PATH];
+ FILE* log;
+ time_t timeOfDay;
+ struct tm* localTime;
+
+ // get executable fullpath
+ DosGetInfoBlocks(NULL, &pib);
+ DosQueryModuleName(pib->pib_hmte, sizeof(szApplicationName), szApplicationName);
+ _splitpath( szApplicationName, szDrive, szDir, szFileName, szExt );
+ // log name
+ _makepath( szApplicationName, szDrive, szDir, szFileName, (".LOG") );
+ log = fopen( szApplicationName, "a");
+ if (!log)
+ return;
+ time( &timeOfDay);
+ localTime = localtime( &timeOfDay);
+ fprintf( log, "%04d/%02d/%02d %02d:%02d:%02d %s\n",
+ localTime->tm_year+1900, localTime->tm_mon+1, localTime->tm_mday,
+ localTime->tm_hour, localTime->tm_min, localTime->tm_sec, msg);
+ fclose( log);
+}
+
+// dump comand line arguments
+void dumpArgs( int argc, char *argv[] )
+{
+ int i;
+
+ logMessage( "Start of command line arguments dump:");
+ for( i=0; i<argc; i++)
+ logMessage( argv[i]);
+}
+
+/*
+ * The intended use of this tool is to pass the argument to
+ * the default mail handler.
+ */
+int main(int argc, char *argv[] )
+{
+ APIRET rc;
+ RESULTCODES result = {0};
+ char szAppFromINI[_MAX_PATH];
+ char szDirFromINI[_MAX_PATH];
+ char szCmdLine[1024];
+ char szFail[ _MAX_PATH];
+ ULONG ulSID;
+ PID pid;
+ int i;
+ BOOL bMailClient = FALSE;
+
+ // check parameters
+ if (argc < 5)
+ {
+ logMessage( "Usage: senddoc --mailclient <client> --attach <uri>");
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // check configuration
+ rc = PrfQueryProfileString(HINI_USER, "WPURLDEFAULTSETTINGS",
+ "DefaultMailExe", "",
+ szAppFromINI, sizeof(szAppFromINI));
+ rc = PrfQueryProfileString(HINI_USER, "WPURLDEFAULTSETTINGS",
+ "DefaultMailWorkingDir", "",
+ szDirFromINI, sizeof(szDirFromINI));
+ if (*szAppFromINI == 0 || *szDirFromINI == 0)
+ {
+ logMessage( "Unable to find default mail handler in USER.INI; exiting.");
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // get default parameter list, at leat -compose is required
+ rc = PrfQueryProfileString(HINI_USER, "WPURLDEFAULTSETTINGS",
+ "DefaultMailParameters", "",
+ szCmdLine, sizeof(szCmdLine));
+ if (strstr( szCmdLine, "-compose") == 0)
+ strcat( szCmdLine, " -compose"); // add if missing!
+
+ // parse cmdline arguments
+ for( i=1; i<argc; i++)
+ {
+ if (!strcmp( argv[i], "--mailclient")) {
+ // we support only Thunderbird/Mozilla command line options, check exe name
+ if (strstr( argv[i+1], "thunderbird") == 0
+ && strstr( argv[i+1], "mozilla") == 0
+ && strstr( argv[i+1], "seamonkey") == 0)
+ {
+ logMessage( "Only Thunderbird/Mozilla is currently supported. Exiting.");
+ dumpArgs( argc, argv);
+ return -1;
+ }
+ // mail client found
+ bMailClient = TRUE;
+ i++;
+ } else if (!strcmp( argv[i], "--attach")) {
+ strcat( szCmdLine, " attachment=file://");
+ strcat( szCmdLine, argv[i+1]);
+ i++;
+ }
+ // ignore other options (BTW currently none)
+ }
+ if (bMailClient == FALSE)
+ {
+ logMessage( "No mail client specified. Exiting.");
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // change default directory
+ _chdir( szDirFromINI);
+
+ // start default handler
+ STARTDATA SData;
+ CHAR szObjBuf[CCHMAXPATH];
+
+ SData.Length = sizeof(STARTDATA);
+ SData.Related = SSF_RELATED_INDEPENDENT;
+ SData.FgBg = (1) ? SSF_FGBG_FORE : SSF_FGBG_BACK;
+ SData.TraceOpt = SSF_TRACEOPT_NONE;
+
+ SData.PgmTitle = (PSZ)szAppFromINI;
+
+ SData.PgmName = (PSZ)szAppFromINI;
+ SData.PgmInputs = (PSZ)szCmdLine;
+
+ SData.TermQ = NULL;
+ SData.Environment = 0;
+ SData.InheritOpt = SSF_INHERTOPT_PARENT;
+ SData.SessionType = SSF_TYPE_PM;
+ SData.IconFile = 0;
+ SData.PgmHandle = 0;
+
+ SData.PgmControl = SSF_CONTROL_VISIBLE;
+
+ SData.InitXPos = 30;
+ SData.InitYPos = 40;
+ SData.InitXSize = 200;
+ SData.InitYSize = 140;
+ SData.Reserved = 0;
+ SData.ObjectBuffer = szFail;
+ SData.ObjectBuffLen = (ULONG)sizeof(szFail);
+
+ rc = DosStartSession( &SData, &ulSID, &pid);
+ // show error dialog in case of problems
+ if (rc != NO_ERROR && rc != ERROR_SMG_START_IN_BACKGROUND) {
+ char szMessage[ _MAX_PATH*2];
+ sprintf( szMessage, "Execution failed! rc: %d, failing module:%s", rc, szFail);
+ logMessage( szMessage);
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // ok
+ return 0;
+}
+
diff --git a/shell/source/unix/misc/senddoc.def b/shell/source/unix/misc/senddoc.def
new file mode 100644
index 000000000000..0abf1553a4a9
--- /dev/null
+++ b/shell/source/unix/misc/senddoc.def
@@ -0,0 +1 @@
+NAME senddoc WINDOWAPI
diff --git a/shell/source/unix/misc/senddoc.sh b/shell/source/unix/misc/senddoc.sh
new file mode 100644
index 000000000000..3d2690379134
--- /dev/null
+++ b/shell/source/unix/misc/senddoc.sh
@@ -0,0 +1,401 @@
+#!/bin/sh
+URI_ENCODE="`dirname $0`/uri-encode"
+FOPTS=""
+
+# linux file utility needs -L option to resolve symlinks
+if [ "`uname -s`" = "Linux" ]
+then
+ FOPTS="-L"
+fi
+
+# do not confuse the system mail clients with OOo and Java libraries
+unset LD_LIBRARY_PATH
+
+# tries to locate the executable specified
+# as first parameter in the user's path.
+which() {
+ if [ ! -z "$1" ]; then
+ for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
+ if [ -x "$i/$1" -a ! -d "$i/$1" ]; then
+ echo "$i/$1"
+ break;
+ fi
+ done
+ fi
+}
+
+# checks for the original mozilla start script(s)
+# and restrict the "-remote" semantics to those.
+run_mozilla() {
+ # find mozilla script in PATH if necessary
+ if [ "`basename $1`" = "$1" ]; then
+ moz=`which $1`
+ else
+ moz=$1
+ fi
+
+ if file $FOPTS "$moz" | grep "script" > /dev/null && grep "[NM]PL" "$moz" > /dev/null; then
+ "$moz" -remote 'ping()' 2>/dev/null >/dev/null
+ if [ $? -eq 2 ]; then
+ "$1" -compose "$2" &
+ else
+ "$1" -remote "xfeDoCommand(composeMessage,$2)" &
+ fi
+ else
+ "$1" -compose "$2" &
+ fi
+}
+
+if [ "$1" = "--mailclient" ]; then
+ shift
+ MAILER=$1
+ shift
+fi
+
+# autodetect mail client from executable name
+case `basename "$MAILER" | sed 's/-.*$//'` in
+
+ iceape | mozilla | netscape | seamonkey | icedove | thunderbird)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ TO=${TO:-}${TO:+,}$2
+ shift
+ ;;
+ --cc)
+ CC=${CC:-}${CC:+,}$2
+ shift
+ ;;
+ --bcc)
+ BCC=${BCC:-}${BCC:+,}$2
+ shift
+ ;;
+ --subject)
+ SUBJECT=$2
+ shift
+ ;;
+ --body)
+ BODY=$2
+ shift
+ ;;
+ --attach)
+ ATTACH=${ATTACH:-}${ATTACH:+,}`echo "file://$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ if [ "$TO" != "" ]; then
+ COMMAND=${COMMAND:-}${COMMAND:+,}to=${TO}
+ fi
+ if [ "$CC" != "" ]; then
+ COMMAND=${COMMAND:-}${COMMAND:+,}cc=${CC}
+ fi
+ if [ "$BCC" != "" ]; then
+ COMMAND=${COMMAND:-}${COMMAND:+,}bcc=${BCC}
+ fi
+ if [ "$SUBJECT" != "" ]; then
+ COMMAND=${COMMAND:-}${COMMAND:+,}subject=${SUBJECT}
+ fi
+ if [ "$BODY" != "" ]; then
+ COMMAND=${COMMAND:-}${COMMAND:+,}body=${BODY}
+ fi
+ if [ "$ATTACH" != "" ]; then
+ COMMAND=${COMMAND:-}${COMMAND:+,}attachment=${ATTACH}
+ fi
+
+ run_mozilla "$MAILER" "$COMMAND"
+ ;;
+
+ kmail)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ TO="${TO:-}${TO:+,}$2"
+ shift
+ ;;
+ --cc)
+ CC="${CC:-}${CC:+,}$2"
+ shift
+ ;;
+ --bcc)
+ BCC="${BCC:-}${BCC:+,}$2"
+ shift
+ ;;
+ --subject)
+ SUBJECT="$2"
+ shift
+ ;;
+ --body)
+ BODY="$2"
+ shift
+ ;;
+ --attach)
+ ATTACH="$2"
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ ${MAILER} --composer ${CC:+--cc} ${CC:+"${CC}"} ${BCC:+--bcc} ${BCC:+"${BCC}"} \
+ ${SUBJECT:+--subject} ${SUBJECT:+"${SUBJECT}"} ${BODY:+--body} ${BODY:+"${BODY}"} \
+ ${ATTACH:+--attach} ${ATTACH:+"${ATTACH}"} ${TO:+"${TO}"}
+ ;;
+
+ mutt)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --from)
+ FROM="$2"
+ shift
+ ;;
+ --to)
+ TO="${TO:-}${TO:+,}$2"
+ shift
+ ;;
+ --cc)
+ CC="${CC:-}${CC:+,}$2"
+ shift
+ ;;
+ --bcc)
+ BCC="${BCC:-}${BCC:+,}$2"
+ shift
+ ;;
+ --subject)
+ SUBJECT="$2"
+ shift
+ ;;
+ --body)
+ TEMPLATE="`basename $0`.mutt.XXXXXXXX"
+ BODY=`mktemp -q -t ${TEMPLATE}`
+ echo "$2" > $BODY
+ shift
+ ;;
+ --attach)
+ ATTACH="$2"
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ x-terminal-emulator -e ${MAILER} \
+ ${FROM:+-e} ${FROM:+"set from=\"${FROM}\""} \
+ ${CC:+-c} ${CC:+"${CC}"} \
+ ${BCC:+-b} ${BCC:+"${BCC}"} \
+ ${SUBJECT:+-s} ${SUBJECT:+"${SUBJECT}"} \
+ ${BODY:+-i} ${BODY:+"${BODY}"} \
+ ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"} \
+ ${TO:+"${TO}"} &
+ rm -f $BODY
+ ;;
+
+ evolution)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ if [ "${TO}" != "" ]; then
+ MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
+ else
+ TO="$2"
+ fi
+ shift
+ ;;
+ --cc)
+ MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --bcc)
+ MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --subject)
+ MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --body)
+ MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --attach)
+ MAILTO="${MAILTO:-}${MAILTO:+&}attach="`echo "file://$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ MAILTO="mailto:${TO}?${MAILTO}"
+ ${MAILER} "${MAILTO}" &
+ ;;
+
+ groupwise)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ if [ "${TO}" != "" ]; then
+ MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
+ else
+ TO="$2"
+ fi
+ shift
+ ;;
+ --cc)
+ MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --bcc)
+ MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --subject)
+ MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --body)
+ MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --attach)
+ MAILTO="${MAILTO:-}${MAILTO:+&}attachment="`echo "file://$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ MAILTO="mailto:${TO}?${MAILTO}"
+ ${MAILER} "${MAILTO}" &
+ ;;
+
+ dtmail)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ TO=${TO:-}${TO:+,}$2
+ shift
+ ;;
+ --attach)
+ ATTACH="$2"
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ ${MAILER} ${TO:+-T} ${TO:-} ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"}
+ ;;
+
+ sylpheed | claws)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ TO=${TO:-}${TO:+,}$2
+ shift
+ ;;
+ --attach)
+ ATTACH="${ATTACH:-}${ATTACH:+ }$2"
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ ${MAILER} ${TO:+--compose} "${TO:-}" ${ATTACH:+--attach} "${ATTACH:-}"
+ ;;
+
+ Mail | Thunderbird | *.app )
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --attach)
+ #i95688# fix filenames containing accented chars, whatever alien
+ ATTACH="${ATTACH:-}${ATTACH:+ }"`echo "file://$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+ /usr/bin/open -a "${MAILER}" ${ATTACH}
+ ;;
+
+ "")
+
+ # DESKTOP_LAUNCH, see http://freedesktop.org/pipermail/xdg/2004-August/004489.html
+ if [ -n "$DESKTOP_LAUNCH" ]; then
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ if [ "${TO}" != "" ]; then
+ MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
+ else
+ TO="$2"
+ fi
+ shift
+ ;;
+ --cc)
+ MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --bcc)
+ MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --subject)
+ MAILTO="${MAILTO:-}${MAILTO:+&}subject="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --body)
+ MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --attach)
+ MAILTO="${MAILTO:-}${MAILTO:+&}attachment="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ MAILTO="mailto:${TO}?${MAILTO}"
+ ${DESKTOP_LAUNCH} "${MAILTO}" &
+ else
+ echo "Could not determine a mail client to use."
+ exit 2
+ fi
+ ;;
+
+ *)
+ echo "Unsupported mail client: `basename $MAILER | sed 's/-.*^//'`"
+ exit 2
+ ;;
+esac
+
+exit 0
diff --git a/shell/source/unix/misc/uri-encode.c b/shell/source/unix/misc/uri-encode.c
new file mode 100644
index 000000000000..e93bd61e6675
--- /dev/null
+++ b/shell/source/unix/misc/uri-encode.c
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main() {
+ for (;;) {
+ int c;
+ errno = 0;
+ c = getchar();
+ if (c == EOF) {
+ exit(errno == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ } else if (isalnum(c) || strchr("!$'()*+,-.:=@_~/\n", c) != NULL) {
+ /* valid RFC 2396 pchar characters + '/' + newline */
+ if (putchar(c) == EOF) {
+ exit(EXIT_FAILURE);
+ }
+ } else if (printf("%%%02X", (unsigned char) (char) c) < 0) {
+ exit(EXIT_FAILURE);
+ }
+ }
+}
diff --git a/shell/source/unix/sysshell/makefile.mk b/shell/source/unix/sysshell/makefile.mk
new file mode 100644
index 000000000000..3d8a55d4377f
--- /dev/null
+++ b/shell/source/unix/sysshell/makefile.mk
@@ -0,0 +1,75 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=shell
+TARGET=sysshell
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(SYSTEM_EXPAT)" == "YES"
+CFLAGS+=-DSYSTEM_EXPAT
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+.IF "$(OS)" != "MACOSX"
+
+SLOFILES=$(SLO)$/recently_used_file.obj \
+ $(SLO)$/recently_used_file_handler.obj
+
+SHL1TARGET=recentfile
+.IF "$(GUI)" == "OS2"
+SHL1IMPLIB=i$(TARGET)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+DEF1NAME= $(SHL1TARGET)
+
+.ELSE
+#SHL1IMPLIB=
+.ENDIF
+
+SHL1STDLIBS=$(EXPATASCII3RDLIB)\
+ $(SALLIB)
+
+SHL1LIBS=$(SLB)$/xmlparser.lib
+SHL1OBJS=$(SLOFILES)
+SHL1VERSIONMAP=recfile.map
+
+.ELSE
+
+dummy:
+ @echo "Nothing to build for MACOSX"
+
+.ENDIF # MACOSX
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/shell/source/unix/sysshell/recently_used_file.cxx b/shell/source/unix/sysshell/recently_used_file.cxx
new file mode 100644
index 000000000000..cc4fbf75adcc
--- /dev/null
+++ b/shell/source/unix/sysshell/recently_used_file.cxx
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#ifndef INCLUDED_RECENTLY_USED_FILE
+#include "recently_used_file.hxx"
+#endif
+#include <rtl/ustring.hxx>
+#include <osl/process.h>
+#include <osl/security.hxx>
+#include <osl/thread.h>
+#include <osl/file.hxx>
+
+#include <sys/file.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <unistd.h>
+
+const rtl::OUString RECENTLY_USED_FILE_NAME = rtl::OUString::createFromAscii(".recently-used");
+const rtl::OUString SLASH = rtl::OUString::createFromAscii("/");
+
+namespace /* private */ {
+
+inline void ensure_final_slash(/*inout*/ rtl::OUString& path)
+{
+ if ((path.getLength() > 0) &&
+ (SLASH.pData->buffer[0] != path.pData->buffer[path.getLength() - 1]))
+ path += SLASH;
+}
+
+} // namespace private
+
+//------------------------------------------------
+recently_used_file::recently_used_file() :
+ file_(NULL)
+{
+ osl::Security sec;
+ rtl::OUString homedir_url;
+
+ if (sec.getHomeDir(homedir_url))
+ {
+ rtl::OUString homedir;
+ osl::FileBase::getSystemPathFromFileURL(homedir_url, homedir);
+
+ rtl::OUString rufn = homedir;
+ ensure_final_slash(rufn);
+ rufn += RECENTLY_USED_FILE_NAME;
+
+ rtl::OString tmp =
+ rtl::OUStringToOString(rufn, osl_getThreadTextEncoding());
+
+ file_ = fopen(tmp.getStr(), "r+");
+
+ /* create if not exist */
+ if (NULL == file_) {
+ mode_t umask_ = umask(S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+ file_ = fopen(tmp.getStr(), "w+");
+ umask(umask_);
+ }
+
+ if (NULL == file_)
+ throw "I/O error opening ~/.recently-used";
+
+ if (lockf(fileno(file_), F_LOCK, 0) != 0)
+ {
+ fclose(file_);
+ throw "Cannot lock ~/.recently-used";
+ }
+ }
+ else
+ throw "Cannot determine user home directory";
+}
+
+//------------------------------------------------
+recently_used_file::~recently_used_file()
+{
+ lockf(fileno(file_), F_ULOCK, 0);
+ fclose(file_);
+}
+
+//------------------------------------------------
+void recently_used_file::reset() const
+{
+ rewind(file_);
+}
+
+//------------------------------------------------
+void recently_used_file::truncate(off_t length)
+{
+ ftruncate(fileno(file_), length);
+}
+
+//------------------------------------------------
+size_t recently_used_file::read(char* buffer, size_t size) const
+{
+ size_t r = fread(reinterpret_cast<void*>(buffer), sizeof(char), size, file_);
+
+ if ((r < size) && ferror(file_))
+ throw "I/O error: read failed";
+
+ return r;
+}
+
+//----------------------------
+void recently_used_file::write(const char* buffer, size_t size) const
+{
+ if (size != fwrite(reinterpret_cast<const void*>(buffer), sizeof(char), size, file_))
+ throw "I/O error: write failed";
+}
+
+//----------------------------
+bool recently_used_file::eof() const
+{
+ return feof(file_);
+}
+
+
+
+
diff --git a/shell/source/unix/sysshell/recently_used_file.hxx b/shell/source/unix/sysshell/recently_used_file.hxx
new file mode 100644
index 000000000000..346541a7efda
--- /dev/null
+++ b/shell/source/unix/sysshell/recently_used_file.hxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_RECENTLY_USED_FILE_HXX
+#define INCLUDED_RECENTLY_USED_FILE_HXX
+
+#include <stdio.h>
+#include <unistd.h>
+
+//##################################
+// simple wrapper around the recently_used_file
+
+class recently_used_file
+{
+public:
+ //----------------------------
+ recently_used_file();
+
+ //----------------------------
+ ~recently_used_file();
+
+ //----------------------------
+ // set file pointer to the start of file
+ void reset() const;
+
+ //----------------------------
+ void truncate(off_t length = 0);
+
+ //----------------------------
+ size_t read(
+ char* buffer,
+ size_t size) const;
+
+ //----------------------------
+ void write(const char* buffer, size_t size) const;
+
+ //----------------------------
+ bool eof() const;
+
+private:
+ FILE* file_;
+};
+
+#endif // INCLUDED_RECENTLY_USED_FILE_HXX
diff --git a/shell/source/unix/sysshell/recently_used_file_handler.cxx b/shell/source/unix/sysshell/recently_used_file_handler.cxx
new file mode 100644
index 000000000000..b124d03b589c
--- /dev/null
+++ b/shell/source/unix/sysshell/recently_used_file_handler.cxx
@@ -0,0 +1,526 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#include "osl/process.h"
+#include "rtl/ustring.hxx"
+#include "rtl/string.hxx"
+#include "rtl/strbuf.hxx"
+
+#include "osl/thread.h"
+#include "recently_used_file.hxx"
+
+#include "internal/xml_parser.hxx"
+#include "internal/i_xml_parser_event_handler.hxx"
+
+#include <map>
+#include <vector>
+#include <algorithm>
+#include <functional>
+#include <string.h>
+
+namespace /* private */ {
+ //########################################
+ typedef std::vector<string_t> string_container_t;
+
+ #define TAG_RECENT_FILES "RecentFiles"
+ #define TAG_RECENT_ITEM "RecentItem"
+ #define TAG_URI "URI"
+ #define TAG_MIME_TYPE "Mime-Type"
+ #define TAG_TIMESTAMP "Timestamp"
+ #define TAG_PRIVATE "Private"
+ #define TAG_GROUPS "Groups"
+ #define TAG_GROUP "Group"
+
+ //------------------------------------------------
+ // compare two string_t's case insensitive, may also be done
+ // by specifying special traits for the string type but in this
+ // case it's easier to do it this way
+ struct str_icase_cmp :
+ public std::binary_function<string_t, string_t, bool>
+ {
+ bool operator() (const string_t& s1, const string_t& s2) const
+ { return (0 == strcasecmp(s1.c_str(), s2.c_str())); }
+ };
+
+ //------------------------------------------------
+ struct recently_used_item
+ {
+ recently_used_item() :
+ is_private_(false)
+ {}
+
+ recently_used_item(
+ const string_t& uri,
+ const string_t& mime_type,
+ const string_container_t& groups,
+ bool is_private = false) :
+ uri_(uri),
+ mime_type_(mime_type),
+ is_private_(is_private),
+ groups_(groups)
+ {
+ timestamp_ = time(NULL);
+ }
+
+ void set_uri(const string_t& character)
+ { uri_ = character; }
+
+ void set_mime_type(const string_t& character)
+ { mime_type_ = character; }
+
+ void set_timestamp(const string_t& character)
+ {
+ time_t t;
+ if (sscanf(character.c_str(), "%ld", &t) != 1)
+ timestamp_ = -1;
+ else
+ timestamp_ = t;
+ }
+
+ void set_is_private(const string_t& /*character*/)
+ { is_private_ = true; }
+
+ void set_groups(const string_t& character)
+ { groups_.push_back(character); }
+
+ void set_nothing(const string_t& /*character*/)
+ {}
+
+ bool has_groups() const
+ {
+ return !groups_.empty();
+ }
+
+ bool has_group(const string_t& name) const
+ {
+ string_container_t::const_iterator iter_end = groups_.end();
+ return (has_groups() &&
+ iter_end != std::find_if(
+ groups_.begin(), iter_end,
+ std::bind2nd(str_icase_cmp(), name)));
+ }
+
+ void write_xml(const recently_used_file& file) const
+ {
+ write_xml_start_tag(TAG_RECENT_ITEM, file, true);
+ write_xml_tag(TAG_URI, uri_, file);
+ write_xml_tag(TAG_MIME_TYPE, mime_type_, file);
+
+ rtl::OString ts = rtl::OString::valueOf((sal_sSize)timestamp_);
+ write_xml_tag(TAG_TIMESTAMP, ts.getStr(), file);
+
+ if (is_private_)
+ write_xml_tag(TAG_PRIVATE, file);
+
+ if (has_groups())
+ {
+ write_xml_start_tag(TAG_GROUPS, file, true);
+
+ string_container_t::const_iterator iter = groups_.begin();
+ string_container_t::const_iterator iter_end = groups_.end();
+
+ for ( ; iter != iter_end; ++iter)
+ write_xml_tag(TAG_GROUP, (*iter), file);
+
+ write_xml_end_tag(TAG_GROUPS, file);
+ }
+ write_xml_end_tag(TAG_RECENT_ITEM, file);
+ }
+
+ static rtl::OString escape_content(const string_t &text)
+ {
+ rtl::OStringBuffer aBuf;
+ for (sal_uInt32 i = 0; i < text.length(); i++)
+ {
+# define MAP(a,b) case a: aBuf.append(b); break
+ switch (text[i])
+ {
+ MAP ('&', "&amp;");
+ MAP ('<', "&lt;");
+ MAP ('>', "&gt;");
+ MAP ('\'', "&apos;");
+ MAP ('"', "&quot;");
+ default:
+ aBuf.append(text[i]);
+ break;
+ }
+# undef MAP
+ }
+ return aBuf.makeStringAndClear();
+ }
+
+ void write_xml_tag(const string_t& name, const string_t& value, const recently_used_file& file) const
+ {
+ write_xml_start_tag(name, file);
+ rtl::OString escaped = escape_content (value);
+ file.write(escaped.getStr(), escaped.getLength());
+ write_xml_end_tag(name, file);
+ }
+
+ void write_xml_tag(const string_t& name, const recently_used_file& file) const
+ {
+ file.write("<", 1);
+ file.write(name.c_str(), name.length());
+ file.write("/>\n", 3);
+ }
+
+ void write_xml_start_tag(const string_t& name, const recently_used_file& file, bool linefeed = false) const
+ {
+ file.write("<", 1);
+ file.write(name.c_str(), name.length());
+ if (linefeed)
+ file.write(">\n", 2);
+ else
+ file.write(">", 1);
+ }
+
+ void write_xml_end_tag(const string_t& name, const recently_used_file& file) const
+ {
+ file.write("</", 2);
+ file.write(name.c_str(), name.length());
+ file.write(">\n", 2);
+ }
+
+ string_t uri_;
+ string_t mime_type_;
+ time_t timestamp_;
+ bool is_private_;
+ string_container_t groups_;
+ };
+
+ typedef std::vector<recently_used_item*> recently_used_item_list_t;
+ typedef void (recently_used_item::* SET_COMMAND)(const string_t&);
+
+ //########################################
+ // thrown if we encounter xml tags that we do not know
+ class unknown_xml_format_exception {};
+
+ //########################################
+ class recently_used_file_filter : public i_xml_parser_event_handler
+ {
+ public:
+ recently_used_file_filter(recently_used_item_list_t& item_list) :
+ item_(NULL),
+ item_list_(item_list)
+ {
+ named_command_map_[TAG_RECENT_FILES] = &recently_used_item::set_nothing;
+ named_command_map_[TAG_RECENT_ITEM] = &recently_used_item::set_nothing;
+ named_command_map_[TAG_URI] = &recently_used_item::set_uri;
+ named_command_map_[TAG_MIME_TYPE] = &recently_used_item::set_mime_type;
+ named_command_map_[TAG_TIMESTAMP] = &recently_used_item::set_timestamp;
+ named_command_map_[TAG_PRIVATE] = &recently_used_item::set_is_private;
+ named_command_map_[TAG_GROUPS] = &recently_used_item::set_nothing;
+ named_command_map_[TAG_GROUP] = &recently_used_item::set_groups;
+ }
+
+ virtual void start_element(
+ const string_t& /*raw_name*/,
+ const string_t& local_name,
+ const xml_tag_attribute_container_t& /*attributes*/)
+ {
+ if ((local_name == TAG_RECENT_ITEM) && (NULL == item_))
+ item_ = new recently_used_item;
+ }
+
+ virtual void end_element(const string_t& /*raw_name*/, const string_t& local_name)
+ {
+ // check for end tags w/o start tag
+ if( local_name != TAG_RECENT_FILES && NULL == item_ )
+ return; // will result in an XML parser error anyway
+
+ if (named_command_map_.find(local_name) != named_command_map_.end())
+ (item_->*named_command_map_[local_name])(current_element_);
+ else
+ {
+ delete item_;
+ throw unknown_xml_format_exception();
+ }
+
+ if (local_name == TAG_RECENT_ITEM)
+ {
+ item_list_.push_back(item_);
+ item_ = NULL;
+ }
+ current_element_.clear();
+ }
+
+ virtual void characters(const string_t& character)
+ {
+ if (character != "\n")
+ current_element_ += character;
+ }
+
+ virtual void start_document() {}
+ virtual void end_document() {}
+
+ virtual void ignore_whitespace(const string_t& /*whitespaces*/)
+ {}
+
+ virtual void processing_instruction(
+ const string_t& /*target*/, const string_t& /*data*/)
+ {}
+
+ virtual void comment(const string_t& /*comment*/)
+ {}
+ private:
+ recently_used_item* item_;
+ std::map<string_t, SET_COMMAND> named_command_map_;
+ string_t current_element_;
+ recently_used_item_list_t& item_list_;
+ private:
+ recently_used_file_filter(const recently_used_file_filter&);
+ recently_used_file_filter& operator=(const recently_used_file_filter&);
+ };
+
+ //------------------------------------------------
+ void read_recently_used_items(
+ recently_used_file& file,
+ recently_used_item_list_t& item_list)
+ {
+ xml_parser xparser;
+ recently_used_file_filter ruff(item_list);
+
+ xparser.set_document_handler(&ruff);
+
+ char buff[16384];
+ while (!file.eof())
+ {
+ if (size_t length = file.read(buff, sizeof(buff)))
+ xparser.parse(buff, length, file.eof());
+ }
+ }
+
+ //------------------------------------------------
+ // The file ~/.recently_used shall not contain more than 500
+ // entries (see www.freedesktop.org)
+ const int MAX_RECENTLY_USED_ITEMS = 500;
+
+ class recent_item_writer
+ {
+ public:
+ recent_item_writer(
+ recently_used_file& file,
+ int max_items_to_write = MAX_RECENTLY_USED_ITEMS) :
+ file_(file),
+ max_items_to_write_(max_items_to_write),
+ items_written_(0)
+ {}
+
+ void operator() (const recently_used_item* item)
+ {
+ if (items_written_++ < max_items_to_write_)
+ item->write_xml(file_);
+ }
+ private:
+ recently_used_file& file_;
+ int max_items_to_write_;
+ int items_written_;
+ };
+
+ //------------------------------------------------
+ const char* XML_HEADER = "<?xml version=\"1.0\"?>\n<RecentFiles>\n";
+ const char* XML_FOOTER = "</RecentFiles>";
+
+ //------------------------------------------------
+ // assumes that the list is ordered decreasing
+ void write_recently_used_items(
+ recently_used_file& file,
+ recently_used_item_list_t& item_list)
+ {
+ if (!item_list.empty())
+ {
+ file.truncate();
+ file.reset();
+
+ file.write(XML_HEADER, strlen(XML_HEADER));
+
+ std::for_each(
+ item_list.begin(),
+ item_list.end(),
+ recent_item_writer(file));
+
+ file.write(XML_FOOTER, strlen(XML_FOOTER));
+ }
+ }
+
+ //------------------------------------------------
+ struct delete_recently_used_item
+ {
+ void operator() (const recently_used_item* item) const
+ { delete item; }
+ };
+
+ //------------------------------------------------
+ void recently_used_item_list_clear(recently_used_item_list_t& item_list)
+ {
+ std::for_each(
+ item_list.begin(),
+ item_list.end(),
+ delete_recently_used_item());
+ item_list.clear();
+ }
+
+ //------------------------------------------------
+ class find_item_predicate
+ {
+ public:
+ find_item_predicate(const string_t& uri) :
+ uri_(uri)
+ {}
+
+ bool operator() (const recently_used_item* item)
+ { return (item->uri_ == uri_); }
+ private:
+ string_t uri_;
+ };
+
+ //------------------------------------------------
+ struct greater_recently_used_item
+ {
+ bool operator ()(const recently_used_item* lhs, const recently_used_item* rhs) const
+ { return (lhs->timestamp_ > rhs->timestamp_); }
+ };
+
+ //------------------------------------------------
+ const char* GROUP_OOO = "openoffice.org";
+ const char* GROUP_STAR_OFFICE = "staroffice";
+ const char* GROUP_STAR_SUITE = "starsuite";
+
+ //------------------------------------------------
+ void recently_used_item_list_add(
+ recently_used_item_list_t& item_list, const rtl::OUString& file_url, const rtl::OUString& mime_type)
+ {
+ rtl::OString f = rtl::OUStringToOString(file_url, RTL_TEXTENCODING_UTF8);
+
+ recently_used_item_list_t::iterator iter =
+ std::find_if(
+ item_list.begin(),
+ item_list.end(),
+ find_item_predicate(f.getStr()));
+
+ if (iter != item_list.end())
+ {
+ (*iter)->timestamp_ = time(NULL);
+
+ if (!(*iter)->has_group(GROUP_OOO))
+ (*iter)->groups_.push_back(GROUP_OOO);
+ if (!(*iter)->has_group(GROUP_STAR_OFFICE))
+ (*iter)->groups_.push_back(GROUP_STAR_OFFICE);
+ if (!(*iter)->has_group(GROUP_STAR_SUITE))
+ (*iter)->groups_.push_back(GROUP_STAR_SUITE);
+ }
+ else
+ {
+ string_container_t groups;
+ groups.push_back(GROUP_OOO);
+ groups.push_back(GROUP_STAR_OFFICE);
+ groups.push_back(GROUP_STAR_SUITE);
+
+ string_t uri(f.getStr());
+ string_t mimetype(rtl::OUStringToOString(mime_type, osl_getThreadTextEncoding()).getStr());
+
+ if (mimetype.length() == 0)
+ mimetype = "application/octet-stream";
+
+ item_list.push_back(new recently_used_item(uri, mimetype, groups));
+ }
+
+ // sort decreasing after the timestamp
+ // so that the newest items appear first
+ std::sort(
+ item_list.begin(),
+ item_list.end(),
+ greater_recently_used_item());
+ }
+
+ //------------------------------------------------
+ struct cleanup_guard
+ {
+ cleanup_guard(recently_used_item_list_t& item_list) :
+ item_list_(item_list)
+ {}
+ ~cleanup_guard()
+ { recently_used_item_list_clear(item_list_); }
+
+ recently_used_item_list_t& item_list_;
+ };
+
+} // namespace private
+
+//###########################################
+/*
+ example (see http::www.freedesktop.org):
+ <?xml version="1.0"?>
+ <RecentFiles>
+ <RecentItem>
+ <URI>file:///home/federico/gedit.txt</URI>
+ <Mime-Type>text/plain</Mime-Type>
+ <Timestamp>1046485966</Timestamp>
+ <Groups>
+ <Group>gedit</Group>
+ </Groups>
+ </RecentItem>
+ <RecentItem>
+ <URI>file:///home/federico/gedit-2.2.0.tar.bz2</URI>
+ <Mime-Type>application/x-bzip</Mime-Type>
+ <Timestamp>1046209851</Timestamp>
+ <Private/>
+ <Groups>
+ </Groups>
+ </RecentItem>
+ </RecentFiles>
+*/
+
+extern "C" void add_to_recently_used_file_list(const rtl::OUString& file_url, const rtl::OUString& mime_type)
+{
+ try
+ {
+ recently_used_file ruf;
+ recently_used_item_list_t item_list;
+ cleanup_guard guard(item_list);
+
+ read_recently_used_items(ruf, item_list);
+ recently_used_item_list_add(item_list, file_url, mime_type);
+ write_recently_used_items(ruf, item_list);
+ }
+ catch(const char* ex)
+ {
+ OSL_ENSURE(false, ex);
+ }
+ catch(const xml_parser_exception&)
+ {
+ OSL_ENSURE(false, "XML parser error");
+ }
+ catch(const unknown_xml_format_exception&)
+ {
+ OSL_ENSURE(false, "XML format unknown");
+ }
+}
+
diff --git a/shell/source/unix/sysshell/recfile.map b/shell/source/unix/sysshell/recfile.map
new file mode 100755
index 000000000000..fa87f39161aa
--- /dev/null
+++ b/shell/source/unix/sysshell/recfile.map
@@ -0,0 +1,6 @@
+RECFILE_1_0_0 {
+ global:
+ add_to_recently_used_file_list;
+ local:
+ *;
+};
diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx
new file mode 100644
index 000000000000..7264afaac109
--- /dev/null
+++ b/shell/source/win32/SysShExec.cxx
@@ -0,0 +1,388 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+#include <osl/diagnose.h>
+#include "SysShExec.hxx"
+#include <osl/file.hxx>
+
+#ifndef _COM_SUN_STAR_SYS_SHELL_SYSTEMSHELLEXECUTEFLAGS_HPP_
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+#endif
+
+#define WIN32_LEAN_AND_MEAN
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#include <shellapi.h>
+#include <objbase.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+//------------------------------------------------------------------------
+// namespace directives
+//------------------------------------------------------------------------
+
+using com::sun::star::uno::Reference;
+using com::sun::star::uno::RuntimeException;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::XInterface;
+using com::sun::star::lang::EventObject;
+using com::sun::star::lang::XServiceInfo;
+using com::sun::star::lang::IllegalArgumentException;
+using rtl::OUString;
+using osl::Mutex;
+using com::sun::star::system::XSystemShellExecute;
+using com::sun::star::system::SystemShellExecuteException;
+
+using namespace ::com::sun::star::system::SystemShellExecuteFlags;
+using namespace cppu;
+
+//------------------------------------------------------------------------
+// defines
+//------------------------------------------------------------------------
+
+#define SYSSHEXEC_IMPL_NAME "com.sun.star.sys.shell.SystemShellExecute"
+
+//------------------------------------------------------------------------
+// helper functions
+//------------------------------------------------------------------------
+
+namespace // private
+{
+ Sequence< OUString > SAL_CALL SysShExec_getSupportedServiceNames()
+ {
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii("com.sun.star.sys.shell.SystemShellExecute");
+ return aRet;
+ }
+
+ /* This is the error table that defines the mapping between OS error
+ codes and errno values */
+
+ struct errentry {
+ unsigned long oscode; /* OS return value */
+ int errnocode; /* System V error code */
+ };
+
+ struct errentry errtable[] = {
+ { ERROR_SUCCESS, osl_File_E_None }, /* 0 */
+ { ERROR_INVALID_FUNCTION, osl_File_E_INVAL }, /* 1 */
+ { ERROR_FILE_NOT_FOUND, osl_File_E_NOENT }, /* 2 */
+ { ERROR_PATH_NOT_FOUND, osl_File_E_NOENT }, /* 3 */
+ { ERROR_TOO_MANY_OPEN_FILES, osl_File_E_MFILE }, /* 4 */
+ { ERROR_ACCESS_DENIED, osl_File_E_ACCES }, /* 5 */
+ { ERROR_INVALID_HANDLE, osl_File_E_BADF }, /* 6 */
+ { ERROR_ARENA_TRASHED, osl_File_E_NOMEM }, /* 7 */
+ { ERROR_NOT_ENOUGH_MEMORY, osl_File_E_NOMEM }, /* 8 */
+ { ERROR_INVALID_BLOCK, osl_File_E_NOMEM }, /* 9 */
+ { ERROR_BAD_ENVIRONMENT, osl_File_E_2BIG }, /* 10 */
+ { ERROR_BAD_FORMAT, osl_File_E_NOEXEC }, /* 11 */
+ { ERROR_INVALID_ACCESS, osl_File_E_INVAL }, /* 12 */
+ { ERROR_INVALID_DATA, osl_File_E_INVAL }, /* 13 */
+ { ERROR_INVALID_DRIVE, osl_File_E_NOENT }, /* 15 */
+ { ERROR_CURRENT_DIRECTORY, osl_File_E_ACCES }, /* 16 */
+ { ERROR_NOT_SAME_DEVICE, osl_File_E_XDEV }, /* 17 */
+ { ERROR_NO_MORE_FILES, osl_File_E_NOENT }, /* 18 */
+ { ERROR_LOCK_VIOLATION, osl_File_E_ACCES }, /* 33 */
+ { ERROR_BAD_NETPATH, osl_File_E_NOENT }, /* 53 */
+ { ERROR_NETWORK_ACCESS_DENIED, osl_File_E_ACCES }, /* 65 */
+ { ERROR_BAD_NET_NAME, osl_File_E_NOENT }, /* 67 */
+ { ERROR_FILE_EXISTS, osl_File_E_EXIST }, /* 80 */
+ { ERROR_CANNOT_MAKE, osl_File_E_ACCES }, /* 82 */
+ { ERROR_FAIL_I24, osl_File_E_ACCES }, /* 83 */
+ { ERROR_INVALID_PARAMETER, osl_File_E_INVAL }, /* 87 */
+ { ERROR_NO_PROC_SLOTS, osl_File_E_AGAIN }, /* 89 */
+ { ERROR_DRIVE_LOCKED, osl_File_E_ACCES }, /* 108 */
+ { ERROR_BROKEN_PIPE, osl_File_E_PIPE }, /* 109 */
+ { ERROR_DISK_FULL, osl_File_E_NOSPC }, /* 112 */
+ { ERROR_INVALID_TARGET_HANDLE, osl_File_E_BADF }, /* 114 */
+ { ERROR_INVALID_HANDLE, osl_File_E_INVAL }, /* 124 */
+ { ERROR_WAIT_NO_CHILDREN, osl_File_E_CHILD }, /* 128 */
+ { ERROR_CHILD_NOT_COMPLETE, osl_File_E_CHILD }, /* 129 */
+ { ERROR_DIRECT_ACCESS_HANDLE, osl_File_E_BADF }, /* 130 */
+ { ERROR_NEGATIVE_SEEK, osl_File_E_INVAL }, /* 131 */
+ { ERROR_SEEK_ON_DEVICE, osl_File_E_ACCES }, /* 132 */
+ { ERROR_DIR_NOT_EMPTY, osl_File_E_NOTEMPTY }, /* 145 */
+ { ERROR_NOT_LOCKED, osl_File_E_ACCES }, /* 158 */
+ { ERROR_BAD_PATHNAME, osl_File_E_NOENT }, /* 161 */
+ { ERROR_MAX_THRDS_REACHED, osl_File_E_AGAIN }, /* 164 */
+ { ERROR_LOCK_FAILED, osl_File_E_ACCES }, /* 167 */
+ { ERROR_ALREADY_EXISTS, osl_File_E_EXIST }, /* 183 */
+ { ERROR_FILENAME_EXCED_RANGE, osl_File_E_NOENT }, /* 206 */
+ { ERROR_NESTING_NOT_ALLOWED, osl_File_E_AGAIN }, /* 215 */
+ { ERROR_NOT_ENOUGH_QUOTA, osl_File_E_NOMEM } /* 1816 */
+ };
+
+ /* size of the table */
+ #define ERRTABLESIZE (sizeof(errtable)/sizeof(errtable[0]))
+
+ /* The following two constants must be the minimum and maximum
+ values in the (contiguous) range of osl_File_E_xec Failure errors. */
+ #define MIN_EXEC_ERROR ERROR_INVALID_STARTING_CODESEG
+ #define MAX_EXEC_ERROR ERROR_INFLOOP_IN_RELOC_CHAIN
+
+ /* These are the low and high value in the range of errors that are
+ access violations */
+ #define MIN_EACCES_RANGE ERROR_WRITE_PROTECT
+ #define MAX_EACCES_RANGE ERROR_SHARING_BUFFER_EXCEEDED
+
+
+ /*******************************************************************************/
+
+ oslFileError _mapError( DWORD dwError )
+ {
+ int i;
+
+ /* check the table for the OS error code */
+ for ( i = 0; i < ERRTABLESIZE; ++i )
+ {
+ if ( dwError == errtable[i].oscode )
+ return (oslFileError)errtable[i].errnocode;
+ }
+
+ /* The error code wasn't in the table. We check for a range of */
+ /* osl_File_E_ACCES errors or exec failure errors (ENOEXEC). Otherwise */
+ /* osl_File_E_INVAL is returned. */
+
+ if ( dwError >= MIN_EACCES_RANGE && dwError <= MAX_EACCES_RANGE)
+ return osl_File_E_ACCES;
+ else if ( dwError >= MIN_EXEC_ERROR && dwError <= MAX_EXEC_ERROR)
+ return osl_File_E_NOEXEC;
+ else
+ return osl_File_E_INVAL;
+ }
+
+ #define MapError( oserror ) _mapError( oserror )
+
+ #define E_UNKNOWN_EXEC_ERROR -1
+
+ //-----------------------------------------
+ //-----------------------------------------
+
+ bool is_system_path(const OUString& path_or_uri)
+ {
+ OUString url;
+ osl::FileBase::RC rc = osl::FileBase::getFileURLFromSystemPath(path_or_uri, url);
+ return (rc == osl::FileBase::E_None);
+ }
+
+ //-----------------------------------------
+ // trying to identify a jump mark
+ //-----------------------------------------
+
+ const OUString JUMP_MARK_HTM = OUString::createFromAscii(".htm#");
+ const OUString JUMP_MARK_HTML = OUString::createFromAscii(".html#");
+ const sal_Unicode HASH_MARK = (sal_Unicode)'#';
+
+ bool has_jump_mark(const OUString& system_path, sal_Int32* jmp_mark_start = NULL)
+ {
+ sal_Int32 jmp_mark = std::max<int>(
+ system_path.lastIndexOf(JUMP_MARK_HTM),
+ system_path.lastIndexOf(JUMP_MARK_HTML));
+
+ if (jmp_mark_start)
+ *jmp_mark_start = jmp_mark;
+
+ return (jmp_mark > -1);
+ }
+
+ //-----------------------------------------
+ //-----------------------------------------
+
+ bool is_existing_file(const OUString& file_name)
+ {
+ OSL_ASSERT(is_system_path(file_name));
+
+ bool exist = false;
+
+ OUString file_url;
+ osl::FileBase::RC rc = osl::FileBase::getFileURLFromSystemPath(file_name, file_url);
+
+ if (osl::FileBase::E_None == rc)
+ {
+ osl::DirectoryItem dir_item;
+ rc = osl::DirectoryItem::get(file_url, dir_item);
+ exist = (osl::FileBase::E_None == rc);
+ }
+ return exist;
+ }
+
+ //-------------------------------------------------
+ // Jump marks in file urls are illegal.
+ //-------------------------------------------------
+
+ void remove_jump_mark(OUString* p_command)
+ {
+ OSL_PRECOND(p_command, "invalid parameter");
+
+ sal_Int32 pos;
+ if (has_jump_mark(*p_command, &pos))
+ {
+ const sal_Unicode* p_jmp_mark = p_command->getStr() + pos;
+ while (*p_jmp_mark && (*p_jmp_mark != HASH_MARK))
+ p_jmp_mark++;
+
+ *p_command = OUString(p_command->getStr(), p_jmp_mark - p_command->getStr());
+ }
+ }
+
+} // end namespace
+
+//-----------------------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------------------
+
+CSysShExec::CSysShExec( ) :
+ WeakComponentImplHelper2< XSystemShellExecute, XServiceInfo >( m_aMutex )
+{
+ /*
+ * As this service is declared thread-affine, it is ensured to be called from a
+ * dedicated thread, so initialize COM here.
+ *
+ * We need COM to be initialized for STA, but osl thread get initialized for MTA.
+ * Once this changed, we can remove the uninitialize call.
+ */
+ CoUninitialize();
+ CoInitialize( NULL );
+}
+
+//-------------------------------------------------
+//
+//-------------------------------------------------
+
+void SAL_CALL CSysShExec::execute( const OUString& aCommand, const OUString& aParameter, sal_Int32 nFlags )
+ throw (IllegalArgumentException, SystemShellExecuteException, RuntimeException)
+{
+ // parameter checking
+ if (0 == aCommand.getLength())
+ throw IllegalArgumentException(
+ OUString::createFromAscii( "Empty command" ),
+ static_cast< XSystemShellExecute* >( this ),
+ 1 );
+
+ if (!(nFlags >= DEFAULTS && nFlags <= NO_SYSTEM_ERROR_MESSAGE))
+ throw IllegalArgumentException(
+ OUString::createFromAscii( "Invalid Flags specified" ),
+ static_cast< XSystemShellExecute* >( this ),
+ 3 );
+
+ /* #i4789#; jump mark detection on system paths
+ if the given command is a system path (not http or
+ other uri schemes) and seems to have a jump mark
+ and names no existing file (remeber the jump mark
+ sign '#' is a valid file name character we remove
+ the jump mark, else ShellExecuteEx fails */
+ OUString preprocessed_command(aCommand);
+ if (is_system_path(preprocessed_command))
+ {
+ if (has_jump_mark(preprocessed_command) && !is_existing_file(preprocessed_command))
+ remove_jump_mark(&preprocessed_command);
+ }
+ /* Convert file uris to system paths */
+ else
+ {
+ OUString aSystemPath;
+ if (::osl::FileBase::E_None == ::osl::FileBase::getSystemPathFromFileURL(preprocessed_command, aSystemPath))
+ preprocessed_command = aSystemPath;
+ }
+
+ SHELLEXECUTEINFOW sei;
+ ZeroMemory(&sei, sizeof( sei));
+
+ sei.cbSize = sizeof(sei);
+ sei.lpFile = reinterpret_cast<LPCWSTR>(preprocessed_command.getStr());
+ sei.lpParameters = reinterpret_cast<LPCWSTR>(aParameter.getStr());
+ sei.nShow = SW_SHOWNORMAL;
+
+ if (NO_SYSTEM_ERROR_MESSAGE & nFlags)
+ sei.fMask = SEE_MASK_FLAG_NO_UI;
+
+ SetLastError( 0 );
+
+ sal_Bool bRet = ShellExecuteExW(&sei) ? sal_True : sal_False;
+
+ if (!bRet && (nFlags & NO_SYSTEM_ERROR_MESSAGE))
+ {
+ // ShellExecuteEx fails to set an error code
+ // we return osl_File_E_INVAL
+ sal_Int32 psxErr = GetLastError();
+ if (ERROR_SUCCESS == psxErr)
+ psxErr = E_UNKNOWN_EXEC_ERROR;
+ else
+ psxErr = MapError(psxErr);
+
+ throw SystemShellExecuteException(
+ OUString::createFromAscii("Error executing command"),
+ static_cast< XSystemShellExecute* >(this),
+ psxErr);
+ }
+}
+
+// -------------------------------------------------
+// XServiceInfo
+// -------------------------------------------------
+
+OUString SAL_CALL CSysShExec::getImplementationName( )
+ throw( RuntimeException )
+{
+ return OUString::createFromAscii( SYSSHEXEC_IMPL_NAME );
+}
+
+// -------------------------------------------------
+// XServiceInfo
+// -------------------------------------------------
+
+sal_Bool SAL_CALL CSysShExec::supportsService( const OUString& ServiceName )
+ throw( RuntimeException )
+{
+ Sequence < OUString > SupportedServicesNames = SysShExec_getSupportedServiceNames();
+
+ for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
+ if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+ return sal_True;
+
+ return sal_False;
+}
+
+// -------------------------------------------------
+// XServiceInfo
+// -------------------------------------------------
+
+Sequence< OUString > SAL_CALL CSysShExec::getSupportedServiceNames( )
+ throw( RuntimeException )
+{
+ return SysShExec_getSupportedServiceNames();
+}
+
diff --git a/shell/source/win32/SysShExec.hxx b/shell/source/win32/SysShExec.hxx
new file mode 100644
index 000000000000..b4d5f18b7899
--- /dev/null
+++ b/shell/source/win32/SysShExec.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SYSSHEXEC_HXX_
+#define _SYSSHEXEC_HXX_
+
+//_______________________________________________________________________________________________________________________
+// includes of other projects
+//_______________________________________________________________________________________________________________________
+
+#include <cppuhelper/compbase2.hxx>
+#include <osl/mutex.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
+#include <com/sun/star/system/XSystemShellExecute.hpp>
+#endif
+
+//----------------------------------------------------------
+// class declaration
+//----------------------------------------------------------
+
+class CSysShExecBase
+{
+protected:
+ osl::Mutex m_aMutex;
+};
+
+class CSysShExec :
+ public CSysShExecBase,
+ public cppu::WeakComponentImplHelper2<
+ com::sun::star::system::XSystemShellExecute,
+ com::sun::star::lang::XServiceInfo >
+{
+public:
+ CSysShExec( );
+
+ //------------------------------------------------
+ // XSystemShellExecute
+ //------------------------------------------------
+
+ virtual void SAL_CALL execute( const ::rtl::OUString& aCommand, const ::rtl::OUString& aParameter, sal_Int32 nFlags )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::system::SystemShellExecuteException, ::com::sun::star::uno::RuntimeException);
+
+ //------------------------------------------------
+ // XServiceInfo
+ //------------------------------------------------
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw(::com::sun::star::uno::RuntimeException);
+};
+
+#endif
diff --git a/shell/source/win32/SysShentry.cxx b/shell/source/win32/SysShentry.cxx
new file mode 100644
index 000000000000..a542d046fc59
--- /dev/null
+++ b/shell/source/win32/SysShentry.cxx
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+//-----------------------------------------------------------------------
+// includes of other projects
+//-----------------------------------------------------------------------
+#include <cppuhelper/factory.hxx>
+#include <com/sun/star/container/XSet.hpp>
+#include <osl/diagnose.h>
+#include "SysShExec.hxx"
+
+//-----------------------------------------------------------------------
+// namespace directives
+//-----------------------------------------------------------------------
+
+using namespace ::rtl ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::container ;
+using namespace ::com::sun::star::lang ;
+using namespace ::com::sun::star::registry ;
+using namespace ::cppu ;
+using com::sun::star::system::XSystemShellExecute;
+
+//-----------------------------------------------------------------------
+// defines
+//-----------------------------------------------------------------------
+
+#define SYSSHEXEC_SERVICE_NAME "com.sun.star.system.SystemShellExecute"
+#define SYSSHEXEC_IMPL_NAME "com.sun.star.system.SystemShellExecute"
+#define SYSSHEXEC_REGKEY_NAME "/com.sun.star.system.SystemShellExecute/UNO/SERVICES/com.sun.star.system.SystemShellExecute"
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+
+namespace
+{
+ Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& )
+ {
+ return Reference< XInterface >( static_cast< XSystemShellExecute* >( new CSysShExec( ) ) );
+ }
+}
+
+//-----------------------------------------------------------------------
+// the 3 important functions which will be exported
+//-----------------------------------------------------------------------
+
+extern "C"
+{
+
+//----------------------------------------------------------------------
+// component_getImplementationEnvironment
+//----------------------------------------------------------------------
+
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ":affine";
+}
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+
+sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
+{
+ sal_Bool bRetVal = sal_True;
+
+ if ( pRegistryKey )
+ {
+ try
+ {
+ Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
+ pXNewKey->createKey(
+ OUString::createFromAscii( SYSSHEXEC_REGKEY_NAME ) );
+ }
+ catch( InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "InvalidRegistryException caught");
+ bRetVal = sal_False;
+ }
+ }
+
+ return bRetVal;
+}
+
+//----------------------------------------------------------------------
+// component_getFactory
+// returns a factory to create XFilePicker-Services
+//----------------------------------------------------------------------
+
+void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
+{
+ void* pRet = 0;
+
+ if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, SYSSHEXEC_IMPL_NAME ) ) )
+ {
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray( )[0] = OUString::createFromAscii( SYSSHEXEC_SERVICE_NAME );
+
+ Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
+ OUString::createFromAscii( pImplName ),
+ createInstance,
+ aSNS ) );
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+
+} // extern "C"
diff --git a/shell/source/win32/exports.dxp b/shell/source/win32/exports.dxp
new file mode 100644
index 000000000000..028ac4175990
--- /dev/null
+++ b/shell/source/win32/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/shell/source/win32/makefile.mk b/shell/source/win32/makefile.mk
new file mode 100644
index 000000000000..9a9564ed76ca
--- /dev/null
+++ b/shell/source/win32/makefile.mk
@@ -0,0 +1,69 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=shell
+TARGET=syssh
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=$(SLO)$/SysShentry.obj\
+ $(SLO)$/SysShExec.obj
+
+SHL1TARGET=$(TARGET).uno
+
+SHL1STDLIBS=$(CPPULIB)\
+ $(CPPUHELPERLIB)\
+ $(SALLIB)\
+ $(UWINAPILIB) \
+ $(ADVAPI32LIB) \
+ $(OLE32LIB) \
+ $(SHELL32LIB)
+
+SHL1DEPN=
+SHL1IMPLIB=i$(SHL1TARGET)
+
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+
diff --git a/shell/source/win32/shlxthandler/classfactory.cxx b/shell/source/win32/shlxthandler/classfactory.cxx
new file mode 100755
index 000000000000..e19dd68383b4
--- /dev/null
+++ b/shell/source/win32/shlxthandler/classfactory.cxx
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/global.hxx"
+#include "classfactory.hxx"
+#include "internal/infotips.hxx"
+#include "internal/propsheets.hxx"
+#include "internal/columninfo.hxx"
+#ifdef __MINGW32__
+#include <algorithm>
+using ::std::max;
+using ::std::min;
+#endif
+#include "internal/thumbviewer.hxx"
+#include "internal/shlxthdl.hxx"
+
+//-----------------------------
+//
+//-----------------------------
+
+long CClassFactory::s_ServerLocks = 0;
+
+//-----------------------------
+//
+//-----------------------------
+
+CClassFactory::CClassFactory(const CLSID& clsid) :
+ m_RefCnt(1),
+ m_Clsid(clsid)
+{
+ InterlockedIncrement(&g_DllRefCnt);
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+CClassFactory::~CClassFactory()
+{
+ InterlockedDecrement(&g_DllRefCnt);
+}
+
+//-----------------------------
+// IUnknown methods
+//-----------------------------
+
+HRESULT STDMETHODCALLTYPE CClassFactory::QueryInterface(REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ *ppvObject = 0;
+
+ if (IID_IUnknown == riid || IID_IClassFactory == riid)
+ {
+ IUnknown* pUnk = this;
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+
+ return E_NOINTERFACE;
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+ULONG STDMETHODCALLTYPE CClassFactory::AddRef(void)
+{
+ return InterlockedIncrement(&m_RefCnt);
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+ULONG STDMETHODCALLTYPE CClassFactory::Release(void)
+{
+ long refcnt = InterlockedDecrement(&m_RefCnt);
+
+ if (0 == refcnt)
+ delete this;
+
+ return refcnt;
+}
+
+//-----------------------------
+// IClassFactory methods
+//-----------------------------
+
+HRESULT STDMETHODCALLTYPE CClassFactory::CreateInstance(
+ IUnknown __RPC_FAR *pUnkOuter,
+ REFIID riid,
+ void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ if ((pUnkOuter != NULL))
+ return CLASS_E_NOAGGREGATION;
+
+ IUnknown* pUnk = 0;
+
+ if (CLSID_PROPERTYSHEET_HANDLER == m_Clsid)
+ pUnk = static_cast<IShellExtInit*>(new CPropertySheet());
+
+ else if (CLSID_INFOTIP_HANDLER == m_Clsid)
+ pUnk = static_cast<IQueryInfo*>(new CInfoTip());
+
+ else if (CLSID_COLUMN_HANDLER == m_Clsid)
+ pUnk = static_cast<IColumnProvider*>(new CColumnInfo());
+
+ else if (CLSID_THUMBVIEWER_HANDLER == m_Clsid)
+ pUnk = static_cast<IExtractImage*>(new CThumbviewer());
+
+ POST_CONDITION(pUnk != 0, "Could not create COM object");
+
+ if (0 == pUnk)
+ return E_OUTOFMEMORY;
+
+ HRESULT hr = pUnk->QueryInterface(riid, ppvObject);
+
+ // if QueryInterface failed the component will destroy itself
+ pUnk->Release();
+
+ return hr;
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+HRESULT STDMETHODCALLTYPE CClassFactory::LockServer(BOOL fLock)
+{
+ if (fLock)
+ InterlockedIncrement(&s_ServerLocks);
+ else
+ InterlockedDecrement(&s_ServerLocks);
+
+ return S_OK;
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+bool CClassFactory::IsLocked()
+{
+ return (s_ServerLocks > 0);
+}
diff --git a/shell/source/win32/shlxthandler/classfactory.hxx b/shell/source/win32/shlxthandler/classfactory.hxx
new file mode 100644
index 000000000000..f0a8b84ae6ee
--- /dev/null
+++ b/shell/source/win32/shlxthandler/classfactory.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CLASSFACTORY_HXX_INCLUDED
+#define CLASSFACTORY_HXX_INCLUDED
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <objidl.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+class CClassFactory : public IClassFactory
+{
+public:
+ CClassFactory(const CLSID& clsid);
+ virtual ~CClassFactory();
+
+ //-----------------------------
+ // IUnknown methods
+ //-----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(
+ REFIID riid,
+ void __RPC_FAR *__RPC_FAR *ppvObject);
+
+ virtual ULONG STDMETHODCALLTYPE AddRef(void);
+
+ virtual ULONG STDMETHODCALLTYPE Release(void);
+
+ //-----------------------------
+ // IClassFactory methods
+ //-----------------------------
+
+ virtual HRESULT STDMETHODCALLTYPE CreateInstance(
+ IUnknown __RPC_FAR *pUnkOuter,
+ REFIID riid,
+ void __RPC_FAR *__RPC_FAR *ppvObject);
+
+ virtual HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock);
+
+ static bool IsLocked();
+
+private:
+ long m_RefCnt;
+ CLSID m_Clsid;
+
+ static long s_ServerLocks;
+};
+
+#endif
diff --git a/shell/source/win32/shlxthandler/columninfo/columninfo.cxx b/shell/source/win32/shlxthandler/columninfo/columninfo.cxx
new file mode 100644
index 000000000000..f8816668f8ab
--- /dev/null
+++ b/shell/source/win32/shlxthandler/columninfo/columninfo.cxx
@@ -0,0 +1,231 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/global.hxx"
+#include "internal/columninfo.hxx"
+#include "internal/fileextensions.hxx"
+#include "internal/metainforeader.hxx"
+#include "internal/utilities.hxx"
+#include "internal/config.hxx"
+
+#include <malloc.h>
+
+//----------------------------
+//
+//----------------------------
+
+namespace /* private */
+{
+ SHCOLUMNINFO ColumnInfoTable[] =
+ {
+ {{PSGUID_SUMMARYINFORMATION, PIDSI_TITLE}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Title", L"Title"},
+ {{PSGUID_SUMMARYINFORMATION, PIDSI_AUTHOR}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Author", L"Author"},
+ {{PSGUID_SUMMARYINFORMATION, PIDSI_SUBJECT}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Subject", L"Subject"},
+ {{PSGUID_SUMMARYINFORMATION, PIDSI_KEYWORDS}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Keywords", L"Keywords"},
+ {{PSGUID_SUMMARYINFORMATION, PIDSI_COMMENTS}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Comments", L"Comments"},
+ {{PSGUID_SUMMARYINFORMATION, PIDSI_PAGECOUNT},VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Pagecount", L"Pagecount"}
+ };
+
+ size_t ColumnInfoTableSize = sizeof(ColumnInfoTable)/sizeof(ColumnInfoTable[0]);
+}
+
+//----------------------------
+//
+//----------------------------
+
+CColumnInfo::CColumnInfo(long RefCnt) :
+ m_RefCnt(RefCnt)
+{
+ InterlockedIncrement(&g_DllRefCnt);
+}
+
+//----------------------------
+//
+//----------------------------
+
+CColumnInfo::~CColumnInfo()
+{
+ InterlockedDecrement(&g_DllRefCnt);
+}
+
+//-----------------------------
+// IUnknown methods
+//-----------------------------
+
+HRESULT STDMETHODCALLTYPE CColumnInfo::QueryInterface(REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ *ppvObject = 0;
+
+ if (IID_IUnknown == riid || IID_IColumnProvider == riid)
+ {
+ IUnknown* pUnk = static_cast<IColumnProvider*>(this);
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+
+ return E_NOINTERFACE;
+}
+
+//----------------------------
+//
+//----------------------------
+
+ULONG STDMETHODCALLTYPE CColumnInfo::AddRef(void)
+{
+ return InterlockedIncrement(&m_RefCnt);
+}
+
+//----------------------------
+//
+//----------------------------
+
+ULONG STDMETHODCALLTYPE CColumnInfo::Release( void)
+{
+ long refcnt = InterlockedDecrement(&m_RefCnt);
+
+ if (0 == m_RefCnt)
+ delete this;
+
+ return refcnt;
+}
+
+//-----------------------------
+// IColumnProvider
+//-----------------------------
+
+HRESULT STDMETHODCALLTYPE CColumnInfo::Initialize(LPCSHCOLUMNINIT /*psci*/)
+{
+ return S_OK;
+}
+
+//-----------------------------
+// Register all columns we support
+//-----------------------------
+
+HRESULT STDMETHODCALLTYPE CColumnInfo::GetColumnInfo(DWORD dwIndex, SHCOLUMNINFO *psci)
+{
+ if (dwIndex >= ColumnInfoTableSize)
+ return S_FALSE;
+
+ // Return information on each column we support. Return S_FALSE
+ // to indicate that we have returned information on all our
+ // columns. GetColumnInfo will be called repeatedly until S_FALSE
+ // or an error is returned
+ psci->scid.fmtid = ColumnInfoTable[dwIndex].scid.fmtid;
+ psci->scid.pid = ColumnInfoTable[dwIndex].scid.pid;
+ ZeroMemory(psci->wszTitle, sizeof(psci->wszTitle));
+ wcsncpy(psci->wszTitle, ColumnInfoTable[dwIndex].wszTitle, (sizeof(psci->wszTitle) - 1));
+
+ //wcscpy(psci->wszTitle, ColumnInfoTable[dwIndex].wszTitle);
+
+ return S_OK;
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+ HRESULT STDMETHODCALLTYPE CColumnInfo::GetItemData(LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT *pvarData)
+{
+ if (IsOOFileExtension(pscd->pwszExt))
+ {
+ try
+ {
+
+ CMetaInfoReader meta_info_accessor(WStringToString(pscd->wszFile));
+
+ VariantClear(pvarData);
+
+ if (IsEqualGUID (pscid->fmtid, FMTID_SummaryInformation) && pscid->pid == PIDSI_TITLE)
+ {
+ pvarData->vt = VT_BSTR;
+ pvarData->bstrVal = SysAllocString(meta_info_accessor.getTagData( META_INFO_TITLE ).c_str());
+
+ return S_OK;
+ }
+ else if (IsEqualGUID (pscid->fmtid, FMTID_SummaryInformation) && pscid->pid == PIDSI_AUTHOR)
+ {
+ pvarData->vt = VT_BSTR;
+ pvarData->bstrVal = SysAllocString(meta_info_accessor.getTagData( META_INFO_AUTHOR).c_str());
+
+ return S_OK;
+ }
+ else if (IsEqualGUID (pscid->fmtid, FMTID_SummaryInformation) && pscid->pid == PIDSI_SUBJECT)
+ {
+ pvarData->vt = VT_BSTR;
+ pvarData->bstrVal = SysAllocString(meta_info_accessor.getTagData( META_INFO_SUBJECT).c_str());
+
+ return S_OK;
+ }
+ else if (IsEqualGUID (pscid->fmtid, FMTID_SummaryInformation) && pscid->pid == PIDSI_KEYWORDS)
+ {
+ pvarData->vt = VT_BSTR;
+ pvarData->bstrVal = SysAllocString(meta_info_accessor.getTagData( META_INFO_KEYWORDS).c_str());
+
+ return S_OK;
+ }
+ else if (IsEqualGUID (pscid->fmtid, FMTID_SummaryInformation) && pscid->pid == PIDSI_COMMENTS)
+ {
+ pvarData->vt = VT_BSTR;
+ pvarData->bstrVal = SysAllocString(meta_info_accessor.getTagData( META_INFO_DESCRIPTION).c_str());
+
+ return S_OK;
+ }
+ else if (IsEqualGUID (pscid->fmtid, FMTID_SummaryInformation) && pscid->pid == PIDSI_PAGECOUNT)
+ {
+ pvarData->vt = VT_BSTR;
+ pvarData->bstrVal = SysAllocString(meta_info_accessor.getTagAttribute( META_INFO_DOCUMENT_STATISTIC, META_INFO_PAGES).c_str());
+
+ return S_OK;
+ }
+ }
+ catch (const std::exception&)
+ {
+ return S_FALSE;
+ }
+ }
+
+ return S_FALSE;
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+bool CColumnInfo::IsOOFileExtension(wchar_t* Extension) const
+{
+ for (size_t i = 0; i < OOFileExtensionTableSize; i++)
+ {
+ if (0 == _wcsicmp(Extension, OOFileExtensionTable[i].ExtensionUnicode))
+ return true;
+ }
+
+ return false;
+}
diff --git a/shell/source/win32/shlxthandler/columninfo/makefile.mk b/shell/source/win32/shlxthandler/columninfo/makefile.mk
new file mode 100644
index 000000000000..868a711e005c
--- /dev/null
+++ b/shell/source/win32/shlxthandler/columninfo/makefile.mk
@@ -0,0 +1,59 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+PRJNAME=shell
+TARGET=columninfo
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS+=-D_WIN32_IE=0x501
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=$(SLO)$/columninfo.obj
+
+.IF "$(BUILD_X64)"!=""
+CFLAGS_X64+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS_X64+=-D_WIN32_IE=0x501
+SLOFILES_X64=$(SLO_X64)$/$(TARGET).obj
+.ENDIF # "$(BUILD_X64)"!=""
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+.INCLUDE : tg_wntx64.mk \ No newline at end of file
diff --git a/shell/source/win32/shlxthandler/exports.dxp b/shell/source/win32/shlxthandler/exports.dxp
new file mode 100644
index 000000000000..953039ccc957
--- /dev/null
+++ b/shell/source/win32/shlxthandler/exports.dxp
@@ -0,0 +1,4 @@
+DllRegisterServer PRIVATE
+DllUnregisterServer PRIVATE
+DllGetClassObject PRIVATE
+DllCanUnloadNow PRIVATE \ No newline at end of file
diff --git a/shell/source/win32/shlxthandler/infotips/infotips.cxx b/shell/source/win32/shlxthandler/infotips/infotips.cxx
new file mode 100644
index 000000000000..72da8c9e7060
--- /dev/null
+++ b/shell/source/win32/shlxthandler/infotips/infotips.cxx
@@ -0,0 +1,402 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/global.hxx"
+#include "internal/infotips.hxx"
+#include "internal/shlxthdl.hxx"
+#include "internal/metainforeader.hxx"
+#include "internal/contentreader.hxx"
+#include "internal/utilities.hxx"
+#include "internal/registry.hxx"
+#include "internal/fileextensions.hxx"
+#include "internal/iso8601_converter.hxx"
+#include "internal/config.hxx"
+
+#include "internal/resource.h"
+#include <stdio.h>
+#include <utility>
+#include <stdlib.h>
+
+
+#define MAX_STRING 80
+#define KB 1024.0
+const std::wstring WSPACE = std::wstring(SPACE);
+
+//-----------------------------
+//
+//-----------------------------
+
+CInfoTip::CInfoTip(long RefCnt) :
+ m_RefCnt(RefCnt)
+{
+ ZeroMemory(m_szFileName, sizeof(m_szFileName));
+ InterlockedIncrement(&g_DllRefCnt);
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+CInfoTip::~CInfoTip()
+{
+ InterlockedDecrement(&g_DllRefCnt);
+}
+
+//-----------------------------
+// IUnknown methods
+//-----------------------------
+
+HRESULT STDMETHODCALLTYPE CInfoTip::QueryInterface(REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ *ppvObject = 0;
+
+ IUnknown* pUnk = 0;
+
+ if (IID_IUnknown == riid || IID_IQueryInfo == riid)
+ {
+ pUnk = static_cast<IQueryInfo*>(this);
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+ else if (IID_IPersistFile == riid)
+ {
+ pUnk = static_cast<IPersistFile*>(this);
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+
+ return E_NOINTERFACE;
+}
+
+//----------------------------
+//
+//----------------------------
+
+ULONG STDMETHODCALLTYPE CInfoTip::AddRef(void)
+{
+ return InterlockedIncrement(&m_RefCnt);
+}
+
+//----------------------------
+//
+//----------------------------
+
+ULONG STDMETHODCALLTYPE CInfoTip::Release( void)
+{
+ long refcnt = InterlockedDecrement(&m_RefCnt);
+
+ if (0 == m_RefCnt)
+ delete this;
+
+ return refcnt;
+}
+
+//********************helper functions for GetInfoTip functions**********************
+
+/** get file type infomation from registry.
+*/
+std::wstring getFileTypeInfo(const std::string& file_extension)
+{
+ char extKeyValue[MAX_STRING];
+ char typeKeyValue[MAX_STRING];
+ ::std::string sDot(".");
+ if (QueryRegistryKey(HKEY_CLASSES_ROOT, (sDot.append(file_extension)).c_str(), "", extKeyValue, MAX_STRING))
+ if (QueryRegistryKey( HKEY_CLASSES_ROOT, extKeyValue, "",typeKeyValue, MAX_STRING))
+ return StringToWString(typeKeyValue);
+
+ return EMPTY_STRING;
+}
+
+/** get file size.
+*/
+DWORD getSizeOfFile( char* FileName )
+{
+ HANDLE hFile = CreateFile(StringToWString(FileName).c_str(), // open file
+ GENERIC_READ, // open for reading
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, // share for all operations
+ NULL, // no security
+ OPEN_EXISTING, // existing file only
+ FILE_ATTRIBUTE_NORMAL, // normal file
+ NULL); // no attr. template
+
+ if (hFile != INVALID_HANDLE_VALUE)
+ {
+ DWORD dwSize = GetFileSize( HANDLE(hFile), NULL );
+ CloseHandle( HANDLE(hFile) );
+ return dwSize;
+ }
+
+ return INVALID_FILE_SIZE;
+}
+
+/** format file size in to be more readable.
+*/
+std::wstring formatSizeOfFile( DWORD dwSize )
+{
+ if ( dwSize < 1000 )
+ {
+ char buffer[3];
+ int dFileSize = dwSize;
+
+ _itoa( dFileSize, buffer, 10 );
+ return StringToWString( buffer ).append(StringToWString("B"));
+ }
+
+ char *buffer=NULL;
+ int decimal, sign;
+ double dFileSize = (double)dwSize/(double)KB;
+
+ buffer = _fcvt( dFileSize, 1, &decimal, &sign );
+
+ ::std::wstring wsTemp = StringToWString( buffer );
+ int pos=decimal % 3;
+ ::std::wstring wsBuffer = wsTemp.substr( 0,pos);
+
+ if ( decimal )
+ for (;decimal - pos > 2;pos += 3)
+ {
+ if (pos)
+ wsBuffer.append(StringToWString(","));
+ wsBuffer.append( wsTemp.substr( pos, 3) );
+ }
+ else
+ wsBuffer.append(StringToWString("0"));
+
+ wsBuffer.append(StringToWString("."));
+ wsBuffer.append(wsTemp.substr( decimal, wsTemp.size()-decimal ));
+ wsBuffer.append(StringToWString("KB"));
+
+ return wsBuffer;
+}
+
+
+/** get file size infomation.
+*/
+std::wstring getFileSizeInfo(char* FileName)
+{
+ DWORD dwSize=getSizeOfFile(FileName);
+ if (dwSize != INVALID_FILE_SIZE)
+ return formatSizeOfFile( dwSize );
+
+ return EMPTY_STRING;
+}
+
+//----------------------------
+// IQueryInfo methods
+//----------------------------
+
+HRESULT STDMETHODCALLTYPE CInfoTip::GetInfoTip(DWORD /*dwFlags*/, wchar_t** ppwszTip)
+{
+ std::wstring msg;
+ const std::wstring CONST_SPACE(SPACE);
+
+ //display File Type, no matter other info is loaded successfully or not.
+ std::wstring tmpTypeStr = getFileTypeInfo( get_file_name_extension(m_szFileName) );
+ if ( tmpTypeStr != EMPTY_STRING )
+ {
+ msg += GetResString(IDS_TYPE_COLON) + CONST_SPACE;
+ msg += tmpTypeStr;
+ }
+
+ try
+ {
+ CMetaInfoReader meta_info_accessor(m_szFileName);
+
+ //display document title;
+ if ( meta_info_accessor.getTagData( META_INFO_TITLE ).length() > 0)
+ {
+ if ( msg != EMPTY_STRING )
+ msg += L"\n";
+ msg += GetResString(IDS_TITLE_COLON) + CONST_SPACE;
+ msg += meta_info_accessor.getTagData( META_INFO_TITLE );
+ }
+ else
+ {
+ if ( msg != EMPTY_STRING )
+ msg += L"\n";
+ msg += GetResString(IDS_TITLE_COLON) + CONST_SPACE;
+ msg += m_FileNameOnly;
+ }
+
+ //display document author;
+ if ( meta_info_accessor.getTagData( META_INFO_AUTHOR ).length() > 0)
+ {
+ if ( msg != EMPTY_STRING )
+ msg += L"\n";
+ msg += GetResString( IDS_AUTHOR_COLON ) + CONST_SPACE;
+ msg += meta_info_accessor.getTagData( META_INFO_AUTHOR );
+ }
+
+ //display document subject;
+ if ( meta_info_accessor.getTagData( META_INFO_SUBJECT ).length() > 0)
+ {
+ if ( msg != EMPTY_STRING )
+ msg += L"\n";
+ msg += GetResString(IDS_SUBJECT_COLON) + CONST_SPACE;
+ msg += meta_info_accessor.getTagData( META_INFO_SUBJECT );
+ }
+
+ //display document description;
+ if ( meta_info_accessor.getTagData( META_INFO_DESCRIPTION ).length() > 0)
+ {
+ if ( msg != EMPTY_STRING )
+ msg += L"\n";
+ msg += GetResString( IDS_COMMENTS_COLON ) + CONST_SPACE;
+ msg += meta_info_accessor.getTagData( META_INFO_DESCRIPTION );
+ }
+
+ //display midified time formated into locale representation.
+ if ( iso8601_date_to_local_date(meta_info_accessor.getTagData(META_INFO_MODIFIED )).length() > 0)
+ {
+ if ( msg != EMPTY_STRING )
+ msg += L"\n";
+ msg += GetResString( IDS_MODIFIED_COLON ) + CONST_SPACE;
+ msg += iso8601_date_to_local_date(meta_info_accessor.getTagData(META_INFO_MODIFIED ));
+ }
+ }
+ catch (const std::exception&)
+ {
+ //return E_FAIL;
+ }
+
+ //display file size, no matter other infomation is loaded successfully or not.
+ std::wstring tmpSizeStr = getFileSizeInfo( m_szFileName );
+ if ( tmpSizeStr != EMPTY_STRING )
+ {
+ msg += L"\n";
+ msg += GetResString( IDS_SIZE_COLON ) + CONST_SPACE;
+ msg += tmpSizeStr;
+ }
+
+
+ //finalize and assignthe string.
+ LPMALLOC lpMalloc;
+ HRESULT hr = SHGetMalloc(&lpMalloc);
+
+ if (SUCCEEDED(hr))
+ {
+ size_t len = sizeof(wchar_t) * msg.length() + sizeof(wchar_t);
+ wchar_t* pMem = reinterpret_cast<wchar_t*>(lpMalloc->Alloc(len));
+
+ ZeroMemory(pMem, len);
+
+ msg.copy(pMem,msg.length());
+
+ *ppwszTip = pMem;
+ lpMalloc->Release();
+
+ return S_OK;
+ }
+
+ return E_FAIL;
+}
+
+//----------------------------
+//
+//----------------------------
+
+HRESULT STDMETHODCALLTYPE CInfoTip::GetInfoFlags(DWORD * /*pdwFlags*/ )
+{
+ return E_NOTIMPL;
+}
+
+//----------------------------
+// IPersist methods
+//----------------------------
+
+HRESULT STDMETHODCALLTYPE CInfoTip::GetClassID(CLSID* pClassID)
+{
+ pClassID = const_cast<CLSID*>(&CLSID_INFOTIP_HANDLER);
+ return S_OK;
+}
+
+//----------------------------
+// IPersistFile methods
+//----------------------------
+
+HRESULT STDMETHODCALLTYPE CInfoTip::Load(LPCOLESTR pszFileName, DWORD /*dwMode*/)
+{
+ std::wstring fname = pszFileName;
+
+ // there must be a '\' and there must even be an
+ // extension, else we would not have been called
+ std::wstring::iterator begin = fname.begin() + fname.find_last_of(L"\\") + 1;
+ std::wstring::iterator end = fname.end();
+
+ m_FileNameOnly = std::wstring(begin, end);
+
+ std::string fnameA = WStringToString(fname);
+
+ // #115531#
+ // ZeroMemory because strncpy doesn't '\0'-terminates the destination
+ // string; reserve the last place in the buffer for the final '\0'
+ // that's why '(sizeof(m_szFileName) - 1)'
+ ZeroMemory(m_szFileName, sizeof(m_szFileName));
+ strncpy(m_szFileName, fnameA.c_str(), (sizeof(m_szFileName) - 1));
+
+ return S_OK;
+}
+
+//----------------------------
+//
+//----------------------------
+
+HRESULT STDMETHODCALLTYPE CInfoTip::IsDirty(void)
+{
+ return E_NOTIMPL;
+}
+
+//----------------------------
+//
+//----------------------------
+
+HRESULT STDMETHODCALLTYPE CInfoTip::Save(LPCOLESTR /*pszFileName*/, BOOL /*fRemember*/)
+{
+ return E_NOTIMPL;
+}
+
+//----------------------------
+//
+//----------------------------
+
+HRESULT STDMETHODCALLTYPE CInfoTip::SaveCompleted(LPCOLESTR /*pszFileName*/)
+{
+ return E_NOTIMPL;
+}
+
+//----------------------------
+//
+//----------------------------
+
+HRESULT STDMETHODCALLTYPE CInfoTip::GetCurFile(LPOLESTR __RPC_FAR * /*ppszFileName*/)
+{
+ return E_NOTIMPL;
+}
diff --git a/shell/source/win32/shlxthandler/infotips/makefile.mk b/shell/source/win32/shlxthandler/infotips/makefile.mk
new file mode 100644
index 000000000000..f69f2cf2fd78
--- /dev/null
+++ b/shell/source/win32/shlxthandler/infotips/makefile.mk
@@ -0,0 +1,60 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+PRJNAME=shell
+TARGET=infotips
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+EXTERNAL_WARNINGS_NOT_ERRORS := TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS+=-D_WIN32_IE=0x501
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=$(SLO)$/$(TARGET).obj
+
+.IF "$(BUILD_X64)"!=""
+CFLAGS_X64+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS_X64+=-D_WIN32_IE=0x501
+SLOFILES_X64=$(SLO_X64)$/$(TARGET).obj
+.ENDIF # "$(BUILD_X64)"!=""
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+.INCLUDE : tg_wntx64.mk \ No newline at end of file
diff --git a/shell/source/win32/shlxthandler/makefile.mk b/shell/source/win32/shlxthandler/makefile.mk
new file mode 100644
index 000000000000..4452cb1a90e6
--- /dev/null
+++ b/shell/source/win32/shlxthandler/makefile.mk
@@ -0,0 +1,158 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=shell
+TARGET=shlxthdl
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+USE_DEFFILE=TRUE
+.IF "$(BUILD_X64)"!=""
+USE_DEFFILE_X64=TRUE
+.ENDIF
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+UWINAPILIB =
+UWINAPILIB_X64 =
+
+CFLAGS+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS+=-D_WIN32_IE=0x501
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=$(SLO)$/classfactory.obj\
+ $(SLO)$/columninfo.obj\
+ $(SLO)$/infotips.obj\
+ $(SLO)$/propsheets.obj\
+ $(SLO)$/shlxthdl.obj\
+ $(SLO)$/listviewbuilder.obj\
+ $(SLO)$/document_statistic.obj\
+ $(SLO)$/thumbviewer.obj\
+
+SHL1TARGET=$(TARGET)
+
+.IF "$(COM)"=="GCC"
+SHL1STDLIBS=$(ZLIB3RDLIB) $(EXPAT3RDLIB) $(COMCTL32LIB)
+SHL1LIBS=
+.ELSE
+SHL1STDLIBS=
+SHL1LIBS=$(SOLARLIBDIR)$/zlib.lib\
+ $(SOLARLIBDIR)$/expat_xmlparse.lib\
+ $(SOLARLIBDIR)$/expat_xmltok.lib
+.ENDIF
+SHL1STDLIBS+=\
+ $(OLEAUT32LIB)\
+ $(ADVAPI32LIB)\
+ $(OLE32LIB)\
+ $(UUIDLIB)\
+ $(SHELL32LIB)\
+ $(KERNEL32LIB)\
+ $(GDI32LIB)\
+ $(GDIPLUSLIB)
+
+.IF "$(COM)"!="GCC"
+SHL1STDLIBS+=\
+ msvcprt.lib
+.ENDIF
+
+SHL1STDLIBS+=\
+ $(SHLWAPILIB)
+
+SHL1LIBS+=$(SLB)$/util.lib\
+ $(SLB)$/ooofilereader.lib
+
+SHL1DEPN=
+
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+SHL1RES=$(RES)$/$(TARGET).res
+
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=exports.dxp
+
+.IF "$(BUILD_X64)"!=""
+# -------------------- x64 -----------------------
+CFLAGS_X64+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS_X64+=-D_WIN32_IE=0x501
+
+SLOFILES_X64= \
+ $(SLO_X64)$/classfactory.obj\
+ $(SLO_X64)$/columninfo.obj\
+ $(SLO_X64)$/infotips.obj\
+ $(SLO_X64)$/propsheets.obj\
+ $(SLO_X64)$/shlxthdl.obj\
+ $(SLO_X64)$/listviewbuilder.obj\
+ $(SLO_X64)$/document_statistic.obj\
+ $(SLO_X64)$/thumbviewer.obj\
+
+SHL1TARGET_X64=$(TARGET)
+SHL1LIBS_X64=$(SOLARLIBDIR_X64)$/zlib.lib\
+ $(SOLARLIBDIR_X64)$/expat_xmlparse.lib\
+ $(SOLARLIBDIR_X64)$/expat_xmltok.lib
+
+SHL1STDLIBS_X64+=\
+ $(OLEAUT32LIB_X64)\
+ $(ADVAPI32LIB_X64)\
+ $(OLE32LIB_X64)\
+ $(UUIDLIB_X64)\
+ $(SHELL32LIB_X64)\
+ $(KERNEL32LIB_X64)\
+ $(GDI32LIB_X64)\
+ $(USER32LIB_X64) \
+ $(GDIPLUSLIB_X64) \
+ $(MSVCRT_X64) \
+ $(MSVCPRT_X64) \
+ $(OLDNAMESLIB_X64) \
+ msvcprt.lib
+
+.IF "$(PRODUCT)"!="full"
+SHL1STDLIBS+=msvcrt.lib
+.ENDIF
+
+SHL1LIBS_X64+=$(SLB_X64)$/util.lib\
+ $(SLB_X64)$/ooofilereader.lib
+SHL1OBJS_X64=$(SLOFILES_X64)
+SHL1DEF_X64=$(MISC_X64)$/$(SHL1TARGET).def
+SHL1RES_X64=$(RES_X64)$/$(TARGET).res
+
+DEF1NAME_X64=$(SHL1TARGET_X64)
+DEF1EXPORTFILE_X64=exports.dxp
+.ENDIF # "$(BUILD_X64)"!=""
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+.INCLUDE : tg_wntx64.mk
+
diff --git a/shell/source/win32/shlxthandler/ooofilt/exports.dxp b/shell/source/win32/shlxthandler/ooofilt/exports.dxp
new file mode 100644
index 000000000000..953039ccc957
--- /dev/null
+++ b/shell/source/win32/shlxthandler/ooofilt/exports.dxp
@@ -0,0 +1,4 @@
+DllRegisterServer PRIVATE
+DllUnregisterServer PRIVATE
+DllGetClassObject PRIVATE
+DllCanUnloadNow PRIVATE \ No newline at end of file
diff --git a/shell/source/win32/shlxthandler/ooofilt/makefile.mk b/shell/source/win32/shlxthandler/ooofilt/makefile.mk
new file mode 100644
index 000000000000..9111069ab889
--- /dev/null
+++ b/shell/source/win32/shlxthandler/ooofilt/makefile.mk
@@ -0,0 +1,141 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+PRJNAME=shell
+TARGET=ooofilt
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+USE_DEFFILE=TRUE
+
+# Do not use the dynamic STLport library.
+NO_DEFAULT_STL=YES
+
+# Do not use the uwinapi library
+UWINAPILIB=
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS+=-D_WIN32_IE=0x501
+# SCPCDEFS+=-D_STLP_USE_STATIC_LIB
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=$(SLO)$/ooofilt.obj\
+ $(SLO)$/propspec.obj\
+ $(SLO)$/stream_helper.obj
+
+# $(SLO)$/utilities.obj
+# $(SLO)$/dbgmacros.obj
+
+SHL1TARGET=$(TARGET)
+.IF "$(COM)"=="GCC"
+SHL1STDLIBS=$(ZLIB3RDLIB) $(EXPAT3RDLIB)
+SHL1LIBS=
+.ELSE
+SHL1STDLIBS=
+SHL1LIBS=$(SOLARLIBDIR)$/zlib.lib\
+ $(SOLARLIBDIR)$/expat_xmlparse.lib\
+ $(SOLARLIBDIR)$/expat_xmltok.lib
+.ENDIF
+SHL1STDLIBS+=$(OLE32LIB)\
+ $(ADVAPI32LIB)\
+ $(COMCTL32LIB)\
+ $(UUIDLIB)\
+ $(SHELL32LIB)\
+ $(KERNEL32LIB)\
+ $(OLDNAMESLIB)
+
+.IF "$(COM)"!="GCC"
+SHL1STDLIBS+=msvcprt.lib
+
+.IF "$(PRODUCT)"!="full"
+SHL1STDLIBS+=msvcrt.lib
+.ENDIF
+.ENDIF
+
+
+# $(LIBSTLPORTST)
+
+SHL1LIBS+=$(SLB)$/util.lib\
+ $(SLB)$/ooofilereader.lib
+
+SHL1DEPN=
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=exports.dxp
+
+
+.IF "$(BUILD_X64)"!=""
+#---------------------------- x64 -------------------------
+CFLAGS_X64+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS_X64+=-D_WIN32_IE=0x501
+USE_DEFFILE_X64=TRUE
+
+SLOFILES_X64=$(SLO_X64)$/ooofilt.obj\
+ $(SLO_X64)$/propspec.obj\
+ $(SLO_X64)$/stream_helper.obj
+
+SHL1TARGET_X64=$(TARGET)
+
+SHL1LIBS_X64=$(SOLARLIBDIR_X64)$/zlib.lib\
+ $(SOLARLIBDIR_X64)$/expat_xmlparse.lib\
+ $(SOLARLIBDIR_X64)$/expat_xmltok.lib
+
+SHL1STDLIBS_X64+=$(OLE32LIB_X64)\
+ $(ADVAPI32LIB_X64)\
+ $(COMCTL32LIB_X64)\
+ $(UUIDLIB_X64)\
+ $(USER32LIB_X64) \
+ $(SHELL32LIB_X64)\
+ $(KERNEL32LIB_X64)\
+ $(MSVCPRT_X64) \
+ $(MSVCRT_X64) \
+ $(OLDNAMESLIB_X64)
+
+SHL1LIBS_X64+=$(SLB_X64)$/util.lib\
+ $(SLB_X64)$/ooofilereader.lib
+SHL1OBJS_X64=$(SLOFILES_X64)
+SHL1DEF_X64=$(MISC_X64)$/$(SHL1TARGET_X64).def
+DEF1NAME_X64=$(SHL1TARGET_X64)
+DEF1EXPORTFILE_X64=exports.dxp
+.ENDIF # "$(BUILD_X64)"!=""
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+.INCLUDE : tg_wntx64.mk
diff --git a/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx b/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx
new file mode 100755
index 000000000000..adcf2b2f8ddf
--- /dev/null
+++ b/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx
@@ -0,0 +1,1490 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+//--------------------------------------------------------------------------
+// File: ooofilt.cxx
+//
+// Contents: Filter Implementation for OpenOffice.Org Document using
+// Indexing Service
+//
+// Summary: The OpenOffice.org filter reads OpenOffice.org files (with the
+// extension .sxw .sxi, etc) and extract their content, author,
+// keywords,subject,comments and title to be filtered.
+//
+// Platform: Windows 2000, Windows XP
+//
+//--------------------------------------------------------------------------
+#include "internal/contentreader.hxx"
+#include "internal/metainforeader.hxx"
+//#include "internal/utilities.hxx"
+#include "internal/registry.hxx"
+#include "internal/fileextensions.hxx"
+
+//--------------------------------------------------------------------------
+//
+// Include file Purpose
+//
+// windows.h Win32 declarations
+// string.h string wstring declarations
+// filter.h IFilter interface declarations
+// filterr.h FACILITY_ITF error definitions for IFilter
+// ntquery.h Indexing Service declarations
+// assert.h assertion function.
+// ooofilt.hxx OpenOffice.org filter declarations
+// propspec.hxx PROPSPEC
+//
+//--------------------------------------------------------------------------
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <string.h>
+#include <filter.h>
+#include <filterr.h>
+#include <ntquery.h>
+#include "assert.h"
+#include "ooofilt.hxx"
+#include <objidl.h>
+#include <stdio.h>
+#include "propspec.hxx"
+#ifdef __MINGW32__
+#include <algorithm>
+using ::std::min;
+#endif
+
+#include "internal/stream_helper.hxx"
+
+//C-------------------------------------------------------------------------
+//
+// Class: COooFilter
+//
+// Summary: Implements OpenOffice.org filter class
+//
+//--------------------------------------------------------------------------
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::COooFilter
+//
+// Summary: Class constructor
+//
+// Arguments: void
+//
+// Purpose: Manages global instance count
+//
+//--------------------------------------------------------------------------
+COooFilter::COooFilter() :
+ m_lRefs(1),
+ m_pContentReader(NULL),
+ m_pMetaInfoReader(NULL),
+ m_eState(FilteringContent),
+ m_ulUnicodeBufferLen(0),
+ m_ulUnicodeCharsRead(0),
+ m_ulPropertyNum(0),
+ m_ulCurrentPropertyNum(0),
+ m_ulChunkID(1),
+ m_fContents(FALSE),
+ m_fEof(FALSE),
+ m_ChunkPosition(0),
+ m_cAttributes(0),
+ m_pAttributes(0),
+ m_pStream(NULL)
+
+{
+ InterlockedIncrement( &g_lInstances );
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::~COooFilter
+//
+// Summary: Class destructor
+//
+// Arguments: void
+//
+// Purpose: Manages global instance count and file handle
+//
+//--------------------------------------------------------------------------
+COooFilter::~COooFilter()
+{
+ delete [] m_pAttributes;
+
+ if (m_pContentReader)
+ delete m_pContentReader;
+ if (m_pMetaInfoReader)
+ delete m_pMetaInfoReader;
+
+ InterlockedDecrement( &g_lInstances );
+}
+
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::QueryInterface (IUnknown::QueryInterface)
+//
+// Summary: Queries for requested interface
+//
+// Arguments: riid
+// [in] Reference IID of requested interface
+// ppvObject
+// [out] Address that receives requested interface pointer
+//
+// Returns: S_OK
+// Interface is supported
+// E_NOINTERFACE
+// Interface is not supported
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilter::QueryInterface(
+ REFIID riid,
+ void ** ppvObject)
+{
+ IUnknown *pUnkTemp = 0;
+ if ( IID_IFilter == riid )
+ pUnkTemp = (IUnknown *)(IFilter *)this;
+ else if ( IID_IPersistFile == riid )
+ pUnkTemp = (IUnknown *)(IPersistFile *)this;
+ else if ( IID_IPersist == riid )
+ pUnkTemp = (IUnknown *)(IPersist *)(IPersistFile *)this;
+ else if (IID_IPersistStream == riid)
+ pUnkTemp = (IUnknown *)(IPersistStream *)this;
+ else if ( IID_IUnknown == riid )
+ pUnkTemp = (IUnknown *)(IPersist *)(IPersistFile *)this;
+ else
+ {
+ *ppvObject = NULL;
+ return E_NOINTERFACE;
+ }
+ *ppvObject = (void *)pUnkTemp;
+ pUnkTemp->AddRef();
+ return S_OK;
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::AddRef (IUnknown::AddRef)
+//
+// Summary: Increments interface refcount
+//
+// Arguments: void
+//
+// Returns: Value of incremented interface refcount
+//
+//--------------------------------------------------------------------------
+ULONG STDMETHODCALLTYPE COooFilter::AddRef()
+{
+ return InterlockedIncrement( &m_lRefs );
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::Release (IUnknown::Release)
+//
+// Summary: Decrements interface refcount, deleting if unreferenced
+//
+// Arguments: void
+//
+// Returns: Value of decremented interface refcount
+//
+//--------------------------------------------------------------------------
+ULONG STDMETHODCALLTYPE COooFilter::Release()
+{
+ ULONG ulTmp = InterlockedDecrement( &m_lRefs );
+
+ if ( 0 == ulTmp )
+ delete this;
+ return ulTmp;
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::Init (IFilter::Init)
+//
+// Summary: Initializes OpenOffice.org filter instance
+//
+// Arguments: grfFlags
+// [in] Flags for filter behavior
+// cAttributes
+// [in] Number attributes in array aAttributes
+// aAttributes
+// [in] Array of requested attribute strings
+// pFlags
+// [out] Pointer to return flags for additional properties
+//
+// Returns: S_OK
+// Initialization succeeded
+// E_FAIL
+// File not previously loaded
+// E_INVALIDARG
+// Count and contents of attributes do not agree
+// FILTER_E_ACCESS
+// Unable to access file to be filtered
+// FILTER_E_PASSWORD
+// (not implemented)
+//
+//--------------------------------------------------------------------------
+const int COUNT_ATTRIBUTES = 5;
+
+SCODE STDMETHODCALLTYPE COooFilter::Init(
+ ULONG grfFlags,
+ ULONG cAttributes,
+ FULLPROPSPEC const * aAttributes,
+ ULONG * pFlags)
+{
+ // Enumerate OLE properties, since any NTFS file can have them
+ *pFlags = IFILTER_FLAGS_OLE_PROPERTIES;
+ try
+ {
+ m_fContents = FALSE;
+ m_ulPropertyNum = 0;
+ m_ulCurrentPropertyNum = 0;
+ if ( m_cAttributes > 0 )
+ {
+ delete[] m_pAttributes;
+ m_pAttributes = 0;
+ m_cAttributes = 0;
+ }
+ if( 0 < cAttributes )
+ {
+ // Filter properties specified in aAttributes
+ if ( 0 == aAttributes )
+ return E_INVALIDARG;
+ m_pAttributes = new CFullPropSpec[cAttributes];
+ m_cAttributes = cAttributes;
+ // Is caller want to filter contents?
+ CFullPropSpec *pAttrib = (CFullPropSpec *) aAttributes;
+ ULONG ulNumAttr;
+ for ( ulNumAttr = 0 ; ulNumAttr < cAttributes; ulNumAttr++ )
+ {
+ if ( pAttrib[ulNumAttr].IsPropertyPropid() &&
+ pAttrib[ulNumAttr].GetPropertyPropid() == PID_STG_CONTENTS &&
+ pAttrib[ulNumAttr].GetPropSet() == guidStorage )
+ {
+ m_fContents = TRUE;
+ }
+ // save the requested properties.
+ m_pAttributes[ulNumAttr] = pAttrib[ulNumAttr];
+ }
+ }
+ else if ( grfFlags & IFILTER_INIT_APPLY_INDEX_ATTRIBUTES )
+ {
+ // Filter contents and all pseudo-properties
+ m_fContents = TRUE;
+
+ m_pAttributes = new CFullPropSpec[COUNT_ATTRIBUTES];
+ m_cAttributes = COUNT_ATTRIBUTES;
+ m_pAttributes[0].SetPropSet( FMTID_SummaryInformation );
+ m_pAttributes[0].SetProperty( PIDSI_AUTHOR );
+ m_pAttributes[1].SetPropSet( FMTID_SummaryInformation );
+ m_pAttributes[1].SetProperty( PIDSI_TITLE );
+ m_pAttributes[2].SetPropSet( FMTID_SummaryInformation );
+ m_pAttributes[2].SetProperty( PIDSI_SUBJECT );
+ m_pAttributes[3].SetPropSet( FMTID_SummaryInformation );
+ m_pAttributes[3].SetProperty( PIDSI_KEYWORDS );
+ m_pAttributes[4].SetPropSet( FMTID_SummaryInformation );
+ m_pAttributes[4].SetProperty( PIDSI_COMMENTS );
+ }
+ else if ( 0 == grfFlags )
+ {
+ // Filter only contents
+ m_fContents = TRUE;
+ }
+ else
+ m_fContents = FALSE;
+ // Re-initialize
+ if ( m_fContents )
+ {
+ m_fEof = FALSE;
+ m_eState = FilteringContent;
+ m_ulUnicodeCharsRead = 0;
+ m_ChunkPosition = 0;
+ }
+ else
+ {
+ m_fEof = TRUE;
+ m_eState = FilteringProperty;
+ }
+ m_ulChunkID = 1;
+ }
+ catch (const std::exception&)
+ {
+ return E_FAIL;
+ }
+
+ return S_OK;
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::GetChunk (IFilter::GetChunk)
+//
+// Summary: Gets the next chunk
+//
+// Arguments: ppStat
+// [out] Pointer to description of current chunk
+// Returns: S_OK
+// Chunk was successfully retrieved
+// E_FAIL
+// Character conversion failed
+// FILTER_E_ACCESS
+// General access failure occurred
+// FILTER_E_END_OF_CHUNKS
+// Previous chunk was the last chunk
+// FILTER_E_EMBEDDING_UNAVAILABLE
+// (not implemented)
+// FILTER_E_LINK_UNAVAILABLE
+// (not implemented)
+// FILTER_E_PASSWORD
+// (not implemented)
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilter::GetChunk(STAT_CHUNK * pStat)
+{
+ for(;;)
+ {
+ switch ( m_eState )
+ {
+ case FilteringContent:
+ {
+ // Read Unicodes from buffer.
+ if( m_ChunkPosition == m_pContentReader ->getChunkBuffer().size() )
+ {
+ m_ulUnicodeBufferLen=0;
+ m_fEof = TRUE;
+ }
+
+ if ( !m_fContents || m_fEof )
+ {
+ m_eState = FilteringProperty;
+ continue;
+ }
+ m_pwsBuffer = m_pContentReader -> getChunkBuffer()[m_ChunkPosition].second;
+ m_ulUnicodeBufferLen = m_pwsBuffer.length();
+ DWORD ChunkLCID = LocaleSetToLCID( m_pContentReader -> getChunkBuffer()[m_ChunkPosition].first );
+ // Set chunk description
+ pStat->idChunk = m_ulChunkID;
+ pStat->breakType = CHUNK_NO_BREAK;
+ pStat->flags = CHUNK_TEXT;
+ pStat->locale = ChunkLCID;
+ pStat->attribute.guidPropSet = guidStorage;
+ pStat->attribute.psProperty.ulKind = PRSPEC_PROPID;
+ pStat->attribute.psProperty.propid = PID_STG_CONTENTS;
+ pStat->idChunkSource = m_ulChunkID;
+ pStat->cwcStartSource = 0;
+ pStat->cwcLenSource = 0;
+ m_ulUnicodeCharsRead = 0;
+ m_ulChunkID++;
+ m_ChunkPosition++;
+ return S_OK;
+ }
+ case FilteringProperty:
+ {
+ if ( m_cAttributes == 0 )
+ return FILTER_E_END_OF_CHUNKS;
+ while( !( ( m_pAttributes[m_ulPropertyNum].IsPropertyPropid() ) &&
+ ( m_pAttributes[m_ulPropertyNum].GetPropSet() == FMTID_SummaryInformation ) )||
+ ( ( m_pAttributes[m_ulPropertyNum].GetPropertyPropid() != PIDSI_AUTHOR ) &&
+ ( m_pAttributes[m_ulPropertyNum].GetPropertyPropid() != PIDSI_TITLE ) &&
+ ( m_pAttributes[m_ulPropertyNum].GetPropertyPropid() != PIDSI_SUBJECT ) &&
+ ( m_pAttributes[m_ulPropertyNum].GetPropertyPropid() != PIDSI_KEYWORDS ) &&
+ ( m_pAttributes[m_ulPropertyNum].GetPropertyPropid() != PIDSI_COMMENTS ) ) )
+ {
+ if ( m_ulPropertyNum < m_cAttributes )
+ m_ulPropertyNum++;
+ else
+ break;
+ }
+ if ( m_ulPropertyNum == m_cAttributes)
+ return FILTER_E_END_OF_CHUNKS;
+ else
+ {
+ // Set chunk description
+ pStat->idChunk = m_ulChunkID;
+ pStat->breakType = CHUNK_EOS;
+ pStat->flags = CHUNK_VALUE;
+ pStat->locale = GetSystemDefaultLCID();
+ pStat->attribute.guidPropSet = FMTID_SummaryInformation;
+ pStat->attribute.psProperty.ulKind = PRSPEC_PROPID;
+ pStat->attribute.psProperty.propid = m_pAttributes[m_ulPropertyNum].GetPropertyPropid();
+ pStat->idChunkSource = m_ulChunkID;
+ pStat->cwcStartSource = 0;
+ pStat->cwcLenSource = 0;
+ m_ulCurrentPropertyNum = m_ulPropertyNum;
+ m_ulPropertyNum++;
+ m_ulChunkID++;
+ return S_OK;
+ }
+ }
+ default:
+ return E_FAIL;
+ }//switch(...)
+ }//for(;;)
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::GetText (IFilter::GetText)
+//
+// Summary: Retrieves UNICODE text for index
+//
+// Arguments: pcwcBuffer
+// [in] Pointer to size of UNICODE buffer
+// [out] Pointer to count of UNICODE characters returned
+// awcBuffer
+// [out] Pointer to buffer to receive UNICODE text
+//
+// Returns: S_OK
+// Text successfully retrieved, but text remains in chunk
+// FILTER_E_NO_MORE_TEXT
+// All of the text in the current chunk has been returned
+// FILTER_S_LAST_TEXT
+// Next call to GetText will return FILTER_E_NO_MORE_TEXT
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilter::GetText(ULONG * pcwcBuffer, WCHAR * awcBuffer)
+{
+ switch ( m_eState )
+ {
+ case FilteringProperty:
+ return FILTER_E_NO_TEXT;
+ case FilteringContent:
+ {
+ if ( !m_fContents || 0 == m_ulUnicodeBufferLen )
+ {
+ *pcwcBuffer = 0;
+ return FILTER_E_NO_MORE_TEXT;
+ }
+ // Copy UNICODE characters in chunk buffer to output UNICODE buffer
+ ULONG ulToCopy = min( *pcwcBuffer, m_ulUnicodeBufferLen - m_ulUnicodeCharsRead );
+ ZeroMemory(awcBuffer, sizeof(awcBuffer));
+ wmemcpy( awcBuffer, m_pwsBuffer.c_str() + m_ulUnicodeCharsRead, ulToCopy );
+ m_ulUnicodeCharsRead += ulToCopy;
+ *pcwcBuffer = ulToCopy;
+ if ( m_ulUnicodeBufferLen == m_ulUnicodeCharsRead )
+ {
+ m_ulUnicodeCharsRead = 0;
+ m_ulUnicodeBufferLen = 0;
+ return FILTER_S_LAST_TEXT;
+ }
+ return S_OK;
+ }
+ default:
+ return E_FAIL;
+ }
+}
+//M-------------------------------------------------------------------------
+//
+// Method: GetMetaInfoNameFromPropertyId
+//
+// Summary: helper function to convert PropertyID into respective
+// MetaInfo names.
+//
+// Arguments: ulPropID
+// [in] property ID
+//
+// Returns: corresponding metainfo names.
+//
+//--------------------------------------------------------------------------
+
+::std::wstring GetMetaInfoNameFromPropertyId( ULONG ulPropID )
+{
+ switch ( ulPropID )
+ {
+ case PIDSI_AUTHOR: return META_INFO_AUTHOR;
+ case PIDSI_TITLE: return META_INFO_TITLE;
+ case PIDSI_SUBJECT: return META_INFO_SUBJECT;
+ case PIDSI_KEYWORDS: return META_INFO_KEYWORDS;
+ case PIDSI_COMMENTS: return META_INFO_DESCRIPTION;
+ default: return EMPTY_STRING;
+ }
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::GetValue (IFilter::GetValue)
+//
+// Summary: Retrieves properites for index
+//
+// Arguments: ppPropValue
+// [out] Address that receives pointer to property value
+//
+// Returns: FILTER_E_NO_VALUES
+// Always
+// FILTER_E_NO_MORE_VALUES
+// (not implemented)
+//
+//--------------------------------------------------------------------------
+
+SCODE STDMETHODCALLTYPE COooFilter::GetValue(PROPVARIANT ** ppPropValue)
+{
+ if (m_eState == FilteringContent)
+ return FILTER_E_NO_VALUES;
+ else if (m_eState == FilteringProperty)
+ {
+ if ( m_cAttributes == 0 || ( m_ulCurrentPropertyNum == m_ulPropertyNum ) )
+ return FILTER_E_NO_MORE_VALUES;
+ PROPVARIANT *pPropVar = (PROPVARIANT *) CoTaskMemAlloc( sizeof (PROPVARIANT) );
+ if ( pPropVar == 0 )
+ return E_OUTOFMEMORY;
+ ::std::wstring wsTagName= GetMetaInfoNameFromPropertyId( m_pAttributes[m_ulCurrentPropertyNum].GetPropertyPropid() );
+ if ( wsTagName == EMPTY_STRING )
+ return FILTER_E_NO_VALUES;
+ ::std::wstring wsTagData = m_pMetaInfoReader->getTagData(wsTagName);
+ pPropVar->vt = VT_LPWSTR;
+ size_t cw = wsTagData.length() + 1; // reserve one for the '\0'
+ pPropVar->pwszVal = static_cast<WCHAR*>( CoTaskMemAlloc(cw*sizeof(WCHAR)) );
+ if (pPropVar->pwszVal == 0)
+ {
+ CoTaskMemFree(pPropVar);
+ return E_OUTOFMEMORY;
+ }
+ wmemcpy(pPropVar->pwszVal, wsTagData.c_str(), cw);
+ *ppPropValue = pPropVar;
+ m_ulCurrentPropertyNum = m_ulPropertyNum;
+ return S_OK;
+ }
+ else
+ return E_FAIL;
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::BindRegion (IFilter::BindRegion)
+//
+// Summary: Creates moniker or other interface for indicated text
+//
+// Arguments: origPos
+// [in] Description of text location and extent
+// riid
+// [in] Reference IID of specified interface
+// ppunk
+// [out] Address that receives requested interface pointer
+//
+// Returns: E_NOTIMPL
+// Always
+// FILTER_W_REGION_CLIPPED
+// (not implemented)
+//
+//--------------------------------------------------------------------------
+
+SCODE STDMETHODCALLTYPE COooFilter::BindRegion(
+ FILTERREGION /*origPos*/,
+ REFIID /*riid*/,
+ void ** /*ppunk*/)
+{
+ // BindRegion is currently reserved for future use
+ return E_NOTIMPL;
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::GetClassID (IPersist::GetClassID)
+//
+// Summary: Retrieves the class id of the filter class
+//
+// Arguments: pClassID
+// [out] Pointer to the class ID of the filter
+//
+// Returns: S_OK
+// Always
+// E_FAIL
+// (not implemented)
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilter::GetClassID(CLSID * pClassID)
+{
+ *pClassID = CLSID_COooFilter;
+ return S_OK;
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::IsDirty (IPersistFile::IsDirty)
+//
+// Summary: Checks whether file has changed since last save
+//
+// Arguments: void
+//
+// Returns: S_FALSE
+// Always
+// S_OK
+// (not implemented)
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilter::IsDirty()
+{
+ // File is opened read-only and never changes
+ return S_FALSE;
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::Load (IPersistFile::Load)
+//
+// Summary: Opens and initializes the specified file
+//
+// Arguments: pszFileName
+// [in] Pointer to zero-terminated string
+// of absolute path of file to open
+// dwMode
+// [in] Access mode to open the file
+//
+// Returns: S_OK
+// File was successfully loaded
+// E_OUTOFMEMORY
+// File could not be loaded due to insufficient memory
+// E_FAIL
+// (not implemented)
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilter::Load(LPCWSTR pszFileName, DWORD /*dwMode*/)
+{
+ // Load just sets the filename for GetChunk to read and ignores the mode
+ m_pwszFileName = pszFileName;
+ // Open the file previously specified in call to IPersistFile::Load and get content.
+ try
+ {
+ if (m_pMetaInfoReader)
+ delete m_pMetaInfoReader;
+ m_pMetaInfoReader = new CMetaInfoReader(WStringToString(m_pwszFileName));
+
+ if (m_pContentReader)
+ delete m_pContentReader;
+ m_pContentReader = new CContentReader(WStringToString(m_pwszFileName), m_pMetaInfoReader->getDefaultLocale());
+ }
+ catch (const std::exception&)
+ {
+ return E_FAIL;
+ }
+ return S_OK;
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::Save (IPersistFile::Save)
+//
+// Summary: Saves a copy of the current file being filtered
+//
+// Arguments: pszFileName
+// [in] Pointer to zero-terminated string of
+// absolute path of where to save file
+// fRemember
+// [in] Whether the saved copy is made the current file
+//
+// Returns: E_FAIL
+// Always
+// S_OK
+// (not implemented)
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilter::Save(LPCWSTR /*pszFileName*/, BOOL /*fRemember*/)
+{
+ // File is opened read-only; saving it is an error
+ return E_FAIL;
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::SaveCompleted (IPersistFile::SaveCompleted)
+//
+// Summary: Determines whether a file save is completed
+//
+// Arguments: pszFileName
+// [in] Pointer to zero-terminated string of
+// absolute path where file was previously saved
+//
+// Returns: S_OK
+// Always
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilter::SaveCompleted(LPCWSTR /*pszFileName*/)
+{
+ // File is opened read-only, so "save" is always finished
+ return S_OK;
+}
+
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::Load (IPersistStream::Load)
+//
+// Summary: Initializes an object from the stream where it was previously saved
+//
+// Arguments: pStm
+// [in] Pointer to stream from which object should be loaded
+//
+//
+// Returns: S_OK
+// E_OUTOFMEMORY
+// E_FAIL
+//
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilter::Load(IStream *pStm)
+{
+ zlib_filefunc_def z_filefunc;
+
+ m_pStream = PrepareIStream( pStm, z_filefunc );
+
+ try
+ {
+ if (m_pMetaInfoReader)
+ delete m_pMetaInfoReader;
+ m_pMetaInfoReader = new CMetaInfoReader((void*)m_pStream, &z_filefunc);
+
+ if (m_pContentReader)
+ delete m_pContentReader;
+ m_pContentReader = new CContentReader((void*)m_pStream, m_pMetaInfoReader->getDefaultLocale(), &z_filefunc);
+ }
+ catch (const std::exception&)
+ {
+ return E_FAIL;
+ }
+ return S_OK;
+}
+
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::GetSizeMax (IPersistStream::GetSizeMax)
+//
+// Summary: Returns the size in bytes of the stream neede to save the object.
+//
+// Arguments: pcbSize
+// [out] Pointer to a 64 bit unsigned int indicating the size needed
+//
+// Returns: E_NOTIMPL
+//
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilter::GetSizeMax(ULARGE_INTEGER * /*pcbSize*/)
+{
+ //
+ return E_NOTIMPL;
+}
+
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::Save (IPersistStream::Save)
+//
+// Summary: Save object to specified stream
+//
+// Arguments: pStm
+// [in] Pointer to stream
+//
+// fClearDirty
+// [in] Indicates whether to clear dirty flag
+//
+// Returns: E_NOTIMPL
+//
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilter::Save(IStream * /*pStm*/, BOOL )
+{
+ //
+ return E_NOTIMPL;
+}
+
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilter::GetCurFile (IPersistFile::GetCurFile)
+//
+// Summary: Returns a copy of the current file name
+//
+// Arguments: ppszFileName
+// [out] Address to receive pointer to zero-terminated
+// string for absolute path to current file
+//
+// Returns: S_OK
+// A valid absolute path was successfully returned
+// S_FALSE
+// (not implemented)
+// E_OUTOFMEMORY
+// Operation failed due to insufficient memory
+// E_FAIL
+// Operation failed due to some reason
+// other than insufficient memory
+//
+//-------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilter::GetCurFile(LPWSTR * ppszFileName)
+{
+ if ( EMPTY_STRING == m_pwszFileName )
+ return E_FAIL;
+ else
+ *ppszFileName = (LPWSTR)m_pwszFileName.c_str();
+ return S_OK;
+}
+
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilterCF::COooFilterCF
+//
+// Summary: Class factory constructor
+//
+// Arguments: void
+//
+// Purpose: Manages global instance count
+//
+//--------------------------------------------------------------------------
+COooFilterCF::COooFilterCF() :
+ m_lRefs(1)
+{
+ InterlockedIncrement( &g_lInstances );
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilterCF::~COooFilterCF
+//
+// Summary: Class factory destructor
+//
+// Arguments: void
+//
+// Purpose: Manages global instance count
+//
+//--------------------------------------------------------------------------
+COooFilterCF::~COooFilterCF()
+{
+ InterlockedDecrement( &g_lInstances );
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilterCF::QueryInterface (IUnknown::QueryInterface)
+//
+// Summary: Queries for requested interface
+//
+// Arguments: riid
+// [in] Reference IID of requested interface
+// ppvObject
+// [out] Address that receives requested interface pointer
+//
+// Returns: S_OK
+// Interface is supported
+// E_NOINTERFACE
+// Interface is not supported
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilterCF::QueryInterface(REFIID riid, void ** ppvObject)
+{
+ IUnknown *pUnkTemp;
+
+ if ( IID_IClassFactory == riid )
+ pUnkTemp = (IUnknown *)(IClassFactory *)this;
+ else if ( IID_IUnknown == riid )
+ pUnkTemp = (IUnknown *)this;
+ else
+ {
+ *ppvObject = NULL;
+ return E_NOINTERFACE;
+ }
+ *ppvObject = (void *)pUnkTemp;
+ pUnkTemp->AddRef();
+ return S_OK;
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilterCF::AddRef (IUknown::AddRef)
+//
+// Summary: Increments interface refcount
+//
+// Arguments: void
+//
+// Returns: Value of incremented interface refcount
+//
+//-------------------------------------------------------------------------
+ULONG STDMETHODCALLTYPE COooFilterCF::AddRef()
+{
+ return InterlockedIncrement( &m_lRefs );
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilterCF::Release (IUnknown::Release)
+//
+// Summary: Decrements interface refcount, deleting if unreferenced
+//
+// Arguments: void
+//
+// Returns: Value of decremented refcount
+//
+//--------------------------------------------------------------------------
+ULONG STDMETHODCALLTYPE COooFilterCF::Release()
+{
+ ULONG ulTmp = InterlockedDecrement( &m_lRefs );
+
+ if ( 0 == ulTmp )
+ delete this;
+ return ulTmp;
+}
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilterCF::CreateInstance (IClassFactory::CreateInstance)
+//
+// Summary: Creates new OpenOffice.org filter object
+//
+// Arguments: pUnkOuter
+// [in] Pointer to IUnknown interface of aggregating object
+// riid
+// [in] Reference IID of requested interface
+// ppvObject
+// [out] Address that receives requested interface pointer
+//
+// Returns: S_OK
+// OpenOffice.org filter object was successfully created
+// CLASS_E_NOAGGREGATION
+// pUnkOuter parameter was non-NULL
+// E_NOINTERFACE
+// (not implemented)
+// E_OUTOFMEMORY
+// OpenOffice.org filter object could not be created
+// due to insufficient memory
+// E_UNEXPECTED
+// Unsuccessful due to an unexpected condition
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilterCF::CreateInstance(
+ IUnknown * pUnkOuter,
+ REFIID riid,
+ void * * ppvObject)
+{
+ COooFilter *pIUnk = 0;
+ if ( 0 != pUnkOuter )
+ return CLASS_E_NOAGGREGATION;
+ pIUnk = new COooFilter();
+ if ( 0 != pIUnk )
+ {
+ if ( SUCCEEDED( pIUnk->QueryInterface( riid , ppvObject ) ) )
+ {
+ // Release extra refcount from QueryInterface
+ pIUnk->Release();
+ }
+ else
+ {
+ delete pIUnk;
+ return E_UNEXPECTED;
+ }
+ }
+ else
+ return E_OUTOFMEMORY;
+ return S_OK;
+}
+
+//M-------------------------------------------------------------------------
+//
+// Method: COooFilterCF::LockServer (IClassFactory::LockServer)
+//
+// Summary: Forces/allows filter class to remain loaded/be unloaded
+//
+// Arguments: fLock
+// [in] TRUE to lock, FALSE to unlock
+//
+// Returns: S_OK
+// Always
+// E_FAIL
+// (not implemented)
+// E_OUTOFMEMORY
+// (not implemented)
+// E_UNEXPECTED
+// (not implemented)
+//
+//--------------------------------------------------------------------------
+SCODE STDMETHODCALLTYPE COooFilterCF::LockServer(BOOL fLock)
+{
+ if( fLock )
+ InterlockedIncrement( &g_lInstances );
+ else
+ InterlockedDecrement( &g_lInstances );
+ return S_OK;
+}
+//+-------------------------------------------------------------------------
+//
+// DLL: ooofilt.dll
+//
+// Summary: Implements Dynamic Link Library functions for OpenOffice.org filter
+//
+//--------------------------------------------------------------------------
+//F-------------------------------------------------------------------------
+//
+// Function: DllMain
+//
+// Summary: Called from C-Runtime on process/thread attach/detach
+//
+// Arguments: hInstance
+// [in] Handle to the DLL
+// fdwReason
+// [in] Reason for calling DLL entry point
+// lpReserve
+// [in] Details of DLL initialization and cleanup
+//
+// Returns: TRUE
+// Always
+//
+//--------------------------------------------------------------------------
+extern "C" BOOL WINAPI DllMain(
+ HINSTANCE hInstance,
+ DWORD fdwReason,
+ LPVOID /*lpvReserved*/
+)
+{
+ if ( DLL_PROCESS_ATTACH == fdwReason )
+ DisableThreadLibraryCalls( hInstance );
+ return TRUE;
+}
+//F-------------------------------------------------------------------------
+//
+// Function: DllGetClassObject
+//
+// Summary: Create OpenOffice.org filter class factory object
+//
+// Arguments: cid
+// [in] Class ID of class that class factory creates
+// iid
+// [in] Reference IID of requested class factory interface
+// ppvObj
+// [out] Address that receives requested interface pointer
+//
+// Returns: S_OK
+// Class factory object was created successfully
+// CLASS_E_CLASSNOTAVAILABLE
+// DLL does not support the requested class
+// E_INVALIDARG
+// (not implemented
+// E_OUTOFMEMORY
+// Insufficient memory to create the class factory object
+// E_UNEXPECTED
+// Unsuccessful due to an unexpected condition
+//
+//-------------------------------------------------------------------------
+extern "C" SCODE STDMETHODCALLTYPE DllGetClassObject(
+ REFCLSID cid,
+ REFIID iid,
+ void ** ppvObj
+)
+{
+ IUnknown *pResult = 0;
+
+ if ( CLSID_COooFilter == cid )
+ pResult = (IUnknown *) new COooFilterCF;
+ else
+ return CLASS_E_CLASSNOTAVAILABLE;
+ if ( 0 != pResult )
+ {
+ if( SUCCEEDED( pResult->QueryInterface( iid, ppvObj ) ) )
+ // Release extra refcount from QueryInterface
+ pResult->Release();
+ else
+ {
+ delete pResult;
+ return E_UNEXPECTED;
+ }
+ }
+ else
+ return E_OUTOFMEMORY;
+ return S_OK;
+}
+//F-------------------------------------------------------------------------
+//
+// Function: DllCanUnloadNow
+//
+// Summary: Indicates whether it is possible to unload DLL
+//
+// Arguments: void
+//
+// Returns: S_OK
+// DLL can be unloaded now
+// S_FALSE
+// DLL must remain loaded
+//
+//--------------------------------------------------------------------------
+extern "C" SCODE STDMETHODCALLTYPE DllCanUnloadNow()
+{
+ if ( 0 >= g_lInstances )
+ return S_OK;
+ else
+ return S_FALSE;
+}
+//F-------------------------------------------------------------------------
+//
+// Function: DllRegisterServer
+// DllUnregisterServer
+//
+// Summary: Registers and unregisters DLL server
+//
+// Returns: DllRegisterServer
+// S_OK
+// Registration was successful
+// SELFREG_E_CLASS
+// Registration was unsuccessful
+// SELFREG_E_TYPELIB
+// (not implemented)
+// E_OUTOFMEMORY
+// (not implemented)
+// E_UNEXPECTED
+// (not implemented)
+// DllUnregisterServer
+// S_OK
+// Unregistration was successful
+// S_FALSE
+// Unregistration was successful, but other
+// entries still exist for the DLL's classes
+// SELFREG_E_CLASS
+// (not implemented)
+// SELFREG_E_TYPELIB
+// (not implemented)
+// E_OUTOFMEMORY
+// (not implemented)
+// E_UNEXPECTED
+// (not implemented)
+//
+//--------------------------------------------------------------------------
+
+
+//F-------------------------------------------------------------------------
+//
+// helper functions to register the Indexing Service.
+//
+//--------------------------------------------------------------------------
+
+namespace /* private */
+{
+ const char* GUID_PLACEHOLDER = "{GUID}";
+ const char* GUID_PERSIST_PLACEHOLDER = "{GUIDPERSIST}";
+ const char* EXTENSION_PLACEHOLDER = "{EXT}";
+ const char* FORWARDKEY_PLACEHOLDER = "{FWDKEY}";
+
+ const char* CLSID_GUID_INPROC_ENTRY = "CLSID\\{GUID}\\InProcServer32";
+ const char* CLSID_GUID_ENTRY = "CLSID\\{GUID}";
+ const char* CLSID_GUID_PERSIST_ADDIN_ENTRY = "CLSID\\{GUID}\\PersistentAddinsRegistered\\{GUIDPERSIST}";
+ const char* CLSID_PERSIST_ENTRY = "CLSID\\{GUID}\\PersistentHandler";
+ const char* EXT_PERSIST_ENTRY = "{EXT}\\PersistentHandler";
+
+ const char* INDEXING_FILTER_DLLSTOREGISTER = "SYSTEM\\CurrentControlSet\\Control\\ContentIndex";
+
+ //---------------------------
+ // "String Placeholder" ->
+ // "String Replacement"
+ //---------------------------
+
+ void SubstitutePlaceholder(std::string& String, const std::string& Placeholder, const std::string& Replacement)
+ {
+ std::string::size_type idx = String.find(Placeholder);
+ std::string::size_type len = Placeholder.length();
+
+ while (std::string::npos != idx)
+ {
+ String.replace(idx, len, Replacement);
+ idx = String.find(Placeholder);
+ }
+ }
+
+ //----------------------------------------------
+ // Make the registry entry and set Filter Handler
+ // HKCR\CLSID\{7BC0E710-5703-45be-A29D-5D46D8B39262} = OpenOffice.org Filter
+ // InProcServer32 (Default) = Path\ooofilt.dll
+ // ThreadingModel = Both
+ //----------------------------------------------
+
+ HRESULT RegisterFilterHandler(const char* FilePath, const CLSID& FilterGuid)
+ {
+ std::string ClsidEntry = CLSID_GUID_ENTRY;
+ SubstitutePlaceholder(ClsidEntry, GUID_PLACEHOLDER, ClsidToString(FilterGuid));
+
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry.c_str(), "", "OpenOffice.org Filter"))
+ return E_FAIL;
+
+ ClsidEntry = CLSID_GUID_INPROC_ENTRY;
+ SubstitutePlaceholder(ClsidEntry, GUID_PLACEHOLDER, ClsidToString(FilterGuid));
+
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry.c_str(), "", FilePath))
+ return E_FAIL;
+
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry.c_str(), "ThreadingModel", "Both"))
+ return E_FAIL;
+
+ return S_OK;
+ }
+
+ //----------------------------------------------
+ // Make the registry entry and set Persistent Handler
+ // HKCR\CLSID\{7BC0E713-5703-45be-A29D-5D46D8B39262} = OpenOffice.org Persistent Handler
+ // PersistentAddinsRegistered
+ // {89BCB740-6119-101A-BCB7-00DD010655AF} = {7BC0E710-5703-45be-A29D-5D46D8B39262}
+ //----------------------------------------------
+
+ HRESULT RegisterPersistentHandler(const CLSID& FilterGuid, const CLSID& PersistentGuid)
+ {
+ std::string ClsidEntry_Persist = CLSID_GUID_ENTRY;
+ SubstitutePlaceholder(ClsidEntry_Persist, GUID_PLACEHOLDER, ClsidToString(PersistentGuid));
+
+
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_Persist.c_str(), "", "OpenOffice.org Persistent Handler"))
+ return E_FAIL;
+
+ // Add missing entry
+ std::string ClsidEntry_Persist_Entry = CLSID_PERSIST_ENTRY;
+ SubstitutePlaceholder(ClsidEntry_Persist_Entry,
+ GUID_PLACEHOLDER,
+ ClsidToString(PersistentGuid));
+
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_Persist_Entry.c_str(), "", ClsidToString(PersistentGuid).c_str()))
+ return E_FAIL;
+
+ std::string ClsidEntry_Persist_Addin = CLSID_GUID_PERSIST_ADDIN_ENTRY;
+ SubstitutePlaceholder(ClsidEntry_Persist_Addin,
+ GUID_PLACEHOLDER,
+ ClsidToString(PersistentGuid));
+ SubstitutePlaceholder(ClsidEntry_Persist_Addin,
+ GUID_PERSIST_PLACEHOLDER,
+ ClsidToString(CLSID_PERSISTENT_HANDLER_ADDIN));
+
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_Persist_Addin.c_str(), "", ClsidToString(FilterGuid).c_str() ))
+ return E_FAIL;
+
+ return S_OK;
+ }
+
+ //---------------------------
+ // Unregister Filter Handler or persistent handler
+ //---------------------------
+
+ HRESULT UnregisterHandler(const CLSID& Guid)
+ {
+ std::string tmp = "CLSID\\";
+ tmp += ClsidToString(Guid);
+ return DeleteRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str()) ? S_OK : E_FAIL;
+ }
+
+ //---------------------------
+ // Register Indexing Service ext and class.
+ // HKCR\{EXT}\PersistentHandler = {7BC0E713-5703-45be-A29D-5D46D8B39262}
+ // HKCR\{GUID\PersistentHandler = {7BC0E713-5703-45be-A29D-5D46D8B39262}
+ //---------------------------
+
+ HRESULT RegisterSearchHandler(const char* ModuleFileName)
+ {
+ if (FAILED(RegisterFilterHandler(ModuleFileName, CLSID_FILTER_HANDLER)))
+ return E_FAIL;
+
+ if (FAILED(RegisterPersistentHandler(CLSID_FILTER_HANDLER, CLSID_PERSISTENT_HANDLER )))
+ return E_FAIL;
+
+ std::string sExtPersistEntry;
+
+ for(size_t i = 0; i < OOFileExtensionTableSize; i++)
+ {
+ // first, register extension.
+ sExtPersistEntry = EXT_PERSIST_ENTRY;
+ SubstitutePlaceholder(sExtPersistEntry, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT,
+ sExtPersistEntry.c_str(),
+ "",
+ ClsidToString(CLSID_PERSISTENT_HANDLER).c_str()))
+ return E_FAIL;
+
+ // second, register class.
+ char extClassName[MAX_PATH];
+ if (QueryRegistryKey(HKEY_CLASSES_ROOT, OOFileExtensionTable[i].ExtensionAnsi, "", extClassName,MAX_PATH))
+ {
+ ::std::string extCLSIDName( extClassName );
+ extCLSIDName += "\\CLSID";
+ char extCLSID[MAX_PATH];
+
+ if (QueryRegistryKey( HKEY_CLASSES_ROOT, extCLSIDName.c_str(), "", extCLSID, MAX_PATH))
+ {
+ std::string ClsidEntry_CLSID_Persist = CLSID_PERSIST_ENTRY;
+ SubstitutePlaceholder(ClsidEntry_CLSID_Persist,
+ GUID_PLACEHOLDER,
+ extCLSID);
+
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT,
+ ClsidEntry_CLSID_Persist.c_str(),
+ "",
+ ClsidToString(CLSID_PERSISTENT_HANDLER).c_str() ))
+ return E_FAIL;
+ }
+ }
+ }
+
+ return S_OK;
+ }
+
+ // Register Indexing Service ext and class.
+ HRESULT UnregisterSearchHandler()
+ {
+ std::string sExtPersistEntry;
+
+ for (size_t i = 0; i < OOFileExtensionTableSize; i++)
+ {
+ // first, unregister extension
+ sExtPersistEntry = EXT_PERSIST_ENTRY;
+ SubstitutePlaceholder(sExtPersistEntry, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+ DeleteRegistryKey(HKEY_CLASSES_ROOT, sExtPersistEntry.c_str());
+
+ // second, unregister class
+ char extClassName[MAX_PATH];
+ if (QueryRegistryKey(HKEY_CLASSES_ROOT, OOFileExtensionTable[i].ExtensionAnsi, "", extClassName,MAX_PATH))
+ {
+ ::std::string extCLSIDName( extClassName );
+ extCLSIDName += "\\CLSID";
+ char extCLSID[MAX_PATH];
+
+ if (QueryRegistryKey( HKEY_CLASSES_ROOT, extCLSIDName.c_str(), "", extCLSID, MAX_PATH))
+ {
+ std::string ClsidEntry_CLSID_Persist = CLSID_PERSIST_ENTRY;
+ SubstitutePlaceholder(ClsidEntry_CLSID_Persist,
+ GUID_PLACEHOLDER,
+ extCLSID);
+
+ DeleteRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_CLSID_Persist.c_str());
+ }
+ }
+ }
+
+ return ((UnregisterHandler(CLSID_FILTER_HANDLER)==S_OK) && (UnregisterHandler(CLSID_PERSISTENT_HANDLER)==S_OK))?S_OK:E_FAIL;
+ }
+
+ //---------------------------
+ // add or remove an entry to DllsToRegister entry of Indexing
+ // Filter to let Indexing Service register our filter automatically
+ // each time.
+ //---------------------------
+ HRESULT AddOrRemoveDllsToRegisterList( const ::std::string & DllPath, bool isAdd )
+ {
+ char DllsToRegisterList[4096];
+ if (QueryRegistryKey(HKEY_LOCAL_MACHINE,
+ INDEXING_FILTER_DLLSTOREGISTER,
+ "DLLsToRegister",
+ DllsToRegisterList,
+ 4096))
+ {
+ char * pChar = DllsToRegisterList;
+ for ( ; *pChar != '\0' || *(pChar +1) != '\0'; pChar++)
+ if ( *pChar == '\0')
+ *pChar = ';';
+ *pChar = ';';
+ *(pChar+1) = '\0';
+
+ ::std::string DllList(DllsToRegisterList);
+ if ( ( isAdd )&&( DllList.find( DllPath ) == ::std::string::npos ) )
+ DllList.append( DllPath );
+ else if ( ( !isAdd )&&( DllList.find( DllPath ) != ::std::string::npos ) )
+ DllList.erase( DllList.find( DllPath )-1, DllPath.length()+1 );
+ else
+ return S_OK;
+
+ pChar = DllsToRegisterList;
+ for ( size_t nChar = 0; nChar < DllList.length(); pChar++,nChar++)
+ {
+ if ( DllList[nChar] == ';')
+ *pChar = '\0';
+ else
+ *pChar = DllList[nChar];
+ }
+ *pChar = *( pChar+1 ) ='\0';
+
+ HKEY hSubKey;
+ int rc = RegCreateKeyExA(HKEY_LOCAL_MACHINE,
+ INDEXING_FILTER_DLLSTOREGISTER,
+ 0,
+ "",
+ REG_OPTION_NON_VOLATILE,
+ KEY_WRITE,
+ 0,
+ &hSubKey,
+ 0);
+
+ if (ERROR_SUCCESS == rc)
+ {
+ rc = RegSetValueExA( hSubKey,
+ "DLLsToRegister",
+ 0,
+ REG_MULTI_SZ,
+ reinterpret_cast<const BYTE*>(DllsToRegisterList),
+ DllList.length() + 2);
+
+ RegCloseKey(hSubKey);
+ }
+
+ return (ERROR_SUCCESS == rc)?S_OK:E_FAIL;
+ }
+
+ return S_OK;
+ }
+
+} // namespace /* private */
+
+STDAPI DllRegisterServer()
+{
+ /*
+ TCHAR ModuleFileName[MAX_PATH];
+
+ GetModuleFileName(
+ GetModuleHandle(MODULE_NAME_FILTER),
+ ModuleFileName,
+ sizeof(ModuleFileName));
+
+ HRESULT hr = S_OK;
+
+
+// register search handler
+#ifdef UNICODE
+ if (FAILED(RegisterSearchHandler(WStringToString(ModuleFileName).c_str())))
+ hr = E_FAIL;
+ if (FAILED(AddOrRemoveDllsToRegisterList(WStringToString(ModuleFileName).c_str(), true)))
+ hr = E_FAIL;
+#else
+ if (FAILED(RegisterSearchHandler(ModuleFileName)))
+ hr = E_FAIL;
+ if (FAILED(AddOrRemoveDllsToRegisterList(ModuleFileName, true)))
+ hr = E_FAIL;
+#endif
+
+
+ return hr;
+ */
+ return S_OK;
+}
+
+//---------------------------
+//
+//---------------------------
+
+STDAPI DllUnregisterServer()
+{
+ /*
+ TCHAR ModuleFileName[MAX_PATH];
+
+ GetModuleFileName(
+ GetModuleHandle(MODULE_NAME_FILTER),
+ ModuleFileName,
+ sizeof(ModuleFileName));
+
+ HRESULT hr = S_OK;
+
+ // unregister search handler
+ if (FAILED(UnregisterSearchHandler()))
+ hr = E_FAIL;
+
+#ifdef UNICODE
+ if (FAILED(AddOrRemoveDllsToRegisterList(WStringToString(ModuleFileName).c_str(),false)))
+ hr = E_FAIL;
+#else
+ if (FAILED(AddOrRemoveDllsToRegisterList(ModuleFileName, false)))
+ hr = E_FAIL;
+#endif
+
+ return hr;
+ */
+ return S_OK;
+}
diff --git a/shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx b/shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx
new file mode 100755
index 000000000000..b68863523b28
--- /dev/null
+++ b/shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx
@@ -0,0 +1,218 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "internal/types.hxx"
+
+//+-------------------------------------------------------------------------
+//
+// Contents: OpenOffice.org filter declarations
+//
+// Platform: Windows 2000, Windows XP
+//
+//--------------------------------------------------------------------------
+
+#pragma once
+
+//+-------------------------------------------------------------------------
+//
+// forward declaration
+//
+//--------------------------------------------------------------------------
+class CContentReader;
+class CMetaInfoReader;
+class CFullPropSpec;
+
+//+-------------------------------------------------------------------------
+//
+// Global definitions
+//
+//--------------------------------------------------------------------------
+
+long g_lInstances = 0; // Global count of COooFilter and COooFilterCF instances
+GUID const guidStorage = PSGUID_STORAGE; // GUID for storage property set
+
+//C-------------------------------------------------------------------------
+//
+// Class: COooFilter
+//
+// Purpose: Implements interfaces of OpenOffice.org filter
+//
+//--------------------------------------------------------------------------
+
+// OooFilter Class ID
+// {7BC0E710-5703-45be-A29D-5D46D8B39262}
+GUID const CLSID_COooFilter =
+{
+ 0x7bc0e710,
+ 0x5703,
+ 0x45be,
+ { 0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62 }
+};
+
+// OpenOffice.org Persistent Handler Class ID
+// {7BC0E713-5703-45be-A29D-5D46D8B39262}
+const CLSID CLSID_PERSISTENT_HANDLER =
+{0x7bc0e713, 0x5703, 0x45be, {0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62}};
+
+// OpenOffice.org Persistent Handler Addin Registered Class ID
+// {89BCB740-6119-101A-BCB7-00DD010655AF}
+const CLSID CLSID_PERSISTENT_HANDLER_ADDIN =
+{0x89bcb740, 0x6119, 0x101a, {0xbc, 0xb7, 0x00, 0xdd, 0x01, 0x06, 0x55, 0xaf}};
+
+// OpenOffice.org Filter Handler Class ID
+// {7BC0E710-5703-45be-A29D-5D46D8B39262}
+const CLSID CLSID_FILTER_HANDLER =
+{0x7bc0e710, 0x5703, 0x45be, {0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62}};
+
+enum FilterState
+{
+ FilteringContent, // Filtering the content property
+ FilteringProperty // Filtering the pseudo property
+};
+class COooFilter : public IFilter, public IPersistFile, public IPersistStream
+{
+public:
+ // From IUnknown
+ virtual SCODE STDMETHODCALLTYPE QueryInterface(
+ REFIID riid,
+ void ** ppvObject);
+ virtual ULONG STDMETHODCALLTYPE AddRef();
+ virtual ULONG STDMETHODCALLTYPE Release();
+
+ // From IFilter
+ virtual SCODE STDMETHODCALLTYPE Init(
+ ULONG grfFlags,
+ ULONG cAttributes,
+ FULLPROPSPEC const * aAttributes,
+ ULONG * pFlags);
+ virtual SCODE STDMETHODCALLTYPE GetChunk(
+ STAT_CHUNK * pStat);
+ virtual SCODE STDMETHODCALLTYPE GetText(
+ ULONG * pcwcBuffer,
+ WCHAR * awcBuffer);
+
+ virtual SCODE STDMETHODCALLTYPE GetValue(
+ PROPVARIANT ** ppPropValue);
+
+ virtual SCODE STDMETHODCALLTYPE BindRegion(
+ FILTERREGION origPos,
+ REFIID riid,
+ void ** ppunk);
+
+ // From IPersistFile
+ virtual SCODE STDMETHODCALLTYPE GetClassID(
+ CLSID * pClassID);
+ virtual SCODE STDMETHODCALLTYPE IsDirty();
+ virtual SCODE STDMETHODCALLTYPE Load(
+ LPCWSTR pszFileName,
+ DWORD dwMode);
+ virtual SCODE STDMETHODCALLTYPE Save(
+ LPCWSTR pszFileName,
+ BOOL fRemember);
+
+ virtual SCODE STDMETHODCALLTYPE SaveCompleted(
+ LPCWSTR pszFileName);
+
+ virtual SCODE STDMETHODCALLTYPE GetCurFile(
+ LPWSTR * ppszFileName);
+
+ // From IPersistStream
+ virtual SCODE STDMETHODCALLTYPE Load(
+ IStream *pStm);
+
+ virtual SCODE STDMETHODCALLTYPE Save(
+ IStream *pStm,
+ BOOL fClearDirty);
+
+ virtual SCODE STDMETHODCALLTYPE GetSizeMax(
+ ULARGE_INTEGER *pcbSize);
+
+
+private:
+ friend class COooFilterCF;
+
+ COooFilter();
+ virtual ~COooFilter();
+
+ long m_lRefs; // Reference count
+ CContentReader * m_pContentReader; // A content reader that retrive document content.
+ CMetaInfoReader * m_pMetaInfoReader; // A metainfo reader that retrive document metainfo.
+ FilterState m_eState; // State of filtering
+ ::std::wstring m_pwszFileName; // Name of input file to filter
+ ULONG m_ulUnicodeBufferLen; // UNICODE Characters read from file to chunk buffer
+ ULONG m_ulUnicodeCharsRead; // UNICODE Characters read from chunk buffer
+ ULONG m_ulPropertyNum; // Number of properties that has been processed
+ ULONG m_ulCurrentPropertyNum; // Current Property that is processing;
+ ULONG m_ulChunkID; // Current chunk id
+ BOOL m_fContents; // TRUE if contents requested
+ BOOL m_fEof; // TRUE if end of file reached
+ ::std::wstring m_pwsBuffer; // Buffer to save UNICODE content from ChunkBuffer.
+ ULONG m_ChunkPosition; // Chunk pointer to specify the current Chunk;
+ ULONG m_cAttributes; // Count of attributes
+ CFullPropSpec * m_pAttributes; // Attributes to filter
+ IStream * m_pStream;
+
+};
+
+//C-------------------------------------------------------------------------
+//
+// Class: COooFilterCF
+//
+// Purpose: Implements class factory for OpenOffice.org filter
+//
+//--------------------------------------------------------------------------
+
+class COooFilterCF : public IClassFactory
+{
+public:
+ // From IUnknown
+ virtual SCODE STDMETHODCALLTYPE QueryInterface(
+ REFIID riid,
+ void ** ppvObject);
+
+ virtual ULONG STDMETHODCALLTYPE AddRef();
+ virtual ULONG STDMETHODCALLTYPE Release();
+
+ // From IClassFactory
+ virtual SCODE STDMETHODCALLTYPE CreateInstance(
+ IUnknown * pUnkOuter,
+ REFIID riid, void ** ppvObject);
+
+ virtual SCODE STDMETHODCALLTYPE LockServer(
+ BOOL fLock);
+
+private:
+ friend SCODE STDMETHODCALLTYPE DllGetClassObject(
+ REFCLSID cid,
+ REFIID iid,
+ void ** ppvObj);
+
+ COooFilterCF();
+ virtual ~COooFilterCF();
+
+ long m_lRefs; // Reference count
+};
diff --git a/shell/source/win32/shlxthandler/ooofilt/propspec.cxx b/shell/source/win32/shlxthandler/ooofilt/propspec.cxx
new file mode 100644
index 000000000000..fd7a24f2711a
--- /dev/null
+++ b/shell/source/win32/shlxthandler/ooofilt/propspec.cxx
@@ -0,0 +1,238 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+//+-------------------------------------------------------------------------
+//
+// File: propspec.cxx
+//
+// Contents: C++ wrappers for FULLPROPSPEC
+//
+//--------------------------------------------------------------------------
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#ifdef _MSC_VER
+#pragma warning(disable: 4512)
+#endif
+#include <filter.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include "propspec.hxx"
+
+//GUID CLSID_Storage = PSGUID_STORAGE;
+//
+//
+//refer to ms-help://MS.VSCC/MS.MSDNVS.2052/com/stgasstg_7agk.htm
+//FMTID_SummaryInformation
+//
+//GUID CLSID_SummaryInforation = {
+// 0xF29F85E0,
+// 0x4FF9,
+// 0x1068,
+// { 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 }
+//};
+//+-------------------------------------------------------------------------
+//
+// Member: CFullPropSpec::CFullPropSpec, public
+//
+// Synopsis: Default constructor
+//
+// Effects: Defines property with null guid and propid 0
+//
+//--------------------------------------------------------------------------
+
+CFullPropSpec::CFullPropSpec()
+{
+ memset( &_guidPropSet, 0, sizeof( _guidPropSet ) );
+ _psProperty.ulKind = PRSPEC_PROPID;
+ _psProperty.propid = 0;
+}
+//+-------------------------------------------------------------------------
+//
+// Member: CFullPropSpec::CFullPropSpec, public
+//
+// Synopsis: Construct propid based propspec
+//
+// Arguments: [guidPropSet] -- Property set
+// [pidProperty] -- Property
+//
+//--------------------------------------------------------------------------
+CFullPropSpec::CFullPropSpec( GUID const & guidPropSet, PROPID pidProperty ) :
+ _guidPropSet( guidPropSet )
+{
+ _psProperty.ulKind = PRSPEC_PROPID;
+ _psProperty.propid = pidProperty;
+}
+//+-------------------------------------------------------------------------
+//
+// Member: CFullPropSpec::CFullPropSpec, public
+//
+// Synopsis: Construct name based propspec
+//
+// Arguments: [guidPropSet] -- Property set
+// [wcsProperty] -- Property
+//
+//--------------------------------------------------------------------------
+CFullPropSpec::CFullPropSpec( GUID const & guidPropSet,
+ WCHAR const * wcsProperty ) :
+ _guidPropSet( guidPropSet )
+{
+ _psProperty.ulKind = PRSPEC_PROPID;
+ SetProperty( wcsProperty );
+}
+//+-------------------------------------------------------------------------
+//
+// Member: CFullPropSpec::CFullPropSpec, public
+//
+// Synopsis: Copy constructor
+//
+// Arguments: [src] -- Source property spec
+//
+//--------------------------------------------------------------------------
+CFullPropSpec::CFullPropSpec( CFullPropSpec const & src ) :
+ _guidPropSet( src._guidPropSet )
+{
+ _psProperty.ulKind = src._psProperty.ulKind;
+ if ( _psProperty.ulKind == PRSPEC_LPWSTR )
+ {
+ if ( src._psProperty.lpwstr )
+ {
+ _psProperty.ulKind = PRSPEC_PROPID;
+ SetProperty( src._psProperty.lpwstr );
+ }
+ else
+ _psProperty.lpwstr = 0;
+ }
+ else
+ {
+ _psProperty.propid = src._psProperty.propid;
+ }
+}
+inline void * operator new( size_t /*size*/, void * p )
+{
+ return( p );
+}
+//+-------------------------------------------------------------------------
+//
+// Member: CFullPropSpec::operator=, public
+//
+// Synopsis: Assignment operator
+//
+// Arguments: [Property] -- Source property
+//
+//--------------------------------------------------------------------------
+CFullPropSpec & CFullPropSpec::operator=( CFullPropSpec const & Property )
+{
+ // Clean up.
+ this->CFullPropSpec::~CFullPropSpec();
+
+#ifdef _MSC_VER
+#pragma warning( disable : 4291 ) // unmatched operator new
+#endif
+ new (this) CFullPropSpec( Property );
+#ifdef _MSC_VER
+#pragma warning( default : 4291 )
+#endif
+ return *this;
+}
+CFullPropSpec::~CFullPropSpec()
+{
+ if ( _psProperty.ulKind == PRSPEC_LPWSTR &&
+ _psProperty.lpwstr )
+ {
+ CoTaskMemFree( _psProperty.lpwstr );
+ }
+}
+void CFullPropSpec::SetProperty( PROPID pidProperty )
+{
+ if ( _psProperty.ulKind == PRSPEC_LPWSTR &&
+ 0 != _psProperty.lpwstr )
+ {
+ CoTaskMemFree( _psProperty.lpwstr );
+ }
+ _psProperty.ulKind = PRSPEC_PROPID;
+ _psProperty.propid = pidProperty;
+}
+BOOL CFullPropSpec::SetProperty( WCHAR const * wcsProperty )
+{
+ if ( _psProperty.ulKind == PRSPEC_LPWSTR &&
+ 0 != _psProperty.lpwstr )
+ {
+ CoTaskMemFree( _psProperty.lpwstr );
+ }
+ _psProperty.ulKind = PRSPEC_LPWSTR;
+ int len = (int) ( (wcslen( wcsProperty ) + 1) * sizeof( WCHAR ) );
+ _psProperty.lpwstr = (WCHAR *)CoTaskMemAlloc( len );
+ if ( 0 != _psProperty.lpwstr )
+ {
+ memcpy( _psProperty.lpwstr,
+ wcsProperty,
+ len );
+ return( TRUE );
+ }
+ else
+ {
+ _psProperty.lpwstr = 0;
+ return( FALSE );
+ }
+}
+int CFullPropSpec::operator==( CFullPropSpec const & prop ) const
+{
+ if ( memcmp( &prop._guidPropSet,
+ &_guidPropSet,
+ sizeof( _guidPropSet ) ) != 0 ||
+ prop._psProperty.ulKind != _psProperty.ulKind )
+ {
+ return( 0 );
+ }
+ switch( _psProperty.ulKind )
+ {
+ case PRSPEC_LPWSTR:
+ return( _wcsicmp( GetPropertyName(), prop.GetPropertyName() ) == 0 );
+ break;
+ case PRSPEC_PROPID:
+ return( GetPropertyPropid() == prop.GetPropertyPropid() );
+ break;
+ default:
+ return( 0 );
+ break;
+ }
+}
+int CFullPropSpec::operator!=( CFullPropSpec const & prop ) const
+{
+ if (*this == prop)
+ return( 0 );
+ else
+ return( 1 );
+}
+
diff --git a/shell/source/win32/shlxthandler/ooofilt/propspec.hxx b/shell/source/win32/shlxthandler/ooofilt/propspec.hxx
new file mode 100644
index 000000000000..ba4c34233d64
--- /dev/null
+++ b/shell/source/win32/shlxthandler/ooofilt/propspec.hxx
@@ -0,0 +1,159 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+//+-------------------------------------------------------------------------
+//
+// File: propspec.hxx
+//
+// Contents: C++ wrapper(s) for FULLPROPSPEC
+//
+//-------------------------------------------------------------------------
+#pragma once
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#include <ole2.h>
+#include <ntquery.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+//+-------------------------------------------------------------------------
+//
+// Declare: CLSID_SummaryInforation, GUID
+// CLSID_Storage, GUID
+//
+// Contents: Definitions of OpenOffice.org Document properties
+//
+//--------------------------------------------------------------------------
+
+//extern GUID CLSID_Storage;
+//
+//extern GUID CLSID_SummaryInformation;
+//const PID_TITLE = PIDSI_TITLE; // 2;
+//const PID_SUBJECT = PIDSI_SUBJECT; // 3;
+//const PID_AUTHOR = PIDSI_AUTHOR; // 4;
+//const PID_KEYWORDS = PIDSI_KEYWORDS; // 5;
+//const PID_COMMENTS = PIDSI_COMMENTS; //6;
+//const PID_REVNUMBER = PIDSI_REVNUMBER; //9;
+//const PID_WORDCOUNT = PIDSI_WORDCOUNT; //f;
+//+-------------------------------------------------------------------------
+//
+// Class: CFullPropertySpec
+//
+// Purpose: Describes full (PropertySet\Property) name of a property.
+//
+//--------------------------------------------------------------------------
+
+class CFullPropSpec
+{
+public:
+ CFullPropSpec();
+ CFullPropSpec( GUID const & guidPropSet, PROPID pidProperty );
+ CFullPropSpec( GUID const & guidPropSet, WCHAR const * wcsProperty );
+ // Validity check
+ inline BOOL IsValid() const;
+
+ // Copy constructors/assignment/clone
+ CFullPropSpec( CFullPropSpec const & Property );
+ CFullPropSpec & operator=( CFullPropSpec const & Property );
+ ~CFullPropSpec();
+ // Memory allocation
+ void * operator new( size_t size );
+ inline void * operator new( size_t size, void * p );
+ void operator delete( void * p );
+ inline FULLPROPSPEC * CastToStruct();
+ inline FULLPROPSPEC const * CastToStruct() const;
+ // Comparators
+ int operator==( CFullPropSpec const & prop ) const;
+ int operator!=( CFullPropSpec const & prop ) const;
+ // Member variable access
+ inline void SetPropSet( GUID const & guidPropSet );
+ inline GUID const & GetPropSet() const;
+
+ void SetProperty( PROPID pidProperty );
+ BOOL SetProperty( WCHAR const * wcsProperty );
+ inline WCHAR const * GetPropertyName() const;
+ inline PROPID GetPropertyPropid() const;
+ inline PROPSPEC GetPropSpec() const;
+ inline BOOL IsPropertyName() const;
+ inline BOOL IsPropertyPropid() const;
+private:
+ GUID _guidPropSet;
+ PROPSPEC _psProperty;
+};
+// Inline methods for CFullPropSpec
+inline void * CFullPropSpec::operator new( size_t size )
+{
+ void * p = CoTaskMemAlloc( size );
+ return( p );
+}
+inline void * CFullPropSpec::operator new( size_t /*size*/, void * p )
+{
+ return( p );
+}
+inline void CFullPropSpec::operator delete( void * p )
+{
+ if ( p )
+ CoTaskMemFree( p );
+}
+inline BOOL CFullPropSpec::IsValid() const
+{
+ return ( _psProperty.ulKind == PRSPEC_PROPID ||
+ 0 != _psProperty.lpwstr );
+}
+inline void CFullPropSpec::SetPropSet( GUID const & guidPropSet )
+{
+ _guidPropSet = guidPropSet;
+}
+inline GUID const & CFullPropSpec::GetPropSet() const
+{
+ return( _guidPropSet );
+}
+inline PROPSPEC CFullPropSpec::GetPropSpec() const
+{
+ return( _psProperty );
+}
+inline WCHAR const * CFullPropSpec::GetPropertyName() const
+{
+ return( _psProperty.lpwstr );
+}
+inline PROPID CFullPropSpec::GetPropertyPropid() const
+{
+ return( _psProperty.propid );
+}
+inline BOOL CFullPropSpec::IsPropertyName() const
+{
+ return( _psProperty.ulKind == PRSPEC_LPWSTR );
+}
+inline BOOL CFullPropSpec::IsPropertyPropid() const
+{
+ return( _psProperty.ulKind == PRSPEC_PROPID );
+}
+
+
+
+
diff --git a/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx b/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx
new file mode 100755
index 000000000000..e12f95a88e50
--- /dev/null
+++ b/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx
@@ -0,0 +1,181 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2010 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include <stdio.h>
+#include <objidl.h>
+
+/*#include <string.h>
+#include <filter.h>
+#include <filterr.h>
+#include <ntquery.h>
+#include "assert.h"
+#include "propspec.hxx"
+#ifdef __MINGW32__
+#include <algorithm>
+using ::std::min;
+#endif
+*/
+
+#include "internal/stream_helper.hxx"
+
+extern "C" {
+ voidpf ZCALLBACK cb_sopen OF((voidpf opaque, const char * filename, int mode));
+ uLong ZCALLBACK cb_sread OF((voidpf opaque, voidpf stream, void* vuf, uLong size));
+ uLong ZCALLBACK cb_swrite OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
+ long ZCALLBACK cb_stell OF((voidpf opaque, voidpf stream));
+ long ZCALLBACK cb_sseek OF((voidpf opaque, voidpf stream, uLong offset, int origin));
+ int ZCALLBACK cb_sclose OF((voidpf opaque, voidpf stream));
+ int ZCALLBACK cb_serror OF((voidpf opaque, voidpf stream));
+
+ void fill_stream_filefunc (zlib_filefunc_def* pzlib_filefunc_def);
+}
+
+//-----------------------------
+IStream* PrepareIStream( IStream* pStream, zlib_filefunc_def &zFileFunc )
+{
+ // These next few lines work around the "Seek pointer" bug found on Vista.
+ char cBuf[20];
+ unsigned long nCount;
+ HRESULT hr;
+ ULARGE_INTEGER nNewPosition;
+ LARGE_INTEGER nMove;
+ nMove.QuadPart = 0;
+ hr = pStream->Seek( nMove, STREAM_SEEK_SET, &nNewPosition );
+ hr = pStream->Read( cBuf, 20, &nCount );
+
+ fill_stream_filefunc( &zFileFunc );
+ zFileFunc.opaque = (void*)pStream;
+
+ return pStream;
+}
+
+extern "C" {
+
+ // IStream callback
+ voidpf ZCALLBACK cb_sopen (voidpf opaque, const char* /*filename*/, int /*mode*/) {
+ return opaque;
+ }
+
+ uLong ZCALLBACK cb_sread (voidpf /*opaque*/, voidpf stream, void* buf, uLong size) {
+ unsigned long newsize;
+ HRESULT hr;
+
+ hr = ((IStream *)stream)->Read (buf, size, &newsize);
+ if (hr == S_OK){
+ return (unsigned long)newsize;
+ }
+ else {
+ return (uLong)0;
+ }
+ }
+
+ long ZCALLBACK cb_sseek (voidpf /*opaque*/, voidpf stream, uLong offset, int origin) {
+ // IStream::Seek parameters
+ HRESULT hr;
+ LARGE_INTEGER Move;
+ DWORD dwOrigin;
+ Move.QuadPart = (__int64)offset;
+
+ switch (origin) {
+ case SEEK_CUR:
+ dwOrigin = STREAM_SEEK_CUR;
+ break;
+ case SEEK_END:
+ dwOrigin = STREAM_SEEK_END;
+ break;
+ case SEEK_SET:
+ dwOrigin = STREAM_SEEK_SET;
+ break;
+ default:
+ return -1;
+ }
+
+ hr = ((IStream*)stream)->Seek (Move, dwOrigin, NULL);
+ if (hr == S_OK){
+ return 0;
+ }
+ else {
+ return -1;
+ }
+ }
+
+ long ZCALLBACK cb_stell (voidpf /*opaque*/, voidpf stream) {
+ // IStream::Seek parameters
+ HRESULT hr;
+ LARGE_INTEGER Move;
+ ULARGE_INTEGER NewPosition;
+ Move.QuadPart = 0;
+ NewPosition.QuadPart = 0;
+
+ hr = ((IStream*)stream)->Seek (Move, STREAM_SEEK_CUR, &NewPosition);
+ if (hr == S_OK){
+ return (long) NewPosition.QuadPart;
+ }
+ else {
+ return -1;
+ }
+ }
+
+ int ZCALLBACK cb_sclose (voidpf /*opaque*/, voidpf /*stream*/) {
+ return 0;
+ }
+
+ int ZCALLBACK cb_serror (voidpf /*opaque*/, voidpf /*stream*/) {
+ return 0; //RJK - for now
+ }
+
+ uLong ZCALLBACK cb_swrite (voidpf /*opaque*/, voidpf stream, const void* buf, uLong size) {
+ HRESULT hr;
+ unsigned long writecount;
+ hr = ((IStream*)stream)->Write (buf, size, &writecount);
+ if (hr == S_OK)
+ return (unsigned int)writecount;
+ else
+ return (uLong)0;
+ }
+
+ void fill_stream_filefunc (zlib_filefunc_def* pzlib_filefunc_def) {
+ pzlib_filefunc_def->zopen_file = cb_sopen;
+ pzlib_filefunc_def->zread_file = cb_sread;
+ pzlib_filefunc_def->zwrite_file = cb_swrite;
+ pzlib_filefunc_def->ztell_file = cb_stell;
+ pzlib_filefunc_def->zseek_file = cb_sseek;
+ pzlib_filefunc_def->zclose_file = cb_sclose;
+ pzlib_filefunc_def->zerror_file = cb_serror;
+ }
+}
diff --git a/shell/source/win32/shlxthandler/prophdl/exports.dxp b/shell/source/win32/shlxthandler/prophdl/exports.dxp
new file mode 100755
index 000000000000..2ada8255f8f7
--- /dev/null
+++ b/shell/source/win32/shlxthandler/prophdl/exports.dxp
@@ -0,0 +1,2 @@
+DllGetClassObject PRIVATE
+DllCanUnloadNow PRIVATE \ No newline at end of file
diff --git a/shell/source/win32/shlxthandler/prophdl/makefile.mk b/shell/source/win32/shlxthandler/prophdl/makefile.mk
new file mode 100644
index 000000000000..dc6d0e159046
--- /dev/null
+++ b/shell/source/win32/shlxthandler/prophdl/makefile.mk
@@ -0,0 +1,142 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2010 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+PRJNAME=shell
+TARGET=propertyhdl
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+NO_DEFAULT_STL=YES
+USE_DEFFILE=TRUE
+.IF "$(BUILD_X64)"!=""
+USE_DEFFILE_X64=TRUE
+.ENDIF
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+UWINAPILIB =
+UWINAPILIB_X64 =
+
+CFLAGS+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820 -wd4100
+CDEFS+=-D_WIN32_IE=0x501
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=$(SLO)$/$(TARGET).obj\
+ $(SLO)$/stream_helper.obj
+
+SHL1TARGET=$(TARGET)
+
+.IF "$(COM)"=="GCC"
+SHL1STDLIBS=$(ZLIB3RDLIB) $(EXPAT3RDLIB) $(COMCTL32LIB)
+SHL1LIBS=
+.ELSE
+SHL1STDLIBS=
+SHL1LIBS=$(SOLARLIBDIR)$/zlib.lib\
+ $(SOLARLIBDIR)$/expat_xmlparse.lib\
+ $(SOLARLIBDIR)$/expat_xmltok.lib
+.ENDIF
+SHL1STDLIBS+=\
+ $(OLEAUT32LIB)\
+ $(ADVAPI32LIB)\
+ $(OLE32LIB)\
+ $(UUIDLIB)\
+ $(SHELL32LIB)\
+ $(KERNEL32LIB)\
+ $(GDI32LIB)\
+ $(GDIPLUSLIB)\
+ $(SHLWAPILIB)\
+ $(PROPSYSLIB)
+
+.IF "$(COM)"!="GCC"
+SHL1STDLIBS+=\
+ msvcprt.lib
+
+.IF "$(PRODUCT)"!="full"
+SHL1STDLIBS+=msvcrt.lib
+.ENDIF
+.ENDIF
+
+SHL1LIBS+=$(SLB)$/util.lib\
+ $(SLB)$/ooofilereader.lib
+
+SHL1DEPN=
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=exports.dxp
+
+# -------------------- x64 -----------------------
+.IF "$(BUILD_X64)"!=""
+CFLAGS_X64+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS_X64+=-D_WIN32_IE=0x501
+SLOFILES_X64=$(SLO_X64)$/$(TARGET).obj
+
+SLOFILES_X64= \
+ $(SLO_X64)$/propertyhdl.obj\
+ $(SLO_X64)$/stream_helper.obj\
+
+SHL1TARGET_X64=$(TARGET)
+SHL1LIBS_X64=$(SOLARLIBDIR_X64)$/zlib.lib\
+ $(SOLARLIBDIR_X64)$/expat_xmlparse.lib\
+ $(SOLARLIBDIR_X64)$/expat_xmltok.lib
+
+SHL1STDLIBS_X64+=\
+ $(OLEAUT32LIB_X64)\
+ $(ADVAPI32LIB_X64)\
+ $(OLE32LIB_X64)\
+ $(UUIDLIB_X64)\
+ $(SHELL32LIB_X64)\
+ $(KERNEL32LIB_X64)\
+ $(GDI32LIB_X64)\
+ $(USER32LIB_X64) \
+ $(GDIPLUSLIB_X64) \
+ $(MSVCRT_X64) \
+ $(MSVCPRT_X64) \
+ $(OLDNAMESLIB_X64)\
+ $(PROPSYSLIB_X64)
+
+SHL1LIBS_X64+=$(SLB_X64)$/util.lib\
+ $(SLB_X64)$/ooofilereader.lib
+SHL1OBJS_X64=$(SLOFILES_X64)
+SHL1DEF_X64=$(MISC_X64)$/$(SHL1TARGET).def
+
+DEF1NAME_X64=$(SHL1TARGET_X64)
+DEF1EXPORTFILE_X64=exports.dxp
+
+.ENDIF # "$(BUILD_X64)"!=""
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+.INCLUDE : tg_wntx64.mk
diff --git a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx
new file mode 100644
index 000000000000..3f495a7aa53d
--- /dev/null
+++ b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx
@@ -0,0 +1,463 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2010 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/global.hxx"
+#include "internal/PropertyHdl.hxx"
+#include "internal/fileextensions.hxx"
+#include "internal/metainforeader.hxx"
+#include "internal/utilities.hxx"
+#include "internal/config.hxx"
+
+#include <propkey.h>
+#include <propvarutil.h>
+
+#include <malloc.h>
+#include <strsafe.h>
+
+#include "internal/stream_helper.hxx"
+
+//---------------------------
+// Module global
+//---------------------------
+long g_DllRefCnt = 0;
+HINSTANCE g_hModule = NULL;
+
+//
+// Map of property keys to the locations of their value(s) in the .??? XML schema
+//
+struct PROPERTYMAP
+{
+ PROPERTYKEY key;
+ PCWSTR pszXPathParent;
+ PCWSTR pszValueNodeName;
+};
+
+PROPERTYMAP g_rgPROPERTYMAP[] =
+{
+ { PKEY_Title, L"OpenOffice.org", L"Title" },
+ { PKEY_Author, L"OpenOffice.org", L"Author" },
+ { PKEY_Subject, L"OpenOffice.org", L"Subject" },
+ { PKEY_Keywords, L"OpenOffice.org", L"Keyword" },
+ { PKEY_Comment, L"OpenOffice.org", L"Comments" },
+};
+
+size_t gPropertyMapTableSize = sizeof(g_rgPROPERTYMAP)/sizeof(g_rgPROPERTYMAP[0]);
+
+//----------------------------
+//
+//----------------------------
+
+CPropertyHdl::CPropertyHdl( long nRefCnt ) :
+ m_RefCnt( nRefCnt ),
+ m_pCache( NULL )
+{
+ OutputDebugStringFormat( "CPropertyHdl: CTOR\n" );
+ InterlockedIncrement( &g_DllRefCnt );
+}
+
+//----------------------------
+//
+//----------------------------
+
+CPropertyHdl::~CPropertyHdl()
+{
+ if ( m_pCache )
+ {
+ m_pCache->Release();
+ m_pCache = NULL;
+ }
+ InterlockedDecrement( &g_DllRefCnt );
+}
+
+//-----------------------------
+// IUnknown methods
+//-----------------------------
+HRESULT STDMETHODCALLTYPE CPropertyHdl::QueryInterface(REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ *ppvObject = 0;
+
+ if (IID_IUnknown == riid || IID_IPropertyStore == riid)
+ {
+ OutputDebugStringFormat( "CPropertyHdl: QueryInterface (IID_IPropertyStore)\n" );
+ IUnknown* pUnk = static_cast<IPropertyStore*>(this);
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+ else if (IID_IPropertyStoreCapabilities == riid)
+ {
+ OutputDebugStringFormat( "CPropertyHdl: QueryInterface (IID_IPropertyStoreCapabilities)\n" );
+ IUnknown* pUnk = static_cast<IPropertyStore*>(this);
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+ else if (IID_IInitializeWithStream == riid)
+ {
+ OutputDebugStringFormat( "CPropertyHdl: QueryInterface (IID_IInitializeWithStream)\n" );
+ IUnknown* pUnk = static_cast<IInitializeWithStream*>(this);
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+ OutputDebugStringFormat( "CPropertyHdl: QueryInterface (something different)\n" );
+
+ return E_NOINTERFACE;
+}
+
+//----------------------------
+ULONG STDMETHODCALLTYPE CPropertyHdl::AddRef( void )
+{
+ return InterlockedIncrement( &m_RefCnt );
+}
+
+//----------------------------
+ULONG STDMETHODCALLTYPE CPropertyHdl::Release( void )
+{
+ long refcnt = InterlockedDecrement( &m_RefCnt );
+
+ if ( 0 == m_RefCnt )
+ delete this;
+
+ return refcnt;
+}
+
+//-----------------------------
+// IPropertyStore
+//-----------------------------
+HRESULT STDMETHODCALLTYPE CPropertyHdl::GetCount( DWORD *pcProps )
+{
+ HRESULT hr = E_UNEXPECTED;
+ if ( m_pCache && pcProps )
+ {
+ hr = m_pCache->GetCount( pcProps );
+ }
+
+ return hr;
+}
+
+//-----------------------------
+HRESULT STDMETHODCALLTYPE CPropertyHdl::GetAt( DWORD iProp, PROPERTYKEY *pKey )
+{
+ HRESULT hr = E_UNEXPECTED;
+ if ( m_pCache )
+ {
+ hr = m_pCache->GetAt( iProp, pKey );
+ }
+
+ return hr;
+}
+
+//-----------------------------
+HRESULT STDMETHODCALLTYPE CPropertyHdl::GetValue( REFPROPERTYKEY key, PROPVARIANT *pPropVar )
+{
+ HRESULT hr = E_UNEXPECTED;
+ if ( m_pCache )
+ {
+ hr = m_pCache->GetValue( key, pPropVar );
+ }
+
+ return hr;
+}
+
+//-----------------------------
+HRESULT STDMETHODCALLTYPE CPropertyHdl::SetValue( REFPROPERTYKEY key, REFPROPVARIANT propVar )
+{
+ HRESULT hr = E_UNEXPECTED;
+ if ( m_pCache )
+ {
+ hr = STG_E_ACCESSDENIED;
+ }
+ return hr;
+}
+
+//-----------------------------
+HRESULT STDMETHODCALLTYPE CPropertyHdl::Commit()
+{
+ return S_OK;
+}
+
+//-----------------------------
+// IPropertyStore
+//-----------------------------
+HRESULT STDMETHODCALLTYPE CPropertyHdl::IsPropertyWritable( REFPROPERTYKEY key )
+{
+ // We start with read only properties only
+ return S_FALSE;
+}
+
+//-----------------------------
+// IInitializeWithStream
+//-----------------------------
+HRESULT STDMETHODCALLTYPE CPropertyHdl::Initialize( IStream *pStream, DWORD grfMode )
+{
+ if ( grfMode & STGM_READWRITE )
+ return STG_E_ACCESSDENIED;
+
+ if ( !m_pCache )
+ {
+#ifdef __MINGW32__
+ if ( FAILED( PSCreateMemoryPropertyStore( IID_IPropertyStoreCache, reinterpret_cast<void**>(&m_pCache) ) ) )
+#else
+ if ( FAILED( PSCreateMemoryPropertyStore( IID_PPV_ARGS( &m_pCache ) ) ) )
+#endif
+ OutputDebugStringFormat( "CPropertyHdl::Initialize: PSCreateMemoryPropertyStore failed" );
+
+ zlib_filefunc_def z_filefunc;
+ pStream = PrepareIStream( pStream, z_filefunc );
+
+ CMetaInfoReader *pMetaInfoReader = NULL;
+
+ try
+ {
+ pMetaInfoReader = new CMetaInfoReader( (void*)pStream, &z_filefunc );
+ }
+ catch (const std::exception& e)
+ {
+ OutputDebugStringFormat( "CPropertyHdl::Initialize: Caught exception [%s]", e.what() );
+ return E_FAIL;
+ }
+
+ LoadProperties( pMetaInfoReader );
+/*
+ // load extended properties and search content
+ _LoadExtendedProperties();
+ _LoadSearchContent();
+*/
+ }
+
+ return S_OK;
+}
+
+//-----------------------------
+void CPropertyHdl::LoadProperties( CMetaInfoReader *pMetaInfoReader )
+{
+ OutputDebugStringFormat( "CPropertyHdl: LoadProperties\n" );
+ PROPVARIANT propvarValues;
+
+ for ( UINT i = 0; i < (UINT)gPropertyMapTableSize; ++i )
+ {
+ PropVariantClear( &propvarValues );
+ HRESULT hr = GetItemData( pMetaInfoReader, i, &propvarValues);
+ if (hr == S_OK)
+ {
+ // coerce the value(s) to the appropriate type for the property key
+ hr = PSCoerceToCanonicalValue( g_rgPROPERTYMAP[i].key, &propvarValues );
+ if (SUCCEEDED(hr))
+ {
+ // cache the value(s) loaded
+ hr = m_pCache->SetValueAndState( g_rgPROPERTYMAP[i].key, &propvarValues, PSC_NORMAL );
+ }
+ }
+ }
+}
+
+//-----------------------------
+HRESULT CPropertyHdl::GetItemData( CMetaInfoReader *pMetaInfoReader, UINT nIndex, PROPVARIANT *pVarData )
+{
+ switch (nIndex) {
+ case 0: {
+ pVarData->vt = VT_BSTR;
+ pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_TITLE ).c_str() );
+ OutputDebugStringFormat( "CPropertyHdl::GetItemData: Title=%S.\n", pMetaInfoReader->getTagData( META_INFO_TITLE ).c_str() );
+ return S_OK;
+ }
+ case 1: {
+ pVarData->vt = VT_BSTR;
+ pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_AUTHOR ).c_str() );
+ OutputDebugStringFormat( "CPropertyHdl::GetItemData: Author=%S.\n", pMetaInfoReader->getTagData( META_INFO_AUTHOR ).c_str() );
+ return S_OK;
+ }
+ case 2: {
+ pVarData->vt = VT_BSTR;
+ pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_SUBJECT ).c_str() );
+ OutputDebugStringFormat( "CPropertyHdl::GetItemData: Subject=%S.\n", pMetaInfoReader->getTagData( META_INFO_SUBJECT ).c_str() );
+ return S_OK;
+ }
+ case 3: {
+ pVarData->vt = VT_BSTR;
+ pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_KEYWORDS ).c_str() );
+ OutputDebugStringFormat( "CPropertyHdl::GetItemData: Keywords=%S.\n", pMetaInfoReader->getTagData( META_INFO_KEYWORDS ).c_str() );
+ return S_OK;
+ }
+ case 4: {
+ pVarData->vt = VT_BSTR;
+ pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_DESCRIPTION ).c_str() );
+ OutputDebugStringFormat( "CPropertyHdl::GetItemData: Description=%S.\n", pMetaInfoReader->getTagData( META_INFO_DESCRIPTION ).c_str() );
+ return S_OK;
+ }
+ case 5: {
+ pVarData->vt = VT_BSTR;
+ pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagAttribute( META_INFO_DOCUMENT_STATISTIC, META_INFO_PAGES ).c_str() );
+ OutputDebugStringFormat( "CPropertyHdl::GetItemData: Pages=%S.\n", pMetaInfoReader->getTagAttribute( META_INFO_DOCUMENT_STATISTIC, META_INFO_PAGES ).c_str() );
+ return S_OK;
+ }
+ }
+
+ return S_FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// CClassFactory
+//-----------------------------------------------------------------------------
+
+long CClassFactory::s_ServerLocks = 0;
+
+//-----------------------------------------------------------------------------
+CClassFactory::CClassFactory( const CLSID& clsid ) :
+ m_RefCnt(1),
+ m_Clsid(clsid)
+{
+ InterlockedIncrement( &g_DllRefCnt );
+}
+
+//-----------------------------------------------------------------------------
+CClassFactory::~CClassFactory()
+{
+ InterlockedDecrement( &g_DllRefCnt );
+}
+
+//-----------------------------------------------------------------------------
+// IUnknown methods
+//-----------------------------------------------------------------------------
+HRESULT STDMETHODCALLTYPE CClassFactory::QueryInterface( REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject )
+{
+ *ppvObject = 0;
+
+ if ( IID_IUnknown == riid || IID_IClassFactory == riid )
+ {
+ IUnknown* pUnk = this;
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+
+ return E_NOINTERFACE;
+}
+
+//-----------------------------------------------------------------------------
+ULONG STDMETHODCALLTYPE CClassFactory::AddRef( void )
+{
+ return InterlockedIncrement( &m_RefCnt );
+}
+
+//-----------------------------------------------------------------------------
+ULONG STDMETHODCALLTYPE CClassFactory::Release( void )
+{
+ long refcnt = InterlockedDecrement( &m_RefCnt );
+
+ if (0 == refcnt)
+ delete this;
+
+ return refcnt;
+}
+
+//-----------------------------------------------------------------------------
+// IClassFactory methods
+//-----------------------------------------------------------------------------
+HRESULT STDMETHODCALLTYPE CClassFactory::CreateInstance(
+ IUnknown __RPC_FAR *pUnkOuter,
+ REFIID riid,
+ void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ if ( pUnkOuter != NULL )
+ return CLASS_E_NOAGGREGATION;
+
+ IUnknown* pUnk = 0;
+
+ if ( CLSID_PROPERTY_HANDLER == m_Clsid )
+ pUnk = static_cast<IPropertyStore*>( new CPropertyHdl() );
+
+ POST_CONDITION(pUnk != 0, "Could not create COM object");
+
+ if (0 == pUnk)
+ return E_OUTOFMEMORY;
+
+ HRESULT hr = pUnk->QueryInterface( riid, ppvObject );
+
+ // if QueryInterface failed the component will destroy itself
+ pUnk->Release();
+
+ return hr;
+}
+
+//-----------------------------------------------------------------------------
+HRESULT STDMETHODCALLTYPE CClassFactory::LockServer( BOOL fLock )
+{
+ if ( fLock )
+ InterlockedIncrement( &s_ServerLocks );
+ else
+ InterlockedDecrement( &s_ServerLocks );
+
+ return S_OK;
+}
+
+//-----------------------------------------------------------------------------
+bool CClassFactory::IsLocked()
+{
+ return ( s_ServerLocks > 0 );
+}
+
+//-----------------------------------------------------------------------------
+extern "C" STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv)
+{
+ OutputDebugStringFormat( "DllGetClassObject.\n" );
+ *ppv = 0;
+
+ if ( rclsid != CLSID_PROPERTY_HANDLER )
+ return CLASS_E_CLASSNOTAVAILABLE;
+
+ if ( (riid != IID_IUnknown) && (riid != IID_IClassFactory) )
+ return E_NOINTERFACE;
+
+ IUnknown* pUnk = new CClassFactory( rclsid );
+ if ( 0 == pUnk )
+ return E_OUTOFMEMORY;
+
+ *ppv = pUnk;
+ return S_OK;
+}
+
+//-----------------------------------------------------------------------------
+extern "C" STDAPI DllCanUnloadNow( void )
+{
+ OutputDebugStringFormat( "DllCanUnloadNow.\n" );
+ if (CClassFactory::IsLocked() || g_DllRefCnt > 0)
+ return S_FALSE;
+
+ return S_OK;
+}
+
+//-----------------------------------------------------------------------------
+BOOL WINAPI DllMain( HINSTANCE hInst, ULONG /*ul_reason_for_call*/, LPVOID /*lpReserved*/ )
+{
+ OutputDebugStringFormat( "DllMain.\n" );
+ g_hModule = hInst;
+ return TRUE;
+}
diff --git a/shell/source/win32/shlxthandler/propsheets/document_statistic.cxx b/shell/source/win32/shlxthandler/propsheets/document_statistic.cxx
new file mode 100644
index 000000000000..1e41f478b95b
--- /dev/null
+++ b/shell/source/win32/shlxthandler/propsheets/document_statistic.cxx
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#ifdef _MSC_VER
+#pragma warning (disable : 4786 4503)
+#endif
+#include "document_statistic.hxx"
+#include "internal/utilities.hxx"
+#include "internal/metainforeader.hxx"
+#include "internal/resource.h"
+#include "internal/fileextensions.hxx"
+#include "internal/config.hxx"
+#include "internal/iso8601_converter.hxx"
+
+//#####################################
+const bool READONLY = false;
+const bool WRITEABLE = true;
+
+//#####################################
+document_statistic_reader_ptr create_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor)
+{
+ File_Type_t file_type = get_file_type(document_name);
+
+ if (WRITER == file_type)
+ return document_statistic_reader_ptr(new writer_document_statistic_reader(document_name, meta_info_accessor));
+ else if (CALC == file_type)
+ return document_statistic_reader_ptr(new calc_document_statistic_reader(document_name, meta_info_accessor));
+ else
+ return document_statistic_reader_ptr(new draw_impress_math_document_statistic_reader(document_name, meta_info_accessor));
+}
+
+
+//#####################################
+document_statistic_reader::document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
+ document_name_(document_name),
+ meta_info_accessor_(meta_info_accessor)
+{}
+
+//#####################################
+document_statistic_reader::~document_statistic_reader()
+{}
+
+//#####################################
+void document_statistic_reader::read(statistic_group_list_t* group_list)
+{
+ group_list->clear();
+ fill_description_section(meta_info_accessor_, group_list);
+ fill_origin_section(meta_info_accessor_, group_list);
+}
+
+//#####################################
+std::string document_statistic_reader::get_document_name() const
+{
+ return document_name_;
+}
+
+//#####################################
+void document_statistic_reader::fill_origin_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
+{
+ statistic_item_list_t il;
+
+ il.push_back(statistic_item(GetResString(IDS_AUTHOR), meta_info_accessor->getTagData( META_INFO_AUTHOR ), READONLY));
+
+ il.push_back(statistic_item(GetResString(IDS_MODIFIED),
+ iso8601_date_to_local_date(meta_info_accessor->getTagData(META_INFO_MODIFIED )), READONLY));
+
+ il.push_back(statistic_item(GetResString(IDS_DOCUMENT_NUMBER), meta_info_accessor->getTagData( META_INFO_DOCUMENT_NUMBER ), READONLY));
+
+ il.push_back(statistic_item(GetResString(IDS_EDITING_TIME),
+ iso8601_duration_to_local_duration(meta_info_accessor->getTagData( META_INFO_EDITING_TIME )), READONLY));
+
+ group_list->push_back(statistic_group_t(GetResString(IDS_ORIGIN), il));
+}
+
+//#####################################
+writer_document_statistic_reader::writer_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
+ document_statistic_reader(document_name, meta_info_accessor)
+{}
+
+//#####################################
+void writer_document_statistic_reader::fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
+{
+ statistic_item_list_t il;
+
+ il.push_back(statistic_item(GetResString(IDS_TITLE), meta_info_accessor->getTagData( META_INFO_TITLE ), READONLY));
+ il.push_back(statistic_item(GetResString(IDS_COMMENTS), meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY));
+ il.push_back(statistic_item(GetResString(IDS_SUBJECT), meta_info_accessor->getTagData( META_INFO_SUBJECT ), READONLY));
+ il.push_back(statistic_item(GetResString(IDS_KEYWORDS), meta_info_accessor->getTagData(META_INFO_KEYWORDS ), READONLY));
+ il.push_back(statistic_item(GetResString(IDS_PAGES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PAGES) , READONLY));
+ il.push_back(statistic_item(GetResString(IDS_TABLES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_TABLES) , READONLY));
+ il.push_back(statistic_item(GetResString(IDS_GRAPHICS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_DRAWS) , READONLY));
+ il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY));
+ il.push_back(statistic_item(GetResString(IDS_PARAGRAPHS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PARAGRAPHS) , READONLY));
+ il.push_back(statistic_item(GetResString(IDS_WORDS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_WORDS) , READONLY));
+ il.push_back(statistic_item(GetResString(IDS_CHARACTERS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_CHARACTERS) , READONLY));
+
+ group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
+}
+
+//#######################################
+calc_document_statistic_reader::calc_document_statistic_reader(
+ const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
+ document_statistic_reader(document_name, meta_info_accessor)
+{}
+
+//#######################################
+void calc_document_statistic_reader::fill_description_section(
+ CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list)
+{
+ statistic_item_list_t il;
+
+ il.push_back(statistic_item(GetResString(IDS_TITLE), meta_info_accessor->getTagData( META_INFO_TITLE ), READONLY));
+ il.push_back(statistic_item(GetResString(IDS_COMMENTS), meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY));
+ il.push_back(statistic_item(GetResString(IDS_SUBJECT), meta_info_accessor->getTagData( META_INFO_SUBJECT ), READONLY));
+ il.push_back(statistic_item(GetResString(IDS_KEYWORDS), meta_info_accessor->getTagData(META_INFO_KEYWORDS ), READONLY));
+ il.push_back(statistic_item(GetResString(IDS_TABLES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_TABLES) , READONLY));
+ il.push_back(statistic_item(GetResString(IDS_CELLS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_CELLS) , READONLY));
+ il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY));
+
+ group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
+}
+
+//#######################################
+draw_impress_math_document_statistic_reader::draw_impress_math_document_statistic_reader(
+ const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
+ document_statistic_reader(document_name, meta_info_accessor)
+{}
+
+//#######################################
+void draw_impress_math_document_statistic_reader::fill_description_section(
+ CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
+{
+ statistic_item_list_t il;
+
+ il.push_back(statistic_item(GetResString(IDS_TITLE), meta_info_accessor->getTagData( META_INFO_TITLE ), READONLY));
+ il.push_back(statistic_item(GetResString(IDS_COMMENTS), meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY));
+ il.push_back(statistic_item(GetResString(IDS_SUBJECT), meta_info_accessor->getTagData( META_INFO_SUBJECT ), READONLY));
+ il.push_back(statistic_item(GetResString(IDS_KEYWORDS), meta_info_accessor->getTagData(META_INFO_KEYWORDS ), READONLY));
+ il.push_back(statistic_item(GetResString(IDS_PAGES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PAGES) , READONLY));
+ il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY));
+
+ group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
+}
diff --git a/shell/source/win32/shlxthandler/propsheets/document_statistic.hxx b/shell/source/win32/shlxthandler/propsheets/document_statistic.hxx
new file mode 100644
index 000000000000..0b3a3dd96c07
--- /dev/null
+++ b/shell/source/win32/shlxthandler/propsheets/document_statistic.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef DOCUMENT_STATISTIC_HXX_INCLUDED
+#define DOCUMENT_STATISTIC_HXX_INCLUDED
+
+#include <utility>
+#include <string>
+#include <vector>
+#include "internal/metainforeader.hxx"
+
+
+//------------------------------------
+//
+//------------------------------------
+
+struct statistic_item
+{
+ statistic_item();
+
+ statistic_item(
+ const std::wstring& title,
+ const std::wstring& value,
+ bool editable) :
+ title_(title),
+ value_(value),
+ editable_(editable)
+ {}
+
+ std::wstring title_;
+ std::wstring value_;
+ bool editable_;
+};
+
+//------------------------------------
+//
+//------------------------------------
+
+typedef std::vector<statistic_item> statistic_item_list_t;
+typedef std::pair<std::wstring, statistic_item_list_t> statistic_group_t;
+typedef std::vector<statistic_group_t> statistic_group_list_t;
+
+//------------------------------------
+//
+//------------------------------------
+
+class document_statistic_reader;
+typedef std::auto_ptr<document_statistic_reader> document_statistic_reader_ptr;
+
+document_statistic_reader_ptr create_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+
+//------------------------------------
+//
+//------------------------------------
+
+class document_statistic_reader
+{
+public:
+ virtual ~document_statistic_reader();
+
+ void read(statistic_group_list_t* group_list);
+
+ std::string get_document_name() const;
+
+protected:
+ document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+
+ virtual void fill_description_section(CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list) = 0;
+
+ virtual void fill_origin_section( CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list);
+
+private:
+ std::string document_name_;
+ CMetaInfoReader* meta_info_accessor_;
+
+ friend document_statistic_reader_ptr create_document_statistic_reader(
+ const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+};
+
+//------------------------------------
+//
+//------------------------------------
+
+class writer_document_statistic_reader : public document_statistic_reader
+{
+protected:
+ writer_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+
+ virtual void fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list);
+
+ friend document_statistic_reader_ptr create_document_statistic_reader(
+ const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+};
+
+//------------------------------------
+//
+//------------------------------------
+
+class calc_document_statistic_reader : public document_statistic_reader
+{
+protected:
+ calc_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+
+ virtual void fill_description_section( CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list);
+
+ friend document_statistic_reader_ptr create_document_statistic_reader(
+ const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+};
+
+//------------------------------------
+//
+//------------------------------------
+
+class draw_impress_math_document_statistic_reader : public document_statistic_reader
+{
+protected:
+ draw_impress_math_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+
+ virtual void fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list);
+
+ friend document_statistic_reader_ptr create_document_statistic_reader(
+ const std::string& document_name, CMetaInfoReader* meta_info_accessor);
+};
+
+#endif
diff --git a/shell/source/win32/shlxthandler/propsheets/listviewbuilder.cxx b/shell/source/win32/shlxthandler/propsheets/listviewbuilder.cxx
new file mode 100644
index 000000000000..5d3d365beb62
--- /dev/null
+++ b/shell/source/win32/shlxthandler/propsheets/listviewbuilder.cxx
@@ -0,0 +1,281 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#ifdef _MSC_VER
+#pragma warning (disable : 4786 4503)
+#endif
+
+//------------------------------------
+// include
+//------------------------------------
+#include "listviewbuilder.hxx"
+#include "document_statistic.hxx"
+#include "internal/utilities.hxx"
+#include "internal/config.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <commctrl.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <commctrl.h>
+#include <tchar.h>
+#include "internal/resource.h"
+
+//------------------------------------
+//
+//------------------------------------
+
+list_view_builder_ptr create_list_view_builder(
+ HWND hwnd_lv, const std::wstring& col1, const std::wstring& col2)
+{
+ if (is_windows_xp_or_above())
+ return list_view_builder_ptr(new winxp_list_view_builder(hwnd_lv, col1, col2));
+ else
+ return list_view_builder_ptr(new list_view_builder(hwnd_lv, col1, col2));
+}
+
+//------------------------------------
+//
+//------------------------------------
+
+list_view_builder::list_view_builder(
+ HWND hwnd_list_view,
+ const std::wstring& column1_title,
+ const std::wstring& column2_title) :
+ hwnd_list_view_(hwnd_list_view),
+ row_index_(-1),
+ column1_title_(column1_title),
+ column2_title_(column2_title)
+{
+}
+
+//------------------------------------
+//
+//------------------------------------
+
+list_view_builder::~list_view_builder()
+{
+}
+
+//------------------------------------
+//
+//------------------------------------
+
+void list_view_builder::build(statistic_group_list_t& gl)
+{
+ setup_list_view();
+
+ statistic_group_list_t::iterator group_iter = gl.begin();
+ statistic_group_list_t::iterator group_iter_end = gl.end();
+
+ for (/**/; group_iter != group_iter_end; ++group_iter)
+ {
+ statistic_item_list_t::iterator item_iter = group_iter->second.begin();
+ statistic_item_list_t::iterator item_iter_end = group_iter->second.end();
+
+ if (item_iter != item_iter_end)
+ insert_group(group_iter->first);
+
+ for (/**/; item_iter != item_iter_end; ++item_iter)
+ insert_item(item_iter->title_, item_iter->value_, item_iter->editable_);
+ }
+}
+
+//------------------------------------
+//
+//------------------------------------
+
+void list_view_builder::setup_list_view()
+{
+ HIMAGELIST h_ils = ImageList_Create(16,15,ILC_MASK, 7, 0);
+ HBITMAP h_bmp = LoadBitmap(GetModuleHandle(MODULE_NAME), MAKEINTRESOURCE(IDB_PROPERTY_IMAGES));
+ ImageList_AddMasked(h_ils, h_bmp, RGB(255, 0, 255));
+
+ ListView_SetImageList(hwnd_list_view_, h_ils, LVSIL_SMALL);
+
+ std::wstring header = GetResString(IDS_PROPERTY);
+
+ LVCOLUMN lvc;
+ lvc.mask = LVCF_FMT |
+ LVCF_WIDTH |
+ LVCF_TEXT |
+ LVCF_SUBITEM;
+
+ lvc.iSubItem = 0;
+ lvc.pszText = const_cast<wchar_t*>(header.c_str());
+ lvc.cx = 120;
+ lvc.fmt = LVCFMT_LEFT;
+
+ ListView_InsertColumn(hwnd_list_view_, 0, &lvc);
+ lvc.iSubItem = 1;
+ header = GetResString(IDS_PROPERTY_VALUE);
+ lvc.pszText = const_cast<wchar_t*>(header.c_str());
+ ListView_InsertColumn(hwnd_list_view_, 1, &lvc);
+}
+
+//------------------------------------
+//
+//------------------------------------
+
+void list_view_builder::insert_group(const std::wstring& /*title*/)
+{
+ insert_item(L"", L"", false);
+}
+
+//------------------------------------
+//
+//------------------------------------
+
+void list_view_builder::insert_item(const std::wstring& title, const std::wstring& value, bool is_editable)
+{
+ LVITEM lvi;
+
+ lvi.iItem = ++row_index_;
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_TEXT;
+ lvi.state = 0;
+ lvi.cchTextMax = title.size() + 1;
+ lvi.stateMask = 0;
+ lvi.pszText = const_cast<wchar_t*>(title.c_str());
+
+ if (title.length() > 0)
+ {
+ lvi.mask |= LVIF_IMAGE;
+
+ if (is_editable)
+ lvi.iImage = 4;
+ else
+ lvi.iImage = 3;
+ }
+
+ ListView_InsertItem(hwnd_list_view_, &lvi);
+
+ lvi.mask = LVIF_TEXT;
+ lvi.iSubItem = 1;
+ lvi.pszText = const_cast<wchar_t*>(value.c_str());
+
+ ListView_SetItem(hwnd_list_view_, &lvi);
+}
+
+//------------------------------------
+//
+//------------------------------------
+
+HWND list_view_builder::get_list_view() const
+{
+ return hwnd_list_view_;
+}
+
+//------------------------------------
+//
+//------------------------------------
+
+winxp_list_view_builder::winxp_list_view_builder(
+ HWND hwnd_list_view,
+ const std::wstring& column1_title,
+ const std::wstring& column2_title) :
+ list_view_builder(hwnd_list_view, column1_title, column2_title),
+ group_count_(-1),
+ row_count_(0)
+{
+}
+
+//------------------------------------
+//
+//------------------------------------
+
+void winxp_list_view_builder::setup_list_view()
+{
+ list_view_builder::setup_list_view();
+
+ ListView_EnableGroupView(get_list_view(), TRUE);
+}
+
+//------------------------------------
+//
+//------------------------------------
+
+void winxp_list_view_builder::insert_group(const std::wstring& name)
+{
+ LVGROUP lvg;
+
+ ZeroMemory(&lvg, sizeof(lvg));
+
+ lvg.cbSize = sizeof(lvg);
+ lvg.mask = LVGF_HEADER | LVGF_STATE | LVGF_GROUPID;
+ lvg.pszHeader = const_cast<wchar_t*>(name.c_str());
+ lvg.cchHeader = name.size() + 1;
+ lvg.iGroupId = ++group_count_;
+ lvg.state = LVGS_NORMAL;
+ lvg.uAlign = LVGA_HEADER_CENTER;
+
+ ListView_InsertGroup(get_list_view(), row_count_++, &lvg);
+}
+
+//------------------------------------
+//
+//------------------------------------
+
+void winxp_list_view_builder::insert_item(
+ const std::wstring& title, const std::wstring& value, bool is_editable)
+{
+ LVITEM lvi;
+
+ lvi.iItem = ++row_index_;
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_TEXT | LVIF_GROUPID;
+ lvi.state = 0;
+ lvi.stateMask = 0;
+ lvi.pszText = const_cast<wchar_t*>(title.c_str());
+ lvi.iGroupId = group_count_;
+
+ if (title.length() > 0)
+ {
+ lvi.mask |= LVIF_IMAGE;
+
+ if (is_editable)
+ lvi.iImage = 4;
+ else
+ lvi.iImage = 3;
+ }
+
+ ListView_InsertItem(get_list_view(), &lvi);
+
+ lvi.mask = LVIF_TEXT;
+ lvi.iSubItem = 1;
+ lvi.pszText = const_cast<wchar_t*>(value.c_str());
+
+ ListView_SetItem(get_list_view(), &lvi);
+
+ row_count_++;
+}
diff --git a/shell/source/win32/shlxthandler/propsheets/listviewbuilder.hxx b/shell/source/win32/shlxthandler/propsheets/listviewbuilder.hxx
new file mode 100644
index 000000000000..c764ff9809ad
--- /dev/null
+++ b/shell/source/win32/shlxthandler/propsheets/listviewbuilder.hxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef LISTVIEWBUILDER_HXX_INCLUDED
+#define LISTVIEWBUILDER_HXX_INCLUDED
+
+//------------------------------------
+// include
+//------------------------------------
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include <string>
+#include <memory>
+#include "document_statistic.hxx"
+
+//------------------------------------
+//
+//------------------------------------
+
+class list_view_builder;
+typedef std::auto_ptr<list_view_builder> list_view_builder_ptr;
+
+// factory method for list_view_builder
+list_view_builder_ptr create_list_view_builder(
+ HWND hwnd_lv, const std::wstring& col1, const std::wstring& col2);
+
+//------------------------------------
+//
+//------------------------------------
+
+class list_view_builder
+{
+public:
+ virtual ~list_view_builder();
+
+ void build(statistic_group_list_t& gl);
+
+protected:
+ list_view_builder(
+ HWND hwnd_list_view,
+ const std::wstring& column1_title,
+ const std::wstring& column2_title);
+
+ virtual void setup_list_view();
+ virtual void insert_group(const std::wstring& title);
+ virtual void insert_item(const std::wstring& title, const std::wstring& value, bool is_editable);
+
+ HWND get_list_view() const;
+ int get_current_row() const;
+
+ int row_index_;
+
+private:
+ HWND hwnd_list_view_;
+ std::wstring column1_title_;
+ std::wstring column2_title_;
+
+ friend list_view_builder_ptr create_list_view_builder(HWND hwnd_lv, const std::wstring& col1, const std::wstring& col2);
+};
+
+//------------------------------------
+//
+//------------------------------------
+
+class winxp_list_view_builder : public list_view_builder
+{
+protected:
+ winxp_list_view_builder(
+ HWND hwnd_list_view,
+ const std::wstring& column1_title,
+ const std::wstring& column2_title);
+
+ virtual void setup_list_view();
+ virtual void insert_group(const std::wstring& name);
+ virtual void insert_item(const std::wstring& title, const std::wstring& value, bool is_editable);
+
+private:
+ int group_count_;
+ int row_count_;
+
+ friend list_view_builder_ptr create_list_view_builder(HWND hwnd_lv, const std::wstring& col1, const std::wstring& col2);
+};
+
+#endif
diff --git a/shell/source/win32/shlxthandler/propsheets/makefile.mk b/shell/source/win32/shlxthandler/propsheets/makefile.mk
new file mode 100644
index 000000000000..55a31c9c59d3
--- /dev/null
+++ b/shell/source/win32/shlxthandler/propsheets/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+PRJNAME=shell
+TARGET=propsheets
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE
+CDEFS+=-U_WIN32_WINNT -D_WIN32_WINNT=0x0501 -U_WIN32_IE -D_WIN32_IE=0x501
+.IF "$(COM)"!="GCC"
+CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CFLAGS_X64+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE
+CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS_X64+=-D_WIN32_WINNT=0x0501 -D_WIN32_IE=0x501
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=$(SLO)$/propsheets.obj\
+ $(SLO)$/listviewbuilder.obj\
+ $(SLO)$/document_statistic.obj
+
+.IF "$(BUILD_X64)"!=""
+SLOFILES_X64=$(SLO_X64)$/propsheets.obj\
+ $(SLO_X64)$/listviewbuilder.obj\
+ $(SLO_X64)$/document_statistic.obj
+.ENDIF # "$(BUILD_X64)"!=""
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+.INCLUDE : tg_wntx64.mk \ No newline at end of file
diff --git a/shell/source/win32/shlxthandler/propsheets/propsheets.cxx b/shell/source/win32/shlxthandler/propsheets/propsheets.cxx
new file mode 100755
index 000000000000..a45c7967f233
--- /dev/null
+++ b/shell/source/win32/shlxthandler/propsheets/propsheets.cxx
@@ -0,0 +1,366 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/config.hxx"
+#include "internal/global.hxx"
+
+#ifndef PROPSEETS_HXX_INCLUDED
+#include "internal/propsheets.hxx"
+#endif
+#include "internal/utilities.hxx"
+#include "internal/resource.h"
+#include "listviewbuilder.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <shellapi.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include <string>
+#include <vector>
+#include <utility>
+#include <strsafe.h>
+
+
+/*---------------------------------------------
+ INFO - INFO - INFO - INFO - INFO - INFO
+
+ See MSDN "Using Windows XP Visual Styles"
+ for hints how to enable the new common
+ control library for our property sheet.
+
+ INFO - INFO - INFO - INFO - INFO - INFO
+----------------------------------------------*/
+
+//-----------------------------
+//
+//-----------------------------
+
+CPropertySheet::CPropertySheet(long RefCnt) :
+ m_RefCnt(RefCnt)
+{
+ OutputDebugStringFormat("CPropertySheet::CTor [%d], [%d]", m_RefCnt, g_DllRefCnt );
+ InterlockedIncrement(&g_DllRefCnt);
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+CPropertySheet::~CPropertySheet()
+{
+ OutputDebugStringFormat("CPropertySheet::DTor [%d], [%d]", m_RefCnt, g_DllRefCnt );
+ InterlockedDecrement(&g_DllRefCnt);
+}
+
+//-----------------------------
+// IUnknown methods
+//-----------------------------
+
+HRESULT STDMETHODCALLTYPE CPropertySheet::QueryInterface(
+ REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ *ppvObject = 0;
+
+ IUnknown* pUnk = 0;
+ if (IID_IUnknown == riid || IID_IShellExtInit == riid)
+ {
+ pUnk = static_cast<IShellExtInit*>(this);
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+ else if (IID_IShellPropSheetExt == riid)
+ {
+ pUnk = static_cast<IShellPropSheetExt*>(this);
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+
+ return E_NOINTERFACE;
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+ULONG STDMETHODCALLTYPE CPropertySheet::AddRef(void)
+{
+ OutputDebugStringFormat("CPropertySheet::AddRef [%d]", m_RefCnt );
+ return InterlockedIncrement(&m_RefCnt);
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+ULONG STDMETHODCALLTYPE CPropertySheet::Release(void)
+{
+ OutputDebugStringFormat("CPropertySheet::Release [%d]", m_RefCnt );
+ long refcnt = InterlockedDecrement(&m_RefCnt);
+
+ if (0 == refcnt)
+ delete this;
+
+ return refcnt;
+}
+
+//-----------------------------
+// IShellExtInit
+//-----------------------------
+
+HRESULT STDMETHODCALLTYPE CPropertySheet::Initialize(
+ LPCITEMIDLIST /*pidlFolder*/, LPDATAOBJECT lpdobj, HKEY /*hkeyProgID*/)
+{
+ InitCommonControls();
+
+ STGMEDIUM medium;
+ FORMATETC fe = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
+
+ HRESULT hr = lpdobj->GetData(&fe, &medium);
+
+ // save the file name
+ if (SUCCEEDED(hr) &&
+ (1 == DragQueryFileA(
+ reinterpret_cast<HDROP>(medium.hGlobal),
+ 0xFFFFFFFF,
+ NULL,
+ 0)))
+ {
+ DragQueryFileA(
+ reinterpret_cast<HDROP>(medium.hGlobal),
+ 0,
+ m_szFileName,
+ sizeof(m_szFileName));
+
+ hr = S_OK;
+ }
+ else
+ hr = E_INVALIDARG;
+
+ ReleaseStgMedium(&medium);
+
+ return hr;
+}
+
+//-----------------------------
+// IShellPropSheetExt
+//-----------------------------
+
+HRESULT STDMETHODCALLTYPE CPropertySheet::AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
+{
+ // Get OS version (we don't need the summary page on Windows Vista or later)
+ OSVERSIONINFO sInfoOS;
+
+ ZeroMemory( &sInfoOS, sizeof(OSVERSIONINFO) );
+ sInfoOS.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
+ GetVersionEx( &sInfoOS );
+ bool bIsVistaOrLater = (sInfoOS.dwMajorVersion >= 6);
+
+ std::wstring proppage_header;
+
+ PROPSHEETPAGE psp;
+ ZeroMemory(&psp, sizeof(PROPSHEETPAGEA));
+
+ // add the summary property page
+ psp.dwSize = sizeof(PROPSHEETPAGE);
+ psp.dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USECALLBACK;
+ psp.hInstance = GetModuleHandle(MODULE_NAME);
+ psp.lParam = reinterpret_cast<LPARAM>(this);
+ psp.pfnCallback = reinterpret_cast<LPFNPSPCALLBACK>(CPropertySheet::PropPageSummaryCallback);
+
+ HPROPSHEETPAGE hPage = NULL;
+
+ if ( !bIsVistaOrLater )
+ {
+ proppage_header = GetResString(IDS_PROPPAGE_SUMMARY_TITLE);
+
+ psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_SUMMARY);
+ psp.pszTitle = proppage_header.c_str();
+ psp.pfnDlgProc = reinterpret_cast<DLGPROC>(CPropertySheet::PropPageSummaryProc);
+
+ hPage = CreatePropertySheetPage(&psp);
+
+ // keep this instance alive, will be released when the
+ // the page is about to be destroyed in the callback function
+
+ if (hPage)
+ {
+ if (lpfnAddPage(hPage, lParam))
+ AddRef();
+ else
+ DestroyPropertySheetPage(hPage);
+ }
+ }
+
+ // add the statistics property page
+ proppage_header = GetResString(IDS_PROPPAGE_STATISTICS_TITLE);
+
+ psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_STATISTICS);
+ psp.pszTitle = proppage_header.c_str();
+ psp.pfnDlgProc = reinterpret_cast<DLGPROC>(CPropertySheet::PropPageStatisticsProc);
+
+ hPage = CreatePropertySheetPage(&psp);
+
+ if (hPage)
+ {
+ if (lpfnAddPage(hPage, lParam))
+ AddRef();
+ else
+ DestroyPropertySheetPage(hPage);
+ }
+
+ // always return success else
+ // no property sheet will be
+ // displayed at all
+ return NOERROR;
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+HRESULT STDMETHODCALLTYPE CPropertySheet::ReplacePage(
+ UINT /*uPageID*/, LPFNADDPROPSHEETPAGE /*lpfnReplaceWith*/, LPARAM /*lParam*/)
+{
+ return E_NOTIMPL;
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+UINT CALLBACK CPropertySheet::PropPageSummaryCallback(
+ HWND /*hwnd*/, UINT uMsg, LPPROPSHEETPAGE ppsp)
+{
+ CPropertySheet* pImpl =
+ reinterpret_cast<CPropertySheet*>(ppsp->lParam);
+
+ // release this instance, acquired
+ // in the AddPages method
+ if (PSPCB_RELEASE == uMsg)
+ {
+ pImpl->Release();
+ }
+
+ return TRUE;
+}
+
+
+//-----------------------------
+//
+//-----------------------------
+
+BOOL CALLBACK CPropertySheet::PropPageSummaryProc(HWND hwnd, UINT uiMsg, WPARAM /*wParam*/, LPARAM lParam)
+{
+ switch (uiMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ LPPROPSHEETPAGE psp = reinterpret_cast<LPPROPSHEETPAGE>(lParam);
+ CPropertySheet* pImpl = reinterpret_cast<CPropertySheet*>(psp->lParam);
+ pImpl->InitPropPageSummary(hwnd, psp);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+//-----------------------------
+//
+//-----------------------------
+
+BOOL CALLBACK CPropertySheet::PropPageStatisticsProc(HWND hwnd, UINT uiMsg, WPARAM /*wParam*/, LPARAM lParam)
+{
+ switch (uiMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ LPPROPSHEETPAGE psp = reinterpret_cast<LPPROPSHEETPAGE>(lParam);
+ CPropertySheet* pImpl = reinterpret_cast<CPropertySheet*>(psp->lParam);
+ pImpl->InitPropPageStatistics(hwnd, psp);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+//##################################
+void CPropertySheet::InitPropPageSummary(HWND hwnd, LPPROPSHEETPAGE /*lppsp*/)
+{
+ CMetaInfoReader metaInfo(m_szFileName);
+
+ SetWindowText(GetDlgItem(hwnd,IDC_TITLE), metaInfo.getTagData( META_INFO_TITLE ).c_str() );
+ SetWindowText(GetDlgItem(hwnd,IDC_AUTHOR), metaInfo.getTagData( META_INFO_AUTHOR ).c_str() );
+ SetWindowText(GetDlgItem(hwnd,IDC_SUBJECT), metaInfo.getTagData( META_INFO_SUBJECT ).c_str() );
+ SetWindowText(GetDlgItem(hwnd,IDC_KEYWORDS), metaInfo.getTagData( META_INFO_KEYWORDS ).c_str() );
+
+ // comments read from meta.xml use "\n" for return, but this will not displayable in Edit control, add
+ // "\r" before "\n" to form "\r\n" in order to display return in Edit control.
+ std::wstring tempStr = metaInfo.getTagData( META_INFO_DESCRIPTION ).c_str();
+ std::wstring::size_type itor = tempStr.find ( L"\n" , 0 );
+ while (itor != std::wstring::npos)
+ {
+ tempStr.insert(itor, L"\r");
+ itor = tempStr.find(L"\n", itor + 2);
+ }
+ SetWindowText(GetDlgItem(hwnd,IDC_COMMENTS), tempStr.c_str());
+
+}
+
+//---------------------------------
+/**
+*/
+void CPropertySheet::InitPropPageStatistics(HWND hwnd, LPPROPSHEETPAGE /*lppsp*/)
+{
+ CMetaInfoReader metaInfo(m_szFileName);
+
+ document_statistic_reader_ptr doc_stat_reader = create_document_statistic_reader(m_szFileName, &metaInfo);
+
+ statistic_group_list_t sgl;
+ doc_stat_reader->read(&sgl);
+
+ list_view_builder_ptr lv_builder = create_list_view_builder(
+ GetDlgItem(hwnd, IDC_STATISTICSLIST),
+ GetResString(IDS_PROPERTY),
+ GetResString(IDS_PROPERTY_VALUE));
+
+ lv_builder->build(sgl);
+
+}
+
+
+
+
diff --git a/shell/source/win32/shlxthandler/res/ctrylnglist.txt b/shell/source/win32/shlxthandler/res/ctrylnglist.txt
new file mode 100644
index 000000000000..ec2196e4da43
--- /dev/null
+++ b/shell/source/win32/shlxthandler/res/ctrylnglist.txt
@@ -0,0 +1,29 @@
+1 LANG_ENGLISH SUBLANG_ENGLISH_US
+3 LANG_PORTUGUESE SUBLANG_PORTUGUESE
+4 LANG_GERMAN SUBLANG_GERMAN
+7 LANG_RUSSIAN SUBLANG_DEFAULT
+30 LANG_GREEK SUBLANG_DEFAULT
+31 LANG_DUTCH SUBLANG_DUTCH
+33 LANG_FRENCH SUBLANG_FRENCH
+34 LANG_SPANISH SUBLANG_SPANISH
+35 LANG_FINNISH SUBLANG_DEFAULT
+36 LANG_HUNGARIAN SUBLANG_DEFAULT
+39 LANG_ITALIAN SUBLANG_ITALIAN
+42 LANG_CZECH SUBLANG_DEFAULT
+43 LANG_SLOVAK SUBLANG_DEFAULT
+44 LANG_ENGLISH SUBLANG_ENGLISH_UK
+45 LANG_DANISH SUBLANG_DEFAULT
+46 LANG_SWEDISH SUBLANG_SWEDISH
+47 LANG_NORWEGIAN SUBLANG_NORWEGIAN_BOKMAL
+48 LANG_POLISH SUBLANG_DEFAULT
+49 LANG_GERMAN SUBLANG_DEFAULT
+55 LANG_PORTUGUESE SUBLANG_PORTUGUESE_BRAZILIAN
+81 LANG_JAPANESE SUBLANG_DEFAULT
+82 LANG_KOREAN SUBLANG_KOREAN
+86 LANG_CHINESE SUBLANG_CHINESE_SIMPLIFIED
+88 LANG_CHINESE SUBLANG_CHINESE_TRADITIONAL
+90 LANG_TURKISH SUBLANG_DEFAULT
+96 LANG_ARABIC SUBLANG_DEFAULT
+97 LANG_HEBREW SUBLANG_DEFAULT
+37 LANG_CATALAN SUBLANG_DEFAULT
+66 LANG_THAI SUBLANG_DEFAULT
diff --git a/shell/source/win32/shlxthandler/res/makefile.mk b/shell/source/win32/shlxthandler/res/makefile.mk
new file mode 100644
index 000000000000..ec0529015179
--- /dev/null
+++ b/shell/source/win32/shlxthandler/res/makefile.mk
@@ -0,0 +1,72 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+PRJ=..$/..$/..$/..
+
+PRJNAME=shell
+TARGET=shlxthdl
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+INCPRE+=$(MFC_INCLUDE)
+
+# --- Files --------------------------------------------------------
+
+
+RCFILES=$(RES)$/$(TARGET).rc
+
+ULFFILES=$(TARGET).ulf
+
+.IF "$(WITH_LANG)"!=""
+ULFDIR:=$(COMMONMISC)$/$(TARGET)
+.ELSE # "$(WITH_LANG)"!=""
+ULFDIR:=.
+.ENDIF # "$(WITH_LANG)"!=""
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(BUILD_X64)"!=""
+$(RES)$/x64$/$(TARGET).res : $(RES)$/$(TARGET).res
+ -$(MKDIR) $(RES)$/x64
+ @@cp $< $@
+.ENDIF # "$(BUILD_X64)"!=""
+
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+.INCLUDE : tg_wntx64.mk
+
+
+
+# Generate the native Windows resource file
+# using lngconvex.exe
+
+$(RCFILES) : $(ULFDIR)$/shlxthdl.ulf makefile.mk rcfooter.txt rcheader.txt rctmpl.txt
+ $(subst,$(SOLARBINDIR)$/lngconvex,$(BIN)$/lngconvex $(LNGCONVEX)) -ulf $(ULFDIR)$/shlxthdl.ulf -rc $(RES)$/shlxthdl.rc -rct rctmpl.txt -rch rcheader.txt -rcf rcfooter.txt
+
diff --git a/shell/source/win32/shlxthandler/res/prop_img.bmp b/shell/source/win32/shlxthandler/res/prop_img.bmp
new file mode 100644
index 000000000000..1849a8bb62f4
--- /dev/null
+++ b/shell/source/win32/shlxthandler/res/prop_img.bmp
Binary files differ
diff --git a/shell/source/win32/shlxthandler/res/rcfooter.txt b/shell/source/win32/shlxthandler/res/rcfooter.txt
new file mode 100644
index 000000000000..ce333b32a1d5
--- /dev/null
+++ b/shell/source/win32/shlxthandler/res/rcfooter.txt
@@ -0,0 +1,4 @@
+
+
+IDP_SIGNET RCDATA "signet.png"
+
diff --git a/shell/source/win32/shlxthandler/res/rcheader.txt b/shell/source/win32/shlxthandler/res/rcheader.txt
new file mode 100644
index 000000000000..fac9fa31f256
--- /dev/null
+++ b/shell/source/win32/shlxthandler/res/rcheader.txt
@@ -0,0 +1,15 @@
+#if defined(_MSC_VER) && (_MSC_VER < 1500)
+#include <winres.h>
+#else
+#define WINVER 0x0500
+#include <winresrc.h>
+#define LB_ADDSTRING (WM_USER+1)
+#define CB_ADDSTRING (WM_USER+3)
+#define IDC_STATIC (-1)
+#endif
+
+#include "internal/resource.h"
+
+MANIFEST_RESOURCE_ID RT_MANIFEST "shlxthdl.manifest"
+
+IDB_PROPERTY_IMAGES BITMAP "prop_img.bmp"
diff --git a/shell/source/win32/shlxthandler/res/rctmpl.txt b/shell/source/win32/shlxthandler/res/rctmpl.txt
new file mode 100644
index 000000000000..a512c69dd9d7
--- /dev/null
+++ b/shell/source/win32/shlxthandler/res/rctmpl.txt
@@ -0,0 +1,71 @@
+
+// Dialog
+
+IDD_PROPPAGE_SUMMARY DIALOGEX 0, 0, 222, 211
+STYLE WS_CHILD
+FONT 8, "MS Sans Serif"
+BEGIN
+ LTEXT %TITLE_COLON% ,IDC_STATIC,7,14,39,10
+ LTEXT %AUTHOR_COLON% ,IDC_STATIC,7,31,47,10
+ LTEXT %SUBJECT_COLON% ,IDC_STATIC,7,47,39,10
+ LTEXT %KEYWORDS_COLON% ,IDC_STATIC,7,94,49,10
+ EDITTEXT IDC_TITLE,63,12,154,12,ES_AUTOHSCROLL | ES_READONLY |
+ NOT WS_BORDER,WS_EX_CLIENTEDGE
+ EDITTEXT IDC_AUTHOR,63,29,154,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER,
+ WS_EX_CLIENTEDGE
+ EDITTEXT IDC_SUBJECT,63,46,154,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER,
+ WS_EX_CLIENTEDGE
+ EDITTEXT IDC_KEYWORDS,64,93,154,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER,
+ WS_EX_CLIENTEDGE
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,75,211,1
+ EDITTEXT IDC_COMMENTS,64,111,154,83,ES_MULTILINE | ES_LEFT | ES_READONLY | ES_WANTRETURN |
+ NOT WS_BORDER | WS_VSCROLL,WS_EX_CLIENTEDGE
+ LTEXT %COMMENTS_COLON% ,IDC_STATIC,7,112,49,10
+END
+
+IDD_PROPPAGE_STATISTICS DIALOG DISCARDABLE 0, 0, 222, 215
+STYLE WS_CHILD
+FONT 8, "MS Sans Serif"
+BEGIN
+ CONTROL "",IDC_STATISTICSLIST,"SysListView32",LVS_REPORT |
+ WS_BORDER | WS_TABSTOP,6,7,214,186
+END
+
+// String Table
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_TITLE %TITLE%
+ IDS_TITLE_COLON %TITLE_COLON%
+ IDS_SUBJECT %SUBJECT%
+ IDS_SUBJECT_COLON %SUBJECT_COLON%
+ IDS_AUTHOR %AUTHOR%
+ IDS_AUTHOR_COLON %AUTHOR_COLON%
+ IDS_KEYWORDS %KEYWORDS%
+ IDS_COMMENTS %COMMENTS%
+ IDS_COMMENTS_COLON %COMMENTS_COLON%
+ IDS_PAGES %PAGES%
+ IDS_TABLES %TABLES%
+ IDS_GRAPHICS %GRAPHICS%
+ IDS_OBJECTS %OBJECTS%
+ IDS_OLE_OBJECTS %OLE_OBJECTS%
+ IDS_PARAGRAPHS %PARAGRAPHS%
+ IDS_WORDS %WORDS%
+ IDS_CHARACTERS %CHARACTERS%
+ IDS_ROWS %ROWS%
+ IDS_ORIGIN %ORIGIN%
+ IDS_VERSION %VERSION%
+ IDS_SHEETS %SHEETS%
+ IDS_CELLS %CELLS%
+ IDS_MODIFIED %MODIFIED%
+ IDS_MODIFIED_COLON %MODIFIED_COLON%
+ IDS_DOCUMENT_NUMBER %DOCUMENT_NUMBER%
+ IDS_EDITING_TIME %EDITING_TIME%
+ IDS_PROPPAGE_STATISTICS_TITLE %STATISTICS_TITLE%
+ IDS_PROPPAGE_SUMMARY_TITLE %SUMMARY_TITLE%
+ IDS_PROPERTY %PROPERTY%
+ IDS_PROPERTY_VALUE %PROPERTY_VALUE%
+ IDS_DESCRIPTION %DESCRIPTION%
+ IDS_SIZE_COLON %SIZE_COLON%
+ IDS_TYPE_COLON %TYPE_COLON%
+END
diff --git a/shell/source/win32/shlxthandler/res/shlxthdl.manifest b/shell/source/win32/shlxthandler/res/shlxthdl.manifest
new file mode 100644
index 000000000000..a785006a9601
--- /dev/null
+++ b/shell/source/win32/shlxthandler/res/shlxthdl.manifest
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+<assemblyIdentity version="1.0.0.0" processorArchitecture="x86" name="OpenOffice.shlxthdl" type="win32" />
+<description>OpenOffice Shell Extension</description>
+<dependency>
+<dependentAssembly>
+<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86"
+ publicKeyToken="6595b64144ccf1df" language="*"/>
+</dependentAssembly>
+</dependency>
+</assembly>
diff --git a/shell/source/win32/shlxthandler/res/shlxthdl.ulf b/shell/source/win32/shlxthandler/res/shlxthdl.ulf
new file mode 100644
index 000000000000..c0e879724e5d
--- /dev/null
+++ b/shell/source/win32/shlxthandler/res/shlxthdl.ulf
@@ -0,0 +1,148 @@
+[%TITLE%]
+en-US = "Title"
+
+[%TITLE_COLON%]
+en-US = "Title:"
+
+[%SUBJECT%]
+en-US = "Subject"
+
+[%SUBJECT_COLON%]
+en-US = "Subject:"
+
+[%AUTHOR%]
+en-US = "Author"
+
+[%AUTHOR_COLON%]
+en-US = "Author:"
+
+[%KEYWORDS%]
+en-US = "Keywords"
+
+[%KEYWORDS_COLON%]
+en-US = "Keywords:"
+
+[%COMMENTS%]
+en-US = "Comments"
+
+[%COMMENTS_COLON%]
+en-US = "Comments:"
+
+[%PAGES%]
+en-US = "Pages"
+
+[%TABLES%]
+en-US = "Tables"
+
+[%GRAPHICS%]
+en-US = "Graphics"
+
+[%OBJECTS%]
+en-US = "Objects"
+
+[%OLE_OBJECTS%]
+en-US = "OLE Objects"
+
+[%PARAGRAPHS%]
+en-US = "Paragraphs"
+
+[%WORDS%]
+en-US = "Words"
+
+[%CHARACTERS%]
+en-US = "Characters"
+
+[%ROWS%]
+en-US = "Lines"
+
+[%ORIGIN%]
+en-US = "Origin"
+
+[%VERSION%]
+en-US = "Version"
+
+[%SHEETS%]
+en-US = "Sheets"
+
+[%CELLS%]
+en-US = "Cells"
+
+[%STATISTICS_TITLE%]
+en-US = "Document Statistics"
+
+[%SUMMARY_TITLE%]
+en-US = "Summary"
+
+[%PROPERTY%]
+en-US = "Property"
+
+[%PROPERTY_VALUE%]
+en-US = "Value"
+
+[%MODIFIED%]
+en-US = "Modified"
+
+[%MODIFIED_COLON%]
+en-US = "Modified:"
+
+[%DOCUMENT_NUMBER%]
+en-US = "Revision number"
+
+[%DOCUMENT_NUMBER_COLON%]
+en-US = "Revision number:"
+
+[%EDITING_TIME%]
+en-US = "Total editing time"
+
+[%EDITING_TIME_COLON%]
+en-US = "Total editing time:"
+
+[%DESCRIPTION%]
+en-US = "Description"
+
+[%DESCRIPTION_COLON%]
+en-US = "Description:"
+
+[%SIZE_COLON%]
+en-US = "Size:"
+
+[%TYPE_COLON%]
+en-US = "Type:"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/shell/source/win32/shlxthandler/res/signet.png b/shell/source/win32/shlxthandler/res/signet.png
new file mode 100644
index 000000000000..bccaaff817d1
--- /dev/null
+++ b/shell/source/win32/shlxthandler/res/signet.png
Binary files differ
diff --git a/shell/source/win32/shlxthandler/shlxthdl.cxx b/shell/source/win32/shlxthandler/shlxthdl.cxx
new file mode 100755
index 000000000000..6263c98ea749
--- /dev/null
+++ b/shell/source/win32/shlxthandler/shlxthdl.cxx
@@ -0,0 +1,427 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/config.hxx"
+#include "internal/global.hxx"
+#include "internal/shlxthdl.hxx"
+#include "classfactory.hxx"
+#include "internal/registry.hxx"
+#include "internal/fileextensions.hxx"
+#include "internal/utilities.hxx"
+
+#include <tchar.h>
+#include <string>
+#include <shlobj.h>
+
+//---------------------------
+// Module global
+//---------------------------
+long g_DllRefCnt = 0;
+HINSTANCE g_hModule = NULL;
+
+namespace /* private */
+{
+ const char* GUID_PLACEHOLDER = "{GUID}";
+ const char* EXTENSION_PLACEHOLDER = "{EXT}";
+ const char* FORWARDKEY_PLACEHOLDER = "{FWDKEY}";
+
+ const char* CLSID_ENTRY = "CLSID\\{GUID}\\InProcServer32";
+ const char* SHELLEX_IID_ENTRY = "{EXT}\\shellex\\{GUID}";
+ const char* SHELLEX_ENTRY = "{EXT}\\shellex";
+ const char* PROPSHEET_ENTRY = "{EXT}\\CLSID\\{GUID}\\InProcServer32";
+ const char* EXTENSION_CLSID = "{EXT}\\CLSID";
+ const char* EXTENSION_CLSID_GUID = "{EXT}\\CLSID\\{GUID}";
+ const char* FORWARD_PROPSHEET_MYPROPSHEET_ENTRY = "{FWDKEY}\\shellex\\PropertySheetHandlers\\MyPropSheet1";
+ const char* FORWARD_PROPSHEET_ENTRY = "{FWDKEY}\\shellex\\PropertySheetHandlers";
+ const char* FORWARD_SHELLEX_ENTRY = "{FWDKEY}\\shellex";
+
+ const char* SHELL_EXTENSION_APPROVED_KEY_NAME = "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved";
+
+ //---------------------------
+ // "String Placeholder" ->
+ // "String Replacement"
+ //---------------------------
+ void SubstitutePlaceholder(std::string& String, const std::string& Placeholder, const std::string& Replacement)
+ {
+ std::string::size_type idx = String.find(Placeholder);
+ std::string::size_type len = Placeholder.length();
+
+ while (std::string::npos != idx)
+ {
+ String.replace(idx, len, Replacement);
+ idx = String.find(Placeholder);
+ }
+ }
+
+ /* Make the registry entry
+ HKCR\CLSID\{GUID}
+ InProcServer32 = Path\shlxthdl.dll
+ ThreadingModel = Apartment
+ */
+ HRESULT RegisterComComponent(const char* FilePath, const CLSID& Guid)
+ {
+ std::string ClsidEntry = CLSID_ENTRY;
+ SubstitutePlaceholder(ClsidEntry, GUID_PLACEHOLDER, ClsidToString(Guid));
+
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry.c_str(), "", FilePath))
+ return E_FAIL;
+
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry.c_str(), "ThreadingModel", "Apartment"))
+ return E_FAIL;
+
+ return S_OK;
+ }
+
+ HRESULT UnregisterComComponent(const CLSID& Guid)
+ {
+ std::string tmp = "CLSID\\";
+ tmp += ClsidToString(Guid);
+ return DeleteRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str()) ? S_OK : E_FAIL;
+ }
+
+ HRESULT RegisterColumnHandler(const char* ModuleFileName)
+ {
+ if (FAILED(RegisterComComponent(ModuleFileName, CLSID_COLUMN_HANDLER)))
+ return E_FAIL;
+
+ std::string tmp = "Folder\\shellex\\ColumnHandlers\\";
+ tmp += ClsidToString(CLSID_COLUMN_HANDLER);
+
+ return SetRegistryKey(
+ HKEY_CLASSES_ROOT,
+ tmp.c_str(),
+ "",
+ WStringToString(COLUMN_HANDLER_DESCRIPTIVE_NAME).c_str()) ? S_OK : E_FAIL;
+ }
+
+ HRESULT UnregisterColumnHandler()
+ {
+ std::string tmp = "Folder\\shellex\\ColumnHandlers\\";
+ tmp += ClsidToString(CLSID_COLUMN_HANDLER);
+
+ if (!DeleteRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str()))
+ return E_FAIL;
+
+ return UnregisterComComponent(CLSID_COLUMN_HANDLER);
+ }
+
+ HRESULT RegisterInfotipHandler(const char* ModuleFileName)
+ {
+ if (FAILED(RegisterComComponent(ModuleFileName, CLSID_INFOTIP_HANDLER)))
+ return E_FAIL;
+
+ std::string iid = ClsidToString(IID_IQueryInfo);
+ std::string tmp;
+
+ for(size_t i = 0; i < OOFileExtensionTableSize; i++)
+ {
+ tmp = SHELLEX_IID_ENTRY;
+ SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+ SubstitutePlaceholder(tmp, GUID_PLACEHOLDER, iid);
+
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str(), "", ClsidToString(CLSID_INFOTIP_HANDLER).c_str()))
+ return E_FAIL;
+ }
+ return S_OK;
+ }
+
+ HRESULT UnregisterInfotipHandler()
+ {
+ std::string iid = ClsidToString(IID_IQueryInfo);
+ std::string tmp;
+
+ for (size_t i = 0; i < OOFileExtensionTableSize; i++)
+ {
+ tmp = SHELLEX_IID_ENTRY;
+
+ SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+ SubstitutePlaceholder(tmp, GUID_PLACEHOLDER, iid);
+
+ DeleteRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str());
+
+ // if there are no further subkey below .ext\\shellex
+ // delete the whole subkey
+ tmp = SHELLEX_ENTRY;
+ SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+
+ bool HasSubKeys = true;
+ if (HasSubkeysRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str(), HasSubKeys) && !HasSubKeys)
+ DeleteRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str());
+ }
+ return UnregisterComComponent(CLSID_INFOTIP_HANDLER);
+ }
+
+ HRESULT RegisterPropSheetHandler(const char* ModuleFileName)
+ {
+ std::string ExtEntry;
+ std::string FwdKeyEntry;
+
+ if (FAILED(RegisterComComponent(ModuleFileName, CLSID_PROPERTYSHEET_HANDLER)))
+ return E_FAIL;
+
+ for (size_t i = 0; i < OOFileExtensionTableSize; i++)
+ {
+ FwdKeyEntry = FORWARD_PROPSHEET_MYPROPSHEET_ENTRY;
+ SubstitutePlaceholder(FwdKeyEntry, FORWARDKEY_PLACEHOLDER, OOFileExtensionTable[i].RegistryForwardKey);
+
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT, FwdKeyEntry.c_str(), "", ClsidToString(CLSID_PROPERTYSHEET_HANDLER).c_str()))
+ return E_FAIL;
+ }
+ return S_OK;
+ }
+
+ HRESULT UnregisterPropSheetHandler()
+ {
+ std::string ExtEntry;
+ std::string FwdKeyEntry;
+
+ for (size_t i = 0; i < OOFileExtensionTableSize; i++)
+ {
+ FwdKeyEntry = FORWARD_PROPSHEET_MYPROPSHEET_ENTRY;
+ SubstitutePlaceholder(FwdKeyEntry, FORWARDKEY_PLACEHOLDER, OOFileExtensionTable[i].RegistryForwardKey);
+
+ DeleteRegistryKey(HKEY_CLASSES_ROOT, FwdKeyEntry.c_str());
+
+ FwdKeyEntry = FORWARD_PROPSHEET_ENTRY;
+ SubstitutePlaceholder(FwdKeyEntry, FORWARDKEY_PLACEHOLDER, OOFileExtensionTable[i].RegistryForwardKey);
+
+ bool HasSubKeys = true;
+ if (HasSubkeysRegistryKey(HKEY_CLASSES_ROOT, FwdKeyEntry.c_str(), HasSubKeys) && !HasSubKeys)
+ DeleteRegistryKey(HKEY_CLASSES_ROOT, FwdKeyEntry.c_str());
+
+ FwdKeyEntry = FORWARD_SHELLEX_ENTRY;
+ SubstitutePlaceholder(FwdKeyEntry, FORWARDKEY_PLACEHOLDER, OOFileExtensionTable[i].RegistryForwardKey);
+
+ HasSubKeys = true;
+ if (HasSubkeysRegistryKey(HKEY_CLASSES_ROOT, FwdKeyEntry.c_str(), HasSubKeys) && !HasSubKeys)
+ DeleteRegistryKey(HKEY_CLASSES_ROOT, FwdKeyEntry.c_str());
+ }
+
+ return UnregisterComComponent(CLSID_PROPERTYSHEET_HANDLER);
+ }
+
+ HRESULT RegisterThumbviewerHandler(const char* ModuleFileName)
+ {
+ if (FAILED(RegisterComComponent(ModuleFileName, CLSID_THUMBVIEWER_HANDLER)))
+ return E_FAIL;
+
+ std::string iid = ClsidToString(IID_IExtractImage);
+ std::string tmp;
+
+ for(size_t i = 0; i < OOFileExtensionTableSize; i++)
+ {
+ tmp = SHELLEX_IID_ENTRY;
+
+ SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+ SubstitutePlaceholder(tmp, GUID_PLACEHOLDER, iid);
+
+ if (!SetRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str(), "", ClsidToString(CLSID_THUMBVIEWER_HANDLER).c_str()))
+ return E_FAIL;
+ }
+ return S_OK;
+ }
+
+ HRESULT UnregisterThumbviewerHandler()
+ {
+ std::string iid = ClsidToString(IID_IExtractImage);
+ std::string tmp;
+
+ for (size_t i = 0; i < OOFileExtensionTableSize; i++)
+ {
+ tmp = SHELLEX_IID_ENTRY;
+
+ SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+ SubstitutePlaceholder(tmp, GUID_PLACEHOLDER, iid);
+
+ DeleteRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str());
+
+ // if there are no further subkey below .ext\\shellex
+ // delete the whole subkey
+ tmp = SHELLEX_ENTRY;
+ SubstitutePlaceholder(tmp, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
+
+ bool HasSubKeys = true;
+ if (HasSubkeysRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str(), HasSubKeys) && !HasSubKeys)
+ DeleteRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str());
+ }
+ return UnregisterComComponent(CLSID_THUMBVIEWER_HANDLER);
+ }
+
+ /** Approving/Unapproving the Shell Extension, it's important under Windows
+ NT/2000/XP, see MSDN: Creating Shell Extension Handlers */
+ HRESULT ApproveShellExtension(CLSID clsid, const std::wstring& Description)
+ {
+ bool bRet = SetRegistryKey(
+ HKEY_LOCAL_MACHINE,
+ SHELL_EXTENSION_APPROVED_KEY_NAME,
+ ClsidToString(clsid).c_str(),
+ WStringToString(Description).c_str());
+
+ return bRet ? S_OK : E_FAIL;
+ }
+
+ HRESULT UnapproveShellExtension(CLSID Clsid)
+ {
+ HKEY hkey;
+
+ LONG rc = RegOpenKeyA(
+ HKEY_LOCAL_MACHINE,
+ SHELL_EXTENSION_APPROVED_KEY_NAME,
+ &hkey);
+
+ if (ERROR_SUCCESS == rc)
+ {
+ rc = RegDeleteValueA(
+ hkey,
+ ClsidToString(Clsid).c_str());
+
+ rc = RegCloseKey(hkey);
+ }
+
+ return rc == ERROR_SUCCESS ? S_OK : E_FAIL;
+ }
+
+} // namespace /* private */
+
+
+//---------------------
+// COM exports
+//---------------------
+
+extern "C" STDAPI DllRegisterServer()
+{
+ TCHAR ModuleFileName[MAX_PATH];
+
+ GetModuleFileName(
+ GetModuleHandle(MODULE_NAME),
+ ModuleFileName,
+ sizeof(ModuleFileName));
+
+ std::string module_path = WStringToString(ModuleFileName);
+ HRESULT hr = S_OK;
+
+ if (SUCCEEDED(RegisterColumnHandler(module_path.c_str())))
+ ApproveShellExtension(CLSID_COLUMN_HANDLER, COLUMN_HANDLER_DESCRIPTIVE_NAME);
+ else
+ hr = E_FAIL;
+
+ if (SUCCEEDED(RegisterInfotipHandler(module_path.c_str())))
+ ApproveShellExtension(CLSID_INFOTIP_HANDLER, INFOTIP_HANDLER_DESCRIPTIVE_NAME);
+ else
+ hr = E_FAIL;
+
+ if (SUCCEEDED(RegisterPropSheetHandler(module_path.c_str())))
+ ApproveShellExtension(CLSID_PROPERTYSHEET_HANDLER, PROPSHEET_HANDLER_DESCRIPTIVE_NAME);
+ else
+ hr = E_FAIL;
+
+ if (SUCCEEDED(RegisterThumbviewerHandler(module_path.c_str())))
+ ApproveShellExtension(CLSID_THUMBVIEWER_HANDLER, THUMBVIEWER_HANDLER_DESCRIPTIVAE_NAME);
+ else
+ hr = E_FAIL;
+
+ // notify the Shell that something has changed
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
+
+ return hr;
+}
+
+extern "C" STDAPI DllUnregisterServer()
+{
+ HRESULT hr = S_OK;
+
+ if (FAILED(UnregisterColumnHandler()))
+ hr = E_FAIL;
+
+ UnapproveShellExtension(CLSID_COLUMN_HANDLER);
+
+ if (FAILED(UnregisterInfotipHandler()))
+ hr = E_FAIL;
+
+ UnapproveShellExtension(CLSID_INFOTIP_HANDLER);
+
+ if (FAILED(UnregisterPropSheetHandler()))
+ hr = E_FAIL;
+
+ UnapproveShellExtension(CLSID_PROPERTYSHEET_HANDLER);
+
+ if (FAILED(UnregisterThumbviewerHandler()))
+ hr = E_FAIL;
+
+ UnapproveShellExtension(CLSID_THUMBVIEWER_HANDLER);
+
+ // notify the Shell that something has changed
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
+
+ return hr;
+}
+
+extern "C" STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv)
+{
+ *ppv = 0;
+
+ if ((rclsid != CLSID_INFOTIP_HANDLER) &&
+ (rclsid != CLSID_COLUMN_HANDLER) &&
+ (rclsid != CLSID_PROPERTYSHEET_HANDLER) &&
+ (rclsid != CLSID_THUMBVIEWER_HANDLER))
+ return CLASS_E_CLASSNOTAVAILABLE;
+
+ if ((riid != IID_IUnknown) && (riid != IID_IClassFactory))
+ return E_NOINTERFACE;
+
+ if ( rclsid == CLSID_INFOTIP_HANDLER )
+ OutputDebugStringFormat( "DllGetClassObject: Create CLSID_INFOTIP_HANDLER\n" );
+ else if ( rclsid == CLSID_COLUMN_HANDLER )
+ OutputDebugStringFormat( "DllGetClassObject: Create CLSID_COLUMN_HANDLER\n" );
+ else if ( rclsid == CLSID_PROPERTYSHEET_HANDLER )
+ OutputDebugStringFormat( "DllGetClassObject: Create CLSID_PROPERTYSHEET_HANDLER\n" );
+ else if ( rclsid == CLSID_THUMBVIEWER_HANDLER )
+ OutputDebugStringFormat( "DllGetClassObject: Create CLSID_THUMBVIEWER_HANDLER\n" );
+
+ IUnknown* pUnk = new CClassFactory(rclsid);
+ if (0 == pUnk)
+ return E_OUTOFMEMORY;
+
+ *ppv = pUnk;
+ return S_OK;
+}
+
+extern "C" STDAPI DllCanUnloadNow(void)
+{
+ if (CClassFactory::IsLocked() || g_DllRefCnt > 0)
+ return S_FALSE;
+
+ return S_OK;
+}
+
+BOOL WINAPI DllMain(HINSTANCE hInst, ULONG /*ul_reason_for_call*/, LPVOID /*lpReserved*/)
+{
+ g_hModule = hInst;
+ return TRUE;
+}
diff --git a/shell/source/win32/shlxthandler/thumbviewer/makefile.mk b/shell/source/win32/shlxthandler/thumbviewer/makefile.mk
new file mode 100644
index 000000000000..1b7dd103026e
--- /dev/null
+++ b/shell/source/win32/shlxthandler/thumbviewer/makefile.mk
@@ -0,0 +1,62 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+PRJNAME=shell
+TARGET=thumbviewer
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+=-DWIN32_LEAN_AND_MEAN -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+#CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS+=-D_WIN32_IE=0x501
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=$(SLO)$/$(TARGET).obj
+
+.IF "$(BUILD_X64)"!=""
+# ----------------- x64 ------------------------
+CFLAGS_X64+=-DWIN32_LEAN_AND_MEAN -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CDEFS_X64+=-D_WIN32_IE=0x501
+
+SLOFILES_X64=$(SLO_X64)$/$(TARGET).obj
+.ENDIF # "$(BUILD_X64)"!=""
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+.INCLUDE : tg_wntx64.mk
+
diff --git a/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx b/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx
new file mode 100644
index 000000000000..13f49c8a2efd
--- /dev/null
+++ b/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx
@@ -0,0 +1,532 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#include "internal/global.hxx"
+
+#ifndef INFOTIPS_HXX_INCLUDED
+#include "internal/thumbviewer.hxx"
+#endif
+#include "internal/shlxthdl.hxx"
+#include "internal/registry.hxx"
+#include "internal/fileextensions.hxx"
+#include "internal/config.hxx"
+#include "internal/zipfile.hxx"
+#include "internal/utilities.hxx"
+
+#include "internal/resource.h"
+
+#include <stdio.h>
+#include <utility>
+#include <stdlib.h>
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <shellapi.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <memory>
+
+extern HINSTANCE g_hModule;
+
+namespace internal
+{
+ /* The signet.png used for thumbnails of signed documents
+ is contained as resource in this module, the resource
+ id is 2000 */
+ void LoadSignetImageFromResource(ZipFile::ZipContentBuffer_t& buffer)
+ {
+ HRSRC hrc = FindResource(g_hModule, TEXT("#2000"), RT_RCDATA);
+ DWORD size = SizeofResource(g_hModule, hrc);
+ HGLOBAL hglob = LoadResource(g_hModule, hrc);
+ char* data = reinterpret_cast<char*>(LockResource(hglob));
+ buffer = ZipFile::ZipContentBuffer_t(data, data + size);
+ }
+
+ bool IsSignedDocument(const ZipFile* zipfile)
+ {
+ return zipfile->HasContent("META-INF/documentsignatures.xml");
+ }
+
+ bool IsWindowsXP()
+ {
+ OSVERSIONINFO osvi;
+ ZeroMemory(&osvi, sizeof(osvi));
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx(&osvi);
+
+ return ((osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
+ ((osvi.dwMajorVersion >= 5) && (osvi.dwMinorVersion >= 1)));
+ }
+
+ /* Calculate where to position the signet image.
+ On Windows ME we need to shift the signet a
+ little bit to the left because Windows ME
+ puts an overlay icon to the lower right
+ corner of a thumbnail image so that our signet
+ we be hidden. */
+ Gdiplus::Point CalcSignetPosition(
+ const Gdiplus::Rect& canvas, const Gdiplus::Rect& thumbnail_border, const Gdiplus::Rect& signet)
+ {
+ int x = 0;
+ int y = 0;
+ int hoffset = canvas.GetRight() - thumbnail_border.GetRight();
+ int voffset = canvas.GetBottom() - thumbnail_border.GetBottom();
+
+ if (hoffset > voffset)
+ {
+ x = thumbnail_border.GetRight() - signet.GetRight() + min(signet.GetRight() / 2, hoffset);
+ y = thumbnail_border.GetBottom() - signet.GetBottom();
+ }
+ else
+ {
+ x = thumbnail_border.GetRight() - signet.GetRight();
+ y = thumbnail_border.GetBottom() - signet.GetBottom() + min(signet.GetBottom() / 2, voffset);
+ }
+
+ if (!IsWindowsXP())
+ x -= 15;
+
+ return Gdiplus::Point(x,y);
+ }
+}
+
+class StreamOnZipBuffer : public IStream
+{
+public:
+ StreamOnZipBuffer(const ZipFile::ZipContentBuffer_t& zip_buffer);
+
+ // IUnknown
+ virtual ULONG STDMETHODCALLTYPE AddRef();
+ virtual ULONG STDMETHODCALLTYPE Release( void);
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject);
+
+ // IStream
+ virtual HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead);
+ virtual HRESULT STDMETHODCALLTYPE Write(void const *pv, ULONG cb, ULONG *pcbWritten);
+ virtual HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition);
+ virtual HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER libNewSize);
+ virtual HRESULT STDMETHODCALLTYPE CopyTo(IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten);
+ virtual HRESULT STDMETHODCALLTYPE Commit(DWORD grfCommitFlags);
+ virtual HRESULT STDMETHODCALLTYPE Revert(void);
+ virtual HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
+ virtual HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
+ virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG *pstatstg, DWORD grfStatFlag);
+ virtual HRESULT STDMETHODCALLTYPE Clone(IStream **ppstm);
+
+private:
+ LONG ref_count_;
+ const ZipFile::ZipContentBuffer_t& ref_zip_buffer_;
+ size_t pos_;
+};
+
+StreamOnZipBuffer::StreamOnZipBuffer(const ZipFile::ZipContentBuffer_t& zip_buffer) :
+ ref_count_(1),
+ ref_zip_buffer_(zip_buffer),
+ pos_(0)
+{
+}
+
+// IUnknown methods
+
+ULONG STDMETHODCALLTYPE StreamOnZipBuffer::AddRef(void)
+{
+ return InterlockedIncrement(&ref_count_);
+}
+
+ULONG STDMETHODCALLTYPE StreamOnZipBuffer::Release( void)
+{
+ long refcnt = InterlockedDecrement(&ref_count_);
+
+ if (0 == ref_count_)
+ delete this;
+
+ return refcnt;
+}
+
+HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::QueryInterface(REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ *ppvObject = 0;
+ IUnknown* pUnk = 0;
+
+ if ((IID_IUnknown == riid) || (IID_IStream == riid))
+ {
+ pUnk = static_cast<IStream*>(this);
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+ return E_NOINTERFACE;
+}
+
+HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::Read(void *pv, ULONG cb, ULONG *pcbRead)
+{
+ if (pv == NULL)
+ return STG_E_INVALIDPOINTER;
+
+ size_t size = ref_zip_buffer_.size();
+
+ if (pos_ > size)
+ return S_FALSE;
+
+ char* p = reinterpret_cast<char*>(pv);
+ ULONG read = 0;
+
+ for ( ;(pos_ < size) && (cb > 0); pos_++, cb--, read++)
+ *p++ = ref_zip_buffer_[pos_];
+
+ if (pcbRead)
+ *pcbRead = read;
+
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *)
+{
+ __int64 size = (__int64) ref_zip_buffer_.size();
+ __int64 p = 0;
+
+ switch (dwOrigin)
+ {
+ case STREAM_SEEK_SET:
+ break;
+ case STREAM_SEEK_CUR:
+ p = (__int64) pos_;
+ break;
+ case STREAM_SEEK_END:
+ p = size - 1;
+ break;
+ }
+
+ HRESULT hr = STG_E_INVALIDFUNCTION;
+
+ p += dlibMove.QuadPart;
+
+ if ( ( p >= 0 ) && (p < size) )
+ {
+ pos_ = (size_t) p;
+ hr = S_OK;
+ }
+ return hr;
+}
+
+HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::Stat(STATSTG *pstatstg, DWORD grfStatFlag)
+{
+ if (pstatstg == NULL)
+ return STG_E_INVALIDPOINTER;
+
+ ZeroMemory(pstatstg, sizeof(STATSTG));
+
+ if (grfStatFlag == STATFLAG_DEFAULT)
+ {
+ size_t sz = 4 * sizeof(wchar_t);
+ wchar_t* name = reinterpret_cast<wchar_t*>(CoTaskMemAlloc(sz));
+ ZeroMemory(name, sz);
+ memcpy(name, L"png", 3 * sizeof(wchar_t));
+ pstatstg->pwcsName = name;
+ }
+
+ pstatstg->type = STGTY_LOCKBYTES;
+
+ ULARGE_INTEGER uli;
+ uli.LowPart = ref_zip_buffer_.size();
+ uli.HighPart = 0;
+
+ pstatstg->cbSize = uli;
+
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::Write(void const *, ULONG, ULONG *)
+{ return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::SetSize(ULARGE_INTEGER)
+{ return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::CopyTo(IStream *, ULARGE_INTEGER, ULARGE_INTEGER *, ULARGE_INTEGER *)
+{ return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::Commit(DWORD)
+{ return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::Revert(void)
+{ return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::LockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD)
+{ return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::UnlockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD)
+{ return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::Clone(IStream **)
+{ return E_NOTIMPL; }
+
+
+//#########################################
+
+
+CThumbviewer::CThumbviewer(long RefCnt) :
+ ref_count_(RefCnt)
+{
+ InterlockedIncrement(&g_DllRefCnt);
+
+ thumbnail_size_.cx = 0;
+ thumbnail_size_.cy = 0;
+
+ Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ Gdiplus::GdiplusStartup(&gdiplus_token_, &gdiplusStartupInput, NULL);
+
+ ZipFile::ZipContentBuffer_t img_data;
+ internal::LoadSignetImageFromResource(img_data);
+ IStream* stream = new StreamOnZipBuffer(img_data);
+ signet_ = new Gdiplus::Bitmap(stream, TRUE);
+ stream->Release();
+}
+
+CThumbviewer::~CThumbviewer()
+{
+ delete signet_;
+ Gdiplus::GdiplusShutdown(gdiplus_token_);
+ InterlockedDecrement(&g_DllRefCnt);
+}
+
+// IUnknown methods
+
+HRESULT STDMETHODCALLTYPE CThumbviewer::QueryInterface(REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ *ppvObject = 0;
+ IUnknown* pUnk = 0;
+
+ if ((IID_IUnknown == riid) || (IID_IPersistFile == riid))
+ {
+ pUnk = static_cast<IPersistFile*>(this);
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+ else if (IID_IExtractImage == riid)
+ {
+ pUnk = static_cast<IExtractImage*>(this);
+ pUnk->AddRef();
+ *ppvObject = pUnk;
+ return S_OK;
+ }
+ return E_NOINTERFACE;
+}
+
+ULONG STDMETHODCALLTYPE CThumbviewer::AddRef(void)
+{
+ return InterlockedIncrement(&ref_count_);
+}
+
+ULONG STDMETHODCALLTYPE CThumbviewer::Release( void)
+{
+ long refcnt = InterlockedDecrement(&ref_count_);
+
+ if (0 == ref_count_)
+ delete this;
+
+ return refcnt;
+}
+
+// IExtractImage2 methods
+
+const std::string THUMBNAIL_CONTENT = "Thumbnails/thumbnail.png";
+
+HRESULT STDMETHODCALLTYPE CThumbviewer::Extract(HBITMAP *phBmpImage)
+{
+ HRESULT hr = E_FAIL;
+
+ try
+ {
+ std::auto_ptr<ZipFile> zipfile(new ZipFile(WStringToString(filename_)));
+
+ if (zipfile->HasContent(THUMBNAIL_CONTENT))
+ {
+ ZipFile::ZipContentBuffer_t thumbnail;
+ zipfile->GetUncompressedContent(THUMBNAIL_CONTENT, thumbnail);
+ IStream* stream = new StreamOnZipBuffer(thumbnail);
+
+ Gdiplus::Bitmap thumbnail_png(stream, TRUE);
+
+ if ((thumbnail_png.GetHeight() == 0) || (thumbnail_png.GetWidth() == 0))
+ {
+ stream->Release();
+ return E_FAIL;
+ }
+
+ HWND hwnd = GetDesktopWindow();
+ HDC hdc = GetDC(hwnd);
+ HDC memDC = CreateCompatibleDC(hdc);
+
+ if (memDC)
+ {
+ UINT offset = 3; // reserve a little border space
+
+ Gdiplus::Rect canvas(0, 0, thumbnail_size_.cx, thumbnail_size_.cy);
+ Gdiplus::Rect canvas_thumbnail(offset, offset, thumbnail_size_.cx - 2 * offset, thumbnail_size_.cy - 2 * offset);
+
+ Gdiplus::Rect scaledRect = CalcScaledAspectRatio(
+ Gdiplus::Rect(0, 0, thumbnail_png.GetWidth(), thumbnail_png.GetHeight()), canvas_thumbnail);
+
+ struct {
+ BITMAPINFOHEADER bi;
+ DWORD ct[256];
+ } dib;
+
+ ZeroMemory(&dib, sizeof(dib));
+
+ dib.bi.biSize = sizeof(BITMAPINFOHEADER);
+ dib.bi.biWidth = thumbnail_size_.cx;
+ dib.bi.biHeight = thumbnail_size_.cy;
+ dib.bi.biPlanes = 1;
+ dib.bi.biBitCount = static_cast<WORD>(color_depth_);
+ dib.bi.biCompression = BI_RGB;
+
+ LPVOID lpBits;
+ HBITMAP hMemBmp = CreateDIBSection(memDC, (LPBITMAPINFO)&dib, DIB_RGB_COLORS, &lpBits, NULL, 0);
+ HGDIOBJ hOldObj = SelectObject(memDC, hMemBmp);
+
+ Gdiplus::Graphics graphics(memDC);
+ Gdiplus::Pen blackPen(Gdiplus::Color(255, 0, 0, 0), 1);
+
+ Gdiplus::SolidBrush whiteBrush(Gdiplus::Color(255, 255, 255, 255));
+ graphics.FillRectangle(&whiteBrush, canvas);
+
+ scaledRect.X = (canvas.Width - scaledRect.Width) / 2;
+ scaledRect.Y = (canvas.Height - scaledRect.Height) / 2;
+
+ Gdiplus::Rect border_rect(scaledRect.X, scaledRect.Y, scaledRect.Width, scaledRect.Height);
+ graphics.DrawRectangle(&blackPen, border_rect);
+
+ scaledRect.X += 1;
+ scaledRect.Y += 1;
+ scaledRect.Width -= 1;
+ scaledRect.Height -= 1;
+
+ graphics.SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic);
+ Gdiplus::Status stat = graphics.DrawImage(
+ &thumbnail_png, scaledRect, 0 , 0,
+ thumbnail_png.GetWidth(), thumbnail_png.GetHeight(), Gdiplus::UnitPixel);
+
+ /* Add a signet sign to the thumbnail of signed documents */
+ if (internal::IsSignedDocument(zipfile.get()))
+ {
+ double SCALING_FACTOR = 0.6;
+ Gdiplus::Rect signet_scaled(
+ 0, 0, static_cast<INT>(signet_->GetWidth() * SCALING_FACTOR), static_cast<INT>(signet_->GetHeight() * SCALING_FACTOR));
+ Gdiplus::Point pos_signet = internal::CalcSignetPosition(canvas_thumbnail, border_rect, signet_scaled);
+ Gdiplus::Rect dest(pos_signet.X, pos_signet.Y, signet_scaled.GetRight(), signet_scaled.GetBottom());
+
+ stat = graphics.DrawImage(
+ signet_, dest,
+ 0, 0, signet_->GetWidth(), signet_->GetHeight(),
+ Gdiplus::UnitPixel);
+ }
+
+ if (stat == Gdiplus::Ok)
+ {
+ *phBmpImage = hMemBmp;
+ hr = NOERROR;
+ }
+
+ SelectObject(memDC, hOldObj);
+ DeleteDC(memDC);
+ }
+
+ ReleaseDC(hwnd, hdc);
+ stream->Release();
+ }
+ }
+ catch(std::exception&)
+ {
+ OutputDebugStringFormat( "CThumbviewer Extract ERROR!\n" );
+ hr = E_FAIL;
+ }
+ return hr;
+}
+
+HRESULT STDMETHODCALLTYPE CThumbviewer::GetLocation(
+ LPWSTR pszPathBuffer, DWORD cchMax, DWORD *pdwPriority, const SIZE *prgSize, DWORD dwRecClrDepth, DWORD *pdwFlags)
+{
+ if ((prgSize == NULL) || (pdwFlags == NULL) || ((*pdwFlags & IEIFLAG_ASYNC) && (pdwPriority == NULL)))
+ return E_INVALIDARG;
+
+ thumbnail_size_ = *prgSize;
+ color_depth_ = dwRecClrDepth;
+
+ *pdwFlags = IEIFLAG_CACHE; // we don't cache the image
+
+ wcsncpy(pszPathBuffer, filename_.c_str(), cchMax);
+
+ return NOERROR;
+}
+
+// IPersist methods
+
+HRESULT STDMETHODCALLTYPE CThumbviewer::GetClassID(CLSID* pClassID)
+{
+ pClassID = const_cast<CLSID*>(&CLSID_THUMBVIEWER_HANDLER);
+ return S_OK;
+}
+
+// IPersistFile methods
+
+HRESULT STDMETHODCALLTYPE CThumbviewer::Load(LPCOLESTR pszFileName, DWORD)
+{
+ filename_ = pszFileName;
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE CThumbviewer::IsDirty()
+{ return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE CThumbviewer::Save(LPCOLESTR, BOOL)
+{ return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE CThumbviewer::SaveCompleted(LPCOLESTR)
+{ return E_NOTIMPL; }
+
+HRESULT STDMETHODCALLTYPE CThumbviewer::GetCurFile(LPOLESTR __RPC_FAR*)
+{ return E_NOTIMPL; }
+
+
+Gdiplus::Rect CThumbviewer::CalcScaledAspectRatio(Gdiplus::Rect src, Gdiplus::Rect dest)
+{
+ Gdiplus::Rect result;
+ if (src.Width >= src.Height)
+ result = Gdiplus::Rect(0, 0, dest.Width, src.Height * dest.Width / src.Width);
+ else
+ result = Gdiplus::Rect(0, 0, src.Width * dest.Height / src.Height, dest.Height);
+
+ return result;
+}
+
diff --git a/shell/source/win32/shlxthandler/util/dbgmacros.cxx b/shell/source/win32/shlxthandler/util/dbgmacros.cxx
new file mode 100644
index 000000000000..01ef1d47c083
--- /dev/null
+++ b/shell/source/win32/shlxthandler/util/dbgmacros.cxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <stdio.h>
+#include "internal/dbgmacros.hxx"
+
+void DbgAssert(bool /*condition*/, const char* /*message*/)
+{
+
+ //if (!condition)
+ //{
+ // char msg[1024];
+ //
+ // sprintf(msg, "Assertion in file %s at line %d\n%s", __FILE__, __LINE__, message);
+
+ // int nRet = MessageBoxA(
+ // 0,
+ // msg,
+ // "Assertion violation",
+ // MB_ICONEXCLAMATION | MB_ABORTRETRYIGNORE);
+ //}
+
+}
+
diff --git a/shell/source/win32/shlxthandler/util/fileextensions.cxx b/shell/source/win32/shlxthandler/util/fileextensions.cxx
new file mode 100644
index 000000000000..b8de490a5c47
--- /dev/null
+++ b/shell/source/win32/shlxthandler/util/fileextensions.cxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/fileextensions.hxx"
+
+//------------------------------------
+//
+//------------------------------------
+
+const std::string WRITER_FILE_EXTENSIONS = "sxwstwsxgodtottodm";
+const std::string CALC_FILE_EXTENSIONS = "sxcstcodsots";
+const std::string DRAW_FILE_EXTENSIONS = "sxdstdodgotg";
+const std::string IMPRESS_FILE_EXTENSIONS = "sxistiodpotp";
+const std::string MATH_FILE_EXTENSIONS = "sxmodf";
+const std::string WEB_FILE_EXTENSIONS = "oth";
+const std::string DATABASE_FILE_EXTENSIONS = "odb";
+
+FileExtensionEntry OOFileExtensionTable[] = {
+ { ".sxw", L".sxw", "soffice.StarWriterDocument.6" },
+ { ".sxc", L".sxc", "soffice.StarCalcDocument.6" },
+ { ".sxi", L".sxi", "soffice.StarImpressDocument.6" },
+ { ".sxd", L".sxd", "soffice.StarDrawDocument.6" },
+ { ".sxm", L".sxm", "soffice.StarMathDocument.6" },
+ { ".stw", L".stw", "soffice.StarWriterTemplate.6" },
+ { ".sxg", L".sxg", "soffice.StarWriterGlobalDocument.6"},
+ { ".std", L".std", "soffice.StarDrawTemplate.6" },
+ { ".sti", L".sti", "soffice.StarImpressTemplate.6" },
+ { ".stc", L".stc", "soffice.StarCalcTemplate.6" },
+ { ".odt", L".odt", "opendocument.WriterDocument.1" },
+ { ".ott", L".ott", "opendocument.WriterTemplate.1" },
+ { ".odm", L".odm", "opendocument.WriterGlobalDocument.1" },
+ { ".oth", L".oth", "opendocument.WriterWebTemplate.1" },
+ { ".ods", L".ods", "opendocument.CalcDocument.1" },
+ { ".ots", L".ots", "opendocument.CalcTemplate.1" },
+ { ".odg", L".odg", "opendocument.DrawDocument.1" },
+ { ".otg", L".otg", "opendocument.DrawTemplate.1" },
+ { ".odp", L".odp", "opendocument.ImpressDocument.1" },
+ { ".otp", L".otp", "opendocument.ImpressTemplate.1" },
+ { ".odf", L".odf", "opendocument.MathDocument.1" },
+ { ".odb", L".odb", "opendocument.DatabaseDocument.1" }
+ };
+
+
+size_t OOFileExtensionTableSize = sizeof(OOFileExtensionTable)/sizeof(OOFileExtensionTable[0]);
+
+//---------------------------------
+/** Return the extension of a file
+ name without the '.'
+*/
+std::string get_file_name_extension(const std::string& file_name)
+{
+ std::string::size_type idx = file_name.find_last_of(".");
+
+ if (std::string::npos != idx++)
+ return std::string(file_name.begin() + idx, file_name.end());
+
+ return std::string();
+}
+
+//---------------------------------
+/** Return the type of a file
+*/
+
+File_Type_t get_file_type(const std::string& file_name)
+{
+ std::string fext = get_file_name_extension(file_name);
+
+ if (std::string::npos != WRITER_FILE_EXTENSIONS.find(fext))
+ return WRITER;
+ else if (std::string::npos != CALC_FILE_EXTENSIONS.find(fext))
+ return CALC;
+ else if (std::string::npos != DRAW_FILE_EXTENSIONS.find(fext))
+ return DRAW;
+ else if (std::string::npos != IMPRESS_FILE_EXTENSIONS.find(fext))
+ return IMPRESS;
+ else if (std::string::npos != MATH_FILE_EXTENSIONS.find(fext))
+ return MATH;
+ else if (std::string::npos != WEB_FILE_EXTENSIONS.find(fext))
+ return WEB;
+ else if (std::string::npos != DATABASE_FILE_EXTENSIONS.find(fext))
+ return DATABASE;
+ else
+ return UNKNOWN;
+}
+
diff --git a/shell/source/win32/shlxthandler/util/iso8601_converter.cxx b/shell/source/win32/shlxthandler/util/iso8601_converter.cxx
new file mode 100644
index 000000000000..dcd779098865
--- /dev/null
+++ b/shell/source/win32/shlxthandler/util/iso8601_converter.cxx
@@ -0,0 +1,182 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/iso8601_converter.hxx"
+#include "internal/utilities.hxx"
+
+#include <sstream>
+#include <iomanip>
+
+//-----------------------------------
+/* Converts ISO 8601 conform date/time
+ represenation to the representation
+ conforming to the current locale
+*/
+std::wstring iso8601_date_to_local_date(const std::wstring& isoDate )
+{
+ const std::wstring CONST_SPACE(L" ");
+ ::std::wstring ws8601DateTime(isoDate);
+
+ if ( ws8601DateTime.length() == 19 )
+ {
+ //fill in the SYSTEMTIME structure;
+ std::string asDateTime = WStringToString( ws8601DateTime );
+ SYSTEMTIME DateTime;
+ DateTime.wYear = ( unsigned short )strtol( asDateTime.substr( 0, 4 ).c_str(), NULL, 10 );
+ DateTime.wMonth = ( unsigned short )strtol( asDateTime.substr( 5, 2 ).c_str(), NULL, 10 );
+ DateTime.wDayOfWeek = 0;
+ DateTime.wDay = ( unsigned short )strtol( asDateTime.substr( 8, 2 ).c_str(), NULL, 10 );
+ DateTime.wHour = ( unsigned short )strtol( asDateTime.substr( 11,2 ).c_str(), NULL, 10 );
+ DateTime.wMinute = ( unsigned short )strtol( asDateTime.substr( 14,2 ).c_str(), NULL, 10 );
+ DateTime.wSecond = ( unsigned short )strtol( asDateTime.substr( 17,2 ).c_str(), NULL, 10 );
+ DateTime.wMilliseconds = 0;
+
+ //get Date info from structure
+ WCHAR DateBuffer[ MAX_PATH ];
+ int DateSize = GetDateFormatW(
+ LOCALE_SYSTEM_DEFAULT,
+ 0,
+ &DateTime,
+ NULL,
+ DateBuffer,
+ MAX_PATH );
+
+ if ( DateSize )
+ ws8601DateTime.assign(DateBuffer);
+ else
+ ws8601DateTime = StringToWString( asDateTime );
+
+ //get Time info from structure
+ WCHAR TimeBuffer[ MAX_PATH ];
+
+ int TimeSize = GetTimeFormatW(
+ LOCALE_SYSTEM_DEFAULT,
+ 0,
+ &DateTime,
+ NULL,
+ TimeBuffer,
+ MAX_PATH );
+
+ if ( TimeSize )
+ {
+ ws8601DateTime.append(L" ");
+ ws8601DateTime.append(TimeBuffer);
+ }
+ else
+ ws8601DateTime = StringToWString( asDateTime );
+ }
+
+ return ws8601DateTime;
+}
+
+//------------------------------------
+/* Converts ISO 8601 conform duration
+ representation to the representation
+ conforming to the current locale
+
+ Expect format PTnHnMnS according to
+ ISO 8601 where n is abitrary number
+ of digits
+*/
+
+std::wstring iso8601_duration_to_local_duration(const std::wstring& iso8601duration)
+{
+ std::wstring days;
+ std::wstring hours;
+ std::wstring minutes;
+ std::wstring seconds;
+
+ std::wstring::const_iterator iter = iso8601duration.begin();
+ std::wstring::const_iterator iter_end = iso8601duration.end();
+
+ std::wstring num;
+
+ for (/**/; iter != iter_end; ++iter)
+ {
+ if (isdigit(*iter))
+ {
+ num += *iter;
+ }
+ else
+ {
+ if (*iter == L'D' || *iter == L'd')
+ days = num;
+ else if (*iter == L'H' || *iter == L'h')
+ hours = num;
+ else if (*iter == L'M' || *iter == L'm')
+ minutes = num;
+ else if (*iter == L'S' || *iter == L's')
+ seconds = num;
+
+ num.clear();
+ }
+ }
+
+ if (days.length() > 0)
+ {
+ int h = ((_wtoi(days.c_str()) * 24) + _wtoi(hours.c_str()));
+ wchar_t buff[10];
+ _itow(h, buff, 10);
+ hours = buff;
+ }
+
+#if defined(_MSC_VER) //&& defined(_M_X64)
+ std::wostringstream oss;
+ oss << std::setw(2) << std::setfill(wchar_t('0')) << hours << L":" <<
+ std::setw(2) << std::setfill(wchar_t('0')) << minutes << L":" <<
+ std::setw(2) << std::setfill(wchar_t('0')) << seconds;
+ return oss.str();
+#elif defined( __MINGW32__ )
+#define ADD_AS_PREFILLED( st, out ) \
+ if ( st.length() == 0 ) \
+ out += L"00"; \
+ else if ( st.length() == 1 ) \
+ out += L"0"; \
+ out += st;
+
+ std::wstring result;
+ ADD_AS_PREFILLED( hours, result )
+ result += L":";
+ ADD_AS_PREFILLED( minutes, result )
+ result += L":";
+ ADD_AS_PREFILLED( seconds, result )
+
+ return result;
+#undef ADD_AS_PREFILLED
+/*
+#else
+ std::wostringstream oss;
+ oss << std::setw(2) << std::setfill('0') << hours << L":" <<
+ std::setw(2) << std::setfill('0') << minutes << L":" <<
+ std::setw(2) << std::setfill('0') << seconds;
+ return oss.str();
+*/
+#endif
+}
+
diff --git a/shell/source/win32/shlxthandler/util/makefile.mk b/shell/source/win32/shlxthandler/util/makefile.mk
new file mode 100644
index 000000000000..8ccf50602f93
--- /dev/null
+++ b/shell/source/win32/shlxthandler/util/makefile.mk
@@ -0,0 +1,68 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+PRJNAME=shell
+TARGET=util
+#LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS+=-D_WIN32_IE=0x501
+
+CFLAGS_X64+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS_X64+=-D_WIN32_IE=0x501
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=$(SLO)$/dbgmacros.obj\
+ $(SLO)$/fileextensions.obj\
+ $(SLO)$/registry.obj\
+ $(SLO)$/utilities.obj\
+ $(SLO)$/iso8601_converter.obj
+
+SLOFILES_X64=$(SLO_X64)$/dbgmacros.obj\
+ $(SLO_X64)$/fileextensions.obj\
+ $(SLO_X64)$/registry.obj\
+ $(SLO_X64)$/utilities.obj\
+ $(SLO_X64)$/iso8601_converter.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+.INCLUDE : tg_wntx64.mk
+
diff --git a/shell/source/win32/shlxthandler/util/registry.cxx b/shell/source/win32/shlxthandler/util/registry.cxx
new file mode 100644
index 000000000000..bac126bb0504
--- /dev/null
+++ b/shell/source/win32/shlxthandler/util/registry.cxx
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <malloc.h>
+#include "internal/dbgmacros.hxx"
+#include "internal/registry.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <objbase.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+//---------------------------------------
+//
+//---------------------------------------
+
+// Size of a CLSID as a string
+const int CLSID_STRING_SIZE = 39;
+
+//---------------------------------------
+//
+//---------------------------------------
+
+bool SetRegistryKey(HKEY RootKey, const char* KeyName, const char* ValueName, const char* Value)
+{
+ HKEY hSubKey;
+
+ // open or create the desired key
+ int rc = RegCreateKeyExA(
+ RootKey, KeyName, 0, "", REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, &hSubKey, 0);
+
+ if (ERROR_SUCCESS == rc)
+ {
+ rc = RegSetValueExA(
+ hSubKey, ValueName, 0, REG_SZ, reinterpret_cast<const BYTE*>(Value), strlen(Value) + 1);
+
+ RegCloseKey(hSubKey);
+ }
+
+ return (ERROR_SUCCESS == rc);
+}
+
+//---------------------------------------
+//
+//---------------------------------------
+
+bool DeleteRegistryKey(HKEY RootKey, const char* KeyName)
+{
+ HKEY hKey;
+
+ int rc = RegOpenKeyExA(
+ RootKey,
+ KeyName,
+ 0,
+ KEY_READ | DELETE,
+ &hKey);
+
+ if ( rc == ERROR_FILE_NOT_FOUND )
+ return true;
+
+ if (ERROR_SUCCESS == rc)
+ {
+ char* SubKey;
+ DWORD nMaxSubKeyLen;
+
+ rc = RegQueryInfoKeyA(
+ hKey, 0, 0, 0, 0,
+ &nMaxSubKeyLen,
+ 0, 0, 0, 0, 0, 0);
+
+ nMaxSubKeyLen++; // space for trailing '\0'
+
+ SubKey = reinterpret_cast<char*>(
+ _alloca(nMaxSubKeyLen*sizeof(char)));
+
+ while (ERROR_SUCCESS == rc)
+ {
+ DWORD nLen = nMaxSubKeyLen;
+
+ rc = RegEnumKeyExA(
+ hKey,
+ 0, // always index zero
+ SubKey,
+ &nLen,
+ 0, 0, 0, 0);
+
+ if (ERROR_NO_MORE_ITEMS == rc)
+ {
+ rc = RegDeleteKeyA(RootKey, KeyName);
+ break;
+ }
+ else if (rc == ERROR_SUCCESS)
+ {
+ DeleteRegistryKey(hKey, SubKey);
+ }
+
+ } // while
+
+ RegCloseKey(hKey);
+
+ } // if
+
+ return (ERROR_SUCCESS == rc);
+}
+
+/** May be used to determine if the specified registry key has subkeys
+ The function returns true on success else if an error occures false
+*/
+bool HasSubkeysRegistryKey(HKEY RootKey, const char* KeyName, /* out */ bool& bResult)
+{
+ HKEY hKey;
+
+ LONG rc = RegOpenKeyExA(RootKey, KeyName, 0, KEY_READ, &hKey);
+
+ if (ERROR_SUCCESS == rc)
+ {
+ DWORD nSubKeys = 0;
+
+ rc = RegQueryInfoKeyA(hKey, 0, 0, 0, &nSubKeys, 0, 0, 0, 0, 0, 0, 0);
+
+ bResult = (nSubKeys > 0);
+ }
+
+ return (ERROR_SUCCESS == rc);
+}
+
+// Convert a CLSID to a char string.
+std::string ClsidToString(const CLSID& clsid)
+{
+ // Get CLSID
+ LPOLESTR wszCLSID = NULL;
+ StringFromCLSID(clsid, &wszCLSID);
+
+ char buff[39];
+ // Covert from wide characters to non-wide.
+ wcstombs(buff, wszCLSID, sizeof(buff));
+
+ // Free memory.
+ CoTaskMemFree(wszCLSID) ;
+
+ return std::string(buff);
+}
+
+//---------------------------------------
+//
+//---------------------------------------
+
+bool QueryRegistryKey(HKEY RootKey, const char* KeyName, const char* ValueName, char *pszData, DWORD dwBufLen)
+{
+ HKEY hKey;
+
+ int rc = RegOpenKeyExA(
+ RootKey,
+ KeyName,
+ 0,
+ KEY_READ,
+ &hKey);
+
+ if (ERROR_SUCCESS == rc)
+ {
+ rc = RegQueryValueExA(
+ hKey, ValueName, NULL, NULL, (LPBYTE)pszData,&dwBufLen);
+
+ RegCloseKey(hKey);
+ }
+
+ return (ERROR_SUCCESS == rc);
+}
diff --git a/shell/source/win32/shlxthandler/util/utilities.cxx b/shell/source/win32/shlxthandler/util/utilities.cxx
new file mode 100644
index 000000000000..f721c4113aa8
--- /dev/null
+++ b/shell/source/win32/shlxthandler/util/utilities.cxx
@@ -0,0 +1,577 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+
+#include "internal/config.hxx"
+#include "internal/dbgmacros.hxx"
+#include "internal/utilities.hxx"
+
+//-----------------------------
+// constants
+//-----------------------------
+
+const size_t MAX_RES_STRING = 1024;
+const wchar_t SPACE_CHAR = _T(' ');
+
+//---------------------------------
+/**
+*/
+std::wstring StringToWString(const std::string& String)
+{
+ int len = MultiByteToWideChar(
+ CP_ACP, 0, String.c_str(), -1, 0, 0);
+
+ wchar_t* buff = reinterpret_cast<wchar_t*>(
+ _alloca(len * sizeof(wchar_t)));
+
+ MultiByteToWideChar(
+ CP_ACP, 0, String.c_str(), -1, buff, len);
+
+ return std::wstring(buff);
+}
+
+//---------------------------------
+/**
+*/
+std::string WStringToString(const std::wstring& String)
+{
+ int len = WideCharToMultiByte(
+ CP_ACP, 0, String.c_str(), -1, 0, 0, 0, 0);
+
+ char* buff = reinterpret_cast<char*>(
+ _alloca(len * sizeof(char)));
+
+ WideCharToMultiByte(
+ CP_ACP, 0, String.c_str(), -1, buff, len, 0, 0);
+
+ return std::string(buff);
+}
+
+//---------------------------------
+/**
+*/
+std::wstring GetResString(int ResId)
+{
+ wchar_t szResStr[MAX_RES_STRING];
+
+ int rc = LoadStringW( GetModuleHandleW(MODULE_NAME), ResId, szResStr, sizeof(szResStr) );
+
+ OutputDebugStringFormat( "GetResString: read %d chars\n", rc );
+ ENSURE(rc, "String resource not found");
+
+ return std::wstring(szResStr);
+}
+
+//---------------------------------
+/**
+*/
+bool is_windows_xp_or_above()
+{
+ OSVERSIONINFO osvi;
+ ZeroMemory(&osvi, sizeof(osvi));
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx(&osvi);
+
+ // LLA: check for windows xp or above (Vista)
+ if (osvi.dwMajorVersion > 5 ||
+ (5 == osvi.dwMajorVersion && osvi.dwMinorVersion >= 1))
+ {
+ return true;
+ }
+ return false;
+}
+
+//---------------------------------
+/**
+*/
+
+void SaveDebugInfoToFile( const std::wstring& str )
+{
+ int handle;
+
+ if ((handle = open("c:\\temp\\SHELLRESULT.$$$", O_CREAT | O_RDWR | O_APPEND )) == -1)
+ {
+ perror("Error: open file error");
+ return;
+ }
+ write(handle, str.c_str(), str.length() );
+ close(handle);
+}
+
+//---------------------------------
+/** helper function to judge if the string is only has spaces.
+ @returns
+ <TRUE>if the provided string contains only but at least one space
+ character else <FALSE/>.
+*/
+
+bool HasOnlySpaces(const std::wstring& String)
+{
+ if ( String.length() == 0 )
+ return false;
+
+ const wchar_t* p = String.c_str();
+
+ while (*p)
+ {
+ if (*p++ != SPACE_CHAR)
+ return false;
+ }
+
+ return true;
+}
+
+/** convert LocaleSet pair into Microsoft List of Locale ID (LCID)
+ according to ISO-639 and ISO-3166.
+ http://etext.lib.virginia.edu/tei/iso639.html
+ http://nl.ijs.si/gnusl/cee/std/ISO_3166.html
+ @param
+ Locale, LocaleSet
+ @returns
+ Windows Locale Identifier corresponding to input LocaleSet.
+ @Usage Sample
+ LocaleSet_t myDefaultLocale( ::std::wstring( L"zh" ),::std::wstring(L"HK") );
+ DWORD myLCID = LocaleSetToLCID( myDefaultLocale );
+ wchar_t buffer[20];
+ _ultow( myLCID, buffer, 16 );
+ MessageBox( NULL, buffer,L"the LCID is:",MB_OK );
+*/
+
+LCID LocaleSetToLCID( const LocaleSet_t & Locale )
+{
+ if ( EMPTY_LOCALE == Locale )
+ return GetSystemDefaultLCID();
+
+ USHORT usPrimaryLang= LANG_NEUTRAL;
+ USHORT usSubLang=SUBLANG_DEFAULT;
+
+ ::std::wstring wsLanguage(Locale.first);
+ ::std::wstring wsCountry(Locale.second);
+
+ if ( wsLanguage == L"ar" )
+ {
+ usPrimaryLang = LANG_ARABIC; // Arabic 01
+
+ if ( wsCountry == L"SA" )
+ usSubLang = SUBLANG_ARABIC_SAUDI_ARABIA; // Arabic (Saudi Arabia)
+ else if ( wsCountry == L"IQ" )
+ usSubLang = SUBLANG_ARABIC_IRAQ; // Arabic (Iraq)
+ else if ( wsCountry == L"EG" )
+ usSubLang = SUBLANG_ARABIC_EGYPT; // Arabic (Egypt)
+ else if ( wsCountry == L"LY" )
+ usSubLang = SUBLANG_ARABIC_LIBYA; // Arabic (Libya)
+ else if ( wsCountry == L"DZ" )
+ usSubLang = SUBLANG_ARABIC_ALGERIA; // Arabic (Algeria)
+ else if ( wsCountry == L"MA" )
+ usSubLang = SUBLANG_ARABIC_MOROCCO; // Arabic (Morocco)
+ else if ( wsCountry == L"TN" )
+ usSubLang = SUBLANG_ARABIC_TUNISIA; // Arabic (Tunisia)
+ else if ( wsCountry == L"OM" )
+ usSubLang = SUBLANG_ARABIC_OMAN; // Arabic (Oman)
+ else if ( wsCountry == L"YE" )
+ usSubLang = SUBLANG_ARABIC_YEMEN; // Arabic (Yemen)
+ else if ( wsCountry == L"SY" )
+ usSubLang = SUBLANG_ARABIC_SYRIA; // Arabic (Syria)
+ else if ( wsCountry == L"JO" )
+ usSubLang = SUBLANG_ARABIC_JORDAN; // Arabic (Jordan)
+ else if ( wsCountry == L"LB" )
+ usSubLang = SUBLANG_ARABIC_LEBANON; // Arabic (Lebanon)
+ else if ( wsCountry == L"KW" )
+ usSubLang = SUBLANG_ARABIC_KUWAIT; // Arabic (Kuwait)
+ else if ( wsCountry == L"AE" )
+ usSubLang = SUBLANG_ARABIC_UAE; // Arabic (U.A.E.)
+ else if ( wsCountry == L"BH" )
+ usSubLang = SUBLANG_ARABIC_BAHRAIN; // Arabic (Bahrain)
+ else if ( wsCountry == L"QA" )
+ usSubLang = SUBLANG_ARABIC_QATAR; // Arabic (Qatar)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"bg" )
+ usPrimaryLang = LANG_BULGARIAN; //Bulgarian 02
+ else if ( wsLanguage == L"ca" )
+ usPrimaryLang = LANG_CATALAN; //Catalan 03
+ else if ( wsLanguage == L"zh" )
+ {
+ usPrimaryLang = LANG_CHINESE; //Chinese
+ if ( wsCountry == L"TW" )
+ usSubLang = SUBLANG_CHINESE_TRADITIONAL; // Chinese (Traditional)
+ else if ( wsCountry == L"CN" )
+ usSubLang = SUBLANG_CHINESE_SIMPLIFIED; // Chinese (Simplified)
+ else if ( wsCountry == L"HK" )
+ usSubLang = SUBLANG_CHINESE_HONGKONG; // Chinese (Hong Kong SAR, PRC)
+ else if ( wsCountry == L"SG" )
+ usSubLang = SUBLANG_CHINESE_SINGAPORE; // Chinese (Singapore)
+ else if ( wsCountry == L"MO" )
+ usSubLang = SUBLANG_CHINESE_MACAU; // Chinese (Macau SAR)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"cs" )
+ usPrimaryLang = LANG_CZECH; //Czech
+ else if ( wsLanguage == L"da" )
+ usPrimaryLang = LANG_DANISH; //Danish
+ else if ( wsLanguage == L"de" )
+ {
+ usPrimaryLang = LANG_GERMAN; //German
+ if ( wsCountry == L"DE" )
+ usSubLang = SUBLANG_GERMAN; // German
+ else if ( wsCountry == L"CH" )
+ usSubLang = SUBLANG_GERMAN_SWISS; // German (Swiss)
+ else if ( wsCountry == L"AT" )
+ usSubLang = SUBLANG_GERMAN_AUSTRIAN; // German (Austrian)
+ else if ( wsCountry == L"LU" )
+ usSubLang = SUBLANG_GERMAN_LUXEMBOURG; // German (Luxembourg)
+ else if ( wsCountry == L"LI" )
+ usSubLang = SUBLANG_GERMAN_LIECHTENSTEIN; // German (Liechtenstein)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"el" )
+ usPrimaryLang = LANG_GREEK; //Greek
+ else if ( wsLanguage == L"en" )
+ {
+ usPrimaryLang = LANG_ENGLISH; //English
+ if ( wsCountry == L"US" )
+ usSubLang = SUBLANG_ENGLISH_US; // English (US)
+ else if ( wsCountry == L"GB" )
+ usSubLang = SUBLANG_ENGLISH_UK; // English (UK)
+ else if ( wsCountry == L"AU" )
+ usSubLang = SUBLANG_ENGLISH_AUS; // English (Australian)
+ else if ( wsCountry == L"CA" )
+ usSubLang = SUBLANG_ENGLISH_CAN; // English (Canadian)
+ else if ( wsCountry == L"NZ" )
+ usSubLang = SUBLANG_ENGLISH_NZ; // English (New Zealand)
+ else if ( wsCountry == L"IE" )
+ usSubLang = SUBLANG_ENGLISH_EIRE; // English (Ireland)
+ else if ( wsCountry == L"ZA" )
+ usSubLang = SUBLANG_ENGLISH_SOUTH_AFRICA; // English (South Africa)
+ else if ( wsCountry == L"JM" )
+ usSubLang = SUBLANG_ENGLISH_JAMAICA; // English (Jamaica)
+ else if ( wsCountry == L"GD" )
+ usSubLang = SUBLANG_ENGLISH_CARIBBEAN; // English (Caribbean) Grenada
+ else if ( wsCountry == L"BZ" )
+ usSubLang = SUBLANG_ENGLISH_BELIZE; // English (Belize)
+ else if ( wsCountry == L"TT" )
+ usSubLang = SUBLANG_ENGLISH_TRINIDAD; // English (Trinidad)
+ else if ( wsCountry == L"ZW" )
+ usSubLang = SUBLANG_ENGLISH_ZIMBABWE; // English (Zimbabwe)
+ else if ( wsCountry == L"PH" )
+ usSubLang = SUBLANG_ENGLISH_PHILIPPINES; // English (Philippines)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"es" )
+ {
+ usPrimaryLang = LANG_SPANISH; //Spanish
+ //else if ( wsCountry == L"ES" )
+ // usSubLang = SUBLANG_SPANISH; // Spanish (Castilian)
+ if ( wsCountry == L"MX" )
+ usSubLang = SUBLANG_SPANISH_MEXICAN; // Spanish (Mexican)
+ else if ( wsCountry == L"ES" )
+ usSubLang = SUBLANG_SPANISH_MODERN; // Spanish (Spain)
+ else if ( wsCountry == L"GT" )
+ usSubLang = SUBLANG_SPANISH_GUATEMALA; // Spanish (Guatemala)
+ else if ( wsCountry == L"CR" )
+ usSubLang = SUBLANG_SPANISH_COSTA_RICA; // Spanish (Costa Rica)
+ else if ( wsCountry == L"PA" )
+ usSubLang = SUBLANG_SPANISH_PANAMA; // Spanish (Panama)
+ else if ( wsCountry == L"DO" )
+ usSubLang = SUBLANG_SPANISH_DOMINICAN_REPUBLIC; // Spanish (Dominican Republic)
+ else if ( wsCountry == L"VE" )
+ usSubLang = SUBLANG_SPANISH_VENEZUELA; // Spanish (Venezuela)
+ else if ( wsCountry == L"CO" )
+ usSubLang = SUBLANG_SPANISH_COLOMBIA; // Spanish (Colombia)
+ else if ( wsCountry == L"PE" )
+ usSubLang = SUBLANG_SPANISH_PERU; // Spanish (Peru)
+ else if ( wsCountry == L"AR" )
+ usSubLang = SUBLANG_SPANISH_ARGENTINA; // Spanish (Argentina)
+ else if ( wsCountry == L"EC" )
+ usSubLang = SUBLANG_SPANISH_ECUADOR; // Spanish (Ecuador)
+ else if ( wsCountry == L"CL" )
+ usSubLang = SUBLANG_SPANISH_CHILE; // Spanish (Chile)
+ else if ( wsCountry == L"UY" )
+ usSubLang = SUBLANG_SPANISH_URUGUAY; // Spanish (Uruguay)
+ else if ( wsCountry == L"PY" )
+ usSubLang = SUBLANG_SPANISH_PARAGUAY; // Spanish (Paraguay)
+ else if ( wsCountry == L"BO" )
+ usSubLang = SUBLANG_SPANISH_BOLIVIA; // Spanish (Bolivia)
+ else if ( wsCountry == L"SV" )
+ usSubLang = SUBLANG_SPANISH_EL_SALVADOR; // Spanish (El Salvador)
+ else if ( wsCountry == L"HN" )
+ usSubLang = SUBLANG_SPANISH_HONDURAS; // Spanish (Honduras)
+ else if ( wsCountry == L"NI" )
+ usSubLang = SUBLANG_SPANISH_NICARAGUA; // Spanish (Nicaragua)
+ else if ( wsCountry == L"PR" )
+ usSubLang = SUBLANG_SPANISH_PUERTO_RICO; // Spanish (Puerto Rico)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"fi" )
+ usPrimaryLang = LANG_FINNISH; //Finnish
+ else if ( wsLanguage == L"fr" )
+ {
+ usPrimaryLang = LANG_FRENCH; //French
+ if ( wsCountry == L"FR" )
+ usSubLang = SUBLANG_FRENCH; // French
+ else if ( wsCountry == L"BE" )
+ usSubLang = SUBLANG_FRENCH_BELGIAN; // French (Belgian)
+ else if ( wsCountry == L"CA" )
+ usSubLang = SUBLANG_FRENCH_CANADIAN; // French (Canadian)
+ else if ( wsCountry == L"CH" )
+ usSubLang = SUBLANG_FRENCH_SWISS; // French (Swiss)
+ else if ( wsCountry == L"LU" )
+ usSubLang = SUBLANG_FRENCH_LUXEMBOURG; // French (Luxembourg)
+ else if ( wsCountry == L"MC" )
+ usSubLang = SUBLANG_FRENCH_MONACO; // French (Monaco)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"iw" )
+ usPrimaryLang = LANG_HEBREW; //Hebrew
+ else if ( wsLanguage == L"hu" )
+ usPrimaryLang = LANG_HUNGARIAN; //Hungarian
+ else if ( wsLanguage == L"is" )
+ usPrimaryLang = LANG_ICELANDIC; //Icelandic
+ else if ( wsLanguage == L"it" )
+ {
+ usPrimaryLang = LANG_ITALIAN; //Italian
+ if ( wsCountry == L"IT" )
+ usSubLang = SUBLANG_ITALIAN; // Italian
+ else if ( wsCountry == L"CH" )
+ usSubLang = SUBLANG_ITALIAN_SWISS; // Italian (Swiss)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"ja" )
+ usPrimaryLang = LANG_JAPANESE; //Japanese
+ else if ( wsLanguage == L"ko" )
+ {
+ usPrimaryLang = LANG_KOREAN; //Korean
+ if ( wsCountry == L"KR" )
+ usSubLang = SUBLANG_KOREAN; // Korean
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"nl" )
+ {
+ usPrimaryLang = LANG_DUTCH; //Dutch
+ if ( wsCountry == L"NL" )
+ usSubLang = SUBLANG_DUTCH; // Dutch
+ else if ( wsCountry == L"BE" )
+ usSubLang = SUBLANG_DUTCH_BELGIAN; // Dutch (Belgian)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"no" )
+ {
+ usPrimaryLang = LANG_NORWEGIAN; //Norwegian
+ if ( wsCountry == L"NO" )
+ usSubLang = SUBLANG_NORWEGIAN_BOKMAL; // Norwegian (Bokmal)
+ //else if ( wsCountry == L"NO" )
+ // usSubLang = SUBLANG_NORWEGIAN_NYNORSK; // Norwegian (Nynorsk)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"pl" )
+ usPrimaryLang = LANG_POLISH; //Polish
+ else if ( wsLanguage == L"pt" )
+ {
+ usPrimaryLang = LANG_PORTUGUESE; //Portuguese
+ if ( wsCountry == L"BR" )
+ usSubLang = SUBLANG_PORTUGUESE_BRAZILIAN; // Portuguese (Brazil)
+ else if ( wsCountry == L"PT" )
+ usSubLang = SUBLANG_PORTUGUESE; // Portuguese (Portugal)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"ro" )
+ usPrimaryLang = LANG_ROMANIAN; //Romanian
+ else if ( wsLanguage == L"ru" )
+ usPrimaryLang = LANG_RUSSIAN; //Russian
+ else if ( wsLanguage == L"hr" )
+ usPrimaryLang = LANG_CROATIAN; //Croatian
+ else if ( wsLanguage == L"sr" )
+ {
+ usPrimaryLang = LANG_SERBIAN; //Serbian
+ if ( wsCountry == L"VA" )
+ usSubLang = SUBLANG_SERBIAN_LATIN; // Serbian (Latin)
+ else if ( wsCountry == L"HR" )
+ usSubLang = SUBLANG_SERBIAN_CYRILLIC; // Serbian (Cyrillic)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"sk" )
+ usPrimaryLang = LANG_SLOVAK; //Slovak
+ else if ( wsLanguage == L"sq" )
+ usPrimaryLang = LANG_ALBANIAN; //Albanian
+ else if ( wsLanguage == L"sv" )
+ {
+ usPrimaryLang = LANG_SWEDISH; //Swedish
+ if ( wsCountry == L"SE" )
+ usSubLang = SUBLANG_SWEDISH; // Swedish
+ else if ( wsCountry == L"FI" )
+ usSubLang = SUBLANG_SWEDISH_FINLAND; // Swedish (Finland)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"th" )
+ usPrimaryLang = LANG_THAI; //Thai
+ else if ( wsLanguage == L"tr" )
+ usPrimaryLang = LANG_TURKISH; //Turkish
+ else if ( wsLanguage == L"ur" )
+ {
+ usPrimaryLang = LANG_URDU; //Urdu
+ if ( wsCountry == L"PK" )
+ usSubLang = SUBLANG_URDU_PAKISTAN; // Urdu (Pakistan)
+ else if ( wsCountry == L"IN" )
+ usSubLang = SUBLANG_URDU_INDIA; // Urdu (India)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"in" )
+ usPrimaryLang = LANG_INDONESIAN; //Indonesian
+ else if ( wsLanguage == L"uk" )
+ usPrimaryLang = LANG_UKRAINIAN; //Ukrainian
+ else if ( wsLanguage == L"be" )
+ usPrimaryLang = LANG_BELARUSIAN; //Belarusian
+ else if ( wsLanguage == L"sl" )
+ usPrimaryLang = LANG_SLOVENIAN; //Slovenian
+ else if ( wsLanguage == L"et" )
+ usPrimaryLang = LANG_ESTONIAN; //Estonian
+ else if ( wsLanguage == L"lv" )
+ usPrimaryLang = LANG_LATVIAN; //Latvian
+ else if ( wsLanguage == L"lt" )
+ {
+ usPrimaryLang = LANG_LITHUANIAN; //Lithuanian
+ if ( wsCountry == L"LT" )
+ usSubLang = SUBLANG_LITHUANIAN; // Lithuanian
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"fa" )
+ usPrimaryLang = LANG_FARSI; //Farsi
+ else if ( wsLanguage == L"vi" )
+ usPrimaryLang = LANG_VIETNAMESE; //Vietnamese
+ else if ( wsLanguage == L"hy" )
+ usPrimaryLang = LANG_ARMENIAN; //Armenian
+ else if ( wsLanguage == L"az" )
+ {
+ usPrimaryLang = LANG_AZERI; //Azeri
+ //if ( wsCountry == L" " )
+ // usSubLang = SUBLANG_AZERI_LATIN; // Azeri (Latin)
+ //else if ( wsCountry == L" " )
+ // usSubLang = SUBLANG_AZERI_CYRILLIC; // Azeri (Cyrillic)
+ }
+ else if ( wsLanguage == L"eu" )
+ usPrimaryLang = LANG_BASQUE; //Basque
+ else if ( wsLanguage == L"mk" )
+ usPrimaryLang = LANG_MACEDONIAN; //FYRO Macedonian
+ else if ( wsLanguage == L"af" )
+ usPrimaryLang = LANG_AFRIKAANS; //Afrikaans
+ else if ( wsLanguage == L"ka" )
+ usPrimaryLang = LANG_GEORGIAN; //Georgian
+ else if ( wsLanguage == L"fo" )
+ usPrimaryLang = LANG_FAEROESE; //Faeroese
+ else if ( wsLanguage == L"hi" )
+ usPrimaryLang = LANG_HINDI; //Hindi
+ else if ( wsLanguage == L"ms" )
+ {
+ usPrimaryLang = LANG_MALAY; //Malay
+ if ( wsCountry == L"MY" )
+ usSubLang = SUBLANG_MALAY_MALAYSIA; // Malay (Malaysia)
+ else if ( wsCountry == L"BN" )
+ usSubLang = SUBLANG_MALAY_BRUNEI_DARUSSALAM; // Malay (Brunei Darassalam)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"kk" )
+ usPrimaryLang = LANG_KAZAK; //Kazak
+ else if ( wsLanguage == L"ky" )
+ usPrimaryLang = LANG_KYRGYZ; //Kyrgyz
+ else if ( wsLanguage == L"sw" )
+ usPrimaryLang = LANG_SWAHILI; //Swahili
+ else if ( wsLanguage == L"uz" )
+ {
+ usPrimaryLang = LANG_UZBEK; //Uzbek
+ if ( wsCountry == L"UZ" )
+ usSubLang = SUBLANG_UZBEK_LATIN; // Uzbek (Latin)
+ else if ( wsCountry == L"DE" )
+ usSubLang = SUBLANG_UZBEK_CYRILLIC; // Uzbek (Cyrillic)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"tt" )
+ usPrimaryLang = LANG_TATAR; //Tatar
+ else if ( wsLanguage == L"bn" )
+ usPrimaryLang = LANG_BENGALI; //Not supported.
+ else if ( wsLanguage == L"pa" )
+ usPrimaryLang = LANG_PUNJABI; //Punjabi
+ else if ( wsLanguage == L"gu" )
+ usPrimaryLang = LANG_GUJARATI; //Gujarati
+ else if ( wsLanguage == L"or" )
+ usPrimaryLang = LANG_ORIYA; //Not supported.
+ else if ( wsLanguage == L"ta" )
+ usPrimaryLang = LANG_TAMIL; //Tamil
+ else if ( wsLanguage == L"te" )
+ usPrimaryLang = LANG_TELUGU; //Telugu
+ else if ( wsLanguage == L"kn" )
+ usPrimaryLang = LANG_KANNADA; //Kannada
+ else if ( wsLanguage == L"ml" )
+ usPrimaryLang = LANG_MALAYALAM; //Not supported.
+ else if ( wsLanguage == L"as" )
+ usPrimaryLang = LANG_ASSAMESE; //Not supported.
+ else if ( wsLanguage == L"mr" )
+ usPrimaryLang = LANG_MARATHI; //Marathi
+ else if ( wsLanguage == L"sa" )
+ usPrimaryLang = LANG_SANSKRIT; //Sanskrit
+ else if ( wsLanguage == L"mn" )
+ usPrimaryLang = LANG_MONGOLIAN; //Mongolian
+ else if ( wsLanguage == L"gl" )
+ usPrimaryLang = LANG_GALICIAN; //Galician
+ else if ( wsLanguage == L"sd" )
+ usPrimaryLang = LANG_SINDHI; //Not supported.
+ else if ( wsLanguage == L"ks" )
+ usPrimaryLang = LANG_KASHMIRI; //Not supported.
+ else if ( wsLanguage == L"ne" )
+ usPrimaryLang = LANG_NEPALI; //Not supported.
+ //else if ( wsLanguage == L" " )
+ // usPrimaryLang = LANG_MANIPURI; //Not supported.
+ //else if ( wsLanguage == L" " )
+ // usPrimaryLang = LANG_KONKANI; //Konkani
+ //else if ( wsLanguage == L" " )
+ // usPrimaryLang = LANG_SYRIAC; //Syriac
+ //else if ( wsLanguage == L" " )
+ // usPrimaryLang = LANG_DIVEHI; //Divehi
+ else
+ return GetSystemDefaultLCID(); //System Default Locale
+
+ return MAKELCID( MAKELANGID( usPrimaryLang, usSubLang ), SORT_DEFAULT );
+}
diff --git a/shell/source/win32/simplemail/exports.dxp b/shell/source/win32/simplemail/exports.dxp
new file mode 100644
index 000000000000..028ac4175990
--- /dev/null
+++ b/shell/source/win32/simplemail/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/shell/source/win32/simplemail/makefile.mk b/shell/source/win32/simplemail/makefile.mk
new file mode 100644
index 000000000000..84a209e4c072
--- /dev/null
+++ b/shell/source/win32/simplemail/makefile.mk
@@ -0,0 +1,79 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=shell
+TARGET=smplmail
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=$(SLO)$/smplmailentry.obj\
+ $(SLO)$/smplmailmsg.obj\
+ $(SLO)$/smplmailclient.obj\
+ $(SLO)$/smplmailsuppl.obj\
+ $(SLO)$/simplemapi.obj
+
+SHL1TARGET=$(TARGET).uno
+
+SHL1STDLIBS=$(CPPULIB)\
+ $(CPPUHELPERLIB)\
+ $(SALLIB)\
+ $(ADVAPI32LIB)
+
+SHL1IMPLIB=i$(SHL1TARGET)
+
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- mapimailer --------------------------------------------------------
+
+TARGETTYPE=CUI
+
+OBJFILES= $(OBJ)$/senddoc.obj\
+ $(OBJ)$/simplemapi.obj
+
+APP1TARGET=senddoc
+APP1OBJS=$(OBJFILES)
+APP1STDLIBS=$(KERNEL32LIB)\
+ $(SALLIB)
+
+APP1DEF=$(MISC)$/$(APP1TARGET).def
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/shell/source/win32/simplemail/senddoc.cxx b/shell/source/win32/simplemail/senddoc.cxx
new file mode 100644
index 000000000000..c8ac40799cea
--- /dev/null
+++ b/shell/source/win32/simplemail/senddoc.cxx
@@ -0,0 +1,347 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include <osl/diagnose.h>
+
+#ifndef _RTL_STRING_HXX_
+//#include <rtl/string.hxx>
+#endif
+#include "simplemapi.hxx"
+
+#define WIN32_LEAN_AND_MEAN
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <tchar.h>
+
+#include <iostream>
+#include <vector>
+#include <sstream>
+#include <stdexcept>
+
+#if OSL_DEBUG_LEVEL > 2
+ void dumpParameter();
+#endif
+
+typedef std::vector<std::string> StringList_t;
+typedef StringList_t::const_iterator StringListIterator_t;
+typedef std::vector<MapiRecipDesc> MapiRecipientList_t;
+typedef std::vector<MapiFileDesc> MapiAttachmentList_t;
+
+const int LEN_SMTP_PREFIX = 5; // "SMTP:"
+
+namespace /* private */
+{
+ std::string gFrom;
+ std::string gSubject;
+ std::string gBody;
+ StringList_t gTo;
+ StringList_t gCc;
+ StringList_t gBcc;
+ StringList_t gAttachments;
+ int gMapiFlags = 0;
+}
+
+/**
+ Add a prefix to an email address. MAPI requires that that
+ email addresses have an 'SMTP:' prefix.
+
+ @param aEmailAddress
+ [in] the email address.
+
+ @param aPrefix
+ [in] the prefix to be added to the email address.
+
+ @returns
+ the email address prefixed with the specified prefix.
+*/
+inline std::string prefixEmailAddress(
+ const std::string& aEmailAddress,
+ const std::string& aPrefix = "SMTP:")
+{
+ return (aPrefix + aEmailAddress);
+}
+
+/** @internal */
+void addRecipient(
+ ULONG recipClass,
+ const std::string& recipAddress,
+ MapiRecipientList_t* pMapiRecipientList)
+{
+ MapiRecipDesc mrd;
+ ZeroMemory(&mrd, sizeof(mrd));
+
+ mrd.ulRecipClass = recipClass;
+ mrd.lpszName = const_cast<char*>(recipAddress.c_str()) + LEN_SMTP_PREFIX;
+ mrd.lpszAddress = const_cast<char*>(recipAddress.c_str());
+ pMapiRecipientList->push_back(mrd);
+}
+
+/** @internal */
+void initRecipientList(MapiRecipientList_t* pMapiRecipientList)
+{
+ OSL_ASSERT(pMapiRecipientList->size() == 0);
+
+ // add to recipients
+ StringListIterator_t iter = gTo.begin();
+ StringListIterator_t iter_end = gTo.end();
+ for (; iter != iter_end; ++iter)
+ addRecipient(MAPI_TO, *iter, pMapiRecipientList);
+
+ // add cc recipients
+ iter = gCc.begin();
+ iter_end = gCc.end();
+ for (; iter != iter_end; ++iter)
+ addRecipient(MAPI_CC, *iter, pMapiRecipientList);
+
+ // add bcc recipients
+ iter = gBcc.begin();
+ iter_end = gBcc.end();
+ for (; iter != iter_end; ++iter)
+ addRecipient(MAPI_BCC, *iter, pMapiRecipientList);
+}
+
+/** @internal */
+void initAttachementList(MapiAttachmentList_t* pMapiAttachmentList)
+{
+ OSL_ASSERT(pMapiAttachmentList->size() == 0);
+
+ StringListIterator_t iter = gAttachments.begin();
+ StringListIterator_t iter_end = gAttachments.end();
+ for (/**/; iter != iter_end; ++iter)
+ {
+ MapiFileDesc mfd;
+ ZeroMemory(&mfd, sizeof(mfd));
+ mfd.lpszPathName = const_cast<char*>(iter->c_str());
+ mfd.nPosition = sal::static_int_cast<ULONG>(-1);
+ pMapiAttachmentList->push_back(mfd);
+ }
+}
+
+/** @internal */
+void initMapiOriginator(MapiRecipDesc* pMapiOriginator)
+{
+ ZeroMemory(pMapiOriginator, sizeof(MapiRecipDesc));
+
+ pMapiOriginator->ulRecipClass = MAPI_ORIG;
+ pMapiOriginator->lpszName = "";
+ pMapiOriginator->lpszAddress = const_cast<char*>(gFrom.c_str());
+}
+
+/** @internal */
+void initMapiMessage(
+ MapiRecipDesc* aMapiOriginator,
+ MapiRecipientList_t& aMapiRecipientList,
+ MapiAttachmentList_t& aMapiAttachmentList,
+ MapiMessage* pMapiMessage)
+{
+ ZeroMemory(pMapiMessage, sizeof(MapiMessage));
+
+ pMapiMessage->lpszSubject = const_cast<char*>(gSubject.c_str());
+ pMapiMessage->lpszNoteText = (gBody.length() ? const_cast<char*>(gBody.c_str()) : NULL);
+ pMapiMessage->lpOriginator = aMapiOriginator;
+ pMapiMessage->lpRecips = &aMapiRecipientList[0];
+ pMapiMessage->nRecipCount = aMapiRecipientList.size();
+ pMapiMessage->lpFiles = &aMapiAttachmentList[0];
+ pMapiMessage->nFileCount = aMapiAttachmentList.size();
+}
+
+char* KnownParameter[] =
+{
+ "--to",
+ "--cc",
+ "--bcc",
+ "--from",
+ "--subject",
+ "--body",
+ "--attach",
+ "--mapi-dialog",
+ "--mapi-logon-ui"
+};
+
+const size_t nKnownParameter = (sizeof(KnownParameter)/sizeof(KnownParameter[0]));
+
+/** @internal */
+bool isKnownParameter(const char* aParameterName)
+{
+ for (size_t i = 0; i < nKnownParameter; i++)
+ if (_tcsicmp(aParameterName, KnownParameter[i]) == 0)
+ return true;
+
+ return false;
+}
+
+/** @internal */
+void initParameter(int argc, char* argv[])
+{
+ for (int i = 1; i < argc; i++)
+ {
+ if (!isKnownParameter(argv[i]))
+ {
+ OSL_ENSURE(false, "Wrong parameter received");
+ continue;
+ }
+
+ if ((_tcsicmp(argv[i], TEXT("--mapi-dialog")) == 0))
+ {
+ gMapiFlags |= MAPI_DIALOG;
+ }
+ else if ((_tcsicmp(argv[i], TEXT("--mapi-logon-ui")) == 0))
+ {
+ gMapiFlags |= MAPI_LOGON_UI;
+ }
+ else if ((i+1) < argc) // is the value of a parameter available too?
+ {
+ if (_tcsicmp(argv[i], TEXT("--to")) == 0)
+ gTo.push_back(prefixEmailAddress(argv[i+1]));
+ else if (_tcsicmp(argv[i], TEXT("--cc")) == 0)
+ gCc.push_back(prefixEmailAddress(argv[i+1]));
+ else if (_tcsicmp(argv[i], TEXT("--bcc")) == 0)
+ gBcc.push_back(prefixEmailAddress(argv[i+1]));
+ else if (_tcsicmp(argv[i], TEXT("--from")) == 0)
+ gFrom = prefixEmailAddress(argv[i+1]);
+ else if (_tcsicmp(argv[i], TEXT("--subject")) == 0)
+ gSubject = argv[i+1];
+ else if (_tcsicmp(argv[i], TEXT("--body")) == 0)
+ gBody = argv[i+1];
+ else if ((_tcsicmp(argv[i], TEXT("--attach")) == 0))
+ gAttachments.push_back(argv[i+1]);
+
+ i++;
+ }
+ }
+}
+
+/**
+ Main.
+ NOTE: Because this is program only serves implementation
+ purposes and should not be used by any end user the
+ parameter checking is very limited. Every unknown parameter
+ will be ignored.
+*/
+int main(int argc, char* argv[])
+{
+ //MessageBox(NULL, "Debug", "Debug", MB_OK);
+
+ initParameter(argc, argv);
+
+#if OSL_DEBUG_LEVEL > 2
+ dumpParameter();
+#endif
+
+ ULONG ulRet = MAPI_E_FAILURE;
+
+ try
+ {
+ CSimpleMapi mapi;
+
+ // #93007# we have to set the flag MAPI_NEW_SESSION,
+ // because in the case Outlook xxx (not Outlook Express!)
+ // is installed as Exchange and Mail Client a Profile
+ // selection dialog must appear because we specify no
+ // profile name, so the user has to specify a profile
+ FLAGS flFlag = MAPI_NEW_SESSION | MAPI_LOGON_UI;
+ LHANDLE hSession;
+ ulRet = mapi.MAPILogon(0, NULL, NULL, flFlag, 0L, &hSession);
+
+ if (ulRet == SUCCESS_SUCCESS)
+ {
+ MapiRecipDesc mapiOriginator;
+ MapiRecipientList_t mapiRecipientList;
+ MapiAttachmentList_t mapiAttachmentList;
+ MapiMessage mapiMsg;
+
+ initMapiOriginator(&mapiOriginator);
+ initRecipientList(&mapiRecipientList);
+ initAttachementList(&mapiAttachmentList);
+ initMapiMessage((gFrom.length() ? &mapiOriginator : NULL), mapiRecipientList, mapiAttachmentList, &mapiMsg);
+
+ ulRet = mapi.MAPISendMail(hSession, 0, &mapiMsg, gMapiFlags, 0);
+
+ mapi.MAPILogoff(hSession, 0, 0, 0);
+ }
+ }
+ catch (const std::runtime_error&
+ #if OSL_DEBUG_LEVEL > 0
+ ex
+ #endif
+ )
+ {
+ OSL_ENSURE(false, ex.what());
+ }
+ return ulRet;
+}
+
+#if OSL_DEBUG_LEVEL > 2
+ void dumpParameter()
+ {
+ std::ostringstream oss;
+
+ if (gFrom.length() > 0)
+ oss << "--from" << " " << gFrom << std::endl;
+
+ if (gSubject.length() > 0)
+ oss << "--subject" << " " << gSubject << std::endl;
+
+ if (gBody.length() > 0)
+ oss << "--body" << " " << gBody << std::endl;
+
+ StringListIterator_t iter = gTo.begin();
+ StringListIterator_t iter_end = gTo.end();
+ for (/**/;iter != iter_end; ++iter)
+ oss << "--to" << " " << *iter << std::endl;
+
+ iter = gCc.begin();
+ iter_end = gCc.end();
+ for (/**/;iter != iter_end; ++iter)
+ oss << "--cc" << " " << *iter << std::endl;
+
+ iter = gBcc.begin();
+ iter_end = gBcc.end();
+ for (/**/;iter != iter_end; ++iter)
+ oss << "--bcc" << " " << *iter << std::endl;
+
+ iter = gAttachments.begin();
+ iter_end = gAttachments.end();
+ for (/**/;iter != iter_end; ++iter)
+ oss << "--attach" << " " << *iter << std::endl;
+
+ if (gMapiFlags & MAPI_DIALOG)
+ oss << "--mapi-dialog" << std::endl;
+
+ if (gMapiFlags & MAPI_LOGON_UI)
+ oss << "--mapi-logon-ui" << std::endl;
+
+ MessageBox(NULL, oss.str().c_str(), "Arguments", MB_OK | MB_ICONINFORMATION);
+ }
+#endif
diff --git a/shell/source/win32/simplemail/simplemapi.cxx b/shell/source/win32/simplemail/simplemapi.cxx
new file mode 100644
index 000000000000..faf383f580aa
--- /dev/null
+++ b/shell/source/win32/simplemail/simplemapi.cxx
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "simplemapi.hxx"
+
+#include <string>
+#include <stdexcept>
+
+CSimpleMapi::CSimpleMapi() :
+ m_lpfnMapiLogon(NULL),
+ m_lpfnMapiLogoff(NULL),
+ m_lpfnMapiSendMail(NULL)
+{
+ m_hMapiDll = LoadLibrary("mapi32.dll");
+ if ((m_hMapiDll == INVALID_HANDLE_VALUE) || (m_hMapiDll == NULL))
+ throw std::runtime_error("Couldn't load MAPI library");
+
+ m_lpfnMapiLogon = reinterpret_cast<LPMAPILOGON>(GetProcAddress(m_hMapiDll, "MAPILogon"));
+ if (!m_lpfnMapiLogon)
+ throw std::runtime_error("Couldn't find method MAPILogon");
+
+ m_lpfnMapiLogoff = reinterpret_cast<LPMAPILOGOFF>(GetProcAddress(m_hMapiDll, "MAPILogoff"));
+ if (!m_lpfnMapiLogoff)
+ throw std::runtime_error("Couldn't find method MAPILogoff");
+
+ m_lpfnMapiSendMail = reinterpret_cast<LPMAPISENDMAIL>(GetProcAddress(m_hMapiDll, "MAPISendMail"));
+ if (!m_lpfnMapiSendMail)
+ throw std::runtime_error("Couldn't find method MAPISendMail");
+}
+
+CSimpleMapi::~CSimpleMapi()
+{
+ FreeLibrary(m_hMapiDll);
+}
+
+ULONG CSimpleMapi::MAPILogon(
+ ULONG ulUIParam,
+ LPTSTR lpszProfileName,
+ LPTSTR lpszPassword,
+ FLAGS flFlags,
+ ULONG ulReserved,
+ LPLHANDLE lplhSession )
+{
+ return m_lpfnMapiLogon(
+ ulUIParam,
+ lpszProfileName,
+ lpszPassword,
+ flFlags,
+ ulReserved,
+ lplhSession );
+}
+
+ULONG CSimpleMapi::MAPILogoff(
+ LHANDLE lhSession,
+ ULONG ulUIParam,
+ FLAGS flFlags,
+ ULONG ulReserved )
+{
+ return m_lpfnMapiLogoff(lhSession, ulUIParam, flFlags, ulReserved);
+}
+
+ULONG CSimpleMapi::MAPISendMail(
+ LHANDLE lhSession,
+ ULONG ulUIParam,
+ lpMapiMessage lpMessage,
+ FLAGS flFlags,
+ ULONG ulReserved )
+{
+ return m_lpfnMapiSendMail(lhSession, ulUIParam, lpMessage, flFlags, ulReserved);
+}
+
diff --git a/shell/source/win32/simplemail/simplemapi.hxx b/shell/source/win32/simplemail/simplemapi.hxx
new file mode 100644
index 000000000000..e4feb3524ed3
--- /dev/null
+++ b/shell/source/win32/simplemail/simplemapi.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_SIMPLEMAPI_HXX
+#define INCLUDED_SIMPLEMAPI_HXX
+
+#define WIN32_LEAN_AND_MEAN
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#include <mapi.h>
+#ifndef __MINGW32__
+#include <mapix.h>
+#endif
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+class CSimpleMapi
+{
+public:
+ /**
+ @throws std::runtime_error
+ if either the mapi32.dll could not be loaded at all
+ or necessary function exports are missing
+ */
+ CSimpleMapi(); // throws std::runtime_error;
+
+ ~CSimpleMapi();
+
+ ULONG MAPILogon(
+ ULONG ulUIParam,
+ LPTSTR lpszProfileName,
+ LPTSTR lpszPassword,
+ FLAGS flFlags,
+ ULONG ulReserved,
+ LPLHANDLE lplhSession );
+
+ ULONG MAPILogoff(
+ LHANDLE lhSession,
+ ULONG ulUIParam,
+ FLAGS flFlags,
+ ULONG ulReserved );
+
+ ULONG MAPISendMail(
+ LHANDLE lhSession,
+ ULONG ulUIParam,
+ lpMapiMessage lpMessage,
+ FLAGS flFlags,
+ ULONG ulReserved );
+
+private:
+ HMODULE m_hMapiDll;
+ LPMAPILOGON m_lpfnMapiLogon;
+ LPMAPILOGOFF m_lpfnMapiLogoff;
+ LPMAPISENDMAIL m_lpfnMapiSendMail;
+};
+
+#endif
diff --git a/shell/source/win32/simplemail/smplmail.xml b/shell/source/win32/simplemail/smplmail.xml
new file mode 100644
index 000000000000..8176f094acad
--- /dev/null
+++ b/shell/source/win32/simplemail/smplmail.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> smplmail </module-name>
+ <component-description>
+ <author> Tino Rachui </author>
+ <name>com.sun.star.comp.system.SimpleSystemMail</name>
+ <description>
+ The win32 implementation of a SimpleSystemMail service.
+</description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language> c++ </language>
+ <status value="beta"/>
+ <supported-service> com.sun.star.system.SimpleSystemMail </supported-service>
+ <service-dependency>...</service-dependency>
+ <type> com.sun.star.system.XSimpleMailClient </type>
+ <type> com.sun.star.system.XSimpleMailClientSupplier </type>
+ <type> com.sun.star.system.XSimpleMailMessage </type>
+ <type> com.sun.star.system.SimpleMailClientFlags </type>
+ <type> com.sun.star.lang.XMultiServiceFactory </type>
+ <type> com.sun.star.lang.XSingleServiceFactory </type>
+ <type> com.sun.star.lang.XServiceInfo </type>
+ <type> com.sun.star.lang.XTypeProvider </type>
+ <type> com.sun.star.lang.IllegalArgumentException </type>
+ <type> com.sun.star.uno.TypeClass </type>
+ <type> com.sun.star.uno.XWeak </type>
+ <type> com.sun.star.uno.XAggregation </type>
+ <type> com.sun.star.registry.XRegistryKey </type>
+ <type> com.sun.star.container.XSet </type>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <runtime-module-dependency> cppuhelper </runtime-module-dependency>
+ <runtime-module-dependency> cppu2 </runtime-module-dependency>
+ <runtime-module-dependency> sal2 </runtime-module-dependency>
+</module-description>
diff --git a/shell/source/win32/simplemail/smplmailclient.cxx b/shell/source/win32/simplemail/smplmailclient.cxx
new file mode 100644
index 000000000000..49c546e5721d
--- /dev/null
+++ b/shell/source/win32/simplemail/smplmailclient.cxx
@@ -0,0 +1,289 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include <osl/diagnose.h>
+#include <osl/process.h>
+#include <rtl/bootstrap.hxx>
+#include "smplmailclient.hxx"
+#include "smplmailmsg.hxx"
+#include <com/sun/star/system/SimpleMailClientFlags.hpp>
+#include <osl/file.hxx>
+
+#define WIN32_LEAN_AND_MEAN
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#include <mapi.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include <process.h>
+#include <vector>
+
+using css::uno::Reference;
+using css::uno::Exception;
+using css::uno::RuntimeException;
+using css::uno::Sequence;
+using css::lang::IllegalArgumentException;
+
+using css::system::XSimpleMailClient;
+using css::system::XSimpleMailMessage;
+using css::system::SimpleMailClientFlags::NO_USER_INTERFACE;
+using css::system::SimpleMailClientFlags::NO_LOGON_DIALOG;
+
+typedef std::vector<rtl::OUString> StringList_t;
+typedef StringList_t::const_iterator StringListIterator_t;
+
+const rtl::OUString TO = rtl::OUString::createFromAscii("--to");
+const rtl::OUString CC = rtl::OUString::createFromAscii("--cc");
+const rtl::OUString BCC = rtl::OUString::createFromAscii("--bcc");
+const rtl::OUString FROM = rtl::OUString::createFromAscii("--from");
+const rtl::OUString SUBJECT = rtl::OUString::createFromAscii("--subject");
+const rtl::OUString BODY = rtl::OUString::createFromAscii("--body");
+const rtl::OUString ATTACH = rtl::OUString::createFromAscii("--attach");
+const rtl::OUString FLAG_MAPI_DIALOG = rtl::OUString::createFromAscii("--mapi-dialog");
+const rtl::OUString FLAG_MAPI_LOGON_UI = rtl::OUString::createFromAscii("--mapi-logon-ui");
+
+namespace /* private */
+{
+ /** @internal
+ look if an alternative program is configured
+ which should be used as senddoc executable */
+ rtl::OUString getAlternativeSenddocUrl()
+ {
+ rtl::OUString altSenddocUrl;
+ HKEY hkey;
+ LONG lret = RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\OpenOffice.org\\SendAsEMailClient", &hkey);
+ if (lret == ERROR_SUCCESS)
+ {
+ wchar_t buff[MAX_PATH];
+ LONG sz = sizeof(buff);
+ lret = RegQueryValueW(hkey, NULL, buff, &sz);
+ if (lret == ERROR_SUCCESS)
+ {
+ osl::FileBase::getFileURLFromSystemPath(reinterpret_cast<const sal_Unicode*>(buff), altSenddocUrl);
+ }
+ RegCloseKey(hkey);
+ }
+ return altSenddocUrl;
+ }
+
+ /**
+ Returns the absolute file Url of the senddoc executable.
+
+ @returns
+ the absolute file Url of the senddoc executable. In case
+ of an error an empty string will be returned.
+ */
+ rtl::OUString getSenddocUrl()
+ {
+ rtl::OUString senddocUrl = getAlternativeSenddocUrl();
+
+ if (senddocUrl.getLength() == 0)
+ {
+ senddocUrl = rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "$OOO_BASE_DIR/program/senddoc.exe"));
+ rtl::Bootstrap::expandMacros(senddocUrl); //TODO: detect failure
+ }
+ return senddocUrl;
+ }
+
+ /**
+ Execute Senddoc.exe which a MAPI wrapper.
+
+ @param rCommandArgs
+ [in] the arguments to be passed to Senddoc.exe
+
+ @returns
+ <TRUE/> on success.
+ */
+ bool executeSenddoc(const StringList_t& rCommandArgs)
+ {
+ rtl::OUString senddocUrl = getSenddocUrl();
+ if (senddocUrl.getLength() == 0)
+ return false;
+
+ oslProcess proc;
+ oslProcessError err = osl_Process_E_Unknown;
+
+ /* for efficiency reasons we are using a 'bad' cast here
+ as a vector or rtl::OUStrings is nothing else than
+ an array of pointers to rtl_uString's */
+ err = osl_executeProcess(
+ senddocUrl.pData,
+ (rtl_uString**)&rCommandArgs[0],
+ rCommandArgs.size(),
+ osl_Process_WAIT | osl_Process_DETACHED,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ &proc);
+
+ if (err != osl_Process_E_None)
+ return false;
+
+ oslProcessInfo procInfo;
+ procInfo.Size = sizeof(oslProcessInfo);
+ osl_getProcessInfo(proc, osl_Process_EXITCODE, &procInfo);
+ osl_freeProcessHandle(proc);
+ return (procInfo.Code == SUCCESS_SUCCESS);
+ }
+} // namespace private
+
+Reference<XSimpleMailMessage> SAL_CALL CSmplMailClient::createSimpleMailMessage()
+ throw (RuntimeException)
+{
+ return Reference<XSimpleMailMessage>(new CSmplMailMsg());
+}
+
+/**
+ Assemble a command line for SendDoc.exe out of the members
+ of the supplied SimpleMailMessage.
+
+ @param xSimpleMailMessage
+ [in] the mail message.
+
+ @param aFlags
+ [in] different flags to be used with the simple mail service.
+
+ @param rCommandArgs
+ [in|out] a buffer for the command line arguments. The buffer
+ is assumed to be empty.
+
+ @throws com::sun::star::lang::IllegalArgumentException
+ if an invalid file URL has been detected in the attachment list.
+*/
+void CSmplMailClient::assembleCommandLine(
+ const Reference<XSimpleMailMessage>& xSimpleMailMessage,
+ sal_Int32 aFlag, StringList_t& rCommandArgs)
+{
+ OSL_ENSURE(rCommandArgs.size() == 0, "Provided command argument buffer not empty");
+
+ rtl::OUString to = xSimpleMailMessage->getRecipient();
+ if (to.getLength() > 0)
+ {
+ rCommandArgs.push_back(TO);
+ rCommandArgs.push_back(to);
+ }
+
+ Sequence<rtl::OUString> ccRecipients = xSimpleMailMessage->getCcRecipient();
+ for (int i = 0; i < ccRecipients.getLength(); i++)
+ {
+ rCommandArgs.push_back(CC);
+ rCommandArgs.push_back(ccRecipients[i]);
+ }
+
+ Sequence<rtl::OUString> bccRecipients = xSimpleMailMessage->getBccRecipient();
+ for (int i = 0; i < bccRecipients.getLength(); i++)
+ {
+ rCommandArgs.push_back(BCC);
+ rCommandArgs.push_back(bccRecipients[i]);
+ }
+
+ rtl::OUString from = xSimpleMailMessage->getOriginator();
+ if (from.getLength() > 0)
+ {
+ rCommandArgs.push_back(FROM);
+ rCommandArgs.push_back(from);
+ }
+
+ rtl::OUString subject = xSimpleMailMessage->getSubject();
+ if (subject.getLength() > 0)
+ {
+ rCommandArgs.push_back(SUBJECT);
+ rCommandArgs.push_back(subject);
+ }
+
+ Sequence<rtl::OUString> attachments = xSimpleMailMessage->getAttachement();
+ for (int i = 0; i < attachments.getLength(); i++)
+ {
+ rtl::OUString sysPath;
+ osl::FileBase::RC err = osl::FileBase::getSystemPathFromFileURL(attachments[i], sysPath);
+ if (err != osl::FileBase::E_None)
+ throw IllegalArgumentException(
+ rtl::OUString::createFromAscii("Invalid attachment file URL"),
+ static_cast<XSimpleMailClient*>(this),
+ 1);
+
+ rCommandArgs.push_back(ATTACH);
+ rCommandArgs.push_back(sysPath);
+ }
+
+ if (!(aFlag & NO_USER_INTERFACE))
+ rCommandArgs.push_back(FLAG_MAPI_DIALOG);
+
+ if (!(aFlag & NO_LOGON_DIALOG))
+ rCommandArgs.push_back(FLAG_MAPI_LOGON_UI);
+}
+
+void SAL_CALL CSmplMailClient::sendSimpleMailMessage(
+ const Reference<XSimpleMailMessage>& xSimpleMailMessage, sal_Int32 aFlag)
+ throw (IllegalArgumentException, Exception, RuntimeException)
+{
+ validateParameter(xSimpleMailMessage, aFlag);
+
+ StringList_t senddocParams;
+ assembleCommandLine(xSimpleMailMessage, aFlag, senddocParams);
+
+ if (!executeSenddoc(senddocParams))
+ throw Exception(
+ rtl::OUString::createFromAscii("Send email failed"),
+ static_cast<XSimpleMailClient*>(this));
+}
+
+void CSmplMailClient::validateParameter(
+ const Reference<XSimpleMailMessage>& xSimpleMailMessage, sal_Int32 aFlag )
+{
+ if (!xSimpleMailMessage.is())
+ throw IllegalArgumentException(
+ rtl::OUString::createFromAscii("Empty mail message reference"),
+ static_cast<XSimpleMailClient*>(this),
+ 1);
+
+ // #93077#
+ OSL_ENSURE(!(aFlag & NO_LOGON_DIALOG), "Flag NO_LOGON_DIALOG has currently no effect");
+
+ // check the flags, the allowed range is 0 - (2^n - 1)
+ if (aFlag < 0 || aFlag > 3)
+ throw IllegalArgumentException(
+ rtl::OUString::createFromAscii("Invalid flag value"),
+ static_cast<XSimpleMailClient*>(this),
+ 2);
+
+ // check if a recipient is specified of the flags NO_USER_INTERFACE is specified
+ if ((aFlag & NO_USER_INTERFACE) && !xSimpleMailMessage->getRecipient().getLength())
+ throw IllegalArgumentException(
+ rtl::OUString::createFromAscii("No recipient specified"),
+ static_cast<XSimpleMailClient*>(this),
+ 1);
+}
diff --git a/shell/source/win32/simplemail/smplmailclient.hxx b/shell/source/win32/simplemail/smplmailclient.hxx
new file mode 100644
index 000000000000..5457dffbffd9
--- /dev/null
+++ b/shell/source/win32/simplemail/smplmailclient.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SMPLMAILCLIENT_HXX_
+#define _SMPLMAILCLIENT_HXX_
+
+#include <cppuhelper/compbase1.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
+#include <com/sun/star/system/XSimpleMailClient.hpp>
+#endif
+
+namespace css = ::com::sun::star;
+
+class CSmplMailClient : public cppu::WeakImplHelper1<css::system::XSimpleMailClient>
+{
+public:
+ virtual css::uno::Reference<css::system::XSimpleMailMessage> SAL_CALL createSimpleMailMessage()
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL sendSimpleMailMessage(const css::uno::Reference<css::system::XSimpleMailMessage>& xSimpleMailMessage, sal_Int32 aFlag)
+ throw (css::lang::IllegalArgumentException, css::uno::Exception, css::uno::RuntimeException);
+
+private:
+ void validateParameter(const css::uno::Reference<css::system::XSimpleMailMessage>& xSimpleMailMessage, sal_Int32 aFlag);
+ void assembleCommandLine(const css::uno::Reference<css::system::XSimpleMailMessage>& xSimpleMailMessage, sal_Int32 aFlag, std::vector<rtl::OUString>& rCommandArgs);
+};
+
+#endif
diff --git a/shell/source/win32/simplemail/smplmailentry.cxx b/shell/source/win32/simplemail/smplmailentry.cxx
new file mode 100644
index 000000000000..e65d93a95fca
--- /dev/null
+++ b/shell/source/win32/simplemail/smplmailentry.cxx
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+//-----------------------------------------------------------------------
+// includes of other projects
+//-----------------------------------------------------------------------
+#include <cppuhelper/factory.hxx>
+#include <com/sun/star/container/XSet.hpp>
+#include <osl/diagnose.h>
+#include "smplmailsuppl.hxx"
+
+//-----------------------------------------------------------------------
+// namespace directives
+//-----------------------------------------------------------------------
+
+using namespace ::rtl ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::container ;
+using namespace ::com::sun::star::lang ;
+using namespace ::com::sun::star::registry ;
+using namespace ::cppu ;
+using com::sun::star::system::XSimpleMailClientSupplier;
+
+//-----------------------------------------------------------------------
+// defines
+//-----------------------------------------------------------------------
+
+#define COMP_SERVICE_NAME "com.sun.star.system.SimpleSystemMail"
+#define COMP_IMPL_NAME "com.sun.star.system.SimpleSystemMail"
+#define COMP_REGKEY_NAME "/com.sun.star.system.SimpleSystemMail/UNO/SERVICES/com.sun.star.system.SimpleSystemMail"
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+
+namespace
+{
+ Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& )
+ {
+ return Reference< XInterface >( static_cast< XSimpleMailClientSupplier* >( new CSmplMailSuppl( ) ) );
+ }
+}
+
+//-----------------------------------------------------------------------
+// the 3 important functions which will be exported
+//-----------------------------------------------------------------------
+
+extern "C"
+{
+
+//----------------------------------------------------------------------
+// component_getImplementationEnvironment
+//----------------------------------------------------------------------
+
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+
+sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
+{
+ sal_Bool bRetVal = sal_True;
+
+ if ( pRegistryKey )
+ {
+ try
+ {
+ Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
+ pXNewKey->createKey(
+ OUString::createFromAscii( COMP_REGKEY_NAME ) );
+ }
+ catch( InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "InvalidRegistryException caught");
+ bRetVal = sal_False;
+ }
+ }
+
+ return bRetVal;
+}
+
+//----------------------------------------------------------------------
+// component_getFactory
+// returns a factory to create XFilePicker-Services
+//----------------------------------------------------------------------
+
+void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
+{
+ void* pRet = 0;
+
+ if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, COMP_IMPL_NAME ) ) )
+ {
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray( )[0] = OUString::createFromAscii( COMP_SERVICE_NAME );
+
+ Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
+ OUString::createFromAscii( pImplName ),
+ createInstance,
+ aSNS ) );
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+
+} // extern "C"
diff --git a/shell/source/win32/simplemail/smplmailmsg.cxx b/shell/source/win32/simplemail/smplmailmsg.cxx
new file mode 100644
index 000000000000..088d84a050ad
--- /dev/null
+++ b/shell/source/win32/simplemail/smplmailmsg.cxx
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+#include <osl/diagnose.h>
+
+#include <osl/file.h>
+#include "smplmailmsg.hxx"
+
+//------------------------------------------------------------------------
+// namespace directives
+//------------------------------------------------------------------------
+
+using com::sun::star::uno::Reference;
+using com::sun::star::uno::RuntimeException;
+using com::sun::star::uno::Sequence;
+using com::sun::star::lang::XServiceInfo;
+using com::sun::star::lang::IllegalArgumentException;
+using rtl::OUString;
+using osl::Mutex;
+
+using namespace cppu;
+
+//------------------------------------------------------------------------
+// helper functions
+//------------------------------------------------------------------------
+
+CSmplMailMsg::CSmplMailMsg( )
+{
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+void SAL_CALL CSmplMailMsg::setRecipient( const ::rtl::OUString& aRecipient )
+ throw (RuntimeException)
+{
+ m_aRecipient = aRecipient;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+::rtl::OUString SAL_CALL CSmplMailMsg::getRecipient( )
+ throw (RuntimeException)
+{
+ return m_aRecipient;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+void SAL_CALL CSmplMailMsg::setCcRecipient( const Sequence< OUString >& aCcRecipient )
+ throw (RuntimeException)
+{
+ m_CcRecipients = aCcRecipient;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+Sequence< OUString > SAL_CALL CSmplMailMsg::getCcRecipient( )
+ throw (RuntimeException)
+{
+ return m_CcRecipients;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+void SAL_CALL CSmplMailMsg::setBccRecipient( const Sequence< OUString >& aBccRecipient )
+ throw (RuntimeException)
+{
+ m_BccRecipients = aBccRecipient;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+Sequence< OUString > SAL_CALL CSmplMailMsg::getBccRecipient( )
+ throw (RuntimeException)
+{
+ return m_BccRecipients;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+void SAL_CALL CSmplMailMsg::setOriginator( const OUString& aOriginator )
+ throw (RuntimeException)
+{
+ m_aOriginator = aOriginator;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+OUString SAL_CALL CSmplMailMsg::getOriginator( )
+ throw (RuntimeException)
+{
+ return m_aOriginator;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+void SAL_CALL CSmplMailMsg::setSubject( const OUString& aSubject )
+ throw (RuntimeException)
+{
+ m_aSubject = aSubject;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+OUString SAL_CALL CSmplMailMsg::getSubject( )
+ throw (RuntimeException)
+{
+ return m_aSubject;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+void SAL_CALL CSmplMailMsg::setAttachement( const Sequence< ::rtl::OUString >& aAttachement )
+ throw (IllegalArgumentException, RuntimeException)
+{
+ m_Attachements = aAttachement;
+}
+
+//------------------------------------------------
+//
+//------------------------------------------------
+
+Sequence< OUString > SAL_CALL CSmplMailMsg::getAttachement( )
+ throw (RuntimeException)
+{
+ return m_Attachements;
+}
diff --git a/shell/source/win32/simplemail/smplmailmsg.hxx b/shell/source/win32/simplemail/smplmailmsg.hxx
new file mode 100644
index 000000000000..caeb0710de90
--- /dev/null
+++ b/shell/source/win32/simplemail/smplmailmsg.hxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SMPLMAILMSG_HXX_
+#define _SMPLMAILMSG_HXX_
+
+//_______________________________________________________________________________________________________________________
+// includes of other projects
+//_______________________________________________________________________________________________________________________
+
+#include <cppuhelper/compbase1.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+
+#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
+#include <com/sun/star/system/XSimpleMailMessage.hpp>
+#endif
+
+//----------------------------------------------------------
+// class declaration
+//----------------------------------------------------------
+
+class CSmplMailMsg :
+ public cppu::WeakImplHelper1< com::sun::star::system::XSimpleMailMessage >
+{
+public:
+ CSmplMailMsg( );
+
+ //------------------------------------------------
+ //
+ //------------------------------------------------
+
+ virtual void SAL_CALL setRecipient( const ::rtl::OUString& aRecipient )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getRecipient( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ //------------------------------------------------
+ //
+ //------------------------------------------------
+
+ virtual void SAL_CALL setCcRecipient( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aCcRecipient )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getCcRecipient( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ //------------------------------------------------
+ //
+ //------------------------------------------------
+
+ virtual void SAL_CALL setBccRecipient( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aBccRecipient )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getBccRecipient( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ //------------------------------------------------
+ //
+ //------------------------------------------------
+
+ virtual void SAL_CALL setOriginator( const ::rtl::OUString& aOriginator )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getOriginator( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ //------------------------------------------------
+ //
+ //------------------------------------------------
+
+ virtual void SAL_CALL setSubject( const ::rtl::OUString& aSubject )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getSubject( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ //------------------------------------------------
+ //
+ //------------------------------------------------
+
+ virtual void SAL_CALL setAttachement( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aAttachement )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAttachement( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ rtl::OUString m_aRecipient;
+ rtl::OUString m_aOriginator;
+ rtl::OUString m_aSubject;
+ com::sun::star::uno::Sequence< rtl::OUString > m_CcRecipients;
+ com::sun::star::uno::Sequence< rtl::OUString > m_BccRecipients;
+ com::sun::star::uno::Sequence< rtl::OUString > m_Attachements;
+};
+
+#endif
diff --git a/shell/source/win32/simplemail/smplmailsuppl.cxx b/shell/source/win32/simplemail/smplmailsuppl.cxx
new file mode 100644
index 000000000000..375da5b07856
--- /dev/null
+++ b/shell/source/win32/simplemail/smplmailsuppl.cxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include <osl/diagnose.h>
+#include "smplmailsuppl.hxx"
+#include "smplmailclient.hxx"
+
+using com::sun::star::uno::Reference;
+using com::sun::star::uno::RuntimeException;
+using com::sun::star::uno::Sequence;
+using com::sun::star::lang::XServiceInfo;
+using com::sun::star::system::XSimpleMailClientSupplier;
+using com::sun::star::system::XSimpleMailClient;
+using rtl::OUString;
+using osl::Mutex;
+
+using namespace cppu;
+
+#define COMP_IMPL_NAME "com.sun.star.sys.shell.SimpleSystemMail"
+
+namespace // private
+{
+ Sequence< OUString > SAL_CALL Component_getSupportedServiceNames()
+ {
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii("com.sun.star.sys.shell.SimpleSystemMail");
+ return aRet;
+ }
+
+} // end private namespace
+
+CSmplMailSuppl::CSmplMailSuppl() :
+ WeakComponentImplHelper2<XSimpleMailClientSupplier, XServiceInfo>(m_aMutex)
+{
+}
+
+CSmplMailSuppl::~CSmplMailSuppl()
+{
+}
+
+Reference<XSimpleMailClient> SAL_CALL CSmplMailSuppl::querySimpleMailClient()
+ throw (RuntimeException)
+{
+ /* We just try to load the MAPI dll as a test
+ if a mail client is available */
+ Reference<XSimpleMailClient> xSmplMailClient;
+ HMODULE handle = LoadLibrary("mapi32.dll");
+ if ((handle != INVALID_HANDLE_VALUE) && (handle != NULL))
+ {
+ FreeLibrary(handle);
+ xSmplMailClient = Reference<XSimpleMailClient>(new CSmplMailClient());
+ }
+ return xSmplMailClient;
+}
+
+// XServiceInfo
+
+OUString SAL_CALL CSmplMailSuppl::getImplementationName()
+ throw(RuntimeException)
+{
+ return OUString::createFromAscii(COMP_IMPL_NAME);
+}
+
+sal_Bool SAL_CALL CSmplMailSuppl::supportsService(const OUString& ServiceName)
+ throw(RuntimeException)
+{
+ Sequence <OUString> SupportedServicesNames = Component_getSupportedServiceNames();
+
+ for (sal_Int32 n = SupportedServicesNames.getLength(); n--;)
+ if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+ return sal_True;
+
+ return sal_False;
+}
+
+Sequence<OUString> SAL_CALL CSmplMailSuppl::getSupportedServiceNames()
+ throw(RuntimeException)
+{
+ return Component_getSupportedServiceNames();
+}
+
diff --git a/shell/source/win32/simplemail/smplmailsuppl.hxx b/shell/source/win32/simplemail/smplmailsuppl.hxx
new file mode 100644
index 000000000000..e945556c6f8b
--- /dev/null
+++ b/shell/source/win32/simplemail/smplmailsuppl.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SMPLMAILSUPPL_HXX_
+#define _SMPLMAILSUPPL_HXX_
+
+#include <cppuhelper/compbase2.hxx>
+#include <osl/mutex.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
+#include <com/sun/star/system/XSimpleMailClientSupplier.hpp>
+#endif
+
+#ifndef _SIMPLEMAPI_HXX_
+#include "simplemapi.hxx"
+#endif
+
+
+class CSmplMailSupplBase
+{
+protected:
+ osl::Mutex m_aMutex;
+};
+
+class CSmplMailSuppl :
+ public CSmplMailSupplBase,
+ public cppu::WeakComponentImplHelper2<
+ com::sun::star::system::XSimpleMailClientSupplier,
+ com::sun::star::lang::XServiceInfo >
+{
+public:
+ CSmplMailSuppl( );
+ ~CSmplMailSuppl( );
+
+ // XSimpleMailClientSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailClient > SAL_CALL querySimpleMailClient( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw(::com::sun::star::uno::RuntimeException);
+};
+
+#endif
diff --git a/shell/source/win32/syssh.xml b/shell/source/win32/syssh.xml
new file mode 100644
index 000000000000..3af4c73dc111
--- /dev/null
+++ b/shell/source/win32/syssh.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> syssh </module-name>
+ <component-description>
+ <author> Tino Rachui </author>
+ <name>com.sun.star.comp.system.SystemShellExecute</name>
+ <description>
+ The win32 implementation of a SystemShellExecute service.
+</description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language> c++ </language>
+ <status value="beta"/>
+ <supported-service> com.sun.star.system.SystemShellExecute </supported-service>
+ <service-dependency>...</service-dependency>
+ <type> com.sun.star.system.XSystemShellExecute </type>
+ <type> com.sun.star.system.SystemShellExecuteException </type>
+ <type> com.sun.star.system.SystemShellExecuteFlags </type>
+ <type> com.sun.star.lang.XMultiServiceFactory </type>
+ <type> com.sun.star.lang.XSingleServiceFactory </type>
+ <type> com.sun.star.lang.XSingleComponentFactory </type>
+ <type> com.sun.star.lang.XServiceInfo </type>
+ <type> com.sun.star.lang.XTypeProvider </type>
+ <type> com.sun.star.lang.XComponent </type>
+ <type> com.sun.star.lang.EventObject </type>
+ <type> com.sun.star.uno.XComponentContext </type>
+ <type> com.sun.star.lang.IllegalArgumentException </type>
+ <type> com.sun.star.uno.TypeClass </type>
+ <type> com.sun.star.uno.XWeak </type>
+ <type> com.sun.star.uno.XAggregation </type>
+ <type> com.sun.star.registry.XRegistryKey </type>
+ <type> com.sun.star.container.XSet </type>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <runtime-module-dependency> cppuhelper </runtime-module-dependency>
+ <runtime-module-dependency> cppu2 </runtime-module-dependency>
+ <runtime-module-dependency> sal2 </runtime-module-dependency>
+</module-description>
diff --git a/shell/source/win32/workbench/TestProxySet.cxx b/shell/source/win32/workbench/TestProxySet.cxx
new file mode 100644
index 000000000000..ab0d89e945d2
--- /dev/null
+++ b/shell/source/win32/workbench/TestProxySet.cxx
@@ -0,0 +1,200 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+
+//-----------------------------------------------------------
+// interface includes
+//-----------------------------------------------------------
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/system/XProxySettings.hpp>
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <osl/diagnose.h>
+
+#ifdef WNT
+
+#include <stdio.h>
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#endif
+
+//--------------------------------------------------------------
+// namesapces
+//--------------------------------------------------------------
+
+using namespace ::rtl ;
+using namespace ::cppu ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::lang ;
+using namespace std ;
+using namespace com::sun::star::system;
+
+//--------------------------------------------------------------
+// defines
+//--------------------------------------------------------------
+
+#ifdef WNT
+
+#define RDB_SYSPATH "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\applicat.rdb"
+
+#endif
+
+//--------------------------------------------------------------
+// global variables
+//--------------------------------------------------------------
+
+Reference< XMultiServiceFactory > g_xFactory;
+
+//--------------------------------------------------------------
+// main
+//--------------------------------------------------------------
+
+
+// int SAL_CALL main(int nArgc, char* Argv[], char* Env[] )
+int SAL_CALL main(int, char*, char* )
+{
+ //-------------------------------------------------
+ // get the global service-manager
+ //-------------------------------------------------
+
+ // Get global factory for uno services.
+ OUString rdbName = OUString( RTL_CONSTASCII_USTRINGPARAM( RDB_SYSPATH ) );
+ Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( rdbName ) );
+
+ // Print a message if an error occured.
+ if ( g_xFactory.is() == sal_False )
+ {
+ OSL_ENSURE(sal_False, "Can't create RegistryServiceFactory");
+ return(-1);
+ }
+
+ printf("Creating RegistryServiceFactory successful\n");
+
+ //-------------------------------------------------
+ // try to get an Interface to a XFilePicker Service
+ //-------------------------------------------------
+
+ try
+ {
+ Reference< XProxySettings > xProxySettings(
+ g_xFactory->createInstance( OUString::createFromAscii( "com.sun.star.system.SystemProxySettings" ) ), UNO_QUERY );
+
+ if ( !xProxySettings.is() )
+ {
+ OSL_ENSURE( sal_False, "Error creating SystemProxySettings Service" );
+ return(-1);
+ }
+
+ printf( "Creating instance of SystemProxySettings successful\n" );
+
+ OUString ftpProxy = xProxySettings->getFtpProxyAddress( );
+ OUString httpProxy = xProxySettings->getHttpProxyAddress( );
+ OUString httpsProxy = xProxySettings->getHttpsProxyAddress( );
+ OUString socksProxy = xProxySettings->getSocksProxyAddress( );
+ OUString gopherProxy = xProxySettings->getGopherProxyAddress( );
+
+ OUString ftpProxyPort = xProxySettings->getFtpProxyPort( );
+ OUString httpProxyPort = xProxySettings->getHttpProxyPort( );
+ OUString httpsProxyPort = xProxySettings->getHttpsProxyPort( );
+ OUString socksProxyPort = xProxySettings->getSocksProxyPort( );
+ OUString gopherProxyPort = xProxySettings->getGopherProxyPort( );
+
+ OUString proxyBypass = xProxySettings->getProxyBypassAddress( );
+
+ printf( "Test of SystemProxySettings successful\n" );
+
+ xProxySettings = Reference< XProxySettings >(
+ g_xFactory->createInstance( OUString::createFromAscii( "com.sun.star.system.SOProxySettings" ) ), UNO_QUERY );
+
+ if ( !xProxySettings.is() )
+ {
+ OSL_ENSURE( sal_False, "Error creating SystemProxySettings Service" );
+ return(-1);
+ }
+
+ printf( "Creating instance of SOProxySettings successful\n" );
+
+ ftpProxy = xProxySettings->getFtpProxyAddress( );
+ httpProxy = xProxySettings->getHttpProxyAddress( );
+ httpsProxy = xProxySettings->getHttpsProxyAddress( );
+ socksProxy = xProxySettings->getSocksProxyAddress( );
+ gopherProxy = xProxySettings->getGopherProxyAddress( );
+
+ ftpProxyPort = xProxySettings->getFtpProxyPort( );
+ httpProxyPort = xProxySettings->getHttpProxyPort( );
+ httpsProxyPort = xProxySettings->getHttpsProxyPort( );
+ socksProxyPort = xProxySettings->getSocksProxyPort( );
+ gopherProxyPort = xProxySettings->getGopherProxyPort( );
+
+ proxyBypass = xProxySettings->getProxyBypassAddress( );
+
+ sal_Bool bProxyEnabled = xProxySettings->isProxyEnabled( );
+ if (bProxyEnabled)
+ {
+ printf("Test ProxyEnabled true\n");
+ }
+
+ printf( "Test of SOProxySettings successful\n" );
+ }
+ catch( Exception& )
+ {
+ }
+
+ //--------------------------------------------------
+ // shutdown
+ //--------------------------------------------------
+
+ // Cast factory to XComponent
+ Reference< XComponent > xComponent( g_xFactory, UNO_QUERY );
+
+ // Print a message if an error occured.
+ if ( xComponent.is() == sal_False )
+ {
+ OSL_ENSURE(sal_False, "Error shuting down");
+ }
+
+ // Dispose and clear factory
+ xComponent->dispose();
+ g_xFactory.clear();
+ g_xFactory = Reference< XMultiServiceFactory >();
+
+ printf("Test successful\n");
+
+ return 0;
+}
diff --git a/shell/source/win32/workbench/TestSmplMail.cxx b/shell/source/win32/workbench/TestSmplMail.cxx
new file mode 100644
index 000000000000..a9b04a9f4e05
--- /dev/null
+++ b/shell/source/win32/workbench/TestSmplMail.cxx
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+
+//-----------------------------------------------------------
+// interface includes
+//-----------------------------------------------------------
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/system/XSimpleMailClientSupplier.hpp>
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <osl/diagnose.h>
+
+#include <stdio.h>
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include <osl/file.hxx>
+
+//--------------------------------------------------------------
+// namesapces
+//--------------------------------------------------------------
+
+using namespace ::rtl ;
+using namespace ::cppu ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::lang ;
+using namespace std ;
+using namespace com::sun::star::system;
+
+//--------------------------------------------------------------
+// defines
+//--------------------------------------------------------------
+
+#define RDB_SYSPATH "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\applicat.rdb"
+
+//--------------------------------------------------------------
+// global variables
+//--------------------------------------------------------------
+
+Reference< XMultiServiceFactory > g_xFactory;
+
+//--------------------------------------------------------------
+// main
+//--------------------------------------------------------------
+
+
+// int SAL_CALL main(int nArgc, char* Argv[], char* pEnv[] )
+// make Warning free, leave out typename
+int SAL_CALL main(int , char*, char* )
+{
+ //-------------------------------------------------
+ // get the global service-manager
+ //-------------------------------------------------
+
+ // Get global factory for uno services.
+ OUString rdbName = OUString( RTL_CONSTASCII_USTRINGPARAM( RDB_SYSPATH ) );
+ Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( rdbName ) );
+
+ // Print a message if an error occured.
+ if ( g_xFactory.is() == sal_False )
+ {
+ OSL_ENSURE(sal_False, "Can't create RegistryServiceFactory");
+ return(-1);
+ }
+
+ printf("Creating RegistryServiceFactory successful\n");
+
+ //-------------------------------------------------
+ // try to get an Interface to a XFilePicker Service
+ //-------------------------------------------------
+
+ try
+ {
+ Reference< XSimpleMailClientSupplier > xSmplMailClientSuppl(
+ g_xFactory->createInstance( OUString::createFromAscii( "com.sun.star.system.SimpleSystemMail" ) ), UNO_QUERY );
+
+ if ( !xSmplMailClientSuppl.is() )
+ {
+ OSL_ENSURE( sal_False, "Error creating SimpleSystemMail Service" );
+ return(-1);
+ }
+
+ Reference< XSimpleMailClient > xSmplMailClient(
+ xSmplMailClientSuppl->querySimpleMailClient( ) );
+
+ if ( xSmplMailClient.is( ) )
+ {
+ Reference< XSimpleMailMessage > xSmplMailMsg(
+ xSmplMailClient->createSimpleMailMessage( ) );
+
+ if ( xSmplMailMsg.is( ) )
+ {
+ xSmplMailMsg->setRecipient( OUString::createFromAscii("tino.rachui@germany.sun.com") );
+ xSmplMailMsg->setOriginator( OUString::createFromAscii( "tino.rachui@germany.sun.com" ) );
+
+ Sequence< OUString > ccRecips( 1 );
+ ccRecips[0] = OUString::createFromAscii( "tino.rachui@germany.sun.com" );
+
+ xSmplMailMsg->setCcRecipient( ccRecips );
+
+ Sequence< OUString > bccRecips( 1 );
+ bccRecips[0] = OUString::createFromAscii( "tino.rachui@germany.sun.com" );
+
+ xSmplMailMsg->setBccRecipient( bccRecips );
+
+ xSmplMailMsg->setSubject( OUString::createFromAscii( "Mapi Test" ) );
+
+ Sequence< OUString > attachements( 2 );
+
+ OUString aFile = OUString::createFromAscii( "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\testprx.exe" );
+ OUString aFileURL;
+
+ osl::FileBase::getFileURLFromSystemPath( aFile, aFileURL );
+ attachements[0] = aFileURL;
+
+ aFile = OUString::createFromAscii( "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\testsyssh.exe" );
+ osl::FileBase::getFileURLFromSystemPath( aFile, aFileURL );
+
+ attachements[1] = aFile;
+
+ xSmplMailMsg->setAttachement( attachements );
+
+ xSmplMailClient->sendSimpleMailMessage( xSmplMailMsg, 0 );
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ }
+
+ //--------------------------------------------------
+ // shutdown
+ //--------------------------------------------------
+
+ // Cast factory to XComponent
+ Reference< XComponent > xComponent( g_xFactory, UNO_QUERY );
+
+ // Print a message if an error occured.
+ if ( xComponent.is() == sal_False )
+ {
+ OSL_ENSURE(sal_False, "Error shuting down");
+ }
+
+ // Dispose and clear factory
+ xComponent->dispose();
+ g_xFactory.clear();
+ g_xFactory = Reference< XMultiServiceFactory >();
+
+ printf("Test successful\n");
+
+ return 0;
+}
diff --git a/shell/source/win32/workbench/TestSysShExec.cxx b/shell/source/win32/workbench/TestSysShExec.cxx
new file mode 100644
index 000000000000..c459408d3802
--- /dev/null
+++ b/shell/source/win32/workbench/TestSysShExec.cxx
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+
+//-----------------------------------------------------------
+// interface includes
+//-----------------------------------------------------------
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+
+#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
+#include <com/sun/star/system/XSystemShellExecute.hpp>
+#endif
+#include <cppuhelper/servicefactory.hxx>
+
+
+#include <osl/file.hxx>
+
+//--------------------------------------------------------------
+// other includes
+//--------------------------------------------------------------
+#include <cppuhelper/servicefactory.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <osl/diagnose.h>
+
+#include <stdio.h>
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+//--------------------------------------------------------------
+// namesapces
+//--------------------------------------------------------------
+
+using namespace ::rtl ;
+using namespace ::cppu ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::lang ;
+using namespace std ;
+using namespace com::sun::star::system;
+
+//--------------------------------------------------------------
+// defines
+//--------------------------------------------------------------
+
+#define RDB_SYSPATH "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\applicat.rdb"
+
+//--------------------------------------------------------------
+// global variables
+//--------------------------------------------------------------
+
+Reference< XMultiServiceFactory > g_xFactory;
+
+
+//--------------------------------------------------------------
+// main
+//--------------------------------------------------------------
+
+
+// int SAL_CALL main(int nArgc, char* Argv[], char* Env[] )
+int SAL_CALL main(int nArgc, char* Argv[], char* )
+{
+ //-------------------------------------------------
+ // get the global service-manager
+ //-------------------------------------------------
+
+ if ( nArgc < 4 )
+ return 0;
+
+ // Get global factory for uno services.
+ OUString rdbName = OUString( RTL_CONSTASCII_USTRINGPARAM( RDB_SYSPATH ) );
+ Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( rdbName ) );
+
+ // Print a message if an error occured.
+ if ( g_xFactory.is() == sal_False )
+ {
+ OSL_ENSURE(sal_False, "Can't create RegistryServiceFactory");
+ return(-1);
+ }
+
+ printf("Creating RegistryServiceFactory successful\n");
+
+ //-------------------------------------------------
+ // try to get an Interface to a XFilePicker Service
+ //-------------------------------------------------
+
+ Reference< XSystemShellExecute > xSysShExec(
+ g_xFactory->createInstance( OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" ) ), UNO_QUERY );
+
+ if ( !xSysShExec.is() )
+ {
+ OSL_ENSURE( sal_False, "Error creating SystemShellExecute Service" );
+ return(-1);
+ }
+
+ //"c:\\winnt\\notepad.exe"
+ OUString cmd = OUString::createFromAscii( Argv[1] );
+ OUString param = OUString::createFromAscii( Argv[2] ); //c:\\winnt\\iis5.log
+
+ try
+ {
+ xSysShExec->execute( cmd, param, atoi( Argv[3] ) );
+ }
+ catch( SystemShellExecuteException& )
+ {
+ OSL_ENSURE( sal_False, "Error executing system command" );
+ }
+ catch( IllegalArgumentException& )
+ {
+ OSL_ENSURE( sal_False, "Invalid parameter" );
+ }
+
+ //--------------------------------------------------
+ // shutdown
+ //--------------------------------------------------
+
+ // Cast factory to XComponent
+ Reference< XComponent > xComponent( g_xFactory, UNO_QUERY );
+
+ // Print a message if an error occured.
+ if ( xComponent.is() == sal_False )
+ {
+ OSL_ENSURE(sal_False, "Error shuting down");
+ }
+
+ // Dispose and clear factory
+ xComponent->dispose();
+ g_xFactory.clear();
+ g_xFactory = Reference< XMultiServiceFactory >();
+
+ printf("Test successful\n");
+
+ return 0;
+}
diff --git a/shell/source/win32/workbench/makefile.mk b/shell/source/win32/workbench/makefile.mk
new file mode 100644
index 000000000000..9d9c7945b9bf
--- /dev/null
+++ b/shell/source/win32/workbench/makefile.mk
@@ -0,0 +1,101 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=shell
+TARGET=testsyssh
+TARGET1=testsmplmail
+TARGET2=testprx
+TARGET4=testfopen
+LIBTARGET=NO
+TARGETTYPE=CUI
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+CFLAGS+=/GX
+
+OBJFILES1=$(OBJ)$/TestSysShExec.obj
+OBJFILES2=$(OBJ)$/TestSmplMail.obj
+OBJFILES3=$(OBJ)$/TestProxySet.obj
+OBJFILES4=$(OBJ)$/Testfopen.obj
+
+OBJFILES=$(OBJFILES1)\
+ $(OBJFILES2)
+
+APP1TARGET=$(TARGET)
+APP1OBJS=$(OBJFILES1)
+
+APP1STDLIBS+= $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(USER32LIB)
+
+APP1DEF= $(MISC)$/$(APP1TARGET).def
+
+
+# --- TestSmplMail ---
+
+APP2TARGET=$(TARGET1)
+APP2OBJS=$(OBJFILES2)
+
+APP2STDLIBS+= $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(USER32LIB)
+
+APP2DEF= $(MISC)$/$(APP2TARGET).def
+
+# --- TestProxy ---
+
+APP3TARGET=$(TARGET2)
+APP3OBJS=$(OBJFILES3)
+
+APP3STDLIBS+= $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+APP3DEF= $(MISC)$/$(APP3TARGET).def
+
+# --- Testfopen ---
+
+APP4TARGET=$(TARGET4)
+APP4OBJS=$(OBJFILES4)
+
+APP4STDLIBS+= $(SALLIB)
+
+APP4DEF= $(MISC)$/$(APP4TARGET).def
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+