Difference between revisions of "OpenOffice.org Internship/Projects/2010/Customizable html export for Impress"

From Apache OpenOffice Wiki
Jump to: navigation, search
Line 58: Line 58:
  
 
==Source code==
 
==Source code==
Contain working source for the extension buildVersion-1.3.7a Dated:6/sept/10  
+
Contain working source for the extension '''buildVersion-1.3.7a Dated:6/sept/10'''
 +
the code below will be updated as the development will progress.
  
 
===Export Extension===
 
===Export Extension===
 
Source code for files at the export extension end.  
 
Source code for files at the export extension end.  
 +
 +
====services.cxx====
 +
<source lang=cpp>
 +
/*************************************************************************
 +
*
 +
* 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_sdext.hxx"
 +
 +
#include "htmlex.hxx"
 +
 +
#include <cppuhelper/factory.hxx>
 +
#include <cppuhelper/implementationentry.hxx>
 +
 +
using namespace ::com::sun::star;
 +
using namespace ::com::sun::star::uno;
 +
using namespace ::com::sun::star::lang;
 +
using namespace ::com::sun::star::registry;
 +
 +
 +
namespace
 +
{
 +
    static Reference< XInterface > Create_HTMLExporter( const Reference< XComponentContext >& _rxContext )
 +
    {
 +
        return *(new HTMLExporter( _rxContext ));
 +
    }
 +
}
 +
 +
extern "C" void SAL_CALL component_getImplementationEnvironment(
 +
    const sal_Char **ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
 +
{
 +
    *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
 +
}
 +
 +
namespace
 +
{
 +
    typedef Reference< XInterface > (SAL_CALL * ComponentFactory)( const Reference< XComponentContext >& );
 +
 +
    struct ComponentDescription
 +
    {
 +
    const sal_Char*     pAsciiServiceName;
 +
    const sal_Char*    pAsciiImplementationName;
 +
        ComponentFactory    pFactory;
 +
 +
        ComponentDescription()
 +
            :pAsciiServiceName( NULL )
 +
            ,pAsciiImplementationName( NULL )
 +
            ,pFactory( NULL )
 +
        {
 +
        }
 +
    ComponentDescription( const sal_Char* _pAsciiServiceName, const sal_Char* _pAsciiImplementationName, ComponentFactory _pFactory )
 +
            :pAsciiServiceName( _pAsciiServiceName )
 +
            ,pAsciiImplementationName( _pAsciiImplementationName )
 +
            ,pFactory( _pFactory )
 +
        {
 +
        }
 +
    };
 +
 +
    static const ComponentDescription* lcl_getComponents()
 +
    {
 +
        static const ComponentDescription aDescriptions[] = {
 +
            ComponentDescription( "com.sun.star.document.ExportFilter", "com.sun.star.comp.documents.HTMLExExporter", Create_HTMLExporter ),
 +
            ComponentDescription()
 +
        };
 +
        return aDescriptions;
 +
    }
 +
}
 +
 +
extern "C" sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
 +
{
 +
Reference< XRegistryKey > xRootKey( static_cast< XRegistryKey* >( pRegistryKey ) );
 +
 +
::rtl::OUString sRootKey( "/", 1, RTL_TEXTENCODING_ASCII_US );
 +
 +
    const ComponentDescription* pComponents = lcl_getComponents();
 +
    while ( pComponents->pAsciiServiceName != NULL )
 +
{
 +
::rtl::OUString sMainKeyName( sRootKey );
 +
sMainKeyName += ::rtl::OUString::createFromAscii( pComponents->pAsciiImplementationName );
 +
sMainKeyName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES" );
 +
 +
try
 +
{
 +
Reference< XRegistryKey >  xNewKey( xRootKey->createKey( sMainKeyName ) );
 +
            xNewKey->createKey( ::rtl::OUString::createFromAscii( pComponents->pAsciiServiceName ) );
 +
}
 +
catch( Exception& )
 +
{
 +
OSL_ASSERT( "OModule::writeComponentInfos: something went wrong while creating the keys!" );
 +
return sal_False;
 +
}
 +
        ++pComponents;
 +
    }
 +
    return sal_True;
 +
}
 +
 +
extern "C" void* SAL_CALL component_getFactory(
 +
    const sal_Char* pImplementationName, void* /*pServiceManager*/, void* /*pRegistryKey*/ )
 +
{
 +
    ::rtl::OUString sImplementationName( ::rtl::OUString::createFromAscii( pImplementationName ) );
 +
 +
    Reference< XSingleComponentFactory > xFactory;
 +
 +
    const ComponentDescription* pComponents = lcl_getComponents();
 +
    while ( pComponents->pAsciiServiceName != NULL )
 +
{
 +
        if ( 0 == sImplementationName.compareToAscii( pComponents->pAsciiImplementationName ) )
 +
        {
 +
            Sequence< ::rtl::OUString > sServices(1);
 +
            sServices[0] = ::rtl::OUString::createFromAscii( pComponents->pAsciiServiceName );
 +
 +
            xFactory = ::cppu::createSingleComponentFactory(
 +
                pComponents->pFactory,
 +
                sImplementationName,
 +
                sServices,
 +
                NULL
 +
            );
 +
            break;
 +
        }
 +
 +
        ++pComponents;
 +
    }
 +
 +
    // by definition, objects returned via this C API need to ber acquired once
 +
    xFactory->acquire();
 +
    return xFactory.get();
 +
}
 +
 +
 +
</source>
 +
  
 
====htmlex.hxx====
 
====htmlex.hxx====
Line 979: Line 1,135:
  
 
</source>
 
</source>
 +
 +
====makefile.mk====
 +
<source lang=makefile>
 +
#*************************************************************************
 +
#
 +
# 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=sdext
 +
TARGET=htmlex
 +
ENABLE_EXCEPTIONS=TRUE
 +
 +
# --- Settings -----------------------------------------------------
 +
 +
MKDEPENDSOLVER:=
 +
.INCLUDE: settings.mk
 +
 +
.IF "$(L10N_framework)"==""
 +
 +
# --- Files --------------------------------------------------------
 +
 +
EXTENSIONNAME:=HTMLEx
 +
EXTENSION_ZIPNAME:=htmlexv1.3.7
 +
CDEFS += -DHTMLEX_IMPL_IDENTIFIER="com.sun.star.$(EXTENSIONNAME)-$(PLATFORMID)"
 +
SLOFILES=\
 +
    $(SLO)$/htmlex.obj \
 +
    $(SLO)$/services.obj
 +
 +
SHL1DLLPRE=
 +
SHL1TARGET=$(TARGET).uno
 +
 +
SHL1LIBS=\
 +
$(SLB)$/$(TARGET).lib
 +
 +
SHL1STDLIBS=\
 +
    $(CPPUHELPERLIB) \
 +
$(ZLIB3RDLIB)     \
 +
$(CPPULIB) \
 +
$(SALLIB)
 +
 +
SHL1DEPN=
 +
SHL1IMPLIB= i$(SHL1TARGET)
 +
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
 +
SHL1VERSIONMAP=$(SOLARENV)/src/component.map
 +
SHL1RPATH=OXT
 +
 +
DEF1NAME=$(SHL1TARGET)
 +
 +
# --- Extension packaging ------------------------------------------
 +
 +
DESCRIPTION_SRC:=config$/description.xml
 +
MANIFEST_SRC:=config$/manifest.xml
 +
COMPONENT_CONFIGDIR:=config
 +
COMPONENT_CONFIGDEST:=.
 +
COMPONENT_XCU= \
 +
    $(EXTENSIONDIR)$/htmlex_export_filter.xcu
 +
 +
COMPONENT_EXTRAS= \
 +
$(EXTENSIONDIR)$/files/manual.txt \
 +
$(EXTENSIONDIR)$/files/oooadd.js \
 +
$(EXTENSIONDIR)$/files/presentation.css \
 +
$(EXTENSIONDIR)$/files/presentation.js \
 +
$(EXTENSIONDIR)$/files/favicon.ico \
 +
$(EXTENSIONDIR)$/files/default.css \
 +
$(EXTENSIONDIR)$/files/default.js \
 +
$(EXTENSIONDIR)$/files/info.txt \
 +
$(EXTENSIONDIR)$/files/bgty.png \
 +
$(EXTENSIONDIR)$/files/end.png \
 +
$(EXTENSIONDIR)$/files/next.png \
 +
$(EXTENSIONDIR)$/files/ns.png \
 +
$(EXTENSIONDIR)$/files/previous.png \
 +
$(EXTENSIONDIR)$/files/ps.png \
 +
$(EXTENSIONDIR)$/files/start.png \
 +
$(EXTENSIONDIR)$/files/stop.png \
 +
$(EXTENSIONDIR)$/files/text.png
 +
 +
# native libraries
 +
COMPONENT_LIBRARIES= \
 +
    $(EXTENSIONDIR)$/$(SHL1TARGET)$(DLLPOST)
 +
 +
EXTENSION_PACKDEPS=$(COMPONENT_EXTRAS) makefile.mk
 +
 +
.INCLUDE : extension_pre.mk
 +
.ENDIF # L10N_framework
 +
.INCLUDE : target.mk
 +
.IF "$(L10N_framework)"==""
 +
.INCLUDE : extension_post.mk
 +
 +
 +
$(COMPONENT_EXTRAS) : files$/$$(@:f)
 +
@@-$(MKDIRHIER) $(@:d)
 +
    $(COPY) $< $@
 +
 +
.ENDIF # L10N_framework
 +
 +
 +
</source>
 +
 +
 +
===Browser end===
 +
files working at client browser end
  
 
==Project status==
 
==Project status==

Revision as of 07:48, 6 September 2010

Overview

The current html export for OOo impress and draw application produces outdated html. The goal of this internship project is to create a new html export extension that will replace the currently available html export in impress and draw. The extension should make use of modern html elements including css and javascript and support a template system so that non coders are able to alter the results of the generated html output.

Goals/Requirements

  • An OOo extension that exports a set of files that make the current presentation document (or draw) viewable in any current browser
  • The extension must include a settings dialog to configure the output during export
  • The extension must support templates, a template will define the visual style and the user interaction elements like navigation buttons or table of contents etc.
  • Template must not be 'hard coded' in the extension so adding more templates is possible without changing and compiling source code.
  • The extension must include 2-3 sample templates that are both "user friendly" and "visual appealing“
  • The extension must support the key features from the old HTML export (export of links, adding additional information like creator, email, automatic slide advances, etc)
  • The extension must be able to also export selected text from the presentation like title, outline and subtitle text. This is mainly an accessibility feature to enable visually impaired users to read

the contents of the exported presentation.

  • Export should an alternative text only view or a text overlay to support accessibility.
  • There should be no connection to the installed OpenOffice or any extensions, the files we put in the export directory must include everything needed.
  • The generated html file should be as simple as possible. All functionality should come from the template. Goal is to make developing, modifying templates easier for the user, not for us.
  • Templates should not make use of any javascript library to avoid conflicts with web pages where other versions of this library are used or incompatible other libraries are used.
  • All important configuration should be done during export.
  • Easy integration in existing web pages
  • The created output should provide a fall-back if javascript is disabled in the browser.
  • The templates used by the extension should be made installable via extensions themselves so others can contribute templates too.
  • Implement a powerful easy to use and easy to develop template system.

Project plan

PHASE I

  • Develop how templates will be implemented-- done
  • Develop a basic prototype template and format-- done
  • Define format of html output created by the extension -- done
  • Develop the JavaScript core and template development API(minimal form)-- done
  • Develop system to integrate in the existing HTML documents-- done

PHASE II

  • Develop a prototype template extension -- In progress
  • Implement the extension with basic export -- In progress
  • Add support for Index/Notes/TextView/Navigation to HTML/javasript. -- In progress

PHASE III

  • Implement the templates system with configuration/extension deployment support
  • Specify configuration dialog
  • Implement configuration dialog

PHASE IV

  • Test and Optimise the developed System and code under all systems and browser.
  • Perform Fixes and improve the system if some imperfections and errors found.

PHASE V
All tasks mentioned below are part of exciting requirements, they are NOT in the current scope of the project, but if there is any time left in the end, following things will be tried upon.

  • Make one small simple browser based tool for non-coders, to make modifing templates a piece of cake.
  • Make a small browser based(cross platform) template development IDE to make development and deployment of templates easy.
  • Implement webcast support(with today's new age technology)

Enhancements/bugs to be cured

All reported bugs and needed enhancements are mentioned here, they will be worked upon in the final stages.

  • Under firefox-Linux version, there is a problem extracting z-index values by javascript, where as in windows it work fine. -- to be cured

Documentation

Here is the raw documentation containing the up to date thoughts and architecture. it will be updated time to time with the progress and advancements done during that time period.( Last Update:5-Aug,2010, , Expected Next Update: by 20-Sept,2010 )

(if there is any problem with this link, kindly inform me at kushal.likhi@gmail.com)

Source code

Contain working source for the extension buildVersion-1.3.7a Dated:6/sept/10 the code below will be updated as the development will progress.

Export Extension

Source code for files at the export extension end.

services.cxx

/*************************************************************************
 *
 * 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_sdext.hxx"
 
#include "htmlex.hxx"
 
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implementationentry.hxx>
 
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::registry;
 
 
namespace
{
    static Reference< XInterface > Create_HTMLExporter( const Reference< XComponentContext >& _rxContext )
    {
        return *(new HTMLExporter( _rxContext ));
    }
}
 
extern "C" void SAL_CALL component_getImplementationEnvironment(
    const sal_Char **ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
{
    *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
 
namespace
{
    typedef Reference< XInterface > (SAL_CALL * ComponentFactory)( const Reference< XComponentContext >& );
 
    struct ComponentDescription
    {
	    const sal_Char*	    pAsciiServiceName;
	    const sal_Char*     pAsciiImplementationName;
        ComponentFactory    pFactory;
 
        ComponentDescription()
            :pAsciiServiceName( NULL )
            ,pAsciiImplementationName( NULL )
            ,pFactory( NULL )
        {
        }
	    ComponentDescription( const sal_Char* _pAsciiServiceName, const sal_Char* _pAsciiImplementationName, ComponentFactory _pFactory )
            :pAsciiServiceName( _pAsciiServiceName )
            ,pAsciiImplementationName( _pAsciiImplementationName )
            ,pFactory( _pFactory )
        {
        }
    };
 
    static const ComponentDescription* lcl_getComponents()
    {
        static const ComponentDescription aDescriptions[] = {
            ComponentDescription( "com.sun.star.document.ExportFilter", "com.sun.star.comp.documents.HTMLExExporter", Create_HTMLExporter ),
            ComponentDescription()
        };
        return aDescriptions;
    }
}
 
extern "C" sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
{
	Reference< XRegistryKey > xRootKey( static_cast< XRegistryKey* >( pRegistryKey ) );
 
	::rtl::OUString sRootKey( "/", 1, RTL_TEXTENCODING_ASCII_US );
 
    const ComponentDescription* pComponents = lcl_getComponents();
    while ( pComponents->pAsciiServiceName != NULL )
	{
		::rtl::OUString sMainKeyName( sRootKey );
		sMainKeyName += ::rtl::OUString::createFromAscii( pComponents->pAsciiImplementationName );
		sMainKeyName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES" );
 
		try
		{
			Reference< XRegistryKey >  xNewKey( xRootKey->createKey( sMainKeyName ) );
            xNewKey->createKey( ::rtl::OUString::createFromAscii( pComponents->pAsciiServiceName ) );
		}
		catch( Exception& )
		{
			OSL_ASSERT( "OModule::writeComponentInfos: something went wrong while creating the keys!" );
			return sal_False;
		}
        ++pComponents;
    }
    return sal_True;
}
 
extern "C" void* SAL_CALL component_getFactory(
    const sal_Char* pImplementationName, void* /*pServiceManager*/, void* /*pRegistryKey*/ )
{
    ::rtl::OUString sImplementationName( ::rtl::OUString::createFromAscii( pImplementationName ) );
 
    Reference< XSingleComponentFactory > xFactory;
 
    const ComponentDescription* pComponents = lcl_getComponents();
    while ( pComponents->pAsciiServiceName != NULL )
	{
        if ( 0 == sImplementationName.compareToAscii( pComponents->pAsciiImplementationName ) )
        {
            Sequence< ::rtl::OUString > sServices(1);
            sServices[0] = ::rtl::OUString::createFromAscii( pComponents->pAsciiServiceName );
 
            xFactory = ::cppu::createSingleComponentFactory(
                pComponents->pFactory,
                sImplementationName,
                sServices,
                NULL
            );
            break;
        }
 
        ++pComponents;
    }
 
    // by definition, objects returned via this C API need to ber acquired once
    xFactory->acquire();
    return xFactory.get();
}


htmlex.hxx

header file for the HTMLExporer

/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * 
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
 
#ifndef INCLUDED_HTMLEX_HXX
#define INCLUDED_HTMLEX_HXX
 
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/util/URL.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess2.hpp>
 
#include <cppuhelper/compbase2.hxx>
#include <cppuhelper/basemutex.hxx>
 
typedef ::cppu::WeakComponentImplHelper2< 
    com::sun::star::document::XFilter,
    com::sun::star::document::XExporter > HTMLExporterBase;
 
 
// prototype of the HTMLExporter Class
class HTMLExporter : private cppu::BaseMutex, public HTMLExporterBase
{
public:
//constructor for the class
    explicit HTMLExporter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
 
// XFilter 
    virtual sal_Bool SAL_CALL filter( const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rFilterData ) throw(com::sun::star::uno::RuntimeException);
 
//on cancel
    virtual void SAL_CALL cancel() throw();
 
// XExporter 
    virtual void SAL_CALL setSourceDocument( const com::sun::star::uno::Reference< com::sun::star::lang::XComponent >& xDocument )
        throw( com::sun::star::lang::IllegalArgumentException );
 
 
 
private:
	com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxContext;
	com::sun::star::uno::Reference< com::sun::star::lang::XMultiComponentFactory > mxServiceFactory;
	com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > mxURLTransformer;
	com::sun::star::uno::Reference< com::sun::star::document::XExporter > mxGraphicExporter;
	com::sun::star::uno::Reference< com::sun::star::ucb::XSimpleFileAccess2 > mxFileAccess;
 
	void getPackedFilesURL();	
	bool copyFile(const rtl::OUString& rSourceURL, const rtl::OUString& rDestURL, bool Replace);
	void createFolders( com::sun::star::util::URL aBaseURL ); 
	void createHTMLFile( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream, const rtl::OUString& rsDocumentTitle );
	void writeHTMLMetaData( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream, const rtl::OUString& aTitle );
	void createSlideImages();	
	bool copyCoreFiles();
	void copyTemplateFiles();
	void createNoJsPresentation( const rtl::OUString& rsDocumentTitle );
	bool copyDefaultTemplateFiles();
	rtl::OUString getSlideImageName( sal_Int32 nPageIndex );
	rtl::OUString copySoundFile( const rtl::OUString& rSourceURL );
	void writeIndexData( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream );
	void writeTextViewData( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream );
	void writeNotesData( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream );
	void writeTemplateSpecificData( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream );
 
// configuration data
	rtl::OUString msImageExtension;
	rtl::OUString msImageFolderName;
	rtl::OUString aExtensionVersion;
	rtl::OUString aNotes;
	rtl::OUString aOutline;
	rtl::OUString aSound;
	rtl::OUString aIndex;
	rtl::OUString aAutoTime;
	rtl::OUString aShowIndexOnStart;
 
// document model access
	com::sun::star::uno::Reference< com::sun::star::frame::XModel > mxModel;
	com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > mxDrawPages;
 
//private data
	com::sun::star::util::URL maDocumentBaseURL;
	com::sun::star::util::URL maExtensionBaseURL;
	com::sun::star::util::URL maCompleteURL;
 
 
 
};
 
#endif


htmlex.cxx

the main C++ code for the export filter

/*************************************************************************
 *
 * 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_sdext.hxx"
#include "htmlex.hxx"
#include<boost/preprocessor/stringize.hpp>
#include <osl/file.h>
#include <osl/thread.h>
#include <osl/diagnose.h>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implementationentry.hxx>
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/frame/XLoadable.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/deployment/XPackageInformationProvider.hpp>
#include <stdio.h>
#include <boost/shared_ptr.hpp>
 
using rtl::OUString;
using namespace com::sun::star;
using namespace com::sun::star::uno;
using namespace com::sun::star::io;
using namespace com::sun::star::util;
using namespace com::sun::star::drawing;
using namespace com::sun::star::container;
using namespace com::sun::star::beans;
using namespace com::sun::star::deployment;
 
 
// constructor for HTMLExporter class
HTMLExporter::HTMLExporter( const Reference< XComponentContext >& xContext )
: HTMLExporterBase( m_aMutex )
, mxContext( xContext, UNO_QUERY_THROW )
, mxServiceFactory( xContext->getServiceManager(), UNO_QUERY_THROW )
, mxURLTransformer( mxServiceFactory->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.URLTransformer" )), xContext), UNO_QUERY_THROW )
, mxGraphicExporter( mxServiceFactory->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GraphicExportFilter")), xContext), UNO_QUERY_THROW )
, mxFileAccess( mxServiceFactory->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess")), xContext), UNO_QUERY_THROW )
, msImageExtension( RTL_CONSTASCII_USTRINGPARAM( "png" ) )
, msImageFolderName( RTL_CONSTASCII_USTRINGPARAM( "slides" ) )
, aExtensionVersion( RTL_CONSTASCII_USTRINGPARAM( "1.x.xb" ) )
, aNotes( RTL_CONSTASCII_USTRINGPARAM( "yes" ) )
, aOutline( RTL_CONSTASCII_USTRINGPARAM( "yes" ) )
, aSound( RTL_CONSTASCII_USTRINGPARAM( "yes" ) )
, aIndex( RTL_CONSTASCII_USTRINGPARAM( "yes" ) )
, aAutoTime( RTL_CONSTASCII_USTRINGPARAM( "5.00" ) )
, aShowIndexOnStart( RTL_CONSTASCII_USTRINGPARAM( "yes" ) )
{
}
 
 
// write the OUString object data to the XOutputStream in UTF-8 Encoding
void writeUTF8String( const Reference< XOutputStream >& xOutputStream, const OUString& rString )
{
	rtl::OString aStr( rtl::OUStringToOString( rString, RTL_TEXTENCODING_UTF8 ) ) ;
 
	const Sequence< sal_Int8 > aData( (const sal_Int8*)aStr.getStr(), aStr.getLength() );
	xOutputStream->writeBytes( aData );
}
 
// write the Character string to the XOutputStream in UTF-8 Encoding
void writeUTF8String( const Reference< XOutputStream >& xOutputStream, const sal_Char* pStr )
{
	const Sequence< sal_Int8 > aData( (const sal_Int8*)pStr, strlen( (char*)pStr ) );
	xOutputStream->writeBytes( aData );
}
 
 
//get the url of the location where extension is installed.
void HTMLExporter::getPackedFilesURL()
{
	Reference<com::sun::star::deployment::XPackageInformationProvider> xProvider( mxContext->getValueByName( OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.deployment.PackageInformationProvider"))),UNO_QUERY_THROW);
 
OUString sURL( xProvider->getPackageLocation(rtl::OUString::createFromAscii( BOOST_PP_STRINGIZE(HTMLEX_IMPL_IDENTIFIER))));
 
 
maExtensionBaseURL.Path = sURL;
maExtensionBaseURL.Name = OUString();
maExtensionBaseURL.Complete = sURL;
//mxURLTransformer->assemble( maExtensionBaseURL );
 
}
 
// function to copy a file
bool HTMLExporter::copyFile(const rtl::OUString& rSourceURL, const rtl::OUString& rDestURL, bool Replace)
{
	if( !mxFileAccess->exists( rDestURL ) )
	{
		mxFileAccess->copy( rSourceURL, rDestURL );
		return true;
	}
	else 
	{
		if(Replace)
		{
			mxFileAccess->kill( rDestURL );
			mxFileAccess->copy( rSourceURL, rDestURL );
		}
		else
		{
			return false;
		}
	}
 
	return true;
 
}
 
// create target directory structure
void HTMLExporter::createFolders(URL aBaseURL)
{
 
	URL aCreateDirBase;
	OUString aDirList[4];
	aDirList[0] = OUString(RTL_CONSTASCII_USTRINGPARAM( "resource" )); 
	aDirList[1] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template" )); 
	aDirList[2] = OUString(RTL_CONSTASCII_USTRINGPARAM( "nojs" )); 
	aDirList[3] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/images" )); 
	sal_Int32 aDirCount = 4; // todo improve
	for(sal_Int32 i = 0; i < aDirCount; i++)
	{
		aCreateDirBase = aBaseURL;
		aCreateDirBase.Path += aDirList[i];
		aCreateDirBase.Name = OUString();		
		mxURLTransformer->assemble( aCreateDirBase );
		if( !mxFileAccess->exists( aCreateDirBase.Complete ) )
			mxFileAccess->createFolder( aCreateDirBase.Complete );
 
	}
 
 
}
 
//XImporter
void SAL_CALL HTMLExporter::setSourceDocument( const uno::Reference< lang::XComponent >& xDocument ) throw( lang::IllegalArgumentException )
{
    mxModel.set( xDocument, UNO_QUERY );
 
	if( mxModel.is() )
	{
		Reference< XDrawPagesSupplier > xDPS( mxModel, UNO_QUERY );
		if( xDPS.is() )
			mxDrawPages.set( xDPS->getDrawPages(), UNO_QUERY );
	}
 
	// we need a document with draw pages to export them
    if( !mxDrawPages.is()  )
		throw lang::IllegalArgumentException();
}
 
 
// XFilter the big one!!
sal_Bool SAL_CALL HTMLExporter::filter( const uno::Sequence< beans::PropertyValue >& rFilterData ) throw( uno::RuntimeException )
{
    sal_Bool bRet = sal_False;
    if( mxModel.is() )
    {
//defining things
        const OUString sOutputStream ( RTL_CONSTASCII_USTRINGPARAM ( "OutputStream" ) );
        const OUString sStream ( RTL_CONSTASCII_USTRINGPARAM ( "StreamForOutput" ) );
	const OUString sDocumentTitle( RTL_CONSTASCII_USTRINGPARAM ( "DocumentTitle" ) );
	const OUString sDocumentBaseURL( RTL_CONSTASCII_USTRINGPARAM ( "DocumentBaseURL" ) );
 
	Reference< XOutputStream > xOutputStream;
	Reference< XOutputStream > xStreamForOutput;
 
	OUString sTitle, sCompleteURL;
 
// parse parameter from the com::sun::star::document::MediaDescriptor service 
        const beans::PropertyValue* pAttribs = rFilterData.getConstArray();
 
        sal_Int32 nAttribs = rFilterData.getLength();
 
        for( sal_Int32 i = 0; i < nAttribs; i++ )
        {
 
            if ( pAttribs[i].Name == sOutputStream )
                pAttribs[i].Value >>= xOutputStream;
            else if ( pAttribs[i].Name == sStream )
                pAttribs[i].Value >>= xStreamForOutput;
			else if ( pAttribs[i].Name == sDocumentTitle )
				pAttribs[i].Value >>= sTitle;
			else if ( pAttribs[i].Name == sDocumentBaseURL )
				pAttribs[i].Value >>= sCompleteURL;
		}
 
 
		if( !xOutputStream.is() )
			xOutputStream = xStreamForOutput;
 
		if( xOutputStream.is() ) try
		{
			// fill out all members of maDocumentBaseURL
			maDocumentBaseURL.Complete = sCompleteURL;
			mxURLTransformer->parseStrict( maDocumentBaseURL );
			maCompleteURL.Complete = sCompleteURL;
 
			getPackedFilesURL();			
			createFolders( maDocumentBaseURL );
			copyCoreFiles();
			copyTemplateFiles();
			createHTMLFile( xOutputStream, sTitle );
			createSlideImages();
			createNoJsPresentation(sTitle);
			bRet = true;
		}
		catch( Exception& )
		{
		}
    }
 
 
    return bRet;
}
 
void SAL_CALL HTMLExporter::cancel() throw()
{
//when cancelled,, not sure what to put here.. :O
}
 
 
OUString HTMLExporter::getSlideImageName( sal_Int32 nPageIndex )
{
	OUString sSlideImageName( RTL_CONSTASCII_USTRINGPARAM( "img" ) );
	sSlideImageName += OUString::valueOf( nPageIndex + 1 );
	sSlideImageName += OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) );
	sSlideImageName += msImageExtension;
	return sSlideImageName;
}
 
rtl::OUString HTMLExporter::copySoundFile( const rtl::OUString& rSourceURL )
{
	URL aSoundSourceURL;
	aSoundSourceURL.Complete = rSourceURL;
	mxURLTransformer->parseStrict( maDocumentBaseURL );
 
	URL aTargetSoundFileURL = maDocumentBaseURL;
	aTargetSoundFileURL.Name = aSoundSourceURL.Name;
	mxURLTransformer->assemble( aTargetSoundFileURL );
 
	// copy if it does not yet exists
	if( !mxFileAccess->exists( aTargetSoundFileURL.Complete ) )
		mxFileAccess->copy( rSourceURL, aTargetSoundFileURL.Complete );
 
	// return relative path (which in this case is only the name)
	return aTargetSoundFileURL.Name;
}
 
void HTMLExporter::createSlideImages()
{
	if( mxDrawPages.is() ) try
	{
		// create images folder		
		URL aSlideFolderURL = maDocumentBaseURL;
		aSlideFolderURL.Path += msImageFolderName;
		aSlideFolderURL.Name = OUString();
		mxURLTransformer->assemble( aSlideFolderURL );
		if( !mxFileAccess->exists( aSlideFolderURL.Complete ) )
			mxFileAccess->createFolder( aSlideFolderURL.Complete );
 
		// export slide images
		const sal_Int32 nSlideCount = mxDrawPages->getCount();
		for( sal_Int32 nPageIndex = 0; nPageIndex < nSlideCount; nPageIndex++ )
		{
			Reference< XComponent > xDrawPage( mxDrawPages->getByIndex(nPageIndex), UNO_QUERY_THROW );
 
			URL aSlideURL = aSlideFolderURL;
			aSlideURL.Name = getSlideImageName( nPageIndex );
			mxURLTransformer->assemble( aSlideURL );
 
			// create the slide image
			Reference< XFilter > xFilter( mxGraphicExporter, UNO_QUERY_THROW );
 
			Sequence< PropertyValue > aFilterData( 2 );
			aFilterData[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("Width") );
			aFilterData[0].Value <<= (sal_Int32)800; // todo: get from configuration dialog
			aFilterData[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("Translucent") );
			aFilterData[1].Value <<= (sal_Bool)sal_False;
 
			Sequence< PropertyValue > aDescriptor( 3 );
			aDescriptor[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("FilterName") );
			aDescriptor[0].Value <<= msImageExtension.toAsciiUpperCase();
			aDescriptor[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("URL") );
			aDescriptor[1].Value <<= aSlideURL.Complete;
			aDescriptor[2].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("FilterData") );
			aDescriptor[2].Value <<= aFilterData;
 
			mxGraphicExporter->setSourceDocument( xDrawPage );
			xFilter->filter( aDescriptor );
		}
	}
	catch( Exception& )
	{
		OSL_ENSURE(false, "HTMLExporter::createHTMLFile, exception caught!");
	}
}
 
// copy core files
bool HTMLExporter::copyCoreFiles()
{
 
	URL aTargetDirectory = maDocumentBaseURL;
 
	URL aSourceCss;
	aSourceCss.Complete = maExtensionBaseURL.Path;
	aSourceCss.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/presentation.css" ) );
	mxURLTransformer->parseStrict( aSourceCss );	
	URL aTargetCss = aTargetDirectory;
	aTargetCss.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "resource" ) );
	aTargetCss.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "presentation.css" ) );
	mxURLTransformer->assemble( aTargetCss );
	if(!copyFile(aSourceCss.Complete, aTargetCss.Complete, true))
		return false;
 
	URL aSourceJs;
	aSourceJs.Complete = maExtensionBaseURL.Path;
	aSourceJs.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/presentation.js" ) );
	mxURLTransformer->parseStrict( aSourceJs );	
	URL aTargetJs = aTargetDirectory;
	aTargetJs.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "resource" ) );
	aTargetJs.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "presentation.js" ) );
	mxURLTransformer->assemble( aTargetJs );	
	if(!copyFile(aSourceJs.Complete, aTargetJs.Complete, true))
		return false;
 
	URL aSourceIco;
	aSourceIco.Complete = maExtensionBaseURL.Path;
	aSourceIco.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/favicon.ico" ) );
	mxURLTransformer->parseStrict( aSourceIco );	
	URL aTargetIco = aTargetDirectory;
	aTargetIco.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "favicon.ico" ) );
	mxURLTransformer->assemble( aTargetIco );	
	if(!copyFile(aSourceIco.Complete, aTargetIco.Complete, true))
		return false;
 
	URL aSourceManual;
	aSourceManual.Complete = maExtensionBaseURL.Path;
	aSourceManual.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/manual.txt" ) );
	mxURLTransformer->parseStrict( aSourceManual );	
	URL aTargetManual = aTargetDirectory;
	aTargetManual.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "manual.txt" ) );
	mxURLTransformer->assemble( aTargetManual );	
	if(!copyFile(aSourceManual.Complete, aTargetManual.Complete, true))
		return false;
 
	URL aSourceAddJs;
	aSourceAddJs.Complete = maExtensionBaseURL.Path;
	aSourceAddJs.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/oooadd.js" ) );
	mxURLTransformer->parseStrict( aSourceAddJs );	
	URL aTargetAddJs = aTargetDirectory;
	aTargetAddJs.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "oooadd.js" ) );
	mxURLTransformer->assemble( aTargetAddJs );	
	if(!copyFile(aSourceAddJs.Complete, aTargetAddJs.Complete, true))
		return false;
 
	return true;		
}
 
// copy default template files
bool HTMLExporter::copyDefaultTemplateFiles()
{
	/*
	URL aCopyFileBase;
	URL aFileSource;
	OUString aFileList[12];
	aFileList[0] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/default.js" )); 
	aFileList[1] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/default.css" )); 
	aFileList[2] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/info.txt" )); 
	aFileList[3] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/images/bgty.png" )); 
	aFileList[4] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/images/end.png" )); 
	aFileList[5] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/images/next.png" )); 
	aFileList[6] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/images/ns.png" )); 
	aFileList[7] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/images/previous.png" )); 
	aFileList[8] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/images/ps.png" )); 
	aFileList[9] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/images/start.png" )); 
	aFileList[10] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/images/stop.png" )); 
	aFileList[11] = OUString(RTL_CONSTASCII_USTRINGPARAM( "template/images/text.png" )); 
	sal_Int32 aFileCount = 12;
	for(sal_Int32 i = 0; i < aFileCount; i++)
	{
		aCopyFileBase = maDocumentBaseURL;
		aFileSource.Complete = maExtensionBaseURL.Path;
		aCopyFileBase.Path += aFileList[i];
		aCopyFileBase.Complete = aCopyFileBase.Path;
		mxURLTransformer->parseStrict( aCopyFileBase );
		aFileSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/" ) );
		aFileSource.Complete += aCopyFileBase.Name;
		if(!copyFile(aFileSource.Complete, aCopyFileBase.Complete, true))
		return false;
 
	}
*/
 
	URL aSource;
	URL aTarget;
 
	aSource.Complete = maExtensionBaseURL.Path;
	aSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/default.css" ) );
	mxURLTransformer->parseStrict( aSource );	
	aTarget = maDocumentBaseURL;
	aTarget.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "template" ) );
	aTarget.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "default.css" ) );
	mxURLTransformer->assemble( aTarget );
	if(!copyFile(aSource.Complete, aTarget.Complete, true))
		return false;
 
	aSource.Complete = maExtensionBaseURL.Path;
	aSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/default.js" ) );
	mxURLTransformer->parseStrict( aSource );	
	aTarget = maDocumentBaseURL;
	aTarget.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "template" ) );
	aTarget.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "default.js" ) );
	mxURLTransformer->assemble( aTarget );
	if(!copyFile(aSource.Complete, aTarget.Complete, true))
		return false;
 
	aSource.Complete = maExtensionBaseURL.Path;
	aSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/bgty.png" ) );
	mxURLTransformer->parseStrict( aSource );	
	aTarget = maDocumentBaseURL;
	aTarget.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "template/images" ) );
	aTarget.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "bgty.png" ) );
	mxURLTransformer->assemble( aTarget );
	if(!copyFile(aSource.Complete, aTarget.Complete, true))
		return false;
 
	aSource.Complete = maExtensionBaseURL.Path;
	aSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/info.txt" ) );
	mxURLTransformer->parseStrict( aSource );	
	aTarget = maDocumentBaseURL;
	aTarget.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "template" ) );
	aTarget.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "info.txt" ) );
	mxURLTransformer->assemble( aTarget );
	if(!copyFile(aSource.Complete, aTarget.Complete, true))
		return false;
 
	aSource.Complete = maExtensionBaseURL.Path;
	aSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/next.png" ) );
	mxURLTransformer->parseStrict( aSource );	
	aTarget = maDocumentBaseURL;
	aTarget.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "template/images" ) );
	aTarget.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "next.png" ) );
	mxURLTransformer->assemble( aTarget );
	if(!copyFile(aSource.Complete, aTarget.Complete, true))
		return false;
 
	aSource.Complete = maExtensionBaseURL.Path;
	aSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/ns.png" ) );
	mxURLTransformer->parseStrict( aSource );	
	aTarget = maDocumentBaseURL;
	aTarget.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "template/images" ) );
	aTarget.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "ns.png" ) );
	mxURLTransformer->assemble( aTarget );
	if(!copyFile(aSource.Complete, aTarget.Complete, true))
		return false;
 
	aSource.Complete = maExtensionBaseURL.Path;
	aSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/previous.png" ) );
	mxURLTransformer->parseStrict( aSource );	
	aTarget = maDocumentBaseURL;
	aTarget.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "template/images" ) );
	aTarget.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "previous.png" ) );
	mxURLTransformer->assemble( aTarget );
	if(!copyFile(aSource.Complete, aTarget.Complete, true))
		return false;
 
	aSource.Complete = maExtensionBaseURL.Path;
	aSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/ps.png" ) );
	mxURLTransformer->parseStrict( aSource );	
	aTarget = maDocumentBaseURL;
	aTarget.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "template/images" ) );
	aTarget.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "ps.png" ) );
	mxURLTransformer->assemble( aTarget );
	if(!copyFile(aSource.Complete, aTarget.Complete, true))
		return false;
 
	aSource.Complete = maExtensionBaseURL.Path;
	aSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/start.png" ) );
	mxURLTransformer->parseStrict( aSource );	
	aTarget = maDocumentBaseURL;
	aTarget.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "template/images" ) );
	aTarget.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "start.png" ) );
	mxURLTransformer->assemble( aTarget );
	if(!copyFile(aSource.Complete, aTarget.Complete, true))
		return false;
 
	aSource.Complete = maExtensionBaseURL.Path;
	aSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/stop.png" ) );
	mxURLTransformer->parseStrict( aSource );	
	aTarget = maDocumentBaseURL;
	aTarget.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "template/images" ) );
	aTarget.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "stop.png" ) );
	mxURLTransformer->assemble( aTarget );
	if(!copyFile(aSource.Complete, aTarget.Complete, true))
		return false;
 
	aSource.Complete = maExtensionBaseURL.Path;
	aSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/text.png" ) );
	mxURLTransformer->parseStrict( aSource );	
	aTarget = maDocumentBaseURL;
	aTarget.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "template/images" ) );
	aTarget.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "text.png" ) );
	mxURLTransformer->assemble( aTarget );
	if(!copyFile(aSource.Complete, aTarget.Complete, true))
		return false;
 
	aSource.Complete = maExtensionBaseURL.Path;
	aSource.Complete += OUString( RTL_CONSTASCII_USTRINGPARAM( "/files/end.png" ) );
	mxURLTransformer->parseStrict( aSource );	
	aTarget = maDocumentBaseURL;
	aTarget.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "template/images" ) );
	aTarget.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "end.png" ) );
	mxURLTransformer->assemble( aTarget );
	if(!copyFile(aSource.Complete, aTarget.Complete, true))
		return false;
 
return true;
 
}
 
 
 
 
//function to export the presentation without javascript in NoJs folder
void HTMLExporter::createNoJsPresentation(const rtl::OUString& rsDocumentTitle)
{
// stream for writing index.html file
	URL afileURL;
	afileURL.Path = maDocumentBaseURL.Path;
	afileURL.Path += OUString( RTL_CONSTASCII_USTRINGPARAM( "nojs/index.html" ) );
	//afileURL.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "index.html" ) );
	//mxURLTransformer->assemble( afileURL );
	Reference< XOutputStream > xOutputStream1;
	xOutputStream1 = mxFileAccess->openFileWrite( afileURL.Path );
//todo Improove to a good format... default format exported
writeUTF8String( xOutputStream1, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n" );
	writeUTF8String( xOutputStream1, "<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<title>");
	writeUTF8String( xOutputStream1, rsDocumentTitle );
	writeUTF8String( xOutputStream1, "</title>\r\n</head>\r\n<body>\r\n" );
 
	if( mxDrawPages.is() )
	{
		const sal_Int32 nSlideCount = mxDrawPages->getCount();
 
		for( sal_Int32 nPageIndex = 0; nPageIndex < nSlideCount; nPageIndex++ ) try
		{
			Reference< XDrawPage > xPage( mxDrawPages->getByIndex( nPageIndex ), UNO_QUERY_THROW );
			Reference< XPropertySet > xPageProps( xPage, UNO_QUERY );
 
			// user interface name of the current slide
			OUString sPageName;
			xPageProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LinkDisplayName" ) ) ) >>= sPageName;
 
			// url to slide sound file
			OUString sSoundURL;
			xPageProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ) ) >>= sSoundURL;
 
 
			writeUTF8String( xOutputStream1, "<div class=\"slide\">\r\n" );
			writeUTF8String( xOutputStream1, "<img class=\"slideimage\" src=\"../" );
			writeUTF8String( xOutputStream1, msImageFolderName );
			writeUTF8String( xOutputStream1, "/" );
			writeUTF8String( xOutputStream1, getSlideImageName( nPageIndex ) );
			writeUTF8String( xOutputStream1, "\" alt=\"" );
			writeUTF8String( xOutputStream1, sPageName );
			writeUTF8String( xOutputStream1, "/>\r\n" );
			writeUTF8String( xOutputStream1, "<div class=\"slidename\">" );
			writeUTF8String( xOutputStream1, sPageName );
			writeUTF8String( xOutputStream1, "</div>\r\n" );
 
			if( sSoundURL.getLength() != 0 )
			{
				// todo: convert to ogg?
				writeUTF8String( xOutputStream1, "<audio preload class=\"slideaudio\"><source src=\"" );
				writeUTF8String( xOutputStream1, copySoundFile( sSoundURL ) );
				writeUTF8String( xOutputStream1, "\"></audio>\r\n" );
			}
			writeUTF8String( xOutputStream1, "</div>\r\n");
		}
		catch( Exception& )
		{
			OSL_ENSURE(false, "HTMLExporter::createHTMLFile, exception caught!");
		}
	}
 
	writeUTF8String( xOutputStream1, "</body>\r\n</html>\r\n" );
	xOutputStream1->flush();
}
 
void HTMLExporter::writeHTMLMetaData( const Reference< XOutputStream >& xOutputStream, const OUString& aTitle )
{// work left here
	const sal_Int32 nSlideCount = mxDrawPages->getCount();
	OUString aAuthor;
	OUString aSlideCount( rtl::OUString::valueOf(nSlideCount,10) );
	OUString aVersion;
	OUString aTimeStamp;
 
 
	//aSlideCount = OUString( RTL_CONSTASCII_USTRINGPARAM ( nSlideCount ));
 
	writeUTF8String( xOutputStream,"<!-- *************** META INFORMATION ******************************* -->\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n");
	writeUTF8String( xOutputStream,"<meta name=\"oooAuthor\" content=\"");
	writeUTF8String( xOutputStream,aAuthor);
	writeUTF8String( xOutputStream,"\" />\r\n");
 
	writeUTF8String( xOutputStream,"<meta name=\"oooSlideCount\" content=\"");
	writeUTF8String( xOutputStream,aSlideCount);
	writeUTF8String( xOutputStream,"\" />\r\n");
 
	writeUTF8String( xOutputStream,"<meta name=\"oooTitle\" content=\"");
	writeUTF8String( xOutputStream,aTitle);
	writeUTF8String( xOutputStream,"\" />\r\n");
 
	writeUTF8String( xOutputStream,"<meta name=\"oooVersion\" content=\"");
	writeUTF8String( xOutputStream,aVersion);
	writeUTF8String( xOutputStream,"\" />\r\n");
 
	writeUTF8String( xOutputStream,"<meta name=\"oooExtensionVersion\" content=\"");
	writeUTF8String( xOutputStream,aExtensionVersion);
	writeUTF8String( xOutputStream,"\" />\r\n");
 
	writeUTF8String( xOutputStream,"<meta name=\"oooTimeStamp\" content=\"");
	writeUTF8String( xOutputStream,aTimeStamp);
	writeUTF8String( xOutputStream,"\" />\r\n");
 
	writeUTF8String( xOutputStream,"<meta name=\"oooOutline\" content=\"");
	writeUTF8String( xOutputStream,aOutline);
	writeUTF8String( xOutputStream,"\" />\r\n");
 
	writeUTF8String( xOutputStream,"<meta name=\"oooNotes\" content=\"");
	writeUTF8String( xOutputStream,aNotes);
	writeUTF8String( xOutputStream,"\" />\r\n");
 
	writeUTF8String( xOutputStream,"<meta name=\"oooIndex\" content=\"");
	writeUTF8String( xOutputStream,aIndex);
	writeUTF8String( xOutputStream,"\" />\r\n");
 
	writeUTF8String( xOutputStream,"<meta name=\"oooSound\" content=\"");
	writeUTF8String( xOutputStream,aSound);
	writeUTF8String( xOutputStream,"\" />\r\n");
 
	writeUTF8String( xOutputStream,"<meta name=\"oooAutoTime\" content=\"");
	writeUTF8String( xOutputStream,aAutoTime);
	writeUTF8String( xOutputStream,"\" />\r\n");
 
	writeUTF8String( xOutputStream,"<meta name=\"oooWebcastStatus\" content=\"0\" />");
 
	writeUTF8String( xOutputStream,"<meta name=\"oooShowIndexOnStart\" content=\"");
	writeUTF8String( xOutputStream,aShowIndexOnStart);
	writeUTF8String( xOutputStream,"\" />\r\n");
 
	writeUTF8String( xOutputStream,"<!-- *************** META INFORMATION ENDS *************************** -->\r\n" );
 
}
 
 
//create the main html file.
void HTMLExporter::createHTMLFile( const Reference< XOutputStream >& xOutputStream, const OUString& rsDocumentTitle )
{
	writeUTF8String( xOutputStream, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n" );
	writeUTF8String( xOutputStream, "<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<title>");
	writeUTF8String( xOutputStream, rsDocumentTitle );
	writeUTF8String( xOutputStream, "</title>\r\n" );
 
// write Meta Data
	writeHTMLMetaData( xOutputStream, rsDocumentTitle );
 
// dependant/required files included
	writeUTF8String( xOutputStream, "<script type=\"text/javascript\" src=\"resource/presentation.js\"></script>\r\n");
	writeUTF8String( xOutputStream, "<link type=\"text/css\" rel=\"stylesheet\" href=\"resource/presentation.css\" />\r\n");
	writeUTF8String( xOutputStream, "<link type=\"text/css\" rel=\"stylesheet\" href=\"template/default.css\" />\r\n");
	writeUTF8String( xOutputStream, "<script type=\"text/javascript\" src=\"template/default.js\"></script>\r\n");
	writeUTF8String( xOutputStream, "<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"favicon.ico\" />\r\n");
 
	writeUTF8String( xOutputStream, "</head>\r\n");
 
	writeUTF8String( xOutputStream, "<body>\r\n");
	writeUTF8String( xOutputStream, "<!-- Nothing unwanted in the body,, everything will be added by template realtime on demand. No Code Redundancy.. Hurray!! -->\r\n");
	writeUTF8String( xOutputStream, "<!-- there could be special template elements added during export process to add flexibility.. that completely depends on template designer and his/her creativity-->\r\n");
	writeUTF8String( xOutputStream, "<!--******************************************************************************************************************\r\n");
	writeUTF8String( xOutputStream, "Followind section is for Javascript RollBack.. this will only be displayed if javascript is disabled.. -->\r\n");
	writeUTF8String( xOutputStream, "<div id=\"NoJs\">\r\n");
	writeUTF8String( xOutputStream, "<h1 align=\"center\">Welcome!</h1>\r\n");
	writeUTF8String( xOutputStream, "<h2 align=\"center\">JavaScript Seems To Be Disabled!</h2>\r\n");
	writeUTF8String( xOutputStream, "<h4 align=\"center\"><a href=\"nojs/index.html\">Click Here To Launch Standard Non Javascript Version</a></h4>\r\n");
	writeUTF8String( xOutputStream, "<h4 align=\"center\">Or</h4>\r\n");
	writeUTF8String( xOutputStream, "<h4 align=\"center\">Enable JavaScript In Your Browser</h4>\r\n");
	writeUTF8String( xOutputStream, "</div>\r\n");
 
	writeUTF8String( xOutputStream, "<!-- Index -->\r\n");
	writeUTF8String( xOutputStream, "<div id=\"index\">\r\n");
 
	// write index data
	writeIndexData( xOutputStream );	
 
	writeUTF8String( xOutputStream, "</div>\r\n");
 
	writeUTF8String( xOutputStream, "<!-- Background -->\r\n");
	writeUTF8String( xOutputStream, "<div id=\"background\"></div>\r\n");
 
	writeUTF8String( xOutputStream, "<!-- text only view -->\r\n");
	writeUTF8String( xOutputStream, "<div id=\"textOnly\">\r\n");
 
	// write text only view data
	writeTextViewData( xOutputStream );
 
	writeUTF8String( xOutputStream, "</div>\r\n");
 
	writeUTF8String( xOutputStream, "<!-- notes -->\r\n");
	writeUTF8String( xOutputStream, "<div id=\"notesContainer\">\r\n");
 
	//notes data
	writeNotesData( xOutputStream );	
 
	writeUTF8String( xOutputStream, "</div>\r\n");
 
	writeUTF8String( xOutputStream, "<!-- TEMPLATE SPECIFIC ELEMENTS HERE (if any)-->\r\n");
 
	//template specific elements 
	writeTemplateSpecificData( xOutputStream );
 
	writeUTF8String( xOutputStream, "</body>\r\n");
	writeUTF8String( xOutputStream, "</html>\r\n");
	xOutputStream->flush();	
}
 
// function to copy template files
void HTMLExporter::copyTemplateFiles()
{
//todo
// to copy default template, for testing and in case no template extension found
copyDefaultTemplateFiles();
}
 
void HTMLExporter::writeIndexData( const Reference< XOutputStream >& xOutputStream )
{
//todo
}
 
void HTMLExporter::writeTextViewData( const Reference< XOutputStream >& xOutputStream )
{
//todo
}
 
void HTMLExporter::writeNotesData( const Reference< XOutputStream >& xOutputStream )
{
//todo
}
 
void HTMLExporter::writeTemplateSpecificData( const Reference< XOutputStream >& xOutputStream )
{
//todo
}

makefile.mk

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


#*************************************************************************
#
# 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=sdext
TARGET=htmlex
ENABLE_EXCEPTIONS=TRUE

# --- Settings -----------------------------------------------------

MKDEPENDSOLVER:=
.INCLUDE: settings.mk

.IF "$(L10N_framework)"==""

# --- Files --------------------------------------------------------

EXTENSIONNAME:=HTMLEx
EXTENSION_ZIPNAME:=htmlexv1.3.7
CDEFS += -DHTMLEX_IMPL_IDENTIFIER="com.sun.star.$(EXTENSIONNAME)-$(PLATFORMID)"
SLOFILES=\
    $(SLO)$/htmlex.obj \
    $(SLO)$/services.obj

SHL1DLLPRE=
SHL1TARGET=$(TARGET).uno

SHL1LIBS=\
	$(SLB)$/$(TARGET).lib

SHL1STDLIBS=\
    $(CPPUHELPERLIB)	\
	$(ZLIB3RDLIB)	    \
	$(CPPULIB)			\
	$(SALLIB)

SHL1DEPN=
SHL1IMPLIB=	i$(SHL1TARGET)
SHL1DEF=	$(MISC)$/$(SHL1TARGET).def
SHL1VERSIONMAP=$(SOLARENV)/src/component.map
SHL1RPATH=OXT

DEF1NAME=$(SHL1TARGET)

# --- Extension packaging ------------------------------------------

DESCRIPTION_SRC:=config$/description.xml
MANIFEST_SRC:=config$/manifest.xml
COMPONENT_CONFIGDIR:=config
COMPONENT_CONFIGDEST:=.
COMPONENT_XCU= \
    $(EXTENSIONDIR)$/htmlex_export_filter.xcu

COMPONENT_EXTRAS= \
	$(EXTENSIONDIR)$/files/manual.txt \
	$(EXTENSIONDIR)$/files/oooadd.js \
	$(EXTENSIONDIR)$/files/presentation.css \
	$(EXTENSIONDIR)$/files/presentation.js \
	$(EXTENSIONDIR)$/files/favicon.ico \
	$(EXTENSIONDIR)$/files/default.css \
	$(EXTENSIONDIR)$/files/default.js \
	$(EXTENSIONDIR)$/files/info.txt	\
	$(EXTENSIONDIR)$/files/bgty.png \
	$(EXTENSIONDIR)$/files/end.png \
	$(EXTENSIONDIR)$/files/next.png \
	$(EXTENSIONDIR)$/files/ns.png \
	$(EXTENSIONDIR)$/files/previous.png \
	$(EXTENSIONDIR)$/files/ps.png \
	$(EXTENSIONDIR)$/files/start.png \
	$(EXTENSIONDIR)$/files/stop.png \
	$(EXTENSIONDIR)$/files/text.png

# native libraries
COMPONENT_LIBRARIES= \
    $(EXTENSIONDIR)$/$(SHL1TARGET)$(DLLPOST)

EXTENSION_PACKDEPS=$(COMPONENT_EXTRAS) makefile.mk

.INCLUDE : extension_pre.mk
.ENDIF # L10N_framework
.INCLUDE : target.mk
.IF "$(L10N_framework)"==""
.INCLUDE : extension_post.mk


$(COMPONENT_EXTRAS) : files$/$$(@:f)
	@@-$(MKDIRHIER) $(@:d)
    $(COPY) $< $@

.ENDIF # L10N_framework


Browser end

files working at client browser end

Project status

  • The project is accepted for the OpenOffice summer internship program 2010
Personal tools