Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sd/source/ui/app/optsitem.cxx
Line
Count
Source (jump to first uncovered line)
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
38
template< class T > static T getSafeValue( const Any& rAny )
39
0
{
40
0
    T value = T();
41
0
    bool bOk = (rAny >>= value);
42
43
0
    DBG_ASSERT( bOk, "SdOptionsItem, wrong type from configuration!" );
44
45
0
    return value;
46
0
}
Unexecuted instantiation: optsitem.cxx:int getSafeValue<int>(com::sun::star::uno::Any const&)
Unexecuted instantiation: optsitem.cxx:double getSafeValue<double>(com::sun::star::uno::Any const&)
47
48
49
SdOptionsItem::SdOptionsItem( const SdOptionsGeneric& rParent, const OUString& rSubTree ) :
50
12
    ConfigItem  ( rSubTree ),
51
12
    mrParent    ( rParent )
52
12
{
53
12
}
54
55
SdOptionsItem::~SdOptionsItem()
56
0
{
57
0
}
58
59
void SdOptionsItem::ImplCommit()
60
0
{
61
0
    if( IsModified() )
62
0
        mrParent.Commit( *this );
63
0
};
64
65
void SdOptionsItem::Notify( const css::uno::Sequence<OUString>& )
66
0
{}
67
68
Sequence< Any > SdOptionsItem::GetProperties( const Sequence< OUString >& rNames )
69
12
{
70
12
    return ConfigItem::GetProperties( rNames );
71
12
}
72
73
bool SdOptionsItem::PutProperties( const Sequence< OUString >& rNames, const Sequence< Any>& rValues )
74
0
{
75
0
    return ConfigItem::PutProperties( rNames, rValues );
76
0
}
77
78
SdOptionsGeneric::SdOptionsGeneric(bool bImpress, const OUString& rSubTree)
79
85.3k
    : maSubTree(rSubTree)
80
85.3k
    , mbImpress(bImpress)
81
85.3k
    , mbInit(rSubTree.isEmpty())
82
85.3k
    , mbEnableModify(false)
83
85.3k
{
84
85.3k
}
85
86
SdOptionsGeneric::SdOptionsGeneric(SdOptionsGeneric const & rSource)
87
52.1k
{
88
52.1k
    operator=(rSource);
89
52.1k
}
90
91
SdOptionsGeneric& SdOptionsGeneric::operator=(SdOptionsGeneric const & rSource)
92
90.8k
{
93
90.8k
    if (this != &rSource)
94
90.8k
    {
95
90.8k
        maSubTree = rSource.maSubTree;
96
90.8k
        mpCfgItem.reset(rSource.mpCfgItem ? new SdOptionsItem(*rSource.mpCfgItem) : nullptr );
97
90.8k
        mbImpress = rSource.mbImpress;
98
90.8k
        mbInit = rSource.mbInit;
99
90.8k
        mbEnableModify = rSource.mbEnableModify;
100
90.8k
    }
101
90.8k
    return *this;
102
90.8k
}
103
104
void SdOptionsGeneric::Init() const
105
1.61M
{
106
1.61M
    if( mbInit )
107
1.61M
        return;
108
109
12
    SdOptionsGeneric* pThis = const_cast<SdOptionsGeneric*>(this);
110
111
12
    if( !mpCfgItem )
112
12
        pThis->mpCfgItem.reset( new SdOptionsItem( *this, maSubTree ) );
113
12
    assert(mpCfgItem && "mpCfgItem is set by now");
114
115
12
    const Sequence< OUString >  aNames( GetPropertyNames() );
116
12
    const Sequence< Any >       aValues = mpCfgItem->GetProperties( aNames );
117
118
12
    if( aNames.hasElements() && ( aValues.getLength() == aNames.getLength() ) )
119
12
    {
120
12
        const Any* pValues = aValues.getConstArray();
121
122
12
        pThis->EnableModify( false );
123
12
        pThis->mbInit = pThis->ReadData( pValues );
124
12
        pThis->EnableModify( true );
125
12
    }
126
0
    else
127
0
        pThis->mbInit = true;
128
12
}
129
130
SdOptionsGeneric::~SdOptionsGeneric()
131
137k
{
132
137k
}
133
134
void SdOptionsGeneric::Commit( SdOptionsItem& rCfgItem ) const
135
0
{
136
0
    const Sequence< OUString >  aNames( GetPropertyNames() );
137
0
    Sequence< Any >             aValues( aNames.getLength() );
138
139
0
    if( aNames.hasElements() )
140
0
    {
141
0
        if( WriteData( aValues.getArray() ) )
142
0
            rCfgItem.PutProperties( aNames, aValues );
143
0
        else
144
0
        {
145
0
            OSL_FAIL( "PutProperties failed" );
146
0
        }
147
0
    }
148
0
}
149
150
Sequence< OUString > SdOptionsGeneric::GetPropertyNames() const
151
12
{
152
12
    sal_uLong           nCount;
153
12
    const char**    ppPropNames;
154
155
12
    GetPropNameArray( ppPropNames, nCount );
156
157
12
    Sequence< OUString > aNames( nCount );
158
12
    OUString*            pNames = aNames.getArray();
159
160
243
    for( sal_uLong i = 0; i < nCount; i++ )
161
231
        pNames[ i ] = OUString::createFromAscii( ppPropNames[ i ] );
162
163
12
    return aNames;
164
12
}
165
166
void SdOptionsGeneric::Store()
167
0
{
168
0
    if( mpCfgItem )
169
0
        mpCfgItem->Commit();
170
0
}
171
172
bool SdOptionsGeneric::isMetricSystem()
173
2
{
174
2
    SvtSysLocale aSysLocale;
175
2
    MeasurementSystem eSys = aSysLocale.GetLocaleData().getMeasurementSystemEnum();
176
177
2
    return ( eSys == MeasurementSystem::Metric );
178
2
}
179
180
/*************************************************************************
181
|*
182
|* SdOptionsMisc
183
|*
184
\************************************************************************/
185
186
SdOptionsMisc::SdOptionsMisc( bool bImpress, bool bUseConfig ) :
187
5
    SdOptionsGeneric( bImpress, bUseConfig ?
188
5
                      ( bImpress ?
189
5
                        u"Office.Impress/Misc"_ustr :
190
5
                        u"Office.Draw/Misc"_ustr ) :
191
5
                      OUString() ),
192
5
    nDefaultObjectSizeWidth(8000),
193
5
    nDefaultObjectSizeHeight(5000),
194
5
    bStartWithTemplate( false ),
195
5
    bMarkedHitMovesAlways( true ),
196
5
    bMoveOnlyDragging( false ),
197
5
    bCrookNoContortion( false ),
198
5
    bQuickEdit( IsImpress() ),
199
5
    bMasterPageCache( true ),
200
5
    bDragWithCopy( false ),
201
5
    bPickThrough( true ),
202
5
    bDoubleClickTextEdit( true ),
203
5
    bClickChangeRotation( false ),
204
5
    bSolidDragging( true ),
205
5
    bSummationOfParagraphs( false ),
206
5
    bTabBarVisible( true ),
207
5
    bShowUndoDeleteWarning( true ),
208
5
    bSlideshowRespectZOrder( true ),
209
5
    bShowComments( true ),
210
5
    bPreviewNewEffects( true ),
211
5
    bPreviewChangedEffects( false ),
212
5
    bPreviewTransitions( true ),
213
5
    mnDisplay( 0 ),
214
5
    mnPenColor( 0xff0000 ),
215
5
    mnPenWidth( 150.0 ),
216
217
    // The default for 6.1-and-above documents is to use printer-independent
218
    // formatting.
219
5
    mnPrinterIndependentLayout (1),
220
5
    mnDragThresholdPixels(6)
221
5
{
222
5
    EnableModify( true );
223
5
}
224
225
bool SdOptionsMisc::operator==( const SdOptionsMisc& rOpt ) const
226
0
{
227
0
    return( IsStartWithTemplate() == rOpt.IsStartWithTemplate() &&
228
0
            IsMarkedHitMovesAlways() == rOpt.IsMarkedHitMovesAlways() &&
229
0
            IsMoveOnlyDragging() == rOpt.IsMoveOnlyDragging() &&
230
0
            IsCrookNoContortion() == rOpt.IsCrookNoContortion() &&
231
0
            IsQuickEdit() == rOpt.IsQuickEdit() &&
232
0
            IsMasterPagePaintCaching() == rOpt.IsMasterPagePaintCaching() &&
233
0
            IsDragWithCopy() == rOpt.IsDragWithCopy() &&
234
0
            IsPickThrough() == rOpt.IsPickThrough() &&
235
0
            IsDoubleClickTextEdit() == rOpt.IsDoubleClickTextEdit() &&
236
0
            IsClickChangeRotation() == rOpt.IsClickChangeRotation() &&
237
0
            IsSummationOfParagraphs() == rOpt.IsSummationOfParagraphs() &&
238
0
            IsTabBarVisible() == rOpt.IsTabBarVisible() &&
239
0
            IsSolidDragging() == rOpt.IsSolidDragging() &&
240
0
            IsShowUndoDeleteWarning() == rOpt.IsShowUndoDeleteWarning() &&
241
0
            IsSlideshowRespectZOrder() == rOpt.IsSlideshowRespectZOrder() &&
242
0
            GetPrinterIndependentLayout() == rOpt.GetPrinterIndependentLayout() &&
243
0
            GetDefaultObjectSizeWidth() == rOpt.GetDefaultObjectSizeWidth() &&
244
0
            GetDefaultObjectSizeHeight() == rOpt.GetDefaultObjectSizeHeight() &&
245
246
0
            IsPreviewNewEffects() == rOpt.IsPreviewNewEffects() &&
247
0
            IsPreviewChangedEffects() == rOpt.IsPreviewChangedEffects() &&
248
0
            IsPreviewTransitions() == rOpt.IsPreviewTransitions() &&
249
0
            GetDisplay() == rOpt.GetDisplay() &&
250
0
            IsShowComments() == rOpt.IsShowComments() &&
251
0
            GetPresentationPenColor() == rOpt.GetPresentationPenColor() &&
252
0
            GetPresentationPenWidth() == rOpt.GetPresentationPenWidth() &&
253
0
            GetDragThresholdPixels() == rOpt.GetDragThresholdPixels()
254
0
        );
255
0
}
256
257
void SdOptionsMisc::GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const
258
5
{
259
5
    static const char* aPropNames[] =
260
5
    {
261
5
        "ObjectMoveable",
262
5
        "NoDistort",
263
5
        "TextObject/QuickEditing",
264
5
        "BackgroundCache",
265
5
        "CopyWhileMoving",
266
5
        "TextObject/Selectable",
267
5
        "DclickTextedit",
268
5
        "RotateClick",
269
5
        "Preview",
270
5
        "ModifyWithAttributes",
271
5
        "DefaultObjectSize/Width",
272
5
        "DefaultObjectSize/Height",
273
274
5
        "Compatibility/PrinterIndependentLayout",
275
276
5
        "ShowComments",
277
5
        "DragThresholdPixels",
278
279
        // just for impress
280
5
        "NewDoc/AutoPilot",
281
5
        "Compatibility/AddBetween",
282
5
        "ShowUndoDeleteWarning",
283
5
        "SlideshowRespectZOrder",
284
285
5
        "PreviewNewEffects",
286
5
        "PreviewChangedEffects",
287
5
        "PreviewTransitions",
288
289
5
        "Display",
290
291
5
        "PenColor",
292
5
        "PenWidth",
293
5
        "TabBarVisible"
294
5
    };
295
296
5
    rCount = ( IsImpress() ? SAL_N_ELEMENTS(aPropNames) : 15 );
297
5
    ppNames = aPropNames;
298
5
}
299
300
bool SdOptionsMisc::ReadData( const Any* pValues )
301
5
{
302
5
    if( pValues[0].hasValue() ) SetMarkedHitMovesAlways( *o3tl::doAccess<bool>(pValues[ 0 ]) );
303
5
    if( pValues[1].hasValue() ) SetCrookNoContortion( *o3tl::doAccess<bool>(pValues[ 1 ]) );
304
5
    if( pValues[2].hasValue() ) SetQuickEdit( *o3tl::doAccess<bool>(pValues[ 2 ]) );
305
5
    if( pValues[3].hasValue() ) SetMasterPagePaintCaching( *o3tl::doAccess<bool>(pValues[ 3 ]) );
306
5
    if( pValues[4].hasValue() ) SetDragWithCopy( *o3tl::doAccess<bool>(pValues[ 4 ]) );
307
5
    if( pValues[5].hasValue() ) SetPickThrough( *o3tl::doAccess<bool>(pValues[ 5 ]) );
308
5
    if( pValues[6].hasValue() ) SetDoubleClickTextEdit( *o3tl::doAccess<bool>(pValues[ 6 ]) );
309
5
    if( pValues[7].hasValue() ) SetClickChangeRotation( *o3tl::doAccess<bool>(pValues[ 7 ]) );
310
5
    if( pValues[9].hasValue() ) SetSolidDragging( *o3tl::doAccess<bool>(pValues[ 9 ]) );
311
5
    if( pValues[10].hasValue() ) SetDefaultObjectSizeWidth( *o3tl::doAccess<sal_Int32>(pValues[ 10 ]) );
312
5
    if( pValues[11].hasValue() ) SetDefaultObjectSizeHeight( *o3tl::doAccess<sal_Int32>(pValues[ 11 ]) );
313
5
    if( pValues[12].hasValue() ) SetPrinterIndependentLayout( *o3tl::doAccess<sal_uInt16>(pValues[ 12 ]) );
314
315
5
    if( pValues[13].hasValue() )
316
0
        SetShowComments(  *o3tl::doAccess<bool>(pValues[ 13 ]) );
317
5
    if (pValues[14].hasValue())
318
0
        SetDragThreshold(*o3tl::doAccess<sal_Int32>(pValues[ 14 ]));
319
320
    // just for Impress
321
5
    if (IsImpress())
322
5
    {
323
5
        if( pValues[15].hasValue() )
324
0
            SetStartWithTemplate( *o3tl::doAccess<bool>(pValues[ 15 ]) );
325
5
        if( pValues[16].hasValue() )
326
0
            SetSummationOfParagraphs( *o3tl::doAccess<bool>(pValues[ 16 ]) );
327
5
        if( pValues[17].hasValue() )
328
0
            SetShowUndoDeleteWarning( *o3tl::doAccess<bool>(pValues[ 17 ]) );
329
330
5
        if( pValues[18].hasValue() )
331
0
            SetSlideshowRespectZOrder(*o3tl::doAccess<bool>(pValues[ 18 ]));
332
333
5
        if( pValues[19].hasValue() )
334
0
            SetPreviewNewEffects(*o3tl::doAccess<bool>(pValues[ 19 ]));
335
336
5
        if( pValues[20].hasValue() )
337
0
            SetPreviewChangedEffects(*o3tl::doAccess<bool>(pValues[ 20 ]));
338
339
5
        if( pValues[21].hasValue() )
340
0
            SetPreviewTransitions(*o3tl::doAccess<bool>(pValues[ 21 ]));
341
342
5
        if( pValues[22].hasValue() )
343
0
            SetDisplay(*o3tl::doAccess<sal_Int32>(pValues[ 22 ]));
344
345
5
        if( pValues[23].hasValue() )
346
0
            SetPresentationPenColor( getSafeValue< sal_Int32 >( pValues[ 23 ] ) );
347
348
5
        if( pValues[24].hasValue() )
349
0
            SetPresentationPenWidth( getSafeValue< double >( pValues[ 24 ] ) );
350
351
5
        if( pValues[25].hasValue() ) {
352
0
            SetTabBarVisible( *o3tl::doAccess<bool>(pValues[ 25 ]) );
353
0
        }
354
5
    }
355
356
5
    return true;
357
5
}
358
359
bool SdOptionsMisc::WriteData( Any* pValues ) const
360
0
{
361
0
    pValues[ 0 ] <<= IsMarkedHitMovesAlways();
362
0
    pValues[ 1 ] <<= IsCrookNoContortion();
363
0
    pValues[ 2 ] <<= IsQuickEdit();
364
0
    pValues[ 3 ] <<= IsMasterPagePaintCaching();
365
0
    pValues[ 4 ] <<= IsDragWithCopy();
366
0
    pValues[ 5 ] <<= IsPickThrough();
367
0
    pValues[ 6 ] <<= IsDoubleClickTextEdit();
368
0
    pValues[ 7 ] <<= IsClickChangeRotation();
369
    // The preview is not supported anymore.  Use a dummy value.
370
0
    pValues[ 8 ] <<= double(0);// GetPreviewQuality();
371
0
    pValues[ 9 ] <<= IsSolidDragging();
372
0
    pValues[ 10 ] <<= GetDefaultObjectSizeWidth();
373
0
    pValues[ 11 ] <<= GetDefaultObjectSizeHeight();
374
0
    pValues[ 12 ] <<= GetPrinterIndependentLayout();
375
0
    pValues[ 13 ] <<= IsShowComments();
376
0
    pValues[ 14 ] <<= GetDragThresholdPixels();
377
378
    // just for Impress
379
0
    if (IsImpress())
380
0
    {
381
0
        pValues[ 15 ] <<= IsStartWithTemplate();
382
0
        pValues[ 16 ] <<= IsSummationOfParagraphs();
383
0
        pValues[ 17 ] <<= IsShowUndoDeleteWarning();
384
0
        pValues[ 18 ] <<= IsSlideshowRespectZOrder();
385
386
0
        pValues[ 19 ] <<= IsPreviewNewEffects();
387
0
        pValues[ 20 ] <<= IsPreviewChangedEffects();
388
0
        pValues[ 21 ] <<= IsPreviewTransitions();
389
390
0
        pValues[ 22 ] <<= GetDisplay();
391
392
0
        pValues[ 23 ] <<= GetPresentationPenColor();
393
0
        pValues[ 24 ] <<= GetPresentationPenWidth();
394
0
        pValues[ 25 ] <<= IsTabBarVisible();
395
0
    }
396
397
0
    return true;
398
0
}
399
400
/*************************************************************************
401
|*
402
|* SdOptionsMiscItem
403
|*
404
\************************************************************************/
405
406
SdOptionsMiscItem::SdOptionsMiscItem()
407
0
:   SfxPoolItem     ( ATTR_OPTIONS_MISC )
408
0
,   maOptionsMisc   ( false, false )
409
0
{
410
0
}
411
412
SdOptionsMiscItem::SdOptionsMiscItem( SdOptions const * pOpts, ::sd::FrameView const * pView )
413
0
:   SfxPoolItem     ( ATTR_OPTIONS_MISC )
414
0
,   maOptionsMisc   ( false, false )
415
0
{
416
0
    if( pOpts )
417
0
    {
418
0
        maOptionsMisc.SetStartWithTemplate( pOpts->IsStartWithTemplate() );
419
0
        maOptionsMisc.SetSummationOfParagraphs( pOpts->IsSummationOfParagraphs() );
420
0
        maOptionsMisc.SetTabBarVisible( pOpts->IsTabBarVisible() );
421
0
        maOptionsMisc.SetShowUndoDeleteWarning( pOpts->IsShowUndoDeleteWarning() );
422
0
        maOptionsMisc.SetPrinterIndependentLayout( pOpts->GetPrinterIndependentLayout() );
423
0
        maOptionsMisc.SetDefaultObjectSizeWidth( pOpts->GetDefaultObjectSizeWidth() );
424
0
        maOptionsMisc.SetDefaultObjectSizeHeight( pOpts->GetDefaultObjectSizeHeight() );
425
426
0
        maOptionsMisc.SetPreviewNewEffects(pOpts->IsPreviewNewEffects());
427
0
        maOptionsMisc.SetPreviewChangedEffects(pOpts->IsPreviewChangedEffects());
428
0
        maOptionsMisc.SetPreviewTransitions(pOpts->IsPreviewTransitions());
429
430
0
        maOptionsMisc.SetDisplay(pOpts->GetDisplay());
431
0
        maOptionsMisc.SetShowComments( pOpts->IsShowComments() );
432
433
0
        maOptionsMisc.SetPresentationPenColor(pOpts->GetPresentationPenColor() );
434
0
        maOptionsMisc.SetPresentationPenWidth(pOpts->GetPresentationPenWidth() );
435
0
    }
436
437
0
    if( pView )
438
0
    {
439
0
        maOptionsMisc.SetMarkedHitMovesAlways( pView->IsMarkedHitMovesAlways() );
440
0
        maOptionsMisc.SetMoveOnlyDragging( pView->IsMoveOnlyDragging() );
441
0
        maOptionsMisc.SetCrookNoContortion( pView->IsCrookNoContortion() );
442
0
        maOptionsMisc.SetQuickEdit( pView->IsQuickEdit() );
443
444
        // #i26631#
445
0
        maOptionsMisc.SetMasterPagePaintCaching( pView->IsMasterPagePaintCaching() );
446
447
0
        maOptionsMisc.SetDragWithCopy( pView->IsDragWithCopy() );
448
0
        maOptionsMisc.SetPickThrough(pView->GetModel().IsPickThroughTransparentTextFrames());
449
0
        maOptionsMisc.SetDoubleClickTextEdit( pView->IsDoubleClickTextEdit() );
450
0
        maOptionsMisc.SetClickChangeRotation( pView->IsClickChangeRotation() );
451
0
        maOptionsMisc.SetSolidDragging( pView->IsSolidDragging() );
452
0
        maOptionsMisc.SetDragThreshold(pView->GetDragThresholdPixels());
453
0
    }
454
0
    else if( pOpts )
455
0
    {
456
0
        maOptionsMisc.SetMarkedHitMovesAlways( pOpts->IsMarkedHitMovesAlways() );
457
0
        maOptionsMisc.SetMoveOnlyDragging( pOpts->IsMoveOnlyDragging() );
458
0
        maOptionsMisc.SetCrookNoContortion( pOpts->IsCrookNoContortion() );
459
0
        maOptionsMisc.SetQuickEdit( pOpts->IsQuickEdit() );
460
0
        maOptionsMisc.SetMasterPagePaintCaching( pOpts->IsMasterPagePaintCaching() );
461
0
        maOptionsMisc.SetDragWithCopy( pOpts->IsDragWithCopy() );
462
0
        maOptionsMisc.SetPickThrough( pOpts->IsPickThrough() );
463
0
        maOptionsMisc.SetDoubleClickTextEdit( pOpts->IsDoubleClickTextEdit() );
464
0
        maOptionsMisc.SetClickChangeRotation( pOpts->IsClickChangeRotation() );
465
0
        maOptionsMisc.SetSolidDragging( pOpts->IsSolidDragging() );
466
0
        maOptionsMisc.SetDragThreshold(pOpts->GetDragThresholdPixels());
467
0
    }
468
0
}
469
470
SdOptionsMiscItem* SdOptionsMiscItem::Clone( SfxItemPool* ) const
471
0
{
472
0
    return new SdOptionsMiscItem( *this );
473
0
}
474
475
bool SdOptionsMiscItem::operator==( const SfxPoolItem& rAttr ) const
476
0
{
477
0
    assert(SfxPoolItem::operator==(rAttr));
478
0
    return maOptionsMisc == static_cast<const SdOptionsMiscItem&>(rAttr).maOptionsMisc;
479
0
}
480
481
void SdOptionsMiscItem::SetOptions( SdOptions* pOpts ) const
482
0
{
483
0
    if( !pOpts )
484
0
        return;
485
    //this needs to reflect all settings from SdTpOptionsMisc::FillItemSet()
486
0
    pOpts->SetStartWithTemplate( maOptionsMisc.IsStartWithTemplate() );
487
0
    pOpts->SetMarkedHitMovesAlways( maOptionsMisc.IsMarkedHitMovesAlways() );
488
0
    pOpts->SetQuickEdit(maOptionsMisc.IsQuickEdit());
489
0
    pOpts->SetPickThrough( maOptionsMisc.IsPickThrough() );
490
0
    pOpts->SetMasterPagePaintCaching( maOptionsMisc.IsMasterPagePaintCaching() );
491
0
    pOpts->SetDragWithCopy( maOptionsMisc.IsDragWithCopy() );
492
0
    pOpts->SetSummationOfParagraphs( maOptionsMisc.IsSummationOfParagraphs() );
493
0
    pOpts->SetCrookNoContortion( maOptionsMisc.IsCrookNoContortion() );
494
495
0
}
496
497
/*************************************************************************
498
|*
499
|* SdOptionsGrid
500
|*
501
\************************************************************************/
502
503
SdOptionsGrid::SdOptionsGrid(bool bImpress) :
504
5
    SdOptionsGeneric( bImpress,
505
5
                      bImpress ?
506
5
                        u"Office.Impress/Grid"_ustr :
507
5
                        u"Office.Draw/Grid"_ustr
508
5
                    )
509
5
{
510
5
    EnableModify( false );
511
5
    SetDefaults();
512
5
    EnableModify( true );
513
5
}
514
515
SdOptionsGrid::~SdOptionsGrid()
516
{
517
}
518
519
void SdOptionsGrid::SetDefaults()
520
5
{
521
5
    const sal_uInt32 nVal = 1000;
522
523
5
    SetFieldDivisionX( nVal );
524
5
    SetFieldDivisionY( nVal );
525
5
    SetFieldDrawX( nVal );
526
5
    SetFieldDrawY( nVal );
527
5
    SetUseGridSnap( false );
528
5
    SetSynchronize( true );
529
5
    SetGridVisible( false );
530
5
    SetEqualGrid( true );
531
5
}
532
533
void SdOptionsGrid::GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const
534
2
{
535
2
    if( isMetricSystem() )
536
0
    {
537
0
        static const char* aPropNamesMetric[] =
538
0
        {
539
0
            "Resolution/XAxis/Metric",
540
0
            "Resolution/YAxis/Metric",
541
0
            "Subdivision/XAxis",
542
0
            "Subdivision/YAxis",
543
0
            "Option/SnapToGrid",
544
0
            "Option/Synchronize",
545
0
            "Option/VisibleGrid",
546
0
            "SnapGrid/Size"
547
0
        };
548
0
        ppNames = aPropNamesMetric;
549
0
        rCount = SAL_N_ELEMENTS(aPropNamesMetric);
550
0
    }
551
2
    else
552
2
    {
553
2
        static const char* aPropNamesNonMetric[] =
554
2
        {
555
2
            "Resolution/XAxis/NonMetric",
556
2
            "Resolution/YAxis/NonMetric",
557
2
            "Subdivision/XAxis",
558
2
            "Subdivision/YAxis",
559
2
            "Option/SnapToGrid",
560
2
            "Option/Synchronize",
561
2
            "Option/VisibleGrid",
562
2
            "SnapGrid/Size"
563
2
        };
564
2
        ppNames = aPropNamesNonMetric;
565
2
        rCount = SAL_N_ELEMENTS(aPropNamesNonMetric);
566
2
    }
567
2
}
568
569
bool SdOptionsGrid::ReadData( const Any* pValues )
570
2
{
571
2
    if( pValues[0].hasValue() ) SetFieldDrawX( *o3tl::doAccess<sal_Int32>(pValues[ 0 ]) );
572
2
    if( pValues[1].hasValue() ) SetFieldDrawY( *o3tl::doAccess<sal_Int32>(pValues[ 1 ]) );
573
574
2
    if( pValues[2].hasValue() )
575
0
    {
576
0
        const sal_uInt32 nDivX = basegfx::fround<sal_uInt32>(*o3tl::doAccess<double>(pValues[2]));
577
0
        SetFieldDivisionX( SvxOptionsGrid::GetFieldDrawX() / ( nDivX + 1 ) );
578
0
    }
579
580
2
    if( pValues[3].hasValue() )
581
0
    {
582
0
        const sal_uInt32 nDivY = basegfx::fround<sal_uInt32>(*o3tl::doAccess<double>(pValues[3]));
583
0
        SetFieldDivisionY( SvxOptionsGrid::GetFieldDrawY() / ( nDivY + 1 ) );
584
0
    }
585
2
    if( pValues[4].hasValue() ) SetUseGridSnap( *o3tl::doAccess<bool>(pValues[ 4 ]) );
586
2
    if( pValues[5].hasValue() ) SetSynchronize( *o3tl::doAccess<bool>(pValues[ 5 ]) );
587
2
    if( pValues[6].hasValue() ) SetGridVisible( *o3tl::doAccess<bool>(pValues[ 6 ]) );
588
2
    if( pValues[7].hasValue() ) SetEqualGrid( *o3tl::doAccess<bool>(pValues[ 7 ]) );
589
590
2
    return true;
591
2
}
592
593
bool SdOptionsGrid::WriteData( Any* pValues ) const
594
0
{
595
0
    pValues[ 0 ] <<= static_cast<sal_Int32>(GetFieldDrawX());
596
0
    pValues[ 1 ] <<= static_cast<sal_Int32>(GetFieldDrawY());
597
0
    pValues[ 2 ] <<= ( GetFieldDivisionX() ? ( static_cast<double>(GetFieldDrawX()) / GetFieldDivisionX() - 1.0 ) : double(0) );
598
0
    pValues[ 3 ] <<= ( GetFieldDivisionY() ? ( static_cast<double>(GetFieldDrawY()) / GetFieldDivisionY() - 1.0 ) : double(0) );
599
0
    pValues[ 4 ] <<= IsUseGridSnap();
600
0
    pValues[ 5 ] <<= IsSynchronize();
601
0
    pValues[ 6 ] <<= IsGridVisible();
602
0
    pValues[ 7 ] <<= IsEqualGrid();
603
604
0
    return true;
605
0
}
606
607
/*************************************************************************
608
|*
609
|* SdOptionsGridItem
610
|*
611
\************************************************************************/
612
613
SdOptionsGridItem::SdOptionsGridItem( SdOptions const * pOpts ) :
614
0
    SvxGridItem( SID_ATTR_GRID_OPTIONS )
615
0
{
616
0
    SetSynchronize( pOpts->IsSynchronize() );
617
0
    SetEqualGrid( pOpts->IsEqualGrid() );
618
619
0
    SetFieldDrawX( pOpts->GetFieldDrawX() );
620
0
    SetFieldDrawY( pOpts->GetFieldDrawY() );
621
0
    SetFieldDivisionX( pOpts->GetFieldDivisionX() ? ( pOpts->GetFieldDrawX() / pOpts->GetFieldDivisionX() - 1 ) : 0 );
622
0
    SetFieldDivisionY( pOpts->GetFieldDivisionY() ? ( pOpts->GetFieldDrawY() / pOpts->GetFieldDivisionY() - 1 ) : 0 );
623
0
    SetUseGridSnap( pOpts->IsUseGridSnap() );
624
0
    SetGridVisible( pOpts->IsGridVisible() );
625
0
}
626
627
void SdOptionsGridItem::SetOptions( SdOptions* pOpts ) const
628
0
{
629
0
    pOpts->SetFieldDrawX( GetFieldDrawX() );
630
0
    pOpts->SetFieldDivisionX( GetFieldDrawX() / ( GetFieldDivisionX() + 1 ) );
631
0
    pOpts->SetFieldDrawY( GetFieldDrawY() );
632
0
    pOpts->SetFieldDivisionY( GetFieldDrawY() / ( GetFieldDivisionY() + 1 ) );
633
0
    pOpts->SetUseGridSnap( GetUseGridSnap() );
634
0
    pOpts->SetSynchronize( GetSynchronize() );
635
0
    pOpts->SetGridVisible( GetGridVisible() );
636
0
    pOpts->SetEqualGrid( GetEqualGrid() );
637
0
}
638
639
/*************************************************************************
640
|*
641
|* SdOptionsPrint
642
|*
643
\************************************************************************/
644
645
SdOptionsPrint::SdOptionsPrint( bool bImpress, bool bUseConfig ) :
646
85.3k
    SdOptionsGeneric( bImpress, bUseConfig ?
647
5
                      ( bImpress ?
648
5
                        u"Office.Impress/Print"_ustr :
649
5
                        u"Office.Draw/Print"_ustr ) :
650
85.3k
                      OUString() ),
651
85.3k
    bDraw( true ),
652
85.3k
    bNotes( false ),
653
85.3k
    bHandout( false ),
654
85.3k
    bOutline( false ),
655
85.3k
    bDate( false ),
656
85.3k
    bTime( false ),
657
85.3k
    bPagename( false ),
658
85.3k
    bHiddenPages( true ),
659
85.3k
    bPagesize( false ),
660
85.3k
    bPagetile( false ),
661
85.3k
    bWarningPrinter( true ),
662
85.3k
    bWarningSize( false ),
663
85.3k
    bWarningOrientation( false ),
664
85.3k
    bBooklet( false ),
665
85.3k
    bFront( true ),
666
85.3k
    bBack( true ),
667
85.3k
    bCutPage( false ),
668
85.3k
    bPaperbin( false ),
669
85.3k
    mbHandoutHorizontal( true ),
670
85.3k
    mnHandoutPages( 6 ),
671
85.3k
    nQuality( 0 )
672
85.3k
{
673
85.3k
    EnableModify( true );
674
85.3k
}
675
676
bool SdOptionsPrint::operator==( const SdOptionsPrint& rOpt ) const
677
344
{
678
344
    return( IsDraw() == rOpt.IsDraw() &&
679
344
            IsNotes() == rOpt.IsNotes() &&
680
344
            IsHandout() == rOpt.IsHandout() &&
681
344
            IsOutline() == rOpt.IsOutline() &&
682
344
            IsDate() == rOpt.IsDate() &&
683
344
            IsTime() == rOpt.IsTime() &&
684
344
            IsPagename() == rOpt.IsPagename() &&
685
344
            IsHiddenPages() == rOpt.IsHiddenPages() &&
686
344
            IsPagesize() == rOpt.IsPagesize() &&
687
344
            IsPagetile() == rOpt.IsPagetile() &&
688
344
            IsWarningPrinter() == rOpt.IsWarningPrinter() &&
689
344
            IsWarningSize() == rOpt.IsWarningSize() &&
690
344
            IsWarningOrientation() == rOpt.IsWarningOrientation() &&
691
344
            IsBooklet() == rOpt.IsBooklet() &&
692
344
            IsFrontPage() == rOpt.IsFrontPage() &&
693
344
            IsBackPage() == rOpt.IsBackPage() &&
694
344
            IsCutPage() == rOpt.IsCutPage() &&
695
344
            IsPaperbin() == rOpt.IsPaperbin() &&
696
344
            GetOutputQuality() == rOpt.GetOutputQuality() &&
697
344
            IsHandoutHorizontal() == rOpt.IsHandoutHorizontal() &&
698
344
            GetHandoutPages() == rOpt.GetHandoutPages() );
699
344
}
700
701
void SdOptionsPrint::GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const
702
5
{
703
5
    if (IsImpress())
704
5
    {
705
5
        static const char* aImpressPropNames[] =
706
5
        {
707
5
            "Other/Date",
708
5
            "Other/Time",
709
5
            "Other/PageName",
710
5
            "Other/HiddenPage",
711
5
            "Page/PageSize",
712
5
            "Page/PageTile",
713
            // bWarningPrinter
714
            // bWarningSize
715
            // bWarningOrientation
716
5
            "Page/Booklet",
717
5
            "Page/BookletFront",
718
5
            "Page/BookletBack",
719
            // bCutPage
720
5
            "Other/FromPrinterSetup",
721
5
            "Other/Quality",
722
5
            "Content/Presentation",
723
5
            "Content/Note",
724
5
            "Content/Handout",
725
5
            "Content/Outline",
726
5
            "Other/HandoutHorizontal",
727
5
            "Other/PagesPerHandout"
728
5
        };
729
5
        rCount = SAL_N_ELEMENTS(aImpressPropNames);
730
5
        ppNames = aImpressPropNames;
731
5
    }
732
0
    else
733
0
    {
734
0
        static const char* aDrawPropNames[] =
735
0
        {
736
0
            "Other/Date",
737
0
            "Other/Time",
738
0
            "Other/PageName",
739
0
            "Other/HiddenPage",
740
0
            "Page/PageSize",
741
0
            "Page/PageTile",
742
            // bWarningPrinter
743
            // bWarningSize
744
            // bWarningOrientation
745
0
            "Page/Booklet",
746
0
            "Page/BookletFront",
747
0
            "Page/BookletBack",
748
            // bCutPage
749
0
            "Other/FromPrinterSetup",
750
0
            "Other/Quality",
751
0
            "Content/Drawing",
752
0
        };
753
0
        rCount = SAL_N_ELEMENTS(aDrawPropNames);
754
0
        ppNames = aDrawPropNames;
755
0
    }
756
5
}
757
758
bool SdOptionsPrint::ReadData( const Any* pValues )
759
5
{
760
5
    if( pValues[0].hasValue() ) SetDate( *o3tl::doAccess<bool>(pValues[ 0 ]) );
761
5
    if( pValues[1].hasValue() ) SetTime( *o3tl::doAccess<bool>(pValues[ 1 ]) );
762
5
    if( pValues[2].hasValue() ) SetPagename( *o3tl::doAccess<bool>(pValues[ 2 ]) );
763
5
    if( pValues[3].hasValue() ) SetHiddenPages( *o3tl::doAccess<bool>(pValues[ 3 ]) );
764
5
    if( pValues[4].hasValue() ) SetPagesize( *o3tl::doAccess<bool>(pValues[ 4 ]) );
765
5
    if( pValues[5].hasValue() ) SetPagetile( *o3tl::doAccess<bool>(pValues[ 5 ]) );
766
5
    if( pValues[6].hasValue() ) SetBooklet( *o3tl::doAccess<bool>(pValues[ 6 ]) );
767
5
    if( pValues[7].hasValue() ) SetFrontPage( *o3tl::doAccess<bool>(pValues[ 7 ]) );
768
5
    if( pValues[8].hasValue() ) SetBackPage( *o3tl::doAccess<bool>(pValues[ 8 ]) );
769
5
    if( pValues[9].hasValue() ) SetPaperbin( *o3tl::doAccess<bool>(pValues[ 9 ]) );
770
5
    if( pValues[10].hasValue() ) SetOutputQuality( static_cast<sal_uInt16>(*o3tl::doAccess<sal_Int32>(pValues[ 10 ])) );
771
5
    if( pValues[11].hasValue() ) SetDraw( *o3tl::doAccess<bool>(pValues[ 11 ]) );
772
773
    // just for impress
774
5
    if (IsImpress())
775
5
    {
776
5
        if( pValues[12].hasValue() ) SetNotes( *o3tl::doAccess<bool>(pValues[ 12 ]) );
777
5
        if( pValues[13].hasValue() ) SetHandout( *o3tl::doAccess<bool>(pValues[ 13 ]) );
778
5
        if( pValues[14].hasValue() ) SetOutline( *o3tl::doAccess<bool>(pValues[ 14 ]) );
779
5
        if( pValues[15].hasValue() ) SetHandoutHorizontal( *o3tl::doAccess<bool>(pValues[15]) );
780
5
        if( pValues[16].hasValue() ) SetHandoutPages( static_cast<sal_uInt16>(*o3tl::doAccess<sal_Int32>(pValues[16])) );
781
5
    }
782
783
5
    return true;
784
5
}
785
786
bool SdOptionsPrint::WriteData( Any* pValues ) const
787
0
{
788
0
    pValues[ 0 ] <<= IsDate();
789
0
    pValues[ 1 ] <<= IsTime();
790
0
    pValues[ 2 ] <<= IsPagename();
791
0
    pValues[ 3 ] <<= IsHiddenPages();
792
0
    pValues[ 4 ] <<= IsPagesize();
793
0
    pValues[ 5 ] <<= IsPagetile();
794
0
    pValues[ 6 ] <<= IsBooklet();
795
0
    pValues[ 7 ] <<= IsFrontPage();
796
0
    pValues[ 8 ] <<= IsBackPage();
797
0
    pValues[ 9 ] <<= IsPaperbin();
798
0
    pValues[ 10 ] <<= static_cast<sal_Int32>(GetOutputQuality());
799
0
    pValues[ 11 ] <<= IsDraw();
800
801
    // just for impress
802
0
    if (IsImpress())
803
0
    {
804
0
        pValues[ 12 ] <<= IsNotes();
805
0
        pValues[ 13 ] <<= IsHandout();
806
0
        pValues[ 14 ] <<= IsOutline();
807
0
        pValues[ 15 ] <<= IsHandoutHorizontal();
808
0
        pValues[ 16 ] <<= GetHandoutPages();
809
0
    }
810
811
0
    return true;
812
0
}
813
814
/*************************************************************************
815
|*
816
|* SdOptionsPrintItem
817
|*
818
\************************************************************************/
819
820
SdOptionsPrintItem::SdOptionsPrintItem()
821
38.6k
:   SfxPoolItem     ( ATTR_OPTIONS_PRINT )
822
38.6k
,   maOptionsPrint  ( false, false )
823
38.6k
{
824
38.6k
}
825
826
SdOptionsPrintItem::SdOptionsPrintItem( SdOptions const * pOpts )
827
46.6k
:   SfxPoolItem     ( ATTR_OPTIONS_PRINT )
828
46.6k
,   maOptionsPrint  ( false, false )
829
46.6k
{
830
46.6k
    if( !pOpts )
831
0
        return;
832
833
46.6k
    maOptionsPrint.SetDraw( pOpts->IsDraw() );
834
46.6k
    maOptionsPrint.SetNotes( pOpts->IsNotes() );
835
46.6k
    maOptionsPrint.SetHandout( pOpts->IsHandout() );
836
46.6k
    maOptionsPrint.SetOutline( pOpts->IsOutline() );
837
46.6k
    maOptionsPrint.SetDate( pOpts->IsDate() );
838
46.6k
    maOptionsPrint.SetTime( pOpts->IsTime() );
839
46.6k
    maOptionsPrint.SetPagename( pOpts->IsPagename() );
840
46.6k
    maOptionsPrint.SetHiddenPages( pOpts->IsHiddenPages() );
841
46.6k
    maOptionsPrint.SetPagesize( pOpts->IsPagesize() );
842
46.6k
    maOptionsPrint.SetPagetile( pOpts->IsPagetile() );
843
46.6k
    maOptionsPrint.SetWarningPrinter( pOpts->IsWarningPrinter() );
844
46.6k
    maOptionsPrint.SetWarningSize( pOpts->IsWarningSize() );
845
46.6k
    maOptionsPrint.SetWarningOrientation( pOpts->IsWarningOrientation() );
846
46.6k
    maOptionsPrint.SetBooklet( pOpts->IsBooklet() );
847
46.6k
    maOptionsPrint.SetFrontPage( pOpts->IsFrontPage() );
848
46.6k
    maOptionsPrint.SetBackPage( pOpts->IsBackPage() );
849
46.6k
    maOptionsPrint.SetCutPage( pOpts->IsCutPage() );
850
46.6k
    maOptionsPrint.SetPaperbin( pOpts->IsPaperbin() );
851
46.6k
    maOptionsPrint.SetOutputQuality( pOpts->GetOutputQuality() );
852
46.6k
}
853
854
SdOptionsPrintItem* SdOptionsPrintItem::Clone( SfxItemPool* ) const
855
52.1k
{
856
52.1k
    return new SdOptionsPrintItem( *this );
857
52.1k
}
858
859
bool SdOptionsPrintItem::operator==( const SfxPoolItem& rAttr ) const
860
344
{
861
344
    assert(SfxPoolItem::operator==(rAttr));
862
344
    return maOptionsPrint == static_cast<const SdOptionsPrintItem&>(rAttr).maOptionsPrint;
863
344
}
864
865
void SdOptionsPrintItem::SetOptions( SdOptions* pOpts ) const
866
0
{
867
0
    if( !pOpts )
868
0
        return;
869
870
0
    pOpts->SetDraw( maOptionsPrint.IsDraw() );
871
0
    pOpts->SetNotes( maOptionsPrint.IsNotes() );
872
0
    pOpts->SetHandout( maOptionsPrint.IsHandout() );
873
0
    pOpts->SetOutline( maOptionsPrint.IsOutline() );
874
0
    pOpts->SetDate( maOptionsPrint.IsDate() );
875
0
    pOpts->SetTime( maOptionsPrint.IsTime() );
876
0
    pOpts->SetPagename( maOptionsPrint.IsPagename() );
877
0
    pOpts->SetHiddenPages( maOptionsPrint.IsHiddenPages() );
878
0
    pOpts->SetPagesize( maOptionsPrint.IsPagesize() );
879
0
    pOpts->SetPagetile( maOptionsPrint.IsPagetile() );
880
0
    pOpts->SetWarningPrinter( maOptionsPrint.IsWarningPrinter() );
881
0
    pOpts->SetWarningSize( maOptionsPrint.IsWarningSize() );
882
0
    pOpts->SetWarningOrientation( maOptionsPrint.IsWarningOrientation() );
883
0
    pOpts->SetBooklet( maOptionsPrint.IsBooklet() );
884
0
    pOpts->SetFrontPage( maOptionsPrint.IsFrontPage() );
885
0
    pOpts->SetBackPage( maOptionsPrint.IsBackPage() );
886
0
    pOpts->SetCutPage( maOptionsPrint.IsCutPage() );
887
0
    pOpts->SetPaperbin( maOptionsPrint.IsPaperbin() );
888
0
    pOpts->SetOutputQuality( maOptionsPrint.GetOutputQuality() );
889
0
}
890
891
/*************************************************************************
892
|*
893
|* SdOptions
894
|*
895
\************************************************************************/
896
897
SdOptions::SdOptions(bool bImpress) :
898
5
    SdOptionsMisc( bImpress, true ),
899
5
    SdOptionsGrid( bImpress ),
900
5
    SdOptionsPrint( bImpress, true )
901
5
{
902
5
}
903
904
SdOptions::~SdOptions()
905
0
{
906
0
}
907
908
void SdOptions::StoreConfig()
909
0
{
910
0
    SdOptionsMisc::Store();
911
0
    SdOptionsGrid::Store();
912
0
    SdOptionsPrint::Store();
913
0
}
914
915
sal_Int32 SdOptionsMisc::GetDragThresholdPixels() const
916
12.5k
{
917
12.5k
    Init();
918
12.5k
    return mnDragThresholdPixels;
919
12.5k
}
920
921
void SdOptionsMisc::SetDragThreshold(sal_Int32 nDragThresholdPixels)
922
0
{
923
0
    if (mnDragThresholdPixels != nDragThresholdPixels)
924
0
    {
925
0
        OptionsChanged();
926
0
        mnDragThresholdPixels = nDragThresholdPixels;
927
0
    }
928
0
}
929
930
sal_Int32 SdOptionsMisc::GetDisplay() const
931
0
{
932
0
    Init();
933
0
    return mnDisplay;
934
0
}
935
936
void SdOptionsMisc::SetDisplay( sal_Int32 nDisplay )
937
0
{
938
0
    if( mnDisplay != nDisplay )
939
0
    {
940
0
        OptionsChanged();
941
0
        mnDisplay = nDisplay;
942
0
    }
943
0
}
944
945
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */