LibreOffice Module svx (master)  1
svdsob.hxx
Go to the documentation of this file.
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 #pragma once
21 
22 #include <com/sun/star/uno/Any.hxx>
23 
24 #include <svx/svxdllapi.h>
25 #include <svx/svdtypes.hxx>
26 
27 /*
28  Stores a bitfield of the layer values that have been set.
29 */
30 
32 {
34 
35 public:
36  explicit SdrLayerIDSet(bool bInitVal = false)
37  {
38  memset(aData, bInitVal ? 0xFF : 0x00, sizeof(aData));
39  }
40 
41  bool operator!=(const SdrLayerIDSet& rCmpSet) const
42  {
43  return (memcmp(aData, rCmpSet.aData, sizeof(aData))!=0);
44  }
45 
46  void Set(SdrLayerID a)
47  {
48  aData[sal_uInt8(a)/8] |= 1 << (sal_uInt8(a) % 8);
49  }
50 
51  void Clear(SdrLayerID a)
52  {
53  aData[sal_uInt8(a)/8] &= ~(1 << (sal_uInt8(a) % 8));
54  }
55 
56  void Set(SdrLayerID a, bool b)
57  {
58  if(b)
59  Set(a);
60  else
61  Clear(a);
62  }
63 
64  bool IsSet(SdrLayerID a) const
65  {
66  return (aData[sal_uInt8(a)/8] & 1<<sal_uInt8(a)%8) != 0;
67  }
68 
69  void SetAll()
70  {
71  memset(aData, 0xFF, sizeof(aData));
72  }
73 
74  void ClearAll()
75  {
76  memset(aData, 0x00, sizeof(aData));
77  }
78 
79  bool IsEmpty() const;
80 
81  void operator&=(const SdrLayerIDSet& r2ndSet);
82 
83  // initialize this set with a UNO sequence of sal_Int8 (e.g. as stored in settings.xml)
84  void PutValue(const css::uno::Any & rAny);
85 
86 };
87 
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Set(SdrLayerID a)
Definition: svdsob.hxx:46
void SetAll()
Definition: svdsob.hxx:69
o3tl::typed_flags< E >::Self operator&=(E &lhs, E rhs)
bool operator!=(const SdrLayerIDSet &rCmpSet) const
Definition: svdsob.hxx:41
void Set(SdrLayerID a, bool b)
Definition: svdsob.hxx:56
constexpr OUStringLiteral aData
sal_uInt8 aData[32]
Definition: svdsob.hxx:33
void Clear(EHistoryType eHistory)
bool IsSet(SdrLayerID a) const
Definition: svdsob.hxx:64
SdrLayerIDSet(bool bInitVal=false)
Definition: svdsob.hxx:36
unsigned char sal_uInt8
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
void ClearAll()
Definition: svdsob.hxx:74
void Clear(SdrLayerID a)
Definition: svdsob.hxx:51