summaryrefslogtreecommitdiff
path: root/sdext/source/minimizer
diff options
context:
space:
mode:
Diffstat (limited to 'sdext/source/minimizer')
-rw-r--r--sdext/source/minimizer/basic.txt89
-rw-r--r--sdext/source/minimizer/configurationaccess.cxx541
-rw-r--r--sdext/source/minimizer/configurationaccess.hxx141
-rw-r--r--sdext/source/minimizer/delzip1
-rw-r--r--sdext/source/minimizer/description.xml30
-rw-r--r--sdext/source/minimizer/fileopendialog.cxx210
-rw-r--r--sdext/source/minimizer/fileopendialog.hxx74
-rw-r--r--sdext/source/minimizer/graphiccollector.cxx462
-rw-r--r--sdext/source/minimizer/graphiccollector.hxx108
-rwxr-xr-xsdext/source/minimizer/help/component.txt2
-rw-r--r--sdext/source/minimizer/help/help_de.odtbin0 -> 8987 bytes
-rw-r--r--sdext/source/minimizer/help/help_en-US.odtbin0 -> 8987 bytes
-rw-r--r--sdext/source/minimizer/impoptimizer.cxx770
-rw-r--r--sdext/source/minimizer/impoptimizer.hxx88
-rw-r--r--sdext/source/minimizer/informationdialog.cxx413
-rw-r--r--sdext/source/minimizer/informationdialog.hxx102
-rw-r--r--sdext/source/minimizer/makefile.mk148
-rw-r--r--sdext/source/minimizer/manifest.xml16
-rw-r--r--sdext/source/minimizer/minimizer.pmk28
-rw-r--r--sdext/source/minimizer/optimizationstats.cxx105
-rw-r--r--sdext/source/minimizer/optimizationstats.hxx66
-rw-r--r--sdext/source/minimizer/optimizerdialog.cxx840
-rw-r--r--sdext/source/minimizer/optimizerdialog.hrc36
-rw-r--r--sdext/source/minimizer/optimizerdialog.hxx248
-rw-r--r--sdext/source/minimizer/optimizerdialogcontrols.cxx962
-rw-r--r--sdext/source/minimizer/pagecollector.cxx182
-rw-r--r--sdext/source/minimizer/pagecollector.hxx52
-rw-r--r--sdext/source/minimizer/pppoptimizer.cxx212
-rw-r--r--sdext/source/minimizer/pppoptimizer.hxx103
-rw-r--r--sdext/source/minimizer/pppoptimizerdialog.cxx218
-rw-r--r--sdext/source/minimizer/pppoptimizerdialog.hxx112
-rw-r--r--sdext/source/minimizer/pppoptimizertoken.cxx349
-rw-r--r--sdext/source/minimizer/pppoptimizertoken.hxx286
-rw-r--r--sdext/source/minimizer/pppoptimizeruno.cxx123
-rw-r--r--sdext/source/minimizer/registry/data/org/openoffice/Office/Addons.xcu65
-rw-r--r--sdext/source/minimizer/registry/data/org/openoffice/Office/ProtocolHandler.xcu10
-rw-r--r--sdext/source/minimizer/registry/data/org/openoffice/Office/extension/SunPresentationMinimizer.xcu383
-rw-r--r--sdext/source/minimizer/registry/data/org/openoffice/Office/extension/makefile.mk50
-rw-r--r--sdext/source/minimizer/registry/data/org/openoffice/Office/makefile.mk48
-rw-r--r--sdext/source/minimizer/registry/schema/org/openoffice/Office/extension/SunPresentationMinimizer.xcs326
-rw-r--r--sdext/source/minimizer/unodialog.cxx406
-rw-r--r--sdext/source/minimizer/unodialog.hxx148
42 files changed, 8553 insertions, 0 deletions
diff --git a/sdext/source/minimizer/basic.txt b/sdext/source/minimizer/basic.txt
new file mode 100644
index 000000000000..3a540aea5730
--- /dev/null
+++ b/sdext/source/minimizer/basic.txt
@@ -0,0 +1,89 @@
+Sub Main
+
+Dim oSettings(11) as new com.sun.star.beans.PropertyValue
+oSettings(0).Name = "JPEGCompression"
+oSettings(0).Value= True
+oSettings(1).Name = "JPEGQuality"
+oSettings(1).Value= 25
+oSettings(2).Name = "RemoveCropArea"
+oSettings(2).Value= True
+oSettings(3).Name = "ImageResolution"
+oSettings(3).Value= 90
+oSettings(4).Name = "OLEOptimization"
+oSettings(4).Value= False
+oSettings(5).Name = "OLEOptimizationType"
+oSettings(5).Value= 1
+oSettings(6).Name = "DeleteUnusedMasterPages"
+oSettings(6).Value= True
+oSettings(7).Name = "DeleteHiddenSlides"
+oSettings(7).Value= True
+oSettings(8).Name = "DeleteNotesPages"
+oSettings(8).Value= True
+oSettings(9).Name = "SaveAs"
+oSettings(9).Value= true
+oSettings(10).Name = "EmbedLinkedGraphics"
+oSettings(10).Value = false
+oSettings(11).Name = "SaveAsURL"
+oSettings(11).Value = ""
+oSettings(12).Name = "FilterName"
+oSettings(12).Value = "impress8"
+
+
+
+Dim oArg(0) as new com.sun.star.beans.PropertyValue
+oArg(0).Name = "Settings"
+oArg(0).Value= oSettings
+
+Dim url As String
+Dim oPresentations(17) as String
+oPresentations( 0)="d:\data\sunpresentations\01-22-07SunIntelAnnouncementPresentation,01-22-2007.star_impress_8x.odp"
+oPresentations( 1)="d:\data\sunpresentations\01_Schwartz_SAS_VF.odp"
+oPresentations( 2)="d:\data\sunpresentations\CorporateSocialResponsibilityCustomerPresentation,02-12-2007.star_impress_8x.odp"
+oPresentations( 3)="d:\data\sunpresentations\Current-ProjectBlackboxCustomerPresentation,03-07-2007.star_impress_8x.odp"
+oPresentations( 4)="d:\data\sunpresentations\JavaSE6CustomerPresentation,12-11-2006(2).star_impress_8x.odp"
+oPresentations( 5)="d:\data\sunpresentations\JavaSE6CustomerPresentation,12-11-2006.star_impress_8x.odp"
+oPresentations( 6)="d:\data\sunpresentations\NetworkComputingLaunchPresentation,Q22006,Washington,DC,05-08-2006.star_impress_8x.odp"
+oPresentations( 7)="d:\data\sunpresentations\ProjectBlackboxTechnicalPresentation-NDAONLY,11-09-2006.star_impress_8x.odp"
+oPresentations( 8)="d:\data\sunpresentations\ScottMcNealy,IntlAssocofPrivacyProfessionals)ConferenceOpeningKeynote,'PlayingonSunday-GettingPrivacyRight',March,8,2007,Washington,DC,,03-08-2007.star_impress_8x.odp"
+oPresentations( 9)="d:\data\sunpresentations\Sun'sStoragetekAcademy-JonathanSchwartzTheSky'sTheLimit!,February,292007,SanFrancisco,CA,02-28-2007.star_impress_8x.odp"
+oPresentations(10)="d:\data\sunpresentations\SunAnalystSummit2007(SAS)-DonGranthamExecutingonStrategy,February,6,2007,SanFrancisco,CA,02-07-2007.star_impress_8x.odp"
+oPresentations(11)="d:\data\sunpresentations\SunConsultingServicesPortfolio-Presentation,03-17-2006.star_impress_6x.sxi"
+oPresentations(12)="d:\data\sunpresentations\SunFedOpenYourMindandSunFedTechDayatGTSI,ScottMcNealy,January23and24,2007,Washington,DC,01-23-2007.star_impress_8x.odp"
+oPresentations(13)="d:\data\sunpresentations\SunFedTechDaysatAccenture,ScottMcNealy,January24,2007,Washington,DC,01-24-2007.star_impress_8x.odp"
+oPresentations(14)="d:\data\sunpresentations\SunManagedServicesGoldenPitch,03-22-2007.star_impress_8x.odp"
+oPresentations(15)="d:\data\sunpresentations\SunServicesEducationServicesGeneralPresentation,01-11-2006.star_impress_6x.sxi"
+oPresentations(16)="d:\data\sunpresentations\SunSystemPacks-CustomerReadyPresentation,01-23-2007.star_impress_8x.odp"
+oPresentations(17)="d:\data\sunpresentations\U.S.SalesMeetingCustomerPresentation(08-01-2006),08-01-2006.odp"
+
+FOR I = 0 TO 17
+url=oPresentations( I )
+oSettings(11)=url+string( I, 2 )
+url=converttourl( url )
+optimize( url, oArg() )
+NEXT I
+
+End Sub
+
+Sub Optimize( url as String, oArg )
+
+Dim oPPPOptimizerDialog as Object
+Dim oUrl as new com.sun.star.util.URL
+Dim oTrans as Object
+oTrans = createUNOService("com.sun.star.util.URLTransformer")
+oUrl.Complete = "vnd.com.sun.star.comp.PPPOptimizer:optimize"
+oTrans.parsestrict(oUrl)
+
+Dim oDoc As Object
+Dim FileProperties(0) As New com.sun.star.beans.PropertyValue
+oSM = CreateObject("com.sun.star.ServiceManager")
+oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
+oDoc = oDesk.loadComponentFromURL( url, "_blank", 0, FileProperties() )
+
+Dim oInitialization( 0 ) as Object
+oInitialization(0) = oDoc.getCurrentController.getFrame
+oPPPOptimizerDialog = createUNOservice("com.sun.star.comp.PPPOptimizerImp")
+oPPPOptimizerDialog.initialize( oInitialization )
+oPPPOptimizerDialog.dispatch(oURL, oArg)
+odoc.dispose
+End Sub
+
diff --git a/sdext/source/minimizer/configurationaccess.cxx b/sdext/source/minimizer/configurationaccess.cxx
new file mode 100644
index 000000000000..449dfe79e702
--- /dev/null
+++ b/sdext/source/minimizer/configurationaccess.cxx
@@ -0,0 +1,541 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "configurationaccess.hxx"
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/util/XMacroExpander.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <sal/macros.h>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+
+static const OUString& GetConfigurationProviderServiceName (void)
+{
+ static const OUString sConfigurationProviderServiceName (
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationProvider"));
+ return sConfigurationProviderServiceName;
+}
+static const OUString& GetPathToConfigurationRoot (void)
+{
+ static const OUString sPathToConfigurationRoot (
+ RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.extension.SunPresentationMinimizer"));
+ return sPathToConfigurationRoot;
+}
+
+void OptimizerSettings::LoadSettingsFromConfiguration( const Reference< XNameAccess >& rSettings )
+{
+ if ( rSettings.is() )
+ {
+ const Sequence< OUString > aElements( rSettings->getElementNames() );
+ for ( int i = 0; i < aElements.getLength(); i++ )
+ {
+ try
+ {
+ const OUString aPropertyName( aElements[ i ] );
+ Any aValue( rSettings->getByName( aPropertyName ) );
+ switch( TKGet( aPropertyName ) )
+ {
+ case TK_Name : aValue >>= maName; break;
+ case TK_JPEGCompression : aValue >>= mbJPEGCompression; break;
+ case TK_JPEGQuality : aValue >>= mnJPEGQuality; break;
+ case TK_RemoveCropArea : aValue >>= mbRemoveCropArea; break;
+ case TK_ImageResolution : aValue >>= mnImageResolution; break;
+ case TK_EmbedLinkedGraphics : aValue >>= mbEmbedLinkedGraphics; break;
+ case TK_OLEOptimization : aValue >>= mbOLEOptimization; break;
+ case TK_OLEOptimizationType : aValue >>= mnOLEOptimizationType; break;
+ case TK_DeleteUnusedMasterPages : aValue >>= mbDeleteUnusedMasterPages; break;
+ case TK_DeleteHiddenSlides : aValue >>= mbDeleteHiddenSlides; break;
+ case TK_DeleteNotesPages : aValue >>= mbDeleteNotesPages ;break;
+ case TK_SaveAs : aValue >>= mbSaveAs; break;
+// case TK_SaveAsURL : aValue >>= maSaveAsURL; break; // URL is not saved to configuration
+// case TK_FilterName : aValue >>= maFilterName; break; // URL is not saved to configuration
+ case TK_OpenNewDocument : aValue >>= mbOpenNewDocument; break;
+ default: break;
+ }
+ }
+ catch( Exception& )
+ {
+ }
+ }
+ }
+}
+
+void OptimizerSettings::SaveSettingsToConfiguration( const Reference< XNameReplace >& rSettings )
+{
+ if ( rSettings.is() )
+ {
+ OUString pNames[] = {
+ TKGet( TK_Name ),
+ TKGet( TK_JPEGCompression ),
+ TKGet( TK_JPEGQuality ),
+ TKGet( TK_RemoveCropArea ),
+ TKGet( TK_ImageResolution ),
+ TKGet( TK_EmbedLinkedGraphics ),
+ TKGet( TK_OLEOptimization ),
+ TKGet( TK_OLEOptimizationType ),
+ TKGet( TK_DeleteUnusedMasterPages ),
+ TKGet( TK_DeleteHiddenSlides ),
+ TKGet( TK_DeleteNotesPages ),
+ TKGet( TK_SaveAs ),
+// TKGet( TK_SaveAsURL ),
+// TKGet( TK_FilterName ),
+ TKGet( TK_OpenNewDocument ) };
+
+ Any pValues[] = {
+ Any( maName ),
+ Any( mbJPEGCompression ),
+ Any( mnJPEGQuality ),
+ Any( mbRemoveCropArea ),
+ Any( mnImageResolution ),
+ Any( mbEmbedLinkedGraphics ),
+ Any( mbOLEOptimization ),
+ Any( mnOLEOptimizationType ),
+ Any( mbDeleteUnusedMasterPages ),
+ Any( mbDeleteHiddenSlides ),
+ Any( mbDeleteNotesPages ),
+ Any( mbSaveAs ),
+// Any( maSaveAsURL ),
+// Any( maFilterName ),
+ Any( mbOpenNewDocument ) };
+
+ sal_Int32 i, nCount = SAL_N_ELEMENTS( pNames );
+
+ for ( i = 0; i < nCount; i++ )
+ {
+ try
+ {
+ rSettings->replaceByName( pNames[ i ], pValues[ i ] );
+ }
+ catch( Exception& /* rException */ )
+ {
+ }
+ }
+ }
+}
+
+sal_Bool OptimizerSettings::operator==( const OptimizerSettings& rOptimizerSettings ) const
+{
+ return ( rOptimizerSettings.mbJPEGCompression == mbJPEGCompression )
+ && ( rOptimizerSettings.mnJPEGQuality == mnJPEGQuality )
+ && ( rOptimizerSettings.mbRemoveCropArea == mbRemoveCropArea )
+ && ( rOptimizerSettings.mnImageResolution == mnImageResolution )
+ && ( rOptimizerSettings.mbEmbedLinkedGraphics == mbEmbedLinkedGraphics )
+ && ( rOptimizerSettings.mbOLEOptimization == mbOLEOptimization )
+ && ( rOptimizerSettings.mnOLEOptimizationType == mnOLEOptimizationType )
+ && ( rOptimizerSettings.mbDeleteUnusedMasterPages == mbDeleteUnusedMasterPages )
+ && ( rOptimizerSettings.mbDeleteHiddenSlides == mbDeleteHiddenSlides )
+ && ( rOptimizerSettings.mbDeleteNotesPages == mbDeleteNotesPages );
+// && ( rOptimizerSettings.mbOpenNewDocument == mbOpenNewDocument );
+}
+
+
+ConfigurationAccess::ConfigurationAccess( const Reference< uno::XComponentContext >& rxMSF, OptimizerSettings* pDefaultSettings ) :
+ mxMSF( rxMSF )
+{
+ LoadStrings();
+ maSettings.push_back( pDefaultSettings ?
+ *pDefaultSettings : OptimizerSettings() );
+ maSettings.back().maName = TKGet( TK_LastUsedSettings );
+ LoadConfiguration();
+ maInitialSettings = maSettings;
+};
+
+ConfigurationAccess::~ConfigurationAccess()
+{
+}
+
+rtl::OUString ConfigurationAccess::getPath( const PPPOptimizerTokenEnum eToken )
+{
+ rtl::OUString aPath;
+ try
+ {
+ static const OUString sProtocol( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.expand:" ) );
+ static const OUString stheMacroExpander( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.util.theMacroExpander" ) );
+ Reference< container::XNameAccess > xSet( OpenConfiguration( true ), UNO_QUERY_THROW );
+ if ( xSet->hasByName( TKGet( eToken ) ) )
+ xSet->getByName( TKGet( eToken ) ) >>= aPath;
+ if ( aPath.match( sProtocol, 0 ) )
+ {
+ rtl::OUString aTmp( aPath.copy( 20 ) );
+ Reference< util::XMacroExpander > xExpander;
+ if ( mxMSF->getValueByName( stheMacroExpander ) >>= xExpander )
+ {
+ aPath = xExpander->expandMacros( aTmp );
+ }
+ }
+ }
+ catch ( Exception& )
+ {
+ }
+ return aPath;
+}
+
+rtl::OUString ConfigurationAccess::getString( const PPPOptimizerTokenEnum eToken ) const
+{
+ std::map< PPPOptimizerTokenEnum, rtl::OUString, Compare >::const_iterator aIter( maStrings.find( eToken ) );
+ return aIter != maStrings.end() ? ((*aIter).second) : rtl::OUString();
+}
+
+void ConfigurationAccess::LoadStrings()
+{
+ try
+ {
+ do
+ {
+ Reference< XInterface > xRoot( OpenConfiguration( true ) );
+ if ( !xRoot.is() )
+ break;
+ Reference< container::XNameAccess > xSet( GetConfigurationNode( xRoot, TKGet( TK_Strings ) ), UNO_QUERY );
+ if ( xSet.is() )
+ {
+ const Sequence< OUString > aElements( xSet->getElementNames() );
+ for ( int i = 0; i < aElements.getLength(); i++ )
+ {
+ try
+ {
+ OUString aString, aPropertyName( aElements[ i ] );
+ if ( xSet->getByName( aPropertyName ) >>= aString )
+ maStrings[ TKGet( aPropertyName ) ] = aString;
+ }
+ catch( Exception& )
+ {
+ }
+ }
+ }
+ }
+ while( false );
+ }
+ catch( Exception& )
+ {
+ }
+}
+
+void ConfigurationAccess::LoadConfiguration()
+{
+ try
+ {
+ do
+ {
+ Reference< XInterface > xRoot( OpenConfiguration( true ) );
+ if ( !xRoot.is() )
+ break;
+ Reference< container::XNameAccess > xSet( GetConfigurationNode( xRoot, TKGet( TK_LastUsedSettings ) ), UNO_QUERY );
+ if ( xSet.is() )
+ {
+ OptimizerSettings& rCurrent( maSettings.front() );
+ rCurrent.LoadSettingsFromConfiguration( xSet );
+ }
+ xSet = Reference< container::XNameAccess >( GetConfigurationNode( xRoot, TKGet( TK_Settings_Templates ) ), UNO_QUERY );
+ if ( xSet.is() )
+ {
+ const Sequence< OUString > aElements( xSet->getElementNames() );
+ for ( int i = 0; i < aElements.getLength(); i++ )
+ {
+ try
+ {
+ OUString aPath( TKGet( TK_Settings_Templates_ ).concat( aElements[ i ] ) );
+ Reference< container::XNameAccess > xTemplates( GetConfigurationNode( xRoot, aPath ), UNO_QUERY );
+ if ( xTemplates.is() )
+ {
+ maSettings.push_back( OptimizerSettings() );
+ maSettings.back().LoadSettingsFromConfiguration( xTemplates );
+ }
+ }
+ catch( Exception& /* rException */ )
+ {
+ }
+ }
+ }
+ }
+ while( false );
+ }
+ catch( Exception& )
+ {
+ }
+}
+
+void ConfigurationAccess::SaveConfiguration()
+{
+ try
+ {
+ do
+ {
+ int i;
+ unsigned int k;
+ Reference<util::XChangesBatch> xRoot( OpenConfiguration( false ), UNO_QUERY_THROW );
+
+ // storing the last used settings
+ Reference< container::XNameReplace > xSet( GetConfigurationNode( xRoot, TKGet( TK_LastUsedSettings ) ), UNO_QUERY_THROW );
+ OptimizerSettings& rCurrent( maSettings.front() );
+ rCurrent.SaveSettingsToConfiguration( xSet );
+
+ // updating template elements
+ xSet = Reference< container::XNameReplace >( GetConfigurationNode( xRoot, TKGet( TK_Settings_Templates ) ), UNO_QUERY_THROW );
+ Reference< container::XNameContainer > xNameContainer( xSet, UNO_QUERY_THROW );
+
+ const Sequence< OUString > aElements( xSet->getElementNames() );
+ for( i = 0; i < aElements.getLength(); i++ )
+ xNameContainer->removeByName( aElements[ i ] );
+
+ for( k = 1; k < maSettings.size(); k++ )
+ {
+ OptimizerSettings& rSettings( maSettings[ k ] );
+ OUString aElementName( TKGet( TK_Template ).concat( OUString::valueOf( static_cast< sal_Int32 >( k ) ) ) );
+ Reference< lang::XSingleServiceFactory > xChildFactory ( xSet, UNO_QUERY_THROW );
+ Reference< container::XNameReplace > xChild( xChildFactory->createInstance(), UNO_QUERY_THROW );
+ xNameContainer->insertByName( aElementName, Any( xChild ) );
+
+ OUString aPath( TKGet( TK_Settings_Templates_ ).concat( aElementName ) );
+ Reference< container::XNameReplace > xTemplates( GetConfigurationNode( xRoot, aPath ), UNO_QUERY );
+ rSettings.SaveSettingsToConfiguration( xTemplates );
+ }
+ xRoot->commitChanges();
+ }
+ while( false );
+ }
+ catch( Exception& /* rException */ )
+ {
+
+ }
+}
+
+Reference< XInterface > ConfigurationAccess::OpenConfiguration( bool bReadOnly )
+{
+ Reference< XInterface > xRoot;
+ try
+ {
+ Reference< lang::XMultiServiceFactory > xProvider( mxMSF->getServiceManager()->createInstanceWithContext( GetConfigurationProviderServiceName(), mxMSF ), UNO_QUERY );
+ if ( xProvider.is() )
+ {
+ Sequence< Any > aCreationArguments( 2 );
+ aCreationArguments[0] = makeAny( PropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ), 0,
+ makeAny( GetPathToConfigurationRoot() ),
+ PropertyState_DIRECT_VALUE ) );
+ aCreationArguments[1] = makeAny(beans::PropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "lazywrite" ) ), 0, makeAny( true ),
+ PropertyState_DIRECT_VALUE ) );
+ OUString sAccessService;
+ if ( bReadOnly )
+ sAccessService = OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationAccess" ) );
+ else
+ sAccessService = OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationUpdateAccess" ) );
+
+ xRoot = xProvider->createInstanceWithArguments(
+ sAccessService, aCreationArguments );
+ }
+ }
+ catch ( Exception& /* rException */ )
+ {
+ }
+ return xRoot;
+}
+
+Reference< XInterface > ConfigurationAccess::GetConfigurationNode(
+ const Reference< XInterface >& xRoot,
+ const OUString& sPathToNode )
+{
+ Reference< XInterface > xNode;
+ try
+ {
+ if ( !sPathToNode.getLength() )
+ xNode = xRoot;
+ else
+ {
+ Reference< XHierarchicalNameAccess > xHierarchy( xRoot, UNO_QUERY );
+ if ( xHierarchy.is() )
+ {
+ xHierarchy->getByHierarchicalName( sPathToNode ) >>= xNode;
+ }
+ }
+ }
+ catch ( Exception& rException )
+ {
+ OSL_TRACE ("caught exception while getting configuration node %s: %s",
+ ::rtl::OUStringToOString(sPathToNode,
+ RTL_TEXTENCODING_UTF8).getStr(),
+ ::rtl::OUStringToOString(rException.Message,
+ RTL_TEXTENCODING_UTF8).getStr());
+ }
+ return xNode;
+}
+
+com::sun::star::uno::Any ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken ) const
+{
+ Any aRetValue;
+ const OptimizerSettings& rSettings( maSettings.front() );
+ try
+ {
+ switch( ePropertyToken )
+ {
+ case TK_Name : aRetValue <<= rSettings.maName; break;
+ case TK_JPEGCompression : aRetValue <<= rSettings.mbJPEGCompression; break;
+ case TK_JPEGQuality : aRetValue <<= rSettings.mnJPEGQuality; break;
+ case TK_RemoveCropArea : aRetValue <<= rSettings.mbRemoveCropArea; break;
+ case TK_ImageResolution : aRetValue <<= rSettings.mnImageResolution; break;
+ case TK_EmbedLinkedGraphics : aRetValue <<= rSettings.mbEmbedLinkedGraphics; break;
+ case TK_OLEOptimization : aRetValue <<= rSettings.mbOLEOptimization; break;
+ case TK_OLEOptimizationType : aRetValue <<= rSettings.mnOLEOptimizationType; break;
+ case TK_DeleteUnusedMasterPages : aRetValue <<= rSettings.mbDeleteUnusedMasterPages; break;
+ case TK_DeleteHiddenSlides : aRetValue <<= rSettings.mbDeleteHiddenSlides; break;
+ case TK_DeleteNotesPages : aRetValue <<= rSettings.mbDeleteNotesPages; break;
+ case TK_SaveAs : aRetValue <<= rSettings.mbSaveAs; break;
+ case TK_SaveAsURL : aRetValue <<= rSettings.maSaveAsURL; break;
+ case TK_FilterName : aRetValue <<= rSettings.maFilterName; break;
+ case TK_OpenNewDocument : aRetValue <<= rSettings.mbOpenNewDocument; break;
+ case TK_EstimatedFileSize : aRetValue <<= rSettings.mnEstimatedFileSize; break;
+ default:
+ break;
+ }
+ }
+ catch( Exception& /* rException */ )
+ {
+ }
+ return aRetValue;
+}
+
+void ConfigurationAccess::SetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken, const com::sun::star::uno::Any& rValue )
+{
+ OptimizerSettings& rSettings( maSettings.front() );
+ try
+ {
+ switch( ePropertyToken )
+ {
+ case TK_Name : rValue >>= rSettings.maName; break;
+ case TK_JPEGCompression : rValue >>= rSettings.mbJPEGCompression; break;
+ case TK_JPEGQuality : rValue >>= rSettings.mnJPEGQuality; break;
+ case TK_RemoveCropArea : rValue >>= rSettings.mbRemoveCropArea; break;
+ case TK_ImageResolution : rValue >>= rSettings.mnImageResolution; break;
+ case TK_EmbedLinkedGraphics : rValue >>= rSettings.mbEmbedLinkedGraphics; break;
+ case TK_OLEOptimization : rValue >>= rSettings.mbOLEOptimization; break;
+ case TK_OLEOptimizationType : rValue >>= rSettings.mnOLEOptimizationType; break;
+ case TK_DeleteUnusedMasterPages : rValue >>= rSettings.mbDeleteUnusedMasterPages; break;
+ case TK_DeleteHiddenSlides : rValue >>= rSettings.mbDeleteHiddenSlides; break;
+ case TK_DeleteNotesPages : rValue >>= rSettings.mbDeleteNotesPages; break;
+ case TK_CustomShowName : rValue >>= rSettings.maCustomShowName; break;
+ case TK_SaveAs : rValue >>= rSettings.mbSaveAs; break;
+ case TK_SaveAsURL : rValue >>= rSettings.maSaveAsURL; break;
+ case TK_FilterName : rValue >>= rSettings.maFilterName; break;
+ case TK_OpenNewDocument : rValue >>= rSettings.mbOpenNewDocument; break;
+ case TK_EstimatedFileSize : rValue >>= rSettings.mnEstimatedFileSize; break;
+ default:
+ break;
+ }
+ }
+ catch( Exception& /* rException */ )
+ {
+ }
+}
+
+sal_Bool ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken, const sal_Bool bDefault ) const
+{
+ sal_Bool bRetValue = bDefault;
+ if ( ! ( GetConfigProperty( ePropertyToken ) >>= bRetValue ) )
+ bRetValue = bDefault;
+ return bRetValue;
+}
+
+sal_Int16 ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken, const sal_Int16 nDefault ) const
+{
+ sal_Int16 nRetValue = nDefault;
+ if ( ! ( GetConfigProperty( ePropertyToken ) >>= nRetValue ) )
+ nRetValue = nDefault;
+ return nRetValue;
+}
+
+sal_Int32 ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken, const sal_Int32 nDefault ) const
+{
+ sal_Int32 nRetValue = nDefault;
+ if ( ! ( GetConfigProperty( ePropertyToken ) >>= nRetValue ) )
+ nRetValue = nDefault;
+ return nRetValue;
+}
+
+Sequence< PropertyValue > ConfigurationAccess::GetConfigurationSequence()
+{
+ Sequence< PropertyValue > aRet( 15 );
+ OptimizerSettings& rSettings( maSettings.front() );
+ aRet[ 0 ].Name = TKGet( TK_JPEGCompression );
+ aRet[ 0 ].Value= Any( rSettings.mbJPEGCompression );
+ aRet[ 1 ].Name = TKGet( TK_JPEGQuality );
+ aRet[ 1 ].Value= Any( rSettings.mnJPEGQuality );
+ aRet[ 2 ].Name = TKGet( TK_RemoveCropArea );
+ aRet[ 2 ].Value= Any( rSettings.mbRemoveCropArea );
+ aRet[ 3 ].Name = TKGet( TK_ImageResolution );
+ aRet[ 3 ].Value= Any( rSettings.mnImageResolution );
+ aRet[ 4 ].Name = TKGet( TK_EmbedLinkedGraphics );
+ aRet[ 4 ].Value= Any( rSettings.mbEmbedLinkedGraphics );
+ aRet[ 5 ].Name = TKGet( TK_OLEOptimization );
+ aRet[ 5 ].Value= Any( rSettings.mbOLEOptimization );
+ aRet[ 6 ].Name = TKGet( TK_OLEOptimizationType );
+ aRet[ 6 ].Value= Any( rSettings.mnOLEOptimizationType );
+ aRet[ 7 ].Name = TKGet( TK_DeleteUnusedMasterPages );
+ aRet[ 7 ].Value= Any( rSettings.mbDeleteUnusedMasterPages );
+ aRet[ 8 ].Name = TKGet( TK_DeleteHiddenSlides );
+ aRet[ 8 ].Value= Any( rSettings.mbDeleteHiddenSlides );
+ aRet[ 9 ].Name = TKGet( TK_DeleteNotesPages );
+ aRet[ 9 ].Value= Any( rSettings.mbDeleteNotesPages );
+ aRet[ 10].Name = TKGet( TK_CustomShowName );
+ aRet[ 10].Value= Any( rSettings.maCustomShowName );
+ aRet[ 11].Name = TKGet( TK_SaveAsURL );
+ aRet[ 11].Value= Any( rSettings.maSaveAsURL );
+ aRet[ 12].Name = TKGet( TK_FilterName );
+ aRet[ 12].Value= Any( rSettings.maFilterName );
+ aRet[ 13].Name = TKGet( TK_OpenNewDocument );
+ aRet[ 13].Value= Any( rSettings.mbOpenNewDocument );
+ aRet[ 14].Name = TKGet( TK_EstimatedFileSize );
+ aRet[ 14].Value= Any( rSettings.mnEstimatedFileSize );
+ return aRet;
+}
+
+std::vector< OptimizerSettings >::iterator ConfigurationAccess::GetOptimizerSettingsByName( const rtl::OUString& rName )
+{
+ std::vector< OptimizerSettings >::iterator aIter( maSettings.begin() + 1 );
+ while ( aIter != maSettings.end() )
+ {
+ if ( aIter->maName == rName )
+ break;
+ aIter++;
+ }
+ return aIter;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/configurationaccess.hxx b/sdext/source/minimizer/configurationaccess.hxx
new file mode 100644
index 000000000000..436ae90fe071
--- /dev/null
+++ b/sdext/source/minimizer/configurationaccess.hxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _CONFIGURATION_ACCESS_HXX_
+#define _CONFIGURATION_ACCESS_HXX_
+#include <vector>
+#include "pppoptimizertoken.hxx"
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/uno/Any.h>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XNameReplace.hpp>
+#include <map>
+
+struct OptimizerSettings
+{
+ rtl::OUString maName;
+ sal_Bool mbJPEGCompression;
+ sal_Int32 mnJPEGQuality;
+ sal_Bool mbRemoveCropArea;
+ sal_Int32 mnImageResolution;
+ sal_Bool mbEmbedLinkedGraphics;
+ sal_Bool mbOLEOptimization;
+ sal_Int16 mnOLEOptimizationType;
+ sal_Bool mbDeleteUnusedMasterPages;
+ sal_Bool mbDeleteHiddenSlides;
+ sal_Bool mbDeleteNotesPages;
+ rtl::OUString maCustomShowName;
+ sal_Bool mbSaveAs;
+ rtl::OUString maSaveAsURL;
+ rtl::OUString maFilterName;
+ sal_Bool mbOpenNewDocument;
+ sal_Int64 mnEstimatedFileSize;
+
+ OptimizerSettings() :
+ mbJPEGCompression( sal_False ),
+ mnJPEGQuality( 90 ),
+ mbRemoveCropArea( sal_False ),
+ mnImageResolution( 0 ),
+ mbEmbedLinkedGraphics( sal_False ),
+ mbOLEOptimization( sal_False ),
+ mnOLEOptimizationType( 0 ),
+ mbDeleteUnusedMasterPages( sal_False ),
+ mbDeleteHiddenSlides( sal_False ),
+ mbDeleteNotesPages( sal_False ),
+ mbSaveAs( sal_True ),
+ mbOpenNewDocument( sal_True ),
+ mnEstimatedFileSize( 0 ){};
+ ~OptimizerSettings(){};
+
+ void LoadSettingsFromConfiguration( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >& rSettings );
+ void SaveSettingsToConfiguration( const com::sun::star::uno::Reference< com::sun::star::container::XNameReplace >& rSettings );
+
+ sal_Bool operator==( const OptimizerSettings& rOptimizerSettings ) const;
+
+};
+class ConfigurationAccess
+{
+ public :
+
+ ConfigurationAccess( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rXFactory,
+ OptimizerSettings* pDefaultSettings = NULL );
+ ~ConfigurationAccess();
+ void SaveConfiguration();
+
+ rtl::OUString getPath( const PPPOptimizerTokenEnum );
+ rtl::OUString getString( const PPPOptimizerTokenEnum ) const;
+
+ // access to current OptimizerSettings (stored in the first entry of maSettings)
+ com::sun::star::uno::Any GetConfigProperty( const PPPOptimizerTokenEnum ) const;
+ void SetConfigProperty( const PPPOptimizerTokenEnum, const com::sun::star::uno::Any& aValue );
+
+ sal_Bool GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Bool bDefault ) const;
+ sal_Int16 GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Int16 nDefault ) const;
+ sal_Int32 GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Int32 nDefault ) const;
+
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > GetConfigurationSequence();
+
+ // getting access to the OptimizerSettings list
+ std::vector< OptimizerSettings >& GetOptimizerSettings() { return maSettings; };
+ std::vector< OptimizerSettings >::iterator GetOptimizerSettingsByName( const rtl::OUString& rName );
+
+ private :
+
+ struct Compare
+ {
+ bool operator()( const PPPOptimizerTokenEnum s1, const PPPOptimizerTokenEnum s2 ) const
+ {
+ return s1 < s2;
+ }
+ };
+ std::map < PPPOptimizerTokenEnum, rtl::OUString, Compare > maStrings;
+
+ std::vector< OptimizerSettings > maSettings;
+ std::vector< OptimizerSettings > maInitialSettings;
+
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxMSF;
+
+ void LoadStrings();
+ void LoadConfiguration();
+ com::sun::star::uno::Reference< com::sun::star::uno::XInterface > OpenConfiguration( bool bReadOnly );
+ com::sun::star::uno::Reference< com::sun::star::uno::XInterface > GetConfigurationNode(
+ const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& xRoot, const rtl::OUString& sPathToNode );
+};
+
+#endif // _CONFIGURATION_ACCESS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/delzip b/sdext/source/minimizer/delzip
new file mode 100644
index 000000000000..8b137891791f
--- /dev/null
+++ b/sdext/source/minimizer/delzip
@@ -0,0 +1 @@
+
diff --git a/sdext/source/minimizer/description.xml b/sdext/source/minimizer/description.xml
new file mode 100644
index 000000000000..f10e8c21efa8
--- /dev/null
+++ b/sdext/source/minimizer/description.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<description
+
+ xmlns="http://openoffice.org/extensions/description/2006"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:dep="http://openoffice.org/extensions/description/2006">
+
+ <identifier value="UPDATED_IDENTIFIER"/>
+
+ <dependencies>
+ <OpenOffice.org-minimal-version value="2.3" dep:name="OpenOffice.org 2.3"/>
+ </dependencies>
+
+ <version value="1.0.3"/>
+
+ <platform value="UPDATED_SUPPORTED_PLATFORM"/>
+
+ <publisher>
+ <name xlink:href="http://www.oracle.com/us/products/applications/open-office" lang="en">Oracle</name>
+ </publisher>
+
+ <display-name>
+ <name lang="en-US">Presentation Minimizer</name>
+ </display-name>
+
+ <icon>
+ <default xlink:href="bitmaps/extension_32.png" />
+ </icon>
+
+</description>
diff --git a/sdext/source/minimizer/fileopendialog.cxx b/sdext/source/minimizer/fileopendialog.cxx
new file mode 100644
index 000000000000..6091e34cf614
--- /dev/null
+++ b/sdext/source/minimizer/fileopendialog.cxx
@@ -0,0 +1,210 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "fileopendialog.hxx"
+#include <sal/types.h>
+#include "pppoptimizertoken.hxx"
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <com/sun/star/ui/dialogs/FilePreviewImageFormats.hpp>
+#include <com/sun/star/ui/dialogs/ControlActions.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
+#include <com/sun/star/ui/dialogs/XFilePreview.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XContainerQuery.hpp>
+#include <com/sun/star/view/XControlAccess.hpp>
+#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
+
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::ui::dialogs;
+
+FileOpenDialog::FileOpenDialog( const Reference< XComponentContext >& rxMSF ) :
+ mxMSF( rxMSF )
+{
+ Sequence< Any > aInitPropSeq( 1 );
+ aInitPropSeq[ 0 ] <<= (sal_Int16)TemplateDescription::FILESAVE_AUTOEXTENSION; // TemplateDescription.FILEOPEN_SIMPLE
+
+ mxFilePicker = Reference < XFilePicker >( mxMSF->getServiceManager()->createInstanceWithArgumentsAndContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aInitPropSeq, rxMSF ),UNO_QUERY_THROW );
+ mxFilePicker->setMultiSelectionMode( sal_False );
+
+ Reference< XFilePickerControlAccess > xAccess( mxFilePicker, UNO_QUERY );
+ if ( xAccess.is() )
+ {
+ Any aValue( static_cast< sal_Bool >( sal_True ) );
+ try
+ {
+ xAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue );
+ }
+ catch( com::sun::star::uno::Exception& )
+ {}
+ }
+
+ // collecting a list of impress filters
+ Reference< XNameAccess > xFilters( mxMSF->getServiceManager()->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" ) ), rxMSF ), UNO_QUERY_THROW );
+ Sequence< OUString > aFilterList( xFilters->getElementNames() );
+ for ( int i = 0; i < aFilterList.getLength(); i++ )
+ {
+ try
+ {
+ Sequence< PropertyValue > aFilterProperties;
+ if ( xFilters->getByName( aFilterList[ i ] ) >>= aFilterProperties )
+ {
+ FilterEntry aFilterEntry;
+ sal_Bool bImpressFilter = sal_False;
+ for ( int j = 0; j < aFilterProperties.getLength(); j++ )
+ {
+ PropertyValue& rProperty( aFilterProperties[ j ] );
+ switch( TKGet( rProperty.Name ) )
+ {
+ case TK_DocumentService :
+ {
+ rtl::OUString sDocumentService;
+ rProperty.Value >>= sDocumentService;
+ if ( sDocumentService == OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) )
+ bImpressFilter = sal_True;
+ else
+ j = aFilterProperties.getLength();
+ }
+ break;
+ case TK_Name : rProperty.Value >>= aFilterEntry.maName; break;
+ case TK_UIName : rProperty.Value >>= aFilterEntry.maUIName; break;
+ case TK_Type : rProperty.Value >>= aFilterEntry.maType; break;
+ case TK_Flags : rProperty.Value >>= aFilterEntry.maFlags; break;
+ default : break;
+ }
+ }
+ if ( bImpressFilter && ( ( aFilterEntry.maFlags & 3 ) == 3 ) )
+ {
+ aFilterEntryList.push_back( aFilterEntry );
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ }
+ }
+
+ Reference< XNameAccess > xTypes( mxMSF->getServiceManager()->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.TypeDetection" ) ), rxMSF ), UNO_QUERY_THROW );
+ Sequence< OUString > aTypeList( xFilters->getElementNames() );
+
+// mxFilePicker->setDefaultName( );
+
+ Reference< XFilterManager > xFilterManager( mxFilePicker, UNO_QUERY_THROW );
+ std::vector< FilterEntry >::iterator aIter( aFilterEntryList.begin() );
+ while( aIter != aFilterEntryList.end() )
+ {
+ Sequence< PropertyValue > aTypeProperties;
+ try
+ {
+ if ( xTypes->getByName( aIter->maType ) >>= aTypeProperties )
+ {
+ Sequence< OUString > aExtensions;
+ for ( int i = 0; i < aTypeProperties.getLength(); i++ )
+ {
+ switch( TKGet( aTypeProperties[ i ].Name ) )
+ {
+ case TK_Extensions : aTypeProperties[ i ].Value >>= aExtensions; break;
+ default: break;
+ }
+ }
+ if ( aExtensions.getLength() )
+ {
+ xFilterManager->appendFilter( aIter->maUIName, aExtensions[ 0 ] );
+ if ( aIter->maFlags & 0x100 )
+ xFilterManager->setCurrentFilter( aIter->maUIName );
+ }
+ }
+ }
+ catch ( Exception& )
+ {
+ }
+ aIter++;
+ }
+}
+FileOpenDialog::~FileOpenDialog()
+{
+}
+sal_Int16 FileOpenDialog::execute()
+{
+ return mxFilePicker->execute();
+}
+void FileOpenDialog::setDefaultName( const rtl::OUString& rDefaultName )
+{
+ mxFilePicker->setDefaultName( rDefaultName );
+}
+::rtl::OUString FileOpenDialog::getURL() const
+{
+ Sequence< OUString > aFileSeq( mxFilePicker->getFiles() );
+ return aFileSeq.getLength() ? aFileSeq[ 0 ] : OUString();
+};
+::rtl::OUString FileOpenDialog::getFilterName() const
+{
+ rtl::OUString aFilterName;
+ Reference< XFilterManager > xFilterManager( mxFilePicker, UNO_QUERY_THROW );
+ rtl::OUString aUIName( xFilterManager->getCurrentFilter() );
+ std::vector< FilterEntry >::const_iterator aIter( aFilterEntryList.begin() );
+ while( aIter != aFilterEntryList.end() )
+ {
+ if ( aIter->maUIName == aUIName )
+ {
+ aFilterName = aIter->maName;
+ break;
+ }
+ aIter++;
+ }
+ return aFilterName;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/fileopendialog.hxx b/sdext/source/minimizer/fileopendialog.hxx
new file mode 100644
index 000000000000..8ddbba752113
--- /dev/null
+++ b/sdext/source/minimizer/fileopendialog.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _FILEOPEN_DIALOG_HXX_
+#define _FILEOPEN_DIALOG_HXX_
+
+#include <vector>
+#include <com/sun/star/beans/StringPair.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+class FileOpenDialog
+{
+ // a list of filters that are provided within the SaveDialog
+ struct FilterEntry
+ {
+ rtl::OUString maName;
+ rtl::OUString maType;
+ rtl::OUString maUIName;
+ rtl::OUString maFilter;
+ sal_Int32 maFlags;
+ com::sun::star::uno::Sequence< rtl::OUString > maExtensions;
+
+ FilterEntry() :
+ maFlags( 0 ) {}
+ };
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxMSF;
+ com::sun::star::uno::Reference < ::com::sun::star::ui::dialogs::XFilePicker > mxFilePicker;
+
+ std::vector< FilterEntry > aFilterEntryList;
+
+public :
+ FileOpenDialog( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxMSF );
+ ~FileOpenDialog();
+
+ sal_Int16 execute();
+
+ void setDefaultName( const rtl::OUString& );
+// void setDefaultDirectory( const rtl::OUString& );
+
+ ::rtl::OUString getURL() const;
+ ::rtl::OUString getFilterName() const;
+};
+
+#endif // _FILEOPEN_DIALOG_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/graphiccollector.cxx b/sdext/source/minimizer/graphiccollector.cxx
new file mode 100644
index 000000000000..5a401e7f0e66
--- /dev/null
+++ b/sdext/source/minimizer/graphiccollector.cxx
@@ -0,0 +1,462 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "graphiccollector.hxx"
+#include <com/sun/star/awt/XDevice.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/BitmapMode.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/presentation/XPresentationPage.hpp>
+#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
+
+#include "impoptimizer.hxx"
+
+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::graphic;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::presentation;
+
+const DeviceInfo& GraphicCollector::GetDeviceInfo( const Reference< XComponentContext >& rxFact )
+{
+ static DeviceInfo aDeviceInfo;
+ if( !aDeviceInfo.Width )
+ {
+ try
+ {
+ Reference< XFramesSupplier > xDesktop( rxFact->getServiceManager()->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ), rxFact ), UNO_QUERY_THROW );
+ Reference< XFrame > xFrame( xDesktop->getActiveFrame() );
+ Reference< XWindow > xWindow( xFrame->getContainerWindow() );
+ Reference< XDevice > xDevice( xWindow, UNO_QUERY_THROW );
+ aDeviceInfo = xDevice->getInfo();
+ }
+ catch( Exception& )
+ {
+ }
+ }
+ return aDeviceInfo;
+}
+
+void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, const GraphicSettings& rGraphicSettings, const GraphicCollector::GraphicUser& rUser )
+{
+ const rtl::OUString aGraphicURL( rUser.maGraphicURL );
+ const rtl::OUString sPackageURL( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.GraphicObject:") );
+
+ if ( rGraphicSettings.mbEmbedLinkedGraphics || ( !aGraphicURL.getLength() || aGraphicURL.match( sPackageURL, 0 ) ) )
+ {
+ std::vector< GraphicCollector::GraphicEntity >::iterator aIter( rGraphicEntities.begin() );
+ while( aIter != rGraphicEntities.end() )
+ {
+ if ( aIter->maUser[ 0 ].maGraphicURL == aGraphicURL )
+ {
+ if ( rUser.maLogicalSize.Width > aIter->maLogicalSize.Width )
+ aIter->maLogicalSize.Width = rUser.maLogicalSize.Width;
+ if ( rUser.maLogicalSize.Height > aIter->maLogicalSize.Height )
+ aIter->maLogicalSize.Height = rUser.maLogicalSize.Height;
+ aIter->maUser.push_back( rUser );
+ break;
+ }
+ ++aIter;
+ }
+ if ( aIter == rGraphicEntities.end() )
+ {
+ GraphicCollector::GraphicEntity aEntity( rUser );
+ rGraphicEntities.push_back( aEntity );
+ }
+ }
+}
+
+void ImpAddGraphicEntity( const Reference< XComponentContext >& rxMSF, Reference< XShape >& rxShape, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities )
+{
+ Reference< XGraphic > xGraphic;
+ Reference< XPropertySet > xShapePropertySet( rxShape, UNO_QUERY_THROW );
+ if ( xShapePropertySet->getPropertyValue( TKGet( TK_Graphic ) ) >>= xGraphic )
+ {
+ text::GraphicCrop aGraphicCropLogic( 0, 0, 0, 0 );
+
+ GraphicCollector::GraphicUser aUser;
+ aUser.mxShape = rxShape;
+ aUser.mbFillBitmap = sal_False;
+ xShapePropertySet->getPropertyValue( TKGet( TK_GraphicURL ) ) >>= aUser.maGraphicURL;
+ xShapePropertySet->getPropertyValue( TKGet( TK_GraphicStreamURL ) ) >>= aUser.maGraphicStreamURL;
+ xShapePropertySet->getPropertyValue( TKGet( TK_GraphicCrop ) ) >>= aGraphicCropLogic;
+ awt::Size aLogicalSize( rxShape->getSize() );
+
+ // calculating the logical size, as if there were no cropping
+ if ( aGraphicCropLogic.Left || aGraphicCropLogic.Right || aGraphicCropLogic.Top || aGraphicCropLogic.Bottom )
+ {
+ awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) );
+ if ( aSize100thMM.Width && aSize100thMM.Height )
+ {
+ awt::Size aCropSize( aSize100thMM.Width - ( aGraphicCropLogic.Left + aGraphicCropLogic.Right ),
+ aSize100thMM.Height - ( aGraphicCropLogic.Top + aGraphicCropLogic.Bottom ));
+ if ( aCropSize.Width && aCropSize.Height )
+ {
+ awt::Size aNewLogSize( static_cast< sal_Int32 >( static_cast< double >( aSize100thMM.Width * aLogicalSize.Width ) / aCropSize.Width ),
+ static_cast< sal_Int32 >( static_cast< double >( aSize100thMM.Height * aLogicalSize.Height ) / aCropSize.Height ) );
+ aLogicalSize = aNewLogSize;
+ }
+ }
+ }
+ aUser.maGraphicCropLogic = aGraphicCropLogic;
+ aUser.maLogicalSize = aLogicalSize;
+ ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser );
+ }
+}
+
+void ImpAddFillBitmapEntity( const Reference< XComponentContext >& rxMSF, const Reference< XPropertySet >& rxPropertySet, const awt::Size& rLogicalSize,
+ std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, const GraphicSettings& rGraphicSettings, const Reference< XPropertySet >& rxPagePropertySet )
+{
+ try
+ {
+ FillStyle eFillStyle;
+ if ( rxPropertySet->getPropertyValue( TKGet( TK_FillStyle ) ) >>= eFillStyle )
+ {
+ if ( eFillStyle == FillStyle_BITMAP )
+ {
+ rtl::OUString aFillBitmapURL;
+ Reference< XBitmap > xFillBitmap;
+ if ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmap ) ) >>= xFillBitmap )
+ {
+ Reference< XGraphic > xGraphic( xFillBitmap, UNO_QUERY_THROW );
+ if ( xGraphic.is() )
+ {
+ awt::Size aLogicalSize( rLogicalSize );
+ Reference< XPropertySetInfo > axPropSetInfo( rxPropertySet->getPropertySetInfo() );
+ if ( axPropSetInfo.is() )
+ {
+ if ( axPropSetInfo->hasPropertyByName( TKGet( TK_FillBitmapMode ) ) )
+ {
+ BitmapMode eBitmapMode;
+ if ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapMode ) ) >>= eBitmapMode )
+ {
+ if ( ( eBitmapMode == BitmapMode_REPEAT ) || ( eBitmapMode == BitmapMode_NO_REPEAT ) )
+ {
+ sal_Bool bLogicalSize = sal_False;
+ awt::Size aSize( 0, 0 );
+ if ( ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapLogicalSize ) ) >>= bLogicalSize )
+ && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeX ) ) >>= aSize.Width )
+ && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeY ) ) >>= aSize.Height ) )
+ {
+ if ( bLogicalSize )
+ {
+ if ( !aSize.Width || !aSize.Height )
+ {
+ awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) );
+ if ( aSize100thMM.Width && aSize100thMM.Height )
+ aLogicalSize = aSize100thMM;
+ }
+ else
+ aLogicalSize = aSize;
+ }
+ else
+ {
+ aLogicalSize.Width = sal::static_int_cast< sal_Int32 >( ( static_cast< double >( aLogicalSize.Width ) * aSize.Width ) / -100.0 );
+ aLogicalSize.Height = sal::static_int_cast< sal_Int32 >( ( static_cast< double >( aLogicalSize.Height ) * aSize.Height ) / -100.0 );
+ }
+ }
+ }
+ }
+ }
+ }
+ GraphicCollector::GraphicUser aUser;
+ aUser.mxPropertySet = rxPropertySet;
+ rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapURL ) ) >>= aUser.maGraphicURL;
+ aUser.mbFillBitmap = sal_True;
+ aUser.maLogicalSize = aLogicalSize;
+ aUser.mxPagePropertySet = rxPagePropertySet;
+ ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser );
+ }
+ }
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ }
+}
+
+void ImpCollectBackgroundGraphic( const Reference< XComponentContext >& rxMSF, const Reference< XDrawPage >& rxDrawPage, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities )
+{
+ try
+ {
+ awt::Size aLogicalSize( 28000, 21000 );
+ Reference< XPropertySet > xPropertySet( rxDrawPage, UNO_QUERY_THROW );
+ xPropertySet->getPropertyValue( TKGet( TK_Width ) ) >>= aLogicalSize.Width;
+ xPropertySet->getPropertyValue( TKGet( TK_Height ) ) >>= aLogicalSize.Height;
+
+ Reference< XPropertySet > xBackgroundPropSet;
+ if ( xPropertySet->getPropertyValue( TKGet( TK_Background ) ) >>= xBackgroundPropSet )
+ ImpAddFillBitmapEntity( rxMSF, xBackgroundPropSet, aLogicalSize, rGraphicEntities, rGraphicSettings, xPropertySet );
+ }
+ catch( Exception& )
+ {
+ }
+}
+
+void ImpCollectGraphicObjects( const Reference< XComponentContext >& rxMSF, const Reference< XShapes >& rxShapes, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities )
+{
+ for ( sal_Int32 i = 0; i < rxShapes->getCount(); i++ )
+ {
+ try
+ {
+ const OUString sGraphicObjectShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicObjectShape" ) );
+ const OUString sGroupShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GroupShape" ) );
+ Reference< XShape > xShape( rxShapes->getByIndex( i ), UNO_QUERY_THROW );
+ const OUString sShapeType( xShape->getShapeType() );
+ if ( sShapeType == sGroupShape )
+ {
+ Reference< XShapes > xShapes( xShape, UNO_QUERY_THROW );
+ ImpCollectGraphicObjects( rxMSF, xShapes, rGraphicSettings, rGraphicEntities );
+ continue;
+ }
+
+ if ( sShapeType == sGraphicObjectShape )
+ ImpAddGraphicEntity( rxMSF, xShape, rGraphicSettings, rGraphicEntities );
+
+ // now check for a fillstyle
+ Reference< XPropertySet > xEmptyPagePropSet;
+ Reference< XPropertySet > xShapePropertySet( xShape, UNO_QUERY_THROW );
+ awt::Size aLogicalSize( xShape->getSize() );
+ ImpAddFillBitmapEntity( rxMSF, xShapePropertySet, aLogicalSize, rGraphicEntities, rGraphicSettings, xEmptyPagePropSet );
+ }
+ catch( Exception& )
+ {
+ }
+ }
+}
+
+awt::Size GraphicCollector::GetOriginalSize( const Reference< XComponentContext >& rxMSF, const Reference< XGraphic >& rxGraphic )
+{
+ awt::Size aSize100thMM( 0, 0 );
+ Reference< XPropertySet > xGraphicPropertySet( rxGraphic, UNO_QUERY_THROW );
+ if ( xGraphicPropertySet->getPropertyValue( TKGet( TK_Size100thMM ) ) >>= aSize100thMM )
+ {
+ if ( !aSize100thMM.Width && !aSize100thMM.Height )
+ { // MAPMODE_PIXEL USED :-(
+ awt::Size aSourceSizePixel( 0, 0 );
+ if ( xGraphicPropertySet->getPropertyValue( TKGet( TK_SizePixel ) ) >>= aSourceSizePixel )
+ {
+ const DeviceInfo& rDeviceInfo( GraphicCollector::GetDeviceInfo( rxMSF ) );
+ if ( rDeviceInfo.PixelPerMeterX && rDeviceInfo.PixelPerMeterY )
+ {
+ aSize100thMM.Width = static_cast< sal_Int32 >( ( aSourceSizePixel.Width * 100000.0 ) / rDeviceInfo.PixelPerMeterX );
+ aSize100thMM.Height = static_cast< sal_Int32 >( ( aSourceSizePixel.Height * 100000.0 ) / rDeviceInfo.PixelPerMeterY );
+ }
+ }
+ }
+ }
+ return aSize100thMM;
+}
+
+void GraphicCollector::CollectGraphics( const Reference< XComponentContext >& rxMSF, const Reference< XModel >& rxModel,
+ const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicList )
+{
+ try
+ {
+ sal_Int32 i;
+ Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
+ Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
+ for ( i = 0; i < xDrawPages->getCount(); i++ )
+ {
+ Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
+ ImpCollectBackgroundGraphic( rxMSF, xDrawPage, rGraphicSettings, rGraphicList );
+ Reference< XShapes > xDrawShapes( xDrawPage, UNO_QUERY_THROW );
+ ImpCollectGraphicObjects( rxMSF, xDrawShapes, rGraphicSettings, rGraphicList );
+
+ Reference< XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW );
+ Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() );
+ ImpCollectBackgroundGraphic( rxMSF, xNotesPage, rGraphicSettings, rGraphicList );
+ Reference< XShapes > xNotesShapes( xNotesPage, UNO_QUERY_THROW );
+ ImpCollectGraphicObjects( rxMSF, xNotesShapes, rGraphicSettings, rGraphicList );
+ }
+ Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW );
+ Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
+ for ( i = 0; i < xMasterPages->getCount(); i++ )
+ {
+ Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW );
+ ImpCollectBackgroundGraphic( rxMSF, xMasterPage, rGraphicSettings, rGraphicList );
+ Reference< XShapes > xMasterPageShapes( xMasterPage, UNO_QUERY_THROW );
+ ImpCollectGraphicObjects( rxMSF, xMasterPageShapes, rGraphicSettings, rGraphicList );
+ }
+
+ std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIter( rGraphicList.begin() );
+ std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIEnd( rGraphicList.end() );
+ while( aGraphicIter != aGraphicIEnd )
+ {
+ // check if it is possible to remove the crop area
+ aGraphicIter->mbRemoveCropArea = rGraphicSettings.mbRemoveCropArea;
+ if ( aGraphicIter->mbRemoveCropArea )
+ {
+ std::vector< GraphicCollector::GraphicUser >::iterator aGUIter( aGraphicIter->maUser.begin() );
+ while( aGraphicIter->mbRemoveCropArea && ( aGUIter != aGraphicIter->maUser.end() ) )
+ {
+ if ( aGUIter->maGraphicCropLogic.Left || aGUIter->maGraphicCropLogic.Top
+ || aGUIter->maGraphicCropLogic.Right || aGUIter->maGraphicCropLogic.Bottom )
+ {
+ if ( aGUIter == aGraphicIter->maUser.begin() )
+ aGraphicIter->maGraphicCropLogic = aGUIter->maGraphicCropLogic;
+ else if ( ( aGraphicIter->maGraphicCropLogic.Left != aGUIter->maGraphicCropLogic.Left )
+ || ( aGraphicIter->maGraphicCropLogic.Top != aGUIter->maGraphicCropLogic.Top )
+ || ( aGraphicIter->maGraphicCropLogic.Right != aGUIter->maGraphicCropLogic.Right )
+ || ( aGraphicIter->maGraphicCropLogic.Bottom != aGUIter->maGraphicCropLogic.Bottom ) )
+ {
+ aGraphicIter->mbRemoveCropArea = sal_False;
+ }
+ }
+ else
+ aGraphicIter->mbRemoveCropArea = sal_False;
+ ++aGUIter;
+ }
+ }
+ if ( !aGraphicIter->mbRemoveCropArea )
+ aGraphicIter->maGraphicCropLogic = text::GraphicCrop( 0, 0, 0, 0 );
+ ++aGraphicIter;
+ }
+ }
+ catch ( Exception& )
+ {
+ }
+}
+
+void ImpCountGraphicObjects( const Reference< XComponentContext >& rxMSF, const Reference< XShapes >& rxShapes, const GraphicSettings& rGraphicSettings, sal_Int32& rnGraphics )
+{
+ for ( sal_Int32 i = 0; i < rxShapes->getCount(); i++ )
+ {
+ try
+ {
+ const OUString sGraphicObjectShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicObjectShape" ) );
+ const OUString sGroupShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GroupShape" ) );
+ Reference< XShape > xShape( rxShapes->getByIndex( i ), UNO_QUERY_THROW );
+ const OUString sShapeType( xShape->getShapeType() );
+ if ( sShapeType == sGroupShape )
+ {
+ Reference< XShapes > xShapes( xShape, UNO_QUERY_THROW );
+ ImpCountGraphicObjects( rxMSF, xShapes, rGraphicSettings, rnGraphics );
+ continue;
+ }
+
+ if ( sShapeType == sGraphicObjectShape )
+ {
+ rnGraphics++;
+ }
+
+ // now check for a fillstyle
+ Reference< XPropertySet > xEmptyPagePropSet;
+ Reference< XPropertySet > xShapePropertySet( xShape, UNO_QUERY_THROW );
+ awt::Size aLogicalSize( xShape->getSize() );
+
+ FillStyle eFillStyle;
+ if ( xShapePropertySet->getPropertyValue( TKGet( TK_FillStyle ) ) >>= eFillStyle )
+ {
+ if ( eFillStyle == FillStyle_BITMAP )
+ {
+ rnGraphics++;
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ }
+ }
+}
+
+void ImpCountBackgroundGraphic( const Reference< XComponentContext >& /* rxMSF */, const Reference< XDrawPage >& rxDrawPage,
+ const GraphicSettings& /* rGraphicSettings */, sal_Int32& rnGraphics )
+{
+ try
+ {
+ awt::Size aLogicalSize( 28000, 21000 );
+ Reference< XPropertySet > xPropertySet( rxDrawPage, UNO_QUERY_THROW );
+ xPropertySet->getPropertyValue( TKGet( TK_Width ) ) >>= aLogicalSize.Width;
+ xPropertySet->getPropertyValue( TKGet( TK_Height ) ) >>= aLogicalSize.Height;
+
+ Reference< XPropertySet > xBackgroundPropSet;
+ if ( xPropertySet->getPropertyValue( TKGet( TK_Background ) ) >>= xBackgroundPropSet )
+ {
+ FillStyle eFillStyle;
+ if ( xBackgroundPropSet->getPropertyValue( TKGet( TK_FillStyle ) ) >>= eFillStyle )
+ {
+ if ( eFillStyle == FillStyle_BITMAP )
+ {
+ rnGraphics++;
+ }
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ }
+}
+
+void GraphicCollector::CountGraphics( const Reference< XComponentContext >& rxMSF, const Reference< XModel >& rxModel,
+ const GraphicSettings& rGraphicSettings, sal_Int32& rnGraphics )
+{
+ try
+ {
+ sal_Int32 i;
+ Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
+ Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
+ for ( i = 0; i < xDrawPages->getCount(); i++ )
+ {
+ Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
+ ImpCountBackgroundGraphic( rxMSF, xDrawPage, rGraphicSettings, rnGraphics );
+ Reference< XShapes > xDrawShapes( xDrawPage, UNO_QUERY_THROW );
+ ImpCountGraphicObjects( rxMSF, xDrawShapes, rGraphicSettings, rnGraphics );
+
+ Reference< XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW );
+ Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() );
+ ImpCountBackgroundGraphic( rxMSF, xNotesPage, rGraphicSettings, rnGraphics );
+ Reference< XShapes > xNotesShapes( xNotesPage, UNO_QUERY_THROW );
+ ImpCountGraphicObjects( rxMSF, xNotesShapes, rGraphicSettings, rnGraphics );
+ }
+ Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW );
+ Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
+ for ( i = 0; i < xMasterPages->getCount(); i++ )
+ {
+ Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW );
+ ImpCountBackgroundGraphic( rxMSF, xMasterPage, rGraphicSettings, rnGraphics );
+ Reference< XShapes > xMasterPageShapes( xMasterPage, UNO_QUERY_THROW );
+ ImpCountGraphicObjects( rxMSF, xMasterPageShapes, rGraphicSettings, rnGraphics );
+ }
+ }
+ catch ( Exception& )
+ {
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/graphiccollector.hxx b/sdext/source/minimizer/graphiccollector.hxx
new file mode 100644
index 000000000000..488cc46b8bfc
--- /dev/null
+++ b/sdext/source/minimizer/graphiccollector.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef GRAPHICCOLLECTOR_HXX
+#define GRAPHICCOLLECTOR_HXX
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/awt/DeviceInfo.hpp>
+#include <com/sun/star/text/GraphicCrop.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <vector>
+
+
+struct GraphicSettings
+{
+ sal_Bool mbJPEGCompression;
+ sal_Int32 mnJPEGQuality;
+ sal_Bool mbRemoveCropArea;
+ sal_Int32 mnImageResolution;
+ sal_Bool mbEmbedLinkedGraphics;
+
+ GraphicSettings( sal_Bool bJPEGCompression, sal_Int32 nJPEGQuality, sal_Bool bRemoveCropArea,
+ sal_Int32 nImageResolution, sal_Bool bEmbedLinkedGraphics )
+ : mbJPEGCompression( bJPEGCompression )
+ , mnJPEGQuality( nJPEGQuality )
+ , mbRemoveCropArea( bRemoveCropArea )
+ , mnImageResolution( nImageResolution )
+ , mbEmbedLinkedGraphics( bEmbedLinkedGraphics ) {};
+};
+
+class GraphicCollector
+{
+ public:
+
+ struct GraphicUser
+ {
+ com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxShape; // if mbFillBitmap is false the xShape has
+ com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > mxPropertySet; // to be used otherwise the PropertySet
+ com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > mxPagePropertySet;
+ rtl::OUString maGraphicURL;
+ rtl::OUString maGraphicStreamURL;
+ com::sun::star::text::GraphicCrop maGraphicCropLogic;
+ com::sun::star::awt::Size maLogicalSize;
+ sal_Bool mbFillBitmap;
+
+ GraphicUser() : mxShape(), maGraphicCropLogic( 0, 0, 0, 0 ), mbFillBitmap( sal_False ) {};
+ };
+
+ struct GraphicEntity
+ {
+ com::sun::star::awt::Size maLogicalSize; // the biggest logical size the graphic will be displayed
+ sal_Bool mbRemoveCropArea; //
+ com::sun::star::text::GraphicCrop maGraphicCropLogic;
+ std::vector< GraphicUser > maUser;
+
+ GraphicEntity( const GraphicUser& rUser )
+ : maLogicalSize( rUser.maLogicalSize ), mbRemoveCropArea( sal_False ), maGraphicCropLogic( 0, 0, 0, 0 ) { maUser.push_back( rUser ); };
+ };
+
+ static const com::sun::star::awt::DeviceInfo& GetDeviceInfo( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxFact );
+ static com::sun::star::awt::Size GetOriginalSize( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxMSF,
+ const com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic >& rxGraphic );
+
+ // collecting graphic instances, the downside of this method is that every graphic is swapped in
+ static void CollectGraphics( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxMSF, const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel,
+ const GraphicSettings& rGraphicSettings, std::vector< GraphicEntity >& io_rGraphicList );
+ // counting graphics without swapping in graphics
+ static void CountGraphics( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxMSF, const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel,
+ const GraphicSettings& rGraphicSettings, sal_Int32& rGraphics );
+};
+
+// --------------------
+// - GRAPHICCOLLECTOR -
+// --------------------
+
+
+#endif // GRAPHICCOLLECTOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/help/component.txt b/sdext/source/minimizer/help/component.txt
new file mode 100755
index 000000000000..98f2687800ff
--- /dev/null
+++ b/sdext/source/minimizer/help/component.txt
@@ -0,0 +1,2 @@
+The Presentation Minimizer is used to reduce the file size of the current presentation. Images will be compressed, and data that is no longer needed will be removed.
+The Presentation Minimizer can optimize the image quality size. Presentations designed for screen or projector do not require the same high quality as presentations designed for print.
diff --git a/sdext/source/minimizer/help/help_de.odt b/sdext/source/minimizer/help/help_de.odt
new file mode 100644
index 000000000000..bb9bc0395c0f
--- /dev/null
+++ b/sdext/source/minimizer/help/help_de.odt
Binary files differ
diff --git a/sdext/source/minimizer/help/help_en-US.odt b/sdext/source/minimizer/help/help_en-US.odt
new file mode 100644
index 000000000000..bb9bc0395c0f
--- /dev/null
+++ b/sdext/source/minimizer/help/help_en-US.odt
Binary files differ
diff --git a/sdext/source/minimizer/impoptimizer.cxx b/sdext/source/minimizer/impoptimizer.cxx
new file mode 100644
index 000000000000..2c1f826140bc
--- /dev/null
+++ b/sdext/source/minimizer/impoptimizer.cxx
@@ -0,0 +1,770 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "impoptimizer.hxx"
+#include "pppoptimizer.hxx"
+#include "graphiccollector.hxx"
+#include "pagecollector.hxx"
+#include "informationdialog.hxx"
+
+#include <unotools/localfilehelper.hxx>
+#include <unotools/processfactory.hxx>
+#include <vector>
+#include "com/sun/star/util/URL.hpp"
+#include "com/sun/star/util/XURLTransformer.hpp"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include <unotools/configmgr.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/drawing/XMasterPageTarget.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
+#include <com/sun/star/presentation/XPresentationSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/presentation/XPresentation.hpp>
+#include <com/sun/star/presentation/XPresentationPage.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include <com/sun/star/graphic/GraphicType.hpp>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/util/URL.hpp>
+
+using namespace ::std;
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::graphic;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::presentation;
+
+void ImpExtractCustomShow( const Reference< XModel >& rxModel, const OUString& rCustomShowName )
+{
+ vector< Reference< XDrawPage > > vNonUsedPageList;
+ try
+ {
+ PageCollector::CollectNonCustomShowPages( rxModel, rCustomShowName, vNonUsedPageList );
+ Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
+ Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
+ vector< Reference< XDrawPage > >::iterator aIter( vNonUsedPageList.begin() );
+ while( aIter != vNonUsedPageList.end() )
+ xDrawPages->remove( *aIter++ );
+ }
+ catch( Exception& )
+ {
+
+ }
+}
+
+void ImpDeleteUnusedMasterPages( const Reference< XModel >& rxModel )
+{
+ vector< PageCollector::MasterPageEntity > aMasterPageList;
+ PageCollector::CollectMasterPages( rxModel, aMasterPageList );
+
+ // now master pages that are not marked can be deleted
+ Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW );
+ Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
+ vector< PageCollector::MasterPageEntity >::iterator aIter( aMasterPageList.begin() );
+ while( aIter != aMasterPageList.end() )
+ {
+ if ( !aIter->bUsed )
+ xMasterPages->remove( aIter->xMasterPage );
+ ++aIter;
+ }
+}
+
+void ImpDeleteHiddenSlides( const Reference< XModel >& rxModel )
+{
+ try
+ {
+ Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, 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 )
+ {
+ xDrawPages->remove( xDrawPage );
+ i--;
+ }
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ }
+}
+
+void ImpDeleteNotesPages( const Reference< XModel >& rxModel )
+{
+ try
+ {
+ Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
+ Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
+ sal_Int32 i, nPages = xDrawPages->getCount();
+ for( i = 0; i < nPages; i++ )
+ {
+ Reference< XPresentationPage > xPresentationPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
+ Reference< XPropertySet > xPropSet( xPresentationPage->getNotesPage(), UNO_QUERY_THROW );
+ Reference< XShapes > xShapes( xPropSet, UNO_QUERY_THROW );
+ while( xShapes->getCount() )
+ xShapes->remove( Reference< XShape >( xShapes->getByIndex( xShapes->getCount() - 1 ), UNO_QUERY_THROW ) );
+
+ const OUString sLayout( RTL_CONSTASCII_USTRINGPARAM( "Layout" ) );
+ xPropSet->setPropertyValue( sLayout, Any( (sal_Int16)21 ) );
+ }
+ }
+ catch( Exception& )
+ {
+ }
+}
+
+void ImpConvertOLE( const Reference< XModel >& rxModel, sal_Int32 nOLEOptimizationType )
+{
+ try
+ {
+ Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, 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 )
+ {
+ Reference< XPropertySet > xPropSet( xShape, UNO_QUERY_THROW );
+
+ sal_Bool bConvertOLE = nOLEOptimizationType == 0;
+ if ( nOLEOptimizationType == 1 )
+ {
+ sal_Bool bIsInternal = sal_True;
+ xPropSet->getPropertyValue( TKGet( TK_IsInternal ) ) >>= bIsInternal;
+ bConvertOLE = !bIsInternal;
+ }
+ if ( bConvertOLE )
+ {
+ Reference< XGraphic > xGraphic;
+ if ( xPropSet->getPropertyValue( TKGet( TK_Graphic ) ) >>= xGraphic )
+ {
+ const OUString sGraphicShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicObjectShape" ) );
+ Reference< XMultiServiceFactory > xFact( rxModel, UNO_QUERY_THROW );
+ Reference< XShape > xShape2( xFact->createInstance( sGraphicShape ), UNO_QUERY_THROW );
+ xShapes->add( xShape2 );
+ xShape2->setPosition( xShape->getPosition() );
+ xShape2->setSize( xShape->getSize() );
+ Reference< XPropertySet > xPropSet2( xShape2, UNO_QUERY_THROW );
+ xPropSet2->setPropertyValue( TKGet( TK_Graphic ), Any( xGraphic ) );
+ xShapes->remove( xShape );
+ xPropSet2->setPropertyValue( TKGet( TK_ZOrder ), Any( j ) );
+ }
+ }
+ }
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ }
+}
+
+void ImpCompressGraphic( Reference< XGraphicProvider >& rxGraphicProvider, const Reference< XGraphic >& rxGraphic, Reference< XOutputStream >& rxOutputStream,
+ const OUString& rDestMimeType, const awt::Size& rLogicalSize, sal_Int32 nJPEGQuality, sal_Int32 nImageResolution, sal_Bool bRemoveCropping, const text::GraphicCrop& rGraphicCropLogic )
+{
+ try
+ {
+ if ( rxGraphicProvider.is() && rxOutputStream.is() )
+ {
+ Sequence< PropertyValue > aFilterData( 8 );
+ aFilterData[ 0 ].Name = TKGet( TK_ImageResolution );
+ aFilterData[ 0 ].Value <<= nImageResolution;
+ aFilterData[ 1 ].Name = TKGet( TK_ColorMode ); // todo: jpeg color mode (0->true color, 1->greyscale)
+ aFilterData[ 1 ].Value <<= (sal_Int32)0;
+ aFilterData[ 2 ].Name = TKGet( TK_Quality ); // quality that is used if we export to jpeg
+ aFilterData[ 2 ].Value <<= nJPEGQuality;
+ aFilterData[ 3 ].Name = TKGet( TK_Compression ); // compression that is used if we export to png
+ aFilterData[ 3 ].Value <<= (sal_Int32)6;
+ aFilterData[ 4 ].Name = TKGet( TK_Interlaced ); // interlaced is turned off if we export to png
+ aFilterData[ 4 ].Value <<= (sal_Int32)0;
+ aFilterData[ 5 ].Name = TKGet( TK_LogicalSize );
+ aFilterData[ 5 ].Value <<= rLogicalSize;
+ aFilterData[ 6 ].Name = TKGet( TK_RemoveCropArea );
+ aFilterData[ 6 ].Value <<= bRemoveCropping;
+ aFilterData[ 7 ].Name = TKGet( TK_GraphicCropLogic );
+ aFilterData[ 7 ].Value <<= rGraphicCropLogic;
+
+ Sequence< PropertyValue > aArgs( 3 );
+ aArgs[ 0 ].Name = TKGet( TK_MimeType ); // the GraphicProvider is using "MimeType", the GraphicExporter "MediaType"...
+ aArgs[ 0 ].Value <<= rDestMimeType;
+ aArgs[ 1 ].Name = TKGet( TK_OutputStream );
+ aArgs[ 1 ].Value <<= rxOutputStream;
+ aArgs[ 2 ].Name = TKGet( TK_FilterData );
+ aArgs[ 2 ].Value <<= aFilterData;
+
+ rxGraphicProvider->storeGraphic( rxGraphic, aArgs );
+ }
+ }
+ catch( Exception& )
+ {
+ }
+}
+
+Reference< XGraphic > ImpCompressGraphic( const Reference< XComponentContext >& rxMSF,
+ const Reference< XGraphic >& xGraphic, const awt::Size& aLogicalSize, const text::GraphicCrop& aGraphicCropLogic,
+ const GraphicSettings& rGraphicSettings )
+{
+ Reference< XGraphic > xNewGraphic;
+ try
+ {
+ OUString aSourceMimeType;
+ Reference< XPropertySet > xGraphicPropertySet( xGraphic, UNO_QUERY_THROW );
+ if ( xGraphicPropertySet->getPropertyValue( TKGet( TK_MimeType ) ) >>= aSourceMimeType )
+ {
+ sal_Int8 nGraphicType( xGraphic->getType() );
+ if ( nGraphicType == com::sun::star::graphic::GraphicType::PIXEL )
+ {
+ sal_Bool bTransparent = sal_False;
+ sal_Bool bAlpha = sal_False;
+ sal_Bool bAnimated = sal_False;
+
+ awt::Size aSourceSizePixel( 0, 0 );
+ text::GraphicCrop aGraphicCropPixel( 0, 0, 0, 0 );
+
+ if ( ( xGraphicPropertySet->getPropertyValue( TKGet( TK_SizePixel ) ) >>= aSourceSizePixel ) &&
+ ( xGraphicPropertySet->getPropertyValue( TKGet( TK_Transparent ) ) >>= bTransparent ) &&
+ ( xGraphicPropertySet->getPropertyValue( TKGet( TK_Alpha ) ) >>= bAlpha ) &&
+ ( xGraphicPropertySet->getPropertyValue( TKGet( TK_Animated ) ) >>= bAnimated ) )
+ {
+ awt::Size aDestSizePixel( aSourceSizePixel );
+ if ( !bAnimated )
+ {
+ sal_Bool bNeedsOptimizing = sal_False;
+ sal_Bool bRemoveCropArea( rGraphicSettings.mbRemoveCropArea );
+
+ // cropping has to be removed from SourceSizePixel
+ if ( aGraphicCropLogic.Left || aGraphicCropLogic.Top || aGraphicCropLogic.Right || aGraphicCropLogic.Bottom )
+ {
+ const awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) );
+
+ if ( bRemoveCropArea )
+ bNeedsOptimizing = sal_True;
+
+ if ( aSize100thMM.Width && aSize100thMM.Height )
+ {
+ aGraphicCropPixel.Left = static_cast< sal_Int32 >( ( (double)aSourceSizePixel.Width * aGraphicCropLogic.Left ) / aSize100thMM.Width );
+ aGraphicCropPixel.Top = static_cast< sal_Int32 >( ( (double)aSourceSizePixel.Height* aGraphicCropLogic.Top ) / aSize100thMM.Height );
+ aGraphicCropPixel.Right = static_cast< sal_Int32 >( ( (double)aSourceSizePixel.Width * ( aSize100thMM.Width - aGraphicCropLogic.Right ) ) / aSize100thMM.Width );
+ aGraphicCropPixel.Bottom = static_cast< sal_Int32 >( ( (double)aSourceSizePixel.Height* ( aSize100thMM.Height - aGraphicCropLogic.Bottom ) ) / aSize100thMM.Height );
+
+ // first calculating new SourceSizePixel by removing the cropped area
+ aSourceSizePixel.Width = aGraphicCropPixel.Right - aGraphicCropPixel.Left;
+ aSourceSizePixel.Height= aGraphicCropPixel.Bottom - aGraphicCropPixel.Top;
+ }
+ else
+ {
+ bRemoveCropArea = sal_False;
+ }
+ }
+ if ( ( aSourceSizePixel.Width > 0 ) && ( aSourceSizePixel.Height > 0 ) )
+ {
+ OUString aDestMimeType( RTL_CONSTASCII_USTRINGPARAM( "image/png" ) );
+ if ( rGraphicSettings.mbJPEGCompression && !bTransparent && !bAlpha && !bAnimated )
+ {
+ aDestMimeType = OUString( RTL_CONSTASCII_USTRINGPARAM( "image/jpeg" ) );
+// if( aSourceMimeType != aDestMimeType )
+ bNeedsOptimizing = sal_True;
+ }
+ if ( bRemoveCropArea )
+ aDestSizePixel = aSourceSizePixel;
+ if ( rGraphicSettings.mnImageResolution && aLogicalSize.Width && aLogicalSize.Height )
+ {
+ const double fSourceDPIX = ((double)aSourceSizePixel.Width / ((double)aLogicalSize.Width / 2540.0 ));
+ const double fSourceDPIY = ((double)aSourceSizePixel.Height/ ((double)aLogicalSize.Height/ 2540.0 ));
+
+ // check, if the bitmap DPI exceeds the maximum DPI
+ if( ( fSourceDPIX > rGraphicSettings.mnImageResolution ) || ( fSourceDPIY > rGraphicSettings.mnImageResolution ) )
+ {
+ const double fNewSizePixelX = ((double)aDestSizePixel.Width * rGraphicSettings.mnImageResolution ) / fSourceDPIX;
+ const double fNewSizePixelY = ((double)aDestSizePixel.Height* rGraphicSettings.mnImageResolution ) / fSourceDPIY;
+
+ aDestSizePixel = awt::Size( (sal_Int32)fNewSizePixelX, (sal_Int32)fNewSizePixelY );
+ bNeedsOptimizing = sal_True;
+ }
+ }
+ if ( bNeedsOptimizing && aDestSizePixel.Width && aDestSizePixel.Height )
+ {
+ Reference< XStream > xTempFile( rxMSF->getServiceManager()->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.TempFile")), rxMSF ), UNO_QUERY_THROW );
+ Reference< XOutputStream > xOutputStream( xTempFile->getOutputStream() );
+ Reference< XGraphicProvider > xGraphicProvider( rxMSF->getServiceManager()->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.GraphicProvider")), rxMSF ), UNO_QUERY_THROW );
+
+ ImpCompressGraphic( xGraphicProvider, xGraphic, xOutputStream, aDestMimeType, aLogicalSize, rGraphicSettings.mnJPEGQuality, rGraphicSettings.mnImageResolution, bRemoveCropArea, aGraphicCropLogic );
+ Reference< XInputStream > xInputStream( xTempFile->getInputStream() );
+ Reference< XSeekable > xSeekable( xInputStream, UNO_QUERY_THROW );
+ xSeekable->seek( 0 );
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[ 0 ].Name = TKGet( TK_InputStream );
+ aArgs[ 0 ].Value <<= xInputStream;
+ xNewGraphic = xGraphicProvider->queryGraphic( aArgs );
+ }
+ }
+ }
+ }
+ }
+ else // this is a metafile
+ {
+ rtl::OUString aDestMimeType( aSourceMimeType );
+ Reference< XStream > xTempFile( rxMSF->getServiceManager()->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.TempFile")), rxMSF ), UNO_QUERY_THROW );
+ Reference< XOutputStream > xOutputStream( xTempFile->getOutputStream() );
+ Reference< XGraphicProvider > xGraphicProvider( rxMSF->getServiceManager()->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.GraphicProvider")), rxMSF ), UNO_QUERY_THROW );
+ ImpCompressGraphic( xGraphicProvider, xGraphic, xOutputStream, aDestMimeType, aLogicalSize, rGraphicSettings.mnJPEGQuality, rGraphicSettings.mnImageResolution, sal_False, aGraphicCropLogic );
+ Reference< XInputStream > xInputStream( xTempFile->getInputStream() );
+ Reference< XSeekable > xSeekable( xInputStream, UNO_QUERY_THROW );
+ xSeekable->seek( 0 );
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[ 0 ].Name = TKGet( TK_InputStream );
+ aArgs[ 0 ].Value <<= xInputStream;
+ xNewGraphic = xGraphicProvider->queryGraphic( aArgs );
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ }
+ return xNewGraphic;
+}
+
+void CompressGraphics( ImpOptimizer& rOptimizer, const Reference< XComponentContext >& rxMSF, const GraphicSettings& rGraphicSettings,
+ std::vector< GraphicCollector::GraphicEntity >& rGraphicList )
+{
+ try
+ {
+ std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIter( rGraphicList.begin() );
+ std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIEnd( rGraphicList.end() );
+ double i = 0;
+ while( aGraphicIter != aGraphicIEnd )
+ {
+ i++;
+ sal_Int32 nProgress = static_cast< sal_Int32 >( 40.0 * ( i / static_cast< double >( rGraphicList.size() ) ) ) + 50;
+ rOptimizer.SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( nProgress ) ) );
+ rOptimizer.DispatchStatus();
+
+ if ( aGraphicIter->maUser.size() )
+ {
+ GraphicSettings aGraphicSettings( rGraphicSettings );
+ aGraphicSettings.mbRemoveCropArea = aGraphicIter->mbRemoveCropArea;
+
+ Reference< XGraphic > xGraphic;
+ if ( aGraphicIter->maUser[ 0 ].mbFillBitmap && aGraphicIter->maUser[ 0 ].mxPropertySet.is() )
+ {
+ Reference< XBitmap > xFillBitmap;
+ if ( aGraphicIter->maUser[ 0 ].mxPropertySet->getPropertyValue( TKGet( TK_FillBitmap ) ) >>= xFillBitmap )
+ xGraphic = Reference< XGraphic >( xFillBitmap, UNO_QUERY_THROW );
+ }
+ else if ( aGraphicIter->maUser[ 0 ].mxShape.is() )
+ {
+ Reference< XPropertySet > xShapePropertySet( aGraphicIter->maUser[ 0 ].mxShape, UNO_QUERY_THROW );
+ xShapePropertySet->getPropertyValue( TKGet( TK_Graphic ) ) >>= xGraphic;
+ }
+ if ( xGraphic.is() )
+ {
+ Reference< XPropertySet > xNewGraphicPropertySet( xGraphic, UNO_QUERY_THROW );
+ awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) );
+ Reference< XGraphic > xNewGraphic( ImpCompressGraphic( rxMSF, xGraphic, aGraphicIter->maLogicalSize, aGraphicIter->maGraphicCropLogic, aGraphicSettings ) );
+ if ( xNewGraphic.is() )
+ {
+ // applying graphic to each user
+ std::vector< GraphicCollector::GraphicUser >::iterator aGraphicUserIter( aGraphicIter->maUser.begin() );
+ while( aGraphicUserIter != aGraphicIter->maUser.end() )
+ {
+ if ( aGraphicUserIter->mxShape.is() )
+ {
+ rtl::OUString sEmptyGraphicURL;
+ Reference< XPropertySet > xShapePropertySet( aGraphicUserIter->mxShape, UNO_QUERY_THROW );
+ xShapePropertySet->setPropertyValue( TKGet( TK_GraphicURL ), Any( sEmptyGraphicURL ) );
+ xShapePropertySet->setPropertyValue( TKGet( TK_Graphic ), Any( xNewGraphic ) );
+
+ if ( aGraphicUserIter->maGraphicCropLogic.Left || aGraphicUserIter->maGraphicCropLogic.Top
+ || aGraphicUserIter->maGraphicCropLogic.Right || aGraphicUserIter->maGraphicCropLogic.Bottom )
+ { // removing crop area was not possible or should't been applied
+ text::GraphicCrop aGraphicCropLogic( 0, 0, 0, 0 );
+ if ( !aGraphicSettings.mbRemoveCropArea )
+ {
+ awt::Size aNewSize( GraphicCollector::GetOriginalSize( rxMSF, xNewGraphic ) );
+ aGraphicCropLogic.Left = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Left * ((double)aNewSize.Width / (double)aSize100thMM.Width));
+ aGraphicCropLogic.Top = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Top * ((double)aNewSize.Height / (double)aSize100thMM.Height));
+ aGraphicCropLogic.Right = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Right * ((double)aNewSize.Width / (double)aSize100thMM.Width));
+ aGraphicCropLogic.Bottom = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Bottom * ((double)aNewSize.Height / (double)aSize100thMM.Height));
+ }
+ xShapePropertySet->setPropertyValue( TKGet( TK_GraphicCrop ), Any( aGraphicCropLogic ) );
+ }
+ }
+ else if ( aGraphicUserIter->mxPropertySet.is() )
+ {
+ Reference< XBitmap > xFillBitmap( xNewGraphic, UNO_QUERY );
+ if ( xFillBitmap.is() )
+ {
+ awt::Size aSize;
+ sal_Bool bLogicalSize;
+
+ Reference< XPropertySet >& rxPropertySet( aGraphicUserIter->mxPropertySet );
+ rxPropertySet->setPropertyValue( TKGet( TK_FillBitmap ), Any( xFillBitmap ) );
+ if ( ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapLogicalSize ) ) >>= bLogicalSize )
+ && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeX ) ) >>= aSize.Width )
+ && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeY ) ) >>= aSize.Height ) )
+ {
+ if ( !aSize.Width || !aSize.Height )
+ {
+ rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapLogicalSize ), Any( sal_True ) );
+ rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapSizeX ), Any( aGraphicUserIter->maLogicalSize.Width ) );
+ rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapSizeY ), Any( aGraphicUserIter->maLogicalSize.Height ) );
+ }
+ }
+ if ( aGraphicUserIter->mxPagePropertySet.is() )
+ aGraphicUserIter->mxPagePropertySet->setPropertyValue( TKGet( TK_Background ), Any( rxPropertySet ) );
+ }
+ }
+ ++aGraphicUserIter;
+ }
+ }
+ }
+ }
+ ++aGraphicIter;
+ }
+ }
+ catch ( Exception& )
+ {
+ }
+}
+
+// ----------------
+// - ImpOptimizer -
+// ----------------
+
+ImpOptimizer::ImpOptimizer( const Reference< XComponentContext >& rxMSF, const Reference< XModel >& rxModel ) :
+ mxMSF ( rxMSF ),
+ mxModel ( rxModel ),
+ mbJPEGCompression ( sal_False ),
+ mnJPEGQuality ( 90 ),
+ mbRemoveCropArea ( sal_False ),
+ mnImageResolution ( 0 ),
+ mbEmbedLinkedGraphics ( sal_True ),
+ mbOLEOptimization ( sal_False ),
+ mnOLEOptimizationType ( 0 ),
+ mbDeleteUnusedMasterPages ( sal_False ),
+ mbDeleteHiddenSlides ( sal_False ),
+ mbDeleteNotesPages ( sal_False ),
+ mbOpenNewDocument ( sal_True )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+ImpOptimizer::~ImpOptimizer()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpOptimizer::DispatchStatus()
+{
+ if ( mxStatusDispatcher.is() )
+ {
+ URL aURL;
+ aURL.Protocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.com.sun.star.comp.SunPresentationMinimizer:" ) );
+ aURL.Path = OUString( RTL_CONSTASCII_USTRINGPARAM( "statusupdate" ) );
+ mxStatusDispatcher->dispatch( aURL, GetStatusSequence() );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool ImpOptimizer::Optimize()
+{
+
+ if ( maCustomShowName.getLength() )
+ ImpExtractCustomShow( mxModel, maCustomShowName );
+
+ if ( mbDeleteUnusedMasterPages )
+ {
+ SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 40 ) ) );
+ SetStatusValue( TK_Status, Any( TKGet( STR_DELETING_SLIDES ) ) );
+ DispatchStatus();
+ ImpDeleteUnusedMasterPages( mxModel );
+ }
+
+ if ( mbDeleteHiddenSlides )
+ {
+ SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 40 ) ) );
+ SetStatusValue( TK_Status, Any( TKGet( STR_DELETING_SLIDES ) ) );
+ DispatchStatus();
+ ImpDeleteHiddenSlides( mxModel );
+ }
+
+ if ( mbDeleteNotesPages )
+ {
+ SetStatusValue( TK_Status, Any( TKGet( STR_DELETING_SLIDES ) ) );
+ DispatchStatus();
+ ImpDeleteNotesPages( mxModel );
+ }
+
+ if ( mbOLEOptimization )
+ {
+ SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 45 ) ) );
+ SetStatusValue( TK_Status, Any( TKGet( STR_CREATING_OLE_REPLACEMENTS ) ) );
+ DispatchStatus();
+ ImpConvertOLE( mxModel, mnOLEOptimizationType );
+ }
+
+ if ( mbJPEGCompression || mbRemoveCropArea || mnImageResolution )
+ {
+ SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 50 ) ) );
+ SetStatusValue( TK_Status, Any( TKGet( STR_OPTIMIZING_GRAPHICS ) ) );
+ DispatchStatus();
+
+ std::vector< GraphicCollector::GraphicEntity > aGraphicList;
+ GraphicSettings aGraphicSettings( mbJPEGCompression, mnJPEGQuality, mbRemoveCropArea, mnImageResolution, mbEmbedLinkedGraphics );
+ GraphicCollector::CollectGraphics( mxMSF, mxModel, aGraphicSettings, aGraphicList );
+ CompressGraphics( *this, mxMSF, aGraphicSettings, aGraphicList );
+ }
+ SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 100 ) ) );
+ DispatchStatus();
+ return sal_True;
+}
+
+static void DispatchURL( Reference< XComponentContext > xMSF, OUString sURL, Reference< XFrame > xFrame )
+{
+ try
+ {
+ Reference< XURLTransformer > xURLTransformer( xMSF->getServiceManager()->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ) ), xMSF ), UNO_QUERY_THROW );
+ util::URL aUrl;
+ aUrl.Complete = sURL;
+ xURLTransformer->parseStrict( aUrl );
+ Sequence< PropertyValue > aArgs;
+ Reference< XDispatchProvider > xDispatchProvider( xFrame, UNO_QUERY_THROW );
+ Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aUrl, OUString(), 0 ); // "_self"
+ if ( xDispatch.is() )
+ xDispatch->dispatch( aUrl, aArgs );
+ }
+ catch( Exception& )
+ {
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool ImpOptimizer::Optimize( const Sequence< PropertyValue >& rArguments )
+{
+ sal_Bool bRet = sal_True;
+
+ if ( mxModel.is() )
+ {
+ sal_Int64 nEstimatedFileSize = 0;
+ SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 0 ) ) );
+ DispatchStatus();
+
+ int i, nICount;
+ for ( i = 0, nICount = rArguments.getLength(); i < nICount; i++ )
+ {
+ switch( TKGet( rArguments[ i ].Name ) )
+ {
+ case TK_StatusDispatcher : rArguments[ i ].Value >>= mxStatusDispatcher; break;
+ case TK_InformationDialog: rArguments[ i ].Value >>= mxInformationDialog; break;
+ case TK_Settings :
+ {
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aSettings;
+ int j, nJCount;
+ rArguments[ i ].Value >>= aSettings;
+ for ( j = 0, nJCount = aSettings.getLength(); j < nJCount; j++ )
+ {
+ switch( TKGet( aSettings[ j ].Name ) )
+ {
+ case TK_JPEGCompression : aSettings[ j ].Value >>= mbJPEGCompression; break;
+ case TK_JPEGQuality : aSettings[ j ].Value >>= mnJPEGQuality; break;
+ case TK_RemoveCropArea : aSettings[ j ].Value >>= mbRemoveCropArea; break;
+ case TK_ImageResolution : aSettings[ j ].Value >>= mnImageResolution; break;
+ case TK_EmbedLinkedGraphics : aSettings[ j ].Value >>= mbEmbedLinkedGraphics; break;
+ case TK_OLEOptimization : aSettings[ j ].Value >>= mbOLEOptimization; break;
+ case TK_OLEOptimizationType : aSettings[ j ].Value >>= mnOLEOptimizationType; break;
+ case TK_CustomShowName : aSettings[ j ].Value >>= maCustomShowName; break;
+ case TK_DeleteUnusedMasterPages : aSettings[ j ].Value >>= mbDeleteUnusedMasterPages; break;
+ case TK_DeleteHiddenSlides : aSettings[ j ].Value >>= mbDeleteHiddenSlides; break;
+ case TK_DeleteNotesPages : aSettings[ j ].Value >>= mbDeleteNotesPages; break;
+ case TK_SaveAsURL : aSettings[ j ].Value >>= maSaveAsURL; break;
+ case TK_FilterName : aSettings[ j ].Value >>= maFilterName; break;
+ case TK_OpenNewDocument : aSettings[ j ].Value >>= mbOpenNewDocument; break;
+ case TK_EstimatedFileSize : aSettings[ j ].Value >>= nEstimatedFileSize; break;
+ default: break;
+ }
+ }
+ }
+ break;
+ default: break;
+ }
+ }
+
+ sal_Int64 nSourceSize = 0;
+ sal_Int64 nDestSize = 0;
+
+ Reference< XFrame > xSelf;
+ if ( maSaveAsURL.getLength() )
+ {
+
+ SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 10 ) ) );
+ SetStatusValue( TK_Status, Any( TKGet( STR_DUPLICATING_PRESENTATION ) ) );
+ DispatchStatus();
+
+ Reference< XStorable >xStorable( mxModel, UNO_QUERY );
+ if ( xStorable.is() )
+ {
+ if ( xStorable->hasLocation() )
+ nSourceSize = PPPOptimizer::GetFileSize( xStorable->getLocation() );
+
+ Sequence< PropertyValue > aArguments;
+ if ( maFilterName.getLength() )
+ {
+ int nLength = aArguments.getLength();
+ aArguments.realloc( nLength + 1 );
+ aArguments[ nLength ].Name = TKGet( TK_FilterName );
+ aArguments[ nLength ].Value <<= maFilterName;
+ }
+ xStorable->storeToURL( maSaveAsURL, aArguments );
+ if ( !nSourceSize )
+ nSourceSize = PPPOptimizer::GetFileSize( maSaveAsURL );
+
+ SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 30 ) ) );
+ SetStatusValue( TK_Status, Any( TKGet( STR_DUPLICATING_PRESENTATION ) ) );
+ DispatchStatus();
+
+ Reference< XDesktop > xDesktop( mxMSF->getServiceManager()->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ), mxMSF ), UNO_QUERY );
+ Reference< XFrame > xFrame( xDesktop, UNO_QUERY );
+ xSelf = xFrame->findFrame( TKGet( TK__blank ), FrameSearchFlag::CREATE );
+ Reference< XComponentLoader > xComponentLoader( xSelf, UNO_QUERY );
+
+ Sequence< PropertyValue > aLoadProps( 1 );
+ aLoadProps[ 0 ].Name = TKGet( TK_Hidden );
+ aLoadProps[ 0 ].Value <<= (sal_Bool)( sal_True );
+ mxModel = Reference< XModel >( xComponentLoader->loadComponentFromURL(
+ maSaveAsURL, TKGet( TK__self ), 0, aLoadProps ), UNO_QUERY );
+ }
+ }
+
+ // check if the document is ReadOnly -> error
+ Reference< XStorable > xStorable( mxModel, UNO_QUERY );
+ if ( xStorable.is() && !xStorable->isReadonly() )
+ {
+ mxModel->lockControllers();
+ bRet = Optimize();
+ mxModel->unlockControllers();
+
+ // clearing undo stack:
+ Reference< XFrame > xFrame( xSelf.is() ? xSelf : mxInformationDialog );
+ if ( xFrame.is() )
+ {
+ const OUString sSlot( RTL_CONSTASCII_USTRINGPARAM( "slot:27115" ) );
+ DispatchURL( mxMSF, sSlot, xFrame );
+ }
+ }
+
+ if ( maSaveAsURL.getLength() )
+ {
+ if ( xStorable.is() )
+ {
+ xStorable->store();
+ nDestSize = PPPOptimizer::GetFileSize( maSaveAsURL );
+ }
+ }
+
+ if ( mxInformationDialog.is() )
+ {
+ InformationDialog aInformationDialog( mxMSF, mxInformationDialog, maSaveAsURL, mbOpenNewDocument, nSourceSize, nDestSize, nEstimatedFileSize );
+ aInformationDialog.execute();
+ SetStatusValue( TK_OpenNewDocument, Any( mbOpenNewDocument ) );
+ DispatchStatus();
+ }
+
+ if ( maSaveAsURL.getLength() )
+ {
+ if ( mbOpenNewDocument && xSelf.is() )
+ {
+ Reference< awt::XWindow > xContainerWindow( xSelf->getContainerWindow() );
+ xContainerWindow->setVisible( sal_True );
+ }
+ else
+ {
+ Reference< XComponent > xComponent( mxModel, UNO_QUERY );
+ xComponent->dispose();
+ }
+ }
+ if ( nSourceSize && nDestSize )
+ {
+ SetStatusValue( TK_FileSizeSource, Any( nSourceSize ) );
+ SetStatusValue( TK_FileSizeDestination, Any( nDestSize ) );
+ DispatchStatus();
+ }
+ }
+ else
+ bRet = sal_False;
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/impoptimizer.hxx b/sdext/source/minimizer/impoptimizer.hxx
new file mode 100644
index 000000000000..ac3b4e8c36e4
--- /dev/null
+++ b/sdext/source/minimizer/impoptimizer.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef IMPOPTIMIZER_HXX
+#define IMPOPTIMIZER_HXX
+
+#include "pppoptimizertoken.hxx"
+#include "optimizationstats.hxx"
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+class Point;
+class Size;
+
+// -------------
+// - PDFExport -
+// -------------
+
+class ImpOptimizer : public OptimizationStats
+{
+private:
+
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxMSF;
+ com::sun::star::uno::Reference< com::sun::star::frame::XModel > mxModel;
+ com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > mxStatusDispatcher;
+
+ sal_Bool mbJPEGCompression;
+ sal_Int32 mnJPEGQuality;
+ sal_Bool mbRemoveCropArea;
+ sal_Int32 mnImageResolution;
+ sal_Bool mbEmbedLinkedGraphics;
+ sal_Bool mbOLEOptimization;
+ sal_Int32 mnOLEOptimizationType;
+ rtl::OUString maCustomShowName;
+ sal_Bool mbDeleteUnusedMasterPages;
+ sal_Bool mbDeleteHiddenSlides;
+ sal_Bool mbDeleteNotesPages;
+ rtl::OUString maSaveAsURL;
+ rtl::OUString maFilterName;
+ sal_Bool mbOpenNewDocument;
+
+ com::sun::star::uno::Reference< com::sun::star::frame::XFrame > mxInformationDialog;
+
+ sal_Bool Optimize();
+
+public:
+
+ ImpOptimizer( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rXFactory,
+ const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel );
+ ~ImpOptimizer();
+
+ sal_Bool Optimize( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rArguments );
+ void DispatchStatus();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/informationdialog.cxx b/sdext/source/minimizer/informationdialog.cxx
new file mode 100644
index 000000000000..946b90f5298c
--- /dev/null
+++ b/sdext/source/minimizer/informationdialog.cxx
@@ -0,0 +1,413 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "informationdialog.hxx"
+#include "optimizationstats.hxx"
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <rtl/ustrbuf.hxx>
+#include <sal/macros.h>
+#include "com/sun/star/util/URL.hpp"
+#include "com/sun/star/util/XURLTransformer.hpp"
+
+#define DIALOG_WIDTH 240
+#define DIALOG_HEIGHT 80
+#define PAGE_POS_X 35
+#define PAGE_WIDTH ( DIALOG_WIDTH - PAGE_POS_X ) - 6
+
+
+// ---------------------
+// - INFORMATIONDIALOG -
+// ---------------------
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::io;
+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 = SAL_N_ELEMENTS( pNames );
+
+ 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( 0 ) ),
+ Any( nHeight ),
+ Any( rURL ),
+ Any( nPosX ),
+ Any( nPosY ),
+ Any( sal_True ),
+ Any( nWidth ) };
+ sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
+
+ 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 = SAL_N_ELEMENTS( pNames );
+
+ 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 = SAL_N_ELEMENTS( pNames );
+
+ 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();
+}
+
+OUString InformationDialog::ImpGetStandardImage( const OUString& sPrivateURL )
+{
+ rtl::OUString sURL;
+ try
+ {
+ mxTempFile = Reference< XStream >( mxMSF->getServiceManager()->createInstanceWithContext( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.TempFile")), mxMSF ), UNO_QUERY_THROW );
+ Reference< XPropertySet > xPropSet( mxTempFile, UNO_QUERY );
+ Reference< XOutputStream > xOutputStream( mxTempFile->getOutputStream() );
+ if ( xOutputStream.is() && xPropSet.is() )
+ {
+ Reference< graphic::XGraphicProvider > xGraphicProvider( mxMSF->getServiceManager()->createInstanceWithContext(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.GraphicProvider")), mxMSF ), UNO_QUERY_THROW );
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[ 0 ].Name = OUString(RTL_CONSTASCII_USTRINGPARAM("URL"));
+ aArgs[ 0 ].Value <<= sPrivateURL;
+ Reference< graphic::XGraphic > xGraphic( xGraphicProvider->queryGraphic( aArgs ) );
+ if ( xGraphic.is() )
+ {
+ OUString aDestMimeType( RTL_CONSTASCII_USTRINGPARAM( "image/png" ) );
+ Sequence< PropertyValue > aArgs2( 2 );
+ aArgs2[ 0 ].Name = TKGet( TK_MimeType ); // the GraphicProvider is using "MimeType", the GraphicExporter "MediaType"...
+ aArgs2[ 0 ].Value <<= aDestMimeType;
+ aArgs2[ 1 ].Name = TKGet( TK_OutputStream );
+ aArgs2[ 1 ].Value <<= xOutputStream;
+ xGraphicProvider->storeGraphic( xGraphic, aArgs2 );
+ }
+ xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Uri")) ) >>= sURL;
+ }
+ }
+ catch( Exception& )
+ {
+ }
+ return sURL;
+}
+
+void InformationDialog::InitDialog()
+{
+ sal_Int32 nDialogHeight = DIALOG_HEIGHT;
+ if ( !maSaveAsURL.getLength() )
+ nDialogHeight -= 22;
+
+ // 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( nDialogHeight ),
+ Any( sal_True ),
+ Any( sal_Int32( 245 ) ),
+ Any( sal_Int32( 115 ) ),
+ Any( getString( STR_SUN_OPTIMIZATION_WIZARD2 ) ),
+ Any( sal_Int32( DIALOG_WIDTH ) ) };
+
+ sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
+
+ Sequence< rtl::OUString > aNames( pNames, nCount );
+ Sequence< Any > aValues( pValues, nCount );
+
+ mxDialogModelMultiPropertySet->setPropertyValues( aNames, aValues );
+
+ sal_Int64 nSource = mnSourceSize;
+ sal_Int64 nDest = mnDestSize;
+
+ PPPOptimizerTokenEnum eInfoString( STR_INFO_1 );
+ if ( mnSourceSize )
+ {
+ if ( mnDestSize )
+ eInfoString = STR_INFO_1;
+ else
+ {
+ eInfoString = STR_INFO_2;
+ nDest = mnApproxSize;
+ }
+ }
+ else if ( mnDestSize )
+ eInfoString = STR_INFO_3;
+ else
+ {
+ eInfoString = STR_INFO_4;
+ nDest = mnApproxSize;
+ }
+
+ rtl::OUString aTitle;
+ if ( maSaveAsURL.getLength() )
+ {
+ Reference< XURLTransformer > xURLTransformer( mxMSF->getServiceManager()->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ) ), mxMSF ), UNO_QUERY );
+ if ( xURLTransformer.is() )
+ {
+ util::URL aURL, aPresentationURL;
+ aURL.Complete = maSaveAsURL;
+ xURLTransformer->parseSmart( aURL, rtl::OUString() );
+
+ const OUString sFileProtocol( RTL_CONSTASCII_USTRINGPARAM( "file:///" ) );
+ aPresentationURL.Complete = sFileProtocol.concat( aURL.Name );
+ aTitle = xURLTransformer->getPresentation( aPresentationURL, sal_False );
+
+ if ( aTitle.match( sFileProtocol, 0 ) )
+ aTitle = aTitle.replaceAt( 0, sFileProtocol.getLength(), rtl::OUString() );
+ }
+ }
+
+ OUString aInfoString( getString( eInfoString ) );
+ const OUString aOldSizePlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%OLDFILESIZE" ) );
+ const OUString aNewSizePlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%NEWFILESIZE" ) );
+ const OUString aTitlePlaceholder( aTitle.getLength() ? OUString(RTL_CONSTASCII_USTRINGPARAM("%TITLE" ))
+ : OUString(RTL_CONSTASCII_USTRINGPARAM("'%TITLE'")) );
+
+ sal_Int32 i = aInfoString.indexOf( aOldSizePlaceholder, 0 );
+ if ( i >= 0 )
+ aInfoString = aInfoString.replaceAt( i, aOldSizePlaceholder.getLength(), ImpValueOfInMB( nSource ) );
+
+ sal_Int32 j = aInfoString.indexOf( aNewSizePlaceholder, 0 );
+ if ( j >= 0 )
+ aInfoString = aInfoString.replaceAt( j, aNewSizePlaceholder.getLength(), ImpValueOfInMB( nDest ) );
+
+ sal_Int32 k = aInfoString.indexOf( aTitlePlaceholder, 0 );
+ if ( k >= 0 )
+ aInfoString = aInfoString.replaceAt( k, aTitlePlaceholder.getLength(), aTitle );
+
+ com::sun::star::uno::Reference< com::sun::star::awt::XItemListener > xItemListener;
+ InsertImage( *this, rtl::OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("aboutimage")) ), ImpGetStandardImage( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:standardimage/query")) ), 5, 5, 25, 25 );
+ InsertFixedText( *this, rtl::OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("fixedtext")) ), aInfoString, PAGE_POS_X, 6, PAGE_WIDTH, 24, sal_True, 0 );
+ if ( maSaveAsURL.getLength() )
+ InsertCheckBox( *this, TKGet( TK_OpenNewDocument ), xItemListener, getString( STR_AUTOMATICALLY_OPEN ), PAGE_POS_X, 42, PAGE_WIDTH, 8, 1 );
+ InsertButton( *this, rtl::OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("button")) ), mxActionListener, DIALOG_WIDTH / 2 - 25, nDialogHeight - 20, 50, 14, 2, STR_OK );
+
+ sal_Bool bOpenNewDocument = mrbOpenNewDocument;
+ setControlProperty( TKGet( TK_OpenNewDocument ), TKGet( TK_State ), Any( (sal_Int16)bOpenNewDocument ) );
+}
+
+// -----------------------------------------------------------------------------
+
+InformationDialog::InformationDialog( const Reference< XComponentContext > &rxMSF, Reference< XFrame >& rxFrame, const rtl::OUString& rSaveAsURL, sal_Bool& rbOpenNewDocument, const sal_Int64& rSourceSize, const sal_Int64& rDestSize, const sal_Int64& rApproxSize ) :
+ UnoDialog( rxMSF, rxFrame ),
+ ConfigurationAccess( rxMSF, NULL ),
+ mxMSF( rxMSF ),
+ mxFrame( rxFrame ),
+ mxActionListener( new OKActionListener( *this ) ),
+ mnSourceSize( rSourceSize ),
+ mnDestSize( rDestSize ),
+ mnApproxSize( rApproxSize ),
+ mrbOpenNewDocument( rbOpenNewDocument ),
+ maSaveAsURL( rSaveAsURL )
+{
+ 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();
+
+ if ( maSaveAsURL.getLength() )
+ {
+ sal_Int16 nInt16 = 0;
+ 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(RTL_CONSTASCII_USTRINGPARAM("button")) ) )
+ {
+ mrInformationDialog.endExecute( sal_True );
+ }
+}
+void OKActionListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
+ throw ( com::sun::star::uno::RuntimeException )
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/informationdialog.hxx b/sdext/source/minimizer/informationdialog.hxx
new file mode 100644
index 000000000000..44d2d4c035be
--- /dev/null
+++ b/sdext/source/minimizer/informationdialog.hxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INFORMATIONDIALOG_HXX
+#define INFORMATIONDIALOG_HXX
+#include <vector>
+#include "unodialog.hxx"
+#include "configurationaccess.hxx"
+#include "pppoptimizertoken.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/awt/XItemListener.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/awt/XItemEventBroadcaster.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/awt/PushButtonType.hpp>
+#include <com/sun/star/io/XStream.hpp>
+
+// ---------------------
+// - 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, const rtl::OUString& rSaveAsURL,
+ sal_Bool& bOpenNewDocument, const sal_Int64& nSourceSize, const sal_Int64& nDestSize, const sal_Int64& nApproxDest );
+ ~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::io::XStream > mxTempFile;
+
+ com::sun::star::uno::Reference< com::sun::star::awt::XActionListener > mxActionListener;
+
+ rtl::OUString ImpGetStandardImage( const rtl::OUString& rPrivateURL );
+ void InitDialog();
+
+ sal_Int64 mnSourceSize;
+ sal_Int64 mnDestSize;
+ sal_Int64 mnApproxSize;
+ sal_Bool& mrbOpenNewDocument;
+ const rtl::OUString& maSaveAsURL;
+
+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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/makefile.mk b/sdext/source/minimizer/makefile.mk
new file mode 100644
index 000000000000..164f106c0c5d
--- /dev/null
+++ b/sdext/source/minimizer/makefile.mk
@@ -0,0 +1,148 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=sdext
+TARGET=SunPresentationMinimizer
+GEN_HID=FALSE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
+.INCLUDE : $(PRJ)$/source$/minimizer$/minimizer.pmk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# set in minimizer.pmk
+EXTENSION_ZIPNAME:=presentation-minimizer
+
+.IF "$(ENABLE_MINIMIZER)" != "YES"
+@all:
+ @echo "Presentation Minimizer build disabled."
+.ENDIF
+
+DLLPRE=
+
+# --- 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)$/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=$(SOLARENV)/src/reg-component.map
+SHL1RPATH= OXT
+DEF1NAME= $(SHL1TARGET)
+
+COMPONENT_XCU_REPLACEMENT=s/@MINIMIZEREXTENSIONPRODUCTNAME@/Presentation Minimizer/g
+
+COMPONENT_MERGED_XCU= \
+ $(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Office$/Addons.xcu \
+ $(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Office$/ProtocolHandler.xcu \
+ $(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Office$/extension$/SunPresentationMinimizer.xcu
+
+COMPONENT_FILES= \
+ $(EXTENSIONDIR)$/registry$/schema$/org$/openoffice$/Office$/extension$/SunPresentationMinimizer.xcs
+
+# native libraries
+COMPONENT_LIBRARIES= \
+ $(EXTENSIONDIR)$/SunPresentationMinimizer.uno$(DLLPOST)
+
+# rather freestyle or common to all?
+COMPONENT_BITMAPS= \
+ $(EXTENSIONDIR)$/bitmaps$/opt_16.png \
+ $(EXTENSIONDIR)$/bitmaps$/opt_26.png \
+ $(EXTENSIONDIR)$/bitmaps$/minimizepresi_80.png
+
+COMPONENT_IMAGES=\
+ $(EXTENSIONDIR)$/bitmaps$/extension_32.png
+
+# rather freestyle or common to all?
+COMPONENT_HELP= \
+ $(EXTENSIONDIR)$/help$/help_de.odt \
+ $(EXTENSIONDIR)$/help$/help_en-US.odt \
+ $(EXTENSIONDIR)$/help$/component.txt
+
+# make sure to add your custom files here
+EXTENSION_PACKDEPS=$(COMPONENT_BITMAPS) $(COMPONENT_IMAGES) $(COMPONENT_HELP)
+
+ZIP2TARGET= presentation_minimizer_develop
+.IF "$(WITH_LANG)"!=""
+ZIP2DIR= $(MISC)/$(EXTENSIONNAME)_in/merge
+.ELSE # "$(WITH_LANG)"!=""
+ZIP2DIR= registry/data
+.ENDIF # "$(WITH_LANG)"!=""
+ZIP2EXT= .zip
+ZIP2FLAGS=-r
+ZIP2LIST= \
+ org/openoffice/Office/Addons.xcu \
+ org/openoffice/Office/extension/*.xcu
+
+# --- Targets ----------------------------------
+
+.INCLUDE : extension_pre.mk
+
+.ENDIF # L10N_framework
+.INCLUDE : target.mk
+
+.IF "$(L10N_framework)"==""
+.INCLUDE : extension_post.mk
+
+$(COMPONENT_BITMAPS) : $(SOLARSRC)$/$(RSCDEFIMG)$/minimizer$/$$(@:f)
+ @@-$(MKDIRHIER) $(@:d)
+ $(COPY) $< $@
+
+$(COMPONENT_IMAGES) : $(SOLARSRC)$/$(RSCDEFIMG)$/desktop$/res$/$$(@:f)
+ @@-$(MKDIRHIER) $(@:d)
+ $(COPY) $< $@
+
+$(COMPONENT_HELP) : help$/$$(@:f)
+ @@-$(MKDIRHIER) $(@:d)
+ $(COPY) $< $@
+
+.ENDIF # L10N_framework
diff --git a/sdext/source/minimizer/manifest.xml b/sdext/source/minimizer/manifest.xml
new file mode 100644
index 000000000000..eac189524f26
--- /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="registry/schema/org/openoffice/Office/extension/SunPresentationMinimizer.xcs"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
+ manifest:full-path="registry/data/org/openoffice/Office/extension/SunPresentationMinimizer.xcu"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
+ manifest:full-path="registry/data/org/openoffice/Office/Addons.xcu"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
+ manifest:full-path="registry/data/org/openoffice/Office/ProtocolHandler.xcu"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.package-bundle-description"
+ manifest:full-path="help/component.txt"/>
+</manifest:manifest>
diff --git a/sdext/source/minimizer/minimizer.pmk b/sdext/source/minimizer/minimizer.pmk
new file mode 100644
index 000000000000..f832f2dea2d5
--- /dev/null
+++ b/sdext/source/minimizer/minimizer.pmk
@@ -0,0 +1,28 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+EXTENSIONNAME:=PresentationMinimizer
diff --git a/sdext/source/minimizer/optimizationstats.cxx b/sdext/source/minimizer/optimizationstats.cxx
new file mode 100644
index 000000000000..8f6eaeeb7f1c
--- /dev/null
+++ b/sdext/source/minimizer/optimizationstats.cxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "optimizationstats.hxx"
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
+
+
+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& )
+ {
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/optimizationstats.hxx b/sdext/source/minimizer/optimizationstats.hxx
new file mode 100644
index 000000000000..3359b5888627
--- /dev/null
+++ b/sdext/source/minimizer/optimizationstats.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OPTIMIZATIONSTATS_HXX
+#define OPTIMIZATIONSTATS_HXX
+
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/beans/PropertyValues.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include "pppoptimizertoken.hxx"
+#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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx
new file mode 100644
index 000000000000..3d60123496fd
--- /dev/null
+++ b/sdext/source/minimizer/optimizerdialog.cxx
@@ -0,0 +1,840 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "optimizerdialog.hxx"
+#include "fileopendialog.hxx"
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/util/XCloseBroadcaster.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <sal/macros.h>
+#include <osl/time.h>
+
+// -------------------
+// - 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_WIZARD2 ) ),
+ Any( sal_Int32( OD_DIALOG_WIDTH ) ) };
+
+ sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
+
+ 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 = SAL_N_ELEMENTS( pNames );
+
+ 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( RTL_CONSTASCII_USTRINGPARAM("/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 = 0;
+ 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 ] ) );
+ }
+ }
+ }
+
+ 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 ] ) );
+ }
+ }
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+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 ) ),
+ mxSpinListenerFormattedField0Pg1( new SpinListenerFormattedField0Pg1( *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_Enabled ), Any( sal_True ) );
+ 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 ) );
+ }
+ pVal = maStats.GetStatusValue( TK_OpenNewDocument );
+ if ( pVal )
+ SetConfigProperty( TK_OpenNewDocument, *pVal );
+
+ 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 = 0;
+ 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_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.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(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")), mrOptimizerDialog.GetComponentContext() ), UNO_QUERY_THROW );
+ Reference< XSimpleFileAccess > xSimpleFileAccess( mrOptimizerDialog.GetComponentContext()->getServiceManager()->createInstanceWithContext(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess")), mrOptimizerDialog.GetComponentContext() ), UNO_QUERY_THROW );
+ Reference< XInputStream > xInputStream( xSimpleFileAccess->openFileRead( sHelpFile ) );
+ Reference< XDesktop > xDesktop( mrOptimizerDialog.GetComponentContext()->getServiceManager()->createInstanceWithContext(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("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(RTL_CONSTASCII_USTRINGPARAM("private:stream")),
+ TKGet( TK__self ), 0, aLoadProps ) );
+
+ Reference< XPropertySet > xPropSet( xHelpFrame, UNO_QUERY_THROW );
+ Reference< XLayoutManager > xLayoutManager;
+ if ( xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ) >>= xLayoutManager )
+ {
+ xLayoutManager->setVisible( sal_False );
+ xLayoutManager->hideElement( OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/menubar/menubar")) );
+ xLayoutManager->destroyElement( OUString(RTL_CONSTASCII_USTRINGPARAM("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() );
+ if ( aLocation.getLength() )
+ {
+ sal_Int32 nIndex = aLocation.lastIndexOf( '/', aLocation.getLength() - 1 );
+ if ( nIndex >= 0 )
+ {
+ if ( nIndex < aLocation.getLength() - 1 )
+ aLocation = aLocation.copy( nIndex + 1 );
+
+ // remove extension
+ nIndex = aLocation.lastIndexOf( '.', aLocation.getLength() - 1 );
+ if ( nIndex >= 0 )
+ aLocation = aLocation.copy( 0, nIndex );
+
+ // adding .mini
+ aLocation = aLocation.concat( OUString(RTL_CONSTASCII_USTRINGPARAM(".mini")) );
+ 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(RTL_CONSTASCII_USTRINGPARAM("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 <<= mrOptimizerDialog.GetFrame();
+
+ 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_False ) );
+ 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 = 0;
+ 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 SpinListenerFormattedField0Pg1::up( const SpinEvent& /* rEvent */ )
+ throw ( com::sun::star::uno::RuntimeException )
+{
+ double fDouble;
+ Any aAny = mrOptimizerDialog.getControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ) );
+ if ( aAny >>= fDouble )
+ {
+ fDouble += 9;
+ if ( fDouble > 100 )
+ fDouble = 100;
+ mrOptimizerDialog.setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( fDouble ) );
+ mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) );
+ }
+}
+void SpinListenerFormattedField0Pg1::down( const SpinEvent& /* rEvent */ )
+ throw ( com::sun::star::uno::RuntimeException )
+{
+ double fDouble;
+ Any aAny = mrOptimizerDialog.getControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ) );
+ if ( aAny >>= fDouble )
+ {
+ fDouble -= 9;
+ if ( fDouble < 0 )
+ fDouble = 0;
+ mrOptimizerDialog.setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( fDouble ) );
+ mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) );
+ }
+}
+void SpinListenerFormattedField0Pg1::first( const SpinEvent& /* rEvent */ )
+ throw ( com::sun::star::uno::RuntimeException )
+{
+ mrOptimizerDialog.setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( static_cast< double >( 0 ) ) );
+ mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)0 ) );
+}
+void SpinListenerFormattedField0Pg1::last( const SpinEvent& /* rEvent */ )
+ throw ( com::sun::star::uno::RuntimeException )
+{
+ mrOptimizerDialog.setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( static_cast< double >( 100 ) ) );
+ mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)100 ) );
+}
+void SpinListenerFormattedField0Pg1::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;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/optimizerdialog.hrc b/sdext/source/minimizer/optimizerdialog.hrc
new file mode 100644
index 000000000000..bc3fd49a277f
--- /dev/null
+++ b/sdext/source/minimizer/optimizerdialog.hrc
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _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..08036c056069
--- /dev/null
+++ b/sdext/source/minimizer/optimizerdialog.hxx
@@ -0,0 +1,248 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OPTIMIZERDIALOG_HXX
+#define OPTIMIZERDIALOG_HXX
+#include "optimizerdialog.hrc"
+#include <vector>
+#include "unodialog.hxx"
+#include "pppoptimizertoken.hxx"
+#include "optimizationstats.hxx"
+#include "configurationaccess.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/awt/XItemListener.hpp>
+#include <com/sun/star/awt/XSpinField.hpp>
+#include <com/sun/star/awt/XSpinListener.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/awt/XItemEventBroadcaster.hpp>
+#include <com/sun/star/util/XCloseListener.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/awt/PushButtonType.hpp>
+
+#define MAX_STEP 4
+#define OD_DIALOG_WIDTH 330
+#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 OD_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::awt::XSpinListener > mxSpinListenerFormattedField0Pg1;
+ 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 SpinListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XSpinListener >
+{
+public:
+ SpinListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
+
+ virtual void SAL_CALL up( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL down( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL first( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL last( const ::com::sun::star::awt::SpinEvent& 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/optimizerdialogcontrols.cxx b/sdext/source/minimizer/optimizerdialogcontrols.cxx
new file mode 100644
index 000000000000..d5af7018ec4c
--- /dev/null
+++ b/sdext/source/minimizer/optimizerdialogcontrols.cxx
@@ -0,0 +1,962 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "optimizerdialog.hxx"
+
+// -------------------
+// - OptimizerDialog -
+// -------------------
+#include "pppoptimizer.hxx"
+#include "graphiccollector.hxx"
+#include "pagecollector.hxx"
+#include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
+#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <rtl/ustrbuf.hxx>
+#include <sal/macros.h>
+
+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 = SAL_N_ELEMENTS( pNames );
+
+ 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 = SAL_N_ELEMENTS( pNames );
+
+ 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 = SAL_N_ELEMENTS( pNames );
+
+ 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 = SAL_N_ELEMENTS( pNames );
+
+ 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, const Reference< XSpinListener > xSpinListener, 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 = SAL_N_ELEMENTS( pNames );
+
+ 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 );
+ if ( xSpinListener.is() )
+ {
+ Reference< XSpinField > xSpinField( xTextComponent, UNO_QUERY_THROW );
+ xSpinField->addSpinListener( xSpinListener );
+ }
+ 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 = SAL_N_ELEMENTS( pNames );
+
+ 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 = SAL_N_ELEMENTS( pNames );
+
+ 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 = SAL_N_ELEMENTS( pNames );
+
+ 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 = OD_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, OD_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, ( OD_DIALOG_WIDTH - 50 ) - ( PAGE_POS_X + 6 ), 12, mnTabIndex++ ) );
+ aControlList.push_back( InsertButton( *this, TKGet( TK_Button0Pg0 ), mxActionListener, OD_DIALOG_WIDTH - 46, DIALOG_HEIGHT - 49, 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( InsertCheckBox( *this, TKGet( TK_CheckBox2Pg3 ), mxItemListener, getString( STR_DELETE_HIDDEN_SLIDES ), PAGE_POS_X + 6, PAGE_POS_Y + 28, 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 + 42, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
+ aControlList.push_back( InsertListBox( *this, TKGet( TK_ListBox0Pg3 ), mxActionListener, sal_True, aCustomShowList, PAGE_POS_X + 14, PAGE_POS_Y + 54, 150, 12, mnTabIndex++ ) );
+ aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox1Pg3 ), mxItemListener, getString( STR_DELETE_NOTES_PAGES ), PAGE_POS_X + 6, PAGE_POS_Y + 70, PAGE_WIDTH - 12, 8, 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, mxSpinListenerFormattedField0Pg1, 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, PAGE_WIDTH - 22, 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, PAGE_WIDTH - 22, 8, sal_False, mnTabIndex++ ) );
+ aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText1Pg2 ), nOLECount ? getString( STR_OLE_OBJECTS_DESC ) : getString( STR_NO_OLE_OBJECTS_DESC ), PAGE_POS_X + 6, PAGE_POS_Y + 64, PAGE_WIDTH - 22, 50, sal_True, sal_False, mnTabIndex++ ) );
+ maControlPages.push_back( aControlList );
+ DeactivatePage( 3 );
+ UpdateControlStatesPage3();
+}
+
+// -----------------------------------------------------------------------------
+
+static OUString ImpValueOfInMB( const sal_Int64& rVal, sal_Unicode nSeparator = '.' )
+{
+ 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.setCharAt( nX, nSeparator );
+ }
+ aVal.append( OUString(RTL_CONSTASCII_USTRINGPARAM(" MB")) );
+ return aVal.makeStringAndClear();
+}
+
+void OptimizerDialog::UpdateControlStatesPage4()
+{
+ sal_Bool bSaveAs( GetConfigProperty( TK_SaveAs, 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_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( sal_False ) );
+
+ sal_uInt32 w;
+ 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 ( w = 1; w < rList.size(); w++ )
+ aItemList[ w - 1 ] = rList[ w ].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 ( w = 1; w < rList.size(); w++ )
+ {
+ if ( rList[ w ] == rList[ 0 ] )
+ {
+ bSaveSettingsEnabled = sal_False;
+ break;
+ }
+ }
+ }
+ sal_Int16 nInt16 = 0;
+ getControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_State ) ) >>= nInt16;
+ setControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled ) );
+ setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled && nInt16 ) );
+
+ std::vector< OUString > aSummaryStrings;
+
+ // taking care of deleted slides
+ 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
+ sal_Int32 nGraphics = 0;
+ 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::CountGraphics( mxMSF, mxController->getModel(), aGraphicSettings, nGraphics );
+ if ( nGraphics > 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( nGraphics ) );
+
+ 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 ] ) );
+
+ 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() );
+
+ if ( nCurrentFileSize )
+ {
+ double fE = static_cast< double >( nCurrentFileSize );
+ if ( nImageResolution )
+ {
+ double v = ( static_cast< double >( nImageResolution ) + 75.0 ) / 300.0;
+ if ( v < 1.0 )
+ fE *= v;
+ }
+ if ( bJPEGCompression )
+ {
+ double v = 0.75 - ( ( 100.0 - static_cast< double >( nJPEGQuality ) ) / 400.0 ) ;
+ fE *= v;
+ }
+ nEstimatedFileSize = static_cast< sal_Int64 >( fE );
+ }
+ sal_Unicode nSeparator = '.';
+ OUString aStr( getString( STR_FILESIZESEPARATOR ) );
+ if ( aStr.getLength() )
+ nSeparator = aStr[ 0 ];
+ setControlProperty( TKGet( TK_FixedText7Pg4 ), TKGet( TK_Label ), Any( ImpValueOfInMB( nCurrentFileSize, nSeparator ) ) );
+ setControlProperty( TKGet( TK_FixedText8Pg4 ), TKGet( TK_Label ), Any( ImpValueOfInMB( nEstimatedFileSize, nSeparator ) ) );
+ SetConfigProperty( TK_EstimatedFileSize, Any( nEstimatedFileSize ) );
+}
+
+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)12 ),
+ Any( TKGet( STR_SAVE_AS ) ),
+ Any( (sal_Int32)( PAGE_POS_X + 6 ) ),
+ Any( (sal_Int32)( DIALOG_HEIGHT - 75 ) ),
+ Any( (sal_Int32)( 0 ) ),
+ Any( (sal_Int32)( 100 ) ),
+ Any( (sal_Int32)( 0 ) ),
+ Any( (sal_Int32)( PAGE_WIDTH - 12 ) ) };
+
+ sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
+
+ 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 );
+ }
+ 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( 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, 88, 8, sal_False, sal_False, mnTabIndex++ ) );
+ aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText7Pg4 ), OUString(), PAGE_POS_X + 100, 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, 88, 8, sal_False, sal_False, mnTabIndex++ ) );
+ aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText8Pg4 ), OUString(), PAGE_POS_X + 100, 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 - 87, 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 - 47, 100, 8, mnTabIndex++ ) );
+ aControlList.push_back( InsertComboBox( *this, TKGet( TK_ComboBox0Pg4 ), xTextListener, sal_True, aItemList, PAGE_POS_X + 106, 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 );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/pagecollector.cxx b/sdext/source/minimizer/pagecollector.cxx
new file mode 100644
index 000000000000..101582c9983a
--- /dev/null
+++ b/sdext/source/minimizer/pagecollector.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "pagecollector.hxx"
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/presentation/XPresentationPage.hpp>
+#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
+#include <com/sun/star/drawing/XMasterPageTarget.hpp>
+#include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+
+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 );
+ }
+ }
+ }
+ 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& )
+ {
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/pagecollector.hxx b/sdext/source/minimizer/pagecollector.hxx
new file mode 100644
index 000000000000..3387dd92213f
--- /dev/null
+++ b/sdext/source/minimizer/pagecollector.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef PAGECOLLECTOR_HXX
+#define PAGECOLLECTOR_HXX
+
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/pppoptimizer.cxx b/sdext/source/minimizer/pppoptimizer.cxx
new file mode 100644
index 000000000000..f49bfc551531
--- /dev/null
+++ b/sdext/source/minimizer/pppoptimizer.cxx
@@ -0,0 +1,212 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "pppoptimizer.hxx"
+#include "impoptimizer.hxx"
+#include <osl/file.hxx>
+
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+
+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_FAIL( "PPPOptimizer::addStatusListener()\nNot implemented yet!" );
+}
+
+//===============================================
+void SAL_CALL PPPOptimizer::removeStatusListener( const Reference< XStatusListener >&, const URL& )
+ throw( RuntimeException )
+{
+ // TODO
+ OSL_FAIL( "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 );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/pppoptimizer.hxx b/sdext/source/minimizer/pppoptimizer.hxx
new file mode 100644
index 000000000000..eaa4502e8d5f
--- /dev/null
+++ b/sdext/source/minimizer/pppoptimizer.hxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef PPPOPTIMIZER_HXX
+#define PPPOPTIMIZER_HXX
+
+#include <cppuhelper/implbase4.hxx>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/frame/XController.hpp>
+
+// ----------------
+// - 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/pppoptimizerdialog.cxx b/sdext/source/minimizer/pppoptimizerdialog.cxx
new file mode 100644
index 000000000000..a04015ab5be4
--- /dev/null
+++ b/sdext/source/minimizer/pppoptimizerdialog.cxx
@@ -0,0 +1,218 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "pppoptimizerdialog.hxx"
+#include "optimizerdialog.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"
+#include <rtl/ustrbuf.hxx>
+
+// ----------------------
+// - 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 )
+ 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 )
+{
+
+ if ( mxController.is() && ( rURL.Protocol.compareToAscii( "vnd.com.sun.star.comp.SunPresentationMinimizer:" ) == 0 ) )
+ {
+ if ( rURL.Path.compareToAscii( "execute" ) == 0 )
+ {
+ try
+ {
+ sal_Int64 nFileSizeSource = 0;
+ sal_Int64 nFileSizeDest = 0;
+ mpOptimizerDialog = new OptimizerDialog( mxMSF, mxFrame, this );
+ 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(RTL_CONSTASCII_USTRINGPARAM("Your Presentation has been minimized from:")) );
+ sBuf.append( rtl::OUString::valueOf( nFileSizeSource >> 10 ) );
+ sBuf.append( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("KB to ")) );
+ sBuf.append( rtl::OUString::valueOf( nFileSizeDest >> 10 ) );
+ sBuf.append( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("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 );
+ }
+ }
+}
+
+//===============================================
+void SAL_CALL PPPOptimizerDialog::addStatusListener( const Reference< XStatusListener >&, const URL& )
+ throw( RuntimeException )
+{
+ // TODO
+ // OSL_FAIL( "PPPOptimizerDialog::addStatusListener()\nNot implemented yet!" );
+}
+
+//===============================================
+void SAL_CALL PPPOptimizerDialog::removeStatusListener( const Reference< XStatusListener >&, const URL& )
+ throw( RuntimeException )
+{
+ // TODO
+ // OSL_FAIL( "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 );
+}
+
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/pppoptimizerdialog.hxx b/sdext/source/minimizer/pppoptimizerdialog.hxx
new file mode 100644
index 000000000000..712db18cb7ee
--- /dev/null
+++ b/sdext/source/minimizer/pppoptimizerdialog.hxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef PPPOPTIMIZERDIALOG_HXX
+#define PPPOPTIMIZERDIALOGOG_HXX
+
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <cppuhelper/implbase4.hxx>
+
+// ----------------------
+// - 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/pppoptimizertoken.cxx b/sdext/source/minimizer/pppoptimizertoken.cxx
new file mode 100644
index 000000000000..669132de7cba
--- /dev/null
+++ b/sdext/source/minimizer/pppoptimizertoken.cxx
@@ -0,0 +1,349 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "pppoptimizertoken.hxx"
+#include <osl/mutex.hxx>
+#include <sal/macros.h>
+#include <boost/unordered_map.hpp>
+#include <string.h>
+
+struct THash
+{
+ size_t operator()( const char* s ) const
+ {
+ return rtl_str_hashCode(s);
+ }
+};
+struct TCheck
+{
+ bool operator()( const char* s1, const char* s2 ) const
+ {
+ return strcmp( s1, s2 ) == 0;
+ }
+};
+typedef boost::unordered_map< const char*, PPPOptimizerTokenEnum, THash, 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 },
+ { "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 },
+ { "EstimatedFileSize", TK_EstimatedFileSize },
+
+ { "Status", TK_Status },
+ { "Pages", TK_Pages },
+ { "CurrentPage", TK_CurrentPage },
+ { "GraphicObjects", TK_GraphicObjects },
+ { "CurrentGraphicObject",TK_CurrentGraphicObject },
+ { "OLEObjects", TK_OLEObjects },
+ { "CurrentOLEObject", TK_CurrentOLEObject },
+
+ { "STR_SUN_OPTIMIZATION_WIZARD2",STR_SUN_OPTIMIZATION_WIZARD2 },
+ { "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__OLE_OBJECTS_DESC", STR_OLE_OBJECTS_DESC },
+ { "STR_NO_OLE_OBJECTS_DESC", STR_NO_OLE_OBJECTS_DESC },
+ { "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_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_OK", STR_OK },
+ { "STR_INFO_1", STR_INFO_1 },
+ { "STR_INFO_2", STR_INFO_2 },
+ { "STR_INFO_3", STR_INFO_3 },
+ { "STR_INFO_4", STR_INFO_4 },
+ { "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 },
+ { "STR_FileSizeSeparator", STR_FILESIZESEPARATOR },
+
+ { "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 + SAL_N_ELEMENTS( pTokenTableArray );
+ 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 );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/pppoptimizertoken.hxx b/sdext/source/minimizer/pppoptimizertoken.hxx
new file mode 100644
index 000000000000..19ae973c7572
--- /dev/null
+++ b/sdext/source/minimizer/pppoptimizertoken.hxx
@@ -0,0 +1,286 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _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_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_EstimatedFileSize,
+
+ TK_Status,
+ TK_Pages,
+ TK_CurrentPage,
+ TK_GraphicObjects,
+ TK_CurrentGraphicObject,
+ TK_OLEObjects,
+ TK_CurrentOLEObject,
+
+ STR_SUN_OPTIMIZATION_WIZARD2,
+ 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_OLE_OBJECTS_DESC,
+ STR_NO_OLE_OBJECTS_DESC,
+ STR_SLIDES,
+ STR_CHOOSE_SLIDES,
+ STR_MASTER_PAGES,
+ STR_DELETE_MASTER_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_OK,
+ STR_INFO_1,
+ STR_INFO_2,
+ STR_INFO_3,
+ STR_INFO_4,
+ STR_DUPLICATING_PRESENTATION,
+ STR_DELETING_SLIDES,
+ STR_OPTIMIZING_GRAPHICS,
+ STR_CREATING_OLE_REPLACEMENTS,
+ STR_FILESIZESEPARATOR,
+
+ TK_Last,
+ TK_NotFound
+};
+
+PPPOptimizerTokenEnum TKGet( const rtl::OUString& );
+rtl::OUString TKGet( const PPPOptimizerTokenEnum );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/pppoptimizeruno.cxx b/sdext/source/minimizer/pppoptimizeruno.cxx
new file mode 100644
index 000000000000..bb126e7ceb98
--- /dev/null
+++ b/sdext/source/minimizer/pppoptimizeruno.cxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#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(RTL_CONSTASCII_USTRINGPARAM("/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(RTL_CONSTASCII_USTRINGPARAM("/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_FAIL( "### 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;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/registry/data/org/openoffice/Office/Addons.xcu b/sdext/source/minimizer/registry/data/org/openoffice/Office/Addons.xcu
new file mode 100644
index 000000000000..2b4465b402f1
--- /dev/null
+++ b/sdext/source/minimizer/registry/data/org/openoffice/Office/Addons.xcu
@@ -0,0 +1,65 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office">
+ <node oor:name="AddonUI">
+ <node oor:name="Images">
+ <node oor:name="opt-image" oor:op="replace">
+ <prop oor:name="URL">
+ <value>vnd.com.sun.star.comp.SunPresentationMinimizer:execute</value>
+ </prop>
+ <node oor:name="UserDefinedImages">
+ <prop oor:name="ImageSmallURL" oor:type="xs:string">
+ <value>%origin%/../../../../../bitmaps/opt_16.png</value>
+ </prop>
+ <prop oor:name="ImageBigURL" oor:type="xs:string">
+ <value>%origin%/../../../../../bitmaps/opt_26.png</value>
+ </prop>
+ <prop oor:name="ImageSmallHCURL" oor:type="xs:string">
+ <value>%origin%/../../../../../bitmaps/opt_16_h.png</value>
+ </prop>
+ <prop oor:name="ImageBigHCURL" oor:type="xs:string">
+ <value>%origin%/../../../../../bitmaps/opt_26_h.png</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="OfficeMenuBarMerging">
+ <node oor:name="SunPresentationMinimizer" oor:op="replace">
+ <node oor:name="Command1" oor:op="replace">
+ <prop oor:name="MergePoint">
+ <value>.uno:ToolsMenu\.uno:AVMediaPlayer</value>
+ </prop>
+ <prop oor:name="MergeCommand">
+ <value>AddAfter</value>
+ </prop>
+ <prop oor:name="MergeFallback">
+ <value>AddPath</value>
+ </prop>
+ <prop oor:name="MergeContext">
+ <value>com.sun.star.presentation.PresentationDocument</value>
+ </prop>
+ <node oor:name="MenuItems">
+ <node oor:name="SunPresentationMinimizerExecute1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>private:separator</value>
+ </prop>
+ </node>
+ <node oor:name="SunPresentationMinimizerExecute2" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.com.sun.star.comp.SunPresentationMinimizer:execute</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">~Minimize Presentation...</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value>com.sun.star.presentation.PresentationDocument</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/sdext/source/minimizer/registry/data/org/openoffice/Office/ProtocolHandler.xcu b/sdext/source/minimizer/registry/data/org/openoffice/Office/ProtocolHandler.xcu
new file mode 100644
index 000000000000..9baea2c363df
--- /dev/null
+++ b/sdext/source/minimizer/registry/data/org/openoffice/Office/ProtocolHandler.xcu
@@ -0,0 +1,10 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="ProtocolHandler" oor:package="org.openoffice.Office">
+ <node oor:name="HandlerSet">
+ <node oor:name="com.sun.star.comp.SunPresentationMinimizerImp" oor:op="replace">
+ <prop oor:name="Protocols" oor:type="oor:string-list">
+ <value>vnd.com.sun.star.comp.SunPresentationMinimizer:*</value>
+ </prop>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/sdext/source/minimizer/registry/data/org/openoffice/Office/extension/SunPresentationMinimizer.xcu b/sdext/source/minimizer/registry/data/org/openoffice/Office/extension/SunPresentationMinimizer.xcu
new file mode 100644
index 000000000000..08324953d32c
--- /dev/null
+++ b/sdext/source/minimizer/registry/data/org/openoffice/Office/extension/SunPresentationMinimizer.xcu
@@ -0,0 +1,383 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="SunPresentationMinimizer" oor:package="org.openoffice.Office.extension">
+
+ <prop oor:name="BitmapPath" oor:type="xs:string">
+ <value>%origin%/../../../../../../bitmaps</value>
+ </prop>
+
+ <prop oor:name="HelpFile" oor:type="xs:string">
+ <value xml:lang="en-US">%origin%/../../../../../../help/help_en-US.odt</value>
+ </prop>
+
+ <node oor:name="Strings">
+ <prop oor:name="STR_SUN_OPTIMIZATION_WIZARD2">
+ <value xml:lang="en-US">@MINIMIZEREXTENSIONPRODUCTNAME@</value>
+ </prop>
+ <prop oor:name="STR_STEPS">
+ <value xml:lang="en-US">Steps</value>
+ </prop>
+ <prop oor:name="STR_HELP">
+ <value xml:lang="en-US">~Help</value>
+ </prop>
+ <prop oor:name="STR_BACK">
+ <value xml:lang="en-US">&lt; ~Back</value>
+ </prop>
+ <prop oor:name="STR_NEXT">
+ <value xml:lang="en-US">~Next &gt;</value>
+ </prop>
+ <prop oor:name="STR_FINISH">
+ <value xml:lang="en-US">~Finish</value>
+ </prop>
+ <prop oor:name="STR_CANCEL">
+ <value xml:lang="en-US">Cancel</value>
+ </prop>
+ <prop oor:name="STR_INTRODUCTION">
+ <value xml:lang="en-US">Introduction</value>
+ </prop>
+ <prop oor:name="STR_INTRODUCTION_T">
+ <value xml:lang="en-US">The @MINIMIZEREXTENSIONPRODUCTNAME@ is used to reduce the file size of the current presentation. Images will be compressed and data, that is no longer needed, will be removed.
+
+ At the last step of the wizard you can choose to apply the changes to the current presentation or to create an optimized new version of the presentation.</value>
+ </prop>
+ <prop oor:name="STR_CHOSE_SETTINGS">
+ <value xml:lang="en-US">~Choose settings for @MINIMIZEREXTENSIONPRODUCTNAME@</value>
+ </prop>
+ <prop oor:name="STR_REMOVE">
+ <value xml:lang="en-US">~Delete</value>
+ </prop>
+ <prop oor:name="STR_GRAPHIC_OPTIMIZATION">
+ <value xml:lang="en-US">Choose settings for optimizing pictures and graphics</value>
+ </prop>
+ <prop oor:name="STR_IMAGE_OPTIMIZATION">
+ <value xml:lang="en-US">Graphics</value>
+ </prop>
+ <prop oor:name="STR_LOSSLESS_COMPRESSION">
+ <value xml:lang="en-US">~Lossless compression</value>
+ </prop>
+ <prop oor:name="STR_JPEG_COMPRESSION">
+ <value xml:lang="en-US">~JPEG compression</value>
+ </prop>
+ <prop oor:name="STR_QUALITY">
+ <value xml:lang="en-US">~Quality in %</value>
+ </prop>
+ <prop oor:name="STR_REMOVE_CROP_AREA">
+ <value xml:lang="en-US">~Delete cropped graphic areas</value>
+ </prop>
+ <prop oor:name="STR_IMAGE_RESOLUTION">
+ <value xml:lang="en-US">Reduce ~image resolution</value>
+ </prop>
+ <prop oor:name="STR_IMAGE_RESOLUTION_0">
+ <value xml:lang="en-US">0;&lt;no change&gt;</value>
+ </prop>
+ <prop oor:name="STR_IMAGE_RESOLUTION_1">
+ <value xml:lang="en-US">90;90 DPI (screen resolution)</value>
+ </prop>
+ <prop oor:name="STR_IMAGE_RESOLUTION_2">
+ <value xml:lang="en-US">150;150 DPI (projector resolution)</value>
+ </prop>
+ <prop oor:name="STR_IMAGE_RESOLUTION_3">
+ <value xml:lang="en-US">300;300 DPI (print resolution)</value>
+ </prop>
+ <prop oor:name="STR_EMBED_LINKED_GRAPHICS">
+ <value xml:lang="en-US">~Break links to external graphics</value>
+ </prop>
+ <prop oor:name="STR_OLE_OBJECTS">
+ <value xml:lang="en-US">OLE Objects</value>
+ </prop>
+ <prop oor:name="STR_OLE_OPTIMIZATION">
+ <value xml:lang="en-US">Choose settings for replacing OLE objects</value>
+ </prop>
+ <prop oor:name="STR_OLE_REPLACE">
+ <value xml:lang="en-US">Create static replacement graphics for OLE objects</value>
+ </prop>
+ <prop oor:name="STR_ALL_OLE_OBJECTS">
+ <value xml:lang="en-US">For ~all OLE objects</value>
+ </prop>
+ <prop oor:name="STR_ALIEN_OLE_OBJECTS_ONLY">
+ <value xml:lang="en-US">~For OLE objects not based on OpenDocument format</value>
+ </prop>
+ <prop oor:name="STR_OLE_OBJECTS_DESC">
+ <value xml:lang="en-US">Object Linking and Embedding (OLE) is a technology that allows embedding and linking to documents and other objects.
+
+The current presentation contains OLE objects.</value>
+ </prop>
+ <prop oor:name="STR_NO_OLE_OBJECTS_DESC">
+ <value xml:lang="en-US">Object Linking and Embedding (OLE) is a technology that allows embedding and linking to documents and other objects.
+
+The current presentation contains no OLE objects.</value>
+ </prop>
+ <prop oor:name="STR_SLIDES">
+ <value xml:lang="en-US">Slides</value>
+ </prop>
+ <prop oor:name="STR_CHOOSE_SLIDES">
+ <value xml:lang="en-US">Choose which slides to delete</value>
+ </prop>
+ <prop oor:name="STR_MASTER_PAGES">
+ <value xml:lang="en-US">Master Pages</value>
+ </prop>
+ <prop oor:name="STR_DELETE_MASTER_PAGES">
+ <value xml:lang="en-US">Delete unused ~master pages</value>
+ </prop>
+ <prop oor:name="STR_DELETE_NOTES_PAGES">
+ <value xml:lang="en-US">~Clear notes</value>
+ </prop>
+ <prop oor:name="STR_DELETE_HIDDEN_SLIDES">
+ <value xml:lang="en-US">Delete hidden ~slides</value>
+ </prop>
+ <prop oor:name="STR_CUSTOM_SHOW">
+ <value xml:lang="en-US">Delete slides that are not used for the ~custom slide show</value>
+ </prop>
+ <prop oor:name="STR_SUMMARY">
+ <value xml:lang="en-US">Summary</value>
+ </prop>
+ <prop oor:name="STR_SUMMARY_TITLE">
+ <value xml:lang="en-US">Choose where to apply the following changes</value>
+ </prop>
+ <prop oor:name="STR_PROGRESS">
+ <value xml:lang="en-US">Progress</value>
+ </prop>
+ <prop oor:name="STR_OBJECTS_OPTIMIZED">
+ <value xml:lang="en-US">Objects optimized</value>
+ </prop>
+ <prop oor:name="STR_APPLY_TO_CURRENT">
+ <value xml:lang="en-US">~Apply changes to current presentation</value>
+ </prop>
+ <prop oor:name="STR_AUTOMATICALLY_OPEN">
+ <value xml:lang="en-US">~Open newly created presentation</value>
+ </prop>
+ <prop oor:name="STR_SAVE_SETTINGS">
+ <value xml:lang="en-US">~Save settings as</value>
+ </prop>
+ <prop oor:name="STR_SAVE_AS">
+ <value xml:lang="en-US">~Duplicate presentation before applying changes</value>
+ </prop>
+ <prop oor:name="STR_DELETE_SLIDES">
+ <value xml:lang="en-US">Delete %SLIDES slides.</value>
+ </prop>
+ <prop oor:name="STR_OPTIMIZE_IMAGES">
+ <value xml:lang="en-US">Optimize %IMAGES graphics to %QUALITY% JPEG quality at %RESOLUTION DPI.</value>
+ </prop>
+ <prop oor:name="STR_CREATE_REPLACEMENT">
+ <value xml:lang="en-US">Create replacement graphics for %OLE objects.</value>
+ </prop>
+ <prop oor:name="STR_CURRENT_FILESIZE">
+ <value xml:lang="en-US">Current file size:</value>
+ </prop>
+ <prop oor:name="STR_ESTIMATED_FILESIZE">
+ <value xml:lang="en-US">Estimated new file size:</value>
+ </prop>
+ <prop oor:name="STR_MB">
+ <value xml:lang="en-US">%1 MB</value>
+ </prop>
+ <prop oor:name="MY_SETTINGS">
+ <value xml:lang="en-US">My Settings </value>
+ </prop>
+ <prop oor:name="STR_DEFAULT_SESSION">
+ <value xml:lang="en-US">default session</value>
+ </prop>
+ <prop oor:name="STR_MODIFY_WARNING">
+ <value xml:lang="en-US">The optimization will modify the current document. Do you want to continue?</value>
+ </prop>
+ <prop oor:name="STR_YES">
+ <value xml:lang="en-US">~Yes</value>
+ </prop>
+ <prop oor:name="STR_OK">
+ <value xml:lang="en-US">OK</value>
+ </prop>
+ <prop oor:name="STR_INFO_1">
+ <value xml:lang="en-US">The @MINIMIZEREXTENSIONPRODUCTNAME@ has successfully updated the presentation '%TITLE'. The file size has changed from %OLDFILESIZE MB to %NEWFILESIZE MB.</value>
+ </prop>
+ <prop oor:name="STR_INFO_2">
+ <value xml:lang="en-US">The @MINIMIZEREXTENSIONPRODUCTNAME@ has successfully updated the presentation '%TITLE'. The file size has changed from %OLDFILESIZE MB to approximated %NEWFILESIZE MB.</value>
+ </prop>
+ <prop oor:name="STR_INFO_3">
+ <value xml:lang="en-US">The @MINIMIZEREXTENSIONPRODUCTNAME@ has successfully updated the presentation '%TITLE'. The file size has changed to %NEWFILESIZE MB.</value>
+ </prop>
+ <prop oor:name="STR_INFO_4">
+ <value xml:lang="en-US">The @MINIMIZEREXTENSIONPRODUCTNAME@ has successfully updated the presentation '%TITLE'. The file size has changed to approximated %NEWFILESIZE MB.</value>
+ </prop>
+ <prop oor:name="STR_DUPLICATING_PRESENTATION">
+ <value xml:lang="en-US">Duplicating presentation...</value>
+ </prop>
+ <prop oor:name="STR_DELETING_SLIDES">
+ <value xml:lang="en-US">Deleting slides...</value>
+ </prop>
+ <prop oor:name="STR_OPTIMIZING_GRAPHICS">
+ <value xml:lang="en-US">Optimizing graphics...</value>
+ </prop>
+ <prop oor:name="STR_CREATING_OLE_REPLACEMENTS">
+ <value xml:lang="en-US">Creating replacement graphics for OLE objects...</value>
+ </prop>
+ <prop oor:name="STR_FILESIZESEPARATOR">
+ <value xml:lang="en-US">.</value>
+ </prop>
+ </node>
+ <node oor:name="LastUsedSettings">
+ <prop oor:name="Name">
+ <value xml:lang="en-US">Projector optimized</value>
+ </prop>
+ <prop oor:name="JPEGCompression">
+ <value>true</value>
+ </prop>
+ <prop oor:name="JPEGQuality">
+ <value>50</value>
+ </prop>
+ <prop oor:name="RemoveCropArea">
+ <value>true</value>
+ </prop>
+ <prop oor:name="ImageResolution">
+ <value>150</value>
+ </prop>
+ <prop oor:name="EmbedLinkedGraphics">
+ <value>true</value>
+ </prop>
+ <prop oor:name="OLEOptimization">
+ <value>true</value>
+ </prop>
+ <prop oor:name="OLEOptimizationType">
+ <value>0</value>
+ </prop>
+ <prop oor:name="DeleteUnusedMasterPages">
+ <value>true</value>
+ </prop>
+ <prop oor:name="DeleteHiddenSlides">
+ <value>true</value>
+ </prop>
+ <prop oor:name="DeleteNotesPages">
+ <value>false</value>
+ </prop>
+ <prop oor:name="SaveAs">
+ <value>true</value>
+ </prop>
+ <prop oor:name="OpenNewDocument">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Settings">
+ <node oor:name="Templates">
+ <node oor:name="template1" oor:op="replace">
+ <prop oor:name="Name">
+ <value xml:lang="en-US">Screen optimized (smallest file size)</value>
+ </prop>
+ <prop oor:name="JPEGCompression">
+ <value>true</value>
+ </prop>
+ <prop oor:name="JPEGQuality">
+ <value>25</value>
+ </prop>
+ <prop oor:name="RemoveCropArea">
+ <value>true</value>
+ </prop>
+ <prop oor:name="ImageResolution">
+ <value>90</value>
+ </prop>
+ <prop oor:name="EmbedLinkedGraphics">
+ <value>true</value>
+ </prop>
+ <prop oor:name="OLEOptimization">
+ <value>true</value>
+ </prop>
+ <prop oor:name="OLEOptimizationType">
+ <value>0</value>
+ </prop>
+ <prop oor:name="DeleteUnusedMasterPages">
+ <value>true</value>
+ </prop>
+ <prop oor:name="DeleteHiddenSlides">
+ <value>true</value>
+ </prop>
+ <prop oor:name="DeleteNotesPages">
+ <value>false</value>
+ </prop>
+ <prop oor:name="SaveAs">
+ <value>true</value>
+ </prop>
+ <prop oor:name="OpenNewDocument">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="template2" oor:op="replace">
+ <prop oor:name="Name">
+ <value xml:lang="en-US">Projector optimized</value>
+ </prop>
+ <prop oor:name="JPEGCompression">
+ <value>true</value>
+ </prop>
+ <prop oor:name="JPEGQuality">
+ <value>50</value>
+ </prop>
+ <prop oor:name="RemoveCropArea">
+ <value>true</value>
+ </prop>
+ <prop oor:name="ImageResolution">
+ <value>150</value>
+ </prop>
+ <prop oor:name="EmbedLinkedGraphics">
+ <value>true</value>
+ </prop>
+ <prop oor:name="OLEOptimization">
+ <value>true</value>
+ </prop>
+ <prop oor:name="OLEOptimizationType">
+ <value>0</value>
+ </prop>
+ <prop oor:name="DeleteUnusedMasterPages">
+ <value>true</value>
+ </prop>
+ <prop oor:name="DeleteHiddenSlides">
+ <value>true</value>
+ </prop>
+ <prop oor:name="DeleteNotesPages">
+ <value>false</value>
+ </prop>
+ <prop oor:name="SaveAs">
+ <value>true</value>
+ </prop>
+ <prop oor:name="OpenNewDocument">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="template3" oor:op="replace">
+ <prop oor:name="Name">
+ <value xml:lang="en-US">Print optimized</value>
+ </prop>
+ <prop oor:name="JPEGCompression">
+ <value>true</value>
+ </prop>
+ <prop oor:name="JPEGQuality">
+ <value>75</value>
+ </prop>
+ <prop oor:name="RemoveCropArea">
+ <value>true</value>
+ </prop>
+ <prop oor:name="ImageResolution">
+ <value>300</value>
+ </prop>
+ <prop oor:name="EmbedLinkedGraphics">
+ <value>true</value>
+ </prop>
+ <prop oor:name="OLEOptimization">
+ <value>true</value>
+ </prop>
+ <prop oor:name="OLEOptimizationType">
+ <value>0</value>
+ </prop>
+ <prop oor:name="DeleteUnusedMasterPages">
+ <value>true</value>
+ </prop>
+ <prop oor:name="DeleteHiddenSlides">
+ <value>true</value>
+ </prop>
+ <prop oor:name="DeleteNotesPages">
+ <value>false</value>
+ </prop>
+ <prop oor:name="SaveAs">
+ <value>true</value>
+ </prop>
+ <prop oor:name="OpenNewDocument">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/sdext/source/minimizer/registry/data/org/openoffice/Office/extension/makefile.mk b/sdext/source/minimizer/registry/data/org/openoffice/Office/extension/makefile.mk
new file mode 100644
index 000000000000..aa0d275a969a
--- /dev/null
+++ b/sdext/source/minimizer/registry/data/org/openoffice/Office/extension/makefile.mk
@@ -0,0 +1,50 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..$/..$/..$/..$/..$/..
+
+PRJNAME=sdext
+TARGET=data_ooOfficeext
+PACKAGE=org.openoffice.Office.extension
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/source$/minimizer$/minimizer.pmk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+XCSROOT=$(PRJ)$/source$/minimizer
+ABSXCSROOT=$(PWD)$/$(PRJ)$/source$/minimizer
+
+# --- Targets ------------------------------------------------------
+
+XCUFILES= \
+ SunPresentationMinimizer.xcu
+
+MODULEFILES=
+
+LOCALIZEDFILES= \
+ SunPresentationMinimizer.xcu
+
+.INCLUDE : target.mk
diff --git a/sdext/source/minimizer/registry/data/org/openoffice/Office/makefile.mk b/sdext/source/minimizer/registry/data/org/openoffice/Office/makefile.mk
new file mode 100644
index 000000000000..659e888045d9
--- /dev/null
+++ b/sdext/source/minimizer/registry/data/org/openoffice/Office/makefile.mk
@@ -0,0 +1,48 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..$/..$/..$/..$/..
+
+PRJNAME=sdext
+TARGET=data_ooOffice
+PACKAGE=org.openoffice.Office
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/source$/minimizer$/minimizer.pmk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Targets ------------------------------------------------------
+
+XCUFILES= \
+ Addons.xcu \
+ ProtocolHandler.xcu
+
+MODULEFILES=
+
+LOCALIZEDFILES= \
+ Addons.xcu
+
+.INCLUDE : target.mk
diff --git a/sdext/source/minimizer/registry/schema/org/openoffice/Office/extension/SunPresentationMinimizer.xcs b/sdext/source/minimizer/registry/schema/org/openoffice/Office/extension/SunPresentationMinimizer.xcs
new file mode 100644
index 000000000000..f121768e0e72
--- /dev/null
+++ b/sdext/source/minimizer/registry/schema/org/openoffice/Office/extension/SunPresentationMinimizer.xcs
@@ -0,0 +1,326 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<oor:component-schema oor:name="SunPresentationMinimizer" oor:package="org.openoffice.Office.extension" xml:lang="en-US" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <templates>
+ <group oor:name="OptimizerSettings">
+ <info>
+ <desc>Describes the Presentation Optimization Wizard settings of one session</desc>
+ </info>
+ <prop oor:name="Name" oor:type="xs:string" oor:localized="true">
+ <info>
+ <desc>Specifies the name settings name</desc>
+ </info>
+ <value>Default</value>
+ </prop>
+ <prop oor:name="JPEGCompression" oor:type="xs:boolean">
+ <info>
+ <desc>Specifies if JPEG compression is being used</desc>
+ </info>
+ <value>true</value>
+ </prop>
+ <prop oor:name="JPEGQuality" oor:type="xs:int">
+ <info>
+ <desc>Specifies quality of the JPG export. A higher value results in higher quality and file size.</desc>
+ </info>
+ <constraints>
+ <minInclusive oor:value="1">
+ <info>
+ <desc>Represents lowest value that can be used. The lower the value, the less good is the compression quality and the bigger is be the file size.</desc>
+ </info>
+ </minInclusive>
+ <maxInclusive oor:value="100">
+ <info>
+ <desc>Represents highest value that can be used. The higher the value, the better is the compression quality and the smaller is the file size.</desc>
+ </info>
+ </maxInclusive>
+ </constraints>
+ <value>45</value>
+ </prop>
+ <prop oor:name="RemoveCropArea" oor:type="xs:boolean">
+ <info>
+ <desc>Specifies if the crop area of a picture has to be removed</desc>
+ </info>
+ <value>true</value>
+ </prop>
+ <prop oor:name="ImageResolution" oor:type="xs:int">
+ <info>
+ <desc>Specifies the Image Resolution that should be used in dpi. A value of zero determines that the image resolution should not be changed.</desc>
+ </info>
+ <value>150</value>
+ </prop>
+ <prop oor:name="EmbedLinkedGraphics" oor:type="xs:boolean">
+ <info>
+ <desc>Specifies if linked graphics are to be embedded</desc>
+ </info>
+ <value>true</value>
+ </prop>
+ <prop oor:name="OLEOptimization" oor:type="xs:boolean">
+ <info>
+ <desc>Specifies if OLE Objects are converted to Graphic objects at all</desc>
+ </info>
+ <value>true</value>
+ </prop>
+ <prop oor:name="OLEOptimizationType" oor:type="xs:short">
+ <info>
+ <desc>Specifies the compression type that is being used,.</desc>
+ </info>
+ <constraints>
+ <enumeration oor:value="0"><info><desc>Each</desc></info></enumeration>
+ <enumeration oor:value="1"><info><desc>Alien</desc></info></enumeration>
+ </constraints>
+ <value>0</value>
+ </prop>
+ <prop oor:name="DeleteUnusedMasterPages" oor:type="xs:boolean">
+ <info>
+ <desc>Specifies if unused Master Pages are being deleted</desc>
+ </info>
+ <value>true</value>
+ </prop>
+ <prop oor:name="DeleteHiddenSlides" oor:type="xs:boolean">
+ <info>
+ <desc>Specifies if hidden Slides are being deleted</desc>
+ </info>
+ <value>true</value>
+ </prop>
+ <prop oor:name="DeleteNotesPages" oor:type="xs:boolean">
+ <info>
+ <desc>Specifies if Notes Pages are being deleted</desc>
+ </info>
+ <value>false</value>
+ </prop>
+ <prop oor:name="SaveAs" oor:type="xs:boolean">
+ <info>
+ <desc>Specifies if the optimization is done on a new document.</desc>
+ </info>
+ <value>true</value>
+ </prop>
+ <prop oor:name="OpenNewDocument" oor:type="xs:boolean">
+ <info>
+ <desc>Specifies if the newly created document is opened automatically.</desc>
+ </info>
+ <value>true</value>
+ </prop>
+ </group>
+ </templates>
+ <component>
+ <prop oor:name="BitmapPath" oor:type="xs:string"/>
+ <prop oor:name="HelpFile" oor:type="xs:string"/>
+ <group oor:name="Strings">
+ <prop oor:name="STR_SUN_OPTIMIZATION_WIZARD2" oor:type="xs:string" oor:localized="true">
+ <value>Presentation Minimizer</value>
+ </prop>
+ <prop oor:name="STR_STEPS" oor:type="xs:string" oor:localized="true">
+ <value>Steps</value>
+ </prop>
+ <prop oor:name="STR_HELP" oor:type="xs:string" oor:localized="true">
+ <value>~Help</value>
+ </prop>
+ <prop oor:name="STR_BACK" oor:type="xs:string" oor:localized="true">
+ <value>&lt; ~Back</value>
+ </prop>
+ <prop oor:name="STR_NEXT" oor:type="xs:string" oor:localized="true">
+ <value>~Next &gt;</value>
+ </prop>
+ <prop oor:name="STR_FINISH" oor:type="xs:string" oor:localized="true">
+ <value>~Finish</value>
+ </prop>
+ <prop oor:name="STR_CANCEL" oor:type="xs:string" oor:localized="true">
+ <value>Cancel</value>
+ </prop>
+ <prop oor:name="STR_INTRODUCTION" oor:type="xs:string" oor:localized="true">
+ <value>Introduction</value>
+ </prop>
+ <prop oor:name="STR_INTRODUCTION_T" oor:type="xs:string" oor:localized="true">
+ <value>The Presentation Minimizer is used to reduce the file size of the current presentation. Images will be compressed and data, that is no longer needed, will be removed.
+
+ At the last step of the wizard you can choose to apply the changes to the current presentation or to create an optimized new version of the presentation.</value>
+ </prop>
+ <prop oor:name="STR_CHOSE_SETTINGS" oor:type="xs:string" oor:localized="true">
+ <value>~Choose settings for the Presentation Minimization Wizard</value>
+ </prop>
+ <prop oor:name="STR_REMOVE" oor:type="xs:string" oor:localized="true">
+ <value>~Delete</value>
+ </prop>
+ <prop oor:name="STR_GRAPHIC_OPTIMIZATION" oor:type="xs:string" oor:localized="true">
+ <value>Choose settings for optimizing pictures and graphics</value>
+ </prop>
+ <prop oor:name="STR_IMAGE_OPTIMIZATION" oor:type="xs:string" oor:localized="true">
+ <value>Graphics</value>
+ </prop>
+ <prop oor:name="STR_LOSSLESS_COMPRESSION" oor:type="xs:string" oor:localized="true">
+ <value>~Lossless compression</value>
+ </prop>
+ <prop oor:name="STR_JPEG_COMPRESSION" oor:type="xs:string" oor:localized="true">
+ <value>~JPEG compression</value>
+ </prop>
+ <prop oor:name="STR_QUALITY" oor:type="xs:string" oor:localized="true">
+ <value>~Quality</value>
+ </prop>
+ <prop oor:name="STR_REMOVE_CROP_AREA" oor:type="xs:string" oor:localized="true">
+ <value>~Delete cropped graphic areas</value>
+ </prop>
+ <prop oor:name="STR_IMAGE_RESOLUTION" oor:type="xs:string" oor:localized="true">
+ <value>~Image Resolution</value>
+ </prop>
+ <prop oor:name="STR_IMAGE_RESOLUTION_0" oor:type="xs:string" oor:localized="true">
+ <value>0;&lt;no change&gt;</value>
+ </prop>
+ <prop oor:name="STR_IMAGE_RESOLUTION_1" oor:type="xs:string" oor:localized="true">
+ <value>90;90 DPI (screen resolution)</value>
+ </prop>
+ <prop oor:name="STR_IMAGE_RESOLUTION_2" oor:type="xs:string" oor:localized="true">
+ <value>150;150 DPI (projector resolution)</value>
+ </prop>
+ <prop oor:name="STR_IMAGE_RESOLUTION_3" oor:type="xs:string" oor:localized="true">
+ <value>300;300 DPI (print resolution)</value>
+ </prop>
+ <prop oor:name="STR_EMBED_LINKED_GRAPHICS" oor:type="xs:string" oor:localized="true">
+ <value>~Break links to external graphics</value>
+ </prop>
+ <prop oor:name="STR_OLE_OBJECTS" oor:type="xs:string" oor:localized="true">
+ <value>OLE Objects</value>
+ </prop>
+ <prop oor:name="STR_OLE_OPTIMIZATION" oor:type="xs:string" oor:localized="true">
+ <value>Choose settings for replacing OLE objects</value>
+ </prop>
+ <prop oor:name="STR_OLE_REPLACE" oor:type="xs:string" oor:localized="true">
+ <value>Create static replacement graphics for OLE objects</value>
+ </prop>
+ <prop oor:name="STR_ALL_OLE_OBJECTS" oor:type="xs:string" oor:localized="true">
+ <value>For ~all OLE objects</value>
+ </prop>
+ <prop oor:name="STR_ALIEN_OLE_OBJECTS_ONLY" oor:type="xs:string" oor:localized="true">
+ <value>~For OLE objects not based on OpenDocument format</value>
+ </prop>
+ <prop oor:name="STR_OLE_OBJECTS_DESC" oor:type="xs:string" oor:localized="true">
+ <value>Object Linking and Embedding (OLE) is a technology that allows embedding and linking to documents and other objects.
+
+The current presentation contains no OLE objects.</value>
+ </prop>
+ <prop oor:name="STR_NO_OLE_OBJECTS_DESC" oor:type="xs:string" oor:localized="true">
+ <value>Object Linking and Embedding (OLE) is a technology that allows embedding and linking to documents and other objects.
+
+The current presentation contains no OLE objects.</value>
+ </prop>
+ <prop oor:name="STR_SLIDES" oor:type="xs:string" oor:localized="true">
+ <value>Slides</value>
+ </prop>
+ <prop oor:name="STR_CHOOSE_SLIDES" oor:type="xs:string" oor:localized="true">
+ <value>Choose which slides to delete</value>
+ </prop>
+ <prop oor:name="STR_MASTER_PAGES" oor:type="xs:string" oor:localized="true">
+ <value>Master Pages</value>
+ </prop>
+ <prop oor:name="STR_DELETE_MASTER_PAGES" oor:type="xs:string" oor:localized="true">
+ <value>Delete unused ~master pages</value>
+ </prop>
+ <prop oor:name="STR_DELETE_NOTES_PAGES" oor:type="xs:string" oor:localized="true">
+ <value>~Clear notes</value>
+ </prop>
+ <prop oor:name="STR_DELETE_HIDDEN_SLIDES" oor:type="xs:string" oor:localized="true">
+ <value>Delete hidden ~slides</value>
+ </prop>
+ <prop oor:name="STR_CUSTOM_SHOW" oor:type="xs:string" oor:localized="true">
+ <value>Delete slides that are not used for the ~custom slide show</value>
+ </prop>
+ <prop oor:name="STR_SUMMARY" oor:type="xs:string" oor:localized="true">
+ <value>Summary</value>
+ </prop>
+ <prop oor:name="STR_SUMMARY_TITLE" oor:type="xs:string" oor:localized="true">
+ <value>Choose where to apply the following changes</value>
+ </prop>
+ <prop oor:name="STR_PROGRESS" oor:type="xs:string" oor:localized="true">
+ <value>Progress</value>
+ </prop>
+ <prop oor:name="STR_OBJECTS_OPTIMIZED" oor:type="xs:string" oor:localized="true">
+ <value>Objects optimized</value>
+ </prop>
+ <prop oor:name="STR_APPLY_TO_CURRENT" oor:type="xs:string" oor:localized="true">
+ <value>~Apply changes to current presentation</value>
+ </prop>
+ <prop oor:name="STR_AUTOMATICALLY_OPEN" oor:type="xs:string" oor:localized="true">
+ <value>~Open newly created presentation</value>
+ </prop>
+ <prop oor:name="STR_SAVE_SETTINGS" oor:type="xs:string" oor:localized="true">
+ <value>~Save settings as</value>
+ </prop>
+ <prop oor:name="STR_SAVE_AS" oor:type="xs:string" oor:localized="true">
+ <value>~Duplicate presentation before applying changes</value>
+ </prop>
+ <prop oor:name="STR_DELETE_SLIDES" oor:type="xs:string" oor:localized="true">
+ <value>Delete %SLIDES slides</value>
+ </prop>
+ <prop oor:name="STR_OPTIMIZE_IMAGES" oor:type="xs:string" oor:localized="true">
+ <info>
+ <desc>The following string is only used in plural.</desc>
+ </info>
+ <value>Optimize %IMAGES graphics to %QUALITY% JPEG quality at %RESOLUTION DPI.</value>
+ </prop>
+ <prop oor:name="STR_CREATE_REPLACEMENT" oor:type="xs:string" oor:localized="true">
+ <value>Create replacement graphics for %OLE objects.</value>
+ </prop>
+ <prop oor:name="STR_CURRENT_FILESIZE" oor:type="xs:string" oor:localized="true">
+ <value>Current file size:</value>
+ </prop>
+ <prop oor:name="STR_ESTIMATED_FILESIZE" oor:type="xs:string" oor:localized="true">
+ <value>Estimated new file size:</value>
+ </prop>
+ <prop oor:name="STR_MB" oor:type="xs:string" oor:localized="true">
+ <value>%1 MB</value>
+ </prop>
+ <prop oor:name="MY_SETTINGS" oor:type="xs:string" oor:localized="true">
+ <value>My Settings</value>
+ </prop>
+ <prop oor:name="STR_DEFAULT_SESSION" oor:type="xs:string" oor:localized="true">
+ <value>default session</value>
+ </prop>
+ <prop oor:name="STR_MODIFY_WARNING" oor:type="xs:string" oor:localized="true">
+ <value>The optimization will modify the current document. Do you want to continue?</value>
+ </prop>
+ <prop oor:name="STR_YES" oor:type="xs:string" oor:localized="true">
+ <value>~Yes</value>
+ </prop>
+ <prop oor:name="STR_OK" oor:type="xs:string" oor:localized="true">
+ <value>OK</value>
+ </prop>
+ <prop oor:name="STR_INFO_1" oor:type="xs:string" oor:localized="true">
+ <value>The Presentation Minimizer has successfully updated the presentation '%TITLE'. The file size has changed from %OLDFILESIZE MB to %NEWFILESIZE MB.</value>
+ </prop>
+ <prop oor:name="STR_INFO_2" oor:type="xs:string" oor:localized="true">
+ <value>The Presentation Minimizer has successfully updated the presentation '%TITLE'. The file size has changed from %OLDFILESIZE MB to approximated %NEWFILESIZE MB.</value>
+ </prop>
+ <prop oor:name="STR_INFO_3" oor:type="xs:string" oor:localized="true">
+ <value>The Presentation Minimizer has successfully updated the presentation '%TITLE'. The file size has changed to %NEWFILESIZE MB.</value>
+ </prop>
+ <prop oor:name="STR_INFO_4" oor:type="xs:string" oor:localized="true">
+ <value>The Presentation Minimizer has successfully updated the presentation '%TITLE'. The file size has changed to approximated %NEWFILESIZE MB.</value>
+ </prop>
+ <prop oor:name="STR_DUPLICATING_PRESENTATION" oor:type="xs:string" oor:localized="true">
+ <value>Duplicating presentation...</value>
+ </prop>
+ <prop oor:name="STR_DELETING_SLIDES" oor:type="xs:string" oor:localized="true">
+ <value>Deleting slides...</value>
+ </prop>
+ <prop oor:name="STR_OPTIMIZING_GRAPHICS" oor:type="xs:string" oor:localized="true">
+ <value>Optimizing graphics...</value>
+ </prop>
+ <prop oor:name="STR_CREATING_OLE_REPLACEMENTS" oor:type="xs:string" oor:localized="true">
+ <value>Creating replacement graphics for OLE objects...</value>
+ </prop>
+ <prop oor:name="STR_FILESIZESEPARATOR" oor:type="xs:string" oor:localized="true">
+ <value>.</value>
+ </prop>
+ </group>
+ <node-ref oor:name="LastUsedSettings" oor:node-type="OptimizerSettings">
+ <info>
+ <desc>describes the name of the last used settings</desc>
+ </info>
+ </node-ref>
+ <group oor:name="Settings">
+ <set oor:name="Templates" oor:node-type="OptimizerSettings">
+ <info>
+ <desc>List of the saved Presentation Optimization Wizard settings</desc>
+ </info>
+ </set>
+ </group>
+ </component>
+</oor:component-schema> \ No newline at end of file
diff --git a/sdext/source/minimizer/unodialog.cxx b/sdext/source/minimizer/unodialog.cxx
new file mode 100644
index 000000000000..e5f6fdceeed3
--- /dev/null
+++ b/sdext/source/minimizer/unodialog.cxx
@@ -0,0 +1,406 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sdext.hxx"
+
+#include "unodialog.hxx"
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/view/XControlAccess.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/awt/XMessageBoxFactory.hpp>
+#include <com/sun/star/awt/MessageBoxButtons.hpp>
+
+// -------------
+// - 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 = 0;
+ 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& )
+ {
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 UnoDialog::getMapsFromPixels( sal_Int32 nPixels ) const
+{
+ double dMaps = 0;
+ try
+ {
+ sal_Int32 nMapWidth = 0;
+ const OUString sWidth( RTL_CONSTASCII_USTRINGPARAM( "Width" ) );
+ if ( mxDialogModelPropertySet->getPropertyValue( sWidth ) >>= nMapWidth )
+ {
+ Reference< XWindow > xWindow( mxDialog, UNO_QUERY_THROW );
+ double pxWidth = xWindow->getPosSize().Width;
+ double mapRatio = ( pxWidth / nMapWidth );
+ dMaps = nPixels / mapRatio;
+ }
+ }
+ catch ( Exception& )
+ {
+ }
+ return static_cast< sal_Int32 >( dMaps );
+}
+
+// -----------------------------------------------------------------------------
+
+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 ) );
+}
+
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/unodialog.hxx b/sdext/source/minimizer/unodialog.hxx
new file mode 100644
index 000000000000..78e3fd0f409c
--- /dev/null
+++ b/sdext/source/minimizer/unodialog.hxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef UNODIALOG_HXX
+#define UNODIALOG_HXX
+
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/awt/XActionListener.hpp>
+#include <com/sun/star/awt/XTextListener.hpp>
+#include <com/sun/star/awt/XButton.hpp>
+#include <com/sun/star/awt/XCheckBox.hpp>
+#include <com/sun/star/awt/XComboBox.hpp>
+#include <com/sun/star/awt/XTextComponent.hpp>
+#include <com/sun/star/awt/XRadioButton.hpp>
+#include <com/sun/star/awt/XListBox.hpp>
+#include <com/sun/star/awt/XFixedText.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/XReschedule.hpp>
+#include <com/sun/star/awt/XDialog.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.hxx>
+
+// -------------
+// - 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();
+
+ sal_Int32 getMapsFromPixels( sal_Int32 nPixels ) const;
+
+ 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 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */