summaryrefslogtreecommitdiff
path: root/shell/source/all
diff options
context:
space:
mode:
Diffstat (limited to 'shell/source/all')
-rwxr-xr-xshell/source/all/makefile.mk73
-rw-r--r--shell/source/all/ooofilereader/autostyletag.cxx102
-rw-r--r--shell/source/all/ooofilereader/autostyletag.hxx75
-rw-r--r--shell/source/all/ooofilereader/basereader.cxx107
-rw-r--r--shell/source/all/ooofilereader/contentreader.cxx237
-rw-r--r--shell/source/all/ooofilereader/dummytag.hxx64
-rw-r--r--shell/source/all/ooofilereader/itag.hxx55
-rw-r--r--shell/source/all/ooofilereader/keywordstag.cxx66
-rw-r--r--shell/source/all/ooofilereader/keywordstag.hxx57
-rwxr-xr-xshell/source/all/ooofilereader/makefile.mk89
-rw-r--r--shell/source/all/ooofilereader/metainforeader.cxx304
-rw-r--r--shell/source/all/ooofilereader/simpletag.cxx68
-rw-r--r--shell/source/all/ooofilereader/simpletag.hxx61
-rw-r--r--shell/source/all/xml_parser.cxx216
-rwxr-xr-xshell/source/all/zipfile/makefile.mk58
-rw-r--r--shell/source/all/zipfile/zipexcptn.cxx140
-rw-r--r--shell/source/all/zipfile/zipexcptn.hxx81
-rw-r--r--shell/source/all/zipfile/zipfile.cxx253
18 files changed, 2106 insertions, 0 deletions
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..3cf81a7bd5f9
--- /dev/null
+++ b/shell/source/all/ooofilereader/autostyletag.cxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/ooofilereader/autostyletag.hxx b/shell/source/all/ooofilereader/autostyletag.hxx
new file mode 100644
index 000000000000..c392b53bb0cb
--- /dev/null
+++ b/shell/source/all/ooofilereader/autostyletag.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/ooofilereader/basereader.cxx b/shell/source/all/ooofilereader/basereader.cxx
new file mode 100644
index 000000000000..39752fe70515
--- /dev/null
+++ b/shell/source/all/ooofilereader/basereader.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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"
+
+#include "internal/xml_parser.hxx"
+
+#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");
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/ooofilereader/contentreader.cxx b/shell/source/all/ooofilereader/contentreader.cxx
new file mode 100644
index 000000000000..360d3dcfd3b6
--- /dev/null
+++ b/shell/source/all/ooofilereader/contentreader.cxx
@@ -0,0 +1,237 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/ooofilereader/dummytag.hxx b/shell/source/all/ooofilereader/dummytag.hxx
new file mode 100644
index 000000000000..b7007f5acf7c
--- /dev/null
+++ b/shell/source/all/ooofilereader/dummytag.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/ooofilereader/itag.hxx b/shell/source/all/ooofilereader/itag.hxx
new file mode 100644
index 000000000000..c4a7eeacf8f5
--- /dev/null
+++ b/shell/source/all/ooofilereader/itag.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/ooofilereader/keywordstag.cxx b/shell/source/all/ooofilereader/keywordstag.cxx
new file mode 100644
index 000000000000..695bfe8b5a60
--- /dev/null
+++ b/shell/source/all/ooofilereader/keywordstag.cxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/ooofilereader/keywordstag.hxx b/shell/source/all/ooofilereader/keywordstag.hxx
new file mode 100644
index 000000000000..9a761acf8072
--- /dev/null
+++ b/shell/source/all/ooofilereader/keywordstag.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/ooofilereader/makefile.mk b/shell/source/all/ooofilereader/makefile.mk
new file mode 100755
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..be6ad746569d
--- /dev/null
+++ b/shell/source/all/ooofilereader/metainforeader.cxx
@@ -0,0 +1,304 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/ooofilereader/simpletag.cxx b/shell/source/all/ooofilereader/simpletag.cxx
new file mode 100644
index 000000000000..fa9f28796869
--- /dev/null
+++ b/shell/source/all/ooofilereader/simpletag.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 ) );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/ooofilereader/simpletag.hxx b/shell/source/all/ooofilereader/simpletag.hxx
new file mode 100644
index 000000000000..fb4b5d8399ce
--- /dev/null
+++ b/shell/source/all/ooofilereader/simpletag.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/xml_parser.cxx b/shell/source/all/xml_parser.cxx
new file mode 100644
index 000000000000..71665ce9fd0d
--- /dev/null
+++ b/shell/source/all/xml_parser.cxx
@@ -0,0 +1,216 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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/xml_parser.hxx"
+#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_;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/zipfile/makefile.mk b/shell/source/all/zipfile/makefile.mk
new file mode 100755
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..c5501d5b6213
--- /dev/null
+++ b/shell/source/all/zipfile/zipexcptn.cxx
@@ -0,0 +1,140 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/zipfile/zipexcptn.hxx b/shell/source/all/zipfile/zipexcptn.hxx
new file mode 100644
index 000000000000..80ddfe9702bc
--- /dev/null
+++ b/shell/source/all/zipfile/zipexcptn.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/all/zipfile/zipfile.cxx b/shell/source/all/zipfile/zipfile.cxx
new file mode 100644
index 000000000000..0b4ac7fd7fc2
--- /dev/null
+++ b/shell/source/all/zipfile/zipfile.cxx
@@ -0,0 +1,253 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */