1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tpoption.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #ifdef SD_DLLIMPLEMENTATION
35 #undef SD_DLLIMPLEMENTATION
39 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/frame/XDesktop.hpp>
42 #include <com/sun/star/lang/XComponent.hpp>
43 #include <com/sun/star/container/XEnumerationAccess.hpp>
44 #include <comphelper/processfactory.hxx>
45 #include <com/sun/star/uno/Exception.hpp>
46 #include <sfx2/module.hxx>
47 #include <sfx2/app.hxx>
48 #include <svx/svxids.hrc>
49 #include <svx/dialogs.hrc>
50 #include <svx/strarray.hxx>
51 #include <svx/dlgutil.hxx>
52 #include <vcl/msgbox.hxx>
55 #include "sdresid.hxx"
56 #include "optsitem.hxx"
57 #include "tpoption.hrc"
58 #include "tpoption.hxx"
59 #include "strings.hrc"
61 #include <svtools/intitem.hxx>
62 #include <sfx2/request.hxx>
63 #define DLGWIN this->GetParent()->GetParent()
65 using namespace ::com::sun::star
;
66 using namespace ::com::sun::star::uno
;
68 /*************************************************************************
70 |* TabPage zum Einstellen der Fang-Optionen
72 \************************************************************************/
74 SdTpOptionsSnap::SdTpOptionsSnap( Window
* pParent
, const SfxItemSet
& rInAttrs
) :
75 SvxGridTabPage(pParent
, rInAttrs
)
78 aCbxSnapHelplines
.Show();
79 aCbxSnapBorder
.Show();
81 aCbxSnapPoints
.Show();
83 aMtrFldSnapArea
.Show();
90 aMtrFldBezAngle
.Show();
94 // -----------------------------------------------------------------------
96 SdTpOptionsSnap::~SdTpOptionsSnap()
100 // -----------------------------------------------------------------------
102 BOOL
SdTpOptionsSnap::FillItemSet( SfxItemSet
& rAttrs
)
104 SvxGridTabPage::FillItemSet(rAttrs
);
105 SdOptionsSnapItem
* pOptsItem
= NULL
;
106 // if(SFX_ITEM_SET != rAttrs.GetItemState( ATTR_OPTIONS_SNAP, FALSE, (const SfxPoolItem**)&pOptsItem ))
107 // pExampleSet->GetItemState( ATTR_OPTIONS_SNAP, FALSE, (const SfxPoolItem**)&pOptsItem );
109 SdOptionsSnapItem
aOptsItem( ATTR_OPTIONS_SNAP
);
111 aOptsItem
.GetOptionsSnap().SetSnapHelplines( aCbxSnapHelplines
.IsChecked() );
112 aOptsItem
.GetOptionsSnap().SetSnapBorder( aCbxSnapBorder
.IsChecked() );
113 aOptsItem
.GetOptionsSnap().SetSnapFrame( aCbxSnapFrame
.IsChecked() );
114 aOptsItem
.GetOptionsSnap().SetSnapPoints( aCbxSnapPoints
.IsChecked() );
115 aOptsItem
.GetOptionsSnap().SetOrtho( aCbxOrtho
.IsChecked() );
116 aOptsItem
.GetOptionsSnap().SetBigOrtho( aCbxBigOrtho
.IsChecked() );
117 aOptsItem
.GetOptionsSnap().SetRotate( aCbxRotate
.IsChecked() );
118 aOptsItem
.GetOptionsSnap().SetSnapArea( (INT16
) aMtrFldSnapArea
.GetValue() );
119 aOptsItem
.GetOptionsSnap().SetAngle( (INT16
) aMtrFldAngle
.GetValue() );
120 aOptsItem
.GetOptionsSnap().SetEliminatePolyPointLimitAngle( (INT16
) aMtrFldBezAngle
.GetValue() );
122 if( pOptsItem
== NULL
|| !(aOptsItem
== *pOptsItem
) )
123 rAttrs
.Put( aOptsItem
);
125 // Evtl. vorhandenes GridItem wird geholt, um nicht versehentlich
126 // irgendwelche Standardwerte einzustellen
130 // -----------------------------------------------------------------------
132 void SdTpOptionsSnap::Reset( const SfxItemSet
& rAttrs
)
134 SvxGridTabPage::Reset(rAttrs
);
136 SdOptionsSnapItem
aOptsItem( (const SdOptionsSnapItem
&) rAttrs
.
137 Get( ATTR_OPTIONS_SNAP
) );
139 aCbxSnapHelplines
.Check( aOptsItem
.GetOptionsSnap().IsSnapHelplines() );
140 aCbxSnapBorder
.Check( aOptsItem
.GetOptionsSnap().IsSnapBorder() );
141 aCbxSnapFrame
.Check( aOptsItem
.GetOptionsSnap().IsSnapFrame() );
142 aCbxSnapPoints
.Check( aOptsItem
.GetOptionsSnap().IsSnapPoints() );
143 aCbxOrtho
.Check( aOptsItem
.GetOptionsSnap().IsOrtho() );
144 aCbxBigOrtho
.Check( aOptsItem
.GetOptionsSnap().IsBigOrtho() );
145 aCbxRotate
.Check( aOptsItem
.GetOptionsSnap().IsRotate() );
146 aMtrFldSnapArea
.SetValue( aOptsItem
.GetOptionsSnap().GetSnapArea() );
147 aMtrFldAngle
.SetValue( aOptsItem
.GetOptionsSnap().GetAngle() );
148 aMtrFldBezAngle
.SetValue( aOptsItem
.GetOptionsSnap().GetEliminatePolyPointLimitAngle() );
150 aCbxRotate
.GetClickHdl().Call(0);
153 // -----------------------------------------------------------------------
155 SfxTabPage
* SdTpOptionsSnap::Create( Window
* pWindow
,
156 const SfxItemSet
& rAttrs
)
158 return( new SdTpOptionsSnap( pWindow
, rAttrs
) );
161 /*************************************************************************
163 |* TabPage zum Einstellen der Inhalte-Optionen
165 \************************************************************************/
167 SdTpOptionsContents::SdTpOptionsContents( Window
* pParent
, const SfxItemSet
& rInAttrs
) :
168 SfxTabPage ( pParent
, SdResId( TP_OPTIONS_CONTENTS
), rInAttrs
),
169 aGrpDisplay ( this, SdResId( GRP_DISPLAY
) ),
170 aCbxRuler ( this, SdResId( CBX_RULER
) ),
171 aCbxDragStripes ( this, SdResId( CBX_HELPLINES
) ),
172 aCbxHandlesBezier ( this, SdResId( CBX_HANDLES_BEZIER
) ),
173 aCbxMoveOutline ( this, SdResId( CBX_MOVE_OUTLINE
) )
178 // -----------------------------------------------------------------------
180 SdTpOptionsContents::~SdTpOptionsContents()
184 // -----------------------------------------------------------------------
186 BOOL
SdTpOptionsContents::FillItemSet( SfxItemSet
& rAttrs
)
188 BOOL bModified
= FALSE
;
190 if( aCbxRuler
.GetSavedValue() != aCbxRuler
.IsChecked() ||
191 aCbxMoveOutline
.GetSavedValue() != aCbxMoveOutline
.IsChecked() ||
192 aCbxDragStripes
.GetSavedValue() != aCbxDragStripes
.IsChecked() ||
193 //aCbxHelplines.GetSavedValue() != aCbxHelplines.IsChecked() ||
194 aCbxHandlesBezier
.GetSavedValue() != aCbxHandlesBezier
.IsChecked() )
196 SdOptionsLayoutItem
aOptsItem( ATTR_OPTIONS_LAYOUT
);
198 aOptsItem
.GetOptionsLayout().SetRulerVisible( aCbxRuler
.IsChecked() );
199 aOptsItem
.GetOptionsLayout().SetMoveOutline( aCbxMoveOutline
.IsChecked() );
200 aOptsItem
.GetOptionsLayout().SetDragStripes( aCbxDragStripes
.IsChecked() );
201 aOptsItem
.GetOptionsLayout().SetHandlesBezier( aCbxHandlesBezier
.IsChecked() );
202 //aOptsItem.GetOptionsLayout().SetHelplines( aCbxHelplines.IsChecked() );
204 rAttrs
.Put( aOptsItem
);
210 // -----------------------------------------------------------------------
212 void SdTpOptionsContents::Reset( const SfxItemSet
& rAttrs
)
214 SdOptionsContentsItem
aOptsItem( (const SdOptionsContentsItem
&) rAttrs
.
215 Get( ATTR_OPTIONS_CONTENTS
) );
217 SdOptionsLayoutItem
aLayoutItem( (const SdOptionsLayoutItem
&) rAttrs
.
218 Get( ATTR_OPTIONS_LAYOUT
) );
220 aCbxRuler
.Check( aLayoutItem
.GetOptionsLayout().IsRulerVisible() );
221 aCbxMoveOutline
.Check( aLayoutItem
.GetOptionsLayout().IsMoveOutline() );
222 aCbxDragStripes
.Check( aLayoutItem
.GetOptionsLayout().IsDragStripes() );
223 aCbxHandlesBezier
.Check( aLayoutItem
.GetOptionsLayout().IsHandlesBezier() );
224 //aCbxHelplines.Check( aLayoutItem.GetOptionsLayout().IsHelplines() );
226 aCbxRuler
.SaveValue();
227 aCbxMoveOutline
.SaveValue();
228 aCbxDragStripes
.SaveValue();
229 aCbxHandlesBezier
.SaveValue();
230 //aCbxHelplines.SaveValue();
233 // -----------------------------------------------------------------------
235 SfxTabPage
* SdTpOptionsContents::Create( Window
* pWindow
,
236 const SfxItemSet
& rAttrs
)
238 return( new SdTpOptionsContents( pWindow
, rAttrs
) );
241 /*************************************************************************
243 |* TabPage zum Einstellen der Sonstige-Optionen
245 \************************************************************************/
246 #define TABLE_COUNT 12
247 #define TOKEN (sal_Unicode(':'))
249 SdTpOptionsMisc::SdTpOptionsMisc( Window
* pParent
, const SfxItemSet
& rInAttrs
) :
250 SfxTabPage ( pParent
, SdResId( TP_OPTIONS_MISC
), rInAttrs
),
251 aGrpText ( this, SdResId( GRP_TEXT
) ),
252 aCbxQuickEdit ( this, SdResId( CBX_QUICKEDIT
) ),
253 aCbxPickThrough ( this, SdResId( CBX_PICKTHROUGH
) ),
255 // Template & Layout laufen z.Z. synchron!
256 aGrpProgramStart ( this, SdResId( GRP_PROGRAMSTART
) ),
257 aCbxStartWithTemplate ( this, SdResId( CBX_START_WITH_TEMPLATE
) ),
259 aGrpSettings ( this, SdResId( GRP_SETTINGS
) ),
260 aCbxMasterPageCache ( this, SdResId( CBX_MASTERPAGE_CACHE
) ),
261 aCbxCopy ( this, SdResId( CBX_COPY
) ),
262 aCbxMarkedHitMovesAlways ( this, SdResId( CBX_MARKED_HIT_MOVES_ALWAYS
) ),
263 aCbxCrookNoContortion ( this, SdResId( CBX_CROOK_NO_CONTORTION
) ),
265 aTxtMetric ( this, SdResId( FT_METRIC
) ),
266 aLbMetric ( this, SdResId( LB_METRIC
) ),
267 aTxtTabstop ( this, SdResId( FT_TABSTOP
) ),
268 aMtrFldTabstop ( this, SdResId( MTR_FLD_TABSTOP
) ),
270 aCbxStartWithActualPage ( this, SdResId( CBX_START_WITH_ACTUAL_PAGE
) ),
271 aGrpStartWithActualPage ( this, SdResId( GRP_START_WITH_ACTUAL_PAGE
) ),
272 aTxtCompatibility ( this, SdResId( FT_COMPATIBILITY
) ),
273 aCbxUsePrinterMetrics ( this, SdResId( CB_USE_PRINTER_METRICS
) ),
274 aCbxCompatibility ( this, SdResId( CB_MERGE_PARA_DIST
) ),
275 aGrpScale ( this, SdResId( GRP_SCALE
) ),
276 aFtScale ( this, SdResId( FT_SCALE
) ),
277 aCbScale ( this, SdResId( CB_SCALE
) ),
278 aFtOriginal ( this, SdResId( FT_ORIGINAL
) ),
279 aFtEquivalent ( this, SdResId( FT_EQUIVALENT
) ),
280 aFtPageWidth ( this, SdResId( FT_PAGEWIDTH
) ),
281 aFiInfo1 ( this, SdResId( FI_INFO_1
) ),
282 aMtrFldOriginalWidth ( this, SdResId( MTR_FLD_ORIGINAL_WIDTH
) ),
283 aFtPageHeight ( this, SdResId( FT_PAGEHEIGHT
) ),
284 aFiInfo2 ( this, SdResId( FI_INFO_2
) ),
285 aMtrFldOriginalHeight ( this, SdResId( MTR_FLD_ORIGINAL_HEIGHT
) ),
286 aMtrFldInfo1 ( this, WinBits( WB_HIDE
) ),
287 aMtrFldInfo2 ( this, WinBits( WB_HIDE
) )
290 SetExchangeSupport();
295 USHORT nWhich
= GetWhich( SID_ATTR_METRIC
);
296 if ( rInAttrs
.GetItemState( nWhich
) >= SFX_ITEM_AVAILABLE
)
298 const SfxUInt16Item
& rItem
= (SfxUInt16Item
&)rInAttrs
.Get( nWhich
);
299 eFUnit
= (FieldUnit
)rItem
.GetValue();
302 eFUnit
= GetModuleFieldUnit();
304 SetFieldUnit( aMtrFldTabstop
, eFUnit
);
306 // ListBox mit Metriken f"ullen
307 SvxStringArray
aMetricArr( RID_SVXSTR_FIELDUNIT_TABLE
);
310 for ( i
= 0; i
< aMetricArr
.Count(); ++i
)
312 String sMetric
= aMetricArr
.GetStringByPos( i
);
313 long nFieldUnit
= aMetricArr
.GetValue( i
);
314 USHORT nPos
= aLbMetric
.InsertEntry( sMetric
);
315 aLbMetric
.SetEntryData( nPos
, (void*)nFieldUnit
);
317 aLbMetric
.SetSelectHdl( LINK( this, SdTpOptionsMisc
, SelectMetricHdl_Impl
) );
319 SetFieldUnit( aMtrFldOriginalWidth
, eFUnit
);
320 SetFieldUnit( aMtrFldOriginalHeight
, eFUnit
);
321 aMtrFldOriginalWidth
.SetLast( 999999999 );
322 aMtrFldOriginalWidth
.SetMax( 999999999 );
323 aMtrFldOriginalHeight
.SetLast( 999999999 );
324 aMtrFldOriginalHeight
.SetMax( 999999999 );
326 // Temporaere Fields fuer Info-Texte (fuer Formatierung/Berechnung)
327 aMtrFldInfo1
.SetUnit( eFUnit
);
328 aMtrFldInfo1
.SetMax( 999999999 );
329 aMtrFldInfo1
.SetDecimalDigits( 2 );
330 aMtrFldInfo2
.SetUnit( eFUnit
);
331 aMtrFldInfo2
.SetMax( 999999999 );
332 aMtrFldInfo2
.SetDecimalDigits( 2 );
334 // PoolUnit ermitteln
335 SfxItemPool
* pPool
= rInAttrs
.GetPool();
336 DBG_ASSERT( pPool
, "Wo ist der Pool?" );
337 ePoolUnit
= pPool
->GetMetric( SID_ATTR_FILL_HATCH
);
340 USHORT aTable
[ TABLE_COUNT
] =
341 { 1, 2, 4, 5, 8, 10, 16, 20, 30, 40, 50, 100 };
343 for( i
= 0; i
< TABLE_COUNT
; i
++ )
344 aCbScale
.InsertEntry( GetScale( 1, aTable
[i
] ) );
345 for( i
= 1; i
< TABLE_COUNT
; i
++ )
346 aCbScale
.InsertEntry( GetScale( aTable
[i
], 1 ) );
349 // -----------------------------------------------------------------------
351 SdTpOptionsMisc::~SdTpOptionsMisc()
354 // -----------------------------------------------------------------------
355 void SdTpOptionsMisc::ActivatePage( const SfxItemSet
& rSet
)
357 // Hier muss noch einmal SaveValue gerufen werden, da sonst u.U.
358 // der Wert in anderen TabPages keine Wirkung hat
359 aLbMetric
.SaveValue();
360 // Metrik ggfs. aendern (da TabPage im Dialog liegt,
361 // wo die Metrik eingestellt werden kann
362 const SfxPoolItem
* pAttr
= NULL
;
363 if( SFX_ITEM_SET
== rSet
.GetItemState( SID_ATTR_METRIC
, FALSE
,
364 (const SfxPoolItem
**)&pAttr
))
366 const SfxUInt16Item
* pItem
= (SfxUInt16Item
*) pAttr
;
368 FieldUnit eFUnit
= (FieldUnit
)(long)pItem
->GetValue();
370 if( eFUnit
!= aMtrFldOriginalWidth
.GetUnit() )
372 // Metriken einstellen
373 sal_Int64 nVal
= aMtrFldOriginalWidth
.Denormalize( aMtrFldOriginalWidth
.GetValue( FUNIT_TWIP
) );
374 SetFieldUnit( aMtrFldOriginalWidth
, eFUnit
, TRUE
);
375 aMtrFldOriginalWidth
.SetValue( aMtrFldOriginalWidth
.Normalize( nVal
), FUNIT_TWIP
);
377 nVal
= aMtrFldOriginalHeight
.Denormalize( aMtrFldOriginalHeight
.GetValue( FUNIT_TWIP
) );
378 SetFieldUnit( aMtrFldOriginalHeight
, eFUnit
, TRUE
);
379 aMtrFldOriginalHeight
.SetValue( aMtrFldOriginalHeight
.Normalize( nVal
), FUNIT_TWIP
);
382 if( nWidth
!= 0 && nHeight
!= 0 )
384 aMtrFldInfo1
.SetUnit( eFUnit
);
385 aMtrFldInfo2
.SetUnit( eFUnit
);
387 SetMetricValue( aMtrFldInfo1
, nWidth
, ePoolUnit
);
388 aInfo1
= aMtrFldInfo1
.GetText();
389 aFiInfo1
.SetText( aInfo1
);
391 SetMetricValue( aMtrFldInfo2
, nHeight
, ePoolUnit
);
392 aInfo2
= aMtrFldInfo2
.GetText();
393 aFiInfo2
.SetText( aInfo2
);
399 // -----------------------------------------------------------------------
401 int SdTpOptionsMisc::DeactivatePage( SfxItemSet
* pActiveSet
)
405 if( SetScale( aCbScale
.GetText(), nX
, nY
) )
408 FillItemSet( *pActiveSet
);
409 return( LEAVE_PAGE
);
411 WarningBox
aWarnBox( GetParent(), WB_YES_NO
, String( SdResId( STR_WARN_SCALE_FAIL
) ) );
412 short nReturn
= aWarnBox
.Execute();
414 if( nReturn
== RET_YES
)
418 FillItemSet( *pActiveSet
);
420 return( LEAVE_PAGE
);
423 // -----------------------------------------------------------------------
425 BOOL
SdTpOptionsMisc::FillItemSet( SfxItemSet
& rAttrs
)
427 BOOL bModified
= FALSE
;
429 if( aCbxStartWithTemplate
.GetSavedValue() != aCbxStartWithTemplate
.IsChecked() ||
430 aCbxMarkedHitMovesAlways
.GetSavedValue()!= aCbxMarkedHitMovesAlways
.IsChecked() ||
431 aCbxCrookNoContortion
.GetSavedValue() != aCbxCrookNoContortion
.IsChecked() ||
432 aCbxQuickEdit
.GetSavedValue() != aCbxQuickEdit
.IsChecked() ||
433 aCbxPickThrough
.GetSavedValue() != aCbxPickThrough
.IsChecked() ||
434 aCbxMasterPageCache
.GetSavedValue() != aCbxMasterPageCache
.IsChecked() ||
435 aCbxCopy
.GetSavedValue() != aCbxCopy
.IsChecked() ||
436 aCbxStartWithActualPage
.GetSavedValue() != aCbxStartWithActualPage
.IsChecked() ||
437 aCbxCompatibility
.GetSavedValue() != aCbxCompatibility
.IsChecked() ||
438 aCbxUsePrinterMetrics
.GetSavedValue() != aCbxUsePrinterMetrics
.IsChecked() )
440 SdOptionsMiscItem
aOptsItem( ATTR_OPTIONS_MISC
);
442 aOptsItem
.GetOptionsMisc().SetStartWithTemplate( aCbxStartWithTemplate
.IsChecked() );
443 aOptsItem
.GetOptionsMisc().SetMarkedHitMovesAlways( aCbxMarkedHitMovesAlways
.IsChecked() );
444 aOptsItem
.GetOptionsMisc().SetCrookNoContortion( aCbxCrookNoContortion
.IsChecked() );
445 aOptsItem
.GetOptionsMisc().SetQuickEdit( aCbxQuickEdit
.IsChecked() );
446 aOptsItem
.GetOptionsMisc().SetPickThrough( aCbxPickThrough
.IsChecked() );
447 aOptsItem
.GetOptionsMisc().SetMasterPagePaintCaching( aCbxMasterPageCache
.IsChecked() );
448 aOptsItem
.GetOptionsMisc().SetDragWithCopy( aCbxCopy
.IsChecked() );
449 aOptsItem
.GetOptionsMisc().SetStartWithActualPage( aCbxStartWithActualPage
.IsChecked() );
450 aOptsItem
.GetOptionsMisc().SetSummationOfParagraphs( aCbxCompatibility
.IsChecked() );
451 aOptsItem
.GetOptionsMisc().SetPrinterIndependentLayout (
452 aCbxUsePrinterMetrics
.IsChecked()
453 ? ::com::sun::star::document::PrinterIndependentLayout::DISABLED
454 : ::com::sun::star::document::PrinterIndependentLayout::ENABLED
);
455 rAttrs
.Put( aOptsItem
);
461 const USHORT nMPos
= aLbMetric
.GetSelectEntryPos();
462 if ( nMPos
!= aLbMetric
.GetSavedValue() )
464 USHORT nFieldUnit
= (USHORT
)(long)aLbMetric
.GetEntryData( nMPos
);
465 rAttrs
.Put( SfxUInt16Item( GetWhich( SID_ATTR_METRIC
),
466 (UINT16
)nFieldUnit
) );
471 if( aMtrFldTabstop
.GetText() != aMtrFldTabstop
.GetSavedValue() )
473 USHORT nWh
= GetWhich( SID_ATTR_DEFTABSTOP
);
474 SfxMapUnit eUnit
= rAttrs
.GetPool()->GetMetric( nWh
);
475 SfxUInt16Item
aDef( nWh
,(USHORT
)GetCoreValue( aMtrFldTabstop
, eUnit
) );
481 if( SetScale( aCbScale
.GetText(), nX
, nY
) )
483 rAttrs
.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X
, nX
) );
484 rAttrs
.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y
, nY
) );
492 // -----------------------------------------------------------------------
494 void SdTpOptionsMisc::Reset( const SfxItemSet
& rAttrs
)
496 SdOptionsMiscItem
aOptsItem( (const SdOptionsMiscItem
&) rAttrs
.
497 Get( ATTR_OPTIONS_MISC
) );
499 aCbxStartWithTemplate
.Check( aOptsItem
.GetOptionsMisc().IsStartWithTemplate() );
500 aCbxMarkedHitMovesAlways
.Check( aOptsItem
.GetOptionsMisc().IsMarkedHitMovesAlways() );
501 aCbxCrookNoContortion
.Check( aOptsItem
.GetOptionsMisc().IsCrookNoContortion() );
502 aCbxQuickEdit
.Check( aOptsItem
.GetOptionsMisc().IsQuickEdit() );
503 aCbxPickThrough
.Check( aOptsItem
.GetOptionsMisc().IsPickThrough() );
504 aCbxMasterPageCache
.Check( aOptsItem
.GetOptionsMisc().IsMasterPagePaintCaching() );
505 aCbxCopy
.Check( aOptsItem
.GetOptionsMisc().IsDragWithCopy() );
506 aCbxStartWithActualPage
.Check( aOptsItem
.GetOptionsMisc().IsStartWithActualPage() );
507 aCbxCompatibility
.Check( aOptsItem
.GetOptionsMisc().IsSummationOfParagraphs() );
508 aCbxUsePrinterMetrics
.Check( aOptsItem
.GetOptionsMisc().GetPrinterIndependentLayout()==1 );
509 aCbxStartWithTemplate
.SaveValue();
510 aCbxMarkedHitMovesAlways
.SaveValue();
511 aCbxCrookNoContortion
.SaveValue();
512 aCbxQuickEdit
.SaveValue();
513 aCbxPickThrough
.SaveValue();
515 aCbxMasterPageCache
.SaveValue();
516 aCbxCopy
.SaveValue();
517 aCbxStartWithActualPage
.SaveValue();
518 aCbxCompatibility
.SaveValue();
519 aCbxUsePrinterMetrics
.SaveValue();
522 USHORT nWhich
= GetWhich( SID_ATTR_METRIC
);
523 aLbMetric
.SetNoSelection();
525 if ( rAttrs
.GetItemState( nWhich
) >= SFX_ITEM_AVAILABLE
)
527 const SfxUInt16Item
& rItem
= (SfxUInt16Item
&)rAttrs
.Get( nWhich
);
528 long nFieldUnit
= (long)rItem
.GetValue();
530 for ( USHORT i
= 0; i
< aLbMetric
.GetEntryCount(); ++i
)
532 if ( (long)aLbMetric
.GetEntryData( i
) == nFieldUnit
)
534 aLbMetric
.SelectEntryPos( i
);
541 nWhich
= GetWhich( SID_ATTR_DEFTABSTOP
);
542 if( rAttrs
.GetItemState( nWhich
) >= SFX_ITEM_AVAILABLE
)
544 SfxMapUnit eUnit
= rAttrs
.GetPool()->GetMetric( nWhich
);
545 const SfxUInt16Item
& rItem
= (SfxUInt16Item
&)rAttrs
.Get( nWhich
);
546 SetMetricValue( aMtrFldTabstop
, rItem
.GetValue(), eUnit
);
548 aLbMetric
.SaveValue();
549 aMtrFldTabstop
.SaveValue();
551 INT32 nX
= ( (const SfxInt32Item
&) rAttrs
.
552 Get( ATTR_OPTIONS_SCALE_X
) ).GetValue();
553 INT32 nY
= ( (const SfxInt32Item
&) rAttrs
.
554 Get( ATTR_OPTIONS_SCALE_Y
) ).GetValue();
555 nWidth
= ( (const SfxUInt32Item
&) rAttrs
.
556 Get( ATTR_OPTIONS_SCALE_WIDTH
) ).GetValue();
557 nHeight
= ( (const SfxUInt32Item
&) rAttrs
.
558 Get( ATTR_OPTIONS_SCALE_HEIGHT
) ).GetValue();
560 aCbScale
.SetText( GetScale( nX
, nY
) );
562 // #92067# broken feature disabled for 6.0
564 aFtEquivalent
.Hide();
565 aMtrFldOriginalWidth
.Hide();
566 aMtrFldOriginalWidth
.SetText( aInfo1
); // leer
567 aMtrFldOriginalHeight
.Hide();
568 aMtrFldOriginalHeight
.SetText( aInfo2
); //leer
570 aFtPageHeight
.Hide();
574 UpdateCompatibilityControls ();
577 // -----------------------------------------------------------------------
579 SfxTabPage
* SdTpOptionsMisc::Create( Window
* pWindow
,
580 const SfxItemSet
& rAttrs
)
582 return( new SdTpOptionsMisc( pWindow
, rAttrs
) );
584 //------------------------------------------------------------------------
586 IMPL_LINK( SdTpOptionsMisc
, SelectMetricHdl_Impl
, ListBox
*, EMPTYARG
)
588 USHORT nPos
= aLbMetric
.GetSelectEntryPos();
590 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
592 FieldUnit eUnit
= (FieldUnit
)(long)aLbMetric
.GetEntryData( nPos
);
594 aMtrFldTabstop
.Denormalize( aMtrFldTabstop
.GetValue( FUNIT_TWIP
) );
595 SetFieldUnit( aMtrFldTabstop
, eUnit
);
596 aMtrFldTabstop
.SetValue( aMtrFldTabstop
.Normalize( nVal
), FUNIT_TWIP
);
603 void lcl_MoveWin( Window
& rWin
, long nYDiff
)
605 Point
aPos(rWin
.GetPosPixel());
607 rWin
.SetPosPixel (aPos
);
610 void lcl_MoveWin( Window
& rWin
, long nXdiff
, long nYdiff
)
612 Point
aPos(rWin
.GetPosPixel());
615 rWin
.SetPosPixel(aPos
);
619 void SdTpOptionsMisc::SetImpressMode (void)
621 long nDialogWidth
= GetSizePixel().Width();
622 long nLineHeight
= aCbxPickThrough
.GetPosPixel().Y()
623 - aCbxQuickEdit
.GetPosPixel().Y();
625 // Put both "Text objects" check boxes side by side.
626 lcl_MoveWin (aCbxPickThrough
,
627 nDialogWidth
/2 - aCbxPickThrough
.GetPosPixel().X(),
630 // Move the other controls up one line.
631 lcl_MoveWin (aGrpProgramStart
, -nLineHeight
);
632 lcl_MoveWin (aCbxStartWithTemplate
, -nLineHeight
);
633 lcl_MoveWin (aGrpSettings
, -nLineHeight
);
634 lcl_MoveWin (aCbxMasterPageCache
, -nLineHeight
);
635 lcl_MoveWin (aCbxCopy
, -nLineHeight
);
636 lcl_MoveWin (aCbxMarkedHitMovesAlways
, -nLineHeight
);
637 lcl_MoveWin (aCbxCrookNoContortion
, -nLineHeight
);
638 lcl_MoveWin (aTxtMetric
, -nLineHeight
);
639 lcl_MoveWin (aLbMetric
, -nLineHeight
);
640 lcl_MoveWin (aTxtTabstop
, -nLineHeight
);
641 lcl_MoveWin (aMtrFldTabstop
, -nLineHeight
);
642 lcl_MoveWin (aGrpStartWithActualPage
, -nLineHeight
);
643 lcl_MoveWin (aCbxStartWithActualPage
, -nLineHeight
);
644 lcl_MoveWin (aTxtCompatibility
, -nLineHeight
);
646 // Move the printer-independent-metrics check box up two lines to change
647 // places with spacing-between-paragraphs check box.
648 lcl_MoveWin (aCbxUsePrinterMetrics
, -2*nLineHeight
);
651 void SdTpOptionsMisc::SetDrawMode()
653 aCbxStartWithTemplate
.Hide();
654 aGrpProgramStart
.Hide();
655 aCbxStartWithActualPage
.Hide();
656 aCbxCompatibility
.Hide();
657 aGrpStartWithActualPage
.Hide();
658 aCbxCrookNoContortion
.Show();
665 aFtEquivalent
.Show();
669 aMtrFldOriginalWidth
.Show();
671 aFtPageHeight
.Show();
673 aMtrFldOriginalHeight
.Show();
675 long nDiff
= aGrpSettings
.GetPosPixel().Y() - aGrpProgramStart
.GetPosPixel().Y();
676 lcl_MoveWin( aGrpSettings
, -nDiff
);
677 lcl_MoveWin( aCbxMasterPageCache
, -nDiff
);
678 lcl_MoveWin( aCbxCopy
, -nDiff
);
679 lcl_MoveWin( aCbxMarkedHitMovesAlways
, -nDiff
);
680 lcl_MoveWin( aCbxCrookNoContortion
, -nDiff
);
681 nDiff
-= aCbxCrookNoContortion
.GetPosPixel().Y() - aCbxMarkedHitMovesAlways
.GetPosPixel().Y();
682 lcl_MoveWin( aTxtMetric
, -nDiff
);
683 lcl_MoveWin( aLbMetric
, -nDiff
);
684 lcl_MoveWin( aTxtTabstop
, -nDiff
);
685 lcl_MoveWin( aMtrFldTabstop
, -nDiff
);
687 // Move the scale controls so that they are visually centered betwen the
688 // group controls above and below.
689 lcl_MoveWin (aFtScale
, -17);
690 lcl_MoveWin (aCbScale
, -17);
692 // Move the printer-independent-metrics check box in the place that the
693 // spacing-between-paragraphs check box normally is in.
694 aCbxUsePrinterMetrics
.SetPosPixel (aCbxCompatibility
.GetPosPixel());
696 // -----------------------------------------------------------------------
698 IMPL_LINK( SdTpOptionsMisc
, ModifyScaleHdl
, void *, EMPTYARG
)
700 // Originalgroesse berechnen
702 if( SetScale( aCbScale
.GetText(), nX
, nY
) )
704 INT32 nW
= nWidth
* nY
/ nX
;
705 INT32 nH
= nHeight
* nY
/ nX
;
707 SetMetricValue( aMtrFldOriginalWidth
, nW
, ePoolUnit
);
708 SetMetricValue( aMtrFldOriginalHeight
, nH
, ePoolUnit
);
714 // -----------------------------------------------------------------------
716 IMPL_LINK( SdTpOptionsMisc
, ModifyOriginalScaleHdl
, void *, EMPTYARG
)
718 // Berechnen des Massstabs
719 long nOrgW
= static_cast<long>(aMtrFldOriginalWidth
.GetValue());
720 long nOrgH
= static_cast<long>(aMtrFldOriginalHeight
.GetValue());
722 if( nOrgW
== 0 || nOrgH
== 0 )
725 Fraction
aFract1( nOrgW
, static_cast<long>(aMtrFldInfo1
.GetValue()) );
726 Fraction
aFract2( nOrgH
, static_cast<long>(aMtrFldInfo2
.GetValue()) );
727 Fraction
aFract( aFract1
> aFract2
? aFract1
: aFract2
);
730 if( aFract
< Fraction( 1, 1 ) )
734 aFract
= Fraction( aFract1
.GetDenominator(), aFract1
.GetNumerator() );
737 // #92067# Swap nominator and denominator
738 aCbScale
.SetText( GetScale( nValue
, 1 ) );
742 double fValue
= aFract
;
744 if( fValue
> (double)nValue
)
747 // #92067# Swap nominator and denominator
748 aCbScale
.SetText( GetScale( 1, nValue
) );
753 // -----------------------------------------------------------------------
755 String
SdTpOptionsMisc::GetScale( INT32 nX
, INT32 nY
)
757 String
aScale( UniString::CreateFromInt32( nX
) );
758 aScale
.Append( TOKEN
);
759 aScale
.Append( UniString::CreateFromInt32( nY
) );
764 // -----------------------------------------------------------------------
766 BOOL
SdTpOptionsMisc::SetScale( const String
& aScale
, INT32
& rX
, INT32
& rY
)
768 if( aScale
.GetTokenCount( TOKEN
) != 2 )
771 ByteString
aTmp( aScale
.GetToken( 0, TOKEN
), RTL_TEXTENCODING_ASCII_US
);
772 if( !aTmp
.IsNumericAscii() )
775 rX
= (long) aTmp
.ToInt32();
779 aTmp
= ByteString( aScale
.GetToken( 1, TOKEN
), RTL_TEXTENCODING_ASCII_US
);
780 if( !aTmp
.IsNumericAscii() )
783 rY
= (long) aTmp
.ToInt32();
793 void SdTpOptionsMisc::UpdateCompatibilityControls (void)
795 // Disable the compatibility controls by default. Enable them only when
796 // there is at least one open document.
797 sal_Bool bIsEnabled
= sal_False
;
801 // Get a component enumeration from the desktop and search it for documents.
802 Reference
<lang::XMultiServiceFactory
> xFactory (
803 ::comphelper::getProcessServiceFactory ());
806 if ( ! xFactory
.is())
809 Reference
<frame::XDesktop
> xDesktop (xFactory
->createInstance (
810 ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), UNO_QUERY
);
811 if ( ! xDesktop
.is())
814 Reference
<container::XEnumerationAccess
> xComponents (
815 xDesktop
->getComponents(), UNO_QUERY
);
816 if ( ! xComponents
.is())
819 Reference
<container::XEnumeration
> xEnumeration (
820 xComponents
->createEnumeration());
821 if ( ! xEnumeration
.is())
824 while (xEnumeration
->hasMoreElements())
826 Reference
<frame::XModel
> xModel (xEnumeration
->nextElement(), UNO_QUERY
);
829 // There is at leas one model/document: Enable the compatibility controls.
830 bIsEnabled
= sal_True
;
836 while (false); // One 'loop'.
838 catch (uno::Exception e
)
840 // When there is an exception then simply use the default value of
841 // bIsEnabled and disable the controls.
844 aTxtCompatibility
.Enable (bIsEnabled
);
845 aCbxCompatibility
.Enable(bIsEnabled
);
846 aCbxUsePrinterMetrics
.Enable (bIsEnabled
);
849 void SdTpOptionsMisc::PageCreated (SfxAllItemSet aSet
)
851 SFX_ITEMSET_ARG (&aSet
,pFlagItem
,SfxUInt32Item
,SID_SDMODE_FLAG
,sal_False
);
854 UINT32 nFlags
=pFlagItem
->GetValue();
855 if ( ( nFlags
& SD_DRAW_MODE
) == SD_DRAW_MODE
)
857 if ( ( nFlags
& SD_IMPRESS_MODE
) == SD_IMPRESS_MODE
)