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
0a601a0c
Kaydet (Commit)
0a601a0c
authored
Eyl 16, 2015
tarafından
Michael Stahl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
sw: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: I3bfb0933d5233b89f24773500f07fdc92d0011e9
üst
529f5441
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
26 deletions
+30
-26
ToxLinkProcessor.hxx
sw/inc/ToxLinkProcessor.hxx
+4
-3
test_ToxLinkProcessor.cxx
sw/qa/core/test_ToxLinkProcessor.cxx
+12
-12
ToxLinkProcessor.cxx
sw/source/core/tox/ToxLinkProcessor.cxx
+14
-11
No files found.
sw/inc/ToxLinkProcessor.hxx
Dosyayı görüntüle @
0a601a0c
...
...
@@ -13,7 +13,8 @@
#include "fmtinfmt.hxx"
#include "rtl/ustring.hxx"
#include <boost/ptr_container/ptr_vector.hpp>
#include <memory>
#include <vector>
class
SwTextNode
;
...
...
@@ -76,9 +77,9 @@ private:
sal_Int32
mEndTextPos
;
};
boost
::
ptr_vector
<
ClosedLink
>
m
ClosedLinks
;
std
::
vector
<
std
::
unique_ptr
<
ClosedLink
>>
m_
ClosedLinks
;
boost
::
ptr_vector
<
StartedLink
>
m
StartedLinks
;
std
::
vector
<
std
::
unique_ptr
<
StartedLink
>>
m_
StartedLinks
;
friend
class
::
ToxLinkProcessorTest
;
};
...
...
sw/qa/core/test_ToxLinkProcessor.cxx
Dosyayı görüntüle @
0a601a0c
...
...
@@ -81,8 +81,8 @@ ToxLinkProcessorTest::StandardOpenLinkIsAddedWhenMoreLinksThanAvaiableAreClosed(
sut
.
StartNewLink
(
0
,
STYLE_NAME_1
);
sut
.
CloseLink
(
1
,
URL_1
);
sut
.
CloseLink
(
1
,
URL_1
);
CPPUNIT_ASSERT_EQUAL
(
2u
,
static_cast
<
unsigned
>
(
sut
.
mClosedLinks
.
size
()));
CPPUNIT_ASSERT_EQUAL
(
0u
,
static_cast
<
unsigned
>
(
sut
.
m
ClosedLinks
.
at
(
1
).
mEndTextPos
));
CPPUNIT_ASSERT_EQUAL
(
2u
,
static_cast
<
unsigned
>
(
sut
.
m
_
ClosedLinks
.
size
()));
CPPUNIT_ASSERT_EQUAL
(
0u
,
static_cast
<
unsigned
>
(
sut
.
m
_ClosedLinks
.
at
(
1
)
->
mEndTextPos
));
}
void
...
...
@@ -93,8 +93,8 @@ ToxLinkProcessorTest::AddingAndClosingTwoLinksResultsInTwoClosedLinks()
sut
.
StartNewLink
(
0
,
STYLE_NAME_2
);
sut
.
CloseLink
(
1
,
URL_1
);
sut
.
CloseLink
(
1
,
URL_2
);
CPPUNIT_ASSERT_EQUAL
(
2u
,
static_cast
<
unsigned
>
(
sut
.
mClosedLinks
.
size
()));
CPPUNIT_ASSERT_MESSAGE
(
"no links are open"
,
sut
.
mStartedLinks
.
empty
());
CPPUNIT_ASSERT_EQUAL
(
2u
,
static_cast
<
unsigned
>
(
sut
.
m
_
ClosedLinks
.
size
()));
CPPUNIT_ASSERT_MESSAGE
(
"no links are open"
,
sut
.
m
_
StartedLinks
.
empty
());
}
class
ToxLinkProcessorWithOverriddenObtainPoolId
:
public
ToxLinkProcessor
{
...
...
@@ -120,8 +120,8 @@ ToxLinkProcessorTest::LinkIsCreatedCorrectly()
sut
.
StartNewLink
(
0
,
STYLE_NAME_1
);
sut
.
CloseLink
(
1
,
URL_1
);
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"Style is stored correctly in link"
,
STYLE_NAME_1
,
sut
.
m
ClosedLinks
.
at
(
0
).
mINetFormat
.
GetVisitedFormat
());
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"Url is stored correctly in link"
,
URL_1
,
sut
.
m
ClosedLinks
.
at
(
0
).
mINetFormat
.
GetValue
());
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"Style is stored correctly in link"
,
STYLE_NAME_1
,
sut
.
m
_ClosedLinks
.
at
(
0
)
->
mINetFormat
.
GetVisitedFormat
());
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"Url is stored correctly in link"
,
URL_1
,
sut
.
m
_ClosedLinks
.
at
(
0
)
->
mINetFormat
.
GetValue
());
}
void
...
...
@@ -138,18 +138,18 @@ ToxLinkProcessorTest::LinkSequenceIsPreserved()
// check first closed element
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"Style is stored correctly in link"
,
STYLE_NAME_2
,
sut
.
m
ClosedLinks
.
at
(
0
).
mINetFormat
.
GetVisitedFormat
());
STYLE_NAME_2
,
sut
.
m
_ClosedLinks
.
at
(
0
)
->
mINetFormat
.
GetVisitedFormat
());
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"Pool id is stored correctly in link"
,
POOL_ID_2
,
sut
.
m
ClosedLinks
.
at
(
0
).
mINetFormat
.
GetINetFormatId
());
POOL_ID_2
,
sut
.
m
_ClosedLinks
.
at
(
0
)
->
mINetFormat
.
GetINetFormatId
());
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"Url is stored correctly in link"
,
URL_2
,
sut
.
m
ClosedLinks
.
at
(
0
).
mINetFormat
.
GetValue
());
URL_2
,
sut
.
m
_ClosedLinks
.
at
(
0
)
->
mINetFormat
.
GetValue
());
// check second closed element
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"Style is stored correctly in link"
,
STYLE_NAME_1
,
sut
.
m
ClosedLinks
.
at
(
1
).
mINetFormat
.
GetVisitedFormat
());
STYLE_NAME_1
,
sut
.
m
_ClosedLinks
.
at
(
1
)
->
mINetFormat
.
GetVisitedFormat
());
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"Pool id is stored correctly in link"
,
POOL_ID_1
,
sut
.
m
ClosedLinks
.
at
(
1
).
mINetFormat
.
GetINetFormatId
());
POOL_ID_1
,
sut
.
m
_ClosedLinks
.
at
(
1
)
->
mINetFormat
.
GetINetFormatId
());
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"Url is stored correctly in link"
,
URL_1
,
sut
.
m
ClosedLinks
.
at
(
1
).
mINetFormat
.
GetValue
());
URL_1
,
sut
.
m
_ClosedLinks
.
at
(
1
)
->
mINetFormat
.
GetValue
());
}
// Put the test suite in the registry
...
...
sw/source/core/tox/ToxLinkProcessor.cxx
Dosyayı görüntüle @
0a601a0c
...
...
@@ -20,32 +20,34 @@ namespace sw {
void
ToxLinkProcessor
::
StartNewLink
(
sal_Int32
startPosition
,
const
OUString
&
characterStyle
)
{
mStartedLinks
.
push_back
(
new
StartedLink
(
startPosition
,
characterStyle
));
m_StartedLinks
.
push_back
(
std
::
unique_ptr
<
StartedLink
>
(
new
StartedLink
(
startPosition
,
characterStyle
)));
}
void
ToxLinkProcessor
::
CloseLink
(
sal_Int32
endPosition
,
const
OUString
&
url
)
{
StartedLink
const
startedLink
(
(
mStartedLinks
.
empty
())
StartedLink
const
startedLink
(
(
m
_
StartedLinks
.
empty
())
?
StartedLink
(
0
,
SW_RES
(
STR_POOLCHR_TOXJUMP
))
:
m
StartedLinks
.
back
()
);
if
(
!
mStartedLinks
.
empty
())
:
*
m_
StartedLinks
.
back
()
);
if
(
!
m
_
StartedLinks
.
empty
())
{
mStartedLinks
.
pop_back
();
m
_
StartedLinks
.
pop_back
();
}
if
(
url
.
isEmpty
())
{
return
;
}
ClosedLink
*
closedLink
=
new
ClosedLink
(
url
,
startedLink
.
mStartPosition
,
endPosition
);
std
::
unique_ptr
<
ClosedLink
>
pClosedLink
(
new
ClosedLink
(
url
,
startedLink
.
mStartPosition
,
endPosition
));
const
OUString
&
characterStyle
=
startedLink
.
mCharacterStyle
;
sal_uInt16
poolId
=
ObtainPoolId
(
characterStyle
);
c
losedLink
->
mINetFormat
.
SetVisitedFormatAndId
(
characterStyle
,
poolId
);
c
losedLink
->
mINetFormat
.
SetINetFormatAndId
(
characterStyle
,
poolId
);
pC
losedLink
->
mINetFormat
.
SetVisitedFormatAndId
(
characterStyle
,
poolId
);
pC
losedLink
->
mINetFormat
.
SetINetFormatAndId
(
characterStyle
,
poolId
);
m
ClosedLinks
.
push_back
(
closedLink
);
m
_ClosedLinks
.
push_back
(
std
::
move
(
pClosedLink
)
);
}
sal_uInt16
...
...
@@ -63,8 +65,9 @@ ToxLinkProcessor::ObtainPoolId(const OUString& characterStyle) const
void
ToxLinkProcessor
::
InsertLinkAttributes
(
SwTextNode
&
node
)
{
for
(
ClosedLink
&
clink
:
mClosedLinks
)
{
node
.
InsertItem
(
clink
.
mINetFormat
,
clink
.
mStartTextPos
,
clink
.
mEndTextPos
);
for
(
auto
const
&
clink
:
m_ClosedLinks
)
{
node
.
InsertItem
(
clink
->
mINetFormat
,
clink
->
mStartTextPos
,
clink
->
mEndTextPos
);
}
}
...
...
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