diff options
Diffstat (limited to 'dbaccess/source/filter')
40 files changed, 468 insertions, 508 deletions
diff --git a/dbaccess/source/filter/hsqldb/columndef.cxx b/dbaccess/source/filter/hsqldb/columndef.cxx index 62bd7b541bf1..643e8187627d 100644 --- a/dbaccess/source/filter/hsqldb/columndef.cxx +++ b/dbaccess/source/filter/hsqldb/columndef.cxx @@ -20,23 +20,22 @@ #include "columndef.hxx" #include <com/sun/star/sdbc/DataType.hpp> +#include <utility> namespace dbahsql { -using namespace css::sdbc; - -ColumnDefinition::ColumnDefinition(const OUString& sName, sal_Int32 eType, - const std::vector<sal_Int32>& aParams, bool bPrimary, +ColumnDefinition::ColumnDefinition(OUString sName, sal_Int32 eType, + std::vector<sal_Int32>&& aParams, bool bPrimary, sal_Int32 nAutoIncr, bool bNullable, bool bCaseInsensitive, - const OUString& sDefault) - : m_sName(sName) + OUString sDefault) + : m_sName(std::move(sName)) , m_eType(eType) - , m_aParams(aParams) + , m_aParams(std::move(aParams)) , m_bPrimaryKey(bPrimary) , m_nAutoIncrement(nAutoIncr) , m_bNullable(bNullable) , m_bCaseInsensitive(bCaseInsensitive) - , m_sDefaultValue(sDefault) + , m_sDefaultValue(std::move(sDefault)) { } } diff --git a/dbaccess/source/filter/hsqldb/columndef.hxx b/dbaccess/source/filter/hsqldb/columndef.hxx index faad744c554e..4ac3532a3454 100644 --- a/dbaccess/source/filter/hsqldb/columndef.hxx +++ b/dbaccess/source/filter/hsqldb/columndef.hxx @@ -28,9 +28,9 @@ private: OUString m_sDefaultValue; public: - ColumnDefinition(const OUString& sName, sal_Int32 eType, const std::vector<sal_Int32>& aParams, + ColumnDefinition(OUString sName, sal_Int32 eType, std::vector<sal_Int32>&& aParams, bool bPrimary = false, sal_Int32 nAutoIncr = -1, bool bNullable = true, - bool bCaseInsensitive = false, const OUString& sDefault = OUString{}); + bool bCaseInsensitive = false, OUString sDefault = OUString{}); OUString const& getName() const { return m_sName; } sal_Int32 getDataType() const { return m_eType; } diff --git a/dbaccess/source/filter/hsqldb/createparser.cxx b/dbaccess/source/filter/hsqldb/createparser.cxx index 9aad116535fb..360741ce0b28 100644 --- a/dbaccess/source/filter/hsqldb/createparser.cxx +++ b/dbaccess/source/filter/hsqldb/createparser.cxx @@ -19,6 +19,7 @@ #include <comphelper/string.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include "createparser.hxx" #include "utils.hxx" #include <com/sun/star/sdbc/DataType.hpp> @@ -30,16 +31,17 @@ namespace { /// Returns substring of sSql from the first occurrence of '(' until the /// last occurrence of ')' (excluding the parenthesis) -OUString lcl_getColumnPart(const OUString& sSql) +std::u16string_view lcl_getColumnPart(std::u16string_view sSql) { - sal_Int32 nBeginIndex = sSql.indexOf("(") + 1; - if (nBeginIndex < 0) + size_t nBeginIndex = sSql.find('('); + if (nBeginIndex == std::u16string_view::npos) { SAL_WARN("dbaccess", "No column definitions found"); - return OUString(); + return std::u16string_view(); } - sal_Int32 nCount = sSql.lastIndexOf(")") - nBeginIndex; - return sSql.copy(nBeginIndex, nCount); + sal_Int32 nCount = sSql.rfind(')') - nBeginIndex - 1; + auto sPart = sSql.substr(nBeginIndex + 1, nCount); + return sPart; } /// Constructs a vector of strings that represents the definitions of each @@ -47,7 +49,7 @@ OUString lcl_getColumnPart(const OUString& sSql) /// /// @param sColumnPart part of the create statement inside the parenthesis /// containing the column definitions -std::vector<OUString> lcl_splitColumnPart(const OUString& sColumnPart) +std::vector<OUString> lcl_splitColumnPart(std::u16string_view sColumnPart) { std::vector<OUString> sParts = string::split(sColumnPart, sal_Unicode(u',')); std::vector<OUString> sReturn; @@ -67,10 +69,11 @@ std::vector<OUString> lcl_splitColumnPart(const OUString& sColumnPart) return sReturn; } -sal_Int32 lcl_getAutoIncrementDefault(const OUString& sColumnDef) +sal_Int32 lcl_getAutoIncrementDefault(std::u16string_view sColumnDef) { // TODO what if there are more spaces? - if (sColumnDef.indexOf("GENERATED BY DEFAULT AS IDENTITY") > 0) + size_t nPos = sColumnDef.find(u"GENERATED BY DEFAULT AS IDENTITY"); + if (nPos != std::u16string_view::npos && nPos > 0) { // TODO parse starting sequence stated by "START WITH" return 0; @@ -78,24 +81,34 @@ sal_Int32 lcl_getAutoIncrementDefault(const OUString& sColumnDef) return -1; } -OUString lcl_getDefaultValue(const OUString& sColumnDef) +std::u16string_view lcl_getDefaultValue(std::u16string_view sColumnDef) { - constexpr char DEFAULT_KW[] = "DEFAULT"; - auto nDefPos = sColumnDef.indexOf(DEFAULT_KW); - if (nDefPos > 0 && lcl_getAutoIncrementDefault(sColumnDef) < 0) + constexpr std::u16string_view DEFAULT_KW = u"DEFAULT"; + size_t nDefPos = sColumnDef.find(DEFAULT_KW); + if (nDefPos > 0 && nDefPos != std::u16string_view::npos + && lcl_getAutoIncrementDefault(sColumnDef) < 0) { - const OUString& fromDefault = sColumnDef.copy(nDefPos + sizeof(DEFAULT_KW)).trim(); + std::u16string_view fromDefault + = o3tl::trim(sColumnDef.substr(nDefPos + DEFAULT_KW.size())); // next word is the value - auto nNextSpace = fromDefault.indexOf(" "); - return nNextSpace > 0 ? fromDefault.copy(0, fromDefault.indexOf(" ")) : fromDefault; + size_t nNextSpace = fromDefault.find(' '); + return (nNextSpace > 0 && nNextSpace != std::u16string_view::npos) + ? fromDefault.substr(0, nNextSpace) + : fromDefault; } - return OUString{}; + return std::u16string_view(); } -bool lcl_isNullable(const OUString& sColumnDef) { return sColumnDef.indexOf("NOT NULL") < 0; } +bool lcl_isNullable(std::u16string_view sColumnDef) +{ + return sColumnDef.find(u"NOT NULL") == std::u16string_view::npos; +} -bool lcl_isPrimaryKey(const OUString& sColumnDef) { return sColumnDef.indexOf("PRIMARY KEY") >= 0; } +bool lcl_isPrimaryKey(std::u16string_view sColumnDef) +{ + return sColumnDef.find(u"PRIMARY KEY") != std::u16string_view::npos; +} sal_Int32 lcl_getDataTypeFromHsql(std::u16string_view sTypeName) { @@ -163,15 +176,15 @@ struct ColumnTypeParts * Separates full type descriptions (e.g. NUMERIC(5,4)) to type name (NUMERIC) and * parameters (5,4) */ -ColumnTypeParts lcl_getColumnTypeParts(const OUString& sFullTypeName) +ColumnTypeParts lcl_getColumnTypeParts(std::u16string_view sFullTypeName) { ColumnTypeParts parts; - auto nParenPos = sFullTypeName.indexOf("("); - if (nParenPos > 0) + auto nParenPos = sFullTypeName.find('('); + if (nParenPos > 0 && nParenPos != std::u16string_view::npos) { - parts.typeName = sFullTypeName.copy(0, nParenPos).trim(); - OUString sParamStr - = sFullTypeName.copy(nParenPos + 1, sFullTypeName.indexOf(")") - nParenPos - 1); + parts.typeName = o3tl::trim(sFullTypeName.substr(0, nParenPos)); + std::u16string_view sParamStr + = sFullTypeName.substr(nParenPos + 1, sFullTypeName.find(')') - nParenPos - 1); auto sParams = string::split(sParamStr, sal_Unicode(u',')); for (const auto& sParam : sParams) { @@ -180,7 +193,7 @@ ColumnTypeParts lcl_getColumnTypeParts(const OUString& sFullTypeName) } else { - parts.typeName = sFullTypeName.trim(); + parts.typeName = o3tl::trim(sFullTypeName); lcl_addDefaultParameters(parts.params, lcl_getDataTypeFromHsql(parts.typeName)); } return parts; @@ -192,13 +205,13 @@ namespace dbahsql { CreateStmtParser::CreateStmtParser() {} -void CreateStmtParser::parsePrimaryKeys(const OUString& sPrimaryPart) +void CreateStmtParser::parsePrimaryKeys(std::u16string_view sPrimaryPart) { - sal_Int32 nParenPos = sPrimaryPart.indexOf("("); - if (nParenPos > 0) + size_t nParenPos = sPrimaryPart.find('('); + if (nParenPos > 0 && nParenPos != std::u16string_view::npos) { - OUString sParamStr - = sPrimaryPart.copy(nParenPos + 1, sPrimaryPart.lastIndexOf(")") - nParenPos - 1); + std::u16string_view sParamStr + = sPrimaryPart.substr(nParenPos + 1, sPrimaryPart.rfind(')') - nParenPos - 1); auto sParams = string::split(sParamStr, sal_Unicode(u',')); for (const auto& sParam : sParams) { @@ -207,7 +220,7 @@ void CreateStmtParser::parsePrimaryKeys(const OUString& sPrimaryPart) } } -void CreateStmtParser::parseColumnPart(const OUString& sColumnPart) +void CreateStmtParser::parseColumnPart(std::u16string_view sColumnPart) { auto sColumns = lcl_splitColumnPart(sColumnPart); for (const OUString& sColumn : sColumns) @@ -232,15 +245,15 @@ void CreateStmtParser::parseColumnPart(const OUString& sColumnPart) = bIsQuoteUsedForColumnName ? sColumn.indexOf("\"", 1) + 1 : sColumn.indexOf(" "); OUString rColumnName = sColumn.copy(0, nEndColumnName); - const OUString& sFromTypeName = sColumn.copy(nEndColumnName).trim(); + const OUString sFromTypeName(o3tl::trim(sColumn.subView(nEndColumnName))); // Now let's manage the column type // search next space to get the whole type name // eg: INTEGER, VARCHAR(10), DECIMAL(6,3) auto nNextSpace = sFromTypeName.indexOf(" "); - OUString sFullTypeName; + std::u16string_view sFullTypeName; if (nNextSpace > 0) - sFullTypeName = sFromTypeName.copy(0, nNextSpace); + sFullTypeName = sFromTypeName.subView(0, nNextSpace); // perhaps column type corresponds to the last info here else sFullTypeName = sFromTypeName; @@ -253,29 +266,30 @@ void CreateStmtParser::parseColumnPart(const OUString& sColumnPart) if (isPrimaryKey) m_PrimaryKeys.push_back(rColumnName); - const OUString sColumnWithoutName = sColumn.copy(sColumn.indexOf(typeParts.typeName)); + const std::u16string_view sColumnWithoutName + = sColumn.subView(sColumn.indexOf(typeParts.typeName)); ColumnDefinition aColDef(rColumnName, lcl_getDataTypeFromHsql(typeParts.typeName), - typeParts.params, isPrimaryKey, + std::move(typeParts.params), isPrimaryKey, lcl_getAutoIncrementDefault(sColumnWithoutName), lcl_isNullable(sColumnWithoutName), bCaseInsensitive, - lcl_getDefaultValue(sColumnWithoutName)); + OUString(lcl_getDefaultValue(sColumnWithoutName))); m_aColumns.push_back(aColDef); } } -void CreateStmtParser::parse(const OUString& sSql) +void CreateStmtParser::parse(std::u16string_view sSql) { // TODO Foreign keys - if (!sSql.startsWith("CREATE")) + if (!o3tl::starts_with(sSql, u"CREATE")) { SAL_WARN("dbaccess", "Not a create statement"); return; } m_sTableName = utils::getTableNameFromStmt(sSql); - OUString sColumnPart = lcl_getColumnPart(sSql); + std::u16string_view sColumnPart = lcl_getColumnPart(sSql); parseColumnPart(sColumnPart); } diff --git a/dbaccess/source/filter/hsqldb/createparser.hxx b/dbaccess/source/filter/hsqldb/createparser.hxx index 909b4063ac58..a92f745860d5 100644 --- a/dbaccess/source/filter/hsqldb/createparser.hxx +++ b/dbaccess/source/filter/hsqldb/createparser.hxx @@ -23,8 +23,8 @@ private: OUString m_sTableName; protected: - void parseColumnPart(const OUString& sColumnPart); - void parsePrimaryKeys(const OUString& sPrimaryPart); + void parseColumnPart(std::u16string_view sColumnPart); + void parsePrimaryKeys(std::u16string_view sPrimaryPart); public: CreateStmtParser(); @@ -56,7 +56,7 @@ public: * * @param SQL "CREATE" statement */ - void parse(const OUString& sSql); + void parse(std::u16string_view sSql); /** * Recreate the sql statement. diff --git a/dbaccess/source/filter/hsqldb/fbalterparser.cxx b/dbaccess/source/filter/hsqldb/fbalterparser.cxx index 818673cbdaf3..a8948069e4e6 100644 --- a/dbaccess/source/filter/hsqldb/fbalterparser.cxx +++ b/dbaccess/source/filter/hsqldb/fbalterparser.cxx @@ -32,18 +32,16 @@ OUString FbAlterStmtParser::compose() const } else if (getActionType() == AlterAction::ADD_FOREIGN) return getStatement(); // do nothing with that - OUStringBuffer sSql("ALTER TABLE "); - sSql.append(getTableName()); + OUStringBuffer sSql("ALTER TABLE " + getTableName()); if (getActionType() == AlterAction::IDENTITY_RESTART) { sSql.append(" ALTER COLUMN "); } - sSql.append(getColumnName()); - sSql.append(" RESTART WITH "); + sSql.append(getColumnName() + " RESTART WITH "); // Firebird: restart with 0 means the first number is 1, not 0. - sSql.append(OUString::number(getIdentityParam() - 1)); + sSql.append(getIdentityParam() - 1); return sSql.makeStringAndClear(); } diff --git a/dbaccess/source/filter/hsqldb/fbcreateparser.cxx b/dbaccess/source/filter/hsqldb/fbcreateparser.cxx index 4f8fb8667d1e..f19778f7439d 100644 --- a/dbaccess/source/filter/hsqldb/fbcreateparser.cxx +++ b/dbaccess/source/filter/hsqldb/fbcreateparser.cxx @@ -29,52 +29,46 @@ using namespace css::sdbc; namespace { -void lcl_appendWithSpace(OUStringBuffer& sBuff, const OUString& sStr) -{ - sBuff.append(" "); - sBuff.append(sStr); -} - OUString lcl_DataTypetoFbTypeName(sal_Int32 eType) { switch (eType) { case DataType::CHAR: case DataType::BINARY: - return "CHAR"; + return u"CHAR"_ustr; case DataType::VARCHAR: case DataType::VARBINARY: - return "VARCHAR"; + return u"VARCHAR"_ustr; case DataType::TINYINT: // no such type in Firebird case DataType::SMALLINT: - return "SMALLINT"; + return u"SMALLINT"_ustr; case DataType::INTEGER: - return "INTEGER"; + return u"INTEGER"_ustr; case DataType::BIGINT: - return "BIGINT"; + return u"BIGINT"_ustr; case DataType::NUMERIC: - return "NUMERIC"; + return u"NUMERIC"_ustr; case DataType::DECIMAL: - return "DECIMAL"; + return u"DECIMAL"_ustr; case DataType::BOOLEAN: - return "BOOLEAN"; + return u"BOOLEAN"_ustr; case DataType::LONGVARCHAR: case DataType::LONGVARBINARY: case DataType::CLOB: case DataType::BLOB: case DataType::OTHER: - return "BLOB"; + return u"BLOB"_ustr; case DataType::DATE: - return "DATE"; + return u"DATE"_ustr; case DataType::TIME: - return "TIME"; + return u"TIME"_ustr; case DataType::TIMESTAMP: - return "TIMESTAMP"; + return u"TIMESTAMP"_ustr; case DataType::DOUBLE: case DataType::REAL: - return "DOUBLE PRECISION"; + return u"DOUBLE PRECISION"_ustr; case DataType::FLOAT: - return "FLOAT"; + return u"FLOAT"_ustr; default: assert(false); return OUString(); @@ -89,12 +83,12 @@ OUString lcl_getTypeModifier(sal_Int32 eType) { case DataType::CLOB: case DataType::LONGVARCHAR: - return "SUB_TYPE 1"; + return u"SUB_TYPE 1"_ustr; case DataType::LONGVARBINARY: - return "SUB_TYPE -9546"; + return u"SUB_TYPE -9546"_ustr; case DataType::BINARY: case DataType::VARBINARY: - return "CHARACTER SET OCTETS"; + return u"CHARACTER SET OCTETS"_ustr; default: return OUString(); } @@ -110,8 +104,7 @@ void FbCreateStmtParser::appendPrimaryKeyPart(OUStringBuffer& rSql) const if (sPrimaryKeys.empty()) return; // no primary key specified - rSql.append(","); - rSql.append("PRIMARY KEY("); + rSql.append(",PRIMARY KEY("); auto it = sPrimaryKeys.cbegin(); while (it != sPrimaryKeys.end()) { @@ -135,16 +128,14 @@ OUString FbCreateStmtParser::compose() const { ensureProperTableLengths(); OUStringBuffer sSql(128); - sSql.append("CREATE TABLE "); - sSql.append(getTableName()); + sSql.append("CREATE TABLE " + getTableName() + " ("); // column declaration - lcl_appendWithSpace(sSql, "("); // column declaration auto& rColumns = getColumnDef(); auto columnIter = rColumns.cbegin(); while (columnIter != rColumns.end()) { - lcl_appendWithSpace(sSql, columnIter->getName()); - lcl_appendWithSpace(sSql, lcl_DataTypetoFbTypeName(columnIter->getDataType())); + sSql.append(" " + columnIter->getName() + " " + + lcl_DataTypetoFbTypeName(columnIter->getDataType())); std::vector<sal_Int32> params{ columnIter->getParams() }; @@ -163,7 +154,7 @@ OUString FbCreateStmtParser::compose() const auto it = params.cbegin(); while (it != params.end()) { - sSql.append(OUString::number(*it)); + sSql.append(*it); ++it; if (it != params.end()) sSql.append(","); @@ -174,32 +165,30 @@ OUString FbCreateStmtParser::compose() const // special modifiers here, based on type (e.g. charset, subtype) OUString sModifier = lcl_getTypeModifier(columnIter->getDataType()); if (!sModifier.isEmpty()) - lcl_appendWithSpace(sSql, sModifier); + sSql.append(" " + sModifier); if (columnIter->isAutoIncremental()) { - lcl_appendWithSpace(sSql, "GENERATED BY DEFAULT AS IDENTITY (START WITH "); - // start with 0: // HSQLDB: first value will be 0. // Firebird: first value will be 1. - sSql.append(columnIter->getStartValue() - 1); - sSql.append(")"); + sSql.append(" GENERATED BY DEFAULT AS IDENTITY (START WITH " + + OUString::number(columnIter->getStartValue() - 1) + ")"); } else if (!columnIter->isNullable()) - lcl_appendWithSpace(sSql, "NOT NULL"); + sSql.append(" NOT NULL"); if (columnIter->isCaseInsensitive()) - lcl_appendWithSpace(sSql, "COLLATE UNICODE_CI"); + sSql.append(" COLLATE UNICODE_CI"); const OUString& sDefaultVal = columnIter->getDefault(); if (!sDefaultVal.isEmpty()) { - lcl_appendWithSpace(sSql, "DEFAULT"); + sSql.append(" DEFAULT "); if (sDefaultVal.equalsIgnoreAsciiCase("NOW")) - lcl_appendWithSpace(sSql, "\'NOW\'"); // Fb likes it single quoted + sSql.append("'NOW'"); // Fb likes it single quoted else - lcl_appendWithSpace(sSql, sDefaultVal); + sSql.append(sDefaultVal); } ++columnIter; diff --git a/dbaccess/source/filter/hsqldb/hsqlimport.cxx b/dbaccess/source/filter/hsqldb/hsqlimport.cxx index f24ceb6f2ff0..918397da620f 100644 --- a/dbaccess/source/filter/hsqldb/hsqlimport.cxx +++ b/dbaccess/source/filter/hsqldb/hsqlimport.cxx @@ -176,13 +176,11 @@ void lcl_setParams(const std::vector<Any>& row, Reference<XParameters> const& xP } } -OUString lcl_createInsertStatement(const OUString& sTableName, +OUString lcl_createInsertStatement(std::u16string_view sTableName, const std::vector<dbahsql::ColumnDefinition>& rColTypes) { assert(rColTypes.size() > 0); - OUStringBuffer sql("INSERT INTO "); - sql.append(sTableName); - sql.append(" ("); + OUStringBuffer sql(OUString::Concat("INSERT INTO ") + sTableName + " ("); // column names for (size_t i = 0; i < rColTypes.size(); ++i) @@ -191,9 +189,7 @@ OUString lcl_createInsertStatement(const OUString& sTableName, if (i < rColTypes.size() - 1) sql.append(", "); } - sql.append(")"); - - sql.append(" VALUES ("); + sql.append(") VALUES ("); for (size_t i = 0; i < rColTypes.size(); ++i) { sql.append("?"); @@ -216,7 +212,8 @@ HsqlImporter::HsqlImporter(Reference<XConnection>& rConnection, const Reference< m_xStorage.set(rStorage); } -void HsqlImporter::insertRow(const std::vector<css::uno::Any>& xRows, const OUString& sTableName, +void HsqlImporter::insertRow(const std::vector<css::uno::Any>& xRows, + std::u16string_view sTableName, const std::vector<ColumnDefinition>& rColTypes) { OUString sStatement = lcl_createInsertStatement(sTableName, rColTypes); @@ -266,7 +263,7 @@ void HsqlImporter::parseTableRows(const std::vector<sal_Int32>& rIndexes, const std::vector<ColumnDefinition>& rColTypes, const OUString& sTableName) { - static constexpr OUStringLiteral BINARY_FILENAME = u"data"; + static constexpr OUString BINARY_FILENAME = u"data"_ustr; if (!m_xStorage->hasByName(BINARY_FILENAME)) { diff --git a/dbaccess/source/filter/hsqldb/hsqlimport.hxx b/dbaccess/source/filter/hsqldb/hsqlimport.hxx index f414d327565d..13bbcd510442 100644 --- a/dbaccess/source/filter/hsqldb/hsqlimport.hxx +++ b/dbaccess/source/filter/hsqldb/hsqlimport.hxx @@ -23,14 +23,14 @@ class Window; namespace dbahsql { -class SAL_DLLPUBLIC_EXPORT HsqlImporter +class UNLESS_MERGELIBS_MORE(SAL_DLLPUBLIC_EXPORT) HsqlImporter { private: css::uno::Reference<css::sdbc::XConnection>& m_rConnection; css::uno::Reference<css::embed::XStorage> m_xStorage; protected: - void insertRow(const std::vector<css::uno::Any>& xRows, const OUString& sTable, + void insertRow(const std::vector<css::uno::Any>& xRows, std::u16string_view sTable, const std::vector<ColumnDefinition>& rColTypes); void processTree(HsqlBinaryNode& rNode, HsqlRowInputStream& rStream, const std::vector<ColumnDefinition>& rColTypes, const OUString& sTableName, diff --git a/dbaccess/source/filter/hsqldb/parseschema.cxx b/dbaccess/source/filter/hsqldb/parseschema.cxx index 3e615428f2d4..8dbeef741575 100644 --- a/dbaccess/source/filter/hsqldb/parseschema.cxx +++ b/dbaccess/source/filter/hsqldb/parseschema.cxx @@ -33,6 +33,7 @@ #include <comphelper/string.hxx> #include <sal/log.hxx> #include <connectivity/dbexception.hxx> +#include <utility> namespace { @@ -46,8 +47,8 @@ private: OUString m_sql; public: - IndexStmtParser(const OUString& sSql) - : m_sql(sSql) + IndexStmtParser(OUString sSql) + : m_sql(std::move(sSql)) { } @@ -60,9 +61,14 @@ public: { assert(isIndexStatement()); - OUString sIndexPart = m_sql.copy(m_sql.indexOf("INDEX") + 5); - sal_Int32 nQuotePos = sIndexPart.indexOf("'") + 1; - OUString sIndexNums = sIndexPart.copy(nQuotePos, sIndexPart.lastIndexOf("'") - nQuotePos); + std::u16string_view sIndexPart = m_sql.subView(m_sql.indexOf("INDEX") + 5); + size_t nQuotePos = sIndexPart.find('\''); + if (nQuotePos == std::u16string_view::npos) + nQuotePos = 0; + else + ++nQuotePos; + std::u16string_view sIndexNums + = sIndexPart.substr(nQuotePos, sIndexPart.rfind('\'') - nQuotePos); std::vector<OUString> sIndexes = string::split(sIndexNums, u' '); IndexVector indexes; @@ -84,10 +90,7 @@ public: if (sName.indexOf('"') >= 0) { // Table name with string delimiter - OUStringBuffer sMultiName("\""); - sMultiName.append(string::split(m_sql, u'"')[1]); - sMultiName.append("\""); - sName = sMultiName.makeStringAndClear(); + sName = "\"" + string::split(m_sql, u'"')[1] + "\""; } return sName; } @@ -115,7 +118,7 @@ void SchemaParser::parseSchema() { assert(m_rStorage); - static constexpr OUStringLiteral SCHEMA_FILENAME = u"script"; + static constexpr OUString SCHEMA_FILENAME = u"script"_ustr; if (!m_rStorage->hasByName(SCHEMA_FILENAME)) { SAL_WARN("dbaccess", "script file does not exist in storage during hsqldb import"); @@ -126,7 +129,7 @@ void SchemaParser::parseSchema() Reference<XComponentContext> rContext = comphelper::getProcessComponentContext(); Reference<XTextInputStream2> xTextInput = TextInputStream::create(rContext); - xTextInput->setEncoding("UTF-8"); + xTextInput->setEncoding(u"UTF-8"_ustr); xTextInput->setInputStream(xStream->getInputStream()); while (!xTextInput->isEOF()) @@ -179,8 +182,8 @@ std::vector<ColumnDefinition> SchemaParser::getTableColumnTypes(const OUString& { if (m_ColumnTypes.count(sTableName) < 1) { - static constexpr OUStringLiteral NOT_EXIST - = u"Internal error while getting column information of table"; + static constexpr OUString NOT_EXIST + = u"Internal error while getting column information of table"_ustr; SAL_WARN("dbaccess", NOT_EXIST << ". Table name is: " << sTableName); dbtools::throwGenericSQLException(NOT_EXIST, ::comphelper::getProcessComponentContext()); } diff --git a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx index 5ded17936c38..7aa11ed5f49c 100644 --- a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx +++ b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx @@ -90,9 +90,8 @@ OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes) RTL_TEXTENCODING_UTF8); } -OUString lcl_makeStringFromBigint(const std::vector<sal_uInt8>& bytes) +OUString lcl_makeStringFromBigint(std::vector<sal_uInt8>&& aBytes) { - std::vector<sal_uInt8> aBytes{ bytes }; OUStringBuffer sRet; // two's complement @@ -116,11 +115,11 @@ OUString lcl_makeStringFromBigint(const std::vector<sal_uInt8>& bytes) return sRet.makeStringAndClear(); } -OUString lcl_putDot(const OUString& sNum, sal_Int32 nScale) +OUString lcl_putDot(std::u16string_view sNum, sal_Int32 nScale) { // e.g. sNum = "0", nScale = 2 -> "0.00" OUStringBuffer sBuf{ sNum }; - sal_Int32 nNullsToAppend = nScale - sNum.getLength() + 1; + sal_Int32 nNullsToAppend = nScale - sNum.size() + 1; for (sal_Int32 i = 0; i < nNullsToAppend; ++i) sBuf.insert(0, "0"); @@ -166,9 +165,8 @@ OUString HsqlRowInputStream::readUTF(sal_Int32 nUTFLen) sal_Int32 nStrLen = 0; while (nCount < nUTFLen) { - unsigned char cIn = 0; - m_pStream->ReadUChar(cIn); - sal_uInt8 c = reinterpret_cast<sal_uInt8&>(cIn); + sal_uInt8 c = 0; + m_pStream->ReadUChar(c); sal_uInt8 char2, char3; switch (c >> 4) { @@ -194,8 +192,7 @@ OUString HsqlRowInputStream::readUTF(sal_Int32 nUTFLen) throw WrongFormatException(); } - m_pStream->ReadUChar(cIn); - char2 = reinterpret_cast<sal_uInt8&>(cIn); + m_pStream->ReadUChar(char2); if ((char2 & 0xC0) != 0x80) { throw WrongFormatException(); @@ -212,10 +209,8 @@ OUString HsqlRowInputStream::readUTF(sal_Int32 nUTFLen) throw WrongFormatException(); } - m_pStream->ReadUChar(cIn); - char2 = reinterpret_cast<sal_uInt8&>(cIn); - m_pStream->ReadUChar(cIn); - char3 = reinterpret_cast<sal_uInt8&>(cIn); + m_pStream->ReadUChar(char2); + m_pStream->ReadUChar(char3); if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) { @@ -235,9 +230,8 @@ OUString HsqlRowInputStream::readUTF(sal_Int32 nUTFLen) bool HsqlRowInputStream::checkNull() { - unsigned char cIn = 0; - m_pStream->ReadUChar(cIn); - sal_uInt8 nNull = reinterpret_cast<sal_uInt8&>(cIn); + sal_uInt8 nNull = 0; + m_pStream->ReadUChar(nNull); return nNull == 0; } @@ -250,7 +244,7 @@ std::vector<Any> HsqlRowInputStream::readOneRow(const std::vector<ColumnDefiniti { if (checkNull()) { - aData.push_back(Any()); + aData.emplace_back(); continue; } @@ -263,28 +257,28 @@ std::vector<Any> HsqlRowInputStream::readOneRow(const std::vector<ColumnDefiniti case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: - aData.push_back(makeAny(readString())); + aData.emplace_back(readString()); break; case DataType::TINYINT: case DataType::SMALLINT: { sal_Int16 value = 0; m_pStream->ReadInt16(value); - aData.push_back(makeAny(value)); + aData.emplace_back(value); } break; case DataType::INTEGER: { sal_Int32 value = 0; m_pStream->ReadInt32(value); - aData.push_back(makeAny(value)); + aData.emplace_back(value); } break; case DataType::BIGINT: { sal_Int64 value = 0; m_pStream->ReadInt64(value); - aData.push_back(makeAny(value)); + aData.emplace_back(value); } break; case DataType::REAL: @@ -294,7 +288,7 @@ std::vector<Any> HsqlRowInputStream::readOneRow(const std::vector<ColumnDefiniti double value = 0; m_pStream->ReadDouble(value); // FIXME double is not necessarily 4 bytes - aData.push_back(makeAny(value)); + aData.emplace_back(value); } break; case DataType::NUMERIC: @@ -310,11 +304,9 @@ std::vector<Any> HsqlRowInputStream::readOneRow(const std::vector<ColumnDefiniti sal_Int32 nScale = 0; m_pStream->ReadInt32(nScale); - Sequence<Any> result(2); - OUString sNum = lcl_makeStringFromBigint(aBytes); - result[0] <<= lcl_putDot(sNum, nScale); - result[1] <<= nScale; - aData.push_back(makeAny(result)); + OUString sNum = lcl_makeStringFromBigint(std::move(aBytes)); + Sequence<Any> result{ Any(lcl_putDot(sNum, nScale)), Any(nScale) }; + aData.emplace_back(result); } break; case DataType::DATE: @@ -327,7 +319,7 @@ std::vector<Any> HsqlRowInputStream::readOneRow(const std::vector<ColumnDefiniti css::util::Date loDate(asDate.day(), asDate.month(), asDate.year()); // day, month, year - aData.push_back(makeAny(loDate)); + aData.emplace_back(loDate); } break; case DataType::TIME: @@ -346,7 +338,7 @@ std::vector<Any> HsqlRowInputStream::readOneRow(const std::vector<ColumnDefiniti const sal_uInt16 nMins = valueInSecs / 60; const sal_uInt16 nSecs = valueInSecs % 60; css::util::Time time((value % 1000) * 1000000, nSecs, nMins, nHours, true); - aData.push_back(makeAny(time)); + aData.emplace_back(time); } break; case DataType::TIMESTAMP: @@ -369,18 +361,18 @@ std::vector<Any> HsqlRowInputStream::readOneRow(const std::vector<ColumnDefiniti dateTime.Day = asDate.day(); dateTime.Month = asDate.month(); dateTime.Year = asDate.year(); - aData.push_back(makeAny(dateTime)); + aData.emplace_back(dateTime); } break; case DataType::BOOLEAN: { sal_uInt8 nBool = 0; m_pStream->ReadUChar(nBool); - aData.push_back(makeAny(static_cast<bool>(nBool))); + aData.emplace_back(static_cast<bool>(nBool)); } break; case DataType::OTHER: - aData.push_back(Any{}); // TODO + aData.emplace_back(); // TODO break; case DataType::BINARY: case DataType::VARBINARY: @@ -391,7 +383,7 @@ std::vector<Any> HsqlRowInputStream::readOneRow(const std::vector<ColumnDefiniti Sequence<sal_Int8> aBytes(nSize); m_pStream->ReadBytes(aBytes.getArray(), nSize); - aData.push_back(makeAny(aBytes)); + aData.emplace_back(aBytes); } break; diff --git a/dbaccess/source/filter/hsqldb/utils.cxx b/dbaccess/source/filter/hsqldb/utils.cxx index 041df17a700a..d8addd33623e 100644 --- a/dbaccess/source/filter/hsqldb/utils.cxx +++ b/dbaccess/source/filter/hsqldb/utils.cxx @@ -21,6 +21,7 @@ #include <comphelper/string.hxx> #include <comphelper/processfactory.hxx> #include <connectivity/dbexception.hxx> +#include <sal/log.hxx> #include "utils.hxx" @@ -79,7 +80,7 @@ OUString utils::convertToUTF8(std::string_view original) if (escape) { i -= 2; - res = res.replaceAt(i, 6, OUString(c)); + res = res.replaceAt(i, 6, rtl::OUStringChar(c)); ++i; } } @@ -87,7 +88,7 @@ OUString utils::convertToUTF8(std::string_view original) return res; } -OUString utils::getTableNameFromStmt(const OUString& sSql) +OUString utils::getTableNameFromStmt(std::u16string_view sSql) { auto stmtComponents = comphelper::string::split(sSql, sal_Unicode(u' ')); assert(stmtComponents.size() > 2); @@ -103,17 +104,22 @@ OUString utils::getTableNameFromStmt(const OUString& sSql) // it may contain spaces if it's put into apostrophes. if (wordIter->indexOf("\"") >= 0) { - sal_Int32 nAposBegin = sSql.indexOf("\""); - sal_Int32 nAposEnd = nAposBegin; + size_t nAposBegin = sSql.find('"'); + size_t nAposEnd = nAposBegin; bool bProperEndAposFound = false; while (!bProperEndAposFound) { - nAposEnd = sSql.indexOf("\"", nAposEnd + 1); + nAposEnd = sSql.find('"', nAposEnd + 1); + if (nAposEnd == std::u16string_view::npos) + { + SAL_WARN("dbaccess", "no matching \""); + return OUString(); + } if (sSql[nAposEnd - 1] != u'\\') bProperEndAposFound = true; } - OUString result = sSql.copy(nAposBegin, nAposEnd - nAposBegin + 1); - return result; + std::u16string_view result = sSql.substr(nAposBegin, nAposEnd - nAposBegin + 1); + return OUString(result); } // next word is the table's name @@ -125,9 +131,9 @@ OUString utils::getTableNameFromStmt(const OUString& sSql) return *wordIter; } -void utils::ensureFirebirdTableLength(const OUString& sName) +void utils::ensureFirebirdTableLength(std::u16string_view sName) { - if (sName.getLength() > 30) // Firebird limitation + if (sName.size() > 30) // Firebird limitation { static constexpr OUStringLiteral NAME_TOO_LONG = u"Firebird 3 doesn't support object (table, field) names " diff --git a/dbaccess/source/filter/hsqldb/utils.hxx b/dbaccess/source/filter/hsqldb/utils.hxx index b8ed1a222c4c..ed5fb8a1e380 100644 --- a/dbaccess/source/filter/hsqldb/utils.hxx +++ b/dbaccess/source/filter/hsqldb/utils.hxx @@ -19,9 +19,9 @@ namespace dbahsql::utils { OUString convertToUTF8(std::string_view original); -OUString getTableNameFromStmt(const OUString& sSql); +OUString getTableNameFromStmt(std::u16string_view sSql); -void ensureFirebirdTableLength(const OUString& sName); +void ensureFirebirdTableLength(std::u16string_view sName); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/filter/xml/dbloader2.cxx b/dbaccess/source/filter/xml/dbloader2.cxx index 7c2efad43a33..b58652810b5e 100644 --- a/dbaccess/source/filter/xml/dbloader2.cxx +++ b/dbaccess/source/filter/xml/dbloader2.cxx @@ -52,8 +52,9 @@ #include <cppuhelper/implbase.hxx> #include <cppuhelper/supportsservice.hxx> #include <sfx2/docfile.hxx> +#include <unotools/fcm.hxx> #include <unotools/moduleoptions.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/svapp.hxx> using namespace ::ucbhelper; @@ -64,7 +65,6 @@ using namespace ::com::sun::star::io; using namespace ::com::sun::star::util; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::document; using namespace ::com::sun::star::sdb; @@ -106,9 +106,9 @@ OUString SAL_CALL DBTypeDetection::detect( css::uno::Sequence< css::beans::Prope { ::comphelper::NamedValueCollection aMedia( Descriptor ); bool bStreamFromDescr = false; - OUString sURL = aMedia.getOrDefault( "URL", OUString() ); + OUString sURL = aMedia.getOrDefault( u"URL"_ustr, OUString() ); - Reference< XInputStream > xInStream( aMedia.getOrDefault( "InputStream", Reference< XInputStream >() ) ); + Reference< XInputStream > xInStream( aMedia.getOrDefault( u"InputStream"_ustr, Reference< XInputStream >() ) ); Reference< XPropertySet > xStorageProperties; if ( xInStream.is() ) { @@ -118,7 +118,7 @@ OUString SAL_CALL DBTypeDetection::detect( css::uno::Sequence< css::beans::Prope } else { - OUString sSalvagedURL( aMedia.getOrDefault( "SalvagedFile", OUString() ) ); + OUString sSalvagedURL( aMedia.getOrDefault( u"SalvagedFile"_ustr, OUString() ) ); OUString sFileLocation( sSalvagedURL.isEmpty() ? sURL : sSalvagedURL ); if ( !sFileLocation.isEmpty() ) @@ -138,8 +138,8 @@ OUString SAL_CALL DBTypeDetection::detect( css::uno::Sequence< css::beans::Prope { // After fixing of the i88522 issue ( use the new file locking for database files ) the stream from the type detection can be used further // for now the file should be reopened to have read/write access - aMedia.remove( OUString( "InputStream" ) ); - aMedia.remove( OUString( "Stream" ) ); + aMedia.remove( u"InputStream"_ustr ); + aMedia.remove( u"Stream"_ustr ); aMedia >>= Descriptor; try { @@ -153,7 +153,7 @@ OUString SAL_CALL DBTypeDetection::detect( css::uno::Sequence< css::beans::Prope } } - return "StarBase"; + return u"StarBase"_ustr; } ::comphelper::disposeComponent(xStorageProperties); } @@ -164,7 +164,7 @@ OUString SAL_CALL DBTypeDetection::detect( css::uno::Sequence< css::beans::Prope // XServiceInfo OUString SAL_CALL DBTypeDetection::getImplementationName() { - return "org.openoffice.comp.dbflt.DBTypeDetection"; + return u"org.openoffice.comp.dbflt.DBTypeDetection"_ustr; } // XServiceInfo @@ -176,7 +176,7 @@ sal_Bool SAL_CALL DBTypeDetection::supportsService(const OUString& ServiceName) // XServiceInfo Sequence< OUString > SAL_CALL DBTypeDetection::getSupportedServiceNames() { - return { "com.sun.star.document.ExtendedTypeDetection" }; + return { u"com.sun.star.document.ExtendedTypeDetection"_ustr }; } } // namespace dbaxml @@ -232,7 +232,7 @@ DBContentLoader::DBContentLoader(const Reference< XComponentContext >& _rxFactor // XServiceInfo OUString SAL_CALL DBContentLoader::getImplementationName() { - return "org.openoffice.comp.dbflt.DBContentLoader2"; + return u"org.openoffice.comp.dbflt.DBContentLoader2"_ustr; } // XServiceInfo @@ -244,7 +244,7 @@ sal_Bool SAL_CALL DBContentLoader::supportsService(const OUString& ServiceName) // XServiceInfo Sequence< OUString > SAL_CALL DBContentLoader::getSupportedServiceNames() { - return { "com.sun.star.frame.FrameLoader" }; + return { u"com.sun.star.frame.FrameLoader"_ustr }; } @@ -297,7 +297,7 @@ bool DBContentLoader::impl_executeNewDatabaseWizard( Reference< XModel > const & })); // create the dialog - Reference< XExecutableDialog > xAdminDialog( m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.sdb.DatabaseWizardDialog", aWizardArgs, m_aContext), UNO_QUERY_THROW); + Reference< XExecutableDialog > xAdminDialog( m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext(u"com.sun.star.sdb.DatabaseWizardDialog"_ustr, aWizardArgs, m_aContext), UNO_QUERY_THROW); // execute it if ( RET_OK != xAdminDialog->execute() ) @@ -305,8 +305,8 @@ bool DBContentLoader::impl_executeNewDatabaseWizard( Reference< XModel > const & Reference<XPropertySet> xProp(xAdminDialog,UNO_QUERY); bool bSuccess = false; - xProp->getPropertyValue("OpenDatabase") >>= bSuccess; - xProp->getPropertyValue("StartTableWizard") >>= _bShouldStartTableWizard; + xProp->getPropertyValue(u"OpenDatabase"_ustr) >>= bSuccess; + xProp->getPropertyValue(u"StartTableWizard"_ustr) >>= _bShouldStartTableWizard; return bSuccess; } @@ -316,7 +316,7 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU { // first check if preview is true, if so return without creating a controller. Preview is not supported ::comphelper::NamedValueCollection aMediaDesc( rArgs ); - bool bPreview = aMediaDesc.getOrDefault( "Preview", false ); + bool bPreview = aMediaDesc.getOrDefault( u"Preview"_ustr, false ); if ( bPreview ) { if (rListener.is()) @@ -324,8 +324,8 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU return; } - Reference< XModel > xModel = aMediaDesc.getOrDefault( "Model", Reference< XModel >() ); - OUString sSalvagedURL = aMediaDesc.getOrDefault( "SalvagedFile", _rURL ); + Reference< XModel > xModel = aMediaDesc.getOrDefault( u"Model"_ustr, Reference< XModel >() ); + OUString sSalvagedURL = aMediaDesc.getOrDefault( u"SalvagedFile"_ustr, _rURL ); bool bCreateNew = false; // does the URL denote the private:factory URL? bool bStartTableWizard = false; // start the table wizard after everything was loaded successfully? @@ -338,20 +338,20 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU // a default handler, we simply ensure there is one. // If a handler is present in the media descriptor, even if it is NULL, we will // not touch it. - if ( !aMediaDesc.has( "InteractionHandler" ) ) + if ( !aMediaDesc.has( u"InteractionHandler"_ustr ) ) { Reference< XInteractionHandler2 > xHandler( InteractionHandler::createWithParent(m_aContext, nullptr) ); - aMediaDesc.put( "InteractionHandler", xHandler ); + aMediaDesc.put( u"InteractionHandler"_ustr, xHandler ); } // it's allowed to pass an existing document Reference< XOfficeDatabaseDocument > xExistentDBDoc; - xModel.set( aMediaDesc.getOrDefault( "Model", xExistentDBDoc ), UNO_QUERY ); - aMediaDesc.remove( "Model" ); + xModel.set( aMediaDesc.getOrDefault( u"Model"_ustr, xExistentDBDoc ), UNO_QUERY ); + aMediaDesc.remove( u"Model"_ustr ); // also, it's allowed to specify the type of view which should be created - OUString sViewName = aMediaDesc.getOrDefault( "ViewName", OUString( "Default" ) ); - aMediaDesc.remove( "ViewName" ); + OUString sViewName = aMediaDesc.getOrDefault( u"ViewName"_ustr, u"Default"_ustr ); + aMediaDesc.remove( u"ViewName"_ustr ); // this needs to stay alive for duration of this method Reference< XDatabaseContext > xDatabaseContext; @@ -374,7 +374,7 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU else { ::comphelper::NamedValueCollection aCreationArgs; - aCreationArgs.put( OUString(INFO_POOLURL), sSalvagedURL ); + aCreationArgs.put( INFO_POOLURL, sSalvagedURL ); xDocumentDataSource.set( xDatabaseContext->createInstanceWithArguments( aCreationArgs.getWrappedNamedValues() ), UNO_QUERY_THROW ); } @@ -421,7 +421,7 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU bool bNeedLoad = xModel->getURL().isEmpty(); try { - aMediaDesc.put( "FileName", _rURL ); + aMediaDesc.put( u"FileName"_ustr, _rURL ); Sequence< PropertyValue > aResource( aMediaDesc.getPropertyValues() ); if ( bNeedLoad ) @@ -447,11 +447,8 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU Reference< XModel2 > xModel2( xModel, UNO_QUERY_THROW ); Reference< XController2 > xController( xModel2->createViewController( sViewName, Sequence< PropertyValue >(), rFrame ), UNO_SET_THROW ); - xController->attachModel( xModel ); - xModel->connectController( xController.get() ); - rFrame->setComponent( xController->getComponentWindow(), xController.get() ); - xController->attachFrame( rFrame ); - xModel->setCurrentController( xController.get() ); + // introduce model/view/controller to each other + utl::ConnectFrameControllerModel(rFrame, xController, xModel); bSuccess = true; } @@ -474,7 +471,7 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU { NamedDatabaseObject aSelection; aSelection.Type = nInitialSelection; - xDocView->select( makeAny( aSelection ) ); + xDocView->select( Any( aSelection ) ); } } @@ -512,9 +509,9 @@ IMPL_LINK_NOARG( DBContentLoader, OnStartTableWizard, void*, void ) {"DatabaseLocation", Any(m_sCurrentURL)} })); SolarMutexGuard aGuard; - Reference< XJobExecutor > xTableWizard( m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.wizards.table.CallTableWizard", aWizArgs, m_aContext), UNO_QUERY); + Reference< XJobExecutor > xTableWizard( m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext(u"com.sun.star.wizards.table.CallTableWizard"_ustr, aWizArgs, m_aContext), UNO_QUERY); if ( xTableWizard.is() ) - xTableWizard->trigger("start"); + xTableWizard->trigger(u"start"_ustr); } catch(const Exception&) { diff --git a/dbaccess/source/filter/xml/xmlAutoStyle.cxx b/dbaccess/source/filter/xml/xmlAutoStyle.cxx index 99101567111a..82bcab3620ea 100644 --- a/dbaccess/source/filter/xml/xmlAutoStyle.cxx +++ b/dbaccess/source/filter/xml/xmlAutoStyle.cxx @@ -24,10 +24,9 @@ namespace dbaxml { using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::xml::sax; void OXMLAutoStylePoolP::exportStyleAttributes( - SvXMLAttributeList& rAttrList, + comphelper::AttributeList& rAttrList, XmlStyleFamily nFamily, const std::vector< XMLPropertyState >& rProperties, const SvXMLExportPropertyMapper& rPropExp diff --git a/dbaccess/source/filter/xml/xmlAutoStyle.hxx b/dbaccess/source/filter/xml/xmlAutoStyle.hxx index 54748a22c307..d358b50f7230 100644 --- a/dbaccess/source/filter/xml/xmlAutoStyle.hxx +++ b/dbaccess/source/filter/xml/xmlAutoStyle.hxx @@ -28,7 +28,7 @@ namespace dbaxml ODBExport& rODBExport; virtual void exportStyleAttributes( - SvXMLAttributeList& rAttrList, + comphelper::AttributeList& rAttrList, XmlStyleFamily nFamily, const std::vector< XMLPropertyState >& rProperties, const SvXMLExportPropertyMapper& rPropExp, diff --git a/dbaccess/source/filter/xml/xmlColumn.cxx b/dbaccess/source/filter/xml/xmlColumn.cxx index 198a92f76fa4..1afbf9f0f419 100644 --- a/dbaccess/source/filter/xml/xmlColumn.cxx +++ b/dbaccess/source/filter/xml/xmlColumn.cxx @@ -25,7 +25,6 @@ #include <com/sun/star/sdbcx/XAppend.hpp> #include "xmlStyleImport.hxx" #include <osl/diagnose.h> -#include <sal/log.hxx> namespace dbaxml { @@ -95,10 +94,10 @@ void OXMLColumn::endFastElement(sal_Int32 ) Reference<XPropertySet> xProp(xFac->createDataDescriptor()); if ( xProp.is() ) { - xProp->setPropertyValue(PROPERTY_NAME,makeAny(m_sName)); - xProp->setPropertyValue(PROPERTY_HIDDEN,makeAny(m_bHidden)); + xProp->setPropertyValue(PROPERTY_NAME,Any(m_sName)); + xProp->setPropertyValue(PROPERTY_HIDDEN,Any(m_bHidden)); if ( !m_sHelpMessage.isEmpty() ) - xProp->setPropertyValue(PROPERTY_HELPTEXT,makeAny(m_sHelpMessage)); + xProp->setPropertyValue(PROPERTY_HELPTEXT,Any(m_sHelpMessage)); if ( m_aDefaultValue.hasValue() ) xProp->setPropertyValue(PROPERTY_CONTROLDEFAULT,m_aDefaultValue); diff --git a/dbaccess/source/filter/xml/xmlComponent.cxx b/dbaccess/source/filter/xml/xmlComponent.cxx index a9ba7a708842..8f219e4d9eae 100644 --- a/dbaccess/source/filter/xml/xmlComponent.cxx +++ b/dbaccess/source/filter/xml/xmlComponent.cxx @@ -24,13 +24,12 @@ #include <strings.hxx> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <comphelper/propertysequence.hxx> namespace dbaxml { using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::xml::sax; @@ -81,7 +80,7 @@ OXMLComponent::OXMLComponent( ODBFilter& rImport Reference< XMultiServiceFactory > xORB( _xParentContainer, UNO_QUERY_THROW ); Reference< XInterface > xComponent( xORB->createInstanceWithArguments( _sComponentServiceName, aArguments ) ); Reference< XNameContainer > xNameContainer( _xParentContainer, UNO_QUERY_THROW ); - xNameContainer->insertByName( sName, makeAny( xComponent ) ); + xNameContainer->insertByName( sName, Any( xComponent ) ); } catch(Exception&) { diff --git a/dbaccess/source/filter/xml/xmlConnectionResource.cxx b/dbaccess/source/filter/xml/xmlConnectionResource.cxx index e5d92a8d0a8e..6e4a006be25b 100644 --- a/dbaccess/source/filter/xml/xmlConnectionResource.cxx +++ b/dbaccess/source/filter/xml/xmlConnectionResource.cxx @@ -22,7 +22,7 @@ #include <xmloff/xmltoken.hxx> #include <xmloff/xmlnamespace.hxx> #include <strings.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace dbaxml { @@ -50,7 +50,7 @@ OXMLConnectionResource::OXMLConnectionResource( ODBFilter& rImport, case XML_ELEMENT(XLINK, XML_HREF): try { - xDataSource->setPropertyValue(PROPERTY_URL,makeAny(aIter.toString())); + xDataSource->setPropertyValue(PROPERTY_URL,Any(aIter.toString())); } catch(const Exception&) { diff --git a/dbaccess/source/filter/xml/xmlDataSource.cxx b/dbaccess/source/filter/xml/xmlDataSource.cxx index e133d09cbc29..9939a197b1aa 100644 --- a/dbaccess/source/filter/xml/xmlDataSource.cxx +++ b/dbaccess/source/filter/xml/xmlDataSource.cxx @@ -27,7 +27,7 @@ #include <xmloff/ProgressBarHelper.hxx> #include "xmlEnums.hxx" #include <strings.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include "xmlConnectionData.hxx" namespace dbaxml @@ -61,7 +61,7 @@ OXMLDataSource::OXMLDataSource( ODBFilter& rImport, case XML_CONNECTION_RESOURCE: try { - xDataSource->setPropertyValue(PROPERTY_URL,makeAny(aIter.toString())); + xDataSource->setPropertyValue(PROPERTY_URL,Any(aIter.toString())); } catch(const Exception&) { @@ -71,7 +71,7 @@ OXMLDataSource::OXMLDataSource( ODBFilter& rImport, case XML_SUPPRESS_VERSION_COLUMNS: try { - xDataSource->setPropertyValue(PROPERTY_SUPPRESSVERSIONCL,makeAny(IsXMLToken(aIter, XML_TRUE))); + xDataSource->setPropertyValue(PROPERTY_SUPPRESSVERSIONCL,Any(IsXMLToken(aIter, XML_TRUE))); bFoundSuppressVersionColumns = true; } catch(const Exception&) @@ -180,7 +180,7 @@ OXMLDataSource::OXMLDataSource( ODBFilter& rImport, { try { - xDataSource->setPropertyValue(PROPERTY_SUPPRESSVERSIONCL,makeAny(true)); + xDataSource->setPropertyValue(PROPERTY_SUPPRESSVERSIONCL,Any(true)); } catch(const Exception&) { diff --git a/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx b/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx index e7362ca5ba77..c1400970181a 100644 --- a/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx +++ b/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx @@ -22,7 +22,6 @@ #include <xmloff/xmltoken.hxx> #include <strings.hxx> #include <com/sun/star/beans/PropertyValue.hpp> -#include <sal/log.hxx> namespace dbaxml { @@ -92,20 +91,20 @@ OXMLDataSourceInfo::OXMLDataSourceInfo( ODBFilter& rImport if ( !bFoundField ) { aProperty.Name = INFO_FIELDDELIMITER; - aProperty.Value <<= OUString(";"); + aProperty.Value <<= u";"_ustr; rImport.addInfo(aProperty); } if ( !bFoundThousand ) { aProperty.Name = INFO_THOUSANDSDELIMITER; - aProperty.Value <<= OUString(","); + aProperty.Value <<= u","_ustr; rImport.addInfo(aProperty); } } if ( (nElement & TOKEN_MASK) == XML_FONT_CHARSET && !bFoundCharset ) { aProperty.Name = INFO_CHARSET; - aProperty.Value <<= OUString("utf8"); + aProperty.Value <<= u"utf8"_ustr; rImport.addInfo(aProperty); } } diff --git a/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx b/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx index 525162664865..9402bb399dca 100644 --- a/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx +++ b/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx @@ -55,7 +55,7 @@ OXMLDataSourceSetting::OXMLDataSourceSetting( ODBFilter& rImport case XML_DATA_SOURCE_SETTING_TYPE: { // needs to be translated into a css::uno::Type - static std::map< OUString, css::uno::Type > s_aTypeNameMap = [&]() + static std::map< OUString, css::uno::Type > s_aTypeNameMap = []() { std::map< OUString, css::uno::Type > tmp; tmp[GetXMLToken( XML_BOOLEAN)] = cppu::UnoType<bool>::get(); @@ -143,7 +143,7 @@ void OXMLDataSourceSetting::addValue(const OUString& _sValue) { sal_Int32 nPos = m_aInfoSequence.getLength(); m_aInfoSequence.realloc(nPos+1); - m_aInfoSequence[nPos] = aValue; + m_aInfoSequence.getArray()[nPos] = aValue; } } diff --git a/dbaccess/source/filter/xml/xmlDocuments.cxx b/dbaccess/source/filter/xml/xmlDocuments.cxx index 71d5b4589e3a..80834d353735 100644 --- a/dbaccess/source/filter/xml/xmlDocuments.cxx +++ b/dbaccess/source/filter/xml/xmlDocuments.cxx @@ -19,6 +19,7 @@ #include "xmlDocuments.hxx" #include "xmlfilter.hxx" +#include <utility> #include <xmloff/xmltoken.hxx> #include <xmloff/ProgressBarHelper.hxx> #include "xmlQuery.hxx" @@ -35,23 +36,23 @@ namespace dbaxml OXMLDocuments::OXMLDocuments( ODBFilter& rImport ,const Reference< XNameAccess >& _xContainer - ,const OUString& _sCollectionServiceName - ,const OUString& _sComponentServiceName) : + ,OUString _sCollectionServiceName + ,OUString _sComponentServiceName) : SvXMLImportContext( rImport ) ,m_xContainer(_xContainer) - ,m_sCollectionServiceName(_sCollectionServiceName) - ,m_sComponentServiceName(_sComponentServiceName) + ,m_sCollectionServiceName(std::move(_sCollectionServiceName)) + ,m_sComponentServiceName(std::move(_sComponentServiceName)) { } OXMLDocuments::OXMLDocuments( ODBFilter& rImport ,const Reference< XNameAccess >& _xContainer - ,const OUString& _sCollectionServiceName + ,OUString _sCollectionServiceName ) : SvXMLImportContext( rImport ) ,m_xContainer(_xContainer) - ,m_sCollectionServiceName(_sCollectionServiceName) + ,m_sCollectionServiceName(std::move(_sCollectionServiceName)) { } @@ -70,7 +71,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLDocuments::createF case XML_TABLE: case XML_TABLE_REPRESENTATION: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLTable( GetOwnImport(), xAttrList, m_xContainer, "com.sun.star.sdb.TableDefinition"); + pContext = new OXMLTable( GetOwnImport(), xAttrList, m_xContainer, u"com.sun.star.sdb.TableDefinition"_ustr); break; case XML_QUERY: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); diff --git a/dbaccess/source/filter/xml/xmlDocuments.hxx b/dbaccess/source/filter/xml/xmlDocuments.hxx index c0542dcfb1a3..49c6346aa83e 100644 --- a/dbaccess/source/filter/xml/xmlDocuments.hxx +++ b/dbaccess/source/filter/xml/xmlDocuments.hxx @@ -37,13 +37,13 @@ namespace dbaxml // for forms and reports OXMLDocuments( ODBFilter& rImport ,const css::uno::Reference< css::container::XNameAccess >& _xContainer - ,const OUString& _sCollectionServiceName - ,const OUString& _sComponentServiceName); + ,OUString _sCollectionServiceName + ,OUString _sComponentServiceName); // for queries OXMLDocuments( ODBFilter& rImport ,const css::uno::Reference< css::container::XNameAccess >& _xContainer - ,const OUString& _sCollectionServiceName = OUString() + ,OUString _sCollectionServiceName = OUString() ); virtual ~OXMLDocuments() override; diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx index 4bf8a063afed..fc3e2228fd5a 100644 --- a/dbaccess/source/filter/xml/xmlExport.cxx +++ b/dbaccess/source/filter/xml/xmlExport.cxx @@ -20,6 +20,7 @@ #include "xmlExport.hxx" #include "xmlAutoStyle.hxx" #include <sax/tools/converter.hxx> +#include <utility> #include <xmloff/xmltoken.hxx> #include <xmloff/xmlnamespace.hxx> #include <xmloff/namespacemap.hxx> @@ -44,7 +45,7 @@ #include <com/sun/star/awt/FontDescriptor.hpp> #include <svl/filenotation.hxx> #include <unotools/pathoptions.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <connectivity/DriversConfig.hxx> #include <connectivity/dbtools.hxx> @@ -62,7 +63,7 @@ com_sun_star_comp_sdb_DBExportFilter_get_implementation( css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { return cppu::acquire(new ::dbaxml::ODBExport(context, - "com.sun.star.comp.sdb.DBExportFilter")); + u"com.sun.star.comp.sdb.DBExportFilter"_ustr)); } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* @@ -70,7 +71,7 @@ com_sun_star_comp_sdb_XMLSettingsExporter_get_implementation( css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { return cppu::acquire(new ::dbaxml::ODBExport(context, - "com.sun.star.comp.sdb.XMLSettingsExporter", + u"com.sun.star.comp.sdb.XMLSettingsExporter"_ustr, SvXMLExportFlags::SETTINGS | SvXMLExportFlags::PRETTY )); } @@ -79,7 +80,7 @@ com_sun_star_comp_sdb_XMLFullExporter_get_implementation( css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { return cppu::acquire(new ::dbaxml::ODBExport(context, - "com.sun.star.comp.sdb.XMLFullExporter", + u"com.sun.star.comp.sdb.XMLFullExporter"_ustr, SvXMLExportFlags::ALL)); } @@ -94,24 +95,24 @@ namespace dbaxml switch (_rType.getTypeClass()) { case TypeClass_STRING: - return "string"; + return u"string"_ustr; case TypeClass_DOUBLE: - return "double"; + return u"double"_ustr; case TypeClass_BOOLEAN: - return "boolean"; + return u"boolean"_ustr; case TypeClass_BYTE: case TypeClass_SHORT: - return "short"; + return u"short"_ustr; case TypeClass_LONG: - return "int"; + return u"int"_ustr; case TypeClass_HYPER: - return "long"; + return u"long"_ustr; case TypeClass_ENUM: - return "int"; + return u"int"_ustr; default: OSL_FAIL( "lcl_implGetPropertyXMLType: unsupported value type!" ); - return "double"; + return u"double"_ustr; } } @@ -126,7 +127,7 @@ namespace dbaxml /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_EXPORT flag set */ virtual void handleSpecialItem( - SvXMLAttributeList& /*rAttrList*/, + comphelper::AttributeList& /*rAttrList*/, const XMLPropertyState& /*rProperty*/, const SvXMLUnitConverter& /*rUnitConverter*/, const SvXMLNamespaceMap& /*rNamespaceMap*/, @@ -182,27 +183,27 @@ ODBExport::ODBExport(const Reference< XComponentContext >& _rxContext, OUString GetAutoStylePool()->AddFamily( XmlStyleFamily::TABLE_TABLE, - OUString(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME ), + XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME, m_xExportHelper.get(), - OUString(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX )); + XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX); GetAutoStylePool()->AddFamily( XmlStyleFamily::TABLE_COLUMN, - OUString(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME ), + XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME, m_xColumnExportHelper.get(), - OUString(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX )); + XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX); GetAutoStylePool()->AddFamily( XmlStyleFamily::TABLE_CELL, - OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME ), + XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME, m_xCellExportHelper.get(), - OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX )); + XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX); GetAutoStylePool()->AddFamily( XmlStyleFamily::TABLE_ROW, - OUString(XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME ), + XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME, m_xRowExportHelper.get(), - OUString(XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX )); + XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX); } void ODBExport::exportDataSource() @@ -244,13 +245,10 @@ void ODBExport::exportDataSource() { } - Sequence< Property > aProperties = xSettingsInfo->getProperties(); - const Property* pProperties = aProperties.getConstArray(); - const Property* pPropertiesEnd = pProperties + aProperties.getLength(); - for ( ; pProperties != pPropertiesEnd; ++pProperties ) + for (auto& property : xSettingsInfo->getProperties()) { OUString sValue; - Any aValue = xDataSourceSettings->getPropertyValue( pProperties->Name ); + Any aValue = xDataSourceSettings->getPropertyValue(property.Name); switch ( aValue.getValueTypeClass() ) { case TypeClass_STRING: @@ -281,15 +279,15 @@ void ODBExport::exportDataSource() const XMLTokenEnum eAttributeToken; const ::std::optional< OUString > aXMLDefault; - PropertyMap( const OUString& _rPropertyName, const XMLTokenEnum _eToken ) - :sPropertyName( _rPropertyName ) + PropertyMap( OUString _sPropertyName, const XMLTokenEnum _eToken ) + :sPropertyName(std::move( _sPropertyName )) ,eAttributeToken( _eToken ) ,aXMLDefault() { } - PropertyMap( const OUString& _rPropertyName, const XMLTokenEnum _eToken, const OUString& _rDefault ) - :sPropertyName( _rPropertyName ) + PropertyMap( OUString _sPropertyName, const XMLTokenEnum _eToken, const OUString& _rDefault ) + :sPropertyName(std::move( _sPropertyName )) ,eAttributeToken( _eToken ) ,aXMLDefault( _rDefault ) { @@ -314,7 +312,7 @@ void ODBExport::exportDataSource() bool bIsXMLDefault = false; for (const auto & aToken : aTokens) { - if ( pProperties->Name == aToken.sPropertyName ) + if (property.Name == aToken.sPropertyName) { eToken = aToken.eAttributeToken; @@ -336,15 +334,15 @@ void ODBExport::exportDataSource() { // for properties which are not REMOVABLE, we care for their state, and // only export them if they're not DEFAULTed - if ( ( pProperties->Attributes & PropertyAttribute::REMOVABLE ) == 0 ) + if ((property.Attributes & PropertyAttribute::REMOVABLE) == 0) { - PropertyState ePropertyState = xSettingsState->getPropertyState( pProperties->Name ); + PropertyState ePropertyState = xSettingsState->getPropertyState(property.Name); if ( PropertyState_DEFAULT_VALUE == ePropertyState ) continue; } // special handlings - if ( pProperties->Name == PROPERTY_BOOLEANCOMPARISONMODE ) + if (property.Name == PROPERTY_BOOLEANCOMPARISONMODE) { if ( sValue == "0" ) sValue = "equal-integer"; @@ -358,56 +356,55 @@ void ODBExport::exportDataSource() continue; eToken = XML_BOOLEAN_COMPARISON_MODE; } - else if ( pProperties->Name == INFO_AUTORETRIEVEENABLED ) + else if (property.Name == INFO_AUTORETRIEVEENABLED) { aValue >>= bAutoIncrementEnabled; continue; } - else if ( pProperties->Name == INFO_AUTORETRIEVEVALUE ) + else if (property.Name == INFO_AUTORETRIEVEVALUE) { aAutoIncrement.first = sValue; continue; } - else if ( pProperties->Name == PROPERTY_AUTOINCREMENTCREATION ) + else if (property.Name == PROPERTY_AUTOINCREMENTCREATION) { aAutoIncrement.second = sValue; continue; } - else if ( pProperties->Name == INFO_TEXTDELIMITER ) + else if (property.Name == INFO_TEXTDELIMITER) { aDelimiter.sText = sValue; aDelimiter.bUsed = true; continue; } - else if ( pProperties->Name == INFO_FIELDDELIMITER ) + else if (property.Name == INFO_FIELDDELIMITER) { aDelimiter.sField = sValue; aDelimiter.bUsed = true; continue; } - else if ( pProperties->Name == INFO_DECIMALDELIMITER ) + else if (property.Name == INFO_DECIMALDELIMITER) { aDelimiter.sDecimal = sValue; aDelimiter.bUsed = true; continue; } - else if ( pProperties->Name == INFO_THOUSANDSDELIMITER ) + else if (property.Name == INFO_THOUSANDSDELIMITER) { aDelimiter.sThousand = sValue; aDelimiter.bUsed = true; continue; } - else if ( pProperties->Name == INFO_CHARSET ) + else if (property.Name == INFO_CHARSET) { m_sCharSet = sValue; continue; } else { - if ( !aDriverSupportedProperties.has(pProperties->Name) || aDriverSupportedProperties.get(pProperties->Name) != aValue ) + if ( !aDriverSupportedProperties.has(property.Name) || aDriverSupportedProperties.get(property.Name) != aValue ) { - m_aDataSourceSettings.emplace_back( - pProperties->Name, pProperties->Type, aValue ); + m_aDataSourceSettings.emplace_back(property.Name, property.Type, aValue); } continue; } @@ -416,7 +413,7 @@ void ODBExport::exportDataSource() aSettingsMap.emplace(eToken,sValue); } if ( bAutoIncrementEnabled && !(aAutoIncrement.first.isEmpty() && aAutoIncrement.second.isEmpty()) ) - m_aAutoIncrement.reset( new TStringPair(aAutoIncrement)); + m_oAutoIncrement = aAutoIncrement; if ( aDelimiter.bUsed ) m_aDelimiter.reset( new TDelimiter( aDelimiter ) ); @@ -560,7 +557,7 @@ void ODBExport::exportConnectionData() Reference< XPropertySetInfo > xSettingsInfo( xDataSourceSettings->getPropertySetInfo(), UNO_SET_THROW ); - const OUString sPropertyName = "LocalSocket"; + static constexpr OUString sPropertyName = u"LocalSocket"_ustr; if ( xSettingsInfo->hasPropertyByName( sPropertyName ) ) { OUString sPropertyValue; @@ -595,7 +592,7 @@ template< typename T > void ODBExport::exportDataSourceSettingsSequence( css::uno::Sequence<T> anySeq; bool bSuccess = in->Value >>= anySeq; assert(bSuccess); (void)bSuccess; - for (T const & i : anySeq ) + for (T const& i : anySeq) { SvXMLElementExport aDataValue(*this,XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_VALUE, true, false); // (no whitespace inside the tag) @@ -698,10 +695,10 @@ void ODBExport::exportDelimiter() void ODBExport::exportAutoIncrement() { - if (m_aAutoIncrement) + if (m_oAutoIncrement) { - AddAttribute(XML_NAMESPACE_DB, XML_ADDITIONAL_COLUMN_STATEMENT,m_aAutoIncrement->second); - AddAttribute(XML_NAMESPACE_DB, XML_ROW_RETRIEVING_STATEMENT,m_aAutoIncrement->first); + AddAttribute(XML_NAMESPACE_DB, XML_ADDITIONAL_COLUMN_STATEMENT,m_oAutoIncrement->second); + AddAttribute(XML_NAMESPACE_DB, XML_ROW_RETRIEVING_STATEMENT,m_oAutoIncrement->first); SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_AUTO_INCREMENT, true, true); } } @@ -714,12 +711,10 @@ void ODBExport::exportSequence(const Sequence< OUString>& _aValue { SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, _eTokenFilter, true, true); - const OUString* pIter = _aValue.getConstArray(); - const OUString* pEnd = pIter + _aValue.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& string : _aValue) { SvXMLElementExport aDataSource(*this,XML_NAMESPACE_DB, _eTokenType, true, false); - Characters(*pIter); + Characters(string); } } } @@ -755,14 +750,11 @@ void ODBExport::exportCollection(const Reference< XNameAccess >& _xCollection std::unique_ptr<SvXMLElementExport> pComponents; if ( _bExportContext ) pComponents.reset( new SvXMLElementExport(*this,XML_NAMESPACE_DB, _eComponents, true, true)); - Sequence< OUString> aSeq = _xCollection->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& name : _xCollection->getElementNames()) { - Reference<XPropertySet> xProp(_xCollection->getByName(*pIter),UNO_QUERY); + Reference<XPropertySet> xProp(_xCollection->getByName(name), UNO_QUERY); if ( _bExportContext && XML_TABLE_REPRESENTATIONS != _eComponents ) - AddAttribute(XML_NAMESPACE_DB, XML_NAME,*pIter); + AddAttribute(XML_NAMESPACE_DB, XML_NAME, name); Reference< XNameAccess > xSub(xProp,UNO_QUERY); if ( xSub.is() ) { @@ -778,7 +770,7 @@ void ODBExport::exportComponent(XPropertySet* _xProp) OUString sValue; _xProp->getPropertyValue(PROPERTY_PERSISTENT_NAME) >>= sValue; bool bIsForm = true; - _xProp->getPropertyValue("IsForm") >>= bIsForm; + _xProp->getPropertyValue(u"IsForm"_ustr) >>= bIsForm; if ( bIsForm ) sValue = "forms/" + sValue; else @@ -839,7 +831,7 @@ void ODBExport::exportTable(XPropertySet* _xProp) exportFilter(_xProp,PROPERTY_ORDER,XML_ORDER_STATEMENT); } -void ODBExport::exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt) +void ODBExport::exportStyleName(XPropertySet* _xProp,comphelper::AttributeList& _rAtt) { Reference<XPropertySet> xFind(_xProp); exportStyleName(XML_STYLE_NAME,xFind,_rAtt,m_aAutoStyleNames); @@ -847,7 +839,7 @@ void ODBExport::exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt) exportStyleName(XML_DEFAULT_ROW_STYLE_NAME,xFind,_rAtt,m_aRowAutoStyleNames); } -void ODBExport::exportStyleName(const ::xmloff::token::XMLTokenEnum _eToken,const uno::Reference<beans::XPropertySet>& _xProp,SvXMLAttributeList& _rAtt,TPropertyStyleMap& _rMap) +void ODBExport::exportStyleName(const ::xmloff::token::XMLTokenEnum _eToken,const uno::Reference<beans::XPropertySet>& _xProp,comphelper::AttributeList& _rAtt,TPropertyStyleMap& _rMap) { TPropertyStyleMap::const_iterator aFind = _rMap.find(_xProp); if ( aFind != _rMap.end() ) @@ -861,15 +853,15 @@ void ODBExport::exportStyleName(const ::xmloff::token::XMLTokenEnum _eToken,cons void ODBExport::exportTableName(XPropertySet* _xProp,bool _bUpdate) { OUString sValue; - _xProp->getPropertyValue(_bUpdate ? OUString(PROPERTY_UPDATE_TABLENAME) : OUString(PROPERTY_NAME)) >>= sValue; + _xProp->getPropertyValue(_bUpdate ? PROPERTY_UPDATE_TABLENAME : PROPERTY_NAME) >>= sValue; if ( sValue.isEmpty() ) return; AddAttribute(XML_NAMESPACE_DB, XML_NAME,sValue); - _xProp->getPropertyValue(_bUpdate ? OUString(PROPERTY_UPDATE_SCHEMANAME) : OUString(PROPERTY_SCHEMANAME)) >>= sValue; + _xProp->getPropertyValue(_bUpdate ? PROPERTY_UPDATE_SCHEMANAME : PROPERTY_SCHEMANAME) >>= sValue; if ( !sValue.isEmpty() ) AddAttribute(XML_NAMESPACE_DB, XML_SCHEMA_NAME,sValue); - _xProp->getPropertyValue(_bUpdate ? OUString(PROPERTY_UPDATE_CATALOGNAME) : OUString(PROPERTY_CATALOGNAME)) >>= sValue; + _xProp->getPropertyValue(_bUpdate ? PROPERTY_UPDATE_CATALOGNAME : PROPERTY_CATALOGNAME) >>= sValue; if ( !sValue.isEmpty() ) AddAttribute(XML_NAMESPACE_DB, XML_CATALOG_NAME,sValue); @@ -910,10 +902,9 @@ void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup) if ( aFind != m_aTableDummyColumns.end() ) { SvXMLElementExport aColumns(*this,XML_NAMESPACE_DB, XML_COLUMNS, true, true); - SvXMLAttributeList* pAtt = new SvXMLAttributeList; - Reference<XAttributeList> xAtt = pAtt; + rtl::Reference<comphelper::AttributeList> pAtt = new comphelper::AttributeList; exportStyleName(aFind->second.get(),*pAtt); - AddAttributeList(xAtt); + AddAttributeList(pAtt); SvXMLElementExport aColumn(*this,XML_NAMESPACE_DB, XML_COLUMN, true, true); } @@ -921,16 +912,12 @@ void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup) } SvXMLElementExport aColumns(*this,XML_NAMESPACE_DB, XML_COLUMNS, true, true); - Sequence< OUString> aSeq = xNameAccess->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for( ; pIter != pEnd ; ++pIter) + for (auto& name : xNameAccess->getElementNames()) { - Reference<XPropertySet> xProp(xNameAccess->getByName(*pIter),UNO_QUERY); + Reference<XPropertySet> xProp(xNameAccess->getByName(name), UNO_QUERY); if ( xProp.is() ) { - SvXMLAttributeList* pAtt = new SvXMLAttributeList; - Reference<XAttributeList> xAtt = pAtt; + rtl::Reference<comphelper::AttributeList> pAtt = new comphelper::AttributeList; exportStyleName(xProp.get(),*pAtt); bool bHidden = getBOOL(xProp->getPropertyValue(PROPERTY_HIDDEN)); @@ -941,7 +928,7 @@ void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup) if ( bHidden || !sValue.isEmpty() || aColumnDefault.hasValue() || pAtt->getLength() ) { - AddAttribute(XML_NAMESPACE_DB, XML_NAME,*pIter); + AddAttribute(XML_NAMESPACE_DB, XML_NAME, name); if ( bHidden ) AddAttribute(XML_NAMESPACE_DB, XML_VISIBLE,XML_FALSE); @@ -958,7 +945,7 @@ void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup) } if ( pAtt->getLength() ) - AddAttributeList(xAtt); + AddAttributeList(pAtt); } if ( GetAttrList().getLength() ) @@ -1073,12 +1060,11 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp) ,TExportPropMapperPair(m_xRowExportHelper,TEnumMapperPair(&m_aRowAutoStyleNames,XmlStyleFamily::TABLE_ROW)) }; - std::vector< XMLPropertyState > aPropertyStates; for (const auto & i : pExportHelper) { - aPropertyStates = i.first->Filter(_xProp); + std::vector< XMLPropertyState > aPropertyStates = i.first->Filter(*this, _xProp); if ( !aPropertyStates.empty() ) - i.second.first->emplace( _xProp,GetAutoStylePool()->Add( i.second.second, aPropertyStates ) ); + i.second.first->emplace( _xProp,GetAutoStylePool()->Add( i.second.second, std::move(aPropertyStates) ) ); } Reference< XNameAccess > xCollection; @@ -1090,7 +1076,7 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp) GetFontAutoStylePool()->Add(aFont.Name,aFont.StyleName,static_cast<FontFamily>(aFont.Family), static_cast<FontPitch>(aFont.Pitch),aFont.CharSet ); - m_aCurrentPropertyStates = m_xCellExportHelper->Filter(_xProp); + m_aCurrentPropertyStates = m_xCellExportHelper->Filter(*this, _xProp); if ( !m_aCurrentPropertyStates.empty() && !xCollection->hasElements() ) { Reference< XDataDescriptorFactory> xFac(xCollection,UNO_QUERY); @@ -1121,7 +1107,7 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp) }; for (const auto & i : pExportHelper) { - std::vector< XMLPropertyState > aPropStates = i.first->Filter( _xProp ); + std::vector< XMLPropertyState > aPropStates = i.first->Filter(*this, _xProp); if ( !aPropStates.empty() ) { const rtl::Reference < XMLPropertySetMapper >& pStyle = i.first->getPropertySetMapper(); @@ -1150,7 +1136,7 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp) if ( XmlStyleFamily::TABLE_CELL == i.second.second ) aPropStates.insert( aPropStates.end(), m_aCurrentPropertyStates.begin(), m_aCurrentPropertyStates.end() ); if ( !aPropStates.empty() ) - i.second.first->emplace( _xProp,GetAutoStylePool()->Add( i.second.second, aPropStates ) ); + i.second.first->emplace( _xProp,GetAutoStylePool()->Add( i.second.second, std::move(aPropStates) ) ); } } } @@ -1195,24 +1181,23 @@ void ODBExport::GetViewSettings(Sequence<PropertyValue>& aProps) try { - sal_Int32 nLength = aProps.getLength(); - aProps.realloc(nLength + 1); - aProps[nLength].Name = "Queries"; Sequence< OUString> aSeq = xCollection->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - Sequence<PropertyValue> aQueries(aSeq.getLength()); - for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i) + auto aQueriesRange = asNonConstRange(aQueries); + for (sal_Int32 i = 0; i < aSeq.getLength(); ++i) { - Reference<XPropertySet> xProp(xCollection->getByName(*pIter),UNO_QUERY); + Reference<XPropertySet> xProp(xCollection->getByName(aSeq[i]), UNO_QUERY); if ( xProp.is() ) { - aQueries[i].Name = *pIter; - aQueries[i].Value = xProp->getPropertyValue(PROPERTY_LAYOUTINFORMATION); + aQueriesRange[i].Name = aSeq[i]; + aQueriesRange[i].Value = xProp->getPropertyValue(PROPERTY_LAYOUTINFORMATION); } } - aProps[nLength].Value <<= aQueries; + sal_Int32 nLength = aProps.getLength(); + aProps.realloc(nLength + 1); + auto& prop = asNonConstRange(aProps)[nLength]; + prop.Name = "Queries"; + prop.Value <<= aQueries; } catch(const Exception&) { @@ -1236,8 +1221,9 @@ void ODBExport::GetConfigurationSettings(Sequence<PropertyValue>& aProps) if ( aPropValues.hasElements() ) { aProps.realloc(nLength + 1); - aProps[nLength].Name = "layout-settings"; - aProps[nLength].Value = aValue; + auto pProps = aProps.getArray(); + pProps[nLength].Name = "layout-settings"; + pProps[nLength].Value = aValue; } } catch(const Exception&) diff --git a/dbaccess/source/filter/xml/xmlExport.hxx b/dbaccess/source/filter/xml/xmlExport.hxx index 7e1d148e197c..fa808eaf6378 100644 --- a/dbaccess/source/filter/xml/xmlExport.hxx +++ b/dbaccess/source/filter/xml/xmlExport.hxx @@ -25,6 +25,9 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> + +#include <optional> +#include <utility> #include <xmloff/maptype.hxx> #include <xmloff/txtprmap.hxx> #include <xmloff/xmlexp.hxx> @@ -43,11 +46,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::document; using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::io; -using namespace ::com::sun::star::xml::sax; class ODBExport : public SvXMLExport @@ -74,15 +73,15 @@ class ODBExport : public SvXMLExport css::uno::Type Type; css::uno::Any Value; - TypedPropertyValue( const OUString& _name, const css::uno::Type& _type, const css::uno::Any& _value ) - :Name( _name ) + TypedPropertyValue( OUString _name, const css::uno::Type& _type, css::uno::Any _value ) + :Name(std::move( _name )) ,Type( _type ) - ,Value( _value ) + ,Value(std::move( _value )) { } }; - std::unique_ptr< TStringPair > m_aAutoIncrement; + std::optional< TStringPair > m_oAutoIncrement; std::unique_ptr< TDelimiter > m_aDelimiter; std::vector< TypedPropertyValue > m_aDataSourceSettings; std::vector< XMLPropertyState > m_aCurrentPropertyStates; @@ -122,8 +121,8 @@ class ODBExport : public SvXMLExport void exportReports(); void exportQueries(bool _bExportContext); void exportTables(bool _bExportContext); - void exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt); - void exportStyleName(const ::xmloff::token::XMLTokenEnum _eToken,const Reference<XPropertySet>& _xProp,SvXMLAttributeList& _rAtt,TPropertyStyleMap& _rMap); + void exportStyleName(XPropertySet* _xProp,comphelper::AttributeList& _rAtt); + void exportStyleName(const ::xmloff::token::XMLTokenEnum _eToken,const Reference<XPropertySet>& _xProp,comphelper::AttributeList& _rAtt,TPropertyStyleMap& _rMap); void exportCollection(const Reference< XNameAccess >& _xCollection ,enum ::xmloff::token::XMLTokenEnum _eComponents ,enum ::xmloff::token::XMLTokenEnum _eSubComponents diff --git a/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx b/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx index 0ee1445a8699..c54acdd6527f 100644 --- a/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx +++ b/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx @@ -22,7 +22,7 @@ #include <xmloff/xmltoken.hxx> #include <xmloff/xmlnamespace.hxx> #include <strings.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <svl/filenotation.hxx> #include <unotools/pathoptions.hxx> #include <dsntypes.hxx> @@ -95,7 +95,7 @@ OXMLFileBasedDatabase::OXMLFileBasedDatabase( ODBFilter& rImport, OUString sURL = aTypeCollection.getDatasourcePrefixFromMediaType(sMediaType,sFileTypeExtension) + sLocation; try { - xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sURL)); + xDataSource->setPropertyValue(PROPERTY_URL,Any(sURL)); } catch(const Exception&) { diff --git a/dbaccess/source/filter/xml/xmlHelper.cxx b/dbaccess/source/filter/xml/xmlHelper.cxx index 38e90e4e9d3a..5386a4036843 100644 --- a/dbaccess/source/filter/xml/xmlHelper.cxx +++ b/dbaccess/source/filter/xml/xmlHelper.cxx @@ -32,7 +32,6 @@ namespace dbaxml { using namespace ::xmloff::token; - using namespace ::com::sun::star::awt; OPropertyHandlerFactory::OPropertyHandlerFactory() { @@ -68,12 +67,11 @@ const XMLPropertyHandler* OPropertyHandlerFactory::GetPropertyHandler(sal_Int32 return pHandler; } -#define MAP_END() { nullptr, 0, 0, XML_TOKEN_INVALID, 0 , 0, SvtSaveOptions::ODFSVER_010, false} rtl::Reference < XMLPropertySetMapper > OXMLHelper::GetTableStylesPropertySetMapper( bool bForExport ) { static const XMLPropertyMapEntry s_aTableStylesProperties[] = { - MAP_END() + { nullptr } }; rtl::Reference < XMLPropertyHandlerFactory> xFac = new ::xmloff::OControlPropertyHandlerFactory(); return new XMLPropertySetMapper(s_aTableStylesProperties, xFac, bForExport); @@ -81,13 +79,14 @@ rtl::Reference < XMLPropertySetMapper > OXMLHelper::GetTableStylesPropertySetMap rtl::Reference < XMLPropertySetMapper > OXMLHelper::GetColumnStylesPropertySetMapper( bool bForExport ) { -#define MAP_CONST_COLUMN( name, prefix, token, type, context ) { name, sizeof(name)-1, prefix, token, type|XML_TYPE_PROP_TABLE_COLUMN, context, SvtSaveOptions::ODFSVER_010, false } static const XMLPropertyMapEntry s_aColumnStylesProperties[] = { - MAP_CONST_COLUMN( PROPERTY_WIDTH, XML_NAMESPACE_STYLE, XML_COLUMN_WIDTH, XML_TYPE_MEASURE, 0), - MAP_CONST_COLUMN( PROPERTY_HIDDEN, XML_NAMESPACE_TABLE, XML_DISPLAY, XML_DB_TYPE_EQUAL|MID_FLAG_SPECIAL_ITEM, CTF_DB_ISVISIBLE ), - MAP_CONST_COLUMN( PROPERTY_NUMBERFORMAT, XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, XML_TYPE_NUMBER|MID_FLAG_SPECIAL_ITEM, CTF_DB_NUMBERFORMAT), - MAP_END() + { PROPERTY_WIDTH, XML_NAMESPACE_STYLE, XML_COLUMN_WIDTH, XML_TYPE_MEASURE|XML_TYPE_PROP_TABLE_COLUMN, 0, SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_HIDDEN, XML_NAMESPACE_TABLE, XML_DISPLAY, XML_DB_TYPE_EQUAL|MID_FLAG_SPECIAL_ITEM|XML_TYPE_PROP_TABLE_COLUMN, + CTF_DB_ISVISIBLE, SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_NUMBERFORMAT, XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, XML_TYPE_NUMBER|MID_FLAG_SPECIAL_ITEM|XML_TYPE_PROP_TABLE_COLUMN, + CTF_DB_NUMBERFORMAT, SvtSaveOptions::ODFSVER_010, false }, + { nullptr } }; rtl::Reference < XMLPropertyHandlerFactory> xFac = new OPropertyHandlerFactory(); return new XMLPropertySetMapper(s_aColumnStylesProperties, xFac, bForExport); @@ -95,40 +94,47 @@ rtl::Reference < XMLPropertySetMapper > OXMLHelper::GetColumnStylesPropertySetMa rtl::Reference < XMLPropertySetMapper > OXMLHelper::GetCellStylesPropertySetMapper( bool bForExport ) { -#define MAP_CONST_CELL( name, prefix, token, type, context ) { name, sizeof(name)-1, prefix, token, type|XML_TYPE_PROP_PARAGRAPH, context, SvtSaveOptions::ODFSVER_010, false } -#define MAP_CONST_TEXT( name, prefix, token, type, context ) { name, sizeof(name)-1, prefix, token, type|XML_TYPE_PROP_TEXT, context, SvtSaveOptions::ODFSVER_010, false } static const XMLPropertyMapEntry s_aCellStylesProperties[] = { - MAP_CONST_CELL( PROPERTY_ALIGN, XML_NAMESPACE_FO, XML_TEXT_ALIGN, XML_TYPE_TEXT_ALIGN, CTF_DB_COLUMN_TEXT_ALIGN), - MAP_CONST_TEXT( PROPERTY_FONTNAME, XML_NAMESPACE_STYLE, XML_FONT_NAME, XML_TYPE_STRING, 0 ), - MAP_CONST_TEXT( PROPERTY_TEXTCOLOR, XML_NAMESPACE_FO, XML_COLOR, XML_TYPE_COLOR, 0 ), - MAP_CONST_TEXT( PROPERTY_TEXTLINECOLOR, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY, 0 ), - - MAP_CONST_TEXT( PROPERTY_TEXTRELIEF, XML_NAMESPACE_STYLE, XML_FONT_RELIEF, XML_TYPE_TEXT_FONT_RELIEF|MID_FLAG_MULTI_PROPERTY, 0 ), - MAP_CONST_TEXT( PROPERTY_TEXTEMPHASIS, XML_NAMESPACE_STYLE, XML_TEXT_EMPHASIZE, XML_TYPE_CONTROL_TEXT_EMPHASIZE, 0 ), - MAP_CONST_TEXT( PROPERTY_FONTCHARWIDTH, XML_NAMESPACE_STYLE, XML_FONT_CHAR_WIDTH, XML_TYPE_NUMBER16, 0 ), - MAP_CONST_TEXT( PROPERTY_FONTCHARSET, XML_NAMESPACE_STYLE, XML_FONT_CHARSET, XML_TYPE_TEXT_FONTENCODING, 0 ), - MAP_CONST_TEXT( PROPERTY_FONTFAMILY, XML_NAMESPACE_STYLE, XML_FONT_FAMILY_GENERIC, XML_TYPE_TEXT_FONTFAMILY, 0 ), - MAP_CONST_TEXT( PROPERTY_FONTHEIGHT, XML_NAMESPACE_FO, XML_FONT_SIZE, XML_TYPE_MEASURE16, 0 ), - MAP_CONST_TEXT( PROPERTY_FONTKERNING, XML_NAMESPACE_STYLE, XML_LETTER_KERNING, XML_TYPE_BOOL, 0 ), - - MAP_CONST_TEXT( PROPERTY_FONTORIENTATION, XML_NAMESPACE_STYLE, XML_ROTATION_ANGLE, XML_TYPE_ROTATION_ANGLE, 0 ), - MAP_CONST_TEXT( PROPERTY_FONTPITCH, XML_NAMESPACE_STYLE, XML_FONT_PITCH, XML_TYPE_TEXT_FONTPITCH, 0 ), - MAP_CONST_TEXT( PROPERTY_FONTSLANT, XML_NAMESPACE_FO, XML_FONT_STYLE, XML_TYPE_TEXT_POSTURE, 0 ), - MAP_CONST_TEXT( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_STYLE, XML_TYPE_TEXT_CROSSEDOUT_STYLE|MID_FLAG_MERGE_PROPERTY, 0), - MAP_CONST_TEXT( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_TYPE, XML_TYPE_TEXT_CROSSEDOUT_TYPE|MID_FLAG_MERGE_PROPERTY, 0), - MAP_CONST_TEXT( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_WIDTH, XML_TYPE_TEXT_CROSSEDOUT_WIDTH|MID_FLAG_MERGE_PROPERTY, 0), - MAP_CONST_TEXT( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_TEXT, XML_TYPE_TEXT_CROSSEDOUT_TEXT|MID_FLAG_MERGE_PROPERTY, 0), - MAP_CONST_TEXT( PROPERTY_FONTSTYLENAME, XML_NAMESPACE_STYLE, XML_FONT_STYLE_NAME, XML_TYPE_STRING, 0 ), - MAP_CONST_TEXT( "CharUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_STYLE, XML_TYPE_TEXT_UNDERLINE_STYLE|MID_FLAG_MERGE_PROPERTY, 0 ), - MAP_CONST_TEXT( "CharUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_TYPE, XML_TYPE_TEXT_UNDERLINE_TYPE|MID_FLAG_MERGE_PROPERTY, 0 ), - MAP_CONST_TEXT( "CharUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_WIDTH, XML_TYPE_TEXT_UNDERLINE_WIDTH|MID_FLAG_MERGE_PROPERTY, 0 ), - MAP_CONST_TEXT( "CharUnderlineColor", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY, 0 ), - MAP_CONST_TEXT( "CharUnderlineHasColor", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_HASCOLOR|MID_FLAG_MERGE_ATTRIBUTE, 0 ), - MAP_CONST_TEXT( PROPERTY_FONTWEIGHT, XML_NAMESPACE_FO, XML_FONT_WEIGHT, XML_TYPE_TEXT_WEIGHT, 0 ), - MAP_CONST_TEXT( PROPERTY_FONTWIDTH, XML_NAMESPACE_STYLE, XML_FONT_WIDTH, XML_TYPE_FONT_WIDTH, 0 ), - MAP_CONST_TEXT( PROPERTY_FONTWORDLINEMODE, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_MODE, XML_TYPE_TEXT_LINE_MODE|MID_FLAG_MERGE_PROPERTY, 0 ), - MAP_END() + { PROPERTY_ALIGN, XML_NAMESPACE_FO, XML_TEXT_ALIGN, XML_TYPE_TEXT_ALIGN|XML_TYPE_PROP_PARAGRAPH, CTF_DB_COLUMN_TEXT_ALIGN, SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTNAME, XML_NAMESPACE_STYLE, XML_FONT_NAME, XML_TYPE_STRING|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_TEXTCOLOR, XML_NAMESPACE_FO, XML_COLOR, XML_TYPE_COLOR|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_TEXTLINECOLOR, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, + XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_TEXTRELIEF, XML_NAMESPACE_STYLE, XML_FONT_RELIEF, + XML_TYPE_TEXT_FONT_RELIEF|MID_FLAG_MULTI_PROPERTY|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_TEXTEMPHASIS, XML_NAMESPACE_STYLE, XML_TEXT_EMPHASIZE, XML_TYPE_CONTROL_TEXT_EMPHASIZE|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTCHARWIDTH, XML_NAMESPACE_STYLE, XML_FONT_CHAR_WIDTH, XML_TYPE_NUMBER16|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTCHARSET, XML_NAMESPACE_STYLE, XML_FONT_CHARSET, XML_TYPE_TEXT_FONTENCODING|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTFAMILY, XML_NAMESPACE_STYLE, XML_FONT_FAMILY_GENERIC, XML_TYPE_TEXT_FONTFAMILY|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTHEIGHT, XML_NAMESPACE_FO, XML_FONT_SIZE, XML_TYPE_MEASURE16|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTKERNING, XML_NAMESPACE_STYLE, XML_LETTER_KERNING, XML_TYPE_BOOL|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTORIENTATION, XML_NAMESPACE_STYLE, XML_ROTATION_ANGLE, XML_TYPE_ROTATION_ANGLE|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTPITCH, XML_NAMESPACE_STYLE, XML_FONT_PITCH, XML_TYPE_TEXT_FONTPITCH|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTSLANT, XML_NAMESPACE_FO, XML_FONT_STYLE, XML_TYPE_TEXT_POSTURE|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_CHAR_STRIKEOUT, XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_STYLE, + XML_TYPE_TEXT_CROSSEDOUT_STYLE|MID_FLAG_MERGE_PROPERTY|XML_TYPE_PROP_TEXT, 0, SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_CHAR_STRIKEOUT, XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_TYPE, + XML_TYPE_TEXT_CROSSEDOUT_TYPE|MID_FLAG_MERGE_PROPERTY|XML_TYPE_PROP_TEXT, 0, SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_CHAR_STRIKEOUT, XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_WIDTH, + XML_TYPE_TEXT_CROSSEDOUT_WIDTH|MID_FLAG_MERGE_PROPERTY|XML_TYPE_PROP_TEXT, 0, SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_CHAR_STRIKEOUT, XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_TEXT, + XML_TYPE_TEXT_CROSSEDOUT_TEXT|MID_FLAG_MERGE_PROPERTY|XML_TYPE_PROP_TEXT, 0, SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTSTYLENAME, XML_NAMESPACE_STYLE, XML_FONT_STYLE_NAME, XML_TYPE_STRING|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_CHAR_UNDERLINE, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_STYLE, + XML_TYPE_TEXT_UNDERLINE_STYLE|MID_FLAG_MERGE_PROPERTY|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_CHAR_UNDERLINE, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_TYPE, + XML_TYPE_TEXT_UNDERLINE_TYPE|MID_FLAG_MERGE_PROPERTY|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_CHAR_UNDERLINE, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_WIDTH, + XML_TYPE_TEXT_UNDERLINE_WIDTH|MID_FLAG_MERGE_PROPERTY|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_CHAR_UNDERLINE_COLOR, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, + XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_CHAR_UNDERLINE_HAS_COLOR, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_HASCOLOR|MID_FLAG_MERGE_ATTRIBUTE|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTWEIGHT, XML_NAMESPACE_FO, XML_FONT_WEIGHT, XML_TYPE_TEXT_WEIGHT|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTWIDTH, XML_NAMESPACE_STYLE, XML_FONT_WIDTH, XML_TYPE_FONT_WIDTH|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { PROPERTY_FONTWORDLINEMODE, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_MODE, + XML_TYPE_TEXT_LINE_MODE|MID_FLAG_MERGE_PROPERTY|XML_TYPE_PROP_TEXT, 0 , SvtSaveOptions::ODFSVER_010, false }, + { nullptr } }; rtl::Reference < XMLPropertyHandlerFactory> xFac = new /*OPropertyHandlerFactory*/::xmloff::OControlPropertyHandlerFactory(); return new XMLPropertySetMapper(s_aCellStylesProperties, xFac, bForExport); @@ -136,11 +142,10 @@ rtl::Reference < XMLPropertySetMapper > OXMLHelper::GetCellStylesPropertySetMapp rtl::Reference < XMLPropertySetMapper > OXMLHelper::GetRowStylesPropertySetMapper() { -#define MAP_CONST_ROW( name, prefix, token, type, context ) { name, sizeof(name)-1, prefix, token, type|XML_TYPE_PROP_TABLE_ROW, context, SvtSaveOptions::ODFSVER_010, false } static const XMLPropertyMapEntry s_aStylesProperties[] = { - MAP_CONST_ROW( PROPERTY_ROW_HEIGHT, XML_NAMESPACE_STYLE, XML_ROW_HEIGHT, XML_TYPE_MEASURE, 0), - MAP_END() + { PROPERTY_ROW_HEIGHT, XML_NAMESPACE_STYLE, XML_ROW_HEIGHT, XML_TYPE_MEASURE|XML_TYPE_PROP_TABLE_ROW, 0, SvtSaveOptions::ODFSVER_010, false }, + { nullptr } }; rtl::Reference < XMLPropertyHandlerFactory> xFac = new OPropertyHandlerFactory(); return new XMLPropertySetMapper(s_aStylesProperties, xFac, true/*bForExport*/); diff --git a/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx b/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx index 879575482b54..74a5b5e3f150 100644 --- a/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx +++ b/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx @@ -21,15 +21,14 @@ #include "xmlComponent.hxx" #include "xmlColumn.hxx" #include "xmlfilter.hxx" +#include <utility> #include <xmloff/xmltoken.hxx> #include <xmloff/ProgressBarHelper.hxx> #include "xmlEnums.hxx" #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <comphelper/propertysequence.hxx> -#include <osl/diagnose.h> -#include <sal/log.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace dbaxml { @@ -42,10 +41,10 @@ OXMLHierarchyCollection::OXMLHierarchyCollection( ODBFilter& rImport ,const Reference< XFastAttributeList > & _xAttrList ,const Reference< XNameAccess >& _xParentContainer ,const OUString& _sCollectionServiceName - ,const OUString& _sComponentServiceName) : + ,OUString _sComponentServiceName) : SvXMLImportContext( rImport ) ,m_sCollectionServiceName(_sCollectionServiceName) - ,m_sComponentServiceName(_sComponentServiceName) + ,m_sComponentServiceName(std::move(_sComponentServiceName)) { OUString sName; for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList )) @@ -75,7 +74,7 @@ OXMLHierarchyCollection::OXMLHierarchyCollection( ODBFilter& rImport m_xContainer.set(xORB->createInstanceWithArguments(_sCollectionServiceName,aArguments),UNO_QUERY); Reference<XNameContainer> xNameContainer(_xParentContainer,UNO_QUERY); if ( xNameContainer.is() && !xNameContainer->hasByName(sName) ) - xNameContainer->insertByName(sName,makeAny(m_xContainer)); + xNameContainer->insertByName(sName,Any(m_xContainer)); } } catch(Exception&) diff --git a/dbaccess/source/filter/xml/xmlHierarchyCollection.hxx b/dbaccess/source/filter/xml/xmlHierarchyCollection.hxx index 689434822922..91f0aae869db 100644 --- a/dbaccess/source/filter/xml/xmlHierarchyCollection.hxx +++ b/dbaccess/source/filter/xml/xmlHierarchyCollection.hxx @@ -39,7 +39,7 @@ namespace dbaxml ,const css::uno::Reference< css::xml::sax::XFastAttributeList > & _xAttrList ,const css::uno::Reference< css::container::XNameAccess >& _xParentContainer ,const OUString& _sCollectionServiceName - ,const OUString& _sComponentServiceName + ,OUString _sComponentServiceName ); OXMLHierarchyCollection( ODBFilter& rImport ,const css::uno::Reference< css::container::XNameAccess >& _xContainer diff --git a/dbaccess/source/filter/xml/xmlLogin.cxx b/dbaccess/source/filter/xml/xmlLogin.cxx index cc7502301233..a4519b26e7a9 100644 --- a/dbaccess/source/filter/xml/xmlLogin.cxx +++ b/dbaccess/source/filter/xml/xmlLogin.cxx @@ -21,7 +21,7 @@ #include "xmlfilter.hxx" #include <xmloff/xmltoken.hxx> #include <strings.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <com/sun/star/sdbc/XDataSource.hpp> namespace dbaxml @@ -52,7 +52,7 @@ OXMLLogin::OXMLLogin( ODBFilter& rImport, bUserFound = true; try { - xDataSource->setPropertyValue(PROPERTY_USER,makeAny(aIter.toString())); + xDataSource->setPropertyValue(PROPERTY_USER,Any(aIter.toString())); } catch(const Exception&) { @@ -63,7 +63,7 @@ OXMLLogin::OXMLLogin( ODBFilter& rImport, case XML_IS_PASSWORD_REQUIRED: try { - xDataSource->setPropertyValue(PROPERTY_ISPASSWORDREQUIRED,makeAny(IsXMLToken(aIter, XML_TRUE))); + xDataSource->setPropertyValue(PROPERTY_ISPASSWORDREQUIRED,Any(IsXMLToken(aIter, XML_TRUE))); } catch(const Exception&) { diff --git a/dbaccess/source/filter/xml/xmlQuery.cxx b/dbaccess/source/filter/xml/xmlQuery.cxx index 8f91145d72e9..b1cdd90bf1b7 100644 --- a/dbaccess/source/filter/xml/xmlQuery.cxx +++ b/dbaccess/source/filter/xml/xmlQuery.cxx @@ -23,9 +23,7 @@ #include <xmloff/ProgressBarHelper.hxx> #include "xmlEnums.hxx" #include <strings.hxx> -#include <osl/diagnose.h> -#include <sal/log.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace dbaxml { @@ -39,7 +37,7 @@ OXMLQuery::OXMLQuery( ODBFilter& rImport ,const Reference< XFastAttributeList > & _xAttrList ,const css::uno::Reference< css::container::XNameAccess >& _xParentContainer ) : - OXMLTable( rImport, _xAttrList,_xParentContainer, "com.sun.star.sdb.CommandDefinition" ) + OXMLTable( rImport, _xAttrList,_xParentContainer, u"com.sun.star.sdb.CommandDefinition"_ustr ) ,m_bEscapeProcessing(true) { for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList )) @@ -92,20 +90,20 @@ void OXMLQuery::setProperties(Reference< XPropertySet > & _xProp ) { OXMLTable::setProperties(_xProp); - _xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(m_sCommand)); - _xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,makeAny(m_bEscapeProcessing)); + _xProp->setPropertyValue(PROPERTY_COMMAND,Any(m_sCommand)); + _xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,Any(m_bEscapeProcessing)); if ( !m_sTable.isEmpty() ) - _xProp->setPropertyValue(PROPERTY_UPDATE_TABLENAME,makeAny(m_sTable)); + _xProp->setPropertyValue(PROPERTY_UPDATE_TABLENAME,Any(m_sTable)); if ( !m_sCatalog.isEmpty() ) - _xProp->setPropertyValue(PROPERTY_UPDATE_CATALOGNAME,makeAny(m_sCatalog)); + _xProp->setPropertyValue(PROPERTY_UPDATE_CATALOGNAME,Any(m_sCatalog)); if ( !m_sSchema.isEmpty() ) - _xProp->setPropertyValue(PROPERTY_UPDATE_SCHEMANAME,makeAny(m_sSchema)); + _xProp->setPropertyValue(PROPERTY_UPDATE_SCHEMANAME,Any(m_sSchema)); const ODBFilter::TPropertyNameMap& rSettings = GetOwnImport().getQuerySettings(); ODBFilter::TPropertyNameMap::const_iterator aFind = rSettings.find(m_sName); if ( aFind != rSettings.end() ) - _xProp->setPropertyValue(PROPERTY_LAYOUTINFORMATION,makeAny(aFind->second)); + _xProp->setPropertyValue(PROPERTY_LAYOUTINFORMATION,Any(aFind->second)); } } catch(Exception&) diff --git a/dbaccess/source/filter/xml/xmlServerDatabase.cxx b/dbaccess/source/filter/xml/xmlServerDatabase.cxx index 590db077437b..a1db053092a1 100644 --- a/dbaccess/source/filter/xml/xmlServerDatabase.cxx +++ b/dbaccess/source/filter/xml/xmlServerDatabase.cxx @@ -22,7 +22,7 @@ #include <xmloff/xmltoken.hxx> #include <strings.hxx> #include <rtl/ustrbuf.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace dbaxml { @@ -74,51 +74,51 @@ OXMLServerDatabase::OXMLServerDatabase( ODBFilter& rImport, OUStringBuffer sURL; if ( sType == "sdbc:mysql:jdbc" || sType == "sdbc:mysqlc" || sType == "sdbc:mysql:mysqlc" ) { - sURL.append( sType ).append( ":" ).append(sHostName); + sURL.append( sType + ":" + sHostName); if ( !sPortNumber.isEmpty() ) { - sURL.append(":").append(sPortNumber); + sURL.append(":" + sPortNumber); } if ( !sDatabaseName.isEmpty() ) { - sURL.append("/").append(sDatabaseName); + sURL.append("/" + sDatabaseName); } } else if ( sType == "jdbc:oracle:thin" ) { - sURL.append("jdbc:oracle:thin:@").append(sHostName); + sURL.append("jdbc:oracle:thin:@" + sHostName); if ( !sPortNumber.isEmpty() ) { - sURL.append(":").append(sPortNumber); + sURL.append(":" + sPortNumber); } if ( !sDatabaseName.isEmpty() ) { - sURL.append(":").append(sDatabaseName); + sURL.append(":" + sDatabaseName); } } else if ( sType == "sdbc:address:ldap" ) { - sURL.append("sdbc:address:ldap:").append(sHostName); + sURL.append("sdbc:address:ldap:" + sHostName); if ( !sPortNumber.isEmpty() ) { - sURL.append(":").append(sPortNumber); + sURL.append(":" + sPortNumber); } } else { - sURL.append(sType).append(":").append(sHostName); + sURL.append(sType + ":" + sHostName); if ( !sPortNumber.isEmpty() ) { - sURL.append(":").append(sPortNumber); + sURL.append(":" + sPortNumber); } if ( !sDatabaseName.isEmpty() ) { - sURL.append(":").append(sDatabaseName); + sURL.append(":" + sDatabaseName); } } try { - xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sURL.makeStringAndClear())); + xDataSource->setPropertyValue(PROPERTY_URL,Any(sURL.makeStringAndClear())); } catch(const Exception&) { diff --git a/dbaccess/source/filter/xml/xmlStyleImport.cxx b/dbaccess/source/filter/xml/xmlStyleImport.cxx index e5a5970c2e00..4196860031a0 100644 --- a/dbaccess/source/filter/xml/xmlStyleImport.cxx +++ b/dbaccess/source/filter/xml/xmlStyleImport.cxx @@ -41,7 +41,7 @@ using namespace xmloff::token; OTableStyleContext::OTableStyleContext( ODBFilter& rImport, - SvXMLStylesContext& rStyles, XmlStyleFamily nFamily ) + OTableStylesContext& rStyles, XmlStyleFamily nFamily ) :XMLPropStyleContext( rImport, rStyles, nFamily, false ) ,pStyles(&rStyles) ,m_nNumberFormat(-1) @@ -101,7 +101,7 @@ void OTableStyleContext::SetDefaults() void OTableStyleContext::AddProperty(const sal_Int16 nContextID, const uno::Any& rValue) { - sal_Int32 nIndex(static_cast<OTableStylesContext *>(pStyles)->GetIndex(nContextID)); + sal_Int32 nIndex(pStyles->GetIndex(nContextID)); OSL_ENSURE(nIndex != -1, "Property not found in Map"); XMLPropertyState aPropState(nIndex, rValue); GetProperties().push_back(aPropState); // has to be inserted in a sort order later @@ -205,7 +205,6 @@ SvXMLStyleContext *OTableStylesContext::CreateStyleStyleChildContext( case XmlStyleFamily::TABLE_COLUMN: case XmlStyleFamily::TABLE_CELL: return new OTableStyleContext( GetOwnImport(), *this, nFamily ); - break; default: break; } diff --git a/dbaccess/source/filter/xml/xmlStyleImport.hxx b/dbaccess/source/filter/xml/xmlStyleImport.hxx index d3fc001b03d5..7f6c9932dac7 100644 --- a/dbaccess/source/filter/xml/xmlStyleImport.hxx +++ b/dbaccess/source/filter/xml/xmlStyleImport.hxx @@ -27,12 +27,13 @@ namespace dbaxml { class ODBFilter; + class OTableStylesContext; class OTableStyleContext : public XMLPropStyleContext { OUString m_sDataStyleName; OUString sPageStyle; - SvXMLStylesContext* pStyles; + OTableStylesContext* pStyles; sal_Int32 m_nNumberFormat; ODBFilter& GetOwnImport(); @@ -46,7 +47,7 @@ namespace dbaxml OTableStyleContext( ODBFilter& rImport, - SvXMLStylesContext& rStyles, XmlStyleFamily nFamily ); + OTableStylesContext& rStyles, XmlStyleFamily nFamily ); virtual ~OTableStyleContext() override; diff --git a/dbaccess/source/filter/xml/xmlTable.cxx b/dbaccess/source/filter/xml/xmlTable.cxx index 1af5f8e1955a..dd7df81c8072 100644 --- a/dbaccess/source/filter/xml/xmlTable.cxx +++ b/dbaccess/source/filter/xml/xmlTable.cxx @@ -19,6 +19,7 @@ #include "xmlTable.hxx" #include "xmlfilter.hxx" +#include <utility> #include <xmloff/xmltoken.hxx> #include <xmloff/ProgressBarHelper.hxx> #include "xmlEnums.hxx" @@ -29,9 +30,7 @@ #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <comphelper/propertysequence.hxx> -#include <osl/diagnose.h> -#include <tools/diagnose_ex.h> -#include <sal/log.hxx> +#include <comphelper/diagnose_ex.hxx> namespace dbaxml { @@ -42,11 +41,11 @@ namespace dbaxml OXMLTable::OXMLTable( ODBFilter& _rImport ,const uno::Reference< XFastAttributeList > & _xAttrList - ,const uno::Reference< css::container::XNameAccess >& _xParentContainer + ,uno::Reference< css::container::XNameAccess > _xParentContainer ,const OUString& _sServiceName ) :SvXMLImportContext( _rImport ) - ,m_xParentContainer(_xParentContainer) + ,m_xParentContainer(std::move(_xParentContainer)) ,m_bApplyFilter(false) ,m_bApplyOrder(false) { @@ -143,12 +142,12 @@ void OXMLTable::setProperties(uno::Reference< XPropertySet > & _xProp ) { if ( _xProp.is() ) { - _xProp->setPropertyValue(PROPERTY_APPLYFILTER,makeAny(m_bApplyFilter)); - _xProp->setPropertyValue(PROPERTY_FILTER,makeAny(m_sFilterStatement)); + _xProp->setPropertyValue(PROPERTY_APPLYFILTER,Any(m_bApplyFilter)); + _xProp->setPropertyValue(PROPERTY_FILTER,Any(m_sFilterStatement)); if ( _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_APPLYORDER) ) - _xProp->setPropertyValue(PROPERTY_APPLYORDER,makeAny(m_bApplyOrder)); - _xProp->setPropertyValue(PROPERTY_ORDER,makeAny(m_sOrderStatement)); + _xProp->setPropertyValue(PROPERTY_APPLYORDER,Any(m_bApplyOrder)); + _xProp->setPropertyValue(PROPERTY_ORDER,Any(m_sOrderStatement)); } } catch(Exception&) @@ -182,7 +181,7 @@ void OXMLTable::endFastElement(sal_Int32 ) } } - xNameContainer->insertByName(m_sName,makeAny(m_xTable)); + xNameContainer->insertByName(m_sName,Any(m_xTable)); } } catch(Exception&) diff --git a/dbaccess/source/filter/xml/xmlTable.hxx b/dbaccess/source/filter/xml/xmlTable.hxx index cee19ef19e40..9be9feaa023a 100644 --- a/dbaccess/source/filter/xml/xmlTable.hxx +++ b/dbaccess/source/filter/xml/xmlTable.hxx @@ -53,7 +53,7 @@ namespace dbaxml OXMLTable( ODBFilter& rImport ,const css::uno::Reference< css::xml::sax::XFastAttributeList > & _xAttrList - ,const css::uno::Reference< css::container::XNameAccess >& _xParentContainer + ,css::uno::Reference< css::container::XNameAccess > _xParentContainer ,const OUString& _sServiceName ); virtual ~OXMLTable() override; diff --git a/dbaccess/source/filter/xml/xmlTableFilterList.cxx b/dbaccess/source/filter/xml/xmlTableFilterList.cxx index 88ec4fa2bcde..a6541684acba 100644 --- a/dbaccess/source/filter/xml/xmlTableFilterList.cxx +++ b/dbaccess/source/filter/xml/xmlTableFilterList.cxx @@ -84,9 +84,9 @@ void OXMLTableFilterList::endFastElement(sal_Int32 ) if ( xDataSource.is() ) { if ( !m_aPatterns.empty() ) - xDataSource->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(comphelper::containerToSequence(m_aPatterns))); + xDataSource->setPropertyValue(PROPERTY_TABLEFILTER,Any(comphelper::containerToSequence(m_aPatterns))); if ( !m_aTypes.empty() ) - xDataSource->setPropertyValue(PROPERTY_TABLETYPEFILTER,makeAny(comphelper::containerToSequence(m_aTypes))); + xDataSource->setPropertyValue(PROPERTY_TABLETYPEFILTER,Any(comphelper::containerToSequence(m_aTypes))); } } diff --git a/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx b/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx index 0c4b2892d2b7..1df9c037ac38 100644 --- a/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx +++ b/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx @@ -22,9 +22,6 @@ namespace dbaxml { - using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::xml::sax; - OXMLTableFilterPattern::OXMLTableFilterPattern( SvXMLImport& rImport ,bool _bNameFilter ,OXMLTableFilterList& _rParent) diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx index 24516771289c..18a1d223df86 100644 --- a/dbaccess/source/filter/xml/xmlfilter.cxx +++ b/dbaccess/source/filter/xml/xmlfilter.cxx @@ -51,7 +51,7 @@ #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <svtools/sfxecode.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <comphelper/sequence.hxx> #include <comphelper/types.hxx> @@ -125,49 +125,45 @@ static ErrCode ReadThroughComponent( static ErrCode ReadThroughComponent( const uno::Reference< embed::XStorage >& xStorage, const uno::Reference<XComponent>& xModelComponent, - const char* pStreamName, + const OUString& sStreamName, const uno::Reference<XComponentContext> & rxContext, ODBFilter& _rFilter) { OSL_ENSURE( xStorage.is(), "Need storage!"); - OSL_ENSURE(nullptr != pStreamName, "Please, please, give me a name!"); - if ( xStorage.is() ) - { - uno::Reference< io::XStream > xDocStream; + if ( !xStorage ) + // TODO/LATER: better error handling + return ErrCode(1); - try - { - // open stream (and set parser input) - OUString sStreamName = OUString::createFromAscii(pStreamName); - if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) ) - { - // stream name not found! return immediately with OK signal - return ERRCODE_NONE; - } + uno::Reference< io::XStream > xDocStream; - // get input stream - xDocStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ ); - } - catch (const packages::WrongPasswordException&) - { - return ERRCODE_SFX_WRONGPASSWORD; - } - catch (const uno::Exception&) + try + { + // open stream (and set parser input) + if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) ) { - return ErrCode(1); // TODO/LATER: error handling + // stream name not found! return immediately with OK signal + return ERRCODE_NONE; } - uno::Reference< XInputStream > xInputStream = xDocStream->getInputStream(); - // read from the stream - return ReadThroughComponent( xInputStream - ,xModelComponent - ,rxContext - ,_rFilter ); + // get input stream + xDocStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ ); + } + catch (const packages::WrongPasswordException&) + { + return ERRCODE_SFX_WRONGPASSWORD; + } + catch (const uno::Exception&) + { + return ErrCode(1); // TODO/LATER: error handling } - // TODO/LATER: better error handling - return ErrCode(1); + uno::Reference< XInputStream > xInputStream = xDocStream->getInputStream(); + // read from the stream + return ReadThroughComponent( xInputStream + ,xModelComponent + ,rxContext + ,_rFilter ); } @@ -178,17 +174,17 @@ ODBFilter::ODBFilter( const uno::Reference< XComponentContext >& _rxContext ) GetMM100UnitConverter().SetCoreMeasureUnit(util::MeasureUnit::MM_10TH); GetMM100UnitConverter().SetXMLMeasureUnit(util::MeasureUnit::CM); - GetNamespaceMap().Add( "_db", + GetNamespaceMap().Add( u"_db"_ustr, GetXMLToken(XML_N_DB), XML_NAMESPACE_DB ); - GetNamespaceMap().Add( "__db", + GetNamespaceMap().Add( u"__db"_ustr, GetXMLToken(XML_N_DB_OASIS), XML_NAMESPACE_DB ); } -ODBFilter::~ODBFilter() throw() +ODBFilter::~ODBFilter() noexcept { } @@ -196,7 +192,7 @@ ODBFilter::~ODBFilter() throw() OUString ODBFilter::getImplementationName_Static() { - return "com.sun.star.comp.sdb.DBFilter"; + return u"com.sun.star.comp.sdb.DBFilter"_ustr; } @@ -246,10 +242,10 @@ bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) bool bRet = true; if (!xStorage.is()) { - if (aMediaDescriptor.has("URL")) - sFileName = aMediaDescriptor.getOrDefault("URL", OUString()); - if (sFileName.isEmpty() && aMediaDescriptor.has("FileName")) - sFileName = aMediaDescriptor.getOrDefault("FileName", sFileName); + if (aMediaDescriptor.has(u"URL"_ustr)) + sFileName = aMediaDescriptor.getOrDefault(u"URL"_ustr, OUString()); + if (sFileName.isEmpty() && aMediaDescriptor.has(u"FileName"_ustr)) + sFileName = aMediaDescriptor.getOrDefault(u"FileName"_ustr, sFileName); OSL_ENSURE(!sFileName.isEmpty(), "ODBFilter::implImport: no URL given!"); bRet = !sFileName.isEmpty(); @@ -325,7 +321,7 @@ bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) uno::Reference<XComponent> xModel(GetModel()); ErrCode nRet = ReadThroughComponent( xStorage ,xModel - ,"settings.xml" + ,u"settings.xml"_ustr ,GetComponentContext() ,*this ); @@ -333,7 +329,7 @@ bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) if ( nRet == ERRCODE_NONE ) nRet = ReadThroughComponent( xStorage ,xModel - ,"content.xml" + ,u"content.xml"_ustr ,GetComponentContext() ,*this ); @@ -402,12 +398,10 @@ public: case XML_ELEMENT(OOO, XML_STYLES): rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); return rImport.CreateStylesContext(false); - break; case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES): case XML_ELEMENT(OOO, XML_AUTOMATIC_STYLES): rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); return rImport.CreateStylesContext(true); - break; } return nullptr; } @@ -454,15 +448,12 @@ public: case XML_ELEMENT(OFFICE, XML_BODY): case XML_ELEMENT(OOO, XML_BODY): return new DBXMLDocumentBodyContext(rImport); - break; case XML_ELEMENT(OFFICE, XML_SCRIPTS): return new XMLScriptContext(GetImport(), rImport.GetModel()); - break; case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES): case XML_ELEMENT(OOO, XML_AUTOMATIC_STYLES): rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); return rImport.CreateStylesContext(true); - break; default: break; } return nullptr; @@ -499,17 +490,15 @@ SvXMLImportContext* ODBFilter::CreateFastContext(sal_Int32 nElement, void ODBFilter::SetViewSettings(const Sequence<PropertyValue>& aViewProps) { - const PropertyValue *pIter = aViewProps.getConstArray(); - const PropertyValue *pEnd = pIter + aViewProps.getLength(); - for (; pIter != pEnd; ++pIter) + for (auto& prop : aViewProps) { - if ( pIter->Name == "Queries" ) + if (prop.Name == "Queries") { - fillPropertyMap(pIter->Value,m_aQuerySettings); + fillPropertyMap(prop.Value, m_aQuerySettings); } - else if ( pIter->Name == "Tables" ) + else if (prop.Name == "Tables") { - fillPropertyMap(pIter->Value,m_aTablesSettings); + fillPropertyMap(prop.Value, m_aTablesSettings); } } } @@ -517,17 +506,15 @@ void ODBFilter::SetViewSettings(const Sequence<PropertyValue>& aViewProps) void ODBFilter::SetConfigurationSettings(const Sequence<PropertyValue>& aConfigProps) { - const PropertyValue *pIter = aConfigProps.getConstArray(); - const PropertyValue *pEnd = pIter + aConfigProps.getLength(); - for (; pIter != pEnd; ++pIter) + for (auto& prop : aConfigProps) { - if ( pIter->Name == "layout-settings" ) + if (prop.Name == "layout-settings") { Sequence<PropertyValue> aWindows; - pIter->Value >>= aWindows; + prop.Value >>= aWindows; uno::Reference<XPropertySet> xProp(getDataSource()); if ( xProp.is() ) - xProp->setPropertyValue(PROPERTY_LAYOUTINFORMATION,makeAny(aWindows)); + xProp->setPropertyValue(PROPERTY_LAYOUTINFORMATION,Any(aWindows)); } } } @@ -537,13 +524,11 @@ void ODBFilter::fillPropertyMap(const Any& _rValue,TPropertyNameMap& _rMap) { Sequence<PropertyValue> aWindows; _rValue >>= aWindows; - const PropertyValue *pIter = aWindows.getConstArray(); - const PropertyValue *pEnd = pIter + aWindows.getLength(); - for (; pIter != pEnd; ++pIter) + for (auto& window : aWindows) { Sequence<PropertyValue> aValue; - pIter->Value >>= aValue; - _rMap.emplace( pIter->Name,aValue ); + window.Value >>= aValue; + _rMap.emplace(window.Name, aValue); } } @@ -610,7 +595,7 @@ void ODBFilter::setPropertyInfo() { try { - xDataSource->setPropertyValue(PROPERTY_INFO,makeAny(aInfo)); + xDataSource->setPropertyValue(PROPERTY_INFO,Any(aInfo)); } catch (const Exception&) { diff --git a/dbaccess/source/filter/xml/xmlfilter.hxx b/dbaccess/source/filter/xml/xmlfilter.hxx index c3e5623906eb..ec776cd75f87 100644 --- a/dbaccess/source/filter/xml/xmlfilter.hxx +++ b/dbaccess/source/filter/xml/xmlfilter.hxx @@ -79,7 +79,7 @@ protected: virtual SvXMLImportContext *CreateFastContext(sal_Int32 Element, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override; - virtual ~ODBFilter() throw() override; + virtual ~ODBFilter() noexcept override; public: explicit ODBFilter( const Reference< XComponentContext >& _rxContext ); |