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