1c142477cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3c142477cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4c142477cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5c142477cSAndrew Rist * distributed with this work for additional information
6c142477cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7c142477cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8c142477cSAndrew Rist * "License"); you may not use this file except in compliance
9c142477cSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11c142477cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13c142477cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14c142477cSAndrew Rist * software distributed under the License is distributed on an
15c142477cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c142477cSAndrew Rist * KIND, either express or implied. See the License for the
17c142477cSAndrew Rist * specific language governing permissions and limitations
18c142477cSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20c142477cSAndrew Rist *************************************************************/
21c142477cSAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sdext.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include "optimizerdialog.hxx"
26597a4c59SAriel Constenla-Haile #include "minimizer.hrc"
27597a4c59SAriel Constenla-Haile #include "helpid.hrc"
28cdf0e10cSrcweir
29cdf0e10cSrcweir // -------------------
30cdf0e10cSrcweir // - OptimizerDialog -
31cdf0e10cSrcweir // -------------------
32cdf0e10cSrcweir #include "pppoptimizer.hxx"
33cdf0e10cSrcweir #include "graphiccollector.hxx"
34cdf0e10cSrcweir #include "pagecollector.hxx"
35cdf0e10cSrcweir #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
36cdf0e10cSrcweir #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
37cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
38cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp>
39cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_XFONTWEIGHT_HPP_
40cdf0e10cSrcweir #include <com/sun/star/awt/FontWeight.hpp>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
43cdf0e10cSrcweir
44cdf0e10cSrcweir using namespace ::com::sun::star::awt;
45cdf0e10cSrcweir using namespace ::com::sun::star::uno;
46cdf0e10cSrcweir using namespace ::com::sun::star::util;
47cdf0e10cSrcweir using namespace ::com::sun::star::lang;
48cdf0e10cSrcweir using namespace ::com::sun::star::frame;
49cdf0e10cSrcweir using namespace ::com::sun::star::beans;
50cdf0e10cSrcweir using namespace ::com::sun::star::script;
51cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
52cdf0e10cSrcweir using namespace ::com::sun::star::container;
53cdf0e10cSrcweir using namespace ::com::sun::star::presentation;
54cdf0e10cSrcweir
55597a4c59SAriel Constenla-Haile using ::rtl::OUString;
56597a4c59SAriel Constenla-Haile using ::rtl::OUStringBuffer;
57cdf0e10cSrcweir // -----------------------------------------------------------------------------
58cdf0e10cSrcweir
ImplSetBold(const rtl::OUString & rControl)59597a4c59SAriel Constenla-Haile void OptimizerDialog::ImplSetBold( const rtl::OUString& rControl )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir FontDescriptor aFontDescriptor;
62597a4c59SAriel Constenla-Haile if ( getControlProperty( rControl, TKGet( TK_FontDescriptor ) ) >>= aFontDescriptor )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir aFontDescriptor.Weight = FontWeight::BOLD;
65597a4c59SAriel Constenla-Haile setControlProperty( rControl, TKGet( TK_FontDescriptor ), Any( aFontDescriptor ) );
66cdf0e10cSrcweir }
67cdf0e10cSrcweir }
68cdf0e10cSrcweir
69cdf0e10cSrcweir // -----------------------------------------------------------------------------
70cdf0e10cSrcweir
ImplInsertSeparator(const OUString & rControlName,sal_Int32 nOrientation,sal_Int32 nPosX,sal_Int32 nPosY,sal_Int32 nWidth,sal_Int32 nHeight)71597a4c59SAriel Constenla-Haile rtl::OUString OptimizerDialog::ImplInsertSeparator(
72597a4c59SAriel Constenla-Haile const OUString& rControlName,
73597a4c59SAriel Constenla-Haile sal_Int32 nOrientation,
74597a4c59SAriel Constenla-Haile sal_Int32 nPosX,
75597a4c59SAriel Constenla-Haile sal_Int32 nPosY,
76597a4c59SAriel Constenla-Haile sal_Int32 nWidth,
77597a4c59SAriel Constenla-Haile sal_Int32 nHeight )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir OUString pNames[] = {
80cdf0e10cSrcweir TKGet( TK_Height ),
81cdf0e10cSrcweir TKGet( TK_Orientation ),
82cdf0e10cSrcweir TKGet( TK_PositionX ),
83cdf0e10cSrcweir TKGet( TK_PositionY ),
84cdf0e10cSrcweir TKGet( TK_Step ),
85cdf0e10cSrcweir TKGet( TK_Width ) };
86cdf0e10cSrcweir
87cdf0e10cSrcweir Any pValues[] = {
88cdf0e10cSrcweir Any( nHeight ),
89cdf0e10cSrcweir Any( nOrientation ),
90cdf0e10cSrcweir Any( nPosX ),
91cdf0e10cSrcweir Any( nPosY ),
92cdf0e10cSrcweir Any( sal_Int16( 0 ) ),
93cdf0e10cSrcweir Any( nWidth ) };
94cdf0e10cSrcweir
95cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
96cdf0e10cSrcweir
97cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount );
98cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount );
99cdf0e10cSrcweir
100597a4c59SAriel Constenla-Haile insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedLineModel" ) ),
101cdf0e10cSrcweir rControlName, aNames, aValues );
102cdf0e10cSrcweir return rControlName;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
105cdf0e10cSrcweir // -----------------------------------------------------------------------------
106cdf0e10cSrcweir
ImplInsertButton(const OUString & rControlName,const rtl::OUString & rHelpURL,sal_Int32 nXPos,sal_Int32 nYPos,sal_Int32 nWidth,sal_Int32 nHeight,sal_Int16 nTabIndex,sal_Bool bEnabled,sal_Int32 nResID,sal_Int16 nPushButtonType)107597a4c59SAriel Constenla-Haile rtl::OUString OptimizerDialog::ImplInsertButton(
108597a4c59SAriel Constenla-Haile const OUString& rControlName,
109597a4c59SAriel Constenla-Haile const rtl::OUString& rHelpURL,
110597a4c59SAriel Constenla-Haile sal_Int32 nXPos,
111597a4c59SAriel Constenla-Haile sal_Int32 nYPos,
112597a4c59SAriel Constenla-Haile sal_Int32 nWidth,
113597a4c59SAriel Constenla-Haile sal_Int32 nHeight,
114597a4c59SAriel Constenla-Haile sal_Int16 nTabIndex,
115597a4c59SAriel Constenla-Haile sal_Bool bEnabled,
116597a4c59SAriel Constenla-Haile sal_Int32 nResID,
117597a4c59SAriel Constenla-Haile sal_Int16 nPushButtonType )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir OUString pNames[] = {
120cdf0e10cSrcweir TKGet( TK_Enabled ),
121cdf0e10cSrcweir TKGet( TK_Height ),
122597a4c59SAriel Constenla-Haile TKGet( TK_HelpURL ),
123cdf0e10cSrcweir TKGet( TK_Label ),
124cdf0e10cSrcweir TKGet( TK_PositionX ),
125cdf0e10cSrcweir TKGet( TK_PositionY ),
126cdf0e10cSrcweir TKGet( TK_PushButtonType ),
127cdf0e10cSrcweir TKGet( TK_Step ),
128cdf0e10cSrcweir TKGet( TK_TabIndex ),
129cdf0e10cSrcweir TKGet( TK_Width ) };
130cdf0e10cSrcweir
131cdf0e10cSrcweir Any pValues[] = {
132cdf0e10cSrcweir Any( bEnabled ),
133cdf0e10cSrcweir Any( nHeight ),
134597a4c59SAriel Constenla-Haile Any( rHelpURL ),
135597a4c59SAriel Constenla-Haile Any( getString( nResID ) ),
136cdf0e10cSrcweir Any( nXPos ),
137cdf0e10cSrcweir Any( nYPos ),
138cdf0e10cSrcweir Any( nPushButtonType ),
139cdf0e10cSrcweir Any( (sal_Int16)0 ),
140cdf0e10cSrcweir Any( nTabIndex ),
141cdf0e10cSrcweir Any( nWidth ) };
142cdf0e10cSrcweir
143cdf0e10cSrcweir
144cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
145cdf0e10cSrcweir
146cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount );
147cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount );
148cdf0e10cSrcweir
149597a4c59SAriel Constenla-Haile insertButton( rControlName, this, aNames, aValues );
150cdf0e10cSrcweir return rControlName;
151cdf0e10cSrcweir }
152cdf0e10cSrcweir
153cdf0e10cSrcweir // -----------------------------------------------------------------------------
154cdf0e10cSrcweir
ImplInsertFixedText(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)155597a4c59SAriel Constenla-Haile rtl::OUString OptimizerDialog::ImplInsertFixedText(
156597a4c59SAriel Constenla-Haile const rtl::OUString& rControlName,
157597a4c59SAriel Constenla-Haile const OUString& rLabel,
158597a4c59SAriel Constenla-Haile sal_Int32 nXPos,
159597a4c59SAriel Constenla-Haile sal_Int32 nYPos,
160597a4c59SAriel Constenla-Haile sal_Int32 nWidth,
161597a4c59SAriel Constenla-Haile sal_Int32 nHeight,
162597a4c59SAriel Constenla-Haile sal_Bool bMultiLine,
163597a4c59SAriel Constenla-Haile sal_Bool bBold,
164597a4c59SAriel Constenla-Haile sal_Int16 nTabIndex )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir OUString pNames[] = {
167cdf0e10cSrcweir TKGet( TK_Height ),
168cdf0e10cSrcweir TKGet( TK_Label ),
169cdf0e10cSrcweir TKGet( TK_MultiLine ),
170cdf0e10cSrcweir TKGet( TK_PositionX ),
171cdf0e10cSrcweir TKGet( TK_PositionY ),
172cdf0e10cSrcweir TKGet( TK_Step ),
173cdf0e10cSrcweir TKGet( TK_TabIndex ),
174cdf0e10cSrcweir TKGet( TK_Width ) };
175cdf0e10cSrcweir
176cdf0e10cSrcweir Any pValues[] = {
177cdf0e10cSrcweir Any( nHeight ),
178cdf0e10cSrcweir Any( rLabel ),
179cdf0e10cSrcweir Any( bMultiLine ),
180cdf0e10cSrcweir Any( nXPos ),
181cdf0e10cSrcweir Any( nYPos ),
182cdf0e10cSrcweir Any( (sal_Int16)0 ),
183cdf0e10cSrcweir Any( nTabIndex ),
184cdf0e10cSrcweir Any( nWidth ) };
185cdf0e10cSrcweir
186cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
187cdf0e10cSrcweir
188cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount );
189cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount );
190cdf0e10cSrcweir
191597a4c59SAriel Constenla-Haile insertFixedText( rControlName, aNames, aValues );
192cdf0e10cSrcweir if ( bBold )
193597a4c59SAriel Constenla-Haile ImplSetBold( rControlName );
194cdf0e10cSrcweir return rControlName;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
197cdf0e10cSrcweir // -----------------------------------------------------------------------------
198cdf0e10cSrcweir
ImplInsertCheckBox(const OUString & rControlName,const OUString & rLabel,const rtl::OUString & rHelpURL,sal_Int32 nXPos,sal_Int32 nYPos,sal_Int32 nWidth,sal_Int32 nHeight,sal_Int16 nTabIndex)199597a4c59SAriel Constenla-Haile rtl::OUString OptimizerDialog::ImplInsertCheckBox(
200597a4c59SAriel Constenla-Haile const OUString& rControlName,
201597a4c59SAriel Constenla-Haile const OUString& rLabel,
202597a4c59SAriel Constenla-Haile const rtl::OUString& rHelpURL,
203597a4c59SAriel Constenla-Haile sal_Int32 nXPos,
204597a4c59SAriel Constenla-Haile sal_Int32 nYPos,
205597a4c59SAriel Constenla-Haile sal_Int32 nWidth,
206597a4c59SAriel Constenla-Haile sal_Int32 nHeight,
207597a4c59SAriel Constenla-Haile sal_Int16 nTabIndex )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir OUString pNames[] = {
210cdf0e10cSrcweir TKGet( TK_Enabled ),
211cdf0e10cSrcweir TKGet( TK_Height ),
212597a4c59SAriel Constenla-Haile TKGet( TK_HelpURL ),
213cdf0e10cSrcweir TKGet( TK_Label ),
214cdf0e10cSrcweir TKGet( TK_PositionX ),
215cdf0e10cSrcweir TKGet( TK_PositionY ),
216cdf0e10cSrcweir TKGet( TK_Step ),
217cdf0e10cSrcweir TKGet( TK_TabIndex ),
218cdf0e10cSrcweir TKGet( TK_Width ) };
219cdf0e10cSrcweir
220cdf0e10cSrcweir Any pValues[] = {
221cdf0e10cSrcweir Any( sal_True ),
222cdf0e10cSrcweir Any( nHeight ),
223597a4c59SAriel Constenla-Haile Any( rHelpURL ),
224cdf0e10cSrcweir Any( rLabel ),
225cdf0e10cSrcweir Any( nXPos ),
226cdf0e10cSrcweir Any( nYPos ),
227cdf0e10cSrcweir Any( (sal_Int16)0 ),
228cdf0e10cSrcweir Any( nTabIndex ),
229cdf0e10cSrcweir Any( nWidth ) };
230cdf0e10cSrcweir
231cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
232cdf0e10cSrcweir
233cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount );
234cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount );
235cdf0e10cSrcweir
236597a4c59SAriel Constenla-Haile Reference< XCheckBox > xCheckBox( insertCheckBox( rControlName, aNames, aValues ) );
237597a4c59SAriel Constenla-Haile xCheckBox->addItemListener( this );
238cdf0e10cSrcweir return rControlName;
239cdf0e10cSrcweir }
240cdf0e10cSrcweir
241cdf0e10cSrcweir // -----------------------------------------------------------------------------
242cdf0e10cSrcweir
ImplInsertFormattedField(const OUString & rControlName,const rtl::OUString & rHelpURL,sal_Int32 nXPos,sal_Int32 nYPos,sal_Int32 nWidth,double fEffectiveMin,double fEffectiveMax,sal_Int16 nTabIndex)243597a4c59SAriel Constenla-Haile rtl::OUString OptimizerDialog::ImplInsertFormattedField(
244597a4c59SAriel Constenla-Haile const OUString& rControlName,
245597a4c59SAriel Constenla-Haile const rtl::OUString& rHelpURL,
246597a4c59SAriel Constenla-Haile sal_Int32 nXPos,
247597a4c59SAriel Constenla-Haile sal_Int32 nYPos,
248597a4c59SAriel Constenla-Haile sal_Int32 nWidth,
249597a4c59SAriel Constenla-Haile double fEffectiveMin,
250597a4c59SAriel Constenla-Haile double fEffectiveMax,
251597a4c59SAriel Constenla-Haile sal_Int16 nTabIndex )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir OUString pNames[] = {
254cdf0e10cSrcweir TKGet( TK_EffectiveMax ),
255cdf0e10cSrcweir TKGet( TK_EffectiveMin ),
256cdf0e10cSrcweir TKGet( TK_Enabled ),
257cdf0e10cSrcweir TKGet( TK_Height ),
258597a4c59SAriel Constenla-Haile TKGet( TK_HelpURL ),
259cdf0e10cSrcweir TKGet( TK_PositionX ),
260cdf0e10cSrcweir TKGet( TK_PositionY ),
261cdf0e10cSrcweir TKGet( TK_Repeat ),
262cdf0e10cSrcweir TKGet( TK_Spin ),
263cdf0e10cSrcweir TKGet( TK_Step ),
264cdf0e10cSrcweir TKGet( TK_TabIndex ),
265cdf0e10cSrcweir TKGet( TK_Width ) };
266cdf0e10cSrcweir
267cdf0e10cSrcweir Any pValues[] = {
268cdf0e10cSrcweir Any( fEffectiveMax ),
269cdf0e10cSrcweir Any( fEffectiveMin ),
270cdf0e10cSrcweir Any( sal_True ),
271cdf0e10cSrcweir Any( (sal_Int32)12 ),
272597a4c59SAriel Constenla-Haile Any( rHelpURL ),
273cdf0e10cSrcweir Any( nXPos ),
274cdf0e10cSrcweir Any( nYPos ),
275cdf0e10cSrcweir Any( (sal_Bool)sal_True ),
276cdf0e10cSrcweir Any( (sal_Bool)sal_True ),
277cdf0e10cSrcweir Any( (sal_Int16)0 ),
278cdf0e10cSrcweir Any( nTabIndex ),
279cdf0e10cSrcweir Any( nWidth ) };
280cdf0e10cSrcweir
281cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
282cdf0e10cSrcweir
283cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount );
284cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount );
285cdf0e10cSrcweir
286597a4c59SAriel Constenla-Haile Reference< XTextComponent > xTextComponent( insertFormattedField( rControlName, aNames, aValues ), UNO_QUERY_THROW );
287597a4c59SAriel Constenla-Haile xTextComponent->addTextListener( this );
288cdf0e10cSrcweir Reference< XSpinField > xSpinField( xTextComponent, UNO_QUERY_THROW );
289597a4c59SAriel Constenla-Haile xSpinField->addSpinListener( this );
290597a4c59SAriel Constenla-Haile
291cdf0e10cSrcweir return rControlName;
292cdf0e10cSrcweir }
293cdf0e10cSrcweir
294cdf0e10cSrcweir // -----------------------------------------------------------------------------
295cdf0e10cSrcweir
ImplInsertComboBox(const OUString & rControlName,const rtl::OUString & rHelpURL,const sal_Bool bEnabled,const Sequence<OUString> & rItemList,sal_Int32 nXPos,sal_Int32 nYPos,sal_Int32 nWidth,sal_Int32 nHeight,sal_Int16 nTabIndex,bool bListen)296597a4c59SAriel Constenla-Haile rtl::OUString OptimizerDialog::ImplInsertComboBox(
297597a4c59SAriel Constenla-Haile const OUString& rControlName,
298597a4c59SAriel Constenla-Haile const rtl::OUString& rHelpURL,
299597a4c59SAriel Constenla-Haile const sal_Bool bEnabled,
300597a4c59SAriel Constenla-Haile const Sequence< OUString >& rItemList,
301597a4c59SAriel Constenla-Haile sal_Int32 nXPos,
302597a4c59SAriel Constenla-Haile sal_Int32 nYPos,
303597a4c59SAriel Constenla-Haile sal_Int32 nWidth,
304597a4c59SAriel Constenla-Haile sal_Int32 nHeight,
305597a4c59SAriel Constenla-Haile sal_Int16 nTabIndex,
306597a4c59SAriel Constenla-Haile bool bListen )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir OUString pNames[] = {
309cdf0e10cSrcweir TKGet( TK_Dropdown ),
310cdf0e10cSrcweir TKGet( TK_Enabled ),
311cdf0e10cSrcweir TKGet( TK_Height ),
312597a4c59SAriel Constenla-Haile TKGet( TK_HelpURL ),
313cdf0e10cSrcweir TKGet( TK_LineCount ),
314cdf0e10cSrcweir TKGet( TK_PositionX ),
315cdf0e10cSrcweir TKGet( TK_PositionY ),
316cdf0e10cSrcweir TKGet( TK_Step ),
317cdf0e10cSrcweir TKGet( TK_StringItemList ),
318cdf0e10cSrcweir TKGet( TK_TabIndex ),
319cdf0e10cSrcweir TKGet( TK_Width ) };
320cdf0e10cSrcweir
321cdf0e10cSrcweir Any pValues[] = {
322cdf0e10cSrcweir Any( sal_True ),
323cdf0e10cSrcweir Any( bEnabled ),
324cdf0e10cSrcweir Any( nHeight ),
325597a4c59SAriel Constenla-Haile Any( rHelpURL ),
326cdf0e10cSrcweir Any( (sal_Int16)8),
327cdf0e10cSrcweir Any( nXPos ),
328cdf0e10cSrcweir Any( nYPos ),
329cdf0e10cSrcweir Any( (sal_Int16)0 ),
330cdf0e10cSrcweir Any( rItemList ),
331cdf0e10cSrcweir Any( nTabIndex ),
332cdf0e10cSrcweir Any( nWidth ) };
333cdf0e10cSrcweir
334cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
335cdf0e10cSrcweir
336cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount );
337cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount );
338cdf0e10cSrcweir
339597a4c59SAriel Constenla-Haile Reference< XTextComponent > xTextComponent( insertComboBox( rControlName, aNames, aValues ), UNO_QUERY_THROW );
340597a4c59SAriel Constenla-Haile if ( bListen )
341597a4c59SAriel Constenla-Haile xTextComponent->addTextListener( this );
342cdf0e10cSrcweir return rControlName;
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
345cdf0e10cSrcweir // -----------------------------------------------------------------------------
346cdf0e10cSrcweir
ImplInsertRadioButton(const rtl::OUString & rControlName,const OUString & rLabel,const rtl::OUString & rHelpURL,sal_Int32 nXPos,sal_Int32 nYPos,sal_Int32 nWidth,sal_Int32 nHeight,sal_Bool bMultiLine,sal_Int16 nTabIndex)347597a4c59SAriel Constenla-Haile rtl::OUString OptimizerDialog::ImplInsertRadioButton(
348597a4c59SAriel Constenla-Haile const rtl::OUString& rControlName,
349597a4c59SAriel Constenla-Haile const OUString& rLabel,
350597a4c59SAriel Constenla-Haile const rtl::OUString& rHelpURL,
351597a4c59SAriel Constenla-Haile sal_Int32 nXPos,
352597a4c59SAriel Constenla-Haile sal_Int32 nYPos,
353597a4c59SAriel Constenla-Haile sal_Int32 nWidth,
354597a4c59SAriel Constenla-Haile sal_Int32 nHeight,
355597a4c59SAriel Constenla-Haile sal_Bool bMultiLine,
356597a4c59SAriel Constenla-Haile sal_Int16 nTabIndex )
357cdf0e10cSrcweir {
358cdf0e10cSrcweir OUString pNames[] = {
359cdf0e10cSrcweir TKGet( TK_Height ),
360597a4c59SAriel Constenla-Haile TKGet( TK_HelpURL ),
361cdf0e10cSrcweir TKGet( TK_Label ),
362cdf0e10cSrcweir TKGet( TK_MultiLine ),
363cdf0e10cSrcweir TKGet( TK_PositionX ),
364cdf0e10cSrcweir TKGet( TK_PositionY ),
365cdf0e10cSrcweir TKGet( TK_Step ),
366cdf0e10cSrcweir TKGet( TK_TabIndex ),
367cdf0e10cSrcweir TKGet( TK_Width ) };
368cdf0e10cSrcweir
369cdf0e10cSrcweir Any pValues[] = {
370cdf0e10cSrcweir Any( nHeight ),
371597a4c59SAriel Constenla-Haile Any( rHelpURL ),
372cdf0e10cSrcweir Any( rLabel ),
373cdf0e10cSrcweir Any( bMultiLine ),
374cdf0e10cSrcweir Any( nXPos ),
375cdf0e10cSrcweir Any( nYPos ),
376cdf0e10cSrcweir Any( (sal_Int16)0 ),
377cdf0e10cSrcweir Any( nTabIndex ),
378cdf0e10cSrcweir Any( nWidth ) };
379cdf0e10cSrcweir
380cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
381cdf0e10cSrcweir
382cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount );
383cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount );
384cdf0e10cSrcweir
385597a4c59SAriel Constenla-Haile Reference< XRadioButton > xRadioButton( insertRadioButton( rControlName, aNames, aValues ) );
386597a4c59SAriel Constenla-Haile xRadioButton->addItemListener( this );
387cdf0e10cSrcweir return rControlName;
388cdf0e10cSrcweir }
389cdf0e10cSrcweir
390cdf0e10cSrcweir // -----------------------------------------------------------------------------
391cdf0e10cSrcweir
ImplInsertListBox(const OUString & rControlName,const rtl::OUString & rHelpURL,const sal_Bool bEnabled,const Sequence<OUString> & rItemList,sal_Int32 nXPos,sal_Int32 nYPos,sal_Int32 nWidth,sal_Int32 nHeight,sal_Int16 nTabIndex)392597a4c59SAriel Constenla-Haile rtl::OUString OptimizerDialog::ImplInsertListBox(
393597a4c59SAriel Constenla-Haile const OUString& rControlName,
394597a4c59SAriel Constenla-Haile const rtl::OUString& rHelpURL,
395597a4c59SAriel Constenla-Haile const sal_Bool bEnabled,
396597a4c59SAriel Constenla-Haile const Sequence< OUString >& rItemList,
397597a4c59SAriel Constenla-Haile sal_Int32 nXPos,
398597a4c59SAriel Constenla-Haile sal_Int32 nYPos,
399597a4c59SAriel Constenla-Haile sal_Int32 nWidth,
400597a4c59SAriel Constenla-Haile sal_Int32 nHeight,
401597a4c59SAriel Constenla-Haile sal_Int16 nTabIndex )
402cdf0e10cSrcweir {
403cdf0e10cSrcweir OUString pNames[] = {
404cdf0e10cSrcweir TKGet( TK_Dropdown ),
405cdf0e10cSrcweir TKGet( TK_Enabled ),
406cdf0e10cSrcweir TKGet( TK_Height ),
407597a4c59SAriel Constenla-Haile TKGet( TK_HelpURL ),
408cdf0e10cSrcweir TKGet( TK_LineCount ),
409cdf0e10cSrcweir TKGet( TK_MultiSelection ),
410cdf0e10cSrcweir TKGet( TK_PositionX ),
411cdf0e10cSrcweir TKGet( TK_PositionY ),
412cdf0e10cSrcweir TKGet( TK_Step ),
413cdf0e10cSrcweir TKGet( TK_StringItemList ),
414cdf0e10cSrcweir TKGet( TK_TabIndex ),
415cdf0e10cSrcweir TKGet( TK_Width ) };
416cdf0e10cSrcweir
417cdf0e10cSrcweir Any pValues[] = {
418cdf0e10cSrcweir Any( sal_True ),
419cdf0e10cSrcweir Any( bEnabled ),
420cdf0e10cSrcweir Any( nHeight ),
421597a4c59SAriel Constenla-Haile Any( rHelpURL ),
422cdf0e10cSrcweir Any( (sal_Int16)8),
423cdf0e10cSrcweir Any( sal_False ),
424cdf0e10cSrcweir Any( nXPos ),
425cdf0e10cSrcweir Any( nYPos ),
426cdf0e10cSrcweir Any( (sal_Int16)0 ),
427cdf0e10cSrcweir Any( rItemList ),
428cdf0e10cSrcweir Any( nTabIndex ),
429cdf0e10cSrcweir Any( nWidth ) };
430cdf0e10cSrcweir
431cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
432cdf0e10cSrcweir
433cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount );
434cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount );
435cdf0e10cSrcweir
436597a4c59SAriel Constenla-Haile Reference< XListBox > xListBox( insertListBox( rControlName, aNames, aValues ) );
437597a4c59SAriel Constenla-Haile xListBox->addActionListener( this );
438cdf0e10cSrcweir return rControlName;
439cdf0e10cSrcweir }
440cdf0e10cSrcweir
441cdf0e10cSrcweir // -----------------------------------------------------------------------------
442cdf0e10cSrcweir
InitNavigationBar()443cdf0e10cSrcweir void OptimizerDialog::InitNavigationBar()
444cdf0e10cSrcweir {
445cdf0e10cSrcweir sal_Int32 nCancelPosX = OD_DIALOG_WIDTH - BUTTON_WIDTH - 6;
446cdf0e10cSrcweir sal_Int32 nFinishPosX = nCancelPosX - 6 - BUTTON_WIDTH;
447cdf0e10cSrcweir sal_Int32 nNextPosX = nFinishPosX - 6 - BUTTON_WIDTH;
448cdf0e10cSrcweir sal_Int32 nBackPosX = nNextPosX - 3 - BUTTON_WIDTH;
449cdf0e10cSrcweir
450597a4c59SAriel Constenla-Haile ImplInsertSeparator( TKGet( TK_lnNavSep1 ), 0, 0, DIALOG_HEIGHT - 26, OD_DIALOG_WIDTH, 1 );
451597a4c59SAriel Constenla-Haile ImplInsertSeparator( TKGet( TK_lnNavSep2 ), 1, 85, 0, 1, BUTTON_POS_Y - 6 );
452cdf0e10cSrcweir
453597a4c59SAriel Constenla-Haile ImplInsertButton( TKGet( TK_btnNavHelp ), HID( HID_SDEXT_MINIMIZER_WIZ_PB_HELP ), 8, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_HELP, PushButtonType_HELP );
454597a4c59SAriel Constenla-Haile ImplInsertButton( TKGet( TK_btnNavBack ), HID( HID_SDEXT_MINIMIZER_WIZ_PB_BACK ), nBackPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_False, STR_BACK, PushButtonType_STANDARD );
455597a4c59SAriel Constenla-Haile ImplInsertButton( TKGet( TK_btnNavNext ), HID( HID_SDEXT_MINIMIZER_WIZ_PB_NEXT ), nNextPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_NEXT, PushButtonType_STANDARD );
456597a4c59SAriel Constenla-Haile ImplInsertButton( TKGet( TK_btnNavFinish ), HID( HID_SDEXT_MINIMIZER_WIZ_PB_FINISH ), nFinishPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_FINISH, PushButtonType_STANDARD );
457597a4c59SAriel Constenla-Haile ImplInsertButton( TKGet( TK_btnNavCancel ), HID( HID_SDEXT_MINIMIZER_WIZ_PB_CANCEL ), nCancelPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_CANCEL, PushButtonType_STANDARD );
458cdf0e10cSrcweir
459cdf0e10cSrcweir setControlProperty( TKGet( TK_btnNavNext ), TKGet( TK_DefaultButton ), Any( sal_True ) );
460cdf0e10cSrcweir }
461cdf0e10cSrcweir
462cdf0e10cSrcweir // -----------------------------------------------------------------------------
463cdf0e10cSrcweir
UpdateControlStatesPage0()464cdf0e10cSrcweir void OptimizerDialog::UpdateControlStatesPage0()
465cdf0e10cSrcweir {
466cdf0e10cSrcweir sal_uInt32 i;
467cdf0e10cSrcweir short nSelectedItem = -1;
468cdf0e10cSrcweir Sequence< OUString > aItemList;
469cdf0e10cSrcweir const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
470cdf0e10cSrcweir if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
471cdf0e10cSrcweir {
472cdf0e10cSrcweir aItemList.realloc( rList.size() - 1 );
473cdf0e10cSrcweir for ( i = 1; i < rList.size(); i++ )
474cdf0e10cSrcweir {
475cdf0e10cSrcweir aItemList[ i - 1 ] = rList[ i ].maName;
476cdf0e10cSrcweir if ( nSelectedItem < 0 )
477cdf0e10cSrcweir {
478cdf0e10cSrcweir if ( rList[ i ] == rList[ 0 ] )
479cdf0e10cSrcweir nSelectedItem = static_cast< short >( i - 1 );
480cdf0e10cSrcweir }
481cdf0e10cSrcweir }
482cdf0e10cSrcweir }
483cdf0e10cSrcweir sal_Bool bRemoveButtonEnabled = sal_False;
484cdf0e10cSrcweir Sequence< short > aSelectedItems;
485cdf0e10cSrcweir if ( nSelectedItem >= 0 )
486cdf0e10cSrcweir {
487cdf0e10cSrcweir aSelectedItems.realloc( 1 );
488cdf0e10cSrcweir aSelectedItems[ 0 ] = nSelectedItem;
489*e1f21a75Smseidel if ( nSelectedItem > 2 ) // only allowing to delete custom themes, the first can't be deleted
490cdf0e10cSrcweir bRemoveButtonEnabled = sal_True;
491cdf0e10cSrcweir }
492cdf0e10cSrcweir setControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_StringItemList ), Any( aItemList ) );
493cdf0e10cSrcweir setControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_SelectedItems ), Any( aSelectedItems ) );
494cdf0e10cSrcweir setControlProperty( TKGet( TK_Button0Pg0 ), TKGet( TK_Enabled ), Any( bRemoveButtonEnabled ) );
495cdf0e10cSrcweir }
InitPage0()496cdf0e10cSrcweir void OptimizerDialog::InitPage0()
497cdf0e10cSrcweir {
498cdf0e10cSrcweir Sequence< OUString > aItemList;
499cdf0e10cSrcweir std::vector< rtl::OUString > aControlList;
500597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText0Pg0 ), getString( STR_INTRODUCTION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) );
501597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText1Pg0 ), getString( STR_INTRODUCTION_T ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 100, sal_True, sal_False, mnTabIndex++ ) );
502597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertSeparator( TKGet( TK_Separator1Pg0 ), 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 66, PAGE_WIDTH - 12, 1 ) );
503*e1f21a75Smseidel aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText2Pg0 ), getString( STR_CHOOSE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 60, PAGE_WIDTH - 12, 8, sal_True, sal_False, mnTabIndex++ ) );
504597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertListBox( TKGet( TK_ListBox0Pg0 ), HID(HID_SDEXT_MINIMIZER_WIZ_STEP1_LB_SETTINGS),sal_True, aItemList, PAGE_POS_X + 6, DIALOG_HEIGHT - 48, ( OD_DIALOG_WIDTH - 50 ) - ( PAGE_POS_X + 6 ), 12, mnTabIndex++ ) );
505597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertButton( TKGet( TK_Button0Pg0 ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP1_PB_DELSETTS ),OD_DIALOG_WIDTH - 46, DIALOG_HEIGHT - 49, 40, 14, mnTabIndex++, sal_True, STR_REMOVE, PushButtonType_STANDARD ) );
506cdf0e10cSrcweir maControlPages.push_back( aControlList );
507cdf0e10cSrcweir DeactivatePage( 0 );
508cdf0e10cSrcweir UpdateControlStatesPage0();
509cdf0e10cSrcweir }
510cdf0e10cSrcweir
511cdf0e10cSrcweir // -----------------------------------------------------------------------------
512cdf0e10cSrcweir
UpdateControlStatesPage1()513cdf0e10cSrcweir void OptimizerDialog::UpdateControlStatesPage1()
514cdf0e10cSrcweir {
515cdf0e10cSrcweir sal_Bool bDeleteUnusedMasterPages( GetConfigProperty( TK_DeleteUnusedMasterPages, sal_False ) );
516cdf0e10cSrcweir sal_Bool bDeleteHiddenSlides( GetConfigProperty( TK_DeleteHiddenSlides, sal_False ) );
517cdf0e10cSrcweir sal_Bool bDeleteNotesPages( GetConfigProperty( TK_DeleteNotesPages, sal_False ) );
518cdf0e10cSrcweir
519cdf0e10cSrcweir setControlProperty( TKGet( TK_CheckBox0Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteUnusedMasterPages ) );
520cdf0e10cSrcweir setControlProperty( TKGet( TK_CheckBox1Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteNotesPages ) );
521cdf0e10cSrcweir setControlProperty( TKGet( TK_CheckBox2Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteHiddenSlides ) );
522cdf0e10cSrcweir }
InitPage1()523cdf0e10cSrcweir void OptimizerDialog::InitPage1()
524cdf0e10cSrcweir {
525cdf0e10cSrcweir Sequence< OUString > aCustomShowList;
526597a4c59SAriel Constenla-Haile Reference< XModel > xModel( mxModel );
527cdf0e10cSrcweir if ( xModel.is() )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir Reference< XCustomPresentationSupplier > aXCPSup( xModel, UNO_QUERY_THROW );
530cdf0e10cSrcweir Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() );
531cdf0e10cSrcweir if ( aXCont.is() )
532cdf0e10cSrcweir aCustomShowList = aXCont->getElementNames();
533cdf0e10cSrcweir }
534cdf0e10cSrcweir std::vector< rtl::OUString > aControlList;
535597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText0Pg3 ), getString( STR_CHOOSE_SLIDES ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) );
536597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertCheckBox( TKGet( TK_CheckBox0Pg3 ), getString( STR_DELETE_MASTER_PAGES ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP2_CB_MASTERPAGES ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
537597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertCheckBox( TKGet( TK_CheckBox2Pg3 ), getString( STR_DELETE_HIDDEN_SLIDES ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP2_CB_HIDDENSLIDES ), PAGE_POS_X + 6, PAGE_POS_Y + 28, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
538597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertCheckBox( TKGet( TK_CheckBox3Pg3 ), getString( STR_CUSTOM_SHOW ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP2_CB_CUSTOMSHOW ), PAGE_POS_X + 6, PAGE_POS_Y + 42, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
539597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertListBox( TKGet( TK_ListBox0Pg3 ), HID(HID_SDEXT_MINIMIZER_WIZ_STEP2_LB_CUSTOMSHOW),sal_True, aCustomShowList, PAGE_POS_X + 14, PAGE_POS_Y + 54, 150, 12, mnTabIndex++ ) );
540597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertCheckBox( TKGet( TK_CheckBox1Pg3 ), getString( STR_DELETE_NOTES_PAGES ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP2_CB_NOTES ), PAGE_POS_X + 6, PAGE_POS_Y + 70, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
541cdf0e10cSrcweir maControlPages.push_back( aControlList );
542cdf0e10cSrcweir DeactivatePage( 1 );
543cdf0e10cSrcweir
544cdf0e10cSrcweir setControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ), Any( sal_False ) );
545cdf0e10cSrcweir setControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_Enabled ), Any( aCustomShowList.getLength() != 0 ) );
546cdf0e10cSrcweir setControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_Enabled ), Any( sal_False ) );
547cdf0e10cSrcweir
548cdf0e10cSrcweir UpdateControlStatesPage1();
549cdf0e10cSrcweir }
550cdf0e10cSrcweir
551cdf0e10cSrcweir // -----------------------------------------------------------------------------
552cdf0e10cSrcweir
UpdateControlStatesPage2()553cdf0e10cSrcweir void OptimizerDialog::UpdateControlStatesPage2()
554cdf0e10cSrcweir {
555cdf0e10cSrcweir sal_Bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, sal_False ) );
556cdf0e10cSrcweir sal_Bool bRemoveCropArea( GetConfigProperty( TK_RemoveCropArea, sal_False ) );
557cdf0e10cSrcweir sal_Bool bEmbedLinkedGraphics( GetConfigProperty( TK_EmbedLinkedGraphics, sal_True ) );
558cdf0e10cSrcweir sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
559cdf0e10cSrcweir
560cdf0e10cSrcweir sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
561cdf0e10cSrcweir
562cdf0e10cSrcweir sal_Int32 nI0, nI1, nI2, nI3;
563cdf0e10cSrcweir nI0 = nI1 = nI2 = nI3 = 0;
564cdf0e10cSrcweir OUString aResolutionText;
565cdf0e10cSrcweir Sequence< OUString > aResolutionItemList( 4 );
566cdf0e10cSrcweir aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
567cdf0e10cSrcweir aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
568cdf0e10cSrcweir aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
569cdf0e10cSrcweir aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
570cdf0e10cSrcweir nI0 = nI1 = nI2 = nI3 = 0;
571cdf0e10cSrcweir if ( getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI0 ).toInt32() == nImageResolution )
572cdf0e10cSrcweir aResolutionText = aResolutionItemList[ 0 ];
573cdf0e10cSrcweir else if ( getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI1 ).toInt32() == nImageResolution )
574cdf0e10cSrcweir aResolutionText = aResolutionItemList[ 1 ];
575cdf0e10cSrcweir else if ( getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI2 ).toInt32() == nImageResolution )
576cdf0e10cSrcweir aResolutionText = aResolutionItemList[ 2 ];
577cdf0e10cSrcweir else if ( getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI3 ).toInt32() == nImageResolution )
578cdf0e10cSrcweir aResolutionText = aResolutionItemList[ 3 ];
579cdf0e10cSrcweir if ( !aResolutionText.getLength() )
580cdf0e10cSrcweir aResolutionText = OUString::valueOf( nImageResolution );
581cdf0e10cSrcweir
582cdf0e10cSrcweir setControlProperty( TKGet( TK_RadioButton0Pg1 ), TKGet( TK_State ), Any( (sal_Int16)( bJPEGCompression != sal_True ) ) );
583cdf0e10cSrcweir setControlProperty( TKGet( TK_RadioButton1Pg1 ), TKGet( TK_State ), Any( (sal_Int16)( bJPEGCompression != sal_False ) ) );
584cdf0e10cSrcweir setControlProperty( TKGet( TK_FixedText1Pg1 ), TKGet( TK_Enabled ), Any( bJPEGCompression ) );
585cdf0e10cSrcweir setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_Enabled ), Any( bJPEGCompression ) );
586cdf0e10cSrcweir setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( (double)nJPEGQuality ) );
587cdf0e10cSrcweir setControlProperty( TKGet( TK_CheckBox1Pg1 ), TKGet( TK_State ), Any( (sal_Int16)bRemoveCropArea ) );
588cdf0e10cSrcweir setControlProperty( TKGet( TK_ComboBox0Pg1 ), TKGet( TK_Text ), Any( aResolutionText ) );
589cdf0e10cSrcweir setControlProperty( TKGet( TK_CheckBox2Pg1 ), TKGet( TK_State ), Any( (sal_Int16)bEmbedLinkedGraphics ) );
590cdf0e10cSrcweir }
InitPage2()591cdf0e10cSrcweir void OptimizerDialog::InitPage2()
592cdf0e10cSrcweir {
593cdf0e10cSrcweir sal_Int32 nI0, nI1, nI2, nI3;
594cdf0e10cSrcweir nI0 = nI1 = nI2 = nI3 = 0;
595cdf0e10cSrcweir Sequence< OUString > aResolutionItemList( 4 );
596cdf0e10cSrcweir aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
597cdf0e10cSrcweir aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
598cdf0e10cSrcweir aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
599cdf0e10cSrcweir aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
600cdf0e10cSrcweir
601cdf0e10cSrcweir std::vector< rtl::OUString > aControlList;
602597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText0Pg1 ), getString( STR_GRAPHIC_OPTIMIZATION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) );
603597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertRadioButton( TKGet( TK_RadioButton0Pg1 ), getString( STR_LOSSLESS_COMPRESSION ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP3_RB_LOSSLESS ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, sal_False, mnTabIndex++ ) );
604597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertRadioButton( TKGet( TK_RadioButton1Pg1 ), getString( STR_JPEG_COMPRESSION ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP3_RB_JPEG ), PAGE_POS_X + 6, PAGE_POS_Y + 28, PAGE_WIDTH - 12, 8, sal_False, mnTabIndex++ ) );
605597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText1Pg1 ), getString( STR_QUALITY ), PAGE_POS_X + 20, PAGE_POS_Y + 40, 72, 8, sal_False, sal_False, mnTabIndex++ ) );
606597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFormattedField( TKGet( TK_FormattedField0Pg1 ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP3_MF_QUALITY ), PAGE_POS_X + 106, PAGE_POS_Y + 38, 50, 0, 100, mnTabIndex++ ) );
607597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText2Pg1 ), getString( STR_IMAGE_RESOLUTION ), PAGE_POS_X + 6, PAGE_POS_Y + 54, 94, 8, sal_False, sal_False, mnTabIndex++ ) );
608597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertComboBox( TKGet( TK_ComboBox0Pg1 ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP3_LB_DPI ), sal_True, aResolutionItemList, PAGE_POS_X + 106, PAGE_POS_Y + 52, 100, 12, mnTabIndex++ ) );
609597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertCheckBox( TKGet( TK_CheckBox1Pg1 ), getString( STR_REMOVE_CROP_AREA ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP3_CB_CROP ), PAGE_POS_X + 6, PAGE_POS_Y + 68, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
610597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertCheckBox( TKGet( TK_CheckBox2Pg1 ), getString( STR_EMBED_LINKED_GRAPHICS ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP3_CB_LINKS ), PAGE_POS_X + 6, PAGE_POS_Y + 82, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
611cdf0e10cSrcweir maControlPages.push_back( aControlList );
612cdf0e10cSrcweir DeactivatePage( 2 );
613cdf0e10cSrcweir UpdateControlStatesPage2();
614cdf0e10cSrcweir }
615cdf0e10cSrcweir
616cdf0e10cSrcweir // -----------------------------------------------------------------------------
617cdf0e10cSrcweir
UpdateControlStatesPage3()618cdf0e10cSrcweir void OptimizerDialog::UpdateControlStatesPage3()
619cdf0e10cSrcweir {
620cdf0e10cSrcweir sal_Bool bConvertOLEObjects( GetConfigProperty( TK_OLEOptimization, sal_False ) );
621cdf0e10cSrcweir sal_Int16 nOLEOptimizationType( GetConfigProperty( TK_OLEOptimizationType, (sal_Int16)0 ) );
622cdf0e10cSrcweir
623cdf0e10cSrcweir setControlProperty( TKGet( TK_CheckBox0Pg2 ), TKGet( TK_State ), Any( (sal_Int16)bConvertOLEObjects ) );
624cdf0e10cSrcweir setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_Enabled ), Any( bConvertOLEObjects ) );
625cdf0e10cSrcweir setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_State ), Any( (sal_Int16)( nOLEOptimizationType == 0 ) ) );
626cdf0e10cSrcweir setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_Enabled ), Any( bConvertOLEObjects ) );
627cdf0e10cSrcweir setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_State ), Any( (sal_Int16)( nOLEOptimizationType == 1 ) ) );
628cdf0e10cSrcweir }
InitPage3()629cdf0e10cSrcweir void OptimizerDialog::InitPage3()
630cdf0e10cSrcweir {
631cdf0e10cSrcweir int nOLECount = 0;
632597a4c59SAriel Constenla-Haile Reference< XModel > xModel( mxModel );
633cdf0e10cSrcweir Reference< XDrawPagesSupplier > xDrawPagesSupplier( xModel, UNO_QUERY_THROW );
634cdf0e10cSrcweir Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
635cdf0e10cSrcweir for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
636cdf0e10cSrcweir {
637cdf0e10cSrcweir Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
638cdf0e10cSrcweir for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
639cdf0e10cSrcweir {
640cdf0e10cSrcweir const OUString sOLE2Shape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.OLE2Shape" ) );
641cdf0e10cSrcweir Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
642cdf0e10cSrcweir if ( xShape->getShapeType() == sOLE2Shape )
643cdf0e10cSrcweir nOLECount++;
644cdf0e10cSrcweir }
645cdf0e10cSrcweir }
646cdf0e10cSrcweir
647cdf0e10cSrcweir std::vector< rtl::OUString > aControlList;
648597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText0Pg2 ), getString( STR_OLE_OPTIMIZATION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) );
649597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertCheckBox( TKGet( TK_CheckBox0Pg2 ), getString( STR_OLE_REPLACE ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP4_CB_OLE ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
650597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertRadioButton( TKGet( TK_RadioButton0Pg2 ), getString( STR_ALL_OLE_OBJECTS ), HID(HID_SDEXT_MINIMIZER_WIZ_STEP4_RB_ALLOLE), PAGE_POS_X + 14, PAGE_POS_Y + 28, PAGE_WIDTH - 22, 8, sal_False, mnTabIndex++ ) );
651597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertRadioButton( TKGet( TK_RadioButton1Pg2 ), getString( STR_ALIEN_OLE_OBJECTS_ONLY ), HID(HID_SDEXT_MINIMIZER_WIZ_STEP4_RB_NOTODF),PAGE_POS_X + 14, PAGE_POS_Y + 40, PAGE_WIDTH - 22, 8, sal_False, mnTabIndex++ ) );
652597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( 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++ ) );
653cdf0e10cSrcweir maControlPages.push_back( aControlList );
654cdf0e10cSrcweir DeactivatePage( 3 );
655cdf0e10cSrcweir UpdateControlStatesPage3();
656cdf0e10cSrcweir }
657cdf0e10cSrcweir
658cdf0e10cSrcweir // -----------------------------------------------------------------------------
659cdf0e10cSrcweir
ImpValueOfInMB(const sal_Int64 & rVal,sal_Unicode nSeparator='.')660cdf0e10cSrcweir static OUString ImpValueOfInMB( const sal_Int64& rVal, sal_Unicode nSeparator = '.' )
661cdf0e10cSrcweir {
662cdf0e10cSrcweir double fVal( static_cast<double>( rVal ) );
663cdf0e10cSrcweir fVal /= ( 1 << 20 );
664cdf0e10cSrcweir fVal += 0.05;
665cdf0e10cSrcweir rtl::OUStringBuffer aVal( OUString::valueOf( fVal ) );
666cdf0e10cSrcweir sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.', 0 ) );
667cdf0e10cSrcweir if ( nX >= 0 )
668cdf0e10cSrcweir {
669cdf0e10cSrcweir aVal.setLength( nX + 2 );
670cdf0e10cSrcweir aVal.setCharAt( nX, nSeparator );
671cdf0e10cSrcweir }
672cdf0e10cSrcweir aVal.append( OUString::createFromAscii( " MB" ) );
673cdf0e10cSrcweir return aVal.makeStringAndClear();
674cdf0e10cSrcweir }
675cdf0e10cSrcweir
UpdateControlStatesPage4()676cdf0e10cSrcweir void OptimizerDialog::UpdateControlStatesPage4()
677cdf0e10cSrcweir {
678cdf0e10cSrcweir sal_Bool bSaveAs( GetConfigProperty( TK_SaveAs, sal_True ) );
679cdf0e10cSrcweir if ( mbIsReadonly )
680cdf0e10cSrcweir {
681cdf0e10cSrcweir setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( sal_False ) ) );
682cdf0e10cSrcweir setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( sal_True ) ) );
683cdf0e10cSrcweir }
684cdf0e10cSrcweir else
685cdf0e10cSrcweir {
686cdf0e10cSrcweir setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bSaveAs == sal_False ) ) );
687cdf0e10cSrcweir setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bSaveAs == sal_True ) ) );
688cdf0e10cSrcweir }
689cdf0e10cSrcweir setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( sal_False ) );
690cdf0e10cSrcweir
691cdf0e10cSrcweir sal_uInt32 w;
692cdf0e10cSrcweir Sequence< OUString > aItemList;
693cdf0e10cSrcweir const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
694cdf0e10cSrcweir if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
695cdf0e10cSrcweir {
696cdf0e10cSrcweir aItemList.realloc( rList.size() - 1 );
697cdf0e10cSrcweir for ( w = 1; w < rList.size(); w++ )
698cdf0e10cSrcweir aItemList[ w - 1 ] = rList[ w ].maName;
699cdf0e10cSrcweir }
700cdf0e10cSrcweir setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_StringItemList ), Any( aItemList ) );
701cdf0e10cSrcweir
702cdf0e10cSrcweir // now check if it is sensible to enable the combo box
703cdf0e10cSrcweir sal_Bool bSaveSettingsEnabled = sal_True;
704cdf0e10cSrcweir if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
705cdf0e10cSrcweir {
706cdf0e10cSrcweir for ( w = 1; w < rList.size(); w++ )
707cdf0e10cSrcweir {
708cdf0e10cSrcweir if ( rList[ w ] == rList[ 0 ] )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir bSaveSettingsEnabled = sal_False;
711cdf0e10cSrcweir break;
712cdf0e10cSrcweir }
713cdf0e10cSrcweir }
714cdf0e10cSrcweir }
715cdf0e10cSrcweir sal_Int16 nInt16 = 0;
716cdf0e10cSrcweir getControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_State ) ) >>= nInt16;
717cdf0e10cSrcweir setControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled ) );
718cdf0e10cSrcweir setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled && nInt16 ) );
719cdf0e10cSrcweir
720cdf0e10cSrcweir std::vector< OUString > aSummaryStrings;
721cdf0e10cSrcweir
722cdf0e10cSrcweir // taking care of deleted slides
723cdf0e10cSrcweir sal_Int32 nDeletedSlides = 0;
724cdf0e10cSrcweir rtl::OUString aCustomShowName;
725cdf0e10cSrcweir if ( getControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ) ) >>= nInt16 )
726cdf0e10cSrcweir {
727cdf0e10cSrcweir if ( nInt16 )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir Sequence< short > aSelectedItems;
730cdf0e10cSrcweir Sequence< OUString > aStringItemList;
731cdf0e10cSrcweir Any aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_SelectedItems ) );
732cdf0e10cSrcweir if ( aAny >>= aSelectedItems )
733cdf0e10cSrcweir {
734cdf0e10cSrcweir if ( aSelectedItems.getLength() )
735cdf0e10cSrcweir {
736cdf0e10cSrcweir sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
737cdf0e10cSrcweir aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_StringItemList ) );
738cdf0e10cSrcweir if ( aAny >>= aStringItemList )
739cdf0e10cSrcweir {
740cdf0e10cSrcweir if ( aStringItemList.getLength() > nSelectedItem )
741cdf0e10cSrcweir SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) );
742cdf0e10cSrcweir }
743cdf0e10cSrcweir }
744cdf0e10cSrcweir }
745cdf0e10cSrcweir }
746cdf0e10cSrcweir }
747cdf0e10cSrcweir if ( aCustomShowName.getLength() )
748cdf0e10cSrcweir {
749cdf0e10cSrcweir std::vector< Reference< XDrawPage > > vNonUsedPageList;
750597a4c59SAriel Constenla-Haile PageCollector::CollectNonCustomShowPages( mxModel, aCustomShowName, vNonUsedPageList );
751cdf0e10cSrcweir nDeletedSlides += vNonUsedPageList.size();
752cdf0e10cSrcweir }
753cdf0e10cSrcweir if ( GetConfigProperty( TK_DeleteHiddenSlides, sal_False ) )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir if ( aCustomShowName.getLength() )
756cdf0e10cSrcweir {
757cdf0e10cSrcweir std::vector< Reference< XDrawPage > > vUsedPageList;
758597a4c59SAriel Constenla-Haile PageCollector::CollectCustomShowPages( mxModel, aCustomShowName, vUsedPageList );
759cdf0e10cSrcweir std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
760cdf0e10cSrcweir while( aIter != vUsedPageList.end() )
761cdf0e10cSrcweir {
762cdf0e10cSrcweir Reference< XPropertySet > xPropSet( *aIter, UNO_QUERY_THROW );
763cdf0e10cSrcweir sal_Bool bVisible = sal_True;
764cdf0e10cSrcweir const OUString sVisible( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) );
765cdf0e10cSrcweir if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
766cdf0e10cSrcweir {
767cdf0e10cSrcweir if (!bVisible )
768cdf0e10cSrcweir nDeletedSlides++;
769cdf0e10cSrcweir }
770cdf0e10cSrcweir aIter++;
771cdf0e10cSrcweir }
772cdf0e10cSrcweir }
773cdf0e10cSrcweir else
774cdf0e10cSrcweir {
775597a4c59SAriel Constenla-Haile Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxModel, UNO_QUERY_THROW );
776cdf0e10cSrcweir Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
777cdf0e10cSrcweir for( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
778cdf0e10cSrcweir {
779cdf0e10cSrcweir Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
780cdf0e10cSrcweir Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY_THROW );
781cdf0e10cSrcweir
782cdf0e10cSrcweir sal_Bool bVisible = sal_True;
783cdf0e10cSrcweir const OUString sVisible( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) );
784cdf0e10cSrcweir if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
785cdf0e10cSrcweir {
786cdf0e10cSrcweir if (!bVisible )
787cdf0e10cSrcweir nDeletedSlides++;
788cdf0e10cSrcweir }
789cdf0e10cSrcweir }
790cdf0e10cSrcweir }
791cdf0e10cSrcweir }
792cdf0e10cSrcweir if ( GetConfigProperty( TK_DeleteUnusedMasterPages, sal_False ) )
793cdf0e10cSrcweir {
794cdf0e10cSrcweir std::vector< PageCollector::MasterPageEntity > aMasterPageList;
795597a4c59SAriel Constenla-Haile PageCollector::CollectMasterPages( mxModel, aMasterPageList );
796597a4c59SAriel Constenla-Haile Reference< XMasterPagesSupplier > xMasterPagesSupplier( mxModel, UNO_QUERY_THROW );
797cdf0e10cSrcweir Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
798cdf0e10cSrcweir std::vector< PageCollector::MasterPageEntity >::iterator aIter( aMasterPageList.begin() );
799cdf0e10cSrcweir while( aIter != aMasterPageList.end() )
800cdf0e10cSrcweir {
801cdf0e10cSrcweir if ( !aIter->bUsed )
802cdf0e10cSrcweir nDeletedSlides++;
803cdf0e10cSrcweir aIter++;
804cdf0e10cSrcweir }
805cdf0e10cSrcweir }
806cdf0e10cSrcweir if ( nDeletedSlides > 1 )
807cdf0e10cSrcweir {
808cdf0e10cSrcweir OUString aStr( getString( STR_DELETE_SLIDES ) );
809cdf0e10cSrcweir OUString aPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%SLIDES" ) );
810cdf0e10cSrcweir sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
811cdf0e10cSrcweir if ( i >= 0 )
812cdf0e10cSrcweir aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::valueOf( nDeletedSlides ) );
813cdf0e10cSrcweir aSummaryStrings.push_back( aStr );
814cdf0e10cSrcweir }
815cdf0e10cSrcweir
816cdf0e10cSrcweir // generating graphic compression info
817cdf0e10cSrcweir sal_Int32 nGraphics = 0;
818cdf0e10cSrcweir sal_Bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, sal_False ) );
819cdf0e10cSrcweir sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
820cdf0e10cSrcweir sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
821cdf0e10cSrcweir GraphicSettings aGraphicSettings( bJPEGCompression, nJPEGQuality, GetConfigProperty( TK_RemoveCropArea, sal_False ),
822cdf0e10cSrcweir nImageResolution, GetConfigProperty( TK_EmbedLinkedGraphics, sal_True ) );
823597a4c59SAriel Constenla-Haile GraphicCollector::CountGraphics( mxContext, mxModel, aGraphicSettings, nGraphics );
824cdf0e10cSrcweir if ( nGraphics > 1 )
825cdf0e10cSrcweir {
826cdf0e10cSrcweir OUString aStr( getString( STR_OPTIMIZE_IMAGES ) );
827cdf0e10cSrcweir OUString aImagePlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%IMAGES" ) );
828cdf0e10cSrcweir OUString aQualityPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%QUALITY" ) );
829cdf0e10cSrcweir OUString aResolutionPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%RESOLUTION" ) );
830cdf0e10cSrcweir sal_Int32 i = aStr.indexOf( aImagePlaceholder, 0 );
831cdf0e10cSrcweir if ( i >= 0 )
832cdf0e10cSrcweir aStr = aStr.replaceAt( i, aImagePlaceholder.getLength(), OUString::valueOf( nGraphics ) );
833cdf0e10cSrcweir
834cdf0e10cSrcweir sal_Int32 j = aStr.indexOf( aQualityPlaceholder, 0 );
835cdf0e10cSrcweir if ( j >= 0 )
836cdf0e10cSrcweir aStr = aStr.replaceAt( j, aQualityPlaceholder.getLength(), OUString::valueOf( nJPEGQuality ) );
837cdf0e10cSrcweir
838cdf0e10cSrcweir sal_Int32 k = aStr.indexOf( aResolutionPlaceholder, 0 );
839cdf0e10cSrcweir if ( k >= 0 )
840cdf0e10cSrcweir aStr = aStr.replaceAt( k, aResolutionPlaceholder.getLength(), OUString::valueOf( nImageResolution ) );
841cdf0e10cSrcweir
842cdf0e10cSrcweir aSummaryStrings.push_back( aStr );
843cdf0e10cSrcweir }
844cdf0e10cSrcweir
845cdf0e10cSrcweir if ( GetConfigProperty( TK_OLEOptimization, sal_False ) )
846cdf0e10cSrcweir {
847cdf0e10cSrcweir sal_Int32 nOLEReplacements = 0;
848597a4c59SAriel Constenla-Haile Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxModel, UNO_QUERY_THROW );
849cdf0e10cSrcweir Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
850cdf0e10cSrcweir for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
851cdf0e10cSrcweir {
852cdf0e10cSrcweir Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
853cdf0e10cSrcweir for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
854cdf0e10cSrcweir {
855cdf0e10cSrcweir const OUString sOLE2Shape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.OLE2Shape" ) );
856cdf0e10cSrcweir Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
857cdf0e10cSrcweir if ( xShape->getShapeType() == sOLE2Shape )
858cdf0e10cSrcweir nOLEReplacements++;
859cdf0e10cSrcweir }
860cdf0e10cSrcweir }
861cdf0e10cSrcweir if ( nOLEReplacements > 1 )
862cdf0e10cSrcweir {
863cdf0e10cSrcweir OUString aStr( getString( STR_CREATE_REPLACEMENT ) );
864cdf0e10cSrcweir OUString aPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%OLE" ) );
865cdf0e10cSrcweir sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
866cdf0e10cSrcweir if ( i >= 0 )
867cdf0e10cSrcweir aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::valueOf( nOLEReplacements ) );
868cdf0e10cSrcweir aSummaryStrings.push_back( aStr );
869cdf0e10cSrcweir }
870cdf0e10cSrcweir }
871cdf0e10cSrcweir while( aSummaryStrings.size() < 3 )
872cdf0e10cSrcweir aSummaryStrings.push_back( OUString() );
873cdf0e10cSrcweir setControlProperty( TKGet( TK_FixedText4Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 0 ] ) );
874cdf0e10cSrcweir setControlProperty( TKGet( TK_FixedText5Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 1 ] ) );
875cdf0e10cSrcweir setControlProperty( TKGet( TK_FixedText6Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 2 ] ) );
876cdf0e10cSrcweir
877cdf0e10cSrcweir sal_Int64 nCurrentFileSize = 0;
878cdf0e10cSrcweir sal_Int64 nEstimatedFileSize = 0;
879597a4c59SAriel Constenla-Haile Reference< XStorable > xStorable( mxModel, UNO_QUERY );
880cdf0e10cSrcweir if ( xStorable.is() && xStorable->hasLocation() )
881cdf0e10cSrcweir nCurrentFileSize = PPPOptimizer::GetFileSize( xStorable->getLocation() );
882cdf0e10cSrcweir
883cdf0e10cSrcweir if ( nCurrentFileSize )
884cdf0e10cSrcweir {
885cdf0e10cSrcweir double fE = static_cast< double >( nCurrentFileSize );
886cdf0e10cSrcweir if ( nImageResolution )
887cdf0e10cSrcweir {
888cdf0e10cSrcweir double v = ( static_cast< double >( nImageResolution ) + 75.0 ) / 300.0;
889cdf0e10cSrcweir if ( v < 1.0 )
890cdf0e10cSrcweir fE *= v;
891cdf0e10cSrcweir }
892cdf0e10cSrcweir if ( bJPEGCompression )
893cdf0e10cSrcweir {
894cdf0e10cSrcweir double v = 0.75 - ( ( 100.0 - static_cast< double >( nJPEGQuality ) ) / 400.0 ) ;
895cdf0e10cSrcweir fE *= v;
896cdf0e10cSrcweir }
897cdf0e10cSrcweir nEstimatedFileSize = static_cast< sal_Int64 >( fE );
898cdf0e10cSrcweir }
899cdf0e10cSrcweir sal_Unicode nSeparator = '.';
900cdf0e10cSrcweir OUString aStr( getString( STR_FILESIZESEPARATOR ) );
901cdf0e10cSrcweir if ( aStr.getLength() )
902cdf0e10cSrcweir nSeparator = aStr[ 0 ];
903cdf0e10cSrcweir setControlProperty( TKGet( TK_FixedText7Pg4 ), TKGet( TK_Label ), Any( ImpValueOfInMB( nCurrentFileSize, nSeparator ) ) );
904cdf0e10cSrcweir setControlProperty( TKGet( TK_FixedText8Pg4 ), TKGet( TK_Label ), Any( ImpValueOfInMB( nEstimatedFileSize, nSeparator ) ) );
905cdf0e10cSrcweir SetConfigProperty( TK_EstimatedFileSize, Any( nEstimatedFileSize ) );
906cdf0e10cSrcweir }
907cdf0e10cSrcweir
InitPage4()908cdf0e10cSrcweir void OptimizerDialog::InitPage4()
909cdf0e10cSrcweir {
910cdf0e10cSrcweir { // creating progress bar:
911cdf0e10cSrcweir OUString pNames[] = {
912cdf0e10cSrcweir TKGet( TK_Height ),
913cdf0e10cSrcweir TKGet( TK_Name ),
914cdf0e10cSrcweir TKGet( TK_PositionX ),
915cdf0e10cSrcweir TKGet( TK_PositionY ),
916cdf0e10cSrcweir TKGet( TK_ProgressValue ),
917cdf0e10cSrcweir TKGet( TK_ProgressValueMax ),
918cdf0e10cSrcweir TKGet( TK_ProgressValueMin ),
919cdf0e10cSrcweir TKGet( TK_Width ) };
920cdf0e10cSrcweir
921cdf0e10cSrcweir Any pValues[] = {
922cdf0e10cSrcweir Any( (sal_Int32)12 ),
923597a4c59SAriel Constenla-Haile Any( OUString( RTL_CONSTASCII_USTRINGPARAM("STR_SAVE_AS") ) ), //TODO
924cdf0e10cSrcweir Any( (sal_Int32)( PAGE_POS_X + 6 ) ),
925cdf0e10cSrcweir Any( (sal_Int32)( DIALOG_HEIGHT - 75 ) ),
926cdf0e10cSrcweir Any( (sal_Int32)( 0 ) ),
927cdf0e10cSrcweir Any( (sal_Int32)( 100 ) ),
928cdf0e10cSrcweir Any( (sal_Int32)( 0 ) ),
929cdf0e10cSrcweir Any( (sal_Int32)( PAGE_WIDTH - 12 ) ) };
930cdf0e10cSrcweir
931cdf0e10cSrcweir sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString );
932cdf0e10cSrcweir
933cdf0e10cSrcweir Sequence< rtl::OUString > aNames( pNames, nCount );
934cdf0e10cSrcweir Sequence< Any > aValues( pValues, nCount );
935cdf0e10cSrcweir
936cdf0e10cSrcweir Reference< XMultiPropertySet > xMultiPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlProgressBarModel" ) ),
937cdf0e10cSrcweir TKGet( TK_Progress ), aNames, aValues ), UNO_QUERY );
938cdf0e10cSrcweir }
939597a4c59SAriel Constenla-Haile
940cdf0e10cSrcweir Sequence< OUString > aItemList;
941cdf0e10cSrcweir std::vector< rtl::OUString > aControlList;
942597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText0Pg4 ), getString( STR_SUMMARY_TITLE ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, sal_False, sal_True, mnTabIndex++ ) );
943597a4c59SAriel Constenla-Haile // aControlList.push_back( ImplInsertSeparator( TKGet( TK_Separator0Pg4 ), 0, PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 1 ) );
944cdf0e10cSrcweir
945597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText4Pg4 ), OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, sal_False, sal_False, mnTabIndex++ ) );
946597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText5Pg4 ), OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 22, PAGE_WIDTH - 12, 8, sal_False, sal_False, mnTabIndex++ ) );
947597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText6Pg4 ), OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 30, PAGE_WIDTH - 12, 8, sal_False, sal_False, mnTabIndex++ ) );
948cdf0e10cSrcweir
949597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText2Pg4 ), getString( STR_CURRENT_FILESIZE ), PAGE_POS_X + 6, PAGE_POS_Y + 50, 88, 8, sal_False, sal_False, mnTabIndex++ ) );
950597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText7Pg4 ), OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 50, 30, 8, sal_False, sal_False, mnTabIndex++ ) );
951cdf0e10cSrcweir setControlProperty( TKGet( TK_FixedText7Pg4 ), TKGet( TK_Align ), Any( static_cast< short >( 2 ) ) );
952597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText3Pg4 ), getString( STR_ESTIMATED_FILESIZE ), PAGE_POS_X + 6, PAGE_POS_Y + 58, 88, 8, sal_False, sal_False, mnTabIndex++ ) );
953597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText8Pg4 ), OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 58, 30, 8, sal_False, sal_False, mnTabIndex++ ) );
954cdf0e10cSrcweir setControlProperty( TKGet( TK_FixedText8Pg4 ), TKGet( TK_Align ), Any( static_cast< short >( 2 ) ) );
955cdf0e10cSrcweir
956597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertRadioButton( TKGet( TK_RadioButton0Pg4 ), getString( STR_APPLY_TO_CURRENT ), HID(HID_SDEXT_MINIMIZER_WIZ_STEP5_RB_CURDOC),PAGE_POS_X + 6, PAGE_POS_Y + 78, PAGE_WIDTH - 12, 8, sal_False, mnTabIndex++ ) );
957597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertRadioButton( TKGet( TK_RadioButton1Pg4 ), getString( STR_SAVE_AS ), HID(HID_SDEXT_MINIMIZER_WIZ_STEP5_RB_NEWDOC),PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 8, sal_False, mnTabIndex++ ) );
958597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertFixedText( TKGet( TK_FixedText1Pg4 ), OUString(), PAGE_POS_X + 6, DIALOG_HEIGHT - 87, PAGE_WIDTH - 12, 8, sal_True, sal_False, mnTabIndex++ ) );
959cdf0e10cSrcweir aControlList.push_back( TKGet( TK_Progress ) );
960597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertSeparator( TKGet( TK_Separator1Pg4 ), 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 58, PAGE_WIDTH - 12, 1 ) );
961597a4c59SAriel Constenla-Haile aControlList.push_back( ImplInsertCheckBox( TKGet( TK_CheckBox1Pg4 ), getString( STR_SAVE_SETTINGS ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP5_CB_SAVESETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 47, 100, 8, mnTabIndex++ ) );
962597a4c59SAriel Constenla-Haile // don't listen to this
963597a4c59SAriel Constenla-Haile aControlList.push_back(
964597a4c59SAriel Constenla-Haile ImplInsertComboBox(
965597a4c59SAriel Constenla-Haile TKGet( TK_ComboBox0Pg4 ), HID( HID_SDEXT_MINIMIZER_WIZ_STEP5_LB_SETTINGSNAME ),sal_True, aItemList,
966597a4c59SAriel Constenla-Haile PAGE_POS_X + 106, DIALOG_HEIGHT - 48, 100, 12, mnTabIndex++ ,
967597a4c59SAriel Constenla-Haile false) );
968cdf0e10cSrcweir maControlPages.push_back( aControlList );
969cdf0e10cSrcweir DeactivatePage( 4 );
970cdf0e10cSrcweir
971cdf0e10cSrcweir // creating a default session name that hasn't been used yet
972cdf0e10cSrcweir OUString aSettingsName;
973cdf0e10cSrcweir OUString aDefault( getString( STR_MY_SETTINGS ) );
974cdf0e10cSrcweir sal_Int32 nSession = 1;
975cdf0e10cSrcweir sal_uInt32 i;
976cdf0e10cSrcweir const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
977cdf0e10cSrcweir do
978cdf0e10cSrcweir {
979cdf0e10cSrcweir OUString aTemp( aDefault.concat( OUString::valueOf( nSession++ ) ) );
980cdf0e10cSrcweir for ( i = 1; i < rList.size(); i++ )
981cdf0e10cSrcweir {
982cdf0e10cSrcweir if ( rList[ i ].maName == aTemp )
983cdf0e10cSrcweir break;
984cdf0e10cSrcweir }
985cdf0e10cSrcweir if ( i == rList.size() )
986cdf0e10cSrcweir aSettingsName = aTemp;
987cdf0e10cSrcweir }
988cdf0e10cSrcweir while( !aSettingsName.getLength() );
989cdf0e10cSrcweir
990cdf0e10cSrcweir setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Text ), Any( aSettingsName ) );
991cdf0e10cSrcweir setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_Enabled ), Any( !mbIsReadonly ) );
992cdf0e10cSrcweir setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_Enabled ), Any( !mbIsReadonly ) );
993cdf0e10cSrcweir
994cdf0e10cSrcweir UpdateControlStatesPage4();
995cdf0e10cSrcweir }
996cdf0e10cSrcweir
997cdf0e10cSrcweir // -----------------------------------------------------------------------------
EnablePage(sal_Int16 nStep)998cdf0e10cSrcweir void OptimizerDialog::EnablePage( sal_Int16 nStep )
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
1001cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
1002cdf0e10cSrcweir while( aBeg != aEnd )
1003cdf0e10cSrcweir setControlProperty( *aBeg++, TKGet( TK_Enabled ), Any( sal_True ) );
1004cdf0e10cSrcweir }
DisablePage(sal_Int16 nStep)1005cdf0e10cSrcweir void OptimizerDialog::DisablePage( sal_Int16 nStep )
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
1008cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
1009cdf0e10cSrcweir while( aBeg != aEnd )
1010cdf0e10cSrcweir setControlProperty( *aBeg++, TKGet( TK_Enabled ), Any( sal_False ) );
1011cdf0e10cSrcweir }
ActivatePage(sal_Int16 nStep)1012cdf0e10cSrcweir void OptimizerDialog::ActivatePage( sal_Int16 nStep )
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
1015cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
1016cdf0e10cSrcweir while( aBeg != aEnd )
1017cdf0e10cSrcweir setVisible( *aBeg++, sal_True );
1018cdf0e10cSrcweir }
DeactivatePage(sal_Int16 nStep)1019cdf0e10cSrcweir void OptimizerDialog::DeactivatePage( sal_Int16 nStep )
1020cdf0e10cSrcweir {
1021cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
1022cdf0e10cSrcweir std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
1023cdf0e10cSrcweir while( aBeg != aEnd )
1024cdf0e10cSrcweir setVisible( *aBeg++, sal_False );
1025cdf0e10cSrcweir }
1026*e1f21a75Smseidel
1027*e1f21a75Smseidel /* vim: set noet sw=4 ts=4: */
1028