1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <sal/config.h>
21 
22 #include <o3tl/any.hxx>
23 #include <svx/svdmodel.hxx>
24 #include <svx/svxids.hrc>
25 #include <tools/debug.hxx>
26 #include <tools/helpers.hxx>
27 #include <unotools/localedatawrapper.hxx>
28 #include <unotools/syslocale.hxx>
29 #include <osl/diagnose.h>
30 
31 #include <optsitem.hxx>
32 #include <FrameView.hxx>
33 #include <sdattr.hrc>
34 
35 using namespace ::utl;
36 using namespace ::com::sun::star::uno;
37 
getSafeValue(const Any & rAny)38 template< class T > static T getSafeValue( const Any& rAny )
39 {
40     T value = T();
41     bool bOk = (rAny >>= value);
42 
43     DBG_ASSERT( bOk, "SdOptionsItem, wrong type from configuration!" );
44 
45     return value;
46 }
47 
48 
SdOptionsItem(const SdOptionsGeneric & rParent,const OUString & rSubTree)49 SdOptionsItem::SdOptionsItem( const SdOptionsGeneric& rParent, const OUString& rSubTree ) :
50     ConfigItem  ( rSubTree ),
51     mrParent    ( rParent )
52 {
53 }
54 
~SdOptionsItem()55 SdOptionsItem::~SdOptionsItem()
56 {
57 }
58 
ImplCommit()59 void SdOptionsItem::ImplCommit()
60 {
61     if( IsModified() )
62         mrParent.Commit( *this );
63 };
64 
Notify(const css::uno::Sequence<OUString> &)65 void SdOptionsItem::Notify( const css::uno::Sequence<OUString>& )
66 {}
67 
GetProperties(const Sequence<OUString> & rNames)68 Sequence< Any > SdOptionsItem::GetProperties( const Sequence< OUString >& rNames )
69 {
70     return ConfigItem::GetProperties( rNames );
71 }
72 
PutProperties(const Sequence<OUString> & rNames,const Sequence<Any> & rValues)73 bool SdOptionsItem::PutProperties( const Sequence< OUString >& rNames, const Sequence< Any>& rValues )
74 {
75     return ConfigItem::PutProperties( rNames, rValues );
76 }
77 
SdOptionsGeneric(bool bImpress,const OUString & rSubTree)78 SdOptionsGeneric::SdOptionsGeneric(bool bImpress, const OUString& rSubTree)
79     : maSubTree(rSubTree)
80     , mbImpress(bImpress)
81     , mbInit(rSubTree.isEmpty())
82     , mbEnableModify(false)
83 {
84 }
85 
SdOptionsGeneric(SdOptionsGeneric const & rSource)86 SdOptionsGeneric::SdOptionsGeneric(SdOptionsGeneric const & rSource)
87 {
88     operator=(rSource);
89 }
90 
operator =(SdOptionsGeneric const & rSource)91 SdOptionsGeneric& SdOptionsGeneric::operator=(SdOptionsGeneric const & rSource)
92 {
93     if (this != &rSource)
94     {
95         maSubTree = rSource.maSubTree;
96         mpCfgItem.reset(rSource.mpCfgItem ? new SdOptionsItem(*rSource.mpCfgItem) : nullptr );
97         mbImpress = rSource.mbImpress;
98         mbInit = rSource.mbInit;
99         mbEnableModify = rSource.mbEnableModify;
100     }
101     return *this;
102 }
103 
Init() const104 void SdOptionsGeneric::Init() const
105 {
106     if( mbInit )
107         return;
108 
109     SdOptionsGeneric* pThis = const_cast<SdOptionsGeneric*>(this);
110 
111     if( !mpCfgItem )
112         pThis->mpCfgItem.reset( new SdOptionsItem( *this, maSubTree ) );
113 
114     const Sequence< OUString >  aNames( GetPropertyNames() );
115     const Sequence< Any >       aValues = mpCfgItem->GetProperties( aNames );
116 
117     if( aNames.hasElements() && ( aValues.getLength() == aNames.getLength() ) )
118     {
119         const Any* pValues = aValues.getConstArray();
120 
121         pThis->EnableModify( false );
122         pThis->mbInit = pThis->ReadData( pValues );
123         pThis->EnableModify( true );
124     }
125     else
126         pThis->mbInit = true;
127 }
128 
~SdOptionsGeneric()129 SdOptionsGeneric::~SdOptionsGeneric()
130 {
131 }
132 
Commit(SdOptionsItem & rCfgItem) const133 void SdOptionsGeneric::Commit( SdOptionsItem& rCfgItem ) const
134 {
135     const Sequence< OUString >  aNames( GetPropertyNames() );
136     Sequence< Any >             aValues( aNames.getLength() );
137 
138     if( aNames.hasElements() )
139     {
140         if( WriteData( aValues.getArray() ) )
141             rCfgItem.PutProperties( aNames, aValues );
142         else
143         {
144             OSL_FAIL( "PutProperties failed" );
145         }
146     }
147 }
148 
GetPropertyNames() const149 Sequence< OUString > SdOptionsGeneric::GetPropertyNames() const
150 {
151     sal_uLong           nCount;
152     const char**    ppPropNames;
153 
154     GetPropNameArray( ppPropNames, nCount );
155 
156     Sequence< OUString > aNames( nCount );
157     OUString*            pNames = aNames.getArray();
158 
159     for( sal_uLong i = 0; i < nCount; i++ )
160         pNames[ i ] = OUString::createFromAscii( ppPropNames[ i ] );
161 
162     return aNames;
163 }
164 
Store()165 void SdOptionsGeneric::Store()
166 {
167     if( mpCfgItem )
168         mpCfgItem->Commit();
169 }
170 
isMetricSystem()171 bool SdOptionsGeneric::isMetricSystem()
172 {
173     SvtSysLocale aSysLocale;
174     MeasurementSystem eSys = aSysLocale.GetLocaleData().getMeasurementSystemEnum();
175 
176     return ( eSys == MeasurementSystem::Metric );
177 }
178 
179 /*************************************************************************
180 |*
181 |* SdOptionsLayout
182 |*
183 \************************************************************************/
184 
SdOptionsLayout(bool bImpress,bool bUseConfig)185 SdOptionsLayout::SdOptionsLayout(bool bImpress, bool bUseConfig) :
186     SdOptionsGeneric( bImpress, bUseConfig ?
187                       ( bImpress ?
188                         OUString( "Office.Impress/Layout" ) :
189                         OUString( "Office.Draw/Layout" ) ) :
190                       OUString() ),
191     bRuler( true ),
192     bMoveOutline( true ),
193     bDragStripes( false ),
194     bHandlesBezier( false ),
195     bHelplines( true ),
196     nMetric(static_cast<sal_uInt16>(isMetricSystem() ? FieldUnit::CM : FieldUnit::INCH)),
197     nDefTab( 1250 )
198 {
199     EnableModify( true );
200 }
201 
operator ==(const SdOptionsLayout & rOpt) const202 bool SdOptionsLayout::operator==( const SdOptionsLayout& rOpt ) const
203 {
204     return( IsRulerVisible() == rOpt.IsRulerVisible() &&
205             IsMoveOutline() == rOpt.IsMoveOutline() &&
206             IsDragStripes() == rOpt.IsDragStripes() &&
207             IsHandlesBezier() == rOpt.IsHandlesBezier() &&
208             IsHelplines() == rOpt.IsHelplines() &&
209             GetMetric() == rOpt.GetMetric() &&
210             GetDefTab() == rOpt.GetDefTab() );
211 }
212 
GetPropNameArray(const char ** & ppNames,sal_uLong & rCount) const213 void SdOptionsLayout::GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const
214 {
215     if( isMetricSystem() )
216     {
217         static const char* aPropNamesMetric[] =
218         {
219             "Display/Ruler",
220             "Display/Bezier",
221             "Display/Contour",
222             "Display/Guide",
223             "Display/Helpline",
224             "Other/MeasureUnit/Metric",
225             "Other/TabStop/Metric"
226         };
227         ppNames = aPropNamesMetric;
228         rCount = SAL_N_ELEMENTS(aPropNamesMetric);
229     }
230     else
231     {
232         static const char* aPropNamesNonMetric[] =
233         {
234             "Display/Ruler",
235             "Display/Bezier",
236             "Display/Contour",
237             "Display/Guide",
238             "Display/Helpline",
239             "Other/MeasureUnit/NonMetric",
240             "Other/TabStop/NonMetric"
241         };
242         ppNames = aPropNamesNonMetric;
243         rCount = SAL_N_ELEMENTS(aPropNamesNonMetric);
244     }
245 }
246 
ReadData(const Any * pValues)247 bool SdOptionsLayout::ReadData( const Any* pValues )
248 {
249     if( pValues[0].hasValue() ) SetRulerVisible( *o3tl::doAccess<bool>(pValues[ 0 ]) );
250     if( pValues[1].hasValue() ) SetHandlesBezier( *o3tl::doAccess<bool>(pValues[ 1 ]) );
251     if( pValues[2].hasValue() ) SetMoveOutline( *o3tl::doAccess<bool>(pValues[ 2 ]) );
252     if( pValues[3].hasValue() ) SetDragStripes( *o3tl::doAccess<bool>(pValues[ 3 ]) );
253     if( pValues[4].hasValue() ) SetHelplines( *o3tl::doAccess<bool>(pValues[ 4 ]) );
254     if( pValues[5].hasValue() ) SetMetric( static_cast<sal_uInt16>(*o3tl::doAccess<sal_Int32>(pValues[ 5 ])) );
255     if( pValues[6].hasValue() ) SetDefTab( static_cast<sal_uInt16>(*o3tl::doAccess<sal_Int32>(pValues[ 6 ])) );
256 
257     return true;
258 }
259 
WriteData(Any * pValues) const260 bool SdOptionsLayout::WriteData( Any* pValues ) const
261 {
262     pValues[ 0 ] <<= IsRulerVisible();
263     pValues[ 1 ] <<= IsHandlesBezier();
264     pValues[ 2 ] <<= IsMoveOutline();
265     pValues[ 3 ] <<= IsDragStripes();
266     pValues[ 4 ] <<= IsHelplines();
267     pValues[ 5 ] <<= static_cast<sal_Int32>(GetMetric());
268     pValues[ 6 ] <<= static_cast<sal_Int32>(GetDefTab());
269 
270     return true;
271 }
272 
273 /*************************************************************************
274 |*
275 |* SdOptionsLayoutItem
276 |*
277 \************************************************************************/
278 
SdOptionsLayoutItem()279 SdOptionsLayoutItem::SdOptionsLayoutItem()
280 :   SfxPoolItem     ( ATTR_OPTIONS_LAYOUT )
281 ,   maOptionsLayout ( false, false )
282 {
283 }
284 
SdOptionsLayoutItem(SdOptions const * pOpts,::sd::FrameView const * pView)285 SdOptionsLayoutItem::SdOptionsLayoutItem( SdOptions const * pOpts, ::sd::FrameView const * pView )
286 :   SfxPoolItem     ( ATTR_OPTIONS_LAYOUT )
287 ,   maOptionsLayout ( false, false )
288 {
289     if( pOpts )
290     {
291         maOptionsLayout.SetMetric( pOpts->GetMetric() );
292         maOptionsLayout.SetDefTab( pOpts->GetDefTab() );
293     }
294 
295     if( pView )
296     {
297         maOptionsLayout.SetRulerVisible( pView->HasRuler() );
298         maOptionsLayout.SetMoveOutline( !pView->IsNoDragXorPolys() );
299         maOptionsLayout.SetDragStripes( pView->IsDragStripes() );
300         maOptionsLayout.SetHandlesBezier( pView->IsPlusHandlesAlwaysVisible() );
301         maOptionsLayout.SetHelplines( pView->IsHlplVisible() );
302     }
303     else if( pOpts )
304     {
305         maOptionsLayout.SetRulerVisible( pOpts->IsRulerVisible() );
306         maOptionsLayout.SetMoveOutline( pOpts->IsMoveOutline() );
307         maOptionsLayout.SetDragStripes( pOpts->IsDragStripes() );
308         maOptionsLayout.SetHandlesBezier( pOpts->IsHandlesBezier() );
309         maOptionsLayout.SetHelplines( pOpts->IsHelplines() );
310     }
311 }
312 
Clone(SfxItemPool *) const313 SdOptionsLayoutItem* SdOptionsLayoutItem::Clone( SfxItemPool* ) const
314 {
315     return new SdOptionsLayoutItem( *this );
316 }
317 
operator ==(const SfxPoolItem & rAttr) const318 bool SdOptionsLayoutItem::operator==( const SfxPoolItem& rAttr ) const
319 {
320     assert(SfxPoolItem::operator==(rAttr));
321     return maOptionsLayout == static_cast<const SdOptionsLayoutItem&>(rAttr).maOptionsLayout;
322 }
323 
SetOptions(SdOptions * pOpts) const324 void SdOptionsLayoutItem::SetOptions( SdOptions* pOpts ) const
325 {
326     if( pOpts )
327     {
328         pOpts->SetRulerVisible( maOptionsLayout.IsRulerVisible() );
329         pOpts->SetMoveOutline( maOptionsLayout.IsMoveOutline() );
330         pOpts->SetDragStripes( maOptionsLayout.IsDragStripes() );
331         pOpts->SetHandlesBezier( maOptionsLayout.IsHandlesBezier() );
332         pOpts->SetHelplines( maOptionsLayout.IsHelplines() );
333         pOpts->SetMetric( maOptionsLayout.GetMetric() );
334         pOpts->SetDefTab( maOptionsLayout.GetDefTab() );
335     }
336 }
337 
338 /*************************************************************************
339 |*
340 |* SdOptionsContents
341 |*
342 \************************************************************************/
343 
SdOptionsContents(bool bImpress)344 SdOptionsContents::SdOptionsContents(bool bImpress) :
345     SdOptionsGeneric( bImpress, bImpress ?
346                         OUString( "Office.Impress/Content" ) :
347                         OUString( "Office.Draw/Content" ) )
348 {
349     EnableModify( true );
350 }
351 
operator ==(const SdOptionsContents &) const352 bool SdOptionsContents::operator==(const SdOptionsContents&) const
353 {
354     return true;
355 }
356 
GetPropNameArray(const char ** & ppNames,sal_uLong & rCount) const357 void SdOptionsContents::GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const
358 {
359     static const char* aPropNames[] =
360     {
361         "Display/PicturePlaceholder",
362         "Display/ContourMode",
363         "Display/LineContour",
364         "Display/TextPlaceholder"
365     };
366 
367     rCount = SAL_N_ELEMENTS(aPropNames);
368     ppNames = aPropNames;
369 }
370 
ReadData(const Any *)371 bool SdOptionsContents::ReadData(const Any*)
372 {
373     return true;
374 }
375 
WriteData(Any * pValues) const376 bool SdOptionsContents::WriteData( Any* pValues ) const
377 {
378     //#i80528# no draft anymore
379     pValues[ 0 ] <<= false;
380     pValues[ 1 ] <<= false;
381     pValues[ 2 ] <<= false;
382     pValues[ 3 ] <<= false;
383 
384     return true;
385 }
386 /*************************************************************************
387 |*
388 |* SdOptionsMisc
389 |*
390 \************************************************************************/
391 
SdOptionsMisc(bool bImpress,bool bUseConfig)392 SdOptionsMisc::SdOptionsMisc( bool bImpress, bool bUseConfig ) :
393     SdOptionsGeneric( bImpress, bUseConfig ?
394                       ( bImpress ?
395                         OUString( "Office.Impress/Misc" ) :
396                         OUString( "Office.Draw/Misc" ) ) :
397                       OUString() ),
398     nDefaultObjectSizeWidth(8000),
399     nDefaultObjectSizeHeight(5000),
400     bStartWithTemplate( false ),
401     bMarkedHitMovesAlways( true ),
402     bMoveOnlyDragging( false ),
403     bCrookNoContortion( false ),
404     bQuickEdit( IsImpress() ),
405     bMasterPageCache( true ),
406     bDragWithCopy( false ),
407     bPickThrough( true ),
408     bDoubleClickTextEdit( true ),
409     bClickChangeRotation( false ),
410     bEnableSdremote( false ),
411     bEnablePresenterScreen( true),
412     bSolidDragging( true ),
413     bSummationOfParagraphs( false ),
414     bTabBarVisible( true ),
415     bShowUndoDeleteWarning( true ),
416     bSlideshowRespectZOrder( true ),
417     bShowComments( true ),
418     bPreviewNewEffects( true ),
419     bPreviewChangedEffects( false ),
420     bPreviewTransitions( true ),
421     mnDisplay( 0 ),
422     mnPenColor( 0xff0000 ),
423     mnPenWidth( 150.0 ),
424 
425     // The default for 6.1-and-above documents is to use printer-independent
426     // formatting.
427     mnPrinterIndependentLayout (1)
428 {
429     EnableModify( true );
430 }
431 
operator ==(const SdOptionsMisc & rOpt) const432 bool SdOptionsMisc::operator==( const SdOptionsMisc& rOpt ) const
433 {
434     return( IsStartWithTemplate() == rOpt.IsStartWithTemplate() &&
435             IsMarkedHitMovesAlways() == rOpt.IsMarkedHitMovesAlways() &&
436             IsMoveOnlyDragging() == rOpt.IsMoveOnlyDragging() &&
437             IsCrookNoContortion() == rOpt.IsCrookNoContortion() &&
438             IsQuickEdit() == rOpt.IsQuickEdit() &&
439             IsMasterPagePaintCaching() == rOpt.IsMasterPagePaintCaching() &&
440             IsDragWithCopy() == rOpt.IsDragWithCopy() &&
441             IsPickThrough() == rOpt.IsPickThrough() &&
442             IsDoubleClickTextEdit() == rOpt.IsDoubleClickTextEdit() &&
443             IsClickChangeRotation() == rOpt.IsClickChangeRotation() &&
444             IsEnableSdremote() == rOpt.IsEnableSdremote() &&
445             IsEnablePresenterScreen() == rOpt.IsEnablePresenterScreen()&&
446             IsSummationOfParagraphs() == rOpt.IsSummationOfParagraphs() &&
447             IsTabBarVisible() == rOpt.IsTabBarVisible() &&
448             IsSolidDragging() == rOpt.IsSolidDragging() &&
449             IsShowUndoDeleteWarning() == rOpt.IsShowUndoDeleteWarning() &&
450             IsSlideshowRespectZOrder() == rOpt.IsSlideshowRespectZOrder() &&
451             GetPrinterIndependentLayout() == rOpt.GetPrinterIndependentLayout() &&
452             GetDefaultObjectSizeWidth() == rOpt.GetDefaultObjectSizeWidth() &&
453             GetDefaultObjectSizeHeight() == rOpt.GetDefaultObjectSizeHeight() &&
454 
455             IsPreviewNewEffects() == rOpt.IsPreviewNewEffects() &&
456             IsPreviewChangedEffects() == rOpt.IsPreviewChangedEffects() &&
457             IsPreviewTransitions() == rOpt.IsPreviewTransitions() &&
458             GetDisplay() == rOpt.GetDisplay() &&
459             IsShowComments() == rOpt.IsShowComments() &&
460             GetPresentationPenColor() == rOpt.GetPresentationPenColor() &&
461             GetPresentationPenWidth() == rOpt.GetPresentationPenWidth()
462         );
463 }
464 
GetPropNameArray(const char ** & ppNames,sal_uLong & rCount) const465 void SdOptionsMisc::GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const
466 {
467     static const char* aPropNames[] =
468     {
469         "ObjectMoveable",
470         "NoDistort",
471         "TextObject/QuickEditing",
472         "BackgroundCache",
473         "CopyWhileMoving",
474         "TextObject/Selectable",
475         "DclickTextedit",
476         "RotateClick",
477         "Preview",
478         "ModifyWithAttributes",
479         "DefaultObjectSize/Width",
480         "DefaultObjectSize/Height",
481 
482         "Compatibility/PrinterIndependentLayout",
483 
484         "ShowComments",
485 
486         // just for impress
487         "NewDoc/AutoPilot",
488         "Compatibility/AddBetween",
489         "ShowUndoDeleteWarning",
490         "SlideshowRespectZOrder",
491 
492         "PreviewNewEffects",
493         "PreviewChangedEffects",
494         "PreviewTransitions",
495 
496         "Display",
497 
498         "PenColor",
499         "PenWidth",
500         "Start/EnableSdremote",
501         "Start/EnablePresenterScreen",
502         "TabBarVisible"
503     };
504 
505     rCount = ( IsImpress() ? SAL_N_ELEMENTS(aPropNames) : 14 );
506     ppNames = aPropNames;
507 }
508 
ReadData(const Any * pValues)509 bool SdOptionsMisc::ReadData( const Any* pValues )
510 {
511     if( pValues[0].hasValue() ) SetMarkedHitMovesAlways( *o3tl::doAccess<bool>(pValues[ 0 ]) );
512     if( pValues[1].hasValue() ) SetCrookNoContortion( *o3tl::doAccess<bool>(pValues[ 1 ]) );
513     if( pValues[2].hasValue() ) SetQuickEdit( *o3tl::doAccess<bool>(pValues[ 2 ]) );
514     if( pValues[3].hasValue() ) SetMasterPagePaintCaching( *o3tl::doAccess<bool>(pValues[ 3 ]) );
515     if( pValues[4].hasValue() ) SetDragWithCopy( *o3tl::doAccess<bool>(pValues[ 4 ]) );
516     if( pValues[5].hasValue() ) SetPickThrough( *o3tl::doAccess<bool>(pValues[ 5 ]) );
517     if( pValues[6].hasValue() ) SetDoubleClickTextEdit( *o3tl::doAccess<bool>(pValues[ 6 ]) );
518     if( pValues[7].hasValue() ) SetClickChangeRotation( *o3tl::doAccess<bool>(pValues[ 7 ]) );
519     if( pValues[9].hasValue() ) SetSolidDragging( *o3tl::doAccess<bool>(pValues[ 9 ]) );
520     if( pValues[10].hasValue() ) SetDefaultObjectSizeWidth( *o3tl::doAccess<sal_uInt32>(pValues[ 10 ]) );
521     if( pValues[11].hasValue() ) SetDefaultObjectSizeHeight( *o3tl::doAccess<sal_uInt32>(pValues[ 11 ]) );
522     if( pValues[12].hasValue() ) SetPrinterIndependentLayout( *o3tl::doAccess<sal_uInt16>(pValues[ 12 ]) );
523 
524     if( pValues[13].hasValue() )
525         SetShowComments(  *o3tl::doAccess<bool>(pValues[ 13 ]) );
526 
527     // just for Impress
528     if (IsImpress())
529     {
530         if( pValues[14].hasValue() )
531             SetStartWithTemplate( *o3tl::doAccess<bool>(pValues[ 14 ]) );
532         if( pValues[15].hasValue() )
533             SetSummationOfParagraphs( *o3tl::doAccess<bool>(pValues[ 15 ]) );
534         if( pValues[16].hasValue() )
535             SetShowUndoDeleteWarning( *o3tl::doAccess<bool>(pValues[ 16 ]) );
536 
537         if( pValues[17].hasValue() )
538             SetSlideshowRespectZOrder(*o3tl::doAccess<bool>(pValues[ 17 ]));
539 
540         if( pValues[18].hasValue() )
541             SetPreviewNewEffects(*o3tl::doAccess<bool>(pValues[ 18 ]));
542 
543         if( pValues[19].hasValue() )
544             SetPreviewChangedEffects(*o3tl::doAccess<bool>(pValues[ 19 ]));
545 
546         if( pValues[20].hasValue() )
547             SetPreviewTransitions(*o3tl::doAccess<bool>(pValues[ 20 ]));
548 
549         if( pValues[21].hasValue() )
550             SetDisplay(*o3tl::doAccess<sal_Int32>(pValues[ 21 ]));
551 
552         if( pValues[22].hasValue() )
553             SetPresentationPenColor( getSafeValue< sal_Int32 >( pValues[ 22 ] ) );
554 
555         if( pValues[23].hasValue() )
556             SetPresentationPenWidth( getSafeValue< double >( pValues[ 23 ] ) );
557 
558         if( pValues[24].hasValue() )
559             SetEnableSdremote( *o3tl::doAccess<bool>(pValues[ 24 ]) );
560 
561         if( pValues[25].hasValue() )
562             SetEnablePresenterScreen( *o3tl::doAccess<bool>(pValues[ 25 ]) );
563 
564         if( pValues[26].hasValue() ) {
565             SetTabBarVisible( *o3tl::doAccess<bool>(pValues[ 26 ]) );
566         }
567     }
568 
569     return true;
570 }
571 
WriteData(Any * pValues) const572 bool SdOptionsMisc::WriteData( Any* pValues ) const
573 {
574     pValues[ 0 ] <<= IsMarkedHitMovesAlways();
575     pValues[ 1 ] <<= IsCrookNoContortion();
576     pValues[ 2 ] <<= IsQuickEdit();
577     pValues[ 3 ] <<= IsMasterPagePaintCaching();
578     pValues[ 4 ] <<= IsDragWithCopy();
579     pValues[ 5 ] <<= IsPickThrough();
580     pValues[ 6 ] <<= IsDoubleClickTextEdit();
581     pValues[ 7 ] <<= IsClickChangeRotation();
582     // The preview is not supported anymore.  Use a dummy value.
583     pValues[ 8 ] <<= double(0);// GetPreviewQuality();
584     pValues[ 9 ] <<= IsSolidDragging();
585     pValues[ 10 ] <<= GetDefaultObjectSizeWidth();
586     pValues[ 11 ] <<= GetDefaultObjectSizeHeight();
587     pValues[ 12 ] <<= GetPrinterIndependentLayout();
588     pValues[ 13 ] <<= IsShowComments();
589 
590     // just for Impress
591     if (IsImpress())
592     {
593         pValues[ 14 ] <<= IsStartWithTemplate();
594         pValues[ 15 ] <<= IsSummationOfParagraphs();
595         pValues[ 16 ] <<= IsShowUndoDeleteWarning();
596         pValues[ 17 ] <<= IsSlideshowRespectZOrder();
597 
598         pValues[ 18 ] <<= IsPreviewNewEffects();
599         pValues[ 19 ] <<= IsPreviewChangedEffects();
600         pValues[ 20 ] <<= IsPreviewTransitions();
601 
602         pValues[ 21 ] <<= GetDisplay();
603 
604         pValues[ 22 ] <<= GetPresentationPenColor();
605         pValues[ 23 ] <<= GetPresentationPenWidth();
606         pValues[ 24 ] <<= IsEnableSdremote();
607         pValues[ 25 ] <<= IsEnablePresenterScreen();
608         pValues[ 26 ] <<= IsTabBarVisible();
609     }
610 
611     return true;
612 }
613 
614 /*************************************************************************
615 |*
616 |* SdOptionsMiscItem
617 |*
618 \************************************************************************/
619 
SdOptionsMiscItem()620 SdOptionsMiscItem::SdOptionsMiscItem()
621 :   SfxPoolItem     ( ATTR_OPTIONS_MISC )
622 ,   maOptionsMisc   ( false, false )
623 {
624 }
625 
SdOptionsMiscItem(SdOptions const * pOpts,::sd::FrameView const * pView)626 SdOptionsMiscItem::SdOptionsMiscItem( SdOptions const * pOpts, ::sd::FrameView const * pView )
627 :   SfxPoolItem     ( ATTR_OPTIONS_MISC )
628 ,   maOptionsMisc   ( false, false )
629 {
630     if( pOpts )
631     {
632         maOptionsMisc.SetStartWithTemplate( pOpts->IsStartWithTemplate() );
633         maOptionsMisc.SetEnableSdremote( pOpts->IsEnableSdremote() );
634         maOptionsMisc.SetEnablePresenterScreen( pOpts->IsEnablePresenterScreen() );
635         maOptionsMisc.SetSummationOfParagraphs( pOpts->IsSummationOfParagraphs() );
636         maOptionsMisc.SetTabBarVisible( pOpts->IsTabBarVisible() );
637         maOptionsMisc.SetShowUndoDeleteWarning( pOpts->IsShowUndoDeleteWarning() );
638         maOptionsMisc.SetPrinterIndependentLayout( pOpts->GetPrinterIndependentLayout() );
639         maOptionsMisc.SetDefaultObjectSizeWidth( pOpts->GetDefaultObjectSizeWidth() );
640         maOptionsMisc.SetDefaultObjectSizeHeight( pOpts->GetDefaultObjectSizeHeight() );
641 
642         maOptionsMisc.SetPreviewNewEffects(pOpts->IsPreviewNewEffects());
643         maOptionsMisc.SetPreviewChangedEffects(pOpts->IsPreviewChangedEffects());
644         maOptionsMisc.SetPreviewTransitions(pOpts->IsPreviewTransitions());
645 
646         maOptionsMisc.SetDisplay(pOpts->GetDisplay());
647         maOptionsMisc.SetShowComments( pOpts->IsShowComments() );
648 
649         maOptionsMisc.SetPresentationPenColor(pOpts->GetPresentationPenColor() );
650         maOptionsMisc.SetPresentationPenWidth(pOpts->GetPresentationPenWidth() );
651     }
652 
653     if( pView )
654     {
655         maOptionsMisc.SetMarkedHitMovesAlways( pView->IsMarkedHitMovesAlways() );
656         maOptionsMisc.SetMoveOnlyDragging( pView->IsMoveOnlyDragging() );
657         maOptionsMisc.SetCrookNoContortion( pView->IsCrookNoContortion() );
658         maOptionsMisc.SetQuickEdit( pView->IsQuickEdit() );
659 
660         // #i26631#
661         maOptionsMisc.SetMasterPagePaintCaching( pView->IsMasterPagePaintCaching() );
662 
663         maOptionsMisc.SetDragWithCopy( pView->IsDragWithCopy() );
664         maOptionsMisc.SetPickThrough( pView->GetModel()->IsPickThroughTransparentTextFrames() );
665         maOptionsMisc.SetDoubleClickTextEdit( pView->IsDoubleClickTextEdit() );
666         maOptionsMisc.SetClickChangeRotation( pView->IsClickChangeRotation() );
667         maOptionsMisc.SetSolidDragging( pView->IsSolidDragging() );
668     }
669     else if( pOpts )
670     {
671         maOptionsMisc.SetMarkedHitMovesAlways( pOpts->IsMarkedHitMovesAlways() );
672         maOptionsMisc.SetMoveOnlyDragging( pOpts->IsMoveOnlyDragging() );
673         maOptionsMisc.SetCrookNoContortion( pOpts->IsCrookNoContortion() );
674         maOptionsMisc.SetQuickEdit( pOpts->IsQuickEdit() );
675         maOptionsMisc.SetMasterPagePaintCaching( pOpts->IsMasterPagePaintCaching() );
676         maOptionsMisc.SetDragWithCopy( pOpts->IsDragWithCopy() );
677         maOptionsMisc.SetPickThrough( pOpts->IsPickThrough() );
678         maOptionsMisc.SetDoubleClickTextEdit( pOpts->IsDoubleClickTextEdit() );
679         maOptionsMisc.SetClickChangeRotation( pOpts->IsClickChangeRotation() );
680         maOptionsMisc.SetSolidDragging( pOpts->IsSolidDragging() );
681     }
682 }
683 
Clone(SfxItemPool *) const684 SdOptionsMiscItem* SdOptionsMiscItem::Clone( SfxItemPool* ) const
685 {
686     return new SdOptionsMiscItem( *this );
687 }
688 
operator ==(const SfxPoolItem & rAttr) const689 bool SdOptionsMiscItem::operator==( const SfxPoolItem& rAttr ) const
690 {
691     assert(SfxPoolItem::operator==(rAttr));
692     return maOptionsMisc == static_cast<const SdOptionsMiscItem&>(rAttr).maOptionsMisc;
693 }
694 
SetOptions(SdOptions * pOpts) const695 void SdOptionsMiscItem::SetOptions( SdOptions* pOpts ) const
696 {
697     if( !pOpts )
698         return;
699 
700     pOpts->SetStartWithTemplate( maOptionsMisc.IsStartWithTemplate() );
701     pOpts->SetMarkedHitMovesAlways( maOptionsMisc.IsMarkedHitMovesAlways() );
702     pOpts->SetMoveOnlyDragging( maOptionsMisc.IsMoveOnlyDragging() );
703     pOpts->SetCrookNoContortion( maOptionsMisc.IsCrookNoContortion() );
704     pOpts->SetQuickEdit( maOptionsMisc.IsQuickEdit() );
705     pOpts->SetMasterPagePaintCaching( maOptionsMisc.IsMasterPagePaintCaching() );
706     pOpts->SetDragWithCopy( maOptionsMisc.IsDragWithCopy() );
707     pOpts->SetPickThrough( maOptionsMisc.IsPickThrough() );
708     pOpts->SetDoubleClickTextEdit( maOptionsMisc.IsDoubleClickTextEdit() );
709     pOpts->SetClickChangeRotation( maOptionsMisc.IsClickChangeRotation() );
710     pOpts->SetEnableSdremote( maOptionsMisc.IsEnableSdremote() );
711     pOpts->SetEnablePresenterScreen( maOptionsMisc.IsEnablePresenterScreen() );
712     pOpts->SetSummationOfParagraphs( maOptionsMisc.IsSummationOfParagraphs() );
713     pOpts->SetTabBarVisible( maOptionsMisc.IsTabBarVisible() );
714 
715     pOpts->SetSolidDragging( maOptionsMisc.IsSolidDragging() );
716     pOpts->SetShowUndoDeleteWarning( maOptionsMisc.IsShowUndoDeleteWarning() );
717     pOpts->SetPrinterIndependentLayout( maOptionsMisc.GetPrinterIndependentLayout() );
718     pOpts->SetShowComments( maOptionsMisc.IsShowComments() );
719     pOpts->SetDefaultObjectSizeWidth( maOptionsMisc.GetDefaultObjectSizeWidth() );
720     pOpts->SetDefaultObjectSizeHeight( maOptionsMisc.GetDefaultObjectSizeHeight() );
721 
722     pOpts->SetPreviewNewEffects( maOptionsMisc.IsPreviewNewEffects() );
723     pOpts->SetPreviewChangedEffects( maOptionsMisc.IsPreviewChangedEffects() );
724     pOpts->SetPreviewTransitions( maOptionsMisc.IsPreviewTransitions() );
725 
726     pOpts->SetDisplay( maOptionsMisc.GetDisplay() );
727 
728     pOpts->SetPresentationPenColor( maOptionsMisc.GetPresentationPenColor() );
729     pOpts->SetPresentationPenWidth( maOptionsMisc.GetPresentationPenWidth() );
730 }
731 
732 /*************************************************************************
733 |*
734 |* SdOptionsSnap
735 |*
736 \************************************************************************/
737 
SdOptionsSnap(bool bImpress,bool bUseConfig)738 SdOptionsSnap::SdOptionsSnap( bool bImpress, bool bUseConfig ) :
739     SdOptionsGeneric( bImpress, bUseConfig ?
740                       ( bImpress ?
741                         OUString( "Office.Impress/Snap" ) :
742                         OUString( "Office.Draw/Snap" ) ) :
743                       OUString() ),
744     bSnapHelplines( true ),
745     bSnapBorder( true ),
746     bSnapFrame( false ),
747     bSnapPoints( false ),
748     bOrtho( false ),
749     bBigOrtho( true ),
750     bRotate( false ),
751     nSnapArea( 5 ),
752     nAngle( 1500 ),
753     nBezAngle( 1500 )
754 
755 {
756     EnableModify( true );
757 }
758 
operator ==(const SdOptionsSnap & rOpt) const759 bool SdOptionsSnap::operator==( const SdOptionsSnap& rOpt ) const
760 {
761     return( IsSnapHelplines() == rOpt.IsSnapHelplines() &&
762             IsSnapBorder() == rOpt.IsSnapBorder() &&
763             IsSnapFrame() == rOpt.IsSnapFrame() &&
764             IsSnapPoints() == rOpt.IsSnapPoints() &&
765             IsOrtho() == rOpt.IsOrtho() &&
766             IsBigOrtho() == rOpt.IsBigOrtho() &&
767             IsRotate() == rOpt.IsRotate() &&
768             GetSnapArea() == rOpt.GetSnapArea() &&
769             GetAngle() == rOpt.GetAngle() &&
770             GetEliminatePolyPointLimitAngle() == rOpt.GetEliminatePolyPointLimitAngle() );
771 }
772 
GetPropNameArray(const char ** & ppNames,sal_uLong & rCount) const773 void SdOptionsSnap::GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const
774 {
775     static const char* aPropNames[] =
776     {
777         "Object/SnapLine",
778         "Object/PageMargin",
779         "Object/ObjectFrame",
780         "Object/ObjectPoint",
781         "Position/CreatingMoving",
782         "Position/ExtendEdges",
783         "Position/Rotating",
784         "Object/Range",
785         "Position/RotatingValue",
786         "Position/PointReduction"
787     };
788 
789     rCount = SAL_N_ELEMENTS(aPropNames);
790     ppNames = aPropNames;
791 }
792 
ReadData(const Any * pValues)793 bool SdOptionsSnap::ReadData( const Any* pValues )
794 {
795     if( pValues[0].hasValue() ) SetSnapHelplines( *o3tl::doAccess<bool>(pValues[ 0 ]) );
796     if( pValues[1].hasValue() ) SetSnapBorder( *o3tl::doAccess<bool>(pValues[ 1 ]) );
797     if( pValues[2].hasValue() ) SetSnapFrame( *o3tl::doAccess<bool>(pValues[ 2 ]) );
798     if( pValues[3].hasValue() ) SetSnapPoints( *o3tl::doAccess<bool>(pValues[ 3 ]) );
799     if( pValues[4].hasValue() ) SetOrtho( *o3tl::doAccess<bool>(pValues[ 4 ]) );
800     if( pValues[5].hasValue() ) SetBigOrtho( *o3tl::doAccess<bool>(pValues[ 5 ]) );
801     if( pValues[6].hasValue() ) SetRotate( *o3tl::doAccess<bool>(pValues[ 6 ]) );
802     if( pValues[7].hasValue() ) SetSnapArea( static_cast<sal_Int16>(*o3tl::doAccess<sal_Int32>(pValues[ 7 ])) );
803     if( pValues[8].hasValue() ) SetAngle( Degree100(*o3tl::doAccess<sal_Int32>(pValues[ 8 ])) );
804     if( pValues[9].hasValue() ) SetEliminatePolyPointLimitAngle( Degree100(*o3tl::doAccess<sal_Int32>(pValues[ 9 ])) );
805 
806     return true;
807 }
808 
WriteData(Any * pValues) const809 bool SdOptionsSnap::WriteData( Any* pValues ) const
810 {
811     pValues[ 0 ] <<= IsSnapHelplines();
812     pValues[ 1 ] <<= IsSnapBorder();
813     pValues[ 2 ] <<= IsSnapFrame();
814     pValues[ 3 ] <<= IsSnapPoints();
815     pValues[ 4 ] <<= IsOrtho();
816     pValues[ 5 ] <<= IsBigOrtho();
817     pValues[ 6 ] <<= IsRotate();
818     pValues[ 7 ] <<= static_cast<sal_Int32>(GetSnapArea());
819     pValues[ 8 ] <<= static_cast<sal_Int32>(GetAngle().get());
820     pValues[ 9 ] <<= static_cast<sal_Int32>(GetEliminatePolyPointLimitAngle().get());
821 
822     return true;
823 }
824 
825 /*************************************************************************
826 |*
827 |* SdOptionsSnapItem
828 |*
829 \************************************************************************/
830 
SdOptionsSnapItem()831 SdOptionsSnapItem::SdOptionsSnapItem()
832 :   SfxPoolItem     ( ATTR_OPTIONS_SNAP )
833 ,   maOptionsSnap   ( false, false )
834 {
835 }
836 
SdOptionsSnapItem(SdOptions const * pOpts,::sd::FrameView const * pView)837 SdOptionsSnapItem::SdOptionsSnapItem( SdOptions const * pOpts, ::sd::FrameView const * pView )
838 :   SfxPoolItem     ( ATTR_OPTIONS_SNAP )
839 ,   maOptionsSnap   ( false, false )
840 {
841     if( pView )
842     {
843         maOptionsSnap.SetSnapHelplines( pView->IsHlplSnap() );
844         maOptionsSnap.SetSnapBorder( pView->IsBordSnap() );
845         maOptionsSnap.SetSnapFrame( pView->IsOFrmSnap() );
846         maOptionsSnap.SetSnapPoints( pView->IsOPntSnap() );
847         maOptionsSnap.SetOrtho( pView->IsOrtho() );
848         maOptionsSnap.SetBigOrtho( pView->IsBigOrtho() );
849         maOptionsSnap.SetRotate( pView->IsAngleSnapEnabled() );
850         maOptionsSnap.SetSnapArea( pView->GetSnapMagneticPixel() );
851         maOptionsSnap.SetAngle( pView->GetSnapAngle() );
852         maOptionsSnap.SetEliminatePolyPointLimitAngle( pView->GetEliminatePolyPointLimitAngle() );
853     }
854     else if( pOpts )
855     {
856         maOptionsSnap.SetSnapHelplines( pOpts->IsSnapHelplines() );
857         maOptionsSnap.SetSnapBorder( pOpts->IsSnapBorder() );
858         maOptionsSnap.SetSnapFrame( pOpts->IsSnapFrame() );
859         maOptionsSnap.SetSnapPoints( pOpts->IsSnapPoints() );
860         maOptionsSnap.SetOrtho( pOpts->IsOrtho() );
861         maOptionsSnap.SetBigOrtho( pOpts->IsBigOrtho() );
862         maOptionsSnap.SetRotate( pOpts->IsRotate() );
863         maOptionsSnap.SetSnapArea( pOpts->GetSnapArea() );
864         maOptionsSnap.SetAngle( pOpts->GetAngle() );
865         maOptionsSnap.SetEliminatePolyPointLimitAngle( pOpts->GetEliminatePolyPointLimitAngle() );
866     }
867 }
868 
Clone(SfxItemPool *) const869 SdOptionsSnapItem* SdOptionsSnapItem::Clone( SfxItemPool* ) const
870 {
871     return new SdOptionsSnapItem( *this );
872 }
873 
operator ==(const SfxPoolItem & rAttr) const874 bool SdOptionsSnapItem::operator==( const SfxPoolItem& rAttr ) const
875 {
876     assert(SfxPoolItem::operator==(rAttr));
877     return maOptionsSnap == static_cast<const SdOptionsSnapItem&>(rAttr).maOptionsSnap;
878 }
879 
SetOptions(SdOptions * pOpts) const880 void SdOptionsSnapItem::SetOptions( SdOptions* pOpts ) const
881 {
882     if( !pOpts )
883         return;
884 
885     pOpts->SetSnapHelplines( maOptionsSnap.IsSnapHelplines() );
886     pOpts->SetSnapBorder( maOptionsSnap.IsSnapBorder() );
887     pOpts->SetSnapFrame( maOptionsSnap.IsSnapFrame() );
888     pOpts->SetSnapPoints( maOptionsSnap.IsSnapPoints() );
889     pOpts->SetOrtho( maOptionsSnap.IsOrtho() );
890     pOpts->SetBigOrtho( maOptionsSnap.IsBigOrtho() );
891     pOpts->SetRotate( maOptionsSnap.IsRotate() );
892     pOpts->SetSnapArea( maOptionsSnap.GetSnapArea() );
893     pOpts->SetAngle( maOptionsSnap.GetAngle() );
894     pOpts->SetEliminatePolyPointLimitAngle( maOptionsSnap.GetEliminatePolyPointLimitAngle() );
895 }
896 
897 /*************************************************************************
898 |*
899 |* SdOptionsZoom
900 |*
901 \************************************************************************/
902 
SdOptionsZoom(bool bImpress)903 SdOptionsZoom::SdOptionsZoom( bool bImpress ) :
904     SdOptionsGeneric( bImpress, bImpress ?
905                                  OUString() :
906                                  OUString("Office.Draw/Zoom") ),
907     nX( 1 ),
908     nY( 1 )
909 
910 {
911     EnableModify( true );
912 }
913 
GetPropNameArray(const char ** & ppNames,sal_uLong & rCount) const914 void SdOptionsZoom::GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const
915 {
916     static const char* aPropNames[] =
917     {
918         "ScaleX",
919         "ScaleY"
920     };
921 
922     rCount = !IsImpress() ? SAL_N_ELEMENTS(aPropNames) : 0;
923     ppNames = aPropNames;
924 }
925 
ReadData(const Any * pValues)926 bool SdOptionsZoom::ReadData( const Any* pValues )
927 {
928     sal_Int32 x = 1, y = 1;
929 
930     if( pValues[0].hasValue() ) x = *o3tl::doAccess<sal_Int32>(pValues[ 0 ]);
931     if( pValues[1].hasValue() ) y = *o3tl::doAccess<sal_Int32>(pValues[ 1 ]);
932 
933     SetScale( x, y );
934 
935     return true;
936 }
937 
WriteData(Any * pValues) const938 bool SdOptionsZoom::WriteData( Any* pValues ) const
939 {
940     sal_Int32 x, y;
941 
942     GetScale( x, y );
943 
944     pValues[ 0 ] <<= x;
945     pValues[ 1 ] <<= y;
946 
947     return true;
948 }
949 
950 /*************************************************************************
951 |*
952 |* SdOptionsGrid
953 |*
954 \************************************************************************/
955 
SdOptionsGrid(bool bImpress)956 SdOptionsGrid::SdOptionsGrid(bool bImpress) :
957     SdOptionsGeneric( bImpress,
958                       bImpress ?
959                         OUString( "Office.Impress/Grid" ) :
960                         OUString( "Office.Draw/Grid" )
961                     )
962 {
963     EnableModify( false );
964     SetDefaults();
965     EnableModify( true );
966 }
967 
~SdOptionsGrid()968 SdOptionsGrid::~SdOptionsGrid()
969 {
970 }
971 
SetDefaults()972 void SdOptionsGrid::SetDefaults()
973 {
974     const sal_uInt32 nVal = 1000;
975 
976     SetFieldDivisionX( nVal );
977     SetFieldDivisionY( nVal );
978     SetFieldDrawX( nVal );
979     SetFieldDrawY( nVal );
980     SetFieldSnapX( nVal );
981     SetFieldSnapY( nVal );
982     SetUseGridSnap( false );
983     SetSynchronize( true );
984     SetGridVisible( false );
985     SetEqualGrid( true );
986 }
987 
GetPropNameArray(const char ** & ppNames,sal_uLong & rCount) const988 void SdOptionsGrid::GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const
989 {
990     if( isMetricSystem() )
991     {
992         static const char* aPropNamesMetric[] =
993         {
994             "Resolution/XAxis/Metric",
995             "Resolution/YAxis/Metric",
996             "Subdivision/XAxis",
997             "Subdivision/YAxis",
998             "SnapGrid/XAxis/Metric",
999             "SnapGrid/YAxis/Metric",
1000             "Option/SnapToGrid",
1001             "Option/Synchronize",
1002             "Option/VisibleGrid",
1003             "SnapGrid/Size"
1004         };
1005         ppNames = aPropNamesMetric;
1006         rCount = SAL_N_ELEMENTS(aPropNamesMetric);
1007     }
1008     else
1009     {
1010         static const char* aPropNamesNonMetric[] =
1011         {
1012             "Resolution/XAxis/NonMetric",
1013             "Resolution/YAxis/NonMetric",
1014             "Subdivision/XAxis",
1015             "Subdivision/YAxis",
1016             "SnapGrid/XAxis/NonMetric",
1017             "SnapGrid/YAxis/NonMetric",
1018             "Option/SnapToGrid",
1019             "Option/Synchronize",
1020             "Option/VisibleGrid",
1021             "SnapGrid/Size"
1022         };
1023         ppNames = aPropNamesNonMetric;
1024         rCount = SAL_N_ELEMENTS(aPropNamesNonMetric);
1025     }
1026 }
1027 
ReadData(const Any * pValues)1028 bool SdOptionsGrid::ReadData( const Any* pValues )
1029 {
1030     if( pValues[0].hasValue() ) SetFieldDrawX( *o3tl::doAccess<sal_Int32>(pValues[ 0 ]) );
1031     if( pValues[1].hasValue() ) SetFieldDrawY( *o3tl::doAccess<sal_Int32>(pValues[ 1 ]) );
1032 
1033     if( pValues[2].hasValue() )
1034     {
1035         const sal_uInt32 nDivX = FRound( *o3tl::doAccess<double>(pValues[ 2 ]) );
1036         SetFieldDivisionX( SvxOptionsGrid::GetFieldDrawX() / ( nDivX + 1 ) );
1037     }
1038 
1039     if( pValues[3].hasValue() )
1040     {
1041         const sal_uInt32 nDivY = FRound( *o3tl::doAccess<double>(pValues[ 3 ]) );
1042         SetFieldDivisionY( SvxOptionsGrid::GetFieldDrawY() / ( nDivY + 1 ) );
1043     }
1044 
1045     if( pValues[4].hasValue() ) SetFieldSnapX( *o3tl::doAccess<sal_Int32>(pValues[ 4 ]) );
1046     if( pValues[5].hasValue() ) SetFieldSnapY( *o3tl::doAccess<sal_Int32>(pValues[ 5 ]) );
1047     if( pValues[6].hasValue() ) SetUseGridSnap( *o3tl::doAccess<bool>(pValues[ 6 ]) );
1048     if( pValues[7].hasValue() ) SetSynchronize( *o3tl::doAccess<bool>(pValues[ 7 ]) );
1049     if( pValues[8].hasValue() ) SetGridVisible( *o3tl::doAccess<bool>(pValues[ 8 ]) );
1050     if( pValues[9].hasValue() ) SetEqualGrid( *o3tl::doAccess<bool>(pValues[ 9 ]) );
1051 
1052     return true;
1053 }
1054 
WriteData(Any * pValues) const1055 bool SdOptionsGrid::WriteData( Any* pValues ) const
1056 {
1057     pValues[ 0 ] <<= static_cast<sal_Int32>(GetFieldDrawX());
1058     pValues[ 1 ] <<= static_cast<sal_Int32>(GetFieldDrawY());
1059     pValues[ 2 ] <<= ( GetFieldDivisionX() ? ( static_cast<double>(GetFieldDrawX()) / GetFieldDivisionX() - 1.0 ) : double(0) );
1060     pValues[ 3 ] <<= ( GetFieldDivisionY() ? ( static_cast<double>(GetFieldDrawY()) / GetFieldDivisionY() - 1.0 ) : double(0) );
1061     pValues[ 4 ] <<= static_cast<sal_Int32>(GetFieldSnapX());
1062     pValues[ 5 ] <<= static_cast<sal_Int32>(GetFieldSnapY());
1063     pValues[ 6 ] <<= IsUseGridSnap();
1064     pValues[ 7 ] <<= IsSynchronize();
1065     pValues[ 8 ] <<= IsGridVisible();
1066     pValues[ 9 ] <<= IsEqualGrid();
1067 
1068     return true;
1069 }
1070 
1071 /*************************************************************************
1072 |*
1073 |* SdOptionsGridItem
1074 |*
1075 \************************************************************************/
1076 
SdOptionsGridItem(SdOptions const * pOpts)1077 SdOptionsGridItem::SdOptionsGridItem( SdOptions const * pOpts ) :
1078     SvxGridItem( SID_ATTR_GRID_OPTIONS )
1079 {
1080     SetSynchronize( pOpts->IsSynchronize() );
1081     SetEqualGrid( pOpts->IsEqualGrid() );
1082 
1083     SetFieldDrawX( pOpts->GetFieldDrawX() );
1084     SetFieldDrawY( pOpts->GetFieldDrawY() );
1085     SetFieldDivisionX( pOpts->GetFieldDivisionX() ? ( pOpts->GetFieldDrawX() / pOpts->GetFieldDivisionX() - 1 ) : 0 );
1086     SetFieldDivisionY( pOpts->GetFieldDivisionY() ? ( pOpts->GetFieldDrawY() / pOpts->GetFieldDivisionY() - 1 ) : 0 );
1087     SetFieldSnapX( pOpts->GetFieldSnapX() );
1088     SetFieldSnapY( pOpts->GetFieldSnapY() );
1089     SetUseGridSnap( pOpts->IsUseGridSnap() );
1090     SetGridVisible( pOpts->IsGridVisible() );
1091 }
1092 
SetOptions(SdOptions * pOpts) const1093 void SdOptionsGridItem::SetOptions( SdOptions* pOpts ) const
1094 {
1095     pOpts->SetFieldDrawX( GetFieldDrawX() );
1096     pOpts->SetFieldDivisionX( GetFieldDrawX() / ( GetFieldDivisionX() + 1 ) );
1097     pOpts->SetFieldDrawY( GetFieldDrawY() );
1098     pOpts->SetFieldDivisionY( GetFieldDrawY() / ( GetFieldDivisionY() + 1 ) );
1099     pOpts->SetFieldSnapX( GetFieldSnapX() );
1100     pOpts->SetFieldSnapY( GetFieldSnapY() );
1101     pOpts->SetUseGridSnap( GetUseGridSnap() );
1102     pOpts->SetSynchronize( GetSynchronize() );
1103     pOpts->SetGridVisible( GetGridVisible() );
1104     pOpts->SetEqualGrid( GetEqualGrid() );
1105 }
1106 
1107 /*************************************************************************
1108 |*
1109 |* SdOptionsPrint
1110 |*
1111 \************************************************************************/
1112 
SdOptionsPrint(bool bImpress,bool bUseConfig)1113 SdOptionsPrint::SdOptionsPrint( bool bImpress, bool bUseConfig ) :
1114     SdOptionsGeneric( bImpress, bUseConfig ?
1115                       ( bImpress ?
1116                         OUString( "Office.Impress/Print" ) :
1117                         OUString( "Office.Draw/Print" ) ) :
1118                       OUString() ),
1119     bDraw( true ),
1120     bNotes( false ),
1121     bHandout( false ),
1122     bOutline( false ),
1123     bDate( false ),
1124     bTime( false ),
1125     bPagename( false ),
1126     bHiddenPages( true ),
1127     bPagesize( false ),
1128     bPagetile( false ),
1129     bWarningPrinter( true ),
1130     bWarningSize( false ),
1131     bWarningOrientation( false ),
1132     bBooklet( false ),
1133     bFront( true ),
1134     bBack( true ),
1135     bCutPage( false ),
1136     bPaperbin( false ),
1137     mbHandoutHorizontal( true ),
1138     mnHandoutPages( 6 ),
1139     nQuality( 0 )
1140 {
1141     EnableModify( true );
1142 }
1143 
operator ==(const SdOptionsPrint & rOpt) const1144 bool SdOptionsPrint::operator==( const SdOptionsPrint& rOpt ) const
1145 {
1146     return( IsDraw() == rOpt.IsDraw() &&
1147             IsNotes() == rOpt.IsNotes() &&
1148             IsHandout() == rOpt.IsHandout() &&
1149             IsOutline() == rOpt.IsOutline() &&
1150             IsDate() == rOpt.IsDate() &&
1151             IsTime() == rOpt.IsTime() &&
1152             IsPagename() == rOpt.IsPagename() &&
1153             IsHiddenPages() == rOpt.IsHiddenPages() &&
1154             IsPagesize() == rOpt.IsPagesize() &&
1155             IsPagetile() == rOpt.IsPagetile() &&
1156             IsWarningPrinter() == rOpt.IsWarningPrinter() &&
1157             IsWarningSize() == rOpt.IsWarningSize() &&
1158             IsWarningOrientation() == rOpt.IsWarningOrientation() &&
1159             IsBooklet() == rOpt.IsBooklet() &&
1160             IsFrontPage() == rOpt.IsFrontPage() &&
1161             IsBackPage() == rOpt.IsBackPage() &&
1162             IsCutPage() == rOpt.IsCutPage() &&
1163             IsPaperbin() == rOpt.IsPaperbin() &&
1164             GetOutputQuality() == rOpt.GetOutputQuality() &&
1165             IsHandoutHorizontal() == rOpt.IsHandoutHorizontal() &&
1166             GetHandoutPages() == rOpt.GetHandoutPages() );
1167 }
1168 
GetPropNameArray(const char ** & ppNames,sal_uLong & rCount) const1169 void SdOptionsPrint::GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const
1170 {
1171     if (IsImpress())
1172     {
1173         static const char* aImpressPropNames[] =
1174         {
1175             "Other/Date",
1176             "Other/Time",
1177             "Other/PageName",
1178             "Other/HiddenPage",
1179             "Page/PageSize",
1180             "Page/PageTile",
1181             // bWarningPrinter
1182             // bWarningSize
1183             // bWarningOrientation
1184             "Page/Booklet",
1185             "Page/BookletFront",
1186             "Page/BookletBack",
1187             // bCutPage
1188             "Other/FromPrinterSetup",
1189             "Other/Quality",
1190             "Content/Presentation",
1191             "Content/Note",
1192             "Content/Handout",
1193             "Content/Outline",
1194             "Other/HandoutHorizontal",
1195             "Other/PagesPerHandout"
1196         };
1197         rCount = SAL_N_ELEMENTS(aImpressPropNames);
1198         ppNames = aImpressPropNames;
1199     }
1200     else
1201     {
1202         static const char* aDrawPropNames[] =
1203         {
1204             "Other/Date",
1205             "Other/Time",
1206             "Other/PageName",
1207             "Other/HiddenPage",
1208             "Page/PageSize",
1209             "Page/PageTile",
1210             // bWarningPrinter
1211             // bWarningSize
1212             // bWarningOrientation
1213             "Page/Booklet",
1214             "Page/BookletFront",
1215             "Page/BookletBack",
1216             // bCutPage
1217             "Other/FromPrinterSetup",
1218             "Other/Quality",
1219             "Content/Drawing",
1220         };
1221         rCount = SAL_N_ELEMENTS(aDrawPropNames);
1222         ppNames = aDrawPropNames;
1223     }
1224 }
1225 
ReadData(const Any * pValues)1226 bool SdOptionsPrint::ReadData( const Any* pValues )
1227 {
1228     if( pValues[0].hasValue() ) SetDate( *o3tl::doAccess<bool>(pValues[ 0 ]) );
1229     if( pValues[1].hasValue() ) SetTime( *o3tl::doAccess<bool>(pValues[ 1 ]) );
1230     if( pValues[2].hasValue() ) SetPagename( *o3tl::doAccess<bool>(pValues[ 2 ]) );
1231     if( pValues[3].hasValue() ) SetHiddenPages( *o3tl::doAccess<bool>(pValues[ 3 ]) );
1232     if( pValues[4].hasValue() ) SetPagesize( *o3tl::doAccess<bool>(pValues[ 4 ]) );
1233     if( pValues[5].hasValue() ) SetPagetile( *o3tl::doAccess<bool>(pValues[ 5 ]) );
1234     if( pValues[6].hasValue() ) SetBooklet( *o3tl::doAccess<bool>(pValues[ 6 ]) );
1235     if( pValues[7].hasValue() ) SetFrontPage( *o3tl::doAccess<bool>(pValues[ 7 ]) );
1236     if( pValues[8].hasValue() ) SetBackPage( *o3tl::doAccess<bool>(pValues[ 8 ]) );
1237     if( pValues[9].hasValue() ) SetPaperbin( *o3tl::doAccess<bool>(pValues[ 9 ]) );
1238     if( pValues[10].hasValue() ) SetOutputQuality( static_cast<sal_uInt16>(*o3tl::doAccess<sal_Int32>(pValues[ 10 ])) );
1239     if( pValues[11].hasValue() ) SetDraw( *o3tl::doAccess<bool>(pValues[ 11 ]) );
1240 
1241     // just for impress
1242     if (IsImpress())
1243     {
1244         if( pValues[12].hasValue() ) SetNotes( *o3tl::doAccess<bool>(pValues[ 12 ]) );
1245         if( pValues[13].hasValue() ) SetHandout( *o3tl::doAccess<bool>(pValues[ 13 ]) );
1246         if( pValues[14].hasValue() ) SetOutline( *o3tl::doAccess<bool>(pValues[ 14 ]) );
1247         if( pValues[15].hasValue() ) SetHandoutHorizontal( *o3tl::doAccess<bool>(pValues[15]) );
1248         if( pValues[16].hasValue() ) SetHandoutPages( static_cast<sal_uInt16>(*o3tl::doAccess<sal_Int32>(pValues[16])) );
1249     }
1250 
1251     return true;
1252 }
1253 
WriteData(Any * pValues) const1254 bool SdOptionsPrint::WriteData( Any* pValues ) const
1255 {
1256     pValues[ 0 ] <<= IsDate();
1257     pValues[ 1 ] <<= IsTime();
1258     pValues[ 2 ] <<= IsPagename();
1259     pValues[ 3 ] <<= IsHiddenPages();
1260     pValues[ 4 ] <<= IsPagesize();
1261     pValues[ 5 ] <<= IsPagetile();
1262     pValues[ 6 ] <<= IsBooklet();
1263     pValues[ 7 ] <<= IsFrontPage();
1264     pValues[ 8 ] <<= IsBackPage();
1265     pValues[ 9 ] <<= IsPaperbin();
1266     pValues[ 10 ] <<= static_cast<sal_Int32>(GetOutputQuality());
1267     pValues[ 11 ] <<= IsDraw();
1268 
1269     // just for impress
1270     if (IsImpress())
1271     {
1272         pValues[ 12 ] <<= IsNotes();
1273         pValues[ 13 ] <<= IsHandout();
1274         pValues[ 14 ] <<= IsOutline();
1275         pValues[ 15 ] <<= IsHandoutHorizontal();
1276         pValues[ 16 ] <<= GetHandoutPages();
1277     }
1278 
1279     return true;
1280 }
1281 
1282 /*************************************************************************
1283 |*
1284 |* SdOptionsPrintItem
1285 |*
1286 \************************************************************************/
1287 
SdOptionsPrintItem()1288 SdOptionsPrintItem::SdOptionsPrintItem()
1289 :   SfxPoolItem     ( ATTR_OPTIONS_PRINT )
1290 ,   maOptionsPrint  ( false, false )
1291 {
1292 }
1293 
SdOptionsPrintItem(SdOptions const * pOpts)1294 SdOptionsPrintItem::SdOptionsPrintItem( SdOptions const * pOpts )
1295 :   SfxPoolItem     ( ATTR_OPTIONS_PRINT )
1296 ,   maOptionsPrint  ( false, false )
1297 {
1298     if( !pOpts )
1299         return;
1300 
1301     maOptionsPrint.SetDraw( pOpts->IsDraw() );
1302     maOptionsPrint.SetNotes( pOpts->IsNotes() );
1303     maOptionsPrint.SetHandout( pOpts->IsHandout() );
1304     maOptionsPrint.SetOutline( pOpts->IsOutline() );
1305     maOptionsPrint.SetDate( pOpts->IsDate() );
1306     maOptionsPrint.SetTime( pOpts->IsTime() );
1307     maOptionsPrint.SetPagename( pOpts->IsPagename() );
1308     maOptionsPrint.SetHiddenPages( pOpts->IsHiddenPages() );
1309     maOptionsPrint.SetPagesize( pOpts->IsPagesize() );
1310     maOptionsPrint.SetPagetile( pOpts->IsPagetile() );
1311     maOptionsPrint.SetWarningPrinter( pOpts->IsWarningPrinter() );
1312     maOptionsPrint.SetWarningSize( pOpts->IsWarningSize() );
1313     maOptionsPrint.SetWarningOrientation( pOpts->IsWarningOrientation() );
1314     maOptionsPrint.SetBooklet( pOpts->IsBooklet() );
1315     maOptionsPrint.SetFrontPage( pOpts->IsFrontPage() );
1316     maOptionsPrint.SetBackPage( pOpts->IsBackPage() );
1317     maOptionsPrint.SetCutPage( pOpts->IsCutPage() );
1318     maOptionsPrint.SetPaperbin( pOpts->IsPaperbin() );
1319     maOptionsPrint.SetOutputQuality( pOpts->GetOutputQuality() );
1320 }
1321 
Clone(SfxItemPool *) const1322 SdOptionsPrintItem* SdOptionsPrintItem::Clone( SfxItemPool* ) const
1323 {
1324     return new SdOptionsPrintItem( *this );
1325 }
1326 
operator ==(const SfxPoolItem & rAttr) const1327 bool SdOptionsPrintItem::operator==( const SfxPoolItem& rAttr ) const
1328 {
1329     assert(SfxPoolItem::operator==(rAttr));
1330     return maOptionsPrint == static_cast<const SdOptionsPrintItem&>(rAttr).maOptionsPrint;
1331 }
1332 
SetOptions(SdOptions * pOpts) const1333 void SdOptionsPrintItem::SetOptions( SdOptions* pOpts ) const
1334 {
1335     if( !pOpts )
1336         return;
1337 
1338     pOpts->SetDraw( maOptionsPrint.IsDraw() );
1339     pOpts->SetNotes( maOptionsPrint.IsNotes() );
1340     pOpts->SetHandout( maOptionsPrint.IsHandout() );
1341     pOpts->SetOutline( maOptionsPrint.IsOutline() );
1342     pOpts->SetDate( maOptionsPrint.IsDate() );
1343     pOpts->SetTime( maOptionsPrint.IsTime() );
1344     pOpts->SetPagename( maOptionsPrint.IsPagename() );
1345     pOpts->SetHiddenPages( maOptionsPrint.IsHiddenPages() );
1346     pOpts->SetPagesize( maOptionsPrint.IsPagesize() );
1347     pOpts->SetPagetile( maOptionsPrint.IsPagetile() );
1348     pOpts->SetWarningPrinter( maOptionsPrint.IsWarningPrinter() );
1349     pOpts->SetWarningSize( maOptionsPrint.IsWarningSize() );
1350     pOpts->SetWarningOrientation( maOptionsPrint.IsWarningOrientation() );
1351     pOpts->SetBooklet( maOptionsPrint.IsBooklet() );
1352     pOpts->SetFrontPage( maOptionsPrint.IsFrontPage() );
1353     pOpts->SetBackPage( maOptionsPrint.IsBackPage() );
1354     pOpts->SetCutPage( maOptionsPrint.IsCutPage() );
1355     pOpts->SetPaperbin( maOptionsPrint.IsPaperbin() );
1356     pOpts->SetOutputQuality( maOptionsPrint.GetOutputQuality() );
1357 }
1358 
1359 /*************************************************************************
1360 |*
1361 |* SdOptions
1362 |*
1363 \************************************************************************/
1364 
SdOptions(bool bImpress)1365 SdOptions::SdOptions(bool bImpress) :
1366     SdOptionsLayout( bImpress, true ),
1367     SdOptionsContents( bImpress ),
1368     SdOptionsMisc( bImpress, true ),
1369     SdOptionsSnap( bImpress, true ),
1370     SdOptionsZoom( bImpress ),
1371     SdOptionsGrid( bImpress ),
1372     SdOptionsPrint( bImpress, true )
1373 {
1374 }
1375 
~SdOptions()1376 SdOptions::~SdOptions()
1377 {
1378 }
1379 
StoreConfig()1380 void SdOptions::StoreConfig()
1381 {
1382     SdOptionsLayout::Store();
1383     SdOptionsContents::Store();
1384     SdOptionsMisc::Store();
1385     SdOptionsSnap::Store();
1386     SdOptionsZoom::Store();
1387     SdOptionsGrid::Store();
1388     SdOptionsPrint::Store();
1389 }
1390 
GetDisplay() const1391 sal_Int32 SdOptionsMisc::GetDisplay() const
1392 {
1393     Init();
1394     return mnDisplay;
1395 }
1396 
SetDisplay(sal_Int32 nDisplay)1397 void SdOptionsMisc::SetDisplay( sal_Int32 nDisplay )
1398 {
1399     if( mnDisplay != nDisplay )
1400     {
1401         OptionsChanged();
1402         mnDisplay = nDisplay;
1403     }
1404 }
1405 
1406 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1407