diff options
author | Sven Jacobi <sj@openoffice.org> | 2007-05-11 13:01:25 +0000 |
---|---|---|
committer | Sven Jacobi <sj@openoffice.org> | 2007-05-11 13:01:25 +0000 |
commit | e22c431e24b4a83ddc928f7703b13a9a109c1b8e (patch) | |
tree | 8a254876a593421bb31a2dce275fb8b91c89b4f6 /sdext | |
parent | 7a35d8d3505efa36215b59d2206e2a4be2844e86 (diff) |
initial version
Diffstat (limited to 'sdext')
21 files changed, 5359 insertions, 0 deletions
diff --git a/sdext/source/minimizer/informationdialog.cxx b/sdext/source/minimizer/informationdialog.cxx new file mode 100644 index 000000000000..6daa26fdab53 --- /dev/null +++ b/sdext/source/minimizer/informationdialog.cxx @@ -0,0 +1,327 @@ + /************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: informationdialog.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:56:24 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INFORMATIONDIALOG_HXX +#include "informationdialog.hxx" +#endif +#ifndef OPTIMIZATIONSTATS_HXX +#include "optimizationstats.hxx" +#endif +#ifndef _COM_SUN_STAR_UI_DIALOGS_EXECUTABLEDIALOGRESULTS_HPP_ +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +#define DIALOG_WIDTH 240 +#define DIALOG_HEIGHT 84 +#define PAGE_POS_X 35 +#define PAGE_WIDTH ( DIALOG_WIDTH - PAGE_POS_X ) - 6 + + +// --------------------- +// - INFORMATIONDIALOG - +// --------------------- + +using namespace ::rtl; +using namespace ::com::sun::star::ui; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::script; +using namespace ::com::sun::star::container; + + + +// ----------------------------------------------------------------------------- + +rtl::OUString InsertFixedText( InformationDialog& rInformationDialog, const rtl::OUString& rControlName, const OUString& rLabel, + sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Int16 nTabIndex ) +{ + OUString pNames[] = { + TKGet( TK_Height ), + TKGet( TK_Label ), + TKGet( TK_MultiLine ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_Step ), + TKGet( TK_TabIndex ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( nHeight ), + Any( rLabel ), + Any( bMultiLine ), + Any( nXPos ), + Any( nYPos ), + Any( (sal_Int16)0 ), + Any( nTabIndex ), + Any( nWidth ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + rInformationDialog.insertFixedText( rControlName, aNames, aValues ); + return rControlName; +} + +rtl::OUString InsertImage( InformationDialog& rInformationDialog, const OUString& rControlName, const OUString& rURL, + sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight ) +{ + OUString pNames[] = { + TKGet( TK_Border ), + TKGet( TK_Height ), + TKGet( TK_ImageURL ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_ScaleImage ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( sal_Int16( 1 ) ), + Any( nHeight ), + Any( rURL ), + Any( nPosX ), + Any( nPosY ), + Any( sal_True ), + Any( nWidth ) }; + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + rInformationDialog.insertImage( rControlName, aNames, aValues ); + return rControlName; +} + +rtl::OUString InsertCheckBox( InformationDialog& rInformationDialog, const OUString& rControlName, + const Reference< XItemListener > xItemListener, const OUString& rLabel, + sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex ) +{ + OUString pNames[] = { + TKGet( TK_Enabled ), + TKGet( TK_Height ), + TKGet( TK_Label ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_Step ), + TKGet( TK_TabIndex ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( sal_True ), + Any( nHeight ), + Any( rLabel ), + Any( nXPos ), + Any( nYPos ), + Any( (sal_Int16)0 ), + Any( nTabIndex ), + Any( nWidth ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + Reference< XCheckBox > xCheckBox( rInformationDialog.insertCheckBox( rControlName, aNames, aValues ) ); + if ( xItemListener.is() ) + xCheckBox->addItemListener( xItemListener ); + return rControlName; +} + +rtl::OUString InsertButton( InformationDialog& rInformationDialog, const OUString& rControlName, Reference< XActionListener >& xActionListener, + sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex, PPPOptimizerTokenEnum nResID ) +{ + OUString pNames[] = { + TKGet( TK_Enabled ), + TKGet( TK_Height ), + TKGet( TK_Label ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_PushButtonType ), + TKGet( TK_Step ), + TKGet( TK_TabIndex ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( sal_True ), + Any( nHeight ), + Any( rInformationDialog.getString( nResID ) ), + Any( nXPos ), + Any( nYPos ), + Any( static_cast< sal_Int16 >( PushButtonType_OK ) ), + Any( (sal_Int16)0 ), + Any( nTabIndex ), + Any( nWidth ) }; + + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + rInformationDialog.insertButton( rControlName, xActionListener, aNames, aValues ); + return rControlName; +} + + +static OUString ImpValueOfInMB( const sal_Int64& rVal ) +{ + double fVal( static_cast<double>( rVal ) ); + fVal /= ( 1 << 20 ); + fVal += 0.05; + rtl::OUStringBuffer aVal( OUString::valueOf( fVal ) ); + sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.', 0 ) ); + if ( nX > 0 ) + aVal.setLength( nX + 2 ); + return aVal.makeStringAndClear(); +} + +void InformationDialog::InitDialog() +{ + // setting the dialog properties + OUString pNames[] = { + TKGet( TK_Closeable ), + TKGet( TK_Height ), + TKGet( TK_Moveable ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_Title ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( sal_True ), + Any( sal_Int32( DIALOG_HEIGHT ) ), + Any( sal_True ), + Any( sal_Int32( 113 ) ), + Any( sal_Int32( 42 ) ), + Any( getString( STR_ABOUT ) ), + Any( sal_Int32( DIALOG_WIDTH ) ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + rtl::OUString sBitmapPath( getPath( TK_BitmapPath ) ); + rtl::OUString sBitmap( rtl::OUString::createFromAscii( "/aboutlogo.png" ) ); + rtl::OUString sURL( sBitmapPath += sBitmap ); + + sal_Bool bOpenNewDocument = mrbOpenNewDocument; + setControlProperty( TKGet( TK_OpenNewDocument ), TKGet( TK_State ), Any( (sal_Int16)bOpenNewDocument ) ); + + mxDialogModelMultiPropertySet->setPropertyValues( aNames, aValues ); + + + OUString aInfoString( getString( STR_INFO_1 ) ); + const OUString aOldSizePlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%OLDFILESIZE" ) ); + const OUString aNewSizePlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%NEWFILESIZE" ) ); + sal_Int32 i = aInfoString.indexOf( aOldSizePlaceholder, 0 ); + if ( i >= 0 ) + aInfoString = aInfoString.replaceAt( i, aOldSizePlaceholder.getLength(), ImpValueOfInMB( mnSourceSize ) ); + + sal_Int32 j = aInfoString.indexOf( aNewSizePlaceholder, 0 ); + if ( j >= 0 ) + aInfoString = aInfoString.replaceAt( j, aNewSizePlaceholder.getLength(), ImpValueOfInMB( mnDestSize ) ); + + com::sun::star::uno::Reference< com::sun::star::awt::XItemListener > xItemListener; + InsertImage( *this, rtl::OUString( rtl::OUString::createFromAscii( "aboutimage" ) ), sURL, 5, 5, 25, 25 ); + InsertFixedText( *this, rtl::OUString( rtl::OUString::createFromAscii( "fixedtext" ) ), aInfoString, PAGE_POS_X, 6, PAGE_WIDTH, 24, sal_True, 0 ); + InsertCheckBox( *this, TKGet( TK_OpenNewDocument ), xItemListener, getString( STR_AUTOMATICALLY_OPEN ), PAGE_POS_X, 42, PAGE_WIDTH, 8, 1 ); + InsertButton( *this, rtl::OUString( rtl::OUString::createFromAscii( "button" ) ), mxActionListener, DIALOG_WIDTH / 2 - 25, DIALOG_HEIGHT - 20, 50, 14, 2, STR_OK ); +} + +// ----------------------------------------------------------------------------- + +InformationDialog::InformationDialog( const Reference< XComponentContext > &rxMSF, Reference< XFrame >& rxFrame, sal_Bool& bOpenNewDocument, sal_Int64 nSourceSize, sal_Int64 nDestSize ) : + UnoDialog( rxMSF, rxFrame ), + ConfigurationAccess( rxMSF, NULL ), + mxMSF( rxMSF ), + mxFrame( rxFrame ), + mxActionListener( new OKActionListener( *this ) ), + mnSourceSize( nSourceSize ), + mnDestSize( nDestSize ), + mrbOpenNewDocument( bOpenNewDocument ) +{ + Reference< XFrame > xFrame( mxController->getFrame() ); + Reference< XWindow > xContainerWindow( xFrame->getContainerWindow() ); + Reference< XWindowPeer > xWindowPeer( xContainerWindow, UNO_QUERY_THROW ); + createWindowPeer( xWindowPeer ); + + InitDialog(); +} + +// ----------------------------------------------------------------------------- + +InformationDialog::~InformationDialog() +{ +} + +// ----------------------------------------------------------------------------- + +sal_Bool InformationDialog::execute() +{ + UnoDialog::execute(); + + sal_Int16 nInt16; + Any aAny( getControlProperty( TKGet( TK_OpenNewDocument ), TKGet( TK_State ) ) ); + if ( aAny >>= nInt16 ) + { + sal_Bool bOpenNewDocument = static_cast< sal_Bool >( nInt16 ); + mrbOpenNewDocument = bOpenNewDocument; + } + return mbStatus; +} + +// ----------------------------------------------------------------------------- + +void OKActionListener::actionPerformed( const ActionEvent& rEvent ) + throw ( com::sun::star::uno::RuntimeException ) +{ + if ( rEvent.ActionCommand == rtl::OUString( rtl::OUString::createFromAscii( "button" ) ) ) + { + mrInformationDialog.endExecute( sal_True ); + } +} +void OKActionListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) + throw ( com::sun::star::uno::RuntimeException ) +{ +} diff --git a/sdext/source/minimizer/informationdialog.hxx b/sdext/source/minimizer/informationdialog.hxx new file mode 100644 index 000000000000..9d2febfba022 --- /dev/null +++ b/sdext/source/minimizer/informationdialog.hxx @@ -0,0 +1,135 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: informationdialog.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:56:41 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INFORMATIONDIALOG_HXX +#define INFORMATIONDIALOG_HXX +#include <vector> +#ifndef UNODIALOG_HXX +#include "unodialog.hxx" +#endif +#ifndef _CONFIGURATION_ACCESS_HXX_ +#include "configurationaccess.hxx" +#endif +#ifndef _PPPOPTIMIZER_TOKEN_HXX +#include "pppoptimizertoken.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XITEMLISTENER_HPP_ +#include <com/sun/star/awt/XItemListener.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif +#ifndef _COM_SUN_STAR_TEXT_XTEXTRANGE_HPP_ +#include <com/sun/star/text/XTextRange.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XSHAPES_HPP_ +#include <com/sun/star/drawing/XShapes.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_ +#include <com/sun/star/frame/XController.hpp> +#endif +#ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_ +#include <com/sun/star/view/XSelectionSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XITEMEVENTBROADCASTER_HPP_ +#include <com/sun/star/awt/XItemEventBroadcaster.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_ +#include <com/sun/star/frame/XStorable.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_ +#include <com/sun/star/frame/XDispatch.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_PUSHBUTTONTYPE_HPP_ +#include <com/sun/star/awt/PushButtonType.hpp> +#endif + +// --------------------- +// - InformationDialog - +// --------------------- +class InformationDialog : public UnoDialog, public ConfigurationAccess +{ +public : + + InformationDialog( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxMSF, + com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rxFrame, + sal_Bool& bOpenNewDocument, sal_Int64 nSourceSize, sal_Int64 nDestSize ); + ~InformationDialog(); + + sal_Bool execute(); + +private : + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >mxMSF; + com::sun::star::uno::Reference< com::sun::star::frame::XFrame > mxFrame; + + com::sun::star::uno::Reference< com::sun::star::awt::XActionListener > mxActionListener; + + void InitDialog(); + + sal_Int64 mnSourceSize; + sal_Int64 mnDestSize; + sal_Bool& mrbOpenNewDocument; + +public : + + com::sun::star::uno::Reference< com::sun::star::frame::XFrame>& GetFrame() { return mxFrame; }; + const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& GetComponentContext() { return mxMSF; }; +}; + +class OKActionListener : public ::cppu::WeakImplHelper1< com::sun::star::awt::XActionListener > +{ +public: + OKActionListener( InformationDialog& rInformationDialog ) : mrInformationDialog( rInformationDialog ){}; + + virtual void SAL_CALL actionPerformed( const ::com::sun::star::awt::ActionEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); +private: + + InformationDialog& mrInformationDialog; +}; + +#endif INFORMATIONDIALOG_HXX diff --git a/sdext/source/minimizer/makefile.mk b/sdext/source/minimizer/makefile.mk new file mode 100644 index 000000000000..42568a533b1b --- /dev/null +++ b/sdext/source/minimizer/makefile.mk @@ -0,0 +1,141 @@ +#************************************************************************* +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: sj $ $Date: 2007-05-11 13:56:50 $ +# +# The Contents of this file are made available subject to +# the terms of GNU Lesser General Public License Version 2.1. +# +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2005 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJNAME=customres +TARGET=SunPresentationMinimizer +GEN_HID=FALSE + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk + +DLLPRE= +common_build_zip= + +# --- Files ------------------------------------- + +SLOFILES= $(SLO)$/unodialog.obj \ + $(SLO)$/optimizerdialog.obj \ + $(SLO)$/optimizerdialogcontrols.obj \ + $(SLO)$/configurationaccess.obj \ + $(SLO)$/impoptimizer.obj \ + $(SLO)$/pppoptimizer.obj \ + $(SLO)$/pppoptimizeruno.obj \ + $(SLO)$/pppoptimizertoken.obj \ + $(SLO)$/pppoptimizerdialog.obj \ + $(SLO)$/fileopendialog.obj \ + $(SLO)$/optimizationstats.obj \ + $(SLO)$/aboutdialog.obj \ + $(SLO)$/graphiccollector.obj \ + $(SLO)$/pagecollector.obj \ + $(SLO)$/informationdialog.obj + +# --- Library ----------------------------------- + +SHL1TARGET= $(TARGET).uno + +SHL1STDLIBS= $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(SALLIB) +SHL1DEPN= +SHL1IMPLIB= i$(SHL1TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def +SHL1VERSIONMAP= exports.map +DEF1NAME= $(SHL1TARGET) + +COMPONENT_FILES= \ + $(MISC)$/SunPresentationMinimizer$/registration$/license_en-US.txt \ + $(MISC)$/SunPresentationMinimizer$/registration$/license_de-DE.txt \ + $(MISC)$/SunPresentationMinimizer$/configuration$/SunPresentationMinimizer.xcs \ + $(MISC)$/SunPresentationMinimizer$/configuration$/SunPresentationMinimizer.xcu \ + $(MISC)$/SunPresentationMinimizer$/configuration$/Addons.xcu \ + $(MISC)$/SunPresentationMinimizer$/configuration$/ImpressWindowState.xcu \ + $(MISC)$/SunPresentationMinimizer$/configuration$/ProtocolHandler.xcu \ + $(MISC)$/SunPresentationMinimizer$/description.xml + +COMPONENT_BITMAPS= \ + $(MISC)$/SunPresentationMinimizer$/bitmaps$/aboutlogo.png \ + $(MISC)$/SunPresentationMinimizer$/bitmaps$/opt_16.png \ + $(MISC)$/SunPresentationMinimizer$/bitmaps$/opt_26.png \ + $(MISC)$/SunPresentationMinimizer$/bitmaps$/opt_16_h.png \ + $(MISC)$/SunPresentationMinimizer$/bitmaps$/opt_26_h.png + +COMPONENT_HELP= \ + $(MISC)$/SunPresentationMinimizer$/help$/help_de.odt \ + $(MISC)$/SunPresentationMinimizer$/help$/help_en-us.odt + +COMPONENT_MANIFEST= \ + $(MISC)$/SunPresentationMinimizer$/META-INF$/manifest.xml + +COMPONENT_LIBRARY= \ + $(MISC)$/SunPresentationMinimizer$/SunPresentationMinimizer.uno$(DLLPOST) + +ZIP1DEPN= $(COMPONENT_MANIFEST) $(COMPONENT_FILES) $(COMPONENT_BITMAPS) $(COMPONENT_HELP) $(COMPONENT_LIBRARY) +ZIP1TARGET= sun-presentation-minimizer +ZIP1DIR= $(MISC)$/SunPresentationMinimizer +ZIP1EXT= .oxt +ZIP1FLAGS=-r +ZIP1LIST= * + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + +$(COMPONENT_MANIFEST) : $$(@:f) + @-$(MKDIRHIER) $(@:d) + +$(TYPE) $< | $(SED) "s/SHARED_EXTENSION/$(DLLPOST)/" > $@ + +$(COMPONENT_FILES) : $$(@:f) + @-$(MKDIRHIER) $(@:d) + +$(COPY) $< $@ + +$(COMPONENT_BITMAPS) : bitmaps$/$$(@:f) + @-$(MKDIRHIER) $(@:d) + +$(COPY) $< $@ + +$(COMPONENT_HELP) : help$/$$(@:f) + @-$(MKDIRHIER) $(@:d) + +$(COPY) $< $@ + +$(COMPONENT_LIBRARY) : $(DLLDEST)$/$$(@:f) + @-$(MKDIRHIER) $(@:d) + +$(COPY) $< $@ + +# remove this once ZIPnDEPN exists +$(ZIP1TARGETN) : $(COMPONENT_MANIFEST) $(COMPONENT_FILES) $(COMPONENT_BITMAPS) $(COMPONENT_HELP) $(COMPONENT_LIBRARY) diff --git a/sdext/source/minimizer/manifest.xml b/sdext/source/minimizer/manifest.xml new file mode 100644 index 000000000000..52fd36356cf3 --- /dev/null +++ b/sdext/source/minimizer/manifest.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd"> +<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest"> + <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=native" + manifest:full-path="SunPresentationMinimizer.unoSHARED_EXTENSION"/> + <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-schema" + manifest:full-path="configuration/SunPresentationMinimizer.xcs"/> + <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data" + manifest:full-path="configuration/SunPresentationMinimizer.xcu"/> + <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data" + manifest:full-path="configuration/Addons.xcu"/> + <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data" + manifest:full-path="configuration/ImpressWindowState.xcu"/> + <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data" + manifest:full-path="configuration/ProtocolHandler.xcu"/> +</manifest:manifest> diff --git a/sdext/source/minimizer/optimizationstats.cxx b/sdext/source/minimizer/optimizationstats.cxx new file mode 100644 index 000000000000..6c47e2fef22b --- /dev/null +++ b/sdext/source/minimizer/optimizationstats.cxx @@ -0,0 +1,118 @@ + /************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: optimizationstats.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:57:05 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef OPTIMIZATIONSTATS_HXX +#include "optimizationstats.hxx" +#endif + +#ifndef _COM_SUN_STAR_AWT_SIZE_HPP_ +#include <com/sun/star/awt/Size.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XSHAPES_HPP_ +#include <com/sun/star/drawing/XShapes.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESSUPPLIER_HPP_ +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XMASTERPAGESSUPPLIER_HPP_ +#include <com/sun/star/drawing/XMasterPagesSupplier.hpp> +#endif + + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::beans; + +// ----------------------------------------------------------------------------- + +OptimizationStats::OptimizationStats() +{ +} + +// ----------------------------------------------------------------------------- + +void OptimizationStats::SetStatusValue( const PPPOptimizerTokenEnum eStat, const uno::Any& rStatValue ) +{ + maStats[ eStat ] = rStatValue; +} + +// ----------------------------------------------------------------------------- + +const uno::Any* OptimizationStats::GetStatusValue( const PPPOptimizerTokenEnum eStat ) const +{ + std::map< PPPOptimizerTokenEnum, uno::Any, Compare >::const_iterator aIter( maStats.find( eStat ) ); + return aIter != maStats.end() ? &((*aIter).second) : NULL; +} + +// ----------------------------------------------------------------------------- + +com::sun::star::beans::PropertyValues OptimizationStats::GetStatusSequence() +{ + int i = 0; + uno::Sequence< PropertyValue > aStatsSequence( maStats.size() ); + std::map< PPPOptimizerTokenEnum, uno::Any, Compare >::iterator aIter( maStats.begin() ); + while( aIter != maStats.end() ) + { + aStatsSequence[ i ].Name = TKGet( (*aIter).first ); + aStatsSequence[ i++ ].Value <<= (*aIter++).second; + } + return aStatsSequence; +} + +// ----------------------------------------------------------------------------- + +void OptimizationStats::InitializeStatusValues( const uno::Sequence< PropertyValue >& rOptimizationStats ) +{ + for( int i = 0; i < rOptimizationStats.getLength(); i++ ) + rOptimizationStats[ i ].Value >>= maStats[ TKGet( rOptimizationStats[ i ].Name ) ]; +} + +// ----------------------------------------------------------------------------- + +void OptimizationStats::InitializeStatusValuesFromDocument( Reference< XModel > rxModel ) +{ + try + { + Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW ); + Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); + SetStatusValue( TK_Pages, Any( awt::Size( 0, xDrawPages->getCount() ) ) ); + } + catch ( Exception& ) + { + } +} diff --git a/sdext/source/minimizer/optimizationstats.hxx b/sdext/source/minimizer/optimizationstats.hxx new file mode 100644 index 000000000000..986891c29461 --- /dev/null +++ b/sdext/source/minimizer/optimizationstats.hxx @@ -0,0 +1,79 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: optimizationstats.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:57:14 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef OPTIMIZATIONSTATS_HXX +#define OPTIMIZATIONSTATS_HXX + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUES_HPP_ +#include <com/sun/star/beans/PropertyValues.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ +#include <com/sun/star/frame/XModel.hpp> +#endif +#ifndef _PPPOPTIMIZER_TOKEN_HXX +#include "pppoptimizertoken.hxx" +#endif +#include <map> + +class OptimizationStats +{ + struct Compare + { + bool operator()( const PPPOptimizerTokenEnum s1, const PPPOptimizerTokenEnum s2 ) const + { + return s1 < s2; + } + }; + std::map < PPPOptimizerTokenEnum, com::sun::star::uno::Any, Compare > maStats; + + public : + + OptimizationStats(); + ~OptimizationStats(){}; + + void SetStatusValue( const PPPOptimizerTokenEnum eStat, const com::sun::star::uno::Any& rStatValue ); + const com::sun::star::uno::Any* GetStatusValue( const PPPOptimizerTokenEnum eStat ) const; + + void InitializeStatusValuesFromDocument( com::sun::star::uno::Reference< com::sun::star::frame::XModel > rxModel ); + void InitializeStatusValues( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rOptimizationStats ); + + com::sun::star::beans::PropertyValues GetStatusSequence(); +}; + + +#endif // OPTIMIZATIONSTATS_HXX diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx new file mode 100644 index 000000000000..facf83c6f945 --- /dev/null +++ b/sdext/source/minimizer/optimizerdialog.cxx @@ -0,0 +1,864 @@ + /************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: optimizerdialog.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:57:22 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef OPTIMIZERDIALOG_HXX +#include "optimizerdialog.hxx" +#endif +#ifndef _FILEOPEN_DIALOG_HXX_ +#include "fileopendialog.hxx" +#endif +#ifndef _COM_SUN_STAR_UI_DIALOGS_EXECUTABLEDIALOGRESULTS_HPP_ +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_XSIMPLEFILEACCESS_HPP_ +#include <com/sun/star/ucb/XSimpleFileAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ +#include <com/sun/star/io/XInputStream.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCloseBroadcaster_HPP_ +#include <com/sun/star/util/XCloseBroadcaster.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_ +#include <com/sun/star/frame/XComponentLoader.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XLAYOUTMANAGER_HPP_ +#include <com/sun/star/frame/XLayoutManager.hpp> +#endif +#ifndef _OSL_TIME_H_ +#include <osl/time.h> +#endif + +// ------------------- +// - OPTIMIZERDIALOG - +// ------------------- + +using namespace ::rtl; +using namespace ::com::sun::star::io; +using namespace ::com::sun::star::ui; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::ucb; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::script; +using namespace ::com::sun::star::container; + + +// ----------------------------------------------------------------------------- + +void OptimizerDialog::InitDialog() +{ + // setting the dialog properties + OUString pNames[] = { + TKGet( TK_Closeable ), + TKGet( TK_Height ), + TKGet( TK_Moveable ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_Title ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( sal_True ), + Any( sal_Int32( DIALOG_HEIGHT ) ), + Any( sal_True ), + Any( sal_Int32( 200 ) ), + Any( sal_Int32( 52 ) ), + Any( getString( STR_SUN_OPTIMIZATION_WIZARD ) ), + Any( sal_Int32( DIALOG_WIDTH ) ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + mxDialogModelMultiPropertySet->setPropertyValues( aNames, aValues ); +} + +// ----------------------------------------------------------------------------- + +void OptimizerDialog::InitRoadmap() +{ + try + { + OUString pNames[] = { + TKGet( TK_Height ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_Step ), + TKGet( TK_TabIndex ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( sal_Int32( DIALOG_HEIGHT - 26 ) ), + Any( sal_Int32( 0 ) ), + Any( sal_Int32( 0 ) ), + Any( sal_Int32( 0 ) ), + Any( mnTabIndex++ ), + Any( sal_Int32( 85 ) ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + mxRoadmapControlModel = insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRoadmapModel" ) ), + TKGet( TK_rdmNavi ), aNames, aValues ); + + Reference< XPropertySet > xPropertySet( mxRoadmapControlModel, UNO_QUERY_THROW ); + xPropertySet->setPropertyValue( TKGet( TK_Name ), Any( TKGet( TK_rdmNavi ) ) ); + mxRoadmapControl = mxDialogControlContainer->getControl( TKGet( TK_rdmNavi ) ); + InsertRoadmapItem( 0, sal_True, getString( STR_INTRODUCTION ), ITEM_ID_INTRODUCTION ); + InsertRoadmapItem( 1, sal_True, getString( STR_SLIDES ), ITEM_ID_SLIDES ); + InsertRoadmapItem( 2, sal_True, getString( STR_IMAGE_OPTIMIZATION ), ITEM_ID_GRAPHIC_OPTIMIZATION ); + InsertRoadmapItem( 3, sal_True, getString( STR_OLE_OBJECTS ), ITEM_ID_OLE_OPTIMIZATION ); + InsertRoadmapItem( 4, sal_True, getString( STR_SUMMARY ), ITEM_ID_SUMMARY ); + + rtl::OUString sBitmapPath( getPath( TK_BitmapPath ) ); + rtl::OUString sBitmap( isHighContrast() ? rtl::OUString::createFromAscii( "/minimizepresi_80_h.png" ) + : rtl::OUString::createFromAscii( "/minimizepresi_80.png" ) ); + rtl::OUString sURL( sBitmapPath += sBitmap ); + + xPropertySet->setPropertyValue( TKGet( TK_ImageURL ), Any( sURL ) ); + xPropertySet->setPropertyValue( TKGet( TK_Activated ), Any( (sal_Bool)sal_True ) ); + xPropertySet->setPropertyValue( TKGet( TK_Complete ), Any( (sal_Bool)sal_True ) ); + xPropertySet->setPropertyValue( TKGet( TK_CurrentItemID ), Any( (sal_Int16)ITEM_ID_INTRODUCTION ) ); + xPropertySet->setPropertyValue( TKGet( TK_Text ), Any( getString( STR_STEPS ) ) ); + } + catch( Exception& ) + { + } +} + +// ----------------------------------------------------------------------------- + +void OptimizerDialog::InsertRoadmapItem( const sal_Int32 nIndex, const sal_Bool bEnabled, const rtl::OUString& rLabel, const sal_Int32 nItemID ) +{ + try + { + Reference< XSingleServiceFactory > xSFRoadmap( mxRoadmapControlModel, UNO_QUERY_THROW ); + Reference< XIndexContainer > aIndexContainerRoadmap( mxRoadmapControlModel, UNO_QUERY_THROW ); + Reference< XInterface > xRoadmapItem( xSFRoadmap->createInstance(), UNO_QUERY_THROW ); + Reference< XPropertySet > xPropertySet( xRoadmapItem, UNO_QUERY_THROW ); + xPropertySet->setPropertyValue( TKGet( TK_Label ), Any( rLabel ) ); + xPropertySet->setPropertyValue( TKGet( TK_Enabled ), Any( bEnabled ) ); + xPropertySet->setPropertyValue( TKGet( TK_ID ), Any( nItemID ) ); + aIndexContainerRoadmap->insertByIndex( nIndex, Any( xRoadmapItem ) ); + } + catch( Exception& ) + { + + } +} + +// ----------------------------------------------------------------------------- + +void OptimizerDialog::UpdateConfiguration() +{ + sal_Int16 nInt16; + OUString aString; + Any aAny; + + Sequence< sal_Int16 > aSelectedItems; + Sequence< OUString > aStringItemList; + + // page0 + aAny = getControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_SelectedItems ) ); + if ( aAny >>= aSelectedItems ) + { + if ( aSelectedItems.getLength() ) + { + sal_Int16 nSelectedItem = aSelectedItems[ 0 ]; + aAny = getControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_StringItemList ) ); + if ( aAny >>= aStringItemList ) + { + if ( aStringItemList.getLength() > nSelectedItem ) + SetConfigProperty( TK_Name, Any( aStringItemList[ nSelectedItem ] ) ); + } + } + } + + // page1 +// aAny = getControlProperty( TKGet( TK_CheckBox0Pg1 ), TKGet( TK_State ) ); +// if ( aAny >>= nInt16 ) +// SetConfigProperty( TK_JPEGCompression, Any( nInt16 != 0 ) ); + +// aAny = getControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ) ); +// if ( aAny >>= fDouble ) +// SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) ); + +// aAny = getControlProperty( TKGet( TK_CheckBox1Pg1 ), TKGet( TK_State ) ); +// if ( aAny >>= nInt16 ) +// SetConfigProperty( TK_RemoveCropArea, Any( nInt16 != 0 ) ); + +// aAny = getControlProperty( TKGet( TK_ComboBox0Pg1 ), TKGet( TK_Text ) ); +// if ( aAny >>= aString ) +// { +// sal_Int32 nI0, nI1, nI2, nI3, nI4; +// nI0 = nI1 = nI2 = nI3 = nI4 = 0; +// +// if ( getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 ) == aString ) +// aString = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI4 ); +// else if ( getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 ) == aString ) +// aString = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI4 ); +// else if ( getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 ) == aString ) +// aString = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI4 ); +// else if ( getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 ) == aString ) +// aString = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI4 ); +// +// SetConfigProperty( TK_ImageResolution, Any( aString.toInt32() ) ); +// } + + // page2 +// aAny = getControlProperty( TKGet( TK_CheckBox0Pg2 ), TKGet( TK_State ) ); +// if ( aAny >>= nInt16 ) +// SetConfigProperty( TK_OLEOptimization, Any( nInt16 != 0 ) ); + +// aAny = getControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_State ) ); +// if ( aAny >>= nInt16 ) +// SetConfigProperty( TK_OLEOptimizationType, Any( nInt16 ) ); + + // page3 +// aAny = getControlProperty( TKGet( TK_CheckBox0Pg3 ), TKGet( TK_State ) ); +// if ( aAny >>= nInt16 ) +// SetConfigProperty( TK_DeleteUnusedMasterPages, Any( nInt16 != 0 ) ); + +// aAny = getControlProperty( TKGet( TK_CheckBox1Pg3 ), TKGet( TK_State ) ); +// if ( aAny >>= nInt16 ) +// SetConfigProperty( TK_DeleteNotesPages, Any( nInt16 != 0 ) ); + +// aAny = getControlProperty( TKGet( TK_CheckBox2Pg3 ), TKGet( TK_State ) ); +// if ( aAny >>= nInt16 ) +// SetConfigProperty( TK_DeleteHiddenSlides, Any( nInt16 != 0 ) ); + + aAny = getControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ) ); + if ( aAny >>= nInt16 ) + { + if ( nInt16 ) + { + aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_SelectedItems ) ); + if ( aAny >>= aSelectedItems ) + { + if ( aSelectedItems.getLength() ) + { + sal_Int16 nSelectedItem = aSelectedItems[ 0 ]; + aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_StringItemList ) ); + if ( aAny >>= aStringItemList ) + { + if ( aStringItemList.getLength() > nSelectedItem ) + SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) ); + } + } + } + } + } + + // page4 +// aAny = getControlProperty( TKGet( TK_CheckBox0Pg4 ), TKGet( TK_State ) ); +// if ( aAny >>= nInt16 ) +// SetConfigProperty( TK_OpenNewDocument, Any( nInt16 != 0 ) ); +} + +// ----------------------------------------------------------------------------- + +OptimizerDialog::OptimizerDialog( const Reference< XComponentContext > &rxMSF, Reference< XFrame >& rxFrame, Reference< XDispatch > rxStatusDispatcher ) : + UnoDialog( rxMSF, rxFrame ), + ConfigurationAccess( rxMSF, NULL ), + mnCurrentStep( 0 ), + mnTabIndex( 0 ), + mxMSF( rxMSF ), + mxFrame( rxFrame ), + mxItemListener( new ItemListener( *this ) ), + mxActionListener( new ActionListener( *this ) ), + mxActionListenerListBox0Pg0( new ActionListenerListBox0Pg0( *this ) ), + mxTextListenerFormattedField0Pg1( new TextListenerFormattedField0Pg1( *this ) ), + mxTextListenerComboBox0Pg1( new TextListenerComboBox0Pg1( *this ) ), + mxStatusDispatcher( rxStatusDispatcher ) +{ + Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY_THROW ); + mbIsReadonly = xStorable->isReadonly(); + + InitDialog(); + InitRoadmap(); + InitNavigationBar(); + InitPage0(); + InitPage1(); + InitPage2(); + InitPage3(); + InitPage4(); + ActivatePage( 0 ); + + OptimizationStats aStats; + aStats.InitializeStatusValuesFromDocument( mxController->getModel() ); + Sequence< PropertyValue > aStatusSequence( aStats.GetStatusSequence() ); + UpdateStatus( aStatusSequence ); +} + +// ----------------------------------------------------------------------------- + +OptimizerDialog::~OptimizerDialog() +{ + // not saving configuration if the dialog has been finished via cancel or close window + if ( mbStatus ) + SaveConfiguration(); +} + +// ----------------------------------------------------------------------------- + +sal_Bool OptimizerDialog::execute() +{ + Reference< XItemEventBroadcaster > maRoadmapBroadcaster( mxRoadmapControl, UNO_QUERY_THROW ); + maRoadmapBroadcaster->addItemListener( mxItemListener ); + UnoDialog::execute(); + UpdateConfiguration(); // taking actual control settings for the configuration + maRoadmapBroadcaster->removeItemListener( mxItemListener ); + return mbStatus; +} + +// ----------------------------------------------------------------------------- + +void OptimizerDialog::SwitchPage( sal_Int16 nNewStep ) +{ + if ( ( nNewStep != mnCurrentStep ) && ( nNewStep <= MAX_STEP ) || ( nNewStep >= 0 ) ) + { + sal_Int16 nOldStep = mnCurrentStep; + if ( nNewStep == 0 ) + disableControl( TKGet( TK_btnNavBack ) ); + else if ( nOldStep == 0 ) + enableControl( TKGet( TK_btnNavBack ) ); + + if ( nNewStep == MAX_STEP ) + disableControl( TKGet( TK_btnNavNext ) ); + else if ( nOldStep == MAX_STEP ) + enableControl( TKGet( TK_btnNavNext ) ); + + setControlProperty( TKGet( TK_rdmNavi ), TKGet( TK_CurrentItemID ), Any( nNewStep ) ); + + DeactivatePage( nOldStep ); + UpdateControlStates( nNewStep ); + + ActivatePage( nNewStep ); + mnCurrentStep = nNewStep; + } +} + +void OptimizerDialog::UpdateControlStates( sal_Int16 nPage ) +{ + switch( nPage ) + { + case 0 : UpdateControlStatesPage0(); break; + case 1 : UpdateControlStatesPage1(); break; + case 2 : UpdateControlStatesPage2(); break; + case 3 : UpdateControlStatesPage3(); break; + case 4 : UpdateControlStatesPage4(); break; + default: + { + UpdateControlStatesPage0(); + UpdateControlStatesPage1(); + UpdateControlStatesPage2(); + UpdateControlStatesPage3(); + UpdateControlStatesPage4(); + } + } +} + +// ----------------------------------------------------------------------------- + +rtl::OUString OptimizerDialog::GetSelectedString( const PPPOptimizerTokenEnum eToken ) +{ + OUString aSelectedItem; + Sequence< sal_Int16 > sSelectedItems; + Sequence< OUString > sItemList; + + if ( ( getControlProperty( TKGet( eToken ), TKGet( TK_SelectedItems ) ) >>= sSelectedItems ) && + ( getControlProperty( TKGet( eToken ), TKGet( TK_StringItemList ) ) >>= sItemList ) ) + { + if ( sSelectedItems.getLength() == 1 ) + { + sal_Int16 nSelectedItem = sSelectedItems[ 0 ]; + if ( nSelectedItem < sItemList.getLength() ) + aSelectedItem = sItemList[ nSelectedItem ]; + } + } + return aSelectedItem; +} + +// ----------------------------------------------------------------------------- + +void OptimizerDialog::UpdateStatus( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rStatus ) +{ + if ( mxReschedule.is() ) + { + maStats.InitializeStatusValues( rStatus ); + const Any* pVal( maStats.GetStatusValue( TK_Status ) ); + if ( pVal ) + { + rtl::OUString sStatus; + if ( *pVal >>= sStatus ) + setControlProperty( TKGet( TK_FixedText1Pg4 ), TKGet( TK_Label ), Any( getString( TKGet( sStatus ) ) ) ); + } + pVal = maStats.GetStatusValue( TK_Progress ); + if ( pVal ) + { + sal_Int32 nProgress = 0; + if ( *pVal >>= nProgress ) + setControlProperty( TKGet( TK_Progress ), TKGet( TK_ProgressValue ), Any( nProgress ) ); + } + mxReschedule->reschedule(); + } +} + +// ----------------------------------------------------------------------------- + +void ItemListener::itemStateChanged( const ItemEvent& Event ) + throw ( RuntimeException ) +{ + try + { + sal_Int16 nState; + OUString aControlName; + Reference< XControl > xControl; + Any aSource( Event.Source ); + if ( aSource >>= xControl ) + { + Reference< XPropertySet > xPropertySet( xControl->getModel(), UNO_QUERY_THROW ); + xPropertySet->getPropertyValue( TKGet( TK_Name ) ) >>= aControlName; + PPPOptimizerTokenEnum eControl( TKGet( aControlName ) ); + switch( eControl ) + { + case TK_rdmNavi : + { + mrOptimizerDialog.SwitchPage( static_cast< sal_Int16 >( Event.ItemId ) ); + } + break; + case TK_CheckBox1Pg1 : + { + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) + mrOptimizerDialog.SetConfigProperty( TK_RemoveCropArea, Any( nState != 0 ) ); + } + break; + case TK_CheckBox2Pg1 : + { + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) + mrOptimizerDialog.SetConfigProperty( TK_EmbedLinkedGraphics, Any( nState != 0 ) ); + } + break; + case TK_CheckBox0Pg2 : + { + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) + { + mrOptimizerDialog.SetConfigProperty( TK_OLEOptimization, Any( nState != 0 ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_Enabled ), Any( nState != 0 ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_Enabled ), Any( nState != 0 ) ); + } + } + break; + case TK_RadioButton0Pg1 : + { + sal_Int16 nInt16; + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nInt16 ) + { + nInt16 ^= 1; + mrOptimizerDialog.SetConfigProperty( TK_JPEGCompression, Any( nInt16 != 0 ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_FixedText1Pg1 ), TKGet( TK_Enabled ), Any( nInt16 != 0 ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_Enabled ), Any( nInt16 != 0 ) ); + } + } + break; + case TK_RadioButton1Pg1 : + { + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) + { + mrOptimizerDialog.SetConfigProperty( TK_JPEGCompression, Any( nState != 0 ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_FixedText1Pg1 ), TKGet( TK_Enabled ), Any( nState != 0 ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_Enabled ), Any( nState != 0 ) ); + } + } + break; + case TK_RadioButton0Pg2 : + { + sal_Int16 nInt16; + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nInt16 ) + { + nInt16 ^= 1; + mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nInt16 ) ); + } + } + break; + case TK_RadioButton1Pg2 : + { + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) + mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nState ) ); + } + break; + case TK_CheckBox0Pg3 : + { + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) + mrOptimizerDialog.SetConfigProperty( TK_DeleteUnusedMasterPages, Any( nState != 0 ) ); + } + break; + case TK_CheckBox1Pg3 : + { + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) + mrOptimizerDialog.SetConfigProperty( TK_DeleteNotesPages, Any( nState != 0 ) ); + } + break; + case TK_CheckBox2Pg3 : + { + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) + mrOptimizerDialog.SetConfigProperty( TK_DeleteHiddenSlides, Any( nState != 0 ) ); + } + break; + case TK_CheckBox3Pg3 : + { + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) + mrOptimizerDialog.setControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_Enabled ), Any( nState != 0 ) ); + } + break; + case TK_CheckBox0Pg4 : + { + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) + mrOptimizerDialog.SetConfigProperty( TK_OpenNewDocument, Any( nState != 0 ) ); + } + break; + case TK_CheckBox1Pg4 : + { + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) + mrOptimizerDialog.setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( nState != 0 ) ); + } + break; + case TK_RadioButton0Pg4 : + case TK_RadioButton1Pg4 : + { + if ( xPropertySet->getPropertyValue( TKGet( TK_State ) ) >>= nState ) + { + mrOptimizerDialog.setControlProperty( TKGet( TK_CheckBox0Pg4 ), TKGet( TK_Enabled ), Any( eControl == TK_RadioButton1Pg4 ) ); + mrOptimizerDialog.SetConfigProperty( TK_SaveAs, Any( eControl == TK_RadioButton1Pg4 ? nState != 0 : nState == 0 ) ); + } + } + break; + default: + break; + } + } + } + catch ( Exception& ) + { + + } +} +void ItemListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) + throw ( com::sun::star::uno::RuntimeException ) +{ +} + +// ----------------------------------------------------------------------------- + +void ActionListener::actionPerformed( const ActionEvent& rEvent ) + throw ( com::sun::star::uno::RuntimeException ) +{ + switch( TKGet( rEvent.ActionCommand ) ) + { + case TK_btnNavHelp : + { + try + { + static Reference< XFrame > xHelpFrame; + if ( !xHelpFrame.is() ) + { + rtl::OUString sHelpFile( mrOptimizerDialog.getPath( TK_HelpFile ) ); + Reference< XDesktop > desktop( mrOptimizerDialog.GetComponentContext()->getServiceManager()->createInstanceWithContext( + OUString::createFromAscii( "com.sun.star.frame.Desktop" ), mrOptimizerDialog.GetComponentContext() ), UNO_QUERY_THROW ); + Reference< XSimpleFileAccess > xSimpleFileAccess( mrOptimizerDialog.GetComponentContext()->getServiceManager()->createInstanceWithContext( + OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), mrOptimizerDialog.GetComponentContext() ), UNO_QUERY_THROW ); + Reference< XInputStream > xInputStream( xSimpleFileAccess->openFileRead( sHelpFile ) ); + Reference< XDesktop > xDesktop( mrOptimizerDialog.GetComponentContext()->getServiceManager()->createInstanceWithContext( + OUString::createFromAscii( "com.sun.star.frame.Desktop" ), mrOptimizerDialog.GetComponentContext() ), UNO_QUERY_THROW ); + Reference< XFrame > xDesktopFrame( xDesktop, UNO_QUERY_THROW ); + xHelpFrame = Reference< XFrame >( xDesktopFrame->findFrame( TKGet( TK__blank ), 0 ) ); + Reference< XCloseBroadcaster > xCloseBroadcaster( xHelpFrame, UNO_QUERY_THROW ); + xCloseBroadcaster->addCloseListener( new HelpCloseListener( xHelpFrame ) ); + Reference< XComponentLoader > xLoader( xHelpFrame, UNO_QUERY_THROW ); + + Sequence< PropertyValue > aLoadProps( 2 ); + aLoadProps[ 0 ].Name = TKGet( TK_ReadOnly ); + aLoadProps[ 0 ].Value <<= (sal_Bool)( sal_True ); + aLoadProps[ 1 ].Name = TKGet( TK_InputStream ); + aLoadProps[ 1 ].Value <<= xInputStream; + + Reference< XComponent >( xLoader->loadComponentFromURL( OUString::createFromAscii( "private:stream" ), + TKGet( TK__self ), 0, aLoadProps ) ); + + Reference< XPropertySet > xPropSet( xHelpFrame, UNO_QUERY_THROW ); + Reference< XLayoutManager > xLayoutManager; + if ( xPropSet->getPropertyValue( OUString::createFromAscii( "LayoutManager" ) ) >>= xLayoutManager ) + { + xLayoutManager->setVisible( sal_False ); + xLayoutManager->hideElement( OUString::createFromAscii( "private:resource/menubar/menubar" ) ); + xLayoutManager->destroyElement( OUString::createFromAscii( "private:resource/statusbar/statusbar" ) ); + } + } + } + catch( Exception& ) + { + + } + } + break; + case TK_btnNavBack : mrOptimizerDialog.SwitchPage( mrOptimizerDialog.mnCurrentStep - 1 ); break; + case TK_btnNavNext : mrOptimizerDialog.SwitchPage( mrOptimizerDialog.mnCurrentStep + 1 ); break; + case TK_btnNavFinish : + { + mrOptimizerDialog.UpdateConfiguration(); + + mrOptimizerDialog.SwitchPage( ITEM_ID_SUMMARY ); + mrOptimizerDialog.DisablePage( ITEM_ID_SUMMARY ); + mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavHelp ), TKGet( TK_Enabled ), Any( sal_False ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavBack ), TKGet( TK_Enabled ), Any( sal_False ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavNext ), TKGet( TK_Enabled ), Any( sal_False ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavFinish ), TKGet( TK_Enabled ), Any( sal_False ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavCancel ), TKGet( TK_Enabled ), Any( sal_False ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_FixedText0Pg4 ), TKGet( TK_Enabled ), Any( sal_True ) ); + + // check if we have to open the FileDialog + sal_Bool bSuccessfullyExecuted = sal_True; + sal_Int16 nInt16 = 0; + mrOptimizerDialog.getControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ) ) >>= nInt16; + if ( nInt16 ) + { + rtl::OUString aSaveAsURL; + FileOpenDialog aFileOpenDialog( ((UnoDialog&)mrOptimizerDialog).mxMSF ); + +/* + // generating default file name + Reference< XStorable > xStorable( mrOptimizerDialog.mxController->getModel(), UNO_QUERY ); + if ( xStorable.is() && xStorable.hasLocation() ) + { + rtl::OUString aLocation( xStorable->getLocation() ); + sal_Int32 nIndex aLocation.lastIndexOf( '/', 0 ); + if ( nIndex >= 0 ) + { + if ( nIndex < aLocation.getLenght() - 1 ) + { + + + } + } + +// aFileOpenDialog.setDefaultName( aLocation ); + } +*/ + sal_Bool bDialogExecuted = aFileOpenDialog.execute() == dialogs::ExecutableDialogResults::OK; + if ( bDialogExecuted ) + { + aSaveAsURL = aFileOpenDialog.getURL(); + mrOptimizerDialog.SetConfigProperty( TK_SaveAsURL, Any( aSaveAsURL ) ); + mrOptimizerDialog.SetConfigProperty( TK_FilterName, Any( aFileOpenDialog.getFilterName() ) ); + } + if ( !aSaveAsURL.getLength() ) + { + // something goes wrong... + bSuccessfullyExecuted = sal_False; + } + + // waiting for 500ms + if ( mrOptimizerDialog.mxReschedule.is() ) + { + mrOptimizerDialog.mxReschedule->reschedule(); + for ( sal_uInt32 i = osl_getGlobalTimer(); ( i + 500 ) > ( osl_getGlobalTimer() ); ) + mrOptimizerDialog.mxReschedule->reschedule(); + } + } + if ( bSuccessfullyExecuted ) + { // now check if we have to store a session template + nInt16 = 0; + OUString aSettingsName; + mrOptimizerDialog.getControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_State ) ) >>= nInt16; + mrOptimizerDialog.getControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Text ) ) >>= aSettingsName; + if ( nInt16 && aSettingsName.getLength() ) + { + std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSettingsName ) ); + std::vector< OptimizerSettings >& rSettings( mrOptimizerDialog.GetOptimizerSettings() ); + OptimizerSettings aNewSettings( rSettings[ 0 ] ); + aNewSettings.maName = aSettingsName; + if ( aIter == rSettings.end() ) + rSettings.push_back( aNewSettings ); + else + *aIter = aNewSettings; + } + } + if ( bSuccessfullyExecuted ) + { + Sequence< Any > aArgs( 1 ); + aArgs[ 0 ] <<= mrOptimizerDialog.GetFrame(); + + Reference < XDispatch > xDispatch( mrOptimizerDialog.GetComponentContext()->getServiceManager()->createInstanceWithArgumentsAndContext( + OUString::createFromAscii( "com.sun.star.comp.PPPOptimizer" ), aArgs, mrOptimizerDialog.GetComponentContext() ), UNO_QUERY ); + + URL aURL; + aURL.Protocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.com.sun.star.comp.PPPOptimizer:" ) ); + aURL.Path = OUString( RTL_CONSTASCII_USTRINGPARAM( "optimize" ) ); + + Sequence< PropertyValue > lArguments( 3 ); + lArguments[ 0 ].Name = TKGet( TK_Settings ); + lArguments[ 0 ].Value <<= mrOptimizerDialog.GetConfigurationSequence(); + lArguments[ 1 ].Name = TKGet( TK_StatusDispatcher ); + lArguments[ 1 ].Value <<= mrOptimizerDialog.GetStatusDispatcher(); + lArguments[ 2 ].Name = TKGet( TK_InformationDialog ); + lArguments[ 2 ].Value <<= sal_True; + + if( xDispatch.is() ) + xDispatch->dispatch( aURL, lArguments ); + + mrOptimizerDialog.endExecute( bSuccessfullyExecuted ); + } + else + { + mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavHelp ), TKGet( TK_Enabled ), Any( sal_True ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavBack ), TKGet( TK_Enabled ), Any( sal_True ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavNext ), TKGet( TK_Enabled ), Any( sal_True ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavFinish ), TKGet( TK_Enabled ), Any( sal_True ) ); + mrOptimizerDialog.setControlProperty( TKGet( TK_btnNavCancel ), TKGet( TK_Enabled ), Any( sal_True ) ); + mrOptimizerDialog.EnablePage( ITEM_ID_SUMMARY ); + } + } + break; + case TK_btnNavCancel : mrOptimizerDialog.endExecute( sal_False ); break; + case TK_Button0Pg0 : // delete configuration + { + OUString aSelectedItem( mrOptimizerDialog.GetSelectedString( TK_ListBox0Pg0 ) ); + if ( aSelectedItem.getLength() ) + { + std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSelectedItem ) ); + std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() ); + if ( aIter != rList.end() ) + { + rList.erase( aIter ); + mrOptimizerDialog.UpdateControlStates(); + } + } + } + break; + default: break; + } +} +void ActionListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) + throw ( com::sun::star::uno::RuntimeException ) +{ +} + +// ----------------------------------------------------------------------------- + +void ActionListenerListBox0Pg0::actionPerformed( const ActionEvent& rEvent ) + throw ( com::sun::star::uno::RuntimeException ) +{ + if ( rEvent.ActionCommand.getLength() ) + { + std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( rEvent.ActionCommand ) ); + std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() ); + if ( aIter != rList.end() ) + rList[ 0 ] = *aIter; + } + mrOptimizerDialog.UpdateControlStates(); +} +void ActionListenerListBox0Pg0::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) + throw ( com::sun::star::uno::RuntimeException ) +{ +} + +// ----------------------------------------------------------------------------- + +void TextListenerFormattedField0Pg1::textChanged( const TextEvent& /* rEvent */ ) + throw ( com::sun::star::uno::RuntimeException ) +{ + double fDouble; + Any aAny = mrOptimizerDialog.getControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ) ); + if ( aAny >>= fDouble ) + mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) ); +} +void TextListenerFormattedField0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) + throw ( com::sun::star::uno::RuntimeException ) +{ +} + +// ----------------------------------------------------------------------------- + +void TextListenerComboBox0Pg1::textChanged( const TextEvent& /* rEvent */ ) + throw ( com::sun::star::uno::RuntimeException ) +{ + rtl::OUString aString; + Any aAny = mrOptimizerDialog.getControlProperty( TKGet( TK_ComboBox0Pg1 ), TKGet( TK_Text ) ); + if ( aAny >>= aString ) + { + sal_Int32 nI0, nI1, nI2, nI3, nI4; + nI0 = nI1 = nI2 = nI3 = nI4 = 0; + + if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 ) == aString ) + aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI4 ); + else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 ) == aString ) + aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI4 ); + else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 ) == aString ) + aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI4 ); + else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 ) == aString ) + aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI4 ); + + mrOptimizerDialog.SetConfigProperty( TK_ImageResolution, Any( aString.toInt32() ) ); + } +} +void TextListenerComboBox0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) + throw ( com::sun::star::uno::RuntimeException ) +{ +} +void HelpCloseListener::addCloseListener( const Reference < XCloseListener >& ) throw( RuntimeException ) +{ +} +void HelpCloseListener::removeCloseListener( const Reference < XCloseListener >& ) throw( RuntimeException ) +{ +} +void HelpCloseListener::queryClosing( const EventObject&, sal_Bool /* bDeliverOwnership */ ) + throw ( RuntimeException, CloseVetoException ) +{ +} +void HelpCloseListener::notifyClosing( const EventObject& ) + throw ( RuntimeException ) +{ +} +void HelpCloseListener::disposing( const EventObject& ) throw ( RuntimeException ) +{ + mrXFrame = NULL; +} diff --git a/sdext/source/minimizer/optimizerdialog.hrc b/sdext/source/minimizer/optimizerdialog.hrc new file mode 100644 index 000000000000..cd114cb6de56 --- /dev/null +++ b/sdext/source/minimizer/optimizerdialog.hrc @@ -0,0 +1,44 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: optimizerdialog.hrc,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:57:31 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef _OPTIMIZERDIALOG_HRC +#define _OPTIMIZERDIALOG_HRC + +#define ITEM_ID_INTRODUCTION 0 +#define ITEM_ID_SLIDES 1 +#define ITEM_ID_GRAPHIC_OPTIMIZATION 2 +#define ITEM_ID_OLE_OPTIMIZATION 3 +#define ITEM_ID_SUMMARY 4 + +#endif diff --git a/sdext/source/minimizer/optimizerdialog.hxx b/sdext/source/minimizer/optimizerdialog.hxx new file mode 100644 index 000000000000..063dd14095e5 --- /dev/null +++ b/sdext/source/minimizer/optimizerdialog.hxx @@ -0,0 +1,275 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: optimizerdialog.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:57:39 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef OPTIMIZERDIALOG_HXX +#define OPTIMIZERDIALOG_HXX +#ifndef _OPTIMIZERDIALOG_HRC +#include "optimizerdialog.hrc" +#endif +#include <vector> +#ifndef UNODIALOG_HXX +#include "unodialog.hxx" +#endif +#ifndef _PPPOPTIMIZER_TOKEN_HXX +#include "pppoptimizertoken.hxx" +#endif +#ifndef OPTIMIZATIONSTATS_HXX +#include "optimizationstats.hxx" +#endif +#ifndef _CONFIGURATION_ACCESS_HXX_ +#include "configurationaccess.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XITEMLISTENER_HPP_ +#include <com/sun/star/awt/XItemListener.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif +#ifndef _COM_SUN_STAR_TEXT_XTEXTRANGE_HPP_ +#include <com/sun/star/text/XTextRange.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XSHAPES_HPP_ +#include <com/sun/star/drawing/XShapes.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_ +#include <com/sun/star/frame/XController.hpp> +#endif +#ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_ +#include <com/sun/star/view/XSelectionSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XITEMEVENTBROADCASTER_HPP_ +#include <com/sun/star/awt/XItemEventBroadcaster.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCloseListener_HPP_ +#include <com/sun/star/util/XCloseListener.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_ +#include <com/sun/star/frame/XStorable.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_ +#include <com/sun/star/frame/XDispatch.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_ +#include <com/sun/star/frame/XDesktop.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_PUSHBUTTONTYPE_HPP_ +#include <com/sun/star/awt/PushButtonType.hpp> +#endif + +#define MAX_STEP 4 +#define DIALOG_WIDTH 310 +#define DIALOG_HEIGHT 210 +#define BUTTON_WIDTH 50 +#define BUTTON_HEIGHT 14 +#define BUTTON_POS_Y DIALOG_HEIGHT - BUTTON_HEIGHT - 6 + +#define PAGE_POS_X 91 +#define PAGE_POS_Y 8 +#define PAGE_WIDTH DIALOG_WIDTH - PAGE_POS_X + +// ------------------- +// - OPTIMIZERDIALOG - +// ------------------- +class OptimizerDialog : public UnoDialog, public ConfigurationAccess +{ +public : + + OptimizerDialog( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxMSF, com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rxFrame, + com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > rxStatusDispatcher ); + ~OptimizerDialog(); + + sal_Bool execute(); + + sal_Int16 mnCurrentStep; + sal_Int16 mnTabIndex; + sal_Bool mbIsReadonly; + +private : + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >mxMSF; + com::sun::star::uno::Reference< com::sun::star::frame::XFrame > mxFrame; + + com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxRoadmapControl; + com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxRoadmapControlModel; + + com::sun::star::uno::Reference< com::sun::star::awt::XItemListener > mxItemListener; + com::sun::star::uno::Reference< com::sun::star::awt::XActionListener > mxActionListener; + com::sun::star::uno::Reference< com::sun::star::awt::XActionListener > mxActionListenerListBox0Pg0; + com::sun::star::uno::Reference< com::sun::star::awt::XTextListener > mxTextListenerFormattedField0Pg1; + com::sun::star::uno::Reference< com::sun::star::awt::XTextListener > mxTextListenerComboBox0Pg1; + com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > mxStatusDispatcher; + + std::vector< std::vector< rtl::OUString > > maControlPages; + + void InitDialog(); + void InitRoadmap(); + void InitNavigationBar(); + void InitPage0(); + void InitPage1(); + void InitPage2(); + void InitPage3(); + void InitPage4(); + void UpdateControlStatesPage0(); + void UpdateControlStatesPage1(); + void UpdateControlStatesPage2(); + void UpdateControlStatesPage3(); + void UpdateControlStatesPage4(); + + void ActivatePage( sal_Int16 nStep ); + void DeactivatePage( sal_Int16 nStep ); + void InsertRoadmapItem( const sal_Int32 nIndex, const sal_Bool bEnabled, const rtl::OUString& rLabel, const sal_Int32 nItemID ); + +public : + + OptimizationStats maStats; + + void UpdateStatus( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rStatus ); + + // the ConfigurationAccess is updated to actual control settings + void UpdateConfiguration(); + + void EnablePage( sal_Int16 nStep ); + void DisablePage( sal_Int16 nStep ); + + void SwitchPage( sal_Int16 nNewStep ); + void UpdateControlStates( sal_Int16 nStep = -1 ); + + rtl::OUString GetSelectedString( PPPOptimizerTokenEnum eListBox ); + com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >& GetStatusDispatcher() { return mxStatusDispatcher; }; + com::sun::star::uno::Reference< com::sun::star::frame::XFrame>& GetFrame() { return mxFrame; }; + const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& GetComponentContext() { return mxMSF; }; +}; + +// ----------------------------------------------------------------------------- + +class ItemListener : public ::cppu::WeakImplHelper1< com::sun::star::awt::XItemListener > +{ +public: + ItemListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; + + virtual void SAL_CALL itemStateChanged( const ::com::sun::star::awt::ItemEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); +private: + + OptimizerDialog& mrOptimizerDialog; +}; + +// ----------------------------------------------------------------------------- + +class ActionListener : public ::cppu::WeakImplHelper1< com::sun::star::awt::XActionListener > +{ +public: + ActionListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; + + virtual void SAL_CALL actionPerformed( const ::com::sun::star::awt::ActionEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); +private: + + OptimizerDialog& mrOptimizerDialog; +}; + +// ----------------------------------------------------------------------------- + +class ActionListenerListBox0Pg0 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XActionListener > +{ +public: + ActionListenerListBox0Pg0( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; + + virtual void SAL_CALL actionPerformed( const ::com::sun::star::awt::ActionEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); +private: + + OptimizerDialog& mrOptimizerDialog; +}; + +// ----------------------------------------------------------------------------- + +class TextListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XTextListener > +{ +public: + TextListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; + + virtual void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); +private: + + OptimizerDialog& mrOptimizerDialog; +}; + +// ----------------------------------------------------------------------------- + +class TextListenerComboBox0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XTextListener > +{ +public: + TextListenerComboBox0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; + + virtual void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); +private: + + OptimizerDialog& mrOptimizerDialog; +}; + +// ----------------------------------------------------------------------------- + +class HelpCloseListener : public ::cppu::WeakImplHelper1< com::sun::star::util::XCloseListener > +{ +public: + HelpCloseListener( com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rXFrame ) : mrXFrame( rXFrame ){}; + + virtual void SAL_CALL addCloseListener(const com::sun::star::uno::Reference < com::sun::star::util::XCloseListener >& ) throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeCloseListener( const com::sun::star::uno::Reference < com::sun::star::util::XCloseListener >& xListener ) throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL notifyClosing( const com::sun::star::lang::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException) ; + virtual void SAL_CALL queryClosing( const com::sun::star::lang::EventObject& aEvent, sal_Bool bDeliverOwnership ) throw (com::sun::star::uno::RuntimeException, com::sun::star::util::CloseVetoException) ; + virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException) ; + +private: + + com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& mrXFrame; +}; + + +#endif // OPTIMIZERDIALOG_HXX diff --git a/sdext/source/minimizer/optimizerdialogcontrols.cxx b/sdext/source/minimizer/optimizerdialogcontrols.cxx new file mode 100644 index 000000000000..74fc78d93f37 --- /dev/null +++ b/sdext/source/minimizer/optimizerdialogcontrols.cxx @@ -0,0 +1,955 @@ + /************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: optimizerdialogcontrols.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:57:48 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#include "optimizerdialog.hxx" + +// ------------------- +// - OptimizerDialog - +// ------------------- +#ifndef PPPOPTIMIZER_HXX +#include "pppoptimizer.hxx" +#endif +#ifndef GRAPHICCOLLECTOR_HXX +#include "graphiccollector.hxx" +#endif +#ifndef PAGECOLLECTOR_HXX +#include "pagecollector.hxx" +#endif +#ifndef _COM_SUN_STAR_PRESENTATION_XCUSTOMPRESENTATIONSUPPLIER_HPP_ +#include <com/sun/star/presentation/XCustomPresentationSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XMASTERPAGESSUPPLIER_HPP_ +#include <com/sun/star/drawing/XMasterPagesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESSUPPLIER_HPP_ +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ +#include <com/sun/star/awt/FontDescriptor.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XFONTWEIGHT_HPP_ +#include <com/sun/star/awt/FontWeight.hpp> +#endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +using namespace ::rtl; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::script; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::presentation; + +// ----------------------------------------------------------------------------- + +void SetBold( OptimizerDialog& rOptimizerDialog, const rtl::OUString& rControl ) +{ + FontDescriptor aFontDescriptor; + if ( rOptimizerDialog.getControlProperty( rControl, TKGet( TK_FontDescriptor ) ) >>= aFontDescriptor ) + { + aFontDescriptor.Weight = FontWeight::BOLD; + rOptimizerDialog.setControlProperty( rControl, TKGet( TK_FontDescriptor ), Any( aFontDescriptor ) ); + } +} + +// ----------------------------------------------------------------------------- + +rtl::OUString InsertSeparator( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, sal_Int32 nOrientation, + sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight ) +{ + OUString pNames[] = { + TKGet( TK_Height ), + TKGet( TK_Orientation ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_Step ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( nHeight ), + Any( nOrientation ), + Any( nPosX ), + Any( nPosY ), + Any( sal_Int16( 0 ) ), + Any( nWidth ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + rOptimizerDialog.insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedLineModel" ) ), + rControlName, aNames, aValues ); + return rControlName; +} + +// ----------------------------------------------------------------------------- + +rtl::OUString InsertButton( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, Reference< XActionListener >& xActionListener, + sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex, sal_Bool bEnabled, PPPOptimizerTokenEnum nResID, sal_Int16 nPushButtonType ) +{ + OUString pNames[] = { + TKGet( TK_Enabled ), + TKGet( TK_Height ), + TKGet( TK_Label ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_PushButtonType ), + TKGet( TK_Step ), + TKGet( TK_TabIndex ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( bEnabled ), + Any( nHeight ), + Any( rOptimizerDialog.getString( nResID ) ), + Any( nXPos ), + Any( nYPos ), + Any( nPushButtonType ), + Any( (sal_Int16)0 ), + Any( nTabIndex ), + Any( nWidth ) }; + + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + rOptimizerDialog.insertButton( rControlName, xActionListener, aNames, aValues ); + return rControlName; +} + +// ----------------------------------------------------------------------------- + +rtl::OUString InsertFixedText( OptimizerDialog& rOptimizerDialog, const rtl::OUString& rControlName, const OUString& rLabel, + sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Bool bBold, sal_Int16 nTabIndex ) +{ + OUString pNames[] = { + TKGet( TK_Height ), + TKGet( TK_Label ), + TKGet( TK_MultiLine ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_Step ), + TKGet( TK_TabIndex ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( nHeight ), + Any( rLabel ), + Any( bMultiLine ), + Any( nXPos ), + Any( nYPos ), + Any( (sal_Int16)0 ), + Any( nTabIndex ), + Any( nWidth ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + rOptimizerDialog.insertFixedText( rControlName, aNames, aValues ); + if ( bBold ) + SetBold( rOptimizerDialog, rControlName ); + return rControlName; +} + +// ----------------------------------------------------------------------------- + +rtl::OUString InsertCheckBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, + const Reference< XItemListener > xItemListener, const OUString& rLabel, + sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex ) +{ + OUString pNames[] = { + TKGet( TK_Enabled ), + TKGet( TK_Height ), + TKGet( TK_Label ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_Step ), + TKGet( TK_TabIndex ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( sal_True ), + Any( nHeight ), + Any( rLabel ), + Any( nXPos ), + Any( nYPos ), + Any( (sal_Int16)0 ), + Any( nTabIndex ), + Any( nWidth ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + Reference< XCheckBox > xCheckBox( rOptimizerDialog.insertCheckBox( rControlName, aNames, aValues ) ); + if ( xItemListener.is() ) + xCheckBox->addItemListener( xItemListener ); + return rControlName; +} + +// ----------------------------------------------------------------------------- + +rtl::OUString InsertFormattedField( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, + const Reference< XTextListener > xTextListener, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, + double fEffectiveMin, double fEffectiveMax, sal_Int16 nTabIndex ) +{ + OUString pNames[] = { + TKGet( TK_EffectiveMax ), + TKGet( TK_EffectiveMin ), + TKGet( TK_Enabled ), + TKGet( TK_Height ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_Repeat ), + TKGet( TK_Spin ), + TKGet( TK_Step ), + TKGet( TK_TabIndex ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( fEffectiveMax ), + Any( fEffectiveMin ), + Any( sal_True ), + Any( (sal_Int32)12 ), + Any( nXPos ), + Any( nYPos ), + Any( (sal_Bool)sal_True ), + Any( (sal_Bool)sal_True ), + Any( (sal_Int16)0 ), + Any( nTabIndex ), + Any( nWidth ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertFormattedField( rControlName, aNames, aValues ), UNO_QUERY_THROW ); + if ( xTextListener.is() ) + xTextComponent->addTextListener( xTextListener ); + return rControlName; +} + +// ----------------------------------------------------------------------------- + +rtl::OUString InsertComboBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, + const Reference< XTextListener > xTextListener, const sal_Bool bEnabled, const Sequence< OUString >& rItemList, + sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex ) +{ + OUString pNames[] = { + TKGet( TK_Dropdown ), + TKGet( TK_Enabled ), + TKGet( TK_Height ), + TKGet( TK_LineCount ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_Step ), + TKGet( TK_StringItemList ), + TKGet( TK_TabIndex ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( sal_True ), + Any( bEnabled ), + Any( nHeight ), + Any( (sal_Int16)8), + Any( nXPos ), + Any( nYPos ), + Any( (sal_Int16)0 ), + Any( rItemList ), + Any( nTabIndex ), + Any( nWidth ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertComboBox( rControlName, aNames, aValues ), UNO_QUERY_THROW ); + if ( xTextListener.is() ) + xTextComponent->addTextListener( xTextListener ); + return rControlName; +} + +// ----------------------------------------------------------------------------- + +rtl::OUString InsertRadioButton( OptimizerDialog& rOptimizerDialog, const rtl::OUString& rControlName, const Reference< XItemListener > xItemListener, + const OUString& rLabel, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Int16 nTabIndex ) +{ + OUString pNames[] = { + TKGet( TK_Height ), + TKGet( TK_Label ), + TKGet( TK_MultiLine ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_Step ), + TKGet( TK_TabIndex ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( nHeight ), + Any( rLabel ), + Any( bMultiLine ), + Any( nXPos ), + Any( nYPos ), + Any( (sal_Int16)0 ), + Any( nTabIndex ), + Any( nWidth ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + Reference< XRadioButton > xRadioButton( rOptimizerDialog.insertRadioButton( rControlName, aNames, aValues ) ); + if ( xItemListener.is() ) + xRadioButton->addItemListener( xItemListener ); + return rControlName; +} + +// ----------------------------------------------------------------------------- + +rtl::OUString InsertListBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, + const Reference< XActionListener > xActionListener, const sal_Bool bEnabled, const Sequence< OUString >& rItemList, + sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex ) +{ + OUString pNames[] = { + TKGet( TK_Dropdown ), + TKGet( TK_Enabled ), + TKGet( TK_Height ), + TKGet( TK_LineCount ), + TKGet( TK_MultiSelection ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_Step ), + TKGet( TK_StringItemList ), + TKGet( TK_TabIndex ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( sal_True ), + Any( bEnabled ), + Any( nHeight ), + Any( (sal_Int16)8), + Any( sal_False ), + Any( nXPos ), + Any( nYPos ), + Any( (sal_Int16)0 ), + Any( rItemList ), + Any( nTabIndex ), + Any( nWidth ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + Reference< XListBox > xListBox( rOptimizerDialog.insertListBox( rControlName, aNames, aValues ) ); + if ( xListBox.is() ) + xListBox->addActionListener( xActionListener ); + return rControlName; +} + +// ----------------------------------------------------------------------------- + +void OptimizerDialog::InitNavigationBar() +{ + sal_Int32 nCancelPosX = DIALOG_WIDTH - BUTTON_WIDTH - 6; + sal_Int32 nFinishPosX = nCancelPosX - 6 - BUTTON_WIDTH; + sal_Int32 nNextPosX = nFinishPosX - 6 - BUTTON_WIDTH; + sal_Int32 nBackPosX = nNextPosX - 3 - BUTTON_WIDTH; + + InsertSeparator( *this, TKGet( TK_lnNavSep1 ), 0, 0, DIALOG_HEIGHT - 26, DIALOG_WIDTH, 1 ); + InsertSeparator( *this, TKGet( TK_lnNavSep2 ), 1, 85, 0, 1, BUTTON_POS_Y - 6 ); + + InsertButton( *this, TKGet( TK_btnNavHelp ), mxActionListener, 8, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_HELP, PushButtonType_STANDARD ); + InsertButton( *this, TKGet( TK_btnNavBack ), mxActionListener, nBackPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_False, STR_BACK, PushButtonType_STANDARD ); + InsertButton( *this, TKGet( TK_btnNavNext ), mxActionListener, nNextPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_NEXT, PushButtonType_STANDARD ); + InsertButton( *this, TKGet( TK_btnNavFinish ), mxActionListener, nFinishPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_FINISH, PushButtonType_STANDARD ); + InsertButton( *this, TKGet( TK_btnNavCancel ), mxActionListener, nCancelPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_CANCEL, PushButtonType_STANDARD ); + + setControlProperty( TKGet( TK_btnNavNext ), TKGet( TK_DefaultButton ), Any( sal_True ) ); +} + +// ----------------------------------------------------------------------------- + +void OptimizerDialog::UpdateControlStatesPage0() +{ + sal_uInt32 i; + short nSelectedItem = -1; + Sequence< OUString > aItemList; + const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() ); + if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one + { + aItemList.realloc( rList.size() - 1 ); + for ( i = 1; i < rList.size(); i++ ) + { + aItemList[ i - 1 ] = rList[ i ].maName; + if ( nSelectedItem < 0 ) + { + if ( rList[ i ] == rList[ 0 ] ) + nSelectedItem = static_cast< short >( i - 1 ); + } + } + } + sal_Bool bRemoveButtonEnabled = sal_False; + Sequence< short > aSelectedItems; + if ( nSelectedItem >= 0 ) + { + aSelectedItems.realloc( 1 ); + aSelectedItems[ 0 ] = nSelectedItem; + if ( nSelectedItem > 2 ) // only allowing to delete custom themes, the first can|t be deleted + bRemoveButtonEnabled = sal_True; + } + setControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_StringItemList ), Any( aItemList ) ); + setControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_SelectedItems ), Any( aSelectedItems ) ); + setControlProperty( TKGet( TK_Button0Pg0 ), TKGet( TK_Enabled ), Any( bRemoveButtonEnabled ) ); +} +void OptimizerDialog::InitPage0() +{ + Sequence< OUString > aItemList; + std::vector< rtl::OUString > aControlList; + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText0Pg0 ), getString( STR_INTRODUCTION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) ); + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText1Pg0 ), getString( STR_INTRODUCTION_T ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 100, sal_True, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator1Pg0 ), 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 66, PAGE_WIDTH - 12, 1 ) ); + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText2Pg0 ), getString( STR_CHOSE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 60, PAGE_WIDTH - 12, 8, sal_True, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertListBox( *this, TKGet( TK_ListBox0Pg0 ), mxActionListenerListBox0Pg0, sal_True, aItemList, PAGE_POS_X + 6, DIALOG_HEIGHT - 48, ( DIALOG_WIDTH - 50 ) - ( PAGE_POS_X + 6 ), 12, mnTabIndex++ ) ); + aControlList.push_back( InsertButton( *this, TKGet( TK_Button0Pg0 ), mxActionListener, DIALOG_WIDTH - 46, DIALOG_HEIGHT - 48, 40, 14, mnTabIndex++, sal_True, STR_REMOVE, PushButtonType_STANDARD ) ); + maControlPages.push_back( aControlList ); + DeactivatePage( 0 ); + UpdateControlStatesPage0(); +} + +// ----------------------------------------------------------------------------- + +void OptimizerDialog::UpdateControlStatesPage1() +{ + sal_Bool bDeleteUnusedMasterPages( GetConfigProperty( TK_DeleteUnusedMasterPages, sal_False ) ); + sal_Bool bDeleteHiddenSlides( GetConfigProperty( TK_DeleteHiddenSlides, sal_False ) ); + sal_Bool bDeleteNotesPages( GetConfigProperty( TK_DeleteNotesPages, sal_False ) ); + + setControlProperty( TKGet( TK_CheckBox0Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteUnusedMasterPages ) ); + setControlProperty( TKGet( TK_CheckBox1Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteNotesPages ) ); + setControlProperty( TKGet( TK_CheckBox2Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteHiddenSlides ) ); +} +void OptimizerDialog::InitPage1() +{ + Sequence< OUString > aCustomShowList; + Reference< XModel > xModel( mxController->getModel() ); + if ( xModel.is() ) + { + Reference< XCustomPresentationSupplier > aXCPSup( xModel, UNO_QUERY_THROW ); + Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() ); + if ( aXCont.is() ) + aCustomShowList = aXCont->getElementNames(); + } + std::vector< rtl::OUString > aControlList; + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText0Pg3 ), getString( STR_CHOOSE_SLIDES ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) ); + aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox0Pg3 ), mxItemListener, getString( STR_DELETE_MASTER_PAGES ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, mnTabIndex++ ) ); + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText1Pg3 ), getString( STR_NOTES_PAGES ), PAGE_POS_X, PAGE_POS_Y + 28, PAGE_WIDTH, 8, sal_False, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox1Pg3 ), mxItemListener, getString( STR_DELETE_NOTES_PAGES ), PAGE_POS_X + 6, PAGE_POS_Y + 42, PAGE_WIDTH - 12, 8, mnTabIndex++ ) ); + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText2Pg3 ), getString( STR_SLIDES ), PAGE_POS_X, PAGE_POS_Y + 56, PAGE_WIDTH, 8, sal_False, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox2Pg3 ), mxItemListener, getString( STR_DELETE_HIDDEN_SLIDES ), PAGE_POS_X + 6, PAGE_POS_Y + 70, PAGE_WIDTH - 12, 8, mnTabIndex++ ) ); + aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox3Pg3 ), mxItemListener, getString( STR_CUSTOM_SHOW ), PAGE_POS_X + 6, PAGE_POS_Y + 84, PAGE_WIDTH - 12, 8, mnTabIndex++ ) ); + aControlList.push_back( InsertListBox( *this, TKGet( TK_ListBox0Pg3 ), mxActionListener, sal_True, aCustomShowList, PAGE_POS_X + 14, PAGE_POS_Y + 96, 150, 12, mnTabIndex++ ) ); + maControlPages.push_back( aControlList ); + DeactivatePage( 1 ); + + setControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ), Any( sal_False ) ); + setControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_Enabled ), Any( aCustomShowList.getLength() != 0 ) ); + setControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_Enabled ), Any( sal_False ) ); + + UpdateControlStatesPage1(); +} + +// ----------------------------------------------------------------------------- + +void OptimizerDialog::UpdateControlStatesPage2() +{ + sal_Bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, sal_False ) ); + sal_Bool bRemoveCropArea( GetConfigProperty( TK_RemoveCropArea, sal_False ) ); + sal_Bool bEmbedLinkedGraphics( GetConfigProperty( TK_EmbedLinkedGraphics, sal_True ) ); + sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) ); + + sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) ); + + sal_Int32 nI0, nI1, nI2, nI3; + nI0 = nI1 = nI2 = nI3 = 0; + OUString aResolutionText; + Sequence< OUString > aResolutionItemList( 4 ); + aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 ); + aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 ); + aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 ); + aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 ); + nI0 = nI1 = nI2 = nI3 = 0; + if ( getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI0 ).toInt32() == nImageResolution ) + aResolutionText = aResolutionItemList[ 0 ]; + else if ( getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI1 ).toInt32() == nImageResolution ) + aResolutionText = aResolutionItemList[ 1 ]; + else if ( getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI2 ).toInt32() == nImageResolution ) + aResolutionText = aResolutionItemList[ 2 ]; + else if ( getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI3 ).toInt32() == nImageResolution ) + aResolutionText = aResolutionItemList[ 3 ]; + if ( !aResolutionText.getLength() ) + aResolutionText = OUString::valueOf( nImageResolution ); + + setControlProperty( TKGet( TK_RadioButton0Pg1 ), TKGet( TK_State ), Any( (sal_Int16)( bJPEGCompression != sal_True ) ) ); + setControlProperty( TKGet( TK_RadioButton1Pg1 ), TKGet( TK_State ), Any( (sal_Int16)( bJPEGCompression != sal_False ) ) ); + setControlProperty( TKGet( TK_FixedText1Pg1 ), TKGet( TK_Enabled ), Any( bJPEGCompression ) ); + setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_Enabled ), Any( bJPEGCompression ) ); + setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( (double)nJPEGQuality ) ); + setControlProperty( TKGet( TK_CheckBox1Pg1 ), TKGet( TK_State ), Any( (sal_Int16)bRemoveCropArea ) ); + setControlProperty( TKGet( TK_ComboBox0Pg1 ), TKGet( TK_Text ), Any( aResolutionText ) ); + setControlProperty( TKGet( TK_CheckBox2Pg1 ), TKGet( TK_State ), Any( (sal_Int16)bEmbedLinkedGraphics ) ); +} +void OptimizerDialog::InitPage2() +{ + sal_Int32 nI0, nI1, nI2, nI3; + nI0 = nI1 = nI2 = nI3 = 0; + Sequence< OUString > aResolutionItemList( 4 ); + aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 ); + aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 ); + aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 ); + aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 ); + + std::vector< rtl::OUString > aControlList; + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText0Pg1 ), getString( STR_GRAPHIC_OPTIMIZATION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) ); + aControlList.push_back( InsertRadioButton( *this, TKGet( TK_RadioButton0Pg1 ), mxItemListener, getString( STR_LOSSLESS_COMPRESSION ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertRadioButton( *this, TKGet( TK_RadioButton1Pg1 ), mxItemListener, getString( STR_JPEG_COMPRESSION ), PAGE_POS_X + 6, PAGE_POS_Y + 28, PAGE_WIDTH - 12, 8, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText1Pg1 ), getString( STR_QUALITY ), PAGE_POS_X + 20, PAGE_POS_Y + 40, 72, 8, sal_False, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertFormattedField( *this, TKGet( TK_FormattedField0Pg1 ), mxTextListenerFormattedField0Pg1, PAGE_POS_X + 106, PAGE_POS_Y + 38, 50, 0, 100, mnTabIndex++ ) ); + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText2Pg1 ), getString( STR_IMAGE_RESOLUTION ), PAGE_POS_X + 6, PAGE_POS_Y + 54, 94, 8, sal_False, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertComboBox( *this, TKGet( TK_ComboBox0Pg1 ), mxTextListenerComboBox0Pg1, sal_True, aResolutionItemList, PAGE_POS_X + 106, PAGE_POS_Y + 52, 100, 12, mnTabIndex++ ) ); + aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox1Pg1 ), mxItemListener, getString( STR_REMOVE_CROP_AREA ), PAGE_POS_X + 6, PAGE_POS_Y + 68, PAGE_WIDTH - 12, 8, mnTabIndex++ ) ); + aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox2Pg1 ), mxItemListener, getString( STR_EMBED_LINKED_GRAPHICS ), PAGE_POS_X + 6, PAGE_POS_Y + 82, PAGE_WIDTH - 12, 8, mnTabIndex++ ) ); + maControlPages.push_back( aControlList ); + DeactivatePage( 2 ); + UpdateControlStatesPage2(); +} + +// ----------------------------------------------------------------------------- + +void OptimizerDialog::UpdateControlStatesPage3() +{ + sal_Bool bConvertOLEObjects( GetConfigProperty( TK_OLEOptimization, sal_False ) ); + sal_Int16 nOLEOptimizationType( GetConfigProperty( TK_OLEOptimizationType, (sal_Int16)0 ) ); + + setControlProperty( TKGet( TK_CheckBox0Pg2 ), TKGet( TK_State ), Any( (sal_Int16)bConvertOLEObjects ) ); + setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_Enabled ), Any( bConvertOLEObjects ) ); + setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_State ), Any( (sal_Int16)( nOLEOptimizationType == 0 ) ) ); + setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_Enabled ), Any( bConvertOLEObjects ) ); + setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_State ), Any( (sal_Int16)( nOLEOptimizationType == 1 ) ) ); +} +void OptimizerDialog::InitPage3() +{ + int nOLECount = 0; + Reference< XModel > xModel( mxController->getModel() ); + Reference< XDrawPagesSupplier > xDrawPagesSupplier( xModel, UNO_QUERY_THROW ); + Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); + for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ ) + { + Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW ); + for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ ) + { + const OUString sOLE2Shape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.OLE2Shape" ) ); + Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW ); + if ( xShape->getShapeType() == sOLE2Shape ) + nOLECount++; + } + } + + std::vector< rtl::OUString > aControlList; + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText0Pg2 ), getString( STR_OLE_OPTIMIZATION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) ); + aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox0Pg2 ), mxItemListener, getString( STR_OLE_REPLACE ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, mnTabIndex++ ) ); + aControlList.push_back( InsertRadioButton( *this, TKGet( TK_RadioButton0Pg2 ), mxItemListener, getString( STR_ALL_OLE_OBJECTS ), PAGE_POS_X + 14, PAGE_POS_Y + 28, 100, 8, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertRadioButton( *this, TKGet( TK_RadioButton1Pg2 ), mxItemListener, getString( STR_ALIEN_OLE_OBJECTS_ONLY ), PAGE_POS_X + 14, PAGE_POS_Y + 40, 100, 8, sal_False, mnTabIndex++ ) ); + if ( !nOLECount ) + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText1Pg2 ), getString( STR_NO_OLE_OBJECTS ), PAGE_POS_X + 14, PAGE_POS_Y + 64, PAGE_WIDTH - 22, 8, sal_True, sal_False, mnTabIndex++ ) ); + maControlPages.push_back( aControlList ); + DeactivatePage( 3 ); + UpdateControlStatesPage3(); +} + +// ----------------------------------------------------------------------------- + +void OptimizerDialog::UpdateControlStatesPage4() +{ + sal_Bool bSaveAs( GetConfigProperty( TK_SaveAs, sal_True ) ); + sal_Bool bOpenNew( GetConfigProperty( TK_OpenNewDocument, sal_True ) ); + if ( mbIsReadonly ) + { + setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( sal_False ) ) ); + setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( sal_True ) ) ); + } + else + { + setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bSaveAs == sal_False ) ) ); + setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bSaveAs == sal_True ) ) ); + } + setControlProperty( TKGet( TK_CheckBox0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bOpenNew ) ) ); + setControlProperty( TKGet( TK_CheckBox0Pg4 ), TKGet( TK_Enabled ), Any( bSaveAs ) ); + setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( sal_False ) ); + + sal_uInt32 i; + Sequence< OUString > aItemList; + const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() ); + if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one + { + aItemList.realloc( rList.size() - 1 ); + for ( i = 1; i < rList.size(); i++ ) + aItemList[ i - 1 ] = rList[ i ].maName; + } + setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_StringItemList ), Any( aItemList ) ); + + // now check if it is sensible to enable the combo box + sal_Bool bSaveSettingsEnabled = sal_True; + if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one + { + for ( i = 1; i < rList.size(); i++ ) + { + if ( rList[ i ] == rList[ 0 ] ) + { + bSaveSettingsEnabled = sal_False; + break; + } + } + } + setControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled ) ); + setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled && GetConfigProperty( TK_CheckBox1Pg4, sal_False ) ) ); + + std::vector< OUString > aSummaryStrings; + + // taking care of deleted slides + sal_Int16 nInt16 = 0; + sal_Int32 nDeletedSlides = 0; + rtl::OUString aCustomShowName; + if ( getControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ) ) >>= nInt16 ) + { + if ( nInt16 ) + { + Sequence< short > aSelectedItems; + Sequence< OUString > aStringItemList; + Any aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_SelectedItems ) ); + if ( aAny >>= aSelectedItems ) + { + if ( aSelectedItems.getLength() ) + { + sal_Int16 nSelectedItem = aSelectedItems[ 0 ]; + aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_StringItemList ) ); + if ( aAny >>= aStringItemList ) + { + if ( aStringItemList.getLength() > nSelectedItem ) + SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) ); + } + } + } + } + } + if ( aCustomShowName.getLength() ) + { + std::vector< Reference< XDrawPage > > vNonUsedPageList; + PageCollector::CollectNonCustomShowPages( mxController->getModel(), aCustomShowName, vNonUsedPageList ); + nDeletedSlides += vNonUsedPageList.size(); + } + if ( GetConfigProperty( TK_DeleteHiddenSlides, sal_False ) ) + { + if ( aCustomShowName.getLength() ) + { + std::vector< Reference< XDrawPage > > vUsedPageList; + PageCollector::CollectCustomShowPages( mxController->getModel(), aCustomShowName, vUsedPageList ); + std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() ); + while( aIter != vUsedPageList.end() ) + { + Reference< XPropertySet > xPropSet( *aIter, UNO_QUERY_THROW ); + sal_Bool bVisible = sal_True; + const OUString sVisible( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) ); + if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible ) + { + if (!bVisible ) + nDeletedSlides++; + } + aIter++; + } + } + else + { + Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW ); + Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); + for( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ ) + { + Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW ); + Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY_THROW ); + + sal_Bool bVisible = sal_True; + const OUString sVisible( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) ); + if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible ) + { + if (!bVisible ) + nDeletedSlides++; + } + } + } + } + if ( GetConfigProperty( TK_DeleteUnusedMasterPages, sal_False ) ) + { + std::vector< PageCollector::MasterPageEntity > aMasterPageList; + PageCollector::CollectMasterPages( mxController->getModel(), aMasterPageList ); + Reference< XMasterPagesSupplier > xMasterPagesSupplier( mxController->getModel(), UNO_QUERY_THROW ); + Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW ); + std::vector< PageCollector::MasterPageEntity >::iterator aIter( aMasterPageList.begin() ); + while( aIter != aMasterPageList.end() ) + { + if ( !aIter->bUsed ) + nDeletedSlides++; + aIter++; + } + } + if ( nDeletedSlides > 1 ) + { + OUString aStr( getString( STR_DELETE_SLIDES ) ); + OUString aPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%SLIDES" ) ); + sal_Int32 i = aStr.indexOf( aPlaceholder, 0 ); + if ( i >= 0 ) + aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::valueOf( nDeletedSlides ) ); + aSummaryStrings.push_back( aStr ); + } + +// generating graphic compression info + std::vector< GraphicCollector::GraphicEntity > aGraphicList; +// sal_Bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, sal_False ) ); + sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) ); + sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) ); +// GraphicSettings aGraphicSettings( bJPEGCompression, nJPEGQuality, GetConfigProperty( TK_RemoveCropArea, sal_False ), +// nImageResolution, GetConfigProperty( TK_EmbedLinkedGraphics, sal_True ) ); +// GraphicCollector::CollectGraphics( mxMSF, mxController->getModel(), aGraphicSettings, aGraphicList ); +// if ( aGraphicList.size() > 1 ) + { + OUString aStr( getString( STR_OPTIMIZE_IMAGES ) ); + OUString aImagePlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%IMAGES" ) ); + OUString aQualityPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%QUALITY" ) ); + OUString aResolutionPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%RESOLUTION" ) ); + sal_Int32 i = aStr.indexOf( aImagePlaceholder, 0 ); + if ( i >= 0 ) + aStr = aStr.replaceAt( i, aImagePlaceholder.getLength(), OUString::valueOf( static_cast< sal_Int32 >( aGraphicList.size() ) ) ); + + sal_Int32 j = aStr.indexOf( aQualityPlaceholder, 0 ); + if ( j >= 0 ) + aStr = aStr.replaceAt( j, aQualityPlaceholder.getLength(), OUString::valueOf( nJPEGQuality ) ); + + sal_Int32 k = aStr.indexOf( aResolutionPlaceholder, 0 ); + if ( k >= 0 ) + aStr = aStr.replaceAt( k, aResolutionPlaceholder.getLength(), OUString::valueOf( nImageResolution ) ); + + aSummaryStrings.push_back( aStr ); + } + + if ( GetConfigProperty( TK_OLEOptimization, sal_False ) ) + { + sal_Int32 nOLEReplacements = 0; + Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW ); + Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); + for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ ) + { + Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW ); + for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ ) + { + const OUString sOLE2Shape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.OLE2Shape" ) ); + Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW ); + if ( xShape->getShapeType() == sOLE2Shape ) + nOLEReplacements++; + } + } + if ( nOLEReplacements > 1 ) + { + OUString aStr( getString( STR_CREATE_REPLACEMENT ) ); + OUString aPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%OLE" ) ); + sal_Int32 i = aStr.indexOf( aPlaceholder, 0 ); + if ( i >= 0 ) + aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::valueOf( nOLEReplacements ) ); + aSummaryStrings.push_back( aStr ); + } + } + while( aSummaryStrings.size() < 3 ) + aSummaryStrings.push_back( OUString() ); + setControlProperty( TKGet( TK_FixedText4Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 0 ] ) ); + setControlProperty( TKGet( TK_FixedText5Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 1 ] ) ); + setControlProperty( TKGet( TK_FixedText6Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 2 ] ) ); +} + +static OUString ImpValueOfInMB( const sal_Int64& rVal ) +{ + double fVal( static_cast<double>( rVal ) ); + fVal /= ( 1 << 20 ); + fVal += 0.05; + rtl::OUStringBuffer aVal( OUString::valueOf( fVal ) ); + sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.', 0 ) ); + if ( nX > 0 ) + aVal.setLength( nX + 2 ); + aVal.append( OUString::createFromAscii( " MB" ) ); + return aVal.makeStringAndClear(); +} + +void OptimizerDialog::InitPage4() +{ + { // creating progress bar: + OUString pNames[] = { + TKGet( TK_Height ), + TKGet( TK_Name ), + TKGet( TK_PositionX ), + TKGet( TK_PositionY ), + TKGet( TK_ProgressValue ), + TKGet( TK_ProgressValueMax ), + TKGet( TK_ProgressValueMin ), + TKGet( TK_Width ) }; + + Any pValues[] = { + Any( (sal_Int32)8 ), + Any( TKGet( STR_SAVE_AS ) ), + Any( (sal_Int32)( PAGE_POS_X + 6 ) ), + Any( (sal_Int32)( DIALOG_HEIGHT - 74 ) ), + Any( (sal_Int32)( 0 ) ), + Any( (sal_Int32)( 100 ) ), + Any( (sal_Int32)( 0 ) ), + Any( (sal_Int32)( PAGE_WIDTH - 12 ) ) }; + + sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + + Sequence< rtl::OUString > aNames( pNames, nCount ); + Sequence< Any > aValues( pValues, nCount ); + + Reference< XMultiPropertySet > xMultiPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlProgressBarModel" ) ), + TKGet( TK_Progress ), aNames, aValues ), UNO_QUERY ); + } + sal_Int64 nCurrentFileSize = 0; + sal_Int64 nEstimatedFileSize = 0; + Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY ); + if ( xStorable.is() && xStorable->hasLocation() ) + nCurrentFileSize = PPPOptimizer::GetFileSize( xStorable->getLocation() ); + + Reference< XTextListener > xTextListener; + Sequence< OUString > aItemList; + std::vector< rtl::OUString > aControlList; + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText0Pg4 ), getString( STR_SUMMARY_TITLE ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) ); +// aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox0Pg4 ), mxItemListener, getString( STR_AUTOMATICALLY_OPEN ), PAGE_POS_X + 14, PAGE_POS_Y + 38, PAGE_WIDTH - 18, 8, mnTabIndex++ ) ); +// aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator0Pg4 ), 0, PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 1 ) ); + + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText4Pg4 ), OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, sal_False, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText5Pg4 ), OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 22, PAGE_WIDTH - 12, 8, sal_False, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText6Pg4 ), OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 30, PAGE_WIDTH - 12, 8, sal_False, sal_False, mnTabIndex++ ) ); + + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText2Pg4 ), getString( STR_CURRENT_FILESIZE ), PAGE_POS_X + 6, PAGE_POS_Y + 50, 58, 8, sal_False, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText7Pg4 ), ImpValueOfInMB( nCurrentFileSize ), PAGE_POS_X + 70, PAGE_POS_Y + 50, 30, 8, sal_False, sal_False, mnTabIndex++ ) ); + setControlProperty( TKGet( TK_FixedText7Pg4 ), TKGet( TK_Align ), Any( static_cast< short >( 2 ) ) ); + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText3Pg4 ), getString( STR_ESTIMATED_FILESIZE ), PAGE_POS_X + 6, PAGE_POS_Y + 58, 58, 8, sal_False, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText8Pg4 ), ImpValueOfInMB( nEstimatedFileSize ), PAGE_POS_X + 70, PAGE_POS_Y + 58, 30, 8, sal_False, sal_False, mnTabIndex++ ) ); + setControlProperty( TKGet( TK_FixedText8Pg4 ), TKGet( TK_Align ), Any( static_cast< short >( 2 ) ) ); + + aControlList.push_back( InsertRadioButton( *this, TKGet( TK_RadioButton0Pg4 ), mxItemListener, getString( STR_APPLY_TO_CURRENT ), PAGE_POS_X + 6, PAGE_POS_Y + 78, PAGE_WIDTH - 12, 8, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertRadioButton( *this, TKGet( TK_RadioButton1Pg4 ), mxItemListener, getString( STR_SAVE_AS ), PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 8, sal_False, mnTabIndex++ ) ); + aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText1Pg4 ), OUString(), PAGE_POS_X + 6, DIALOG_HEIGHT - 86, PAGE_WIDTH - 12, 8, sal_True, sal_False, mnTabIndex++ ) ); + aControlList.push_back( TKGet( TK_Progress ) ); + aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator1Pg4 ), 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 58, PAGE_WIDTH - 12, 1 ) ); + aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox1Pg4 ), mxItemListener, getString( STR_SAVE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 48, PAGE_WIDTH - 12, 8, mnTabIndex++ ) ); + aControlList.push_back( InsertComboBox( *this, TKGet( TK_ComboBox0Pg4 ), xTextListener, sal_True, aItemList, PAGE_POS_X + 76, DIALOG_HEIGHT - 48, 100, 12, mnTabIndex++ ) ); + maControlPages.push_back( aControlList ); + DeactivatePage( 4 ); + + // creating a default session name that hasn't been used yet + OUString aSettingsName; + OUString aDefault( getString( STR_MY_SETTINGS ) ); + sal_Int32 nSession = 1; + sal_uInt32 i; + const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() ); + do + { + OUString aTemp( aDefault.concat( OUString::valueOf( nSession++ ) ) ); + for ( i = 1; i < rList.size(); i++ ) + { + if ( rList[ i ].maName == aTemp ) + break; + } + if ( i == rList.size() ) + aSettingsName = aTemp; + } + while( !aSettingsName.getLength() ); + + setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Text ), Any( aSettingsName ) ); + setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_Enabled ), Any( !mbIsReadonly ) ); + setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_Enabled ), Any( !mbIsReadonly ) ); + + UpdateControlStatesPage4(); +} + +// ----------------------------------------------------------------------------- +void OptimizerDialog::EnablePage( sal_Int16 nStep ) +{ + std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() ); + std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() ); + while( aBeg != aEnd ) + setControlProperty( *aBeg++, TKGet( TK_Enabled ), Any( sal_True ) ); +} +void OptimizerDialog::DisablePage( sal_Int16 nStep ) +{ + std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() ); + std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() ); + while( aBeg != aEnd ) + setControlProperty( *aBeg++, TKGet( TK_Enabled ), Any( sal_False ) ); +} +void OptimizerDialog::ActivatePage( sal_Int16 nStep ) +{ + std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() ); + std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() ); + while( aBeg != aEnd ) + setVisible( *aBeg++, sal_True ); +} +void OptimizerDialog::DeactivatePage( sal_Int16 nStep ) +{ + std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() ); + std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() ); + while( aBeg != aEnd ) + setVisible( *aBeg++, sal_False ); +} diff --git a/sdext/source/minimizer/pagecollector.cxx b/sdext/source/minimizer/pagecollector.cxx new file mode 100644 index 000000000000..2015f16b47bd --- /dev/null +++ b/sdext/source/minimizer/pagecollector.cxx @@ -0,0 +1,205 @@ + /************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: pagecollector.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:59:09 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef PAGECOLLECTOR_HXX +#include "pagecollector.hxx" +#endif + +#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESSUPPLIER_HPP_ +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_PRESENTATION_XPRESENTATIONPAGE_HPP_ +#include <com/sun/star/presentation/XPresentationPage.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XMASTERPAGESSUPPLIER_HPP_ +#include <com/sun/star/drawing/XMasterPagesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XMASTERPAGETARGET_HPP_ +#include <com/sun/star/drawing/XMasterPageTarget.hpp> +#endif +#ifndef _COM_SUN_STAR_PRESENTATION_XCUSTOMPRESENTATIONSUPPLIER_HPP_ +#include <com/sun/star/presentation/XCustomPresentationSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_ +#include <com/sun/star/container/XIndexContainer.hpp> +#endif + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::presentation; + +void PageCollector::CollectCustomShowPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel, const rtl::OUString& rCustomShowName, std::vector< Reference< XDrawPage > >& rUsedPageList ) +{ + try + { + Reference< XCustomPresentationSupplier > aXCPSup( rxModel, UNO_QUERY_THROW ); + Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() ); + if ( aXCont.is() ) + { + // creating a list of every page that is used within our customshow + Sequence< OUString> aNameSeq( aXCont->getElementNames() ); + const OUString* pUString = aNameSeq.getArray(); + sal_Int32 i, nCount = aNameSeq.getLength(); + for ( i = 0; i < nCount; i++ ) + { + if ( pUString[ i ] == rCustomShowName ) + { + Reference< container::XIndexContainer > aXIC( aXCont->getByName( pUString[ i ] ), UNO_QUERY_THROW ); + sal_Int32 j, nSlideCount = aXIC->getCount(); + for ( j = 0; j < nSlideCount; j++ ) + { + Reference< XDrawPage > xDrawPage( aXIC->getByIndex( j ), UNO_QUERY_THROW ); + std::vector< Reference< XDrawPage > >::iterator aIter( rUsedPageList.begin() ); + std::vector< Reference< XDrawPage > >::iterator aEnd( rUsedPageList.end() ); + while( aIter != aEnd ) + { + if ( *aIter == xDrawPage ) + break; + aIter++; + } + if ( aIter == aEnd ) + rUsedPageList.push_back( xDrawPage ); + } + } + } + } + } + catch( Exception& ) + { + + } +} + +void PageCollector::CollectNonCustomShowPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel, const rtl::OUString& rCustomShowName, std::vector< Reference< XDrawPage > >& rNonUsedPageList ) +{ + try + { + std::vector< Reference< XDrawPage > > vUsedPageList; + PageCollector::CollectCustomShowPages( rxModel, rCustomShowName, vUsedPageList ); + if ( vUsedPageList.size() ) + { + Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW ); + Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); + for ( sal_Int32 j = 0; j < xDrawPages->getCount(); j++ ) + { + Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( j ), UNO_QUERY_THROW ); + std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() ); + std::vector< Reference< XDrawPage > >::iterator aEnd( vUsedPageList.end() ); + while( aIter != aEnd ) + { + if ( *aIter == xDrawPage ) + break; + aIter++; + } + if ( aIter == aEnd ) + { + rNonUsedPageList.push_back( xDrawPage ); + j--; + } + } + } + } + catch( Exception& ) + { + } +} + + +void PageCollector::CollectMasterPages( const Reference< XModel >& rxModel, std::vector< PageCollector::MasterPageEntity >& rMasterPageList ) +{ + typedef std::vector< MasterPageEntity > MasterPageList; + typedef MasterPageList::iterator MasterPageIter; + + try + { + // generating list of all master pages + Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW ); + Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW ); + for ( sal_Int32 i = 0; i < xMasterPages->getCount(); i++ ) + { + Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW ); + MasterPageIter aIter( rMasterPageList.begin() ); + MasterPageIter aEnd ( rMasterPageList.end() ); + while( aIter != aEnd ) + { + if ( aIter->xMasterPage == xMasterPage ) + break; + aIter++; + } + if ( aIter == aEnd ) + { + MasterPageEntity aMasterPageEntity; + aMasterPageEntity.xMasterPage = xMasterPage; + aMasterPageEntity.bUsed = sal_False; + rMasterPageList.push_back( aMasterPageEntity ); + } + } + + // mark masterpages which are referenced by drawpages + Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW ); + Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); + for ( sal_Int32 j = 0; j < xDrawPages->getCount(); j++ ) + { + Reference< XMasterPageTarget > xMasterPageTarget( xDrawPages->getByIndex( j ), UNO_QUERY_THROW ); + Reference< XDrawPage > xMasterPage( xMasterPageTarget->getMasterPage(), UNO_QUERY_THROW ); + MasterPageIter aIter( rMasterPageList.begin() ); + MasterPageIter aEnd ( rMasterPageList.end() ); + while( aIter != aEnd ) + { + if ( aIter->xMasterPage == xMasterPage ) + { + aIter->bUsed = sal_True; + break; + } + aIter++; + } + if ( aIter == aEnd ) + throw uno::RuntimeException(); + } + } + catch( Exception& ) + { + } +} + diff --git a/sdext/source/minimizer/pagecollector.hxx b/sdext/source/minimizer/pagecollector.hxx new file mode 100644 index 000000000000..9e3392555a56 --- /dev/null +++ b/sdext/source/minimizer/pagecollector.hxx @@ -0,0 +1,61 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: pagecollector.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:59:19 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef PAGECOLLECTOR_HXX +#define PAGECOLLECTOR_HXX + +#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ +#include <com/sun/star/frame/XModel.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESSUPPLIER_HPP_ +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#endif +#include <vector> + +class PageCollector +{ + public: + + struct MasterPageEntity + { + com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > xMasterPage; + sal_Bool bUsed; + }; + static void CollectCustomShowPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >&, const rtl::OUString& rCustomShow, std::vector< com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > >& ); + static void CollectNonCustomShowPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >&, const rtl::OUString& rCustomShow, std::vector< com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > >& ); + static void CollectMasterPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >&, std::vector< MasterPageEntity >& ); +}; + +#endif // PAGECOLLECTOR_HXX diff --git a/sdext/source/minimizer/pppoptimizer.cxx b/sdext/source/minimizer/pppoptimizer.cxx new file mode 100644 index 000000000000..683a835d1764 --- /dev/null +++ b/sdext/source/minimizer/pppoptimizer.cxx @@ -0,0 +1,214 @@ + /************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: pppoptimizer.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:59:28 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef PPPOPTIMIZER_HXX +#include "pppoptimizer.hxx" +#endif +#include "impoptimizer.hxx" +#include <osl/file.hxx> + +using namespace ::rtl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; + +#define SERVICE_NAME "com.sun.star.comp.PPPOptimizer" + +// ---------------- +// - PPPOptimizer - +// ---------------- + +PPPOptimizer::PPPOptimizer( const Reference< XComponentContext > &rxMSF ) : + mxMSF( rxMSF ) +{ +} + +// ----------------------------------------------------------------------------- + +PPPOptimizer::~PPPOptimizer() +{ +} + +// ----------------------------------------------------------------------------- +// XInitialization +// ----------------------------------------------------------------------------- + +void SAL_CALL PPPOptimizer::initialize( const Sequence< Any >& aArguments ) + throw ( Exception, RuntimeException ) +{ + if( aArguments.getLength() != 1 ) + throw IllegalArgumentException(); + + Reference< XFrame > xFrame; + aArguments[ 0 ] >>= xFrame; + if ( xFrame.is() ) + mxController = xFrame->getController(); +} + +// ----------------------------------------------------------------------------- +// XServiceInfo +// ----------------------------------------------------------------------------- + +OUString SAL_CALL PPPOptimizer::getImplementationName() + throw ( RuntimeException ) +{ + return PPPOptimizer_getImplementationName(); +} + +sal_Bool SAL_CALL PPPOptimizer::supportsService( const OUString& rServiceName ) + throw ( RuntimeException ) +{ + return rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SERVICE_NAME ) ); +} + +Sequence< OUString > SAL_CALL PPPOptimizer::getSupportedServiceNames() + throw ( RuntimeException ) +{ + return PPPOptimizer_getSupportedServiceNames(); +} + +// ----------------------------------------------------------------------------- +// XDispatchProvider +// ----------------------------------------------------------------------------- + +Reference< com::sun::star::frame::XDispatch > SAL_CALL PPPOptimizer::queryDispatch( + const URL& aURL, const ::rtl::OUString& /* aTargetFrameName */, sal_Int32 /* nSearchFlags */ ) throw( RuntimeException ) +{ + Reference < XDispatch > xRet; + if ( aURL.Protocol.compareToAscii( "vnd.com.sun.star.comp.PPPOptimizer:" ) == 0 ) + { +// if ( aURL.Path.compareToAscii( "Function1" ) == 0 ) + xRet = this; + } + return xRet; +} + +//------------------------------------------------------------------------------ + +Sequence< Reference< com::sun::star::frame::XDispatch > > SAL_CALL PPPOptimizer::queryDispatches( + const Sequence< com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw( RuntimeException ) +{ + Sequence< Reference< com::sun::star::frame::XDispatch> > aReturn( aDescripts.getLength() ); + Reference< com::sun::star::frame::XDispatch>* pReturn = aReturn.getArray(); + const com::sun::star::frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray(); + for (sal_Int16 i = 0; i < aDescripts.getLength(); ++i, ++pReturn, ++pDescripts ) + { + *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags ); + } + return aReturn; +} + +// ----------------------------------------------------------------------------- +// XDispatch +// ----------------------------------------------------------------------------- + +void SAL_CALL PPPOptimizer::dispatch( const URL& rURL, const Sequence< PropertyValue >& lArguments ) + throw( RuntimeException ) +{ + if ( mxController.is() && ( rURL.Protocol.compareToAscii( "vnd.com.sun.star.comp.PPPOptimizer:" ) == 0 ) ) + { + if ( rURL.Path.compareToAscii( "optimize" ) == 0 ) + { + Reference< XModel > xModel( mxController->getModel() ); + if ( xModel.is() ) + { + try + { + ImpOptimizer aOptimizer( mxMSF, xModel ); + aOptimizer.Optimize( lArguments ); + } + catch( Exception& ) + { + } + } + } + } +} + +//=============================================== +void SAL_CALL PPPOptimizer::addStatusListener( const Reference< XStatusListener >&, const URL& ) + throw( RuntimeException ) +{ + // TODO + OSL_ENSURE( sal_False, "PPPOptimizer::addStatusListener()\nNot implemented yet!" ); +} + +//=============================================== +void SAL_CALL PPPOptimizer::removeStatusListener( const Reference< XStatusListener >&, const URL& ) + throw( RuntimeException ) +{ + // TODO + OSL_ENSURE( sal_False, "PPPOptimizer::removeStatusListener()\nNot implemented yet!" ); +} + +// ----------------------------------------------------------------------------- +// returning filesize, on error zero is returned +sal_Int64 PPPOptimizer::GetFileSize( const rtl::OUString& rURL ) +{ + sal_Int64 nFileSize = 0; + osl::DirectoryItem aItem; + if ( osl::DirectoryItem::get( rURL, aItem ) == osl::FileBase::E_None ) + { + osl::FileStatus aStatus( osl_FileStatus_Mask_FileSize ); + if ( aItem.getFileStatus( aStatus ) == osl::FileBase::E_None ) + { + nFileSize = aStatus.getFileSize(); + } + } + return nFileSize; +} + +// ----------------------------------------------------------------------------- + +OUString PPPOptimizer_getImplementationName() +{ + return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.PPPOptimizerImp" ) ); +} + +Sequence< OUString > PPPOptimizer_getSupportedServiceNames() +{ + Sequence < OUString > aRet(1); + OUString* pArray = aRet.getArray(); + pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) ); + return aRet; +} + +Reference< XInterface > PPPOptimizer_createInstance( const Reference< XComponentContext > & rSMgr ) + throw( Exception ) +{ + return (cppu::OWeakObject*) new PPPOptimizer( rSMgr ); +} diff --git a/sdext/source/minimizer/pppoptimizer.hxx b/sdext/source/minimizer/pppoptimizer.hxx new file mode 100644 index 000000000000..25290227bf97 --- /dev/null +++ b/sdext/source/minimizer/pppoptimizer.hxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: pppoptimizer.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:59:38 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef PPPOPTIMIZER_HXX +#define PPPOPTIMIZER_HXX + +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#include <cppuhelper/implbase4.hxx> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_ +#include <com/sun/star/frame/XDispatch.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_ +#include <com/sun/star/frame/XDispatchProvider.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTICOMPONENTFACTORY_HPP_ +#include <com/sun/star/lang/XMultiComponentFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include <com/sun/star/lang/XInitialization.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_ +#include <com/sun/star/frame/XController.hpp> +#endif +#ifndef _COMPHELPER_PROPERTY_HXX_ +#include <comphelper/property.hxx> +#endif + +// ---------------- +// - PPPOptimizer - +// ---------------- + +class PPPOptimizer : public cppu::WeakImplHelper4< + com::sun::star::lang::XInitialization, + com::sun::star::lang::XServiceInfo, + com::sun::star::frame::XDispatchProvider, + com::sun::star::frame::XDispatch > +{ + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxMSF; + com::sun::star::uno::Reference< com::sun::star::frame::XController > mxController; + +public: + + PPPOptimizer( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxMSF ); + virtual ~PPPOptimizer(); + + // XInitialization + void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) + throw( com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException ); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw( com::sun::star::uno::RuntimeException ); + + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName ) + throw( com::sun::star::uno::RuntimeException ); + + virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() + throw( com::sun::star::uno::RuntimeException ); + + // XDispatchProvider + virtual com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( + const com::sun::star::util::URL& aURL, const rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) + throw(com::sun::star::uno::RuntimeException); + + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( + const com::sun::star::uno::Sequence< com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw( com::sun::star::uno::RuntimeException ); + + // XDispatch + virtual void SAL_CALL dispatch( const com::sun::star::util::URL& aURL, + const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& lArguments ) + throw( com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL addStatusListener( const com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener >& xListener, + const com::sun::star::util::URL& aURL ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeStatusListener( const com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener >& xListener, + const com::sun::star::util::URL& aURL ) + throw( com::sun::star::uno::RuntimeException ); + + static sal_Int64 GetFileSize( const rtl::OUString& rURL ); +}; + +rtl::OUString PPPOptimizer_getImplementationName(); +com::sun::star::uno::Sequence< rtl::OUString > PPPOptimizer_getSupportedServiceNames(); +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > PPPOptimizer_createInstance( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & rSMgr ) + throw( com::sun::star::uno::Exception ); + +#endif // PPPOPTIMIZER_HXX diff --git a/sdext/source/minimizer/pppoptimizerdialog.cxx b/sdext/source/minimizer/pppoptimizerdialog.cxx new file mode 100644 index 000000000000..04b156082779 --- /dev/null +++ b/sdext/source/minimizer/pppoptimizerdialog.cxx @@ -0,0 +1,232 @@ + /************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: pppoptimizerdialog.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:59:48 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#include "pppoptimizerdialog.hxx" +#include "optimizerdialog.hxx" +#include "aboutdialog.hxx" + +using namespace ::rtl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; + +#define SERVICE_NAME "com.sun.star.comp.SunPresentationMinimizer" +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +// ---------------------- +// - PPPOptimizerDialog - +// ---------------------- + +PPPOptimizerDialog::PPPOptimizerDialog( const Reference< XComponentContext > &rxMSF ) : + mxMSF( rxMSF ), + mpOptimizerDialog( NULL ) +{ +} + +// ----------------------------------------------------------------------------- + +PPPOptimizerDialog::~PPPOptimizerDialog() +{ +} + +// ----------------------------------------------------------------------------- +// XInitialization +// ----------------------------------------------------------------------------- + +void SAL_CALL PPPOptimizerDialog::initialize( const Sequence< Any >& aArguments ) + throw ( Exception, RuntimeException ) +{ + if( aArguments.getLength() != 1 ) + throw IllegalArgumentException(); + + aArguments[ 0 ] >>= mxFrame; + if ( mxFrame.is() ) + mxController = mxFrame->getController(); +} + +// ----------------------------------------------------------------------------- +// XServiceInfo +// ----------------------------------------------------------------------------- + +OUString SAL_CALL PPPOptimizerDialog::getImplementationName() + throw (RuntimeException) +{ + return PPPOptimizerDialog_getImplementationName(); +} + +sal_Bool SAL_CALL PPPOptimizerDialog::supportsService( const OUString& ServiceName ) + throw ( RuntimeException ) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SERVICE_NAME ) ); +} + +Sequence< OUString > SAL_CALL PPPOptimizerDialog::getSupportedServiceNames() + throw (RuntimeException) +{ + return PPPOptimizerDialog_getSupportedServiceNames(); +} + +// ----------------------------------------------------------------------------- +// XDispatchProvider +// ----------------------------------------------------------------------------- + +Reference< com::sun::star::frame::XDispatch > SAL_CALL PPPOptimizerDialog::queryDispatch( + const URL& aURL, const ::rtl::OUString& /* aTargetFrameName */, sal_Int32 /* nSearchFlags */ ) throw( RuntimeException ) +{ + Reference < XDispatch > xRet; + if ( aURL.Protocol.compareToAscii( "vnd.com.sun.star.comp.SunPresentationMinimizer:" ) == 0 ) + { +// if ( aURL.Path.compareToAscii( "Function1" ) == 0 ) + xRet = this; + } + return xRet; +} + +//------------------------------------------------------------------------------ + +Sequence< Reference< com::sun::star::frame::XDispatch > > SAL_CALL PPPOptimizerDialog::queryDispatches( + const Sequence< com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw( RuntimeException ) +{ + Sequence< Reference< com::sun::star::frame::XDispatch> > aReturn( aDescripts.getLength() ); + Reference< com::sun::star::frame::XDispatch>* pReturn = aReturn.getArray(); + const com::sun::star::frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray(); + for (sal_Int16 i = 0; i < aDescripts.getLength(); ++i, ++pReturn, ++pDescripts ) + { + *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags ); + } + return aReturn; +} + +// ----------------------------------------------------------------------------- +// XDispatch +// ----------------------------------------------------------------------------- + +void SAL_CALL PPPOptimizerDialog::dispatch( const URL& rURL, + const Sequence< PropertyValue >& rArguments ) + throw( RuntimeException ) +{ + sal_Int64 nFileSizeSource = 0; + sal_Int64 nFileSizeDest = 0; + + if ( mxController.is() && ( rURL.Protocol.compareToAscii( "vnd.com.sun.star.comp.SunPresentationMinimizer:" ) == 0 ) ) + { + if ( rURL.Path.compareToAscii( "execute" ) == 0 ) + { + sal_Bool bDialogExecuted = sal_False; + + try + { + mpOptimizerDialog = new OptimizerDialog( mxMSF, mxFrame, this ); + bDialogExecuted = mpOptimizerDialog->execute(); + + const Any* pVal( mpOptimizerDialog->maStats.GetStatusValue( TK_FileSizeSource ) ); + if ( pVal ) + *pVal >>= nFileSizeSource; + pVal = mpOptimizerDialog->maStats.GetStatusValue( TK_FileSizeDestination ); + if ( pVal ) + *pVal >>= nFileSizeDest; + + if ( nFileSizeSource && nFileSizeDest ) + { + rtl::OUStringBuffer sBuf( rtl::OUString::createFromAscii( "Your Presentation has been minimized from:" ) ); + sBuf.append( rtl::OUString::valueOf( nFileSizeSource >> 10 ) ); + sBuf.append( rtl::OUString::createFromAscii( "KB to " ) ); + sBuf.append( rtl::OUString::valueOf( nFileSizeDest >> 10 ) ); + sBuf.append( rtl::OUString::createFromAscii( "KB." ) ); + OUString sResult( sBuf.makeStringAndClear() ); +// mpOptimizerDialog->showMessageBox( sResult, sResult, sal_False ); + } + delete mpOptimizerDialog, mpOptimizerDialog = NULL; + } + catch( ... ) + { + + } + } + else if ( rURL.Path.compareToAscii( "statusupdate" ) == 0 ) + { + if ( mpOptimizerDialog ) + mpOptimizerDialog->UpdateStatus( rArguments ); + } + else if ( rURL.Path.compareToAscii( "about" ) == 0 ) + { + AboutDialog aAboutDialog( mxMSF, mxFrame ); + aAboutDialog.execute(); + } + } +} + +//=============================================== +void SAL_CALL PPPOptimizerDialog::addStatusListener( const Reference< XStatusListener >&, const URL& ) + throw( RuntimeException ) +{ + // TODO + // OSL_ENSURE( sal_False, "PPPOptimizerDialog::addStatusListener()\nNot implemented yet!" ); +} + +//=============================================== +void SAL_CALL PPPOptimizerDialog::removeStatusListener( const Reference< XStatusListener >&, const URL& ) + throw( RuntimeException ) +{ + // TODO + // OSL_ENSURE( sal_False, "PPPOptimizerDialog::removeStatusListener()\nNot implemented yet!" ); +} + +// ----------------------------------------------------------------------------- + +OUString PPPOptimizerDialog_getImplementationName() +{ + return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.SunPresentationMinimizerImp" ) ); +} + +Sequence< OUString > PPPOptimizerDialog_getSupportedServiceNames() +{ + Sequence < OUString > aRet(1); + OUString* pArray = aRet.getArray(); + pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) ); + return aRet; +} + +Reference< XInterface > PPPOptimizerDialog_createInstance( const Reference< XComponentContext > & rSMgr) + throw( Exception ) +{ + return (cppu::OWeakObject*) new PPPOptimizerDialog( rSMgr ); +} + +// ----------------------------------------------------------------------------- diff --git a/sdext/source/minimizer/pppoptimizerdialog.hxx b/sdext/source/minimizer/pppoptimizerdialog.hxx new file mode 100644 index 000000000000..455c07772c15 --- /dev/null +++ b/sdext/source/minimizer/pppoptimizerdialog.hxx @@ -0,0 +1,143 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: pppoptimizerdialog.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 13:59:59 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef PPPOPTIMIZERDIALOG_HXX +#define PPPOPTIMIZERDIALOGOG_HXX + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_ +#include <com/sun/star/document/XExporter.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYACCESS_HPP_ +#include <com/sun/star/beans/XPropertyAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_ +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTI_COMPONENT_FACTORY_HPP_ +#include <com/sun/star/lang/XMultiComponentFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include <com/sun/star/lang/XInitialization.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_ +#include <com/sun/star/frame/XController.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_ +#include <com/sun/star/frame/XDispatch.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_ +#include <com/sun/star/frame/XDispatchProvider.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#include <cppuhelper/implbase4.hxx> +#endif + +// ---------------------- +// - PPPOptimizerDialog - +// ---------------------- + +class OptimizerDialog; +class PPPOptimizerDialog : public ::cppu::WeakImplHelper4< + com::sun::star::lang::XInitialization, + com::sun::star::lang::XServiceInfo, + com::sun::star::frame::XDispatchProvider, + com::sun::star::frame::XDispatch > +{ + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxMSF; + com::sun::star::uno::Reference< com::sun::star::frame::XFrame > mxFrame; + com::sun::star::uno::Reference< com::sun::star::frame::XController > mxController; + + OptimizerDialog* mpOptimizerDialog; + +public: + + PPPOptimizerDialog( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxMSF ); + virtual ~PPPOptimizerDialog(); + + // XInitialization + void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) + throw( com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException ); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw( com::sun::star::uno::RuntimeException ); + + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName ) + throw( com::sun::star::uno::RuntimeException ); + + virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() + throw( com::sun::star::uno::RuntimeException ); + + // XDispatchProvider + virtual com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( + const com::sun::star::util::URL& aURL, const rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) + throw(com::sun::star::uno::RuntimeException); + + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( + const com::sun::star::uno::Sequence< com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw( com::sun::star::uno::RuntimeException ); + + // XDispatch + virtual void SAL_CALL dispatch( const com::sun::star::util::URL& aURL, + const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& lArguments ) + throw( com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL addStatusListener( const com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener >& xListener, + const com::sun::star::util::URL& aURL ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeStatusListener( const com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener >& xListener, + const com::sun::star::util::URL& aURL ) + throw( com::sun::star::uno::RuntimeException ); +}; + +rtl::OUString PPPOptimizerDialog_getImplementationName(); +com::sun::star::uno::Sequence< rtl::OUString > PPPOptimizerDialog_getSupportedServiceNames(); +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > PPPOptimizerDialog_createInstance( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & rSMgr ) + throw( com::sun::star::uno::Exception ); + +// ----------------------------------------------------------------------------- + +#endif // PPPOPTIMIZERDIALOG_HXX diff --git a/sdext/source/minimizer/pppoptimizertoken.cxx b/sdext/source/minimizer/pppoptimizertoken.cxx new file mode 100644 index 000000000000..e3cbeae45deb --- /dev/null +++ b/sdext/source/minimizer/pppoptimizertoken.cxx @@ -0,0 +1,346 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: pppoptimizertoken.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 14:00:09 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _PPPOPTIMIZER_TOKEN_HXX +#include "pppoptimizertoken.hxx" +#endif +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif +#include <hash_map> + +struct TCheck +{ + bool operator()( const char* s1, const char* s2 ) const + { + return strcmp( s1, s2 ) == 0; + } +}; +typedef std::hash_map< const char*, PPPOptimizerTokenEnum, std::hash<const char*>, TCheck> TypeNameHashMap; +static TypeNameHashMap* pHashMap = NULL; +static ::osl::Mutex& getHashMapMutex() +{ + static osl::Mutex s_aHashMapProtection; + return s_aHashMapProtection; +} + +struct TokenTable +{ + const char* pS; + PPPOptimizerTokenEnum pE; +}; + +static const TokenTable pTokenTableArray[] = +{ + { "rdmNavi", TK_rdmNavi }, + { "lnNavSep1", TK_lnNavSep1 }, + { "lnNavSep2", TK_lnNavSep2 }, + { "btnNavHelp", TK_btnNavHelp }, + { "btnNavBack", TK_btnNavBack }, + { "btnNavNext", TK_btnNavNext }, + { "btnNavFinish", TK_btnNavFinish }, + { "btnNavCancel", TK_btnNavCancel }, + + { "FixedText0Pg0", TK_FixedText0Pg0 }, + { "FixedText1Pg0", TK_FixedText1Pg0 }, + { "Separator1Pg0", TK_Separator1Pg0 }, + { "FixedText2Pg0", TK_FixedText2Pg0 }, + { "ListBox0Pg0", TK_ListBox0Pg0 }, + { "Button0Pg0", TK_Button0Pg0 }, + { "RadioButton0Pg1", TK_RadioButton0Pg1 }, + { "RadioButton1Pg1", TK_RadioButton1Pg1 }, + { "FixedText0Pg1", TK_FixedText0Pg1 }, + { "CheckBox1Pg1", TK_CheckBox1Pg1 }, + { "FixedText1Pg1", TK_FixedText1Pg1 }, + { "FixedText2Pg1", TK_FixedText2Pg1 }, + { "FormattedField0Pg1", TK_FormattedField0Pg1 }, + { "ComboBox0Pg1", TK_ComboBox0Pg1 }, + { "CheckBox2Pg1", TK_CheckBox2Pg1 }, + { "FixedText0Pg2", TK_FixedText0Pg2 }, + { "FixedText1Pg2", TK_FixedText1Pg2 }, + { "CheckBox0Pg2", TK_CheckBox0Pg2 }, + { "RadioButton0Pg2", TK_RadioButton0Pg2 }, + { "RadioButton1Pg2", TK_RadioButton1Pg2 }, + { "FixedText0Pg3", TK_FixedText0Pg3 }, + { "CheckBox0Pg3", TK_CheckBox0Pg3 }, + { "FixedText1Pg3", TK_FixedText1Pg3 }, + { "CheckBox1Pg3", TK_CheckBox1Pg3 }, + { "FixedText2Pg3", TK_FixedText2Pg3 }, + { "CheckBox2Pg3", TK_CheckBox2Pg3 }, + { "CheckBox3Pg3", TK_CheckBox3Pg3 }, + { "ListBox0Pg3", TK_ListBox0Pg3 }, + { "Separator0Pg4", TK_Separator0Pg4 }, + { "RadioButton0Pg4", TK_RadioButton0Pg4 }, + { "RadioButton1Pg4", TK_RadioButton1Pg4 }, + { "CheckBox0Pg4", TK_CheckBox0Pg4 }, + { "Separator1Pg4", TK_Separator1Pg4 }, + { "FixedText0Pg4", TK_FixedText0Pg4 }, + { "FixedText1Pg4", TK_FixedText1Pg4 }, + { "FixedText2Pg4", TK_FixedText2Pg4 }, + { "FixedText3Pg4", TK_FixedText3Pg4 }, + { "FixedText4Pg4", TK_FixedText4Pg4 }, + { "FixedText5Pg4", TK_FixedText5Pg4 }, + { "FixedText6Pg4", TK_FixedText6Pg4 }, + { "FixedText7Pg4", TK_FixedText7Pg4 }, + { "FixedText8Pg4", TK_FixedText8Pg4 }, + { "CheckBox1Pg4", TK_CheckBox1Pg4 }, + { "ComboBox0Pg4", TK_ComboBox0Pg4 }, + + { "_blank", TK__blank }, + { "_self", TK__self }, + { "Activated", TK_Activated }, + { "Align", TK_Align }, + { "Alpha", TK_Alpha }, + { "Animated", TK_Animated }, + { "Background", TK_Background }, + { "BitmapPath", TK_BitmapPath }, + { "Border", TK_Border }, + { "Closeable", TK_Closeable }, + { "ColorMode", TK_ColorMode }, + { "Complete", TK_Complete }, + { "Compression", TK_Compression }, + { "CurrentItemID", TK_CurrentItemID }, + { "DefaultButton", TK_DefaultButton }, + { "DocumentService", TK_DocumentService }, + { "Dropdown", TK_Dropdown }, + { "EffectiveValue", TK_EffectiveValue }, + { "EffectiveMin", TK_EffectiveMin }, + { "EffectiveMax", TK_EffectiveMax }, + { "Enabled", TK_Enabled }, + { "Extensions", TK_Extensions }, + { "FileSizeDestination",TK_FileSizeDestination }, + { "FileSizeSource", TK_FileSizeSource }, + { "FillBitmap", TK_FillBitmap }, + { "FillBitmapLogicalSize",TK_FillBitmapLogicalSize }, + { "FillBitmapMode", TK_FillBitmapMode }, + { "FillBitmapSizeX", TK_FillBitmapSizeX }, + { "FillBitmapSizeY", TK_FillBitmapSizeY }, + { "FillBitmapURL", TK_FillBitmapURL }, + { "FillStyle", TK_FillStyle }, + { "FilterData", TK_FilterData }, + { "FilterName", TK_FilterName }, + { "Flags", TK_Flags }, + { "FontDescriptor", TK_FontDescriptor }, + { "Graphic", TK_Graphic }, + { "GraphicCrop", TK_GraphicCrop }, + { "GraphicCropLogic", TK_GraphicCropLogic }, + { "GraphicURL", TK_GraphicURL }, + { "GraphicStreamURL", TK_GraphicStreamURL }, + { "Height", TK_Height }, + { "HelpFile", TK_HelpFile }, + { "Hidden", TK_Hidden }, + { "ID", TK_ID }, + { "ImageURL", TK_ImageURL }, + { "InformationDialog", TK_InformationDialog }, + { "InputStream", TK_InputStream }, + { "Interlaced", TK_Interlaced }, + { "IsInternal", TK_IsInternal }, + { "Label", TK_Label }, + { "LineCount", TK_LineCount }, + { "LogicalHeight", TK_LogicalHeight }, + { "LogicalWidth", TK_LogicalWidth }, + { "LogicalSize", TK_LogicalSize }, + { "MimeType", TK_MimeType }, + { "Moveable", TK_Moveable }, + { "MultiLine", TK_MultiLine }, + { "MultiSelection", TK_MultiSelection }, + { "Name", TK_Name }, + { "Orientation", TK_Orientation }, + { "OutputStream", TK_OutputStream }, + { "PixelHeight", TK_PixelHeight }, + { "PixelWidth", TK_PixelWidth }, + { "PositionX", TK_PositionX }, + { "PositionY", TK_PositionY }, + { "Progress", TK_Progress }, + { "ProgressValue", TK_ProgressValue }, + { "ProgressValueMax", TK_ProgressValueMax }, + { "ProgressValueMin", TK_ProgressValueMin }, + { "PushButtonType", TK_PushButtonType }, + { "Quality", TK_Quality }, + { "ReadOnly", TK_ReadOnly }, + { "Repeat", TK_Repeat }, + { "ScaleImage", TK_ScaleImage }, + { "SelectedItems", TK_SelectedItems }, + { "Settings", TK_Settings }, + { "Size100thMM", TK_Size100thMM }, + { "SizePixel", TK_SizePixel }, + { "Spin", TK_Spin }, + { "Step", TK_Step }, + { "State", TK_State }, + { "StatusDispatcher", TK_StatusDispatcher }, + { "StringItemList", TK_StringItemList }, + { "Strings", TK_Strings }, + { "TabIndex", TK_TabIndex }, + { "Template", TK_Template }, + { "Text", TK_Text }, + { "Title", TK_Title }, + { "Transparent", TK_Transparent }, + { "Type", TK_Type }, + { "UIName", TK_UIName }, + { "Value", TK_Value }, + { "Width", TK_Width }, + { "ZOrder", TK_ZOrder }, + + { "LastUsedSettings", TK_LastUsedSettings }, + { "Settings/Templates", TK_Settings_Templates }, + { "Settings/Templates/",TK_Settings_Templates_ }, + { "JPEGCompression", TK_JPEGCompression }, + { "JPEGQuality", TK_JPEGQuality }, + { "RemoveCropArea", TK_RemoveCropArea }, + { "ImageResolution", TK_ImageResolution }, + { "EmbedLinkedGraphics",TK_EmbedLinkedGraphics }, + { "OLEOptimization", TK_OLEOptimization }, + { "OLEOptimizationType",TK_OLEOptimizationType }, + { "DeleteUnusedMasterPages", TK_DeleteUnusedMasterPages }, + { "DeleteHiddenSlides", TK_DeleteHiddenSlides }, + { "DeleteNotesPages", TK_DeleteNotesPages }, + { "CustomShowName", TK_CustomShowName }, + { "SaveAs", TK_SaveAs }, + { "SaveAsURL", TK_SaveAsURL }, + { "OpenNewDocument", TK_OpenNewDocument }, + + { "Status", TK_Status }, + { "Pages", TK_Pages }, + { "CurrentPage", TK_CurrentPage }, + { "GraphicObjects", TK_GraphicObjects }, + { "CurrentGraphicObject",TK_CurrentGraphicObject }, + { "OLEObjects", TK_OLEObjects }, + { "CurrentOLEObject", TK_CurrentOLEObject }, + + { "STR_SUN_OPTIMIZATION_WIZARD",STR_SUN_OPTIMIZATION_WIZARD }, + { "STR_STEPS", STR_STEPS }, + { "STR_HELP", STR_HELP }, + { "STR_BACK", STR_BACK }, + { "STR_NEXT", STR_NEXT }, + { "STR_FINISH", STR_FINISH }, + { "STR_CANCEL", STR_CANCEL }, + { "STR_INTRODUCTION", STR_INTRODUCTION }, + { "STR_INTRODUCTION_T", STR_INTRODUCTION_T }, + { "STR_CHOSE_SETTINGS", STR_CHOSE_SETTINGS }, + { "STR_REMOVE", STR_REMOVE }, + { "STR_GRAPHIC_OPTIMIZATION", STR_GRAPHIC_OPTIMIZATION }, + { "STR_IMAGE_OPTIMIZATION", STR_IMAGE_OPTIMIZATION }, + { "STR_LOSSLESS_COMPRESSION", STR_LOSSLESS_COMPRESSION }, + { "STR_JPEG_COMPRESSION", STR_JPEG_COMPRESSION }, + { "STR_QUALITY", STR_QUALITY }, + { "STR_REMOVE_CROP_AREA", STR_REMOVE_CROP_AREA }, + { "STR_IMAGE_RESOLUTION", STR_IMAGE_RESOLUTION }, + { "STR_IMAGE_RESOLUTION_0", STR_IMAGE_RESOLUTION_0 }, + { "STR_IMAGE_RESOLUTION_1", STR_IMAGE_RESOLUTION_1 }, + { "STR_IMAGE_RESOLUTION_2", STR_IMAGE_RESOLUTION_2 }, + { "STR_IMAGE_RESOLUTION_3", STR_IMAGE_RESOLUTION_3 }, + { "STR_EMBED_LINKED_GRAPHICS", STR_EMBED_LINKED_GRAPHICS }, + { "STR_OLE_OBJECTS", STR_OLE_OBJECTS }, + { "STR_OLE_OPTIMIZATION", STR_OLE_OPTIMIZATION }, + { "STR_OLE_REPLACE", STR_OLE_REPLACE }, + { "STR_ALL_OLE_OBJECTS", STR_ALL_OLE_OBJECTS }, + { "STR_ALIEN_OLE_OBJECTS_ONLY", STR_ALIEN_OLE_OBJECTS_ONLY }, + { "STR_NO_OLE_OBJECTS", STR_NO_OLE_OBJECTS }, + { "STR_SLIDES", STR_SLIDES }, + { "STR_CHOOSE_SLIDES", STR_CHOOSE_SLIDES }, + { "STR_MASTER_PAGES", STR_MASTER_PAGES }, + { "STR_DELETE_MASTER_PAGES", STR_DELETE_MASTER_PAGES }, + { "STR_NOTES_PAGES", STR_NOTES_PAGES }, + { "STR_DELETE_NOTES_PAGES", STR_DELETE_NOTES_PAGES }, + { "STR_DELETE_HIDDEN_SLIDES", STR_DELETE_HIDDEN_SLIDES }, + { "STR_CUSTOM_SHOW", STR_CUSTOM_SHOW }, + { "STR_SUMMARY", STR_SUMMARY }, + { "STR_SUMMARY_TITLE", STR_SUMMARY_TITLE }, + { "STR_PROGRESS", STR_PROGRESS }, + { "STR_OBJECTS_OPTIMIZED", STR_OBJECTS_OPTIMIZED }, + { "STR_APPLY_TO_CURRENT", STR_APPLY_TO_CURRENT }, + { "STR_AUTOMATICALLY_OPEN", STR_AUTOMATICALLY_OPEN }, + { "STR_SAVE_SETTINGS", STR_SAVE_SETTINGS }, + { "STR_SAVE_AS", STR_SAVE_AS }, + { "STR_DELETE_SLIDES", STR_DELETE_SLIDES }, + { "STR_OPTIMIZE_IMAGES", STR_OPTIMIZE_IMAGES }, + { "STR_CREATE_REPLACEMENT", STR_CREATE_REPLACEMENT }, + { "STR_CURRENT_FILESIZE", STR_CURRENT_FILESIZE }, + { "STR_ESTIMATED_FILESIZE", STR_ESTIMATED_FILESIZE }, + { "STR_MB", STR_MB }, + { "MY_SETTINGS", STR_MY_SETTINGS }, + { "STR_DEFAULT_SESSION", STR_DEFAULT_SESSION }, + { "STR_MODIFY_WARNING", STR_MODIFY_WARNING }, + { "STR_YES", STR_YES }, + { "STR_ABOUT", STR_ABOUT }, + { "STR_ABOUT_VERSION", STR_ABOUT_VERSION }, + { "STR_ABOUT_PRN", STR_ABOUT_PRN }, + { "STR_OK", STR_OK }, + { "STR_INFO_1", STR_INFO_1 }, + { "STR_INFO_2", STR_INFO_2 }, + { "STR_DUPLICATING_PRESENTATION",STR_DUPLICATING_PRESENTATION }, + { "STR_DELETING_SLIDES", STR_DELETING_SLIDES }, + { "STR_OPTIMIZING_GRAPHICS", STR_OPTIMIZING_GRAPHICS }, + { "STR_CREATING_OLE_REPLACEMENTS",STR_CREATING_OLE_REPLACEMENTS }, + + { "Last", TK_Last }, + { "NotFound", TK_NotFound } +}; + +PPPOptimizerTokenEnum TKGet( const rtl::OUString& rToken ) +{ + if ( !pHashMap ) + { // init hash map + ::osl::MutexGuard aGuard( getHashMapMutex() ); + if ( !pHashMap ) + { + TypeNameHashMap* pH = new TypeNameHashMap; + const TokenTable* pPtr = pTokenTableArray; + const TokenTable* pEnd = pPtr + ( sizeof( pTokenTableArray ) / sizeof( TokenTable ) ); + for ( ; pPtr < pEnd; pPtr++ ) + (*pH)[ pPtr->pS ] = pPtr->pE; + pHashMap = pH; + } + } + PPPOptimizerTokenEnum eRetValue = TK_NotFound; + int i, nLen = rToken.getLength(); + char* pBuf = new char[ nLen + 1 ]; + for ( i = 0; i < nLen; i++ ) + pBuf[ i ] = (char)rToken[ i ]; + pBuf[ i ] = 0; + TypeNameHashMap::iterator aHashIter( pHashMap->find( pBuf ) ); + delete[] pBuf; + if ( aHashIter != pHashMap->end() ) + eRetValue = (*aHashIter).second; + return eRetValue; +} + +rtl::OUString TKGet( const PPPOptimizerTokenEnum eToken ) +{ + sal_uInt32 i = eToken >= TK_Last + ? (sal_uInt32)TK_NotFound + : (sal_uInt32)eToken; + return rtl::OUString::createFromAscii( pTokenTableArray[ i ].pS ); +} diff --git a/sdext/source/minimizer/pppoptimizertoken.hxx b/sdext/source/minimizer/pppoptimizertoken.hxx new file mode 100644 index 000000000000..7274389db790 --- /dev/null +++ b/sdext/source/minimizer/pppoptimizertoken.hxx @@ -0,0 +1,291 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: pppoptimizertoken.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 14:00:23 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _PPPOPTIMIZER_TOKEN_HXX +#define _PPPOPTIMIZER_TOKEN_HXX + +#include <rtl/ustring.hxx> + +enum PPPOptimizerTokenEnum +{ + TK_rdmNavi, + TK_lnNavSep1, + TK_lnNavSep2, + TK_btnNavHelp, + TK_btnNavBack, + TK_btnNavNext, + TK_btnNavFinish, + TK_btnNavCancel, + + TK_FixedText0Pg0, + TK_FixedText1Pg0, + TK_Separator1Pg0, + TK_FixedText2Pg0, + TK_ListBox0Pg0, + TK_Button0Pg0, + TK_RadioButton0Pg1, + TK_RadioButton1Pg1, + TK_FixedText0Pg1, + TK_CheckBox1Pg1, + TK_FixedText1Pg1, + TK_FixedText2Pg1, + TK_FormattedField0Pg1, + TK_ComboBox0Pg1, + TK_CheckBox2Pg1, + TK_FixedText0Pg2, + TK_FixedText1Pg2, + TK_CheckBox0Pg2, + TK_RadioButton0Pg2, + TK_RadioButton1Pg2, + TK_FixedText0Pg3, + TK_CheckBox0Pg3, + TK_FixedText1Pg3, + TK_CheckBox1Pg3, + TK_FixedText2Pg3, + TK_CheckBox2Pg3, + TK_CheckBox3Pg3, + TK_ListBox0Pg3, + TK_Separator0Pg4, + TK_RadioButton0Pg4, + TK_RadioButton1Pg4, + TK_CheckBox0Pg4, + TK_Separator1Pg4, + TK_FixedText0Pg4, + TK_FixedText1Pg4, + TK_FixedText2Pg4, + TK_FixedText3Pg4, + TK_FixedText4Pg4, + TK_FixedText5Pg4, + TK_FixedText6Pg4, + TK_FixedText7Pg4, + TK_FixedText8Pg4, + TK_CheckBox1Pg4, + TK_ComboBox0Pg4, + + TK__blank, + TK__self, + TK_Activated, + TK_Align, + TK_Alpha, + TK_Animated, + TK_Background, + TK_BitmapPath, + TK_Border, + TK_Closeable, + TK_ColorMode, + TK_Complete, + TK_Compression, + TK_CurrentItemID, + TK_DefaultButton, + TK_DocumentService, + TK_Dropdown, + TK_EffectiveValue, + TK_EffectiveMin, + TK_EffectiveMax, + TK_Enabled, + TK_Extensions, + TK_FileSizeDestination, + TK_FileSizeSource, + TK_FillBitmap, + TK_FillBitmapLogicalSize, + TK_FillBitmapMode, + TK_FillBitmapSizeX, + TK_FillBitmapSizeY, + TK_FillBitmapURL, + TK_FillStyle, + TK_FilterData, + TK_FilterName, + TK_Flags, + TK_FontDescriptor, + TK_Graphic, + TK_GraphicCrop, + TK_GraphicCropLogic, + TK_GraphicURL, + TK_GraphicStreamURL, + TK_Height, + TK_HelpFile, + TK_Hidden, + TK_ID, + TK_ImageURL, + TK_InformationDialog, + TK_InputStream, + TK_Interlaced, + TK_IsInternal, + TK_Label, + TK_LineCount, + TK_LogicalHeight, + TK_LogicalWidth, + TK_LogicalSize, + TK_MimeType, + TK_Moveable, + TK_MultiLine, + TK_MultiSelection, + TK_Name, + TK_Orientation, + TK_OutputStream, + TK_PixelHeight, + TK_PixelWidth, + TK_PositionX, + TK_PositionY, + TK_Progress, + TK_ProgressValue, + TK_ProgressValueMax, + TK_ProgressValueMin, + TK_PushButtonType, + TK_Quality, + TK_ReadOnly, + TK_Repeat, + TK_ScaleImage, + TK_SelectedItems, + TK_Settings, + TK_Size100thMM, + TK_SizePixel, + TK_Spin, + TK_Step, + TK_State, + TK_StatusDispatcher, + TK_StringItemList, + TK_Strings, + TK_TabIndex, + TK_Template, + TK_Text, + TK_Title, + TK_Transparent, + TK_Type, + TK_UIName, + TK_Value, + TK_Width, + TK_ZOrder, + + TK_LastUsedSettings, + TK_Settings_Templates, + TK_Settings_Templates_, + TK_JPEGCompression, + TK_JPEGQuality, + TK_RemoveCropArea, + TK_ImageResolution, + TK_EmbedLinkedGraphics, + TK_OLEOptimization, + TK_OLEOptimizationType, + TK_DeleteUnusedMasterPages, + TK_DeleteHiddenSlides, + TK_DeleteNotesPages, + TK_CustomShowName, + TK_SaveAs, + TK_SaveAsURL, + TK_OpenNewDocument, + + TK_Status, + TK_Pages, + TK_CurrentPage, + TK_GraphicObjects, + TK_CurrentGraphicObject, + TK_OLEObjects, + TK_CurrentOLEObject, + + STR_SUN_OPTIMIZATION_WIZARD, + STR_STEPS, + STR_HELP, + STR_BACK, + STR_NEXT, + STR_FINISH, + STR_CANCEL, + STR_INTRODUCTION, + STR_INTRODUCTION_T, + STR_CHOSE_SETTINGS, + STR_REMOVE, + STR_GRAPHIC_OPTIMIZATION, + STR_IMAGE_OPTIMIZATION, + STR_LOSSLESS_COMPRESSION, + STR_JPEG_COMPRESSION, + STR_QUALITY, + STR_REMOVE_CROP_AREA, + STR_IMAGE_RESOLUTION, + STR_IMAGE_RESOLUTION_0, + STR_IMAGE_RESOLUTION_1, + STR_IMAGE_RESOLUTION_2, + STR_IMAGE_RESOLUTION_3, + STR_EMBED_LINKED_GRAPHICS, + STR_OLE_OBJECTS, + STR_OLE_OPTIMIZATION, + STR_OLE_REPLACE, + STR_ALL_OLE_OBJECTS, + STR_ALIEN_OLE_OBJECTS_ONLY, + STR_NO_OLE_OBJECTS, + STR_SLIDES, + STR_CHOOSE_SLIDES, + STR_MASTER_PAGES, + STR_DELETE_MASTER_PAGES, + STR_NOTES_PAGES, + STR_DELETE_NOTES_PAGES, + STR_DELETE_HIDDEN_SLIDES, + STR_CUSTOM_SHOW, + STR_SUMMARY, + STR_SUMMARY_TITLE, + STR_PROGRESS, + STR_OBJECTS_OPTIMIZED, + STR_APPLY_TO_CURRENT, + STR_AUTOMATICALLY_OPEN, + STR_SAVE_SETTINGS, + STR_SAVE_AS, + STR_DELETE_SLIDES, + STR_OPTIMIZE_IMAGES, + STR_CREATE_REPLACEMENT, + STR_CURRENT_FILESIZE, + STR_ESTIMATED_FILESIZE, + STR_MB, + STR_MY_SETTINGS, + STR_DEFAULT_SESSION, + STR_MODIFY_WARNING, + STR_YES, + STR_ABOUT, + STR_ABOUT_VERSION, + STR_ABOUT_PRN, + STR_OK, + STR_INFO_1, + STR_INFO_2, + STR_DUPLICATING_PRESENTATION, + STR_DELETING_SLIDES, + STR_OPTIMIZING_GRAPHICS, + STR_CREATING_OLE_REPLACEMENTS, + + TK_Last, + TK_NotFound +}; + +PPPOptimizerTokenEnum TKGet( const rtl::OUString& ); +rtl::OUString TKGet( const PPPOptimizerTokenEnum ); + +#endif diff --git a/sdext/source/minimizer/pppoptimizeruno.cxx b/sdext/source/minimizer/pppoptimizeruno.cxx new file mode 100644 index 000000000000..b594fbd46a3d --- /dev/null +++ b/sdext/source/minimizer/pppoptimizeruno.cxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: pppoptimizeruno.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 14:00:33 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#include <stdio.h> +#include <osl/mutex.hxx> +#include <osl/thread.h> +#include <cppuhelper/factory.hxx> +#include <pppoptimizer.hxx> +#include <pppoptimizerdialog.hxx> + +using namespace ::rtl; +using namespace ::cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; + +extern "C" +{ + void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** ) + { + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; + } + + // ------------------------------------------------------------------------- + + sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey ) + { + if (pRegistryKey) + { + try + { + Reference< XRegistryKey > xNewKey; + sal_Int32 nPos; + + xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( PPPOptimizer_getImplementationName() ); + xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) ); + const Sequence< OUString > & rSNL1 = PPPOptimizer_getSupportedServiceNames(); + const OUString * pArray1 = rSNL1.getConstArray(); + for ( nPos = rSNL1.getLength(); nPos--; ) + xNewKey->createKey( pArray1[nPos] ); + + xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( PPPOptimizerDialog_getImplementationName() ); + xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) ); + const Sequence< OUString > & rSNL2 = PPPOptimizerDialog_getSupportedServiceNames(); + const OUString * pArray2 = rSNL2.getConstArray(); + for ( nPos = rSNL2.getLength(); nPos--; ) + xNewKey->createKey( pArray2[nPos] ); + + return sal_True; + } + catch (InvalidRegistryException &) + { + OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); + } + } + return sal_False; + } + + // ------------------------------------------------------------------------- + + void* SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) + { + OUString aImplName( OUString::createFromAscii( pImplName ) ); + void* pRet = 0; + + if( pServiceManager ) + { + Reference< XSingleComponentFactory > xFactory; + if( aImplName.equals( PPPOptimizer_getImplementationName() ) ) + { + xFactory = createSingleComponentFactory( + PPPOptimizer_createInstance, + OUString::createFromAscii( pImplName ), + PPPOptimizer_getSupportedServiceNames() ); + + } + else if( aImplName.equals( PPPOptimizerDialog_getImplementationName() ) ) + { + xFactory = createSingleComponentFactory( + PPPOptimizerDialog_createInstance, + OUString::createFromAscii( pImplName ), + PPPOptimizerDialog_getSupportedServiceNames() ); + } + if( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + return pRet; + } +} diff --git a/sdext/source/minimizer/unodialog.cxx b/sdext/source/minimizer/unodialog.cxx new file mode 100644 index 000000000000..166858d55443 --- /dev/null +++ b/sdext/source/minimizer/unodialog.cxx @@ -0,0 +1,448 @@ + /************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unodialog.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 14:01:14 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#include "unodialog.hxx" +#ifndef _COM_SUN_STAR_TEXT_XTEXTRANGE_HPP_ +#include <com/sun/star/text/XTextRange.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XSHAPES_HPP_ +#include <com/sun/star/drawing/XShapes.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_ +#include <com/sun/star/view/XSelectionSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_VIEW_XCONTROLACCESS_HPP_ +#include <com/sun/star/view/XControlAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_ +#include <com/sun/star/frame/XDispatch.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XMESSAGEBOXFACTORY_HPP_ +#include <com/sun/star/awt/XMessageBoxFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_MESSAGEBOXBUTTONS_HPP_ +#include <com/sun/star/awt/MessageBoxButtons.hpp> +#endif + +// ------------- +// - UnoDialog - +// ------------- + +using namespace ::rtl; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::view; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::script; + +UnoDialog::UnoDialog( const Reference< XComponentContext > &rxMSF, Reference< XFrame >& rxFrame ) : + mxMSF( rxMSF ), + mxController( rxFrame->getController() ), + mxDialogModel( mxMSF->getServiceManager()->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.awt.UnoControlDialogModel" ) ), mxMSF ), UNO_QUERY_THROW ), + mxDialogModelMultiPropertySet( mxDialogModel, UNO_QUERY_THROW ), + mxDialogModelPropertySet( mxDialogModel, UNO_QUERY_THROW ), + mxDialogModelMSF( mxDialogModel, UNO_QUERY_THROW ), + mxDialogModelNameContainer( mxDialogModel, UNO_QUERY_THROW ), + mxDialogModelNameAccess( mxDialogModel, UNO_QUERY_THROW ), + mxControlModel( mxDialogModel, UNO_QUERY_THROW ), + mxDialog( mxMSF->getServiceManager()->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.awt.UnoControlDialog" ) ), mxMSF ), UNO_QUERY_THROW ), + mxControl( mxDialog, UNO_QUERY_THROW ), + mbStatus( sal_False ) +{ + mxControl->setModel( mxControlModel ); + mxDialogControlContainer = Reference< XControlContainer >( mxDialog, UNO_QUERY_THROW ); + mxDialogComponent = Reference< XComponent >( mxDialog, UNO_QUERY_THROW ); + mxDialogWindow = Reference< XWindow >( mxDialog, UNO_QUERY_THROW ); + + Reference< XFrame > xFrame( mxController->getFrame() ); + Reference< XWindow > xContainerWindow( xFrame->getContainerWindow() ); + mxWindowPeer = Reference< XWindowPeer >( xContainerWindow, UNO_QUERY_THROW ); + createWindowPeer( mxWindowPeer ); +} + +// ----------------------------------------------------------------------------- + +UnoDialog::~UnoDialog() +{ + +} + +// ----------------------------------------------------------------------------- + +void UnoDialog::execute() +{ + mxDialogWindow->setEnable( sal_True ); + mxDialogWindow->setVisible( sal_True ); + mxDialog->execute(); +} + +void UnoDialog::endExecute( sal_Bool bStatus ) +{ + mbStatus = bStatus; + mxDialog->endExecute(); +} + +// ----------------------------------------------------------------------------- + +Reference< XWindowPeer > UnoDialog::createWindowPeer( Reference< XWindowPeer > xParentPeer ) + throw ( Exception ) +{ + mxDialogWindow->setVisible( sal_False ); + Reference< XToolkit > xToolkit( mxMSF->getServiceManager()->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" ) ), mxMSF ), UNO_QUERY_THROW ); + if ( !xParentPeer.is() ) + xParentPeer = xToolkit->getDesktopWindow(); + mxReschedule = Reference< XReschedule >( xToolkit, UNO_QUERY ); + mxControl->createPeer( xToolkit, xParentPeer ); +// xWindowPeer = xControl.getPeer(); + return mxControl->getPeer(); +} + +// ----------------------------------------------------------------------------- + +Reference< XInterface > UnoDialog::insertControlModel( const OUString& rServiceName, const OUString& rName, + const Sequence< OUString >& rPropertyNames, const Sequence< Any >& rPropertyValues ) +{ + Reference< XInterface > xControlModel; + try + { + xControlModel = mxDialogModelMSF->createInstance( rServiceName ); + Reference< XMultiPropertySet > xMultiPropSet( xControlModel, UNO_QUERY_THROW ); + xMultiPropSet->setPropertyValues( rPropertyNames, rPropertyValues ); + mxDialogModelNameContainer->insertByName( rName, Any( xControlModel ) ); + } + catch( Exception& ) + { + } + return xControlModel; +} + +// ----------------------------------------------------------------------------- + +void UnoDialog::setVisible( const OUString& rName, sal_Bool bVisible ) +{ + try + { + Reference< XInterface > xControl( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW ); + Reference< XWindow > xWindow( xControl, UNO_QUERY_THROW ); + xWindow->setVisible( bVisible ); + } + catch ( Exception& ) + { + } +} + +// ----------------------------------------------------------------------------- + +sal_Bool UnoDialog::isHighContrast() +{ + sal_Bool bHighContrast = sal_False; + try + { + sal_Int32 nBackgroundColor; + if ( mxDialogModelPropertySet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "BackgroundColor" ) ) ) >>= nBackgroundColor ) + { + sal_uInt8 nLum( static_cast< sal_uInt8 >( ( static_cast< sal_uInt8 >( nBackgroundColor >> 16 ) * 28 + + static_cast< sal_uInt8 >( nBackgroundColor >> 8 ) * 151 + + static_cast< sal_uInt8 >( nBackgroundColor ) * 77 ) >> 8 ) ); + bHighContrast = nLum <= 38; + } + } + catch( Exception& ) + { + } + return bHighContrast; +} + +// ----------------------------------------------------------------------------- + +Reference< XButton > UnoDialog::insertButton( const OUString& rName, Reference< XActionListener > xActionListener, + const Sequence< OUString >& rPropertyNames, const Sequence< Any >& rPropertyValues ) +{ + Reference< XButton > xButton; + try + { + Reference< XInterface > xButtonModel( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ), + rName, rPropertyNames, rPropertyValues ) ); + Reference< XPropertySet > xPropertySet( xButtonModel, UNO_QUERY_THROW ); + xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) ); + xButton = Reference< XButton >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW ); + + if ( xActionListener.is() ) + { + xButton->addActionListener( xActionListener ); + xButton->setActionCommand( rName ); + } + return xButton; + } + catch( Exception& ) + { + } + return xButton; +} + +// ----------------------------------------------------------------------------- + +Reference< XFixedText > UnoDialog::insertFixedText( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues ) +{ + Reference< XFixedText > xFixedText; + try + { + Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" ) ), + rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW ); + xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) ); + xFixedText = Reference< XFixedText >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW ); + } + catch ( Exception& ) + { + } + return xFixedText; +} + +// ----------------------------------------------------------------------------- + +Reference< XCheckBox > UnoDialog::insertCheckBox( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues ) +{ + Reference< XCheckBox > xCheckBox; + try + { + Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" ) ), + rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW ); + xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) ); + xCheckBox = Reference< XCheckBox >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW ); + } + catch ( Exception& ) + { + } + return xCheckBox; +} + +// ----------------------------------------------------------------------------- + +Reference< XControl > UnoDialog::insertFormattedField( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues ) +{ + Reference< XControl > xControl; + try + { + Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFormattedFieldModel" ) ), + rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW ); + xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) ); + xControl = Reference< XControl >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW ); + } + catch ( Exception& ) + { + } + return xControl; +} + +// ----------------------------------------------------------------------------- + +Reference< XComboBox > UnoDialog::insertComboBox( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues ) +{ + Reference< XComboBox > xControl; + try + { + Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" ) ), + rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW ); + xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) ); + xControl = Reference< XComboBox >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW ); + } + catch ( Exception& ) + { + } + return xControl; +} + +// ----------------------------------------------------------------------------- + +Reference< XRadioButton > UnoDialog::insertRadioButton( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues ) +{ + Reference< XRadioButton > xControl; + try + { + Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" ) ), + rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW ); + xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) ); + xControl = Reference< XRadioButton >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW ); + } + catch ( Exception& ) + { + } + return xControl; +} + +// ----------------------------------------------------------------------------- + +Reference< XListBox > UnoDialog::insertListBox( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues ) +{ + Reference< XListBox > xControl; + try + { + Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" ) ), + rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW ); + xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) ); + xControl = Reference< XListBox >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW ); + } + catch ( Exception& ) + { + } + return xControl; +} + +// ----------------------------------------------------------------------------- + +Reference< XControl > UnoDialog::insertImage( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues ) +{ + Reference< XControl > xControl; + try + { + Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" ) ), + rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW ); + xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) ); + xControl = Reference< XControl >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW ); + } + catch ( Exception& ) + { + } + return xControl; +} + +// ----------------------------------------------------------------------------- + +void UnoDialog::setControlProperty( const OUString& rControlName, const OUString& rPropertyName, const Any& rPropertyValue ) +{ + try + { + if ( mxDialogModelNameAccess->hasByName( rControlName ) ) + { + Reference< XPropertySet > xPropertySet( mxDialogModelNameAccess->getByName( rControlName ), UNO_QUERY_THROW ); + xPropertySet->setPropertyValue( rPropertyName, rPropertyValue ); + } + } + catch ( Exception& ) + { + } +} + +// ----------------------------------------------------------------------------- + +void UnoDialog::showMessageBox( const OUString& rTitle, const OUString& rMessage, sal_Bool bErrorBox ) const +{ + try + { + Reference< XMessageBoxFactory > xMessageBoxFactory( mxMSF->getServiceManager()->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" ) ), mxMSF ), UNO_QUERY_THROW ); + if ( xMessageBoxFactory.is() ) + { + Rectangle aRectangle( 0, 0, 0, 0 ); + Reference< XMessageBox > xMessageBox( xMessageBoxFactory->createMessageBox( mxWindowPeer, aRectangle, + bErrorBox ? OUString( RTL_CONSTASCII_USTRINGPARAM( "errorbox" ) ) : OUString( RTL_CONSTASCII_USTRINGPARAM( "querybox" ) ), MessageBoxButtons::BUTTONS_OK, rTitle, rMessage ) ); + Reference< XComponent > xComponent( xMessageBox, UNO_QUERY_THROW ); + /* sal_Int16 nResult = */ xMessageBox->execute(); + xComponent->dispose(); + } + } + catch ( Exception& ) + { + } + +/* +public void showErrorMessageBox(XWindowPeer _xParentWindowPeer, String _sTitle, String _sMessage){ +XComponent xComponent = null; +try { + Object oToolkit = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext); + XMessageBoxFactory xMessageBoxFactory = (XMessageBoxFactory) UnoRuntime.queryInterface(XMessageBoxFactory.class, oToolkit); + // rectangle may be empty if position is in the center of the parent peer + + Rectangle aRectangle = new Rectangle(); + XMessageBox xMessageBox = xMessageBoxFactory.createMessageBox(_xParentWindowPeer, aRectangle, "errorbox", com.sun.star.awt.MessageBoxButtons.BUTTONS_OK, _sTitle, _sMessage); + xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xMessageBox); + if (xMessageBox != null){ + short nResult = xMessageBox.execute(); + } +} catch (com.sun.star.uno.Exception ex) { + ex.printStackTrace(System.out); +} +finally{ + //make sure always to dispose the component and free the memory! + if (xComponent != null){ + xComponent.dispose(); + } +}} +*/ +} + +// ----------------------------------------------------------------------------- + +Any UnoDialog::getControlProperty( const OUString& rControlName, const OUString& rPropertyName ) +{ + Any aRet; + try + { + if ( mxDialogModelNameAccess->hasByName( rControlName ) ) + { + Reference< XPropertySet > xPropertySet( mxDialogModelNameAccess->getByName( rControlName ), UNO_QUERY_THROW ); + aRet = xPropertySet->getPropertyValue( rPropertyName ); + } + } + catch ( Exception& ) + { + } + return aRet; +} + +// ----------------------------------------------------------------------------- + +void UnoDialog::enableControl( const OUString& rControlName ) +{ + const OUString sEnabled( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) ); + setControlProperty( rControlName, sEnabled, Any( sal_True ) ); +} + +// ----------------------------------------------------------------------------- + +void UnoDialog::disableControl( const OUString& rControlName ) +{ + const OUString sEnabled( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) ); + setControlProperty( rControlName, sEnabled, Any( sal_False ) ); +} + +// ----------------------------------------------------------------------------- diff --git a/sdext/source/minimizer/unodialog.hxx b/sdext/source/minimizer/unodialog.hxx new file mode 100644 index 000000000000..ee56406f2056 --- /dev/null +++ b/sdext/source/minimizer/unodialog.hxx @@ -0,0 +1,213 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unodialog.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sj $ $Date: 2007-05-11 14:01:25 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef UNODIALOG_HXX +#define UNODIALOG_HXX + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTI_COMPONENT_FACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_ +#include <com/sun/star/container/XIndexContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_ +#include <com/sun/star/frame/XController.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ +#include <com/sun/star/frame/XFrame.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XINVOCATION_HPP_ +#include <com/sun/star/script/XInvocation.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XMULTIPROPERTYSET_HPP_ +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROL_HPP_ +#include <com/sun/star/awt/XControl.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROLMODEL_HPP_ +#include <com/sun/star/awt/XControlModel.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include <com/sun/star/uno/XComponentContext.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XACTIONLISTENER_HPP_ +#include <com/sun/star/awt/XActionListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XTEXTLISTENER_HPP_ +#include <com/sun/star/awt/XTextListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XBUTTON_HPP_ +#include <com/sun/star/awt/XButton.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCHECKBOX_HPP_ +#include <com/sun/star/awt/XCheckBox.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCOMBOBOX_HPP_ +#include <com/sun/star/awt/XComboBox.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XTEXTCOMPONENT_HPP_ +#include <com/sun/star/awt/XTextComponent.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XRADIOBUTTON_HPP_ +#include <com/sun/star/awt/XRadioButton.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XLISTBOX_HPP_ +#include <com/sun/star/awt/XListBox.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XFIXEDTEXT_HPP_ +#include <com/sun/star/awt/XFixedText.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROLCONTAINER_HPP_ +#include <com/sun/star/awt/XControlContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XRESCHEDULE_HPP_ +#include <com/sun/star/awt/XReschedule.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XDIALOG_HPP_ +#include <com/sun/star/awt/XDialog.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_SIZE_HPP_ +#include <com/sun/star/awt/Size.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include <cppuhelper/implbase3.hxx> +#endif + +// ------------- +// - UnoDialog - +// ------------- + +//////////////////////////////////////////////////////////////////////// + +class UnoDialog +{ +public : + + UnoDialog( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxMSF, com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rxFrame ); + ~UnoDialog(); + + void execute(); + void endExecute( sal_Bool bStatus ); + + com::sun::star::uno::Reference< com::sun::star::awt::XWindowPeer > createWindowPeer( com::sun::star::uno::Reference< com::sun::star::awt::XWindowPeer > xParentPeer ) + throw ( com::sun::star::uno::Exception ); + + com::sun::star::uno::Reference< com::sun::star::uno::XInterface > insertControlModel( const rtl::OUString& rServiceName, const rtl::OUString& rName, + const com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames, const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& rPropertyValues ); + + void setVisible( const rtl::OUString& rName, sal_Bool bVisible ); + + sal_Bool isHighContrast(); + + com::sun::star::uno::Reference< com::sun::star::awt::XButton > insertButton( const rtl::OUString& rName, + com::sun::star::uno::Reference< com::sun::star::awt::XActionListener > xActionListener, const com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames, + const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& rPropertyValues ); + + com::sun::star::uno::Reference< com::sun::star::awt::XFixedText > insertFixedText( const rtl::OUString& rName, + const com::sun::star::uno::Sequence< rtl::OUString > rPropertyNames, const com::sun::star::uno::Sequence< com::sun::star::uno::Any > rPropertyValues ); + + com::sun::star::uno::Reference< com::sun::star::awt::XCheckBox > insertCheckBox( const rtl::OUString& rName, + const com::sun::star::uno::Sequence< rtl::OUString > rPropertyNames, const com::sun::star::uno::Sequence< com::sun::star::uno::Any > rPropertyValues ); + + com::sun::star::uno::Reference< com::sun::star::awt::XControl > insertFormattedField( const rtl::OUString& rName, + const com::sun::star::uno::Sequence< rtl::OUString > rPropertyNames, const com::sun::star::uno::Sequence< com::sun::star::uno::Any > rPropertyValues ); + + com::sun::star::uno::Reference< com::sun::star::awt::XComboBox > insertComboBox( const rtl::OUString& rName, + const com::sun::star::uno::Sequence< rtl::OUString > rPropertyNames, const com::sun::star::uno::Sequence< com::sun::star::uno::Any > rPropertyValues ); + + com::sun::star::uno::Reference< com::sun::star::awt::XRadioButton > insertRadioButton( const rtl::OUString& rName, + const com::sun::star::uno::Sequence< rtl::OUString > rPropertyNames, const com::sun::star::uno::Sequence< com::sun::star::uno::Any > rPropertyValues ); + + com::sun::star::uno::Reference< com::sun::star::awt::XListBox > insertListBox( const rtl::OUString& rName, + const com::sun::star::uno::Sequence< rtl::OUString > rPropertyNames, const com::sun::star::uno::Sequence< com::sun::star::uno::Any > rPropertyValues ); + + com::sun::star::uno::Reference< com::sun::star::awt::XControl > insertImage( const rtl::OUString& rName, + const com::sun::star::uno::Sequence< rtl::OUString > rPropertyNames, const com::sun::star::uno::Sequence< com::sun::star::uno::Any > rPropertyValues ); + + void setControlProperty( const rtl::OUString& rControlName, const rtl::OUString& rPropertyName, const com::sun::star::uno::Any& rPropertyValue ); + com::sun::star::uno::Any getControlProperty( const rtl::OUString& rControlName, const rtl::OUString& rPropertyName ); + + void showMessageBox( const rtl::OUString& rTitle, const rtl::OUString& rMessage, sal_Bool bErrorBox ) const; + + void enableControl( const rtl::OUString& rControlName ); + void disableControl( const rtl::OUString& rControlName ); + + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxMSF; + com::sun::star::uno::Reference< com::sun::star::frame::XController > mxController; + com::sun::star::uno::Reference< com::sun::star::awt::XReschedule > mxReschedule; + + com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxDialogModel; + com::sun::star::uno::Reference< com::sun::star::beans::XMultiPropertySet > mxDialogModelMultiPropertySet; + com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > mxDialogModelPropertySet; + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxDialogModelMSF; + com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > mxDialogModelNameContainer; + com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > mxDialogModelNameAccess; + + com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > mxControlModel; + + com::sun::star::uno::Reference< com::sun::star::awt::XDialog > mxDialog; + com::sun::star::uno::Reference< com::sun::star::awt::XControl > mxControl; + com::sun::star::uno::Reference< com::sun::star::awt::XWindowPeer > mxWindowPeer; + + com::sun::star::uno::Reference< com::sun::star::awt::XControlContainer > mxDialogControlContainer; + com::sun::star::uno::Reference< com::sun::star::lang::XComponent > mxDialogComponent; + com::sun::star::uno::Reference< com::sun::star::awt::XWindow > mxDialogWindow; + + sal_Bool mbStatus; +}; + +#endif // UNODIALOG_HXX |