cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / optsitem.hxx
blob65bca19910906c76f2e643f96969c7e4396e2ecd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <unotools/configitem.hxx>
23 #include <sfx2/module.hxx>
24 #include <svx/optgrid.hxx>
25 #include <tools/degree.hxx>
26 #include <sddllapi.h>
27 #include <memory>
29 class SdOptions;
31 namespace sd {
32 class FrameView;
35 class SdOptionsGeneric;
37 class SD_DLLPUBLIC SdOptionsItem final : public ::utl::ConfigItem
40 private:
42 const SdOptionsGeneric& mrParent;
44 virtual void ImplCommit() override;
46 public:
48 SdOptionsItem( const SdOptionsGeneric& rParent, const OUString& rSubTree );
49 virtual ~SdOptionsItem() override;
51 SdOptionsItem(SdOptionsItem const &) = default;
52 SdOptionsItem(SdOptionsItem &&) = default;
53 SdOptionsItem & operator =(SdOptionsItem const &) = delete; // due to ConfigItem
54 SdOptionsItem & operator =(SdOptionsItem &&) = delete; // due to ConfigItem
56 virtual void Notify( const css::uno::Sequence<OUString>& aPropertyNames) override;
58 css::uno::Sequence< css::uno::Any > GetProperties( const css::uno::Sequence< OUString >& rNames );
59 bool PutProperties( const css::uno::Sequence< OUString >& rNames,
60 const css::uno::Sequence< css::uno::Any>& rValues );
61 using ConfigItem::SetModified;
64 class SD_DLLPUBLIC SdOptionsGeneric
66 friend class SdOptionsItem;
68 private:
70 OUString maSubTree;
71 std::unique_ptr<SdOptionsItem>
72 mpCfgItem;
73 bool mbImpress;
74 bool mbInit : 1;
75 bool mbEnableModify : 1;
77 SAL_DLLPRIVATE void Commit( SdOptionsItem& rCfgItem ) const;
78 SAL_DLLPRIVATE css::uno::Sequence< OUString > GetPropertyNames() const;
80 protected:
82 void Init() const;
83 void OptionsChanged() { if( mpCfgItem && mbEnableModify ) mpCfgItem->SetModified(); }
85 protected:
87 virtual void GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const = 0;
88 virtual bool ReadData( const css::uno::Any* pValues ) = 0;
89 virtual bool WriteData( css::uno::Any* pValues ) const = 0;
91 public:
93 SdOptionsGeneric(bool bImpress, const OUString& rSubTree);
94 SdOptionsGeneric(SdOptionsGeneric const &);
95 virtual ~SdOptionsGeneric();
97 SdOptionsGeneric& operator=( SdOptionsGeneric const & );
99 bool IsImpress() const { return mbImpress; }
101 void EnableModify( bool bModify ) { mbEnableModify = bModify; }
103 void Store();
105 static bool isMetricSystem();
108 class SD_DLLPUBLIC SdOptionsMisc : public SdOptionsGeneric
110 private:
112 sal_Int32 nDefaultObjectSizeWidth;
113 sal_Int32 nDefaultObjectSizeHeight;
115 bool bStartWithTemplate : 1; // Misc/NewDoc/AutoPilot
116 bool bMarkedHitMovesAlways : 1; // Misc/ObjectMoveable
117 bool bMoveOnlyDragging : 1; // Currently, not in use !!!
118 bool bCrookNoContortion : 1; // Misc/NoDistort
119 bool bQuickEdit : 1; // Misc/TextObject/QuickEditing
120 bool bMasterPageCache : 1; // Misc/BackgroundCache
121 bool bDragWithCopy : 1; // Misc/CopyWhileMoving
122 bool bPickThrough : 1; // Misc/TextObject/Selectable
123 bool bDoubleClickTextEdit : 1; // Misc/DclickTextedit
124 bool bClickChangeRotation : 1; // Misc/RotateClick
125 bool bSolidDragging : 1; // Misc/ModifyWithAttributes
126 bool bSummationOfParagraphs : 1; // misc/SummationOfParagraphs
127 bool bTabBarVisible : 1; // Misc/TabBarVisible
128 bool bShowUndoDeleteWarning : 1; // Misc/ShowUndoDeleteWarning
129 // #i75315#
130 bool bSlideshowRespectZOrder : 1; // Misc/SlideshowRespectZOrder
131 bool bShowComments : 1; // Misc/ShowComments
133 bool bPreviewNewEffects;
134 bool bPreviewChangedEffects;
135 bool bPreviewTransitions;
137 sal_Int32 mnDisplay;
139 sal_Int32 mnPenColor;
140 double mnPenWidth;
142 /** This value controls the device to use for formatting documents.
143 The currently supported values are 0 for the current printer or 1
144 for the printer independent virtual device the can be retrieved from
145 the modules.
147 sal_uInt16 mnPrinterIndependentLayout; // Misc/Compatibility/PrinterIndependentLayout
149 /// Minimum mouse move distance for it to register as a drag action
150 sal_Int32 mnDragThresholdPixels; // Misc/DragThresholdPixels
151 // Misc
153 protected:
155 virtual void GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const override;
156 virtual bool ReadData( const css::uno::Any* pValues ) override;
157 virtual bool WriteData( css::uno::Any* pValues ) const override;
159 public:
161 SdOptionsMisc(bool bImpress, bool bUseConfig);
163 bool operator==( const SdOptionsMisc& rOpt ) const;
165 bool IsStartWithTemplate() const { Init(); return bStartWithTemplate; }
166 bool IsMarkedHitMovesAlways() const { Init(); return bMarkedHitMovesAlways; }
167 bool IsMoveOnlyDragging() const { Init(); return bMoveOnlyDragging; }
168 bool IsCrookNoContortion() const { Init(); return bCrookNoContortion; }
169 bool IsQuickEdit() const { Init(); return bQuickEdit; }
170 bool IsMasterPagePaintCaching() const { Init(); return bMasterPageCache; }
171 bool IsDragWithCopy() const { Init(); return bDragWithCopy; }
172 bool IsPickThrough() const { Init(); return bPickThrough; }
173 bool IsDoubleClickTextEdit() const { Init(); return bDoubleClickTextEdit; }
174 bool IsClickChangeRotation() const { Init(); return bClickChangeRotation; }
175 bool IsSolidDragging() const { Init(); return bSolidDragging; }
176 bool IsSummationOfParagraphs() const { Init(); return bSummationOfParagraphs; };
177 bool IsTabBarVisible() const { Init(); return bTabBarVisible; };
179 /** Return the currently selected printer independent layout mode.
180 @return
181 Returns 1 for printer independent layout enabled and 0 when it
182 is disabled. Other values are reserved for future use.
184 sal_uInt16 GetPrinterIndependentLayout() const { Init(); return mnPrinterIndependentLayout; };
185 bool IsShowUndoDeleteWarning() const { Init(); return bShowUndoDeleteWarning; }
186 bool IsSlideshowRespectZOrder() const { Init(); return bSlideshowRespectZOrder; }
187 sal_Int32 GetDefaultObjectSizeWidth() const { Init(); return nDefaultObjectSizeWidth; }
188 sal_Int32 GetDefaultObjectSizeHeight() const { Init(); return nDefaultObjectSizeHeight; }
190 bool IsPreviewNewEffects() const { Init(); return bPreviewNewEffects; }
191 bool IsPreviewChangedEffects() const { Init(); return bPreviewChangedEffects; }
192 bool IsPreviewTransitions() const { Init(); return bPreviewTransitions; }
194 sal_Int32 GetDisplay() const;
195 void SetDisplay( sal_Int32 nDisplay );
197 sal_Int32 GetPresentationPenColor() const { Init(); return mnPenColor; }
198 void SetPresentationPenColor( sal_Int32 nPenColor ) { if( mnPenColor != nPenColor ) { OptionsChanged(); mnPenColor = nPenColor; } }
200 double GetPresentationPenWidth() const { Init(); return mnPenWidth; }
201 void SetPresentationPenWidth( double nPenWidth ) { if( mnPenWidth != nPenWidth ) { OptionsChanged(); mnPenWidth = nPenWidth; } }
203 sal_Int32 GetDragThresholdPixels() const;
204 void SetDragThreshold(sal_Int32 nDragThresholdPixels);
206 void SetStartWithTemplate( bool bOn ) { if( bStartWithTemplate != bOn ) { OptionsChanged(); bStartWithTemplate = bOn; } }
207 void SetMarkedHitMovesAlways( bool bOn ) { if( bMarkedHitMovesAlways != bOn ) { OptionsChanged(); bMarkedHitMovesAlways = bOn; } }
208 void SetMoveOnlyDragging( bool bOn ) { if( bMoveOnlyDragging != bOn ) { OptionsChanged(); bMoveOnlyDragging = bOn; } }
209 void SetCrookNoContortion( bool bOn ) { if( bCrookNoContortion != bOn ) { OptionsChanged(); bCrookNoContortion = bOn; } }
210 void SetQuickEdit( bool bOn ) { if( bQuickEdit != bOn ) { OptionsChanged(); bQuickEdit = bOn; } }
211 void SetMasterPagePaintCaching( bool bOn ) { if( bMasterPageCache != bOn ) { OptionsChanged(); bMasterPageCache = bOn; } }
212 void SetDragWithCopy( bool bOn ) { if( bDragWithCopy != bOn ) { OptionsChanged(); bDragWithCopy = bOn; } }
213 void SetPickThrough( bool bOn ) { if( bPickThrough != bOn ) { OptionsChanged(); bPickThrough = bOn; } }
214 void SetDoubleClickTextEdit( bool bOn ) { if( bDoubleClickTextEdit != bOn ) { OptionsChanged(); bDoubleClickTextEdit = bOn; } }
215 void SetClickChangeRotation( bool bOn ) { if( bClickChangeRotation != bOn ) { OptionsChanged(); bClickChangeRotation = bOn; } }
216 void SetSummationOfParagraphs( bool bOn ){ if ( bOn != bSummationOfParagraphs ) { OptionsChanged(); bSummationOfParagraphs = bOn; } }
217 void SetTabBarVisible( bool bOn ){ if ( bOn != bTabBarVisible ) { OptionsChanged(); bTabBarVisible = bOn; } }
218 /** Set the printer independent layout mode.
219 @param nOn
220 The default value is to switch printer independent layout on,
221 hence the parameters name. Use 0 for turning it off. Other
222 values are reserved for future use.
224 void SetPrinterIndependentLayout (sal_uInt16 nOn ){ if ( nOn != mnPrinterIndependentLayout ) { OptionsChanged(); mnPrinterIndependentLayout = nOn; } }
225 void SetSolidDragging( bool bOn ) { if( bSolidDragging != bOn ) { OptionsChanged(); bSolidDragging = bOn; } }
226 void SetShowUndoDeleteWarning( bool bOn ) { if( bShowUndoDeleteWarning != bOn ) { OptionsChanged(); bShowUndoDeleteWarning = bOn; } }
227 void SetSlideshowRespectZOrder( bool bOn ) { if( bSlideshowRespectZOrder != bOn ) { OptionsChanged(); bSlideshowRespectZOrder = bOn; } }
228 void SetDefaultObjectSizeWidth( sal_Int32 nWidth ) { if( nDefaultObjectSizeWidth != nWidth ) { OptionsChanged(); nDefaultObjectSizeWidth = nWidth; } }
229 void SetDefaultObjectSizeHeight( sal_Int32 nHeight ) { if( nDefaultObjectSizeHeight != nHeight ) { OptionsChanged(); nDefaultObjectSizeHeight = nHeight; } }
231 void SetPreviewNewEffects( bool bOn ) { if( bPreviewNewEffects != bOn ) { OptionsChanged(); bPreviewNewEffects = bOn; } }
232 void SetPreviewChangedEffects( bool bOn ) { if( bPreviewChangedEffects != bOn ) { OptionsChanged(); bPreviewChangedEffects = bOn; } }
233 void SetPreviewTransitions( bool bOn ) { if( bPreviewTransitions != bOn ) { OptionsChanged(); bPreviewTransitions = bOn; } }
235 bool IsShowComments() const { Init(); return bShowComments; }
236 void SetShowComments( bool bShow ) { if( bShowComments != bShow ) { OptionsChanged(); bShowComments = bShow; } }
239 class SD_DLLPUBLIC SdOptionsMiscItem final : public SfxPoolItem
241 public:
243 explicit SdOptionsMiscItem();
244 SdOptionsMiscItem( SdOptions const * pOpts, ::sd::FrameView const * pView );
246 virtual SdOptionsMiscItem* Clone( SfxItemPool *pPool = nullptr ) const override;
247 virtual bool operator==( const SfxPoolItem& ) const override;
249 void SetOptions( SdOptions* pOpts ) const;
251 SdOptionsMisc& GetOptionsMisc() { return maOptionsMisc; }
252 const SdOptionsMisc& GetOptionsMisc() const { return maOptionsMisc; }
253 private:
254 SdOptionsMisc maOptionsMisc;
257 class SdOptionsGrid : public SdOptionsGeneric, public SvxOptionsGrid
259 protected:
261 virtual void GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const override;
262 virtual bool ReadData( const css::uno::Any* pValues ) override;
263 virtual bool WriteData( css::uno::Any* pValues ) const override;
265 public:
267 explicit SdOptionsGrid(bool bImpress);
268 virtual ~SdOptionsGrid() override;
270 void SetDefaults();
272 sal_uInt32 GetFieldDrawX() const { Init(); return SvxOptionsGrid::GetFieldDrawX(); }
273 sal_uInt32 GetFieldDivisionX() const { Init(); return SvxOptionsGrid::GetFieldDivisionX(); }
274 sal_uInt32 GetFieldDrawY() const { Init(); return SvxOptionsGrid::GetFieldDrawY(); }
275 sal_uInt32 GetFieldDivisionY() const { Init(); return SvxOptionsGrid::GetFieldDivisionY(); }
276 bool IsUseGridSnap() const { Init(); return SvxOptionsGrid::GetUseGridSnap(); }
277 bool IsSynchronize() const { Init(); return SvxOptionsGrid::GetSynchronize(); }
278 bool IsGridVisible() const { Init(); return SvxOptionsGrid::GetGridVisible(); }
279 bool IsEqualGrid() const { Init(); return SvxOptionsGrid::GetEqualGrid(); }
281 void SetFieldDrawX( sal_uInt32 nSet ) { if( nSet != SvxOptionsGrid::GetFieldDrawX() ) { OptionsChanged(); SvxOptionsGrid::SetFieldDrawX( nSet ); } }
282 void SetFieldDivisionX( sal_uInt32 nSet ) { if( nSet != SvxOptionsGrid::GetFieldDivisionX() ) { OptionsChanged(); SvxOptionsGrid::SetFieldDivisionX( nSet ); } }
283 void SetFieldDrawY( sal_uInt32 nSet ) { if( nSet != SvxOptionsGrid::GetFieldDrawY() ) { OptionsChanged(); SvxOptionsGrid::SetFieldDrawY( nSet ); } }
284 void SetFieldDivisionY( sal_uInt32 nSet ) { if( nSet != SvxOptionsGrid::GetFieldDivisionY() ) { OptionsChanged(); SvxOptionsGrid::SetFieldDivisionY( nSet ); } }
285 void SetUseGridSnap( bool bSet ) { if( bSet != SvxOptionsGrid::GetUseGridSnap() ) { OptionsChanged(); SvxOptionsGrid::SetUseGridSnap( bSet ); } }
286 void SetSynchronize( bool bSet ) { if( bSet != SvxOptionsGrid::GetSynchronize() ) { OptionsChanged(); SvxOptionsGrid::SetSynchronize( bSet ); } }
287 void SetGridVisible( bool bSet ) { if( bSet != SvxOptionsGrid::GetGridVisible() ) { OptionsChanged(); SvxOptionsGrid::SetGridVisible( bSet ); } }
288 void SetEqualGrid( bool bSet ) { if( bSet != SvxOptionsGrid::GetEqualGrid() ) { OptionsChanged(); SvxOptionsGrid::SetEqualGrid( bSet ); } }
291 class SdOptionsGridItem final : public SvxGridItem
294 public:
295 explicit SdOptionsGridItem( SdOptions const * pOpts );
297 void SetOptions( SdOptions* pOpts ) const;
300 class SD_DLLPUBLIC SdOptionsPrint : public SdOptionsGeneric
302 private:
304 bool bDraw : 1; // Print/Content/Drawing
305 bool bNotes : 1; // Print/Content/Note
306 bool bHandout : 1; // Print/Content/Handout
307 bool bOutline : 1; // Print/Content/Outline
308 bool bDate : 1; // Print/Other/Date
309 bool bTime : 1; // Print/Other/Time
310 bool bPagename : 1; // Print/Other/PageName
311 bool bHiddenPages : 1; // Print/Other/HiddenPage
312 bool bPagesize : 1; // Print/Page/PageSize
313 bool bPagetile : 1; // Print/Page/PageTile
314 bool bWarningPrinter : 1; // These flags you get
315 bool bWarningSize : 1; // from the common options,
316 bool bWarningOrientation : 1; // currently org.openoffice.Office.Common.xml (class OfaMiscCfg ; sfx2/misccfg.hxx )
317 bool bBooklet : 1; // Print/Page/Booklet
318 bool bFront : 1; // Print/Page/BookletFront
319 bool bBack : 1; // Print/Page/BookletFront
320 bool bCutPage : 1; // NOT persistent !!!
321 bool bPaperbin : 1; // Print/Other/FromPrinterSetup
322 bool mbHandoutHorizontal : 1; // Order Page previews on Handout Pages horizontal
323 sal_uInt16 mnHandoutPages; // Number of page previews on handout page (only 1/2/4/6/9 are supported)
324 sal_uInt16 nQuality; // Print/Other/Quality
326 protected:
328 virtual void GetPropNameArray( const char**& ppNames, sal_uLong& rCount ) const override;
329 virtual bool ReadData( const css::uno::Any* pValues ) override;
330 virtual bool WriteData( css::uno::Any* pValues ) const override;
332 public:
334 SdOptionsPrint(bool bImpress, bool bUseConfig);
336 bool operator==( const SdOptionsPrint& rOpt ) const;
338 bool IsDraw() const { Init(); return bDraw; }
339 bool IsNotes() const { Init(); return bNotes; }
340 bool IsHandout() const { Init(); return bHandout; }
341 bool IsOutline() const { Init(); return bOutline; }
342 bool IsDate() const { Init(); return bDate; }
343 bool IsTime() const { Init(); return bTime; }
344 bool IsPagename() const { Init(); return bPagename; }
345 bool IsHiddenPages() const { Init(); return bHiddenPages; }
346 bool IsPagesize() const { Init(); return bPagesize; }
347 bool IsPagetile() const { Init(); return bPagetile; }
348 bool IsWarningPrinter() const { Init(); return bWarningPrinter; }
349 bool IsWarningSize() const { Init(); return bWarningSize; }
350 bool IsWarningOrientation() const { Init(); return bWarningOrientation; }
351 bool IsBooklet() const { Init(); return bBooklet; }
352 bool IsFrontPage() const { Init(); return bFront; }
353 bool IsBackPage() const { Init(); return bBack; }
354 bool IsCutPage() const { Init(); return bCutPage; }
355 bool IsPaperbin() const { Init(); return bPaperbin; }
356 sal_uInt16 GetOutputQuality() const { Init(); return nQuality; }
357 bool IsHandoutHorizontal() const { Init(); return mbHandoutHorizontal; }
358 sal_uInt16 GetHandoutPages() const { Init(); return mnHandoutPages; }
360 void SetDraw( bool bOn ) { if( bDraw != bOn ) { OptionsChanged(); bDraw = bOn; } }
361 void SetNotes( bool bOn ) { if( bNotes != bOn ) { OptionsChanged(); bNotes = bOn; } }
362 void SetHandout( bool bOn ) { if( bHandout != bOn ) { OptionsChanged(); bHandout = bOn; } }
363 void SetOutline( bool bOn ) { if( bOutline != bOn ) { OptionsChanged(); bOutline = bOn; } }
364 void SetDate( bool bOn ) { if( bDate != bOn ) { OptionsChanged(); bDate = bOn; } }
365 void SetTime( bool bOn ) { if( bTime != bOn ) { OptionsChanged(); bTime = bOn; } }
366 void SetPagename( bool bOn ) { if( bPagename != bOn ) { OptionsChanged(); bPagename = bOn; } }
367 void SetHiddenPages( bool bOn ) { if( bHiddenPages != bOn ) { OptionsChanged(); bHiddenPages = bOn; } }
368 void SetPagesize( bool bOn ) { if( bPagesize != bOn ) { OptionsChanged(); bPagesize = bOn; } }
369 void SetPagetile( bool bOn ) { if( bPagetile != bOn ) { OptionsChanged(); bPagetile = bOn; } }
370 void SetWarningPrinter( bool bOn ) { if( bWarningPrinter != bOn ) { OptionsChanged(); bWarningPrinter = bOn; } }
371 void SetWarningSize( bool bOn ) { if( bWarningSize != bOn ) { OptionsChanged(); bWarningSize = bOn; } }
372 void SetWarningOrientation( bool bOn) { if( bWarningOrientation != bOn ) { OptionsChanged(); bWarningOrientation = bOn; } }
373 void SetBooklet( bool bOn ) { if( bBooklet != bOn ) { OptionsChanged(); bBooklet = bOn; } }
374 void SetFrontPage( bool bOn ) { if( bFront != bOn ) { OptionsChanged(); bFront = bOn; } }
375 void SetBackPage( bool bOn ) { if( bBack != bOn ) { OptionsChanged(); bBack = bOn; } }
376 void SetCutPage( bool bOn ) { if( bCutPage != bOn ) { OptionsChanged(); bCutPage = bOn; } }
377 void SetPaperbin( bool bOn ) { if( bPaperbin != bOn ) { OptionsChanged(); bPaperbin = bOn; } }
378 void SetOutputQuality( sal_uInt16 nInQuality ) { if( nQuality != nInQuality ) { OptionsChanged(); nQuality = nInQuality; } }
379 void SetHandoutHorizontal( bool bHandoutHorizontal ) { if( mbHandoutHorizontal != bHandoutHorizontal ) { OptionsChanged(); mbHandoutHorizontal = bHandoutHorizontal; } }
380 void SetHandoutPages( sal_uInt16 nHandoutPages ) { if( nHandoutPages != mnHandoutPages ) { OptionsChanged(); mnHandoutPages = nHandoutPages; } }
383 class SD_DLLPUBLIC SdOptionsPrintItem final : public SfxPoolItem
385 public:
387 explicit SdOptionsPrintItem();
388 explicit SdOptionsPrintItem( SdOptions const * pOpts );
390 virtual SdOptionsPrintItem* Clone( SfxItemPool *pPool = nullptr ) const override;
391 virtual bool operator==( const SfxPoolItem& ) const override;
393 void SetOptions( SdOptions* pOpts ) const;
395 SdOptionsPrint& GetOptionsPrint() { return maOptionsPrint; }
396 const SdOptionsPrint& GetOptionsPrint() const { return maOptionsPrint; }
397 private:
398 SdOptionsPrint maOptionsPrint;
401 class SdOptions final :
402 public SdOptionsMisc,
403 public SdOptionsGrid,
404 public SdOptionsPrint
406 public:
408 explicit SdOptions(bool bImpress);
409 virtual ~SdOptions() override;
411 void StoreConfig();
414 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */