Coverage Report

Created: 2026-11-06 11:29

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