fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / dlg / tpoption.cxx
blob57ad7bb3be3ba980de72f771d8caa5c6d21fa726
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
21 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
22 #include <com/sun/star/frame/Desktop.hpp>
23 #include <com/sun/star/lang/XComponent.hpp>
24 #include <com/sun/star/container/XEnumerationAccess.hpp>
25 #include <comphelper/processfactory.hxx>
26 #include <comphelper/string.hxx>
27 #include <com/sun/star/uno/Exception.hpp>
28 #include <sfx2/module.hxx>
29 #include <sfx2/app.hxx>
30 #include <svx/svxids.hrc>
31 #include <svx/dialogs.hrc>
32 #include <svx/strarray.hxx>
33 #include <svx/dlgutil.hxx>
34 #include <vcl/msgbox.hxx>
36 #include "sdattr.hxx"
37 #include "sdresid.hxx"
38 #include "optsitem.hxx"
39 #include "tpoption.hrc"
40 #include "tpoption.hxx"
41 #include "strings.hrc"
42 #include "app.hrc"
43 #include <svl/intitem.hxx>
44 #include <sfx2/request.hxx>
46 using namespace ::com::sun::star;
47 using namespace ::com::sun::star::uno;
49 SdTpOptionsSnap::SdTpOptionsSnap( Window* pParent, const SfxItemSet& rInAttrs ) :
50 SvxGridTabPage(pParent, rInAttrs)
52 aGrpSnap.Show();
53 aCbxSnapHelplines.Show();
54 aCbxSnapBorder.Show();
55 aCbxSnapFrame.Show();
56 aCbxSnapPoints.Show();
57 aFtSnapArea.Show();
58 aMtrFldSnapArea.Show();
59 aGrpOrtho.Show();
60 aCbxOrtho.Show();
61 aCbxBigOrtho.Show();
62 aCbxRotate.Show();
63 aMtrFldAngle.Show();
64 aFtBezAngle.Show();
65 aMtrFldBezAngle.Show();
66 aSeparatorFL.Show();
69 // -----------------------------------------------------------------------
71 SdTpOptionsSnap::~SdTpOptionsSnap()
75 // -----------------------------------------------------------------------
77 sal_Bool SdTpOptionsSnap::FillItemSet( SfxItemSet& rAttrs )
79 SvxGridTabPage::FillItemSet(rAttrs);
80 SdOptionsSnapItem aOptsItem( ATTR_OPTIONS_SNAP );
82 aOptsItem.GetOptionsSnap().SetSnapHelplines( aCbxSnapHelplines.IsChecked() );
83 aOptsItem.GetOptionsSnap().SetSnapBorder( aCbxSnapBorder.IsChecked() );
84 aOptsItem.GetOptionsSnap().SetSnapFrame( aCbxSnapFrame.IsChecked() );
85 aOptsItem.GetOptionsSnap().SetSnapPoints( aCbxSnapPoints.IsChecked() );
86 aOptsItem.GetOptionsSnap().SetOrtho( aCbxOrtho.IsChecked() );
87 aOptsItem.GetOptionsSnap().SetBigOrtho( aCbxBigOrtho.IsChecked() );
88 aOptsItem.GetOptionsSnap().SetRotate( aCbxRotate.IsChecked() );
89 aOptsItem.GetOptionsSnap().SetSnapArea( (sal_Int16) aMtrFldSnapArea.GetValue() );
90 aOptsItem.GetOptionsSnap().SetAngle( (sal_Int16) aMtrFldAngle.GetValue() );
91 aOptsItem.GetOptionsSnap().SetEliminatePolyPointLimitAngle( (sal_Int16) aMtrFldBezAngle.GetValue() );
93 rAttrs.Put( aOptsItem );
95 // we get a possible existing GridItem, this ensures that we do net set
96 // some default values by accident
97 return( sal_True );
100 // -----------------------------------------------------------------------
102 void SdTpOptionsSnap::Reset( const SfxItemSet& rAttrs )
104 SvxGridTabPage::Reset(rAttrs);
106 SdOptionsSnapItem aOptsItem( (const SdOptionsSnapItem&) rAttrs.
107 Get( ATTR_OPTIONS_SNAP ) );
109 aCbxSnapHelplines.Check( aOptsItem.GetOptionsSnap().IsSnapHelplines() );
110 aCbxSnapBorder.Check( aOptsItem.GetOptionsSnap().IsSnapBorder() );
111 aCbxSnapFrame.Check( aOptsItem.GetOptionsSnap().IsSnapFrame() );
112 aCbxSnapPoints.Check( aOptsItem.GetOptionsSnap().IsSnapPoints() );
113 aCbxOrtho.Check( aOptsItem.GetOptionsSnap().IsOrtho() );
114 aCbxBigOrtho.Check( aOptsItem.GetOptionsSnap().IsBigOrtho() );
115 aCbxRotate.Check( aOptsItem.GetOptionsSnap().IsRotate() );
116 aMtrFldSnapArea.SetValue( aOptsItem.GetOptionsSnap().GetSnapArea() );
117 aMtrFldAngle.SetValue( aOptsItem.GetOptionsSnap().GetAngle() );
118 aMtrFldBezAngle.SetValue( aOptsItem.GetOptionsSnap().GetEliminatePolyPointLimitAngle() );
120 aCbxRotate.GetClickHdl().Call(0);
123 // -----------------------------------------------------------------------
125 SfxTabPage* SdTpOptionsSnap::Create( Window* pWindow,
126 const SfxItemSet& rAttrs )
128 return( new SdTpOptionsSnap( pWindow, rAttrs ) );
131 /*************************************************************************
133 |* TabPage to adjust the content options
135 \************************************************************************/
137 SdTpOptionsContents::SdTpOptionsContents( Window* pParent, const SfxItemSet& rInAttrs ) :
138 SfxTabPage ( pParent, SdResId( TP_OPTIONS_CONTENTS ), rInAttrs ),
139 aGrpDisplay ( this, SdResId( GRP_DISPLAY ) ),
140 aCbxRuler ( this, SdResId( CBX_RULER ) ),
141 aCbxDragStripes ( this, SdResId( CBX_HELPLINES ) ),
142 aCbxHandlesBezier ( this, SdResId( CBX_HANDLES_BEZIER ) ),
143 aCbxMoveOutline ( this, SdResId( CBX_MOVE_OUTLINE ) )
145 FreeResource();
148 // -----------------------------------------------------------------------
150 SdTpOptionsContents::~SdTpOptionsContents()
154 // -----------------------------------------------------------------------
156 sal_Bool SdTpOptionsContents::FillItemSet( SfxItemSet& rAttrs )
158 sal_Bool bModified = sal_False;
160 if( aCbxRuler.GetSavedValue() != aCbxRuler.IsChecked() ||
161 aCbxMoveOutline.GetSavedValue() != aCbxMoveOutline.IsChecked() ||
162 aCbxDragStripes.GetSavedValue() != aCbxDragStripes.IsChecked() ||
163 aCbxHandlesBezier.GetSavedValue() != aCbxHandlesBezier.IsChecked() )
165 SdOptionsLayoutItem aOptsItem( ATTR_OPTIONS_LAYOUT );
167 aOptsItem.GetOptionsLayout().SetRulerVisible( aCbxRuler.IsChecked() );
168 aOptsItem.GetOptionsLayout().SetMoveOutline( aCbxMoveOutline.IsChecked() );
169 aOptsItem.GetOptionsLayout().SetDragStripes( aCbxDragStripes.IsChecked() );
170 aOptsItem.GetOptionsLayout().SetHandlesBezier( aCbxHandlesBezier.IsChecked() );
172 rAttrs.Put( aOptsItem );
173 bModified = sal_True;
175 return( bModified );
178 // -----------------------------------------------------------------------
180 void SdTpOptionsContents::Reset( const SfxItemSet& rAttrs )
182 SdOptionsContentsItem aOptsItem( (const SdOptionsContentsItem&) rAttrs.
183 Get( ATTR_OPTIONS_CONTENTS ) );
185 SdOptionsLayoutItem aLayoutItem( (const SdOptionsLayoutItem&) rAttrs.
186 Get( ATTR_OPTIONS_LAYOUT ) );
188 aCbxRuler.Check( aLayoutItem.GetOptionsLayout().IsRulerVisible() );
189 aCbxMoveOutline.Check( aLayoutItem.GetOptionsLayout().IsMoveOutline() );
190 aCbxDragStripes.Check( aLayoutItem.GetOptionsLayout().IsDragStripes() );
191 aCbxHandlesBezier.Check( aLayoutItem.GetOptionsLayout().IsHandlesBezier() );
193 aCbxRuler.SaveValue();
194 aCbxMoveOutline.SaveValue();
195 aCbxDragStripes.SaveValue();
196 aCbxHandlesBezier.SaveValue();
199 // -----------------------------------------------------------------------
201 SfxTabPage* SdTpOptionsContents::Create( Window* pWindow,
202 const SfxItemSet& rAttrs )
204 return( new SdTpOptionsContents( pWindow, rAttrs ) );
207 /*************************************************************************
209 |* TabPage to adjust the misc options
211 \************************************************************************/
212 #define TABLE_COUNT 12
213 #define TOKEN (sal_Unicode(':'))
215 SdTpOptionsMisc::SdTpOptionsMisc( Window* pParent, const SfxItemSet& rInAttrs ) :
216 SfxTabPage ( pParent, SdResId( TP_OPTIONS_MISC ), rInAttrs ),
217 aGrpText ( this, SdResId( GRP_TEXT ) ),
218 aCbxQuickEdit ( this, SdResId( CBX_QUICKEDIT ) ),
219 aCbxPickThrough ( this, SdResId( CBX_PICKTHROUGH ) ),
221 // At the moment, template & layout are not running synchronized
222 aGrpProgramStart ( this, SdResId( GRP_PROGRAMSTART ) ),
223 aCbxStartWithTemplate ( this, SdResId( CBX_START_WITH_TEMPLATE ) ),
225 aGrpSettings ( this, SdResId( GRP_SETTINGS ) ),
226 aCbxMasterPageCache ( this, SdResId( CBX_MASTERPAGE_CACHE ) ),
227 aCbxCopy ( this, SdResId( CBX_COPY ) ),
228 aCbxMarkedHitMovesAlways ( this, SdResId( CBX_MARKED_HIT_MOVES_ALWAYS ) ),
229 aCbxCrookNoContortion ( this, SdResId( CBX_CROOK_NO_CONTORTION ) ),
231 aTxtMetric ( this, SdResId( FT_METRIC ) ),
232 aLbMetric ( this, SdResId( LB_METRIC ) ),
233 aTxtTabstop ( this, SdResId( FT_TABSTOP ) ),
234 aMtrFldTabstop ( this, SdResId( MTR_FLD_TABSTOP ) ),
236 aCbxStartWithActualPage ( this, SdResId( CBX_START_WITH_ACTUAL_PAGE ) ),
237 aGrpStartWithActualPage ( this, SdResId( GRP_START_WITH_ACTUAL_PAGE ) ),
238 aCbxEnableSdremote ( this, SdResId( CBX_ENABLE_SDREMOTE ) ),
239 aCbxEnablePresenterScreen ( this, SdResId( CBX_ENABLE_PRESENTER_SCREEN ) ),
240 aTxtCompatibility ( this, SdResId( FT_COMPATIBILITY ) ),
241 aCbxUsePrinterMetrics ( this, SdResId( CB_USE_PRINTER_METRICS ) ),
242 aCbxCompatibility ( this, SdResId( CB_MERGE_PARA_DIST ) ),
243 aGrpScale ( this, SdResId( GRP_SCALE ) ),
244 aFtScale ( this, SdResId( FT_SCALE ) ),
245 aCbScale ( this, SdResId( CB_SCALE ) ),
246 aFtOriginal ( this, SdResId( FT_ORIGINAL ) ),
247 aFtEquivalent ( this, SdResId( FT_EQUIVALENT ) ),
248 aFtPageWidth ( this, SdResId( FT_PAGEWIDTH ) ),
249 aFiInfo1 ( this, SdResId( FI_INFO_1 ) ),
250 aMtrFldOriginalWidth ( this, SdResId( MTR_FLD_ORIGINAL_WIDTH ) ),
251 aFtPageHeight ( this, SdResId( FT_PAGEHEIGHT ) ),
252 aFiInfo2 ( this, SdResId( FI_INFO_2 ) ),
253 aMtrFldOriginalHeight ( this, SdResId( MTR_FLD_ORIGINAL_HEIGHT ) ),
254 aMtrFldInfo1 ( this, WinBits( WB_HIDE ) ),
255 aMtrFldInfo2 ( this, WinBits( WB_HIDE ) )
257 FreeResource();
258 SetExchangeSupport();
260 // set metric
261 FieldUnit eFUnit;
263 sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC );
264 if ( rInAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
266 const SfxUInt16Item& rItem = (SfxUInt16Item&)rInAttrs.Get( nWhich );
267 eFUnit = (FieldUnit)rItem.GetValue();
269 else
270 eFUnit = SfxModule::GetCurrentFieldUnit();
272 SetFieldUnit( aMtrFldTabstop, eFUnit );
274 // fill ListBox with metrics
275 SvxStringArray aMetricArr( RID_SVXSTR_FIELDUNIT_TABLE );
276 sal_uInt16 i;
278 for ( i = 0; i < aMetricArr.Count(); ++i )
280 String sMetric = aMetricArr.GetStringByPos( i );
281 long nFieldUnit = aMetricArr.GetValue( i );
282 sal_uInt16 nPos = aLbMetric.InsertEntry( sMetric );
283 aLbMetric.SetEntryData( nPos, (void*)nFieldUnit );
285 aLbMetric.SetSelectHdl( LINK( this, SdTpOptionsMisc, SelectMetricHdl_Impl ) );
287 SetFieldUnit( aMtrFldOriginalWidth, eFUnit );
288 SetFieldUnit( aMtrFldOriginalHeight, eFUnit );
289 aMtrFldOriginalWidth.SetLast( 999999999 );
290 aMtrFldOriginalWidth.SetMax( 999999999 );
291 aMtrFldOriginalHeight.SetLast( 999999999 );
292 aMtrFldOriginalHeight.SetMax( 999999999 );
294 // temporary fields for info texts (for formatting/calculation)
295 aMtrFldInfo1.SetUnit( eFUnit );
296 aMtrFldInfo1.SetMax( 999999999 );
297 aMtrFldInfo1.SetDecimalDigits( 2 );
298 aMtrFldInfo2.SetUnit( eFUnit );
299 aMtrFldInfo2.SetMax( 999999999 );
300 aMtrFldInfo2.SetDecimalDigits( 2 );
302 // determine PoolUnit
303 SfxItemPool* pPool = rInAttrs.GetPool();
304 DBG_ASSERT( pPool, "Where is the Pool?" );
305 ePoolUnit = pPool->GetMetric( SID_ATTR_FILL_HATCH );
307 // Fuellen der CB
308 sal_uInt16 aTable[ TABLE_COUNT ] =
309 { 1, 2, 4, 5, 8, 10, 16, 20, 30, 40, 50, 100 };
311 for( i = 0; i < TABLE_COUNT; i++ )
312 aCbScale.InsertEntry( GetScale( 1, aTable[i] ) );
313 for( i = 1; i < TABLE_COUNT; i++ )
314 aCbScale.InsertEntry( GetScale( aTable[i], 1 ) );
317 // -----------------------------------------------------------------------
319 SdTpOptionsMisc::~SdTpOptionsMisc()
322 // -----------------------------------------------------------------------
323 void SdTpOptionsMisc::ActivatePage( const SfxItemSet& rSet )
325 // We have to call SaveValue again since it can happen that the value
326 // has no effect on other TabPages
327 aLbMetric.SaveValue();
328 // change metric if necessary (since TabPage is in the Dialog where
329 // the metric is set)
330 const SfxPoolItem* pAttr = NULL;
331 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC , sal_False,
332 (const SfxPoolItem**)&pAttr ))
334 const SfxUInt16Item* pItem = (SfxUInt16Item*) pAttr;
336 FieldUnit eFUnit = (FieldUnit)(long)pItem->GetValue();
338 if( eFUnit != aMtrFldOriginalWidth.GetUnit() )
340 // set metrics
341 sal_Int64 nVal = aMtrFldOriginalWidth.Denormalize( aMtrFldOriginalWidth.GetValue( FUNIT_TWIP ) );
342 SetFieldUnit( aMtrFldOriginalWidth, eFUnit, sal_True );
343 aMtrFldOriginalWidth.SetValue( aMtrFldOriginalWidth.Normalize( nVal ), FUNIT_TWIP );
345 nVal = aMtrFldOriginalHeight.Denormalize( aMtrFldOriginalHeight.GetValue( FUNIT_TWIP ) );
346 SetFieldUnit( aMtrFldOriginalHeight, eFUnit, sal_True );
347 aMtrFldOriginalHeight.SetValue( aMtrFldOriginalHeight.Normalize( nVal ), FUNIT_TWIP );
350 if( nWidth != 0 && nHeight != 0 )
352 aMtrFldInfo1.SetUnit( eFUnit );
353 aMtrFldInfo2.SetUnit( eFUnit );
355 SetMetricValue( aMtrFldInfo1, nWidth, ePoolUnit );
356 aInfo1 = aMtrFldInfo1.GetText();
357 aFiInfo1.SetText( aInfo1 );
359 SetMetricValue( aMtrFldInfo2, nHeight, ePoolUnit );
360 aInfo2 = aMtrFldInfo2.GetText();
361 aFiInfo2.SetText( aInfo2 );
367 // -----------------------------------------------------------------------
369 int SdTpOptionsMisc::DeactivatePage( SfxItemSet* pActiveSet )
371 // check parser
372 sal_Int32 nX, nY;
373 if( SetScale( aCbScale.GetText(), nX, nY ) )
375 if( pActiveSet )
376 FillItemSet( *pActiveSet );
377 return( LEAVE_PAGE );
379 WarningBox aWarnBox( GetParent(), WB_YES_NO, String( SdResId( STR_WARN_SCALE_FAIL ) ) );
380 short nReturn = aWarnBox.Execute();
382 if( nReturn == RET_YES )
383 return( KEEP_PAGE );
385 if( pActiveSet )
386 FillItemSet( *pActiveSet );
388 return( LEAVE_PAGE );
391 // -----------------------------------------------------------------------
393 sal_Bool SdTpOptionsMisc::FillItemSet( SfxItemSet& rAttrs )
395 sal_Bool bModified = sal_False;
397 if( aCbxStartWithTemplate.GetSavedValue() != aCbxStartWithTemplate.IsChecked() ||
398 aCbxMarkedHitMovesAlways.GetSavedValue()!= aCbxMarkedHitMovesAlways.IsChecked() ||
399 aCbxCrookNoContortion.GetSavedValue() != aCbxCrookNoContortion.IsChecked() ||
400 aCbxQuickEdit.GetSavedValue() != aCbxQuickEdit.IsChecked() ||
401 aCbxPickThrough.GetSavedValue() != aCbxPickThrough.IsChecked() ||
402 aCbxMasterPageCache.GetSavedValue() != aCbxMasterPageCache.IsChecked() ||
403 aCbxCopy.GetSavedValue() != aCbxCopy.IsChecked() ||
404 aCbxStartWithActualPage.GetSavedValue() != aCbxStartWithActualPage.IsChecked() ||
405 aCbxEnableSdremote.GetSavedValue() != aCbxEnableSdremote.IsChecked() ||
406 aCbxEnablePresenterScreen.GetSavedValue()!= aCbxEnablePresenterScreen.IsChecked() ||
407 aCbxCompatibility.GetSavedValue() != aCbxCompatibility.IsChecked() ||
408 aCbxUsePrinterMetrics.GetSavedValue() != aCbxUsePrinterMetrics.IsChecked() )
410 SdOptionsMiscItem aOptsItem( ATTR_OPTIONS_MISC );
412 aOptsItem.GetOptionsMisc().SetStartWithTemplate( aCbxStartWithTemplate.IsChecked() );
413 aOptsItem.GetOptionsMisc().SetMarkedHitMovesAlways( aCbxMarkedHitMovesAlways.IsChecked() );
414 aOptsItem.GetOptionsMisc().SetCrookNoContortion( aCbxCrookNoContortion.IsChecked() );
415 aOptsItem.GetOptionsMisc().SetQuickEdit( aCbxQuickEdit.IsChecked() );
416 aOptsItem.GetOptionsMisc().SetPickThrough( aCbxPickThrough.IsChecked() );
417 aOptsItem.GetOptionsMisc().SetMasterPagePaintCaching( aCbxMasterPageCache.IsChecked() );
418 aOptsItem.GetOptionsMisc().SetDragWithCopy( aCbxCopy.IsChecked() );
419 aOptsItem.GetOptionsMisc().SetStartWithActualPage( aCbxStartWithActualPage.IsChecked() );
420 aOptsItem.GetOptionsMisc().SetEnableSdremote( aCbxEnableSdremote.IsChecked() );
421 aOptsItem.GetOptionsMisc().SetEnablePresenterScreen( aCbxEnablePresenterScreen.IsChecked() );
422 aOptsItem.GetOptionsMisc().SetSummationOfParagraphs( aCbxCompatibility.IsChecked() );
423 aOptsItem.GetOptionsMisc().SetPrinterIndependentLayout (
424 aCbxUsePrinterMetrics.IsChecked()
425 ? ::com::sun::star::document::PrinterIndependentLayout::DISABLED
426 : ::com::sun::star::document::PrinterIndependentLayout::ENABLED);
427 rAttrs.Put( aOptsItem );
429 bModified = sal_True;
432 // metric
433 const sal_uInt16 nMPos = aLbMetric.GetSelectEntryPos();
434 if ( nMPos != aLbMetric.GetSavedValue() )
436 sal_uInt16 nFieldUnit = (sal_uInt16)(long)aLbMetric.GetEntryData( nMPos );
437 rAttrs.Put( SfxUInt16Item( GetWhich( SID_ATTR_METRIC ),
438 (sal_uInt16)nFieldUnit ) );
439 bModified |= sal_True;
442 // tabulator space
443 if( aMtrFldTabstop.GetText() != aMtrFldTabstop.GetSavedValue() )
445 sal_uInt16 nWh = GetWhich( SID_ATTR_DEFTABSTOP );
446 SfxMapUnit eUnit = rAttrs.GetPool()->GetMetric( nWh );
447 SfxUInt16Item aDef( nWh,(sal_uInt16)GetCoreValue( aMtrFldTabstop, eUnit ) );
448 rAttrs.Put( aDef );
449 bModified |= sal_True;
452 sal_Int32 nX, nY;
453 if( SetScale( aCbScale.GetText(), nX, nY ) )
455 rAttrs.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
456 rAttrs.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
458 bModified = sal_True;
461 return( bModified );
464 // -----------------------------------------------------------------------
466 void SdTpOptionsMisc::Reset( const SfxItemSet& rAttrs )
468 SdOptionsMiscItem aOptsItem( (const SdOptionsMiscItem&) rAttrs.
469 Get( ATTR_OPTIONS_MISC ) );
471 aCbxStartWithTemplate.Check( aOptsItem.GetOptionsMisc().IsStartWithTemplate() );
472 aCbxMarkedHitMovesAlways.Check( aOptsItem.GetOptionsMisc().IsMarkedHitMovesAlways() );
473 aCbxCrookNoContortion.Check( aOptsItem.GetOptionsMisc().IsCrookNoContortion() );
474 aCbxQuickEdit.Check( aOptsItem.GetOptionsMisc().IsQuickEdit() );
475 aCbxPickThrough.Check( aOptsItem.GetOptionsMisc().IsPickThrough() );
476 aCbxMasterPageCache.Check( aOptsItem.GetOptionsMisc().IsMasterPagePaintCaching() );
477 aCbxCopy.Check( aOptsItem.GetOptionsMisc().IsDragWithCopy() );
478 aCbxStartWithActualPage.Check( aOptsItem.GetOptionsMisc().IsStartWithActualPage() );
479 aCbxEnableSdremote.Check( aOptsItem.GetOptionsMisc().IsEnableSdremote() );
480 aCbxEnablePresenterScreen.Check( aOptsItem.GetOptionsMisc().IsEnablePresenterScreen() );
481 aCbxCompatibility.Check( aOptsItem.GetOptionsMisc().IsSummationOfParagraphs() );
482 aCbxUsePrinterMetrics.Check( aOptsItem.GetOptionsMisc().GetPrinterIndependentLayout()==1 );
483 aCbxStartWithTemplate.SaveValue();
484 aCbxMarkedHitMovesAlways.SaveValue();
485 aCbxCrookNoContortion.SaveValue();
486 aCbxQuickEdit.SaveValue();
487 aCbxPickThrough.SaveValue();
489 aCbxMasterPageCache.SaveValue();
490 aCbxCopy.SaveValue();
491 aCbxEnableSdremote.SaveValue();
492 aCbxEnablePresenterScreen.SaveValue();
493 aCbxCompatibility.SaveValue();
494 aCbxUsePrinterMetrics.SaveValue();
496 // metric
497 sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC );
498 aLbMetric.SetNoSelection();
500 if ( rAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
502 const SfxUInt16Item& rItem = (SfxUInt16Item&)rAttrs.Get( nWhich );
503 long nFieldUnit = (long)rItem.GetValue();
505 for ( sal_uInt16 i = 0; i < aLbMetric.GetEntryCount(); ++i )
507 if ( (long)aLbMetric.GetEntryData( i ) == nFieldUnit )
509 aLbMetric.SelectEntryPos( i );
510 break;
515 // tabulator space
516 nWhich = GetWhich( SID_ATTR_DEFTABSTOP );
517 if( rAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
519 SfxMapUnit eUnit = rAttrs.GetPool()->GetMetric( nWhich );
520 const SfxUInt16Item& rItem = (SfxUInt16Item&)rAttrs.Get( nWhich );
521 SetMetricValue( aMtrFldTabstop, rItem.GetValue(), eUnit );
523 aLbMetric.SaveValue();
524 aMtrFldTabstop.SaveValue();
525 //Scale
526 sal_Int32 nX = ( (const SfxInt32Item&) rAttrs.
527 Get( ATTR_OPTIONS_SCALE_X ) ).GetValue();
528 sal_Int32 nY = ( (const SfxInt32Item&) rAttrs.
529 Get( ATTR_OPTIONS_SCALE_Y ) ).GetValue();
530 nWidth = ( (const SfxUInt32Item&) rAttrs.
531 Get( ATTR_OPTIONS_SCALE_WIDTH ) ).GetValue();
532 nHeight = ( (const SfxUInt32Item&) rAttrs.
533 Get( ATTR_OPTIONS_SCALE_HEIGHT ) ).GetValue();
535 aCbScale.SetText( GetScale( nX, nY ) );
537 aFtOriginal.Hide();
538 aFtEquivalent.Hide();
539 aMtrFldOriginalWidth.Hide();
540 aMtrFldOriginalWidth.SetText( aInfo1 ); // empty
541 aMtrFldOriginalHeight.Hide();
542 aMtrFldOriginalHeight.SetText( aInfo2 ); //empty
543 aFtPageWidth.Hide();
544 aFtPageHeight.Hide();
545 aFiInfo1.Hide();
546 aFiInfo2.Hide();
548 UpdateCompatibilityControls ();
551 // -----------------------------------------------------------------------
553 SfxTabPage* SdTpOptionsMisc::Create( Window* pWindow,
554 const SfxItemSet& rAttrs )
556 return( new SdTpOptionsMisc( pWindow, rAttrs ) );
558 //------------------------------------------------------------------------
560 IMPL_LINK_NOARG(SdTpOptionsMisc, SelectMetricHdl_Impl)
562 sal_uInt16 nPos = aLbMetric.GetSelectEntryPos();
564 if( nPos != LISTBOX_ENTRY_NOTFOUND )
566 FieldUnit eUnit = (FieldUnit)(long)aLbMetric.GetEntryData( nPos );
567 sal_Int64 nVal =
568 aMtrFldTabstop.Denormalize( aMtrFldTabstop.GetValue( FUNIT_TWIP ) );
569 SetFieldUnit( aMtrFldTabstop, eUnit );
570 aMtrFldTabstop.SetValue( aMtrFldTabstop.Normalize( nVal ), FUNIT_TWIP );
572 return 0;
576 namespace {
577 void lcl_MoveWin( Window& rWin, long nYDiff)
579 Point aPos(rWin.GetPosPixel());
580 aPos.Y() += nYDiff;
581 rWin.SetPosPixel (aPos);
584 void lcl_MoveWin( Window& rWin, long nXdiff, long nYdiff)
586 Point aPos(rWin.GetPosPixel());
587 aPos.X() += nXdiff;
588 aPos.Y() += nYdiff;
589 rWin.SetPosPixel(aPos);
593 void SdTpOptionsMisc::SetImpressMode (void)
595 long nDialogWidth = GetSizePixel().Width();
596 long nLineHeight = aCbxPickThrough.GetPosPixel().Y()
597 - aCbxQuickEdit.GetPosPixel().Y();
599 // Put both "Text objects" check boxes side by side.
600 lcl_MoveWin (aCbxPickThrough,
601 nDialogWidth/2 - aCbxPickThrough.GetPosPixel().X(),
602 -nLineHeight);
604 // Move the other controls up one line.
605 lcl_MoveWin (aGrpProgramStart, -nLineHeight);
606 lcl_MoveWin (aCbxStartWithTemplate, -nLineHeight);
607 lcl_MoveWin (aGrpSettings, -nLineHeight);
608 lcl_MoveWin (aCbxMasterPageCache, -nLineHeight);
609 lcl_MoveWin (aCbxCopy, -nLineHeight);
610 lcl_MoveWin (aCbxMarkedHitMovesAlways, -nLineHeight);
611 lcl_MoveWin (aCbxCrookNoContortion, -nLineHeight);
612 lcl_MoveWin (aTxtMetric, -nLineHeight);
613 lcl_MoveWin (aLbMetric, -nLineHeight);
614 lcl_MoveWin (aTxtTabstop, -nLineHeight);
615 lcl_MoveWin (aMtrFldTabstop, -nLineHeight);
616 lcl_MoveWin (aGrpStartWithActualPage, -nLineHeight);
617 lcl_MoveWin (aCbxStartWithActualPage, -nLineHeight);
618 lcl_MoveWin (aCbxEnableSdremote, -nLineHeight);
619 lcl_MoveWin (aCbxEnablePresenterScreen,
620 nDialogWidth/2 - aCbxEnablePresenterScreen.GetPosPixel().X(),
621 -2*nLineHeight);
622 lcl_MoveWin (aTxtCompatibility, -nLineHeight);
624 // Move the printer-independent-metrics check box up two lines to change
625 // places with spacing-between-paragraphs check box.
626 lcl_MoveWin (aCbxUsePrinterMetrics, -2*nLineHeight);
627 #ifndef ENABLE_SDREMOTE_BLUETOOTH
628 aCbxEnableSdremote.Hide();
629 #endif
632 void SdTpOptionsMisc::SetDrawMode()
634 aCbxStartWithTemplate.Hide();
635 aGrpProgramStart.Hide();
636 aCbxStartWithActualPage.Hide();
637 aCbxEnableSdremote.Hide();
638 aCbxEnablePresenterScreen.Hide();
639 aCbxCompatibility.Hide();
640 aGrpStartWithActualPage.Hide();
641 aCbxCrookNoContortion.Show();
643 aGrpScale.Show();
644 aFtScale.Show();
645 aCbScale.Show();
647 aFtOriginal.Show();
648 aFtEquivalent.Show();
650 aFtPageWidth.Show();
651 aFiInfo1.Show();
652 aMtrFldOriginalWidth.Show();
654 aFtPageHeight.Show();
655 aFiInfo2.Show();
656 aMtrFldOriginalHeight.Show();
658 long nDiff = aGrpSettings.GetPosPixel().Y() - aGrpProgramStart.GetPosPixel().Y();
659 lcl_MoveWin( aGrpSettings, -nDiff );
660 lcl_MoveWin( aCbxMasterPageCache, -nDiff );
661 lcl_MoveWin( aCbxCopy, -nDiff );
662 lcl_MoveWin( aCbxMarkedHitMovesAlways, -nDiff );
663 lcl_MoveWin( aCbxCrookNoContortion, -nDiff );
664 nDiff -= aCbxCrookNoContortion.GetPosPixel().Y() - aCbxMarkedHitMovesAlways.GetPosPixel().Y();
665 lcl_MoveWin( aTxtMetric, -nDiff );
666 lcl_MoveWin( aLbMetric, -nDiff );
667 lcl_MoveWin( aTxtTabstop, -nDiff );
668 lcl_MoveWin( aMtrFldTabstop, -nDiff );
670 // Move the scale controls so that they are visually centered between the
671 // group controls above and below.
672 lcl_MoveWin (aFtScale, -17);
673 lcl_MoveWin (aCbScale, -17);
675 // Move the printer-independent-metrics check box in the place that the
676 // spacing-between-paragraphs check box normally is in.
677 aCbxUsePrinterMetrics.SetPosPixel (aCbxCompatibility.GetPosPixel());
680 // -----------------------------------------------------------------------
682 String SdTpOptionsMisc::GetScale( sal_Int32 nX, sal_Int32 nY )
684 String aScale( OUString::valueOf( nX ) );
685 aScale.Append( TOKEN );
686 aScale.Append( OUString::valueOf( nY ) );
688 return( aScale );
691 // -----------------------------------------------------------------------
693 sal_Bool SdTpOptionsMisc::SetScale( const String& aScale, sal_Int32& rX, sal_Int32& rY )
695 if( comphelper::string::getTokenCount(aScale, TOKEN) != 2 )
696 return( sal_False );
698 OUString aTmp(aScale.GetToken( 0, TOKEN ));
699 if (!comphelper::string::isdigitAsciiString(aTmp))
700 return sal_False;
702 rX = (long) aTmp.toInt32();
703 if( rX == 0 )
704 return( sal_False );
706 aTmp = aScale.GetToken( 1, TOKEN );
707 if (!comphelper::string::isdigitAsciiString(aTmp))
708 return sal_False;
710 rY = (long) aTmp.toInt32();
711 if( rY == 0 )
712 return sal_False;
714 return sal_True;
717 void SdTpOptionsMisc::UpdateCompatibilityControls (void)
719 // Disable the compatibility controls by default. Enable them only when
720 // there is at least one open document.
721 sal_Bool bIsEnabled = sal_False;
725 // Get a component enumeration from the desktop and search it for documents.
726 Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext());
729 Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(xContext);
731 Reference<container::XEnumerationAccess> xComponents (
732 xDesktop->getComponents(), UNO_QUERY);
733 if ( ! xComponents.is())
734 break;
736 Reference<container::XEnumeration> xEnumeration (
737 xComponents->createEnumeration());
738 if ( ! xEnumeration.is())
739 break;
741 while (xEnumeration->hasMoreElements())
743 Reference<frame::XModel> xModel (xEnumeration->nextElement(), UNO_QUERY);
744 if (xModel.is())
746 // There is at leas one model/document: Enable the compatibility controls.
747 bIsEnabled = sal_True;
748 break;
753 while (false); // One 'loop'.
755 catch (const uno::Exception&)
757 // When there is an exception then simply use the default value of
758 // bIsEnabled and disable the controls.
761 aTxtCompatibility.Enable (bIsEnabled);
762 aCbxCompatibility.Enable(bIsEnabled);
763 aCbxUsePrinterMetrics.Enable (bIsEnabled);
766 void SdTpOptionsMisc::PageCreated (SfxAllItemSet aSet)
768 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_SDMODE_FLAG,sal_False);
769 if (pFlagItem)
771 sal_uInt32 nFlags=pFlagItem->GetValue();
772 if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE )
773 SetDrawMode();
774 if ( ( nFlags & SD_IMPRESS_MODE ) == SD_IMPRESS_MODE )
775 SetImpressMode();
779 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */