Skip to content

Conversation

@LiHua000
Copy link
Contributor

align XPS core property keys with DocSheet expectations and drop hardcoded fallbacks to restore keyword exposure in file info

prefer document-supplied author/keyword metadata in DocSheet, logging owner-based fallbacks for traceability

add debugging hooks for missing XPS core properties and empty outline structures to ease QA validation

task:https://pms.uniontech.com/task-view-383459.html

    align XPS core property keys with DocSheet expectations and drop hardcoded fallbacks to restore keyword exposure in file info

    prefer document-supplied author/keyword metadata in DocSheet, logging owner-based fallbacks for traceability

    add debugging hooks for missing XPS core properties and empty outline structures to ease QA validation

task:https://pms.uniontech.com/task-view-383459.html
@deepin-ci-robot
Copy link

deepin pr auto review

我来对这段代码的修改进行审查分析:

  1. 代码逻辑改进:
  • 将normalizedString的默认fallback参数从"未知"改为空字符串更合理,避免硬编码
  • 增加了更详细的日志记录,有助于调试和问题追踪
  • 改进了作者(author)和关键词(keywords)的处理逻辑,增加了多个备选值的检查
  1. 代码质量提升:
  • 使用lambda表达式(setPropertyWithLog)提高了代码复用性
  • 增加了更多的错误处理和边界条件检查
  • 统一了属性键名的命名规范(如"KeyWords"改为"Keywords")
  1. 性能优化:
  • 没有明显的性能问题,修改主要是增加日志和错误处理
  • 使用QStringLiteral处理字符串字面量,提高运行时效率
  1. 安全性考虑:
  • 增加了对空值和无效数据的检查
  • 使用了更安全的字符串处理方式
  • 日志记录有助于追踪潜在问题

具体建议:

  1. 对于normalizedString函数:
QString normalizedString(const gchar *value, const QString &fallback = QString())
{
    if (!value) return fallback;  // 增加空指针检查
    QString result = QString::fromUtf8(value).trimmed();
    return result.isEmpty() ? fallback : result;
}
  1. 对于ensureProperties函数中的setPropertyWithLog lambda:
const auto setPropertyWithLog = [&](const QString &key, const gchar *value) {
    if (!value) {  // 增加空指针检查
        qCDebug(appLog) << "XPS metadata missing field:" << key;
        return;
    }
    const QString text = normalizedString(value);
    if (text.isEmpty()) {
        qCDebug(appLog) << "XPS metadata empty field:" << key;
    }
    props[key] = text;
};
  1. 对于作者信息的处理:
QString author = propertys.value("Author").toString();
if (author.isEmpty()) {
    author = propertys.value("Creator").toString();
}
if (author.isEmpty()) {
    author = fileInfo.owner();
    if (!author.isEmpty()) {  // 增加非空检查
        qCDebug(appLog) << "Using file owner as fallback author for document";
    }
}
tFileInfo.auther = author;

这些修改提高了代码的健壮性和可维护性,同时增加了更多的错误处理和日志记录,有助于问题诊断和调试。整体来看,这是一次积极的代码改进。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiHua000, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@LiHua000
Copy link
Contributor Author

/forcemerge

@deepin-bot deepin-bot bot merged commit df5a3f0 into linuxdeepin:master Nov 13, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants