LibreOffice Module sw (master)
1
sw
inc
bparr.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 <assert.h>
23
24
#include "
swdllapi.h
"
25
#include <array>
26
#include <memory>
27
28
struct
BlockInfo
;
29
class
BigPtrArray
;
30
31
class
BigPtrEntry
32
{
33
friend
class
BigPtrArray
;
34
BlockInfo
*
m_pBlock
;
35
sal_uInt16
m_nOffset
;
36
public
:
37
BigPtrEntry
() :
m_pBlock
(nullptr),
m_nOffset
(0) {}
38
BigPtrEntry
(
BigPtrEntry
const
&) =
default
;
39
virtual
~BigPtrEntry
() =
default
;
40
BigPtrEntry
&
operator =
(
BigPtrEntry
const
&) =
default
;
41
42
inline
sal_Int32
GetPos
()
const
;
43
inline
BigPtrArray
&
GetArray
()
const
;
44
};
45
46
// 1000 entries per Block = a bit less than 4K
47
#define MAXENTRY 1000
48
49
// number of entries that may remain free during compression
50
// this value is for the worst case; because we defined MAXBLOCK with ca 25%
51
// overhead, 80% = 800 entries are enough
52
// if complete compression is desired, 100 has to be specified
53
#define COMPRESSLVL 80
54
55
struct
BlockInfo
final
56
{
57
BigPtrArray
*
pBigArr
;
58
sal_Int32
nStart
,
nEnd
;
59
sal_uInt16
nElem
;
60
std::array<BigPtrEntry*, MAXENTRY>
61
mvData
;
62
};
63
64
class
SW_DLLPUBLIC
BigPtrArray
65
{
66
protected
:
67
std::unique_ptr<BlockInfo*[]>
68
m_ppInf
;
69
sal_Int32
m_nSize
;
70
sal_uInt16
m_nMaxBlock
;
71
sal_uInt16
m_nBlock
;
72
mutable
73
sal_uInt16
m_nCur
;
74
75
sal_uInt16 Index2Block( sal_Int32 )
const
;
76
BlockInfo
* InsBlock( sal_uInt16 );
77
void
BlockDel( sal_uInt16 );
78
void
UpdIndex( sal_uInt16 );
79
80
// fill all blocks
81
sal_uInt16 Compress();
82
83
public
:
84
BigPtrArray
();
85
~BigPtrArray
();
86
87
sal_Int32
Count
()
const
{
return
m_nSize
; }
88
89
void
Insert
(
BigPtrEntry
* p, sal_Int32 pos );
90
void
Remove
( sal_Int32 pos, sal_Int32 n = 1 );
91
void
Move
( sal_Int32 from, sal_Int32 to );
92
void
Replace
( sal_Int32 pos,
BigPtrEntry
* p);
93
94
BigPtrEntry
* operator[]( sal_Int32 )
const
;
95
};
96
97
inline
sal_Int32
BigPtrEntry::GetPos
()
const
98
{
99
assert(
this
==
m_pBlock
->
mvData
[
m_nOffset
]);
// element not in the block
100
return
m_pBlock
->
nStart
+
m_nOffset
;
101
}
102
103
inline
BigPtrArray
&
BigPtrEntry::GetArray
()
const
104
{
105
return
*
m_pBlock
->
pBigArr
;
106
}
107
108
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScChangeTrackMsgType::Remove
@ Remove
BigPtrArray
Definition:
bparr.hxx:65
BigPtrArray::m_nBlock
sal_uInt16 m_nBlock
number of blocks
Definition:
bparr.hxx:71
BigPtrArray::Count
sal_Int32 Count() const
Definition:
bparr.hxx:87
BigPtrArray::m_ppInf
std::unique_ptr< BlockInfo *[]> m_ppInf
block info
Definition:
bparr.hxx:68
BigPtrArray::m_nMaxBlock
sal_uInt16 m_nMaxBlock
current max. number of blocks
Definition:
bparr.hxx:70
BigPtrArray::m_nSize
sal_Int32 m_nSize
number of elements
Definition:
bparr.hxx:69
BigPtrArray::m_nCur
sal_uInt16 m_nCur
last used block
Definition:
bparr.hxx:73
BigPtrEntry
Definition:
bparr.hxx:32
BigPtrEntry::m_nOffset
sal_uInt16 m_nOffset
Definition:
bparr.hxx:35
BigPtrEntry::GetPos
sal_Int32 GetPos() const
Definition:
bparr.hxx:97
BigPtrEntry::BigPtrEntry
BigPtrEntry(BigPtrEntry const &)=default
BigPtrEntry::BigPtrEntry
BigPtrEntry()
Definition:
bparr.hxx:37
BigPtrEntry::~BigPtrEntry
virtual ~BigPtrEntry()=default
BigPtrEntry::operator=
BigPtrEntry & operator=(BigPtrEntry const &)=default
BigPtrEntry::GetArray
BigPtrArray & GetArray() const
Definition:
bparr.hxx:103
BigPtrEntry::m_pBlock
BlockInfo * m_pBlock
Definition:
bparr.hxx:34
Insert
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
m_nSize
sal_uInt32 m_nSize
ModifyFlags::Replace
@ Replace
BlockInfo
Definition:
bparr.hxx:56
BlockInfo::nElem
sal_uInt16 nElem
number of elements
Definition:
bparr.hxx:59
BlockInfo::pBigArr
BigPtrArray * pBigArr
in this array the block is located
Definition:
bparr.hxx:57
BlockInfo::mvData
std::array< BigPtrEntry *, MAXENTRY > mvData
data block
Definition:
bparr.hxx:61
BlockInfo::nEnd
sal_Int32 nEnd
start- and end index
Definition:
bparr.hxx:58
BlockInfo::nStart
sal_Int32 nStart
Definition:
bparr.hxx:58
SdrHdlKind::Move
@ Move
swdllapi.h
SW_DLLPUBLIC
#define SW_DLLPUBLIC
Definition:
swdllapi.h:28
Generated on Sun Jul 30 2023 04:27:57 for LibreOffice Module sw (master) by
1.9.3