From 05050cdb23de586870bf479a9df5ced06828d498 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 6 Nov 2014 07:45:00 +0200 Subject: use the new OUString::fromUtf8 method Change-Id: I771004b7ccab3344a67e827e45bc34c22ffa5f77 --- idlc/source/astconstant.cxx | 4 ++-- idlc/source/astdump.cxx | 40 +++++++++++++++++----------------------- idlc/source/astenum.cxx | 4 ++-- idlc/source/astinterface.cxx | 12 ++++-------- idlc/source/astoperation.cxx | 15 +++++---------- idlc/source/aststruct.cxx | 15 ++++++--------- idlc/source/idlc.cxx | 2 +- idlc/source/idlccompile.cxx | 13 ++++++------- idlc/source/idlcproduce.cxx | 6 +++--- idlc/source/options.cxx | 2 +- idlc/source/parser.y | 10 +++------- 11 files changed, 50 insertions(+), 73 deletions(-) (limited to 'idlc') diff --git a/idlc/source/astconstant.cxx b/idlc/source/astconstant.cxx index b37ff90e6b73..7b9797981e61 100644 --- a/idlc/source/astconstant.cxx +++ b/idlc/source/astconstant.cxx @@ -109,13 +109,13 @@ bool AstConstant::dumpBlob( OUString type; if ( getNodeType() != NT_enum_val ) { - type = OStringToOUString(exprTypeToString(getConstValueType()), RTL_TEXTENCODING_UTF8); + type = OUString::fromUtf8(exprTypeToString(getConstValueType())); } rBlob.setFieldData( index, getDocumentation(), OUString(), RT_ACCESS_CONST | (published ? RT_ACCESS_PUBLISHED : 0), - OStringToOUString(name, RTL_TEXTENCODING_UTF8), type, aConst); + OUString::fromUtf8(name), type, aConst); return true; } diff --git a/idlc/source/astdump.cxx b/idlc/source/astdump.cxx index c9a2c473f3fa..01ca504aaefd 100644 --- a/idlc/source/astdump.cxx +++ b/idlc/source/astdump.cxx @@ -41,7 +41,7 @@ bool AstModule::dump(RegistryKey& rKey) localKey = rKey; }else { - if (rKey.createKey( OStringToOUString(getFullName(), RTL_TEXTENCODING_UTF8 ), localKey)) + if (rKey.createKey( OUString::fromUtf8(getFullName()), localKey)) { fprintf(stderr, "%s: warning, could not create key '%s' in '%s'\n", idlc()->getOptions()->getProgramName().getStr(), @@ -62,7 +62,7 @@ bool AstModule::dump(RegistryKey& rKey) m_bPublished ? TYPEREG_VERSION_1 : TYPEREG_VERSION_0, getDocumentation(), emptyStr, typeClass, m_bPublished, - OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), 0, + OUString::fromUtf8(getRelativName()), 0, nConst, 0, 0); DeclList::const_iterator iter = getIteratorBegin(); @@ -102,7 +102,7 @@ bool AstModule::dump(RegistryKey& rKey) typereg::Writer aBlob( m_bPublished ? TYPEREG_VERSION_1 : TYPEREG_VERSION_0, getDocumentation(), emptyStr, typeClass, m_bPublished, - OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), 0, 0, 0, + OUString::fromUtf8(getRelativName()), 0, 0, 0, 0); sal_uInt32 aBlobSize; @@ -131,7 +131,7 @@ bool AstTypeDef::dump(RegistryKey& rKey) { OUString emptyStr; RegistryKey localKey; - if (rKey.createKey( OStringToOUString(getFullName(), RTL_TEXTENCODING_UTF8 ), localKey)) + if (rKey.createKey( OUString::fromUtf8(getFullName()), localKey)) { fprintf(stderr, "%s: warning, could not create key '%s' in '%s'\n", idlc()->getOptions()->getProgramName().getStr(), @@ -142,11 +142,10 @@ bool AstTypeDef::dump(RegistryKey& rKey) typereg::Writer aBlob( m_bPublished ? TYPEREG_VERSION_1 : TYPEREG_VERSION_0, getDocumentation(), emptyStr, RT_TYPE_TYPEDEF, m_bPublished, - OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), 1, 0, 0, 0); + OUString::fromUtf8(getRelativName()), 1, 0, 0, 0); aBlob.setSuperTypeName( 0, - OStringToOUString( - getBaseType()->getRelativName(), RTL_TEXTENCODING_UTF8)); + OUString::fromUtf8(getBaseType()->getRelativName())); sal_uInt32 aBlobSize; void const * pBlob = aBlob.getBlob(&aBlobSize); @@ -217,7 +216,7 @@ bool AstService::dump(RegistryKey& rKey) } RegistryKey localKey; if (rKey.createKey( - OStringToOUString(getFullName(), RTL_TEXTENCODING_UTF8), + OUString::fromUtf8(getFullName()), localKey)) { fprintf( stderr, "%s: warning, could not create key '%s' in '%s'\n", @@ -231,12 +230,12 @@ bool AstService::dump(RegistryKey& rKey) version, getDocumentation(), emptyStr, getNodeType() == NT_singleton ? RT_TYPE_SINGLETON : RT_TYPE_SERVICE, m_bPublished, - OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), + OUString::fromUtf8(getRelativName()), superName.isEmpty() ? 0 : 1, properties, constructors, references); if (!superName.isEmpty()) { writer.setSuperTypeName( - 0, OStringToOUString(superName, RTL_TEXTENCODING_UTF8)); + 0, OUString::fromUtf8(superName)); } sal_uInt16 constructorIndex = 0; sal_uInt16 propertyIndex = 0; @@ -258,8 +257,7 @@ bool AstService::dump(RegistryKey& rKey) writer.setReferenceData( referenceIndex++, decl->getDocumentation(), RT_REF_SUPPORTS, (decl->isOptional() ? RT_ACCESS_OPTIONAL : RT_ACCESS_INVALID), - OStringToOUString( decl->getRealInterface()->getRelativName(), - RTL_TEXTENCODING_UTF8)); + OUString::fromUtf8( decl->getRealInterface()->getRelativName() )); break; } @@ -269,8 +267,7 @@ bool AstService::dump(RegistryKey& rKey) AstServiceMember * decl = static_cast(*i); writer.setReferenceData(referenceIndex++, decl->getDocumentation(), RT_REF_EXPORTS, (decl->isOptional() ? RT_ACCESS_OPTIONAL : RT_ACCESS_INVALID), - OStringToOUString(decl->getRealService()->getRelativName(), - RTL_TEXTENCODING_UTF8)); + OUString::fromUtf8(decl->getRealService()->getRelativName())); } break; @@ -279,8 +276,7 @@ bool AstService::dump(RegistryKey& rKey) AstObserves * decl = static_cast(*i); writer.setReferenceData(referenceIndex++, decl->getDocumentation(), RT_REF_OBSERVES, RT_ACCESS_INVALID, - OStringToOUString( decl->getRealInterface()->getRelativName(), - RTL_TEXTENCODING_UTF8)); + OUString::fromUtf8( decl->getRealInterface()->getRelativName())); break; } @@ -289,8 +285,7 @@ bool AstService::dump(RegistryKey& rKey) AstNeeds * decl = static_cast(*i); writer.setReferenceData( referenceIndex++, decl->getDocumentation(), RT_REF_NEEDS, RT_ACCESS_INVALID, - OStringToOUString( decl->getRealService()->getRelativName(), - RTL_TEXTENCODING_UTF8)); + OUString::fromUtf8( decl->getRealService()->getRelativName())); break; } @@ -367,10 +362,10 @@ bool AstAttribute::dumpBlob( accessMode |= RT_ACCESS_REMOVABLE; } - OUString name(OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8)); + OUString name(OUString::fromUtf8(getLocalName())); rBlob.setFieldData( index, getDocumentation(), OUString(), accessMode, name, - OStringToOUString(getType()->getRelativName(), RTL_TEXTENCODING_UTF8), + OUString::fromUtf8(getType()->getRelativName()), RTConstValue()); dumpExceptions( rBlob, m_getDocumentation, m_getExceptions, RT_MODE_ATTRIBUTE_GET, @@ -393,7 +388,7 @@ void AstAttribute::dumpExceptions( // AstInterface::dump: writer.setMethodData( idx, documentation, flags, - OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8), + OUString::fromUtf8(getLocalName()), OUString("void"), 0, static_cast< sal_uInt16 >(exceptions.size())); sal_uInt16 exceptionIndex = 0; @@ -402,8 +397,7 @@ void AstAttribute::dumpExceptions( { writer.setMethodExceptionTypeName( idx, exceptionIndex++, - OStringToOUString( - (*i)->getRelativName(), RTL_TEXTENCODING_UTF8)); + OUString::fromUtf8((*i)->getRelativName())); } } } diff --git a/idlc/source/astenum.cxx b/idlc/source/astenum.cxx index 1f330b18f780..7332f1c76d32 100644 --- a/idlc/source/astenum.cxx +++ b/idlc/source/astenum.cxx @@ -60,7 +60,7 @@ AstConstant* AstEnum::checkValue(AstExpression* pExpr) bool AstEnum::dump(RegistryKey& rKey) { RegistryKey localKey; - if (rKey.createKey( OStringToOUString(getFullName(), RTL_TEXTENCODING_UTF8 ), localKey)) + if (rKey.createKey( OUString::fromUtf8(getFullName()), localKey)) { fprintf(stderr, "%s: warning, could not create key '%s' in '%s'\n", idlc()->getOptions()->getProgramName().getStr(), @@ -75,7 +75,7 @@ bool AstEnum::dump(RegistryKey& rKey) typereg::Writer aBlob( m_bPublished ? TYPEREG_VERSION_1 : TYPEREG_VERSION_0, getDocumentation(), emptyStr, RT_TYPE_ENUM, m_bPublished, - OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), 0, + OUString::fromUtf8(getRelativName()), 0, nConst, 0, 0); DeclList::const_iterator iter = getIteratorBegin(); diff --git a/idlc/source/astinterface.cxx b/idlc/source/astinterface.cxx index 8bd8fb7cbfd9..4f5affb721af 100644 --- a/idlc/source/astinterface.cxx +++ b/idlc/source/astinterface.cxx @@ -103,7 +103,7 @@ bool AstInterface::dump(RegistryKey& rKey) return true; RegistryKey localKey; - if (rKey.createKey( OStringToOUString(getFullName(), RTL_TEXTENCODING_UTF8 ), localKey)) + if (rKey.createKey( OUString::fromUtf8(getFullName()), localKey)) { fprintf(stderr, "%s: warning, could not create key '%s' in '%s'\n", idlc()->getOptions()->getProgramName().getStr(), @@ -194,7 +194,7 @@ bool AstInterface::dump(RegistryKey& rKey) OUString emptyStr; typereg::Writer aBlob( version, getDocumentation(), emptyStr, RT_TYPE_INTERFACE, m_bPublished, - OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), nBaseTypes, + OUString::fromUtf8(getRelativName()), nBaseTypes, nAttributes, nMethods, nReferences); sal_uInt16 superTypeIndex = 0; @@ -206,15 +206,11 @@ bool AstInterface::dump(RegistryKey& rKey) aBlob.setReferenceData( referenceIndex++, i->getDocumentation(), RT_REF_SUPPORTS, RT_ACCESS_OPTIONAL, - OStringToOUString( - i->getInterface()->getRelativName(), - RTL_TEXTENCODING_UTF8)); + OUString::fromUtf8(i->getInterface()->getRelativName())); } else { aBlob.setSuperTypeName( superTypeIndex++, - OStringToOUString( - i->getInterface()->getRelativName(), - RTL_TEXTENCODING_UTF8)); + OUString::fromUtf8(i->getInterface()->getRelativName())); } } diff --git a/idlc/source/astoperation.cxx b/idlc/source/astoperation.cxx index 5a38c8acbc20..bcc23ec14907 100644 --- a/idlc/source/astoperation.cxx +++ b/idlc/source/astoperation.cxx @@ -48,12 +48,11 @@ bool AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index) if (m_pReturnType == 0) { returnTypeName = "void"; } else { - returnTypeName = OStringToOUString( - m_pReturnType->getRelativName(), RTL_TEXTENCODING_UTF8); + returnTypeName = OUString::fromUtf8(m_pReturnType->getRelativName()); } rBlob.setMethodData( index, getDocumentation(), methodMode, - OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8), + OUString::fromUtf8(getLocalName()), returnTypeName, nParam, nExcep); if ( nParam ) @@ -91,11 +90,8 @@ bool AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index) rBlob.setMethodParameterData( index, paramIndex++, paramMode, - OStringToOUString( - pDecl->getLocalName(), RTL_TEXTENCODING_UTF8), - OStringToOUString( - pParam->getType()->getRelativName(), - RTL_TEXTENCODING_UTF8)); + OUString::fromUtf8(pDecl->getLocalName()), + OUString::fromUtf8(pParam->getType()->getRelativName())); } ++iter; } @@ -110,8 +106,7 @@ bool AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index) { rBlob.setMethodExceptionTypeName( index, exceptIndex++, - OStringToOUString( - (*iter)->getRelativName(), RTL_TEXTENCODING_UTF8)); + OUString::fromUtf8((*iter)->getRelativName())); ++iter; } } diff --git a/idlc/source/aststruct.cxx b/idlc/source/aststruct.cxx index 482ee73dadfa..b8f0a2e3a264 100644 --- a/idlc/source/aststruct.cxx +++ b/idlc/source/aststruct.cxx @@ -78,7 +78,7 @@ bool AstStruct::isType() const { bool AstStruct::dump(RegistryKey& rKey) { RegistryKey localKey; - if (rKey.createKey( OStringToOUString(getFullName(), RTL_TEXTENCODING_UTF8 ), localKey)) + if (rKey.createKey( OUString::fromUtf8(getFullName()), localKey)) { fprintf(stderr, "%s: warning, could not create key '%s' in '%s'\n", idlc()->getOptions()->getProgramName().getStr(), @@ -107,14 +107,13 @@ bool AstStruct::dump(RegistryKey& rKey) (m_typeParameters.empty() && !m_bPublished ? TYPEREG_VERSION_0 : TYPEREG_VERSION_1), getDocumentation(), emptyStr, typeClass, m_bPublished, - OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), + OUString::fromUtf8(getRelativName()), m_pBaseType == 0 ? 0 : 1, nMember, 0, static_cast< sal_uInt16 >(m_typeParameters.size())); if (m_pBaseType != 0) { aBlob.setSuperTypeName( 0, - OStringToOUString( - m_pBaseType->getRelativName(), RTL_TEXTENCODING_UTF8)); + OUString::fromUtf8(m_pBaseType->getRelativName())); } if ( nMember > 0 ) @@ -140,9 +139,8 @@ bool AstStruct::dump(RegistryKey& rKey) } aBlob.setFieldData( index++, pMember->getDocumentation(), emptyStr, flags, - OStringToOUString( - pMember->getLocalName(), RTL_TEXTENCODING_UTF8), - OStringToOUString(typeName, RTL_TEXTENCODING_UTF8), + OUString::fromUtf8(pMember->getLocalName()), + OUString::fromUtf8(typeName), RTConstValue()); } ++iter; @@ -155,8 +153,7 @@ bool AstStruct::dump(RegistryKey& rKey) { aBlob.setReferenceData( index++, emptyStr, RT_REF_TYPE_PARAMETER, RT_ACCESS_INVALID, - OStringToOUString( - (*i)->getLocalName(), RTL_TEXTENCODING_UTF8)); + OUString::fromUtf8((*i)->getLocalName())); } sal_uInt32 aBlobSize; diff --git a/idlc/source/idlc.cxx b/idlc/source/idlc.cxx index 75a71dfa6a6b..b5ed727b9e5a 100644 --- a/idlc/source/idlc.cxx +++ b/idlc/source/idlc.cxx @@ -272,7 +272,7 @@ OUString Idlc::processDocumentation() if (m_bIsDocValid) { OString raw(getDocumentation()); if (m_bGenerateDoc) { - doc = OStringToOUString(raw, RTL_TEXTENCODING_UTF8); + doc = OUString::fromUtf8(raw); } else if (raw.indexOf("@deprecated") != -1) { //TODO: this check is somewhat crude doc = "@deprecated"; diff --git a/idlc/source/idlccompile.cxx b/idlc/source/idlccompile.cxx index 695db41d2097..53fd802fc5f6 100644 --- a/idlc/source/idlccompile.cxx +++ b/idlc/source/idlccompile.cxx @@ -258,9 +258,8 @@ sal_Int32 compileFile(const OString * pathname) { cppArgs.append("-I"); cppArgs.append(filePath); - lCppArgs.push_back(OStringToOUString( - cppArgs.makeStringAndClear().replace('\\', '/'), - RTL_TEXTENCODING_UTF8)); + lCppArgs.push_back(OUString::fromUtf8( + cppArgs.makeStringAndClear().replace('\\', '/'))); } } @@ -272,7 +271,7 @@ sal_Int32 compileFile(const OString * pathname) { token = dOpt.getToken( 0, ' ', nIndex ); if (token.getLength()) - lCppArgs.push_back(OStringToOUString("-D" + token, RTL_TEXTENCODING_UTF8)); + lCppArgs.push_back(OUString::fromUtf8("-D" + token)); } while( nIndex != -1 ); } @@ -284,17 +283,17 @@ sal_Int32 compileFile(const OString * pathname) { token = incOpt.getToken( 0, ' ', nIndex ); if (token.getLength()) - lCppArgs.push_back(OStringToOUString("-I" + token, RTL_TEXTENCODING_UTF8)); + lCppArgs.push_back(OUString::fromUtf8("-I" + token)); } while( nIndex != -1 ); } lCppArgs.push_back(OUString("-o")); cppArgs.append(preprocFile); - lCppArgs.push_back(OStringToOUString(cppArgs.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); + lCppArgs.push_back(OUString::fromUtf8(cppArgs.makeStringAndClear())); cppArgs.append(tmpFile); - lCppArgs.push_back(OStringToOUString(cppArgs.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); + lCppArgs.push_back(OUString::fromUtf8(cppArgs.makeStringAndClear())); OUString cpp; OUString startDir; diff --git a/idlc/source/idlcproduce.cxx b/idlc/source/idlcproduce.cxx index 35a3a20a5517..d7dd9f1c7946 100644 --- a/idlc/source/idlcproduce.cxx +++ b/idlc/source/idlcproduce.cxx @@ -119,7 +119,7 @@ static bool cleanPath() void removeIfExists(const OString& pathname) { - osl::File::remove(OStringToOUString(pathname, RTL_TEXTENCODING_UTF8)); + osl::File::remove(OUString::fromUtf8(pathname)); } sal_Int32 SAL_CALL @@ -154,7 +154,7 @@ produceFile(const OString& regFileName, sPair_t const*const pDepFile) OString urlRegTmpName = convertToFileUrl(regTmpName); Registry regFile; - if ( regFile.create(OStringToOUString(urlRegTmpName, RTL_TEXTENCODING_UTF8)) != REG_NO_ERROR ) + if ( regFile.create(OUString::fromUtf8(urlRegTmpName)) != REG_NO_ERROR ) { fprintf(stderr, "%s: could not create registry file '%s'\n", pOptions->getProgramName().getStr(), regTmpName.getStr()); @@ -184,7 +184,7 @@ produceFile(const OString& regFileName, sPair_t const*const pDepFile) fprintf(stderr, "%s: could not close registry file '%s'\n", pOptions->getProgramName().getStr(), regFileName.getStr()); } - regFile.destroy(OStringToOUString(regFileName, RTL_TEXTENCODING_UTF8)); + regFile.destroy(OUString::fromUtf8(regFileName)); removeIfExists(regFileName); cleanPath(); return 1; diff --git a/idlc/source/options.cxx b/idlc/source/options.cxx index dfdb9bd291a9..cf6e46de9150 100644 --- a/idlc/source/options.cxx +++ b/idlc/source/options.cxx @@ -197,7 +197,7 @@ bool Options::setOption(char const * option, std::string const & rArg) with error. */ OString convertIncPathtoShortWindowsPath(const OString& incPath) { - OUString path = OStringToOUString(incPath, RTL_TEXTENCODING_UTF8); + OUString path = OUString::fromUtf8(incPath); std::vector vec(path.getLength() + 1); //GetShortPathNameW only works if the file can be found! diff --git a/idlc/source/parser.y b/idlc/source/parser.y index 400778026c9c..a9267ac17ad5 100644 --- a/idlc/source/parser.y +++ b/idlc/source/parser.y @@ -61,7 +61,6 @@ using ::rtl::OUString; using ::rtl::OString; -using ::rtl::OStringToOUString; using ::rtl::OStringBuffer; extern int yylex(void); @@ -897,8 +896,7 @@ attribute_get_raises: IDL_GET raises ';' { $$.documentation = new rtl::OUString( - rtl::OStringToOUString( - idlc()->getDocumentation(), RTL_TEXTENCODING_UTF8)); + rtl::OUString::fromUtf8(idlc()->getDocumentation())); $$.exceptions = $2; } ; @@ -920,8 +918,7 @@ attribute_set_raises: raises ';' { $$.documentation = new rtl::OUString( - rtl::OStringToOUString( - idlc()->getDocumentation(), RTL_TEXTENCODING_UTF8)); + rtl::OUString::fromUtf8(idlc()->getDocumentation())); $$.exceptions = $3; } ; @@ -1203,8 +1200,7 @@ interface_inheritance_decl: } else { addInheritedInterface( ifc, *$4, $1, - rtl::OStringToOUString( - idlc()->getDocumentation(), RTL_TEXTENCODING_UTF8)); + rtl::OUString::fromUtf8(idlc()->getDocumentation())); } delete $4; } -- cgit