我们很高兴与您分享我们发布了另一个新版本,您现在可以从下载部分下载 Aspose.Words for C++ 19.11 API。以下列表突出了主要功能,您还将了解如何使用 Aspose.Words for C++ 19.11 来:

  • 使用 Web 扩展和任务窗格
  • 自定义水平规则形状的格式
  • Aspose.Words for C++ 现在改进了设置“使用打印机指标”选项时的字符间距计算
  • 此版本中改进了宏支持

使用 Web 扩展和任务窗格

表示 Office 插件的不同类现在是 Aspose.Words for C++ 的 WebExtensions 命名空间 的一部分。您现在可以使用 Aspose.Words for C++ 来处理 Office 加载项中的 Web 扩展和任务窗格。例如,API 现在提供了新的 TaskPane 类、TaskPaneCollection 类、TaskPaneDockState 枚举、Document.WebExtensionTaskPanes 属性等。

以下代码示例可用于 创建任务窗格并添加到 Web 扩展任务窗格 具有基本属性。

System::SharedPtr<Document> doc = System::MakeObject<Document>();

System::SharedPtr<TaskPane> taskPane = System::MakeObject<TaskPane>();
doc->get_WebExtensionTaskPanes()->Add(taskPane);

taskPane->set_DockState(TaskPaneDockState::Right);
taskPane->set_IsVisible(true);
taskPane->set_Width(300);

taskPane->get_WebExtension()->get_Reference()->set_Id(u"wa102923726");
taskPane->get_WebExtension()->get_Reference()->set_Version(u"1.0.0.0");
taskPane->get_WebExtension()->get_Reference()->set_StoreType(WebExtensionStoreType::OMEX);
taskPane->get_WebExtension()->get_Reference()->set_Store(u"th-TH");

doc->Save(outputDataDir + u"WorkingWithWebExtension.UsingWebExtensionTaskPanes.docx", SaveFormat::Docx);

自定义水平规则形状的格式

Shape.HorizontalRuleFormat 属性现在在 Aspose.Words for C++ API 中可用,用于访问水平规则形状的属性。 HorizontalRuleFormat 类中现在提供了 Height、Color、NoShade 等基本属性。例如,您可以使用以下代码来设置 HorizontalRuleFormat 以格式化水平规则形状

// 初始化文档。
System::SharedPtr<DocumentBuilder> builder = System::MakeObject<DocumentBuilder>();

System::SharedPtr<Shape> shape = builder->InsertHorizontalRule();
System::SharedPtr<HorizontalRuleFormat> horizontalRuleFormat = shape->get_HorizontalRuleFormat();

horizontalRuleFormat->set_Alignment(HorizontalRuleAlignment::Center);
horizontalRuleFormat->set_WidthPercent(70);
horizontalRuleFormat->set_Height(3);
horizontalRuleFormat->set_Color(System::Drawing::Color::get_Blue());
horizontalRuleFormat->set_NoShade(true);

builder->get_Document()->Save(outputDataDir + u"HorizontalRuleFormat.docx");

改进了 VBA 宏支持

Aspose.Words for C++ API 现在提供 Dcoument.VbaProject 属性来获取或设置 Word 文档中的 VbaProject。下面的代码示例演示了如何创建 VBA 项目和 VBA 模块 以及基本属性,例如名称和类型。

System::SharedPtr<Document> doc = System::MakeObject<Document>();

// 创建一个新的 VBA 项目。
System::SharedPtr<VbaProject> project = System::MakeObject<VbaProject>();
project->set_Name(u"AsposeProject");
doc->set_VbaProject(project);

// 创建一个新模块并指定一个宏源代码。
System::SharedPtr<VbaModule> vbModule = System::MakeObject<VbaModule>();
vbModule->set_Name(u"AsposeModule");
vbModule->set_Type(VbaModuleType::ProceduralModule);
vbModule->set_SourceCode(u"New source code");

// 将模块添加到 VBA 项目。
doc->get_VbaProject()->get_Modules()->Add(vbModule);

doc->Save(outputDataDir +  u"WorkingWithVbaMacros.CreateVbaMacros.docm");

另请参阅有用的链接

您可能需要完成任务的资源:

要获得 Aspose.Words for C++ 的技术支持,请随时在 Aspose.Words for C++ 支持论坛 中发布您的疑问/问题。