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
83345ff8
Kaydet (Commit)
83345ff8
authored
Kas 26, 2011
tarafından
August Sodora
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Simplification and accompanying tests
üst
e280ff03
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
25 deletions
+51
-25
test_lngmisc.cxx
svl/qa/unit/test_lngmisc.cxx
+32
-4
lngmisc.cxx
svl/source/misc/lngmisc.cxx
+19
-21
No files found.
svl/qa/unit/test_lngmisc.cxx
Dosyayı görüntüle @
83345ff8
...
@@ -17,14 +17,14 @@ namespace
...
@@ -17,14 +17,14 @@ namespace
private
:
private
:
void
testRemoveHyphens
();
void
testRemoveHyphens
();
void
testRemoveControlChars
();
void
testRemoveControlChars
();
//
void testReplaceControlChars();
void
testReplaceControlChars
();
// void testGetThesaurusReplaceText();
// void testGetThesaurusReplaceText();
CPPUNIT_TEST_SUITE
(
LngMiscTest
);
CPPUNIT_TEST_SUITE
(
LngMiscTest
);
CPPUNIT_TEST
(
testRemoveHyphens
);
CPPUNIT_TEST
(
testRemoveHyphens
);
CPPUNIT_TEST
(
testRemoveControlChars
);
CPPUNIT_TEST
(
testRemoveControlChars
);
//
CPPUNIT_TEST(testReplaceControlChars);
CPPUNIT_TEST
(
testReplaceControlChars
);
// CPPUNIT_TEST(testGetThesaurusReplaceText);
// CPPUNIT_TEST(testGetThesaurusReplaceText);
CPPUNIT_TEST_SUITE_END
();
CPPUNIT_TEST_SUITE_END
();
...
@@ -92,12 +92,40 @@ namespace
...
@@ -92,12 +92,40 @@ namespace
CPPUNIT_ASSERT
(
str4
.
equalsAsciiL
(
RTL_CONSTASCII_STRINGPARAM
(
" "
)));
CPPUNIT_ASSERT
(
str4
.
equalsAsciiL
(
RTL_CONSTASCII_STRINGPARAM
(
" "
)));
}
}
/*
void
LngMiscTest
::
testReplaceControlChars
()
void
LngMiscTest
::
testReplaceControlChars
()
{
{
CPPUNIT_ASSERT(true);
::
rtl
::
OUString
str1
(
RTL_CONSTASCII_USTRINGPARAM
(
""
));
::
rtl
::
OUString
str2
(
RTL_CONSTASCII_USTRINGPARAM
(
"asdf"
));
::
rtl
::
OUString
str3
(
RTL_CONSTASCII_USTRINGPARAM
(
"asdf
\n
asdf"
));
::
rtl
::
OUStringBuffer
str4Buf
(
33
);
str4Buf
.
setLength
(
33
);
for
(
int
i
=
0
;
i
<
33
;
i
++
)
str4Buf
[
i
]
=
static_cast
<
sal_Unicode
>
(
i
);
// TODO: is this a bug? shouldn't RemoveControlChars remove this?
// str4Buf[33] = static_cast<sal_Unicode>(0x7F);
::
rtl
::
OUString
str4
(
str4Buf
.
makeStringAndClear
());
bool
bModified
=
linguistic
::
ReplaceControlChars
(
str1
);
CPPUNIT_ASSERT
(
!
bModified
);
CPPUNIT_ASSERT
(
str1
.
isEmpty
());
bModified
=
linguistic
::
ReplaceControlChars
(
str2
);
CPPUNIT_ASSERT
(
!
bModified
);
CPPUNIT_ASSERT
(
str2
.
equalsAsciiL
(
RTL_CONSTASCII_STRINGPARAM
(
"asdf"
)));
bModified
=
linguistic
::
ReplaceControlChars
(
str3
);
CPPUNIT_ASSERT
(
bModified
);
CPPUNIT_ASSERT
(
str3
.
equalsAsciiL
(
RTL_CONSTASCII_STRINGPARAM
(
"asdf asdf"
)));
bModified
=
linguistic
::
ReplaceControlChars
(
str4
);
CPPUNIT_ASSERT
(
bModified
);
CPPUNIT_ASSERT
(
str4
.
getLength
()
==
32
);
for
(
int
i
=
0
;
i
<
32
;
i
++
)
CPPUNIT_ASSERT
(
str4
[
i
]
==
' '
);
}
}
/*
void LngMiscTest::testGetThesaurusReplaceText()
void LngMiscTest::testGetThesaurusReplaceText()
{
{
CPPUNIT_ASSERT(true);
CPPUNIT_ASSERT(true);
...
...
svl/source/misc/lngmisc.cxx
Dosyayı görüntüle @
83345ff8
...
@@ -82,29 +82,27 @@ namespace linguistic
...
@@ -82,29 +82,27 @@ namespace linguistic
// 1. non breaking field characters get removed
// 1. non breaking field characters get removed
// 2. remaining control characters will be replaced by ' '
// 2. remaining control characters will be replaced by ' '
bool
bModified
=
false
;
if
(
GetNumControlChars
(
rTxt
)
==
0
)
sal_Int32
nCtrlChars
=
GetNumControlChars
(
rTxt
);
return
false
;
if
(
nCtrlChars
)
sal_Int32
n
=
rTxt
.
getLength
();
rtl
::
OUStringBuffer
aBuf
(
n
);
aBuf
.
setLength
(
n
);
sal_Int32
j
=
0
;
for
(
sal_Int32
i
=
0
;
i
<
n
&&
j
<
n
;
++
i
)
{
{
sal_Int32
nLen
=
rTxt
.
getLength
();
if
(
CH_TXTATR_INWORD
==
rTxt
[
i
])
rtl
::
OUStringBuffer
aBuf
(
nLen
);
continue
;
sal_Int32
nCnt
=
0
;
for
(
sal_Int32
i
=
0
;
i
<
nLen
;
++
i
)
aBuf
[
j
++
]
=
IsControlChar
(
rTxt
[
i
])
?
' '
:
rTxt
[
i
];
{
sal_Unicode
cChar
=
rTxt
[
i
];
if
(
CH_TXTATR_INWORD
!=
cChar
)
{
if
(
IsControlChar
(
cChar
))
cChar
=
' '
;
DBG_ASSERT
(
nCnt
<
nLen
,
"index out of range"
);
aBuf
.
setCharAt
(
nCnt
++
,
cChar
);
}
}
aBuf
.
setLength
(
nCnt
);
rTxt
=
aBuf
.
makeStringAndClear
();
bModified
=
true
;
}
}
return
bModified
;
aBuf
.
setLength
(
j
);
rTxt
=
aBuf
.
makeStringAndClear
();
return
true
;
}
}
String
GetThesaurusReplaceText
(
const
String
&
rText
)
String
GetThesaurusReplaceText
(
const
String
&
rText
)
...
...
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