Method and device for processing combined graphics in a presentation file, and storage medium
Patent Information
- Application Number
- CN202611379603.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-07
- Publication Date
- 2026-10-13
AI Technical Summary
[0003]本申请的主要目的在于提供一种演示文稿文件中组合图形的处理方法、装置及存储介质,旨在解决目前的演示文稿文件中组合图形合并渲染时资源标识符冲突导致浏览器或渲染引擎解析时发生错配的技术问题
[0025]本申请提出的一个或多个技术方案,通过为各子矢量图形的定义资源生成具有区分度的标识符,并同步更新主体图形节点中的引用关联,确保来自不同子矢量图形的同名定义资源在合并后不会产生标识符冲突,即使多个子矢量图形中原本存在相同标识符但内容不同的定义资源,合并后也能各自保持独立的定义内容和正确的引用指向,避免渲染错乱。通过对定义资源进行标识符区分与引用同步更新,消除了合并过程中的资源冲突;通过基于层级结构确定位置参数并构建空间变换关系,恢复了子矢量图形在顶层坐标系下的真实空间姿态;通过将处理后的资源与节点汇总生成目标矢量图形,实现了组合图形的高效合并渲染。
Smart Images

Figure CN122904882A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of document parsing and rendering technology, and in particular to methods, apparatus and storage media for processing combined graphics in presentation files. Background Technology
[0002] In the process of parsing presentation files and converting web pages, in order to reduce the number of rendering nodes and maintain visual integrity, multiple sub-vector graphics within a composite graphic are usually merged into a single target vector graphics container. However, current solutions perform this merging process by outputting each vectorizable sub-shape in the composite graphic as an independent SVG (Scalable Vector Graphic). But these SVGs use the same local identifier, and directly merging them leads to identifier conflicts, causing mismatches when browsers or rendering engines parse and reference them. Summary of the Invention
[0003] The main purpose of this application is to provide a method, apparatus and storage medium for processing combined graphics in presentation files, which aims to solve the technical problem of resource identifier conflicts causing mismatches in browser or rendering engine parsing when combined graphics are rendered in presentation files.
[0004] To achieve the above objectives, this application proposes a method for processing combined graphics in a presentation file, the method comprising: The presentation file is parsed to identify mergeable vector objects and extract the sub-vector graphics corresponding to the mergeable vector objects. The sub-vector graphics include definition resources and main graphic nodes. A distinctive identifier is generated for the defined resource, and based on the identifier, the reference association of the main graphic node to the defined resource is updated to obtain the defined resource and the main graphic node after identifier replacement and reference association update; Based on the hierarchical structure of the combined graphics, the position parameters of the mergeable vector objects are determined, and the corresponding spatial transformation relationship is constructed according to the transformation attributes of the mergeable vector objects. The defined resources and main graphic nodes after identifier replacement and reference association updates are summarized, and combined with the position parameters and spatial transformation relationships, a target vector graphic covering the combined graphic area is generated.
[0005] In one embodiment, the step of generating a distinctive identifier for the defined resource includes: Assign a separate namespace to the sub-vector graphics; The original identifier of the defined resource is renamed based on the namespace to generate a distinctive identifier.
[0006] In one embodiment, the step of allocating an independent namespace to the sub-vector graphic includes: Obtain the traversal sequence number, page identifier, combined graphic identifier, sub-element identifier, and sub-vector graphic content summary of the sub-vector graphic within the combined graphic; Based on at least one of the traversal sequence number, the page identifier, the combined graphic identifier, the sub-element identifier, and the sub-vector graphic content summary, generate an independent namespace for the sub-vector graphic.
[0007] In one embodiment, the step of parsing combined graphics in a presentation file and identifying mergeable vector objects includes: A depth-first traversal strategy is adopted, starting with the canvas node in the presentation file as the traversal node; Perform a child node traversal on the current combined graphic node to obtain the traversal result; If the traversal result indicates that the child node of the current combined graphic node is a non-combined graphic node, the vector object corresponding to the non-combined graphic node is determined as a mergeable vector object.
[0008] In one embodiment, after the step of performing child node traversal on the current combined graphic node to obtain the traversal result, the method further includes: If the traversal result indicates that the child node of the current combined graphic node is a combined graphic node, determine the offset of the combined graphic node; Convert the offset to the measurement unit used by the target coordinate system and add it to the current parent offset; Based on the accumulated parent offset, the child node traversal is recursively performed on the combined graphic node to obtain the recursive traversal result. The mergeable vector objects identified in the recursive traversal results are added to the mergeable vector object set of the current level.
[0009] In one embodiment, the step of determining the position parameters of the mergeable vector objects based on the hierarchical structure of the combined graphics includes: Based on the hierarchical structure of the combined graphics, the direct parent combined graphics of the mergeable vector objects are determined, and the relative position coordinates of the mergeable vector objects relative to the direct parent combined graphics are determined. The absolute position coordinates of the mergeable vector object in the top-level coordinate system are calculated based on the relative position coordinates and the offsets of the parent combination graphics at each level, and the position parameters of the mergeable vector object are obtained based on the absolute position coordinates.
[0010] In one embodiment, the step of constructing the corresponding spatial transformation relationship based on the transformation attributes of the mergeable vector object includes: Based on the transformation properties of the mergeable vector object, the transformation parameters are extracted, and the transformation parameters include at least one of translation parameters, rotation parameters, and scaling parameters; Using the center point of the mergeable vector object as the transformation origin, construct the corresponding transformation matrix according to the transformation parameters; The transformation matrix is applied to the main graphic node of the mergeable vector object to generate the spatial transformation relationship of the mergeable vector object.
[0011] In one embodiment, the step of updating the reference association between the main graphical node and the defined resource based on the identifier includes: Obtain a reference table representing the relationship between the original identifier and the referenced position; Obtain the mapping relationship between the original identifier and the identifier; Based on the reference relationship table, the mapping relationship, and the identifier, update the reference association of the defined resource in the main graphical node, so that the reference of the original identifier in the main graphical node points to the identifier.
[0012] In one embodiment, the step of obtaining the reference table representing the mapping relationship between the original identifier and the reference position includes: Scan the reference attributes in the definition resources and main graphic content of each of the sub-vector graphics, wherein the reference attributes include at least one of the following: Uniform Resource Locator (URL) reference attributes, Hypertext reference attributes, and Cross-Document Link (CLR) reference attributes; Establish the relationship between the original identifier and the reference location based on the reference attributes; Construct a reference relationship table based on the described relationship.
[0013] In one embodiment, after the step of generating a distinctive identifier for the defined resource, the method further includes: The content summary of the defined resources with the same calculation content; In the case of multiple defined resources having the same content digest, the same identifier shall be assigned to the defined resources; When multiple defined resources have the same original identifier but different content digests, assign different identifiers to each defined resource.
[0014] In one embodiment, the step of generating a target vector graphic covering the combined graphic region by replacing and referencing the updated defined resources and main graphic nodes with the summary identifier, and combining the position parameters and the spatial transformation relationship, includes: Set the size parameters of the target vector graphic using the width and height of the top-level composite graphic, and set the viewport parameters; According to the traversal order, the definition resources of each sub-vector graphic after identifier replacement and reference association update are summarized into the definition resource area, and the main graphic nodes of each sub-vector graphic are summarized into the main area after combining the corresponding position parameters and spatial transformation relationships. When the set of main graphic nodes in the main area is not empty, a target vector graphic covering the combined graphic area is generated based on the size parameter, the viewport parameter, the defined resource area, and the main area. The target vector graphic inherits the position, size, rotation, and hierarchy attributes of the combined graphic container.
[0015] In one embodiment, the method further includes: Analyze composite graphics in presentation files and identify non-vector objects; Insert the target vector graphic as the first child element into the hypertext markup language container corresponding to the combined graphic; The non-vector objects are converted into corresponding Hypertext Markup Language (HML) elements, and the HML elements are inserted as second child elements into the HML container, so that the target vector graphics and the HML elements corresponding to each non-vector object coexist in the same HML container.
[0016] In one embodiment, the method further includes: During the process of extracting the sub-vector graphics corresponding to the mergeable vector objects, it is detected whether each sub-vector graphic meets the preset abnormal conditions; When the sub-vector graphic meets the abnormal conditions, the sub-vector graphic will be generated into an independent vector graphic element; Insert the vector graphic element into the hypertext markup language container corresponding to the combined graphic.
[0017] Furthermore, to achieve the above objectives, this application also proposes a processing apparatus for combined graphics in a presentation file, the processing apparatus for combined graphics in a presentation file comprising: The parsing module is used to parse the combined graphics in the presentation file, identify mergeable vector objects, and extract the sub-vector graphics corresponding to the mergeable vector objects, wherein the sub-vector graphics include definition resources and main graphic nodes; The generation module is used to generate a distinctive identifier for the defined resource, and based on the identifier, update the reference association of the main graphic node to the defined resource, so as to obtain the defined resource and the main graphic node after identifier replacement and reference association update; The determination module is used to determine the position parameters of the mergeable vector objects based on the hierarchical structure of the combined graphics, and to construct the corresponding spatial transformation relationship according to the transformation attributes of the mergeable vector objects; The summary module is used to summarize the defined resources and main graphic nodes after identifier replacement and reference association updates, and generate target vector graphics covering the combined graphic area by combining the position parameters and the spatial transformation relationship.
[0018] In one embodiment, the generation module is further configured to allocate an independent namespace for the sub-vector graphics; The original identifier of the defined resource is renamed based on the namespace to generate a distinctive identifier.
[0019] In one embodiment, the generation module is further configured to obtain the traversal sequence number of the sub-vector graphic within the combined graphic, the page identifier, the combined graphic identifier, the sub-element identifier, and the sub-vector graphic content summary; Based on at least one of the traversal sequence number, the page identifier, the combined graphic identifier, the sub-element identifier, and the sub-vector graphic content summary, generate an independent namespace for the sub-vector graphic.
[0020] In one embodiment, the parsing module is further configured to update the reference association between the main graphical node and the defined resource based on the identifier, and the steps of obtaining the defined resource and the main graphical node after identifier replacement and reference association update include: A depth-first traversal strategy is adopted, starting with the canvas node in the presentation file as the traversal node; Perform a child node traversal on the current combined graphic node to obtain the traversal result; If the traversal result indicates that the child node of the current combined graphic node is a non-combined graphic node, the vector object corresponding to the non-combined graphic node is determined as a mergeable vector object.
[0021] In one embodiment, the parsing module is further configured to determine the offset of the combined graphic node when the traversal result indicates that the child node of the current combined graphic node is a combined graphic node; Convert the offset to the measurement unit used by the target coordinate system and add it to the current parent offset; Based on the accumulated parent offset, the child node traversal is recursively performed on the combined graphic node to obtain the recursive traversal result. The mergeable vector objects identified in the recursive traversal results are added to the mergeable vector object set of the current level.
[0022] Furthermore, to achieve the above objectives, this application also proposes a processing apparatus for combined graphics in a presentation file, the apparatus comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the processing method for combined graphics in a presentation file as described above.
[0023] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the processing method for combining graphics in a presentation file as described above.
[0024] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the processing method for combining graphics in a presentation file as described above.
[0025] This application proposes one or more technical solutions that, by generating distinctive identifiers for the definition resources of each sub-vector graphic and synchronously updating the reference associations in the main graphic nodes, ensure that definition resources with the same name from different sub-vector graphics will not cause identifier conflicts after merging. Even if multiple sub-vector graphics originally had definition resources with the same identifier but different content, they can still maintain their independent definition content and correct reference points after merging, avoiding rendering errors. By differentiating the identifiers of definition resources and synchronously updating the references, resource conflicts during the merging process are eliminated; by determining the position parameters based on the hierarchical structure and constructing spatial transformation relationships, the true spatial posture of the sub-vector graphics in the top-level coordinate system is restored; and by aggregating the processed resources and nodes to generate the target vector graphic, efficient merging and rendering of combined graphics is achieved. Attached Figure Description
[0026] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0027] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 This is a flowchart illustrating an embodiment of the method for processing combined graphics in the presentation file of this application. Figure 2This is a flowchart illustrating a second embodiment of the method for processing combined graphics in a presentation file of this application. Figure 3 This is a flowchart illustrating a method for processing combined graphics in a presentation file of this application, as provided in Embodiment 3. Figure 4 This is a flowchart illustrating Embodiment 4 of the method for processing combined graphics in the presentation file of this application. Figure 5 This is a schematic diagram of the module structure of the processing device for combined graphics in the presentation file of the embodiments of this application; Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the processing method of combined graphics in the presentation file of this application embodiment.
[0029] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0030] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0031] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0032] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone; or an electronic device capable of performing the above functions, or a processing device for combining graphics in a presentation file, such as a web page backend server. The following description uses a web page backend server as an example to illustrate this embodiment and the subsequent embodiments. All actions involving the acquisition of signals, information, or data in this application are performed in accordance with the relevant data protection regulations of the locality and with authorization from the owner of the corresponding device.
[0033] Based on this, embodiments of this application provide a method for processing combined graphics in a presentation file, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the method for processing combined graphics in the presentation file of this application.
[0034] In this embodiment, the method for processing the combined graphics in the presentation file includes steps S10 to S40: Step S10: Parse the combined graphics in the presentation file, identify mergeable vector objects, and extract the sub-vector graphics corresponding to the mergeable vector objects, wherein the sub-vector graphics include definition resources and main graphic nodes.
[0035] It should be noted that the presentation file can be an electronic document in various formats such as PPTX, ODP, and KEYNOTE. This application does not limit the format; this embodiment uses PPTX as an example for illustration.
[0036] A single slide in a PPTX file typically contains text boxes, pictures, freeform shapes, preset shapes, lines, combined graphics, and nested combined graphics.
[0037] Composite graphics refer to complex objects formed by grouping multiple sub-elements (such as the GroupShape node in PPTX).
[0038] During the parsing process, the webpage's backend server traverses the child node tree of the composite graphic, filtering out mergeable vector objects based on element type and content attributes. Mergeable vector objects typically refer to shape elements containing only pure vector rendering attributes such as path data, fill, and borders, excluding non-vector objects such as text boxes, images, videos, or tables. For each identified mergeable vector object, it is converted into an intermediate format vector description (such as an SVG fragment), and the definition resource and main graphic nodes are separated from this description. During the extraction of sub-vector graphics, the merging switch in the sub-element generation process is turned off to prevent recursive re-entry and repeated merging in the composite graphic processing.
[0039] Defined resources refer to reusable style or effect definitions referenced by the main graphic, such as linear gradients, radial gradients, pattern fills, filter effects, cropping paths, or masks (corresponding to the content of the defs element in SVG); main graphic nodes refer to the nodes that actually constitute the geometric outline and visible content of the graphic, such as path, circle, polygon, or g elements.
[0040] By accurately identifying and extracting vector sub-elements that were originally scattered within the combined graphics, a standardized data foundation is provided for subsequent merging processing. At the same time, non-vector objects that are not suitable for merging are excluded, avoiding semantic loss or interactive function failure caused by forced merging.
[0041] In one feasible implementation, an exception rollback mechanism is set up during the extraction of sub-vector graphics corresponding to mergeable vector objects. Therefore, after the step of identifying mergeable vector objects, the method further includes: during the extraction of sub-vector graphics corresponding to the mergeable vector objects, detecting whether each sub-vector graphic meets a preset exception condition; when the sub-vector graphic meets the exception condition, generating an independent vector graphic element from the sub-vector graphic; and inserting the vector graphic element into the hypertext markup language container corresponding to the combined graphic.
[0042] In practical engineering applications, presentation files come from various sources, and may contain errors such as those exported by editing software, corrupted files during transmission, or non-standard data generated by non-standard plugins. This can lead to incomplete data structures or the inclusion of illegal parameters in some sub-vector graphics. If the merging process lacks fault tolerance for these abnormal data, it can easily cause parsing interruptions, memory overflows, or rendering engine crashes, resulting in the entire combined graphic or even an entire slide failing to display correctly. Therefore, this application embeds real-time anomaly detection logic on the critical path of extracting sub-vector graphics. This detection occurs during the process of attempting to convert the original document nodes into standardized vector descriptions (such as SVG fragments).
[0043] The preset exception conditions cover a variety of data states that may lead to merging failure or rendering errors, such as parsing failure, the existence of unrewriteable external references, or invalid transformation parameters. Parsing failure means that the underlying XML or JSON structure of the sub-vector graphics does not conform to the expected specifications, such as missing necessary path data attributes, unclosed tags, or incorrect encoding formats, causing the converter to be unable to generate valid vector instructions. Unrewriteable external references mean that the sub-vector graphics contain links to external resources (such as image fills or external symbol references), but these links are invalid, blocked by security policies, or cannot be resolved to local resources in the current context. Forcing a merge will result in broken icons or blank areas during rendering. Invalid transformation parameters mean that the coordinates, rotation angles, or scaling ratios of the sub-graphics contain non-numeric (NaN), infinity, or out-of-reasonable values.
[0044] When a sub-vector graphic is detected to meet any of the above-mentioned abnormal conditions, the processing flow of the entire composite graphic is not terminated; instead, a local rollback strategy is triggered. Specifically, the abnormal sub-graphic is not included in the target vector graphic for merging and optimization; instead, it is generated as a separate independent vector graphic element. Although this independent vector graphic element is logically separated from the merge container, it still needs to maintain the same position and style as the original design in visual presentation. Therefore, when generating this independent element, the correct positioning and transformation attributes are set according to the absolute position coordinates and spatial transformation relationships to ensure that its rendering position on the page completely coincides with the expected position within the original composite graphic. Subsequently, this vector graphic element is inserted as a child node into the hypertext markup language container corresponding to the composite graphic. At this point, the container contains the target vector graphic formed by merging normal sub-graphics, the independent vector graphic element that has rolled back due to the abnormality, and non-vector objects. These three types of elements coexist in the same container according to their respective hierarchical order, jointly restoring the complete visual effect of the original composite graphic.
[0045] In one feasible implementation, the step of "parseting the combined graphics in the presentation file and identifying mergeable vector objects" in step S10 may include steps A11-A13: Step A11: Use a depth-first traversal strategy, starting with the canvas node in the presentation file as the traversal node; In choosing a traversal strategy, this application adopts depth-first search (DFS) instead of breadth-first search. The reason is that the object model of the presentation file is essentially a tree structure with strict parent-child nesting relationships. Depth-first search can naturally go deeper along the path of "parent container-child container-leaf element". This not only conforms to the storage logic of document data, but more importantly, it can ensure that the access order of elements is consistent with the stacking order (Z-order) during visual rendering.
[0046] The starting point of the traversal is set to the canvas node, that is, the root container or slide node of the presentation page, to establish the boundary of the global search and ensure that all levels of combined graphics within the page can be included in the scanning range.
[0047] In practical implementation, the presentation file can be parsed to obtain a page element tree, and the page with the combined graphic SVG merging function enabled can be identified. For example, the merge_group_svg request parameter can be used to control whether the combined graphic SVG merging is enabled. When this parameter is off, each child element is output separately according to the original processing method; when this parameter is on, the combined graphic enters the recursive collection and merging process of this application.
[0048] Step A12: Perform a child node traversal on the current combined graphic node to obtain the traversal result; During child node traversal, each visited node undergoes a type determination. First, nodes that are "non-combination graphic nodes," such as GroupShape in PPTX format or the g tag in XML structure, are directly excluded from merging objects. Since combination graphic nodes only serve as logical grouping and coordinate transformation references, they do not contain actual path data or fill styles. If they are incorrectly identified as merging objects and attempts are made to extract their vector descriptions, not only will effective geometric information not be obtained, but the original hierarchical nesting structure will be disrupted, causing subsequent coordinate transformation calculations to lose their reference. Second, the non-combination graphic node must also meet the attribute requirement of being a "vector object," meaning the node should contain geometric contours that can be described by vector commands (such as path, circle, polygon, etc.), and should not include non-vector content such as text boxes, bitmap images, video placeholders, or tables.
[0049] Step A13: If the traversal result indicates that the child node of the current combined graphic node is a non-combined graphic node, the vector object corresponding to the non-combined graphic node is determined as a mergeable vector object.
[0050] For example, when processing a combined graphic containing a rectangle, text labels, and an image, the above logic marks the rectangle as a mergeable vector object, while leaving the text labels and image in place or delegating them to other processes.
[0051] In practice, vector shape elements include at least shape type, path data, fill information, border information, gradient or pattern definition, shadow or filter information, and optional text content.
[0052] The system can determine whether a child element can be a mergeable vector object based on its element type, path data, and content attributes. Shape elements with path data are identified as mergeable vector objects, while line objects are excluded. When a candidate shape contains visible text, it is not merged as a mergeable vector object; instead, the text overlay is preserved or treated as a non-vector object. When a child element is a mergeable vector object, the single-element HTML / SVG generation logic is invoked to obtain the original SVG, and the combined graphic merging switch is explicitly turned off to prevent recursive merging from re-entering when generating a single-element SVG. Subsequently, the content inside the `defs` attribute of the original SVG and the main content excluding `defs` are extracted.
[0053] In one feasible implementation, the recursive traversal of the composite graphic specifically includes different types of composite graphics. Therefore, after step A12, the following steps are also included: If the traversal result indicates that the child node of the current combined graphic node is a combined graphic node, determine the offset of the combined graphic node; Convert the offset to the measurement unit used by the target coordinate system and add it to the current parent offset; Based on the accumulated parent offset, the child node traversal is recursively performed on the combined graphic node to obtain the recursive traversal result. The mergeable vector objects identified in the recursive traversal results are added to the mergeable vector object set of the current level.
[0054] For the top-level composite graphic, initialize the parent offsets `parentOffsetX` and `parentOffsetY` to 0, and create a shared namespace sequence state within the composite graphic. Traverse the child elements in their original hierarchical order.
[0055] This embodiment primarily addresses the handling mechanism for a special scenario encountered during traversal: nested composite graphics (i.e., child nodes are themselves containers rather than leaf nodes). During depth-first traversal, when it is detected that the currently visited child node is not a regular vector shape but a new composite graphic node, it means that a deeper level of nesting has been entered. In this case, the offset of the child composite graphic node relative to its direct parent container is first determined. This offset is typically defined by the underlying data structure of the presentation file; for example, in PPTX format, it might be represented as a transformation matrix (Transform) or position attribute (Offset) within a GroupShape element. It describes the starting drawing position of the child composite graphic in the local coordinate system of its parent container.
[0056] After obtaining the original offset, it is converted to the measurement unit used by the target coordinate system and added to the current parent offset. When the child element is a nested composite graphic, its own left and top values are converted to pixel units used by the target SVG and added to the parent offset respectively, and then its child elements are processed recursively. The defined resources and main nodes in the recursive result are merged into the top-level collection, while non-SVG content is retained in the corresponding composite container.
[0057] Because the internal units of measurement in presentation files often differ from those used in the final generated target vector graphics (such as SVG or HTMLCanvas), for example, the original document might use imperial units (such as EMU, English Metric Units) or points to record positions, while the target rendering environment typically uses pixels as the standard unit. Directly adding values from different units mathematically would lead to coordinate calculation errors. Therefore, before each recursive move to the next level, the local offset of the current level is normalized to the target unit and then superimposed on the accumulated offset passed down from the upper level. This "conversion-accumulation" mechanism effectively constructs a global coordinate transfer chain that runs through the entire nested tree, ensuring that the positional information of a child object can be accurately mapped to the unified reference system at the top level, regardless of how many layers of combined graphics it is hidden under.
[0058] Subsequently, using the cumulatively updated parent offset as the new baseline context, the child node traversal is recursively performed on the child composite graphic node. After the recursive traversal is completed, a set of mergeable vector objects and their related data identified in this deep nested structure are obtained. Finally, these deeply identified objects are merged into the current level's set of mergeable vector objects. All suitable vector primitives are eventually collected into a unified list or set, and each primitive carries a fully accumulated absolute position parameter. When the child element is a non-SVG object, the original element HTML generation logic is called again, and the generated result is added to the non-SVG content set. Thus, the same composite graphic can form a hybrid output of "unified SVG vector layer + ordinary HTML object layer".
[0059] To illustrate the process more clearly, consider a three-level nested structure: Assume the top-level composite graphic A contains a sub-composite graphic B, and B contains a pure vector shape C. When traversing to B, the system obtains the offset of B relative to A (e.g., 100px), adds it to the current parent offset (initially 0), resulting in 100px. Then, recursively traversing to C within B, it obtains the offset of C relative to B (e.g., 50px), adds it to the current parent offset (100px), resulting in 150px. Finally, shape C is identified as a mergeable object and added to the top-level set to be merged with a global offset of 150px. This effectively solves the problem of coordinate baseline unification in deeply nested structures, ensuring that all sub-objects can be correctly merged within the same coordinate system, and completely eliminating the risk of visual displacement or misalignment caused by layer flattening.
[0060] For example, a top-level composite graphic contains a nested composite graphic located at (40pt, 30pt), and the nested composite graphic contains a vector shape located at (10pt, 8pt). The two offsets are converted to pixels and accumulated to obtain the absolute position of the sub-shape in the top-level target SVG. If the sub-shape is rotated 30 degrees and horizontally flipped, a transformation chain consisting of translation, rotation, horizontal scaling, and reverse translation is constructed around the shape's center, and its main node is wrapped in a g node.
[0061] Step S20: Generate a distinctive identifier for the defined resource, and based on the identifier, update the reference association of the main graphic node to the defined resource to obtain the defined resource and the main graphic node after identifier replacement and reference association update.
[0062] In practice, different sub-vector graphics may use the same local identifier in their original state. For example, multiple sub-graphics may define a gradient with the id "gradient1". If they are merged directly, it will cause an identifier conflict, making it impossible for the rendering engine to distinguish the resources correctly.
[0063] Therefore, this step generates a new, unique, and distinguishable identifier for each sub-vector graphic's definition resource within the current merging context. Generation methods can employ strategies such as namespace prefixes, hash values, or incremental sequence numbers. After generating the new identifier, the system not only renames the ID attribute of the definition resource itself but also synchronously scans and updates all references to that resource in the main graphic nodes. For example, attribute values such as fill="url(#oldId)", stroke="url(#oldId)", filter="url(#oldId)", or xlink:href="#oldId" are replaced with references to the new identifier. Specifically, for each oldId, url(#oldId) is replaced with url(#newId), and href="#oldId" and xlink:href="#oldId" are replaced with the corresponding new identifier.
[0064] This end-to-end synchronous update mechanism ensures that the reference relationship between the main graphic and the defined resources remains closed and correct after the identifier is reconstructed, fundamentally eliminating style mismatch or rendering abnormalities caused by ID collisions during merged rendering.
[0065] In one feasible implementation, the step S20 of "updating the reference association between the main graphical node and the defined resource based on the identifier" may include steps A21 to A23: Step A21: Obtain the reference relationship table representing the relationship between the original identifier and the reference position; It's important to note that at the time, the reference table was a metadata index built during the parsing phase using deep scanning. It precisely recorded all the specific locations in which each original identifier was referenced within the current sub-vector graphics. These reference locations included not only URL references in common main graphic nodes such as fill, stroke, filter, mask, or clip-path attributes (e.g., fill="url(#gradient1)"), but also cross-document link reference attributes (e.g., xlink:href="#symbol1") and hypertext reference attributes. The scope of the reference table further covered mutual references within defined resources (e.g., a complex filter referencing another blur filter), style sheet declarations (CSS rules in the style attribute or embedded style tag), reused nodes (use elements), and text path nodes (textPath).
[0066] In one feasible implementation, step A21 may include: scanning the reference attributes in the definition resources and main graphic content of each of the sub-vector graphics, wherein the reference attributes include at least one of the Uniform Resource Locator (URL) reference attributes, Hypertext reference attributes, and Cross-Document Link (CLR) reference attributes; establishing a relationship between the original identifier and the reference location based on the reference attributes; and constructing a reference relationship table based on the relationship.
[0067] During the conversion of presentation files into vector graphics, the way sub-vector graphics reference defined resources is not singular or fixed, but rather scattered throughout the document structure with varying syntax. If only common fill or stroke attributes are scanned, other critical references are easily overlooked, leading to missing styles or rendering errors in the merged graphics.
[0068] Therefore, this application constructs a comprehensive scanning mechanism, whose scanning scope strictly covers two core areas of the sub-vector graphics: one is the internal definition of the resource, that is, the interdependencies between nodes within the resource definition area, such as a complex filter effect referencing another Gaussian blur filter, or a pattern fill referencing a symbol object; the other is the main graphic content, that is, the calls made by the nodes that actually constitute the visible part of the graphic to the defined resource. This dual scanning strategy ensures that both internal dependencies between resources and external service calls from resources can be completely captured.
[0069] During the scanning process, the identified reference attributes covered a variety of standard and non-standard reference syntaxes. Among them, the Uniform Resource Locator (URL) reference attributes were manifested as references using the "url(#id)" format in attribute values such as fill, stroke, filter, mask, clip-path, and marker-start / marker-mid / marker-end.
[0070] Hypertext reference attributes primarily appear in reuse nodes (use) or text path nodes (textPath), typically pointing to the target resource in the form of an "href" attribute. While cross-document link reference attributes are relatively rare in single-file merging scenarios, the system still supports resolving reference attributes under traditional namespaces such as "xlink:href" to ensure compatibility with imported or legacy presentation data.
[0071] After identifying a specific reference attribute, the relationship establishment and table construction steps are then executed. Specifically, the original identifier being referenced is extracted from the matched attribute value, and the node path, attribute name, and attribute value string fragment of the attribute are recorded, thus forming a complete "original identifier-reference location" record. For example, when "url(#grad1)" is found in the fill attribute of a path node, a record is generated indicating that the original identifier "grad1" is referenced at the fill attribute of that path node. As the scan progresses, all such records are summarized and structured for storage, ultimately generating the aforementioned reference relationship table.
[0072] Specifically, it further scans url(#id), href="#id", xlink:href="#id", and attributes such as fill, stroke, filter, mask, clip-path, marker-start, marker-mid, and marker-end to establish a reference relationship table between the defined identifiers and their reference locations. It also parses the begin, end, or target references of the style attribute, CSS declarations in the style node, use nodes, textPath nodes, and animation nodes. For cases where defs reference other defs resources, the corresponding references are also added to the relationship table to ensure reference closure after renaming.
[0073] Step A22: Obtain the mapping relationship between the original identifier and the identifier; The mapping relationship represents a one-to-one correspondence from the "original identifier" to the "new identifier with distinctiveness".
[0074] In practice, for each sub-SVG to be merged, the system can scan the defs and id attributes in the main content to create an original identifier table.
[0075] Step A23: Based on the reference relationship table, the mapping relationship, and the identifier, update the reference association of the defined resource in the main graphical node, so that the reference of the original identifier in the main graphical node points to the identifier.
[0076] When performing an update operation, instead of blindly replacing all strings in the document content, the reference relationship table is used as a navigation map to accurately locate each reference point that needs to be modified, then the mapping relationship is queried to obtain the corresponding new identifier, and finally the targeted replacement is performed.
[0077] For example, when the reference table indicates that the fill attribute of a path node references a resource with the original ID "grad1", and the mapping relationship indicates that "grad1" should be converted to "svg0-grad1" in the current namespace, the system only updates the fill attribute value of that path node to "url(#svg0-grad1)", without affecting other text content in the document that may contain the same string but does not belong to the reference syntax. Furthermore, during the replacement process, special characters in regular expressions that may exist in the original identifier are escaped to prevent the replacement logic from being accidentally triggered or parsed incorrectly.
[0078] First, modify the `id` attribute in `defs` according to the mapping table, then synchronously modify the main content and all references within `defs` according to the reference relationship table. In further implementation, apply the same mapping to `#oldId` in CSS selectors, resource references in the `style` attribute, `use` and `textPath` references, filter chain references, and animation dependency references. During rewriting, escape special characters in the original identifiers using regular expressions to prevent the replacement expression from interpreting the identifier content as matching syntax.
[0079] Step S30: Based on the hierarchical structure of the combined graphics, determine the position parameters of the mergeable vector objects, and construct the corresponding spatial transformation relationship according to the transformation attributes of the mergeable vector objects.
[0080] It's understandable that composite graphics often have multi-layered nested structures, and the original coordinates of child elements are usually local coordinates relative to their direct parent composite graphics. To correctly merge all child vector graphics into a unified target container, local coordinates can be converted to absolute position parameters in the top-level coordinate system. This requires recursively traversing the hierarchy tree and accumulating the offsets of each parent composite graphic. Furthermore, child vector graphics may also contain transformation attributes such as rotation, horizontal flip, vertical flip, or scaling. If only path data is copied while ignoring these transformations, the merged graphics will exhibit positional offsets or pose distortions. Therefore, based on the extracted transformation parameters (such as rotation angle, flip flag, scaling ratio, etc.), a corresponding spatial transformation relationship (e.g., an affine transformation matrix) can be constructed with the geometric center of the child vector graphics as the reference point. This transformation relationship can accurately describe the true spatial pose of the child graphics in the top-level coordinate system.
[0081] Step S40: Summarize the defined resources and main graphic nodes after identifier replacement and reference association update, and combine them with the position parameters and spatial transformation relationships to generate a target vector graphic covering the combined graphic area.
[0082] Understandably, the processed sub-vector graphics components are assembled. First, all deduplicated and renamed definition resources are aggregated into the resource definition area of the target vector graphics (e.g., within the defs tag under the SVG root node). Second, following the original traversal order (to maintain the correct occlusion hierarchy), the main graphic nodes with applied position parameters and spatial transformations are sequentially appended to the main drawing area of the target vector graphics. The final generated target vector graphics is an independent, self-contained vector rendering container (e.g., a complete SVG element), whose size and viewport (viewBox) are set to cover the entire boundary area of the original combined graphics, and inherits the container properties of the original combined graphics on the page, such as absolute positioning, rotation, and stacking order. Through this aggregation generation mechanism, the complex combined graphics originally composed of multiple independent DOM nodes are optimized into a single lightweight vector graphics node. This significantly reduces the complexity of the page rendering tree and improves rendering performance while fully preserving the visual effects, style details, and spatial layout of the original graphics, achieving the best balance between performance and quality.
[0083] Specifically, the service interface receives a PPTX file and the `merge_group_svg` parameter. It parses the file to obtain the slideshow JSON data and calls the HTML generation process page by page. When processing group elements and the switch is on, it calls the combined graphic SVG collection and merging module. After generation, it returns the HTML for each page, the total number of pages, page width and height, and information on optional media resources.
[0084] The switch can be used as a cache key or conversion version identifier, allowing the results of enabling and disabling merging to be cached separately. Service logs can record page numbers, combined graphic numbers, the number of merged SVGs, the number of renamed identifiers, the number of reference rewrites, and the number of rollbacks, for quality analysis.
[0085] This embodiment provides a method for processing combined graphics in a presentation file. By generating distinctive identifiers for the definition resources of each sub-vector graphic and synchronously updating the reference associations in the main graphic nodes, it ensures that definition resources with the same name from different sub-vector graphics will not cause identifier conflicts after merging. Even if multiple sub-vector graphics originally had definition resources with the same identifier but different content, they can still maintain their independent definition content and correct reference points after merging, avoiding rendering errors. By differentiating the identifiers of definition resources and synchronously updating the references, resource conflicts during the merging process are eliminated; by determining the position parameters based on the hierarchical structure and constructing spatial transformation relationships, the true spatial posture of the sub-vector graphics in the top-level coordinate system is restored; and by summarizing the processed resources and nodes to generate the target vector graphic, efficient merging and rendering of combined graphics is achieved.
[0086] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 Step S20 includes steps S201 to S203: Step S201: Assign an independent namespace to the sub-vector graphics.
[0087] It should be noted that when merging multiple sub-vector graphics into a single target vector graphic, the original definition resources of different sub-vector graphics, such as linear gradients, pattern fills, and filter effects, may use the same local identifier, for example, both named "gradient1" or "filter1". If these resources are placed directly in the same document scope, it will cause identifier conflicts, making it impossible for the rendering engine to correctly resolve the reference relationships.
[0088] To address this issue, this embodiment introduces an independent namespace mechanism. An independent namespace is not merely a simple string prefix, but rather refers to constructing a logically isolated resource definition domain for each sub-vector graphic to be merged. Unlike the random string (such as UUID) renaming scheme commonly used in existing solutions, the namespace in this embodiment is generated based on the structural position or content characteristics of the sub-vector graphics within the combined graphic, possessing determinism and readability.
[0089] In one feasible implementation, step S201 may include steps B11-B12: Step B11: Obtain the traversal sequence number, page identifier, combined graphic identifier, sub-element identifier, and sub-vector graphic content summary of the sub-vector graphic within the combined graphic; It is understood that this embodiment adopts a multi-dimensional factor collaborative generation strategy. The traversal sequence number refers to the order in which the current sub-vector graphics are accessed when performing a depth-first traversal of the combined graphics. The traversal sequence number can ensure that even if there are multiple sub-elements with the same structure in the same combined graphics, they can obtain different namespaces due to their different processing order, thereby achieving order-sensitive uniqueness differentiation.
[0090] Page identifiers and composite graphic identifiers provide hierarchical isolation boundaries. Page identifiers ensure that resources across different slide pages do not interfere with each other, while composite graphic identifiers ensure that resources between different composite graphic containers within the same page are independent, preventing identifier collisions across containers or pages. Child element identifiers typically refer to the inherent ID or handle of the element in the original document structure, serving as the original anchor point for object identity and helping to establish the mapping relationship between old and new identifiers during debugging or backtracking. The sub-vector graphic content digest is a feature value obtained by hashing the normalized content of the defined resource (such as gradient color values, path data, filter parameters, etc.). The core function of the sub-vector graphic content digest is to provide idempotency guarantees, meaning that as long as the content of the defined resource does not change, the generated content digest remains consistent regardless of changes in the page it resides on or the traversal order.
[0091] Step B12: Generate an independent namespace for the sub-vector graphics based on at least one of the traversal sequence number, the page identifier, the combined graphic identifier, the sub-element identifier, and the sub-vector graphics content summary.
[0092] In practice, multiple input factors can be concatenated into a prefix string according to preset rules, and then this prefix string can be added before the original identifier to finally generate a new unique identifier with a namespace tag. Alternatively, any factor can be selected as an independent namespace representation for the sub-vector graphics, for example, using the incrementing index within the combined graphic as the namespace index.
[0093] The independent namespace representation of a sub-vector graphic is: P=F(PageId, GroupId, TraverseIndex, ContentDigest), where PageId is the page identifier, GroupId is the group graphic identifier, TraverseIndex is the traversal index, and ContentDigest is the content summary of the sub-vector graphic.
[0094] For example, the traversal sequence number can be concatenated with the page identifier to obtain a prefix in the form of "p1-s3-", so that all identifiers from the definition resource of the third sub-vector graphic on the first page have this prefix, thus avoiding the duplication of identifiers between different sub-vector graphics from the root.
[0095] Step S202: Rename the original identifier of the defined resource based on the namespace to generate a distinguishable identifier.
[0096] In practice, when renaming is performed, the allocated namespace is used as a prefix or modifier and concatenated with the original identifier that defines the resource according to preset rules, thereby generating a new identifier that is globally unique in the current merge context.
[0097] For example, if a subvector graphic is assigned the namespace "svg0" and its original identifier is "gradient1", then the renamed identifier can be "svg0-gradient1".
[0098] Understandably, in order to solve the problem of redundancy and conflict in resource definitions during the merging of combined graphics, after generating a distinguishable identifier, the method also includes: calculating the content summary of the defined resources with the same content; assigning the same identifier to the defined resources when the content summaries of multiple defined resources are the same; and assigning different identifiers to each defined resource when the original identifiers of multiple defined resources are the same but the content summaries are different.
[0099] Understandably, the content summary is not a direct hash calculation of the original XML or text data. Instead, it is calculated by first normalizing defined resources with identical content. Normalization includes sorting node attributes, converting color values to standard hexadecimal format, removing redundant whitespace characters, and normalizing transformation parameters. The purpose is to eliminate non-semantic noise caused by differences in editor export or serialization order, ensuring that only resources with truly identical visual appearance are considered identical.
[0100] The algorithm for calculating the content digest can be MD5, SHA-256, or other hash algorithms that can uniquely characterize data features, and the generated digest value serves as a digital fingerprint of the resource content.
[0101] In terms of processing logic, a differentiated identifier allocation strategy is executed based on the comparison results of the content digests. When multiple resources with identical content digests are detected, the same identifier is assigned to them regardless of whether these resources have the same identifier in the original document. This situation typically corresponds to completely duplicated resources, such as multiple sub-shapes in a composite graphic using linear gradients with completely consistent visual effects, but defined as "gradient1", "gradient2", etc., respectively in the original data. By reusing the same identifier, automatic deduplication of resources is achieved, which not only significantly reduces the number of nodes defining resource areas in the target vector graphics and reduces document size, but also allows browsers or rendering engines to utilize caching mechanisms more efficiently, avoiding repeated parsing and rendering of the same styles, thereby improving overall rendering performance.
[0102] When multiple defined resources are detected to have the same original identifier but different content digests, different identifiers are assigned to each defined resource. This situation corresponds to a "hierarchical resource with the same name" conflict, which is the most likely point of visual error risk in merged rendering. For example, in a complex presentation graphic composition, two different sub-vector graphics may each contain a linear gradient definition with the ID "grad1", but one is a gradient from red to white and the other is a gradient from blue to black. If merging is based solely on the original ID without content validation, the post-processed resource will overwrite the pre-processed resource, causing an error in the fill style of one of the graphics.
[0103] In this embodiment, because the content digests of the two resources are identified to be inconsistent, even if their original IDs are the same and they may be in the same namespace generation context, the system will generate new, distinct identifiers such as "ns1-grad1" and "ns2-grad1" for them by appending suffixes, incrementing serial numbers, or utilizing the aforementioned independent namespace mechanism, and will synchronously update their respective reference relationships. This approach fundamentally eliminates the problem of style misuse caused by blindly merging resources with the same name.
[0104] Step S203: Based on the identifier, update the reference association between the main graphic node and the defined resource to obtain the defined resource and the main graphic node after identifier replacement and reference association update.
[0105] In practice, based on each reference location recorded in the reference relationship table, the attribute values of the original reference identifiers are updated one by one to the reference format corresponding to the new identifiers, maintaining the original reference syntax rules unchanged. For mutual references existing within the resource definition area, the same rules are followed for synchronous updates, ensuring that all dependencies correctly point to the renamed resources and avoiding issues such as broken references or pointing to incorrect resources. After completing all reference updates, a set of defined resources and a set of main graphical nodes with no identifier conflicts and complete and correct reference relationships are obtained.
[0106] For the original identifier oldId, generate a new identifier newId and establish a mapping table M: newId=P+"-"+oldId,M[oldId]=newId Conflicts can be categorized into: strong conflicts with the same ID but different resource content, deduplicatable resources with different IDs but the same normalized content, prefix conflicts with inconsistent XML namespace prefix correspondences, and CSS class name or animation name conflicts. This embodiment at least handles defs identifier conflicts and their reference rewriting.
[0107] For example, a composite graphic contains two vector sub-shapes. Both sub-SVGs have a `linearGradient` with `id="gradient1"` in their `defs` statements, but their gradient colors and directions differ; both paths use `fill="url(#gradient1)"`. The system assigns namespaces `svg0` and `svg1` to the two sub-SVGs in traversal order, renames the definitions to `svg0-gradient1` and `svg1-gradient1` respectively, and synchronously modifies the `fill` references of the corresponding paths. After merging, the two shapes retain their respective gradients and do not share them.
[0108] This embodiment allocates an independent namespace for the sub-vector graphics; renames the original identifier of the defined resource based on the namespace to generate a distinctive identifier; and updates the reference association of the main graphic node to the defined resource based on the identifier, resulting in the defined resource and main graphic node after identifier replacement and reference association update. Through the deterministic generation rules of the namespace, the global uniqueness of the identifier is guaranteed, completely resolving the resource identifier conflict problem between different sub-vector graphics, while avoiding the redundant entropy increase caused by random naming. The generated identifier is traceable, facilitating subsequent debugging and modification, and improving the reliability and maintainability of the combined graphic merging process.
[0109] Based on the first embodiment of this application, in the third embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3 Step S30 includes steps S301 to S305: Step S301: Based on the hierarchical structure of the combined graphics, determine the direct parent combined graphics of the mergeable vector objects, and determine the relative position coordinates of the mergeable vector objects relative to the direct parent combined graphics.
[0110] It's important to note that in presentation files, composite graphics often present a complex, nested tree structure. The original coordinates of child elements are usually local coordinates relative to their direct parent container. For example, a vector shape located inside a nested composite graphic has its `left` and `top` properties describing only its position within that nested container, not its position across the entire slide page or the final target vector graphic. If only these local coordinates are used for rendering, the child graphic will deviate from its expected visual position when the nested container itself shifts.
[0111] Therefore, this application clearly distinguishes between the concepts of direct parent composite graph and composite graphs of parent levels. The direct parent composite graph refers to the nearest container that directly wraps the currently mergeable vector object in the hierarchy tree, providing the local positioning reference for the child object; while the composite graphs of parent levels refer to the set of all ancestor nodes traced upwards from the direct parent to the top-level composite graph container, which together constitute the coordinate transfer link from local to global.
[0112] For example, the relative position coordinates of the vector objects relative to the direct parent composite graphic can be (left, top).
[0113] Step S302: Calculate the absolute position coordinates of the mergeable vector object in the top-level coordinate system based on the relative position coordinates and the offsets of the parent combination graphics at each level, and obtain the position parameters of the mergeable vector object based on the absolute position coordinates.
[0114] In practical implementation, the offsets of the parent-level combined graphics from the outside to the inside are (giX, giY), and the absolute position coordinates of the combined vector objects in the top-level coordinate system are calculated as follows: absX=ptToPx(left)+ΣgiX absY=ptToPx(top)+ΣgiY Here, giX and giY are both converted to pixel units used by the target SVG. Using the above formula, the position parameters of the mergeable vector objects are obtained, which allows us to merge the absolute position coordinates (absX, absY) of the vector objects.
[0115] Step S303: Extract transformation parameters based on the transformation attributes of the mergeable vector object. The transformation parameters include at least one of translation parameters, rotation parameters, and scaling parameters.
[0116] It should be understood that in presentation files, the rotation or flipping operations performed by the user on shapes are usually recorded in the underlying data model as transformation properties relative to the geometric center of the shape itself.
[0117] Step S304: Using the center point of the mergeable vector object as the transformation origin, construct the corresponding transformation matrix according to the transformation parameters.
[0118] In common vector graphics rendering standards (such as SVG) or web rendering engines, the default transformation reference point is often the top-left origin (0, 0) of the coordinate system. If the original transformation parameters are directly applied to the merged graphic without reference point correction, the graphic will rotate around the top-left corner instead of its visual center, causing an unexpected and drastic shift in its position on the canvas, commonly known as "skewness". Therefore, this application uses the center point of the mergeable vector objects as the transformation origin.
[0119] In the specific execution of constructing spatial transformation relationships, transformation parameters are first extracted from the properties of mergeable vector objects. These parameters include not only translation parameters describing positional movement (such as offset relative to the parent container), but also rotation parameters describing orientation adjustment (such as rotation angle θ) and scaling parameters describing size or mirror changes. Scaling parameters include both conventional aspect ratio scaling and negative scaling factors used to characterize horizontal or vertical flips. For example, when a horizontal flip flag is detected, the horizontal scaling factor fx is set to -1; when a vertical flip flag is detected, the vertical scaling factor fy is set to -1; and if there is no flip, the corresponding factor is 1.
[0120] Subsequently, a composite transformation matrix is constructed based on the extracted parameters. To achieve correct spatial transformation with the center point as the reference, this transformation matrix is not a single basic transformation matrix, but a composite matrix formed by cascading multiple basic transformation matrices in a specific order. In a preferred embodiment, let the transformed width and height of the sub-shape be w and h, respectively, and the center coordinates be cx = absX + w / 2 and cy = absY + h / 2. The construction of this composite transformation matrix follows a logical sequence of "translation-rotation / scaling-reverse translation," and its mathematical expression is as follows: M=T(cx, cy)·R(θ)·S(fx, fy)·T( w / 2, h / 2) Where θ is the rotation angle; when flipping horizontally, fx = 1, otherwise fx=1; when flipped vertically, fy= 1, otherwise fy=1.
[0121] Step S305: Apply the transformation matrix to the main graphic node of the mergeable vector object to generate the spatial transformation relationship of the mergeable vector object.
[0122] Finally, the constructed transformation matrix M is applied to the main graphic node of the mergeable vector objects. By wrapping the main content of the child SVG in the g node to which this transformation chain is applied, it maintains its actual position and orientation within the PPTX combined graphic in the target SVG.
[0123] In practical implementation, a container node (such as the `g` element in SVG) can be created to wrap the main graphic node, and the transformation matrix `M` can be converted into the `transform` property value of that container node. In this way, the main graphic node and all its internal sub-paths, fill styles, etc., will inherit this spatial transformation relationship, thus presenting a spatial posture in the target vector graphics that is completely consistent with the original presentation file. By introducing a composite transformation chain construction mechanism based on the geometric center, the problems of graphic misalignment, deformation, or positional drift caused by mismatched transformation reference points are fundamentally eliminated, ensuring the geometric fidelity of complex composite graphics during the layer flattening and merging rendering process.
[0124] This embodiment, based on the hierarchical structure of the combined graphics, determines the direct parent combined graphics of the mergeable vector objects and the relative position coordinates of the mergeable vector objects relative to the direct parent combined graphics. It calculates the absolute position coordinates of the mergeable vector objects in the top-level coordinate system based on the relative position coordinates and the offsets of each level of parent combined graphics, and obtains the position parameters of the mergeable vector objects based on the absolute position coordinates. It extracts transformation parameters based on the transformation attributes of the mergeable vector objects, including at least one of translation, rotation, and scaling parameters. Using the center point of the mergeable vector objects as the transformation origin, it constructs a corresponding transformation matrix based on the transformation parameters. The transformation matrix is applied to the main graphic nodes of the mergeable vector objects to generate the spatial transformation relationship of the mergeable vector objects. Through these steps, the problems of graphic position offset and deformation caused by local coordinate mismatch and inconsistent transformation reference points under nested hierarchical structures are solved. During the process of flattening and merging the combined graphics hierarchy, it ensures that each mergeable vector object can restore the same position, rotation, and scaling state as in the original presentation, improving the geometric accuracy and visual fidelity of the exported combined graphic vectors.
[0125] Based on the first to third embodiments of this application, in the fourth embodiment of this application, the content that is the same as or similar to the first to third embodiments described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 4 Step S40 includes steps S401 to S403: Step S401: Set the size parameters of the target vector graphic using the width and height of the top-level composite graphic, and set the viewport parameters.
[0126] In practice, the width and height of the top-level grouped graphic can be used as the size parameters of the target SVG, while the viewport parameter viewBox is set to "0 0 groupWidthPx groupHeightPx".
[0127] Step S402: According to the traversal order, the definition resources of each sub-vector graphic after identifier replacement and reference association update are summarized into the definition resource area, and the main graphic nodes of each sub-vector graphic are summarized into the main area after combining the corresponding position parameters and spatial transformation relationships.
[0128] It should be understood that the Z-order of elements in a presentation file is determined by their order in the document tree, with elements traversed first at the bottom and those traversed later at the top. Therefore, when writing the main graphic nodes of each sub-vector graphic into the main area of the target vector graphic, they are appended sequentially according to the depth-first traversal order. Disrupting this order will cause background graphics that should be occluded to incorrectly cover foreground graphics, resulting in severe visual hierarchy confusion. Simultaneously, for defined resources that have undergone identifier deduplication and renaming, they are uniformly aggregated into the definition resource area of the target vector graphic (e.g., within the defs element under the SVG root node). This structure, which separates and sequentially arranges "definitions" and "instances," not only conforms to the syntax of the vector graphics standard but also allows the rendering engine to pre-parse resource definitions, improving the execution efficiency of subsequent drawing instructions. Each main graphic node is bound to absolute position parameters and a spatial transformation matrix during aggregation, ensuring that its posture in the target canvas is completely consistent with the original design.
[0129] Step S403: When the set of main graphic nodes in the main area is not empty, a target vector graphic covering the combined graphic area is generated based on the size parameter, the viewport parameter, the defined resource area and the main area, wherein the target vector graphic inherits the position, size, rotation and hierarchy attributes of the combined graphic container.
[0130] Before performing the final generation action, a non-empty validation mechanism is introduced. The target vector graphic object is only instantiated if the set of main graphic nodes in the main area is not empty. This defensive design is to deal with the extreme case where the combined graphic may not contain any mergeable vector objects (such as a combination consisting only of plain text or bitmaps), avoiding the generation of meaningless empty vector containers and thus reducing the redundant overhead of page DOM nodes. When the generation conditions are met, the complete target vector graphic is constructed based on the prepared size parameters, viewport parameters, defined resource areas, and main area. More importantly, the target vector graphic does not exist in isolation, but fully inherits the external layout properties of the original combined graphic container. This includes, but is not limited to, absolute positioning coordinates (top / left), overall rotation angle, scaling ratio, and stacking order (z-index) on the page. Through this property inheritance mechanism, the target vector graphic can seamlessly replace the original combined graphic container as a whole, occupying the exact same spatial position in the web page layout flow and responding to the same interactive events, without causing any layout disturbance to other page elements around it.
[0131] Specifically, the size parameters can be set to the width and height attributes of the SVG root element, and the viewport parameter can be set to the viewBox attribute of the SVG root element, so that the coordinate space of the target SVG is consistent with the pixel size of the composite graphic; all defined resources (such as gradients, filters, clipping paths, symbols, etc.) summarized in the defined resource area can be written into the target SVG. <defs>Within the child elements, a common resource pool is used as a reference for subsequent main graphic elements; all main graphic nodes summarized in the main area are written to the target SVG. <g>Within the main element, nodes maintain their traversal order to preserve the original occlusion relationships. Since the target SVG's width, height, and viewBox are all based on the size of the top-level composite graphic, and its positioning offset is zero, the target SVG's rendering area precisely covers the entire composite graphic area. The target SVG can be set to absolute positioning, top=0, left=0, and overflow=visible, and inherits the overall position, size, rotation, and hierarchy of the composite graphic container. The order of each child graphic in the target SVG is consistent with the original element tree order to maintain occlusion relationships.
[0132] In practice, in actual presentation files, composite graphics often contain not only pure vector shapes but also a large number of non-vector objects that are unsuitable or cannot be vectorized. These non-vector objects include, but are not limited to, text boxes, bitmap images, audio and video media, tables, charts, and form controls with complex interactive properties. Forcibly converting these objects into vector paths (e.g., converting text into outline curves) may achieve a superficial unification, but it leads to severe semantic loss, making the text content uneditable, unsearchable, and unrecognizable by assistive reading devices. It also results in the loss of the original resolution adaptability of images and the interactive playback capabilities of media. Conversely, abandoning vector merging optimization of the entire composite graphic due to the presence of non-vector objects would lead to a surge in the number of DOM nodes on the page, affecting rendering efficiency. Therefore, this application adopts a "hybrid coexistence" output strategy, that is, accommodating both vector and non-vector rendering results within the same Hypertext Markup Language container (e.g., the div element in HTML).
[0133] After the merge is complete, the system checks whether the IDs within the target SVG are unique, whether each internal reference has a target definition, whether the number of main nodes matches the number of mergeable objects, and whether the generated viewBoxes and coordinate values are valid.
[0134] In one feasible implementation, after step S40, the method further includes: Analyze composite graphics in presentation files and identify non-vector objects; Insert the target vector graphic as the first child element into the hypertext markup language container corresponding to the combined graphic; The non-vector objects are converted into corresponding Hypertext Markup Language (HML) elements, and the HML elements are inserted as second child elements into the HML container, so that the target vector graphics and the HML elements corresponding to each non-vector object coexist in the same HML container.
[0135] During execution, the first step in the parsing phase is to classify and identify all sub-elements within the composite graphic. In addition to filtering out merging vector objects, elements that lack pure vector rendering attributes or contain non-vector content are also identified and marked as non-vector objects. Subsequently, a unified Hypertext Markup Language container is constructed as the carrier for the composite graphic on the webpage. This container typically inherits the original composite graphic's absolute positioning coordinates, size, rotation angle, and stacking order from the page layout to ensure its placement in the page flow is completely consistent with the original design.
[0136] During the content filling phase, the target vector graphic is inserted into the container as the first child element. As a self-contained vector rendering unit, the target vector graphic is responsible for presenting all merged pure vector content within the combined graphic. Next, each identified non-vector object is converted into its corresponding standard Hypertext Markup Language (HTML) element. For example, text objects are converted to `span`, `p`, or `div` tags, retaining their font, color, alignment, and other style attributes; image objects are converted to `img` tags and bound to the correct resource address and size; media objects are converted to `video` or `audio` tags and configured with appropriate playback control attributes. These converted HTML elements are then inserted into the same container as second child elements, according to their Z-order in the original document tree. To ensure visual accuracy, all child elements within the container (including the first and second child elements) typically use absolute positioning (`position: absolute`) or other equivalent layout controls to ensure that the spatial overlay and occlusion order of vector graphics and non-vector content remain pixel-level consistent with the original presentation file. For non-SVG content within nested composite graphics, the nested div container and its relative positioning style can be preserved to avoid the parent offset being calculated repeatedly.
[0137] To illustrate the hybrid rendering mechanism more clearly, consider a typical text-image combination: a combined graphic contains three pure path shapes, a text object, and an image object. The system merges the three path shapes into a single target SVG; the text object generates a slide-text node, and the image object generates an img node. The target SVG and non-SVG nodes are placed together within the slide-group container, preserving their original hierarchy and relative positioning.
[0138] In this embodiment, the size parameters of the target vector graphic are set based on the width and height of the top-level composite graphic, and the viewport parameters are also set. Following the traversal order, the definition resources of each sub-vector graphic after identifier replacement and reference association updates are aggregated into the definition resource area. The main graphic nodes of each sub-vector graphic are then aggregated into the main area after combining their corresponding position parameters and spatial transformation relationships. When the set of main graphic nodes in the main area is not empty, a target vector graphic covering the composite graphic area is generated based on the size parameters, the viewport parameters, the definition resource area, and the main area. The target vector graphic inherits the position, size, rotation, and hierarchy attributes of the composite graphic container. By strictly summarizing the traversal order, the absolute correctness of the rendering hierarchy is guaranteed at the data structure level, eliminating common occlusion errors during the merging process. Secondly, by inheriting container properties and setting precise viewports, the merged target vector graphics are ensured to maintain pixel-level consistency with the original combined graphics, without the need for additional outer wrapping containers for position correction. Finally, by encapsulating multiple discrete sub-graphics and their resources into a single, compact vector container, the number of nodes in the browser's rendering tree and the overhead of reflow and repaint are significantly reduced, improving page loading and rendering performance while maintaining the original complex visual expressiveness of the presentation file.
[0139] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the processing method of combined graphics in the presentation file of this application. Any simple transformations based on this technical concept are within the protection scope of this application.
[0140] This application also provides a processing apparatus for combining graphics in a presentation file, please refer to... Figure 5 The processing device for combining graphics in the presentation file includes: The parsing module 10 is used to parse the combined graphics in the presentation file, identify mergeable vector objects, and extract the sub-vector graphics corresponding to the mergeable vector objects, wherein the sub-vector graphics include definition resources and main graphic nodes.
[0141] The generation module 20 is used to generate a distinctive identifier for the defined resource, and based on the identifier, update the reference association of the main graphic node to the defined resource, so as to obtain the defined resource and the main graphic node after identifier replacement and reference association update.
[0142] The determination module 30 is used to determine the position parameters of the mergeable vector objects based on the hierarchical structure of the combined graphics, and to construct the corresponding spatial transformation relationship according to the transformation attributes of the mergeable vector objects.
[0143] The summary module 40 is used to summarize the defined resources and main graphic nodes after identifier replacement and reference association updates, and generate target vector graphics covering the combined graphic area by combining the position parameters and the spatial transformation relationship.
[0144] The present application provides a processing apparatus for combined graphics in presentation files, employing the processing method for combined graphics in presentation files described in the above embodiments. This apparatus solves the technical problem of resource identifier conflicts causing mismatches during browser or rendering engine parsing when combined graphics are merged and rendered in presentation files. Compared to the prior art, the beneficial effects of the processing apparatus for combined graphics in presentation files provided in this application are the same as those of the processing method for combined graphics in presentation files provided in the above embodiments. Furthermore, other technical features in the processing apparatus for combined graphics in presentation files are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0145] In one embodiment, the generation module 20 is further configured to allocate an independent namespace for the sub-vector graphics; The original identifier of the defined resource is renamed based on the namespace to generate a distinctive identifier.
[0146] In one embodiment, the generation module 20 is further configured to obtain the traversal sequence number of the sub-vector graphic within the combined graphic, the page identifier, the combined graphic identifier, the sub-element identifier, and the sub-vector graphic content summary; Based on at least one of the traversal sequence number, the page identifier, the combined graphic identifier, the sub-element identifier, and the sub-vector graphic content summary, generate an independent namespace for the sub-vector graphic.
[0147] In one embodiment, the parsing module 10 is further configured to update the reference association between the main graphical node and the defined resource based on the identifier, and the steps of obtaining the defined resource and the main graphical node after identifier replacement and reference association update include: A depth-first traversal strategy is adopted, starting with the canvas node in the presentation file as the traversal node; Perform a child node traversal on the current combined graphic node to obtain the traversal result; If the traversal result indicates that the child node of the current combined graphic node is a non-combined graphic node, the vector object corresponding to the non-combined graphic node is determined as a mergeable vector object.
[0148] In one embodiment, the parsing module 10 is further configured to determine the offset of the combined graphic node when the traversal result indicates that the child node of the current combined graphic node is a combined graphic node. Convert the offset to the measurement unit used by the target coordinate system and add it to the current parent offset; Based on the accumulated parent offset, the child node traversal is recursively performed on the combined graphic node to obtain the recursive traversal result. The mergeable vector objects identified in the recursive traversal results are added to the mergeable vector object set of the current level.
[0149] In one embodiment, the determining module 30 is further configured to determine the direct parent composite graphic of the mergeable vector object based on the hierarchical structure of the composite graphic, and to determine the relative position coordinates of the mergeable vector object relative to the direct parent composite graphic; The absolute position coordinates of the mergeable vector object in the top-level coordinate system are calculated based on the relative position coordinates and the offsets of the parent combination graphics at each level, and the position parameters of the mergeable vector object are obtained based on the absolute position coordinates.
[0150] In one embodiment, the determining module 30 is further configured to extract transformation parameters based on the transformation attributes of the mergeable vector object, wherein the transformation parameters include at least one of translation parameters, rotation parameters, and scaling parameters; Using the center point of the mergeable vector object as the transformation origin, construct the corresponding transformation matrix according to the transformation parameters; The transformation matrix is applied to the main graphic node of the mergeable vector object to generate the spatial transformation relationship of the mergeable vector object.
[0151] In one embodiment, the generation module 20 is further configured to obtain a reference relationship table representing the relationship between the original identifier and the reference position; Obtain the mapping relationship between the original identifier and the identifier; Based on the reference relationship table, the mapping relationship, and the identifier, update the reference association of the defined resource in the main graphical node, so that the reference of the original identifier in the main graphical node points to the identifier.
[0152] In one embodiment, the generation module 20 is further configured to scan the reference attributes in the definition resources and main graphic content of each of the sub-vector graphics, wherein the reference attributes include at least one of the Uniform Resource Locator (URL) reference attributes, hypertext reference attributes, and cross-document link reference attributes; Establish the relationship between the original identifier and the reference location based on the reference attributes; Construct a reference relationship table based on the described relationship.
[0153] In one embodiment, the generation module 20 is further configured to calculate a content summary of the defined resource with the same content; In the case of multiple defined resources having the same content digest, the same identifier shall be assigned to the defined resources; When multiple defined resources have the same original identifier but different content digests, assign different identifiers to each defined resource.
[0154] In one embodiment, the summarization module 40 is further configured to set the size parameters of the target vector graphic with the width and height of the top-level composite graphic, and to set the viewport parameters; According to the traversal order, the definition resources of each sub-vector graphic after identifier replacement and reference association update are summarized into the definition resource area, and the main graphic nodes of each sub-vector graphic are summarized into the main area after combining the corresponding position parameters and spatial transformation relationships. When the set of main graphic nodes in the main area is not empty, a target vector graphic covering the combined graphic area is generated based on the size parameter, the viewport parameter, the defined resource area, and the main area. The target vector graphic inherits the position, size, rotation, and hierarchy attributes of the combined graphic container.
[0155] In one embodiment, the parsing module 10 is further configured to parse the combined graphics in the presentation file and identify non-vector objects; Insert the target vector graphic as the first child element into the hypertext markup language container corresponding to the combined graphic; The non-vector objects are converted into corresponding Hypertext Markup Language (HML) elements, and the HML elements are inserted as second child elements into the HML container, so that the target vector graphics and the HML elements corresponding to each non-vector object coexist in the same HML container.
[0156] In one embodiment, the device further includes a detection module, which is used to detect whether each of the sub-vector graphics meets a preset abnormal condition during the process of extracting the sub-vector graphics corresponding to the mergeable vector object; When the sub-vector graphic meets the abnormal conditions, the sub-vector graphic will be generated into an independent vector graphic element; Insert the vector graphic element into the hypertext markup language container corresponding to the combined graphic.
[0157] This application provides a processing apparatus for combined graphics in a presentation file. The processing apparatus for combined graphics in a presentation file includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the processing method for combined graphics in a presentation file as described in Embodiment 1 above.
[0158] The following is for reference. Figure 6 This document illustrates a schematic diagram of a processing device suitable for implementing composite graphics in a presentation file according to embodiments of this application. The processing device for composite graphics in a presentation file in embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), tablets, PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The processing device for combining graphics in the illustrated presentation file is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0159] like Figure 6 As shown, the processing device for combining graphics in a presentation file may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in ROM (Read Only Memory) 1002 or a program loaded from storage device 1003 into RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the processing device for combining graphics in the presentation file. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. Input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, LCDs (Liquid Crystal Displays), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the processing device for combining graphics in a presentation file to wirelessly or wiredly communicate with other devices to exchange data. Although the figures show processing devices for combining graphics in a presentation file with various systems, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented alternatively.
[0160] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0161] The presentation file combined graphics processing device provided in this application, employing the presentation file combined graphics processing method in the above embodiments, can solve the technical problem of resource identifier conflicts causing mismatches during browser or rendering engine parsing when rendering combined graphics in presentation files. Compared with the prior art, the beneficial effects of the presentation file combined graphics processing device provided in this application are the same as those of the presentation file combined graphics processing method provided in the above embodiments, and other technical features in this presentation file combined graphics processing device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0162] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0163] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0164] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the processing method of combining graphics in the presentation file of the above embodiments.
[0165] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, RAM (Random Access Memory), ROM (Read Only Memory), EPROM (Erasable Programmable Read Only Memory or Flash Memory), optical fibers, CD-ROM (CD-Read Only Memory), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0166] The aforementioned computer-readable storage medium may be included in a processing device that combines graphics in a presentation file; or it may exist independently and not be assembled into a processing device that combines graphics in a presentation file.
[0167] The aforementioned computer-readable storage medium carries one or more programs that, when executed by a device processing composite graphics in a presentation file, cause the device to: parse the composite graphics in the presentation file, identify mergeable vector objects, and extract sub-vector graphics corresponding to the mergeable vector objects, wherein the sub-vector graphics include definition resources and main graphic nodes; generate a distinguishable identifier for the definition resources, and update the reference association of the main graphic nodes to the definition resources based on the identifier, obtaining the definition resources and main graphic nodes after identifier replacement and reference association update; determine the position parameters of the mergeable vector objects based on the hierarchical structure of the composite graphics, and construct corresponding spatial transformation relationships according to the transformation attributes of the mergeable vector objects; summarize the definition resources and main graphic nodes after identifier replacement and reference association update, and combine the position parameters and the spatial transformation relationships to generate a target vector graphic covering the area of the composite graphics.
[0168] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LAN (Local Area Network) or WAN (Wide Area Network)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0169] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0170] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0171] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the processing method of combined graphics in the above-described presentation file. This solves the technical problem of resource identifier conflicts causing mismatches during browser or rendering engine parsing when combined graphics are merged and rendered in current presentation files. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the processing method of combined graphics in the presentation file provided in the above embodiments, and will not be repeated here.
[0172] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the processing method for combining graphics in a presentation file as described above.
[0173] The computer program product provided in this application can solve the technical problem of resource identifier conflicts causing mismatches during browser or rendering engine parsing when combining graphics in presentation files. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as the beneficial effects of the method for processing combined graphics in presentation files provided in the above embodiments, and will not be repeated here.
[0174] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
[0175] This application discloses A1. A method for processing combined graphics in a presentation file, the method comprising: The presentation file is parsed to identify mergeable vector objects and extract the sub-vector graphics corresponding to the mergeable vector objects. The sub-vector graphics include definition resources and main graphic nodes. A distinctive identifier is generated for the defined resource, and based on the identifier, the reference association of the main graphic node to the defined resource is updated to obtain the defined resource and the main graphic node after identifier replacement and reference association update; Based on the hierarchical structure of the combined graphics, the position parameters of the mergeable vector objects are determined, and the corresponding spatial transformation relationship is constructed according to the transformation attributes of the mergeable vector objects. The defined resources and main graphic nodes after identifier replacement and reference association updates are summarized, and combined with the position parameters and spatial transformation relationships, a target vector graphic covering the combined graphic area is generated.
[0176] A2. As described in A1, the step of generating a distinctive identifier for the defined resource includes: Assign a separate namespace to the sub-vector graphics; The original identifier of the defined resource is renamed based on the namespace to generate a distinctive identifier.
[0177] A3. As described in A2, the step of allocating an independent namespace to the sub-vector graphic includes: Obtain the traversal sequence number, page identifier, combined graphic identifier, sub-element identifier, and sub-vector graphic content summary of the sub-vector graphic within the combined graphic; Based on at least one of the traversal sequence number, the page identifier, the combined graphic identifier, the sub-element identifier, and the sub-vector graphic content summary, generate an independent namespace for the sub-vector graphic.
[0178] A4. As described in A1, the steps for parsing combined graphics in a presentation file and identifying mergeable vector objects include: A depth-first traversal strategy is adopted, starting with the canvas node in the presentation file as the traversal node; Perform a child node traversal on the current combined graphic node to obtain the traversal result; If the traversal result indicates that the child node of the current combined graphic node is a non-combined graphic node, the vector object corresponding to the non-combined graphic node is determined as a mergeable vector object.
[0179] A5. As described in A4, after the step of performing child node traversal on the current combined graphic node to obtain the traversal result, the method further includes: If the traversal result indicates that the child node of the current combined graphic node is a combined graphic node, determine the offset of the combined graphic node; Convert the offset to the measurement unit used by the target coordinate system and add it to the current parent offset; Based on the accumulated parent offset, the child node traversal is recursively performed on the combined graphic node to obtain the recursive traversal result. The mergeable vector objects identified in the recursive traversal results are added to the mergeable vector object set of the current level.
[0180] A6. As described in A1, the step of determining the position parameters of the mergeable vector objects based on the hierarchical structure of the combined graphics includes: Based on the hierarchical structure of the combined graphics, the direct parent combined graphics of the mergeable vector objects are determined, and the relative position coordinates of the mergeable vector objects relative to the direct parent combined graphics are determined. The absolute position coordinates of the mergeable vector object in the top-level coordinate system are calculated based on the relative position coordinates and the offsets of the parent combination graphics at each level, and the position parameters of the mergeable vector object are obtained based on the absolute position coordinates.
[0181] A7. As described in A1, the step of constructing the corresponding spatial transformation relationship based on the transformation attributes of the mergeable vector object includes: Based on the transformation properties of the mergeable vector object, the transformation parameters are extracted, and the transformation parameters include at least one of translation parameters, rotation parameters, and scaling parameters; Using the center point of the mergeable vector object as the transformation origin, construct the corresponding transformation matrix according to the transformation parameters; The transformation matrix is applied to the main graphic node of the mergeable vector object to generate the spatial transformation relationship of the mergeable vector object.
[0182] A8. As described in A1, the step of updating the reference association of the main graphical node to the defined resource based on the identifier includes: Obtain a reference table representing the relationship between the original identifier and the referenced position; Obtain the mapping relationship between the original identifier and the identifier; Based on the reference relationship table, the mapping relationship, and the identifier, update the reference association of the defined resource in the main graphical node, so that the reference of the original identifier in the main graphical node points to the identifier.
[0183] A9. As described in A8, the step of obtaining the reference table representing the mapping relationship between the original identifier and the reference position includes: Scan the reference attributes in the definition resources and main graphic content of each of the sub-vector graphics, wherein the reference attributes include at least one of the following: Uniform Resource Locator (URL) reference attributes, Hypertext reference attributes, and Cross-Document Link (CLR) reference attributes; Establish the relationship between the original identifier and the reference location based on the reference attributes; Construct a reference relationship table based on the described relationship.
[0184] A10. The method of any one of A1 to A9, after the step of generating a distinctive identifier for the defined resource, further includes: The content summary of the defined resources with the same calculation content; In the case of multiple defined resources having the same content digest, the same identifier shall be assigned to the defined resources; When multiple defined resources have the same original identifier but different content digests, assign different identifiers to each defined resource.
[0185] A11. The method as described in any one of A1 to A9, wherein the step of replacing and referencing the updated defined resources and main graphic nodes with the summary identifier, and generating a target vector graphic covering the combined graphic area in conjunction with the position parameters and the spatial transformation relationship, includes: Set the size parameters of the target vector graphic using the width and height of the top-level composite graphic, and set the viewport parameters; According to the traversal order, the definition resources of each sub-vector graphic after identifier replacement and reference association update are summarized into the definition resource area, and the main graphic nodes of each sub-vector graphic are summarized into the main area after combining the corresponding position parameters and spatial transformation relationships. When the set of main graphic nodes in the main area is not empty, a target vector graphic covering the combined graphic area is generated based on the size parameter, the viewport parameter, the defined resource area, and the main area. The target vector graphic inherits the position, size, rotation, and hierarchy attributes of the combined graphic container.
[0186] A12. The method as described in any one of A1 to A9, wherein the method further comprises: Analyze composite graphics in presentation files and identify non-vector objects; Insert the target vector graphic as the first child element into the hypertext markup language container corresponding to the combined graphic; The non-vector objects are converted into corresponding Hypertext Markup Language (HML) elements, and the HML elements are inserted as second child elements into the HML container, so that the target vector graphics and the HML elements corresponding to each non-vector object coexist in the same HML container.
[0187] A13. The method as described in any one of A1 to A9, wherein the method further comprises: During the process of extracting the sub-vector graphics corresponding to the mergeable vector objects, it is detected whether each sub-vector graphic meets the preset abnormal conditions; When the sub-vector graphic meets the abnormal conditions, the sub-vector graphic will be generated into an independent vector graphic element; Insert the vector graphic element into the hypertext markup language container corresponding to the combined graphic.
[0188] This application also discloses B14. A processing apparatus for combining graphics in a presentation file, the apparatus comprising: The parsing module is used to parse the combined graphics in the presentation file, identify mergeable vector objects, and extract the sub-vector graphics corresponding to the mergeable vector objects, wherein the sub-vector graphics include definition resources and main graphic nodes; The generation module is used to generate a distinctive identifier for the defined resource, and based on the identifier, update the reference association of the main graphic node to the defined resource, so as to obtain the defined resource and the main graphic node after identifier replacement and reference association update; The determination module is used to determine the position parameters of the mergeable vector objects based on the hierarchical structure of the combined graphics, and to construct the corresponding spatial transformation relationship according to the transformation attributes of the mergeable vector objects; The summary module is used to summarize the defined resources and main graphic nodes after identifier replacement and reference association updates, and generate target vector graphics covering the combined graphic area by combining the position parameters and the spatial transformation relationship.
[0189] B15. The apparatus as described in B14, wherein the generation module is further configured to allocate an independent namespace for the sub-vector graphics; The original identifier of the defined resource is renamed based on the namespace to generate a distinctive identifier.
[0190] B16. The apparatus as described in B15, wherein the generation module is further configured to obtain the traversal sequence number of the sub-vector graphic within the combined graphic, the page identifier, the combined graphic identifier, the sub-element identifier, and the sub-vector graphic content summary; Based on at least one of the traversal sequence number, the page identifier, the combined graphic identifier, the sub-element identifier, and the sub-vector graphic content summary, generate an independent namespace for the sub-vector graphic.
[0191] B17. The apparatus as described in B14, wherein the parsing module is further configured to update the reference association of the main graphical node to the defined resource based on the identifier, and the step of obtaining the defined resource and the main graphical node after identifier replacement and reference association update includes: A depth-first traversal strategy is adopted, starting with the canvas node in the presentation file as the traversal node; Perform a child node traversal on the current combined graphic node to obtain the traversal result; If the traversal result indicates that the child node of the current combined graphic node is a non-combined graphic node, the vector object corresponding to the non-combined graphic node is determined as a mergeable vector object.
[0192] B18. The apparatus as described in B17, wherein the parsing module is further configured to determine the offset of the combined graphic node when the traversal result indicates that the child node of the current combined graphic node is a combined graphic node; Convert the offset to the measurement unit used by the target coordinate system and add it to the current parent offset; Based on the accumulated parent offset, the child node traversal is recursively performed on the combined graphic node to obtain the recursive traversal result. The mergeable vector objects identified in the recursive traversal results are added to the mergeable vector object set of the current level.
[0193] This application also discloses C19. A processing apparatus for combined graphics in a presentation file, the apparatus comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the processing method for combined graphics in a presentation file as described above.
[0194] This application also discloses D20. A storage medium, which is a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the processing method for combining graphics in a presentation file as described above.< / g> < / defs>
Claims
1. A method for processing combined graphics in a presentation file, characterized in that, The method for processing combined graphics in the presentation file includes: The presentation file is parsed to identify mergeable vector objects and extract the sub-vector graphics corresponding to the mergeable vector objects. The sub-vector graphics include definition resources and main graphic nodes. A distinctive identifier is generated for the defined resource, and based on the identifier, the reference association of the main graphic node to the defined resource is updated to obtain the defined resource and the main graphic node after identifier replacement and reference association update; Based on the hierarchical structure of the combined graphics, the position parameters of the mergeable vector objects are determined, and the corresponding spatial transformation relationship is constructed according to the transformation attributes of the mergeable vector objects. The defined resources and main graphic nodes after identifier replacement and reference association updates are summarized, and combined with the position parameters and spatial transformation relationships, a target vector graphic covering the combined graphic area is generated.
2. The method as described in claim 1, characterized in that, The steps for generating distinctive identifiers for the defined resources include: Assign a separate namespace to the sub-vector graphics; The original identifier of the defined resource is renamed based on the namespace to generate a distinctive identifier.
3. The method as described in claim 2, characterized in that, The step of allocating an independent namespace for the sub-vector graphics includes: Obtain the traversal sequence number, page identifier, combined graphic identifier, sub-element identifier, and sub-vector graphic content summary of the sub-vector graphic within the combined graphic; Based on at least one of the traversal sequence number, the page identifier, the combined graphic identifier, the sub-element identifier, and the sub-vector graphic content summary, generate an independent namespace for the sub-vector graphic.
4. The method as described in claim 1, characterized in that, The steps for parsing combined graphics in a presentation file and identifying mergeable vector objects include: A depth-first traversal strategy is adopted, starting with the canvas node in the presentation file as the traversal node; Perform a child node traversal on the current combined graphic node to obtain the traversal result; If the traversal result indicates that the child node of the current combined graphic node is a non-combined graphic node, the vector object corresponding to the non-combined graphic node is determined as a mergeable vector object.
5. The method as described in claim 4, characterized in that, After the step of performing child node traversal on the current combined graphic node to obtain the traversal result, the method further includes: If the traversal result indicates that the child node of the current combined graphic node is a combined graphic node, determine the offset of the combined graphic node; Convert the offset to the measurement unit used by the target coordinate system and add it to the current parent offset; Based on the accumulated parent offset, the child node traversal is recursively performed on the combined graphic node to obtain the recursive traversal result. The mergeable vector objects identified in the recursive traversal results are added to the mergeable vector object set of the current level.
6. The method as described in claim 1, characterized in that, Based on the hierarchical structure of the combined graphics, the steps for determining the position parameters of the mergeable vector objects include: Based on the hierarchical structure of the combined graphics, the direct parent combined graphics of the mergeable vector objects are determined, and the relative position coordinates of the mergeable vector objects relative to the direct parent combined graphics are determined. The absolute position coordinates of the mergeable vector object in the top-level coordinate system are calculated based on the relative position coordinates and the offsets of the parent combination graphics at each level, and the position parameters of the mergeable vector object are obtained based on the absolute position coordinates.
7. The method as described in claim 1, characterized in that, The steps for constructing the corresponding spatial transformation relationship based on the transformation properties of the mergeable vector objects include: Based on the transformation properties of the mergeable vector object, the transformation parameters are extracted, and the transformation parameters include at least one of translation parameters, rotation parameters, and scaling parameters; Using the center point of the mergeable vector object as the transformation origin, construct the corresponding transformation matrix according to the transformation parameters; The transformation matrix is applied to the main graphic node of the mergeable vector object to generate the spatial transformation relationship of the mergeable vector object.
8. A processing apparatus for combining graphics in a presentation file, characterized in that, The device includes: The parsing module is used to parse the combined graphics in the presentation file, identify mergeable vector objects, and extract the sub-vector graphics corresponding to the mergeable vector objects, wherein the sub-vector graphics include definition resources and main graphic nodes; The generation module is used to generate a distinctive identifier for the defined resource, and based on the identifier, update the reference association of the main graphic node to the defined resource, so as to obtain the defined resource and the main graphic node after identifier replacement and reference association update; The determination module is used to determine the position parameters of the mergeable vector objects based on the hierarchical structure of the combined graphics, and to construct the corresponding spatial transformation relationship according to the transformation attributes of the mergeable vector objects; The summary module is used to summarize the defined resources and main graphic nodes after identifier replacement and reference association updates, and generate target vector graphics covering the combined graphic area by combining the position parameters and the spatial transformation relationship.
9. A processing device for combining graphics in a presentation file, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the method for processing combined graphics in a presentation file as claimed in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the method for processing combined graphics in a presentation file as described in any one of claims 1 to 7.