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
8e1a7034
Kaydet (Commit)
8e1a7034
authored
Eyl 02, 2014
tarafından
Michael Jaumann
Kaydeden (comit)
Michael Meeks
Eyl 08, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fdo#82854 - use OUStringBuffer in fontdefs.cxx plus unit-test.
Change-Id: Ia3a4814467ed98bd3b1889991cc3644c0c23f515
üst
253b97cc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
21 deletions
+116
-21
CppunitTest_unotools_fontdefs.mk
unotools/CppunitTest_unotools_fontdefs.mk
+34
-0
Module_unotools.mk
unotools/Module_unotools.mk
+3
-0
testGetEnlishSearchName.cxx
unotools/qa/unit/testGetEnlishSearchName.cxx
+70
-0
fontdefs.cxx
unotools/source/misc/fontdefs.cxx
+9
-21
No files found.
unotools/CppunitTest_unotools_fontdefs.mk
0 → 100644
Dosyayı görüntüle @
8e1a7034
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_CppunitTest_CppunitTest,unotools_fontdefs))
$(eval $(call gb_CppunitTest_use_external,unotools_fontdefs,boost_headers))
$(eval $(call gb_CppunitTest_use_api,unotools_fontdefs, \
offapi \
udkapi \
))
$(eval $(call gb_CppunitTest_add_exception_objects,unotools_fontdefs, \
unotools/qa/unit/testGetEnlishSearchName \
))
$(eval $(call gb_CppunitTest_use_libraries,unotools_fontdefs, \
comphelper \
cppu \
cppuhelper \
tl \
sal \
svt \
utl \
$(gb_UWINAPI) \
))
# vim: set noet sw=4 ts=4:
unotools/Module_unotools.mk
Dosyayı görüntüle @
8e1a7034
...
...
@@ -16,5 +16,8 @@ $(eval $(call gb_Module_add_targets,unotools,\
$(eval $(call gb_Module_add_subsequentcheck_targets,unotools,\
JunitTest_unotools_complex \
))
$(eval $(call gb_Module_add_check_targets,unotools,\
CppunitTest_unotools_fontdefs \
))
# vim: set noet sw=4 ts=4:
unotools/qa/unit/testGetEnlishSearchName.cxx
0 → 100644
Dosyayı görüntüle @
8e1a7034
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#include "cppunit/TestCase.h"
#include "cppunit/TestFixture.h"
#include "cppunit/TestSuite.h"
#include "cppunit/extensions/HelperMacros.h"
#include "cppunit/plugin/TestPlugIn.h"
#include <unotools/fontdefs.hxx>
class
Test
:
public
CppUnit
::
TestFixture
{
public
:
virtual
void
setUp
()
SAL_OVERRIDE
;
void
testSingleElement
();
CPPUNIT_TEST_SUITE
(
Test
);
CPPUNIT_TEST
(
testSingleElement
);
CPPUNIT_TEST_SUITE_END
();
};
void
Test
::
setUp
()
{};
void
Test
::
testSingleElement
()
{
{
//lowercase
printf
(
"GetEnglishSearchFontName(
\"
SYMBOL
\"
)"
);
OUString
test1
=
GetEnglishSearchFontName
(
"SYMBOL"
);
CPPUNIT_ASSERT_EQUAL
(
test1
,
OUString
(
"symbol"
));
printf
(
"return %s"
,
test1
.
getStr
());
//trailingWhitespaces
printf
(
"GetEnglishSearchFontName(
\"
SYMBOL
\"
)"
);
test1
=
GetEnglishSearchFontName
(
"Symbol "
);
CPPUNIT_ASSERT_EQUAL
(
test1
,
OUString
(
"symbol"
));
printf
(
"return %s"
,
test1
.
getStr
());
//removing Skripts
printf
(
"GetEnglishSearchFontName(
\"
SYMBOL(skript)
\"
)"
);
test1
=
GetEnglishSearchFontName
(
"Symbol(skript)"
);
CPPUNIT_ASSERT_EQUAL
(
test1
,
OUString
(
"symbol"
));
printf
(
"return %s"
,
test1
.
getStr
());
//remove Whitespaces between
printf
(
"GetEnglishSearchFontName(
\"
SYMBOL (skript)
\"
)"
);
test1
=
GetEnglishSearchFontName
(
"Symbol (skript)"
);
CPPUNIT_ASSERT_EQUAL
(
test1
,
OUString
(
"symbol"
));
printf
(
"return %s"
,
test1
.
getStr
());
//trailingWhitespaces
}
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
Test
);
CPPUNIT_PLUGIN_IMPLEMENT
();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
unotools/source/misc/fontdefs.cxx
Dosyayı görüntüle @
8e1a7034
...
...
@@ -322,8 +322,7 @@ static ImplLocalizedFontName aImplLocalizedNamesList[] =
OUString
GetEnglishSearchFontName
(
const
OUString
&
rInName
)
{
OUString
rName
(
rInName
);
OUStringBuffer
rName
(
rInName
.
getStr
());
bool
bNeedTranslation
=
false
;
sal_Int32
nLen
=
rName
.
getLength
();
...
...
@@ -332,7 +331,7 @@ OUString GetEnglishSearchFontName( const OUString& rInName )
while
(
i
&&
(
rName
[
i
-
1
]
<
32
)
)
i
--
;
if
(
i
!=
nLen
)
rName
=
rName
.
copy
(
0
,
i
);
rName
.
truncate
(
i
);
// Remove Script at the end
// Scriptname must be the last part of the fontname and
...
...
@@ -352,7 +351,7 @@ OUString GetEnglishSearchFontName( const OUString& rInName )
// Remove Space at the end
if
(
nTempLen
&&
(
rName
[
nTempLen
-
1
]
==
' '
)
)
nTempLen
--
;
rName
=
rName
.
copy
(
0
,
nTempLen
);
rName
.
truncate
(
nTempLen
);
nLen
=
nTempLen
;
break
;
}
...
...
@@ -379,11 +378,8 @@ OUString GetEnglishSearchFontName( const OUString& rInName )
// Upper to Lower
if
(
(
c
>=
'A'
)
&&
(
c
<=
'Z'
)
)
c
+=
'a'
-
'A'
;
//rName[ i ] = c;
OUStringBuffer
aTmpStr
(
rName
.
getStr
()
);
aTmpStr
[
i
]
=
c
;
rName
=
aTmpStr
.
makeStringAndClear
();
rName
[
i
]
=
c
;
}
else
...
...
@@ -399,21 +395,13 @@ OUString GetEnglishSearchFontName( const OUString& rInName )
if
(
(
c
>=
'A'
)
&&
(
c
<=
'Z'
)
)
{
c
+=
'a'
-
'A'
;
//rName[ i ] = c;
OUStringBuffer
aTmpStr
(
rName
.
getStr
()
);
aTmpStr
[
i
]
=
c
;
rName
=
aTmpStr
.
makeStringAndClear
();
rName
[
i
]
=
c
;
}
else
if
(
((
c
<
'0'
)
||
(
c
>
'9'
))
&&
(
c
!=
';'
)
)
// not 0-9 or semicolon
{
// Remove white spaces and special characters
OUStringBuffer
aTmpStr
(
rName
.
getStr
()
);
aTmpStr
.
remove
(
i
,
1
);
rName
=
aTmpStr
.
makeStringAndClear
();
rName
.
remove
(
i
,
1
);
nLen
--
;
continue
;
}
...
...
@@ -421,7 +409,7 @@ OUString GetEnglishSearchFontName( const OUString& rInName )
i
++
;
}
OUString
rNameStr
=
rName
.
makeStringAndClear
();
// translate normalized localized name to its normalized English ASCII name
if
(
bNeedTranslation
)
{
...
...
@@ -436,12 +424,12 @@ OUString GetEnglishSearchFontName( const OUString& rInName )
aDictionary
[
pList
->
mpLocalizedNames
]
=
pList
->
mpEnglishName
;
}
FontNameDictionary
::
const_iterator
it
=
aDictionary
.
find
(
rName
);
FontNameDictionary
::
const_iterator
it
=
aDictionary
.
find
(
rName
Str
);
if
(
it
!=
aDictionary
.
end
()
)
rName
=
OUString
::
createFromAscii
(
it
->
second
);
}
return
rName
;
return
rName
Str
;
}
OUString
GetNextFontToken
(
const
OUString
&
rTokenStr
,
sal_Int32
&
rIndex
)
...
...
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