Kaydet (Commit) dd8d5e57 authored tarafından Noel Grandin's avatar Noel Grandin

improve loplugin:stringconstant

to find more places we can elide the OUString() constructor at call
sites

Change-Id: Ie09f3c61f2c4b4959c97dc98ebcbaf7c51d5d713
Reviewed-on: https://gerrit.libreoffice.org/71514
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 22f2cf3c
......@@ -58,7 +58,19 @@ bool isLhsOfAssignment(FunctionDecl const * decl, unsigned parameter) {
|| (oo >= OO_PlusEqual && oo <= OO_GreaterGreaterEqual);
}
bool hasOverloads(FunctionDecl const * decl, unsigned arguments) {
bool typecheckIsOUStringParam(const clang::QualType t) {
return bool(loplugin::TypeCheck(t).NotSubstTemplateTypeParmType()
.LvalueReference().Const().NotSubstTemplateTypeParmType()
.Class("OUString").Namespace("rtl").GlobalNamespace());
}
bool typecheckIsOStringParam(const clang::QualType t) {
return bool(loplugin::TypeCheck(t).NotSubstTemplateTypeParmType()
.LvalueReference().Const().NotSubstTemplateTypeParmType()
.Class("OString").Namespace("rtl").GlobalNamespace());
}
bool hasOverloads(FunctionDecl const * decl, unsigned arguments, unsigned paramIndex) {
int n = 0;
auto ctx = decl->getDeclContext();
if (ctx->getDeclKind() == Decl::LinkageSpec) {
......@@ -67,17 +79,32 @@ bool hasOverloads(FunctionDecl const * decl, unsigned arguments) {
auto res = ctx->lookup(decl->getDeclName());
for (auto d = res.begin(); d != res.end(); ++d) {
FunctionDecl const * f = dyn_cast<FunctionDecl>(*d);
if (f != nullptr && f->getMinRequiredArguments() <= arguments
&& f->getNumParams() >= arguments)
{
auto consDecl = dyn_cast<CXXConstructorDecl>(f);
if (consDecl && consDecl->isCopyOrMoveConstructor()) {
continue;
}
++n;
if (n == 2) {
return true;
}
if (f == nullptr || f->getMinRequiredArguments() > arguments
|| f->getNumParams() < arguments) {
continue;
}
auto consDecl = dyn_cast<CXXConstructorDecl>(f);
if (consDecl && consDecl->isCopyOrMoveConstructor()) {
continue;
}
// Deleted stuff like in ORowSetValueDecorator in connectivity can cause
// trouble.
if (consDecl && consDecl->isDeleted()) {
return true;
}
if (paramIndex >= f->getNumParams()) {
continue;
}
auto t = f->getParamDecl(paramIndex)->getType();
// bool because 'const char *' converts to bool
if (!typecheckIsOUStringParam(t) && !typecheckIsOStringParam(t)
&& !loplugin::TypeCheck(t).Pointer().Const().Char()
&& !loplugin::TypeCheck(t).AnyBoolean()) {
continue;
}
++n;
if (n == 2) {
return true;
}
}
return false;
......@@ -269,29 +296,6 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
if (fdecl == nullptr) {
return true;
}
for (unsigned i = 0; i != fdecl->getNumParams(); ++i) {
auto t = fdecl->getParamDecl(i)->getType();
if (loplugin::TypeCheck(t).NotSubstTemplateTypeParmType()
.LvalueReference().Const().NotSubstTemplateTypeParmType()
.Class("OUString").Namespace("rtl").GlobalNamespace())
{
if (!(isLhsOfAssignment(fdecl, i)
|| hasOverloads(fdecl, expr->getNumArgs())))
{
handleOUStringCtor(expr, i, fdecl, true);
}
}
if (loplugin::TypeCheck(t).NotSubstTemplateTypeParmType()
.LvalueReference().Const().NotSubstTemplateTypeParmType()
.Class("OString").Namespace("rtl").GlobalNamespace())
{
if (!(isLhsOfAssignment(fdecl, i)
|| hasOverloads(fdecl, expr->getNumArgs())))
{
handleOStringCtor(expr, i, fdecl, true);
}
}
}
loplugin::DeclCheck dc(fdecl);
//TODO: u.compareToAscii("foo") -> u.???("foo")
//TODO: u.compareToIgnoreAsciiCaseAscii("foo") -> u.???("foo")
......@@ -773,6 +777,25 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
}
return true;
}
for (unsigned i = 0; i != fdecl->getNumParams(); ++i) {
auto t = fdecl->getParamDecl(i)->getType();
if (typecheckIsOUStringParam(t))
{
if (!(isLhsOfAssignment(fdecl, i)
|| hasOverloads(fdecl, expr->getNumArgs(), i)))
{
handleOUStringCtor(expr, i, fdecl, true);
}
}
if (typecheckIsOStringParam(t))
{
if (!(isLhsOfAssignment(fdecl, i)
|| hasOverloads(fdecl, expr->getNumArgs(), i)))
{
handleOStringCtor(expr, i, fdecl, true);
}
}
}
return true;
}
......@@ -1176,27 +1199,23 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) {
auto consDecl = expr->getConstructor();
for (unsigned i = 0; i != consDecl->getNumParams(); ++i) {
auto t = consDecl->getParamDecl(i)->getType();
if (loplugin::TypeCheck(t).NotSubstTemplateTypeParmType()
.LvalueReference().Const().NotSubstTemplateTypeParmType()
.Class("OUString").Namespace("rtl").GlobalNamespace())
if (typecheckIsOUStringParam(t))
{
auto argExpr = expr->getArg(i);
if (argExpr && i <= consDecl->getNumParams())
{
if (!hasOverloads(consDecl, expr->getNumArgs()))
if (!hasOverloads(consDecl, expr->getNumArgs(), i))
{
handleOUStringCtor(expr, argExpr, consDecl, true);
}
}
}
if (loplugin::TypeCheck(t).NotSubstTemplateTypeParmType()
.LvalueReference().Const().NotSubstTemplateTypeParmType()
.Class("OString").Namespace("rtl").GlobalNamespace())
if (typecheckIsOStringParam(t))
{
auto argExpr = expr->getArg(i);
if (argExpr && i <= consDecl->getNumParams())
{
if (!hasOverloads(consDecl, expr->getNumArgs()))
if (!hasOverloads(consDecl, expr->getNumArgs(), i))
{
handleOStringCtor(expr, argExpr, consDecl, true);
}
......
......@@ -17,6 +17,7 @@
extern void foo(OUString const &);
struct Foo {
Foo(int, const OUString &) {}
Foo(OUString const &, int) {}
Foo(OUString const &) {}
void foo(OUString const &) const {}
......@@ -28,6 +29,11 @@ struct Foo2 {
void foo(OString const &) const {}
};
struct NegativeFoo {
NegativeFoo(const OString&, const OString& ) {}
NegativeFoo(const OString&, const OUString& ) {}
};
int main() {
char const s1[] = "foo";
char const * const s2 = "foo";
......@@ -67,9 +73,15 @@ int main() {
(void)aFoo;
Foo aFoo2(OUString("xxx")); // expected-error {{in call of 'Foo::Foo', replace 'OUString' constructed from a string literal directly with the string literal}}
aFoo2.foo(OUString("xxx")); // expected-error {{in call of 'Foo::foo', replace 'OUString' constructed from a string literal directly with the string literal}}
Foo aFoo3(1, OUString("xxx")); // expected-error {{in call of 'Foo::Foo', replace 'OUString' constructed from a string literal directly with the string literal}}
(void)aFoo3;
Foo2 aFoo4(OString("xxx")); // expected-error {{in call of 'Foo2::Foo2', replace 'OUString' constructed from a string literal directly with the string literal}}
aFoo4.foo(OString("xxx")); // expected-error {{in call of 'Foo2::foo', replace 'OUString' constructed from a string literal directly with the string literal}}
Foo2 aFoo3(OString("xxx")); // expected-error {{in call of 'Foo2::Foo2', replace 'OUString' constructed from a string literal directly with the string literal}}
aFoo3.foo(OString("xxx")); // expected-error {{in call of 'Foo2::foo', replace 'OUString' constructed from a string literal directly with the string literal}}
// no warning expected
NegativeFoo aNegativeFoo(OString("xxx"), OUString("1"));
(void)aNegativeFoo;
(void) OUString("xxx", 3, RTL_TEXTENCODING_ASCII_US); // expected-error {{simplify construction of 'OUString' with string constant argument [loplugin:stringconstant]}}
(void) OUString("xxx", 3, RTL_TEXTENCODING_ISO_8859_1); // expected-error {{suspicious 'rtl::OUString' constructor with text encoding 12 but plain ASCII content; use 'RTL_TEXTENCODING_ASCII_US' instead [loplugin:stringconstant]}}
......
......@@ -22,8 +22,7 @@
#include <vcl/keycodes.hxx>
SvxSwAutoFormatFlags::SvxSwAutoFormatFlags()
: aBulletFont( OUString("StarSymbol"),
Size( 0, 14 ) )
: aBulletFont( "StarSymbol", Size( 0, 14 ) )
{
bAutoCorrect =
bCapitalStartSentence =
......
......@@ -219,7 +219,7 @@ sal_uInt32 ImplEESdrWriter::ImplWriteShape( ImplEESdrObject& rObj,
}
break;
}
rObj.SetAngle( rObj.ImplGetInt32PropertyValue( OUString( "RotateAngle" ) ));
rObj.SetAngle( rObj.ImplGetInt32PropertyValue( "RotateAngle" ));
if( ( rObj.ImplGetPropertyValue( "IsFontwork" ) &&
::cppu::any2bool( rObj.GetUsrAny() ) ) ||
......@@ -722,7 +722,7 @@ void ImplEESdrWriter::ImplWriteAdditionalText( ImplEESdrObject& rObj )
if ( !mpPicStrm )
mpPicStrm = mpEscherEx->QueryPictureStream();
EscherPropertyContainer aPropOpt( mpEscherEx->GetGraphicProvider(), mpPicStrm, aRect100thmm );
rObj.SetAngle( rObj.ImplGetInt32PropertyValue( OUString( "RotateAngle" )));
rObj.SetAngle( rObj.ImplGetInt32PropertyValue( "RotateAngle" ));
sal_Int32 nAngle = rObj.GetAngle();
if( rObj.GetType() == "drawing.Line" )
{
......
......@@ -1091,7 +1091,7 @@ void PDFExport::ImplExportPage( vcl::PDFWriter& rWriter, vcl::PDFExtOutDevData&
void PDFExport::ImplWriteWatermark( vcl::PDFWriter& rWriter, const Size& rPageSize )
{
vcl::Font aFont( OUString( "Helvetica" ), Size( 0, 3*rPageSize.Height()/4 ) );
vcl::Font aFont( "Helvetica", Size( 0, 3*rPageSize.Height()/4 ) );
aFont.SetItalic( ITALIC_NONE );
aFont.SetWidthType( WIDTH_NORMAL );
aFont.SetWeight( WEIGHT_NORMAL );
......@@ -1158,7 +1158,7 @@ void PDFExport::ImplWriteWatermark( vcl::PDFWriter& rWriter, const Size& rPageSi
void PDFExport::ImplWriteTiledWatermark( vcl::PDFWriter& rWriter, const Size& rPageSize )
{
vcl::Font aFont( OUString( "Liberation Sans" ), Size( 0, 40 ) );
vcl::Font aFont( "Liberation Sans", Size( 0, 40 ) );
aFont.SetItalic( ITALIC_NONE );
aFont.SetWidthType( WIDTH_NORMAL );
aFont.SetWeight( WEIGHT_NORMAL );
......
......@@ -60,7 +60,7 @@ using namespace ::com::sun::star;
#define PROPERTYNAME_CONTEXT ADDONSMENUITEM_STRING_CONTEXT
#define PROPERTYNAME_SUBMENU ADDONSMENUITEM_STRING_SUBMENU
#define IMAGES_NODENAME OUString("UserDefinedImages" )
#define IMAGES_NODENAME "UserDefinedImages"
// The following order is mandatory. Please add properties at the end!
#define INDEX_URL 0
......
......@@ -317,9 +317,7 @@ template< class C >
SAL_DEPRECATED("use uno_Mapping")
inline bool mapToCpp( Reference< C > * ppRet, uno_Interface * pUnoI )
{
Mapping aMapping(
::rtl::OUString( UNO_LB_UNO ),
::rtl::OUString( CPPU_CURRENT_LANGUAGE_BINDING_NAME ) );
Mapping aMapping( UNO_LB_UNO, CPPU_CURRENT_LANGUAGE_BINDING_NAME );
OSL_ASSERT( aMapping.is() );
aMapping.mapInterface(
reinterpret_cast<void **>(ppRet), pUnoI, ::cppu::getTypeFavourUnsigned( ppRet ) );
......@@ -341,9 +339,7 @@ template< class C >
SAL_DEPRECATED("use uno_Mapping")
inline bool mapToUno( uno_Interface ** ppRet, const Reference< C > & x )
{
Mapping aMapping(
::rtl::OUString( CPPU_CURRENT_LANGUAGE_BINDING_NAME ),
::rtl::OUString( UNO_LB_UNO ) );
Mapping aMapping( CPPU_CURRENT_LANGUAGE_BINDING_NAME, UNO_LB_UNO );
OSL_ASSERT( aMapping.is() );
aMapping.mapInterface(
reinterpret_cast<void **>(ppRet), x.get(), ::cppu::getTypeFavourUnsigned( &x ) );
......
......@@ -84,11 +84,11 @@ OFormatProperties::OFormatProperties()
SvtLinguConfig aLinguConfig;
using namespace ::com::sun::star::i18n::ScriptType;
aLinguConfig.GetProperty(OUString("DefaultLocale")) >>= aCharLocale;
aLinguConfig.GetProperty("DefaultLocale") >>= aCharLocale;
LanguageType eCurLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aCharLocale, false), LATIN);
aLinguConfig.GetProperty(OUString("DefaultLocale_CJK")) >>= aCharLocaleAsian;
aLinguConfig.GetProperty("DefaultLocale_CJK") >>= aCharLocaleAsian;
LanguageType eCurLangCJK = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aCharLocaleAsian, false), ASIAN);
aLinguConfig.GetProperty(OUString("DefaultLocale_CTL")) >>= aCharLocaleComplex;
aLinguConfig.GetProperty("DefaultLocale_CTL") >>= aCharLocaleComplex;
LanguageType eCurLangCTL = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aCharLocaleComplex, false), COMPLEX);
vcl::Font aLatin,aCJK,aCTL;
......
......@@ -200,9 +200,9 @@ static void lcl_setModelReadOnly(const uno::Reference< embed::XStorage >& _xStor
}
static void lcl_stripLoadArguments( utl::MediaDescriptor& _rDescriptor, uno::Sequence< beans::PropertyValue >& _rArgs )
{
_rDescriptor.erase( OUString( "StatusIndicator" ) );
_rDescriptor.erase( OUString( "InteractionHandler" ) );
_rDescriptor.erase( OUString( "Model" ) );
_rDescriptor.erase( "StatusIndicator" );
_rDescriptor.erase( "InteractionHandler" );
_rDescriptor.erase( "Model" );
_rDescriptor >> _rArgs;
}
......
......@@ -88,7 +88,7 @@ IMPL_STATIC_LINK(
pNewObj = new OOle2Obj(aParams.rSdrModel, SERVICE_REPORTDEFINITION, OBJ_DLG_SUBREPORT);
break;
case OBJ_OLE2:
pNewObj = new OOle2Obj(aParams.rSdrModel, OUString("com.sun.star.chart2.ChartDocument"),OBJ_OLE2);
pNewObj = new OOle2Obj(aParams.rSdrModel, "com.sun.star.chart2.ChartDocument", OBJ_OLE2);
break;
default:
OSL_FAIL("Unknown object id");
......
......@@ -40,7 +40,7 @@ private:
CPPUNIT_TEST_SUITE_REGISTRATION(test::oustringbuffer::ToString);
void test::oustringbuffer::ToString::testToString() {
OUStringBuffer sb(OUString("test string"));
OUStringBuffer sb("test string");
OUString str = sb.toString();
CPPUNIT_ASSERT_EQUAL( OUString("test string"), str );
// returned OUString must be independent from sb
......
......@@ -3200,9 +3200,9 @@ void ScInterpreter::ScInfo()
OUString aStr = GetString().getString();
ScCellKeywordTranslator::transKeyword(aStr, ScGlobal::GetLocale(), ocInfo);
if( aStr == "SYSTEM" )
PushString( OUString( SC_INFO_OSVERSION ) );
PushString( SC_INFO_OSVERSION );
else if( aStr == "OSVERSION" )
PushString( OUString( "Windows (32-bit) NT 5.01" ) );
PushString( "Windows (32-bit) NT 5.01" );
else if( aStr == "RELEASE" )
PushString( ::utl::Bootstrap::getBuildIdData( OUString() ) );
else if( aStr == "NUMFILE" )
......
......@@ -195,7 +195,7 @@ ExcelToSc::~ExcelToSc()
std::unique_ptr<ScTokenArray> ExcelToSc::GetDummy()
{
aPool.Store( OUString("Dummy()") );
aPool.Store( "Dummy()" );
aPool >> aStack;
return aPool.GetTokenArray( aStack.Get());
}
......@@ -221,7 +221,7 @@ ConvErr ExcelToSc::Convert( std::unique_ptr<ScTokenArray>& pResult, XclImpStream
if( nFormulaLen == 0 )
{
aPool.Store( OUString("-/-") );
aPool.Store( "-/-" );
aPool >> aStack;
pResult = aPool.GetTokenArray( aStack.Get());
return ConvErr::OK;
......
......@@ -149,7 +149,7 @@ ConvErr ExcelToSc8::Convert( std::unique_ptr<ScTokenArray>& rpTokArray, XclImpSt
if( nFormulaLen == 0 )
{
aPool.Store( OUString( "-/-" ) );
aPool.Store( "-/-" );
aPool >> aStack;
rpTokArray = aPool.GetTokenArray( aStack.Get());
return ConvErr::OK;
......@@ -1296,7 +1296,7 @@ void ExcelToSc8::ConvertExternName( std::unique_ptr<ScTokenArray>& rpArray, XclI
if (nFormulaLen == 0)
{
aPool.Store(OUString("-/-"));
aPool.Store("-/-");
aPool >> aStack;
rpArray = aPool.GetTokenArray( aStack.Get());
return;
......
......@@ -2280,7 +2280,7 @@ void ScModule::SetAutoSpellProperty( bool bSet )
// loading the linguistic component
SvtLinguConfig aConfig;
aConfig.SetProperty( OUString( LINGUPROP_AUTOSPELL ), uno::Any(bSet) );
aConfig.SetProperty( LINGUPROP_AUTOSPELL, uno::Any(bSet) );
}
bool ScModule::HasThesaurusLanguage( LanguageType nLang )
......
......@@ -1173,7 +1173,7 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet,
vcl::Font SdStyleSheetPool::GetBulletFont()
{
vcl::Font aBulletFont( OUString( "StarSymbol" ), Size(0, 1000) );
vcl::Font aBulletFont( "StarSymbol", Size(0, 1000) );
aBulletFont.SetCharSet(RTL_TEXTENCODING_UNICODE);
aBulletFont.SetWeight(WEIGHT_NORMAL);
aBulletFont.SetUnderline(LINESTYLE_NONE);
......
......@@ -633,7 +633,7 @@ void PresenterNotesView::ChangeFontSize (const sal_Int32 nSizeChange)
if (pConfiguration == nullptr || !pConfiguration->IsValid())
return;
pConfiguration->GoToChild(OUString("Font"));
pConfiguration->GoToChild("Font");
pConfiguration->SetProperty("Size", Any(static_cast<sal_Int32>(nNewSize+0.5)));
pConfiguration->CommitChanges();
}
......
......@@ -249,7 +249,7 @@ void PresenterScrollBar::SetCanvas (const Reference<css::rendering::XCanvas>& rx
try
{
mpBitmaps.reset(new PresenterBitmapContainer(
OUString("PresenterScreenSettings/ScrollBar/Bitmaps"),
"PresenterScreenSettings/ScrollBar/Bitmaps",
std::shared_ptr<PresenterBitmapContainer>(),
mxComponentContext,
mxCanvas));
......
......@@ -97,7 +97,7 @@ PresenterSlidePreview::PresenterSlidePreview (
rxContext),
UNO_QUERY);
mpBitmaps.reset(new PresenterBitmapContainer(
OUString("PresenterScreenSettings/ScrollBar/Bitmaps"),
"PresenterScreenSettings/ScrollBar/Bitmaps",
std::shared_ptr<PresenterBitmapContainer>(),
rxContext,
mxCanvas));
......
......@@ -498,7 +498,7 @@ void PresenterWindowManager::StoreViewMode (const ViewMode eViewMode)
mxComponentContext,
"/org.openoffice.Office.PresenterScreen/",
PresenterConfigurationAccess::READ_WRITE);
aConfiguration.GoToChild(OUString("Presenter"));
aConfiguration.GoToChild("Presenter");
Any aValue;
switch (eViewMode)
{
......
......@@ -1046,7 +1046,7 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c
const SfxUInt32Item* pUndoConflict = dynamic_cast< const SfxUInt32Item * >( pState );
if ( pUndoConflict && pUndoConflict->GetValue() > 0 )
{
aBuffer.append(OUString("disabled"));
aBuffer.append("disabled");
}
else
{
......@@ -1148,7 +1148,7 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c
}
else
{
aBuffer.append(OUString("disabled"));
aBuffer.append("disabled");
}
}
else if (aEvent.FeatureURL.Path == "Position")
......
......@@ -318,9 +318,7 @@ const Mapping & IdlReflectionServiceImpl::getCpp2Uno()
MutexGuard aGuard( getMutexAccess() );
if (! _aCpp2Uno.is())
{
_aCpp2Uno = Mapping(
OUString( CPPU_CURRENT_LANGUAGE_BINDING_NAME ),
OUString( UNO_LB_UNO ) );
_aCpp2Uno = Mapping( CPPU_CURRENT_LANGUAGE_BINDING_NAME, UNO_LB_UNO );
OSL_ENSURE( _aCpp2Uno.is(), "### cannot get c++ to uno mapping!" );
if (! _aCpp2Uno.is())
{
......@@ -340,9 +338,7 @@ const Mapping & IdlReflectionServiceImpl::getUno2Cpp()
MutexGuard aGuard( getMutexAccess() );
if (! _aUno2Cpp.is())
{
_aUno2Cpp = Mapping(
OUString( UNO_LB_UNO ),
OUString( CPPU_CURRENT_LANGUAGE_BINDING_NAME ) );
_aUno2Cpp = Mapping( UNO_LB_UNO, CPPU_CURRENT_LANGUAGE_BINDING_NAME );
OSL_ENSURE( _aUno2Cpp.is(), "### cannot get uno to c++ mapping!" );
if (! _aUno2Cpp.is())
{
......
......@@ -324,7 +324,7 @@ ChineseDictionaryDialog::ChineseDictionaryDialog(weld::Window* pParent)
SvtLinguConfig aLngCfg;
bool bValue;
Any aAny( aLngCfg.GetProperty( OUString( UPN_IS_REVERSE_MAPPING ) ) );
Any aAny( aLngCfg.GetProperty( UPN_IS_REVERSE_MAPPING ) );
if( aAny >>= bValue )
m_xCB_Reverse->set_active( bValue );
......@@ -637,7 +637,7 @@ short ChineseDictionaryDialog::run()
{
//save settings to configuration
SvtLinguConfig aLngCfg;
aLngCfg.SetProperty( OUString( UPN_IS_REVERSE_MAPPING ), uno::Any(m_xCB_Reverse->get_active()) );
aLngCfg.SetProperty( UPN_IS_REVERSE_MAPPING, uno::Any(m_xCB_Reverse->get_active()) );
m_xCT_DictionaryToSimplified->save();
m_xCT_DictionaryToTraditional->save();
......
......@@ -40,14 +40,14 @@ ChineseTranslationDialog::ChineseTranslationDialog(weld::Window* pParent)
{
SvtLinguConfig aLngCfg;
bool bValue = false;
Any aAny( aLngCfg.GetProperty( OUString( UPN_IS_DIRECTION_TO_SIMPLIFIED ) ) );
Any aAny( aLngCfg.GetProperty( UPN_IS_DIRECTION_TO_SIMPLIFIED ) );
aAny >>= bValue;
if( bValue )
m_xRB_To_Simplified->set_active(true);
else
m_xRB_To_Traditional->set_active(true);
aAny = aLngCfg.GetProperty( OUString( UPN_IS_TRANSLATE_COMMON_TERMS ) );
aAny = aLngCfg.GetProperty( UPN_IS_TRANSLATE_COMMON_TERMS );
if( aAny >>= bValue )
m_xCB_Translate_Commonterms->set_active( bValue );
......@@ -72,9 +72,9 @@ IMPL_LINK_NOARG(ChineseTranslationDialog, OkHdl, weld::Button&, void)
SvtLinguConfig aLngCfg;
Any aAny;
aAny <<= m_xRB_To_Simplified->get_active();
aLngCfg.SetProperty( OUString( UPN_IS_DIRECTION_TO_SIMPLIFIED ), aAny );
aLngCfg.SetProperty( UPN_IS_DIRECTION_TO_SIMPLIFIED, aAny );
aAny <<= m_xCB_Translate_Commonterms->get_active();
aLngCfg.SetProperty( OUString( UPN_IS_TRANSLATE_COMMON_TERMS ), aAny );
aLngCfg.SetProperty( UPN_IS_TRANSLATE_COMMON_TERMS, aAny );
m_xDialog->response(RET_OK);
}
......
......@@ -2248,7 +2248,7 @@ void SwUiWriterTest::testTdf69282()
verticalSpace.SetLower(14);
rSourceMasterFormat.SetFormatAttr(verticalSpace);
//Changing the style and copying it to target
source->ChgPageDesc(OUString("SourceStyle"), *sPageDesc);
source->ChgPageDesc("SourceStyle", *sPageDesc);
target->CopyPageDesc(*sPageDesc, *tPageDesc);
//Checking the set values on all Formats in target
SwFrameFormat& rTargetMasterFormat = tPageDesc->GetMaster();
......@@ -2309,7 +2309,7 @@ void SwUiWriterTest::testTdf69282WithMirror()
verticalSpace.SetLower(14);
rSourceMasterFormat.SetFormatAttr(verticalSpace);
//Changing the style and copying it to target
source->ChgPageDesc(OUString("SourceStyle"), *sPageDesc);
source->ChgPageDesc("SourceStyle", *sPageDesc);
target->CopyPageDesc(*sPageDesc, *tPageDesc);
//Checking the set values on all Formats in target
SwFrameFormat& rTargetMasterFormat = tPageDesc->GetMaster();
......
......@@ -124,8 +124,7 @@ DocumentTimerManager::IdleJob DocumentTimerManager::GetNextIdleJob() const
{
bool bIsOnlineSpell = pShell->GetViewOptions()->IsOnlineSpell();
bool bIsAutoGrammar = false;
SvtLinguConfig().GetProperty( OUString(
UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar;
SvtLinguConfig().GetProperty( UPN_IS_GRAMMAR_AUTO ) >>= bIsAutoGrammar;
if( bIsOnlineSpell && bIsAutoGrammar && m_rDoc.StartGrammarChecking( true ) )
return IdleJob::Grammar;
......
......@@ -68,7 +68,7 @@ ErrCode SwXMLTextBlocks::GetDoc( sal_uInt16 nIdx )
try
{
xRoot = xBlkRoot->openStorageElement( aFolderName, embed::ElementModes::READ );
xMedium = new SfxMedium( xRoot, GetBaseURL(), OUString( "writer8" ) );
xMedium = new SfxMedium( xRoot, GetBaseURL(), "writer8" );
SwReader aReader( *xMedium, aFolderName, m_xDoc.get() );
ReadXML->SetBlockMode( true );
aReader.Read( *ReadXML );
......
......@@ -259,7 +259,7 @@ void RtfExport::WriteRevTab()
return;
// RTF always seems to use Unknown as the default first entry
GetRedline(OUString("Unknown"));
GetRedline("Unknown");
for (SwRangeRedline* pRedl : m_pDoc->getIDocumentRedlineAccess().GetRedlineTable())
{
......
......@@ -151,17 +151,17 @@ std::unique_ptr<SfxItemSet> SwModule::CreateItemSet( sal_uInt16 nId )
using namespace ::com::sun::star::i18n::ScriptType;
Any aLang = aLinguCfg.GetProperty(OUString("DefaultLocale"));
Any aLang = aLinguCfg.GetProperty("DefaultLocale");
aLang >>= aLocale;
nLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aLocale, false), LATIN);
pRet->Put(SvxLanguageItem(nLang, SID_ATTR_LANGUAGE));
aLang = aLinguCfg.GetProperty(OUString("DefaultLocale_CJK"));
aLang = aLinguCfg.GetProperty("DefaultLocale_CJK");
aLang >>= aLocale;
nLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aLocale, false), ASIAN);
pRet->Put(SvxLanguageItem(nLang, SID_ATTR_CHAR_CJK_LANGUAGE));
aLang = aLinguCfg.GetProperty(OUString("DefaultLocale_CTL"));
aLang = aLinguCfg.GetProperty("DefaultLocale_CTL");
aLang >>= aLocale;
nLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aLocale, false), COMPLEX);
pRet->Put(SvxLanguageItem(nLang, SID_ATTR_CHAR_CTL_LANGUAGE));
......
......@@ -107,14 +107,14 @@ public:
{
Config aConfig(maConfigFile);
aConfig.SetGroup("TestGroup");
CPPUNIT_ASSERT_EQUAL(OString("testvalue"), aConfig.ReadKey(OString("testkey")));
CPPUNIT_ASSERT_EQUAL(OString(), aConfig.ReadKey(OString("nonexistenttestkey")));
CPPUNIT_ASSERT_EQUAL(OString("testvalue"), aConfig.ReadKey("testkey"));
CPPUNIT_ASSERT_EQUAL(OString(), aConfig.ReadKey("nonexistenttestkey"));
CPPUNIT_ASSERT_EQUAL(OString("notexists"),
aConfig.ReadKey("nonexistenttestkey", "notexists"));
aConfig.SetGroup("TestGroup2");
CPPUNIT_ASSERT_EQUAL(OString("testvalue"), aConfig.ReadKey(OString("testkey2")));
CPPUNIT_ASSERT_EQUAL(OString(), aConfig.ReadKey(OString("nonexistenttestkey")));
CPPUNIT_ASSERT_EQUAL(OString("testvalue"), aConfig.ReadKey("testkey2"));
CPPUNIT_ASSERT_EQUAL(OString(), aConfig.ReadKey("nonexistenttestkey"));
CPPUNIT_ASSERT_EQUAL(OString("notexists"),
aConfig.ReadKey("nonexistenttestkey", "notexists"));
}
......@@ -138,14 +138,14 @@ public:
sal_uInt16 nExpected = 2;
sal_uInt16 nActual = aConfig.GetKeyCount();
CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
CPPUNIT_ASSERT_EQUAL(OString("testvalue"), aConfig.ReadKey(OString("testkey_new")));
CPPUNIT_ASSERT_EQUAL(OString("testvalue"), aConfig.ReadKey("testkey_new"));
aConfig.DeleteKey("testkey_new");
nExpected = 1;
nActual = aConfig.GetKeyCount();
CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
CPPUNIT_ASSERT_EQUAL(OString(), aConfig.ReadKey(OString("testkey_new")));
CPPUNIT_ASSERT_EQUAL(OString(), aConfig.ReadKey("testkey_new"));
aConfig.SetGroup("TestGroup2");
aConfig.WriteKey("testkey_new", "testvalue");
......@@ -153,14 +153,14 @@ public:
nActual = aConfig.GetKeyCount();
nExpected = 2;
CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
CPPUNIT_ASSERT_EQUAL(OString("testvalue"), aConfig.ReadKey(OString("testkey_new")));
CPPUNIT_ASSERT_EQUAL(OString("testvalue"), aConfig.ReadKey("testkey_new"));
aConfig.DeleteKey("testkey_new");
nActual = aConfig.GetKeyCount();
nExpected = 1;
CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
CPPUNIT_ASSERT_EQUAL(OString(), aConfig.ReadKey(OString("testkey_new")));
CPPUNIT_ASSERT_EQUAL(OString(), aConfig.ReadKey("testkey_new"));
aConfig.SetGroup("TestGroup3");
aConfig.WriteKey("testkey_new_group3", "testvalue");
......@@ -168,7 +168,7 @@ public:
nActual = aConfig.GetKeyCount();
nExpected = 1;
CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
CPPUNIT_ASSERT_EQUAL(OString("testvalue"), aConfig.ReadKey(OString("testkey_new_group3")));
CPPUNIT_ASSERT_EQUAL(OString("testvalue"), aConfig.ReadKey("testkey_new_group3"));
nExpected = 3;
CPPUNIT_ASSERT_EQUAL(nExpected, aConfig.GetGroupCount());
......
......@@ -2302,8 +2302,7 @@ bool INetURLObject::setPassword(OUString const & rThePassword,
}
else if (m_aHost.isPresent())
{
m_aAbsURIRef.insert(m_aHost.getBegin(),
OUString( ":@" ));
m_aAbsURIRef.insert(m_aHost.getBegin(), ":@" );
m_aUser.set(m_aAbsURIRef, OUString(), m_aHost.getBegin());
nDelta
= m_aAuth.set(m_aAbsURIRef, aNewAuth, m_aHost.getBegin() + 1) + 2;
......
......@@ -94,7 +94,7 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
pJobSetup->SetPaperBin( 0xffff );
if( rData.m_pParser )
pKey = rData.m_pParser->getKey( OUString( "InputSlot" ) );
pKey = rData.m_pParser->getKey( "InputSlot" );
if( pKey )
pValue = rData.m_aContext.getValue( pKey );
if( pKey && pValue )
......@@ -116,7 +116,7 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
pJobSetup->