From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- shell/inc/basereader.hxx | 73 ++++++++++++ shell/inc/columninfo.hxx | 61 ++++++++++ shell/inc/config.hxx | 86 ++++++++++++++ shell/inc/contentreader.hxx | 122 ++++++++++++++++++++ shell/inc/fileextensions.hxx | 62 +++++++++++ shell/inc/filepath.hxx | 29 +++++ shell/inc/global.hxx | 32 ++++++ shell/inc/i_xml_parser_event_handler.hxx | 63 +++++++++++ shell/inc/infotips.hxx | 88 +++++++++++++++ shell/inc/iso8601_converter.hxx | 42 +++++++ shell/inc/metainforeader.hxx | 144 ++++++++++++++++++++++++ shell/inc/propertyhdl.hxx | 109 ++++++++++++++++++ shell/inc/propsheets.hxx | 83 ++++++++++++++ shell/inc/registry.hxx | 58 ++++++++++ shell/inc/resource.h | 72 ++++++++++++ shell/inc/shlxthdl.hxx | 45 ++++++++ shell/inc/spsupp/COMOpenDocuments.hpp | 186 +++++++++++++++++++++++++++++++ shell/inc/spsupp/COMRefCounted.hpp | 47 ++++++++ shell/inc/spsupp/registrar.hpp | 49 ++++++++ shell/inc/spsupp/spsuppClassFactory.hpp | 49 ++++++++ shell/inc/spsupp/spsuppServ.hpp | 20 ++++ shell/inc/spsupp/spsuppStrings.hrc | 23 ++++ shell/inc/stream_helper.hxx | 54 +++++++++ shell/inc/thumbviewer.hxx | 99 ++++++++++++++++ shell/inc/types.hxx | 79 +++++++++++++ shell/inc/utilities.hxx | 104 +++++++++++++++++ shell/inc/xml_parser.hxx | 109 ++++++++++++++++++ shell/inc/zipfile.hxx | 152 +++++++++++++++++++++++++ 28 files changed, 2140 insertions(+) create mode 100644 shell/inc/basereader.hxx create mode 100644 shell/inc/columninfo.hxx create mode 100644 shell/inc/config.hxx create mode 100644 shell/inc/contentreader.hxx create mode 100644 shell/inc/fileextensions.hxx create mode 100644 shell/inc/filepath.hxx create mode 100644 shell/inc/global.hxx create mode 100644 shell/inc/i_xml_parser_event_handler.hxx create mode 100644 shell/inc/infotips.hxx create mode 100644 shell/inc/iso8601_converter.hxx create mode 100644 shell/inc/metainforeader.hxx create mode 100644 shell/inc/propertyhdl.hxx create mode 100644 shell/inc/propsheets.hxx create mode 100644 shell/inc/registry.hxx create mode 100644 shell/inc/resource.h create mode 100644 shell/inc/shlxthdl.hxx create mode 100644 shell/inc/spsupp/COMOpenDocuments.hpp create mode 100644 shell/inc/spsupp/COMRefCounted.hpp create mode 100644 shell/inc/spsupp/registrar.hpp create mode 100644 shell/inc/spsupp/spsuppClassFactory.hpp create mode 100644 shell/inc/spsupp/spsuppServ.hpp create mode 100644 shell/inc/spsupp/spsuppStrings.hrc create mode 100644 shell/inc/stream_helper.hxx create mode 100644 shell/inc/thumbviewer.hxx create mode 100644 shell/inc/types.hxx create mode 100644 shell/inc/utilities.hxx create mode 100644 shell/inc/xml_parser.hxx create mode 100644 shell/inc/zipfile.hxx (limited to 'shell/inc') diff --git a/shell/inc/basereader.hxx b/shell/inc/basereader.hxx new file mode 100644 index 000000000..1f09f9bc2 --- /dev/null +++ b/shell/inc/basereader.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_BASEREADER_HXX +#define INCLUDED_SHELL_INC_INTERNAL_BASEREADER_HXX + +#include "global.hxx" +#include "types.hxx" +#include "config.hxx" +#include "utilities.hxx" +#include "i_xml_parser_event_handler.hxx" + +#include "xml_parser.hxx" +#include "zipfile.hxx" +#include "filepath.hxx" + +class CBaseReader : public i_xml_parser_event_handler +{ +public: + virtual ~CBaseReader() override; + +protected: // protected because its only an implementation relevant class + CBaseReader( const Filepath_t& DocumentName ); + + CBaseReader( StreamInterface *stream ); + + virtual void start_document(); + + virtual void end_document(); + + virtual void start_element( + const string_t& raw_name, + const string_t& local_name, + const xml_tag_attribute_container_t& attributes) override = 0; + + virtual void end_element( + const string_t& raw_name, const string_t& local_name) override = 0; + + virtual void characters(const string_t& character) override = 0; + + virtual void ignore_whitespace(const string_t& /*whitespaces*/) override {}; + + virtual void processing_instruction( + const std::wstring& /*target*/, const std::wstring& /*data*/){}; + + virtual void comment(const string_t& /*comment*/) override {}; + + void Initialize( const std::string& /*ContentName*/); + +private: + ZipFile m_ZipFile; + ZipFile::ZipContentBuffer_t m_ZipContent; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/columninfo.hxx b/shell/inc/columninfo.hxx new file mode 100644 index 000000000..6a6710a65 --- /dev/null +++ b/shell/inc/columninfo.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_COLUMNINFO_HXX +#define INCLUDED_SHELL_INC_INTERNAL_COLUMNINFO_HXX + +#include + + +class CColumnInfo : public IColumnProvider +{ +public: + CColumnInfo(long RefCnt = 1); + virtual ~CColumnInfo(); + + + // IUnknown methods + + + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE QueryInterface( + REFIID riid, + void __RPC_FAR *__RPC_FAR *ppvObject) override; + + virtual COM_DECLSPEC_NOTHROW ULONG STDMETHODCALLTYPE AddRef() override; + + virtual COM_DECLSPEC_NOTHROW ULONG STDMETHODCALLTYPE Release() override; + + + // IColumnProvider + + + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE Initialize(LPCSHCOLUMNINIT psci) override; + + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetColumnInfo(DWORD dwIndex, SHCOLUMNINFO *psci) override; + + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetItemData( + LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT *pvarData) override; + +private: + long m_RefCnt; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/config.hxx b/shell/inc/config.hxx new file mode 100644 index 000000000..58b5dd4bf --- /dev/null +++ b/shell/inc/config.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_CONFIG_HXX +#define INCLUDED_SHELL_INC_INTERNAL_CONFIG_HXX + +#ifdef _AMD64_ +#define MODULE_NAME L"shlxthdl_x64.dll" +#else +#define MODULE_NAME L"shlxthdl.dll" +#endif + +#define COLUMN_HANDLER_DESCRIPTIVE_NAME L"LibreOffice Column Handler" +#define INFOTIP_HANDLER_DESCRIPTIVE_NAME L"LibreOffice Infotip Handler" +#define PROPSHEET_HANDLER_DESCRIPTIVE_NAME L"LibreOffice Property Sheet Handler" +#define THUMBVIEWER_HANDLER_DESCRIPTIVE_NAME L"LibreOffice 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_PARAGRAPHS L"paragraph-count" +#define META_INFO_WORDS L"word-count" +#define META_INFO_CHARACTERS L"character-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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/contentreader.hxx b/shell/inc/contentreader.hxx new file mode 100644 index 000000000..a8af703dd --- /dev/null +++ b/shell/inc/contentreader.hxx @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_CONTENTREADER_HXX +#define INCLUDED_SHELL_INC_INTERNAL_CONTENTREADER_HXX + +#include "basereader.hxx" +#include +#include "filepath.hxx" + +class ITag; +class StreamInterface; + +class CContentReader : public CBaseReader +{ +public: + virtual ~CContentReader() override; + + CContentReader( const Filepath_t& DocumentName, LocaleSet_t const & DocumentLocale ); + + CContentReader( StreamInterface* stream, LocaleSet_t const & DocumentLocale ); + + + /** Get the chunkbuffer. + + @return + the chunkbuffer of the document. + */ + 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 string_t& raw_name, + const string_t& local_name, + const xml_tag_attribute_container_t& attributes) override; + + /** 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 string_t& raw_name, const string_t& local_name) override; + + /** characters occurs when receiving characters + + @param character + content of the information received. + */ + virtual void characters(const string_t& character) override; + +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 + */ + StyleLocaleMap_t const & getStyleMap( ) const{ return m_StyleMap; }; + + /** get style of the current content. + + @return style of the current content. + */ + ::std::wstring getCurrentContentStyle(); + + /** 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 m_TagBuilderStack; + + ChunkBuffer_t m_ChunkBuffer; + StyleLocaleMap_t m_StyleMap; + LocaleSet_t m_DefaultLocale; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/fileextensions.hxx b/shell/inc/fileextensions.hxx new file mode 100644 index 000000000..5c499beb8 --- /dev/null +++ b/shell/inc/fileextensions.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_FILEEXTENSIONS_HXX +#define INCLUDED_SHELL_INC_INTERNAL_FILEEXTENSIONS_HXX + +#include "global.hxx" + +#include +#include "filepath.hxx" + +// 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 +{ + const char* ExtensionA; // e.g. ".sxw" + const wchar_t* ExtensionU; // e.g. L".sxw" + const wchar_t* RegistryForwardKey; // e.g. "soffice.StarWriterDocument.6" +}; + +extern const FileExtensionEntry OOFileExtensionTable[]; + +extern const size_t OOFileExtensionTableSize; + +/** Return the extension of a file + name without the '.' +*/ +Filepath_t get_file_name_extension(const Filepath_t& 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 Filepath_t& file_name); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/filepath.hxx b/shell/inc/filepath.hxx new file mode 100644 index 000000000..cc1d42a1c --- /dev/null +++ b/shell/inc/filepath.hxx @@ -0,0 +1,29 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_FILEPATH_HXX +#define INCLUDED_SHELL_INC_INTERNAL_FILEPATH_HXX + + +// typedefs to allow using Unicode paths on Windows + + +#include + +#if defined _WIN32 +typedef wchar_t Filepath_char_t; +typedef std::wstring Filepath_t; +#else +typedef char Filepath_char_t; +typedef std::string Filepath_t; +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/global.hxx b/shell/inc/global.hxx new file mode 100644 index 000000000..07b7d5f79 --- /dev/null +++ b/shell/inc/global.hxx @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_GLOBAL_HXX +#define INCLUDED_SHELL_INC_INTERNAL_GLOBAL_HXX + +#if !defined WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif +#include + +extern long g_DllRefCnt; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/i_xml_parser_event_handler.hxx b/shell/inc/i_xml_parser_event_handler.hxx new file mode 100644 index 000000000..48dd746fb --- /dev/null +++ b/shell/inc/i_xml_parser_event_handler.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_I_XML_PARSER_EVENT_HANDLER_HXX +#define INCLUDED_SHELL_INC_INTERNAL_I_XML_PARSER_EVENT_HANDLER_HXX + +#include +#include + +#ifdef _WIN32 + 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 xml_tag_attribute_container_t; + + +class i_xml_parser_event_handler +{ +public: + virtual ~i_xml_parser_event_handler() {}; + + 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 comment(const string_t& comment) = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/infotips.hxx b/shell/inc/infotips.hxx new file mode 100644 index 000000000..ac9218a71 --- /dev/null +++ b/shell/inc/infotips.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_INFOTIPS_HXX +#define INCLUDED_SHELL_INC_INTERNAL_INFOTIPS_HXX + +#include +#include +#include +#include "filepath.hxx" + +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) override; + + virtual ULONG STDMETHODCALLTYPE AddRef() override; + + virtual ULONG STDMETHODCALLTYPE Release() override; + + + // IQueryInfo methods + + + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetInfoTip(DWORD dwFlags, PWSTR* ppwszTip) override; + + virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE GetInfoFlags(DWORD *pdwFlags) override; + + + // IPersist methods + + + virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID* pClassID) override; + + + // IPersistFile methods + + + virtual HRESULT STDMETHODCALLTYPE IsDirty() override; + + virtual HRESULT STDMETHODCALLTYPE Load( + /* [in] */ LPCOLESTR pszFileName, + /* [in] */ DWORD dwMode) override; + + virtual HRESULT STDMETHODCALLTYPE Save( + /* [unique][in] */ LPCOLESTR pszFileName, + /* [in] */ BOOL fRemember) override; + + virtual HRESULT STDMETHODCALLTYPE SaveCompleted( + /* [unique][in] */ LPCOLESTR pszFileName) override; + + virtual HRESULT STDMETHODCALLTYPE GetCurFile( + /* [out] */ LPOLESTR __RPC_FAR *ppszFileName) override; + +private: + long m_RefCnt; + Filepath_char_t m_szFileName[MAX_PATH]; + std::wstring m_FileNameOnly; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/iso8601_converter.hxx b/shell/inc/iso8601_converter.hxx new file mode 100644 index 000000000..a8a0b4ed2 --- /dev/null +++ b/shell/inc/iso8601_converter.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_ISO8601_CONVERTER_HXX +#define INCLUDED_SHELL_INC_INTERNAL_ISO8601_CONVERTER_HXX + +#include + + +/* Converts ISO 8601 compliant date/time + representation to the representation + conforming to the current locale, + ignoring the milliseconds part if exists +*/ +std::wstring iso8601_date_to_local_date(const std::wstring& iso8601date); + + +/* Converts ISO 8601 compliant duration + representation to the representation + conforming to the current locale +*/ +std::wstring iso8601_duration_to_local_duration(const std::wstring& iso8601duration); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/metainforeader.hxx b/shell/inc/metainforeader.hxx new file mode 100644 index 000000000..7ff0a734f --- /dev/null +++ b/shell/inc/metainforeader.hxx @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_METAINFOREADER_HXX +#define INCLUDED_SHELL_INC_INTERNAL_METAINFOREADER_HXX + +#include "basereader.hxx" +#include "types.hxx" +#include +#include "filepath.hxx" + +class ITag; +class CKeywordsTag; +class CSimpleTag; +class CDummyTag; + +class CMetaInfoReader : public CBaseReader +{ +public: + virtual ~CMetaInfoReader() override; + + CMetaInfoReader( const Filepath_t& DocumentName ); + + CMetaInfoReader( StreamInterface* stream ); + + /** check if the Tag is in the target meta.xml file. + + @param TagName + the name of the tag that will be retrieved. + */ + bool hasTag(const 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 retrieved. + */ + 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, const 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, const 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 string_t& raw_name, + const string_t& local_name, + const xml_tag_attribute_container_t& attributes) override; + + /** 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 string_t& raw_name, const string_t& local_name) override; + + /** characters occurs when receiving characters + + @param character + content of the information received. + */ + virtual void characters(const string_t& character) override; + +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 m_TagBuilderStack; + +private: + CKeywordsTag* m_pKeywords_Builder; + CDummyTag* m_pDummy_Builder; + CSimpleTag* m_pSimple_Builder; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/propertyhdl.hxx b/shell/inc/propertyhdl.hxx new file mode 100644 index 000000000..725885525 --- /dev/null +++ b/shell/inc/propertyhdl.hxx @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_PROPERTYHDL_HXX +#define INCLUDED_SHELL_INC_INTERNAL_PROPERTYHDL_HXX + +#include + +// {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 ) override; + virtual ULONG STDMETHODCALLTYPE AddRef() override; + virtual ULONG STDMETHODCALLTYPE Release() override; + + + // IPropertyStore + + virtual HRESULT STDMETHODCALLTYPE GetCount( DWORD *pcProps ) override; + virtual HRESULT STDMETHODCALLTYPE GetAt( DWORD iProp, PROPERTYKEY *pkey ) override; + virtual HRESULT STDMETHODCALLTYPE GetValue( REFPROPERTYKEY key, PROPVARIANT *pPropVar ) override; + virtual HRESULT STDMETHODCALLTYPE SetValue( REFPROPERTYKEY key, REFPROPVARIANT propVar ) override; + virtual HRESULT STDMETHODCALLTYPE Commit() override; + + + // IPropertyStoreCapabilities + + virtual HRESULT STDMETHODCALLTYPE IsPropertyWritable( REFPROPERTYKEY key ) override; + + + // IInitializeWithStream + + virtual HRESULT STDMETHODCALLTYPE Initialize(IStream *pStream, DWORD grfMode) override; + +private: + void LoadProperties( CMetaInfoReader *pMetaInfoReader ); + +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) override; + virtual ULONG STDMETHODCALLTYPE AddRef() override; + virtual ULONG STDMETHODCALLTYPE Release() override; + + + // IClassFactory methods + + virtual HRESULT STDMETHODCALLTYPE CreateInstance( + IUnknown __RPC_FAR *pUnkOuter, + REFIID riid, + void __RPC_FAR *__RPC_FAR *ppvObject) override; + + virtual HRESULT STDMETHODCALLTYPE LockServer( BOOL fLock ) override; + static bool IsLocked(); + +private: + long m_RefCnt; + CLSID m_Clsid; + static long s_ServerLocks; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/propsheets.hxx b/shell/inc/propsheets.hxx new file mode 100644 index 000000000..2c3883555 --- /dev/null +++ b/shell/inc/propsheets.hxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_PROPSHEETS_HXX +#define INCLUDED_SHELL_INC_INTERNAL_PROPSHEETS_HXX + +#include "metainforeader.hxx" + +#include +#include +#include +#include "filepath.hxx" + +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) override; + + virtual ULONG STDMETHODCALLTYPE AddRef() override; + + virtual ULONG STDMETHODCALLTYPE Release() override; + + + // IShellExtInit + + + virtual HRESULT STDMETHODCALLTYPE Initialize( + LPCITEMIDLIST pidlFolder, IDataObject * lpdobj, HKEY hkeyProgID) override; + + + // IShellPropSheetExt + + + virtual HRESULT STDMETHODCALLTYPE AddPages(LPFNSVADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam) override; + + virtual HRESULT STDMETHODCALLTYPE ReplacePage( + EXPPS uPageID, LPFNSVADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam) override; + +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; + Filepath_char_t m_szFileName[MAX_PATH]; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/registry.hxx b/shell/inc/registry.hxx new file mode 100644 index 000000000..3ea0d85f7 --- /dev/null +++ b/shell/inc/registry.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_REGISTRY_HXX +#define INCLUDED_SHELL_INC_INTERNAL_REGISTRY_HXX + + +// registry helper functions + + +#include +#include +#include "filepath.hxx" + +/** Sets a value of the specified registry key, an empty ValueName sets the default + value + Returns true on success +*/ +bool SetRegistryKey(HKEY RootKey, const Filepath_char_t* KeyName, const Filepath_char_t* ValueName, const Filepath_char_t* Value); + +/** Deletes the specified registry key and all of its subkeys + Returns true on success +*/ +bool DeleteRegistryKey(HKEY RootKey, const Filepath_char_t* KeyName); + +/** May be used to determine if the specified registry key has subkeys + The function returns true on success else if an error occurs false +*/ +bool HasSubkeysRegistryKey(HKEY RootKey, const Filepath_char_t* KeyName, bool& bResult); + +/** Converts a GUID to its string representation +*/ +Filepath_t ClsidToString(const CLSID& clsid); + +/** Get the content of a specific key. +*/ +bool QueryRegistryKey(HKEY RootKey, const Filepath_char_t* KeyName, const Filepath_char_t* ValueName, Filepath_char_t *pszData, DWORD dwBufLen); + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/resource.h b/shell/inc/resource.h new file mode 100644 index 000000000..e17d3b81c --- /dev/null +++ b/shell/inc/resource.h @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_RESOURCE_H +#define INCLUDED_SHELL_INC_INTERNAL_RESOURCE_H + +#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_COMMENTS 1005 +#define IDC_KEYWORDS 1006 +#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_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_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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/shlxthdl.hxx b/shell/inc/shlxthdl.hxx new file mode 100644 index 000000000..2f1c1b1e8 --- /dev/null +++ b/shell/inc/shlxthdl.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_SHLXTHDL_HXX +#define INCLUDED_SHELL_INC_INTERNAL_SHLXTHDL_HXX + +#include + +// {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 } }; + +extern HINSTANCE g_hModule; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/spsupp/COMOpenDocuments.hpp b/shell/inc/spsupp/COMOpenDocuments.hpp new file mode 100644 index 000000000..21b378d89 --- /dev/null +++ b/shell/inc/spsupp/COMOpenDocuments.hpp @@ -0,0 +1,186 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* +* This file is part of the LibreOffice project. +* +* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ + +#ifndef INCLUDED_SHELL_INC_SPSUPP_COMOPENDOCUMENTS_HPP +#define INCLUDED_SHELL_INC_SPSUPP_COMOPENDOCUMENTS_HPP + +#if defined __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnon-virtual-dtor" +#endif +#include +#if defined __clang__ +#pragma clang diagnostic pop +#endif +#include "COMRefCounted.hpp" +#include +#include + +class COMOpenDocuments : public COMRefCounted +{ +public: + + class Error { + public: + Error(HRESULT syserr) : m_nErr(syserr) {} + HRESULT val() const { return m_nErr; } + private: + HRESULT m_nErr; + }; + + COMOpenDocuments(); + virtual ~COMOpenDocuments() override; + + // IUnknown methods + + HRESULT STDMETHODCALLTYPE QueryInterface( + REFIID riid, + void **ppvObject) override; + + // IDispatch methods + + HRESULT STDMETHODCALLTYPE GetTypeInfoCount( + UINT *pctinfo) override; + + HRESULT STDMETHODCALLTYPE GetTypeInfo( + UINT iTInfo, + LCID lcid, + ITypeInfo **ppTInfo) override; + + HRESULT STDMETHODCALLTYPE GetIDsOfNames( + REFIID riid, + LPOLESTR *rgszNames, + UINT cNames, + LCID lcid, + DISPID *rgDispId) override; + + HRESULT STDMETHODCALLTYPE Invoke( + DISPID dispIdMember, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS *pDispParams, + VARIANT *pVarResult, + EXCEPINFO *pExcepInfo, + UINT *puArgErr) override; + + // IOWSNewDocument methods https://msdn.microsoft.com/en-us/library/cc264316 + + HRESULT STDMETHODCALLTYPE CreateNewDocument( + BSTR bstrTemplateLocation, + BSTR bstrDefaultSaveLocation, + VARIANT_BOOL *pbResult) override; + + HRESULT STDMETHODCALLTYPE EditDocument( + BSTR bstrDocumentLocation, + VARIANT varProgID, + VARIANT_BOOL *pbResult) override; + + // IOWSNewDocument2 methods + + HRESULT STDMETHODCALLTYPE ViewDocument( + BSTR bstrDocumentLocation, + VARIANT varProgID, + VARIANT_BOOL *pbResult) override; + + HRESULT STDMETHODCALLTYPE ViewDocument2( + IDispatch *pdisp, + BSTR bstrDocumentLocation, + VARIANT varProgID, + VARIANT_BOOL *pbResult) override; + + HRESULT STDMETHODCALLTYPE EditDocument2( + IDispatch *pdisp, + BSTR bstrDocumentLocation, + VARIANT varProgID, + VARIANT_BOOL *pbResult) override; + + HRESULT STDMETHODCALLTYPE CreateNewDocument2( + IDispatch *pdisp, + BSTR bstrTemplateLocation, + BSTR bstrDefaultSaveLocation, + VARIANT_BOOL *pbResult) override; + + HRESULT STDMETHODCALLTYPE PromptedOnLastOpen( + VARIANT_BOOL *pbResult) override; + + // IOWSNewDocument3 methods + + HRESULT STDMETHODCALLTYPE ViewDocument3( + IDispatch *pdisp, + BSTR bstrDocumentLocation, + int OpenType, + VARIANT varProgID, + VARIANT_BOOL *pbResult) override; + + HRESULT STDMETHODCALLTYPE CheckinDocument( + BSTR bstrDocumentLocation, + int CheckinType, + BSTR CheckinComment, + VARIANT_BOOL bKeepCheckout, + VARIANT_BOOL *pbResult) override; + + HRESULT STDMETHODCALLTYPE DiscardLocalCheckout( + BSTR bstrDocumentLocationRaw, + VARIANT_BOOL *pbResult) override; + + HRESULT STDMETHODCALLTYPE ViewInExcel( + BSTR SiteUrl, + BSTR FileName, + BSTR SessionId, + BSTR Cmd, + BSTR Sheet, + int Row, + int Column, + VARIANT varProgID) override; + + HRESULT STDMETHODCALLTYPE CheckoutDocumentPrompt( + BSTR bstrDocumentLocationRaw, + VARIANT_BOOL fEditAfterCheckout, + VARIANT varProgID, + VARIANT_BOOL *pbResult) override; + + HRESULT STDMETHODCALLTYPE EditDocument3( + IDispatch *pdisp, + BSTR bstrDocumentLocation, + VARIANT_BOOL fUseLocalCopy, + VARIANT varProgID, + VARIANT_BOOL *pbResult) override; + + HRESULT STDMETHODCALLTYPE NewBlogPost( + BSTR bstrProviderId, + BSTR bstrBlogUrl, + BSTR bstrBlogName) override; + + // IObjectSafety methods + + HRESULT STDMETHODCALLTYPE GetInterfaceSafetyOptions( + REFIID riid, + DWORD *pdwSupportedOptions, + DWORD *pdwEnabledOptions) override; + + HRESULT STDMETHODCALLTYPE SetInterfaceSafetyOptions( + REFIID riid, + DWORD dwOptionSetMask, + DWORD dwEnabledOptions) override; + + // Non-COM methods + + static long GetObjectCount(); + +private: + static long m_nObjCount; + static ITypeInfo* m_pTypeInfo; + static constexpr DWORD iSupportedOptionsMask = INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA; + DWORD m_iEnabledOptions = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/spsupp/COMRefCounted.hpp b/shell/inc/spsupp/COMRefCounted.hpp new file mode 100644 index 000000000..0c2460ba2 --- /dev/null +++ b/shell/inc/spsupp/COMRefCounted.hpp @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* +* This file is part of the LibreOffice project. +* +* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ + +#ifndef INCLUDED_SHELL_INC_SPSUPP_COMREFCOUNTED_HPP +#define INCLUDED_SHELL_INC_SPSUPP_COMREFCOUNTED_HPP + +#include +#include + +template +class COMRefCounted : public Interfaces... +{ +public: + COMRefCounted() {} + virtual ~COMRefCounted() {} + + // IUnknown methods + + ULONG STDMETHODCALLTYPE AddRef() override + { + return static_cast(::InterlockedIncrement(&m_nRef)); + } + + ULONG STDMETHODCALLTYPE Release() override + { + assert(m_nRef > 0); + if (::InterlockedDecrement(&m_nRef) == 0) + { + delete this; + return 0; + } + return static_cast(m_nRef); + } + +private: + long m_nRef = 1; // Created referenced +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/spsupp/registrar.hpp b/shell/inc/spsupp/registrar.hpp new file mode 100644 index 000000000..920e076de --- /dev/null +++ b/shell/inc/spsupp/registrar.hpp @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* +* This file is part of the LibreOffice project. +* +* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ + +#ifndef INCLUDED_SHELL_INC_SPSUPP_REGISTRAR_H +#define INCLUDED_SHELL_INC_SPSUPP_REGISTRAR_H + +#include + +#if !defined WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif +#include + +class Registrar { +public: + explicit Registrar(REFIID riidCLSID); + // First version in list becomes default + HRESULT RegisterObject(REFIID riidTypeLib, + const wchar_t* sProgram, + const wchar_t* sComponent, + std::initializer_list aVersions, + const wchar_t* Path); + HRESULT UnRegisterObject(const wchar_t* sProgram, const wchar_t* sComponent, + std::initializer_list aVersions); + // First version in list becomes the default + HRESULT RegisterProgIDs(const wchar_t* sProgram, const wchar_t* sComponent, + std::initializer_list aVersions); + HRESULT UnRegisterProgIDs(const wchar_t* sProgram, const wchar_t* sComponent, + std::initializer_list aVersions); + +private: + HRESULT RegisterProgID(const wchar_t* sProgram, const wchar_t* sComponent, int nVersion, + bool bSetDefault); + HRESULT UnRegisterProgID(const wchar_t* sProgram, const wchar_t* sComponent, int nVersion); + + static const size_t nGUIDlen = 40; + wchar_t m_sCLSID[nGUIDlen]; + HRESULT m_ConstructionResult; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/spsupp/spsuppClassFactory.hpp b/shell/inc/spsupp/spsuppClassFactory.hpp new file mode 100644 index 000000000..9deccbd97 --- /dev/null +++ b/shell/inc/spsupp/spsuppClassFactory.hpp @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* +* This file is part of the LibreOffice project. +* +* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ + +#ifndef INCLUDED_SHELL_INC_SPSUPP_SPSUPPCLASSFACTORY_HPP +#define INCLUDED_SHELL_INC_SPSUPP_SPSUPPCLASSFACTORY_HPP + +#include "COMRefCounted.hpp" + +class ClassFactory : public COMRefCounted +{ +public: + ClassFactory(); + virtual ~ClassFactory() override; + + // IUnknown methods + + HRESULT STDMETHODCALLTYPE QueryInterface( + REFIID riid, + void **ppvObject) override; + + // IClassFactory methods + + HRESULT STDMETHODCALLTYPE CreateInstance( + IUnknown *pUnkOuter, + REFIID riid, + void **ppvObject) override; + + HRESULT STDMETHODCALLTYPE LockServer( + BOOL fLock) override; + + // Non-COM methods + + static long GetObjectCount() { return m_nObjCount; } + static long GetLockCount() { return m_nLockCount; } + +private: + static long m_nObjCount; + static long m_nLockCount; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/spsupp/spsuppServ.hpp b/shell/inc/spsupp/spsuppServ.hpp new file mode 100644 index 000000000..7e4d2fc54 --- /dev/null +++ b/shell/inc/spsupp/spsuppServ.hpp @@ -0,0 +1,20 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* +* This file is part of the LibreOffice project. +* +* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ + +#ifndef INCLUDED_SHELL_INC_SPSUPP_SPSUPPSERV_HPP +#define INCLUDED_SHELL_INC_SPSUPP_SPSUPPSERV_HPP + +#include + +ITypeLib* GetTypeLib(); +const wchar_t* GetHelperExe(); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/spsupp/spsuppStrings.hrc b/shell/inc/spsupp/spsuppStrings.hrc new file mode 100644 index 000000000..dc96fbb89 --- /dev/null +++ b/shell/inc/spsupp/spsuppStrings.hrc @@ -0,0 +1,23 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SHELL_INC_SPSUPP_STRINGS_HRC +#define INCLUDED_SHELL_INC_SPSUPP_STRINGS_HRC + +#define NC_(Context, String) reinterpret_cast(Context "\004" u8##String) + +#define RID_STR_SP_VIEW_OR_EDIT_TITLE NC_("RID_STR_SP_VIEW_OR_EDIT_TITLE", "Open Document") +#define RID_STR_SP_VIEW_OR_EDIT_MESSAGE NC_("RID_STR_SP_VIEW_OR_EDIT_MESSAGE", "You are opening document\n\n %DOCNAME\n\nDo you want to open it to view or to edit?") +#define RID_STR_SP_VIEW_OR_EDIT_VIEW NC_("RID_STR_SP_VIEW_OR_EDIT_VIEW", "View") +#define RID_STR_SP_VIEW_OR_EDIT_EDIT NC_("RID_STR_SP_VIEW_OR_EDIT_EDIT", "Edit") +#define RID_STR_SP_VIEW_OR_EDIT_CANCEL NC_("RID_STR_SP_VIEW_OR_EDIT_CANCEL", "Cancel") + +#endif // INCLUDED_SHELL_INC_SPSUPP_STRINGS_HRC + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/stream_helper.hxx b/shell/inc/stream_helper.hxx new file mode 100644 index 000000000..bcd2f28f0 --- /dev/null +++ b/shell/inc/stream_helper.hxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_STREAM_HELPER_HXX +#define INCLUDED_SHELL_INC_INTERNAL_STREAM_HELPER_HXX + +#include "types.hxx" +#include "filepath.hxx" + +struct IStream; + +class BufferStream : public StreamInterface +{ +public: + BufferStream(IStream *str); + ~BufferStream() override; + unsigned long sread (unsigned char *vuf, unsigned long size) override; + long stell () override; + long sseek (long offset, int origin) override; +private: + IStream *stream; +}; + +class FileStream : public StreamInterface +{ +public: + FileStream(const Filepath_char_t *filename); + ~FileStream() override; + unsigned long sread (unsigned char *buf, unsigned long size) override; + long stell () override; + long sseek (long offset, int origin) override; +private: + FILE *file; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/thumbviewer.hxx b/shell/inc/thumbviewer.hxx new file mode 100644 index 000000000..37e348118 --- /dev/null +++ b/shell/inc/thumbviewer.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_THUMBVIEWER_HXX +#define INCLUDED_SHELL_INC_INTERNAL_THUMBVIEWER_HXX + +#include +#include +#ifndef DONT_HAVE_GDIPLUS +#include +#endif +#include + +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) override; + + virtual ULONG STDMETHODCALLTYPE AddRef() override; + + virtual ULONG STDMETHODCALLTYPE Release() override; + + + // IExtractImage methods + + + virtual HRESULT STDMETHODCALLTYPE Extract(HBITMAP *phBmpImage) override; + + virtual HRESULT STDMETHODCALLTYPE GetLocation( + LPWSTR pszPathBuffer, + DWORD cchMax, + DWORD *pdwPriority, + const SIZE *prgSize, + DWORD dwRecClrDepth, + DWORD *pdwFlags) override; + + + // IPersist methods + + + virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID* pClassID) override; + + + // IPersistFile methods + + + virtual HRESULT STDMETHODCALLTYPE IsDirty() override; + + virtual HRESULT STDMETHODCALLTYPE Load( + /* [in] */ LPCOLESTR pszFileName, + /* [in] */ DWORD dwMode) override; + + virtual HRESULT STDMETHODCALLTYPE Save( + /* [unique][in] */ LPCOLESTR pszFileName, + /* [in] */ BOOL fRemember) override; + + virtual HRESULT STDMETHODCALLTYPE SaveCompleted( + /* [unique][in] */ LPCOLESTR pszFileName) override; + + virtual HRESULT STDMETHODCALLTYPE GetCurFile( + /* [out] */ LPOLESTR __RPC_FAR *ppszFileName) override; + +private: + long ref_count_; + std::wstring filename_; + SIZE thumbnail_size_; + DWORD color_depth_; + ULONG_PTR gdiplus_token_; + Gdiplus::Bitmap* signet_; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/types.hxx b/shell/inc/types.hxx new file mode 100644 index 000000000..6834bc609 --- /dev/null +++ b/shell/inc/types.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_TYPES_HXX +#define INCLUDED_SHELL_INC_INTERNAL_TYPES_HXX + +#include +#include +#include +#include + +//+------------------------------------------------------------------------- +// 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::map XmlTagAttributes_t; +typedef std::pair XmlTag_t; +typedef std::map 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 LocaleSet_t; + +typedef ::std::wstring Content_t; +typedef ::std::pair 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 Style-Locale pair. +// Contents: Definitions of Style Names. + +typedef ::std::wstring StyleName_t; +typedef ::std::pair StyleLocalePair_t; +typedef ::std::map StyleLocaleMap_t; + +const StyleLocalePair_t EMPTY_STYLELOCALE_PAIR = ::std::make_pair(::std::wstring(), EMPTY_LOCALE ); + +class StreamInterface +{ +public: + virtual ~StreamInterface() {} + virtual unsigned long sread (unsigned char* vuf, unsigned long size) = 0; + virtual long stell () = 0; + virtual long sseek (long offset, int origin) = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/utilities.hxx b/shell/inc/utilities.hxx new file mode 100644 index 000000000..a199c83db --- /dev/null +++ b/shell/inc/utilities.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_UTILITIES_HXX +#define INCLUDED_SHELL_INC_INTERNAL_UTILITIES_HXX + +#include + +#if !defined WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN +#endif +#include + +#include +#include +#include +#include "types.hxx" + +#include +#define STRSAFE_NO_DEPRECATE +#include + +/** 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); + + +/** Convert a string to a wstring + using CP_UTF8 +*/ +std::wstring UTF8ToWString(const std::string& String); + + +/** Retrieve a string from the + resources of this module +*/ +std::wstring GetResString(int ResId); + + +/** helper function to judge if the string is only has spaces. + @returns + if the provided string contains only but at least one space + character else . +*/ +bool HasOnlySpaces(const std::wstring& String); + +/** convert LocaleSet pair into Windows LCID identifier. + @returns + Windows Locale Identifier corresponding to input LocaleSet. +*/ + + +/** Convert a long path name using Windows api call GetShortPathName +*/ +std::wstring getShortPathName( const std::wstring& aLongName ); + + +LCID LocaleSetToLCID( const LocaleSet_t & Locale ); + + +#ifdef DEBUG +inline void OutputDebugStringFormatW( LPCWSTR pFormat, ... ) +{ + WCHAR buffer[1024]; + va_list args; + + va_start( args, pFormat ); + StringCchVPrintfW( buffer, sizeof(buffer)/sizeof(*buffer), pFormat, args ); + va_end( args ); + OutputDebugStringW( buffer ); +} +#else +static inline void OutputDebugStringFormatW( LPCWSTR, ... ) +{ +} +#endif + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/xml_parser.hxx b/shell/inc/xml_parser.hxx new file mode 100644 index 000000000..aea4240b5 --- /dev/null +++ b/shell/inc/xml_parser.hxx @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_XML_PARSER_HXX +#define INCLUDED_SHELL_INC_INTERNAL_XML_PARSER_HXX + +#include +#include + +#include + +class xml_parser_exception final : public std::runtime_error +{ +public: + + xml_parser_exception( + const std::string& error_msg) : + std::runtime_error(error_msg) + {} + +}; + + +// Simple wrapper around expat, the xml parser library +// created by James Clark + +class i_xml_parser_event_handler; + +class xml_parser +{ +public: + xml_parser(); + + ~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 useful 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); + + /** 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 interested 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 { return document_handler_;} +private: + + void init(); + +private: + i_xml_parser_event_handler* document_handler_; + XML_Parser xml_parser_; + +private: + xml_parser(const xml_parser&) = delete; + xml_parser& operator=(const xml_parser&) = delete; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/inc/zipfile.hxx b/shell/inc/zipfile.hxx new file mode 100644 index 000000000..1b4a27706 --- /dev/null +++ b/shell/inc/zipfile.hxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SHELL_INC_INTERNAL_ZIPFILE_HXX +#define INCLUDED_SHELL_INC_INTERNAL_ZIPFILE_HXX + +#include + +#include +#include +#include +#include "filepath.hxx" + +class StreamInterface; + +/** A simple zip content provider based on the zlib +*/ + +class ZipFile +{ +public: + typedef std::vector Directory_t; + typedef std::unique_ptr DirectoryPtr_t; + typedef std::vector 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 Filepath_t &FileName); + + static bool IsZipFile(void *stream); + + + /** Returns whether 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 Filepath_t &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 Filepath_t &FileName); + + ZipFile(StreamInterface *stream); + + + /** 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 a 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; + + /** Convenience 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 a zip error occurs + */ + long GetFileLongestFileNameLength() const; + +private: + StreamInterface *m_pStream; + bool m_bShouldFree; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3