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{
33 // For now, have up to 256 layers
35
36public:
37 explicit SdrLayerIDSet(bool bInitVal = false)
38 {
39 memset(aData, bInitVal ? 0xFF : 0x00, sizeof(aData));
40 }
41
42 bool operator!=(const SdrLayerIDSet& rCmpSet) const
43 {
44 return (memcmp(aData, rCmpSet.aData, sizeof(aData))!=0);
45 }
46
48 {
49 const sal_Int16 nId = a.get();
50 if (nId >= 0 && nId < 256)
51 aData[nId / 8] |= 1 << (nId % 8);
52 }
53
55 {
56 const sal_Int16 nId = a.get();
57 if (nId >= 0 && nId < 256)
58 aData[nId / 8] &= ~(1 << (nId % 8));
59 }
60
61 void Set(SdrLayerID a, bool b)
62 {
63 if(b)
64 Set(a);
65 else
66 Clear(a);
67 }
68
69 bool IsSet(SdrLayerID a) const
70 {
71 const sal_Int16 nId = a.get();
72 return nId >= 0 && nId < 256 && (aData[nId / 8] & 1 << nId % 8) != 0;
73 }
74
75 void SetAll()
76 {
77 memset(aData, 0xFF, sizeof(aData));
78 }
79
80 void ClearAll()
81 {
82 memset(aData, 0x00, sizeof(aData));
83 }
84
85 bool IsEmpty() const;
86
87 void operator&=(const SdrLayerIDSet& r2ndSet);
88
89 // initialize this set with a UNO sequence of sal_Int8 (e.g. as stored in settings.xml)
90 void PutValue(const css::uno::Any & rAny);
91
92};
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Set(SdrLayerID a)
Definition: svdsob.hxx:47
void Clear(SdrLayerID a)
Definition: svdsob.hxx:54
void Set(SdrLayerID a, bool b)
Definition: svdsob.hxx:61
sal_uInt8 aData[32]
Definition: svdsob.hxx:34
bool IsSet(SdrLayerID a) const
Definition: svdsob.hxx:69
bool operator!=(const SdrLayerIDSet &rCmpSet) const
Definition: svdsob.hxx:42
void ClearAll()
Definition: svdsob.hxx:80
SdrLayerIDSet(bool bInitVal=false)
Definition: svdsob.hxx:37
void SetAll()
Definition: svdsob.hxx:75
uno_Any a
constexpr OUStringLiteral aData
void Clear(EHistoryType eHistory)
sal_Int16 nId
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
o3tl::typed_flags< E >::Self operator&=(E &lhs, E rhs)
unsigned char sal_uInt8