Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "optimizerdialog.hxx"
31 : :
32 : : // -------------------
33 : : // - OptimizerDialog -
34 : : // -------------------
35 : : #include "pppoptimizer.hxx"
36 : : #include "graphiccollector.hxx"
37 : : #include "pagecollector.hxx"
38 : : #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
39 : : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
40 : : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
41 : : #include <com/sun/star/awt/FontDescriptor.hpp>
42 : : #include <com/sun/star/awt/FontWeight.hpp>
43 : : #include <rtl/ustrbuf.hxx>
44 : : #include <sal/macros.h>
45 : :
46 : : using namespace ::rtl;
47 : : using namespace ::com::sun::star::awt;
48 : : using namespace ::com::sun::star::uno;
49 : : using namespace ::com::sun::star::util;
50 : : using namespace ::com::sun::star::lang;
51 : : using namespace ::com::sun::star::frame;
52 : : using namespace ::com::sun::star::beans;
53 : : using namespace ::com::sun::star::script;
54 : : using namespace ::com::sun::star::drawing;
55 : : using namespace ::com::sun::star::container;
56 : : using namespace ::com::sun::star::presentation;
57 : :
58 : : // -----------------------------------------------------------------------------
59 : :
60 : 0 : void SetBold( OptimizerDialog& rOptimizerDialog, const rtl::OUString& rControl )
61 : : {
62 : 0 : FontDescriptor aFontDescriptor;
63 : 0 : if ( rOptimizerDialog.getControlProperty( rControl, TKGet( TK_FontDescriptor ) ) >>= aFontDescriptor )
64 : : {
65 : 0 : aFontDescriptor.Weight = FontWeight::BOLD;
66 : 0 : rOptimizerDialog.setControlProperty( rControl, TKGet( TK_FontDescriptor ), Any( aFontDescriptor ) );
67 : 0 : }
68 : 0 : }
69 : :
70 : : // -----------------------------------------------------------------------------
71 : :
72 : 0 : rtl::OUString InsertSeparator( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, sal_Int32 nOrientation,
73 : : sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight )
74 : : {
75 : : OUString pNames[] = {
76 : : TKGet( TK_Height ),
77 : : TKGet( TK_Orientation ),
78 : : TKGet( TK_PositionX ),
79 : : TKGet( TK_PositionY ),
80 : : TKGet( TK_Step ),
81 : 0 : TKGet( TK_Width ) };
82 : :
83 : : Any pValues[] = {
84 : : Any( nHeight ),
85 : : Any( nOrientation ),
86 : : Any( nPosX ),
87 : : Any( nPosY ),
88 : : Any( sal_Int16( 0 ) ),
89 : 0 : Any( nWidth ) };
90 : :
91 : 0 : sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
92 : :
93 : 0 : Sequence< rtl::OUString > aNames( pNames, nCount );
94 : 0 : Sequence< Any > aValues( pValues, nCount );
95 : :
96 : : rOptimizerDialog.insertControlModel( OUString( "com.sun.star.awt.UnoControlFixedLineModel" ),
97 : 0 : rControlName, aNames, aValues );
98 : 0 : return rControlName;
99 : : }
100 : :
101 : : // -----------------------------------------------------------------------------
102 : :
103 : 0 : rtl::OUString InsertButton( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, Reference< XActionListener >& xActionListener,
104 : : sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex, sal_Bool bEnabled, PPPOptimizerTokenEnum nResID, sal_Int16 nPushButtonType )
105 : : {
106 : : OUString pNames[] = {
107 : : TKGet( TK_Enabled ),
108 : : TKGet( TK_Height ),
109 : : TKGet( TK_Label ),
110 : : TKGet( TK_PositionX ),
111 : : TKGet( TK_PositionY ),
112 : : TKGet( TK_PushButtonType ),
113 : : TKGet( TK_Step ),
114 : : TKGet( TK_TabIndex ),
115 : 0 : TKGet( TK_Width ) };
116 : :
117 : : Any pValues[] = {
118 : : Any( bEnabled ),
119 : : Any( nHeight ),
120 : : Any( rOptimizerDialog.getString( nResID ) ),
121 : : Any( nXPos ),
122 : : Any( nYPos ),
123 : : Any( nPushButtonType ),
124 : : Any( (sal_Int16)0 ),
125 : : Any( nTabIndex ),
126 : 0 : Any( nWidth ) };
127 : :
128 : :
129 : 0 : sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
130 : :
131 : 0 : Sequence< rtl::OUString > aNames( pNames, nCount );
132 : 0 : Sequence< Any > aValues( pValues, nCount );
133 : :
134 : 0 : rOptimizerDialog.insertButton( rControlName, xActionListener, aNames, aValues );
135 : 0 : return rControlName;
136 : : }
137 : :
138 : : // -----------------------------------------------------------------------------
139 : :
140 : 0 : rtl::OUString InsertFixedText( OptimizerDialog& rOptimizerDialog, const rtl::OUString& rControlName, const OUString& rLabel,
141 : : sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Bool bBold, sal_Int16 nTabIndex )
142 : : {
143 : : OUString pNames[] = {
144 : : TKGet( TK_Height ),
145 : : TKGet( TK_Label ),
146 : : TKGet( TK_MultiLine ),
147 : : TKGet( TK_PositionX ),
148 : : TKGet( TK_PositionY ),
149 : : TKGet( TK_Step ),
150 : : TKGet( TK_TabIndex ),
151 : 0 : TKGet( TK_Width ) };
152 : :
153 : : Any pValues[] = {
154 : : Any( nHeight ),
155 : : Any( rLabel ),
156 : : Any( bMultiLine ),
157 : : Any( nXPos ),
158 : : Any( nYPos ),
159 : : Any( (sal_Int16)0 ),
160 : : Any( nTabIndex ),
161 : 0 : Any( nWidth ) };
162 : :
163 : 0 : sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
164 : :
165 : 0 : Sequence< rtl::OUString > aNames( pNames, nCount );
166 : 0 : Sequence< Any > aValues( pValues, nCount );
167 : :
168 : 0 : rOptimizerDialog.insertFixedText( rControlName, aNames, aValues );
169 : 0 : if ( bBold )
170 : 0 : SetBold( rOptimizerDialog, rControlName );
171 : 0 : return rControlName;
172 : : }
173 : :
174 : : // -----------------------------------------------------------------------------
175 : :
176 : 0 : rtl::OUString InsertCheckBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
177 : : const Reference< XItemListener > xItemListener, const OUString& rLabel,
178 : : sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
179 : : {
180 : : OUString pNames[] = {
181 : : TKGet( TK_Enabled ),
182 : : TKGet( TK_Height ),
183 : : TKGet( TK_Label ),
184 : : TKGet( TK_PositionX ),
185 : : TKGet( TK_PositionY ),
186 : : TKGet( TK_Step ),
187 : : TKGet( TK_TabIndex ),
188 : 0 : TKGet( TK_Width ) };
189 : :
190 : : Any pValues[] = {
191 : : Any( sal_True ),
192 : : Any( nHeight ),
193 : : Any( rLabel ),
194 : : Any( nXPos ),
195 : : Any( nYPos ),
196 : : Any( (sal_Int16)0 ),
197 : : Any( nTabIndex ),
198 : 0 : Any( nWidth ) };
199 : :
200 : 0 : sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
201 : :
202 : 0 : Sequence< rtl::OUString > aNames( pNames, nCount );
203 : 0 : Sequence< Any > aValues( pValues, nCount );
204 : :
205 : 0 : Reference< XCheckBox > xCheckBox( rOptimizerDialog.insertCheckBox( rControlName, aNames, aValues ) );
206 : 0 : if ( xItemListener.is() )
207 : 0 : xCheckBox->addItemListener( xItemListener );
208 : 0 : return rControlName;
209 : : }
210 : :
211 : : // -----------------------------------------------------------------------------
212 : :
213 : 0 : rtl::OUString InsertFormattedField( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
214 : : const Reference< XTextListener > xTextListener, const Reference< XSpinListener > xSpinListener, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth,
215 : : double fEffectiveMin, double fEffectiveMax, sal_Int16 nTabIndex )
216 : : {
217 : : OUString pNames[] = {
218 : : TKGet( TK_EffectiveMax ),
219 : : TKGet( TK_EffectiveMin ),
220 : : TKGet( TK_Enabled ),
221 : : TKGet( TK_Height ),
222 : : TKGet( TK_PositionX ),
223 : : TKGet( TK_PositionY ),
224 : : TKGet( TK_Repeat ),
225 : : TKGet( TK_Spin ),
226 : : TKGet( TK_Step ),
227 : : TKGet( TK_TabIndex ),
228 : 0 : TKGet( TK_Width ) };
229 : :
230 : : Any pValues[] = {
231 : : Any( fEffectiveMax ),
232 : : Any( fEffectiveMin ),
233 : : Any( sal_True ),
234 : : Any( (sal_Int32)12 ),
235 : : Any( nXPos ),
236 : : Any( nYPos ),
237 : : Any( (sal_Bool)sal_True ),
238 : : Any( (sal_Bool)sal_True ),
239 : : Any( (sal_Int16)0 ),
240 : : Any( nTabIndex ),
241 : 0 : Any( nWidth ) };
242 : :
243 : 0 : sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
244 : :
245 : 0 : Sequence< rtl::OUString > aNames( pNames, nCount );
246 : 0 : Sequence< Any > aValues( pValues, nCount );
247 : :
248 : 0 : Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertFormattedField( rControlName, aNames, aValues ), UNO_QUERY_THROW );
249 : 0 : if ( xTextListener.is() )
250 : 0 : xTextComponent->addTextListener( xTextListener );
251 : 0 : if ( xSpinListener.is() )
252 : : {
253 : 0 : Reference< XSpinField > xSpinField( xTextComponent, UNO_QUERY_THROW );
254 : 0 : xSpinField->addSpinListener( xSpinListener );
255 : : }
256 : 0 : return rControlName;
257 : : }
258 : :
259 : : // -----------------------------------------------------------------------------
260 : :
261 : 0 : rtl::OUString InsertComboBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
262 : : const Reference< XTextListener > xTextListener, const sal_Bool bEnabled, const Sequence< OUString >& rItemList,
263 : : sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
264 : : {
265 : : OUString pNames[] = {
266 : : TKGet( TK_Dropdown ),
267 : : TKGet( TK_Enabled ),
268 : : TKGet( TK_Height ),
269 : : TKGet( TK_LineCount ),
270 : : TKGet( TK_PositionX ),
271 : : TKGet( TK_PositionY ),
272 : : TKGet( TK_Step ),
273 : : TKGet( TK_StringItemList ),
274 : : TKGet( TK_TabIndex ),
275 : 0 : TKGet( TK_Width ) };
276 : :
277 : : Any pValues[] = {
278 : : Any( sal_True ),
279 : : Any( bEnabled ),
280 : : Any( nHeight ),
281 : : Any( (sal_Int16)8),
282 : : Any( nXPos ),
283 : : Any( nYPos ),
284 : : Any( (sal_Int16)0 ),
285 : : Any( rItemList ),
286 : : Any( nTabIndex ),
287 : 0 : Any( nWidth ) };
288 : :
289 : 0 : sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
290 : :
291 : 0 : Sequence< rtl::OUString > aNames( pNames, nCount );
292 : 0 : Sequence< Any > aValues( pValues, nCount );
293 : :
294 : 0 : Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertComboBox( rControlName, aNames, aValues ), UNO_QUERY_THROW );
295 : 0 : if ( xTextListener.is() )
296 : 0 : xTextComponent->addTextListener( xTextListener );
297 : 0 : return rControlName;
298 : : }
299 : :
300 : : // -----------------------------------------------------------------------------
301 : :
302 : 0 : rtl::OUString InsertRadioButton( OptimizerDialog& rOptimizerDialog, const rtl::OUString& rControlName, const Reference< XItemListener > xItemListener,
303 : : const OUString& rLabel, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Bool bMultiLine, sal_Int16 nTabIndex )
304 : : {
305 : : OUString pNames[] = {
306 : : TKGet( TK_Height ),
307 : : TKGet( TK_Label ),
308 : : TKGet( TK_MultiLine ),
309 : : TKGet( TK_PositionX ),
310 : : TKGet( TK_PositionY ),
311 : : TKGet( TK_Step ),
312 : : TKGet( TK_TabIndex ),
313 : 0 : TKGet( TK_Width ) };
314 : :
315 : : Any pValues[] = {
316 : : Any( nHeight ),
317 : : Any( rLabel ),
318 : : Any( bMultiLine ),
319 : : Any( nXPos ),
320 : : Any( nYPos ),
321 : : Any( (sal_Int16)0 ),
322 : : Any( nTabIndex ),
323 : 0 : Any( nWidth ) };
324 : :
325 : 0 : sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
326 : :
327 : 0 : Sequence< rtl::OUString > aNames( pNames, nCount );
328 : 0 : Sequence< Any > aValues( pValues, nCount );
329 : :
330 : 0 : Reference< XRadioButton > xRadioButton( rOptimizerDialog.insertRadioButton( rControlName, aNames, aValues ) );
331 : 0 : if ( xItemListener.is() )
332 : 0 : xRadioButton->addItemListener( xItemListener );
333 : 0 : return rControlName;
334 : : }
335 : :
336 : : // -----------------------------------------------------------------------------
337 : :
338 : 0 : rtl::OUString InsertListBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
339 : : const Reference< XActionListener > xActionListener, const sal_Bool bEnabled, const Sequence< OUString >& rItemList,
340 : : sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
341 : : {
342 : : OUString pNames[] = {
343 : : TKGet( TK_Dropdown ),
344 : : TKGet( TK_Enabled ),
345 : : TKGet( TK_Height ),
346 : : TKGet( TK_LineCount ),
347 : : TKGet( TK_MultiSelection ),
348 : : TKGet( TK_PositionX ),
349 : : TKGet( TK_PositionY ),
350 : : TKGet( TK_Step ),
351 : : TKGet( TK_StringItemList ),
352 : : TKGet( TK_TabIndex ),
353 : 0 : TKGet( TK_Width ) };
354 : :
355 : : Any pValues[] = {
356 : : Any( sal_True ),
357 : : Any( bEnabled ),
358 : : Any( nHeight ),
359 : : Any( (sal_Int16)8),
360 : : Any( sal_False ),
361 : : Any( nXPos ),
362 : : Any( nYPos ),
363 : : Any( (sal_Int16)0 ),
364 : : Any( rItemList ),
365 : : Any( nTabIndex ),
366 : 0 : Any( nWidth ) };
367 : :
368 : 0 : sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
369 : :
370 : 0 : Sequence< rtl::OUString > aNames( pNames, nCount );
371 : 0 : Sequence< Any > aValues( pValues, nCount );
372 : :
373 : 0 : Reference< XListBox > xListBox( rOptimizerDialog.insertListBox( rControlName, aNames, aValues ) );
374 : 0 : if ( xListBox.is() )
375 : 0 : xListBox->addActionListener( xActionListener );
376 : 0 : return rControlName;
377 : : }
378 : :
379 : : // -----------------------------------------------------------------------------
380 : :
381 : 0 : void OptimizerDialog::InitNavigationBar()
382 : : {
383 : 0 : sal_Int32 nCancelPosX = OD_DIALOG_WIDTH - BUTTON_WIDTH - 6;
384 : 0 : sal_Int32 nFinishPosX = nCancelPosX - 6 - BUTTON_WIDTH;
385 : 0 : sal_Int32 nNextPosX = nFinishPosX - 6 - BUTTON_WIDTH;
386 : 0 : sal_Int32 nBackPosX = nNextPosX - 3 - BUTTON_WIDTH;
387 : :
388 : 0 : InsertSeparator( *this, TKGet( TK_lnNavSep1 ), 0, 0, DIALOG_HEIGHT - 26, OD_DIALOG_WIDTH, 1 );
389 : 0 : InsertSeparator( *this, TKGet( TK_lnNavSep2 ), 1, 85, 0, 1, BUTTON_POS_Y - 6 );
390 : :
391 : 0 : InsertButton( *this, TKGet( TK_btnNavBack ), mxActionListener, nBackPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_False, STR_BACK, PushButtonType_STANDARD );
392 : 0 : InsertButton( *this, TKGet( TK_btnNavNext ), mxActionListener, nNextPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_NEXT, PushButtonType_STANDARD );
393 : 0 : InsertButton( *this, TKGet( TK_btnNavFinish ), mxActionListener, nFinishPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_FINISH, PushButtonType_STANDARD );
394 : 0 : InsertButton( *this, TKGet( TK_btnNavCancel ), mxActionListener, nCancelPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, sal_True, STR_CANCEL, PushButtonType_STANDARD );
395 : :
396 : 0 : setControlProperty( TKGet( TK_btnNavNext ), TKGet( TK_DefaultButton ), Any( sal_True ) );
397 : 0 : }
398 : :
399 : : // -----------------------------------------------------------------------------
400 : :
401 : 0 : void OptimizerDialog::UpdateControlStatesPage0()
402 : : {
403 : : sal_uInt32 i;
404 : 0 : short nSelectedItem = -1;
405 : 0 : Sequence< OUString > aItemList;
406 : 0 : const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
407 : 0 : if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
408 : : {
409 : 0 : aItemList.realloc( rList.size() - 1 );
410 : 0 : for ( i = 1; i < rList.size(); i++ )
411 : : {
412 : 0 : aItemList[ i - 1 ] = rList[ i ].maName;
413 : 0 : if ( nSelectedItem < 0 )
414 : : {
415 : 0 : if ( rList[ i ] == rList[ 0 ] )
416 : 0 : nSelectedItem = static_cast< short >( i - 1 );
417 : : }
418 : : }
419 : : }
420 : 0 : sal_Bool bRemoveButtonEnabled = sal_False;
421 : 0 : Sequence< short > aSelectedItems;
422 : 0 : if ( nSelectedItem >= 0 )
423 : : {
424 : 0 : aSelectedItems.realloc( 1 );
425 : 0 : aSelectedItems[ 0 ] = nSelectedItem;
426 : 0 : if ( nSelectedItem > 2 ) // only allowing to delete custom themes, the first can|t be deleted
427 : 0 : bRemoveButtonEnabled = sal_True;
428 : : }
429 : 0 : setControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_StringItemList ), Any( aItemList ) );
430 : 0 : setControlProperty( TKGet( TK_ListBox0Pg0 ), TKGet( TK_SelectedItems ), Any( aSelectedItems ) );
431 : 0 : setControlProperty( TKGet( TK_Button0Pg0 ), TKGet( TK_Enabled ), Any( bRemoveButtonEnabled ) );
432 : 0 : }
433 : 0 : void OptimizerDialog::InitPage0()
434 : : {
435 : 0 : Sequence< OUString > aItemList;
436 : 0 : std::vector< rtl::OUString > aControlList;
437 : 0 : 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++ ) );
438 : 0 : 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++ ) );
439 : 0 : aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator1Pg0 ), 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 66, PAGE_WIDTH - 12, 1 ) );
440 : 0 : 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++ ) );
441 : 0 : 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++ ) );
442 : 0 : 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 ) );
443 : 0 : maControlPages.push_back( aControlList );
444 : 0 : DeactivatePage( 0 );
445 : 0 : UpdateControlStatesPage0();
446 : 0 : }
447 : :
448 : : // -----------------------------------------------------------------------------
449 : :
450 : 0 : void OptimizerDialog::UpdateControlStatesPage1()
451 : : {
452 : 0 : sal_Bool bDeleteUnusedMasterPages( GetConfigProperty( TK_DeleteUnusedMasterPages, sal_False ) );
453 : 0 : sal_Bool bDeleteHiddenSlides( GetConfigProperty( TK_DeleteHiddenSlides, sal_False ) );
454 : 0 : sal_Bool bDeleteNotesPages( GetConfigProperty( TK_DeleteNotesPages, sal_False ) );
455 : :
456 : 0 : setControlProperty( TKGet( TK_CheckBox0Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteUnusedMasterPages ) );
457 : 0 : setControlProperty( TKGet( TK_CheckBox1Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteNotesPages ) );
458 : 0 : setControlProperty( TKGet( TK_CheckBox2Pg3 ), TKGet( TK_State ), Any( (sal_Int16)bDeleteHiddenSlides ) );
459 : 0 : }
460 : 0 : void OptimizerDialog::InitPage1()
461 : : {
462 : 0 : Sequence< OUString > aCustomShowList;
463 : 0 : Reference< XModel > xModel( mxController->getModel() );
464 : 0 : if ( xModel.is() )
465 : : {
466 : 0 : Reference< XCustomPresentationSupplier > aXCPSup( xModel, UNO_QUERY_THROW );
467 : 0 : Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() );
468 : 0 : if ( aXCont.is() )
469 : 0 : aCustomShowList = aXCont->getElementNames();
470 : : }
471 : 0 : std::vector< rtl::OUString > aControlList;
472 : 0 : 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++ ) );
473 : 0 : 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++ ) );
474 : 0 : 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++ ) );
475 : 0 : 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++ ) );
476 : 0 : aControlList.push_back( InsertListBox( *this, TKGet( TK_ListBox0Pg3 ), mxActionListener, sal_True, aCustomShowList, PAGE_POS_X + 14, PAGE_POS_Y + 54, 150, 12, mnTabIndex++ ) );
477 : 0 : 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++ ) );
478 : 0 : maControlPages.push_back( aControlList );
479 : 0 : DeactivatePage( 1 );
480 : :
481 : 0 : setControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ), Any( sal_False ) );
482 : 0 : setControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_Enabled ), Any( aCustomShowList.getLength() != 0 ) );
483 : 0 : setControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_Enabled ), Any( sal_False ) );
484 : :
485 : 0 : UpdateControlStatesPage1();
486 : 0 : }
487 : :
488 : : // -----------------------------------------------------------------------------
489 : :
490 : 0 : void OptimizerDialog::UpdateControlStatesPage2()
491 : : {
492 : 0 : sal_Bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, sal_False ) );
493 : 0 : sal_Bool bRemoveCropArea( GetConfigProperty( TK_RemoveCropArea, sal_False ) );
494 : 0 : sal_Bool bEmbedLinkedGraphics( GetConfigProperty( TK_EmbedLinkedGraphics, sal_True ) );
495 : 0 : sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
496 : :
497 : 0 : sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
498 : :
499 : : sal_Int32 nI0, nI1, nI2, nI3;
500 : 0 : nI0 = nI1 = nI2 = nI3 = 0;
501 : 0 : OUString aResolutionText;
502 : 0 : Sequence< OUString > aResolutionItemList( 4 );
503 : 0 : aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
504 : 0 : aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
505 : 0 : aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
506 : 0 : aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
507 : 0 : nI0 = nI1 = nI2 = nI3 = 0;
508 : 0 : if ( getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI0 ).toInt32() == nImageResolution )
509 : 0 : aResolutionText = aResolutionItemList[ 0 ];
510 : 0 : else if ( getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI1 ).toInt32() == nImageResolution )
511 : 0 : aResolutionText = aResolutionItemList[ 1 ];
512 : 0 : else if ( getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI2 ).toInt32() == nImageResolution )
513 : 0 : aResolutionText = aResolutionItemList[ 2 ];
514 : 0 : else if ( getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI3 ).toInt32() == nImageResolution )
515 : 0 : aResolutionText = aResolutionItemList[ 3 ];
516 : 0 : if ( aResolutionText.isEmpty() )
517 : 0 : aResolutionText = OUString::valueOf( nImageResolution );
518 : :
519 : 0 : setControlProperty( TKGet( TK_RadioButton0Pg1 ), TKGet( TK_State ), Any( (sal_Int16)( bJPEGCompression != sal_True ) ) );
520 : 0 : setControlProperty( TKGet( TK_RadioButton1Pg1 ), TKGet( TK_State ), Any( (sal_Int16)( bJPEGCompression != sal_False ) ) );
521 : 0 : setControlProperty( TKGet( TK_FixedText1Pg1 ), TKGet( TK_Enabled ), Any( bJPEGCompression ) );
522 : 0 : setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_Enabled ), Any( bJPEGCompression ) );
523 : 0 : setControlProperty( TKGet( TK_FormattedField0Pg1 ), TKGet( TK_EffectiveValue ), Any( (double)nJPEGQuality ) );
524 : 0 : setControlProperty( TKGet( TK_CheckBox1Pg1 ), TKGet( TK_State ), Any( (sal_Int16)bRemoveCropArea ) );
525 : 0 : setControlProperty( TKGet( TK_ComboBox0Pg1 ), TKGet( TK_Text ), Any( aResolutionText ) );
526 : 0 : setControlProperty( TKGet( TK_CheckBox2Pg1 ), TKGet( TK_State ), Any( (sal_Int16)bEmbedLinkedGraphics ) );
527 : 0 : }
528 : 0 : void OptimizerDialog::InitPage2()
529 : : {
530 : : sal_Int32 nI0, nI1, nI2, nI3;
531 : 0 : nI0 = nI1 = nI2 = nI3 = 0;
532 : 0 : Sequence< OUString > aResolutionItemList( 4 );
533 : 0 : aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
534 : 0 : aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
535 : 0 : aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
536 : 0 : aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
537 : :
538 : 0 : std::vector< rtl::OUString > aControlList;
539 : 0 : 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++ ) );
540 : 0 : 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++ ) );
541 : 0 : 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++ ) );
542 : 0 : 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++ ) );
543 : 0 : aControlList.push_back( InsertFormattedField( *this, TKGet( TK_FormattedField0Pg1 ), mxTextListenerFormattedField0Pg1, mxSpinListenerFormattedField0Pg1, PAGE_POS_X + 106, PAGE_POS_Y + 38, 50, 0, 100, mnTabIndex++ ) );
544 : 0 : 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++ ) );
545 : 0 : aControlList.push_back( InsertComboBox( *this, TKGet( TK_ComboBox0Pg1 ), mxTextListenerComboBox0Pg1, sal_True, aResolutionItemList, PAGE_POS_X + 106, PAGE_POS_Y + 52, 100, 12, mnTabIndex++ ) );
546 : 0 : 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++ ) );
547 : 0 : 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++ ) );
548 : 0 : maControlPages.push_back( aControlList );
549 : 0 : DeactivatePage( 2 );
550 : 0 : UpdateControlStatesPage2();
551 : 0 : }
552 : :
553 : : // -----------------------------------------------------------------------------
554 : :
555 : 0 : void OptimizerDialog::UpdateControlStatesPage3()
556 : : {
557 : 0 : sal_Bool bConvertOLEObjects( GetConfigProperty( TK_OLEOptimization, sal_False ) );
558 : 0 : sal_Int16 nOLEOptimizationType( GetConfigProperty( TK_OLEOptimizationType, (sal_Int16)0 ) );
559 : :
560 : 0 : setControlProperty( TKGet( TK_CheckBox0Pg2 ), TKGet( TK_State ), Any( (sal_Int16)bConvertOLEObjects ) );
561 : 0 : setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_Enabled ), Any( bConvertOLEObjects ) );
562 : 0 : setControlProperty( TKGet( TK_RadioButton0Pg2 ), TKGet( TK_State ), Any( (sal_Int16)( nOLEOptimizationType == 0 ) ) );
563 : 0 : setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_Enabled ), Any( bConvertOLEObjects ) );
564 : 0 : setControlProperty( TKGet( TK_RadioButton1Pg2 ), TKGet( TK_State ), Any( (sal_Int16)( nOLEOptimizationType == 1 ) ) );
565 : 0 : }
566 : 0 : void OptimizerDialog::InitPage3()
567 : : {
568 : 0 : int nOLECount = 0;
569 : 0 : Reference< XModel > xModel( mxController->getModel() );
570 : 0 : Reference< XDrawPagesSupplier > xDrawPagesSupplier( xModel, UNO_QUERY_THROW );
571 : 0 : Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
572 : 0 : for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
573 : : {
574 : 0 : Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
575 : 0 : for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
576 : : {
577 : 0 : const OUString sOLE2Shape( "com.sun.star.drawing.OLE2Shape" );
578 : 0 : Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
579 : 0 : if ( xShape->getShapeType() == sOLE2Shape )
580 : 0 : nOLECount++;
581 : 0 : }
582 : 0 : }
583 : :
584 : 0 : std::vector< rtl::OUString > aControlList;
585 : 0 : 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++ ) );
586 : 0 : 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++ ) );
587 : 0 : 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++ ) );
588 : 0 : 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++ ) );
589 : 0 : 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++ ) );
590 : 0 : maControlPages.push_back( aControlList );
591 : 0 : DeactivatePage( 3 );
592 : 0 : UpdateControlStatesPage3();
593 : 0 : }
594 : :
595 : : // -----------------------------------------------------------------------------
596 : :
597 : 0 : static OUString ImpValueOfInMB( const sal_Int64& rVal, sal_Unicode nSeparator = '.' )
598 : : {
599 : 0 : double fVal( static_cast<double>( rVal ) );
600 : 0 : fVal /= ( 1 << 20 );
601 : 0 : fVal += 0.05;
602 : 0 : rtl::OUStringBuffer aVal( OUString::valueOf( fVal ) );
603 : 0 : sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.', 0 ) );
604 : 0 : if ( nX >= 0 )
605 : : {
606 : 0 : aVal.setLength( nX + 2 );
607 : 0 : aVal[nX] = nSeparator;
608 : : }
609 : 0 : aVal.append( OUString(" MB") );
610 : 0 : return aVal.makeStringAndClear();
611 : : }
612 : :
613 : 0 : void OptimizerDialog::UpdateControlStatesPage4()
614 : : {
615 : 0 : sal_Bool bSaveAs( GetConfigProperty( TK_SaveAs, sal_True ) );
616 : 0 : if ( mbIsReadonly )
617 : : {
618 : 0 : setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( sal_False ) ) );
619 : 0 : setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( sal_True ) ) );
620 : : }
621 : : else
622 : : {
623 : 0 : setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bSaveAs == sal_False ) ) );
624 : 0 : setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_State ), Any( (sal_Int16)( bSaveAs == sal_True ) ) );
625 : : }
626 : 0 : setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( sal_False ) );
627 : :
628 : : sal_uInt32 w;
629 : 0 : Sequence< OUString > aItemList;
630 : 0 : const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
631 : 0 : if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
632 : : {
633 : 0 : aItemList.realloc( rList.size() - 1 );
634 : 0 : for ( w = 1; w < rList.size(); w++ )
635 : 0 : aItemList[ w - 1 ] = rList[ w ].maName;
636 : : }
637 : 0 : setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_StringItemList ), Any( aItemList ) );
638 : :
639 : : // now check if it is sensible to enable the combo box
640 : 0 : sal_Bool bSaveSettingsEnabled = sal_True;
641 : 0 : if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
642 : : {
643 : 0 : for ( w = 1; w < rList.size(); w++ )
644 : : {
645 : 0 : if ( rList[ w ] == rList[ 0 ] )
646 : : {
647 : 0 : bSaveSettingsEnabled = sal_False;
648 : 0 : break;
649 : : }
650 : : }
651 : : }
652 : 0 : sal_Int16 nInt16 = 0;
653 : 0 : getControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_State ) ) >>= nInt16;
654 : 0 : setControlProperty( TKGet( TK_CheckBox1Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled ) );
655 : 0 : setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Enabled ), Any( bSaveSettingsEnabled && nInt16 ) );
656 : :
657 : 0 : std::vector< OUString > aSummaryStrings;
658 : :
659 : : // taking care of deleted slides
660 : 0 : sal_Int32 nDeletedSlides = 0;
661 : 0 : rtl::OUString aCustomShowName;
662 : 0 : if ( getControlProperty( TKGet( TK_CheckBox3Pg3 ), TKGet( TK_State ) ) >>= nInt16 )
663 : : {
664 : 0 : if ( nInt16 )
665 : : {
666 : 0 : Sequence< short > aSelectedItems;
667 : 0 : Sequence< OUString > aStringItemList;
668 : 0 : Any aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_SelectedItems ) );
669 : 0 : if ( aAny >>= aSelectedItems )
670 : : {
671 : 0 : if ( aSelectedItems.getLength() )
672 : : {
673 : 0 : sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
674 : 0 : aAny = getControlProperty( TKGet( TK_ListBox0Pg3 ), TKGet( TK_StringItemList ) );
675 : 0 : if ( aAny >>= aStringItemList )
676 : : {
677 : 0 : if ( aStringItemList.getLength() > nSelectedItem )
678 : 0 : SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) );
679 : : }
680 : : }
681 : 0 : }
682 : : }
683 : : }
684 : 0 : if ( !aCustomShowName.isEmpty() )
685 : : {
686 : 0 : std::vector< Reference< XDrawPage > > vNonUsedPageList;
687 : 0 : PageCollector::CollectNonCustomShowPages( mxController->getModel(), aCustomShowName, vNonUsedPageList );
688 : 0 : nDeletedSlides += vNonUsedPageList.size();
689 : : }
690 : 0 : if ( GetConfigProperty( TK_DeleteHiddenSlides, sal_False ) )
691 : : {
692 : 0 : if ( !aCustomShowName.isEmpty() )
693 : : {
694 : 0 : std::vector< Reference< XDrawPage > > vUsedPageList;
695 : 0 : PageCollector::CollectCustomShowPages( mxController->getModel(), aCustomShowName, vUsedPageList );
696 : 0 : std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
697 : 0 : while( aIter != vUsedPageList.end() )
698 : : {
699 : 0 : Reference< XPropertySet > xPropSet( *aIter, UNO_QUERY_THROW );
700 : 0 : sal_Bool bVisible = sal_True;
701 : 0 : const OUString sVisible( "Visible" );
702 : 0 : if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
703 : : {
704 : 0 : if (!bVisible )
705 : 0 : nDeletedSlides++;
706 : : }
707 : 0 : ++aIter;
708 : 0 : }
709 : : }
710 : : else
711 : : {
712 : 0 : Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
713 : 0 : Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
714 : 0 : for( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
715 : : {
716 : 0 : Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
717 : 0 : Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY_THROW );
718 : :
719 : 0 : sal_Bool bVisible = sal_True;
720 : 0 : const OUString sVisible( "Visible" );
721 : 0 : if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
722 : : {
723 : 0 : if (!bVisible )
724 : 0 : nDeletedSlides++;
725 : : }
726 : 0 : }
727 : : }
728 : : }
729 : 0 : if ( GetConfigProperty( TK_DeleteUnusedMasterPages, sal_False ) )
730 : : {
731 : 0 : std::vector< PageCollector::MasterPageEntity > aMasterPageList;
732 : 0 : PageCollector::CollectMasterPages( mxController->getModel(), aMasterPageList );
733 : 0 : Reference< XMasterPagesSupplier > xMasterPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
734 : 0 : Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
735 : 0 : std::vector< PageCollector::MasterPageEntity >::iterator aIter( aMasterPageList.begin() );
736 : 0 : while( aIter != aMasterPageList.end() )
737 : : {
738 : 0 : if ( !aIter->bUsed )
739 : 0 : nDeletedSlides++;
740 : 0 : ++aIter;
741 : 0 : }
742 : : }
743 : 0 : if ( nDeletedSlides > 1 )
744 : : {
745 : 0 : OUString aStr( getString( STR_DELETE_SLIDES ) );
746 : 0 : OUString aPlaceholder( "%SLIDES" );
747 : 0 : sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
748 : 0 : if ( i >= 0 )
749 : 0 : aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::valueOf( nDeletedSlides ) );
750 : 0 : aSummaryStrings.push_back( aStr );
751 : : }
752 : :
753 : : // generating graphic compression info
754 : 0 : sal_Int32 nGraphics = 0;
755 : 0 : sal_Bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, sal_False ) );
756 : 0 : sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
757 : 0 : sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
758 : 0 : GraphicSettings aGraphicSettings( bJPEGCompression, nJPEGQuality, GetConfigProperty( TK_RemoveCropArea, sal_False ),
759 : 0 : nImageResolution, GetConfigProperty( TK_EmbedLinkedGraphics, sal_True ) );
760 : 0 : GraphicCollector::CountGraphics( mxMSF, mxController->getModel(), aGraphicSettings, nGraphics );
761 : 0 : if ( nGraphics > 1 )
762 : : {
763 : 0 : OUString aStr( getString( STR_OPTIMIZE_IMAGES ) );
764 : 0 : OUString aImagePlaceholder( "%IMAGES" );
765 : 0 : OUString aQualityPlaceholder( "%QUALITY" );
766 : 0 : OUString aResolutionPlaceholder( "%RESOLUTION" );
767 : 0 : sal_Int32 i = aStr.indexOf( aImagePlaceholder, 0 );
768 : 0 : if ( i >= 0 )
769 : 0 : aStr = aStr.replaceAt( i, aImagePlaceholder.getLength(), OUString::valueOf( nGraphics ) );
770 : :
771 : 0 : sal_Int32 j = aStr.indexOf( aQualityPlaceholder, 0 );
772 : 0 : if ( j >= 0 )
773 : 0 : aStr = aStr.replaceAt( j, aQualityPlaceholder.getLength(), OUString::valueOf( nJPEGQuality ) );
774 : :
775 : 0 : sal_Int32 k = aStr.indexOf( aResolutionPlaceholder, 0 );
776 : 0 : if ( k >= 0 )
777 : 0 : aStr = aStr.replaceAt( k, aResolutionPlaceholder.getLength(), OUString::valueOf( nImageResolution ) );
778 : :
779 : 0 : aSummaryStrings.push_back( aStr );
780 : : }
781 : :
782 : 0 : if ( GetConfigProperty( TK_OLEOptimization, sal_False ) )
783 : : {
784 : 0 : sal_Int32 nOLEReplacements = 0;
785 : 0 : Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
786 : 0 : Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
787 : 0 : for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
788 : : {
789 : 0 : Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
790 : 0 : for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
791 : : {
792 : 0 : const OUString sOLE2Shape( "com.sun.star.drawing.OLE2Shape" );
793 : 0 : Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
794 : 0 : if ( xShape->getShapeType() == sOLE2Shape )
795 : 0 : nOLEReplacements++;
796 : 0 : }
797 : 0 : }
798 : 0 : if ( nOLEReplacements > 1 )
799 : : {
800 : 0 : OUString aStr( getString( STR_CREATE_REPLACEMENT ) );
801 : 0 : OUString aPlaceholder( "%OLE" );
802 : 0 : sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
803 : 0 : if ( i >= 0 )
804 : 0 : aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::valueOf( nOLEReplacements ) );
805 : 0 : aSummaryStrings.push_back( aStr );
806 : 0 : }
807 : : }
808 : 0 : while( aSummaryStrings.size() < 3 )
809 : 0 : aSummaryStrings.push_back( OUString() );
810 : 0 : setControlProperty( TKGet( TK_FixedText4Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 0 ] ) );
811 : 0 : setControlProperty( TKGet( TK_FixedText5Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 1 ] ) );
812 : 0 : setControlProperty( TKGet( TK_FixedText6Pg4 ), TKGet( TK_Label ), Any( aSummaryStrings[ 2 ] ) );
813 : :
814 : 0 : sal_Int64 nCurrentFileSize = 0;
815 : 0 : sal_Int64 nEstimatedFileSize = 0;
816 : 0 : Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY );
817 : 0 : if ( xStorable.is() && xStorable->hasLocation() )
818 : 0 : nCurrentFileSize = PPPOptimizer::GetFileSize( xStorable->getLocation() );
819 : :
820 : 0 : if ( nCurrentFileSize )
821 : : {
822 : 0 : double fE = static_cast< double >( nCurrentFileSize );
823 : 0 : if ( nImageResolution )
824 : : {
825 : 0 : double v = ( static_cast< double >( nImageResolution ) + 75.0 ) / 300.0;
826 : 0 : if ( v < 1.0 )
827 : 0 : fE *= v;
828 : : }
829 : 0 : if ( bJPEGCompression )
830 : : {
831 : 0 : double v = 0.75 - ( ( 100.0 - static_cast< double >( nJPEGQuality ) ) / 400.0 ) ;
832 : 0 : fE *= v;
833 : : }
834 : 0 : nEstimatedFileSize = static_cast< sal_Int64 >( fE );
835 : : }
836 : 0 : sal_Unicode nSeparator = '.';
837 : 0 : OUString aStr( getString( STR_FILESIZESEPARATOR ) );
838 : 0 : if ( !aStr.isEmpty() )
839 : 0 : nSeparator = aStr[ 0 ];
840 : 0 : setControlProperty( TKGet( TK_FixedText7Pg4 ), TKGet( TK_Label ), Any( ImpValueOfInMB( nCurrentFileSize, nSeparator ) ) );
841 : 0 : setControlProperty( TKGet( TK_FixedText8Pg4 ), TKGet( TK_Label ), Any( ImpValueOfInMB( nEstimatedFileSize, nSeparator ) ) );
842 : 0 : SetConfigProperty( TK_EstimatedFileSize, Any( nEstimatedFileSize ) );
843 : 0 : }
844 : :
845 : 0 : void OptimizerDialog::InitPage4()
846 : : {
847 : : { // creating progress bar:
848 : : OUString pNames[] = {
849 : : TKGet( TK_Height ),
850 : : TKGet( TK_Name ),
851 : : TKGet( TK_PositionX ),
852 : : TKGet( TK_PositionY ),
853 : : TKGet( TK_ProgressValue ),
854 : : TKGet( TK_ProgressValueMax ),
855 : : TKGet( TK_ProgressValueMin ),
856 : 0 : TKGet( TK_Width ) };
857 : :
858 : : Any pValues[] = {
859 : : Any( (sal_Int32)12 ),
860 : : Any( TKGet( STR_SAVE_AS ) ),
861 : : Any( (sal_Int32)( PAGE_POS_X + 6 ) ),
862 : : Any( (sal_Int32)( DIALOG_HEIGHT - 75 ) ),
863 : : Any( (sal_Int32)( 0 ) ),
864 : : Any( (sal_Int32)( 100 ) ),
865 : : Any( (sal_Int32)( 0 ) ),
866 : 0 : Any( (sal_Int32)( PAGE_WIDTH - 12 ) ) };
867 : :
868 : 0 : sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
869 : :
870 : 0 : Sequence< rtl::OUString > aNames( pNames, nCount );
871 : 0 : Sequence< Any > aValues( pValues, nCount );
872 : :
873 : : Reference< XMultiPropertySet > xMultiPropertySet( insertControlModel( OUString( "com.sun.star.awt.UnoControlProgressBarModel" ),
874 : 0 : TKGet( TK_Progress ), aNames, aValues ), UNO_QUERY );
875 : : }
876 : 0 : Reference< XTextListener > xTextListener;
877 : 0 : Sequence< OUString > aItemList;
878 : 0 : std::vector< rtl::OUString > aControlList;
879 : 0 : 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++ ) );
880 : : // aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator0Pg4 ), 0, PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 1 ) );
881 : :
882 : 0 : 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++ ) );
883 : 0 : 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++ ) );
884 : 0 : 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++ ) );
885 : :
886 : 0 : 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++ ) );
887 : 0 : aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText7Pg4 ), OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 50, 30, 8, sal_False, sal_False, mnTabIndex++ ) );
888 : 0 : setControlProperty( TKGet( TK_FixedText7Pg4 ), TKGet( TK_Align ), Any( static_cast< short >( 2 ) ) );
889 : 0 : 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++ ) );
890 : 0 : aControlList.push_back( InsertFixedText( *this, TKGet( TK_FixedText8Pg4 ), OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 58, 30, 8, sal_False, sal_False, mnTabIndex++ ) );
891 : 0 : setControlProperty( TKGet( TK_FixedText8Pg4 ), TKGet( TK_Align ), Any( static_cast< short >( 2 ) ) );
892 : :
893 : 0 : 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++ ) );
894 : 0 : 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++ ) );
895 : 0 : 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++ ) );
896 : 0 : aControlList.push_back( TKGet( TK_Progress ) );
897 : 0 : aControlList.push_back( InsertSeparator( *this, TKGet( TK_Separator1Pg4 ), 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 58, PAGE_WIDTH - 12, 1 ) );
898 : 0 : aControlList.push_back( InsertCheckBox( *this, TKGet( TK_CheckBox1Pg4 ), mxItemListener, getString( STR_SAVE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 47, 100, 8, mnTabIndex++ ) );
899 : 0 : aControlList.push_back( InsertComboBox( *this, TKGet( TK_ComboBox0Pg4 ), xTextListener, sal_True, aItemList, PAGE_POS_X + 106, DIALOG_HEIGHT - 48, 100, 12, mnTabIndex++ ) );
900 : 0 : maControlPages.push_back( aControlList );
901 : 0 : DeactivatePage( 4 );
902 : :
903 : : // creating a default session name that hasn't been used yet
904 : 0 : OUString aSettingsName;
905 : 0 : OUString aDefault( getString( STR_MY_SETTINGS ) );
906 : 0 : sal_Int32 nSession = 1;
907 : : sal_uInt32 i;
908 : 0 : const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
909 : 0 : do
910 : : {
911 : 0 : OUString aTemp( aDefault.concat( OUString::valueOf( nSession++ ) ) );
912 : 0 : for ( i = 1; i < rList.size(); i++ )
913 : : {
914 : 0 : if ( rList[ i ].maName == aTemp )
915 : 0 : break;
916 : : }
917 : 0 : if ( i == rList.size() )
918 : 0 : aSettingsName = aTemp;
919 : : }
920 : : while( aSettingsName.isEmpty() );
921 : :
922 : 0 : setControlProperty( TKGet( TK_ComboBox0Pg4 ), TKGet( TK_Text ), Any( aSettingsName ) );
923 : 0 : setControlProperty( TKGet( TK_RadioButton0Pg4 ), TKGet( TK_Enabled ), Any( !mbIsReadonly ) );
924 : 0 : setControlProperty( TKGet( TK_RadioButton1Pg4 ), TKGet( TK_Enabled ), Any( !mbIsReadonly ) );
925 : :
926 : 0 : UpdateControlStatesPage4();
927 : 0 : }
928 : :
929 : : // -----------------------------------------------------------------------------
930 : 0 : void OptimizerDialog::EnablePage( sal_Int16 nStep )
931 : : {
932 : 0 : std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
933 : 0 : std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
934 : 0 : while( aBeg != aEnd )
935 : 0 : setControlProperty( *aBeg++, TKGet( TK_Enabled ), Any( sal_True ) );
936 : 0 : }
937 : 0 : void OptimizerDialog::DisablePage( sal_Int16 nStep )
938 : : {
939 : 0 : std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
940 : 0 : std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
941 : 0 : while( aBeg != aEnd )
942 : 0 : setControlProperty( *aBeg++, TKGet( TK_Enabled ), Any( sal_False ) );
943 : 0 : }
944 : 0 : void OptimizerDialog::ActivatePage( sal_Int16 nStep )
945 : : {
946 : 0 : std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
947 : 0 : std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
948 : 0 : while( aBeg != aEnd )
949 : 0 : setVisible( *aBeg++, sal_True );
950 : 0 : }
951 : 0 : void OptimizerDialog::DeactivatePage( sal_Int16 nStep )
952 : : {
953 : 0 : std::vector< rtl::OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
954 : 0 : std::vector< rtl::OUString >::iterator aEnd( maControlPages[ nStep ].end() );
955 : 0 : while( aBeg != aEnd )
956 : 0 : setVisible( *aBeg++, sal_False );
957 : 0 : }
958 : :
959 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|