<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
  =============================================================================
  B27 中文版 — Office JS 加载项 manifest.xml
  B27 Chinese — Office JS Add-in manifest.xml
  =============================================================================
  使用说明 / How to use:
  1. 把 <Id> 换成你自己的 GUID（搜"GUID 生成器"随便生成一个）。
     Replace <Id> with your own GUID.
  2. 本地调试默认端口 3000；改了端口要同步改 Resources 里的所有 URL。
     Default dev port is 3000; if you change it, update all URLs in <Resources>.
  3. 侧载：Excel → 插入 → 加载项 → 我的加载项 → 上传我的加载项 → 选本文件。
     Sideload: Excel → Insert → Add-ins → My Add-ins → Upload My Add-in → pick this file.
  =============================================================================
-->
<OfficeApp
  xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
  xsi:type="TaskPaneApp">
  <Id>626fad87-8dc1-4a6a-98f8-5864bf21eafa</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>程晓教程示例</ProviderName>
  <DefaultLocale>zh-CN</DefaultLocale>
  <!-- 显示名 / Display name -->
  <DisplayName DefaultValue="我的自定义函数示例" />
  <!-- 加载项描述 / Add-in description -->
  <Description DefaultValue="AI 辅助开发的一个 Office JS 自定义函数加载项。" />

  <!--
    ========================================================================
    Requirements：声明加载项需要的能力集。
    ========================================================================
    CustomFunctionsRuntime 1.1 是自定义函数（custom functions）的硬性要求。
    缺它，单元格里输入 =TUTORIAL.ADD(1,2) 会报 #NAME?。
    CustomFunctionsRuntime 1.1 is REQUIRED for custom functions.
    Without it, =TUTORIAL.ADD(1,2) returns #NAME?.
  -->
  <Requirements>
    <Sets>
      <Set Name="CustomFunctionsRuntime" MinVersion="1.1" />
    </Sets>
  </Requirements>

  <!-- Hosts：宿主类型，这里只对 Excel 工作簿生效 -->
  <Hosts>
    <Host Name="Workbook" />
  </Hosts>

  <!-- DefaultSettings：默认入口（点"打开加载项"按钮时加载的页面） -->
  <DefaultSettings>
    <SourceLocation DefaultValue="https://localhost:3000/taskpane.html" />
  </DefaultSettings>

  <!-- 权限：ReadWriteDocument = 可读写文档 -->
  <Permissions>ReadWriteDocument</Permissions>

  <!--
    ========================================================================
    VersionOverrides：扩展配置段
    关键点：
      - <Namespace resid="..." />：自定义函数命名空间前缀（用户调用格式 = 前缀.函数名）
      - <Script>  + <Page> + <Metadata>：分别指向 functions.js / functions.html / functions.json
      - 三个 <SourceLocation> 都用 子元素写法（不是 DefaultValue 属性）
    ========================================================================
  -->
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Hosts>
      <Host xsi:type="Workbook">

        <!-- 所有形态（桌面 + Web）都开启 / All form factors -->
        <AllFormFactors>
          <ExtensionPoint xsi:type="CustomFunctions">
            <Script>
              <SourceLocation resid="Functions.Script.Url" />
            </Script>
            <Page>
              <SourceLocation resid="Functions.Page.Url" />
            </Page>
            <Metadata>
              <SourceLocation resid="Functions.Metadata.Url" />
            </Metadata>
            <!-- 命名空间用 resid 引用：值来自下面 <bt:ShortStrings> -->
            <!-- Namespace uses resid reference; actual value lives in <bt:ShortStrings> below -->
            <Namespace resid="Functions.Namespace" />
          </ExtensionPoint>
        </AllFormFactors>

        <!-- 桌面端特有：任务窗格按钮 / Desktop-only: taskpane button -->
        <DesktopFormFactor>
          <FunctionFile resid="Commands.Url" />
          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <OfficeTab id="TabHome">
              <Group id="CommandsGroup">
                <Label resid="CommandsGroup.Label" />
                <Control xsi:type="Button" id="TaskPaneButton">
                  <Label resid="TaskPaneButton.Label" />
                  <Supertip>
                    <Title resid="TaskPaneButton.Label" />
                    <Description resid="TaskPaneButton.Tooltip" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Icon.16x16" />
                    <bt:Image size="32" resid="Icon.32x32" />
                    <bt:Image size="80" resid="Icon.80x80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <TaskpaneId>TaskPaneId1</TaskpaneId>
                    <SourceLocation resid="Taskpane.Url" />
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>
        </DesktopFormFactor>

      </Host>
    </Hosts>

    <!--
      ======================================================================
      Resources：所有 resid 都在这里定义实际值。
      关键点：图标文件必须真实存在于 https://localhost:3000/assets/
      ======================================================================
    -->
    <Resources>
      <bt:Images>
        <bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png" />
        <bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png" />
        <bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png" />
      </bt:Images>
      <bt:Urls>
        <bt:Url id="Commands.Url"             DefaultValue="https://localhost:3000/commands.html" />
        <bt:Url id="Taskpane.Url"            DefaultValue="https://localhost:3000/taskpane.html" />
        <bt:Url id="Functions.Script.Url"    DefaultValue="https://localhost:3000/functions.js" />
        <bt:Url id="Functions.Page.Url"      DefaultValue="https://localhost:3000/functions.html" />
        <bt:Url id="Functions.Metadata.Url"  DefaultValue="https://localhost:3000/functions.json" />
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="CommandsGroup.Label"   DefaultValue="我的加载项" />
        <bt:String id="TaskPaneButton.Label"  DefaultValue="打开说明面板" />
        <!-- 命名空间实际值 —— 决定 Excel 里调用前缀（前缀.函数名） -->
        <!-- Actual namespace value — determines the call prefix in Excel -->
        <bt:String id="Functions.Namespace"   DefaultValue="TUTORIAL" />
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="TaskPaneButton.Tooltip" DefaultValue="点开查看自定义函数用法" />
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>