1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_sd.hxx"
32 #ifdef SD_DLLIMPLEMENTATION
33 #undef SD_DLLIMPLEMENTATION
37 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
38 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
39 #include <com/sun/star/frame/XDesktop.hpp>
40 #include <com/sun/star/lang/XComponent.hpp>
41 #include <com/sun/star/container/XEnumerationAccess.hpp>
42 #include <comphelper/processfactory.hxx>
43 #include <com/sun/star/uno/Exception.hpp>
44 #include <sfx2/module.hxx>
45 #include <sfx2/app.hxx>
46 #include <svx/svxids.hrc>
47 #include <svx/dialogs.hrc>
48 #include <svx/strarray.hxx>
49 #include <svx/dlgutil.hxx>
50 #include <vcl/msgbox.hxx>
53 #include "sdresid.hxx"
54 #include "optsitem.hxx"
55 #include "tpoption.hrc"
56 #include "tpoption.hxx"
57 #include "strings.hrc"
59 #include <svl/intitem.hxx>
60 #include <sfx2/request.hxx>
61 #define DLGWIN this->GetParent()->GetParent()
63 using namespace ::com::sun::star
;
64 using namespace ::com::sun::star::uno
;
66 /*************************************************************************
68 |* TabPage zum Einstellen der Fang-Optionen
70 \************************************************************************/
72 SdTpOptionsSnap::SdTpOptionsSnap( Window
* pParent
, const SfxItemSet
& rInAttrs
) :
73 SvxGridTabPage(pParent
, rInAttrs
)
76 aCbxSnapHelplines
.Show();
77 aCbxSnapBorder
.Show();
79 aCbxSnapPoints
.Show();
81 aMtrFldSnapArea
.Show();
88 aMtrFldBezAngle
.Show();
92 // -----------------------------------------------------------------------
94 SdTpOptionsSnap::~SdTpOptionsSnap()
98 // -----------------------------------------------------------------------
100 BOOL
SdTpOptionsSnap::FillItemSet( SfxItemSet
& rAttrs
)
102 SvxGridTabPage::FillItemSet(rAttrs
);
103 SdOptionsSnapItem
* pOptsItem
= NULL
;
104 // if(SFX_ITEM_SET != rAttrs.GetItemState( ATTR_OPTIONS_SNAP, FALSE, (const SfxPoolItem**)&pOptsItem ))
105 // pExampleSet->GetItemState( ATTR_OPTIONS_SNAP, FALSE, (const SfxPoolItem**)&pOptsItem );
107 SdOptionsSnapItem
aOptsItem( ATTR_OPTIONS_SNAP
);
109 aOptsItem
.GetOptionsSnap().SetSnapHelplines( aCbxSnapHelplines
.IsChecked() );
110 aOptsItem
.GetOptionsSnap().SetSnapBorder( aCbxSnapBorder
.IsChecked() );
111 aOptsItem
.GetOptionsSnap().SetSnapFrame( aCbxSnapFrame
.IsChecked() );
112 aOptsItem
.GetOptionsSnap().SetSnapPoints( aCbxSnapPoints
.IsChecked() );
113 aOptsItem
.GetOptionsSnap().SetOrtho( aCbxOrtho
.IsChecked() );
114 aOptsItem
.GetOptionsSnap().SetBigOrtho( aCbxBigOrtho
.IsChecked() );
115 aOptsItem
.GetOptionsSnap().SetRotate( aCbxRotate
.IsChecked() );
116 aOptsItem
.GetOptionsSnap().SetSnapArea( (INT16
) aMtrFldSnapArea
.GetValue() );
117 aOptsItem
.GetOptionsSnap().SetAngle( (INT16
) aMtrFldAngle
.GetValue() );
118 aOptsItem
.GetOptionsSnap().SetEliminatePolyPointLimitAngle( (INT16
) aMtrFldBezAngle
.GetValue() );
120 if( pOptsItem
== NULL
|| !(aOptsItem
== *pOptsItem
) )
121 rAttrs
.Put( aOptsItem
);
123 // Evtl. vorhandenes GridItem wird geholt, um nicht versehentlich
124 // irgendwelche Standardwerte einzustellen
128 // -----------------------------------------------------------------------
130 void SdTpOptionsSnap::Reset( const SfxItemSet
& rAttrs
)
132 SvxGridTabPage::Reset(rAttrs
);
134 SdOptionsSnapItem
aOptsItem( (const SdOptionsSnapItem
&) rAttrs
.
135 Get( ATTR_OPTIONS_SNAP
) );
137 aCbxSnapHelplines
.Check( aOptsItem
.GetOptionsSnap().IsSnapHelplines() );
138 aCbxSnapBorder
.Check( aOptsItem
.GetOptionsSnap().IsSnapBorder() );
139 aCbxSnapFrame
.Check( aOptsItem
.GetOptionsSnap().IsSnapFrame() );
140 aCbxSnapPoints
.Check( aOptsItem
.GetOptionsSnap().IsSnapPoints() );
141 aCbxOrtho
.Check( aOptsItem
.GetOptionsSnap().IsOrtho() );
142 aCbxBigOrtho
.Check( aOptsItem
.GetOptionsSnap().IsBigOrtho() );
143 aCbxRotate
.Check( aOptsItem
.GetOptionsSnap().IsRotate() );
144 aMtrFldSnapArea
.SetValue( aOptsItem
.GetOptionsSnap().GetSnapArea() );
145 aMtrFldAngle
.SetValue( aOptsItem
.GetOptionsSnap().GetAngle() );
146 aMtrFldBezAngle
.SetValue( aOptsItem
.GetOptionsSnap().GetEliminatePolyPointLimitAngle() );
148 aCbxRotate
.GetClickHdl().Call(0);
151 // -----------------------------------------------------------------------
153 SfxTabPage
* SdTpOptionsSnap::Create( Window
* pWindow
,
154 const SfxItemSet
& rAttrs
)
156 return( new SdTpOptionsSnap( pWindow
, rAttrs
) );
159 /*************************************************************************
161 |* TabPage zum Einstellen der Inhalte-Optionen
163 \************************************************************************/
165 SdTpOptionsContents::SdTpOptionsContents( Window
* pParent
, const SfxItemSet
& rInAttrs
) :
166 SfxTabPage ( pParent
, SdResId( TP_OPTIONS_CONTENTS
), rInAttrs
),
167 aGrpDisplay ( this, SdResId( GRP_DISPLAY
) ),
168 aCbxRuler ( this, SdResId( CBX_RULER
) ),
169 aCbxDragStripes ( this, SdResId( CBX_HELPLINES
) ),
170 aCbxHandlesBezier ( this, SdResId( CBX_HANDLES_BEZIER
) ),
171 aCbxMoveOutline ( this, SdResId( CBX_MOVE_OUTLINE
) )
176 // -----------------------------------------------------------------------
178 SdTpOptionsContents::~SdTpOptionsContents()
182 // -----------------------------------------------------------------------
184 BOOL
SdTpOptionsContents::FillItemSet( SfxItemSet
& rAttrs
)
186 BOOL bModified
= FALSE
;
188 if( aCbxRuler
.GetSavedValue() != aCbxRuler
.IsChecked() ||
189 aCbxMoveOutline
.GetSavedValue() != aCbxMoveOutline
.IsChecked() ||
190 aCbxDragStripes
.GetSavedValue() != aCbxDragStripes
.IsChecked() ||
191 //aCbxHelplines.GetSavedValue() != aCbxHelplines.IsChecked() ||
192 aCbxHandlesBezier
.GetSavedValue() != aCbxHandlesBezier
.IsChecked() )
194 SdOptionsLayoutItem
aOptsItem( ATTR_OPTIONS_LAYOUT
);
196 aOptsItem
.GetOptionsLayout().SetRulerVisible( aCbxRuler
.IsChecked() );
197 aOptsItem
.GetOptionsLayout().SetMoveOutline( aCbxMoveOutline
.IsChecked() );
198 aOptsItem
.GetOptionsLayout().SetDragStripes( aCbxDragStripes
.IsChecked() );
199 aOptsItem
.GetOptionsLayout().SetHandlesBezier( aCbxHandlesBezier
.IsChecked() );
200 //aOptsItem.GetOptionsLayout().SetHelplines( aCbxHelplines.IsChecked() );
202 rAttrs
.Put( aOptsItem
);
208 // -----------------------------------------------------------------------
210 void SdTpOptionsContents::Reset( const SfxItemSet
& rAttrs
)
212 SdOptionsContentsItem
aOptsItem( (const SdOptionsContentsItem
&) rAttrs
.
213 Get( ATTR_OPTIONS_CONTENTS
) );
215 SdOptionsLayoutItem
aLayoutItem( (const SdOptionsLayoutItem
&) rAttrs
.
216 Get( ATTR_OPTIONS_LAYOUT
) );
218 aCbxRuler
.Check( aLayoutItem
.GetOptionsLayout().IsRulerVisible() );
219 aCbxMoveOutline
.Check( aLayoutItem
.GetOptionsLayout().IsMoveOutline() );
220 aCbxDragStripes
.Check( aLayoutItem
.GetOptionsLayout().IsDragStripes() );
221 aCbxHandlesBezier
.Check( aLayoutItem
.GetOptionsLayout().IsHandlesBezier() );
222 //aCbxHelplines.Check( aLayoutItem.GetOptionsLayout().IsHelplines() );
224 aCbxRuler
.SaveValue();
225 aCbxMoveOutline
.SaveValue();
226 aCbxDragStripes
.SaveValue();
227 aCbxHandlesBezier
.SaveValue();
228 //aCbxHelplines.SaveValue();
231 // -----------------------------------------------------------------------
233 SfxTabPage
* SdTpOptionsContents::Create( Window
* pWindow
,
234 const SfxItemSet
& rAttrs
)
236 return( new SdTpOptionsContents( pWindow
, rAttrs
) );
239 /*************************************************************************
241 |* TabPage zum Einstellen der Sonstige-Optionen
243 \************************************************************************/
244 #define TABLE_COUNT 12
245 #define TOKEN (sal_Unicode(':'))
247 SdTpOptionsMisc::SdTpOptionsMisc( Window
* pParent
, const SfxItemSet
& rInAttrs
) :
248 SfxTabPage ( pParent
, SdResId( TP_OPTIONS_MISC
), rInAttrs
),
249 aGrpText ( this, SdResId( GRP_TEXT
) ),
250 aCbxQuickEdit ( this, SdResId( CBX_QUICKEDIT
) ),
251 aCbxPickThrough ( this, SdResId( CBX_PICKTHROUGH
) ),
253 // Template & Layout laufen z.Z. synchron!
254 aGrpProgramStart ( this, SdResId( GRP_PROGRAMSTART
) ),
255 aCbxStartWithTemplate ( this, SdResId( CBX_START_WITH_TEMPLATE
) ),
257 aGrpSettings ( this, SdResId( GRP_SETTINGS
) ),
258 aCbxMasterPageCache ( this, SdResId( CBX_MASTERPAGE_CACHE
) ),
259 aCbxCopy ( this, SdResId( CBX_COPY
) ),
260 aCbxMarkedHitMovesAlways ( this, SdResId( CBX_MARKED_HIT_MOVES_ALWAYS
) ),
261 aCbxCrookNoContortion ( this, SdResId( CBX_CROOK_NO_CONTORTION
) ),
263 aTxtMetric ( this, SdResId( FT_METRIC
) ),
264 aLbMetric ( this, SdResId( LB_METRIC
) ),
265 aTxtTabstop ( this, SdResId( FT_TABSTOP
) ),
266 aMtrFldTabstop ( this, SdResId( MTR_FLD_TABSTOP
) ),
268 aCbxStartWithActualPage ( this, SdResId( CBX_START_WITH_ACTUAL_PAGE
) ),
269 aGrpStartWithActualPage ( this, SdResId( GRP_START_WITH_ACTUAL_PAGE
) ),
270 aTxtCompatibility ( this, SdResId( FT_COMPATIBILITY
) ),
271 aCbxUsePrinterMetrics ( this, SdResId( CB_USE_PRINTER_METRICS
) ),
272 aCbxCompatibility ( this, SdResId( CB_MERGE_PARA_DIST
) ),
273 aGrpScale ( this, SdResId( GRP_SCALE
) ),
274 aFtScale ( this, SdResId( FT_SCALE
) ),
275 aCbScale ( this, SdResId( CB_SCALE
) ),
276 aFtOriginal ( this, SdResId( FT_ORIGINAL
) ),
277 aFtEquivalent ( this, SdResId( FT_EQUIVALENT
) ),
278 aFtPageWidth ( this, SdResId( FT_PAGEWIDTH
) ),
279 aFiInfo1 ( this, SdResId( FI_INFO_1
) ),
280 aMtrFldOriginalWidth ( this, SdResId( MTR_FLD_ORIGINAL_WIDTH
) ),
281 aFtPageHeight ( this, SdResId( FT_PAGEHEIGHT
) ),
282 aFiInfo2 ( this, SdResId( FI_INFO_2
) ),
283 aMtrFldOriginalHeight ( this, SdResId( MTR_FLD_ORIGINAL_HEIGHT
) ),
284 aMtrFldInfo1 ( this, WinBits( WB_HIDE
) ),
285 aMtrFldInfo2 ( this, WinBits( WB_HIDE
) )
288 SetExchangeSupport();
293 USHORT nWhich
= GetWhich( SID_ATTR_METRIC
);
294 if ( rInAttrs
.GetItemState( nWhich
) >= SFX_ITEM_AVAILABLE
)
296 const SfxUInt16Item
& rItem
= (SfxUInt16Item
&)rInAttrs
.Get( nWhich
);
297 eFUnit
= (FieldUnit
)rItem
.GetValue();
300 eFUnit
= SfxModule::GetCurrentFieldUnit();
302 SetFieldUnit( aMtrFldTabstop
, eFUnit
);
304 // ListBox mit Metriken f"ullen
305 SvxStringArray
aMetricArr( RID_SVXSTR_FIELDUNIT_TABLE
);
308 for ( i
= 0; i
< aMetricArr
.Count(); ++i
)
310 String sMetric
= aMetricArr
.GetStringByPos( i
);
311 long nFieldUnit
= aMetricArr
.GetValue( i
);
312 USHORT nPos
= aLbMetric
.InsertEntry( sMetric
);
313 aLbMetric
.SetEntryData( nPos
, (void*)nFieldUnit
);
315 aLbMetric
.SetSelectHdl( LINK( this, SdTpOptionsMisc
, SelectMetricHdl_Impl
) );
317 SetFieldUnit( aMtrFldOriginalWidth
, eFUnit
);
318 SetFieldUnit( aMtrFldOriginalHeight
, eFUnit
);
319 aMtrFldOriginalWidth
.SetLast( 999999999 );
320 aMtrFldOriginalWidth
.SetMax( 999999999 );
321 aMtrFldOriginalHeight
.SetLast( 999999999 );
322 aMtrFldOriginalHeight
.SetMax( 999999999 );
324 // Temporaere Fields fuer Info-Texte (fuer Formatierung/Berechnung)
325 aMtrFldInfo1
.SetUnit( eFUnit
);
326 aMtrFldInfo1
.SetMax( 999999999 );
327 aMtrFldInfo1
.SetDecimalDigits( 2 );
328 aMtrFldInfo2
.SetUnit( eFUnit
);
329 aMtrFldInfo2
.SetMax( 999999999 );
330 aMtrFldInfo2
.SetDecimalDigits( 2 );
332 // PoolUnit ermitteln
333 SfxItemPool
* pPool
= rInAttrs
.GetPool();
334 DBG_ASSERT( pPool
, "Wo ist der Pool?" );
335 ePoolUnit
= pPool
->GetMetric( SID_ATTR_FILL_HATCH
);
338 USHORT aTable
[ TABLE_COUNT
] =
339 { 1, 2, 4, 5, 8, 10, 16, 20, 30, 40, 50, 100 };
341 for( i
= 0; i
< TABLE_COUNT
; i
++ )
342 aCbScale
.InsertEntry( GetScale( 1, aTable
[i
] ) );
343 for( i
= 1; i
< TABLE_COUNT
; i
++ )
344 aCbScale
.InsertEntry( GetScale( aTable
[i
], 1 ) );
347 // -----------------------------------------------------------------------
349 SdTpOptionsMisc::~SdTpOptionsMisc()
352 // -----------------------------------------------------------------------
353 void SdTpOptionsMisc::ActivatePage( const SfxItemSet
& rSet
)
355 // Hier muss noch einmal SaveValue gerufen werden, da sonst u.U.
356 // der Wert in anderen TabPages keine Wirkung hat
357 aLbMetric
.SaveValue();
358 // Metrik ggfs. aendern (da TabPage im Dialog liegt,
359 // wo die Metrik eingestellt werden kann
360 const SfxPoolItem
* pAttr
= NULL
;
361 if( SFX_ITEM_SET
== rSet
.GetItemState( SID_ATTR_METRIC
, FALSE
,
362 (const SfxPoolItem
**)&pAttr
))
364 const SfxUInt16Item
* pItem
= (SfxUInt16Item
*) pAttr
;
366 FieldUnit eFUnit
= (FieldUnit
)(long)pItem
->GetValue();
368 if( eFUnit
!= aMtrFldOriginalWidth
.GetUnit() )
370 // Metriken einstellen
371 sal_Int64 nVal
= aMtrFldOriginalWidth
.Denormalize( aMtrFldOriginalWidth
.GetValue( FUNIT_TWIP
) );
372 SetFieldUnit( aMtrFldOriginalWidth
, eFUnit
, TRUE
);
373 aMtrFldOriginalWidth
.SetValue( aMtrFldOriginalWidth
.Normalize( nVal
), FUNIT_TWIP
);
375 nVal
= aMtrFldOriginalHeight
.Denormalize( aMtrFldOriginalHeight
.GetValue( FUNIT_TWIP
) );
376 SetFieldUnit( aMtrFldOriginalHeight
, eFUnit
, TRUE
);
377 aMtrFldOriginalHeight
.SetValue( aMtrFldOriginalHeight
.Normalize( nVal
), FUNIT_TWIP
);
380 if( nWidth
!= 0 && nHeight
!= 0 )
382 aMtrFldInfo1
.SetUnit( eFUnit
);
383 aMtrFldInfo2
.SetUnit( eFUnit
);
385 SetMetricValue( aMtrFldInfo1
, nWidth
, ePoolUnit
);
386 aInfo1
= aMtrFldInfo1
.GetText();
387 aFiInfo1
.SetText( aInfo1
);
389 SetMetricValue( aMtrFldInfo2
, nHeight
, ePoolUnit
);
390 aInfo2
= aMtrFldInfo2
.GetText();
391 aFiInfo2
.SetText( aInfo2
);
397 // -----------------------------------------------------------------------
399 int SdTpOptionsMisc::DeactivatePage( SfxItemSet
* pActiveSet
)
403 if( SetScale( aCbScale
.GetText(), nX
, nY
) )
406 FillItemSet( *pActiveSet
);
407 return( LEAVE_PAGE
);
409 WarningBox
aWarnBox( GetParent(), WB_YES_NO
, String( SdResId( STR_WARN_SCALE_FAIL
) ) );
410 short nReturn
= aWarnBox
.Execute();
412 if( nReturn
== RET_YES
)
416 FillItemSet( *pActiveSet
);
418 return( LEAVE_PAGE
);
421 // -----------------------------------------------------------------------
423 BOOL
SdTpOptionsMisc::FillItemSet( SfxItemSet
& rAttrs
)
425 BOOL bModified
= FALSE
;
427 if( aCbxStartWithTemplate
.GetSavedValue() != aCbxStartWithTemplate
.IsChecked() ||
428 aCbxMarkedHitMovesAlways
.GetSavedValue()!= aCbxMarkedHitMovesAlways
.IsChecked() ||
429 aCbxCrookNoContortion
.GetSavedValue() != aCbxCrookNoContortion
.IsChecked() ||
430 aCbxQuickEdit
.GetSavedValue() != aCbxQuickEdit
.IsChecked() ||
431 aCbxPickThrough
.GetSavedValue() != aCbxPickThrough
.IsChecked() ||
432 aCbxMasterPageCache
.GetSavedValue() != aCbxMasterPageCache
.IsChecked() ||
433 aCbxCopy
.GetSavedValue() != aCbxCopy
.IsChecked() ||
434 aCbxStartWithActualPage
.GetSavedValue() != aCbxStartWithActualPage
.IsChecked() ||
435 aCbxCompatibility
.GetSavedValue() != aCbxCompatibility
.IsChecked() ||
436 aCbxUsePrinterMetrics
.GetSavedValue() != aCbxUsePrinterMetrics
.IsChecked() )
438 SdOptionsMiscItem
aOptsItem( ATTR_OPTIONS_MISC
);
440 aOptsItem
.GetOptionsMisc().SetStartWithTemplate( aCbxStartWithTemplate
.IsChecked() );
441 aOptsItem
.GetOptionsMisc().SetMarkedHitMovesAlways( aCbxMarkedHitMovesAlways
.IsChecked() );
442 aOptsItem
.GetOptionsMisc().SetCrookNoContortion( aCbxCrookNoContortion
.IsChecked() );
443 aOptsItem
.GetOptionsMisc().SetQuickEdit( aCbxQuickEdit
.IsChecked() );
444 aOptsItem
.GetOptionsMisc().SetPickThrough( aCbxPickThrough
.IsChecked() );
445 aOptsItem
.GetOptionsMisc().SetMasterPagePaintCaching( aCbxMasterPageCache
.IsChecked() );
446 aOptsItem
.GetOptionsMisc().SetDragWithCopy( aCbxCopy
.IsChecked() );
447 aOptsItem
.GetOptionsMisc().SetStartWithActualPage( aCbxStartWithActualPage
.IsChecked() );
448 aOptsItem
.GetOptionsMisc().SetSummationOfParagraphs( aCbxCompatibility
.IsChecked() );
449 aOptsItem
.GetOptionsMisc().SetPrinterIndependentLayout (
450 aCbxUsePrinterMetrics
.IsChecked()
451 ? ::com::sun::star::document::PrinterIndependentLayout::DISABLED
452 : ::com::sun::star::document::PrinterIndependentLayout::ENABLED
);
453 rAttrs
.Put( aOptsItem
);
459 const USHORT nMPos
= aLbMetric
.GetSelectEntryPos();
460 if ( nMPos
!= aLbMetric
.GetSavedValue() )
462 USHORT nFieldUnit
= (USHORT
)(long)aLbMetric
.GetEntryData( nMPos
);
463 rAttrs
.Put( SfxUInt16Item( GetWhich( SID_ATTR_METRIC
),
464 (UINT16
)nFieldUnit
) );
469 if( aMtrFldTabstop
.GetText() != aMtrFldTabstop
.GetSavedValue() )
471 USHORT nWh
= GetWhich( SID_ATTR_DEFTABSTOP
);
472 SfxMapUnit eUnit
= rAttrs
.GetPool()->GetMetric( nWh
);
473 SfxUInt16Item
aDef( nWh
,(USHORT
)GetCoreValue( aMtrFldTabstop
, eUnit
) );
479 if( SetScale( aCbScale
.GetText(), nX
, nY
) )
481 rAttrs
.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X
, nX
) );
482 rAttrs
.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y
, nY
) );
490 // -----------------------------------------------------------------------
492 void SdTpOptionsMisc::Reset( const SfxItemSet
& rAttrs
)
494 SdOptionsMiscItem
aOptsItem( (const SdOptionsMiscItem
&) rAttrs
.
495 Get( ATTR_OPTIONS_MISC
) );
497 aCbxStartWithTemplate
.Check( aOptsItem
.GetOptionsMisc().IsStartWithTemplate() );
498 aCbxMarkedHitMovesAlways
.Check( aOptsItem
.GetOptionsMisc().IsMarkedHitMovesAlways() );
499 aCbxCrookNoContortion
.Check( aOptsItem
.GetOptionsMisc().IsCrookNoContortion() );
500 aCbxQuickEdit
.Check( aOptsItem
.GetOptionsMisc().IsQuickEdit() );
501 aCbxPickThrough
.Check( aOptsItem
.GetOptionsMisc().IsPickThrough() );
502 aCbxMasterPageCache
.Check( aOptsItem
.GetOptionsMisc().IsMasterPagePaintCaching() );
503 aCbxCopy
.Check( aOptsItem
.GetOptionsMisc().IsDragWithCopy() );
504 aCbxStartWithActualPage
.Check( aOptsItem
.GetOptionsMisc().IsStartWithActualPage() );
505 aCbxCompatibility
.Check( aOptsItem
.GetOptionsMisc().IsSummationOfParagraphs() );
506 aCbxUsePrinterMetrics
.Check( aOptsItem
.GetOptionsMisc().GetPrinterIndependentLayout()==1 );
507 aCbxStartWithTemplate
.SaveValue();
508 aCbxMarkedHitMovesAlways
.SaveValue();
509 aCbxCrookNoContortion
.SaveValue();
510 aCbxQuickEdit
.SaveValue();
511 aCbxPickThrough
.SaveValue();
513 aCbxMasterPageCache
.SaveValue();
514 aCbxCopy
.SaveValue();
515 aCbxStartWithActualPage
.SaveValue();
516 aCbxCompatibility
.SaveValue();
517 aCbxUsePrinterMetrics
.SaveValue();
520 USHORT nWhich
= GetWhich( SID_ATTR_METRIC
);
521 aLbMetric
.SetNoSelection();
523 if ( rAttrs
.GetItemState( nWhich
) >= SFX_ITEM_AVAILABLE
)
525 const SfxUInt16Item
& rItem
= (SfxUInt16Item
&)rAttrs
.Get( nWhich
);
526 long nFieldUnit
= (long)rItem
.GetValue();
528 for ( USHORT i
= 0; i
< aLbMetric
.GetEntryCount(); ++i
)
530 if ( (long)aLbMetric
.GetEntryData( i
) == nFieldUnit
)
532 aLbMetric
.SelectEntryPos( i
);
539 nWhich
= GetWhich( SID_ATTR_DEFTABSTOP
);
540 if( rAttrs
.GetItemState( nWhich
) >= SFX_ITEM_AVAILABLE
)
542 SfxMapUnit eUnit
= rAttrs
.GetPool()->GetMetric( nWhich
);
543 const SfxUInt16Item
& rItem
= (SfxUInt16Item
&)rAttrs
.Get( nWhich
);
544 SetMetricValue( aMtrFldTabstop
, rItem
.GetValue(), eUnit
);
546 aLbMetric
.SaveValue();
547 aMtrFldTabstop
.SaveValue();
549 INT32 nX
= ( (const SfxInt32Item
&) rAttrs
.
550 Get( ATTR_OPTIONS_SCALE_X
) ).GetValue();
551 INT32 nY
= ( (const SfxInt32Item
&) rAttrs
.
552 Get( ATTR_OPTIONS_SCALE_Y
) ).GetValue();
553 nWidth
= ( (const SfxUInt32Item
&) rAttrs
.
554 Get( ATTR_OPTIONS_SCALE_WIDTH
) ).GetValue();
555 nHeight
= ( (const SfxUInt32Item
&) rAttrs
.
556 Get( ATTR_OPTIONS_SCALE_HEIGHT
) ).GetValue();
558 aCbScale
.SetText( GetScale( nX
, nY
) );
560 // #92067# broken feature disabled for 6.0
562 aFtEquivalent
.Hide();
563 aMtrFldOriginalWidth
.Hide();
564 aMtrFldOriginalWidth
.SetText( aInfo1
); // leer
565 aMtrFldOriginalHeight
.Hide();
566 aMtrFldOriginalHeight
.SetText( aInfo2
); //leer
568 aFtPageHeight
.Hide();
572 UpdateCompatibilityControls ();
575 // -----------------------------------------------------------------------
577 SfxTabPage
* SdTpOptionsMisc::Create( Window
* pWindow
,
578 const SfxItemSet
& rAttrs
)
580 return( new SdTpOptionsMisc( pWindow
, rAttrs
) );
582 //------------------------------------------------------------------------
584 IMPL_LINK( SdTpOptionsMisc
, SelectMetricHdl_Impl
, ListBox
*, EMPTYARG
)
586 USHORT nPos
= aLbMetric
.GetSelectEntryPos();
588 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
590 FieldUnit eUnit
= (FieldUnit
)(long)aLbMetric
.GetEntryData( nPos
);
592 aMtrFldTabstop
.Denormalize( aMtrFldTabstop
.GetValue( FUNIT_TWIP
) );
593 SetFieldUnit( aMtrFldTabstop
, eUnit
);
594 aMtrFldTabstop
.SetValue( aMtrFldTabstop
.Normalize( nVal
), FUNIT_TWIP
);
601 void lcl_MoveWin( Window
& rWin
, long nYDiff
)
603 Point
aPos(rWin
.GetPosPixel());
605 rWin
.SetPosPixel (aPos
);
608 void lcl_MoveWin( Window
& rWin
, long nXdiff
, long nYdiff
)
610 Point
aPos(rWin
.GetPosPixel());
613 rWin
.SetPosPixel(aPos
);
617 void SdTpOptionsMisc::SetImpressMode (void)
619 long nDialogWidth
= GetSizePixel().Width();
620 long nLineHeight
= aCbxPickThrough
.GetPosPixel().Y()
621 - aCbxQuickEdit
.GetPosPixel().Y();
623 // Put both "Text objects" check boxes side by side.
624 lcl_MoveWin (aCbxPickThrough
,
625 nDialogWidth
/2 - aCbxPickThrough
.GetPosPixel().X(),
628 // Move the other controls up one line.
629 lcl_MoveWin (aGrpProgramStart
, -nLineHeight
);
630 lcl_MoveWin (aCbxStartWithTemplate
, -nLineHeight
);
631 lcl_MoveWin (aGrpSettings
, -nLineHeight
);
632 lcl_MoveWin (aCbxMasterPageCache
, -nLineHeight
);
633 lcl_MoveWin (aCbxCopy
, -nLineHeight
);
634 lcl_MoveWin (aCbxMarkedHitMovesAlways
, -nLineHeight
);
635 lcl_MoveWin (aCbxCrookNoContortion
, -nLineHeight
);
636 lcl_MoveWin (aTxtMetric
, -nLineHeight
);
637 lcl_MoveWin (aLbMetric
, -nLineHeight
);
638 lcl_MoveWin (aTxtTabstop
, -nLineHeight
);
639 lcl_MoveWin (aMtrFldTabstop
, -nLineHeight
);
640 lcl_MoveWin (aGrpStartWithActualPage
, -nLineHeight
);
641 lcl_MoveWin (aCbxStartWithActualPage
, -nLineHeight
);
642 lcl_MoveWin (aTxtCompatibility
, -nLineHeight
);
644 // Move the printer-independent-metrics check box up two lines to change
645 // places with spacing-between-paragraphs check box.
646 lcl_MoveWin (aCbxUsePrinterMetrics
, -2*nLineHeight
);
649 void SdTpOptionsMisc::SetDrawMode()
651 aCbxStartWithTemplate
.Hide();
652 aGrpProgramStart
.Hide();
653 aCbxStartWithActualPage
.Hide();
654 aCbxCompatibility
.Hide();
655 aGrpStartWithActualPage
.Hide();
656 aCbxCrookNoContortion
.Show();
663 aFtEquivalent
.Show();
667 aMtrFldOriginalWidth
.Show();
669 aFtPageHeight
.Show();
671 aMtrFldOriginalHeight
.Show();
673 long nDiff
= aGrpSettings
.GetPosPixel().Y() - aGrpProgramStart
.GetPosPixel().Y();
674 lcl_MoveWin( aGrpSettings
, -nDiff
);
675 lcl_MoveWin( aCbxMasterPageCache
, -nDiff
);
676 lcl_MoveWin( aCbxCopy
, -nDiff
);
677 lcl_MoveWin( aCbxMarkedHitMovesAlways
, -nDiff
);
678 lcl_MoveWin( aCbxCrookNoContortion
, -nDiff
);
679 nDiff
-= aCbxCrookNoContortion
.GetPosPixel().Y() - aCbxMarkedHitMovesAlways
.GetPosPixel().Y();
680 lcl_MoveWin( aTxtMetric
, -nDiff
);
681 lcl_MoveWin( aLbMetric
, -nDiff
);
682 lcl_MoveWin( aTxtTabstop
, -nDiff
);
683 lcl_MoveWin( aMtrFldTabstop
, -nDiff
);
685 // Move the scale controls so that they are visually centered betwen the
686 // group controls above and below.
687 lcl_MoveWin (aFtScale
, -17);
688 lcl_MoveWin (aCbScale
, -17);
690 // Move the printer-independent-metrics check box in the place that the
691 // spacing-between-paragraphs check box normally is in.
692 aCbxUsePrinterMetrics
.SetPosPixel (aCbxCompatibility
.GetPosPixel());
694 // -----------------------------------------------------------------------
696 IMPL_LINK( SdTpOptionsMisc
, ModifyScaleHdl
, void *, EMPTYARG
)
698 // Originalgroesse berechnen
700 if( SetScale( aCbScale
.GetText(), nX
, nY
) )
702 INT32 nW
= nWidth
* nY
/ nX
;
703 INT32 nH
= nHeight
* nY
/ nX
;
705 SetMetricValue( aMtrFldOriginalWidth
, nW
, ePoolUnit
);
706 SetMetricValue( aMtrFldOriginalHeight
, nH
, ePoolUnit
);
712 // -----------------------------------------------------------------------
714 IMPL_LINK( SdTpOptionsMisc
, ModifyOriginalScaleHdl
, void *, EMPTYARG
)
716 // Berechnen des Massstabs
717 long nOrgW
= static_cast<long>(aMtrFldOriginalWidth
.GetValue());
718 long nOrgH
= static_cast<long>(aMtrFldOriginalHeight
.GetValue());
720 if( nOrgW
== 0 || nOrgH
== 0 )
723 Fraction
aFract1( nOrgW
, static_cast<long>(aMtrFldInfo1
.GetValue()) );
724 Fraction
aFract2( nOrgH
, static_cast<long>(aMtrFldInfo2
.GetValue()) );
725 Fraction
aFract( aFract1
> aFract2
? aFract1
: aFract2
);
728 if( aFract
< Fraction( 1, 1 ) )
732 aFract
= Fraction( aFract1
.GetDenominator(), aFract1
.GetNumerator() );
735 // #92067# Swap nominator and denominator
736 aCbScale
.SetText( GetScale( nValue
, 1 ) );
740 double fValue
= aFract
;
742 if( fValue
> (double)nValue
)
745 // #92067# Swap nominator and denominator
746 aCbScale
.SetText( GetScale( 1, nValue
) );
751 // -----------------------------------------------------------------------
753 String
SdTpOptionsMisc::GetScale( INT32 nX
, INT32 nY
)
755 String
aScale( UniString::CreateFromInt32( nX
) );
756 aScale
.Append( TOKEN
);
757 aScale
.Append( UniString::CreateFromInt32( nY
) );
762 // -----------------------------------------------------------------------
764 BOOL
SdTpOptionsMisc::SetScale( const String
& aScale
, INT32
& rX
, INT32
& rY
)
766 if( aScale
.GetTokenCount( TOKEN
) != 2 )
769 ByteString
aTmp( aScale
.GetToken( 0, TOKEN
), RTL_TEXTENCODING_ASCII_US
);
770 if( !aTmp
.IsNumericAscii() )
773 rX
= (long) aTmp
.ToInt32();
777 aTmp
= ByteString( aScale
.GetToken( 1, TOKEN
), RTL_TEXTENCODING_ASCII_US
);
778 if( !aTmp
.IsNumericAscii() )
781 rY
= (long) aTmp
.ToInt32();
791 void SdTpOptionsMisc::UpdateCompatibilityControls (void)
793 // Disable the compatibility controls by default. Enable them only when
794 // there is at least one open document.
795 sal_Bool bIsEnabled
= sal_False
;
799 // Get a component enumeration from the desktop and search it for documents.
800 Reference
<lang::XMultiServiceFactory
> xFactory (
801 ::comphelper::getProcessServiceFactory ());
804 if ( ! xFactory
.is())
807 Reference
<frame::XDesktop
> xDesktop (xFactory
->createInstance (
808 ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), UNO_QUERY
);
809 if ( ! xDesktop
.is())
812 Reference
<container::XEnumerationAccess
> xComponents (
813 xDesktop
->getComponents(), UNO_QUERY
);
814 if ( ! xComponents
.is())
817 Reference
<container::XEnumeration
> xEnumeration (
818 xComponents
->createEnumeration());
819 if ( ! xEnumeration
.is())
822 while (xEnumeration
->hasMoreElements())
824 Reference
<frame::XModel
> xModel (xEnumeration
->nextElement(), UNO_QUERY
);
827 // There is at leas one model/document: Enable the compatibility controls.
828 bIsEnabled
= sal_True
;
834 while (false); // One 'loop'.
836 catch (uno::Exception e
)
838 // When there is an exception then simply use the default value of
839 // bIsEnabled and disable the controls.
842 aTxtCompatibility
.Enable (bIsEnabled
);
843 aCbxCompatibility
.Enable(bIsEnabled
);
844 aCbxUsePrinterMetrics
.Enable (bIsEnabled
);
847 void SdTpOptionsMisc::PageCreated (SfxAllItemSet aSet
)
849 SFX_ITEMSET_ARG (&aSet
,pFlagItem
,SfxUInt32Item
,SID_SDMODE_FLAG
,sal_False
);
852 UINT32 nFlags
=pFlagItem
->GetValue();
853 if ( ( nFlags
& SD_DRAW_MODE
) == SD_DRAW_MODE
)
855 if ( ( nFlags
& SD_IMPRESS_MODE
) == SD_IMPRESS_MODE
)
860 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */