Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
4623c603
Kaydet (Commit)
4623c603
authored
Tem 30, 2012
tarafından
Noel Grandin
Kaydeden (comit)
Michael Stahl
Tem 31, 2012
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
sw: convert SwpHtStart SwpHtEnd to sorted_vector
Change-Id: I74696094ef066687582bd961d61a4877673016fd
üst
7ee95c52
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
102 deletions
+49
-102
ndhints.hxx
sw/inc/ndhints.hxx
+19
-12
ndhints.cxx
sw/source/core/txtnode/ndhints.cxx
+30
-90
No files found.
sw/inc/ndhints.hxx
Dosyayı görüntüle @
4623c603
...
@@ -29,8 +29,8 @@
...
@@ -29,8 +29,8 @@
#define _NDHINTS_HXX
#define _NDHINTS_HXX
#include <svl/svarray.hxx>
#include <tools/mempool.hxx>
#include <tools/mempool.hxx>
#include <o3tl/sorted_vector.hxx>
#include "swtypes.hxx"
#include "swtypes.hxx"
...
@@ -71,9 +71,17 @@ MakeRedlineTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr );
...
@@ -71,9 +71,17 @@ MakeRedlineTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr );
// Class SwpHtStart/End
// Class SwpHtStart/End
struct
CompareSwpHtStart
{
bool
operator
()(
SwTxtAttr
*
const
lhs
,
SwTxtAttr
*
const
rhs
)
const
;
};
class
SwpHtStart
:
public
o3tl
::
sorted_vector
<
SwTxtAttr
*
,
CompareSwpHtStart
>
{};
SV_DECL_PTRARR_SORT
(
SwpHtStart
,
SwTxtAttr
*
,
1
)
struct
CompareSwpHtEnd
SV_DECL_PTRARR_SORT
(
SwpHtEnd
,
SwTxtAttr
*
,
1
)
{
bool
operator
()(
SwTxtAttr
*
const
lhs
,
SwTxtAttr
*
const
rhs
)
const
;
};
class
SwpHtEnd
:
public
o3tl
::
sorted_vector
<
SwTxtAttr
*
,
CompareSwpHtEnd
>
{};
// Class SwpHintsArr
// Class SwpHintsArr
...
@@ -102,18 +110,17 @@ public:
...
@@ -102,18 +110,17 @@ public:
inline
SwTxtAttr
*
GetEnd
(
const
sal_uInt16
nPos
)
inline
SwTxtAttr
*
GetEnd
(
const
sal_uInt16
nPos
)
{
return
m_HintEnds
[
nPos
];
}
{
return
m_HintEnds
[
nPos
];
}
inline
sal_uInt16
GetEndCount
()
const
{
return
m_HintEnds
.
Count
();
}
inline
sal_uInt16
GetEndCount
()
const
{
return
m_HintEnds
.
size
();
}
inline
sal_uInt16
GetStartCount
()
const
{
return
m_HintStarts
.
Count
();
}
inline
sal_uInt16
GetStartCount
()
const
{
return
m_HintStarts
.
size
();
}
inline
sal_uInt16
GetStartOf
(
const
SwTxtAttr
*
pHt
)
const
;
inline
sal_uInt16
GetStartOf
(
const
SwTxtAttr
*
pHt
)
const
;
inline
sal_uInt16
GetPos
(
const
SwTxtAttr
*
pHt
)
const
sal_uInt16
GetPos
(
const
SwTxtAttr
*
pHt
)
const
;
{
return
m_HintStarts
.
GetPos
(
pHt
);
}
inline
SwTxtAttr
*
GetTextHint
(
const
sal_uInt16
nIdx
)
inline
SwTxtAttr
*
GetTextHint
(
const
sal_uInt16
nIdx
)
{
return
GetStart
(
nIdx
);
}
{
return
GetStart
(
nIdx
);
}
inline
const
SwTxtAttr
*
operator
[](
const
sal_uInt16
nIdx
)
const
inline
const
SwTxtAttr
*
operator
[](
const
sal_uInt16
nIdx
)
const
{
return
m_HintStarts
[
nIdx
];
}
{
return
m_HintStarts
[
nIdx
];
}
inline
sal_uInt16
Count
()
const
{
return
m_HintStarts
.
Count
();
}
inline
sal_uInt16
Count
()
const
{
return
m_HintStarts
.
size
();
}
#ifdef DBG_UTIL
#ifdef DBG_UTIL
bool
Check
()
const
;
bool
Check
()
const
;
...
@@ -205,12 +212,12 @@ SvStream &operator<<(SvStream &aS, const SwpHints &rHints); //$ ostream
...
@@ -205,12 +212,12 @@ SvStream &operator<<(SvStream &aS, const SwpHints &rHints); //$ ostream
inline
sal_uInt16
SwpHintsArray
::
GetStartOf
(
const
SwTxtAttr
*
pHt
)
const
inline
sal_uInt16
SwpHintsArray
::
GetStartOf
(
const
SwTxtAttr
*
pHt
)
const
{
{
sal_uInt16
nPos
;
SwpHtStart
::
const_iterator
it
=
m_HintStarts
.
find
(
(
SwTxtAttr
*
)
pHt
)
;
if
(
!
m_HintStarts
.
Seek_Entry
(
pHt
,
&
nPos
)
)
if
(
it
==
m_HintStarts
.
end
(
)
)
{
{
nPos
=
USHRT_MAX
;
return
USHRT_MAX
;
}
}
return
nPos
;
return
it
-
m_HintStarts
.
begin
()
;
}
}
inline
SwTxtAttr
*
SwpHintsArray
::
Cut
(
const
sal_uInt16
nPosInStart
)
inline
SwTxtAttr
*
SwpHintsArray
::
Cut
(
const
sal_uInt16
nPosInStart
)
...
...
sw/source/core/txtnode/ndhints.cxx
Dosyayı görüntüle @
4623c603
...
@@ -36,9 +36,6 @@
...
@@ -36,9 +36,6 @@
#endif
#endif
_SV_IMPL_SORTAR_ALG
(
SwpHtStart
,
SwTxtAttr
*
)
_SV_IMPL_SORTAR_ALG
(
SwpHtEnd
,
SwTxtAttr
*
)
inline
void
DumpHints
(
const
SwpHtStart
&
,
const
SwpHtEnd
&
)
{
}
inline
void
DumpHints
(
const
SwpHtStart
&
,
const
SwpHtEnd
&
)
{
}
/*************************************************************************
/*************************************************************************
...
@@ -125,76 +122,14 @@ static sal_Bool lcl_IsLessEnd( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 )
...
@@ -125,76 +122,14 @@ static sal_Bool lcl_IsLessEnd( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 )
return
(
nHt1
<
nHt2
);
return
(
nHt1
<
nHt2
);
}
}
/*************************************************************************
bool
CompareSwpHtStart
::
operator
()(
SwTxtAttr
*
const
lhs
,
SwTxtAttr
*
const
rhs
)
const
* SwpHtStart::Seek_Entry()
*************************************************************************/
sal_Bool
SwpHtStart
::
Seek_Entry
(
const
SwTxtAttr
*
pElement
,
sal_uInt16
*
pPos
)
const
{
{
sal_uInt16
nOben
=
Count
(),
nMitte
,
nUnten
=
0
;
return
lcl_IsLessStart
(
*
lhs
,
*
rhs
);
if
(
nOben
>
0
)
{
nOben
--
;
while
(
nUnten
<=
nOben
)
{
nMitte
=
nUnten
+
(
nOben
-
nUnten
)
/
2
;
const
SwTxtAttr
*
pMitte
=
(
*
this
)[
nMitte
];
if
(
IsEqual
(
*
pMitte
,
*
pElement
)
)
{
*
pPos
=
nMitte
;
return
sal_True
;
}
else
if
(
lcl_IsLessStart
(
*
pMitte
,
*
pElement
)
)
nUnten
=
nMitte
+
1
;
else
if
(
nMitte
==
0
)
{
*
pPos
=
nUnten
;
return
sal_False
;
}
else
nOben
=
nMitte
-
1
;
}
}
*
pPos
=
nUnten
;
return
sal_False
;
}
}
/*************************************************************************
bool
CompareSwpHtEnd
::
operator
()(
SwTxtAttr
*
const
lhs
,
SwTxtAttr
*
const
rhs
)
const
* SwpHtEnd::Seek_Entry()
*************************************************************************/
sal_Bool
SwpHtEnd
::
Seek_Entry
(
const
SwTxtAttr
*
pElement
,
sal_uInt16
*
pPos
)
const
{
{
sal_uInt16
nOben
=
Count
(),
nMitte
,
nUnten
=
0
;
return
lcl_IsLessEnd
(
*
lhs
,
*
rhs
);
if
(
nOben
>
0
)
{
nOben
--
;
while
(
nUnten
<=
nOben
)
{
nMitte
=
nUnten
+
(
nOben
-
nUnten
)
/
2
;
const
SwTxtAttr
*
pMitte
=
(
*
this
)[
nMitte
];
if
(
IsEqual
(
*
pMitte
,
*
pElement
)
)
{
*
pPos
=
nMitte
;
return
sal_True
;
}
else
if
(
lcl_IsLessEnd
(
*
pMitte
,
*
pElement
)
)
nUnten
=
nMitte
+
1
;
else
if
(
nMitte
==
0
)
{
*
pPos
=
nUnten
;
return
sal_False
;
}
else
nOben
=
nMitte
-
1
;
}
}
*
pPos
=
nUnten
;
return
sal_False
;
}
}
/*************************************************************************
/*************************************************************************
...
@@ -205,27 +140,32 @@ void SwpHintsArray::Insert( const SwTxtAttr *pHt )
...
@@ -205,27 +140,32 @@ void SwpHintsArray::Insert( const SwTxtAttr *pHt )
{
{
Resort
();
Resort
();
#if OSL_DEBUG_LEVEL > 0
#if OSL_DEBUG_LEVEL > 0
sal_uInt16
nPos
;
OSL_ENSURE
(
m_HintStarts
.
find
(
(
SwTxtAttr
*
)
pHt
)
==
m_HintStarts
.
end
(),
OSL_ENSURE
(
!
m_HintStarts
.
Seek_Entry
(
pHt
,
&
nPos
),
"Insert: hint already in HtStart"
);
"Insert: hint already in HtStart"
);
OSL_ENSURE
(
!
m_HintEnds
.
Seek_Entry
(
pHt
,
&
nPos
),
OSL_ENSURE
(
m_HintEnds
.
find
(
(
SwTxtAttr
*
)
pHt
)
==
m_HintEnds
.
end
(
),
"Insert: hint already in HtEnd"
);
"Insert: hint already in HtEnd"
);
#endif
#endif
m_HintStarts
.
Insert
(
pHt
);
m_HintStarts
.
insert
(
(
SwTxtAttr
*
)
pHt
);
m_HintEnds
.
Insert
(
pHt
);
m_HintEnds
.
insert
(
(
SwTxtAttr
*
)
pHt
);
}
}
void
SwpHintsArray
::
DeleteAtPos
(
const
sal_uInt16
nPos
)
void
SwpHintsArray
::
DeleteAtPos
(
const
sal_uInt16
nPos
)
{
{
// optimization: nPos is the position in the Starts array
// optimization: nPos is the position in the Starts array
const
SwTxtAttr
*
pHt
=
m_HintStarts
[
nPos
];
SwTxtAttr
*
pHt
=
m_HintStarts
[
nPos
];
m_HintStarts
.
Remove
(
nPos
);
m_HintStarts
.
erase
(
m_HintStarts
.
begin
()
+
nPos
);
Resort
();
Resort
();
sal_uInt16
nEndPos
;
m_HintEnds
.
erase
(
pHt
);
m_HintEnds
.
Seek_Entry
(
pHt
,
&
nEndPos
);
}
m_HintEnds
.
Remove
(
nEndPos
);
sal_uInt16
SwpHintsArray
::
GetPos
(
const
SwTxtAttr
*
pHt
)
const
{
SwpHtStart
::
const_iterator
it
=
m_HintStarts
.
find
(
(
SwTxtAttr
*
)
pHt
);
if
(
it
==
m_HintStarts
.
end
()
)
return
USHRT_MAX
;
return
it
-
m_HintStarts
.
begin
();
}
}
#ifdef DBG_UTIL
#ifdef DBG_UTIL
...
@@ -246,7 +186,7 @@ void SwpHintsArray::DeleteAtPos( const sal_uInt16 nPos )
...
@@ -246,7 +186,7 @@ void SwpHintsArray::DeleteAtPos( const sal_uInt16 nPos )
bool
SwpHintsArray
::
Check
()
const
bool
SwpHintsArray
::
Check
()
const
{
{
// 1) gleiche Anzahl in beiden Arrays
// 1) gleiche Anzahl in beiden Arrays
CHECK_ERR
(
m_HintStarts
.
Count
()
==
m_HintEnds
.
Count
(),
CHECK_ERR
(
m_HintStarts
.
size
()
==
m_HintEnds
.
size
(),
"HintsCheck: wrong sizes"
);
"HintsCheck: wrong sizes"
);
xub_StrLen
nLastStart
=
0
;
xub_StrLen
nLastStart
=
0
;
xub_StrLen
nLastEnd
=
0
;
xub_StrLen
nLastEnd
=
0
;
...
@@ -294,13 +234,13 @@ bool SwpHintsArray::Check() const
...
@@ -294,13 +234,13 @@ bool SwpHintsArray::Check() const
// --- Ueberkreuzungen ---
// --- Ueberkreuzungen ---
// 5) gleiche Pointer in beiden Arrays
// 5) gleiche Pointer in beiden Arrays
if
(
!
m_HintStarts
.
Seek_Entry
(
pHt
,
&
nIdx
)
)
if
(
m_HintStarts
.
find
(
(
SwTxtAttr
*
)
pHt
)
==
m_HintStarts
.
end
(
)
)
nIdx
=
STRING_LEN
;
nIdx
=
STRING_LEN
;
CHECK_ERR
(
STRING_LEN
!=
nIdx
,
"HintsCheck: no GetStartOf"
);
CHECK_ERR
(
STRING_LEN
!=
nIdx
,
"HintsCheck: no GetStartOf"
);
// 6) gleiche Pointer in beiden Arrays
// 6) gleiche Pointer in beiden Arrays
if
(
!
m_HintEnds
.
Seek_Entry
(
pHt
,
&
nIdx
)
)
if
(
m_HintEnds
.
find
(
(
SwTxtAttr
*
)
pHt
)
==
m_HintEnds
.
end
(
)
)
nIdx
=
STRING_LEN
;
nIdx
=
STRING_LEN
;
CHECK_ERR
(
STRING_LEN
!=
nIdx
,
"HintsCheck: no GetEndOf"
);
CHECK_ERR
(
STRING_LEN
!=
nIdx
,
"HintsCheck: no GetEndOf"
);
...
@@ -386,13 +326,13 @@ bool SwpHintsArray::Resort()
...
@@ -386,13 +326,13 @@ bool SwpHintsArray::Resort()
const
SwTxtAttr
*
pLast
=
0
;
const
SwTxtAttr
*
pLast
=
0
;
sal_uInt16
i
;
sal_uInt16
i
;
for
(
i
=
0
;
i
<
m_HintStarts
.
Count
();
++
i
)
for
(
i
=
0
;
i
<
m_HintStarts
.
size
();
++
i
)
{
{
const
SwTxtAttr
*
pHt
=
m_HintStarts
[
i
];
SwTxtAttr
*
pHt
=
m_HintStarts
[
i
];
if
(
pLast
&&
!
lcl_IsLessStart
(
*
pLast
,
*
pHt
)
)
if
(
pLast
&&
!
lcl_IsLessStart
(
*
pLast
,
*
pHt
)
)
{
{
m_HintStarts
.
Remove
(
i
);
m_HintStarts
.
erase
(
m_HintStarts
.
begin
()
+
i
);
m_HintStarts
.
I
nsert
(
pHt
);
m_HintStarts
.
i
nsert
(
pHt
);
pHt
=
m_HintStarts
[
i
];
pHt
=
m_HintStarts
[
i
];
if
(
pHt
!=
pLast
)
if
(
pHt
!=
pLast
)
--
i
;
--
i
;
...
@@ -402,13 +342,13 @@ bool SwpHintsArray::Resort()
...
@@ -402,13 +342,13 @@ bool SwpHintsArray::Resort()
}
}
pLast
=
0
;
pLast
=
0
;
for
(
i
=
0
;
i
<
m_HintEnds
.
Count
();
++
i
)
for
(
i
=
0
;
i
<
m_HintEnds
.
size
();
++
i
)
{
{
const
SwTxtAttr
*
pHt
=
m_HintEnds
[
i
];
SwTxtAttr
*
pHt
=
m_HintEnds
[
i
];
if
(
pLast
&&
!
lcl_IsLessEnd
(
*
pLast
,
*
pHt
)
)
if
(
pLast
&&
!
lcl_IsLessEnd
(
*
pLast
,
*
pHt
)
)
{
{
m_HintEnds
.
Remove
(
i
);
m_HintEnds
.
erase
(
m_HintEnds
.
begin
()
+
i
);
m_HintEnds
.
I
nsert
(
pHt
);
m_HintEnds
.
i
nsert
(
pHt
);
pHt
=
m_HintEnds
[
i
];
// normalerweise == pLast
pHt
=
m_HintEnds
[
i
];
// normalerweise == pLast
// Wenn die Unordnung etwas groesser ist (24200),
// Wenn die Unordnung etwas groesser ist (24200),
// muessen wir Position i erneut vergleichen.
// muessen wir Position i erneut vergleichen.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment