DWG file nested OLE object cross-platform display method and system
By extracting and reconstructing the data information of OLE objects nested in DWG files in a cross-platform environment, the problem that OLE objects cannot be displayed in non-Windows systems is solved, and cross-platform display and reverse restoration of OLE objects are realized, improving user experience.
Patent Information
- Application Number
- CN202411943357.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-05-31
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-26
AI Technical Summary
In a cross-platform environment, the OLE objects nested in DWG files cannot be displayed or operated normally, resulting in the inability to effectively display the contents of these files in non-Windows systems.
By creating a DWG file on the first platform and nesting OLE objects, importing the DWG file on the second platform and extracting the data information of the OLE object, grouping and threading the OLE objects according to the data information, rebuilding the OLE object to reverse restore and display.
Cross-platform display of OLE objects in DWG files is realized, so that OLE objects can be displayed normally in systems that originally did not support OLE objects, improving user experience and reducing the need for data structure conversion.
Smart Images

Figure CN119740281A_ABST
Abstract
Description
[0001] Priority application This application claims priority to the Chinese invention patent application [Application Number: 2024106999959] [A cross-platform display method, device, system, storage medium, and program product for nested OLE objects in a DWG file] filed on May 31, 2024, which is incorporated by reference in its entirety. Technical Field
[0002] The present invention belongs to the technical field of Computer Aided Design (CAD), and in particular relates to a cross-platform display method and system for OLE objects nested in a DWG file. Background Art
[0003] In the CAD design process, it is necessary to import external files of various formats, including wmf, emf, bmp, doc, ppt, xls, rtf, dwg, vsd, png and other file formats. It is very easy to import files of the above formats into the CAD system under Windows system, because OLE "Object Linking and Embedding" (OLE for short) is integrated into Windows system. OLE is a technology that allows data to be shared between different applications. It was originally developed by Microsoft to support data exchange between applications in Windows operating system.
[0004] However, in a cross-platform environment (e.g., from Windows to Linux or macOS), due to the lack of comprehensive support for OLE technology, these OLE objects embedded in DWG files (i.e., the above-mentioned wmf, emf, bmp, doc, ppt, xls, rtf, dwg, vsd, png and other external files) may not be displayed or operated normally, so that even if these formats of files can be imported into the drawing interface of the CAD system to generate OLE objects, the contents of these files cannot be displayed, see Figure 1 Alternatively, when a dwg file that has been embedded with the above-mentioned format files is opened in a CAD system, the specific contents of these files cannot be displayed normally.
[0005] The Chinese invention patent application with the publication number CN1862498A discloses a method for converting an object link and embedded object, which converts an existing or newly inserted OLE object in a file into a corresponding object in the current application so that the converted object can be edited or updated. For example, the EIOffice software reads the object link and embedded object in a Microsoft file, parses its file data structure, and obtains that the object type of the object link and embedded object is a Microsoft chart object type (bar chart or stock chart, etc.); EIOffice generates a new chart object in the EIOffice spreadsheet application, and continues to parse the file data structure in the object link and embedded object to obtain a specific Microsoft chart type (bar chart or stock chart, etc.), and according to these specific chart types, obtains the data structure of the functions of the chart type and the attribute functions set by the chart, such as the data structure of the chart area (ChartArea), plot area (PlotArea), data series (Series), value axis (value axis) and other functions in the Microsoft chart. EIOffice converts the object links and embedded objects obtained through parsing into data in the data structure corresponding to the current EIOffice chart according to the data structure of the chart in the current EIOffice, and sets the parsed and converted data to the newly generated EIOffice chart object through its corresponding programming interface (Application Programming Interface, API for short), that is, converting the OLE object under Microsoft into the OLE object under EIOffice.
[0006] It can be seen that in order to make the OLE objects created in one application program editable in other applications, the above prior art uses the OLE objects as an intermediate transition area to convert the objects between Microsoft Office and EIOffice. However, during the conversion process, data loss or change is likely to occur. On the other hand, the premise of the conversion is that EiOffice itself supports the chart. If EIOffice does not support the chart, then it is naturally impossible to convert and display it.
[0007] In view of this, there is an urgent need for a solution that can realize cross-platform display of nested OLE objects in DWG files. Summary of the invention
[0008] The object of the present invention is to provide a method and system for cross-platform display of OLE objects nested in DWG files, which partially solves or alleviates the above-mentioned deficiencies in the prior art and enables cross-platform display of OLE objects nested in DWG files.
[0009] In order to solve the above-mentioned technical problems, the present invention specifically adopts the following technical solutions: The present invention provides a cross-platform display method of an OLE object nested in a DWG file, comprising: Creating a DWG file on the first platform, and embedding a plurality of OLE objects in the DWG file; Importing the created DWG file on the second platform, and extracting data information of the OLE object from the DWG file; According to the data information of the OLE objects, several OLE objects in the DWG file are grouped, and the OLE objects in the group are reconstructed according to the group configuration thread, so as to reversely restore and display the OLE objects.
[0010] As an improvement, the steps to configure threads by group include: When the total amount of OLE object data in a group is greater than or equal to a first preset threshold, configuring a first preset number of threads for the group; When the total amount of OLE object data in a group is less than a first preset threshold, configuring a second preset number of threads for the group; If at least one thread of any group completes a task, it is merged into the thread of another group for parallel processing; the second preset number is smaller than the first preset number.
[0011] As an improvement, a machine learning algorithm is used to configure threads; the machine learning algorithm configures threads for each group according to the number of groups, the total size of OLE objects in each group, the current memory usage rate, and the current CPU occupancy rate.
[0012] As an improvement, the larger OLE object in the group is divided into several data blocks; the steps of configuring the thread include: When the number of data blocks in a certain group is greater than or equal to the number threshold, configuring a third preset number of threads for the group; When the number of data blocks in a certain group is less than the number threshold, a fourth preset number of threads is configured for the group; the fourth preset number is less than the third preset number.
[0013] As an improvement, the step of configuring threads using a machine learning algorithm specifically includes: the machine learning algorithm automatically configures threads for each group and each larger OLE object in the group based on the number of groups, the total size of OLE objects in each group, the number of larger OLE objects in each group and the number of data blocks of each larger OLE object, the current memory usage rate, and the current CPU occupancy rate.
[0014] As an improved way to recognize larger OLE objects, the following steps are included: When the data volume of an OLE object exceeds a data volume threshold, the OLE object is marked as a larger OLE object; or, when an OLE object is loaded into memory, if the memory occupied by the OLE exceeds a preset proportion of the system available memory, the OLE object is marked as a larger OLE object.
[0015] As an improvement, the data information includes: the type of the OLE object, and the file format of the external file corresponding to the OLE object; grouping is performed according to the type of the OLE object, or grouping is performed according to the file format of the external file corresponding to the OLE object.
[0016] As an improvement, grouping by OLE object type includes native WMF group, placeable WMF group, native EMF group, enhanced type 1 EMF group, and enhanced type 2 EMF group; When extracting OLE object data information, identify the type of OLE object. The specific steps include: According to the value of the first preset threshold (for example, 4) bytes of the header in the OLE object data stream, the native WMF type, the placeable WMF type and the EMF type are identified; After the OLE object is identified as an EMF type, the specific category of the EMF type is identified according to the header length; wherein the header length of the native EMF is a second preset threshold (e.g., 88) bytes, the header length of the enhanced type 1 EMF is a third preset threshold (e.g., 100) bytes, and the header length of the enhanced type 2 EMF is a fourth preset threshold (e.g., 108) bytes. Preferably, the second preset threshold is less than the third preset threshold, and the third preset threshold is less than the fourth preset threshold.
[0017] As an improvement, the thread task queue is sorted, and the smaller the OLE object data size, the higher its priority.
[0018] As an improvement, a data block index table is established to assign a unique ID to each data block; the index record of the index table includes the data block ID and the corresponding address and data size.
[0019] As an improvement, when dividing the data blocks of the OLE object, the data blocks are spread out in an orderly manner around the mouse focus.
[0020] The present invention also provides a DWG file nested OLE object cross-platform display system, comprising: A DWG file creation module, used for creating a DWG file on the first platform and embedding a plurality of OLE objects in the DWG file; A data information extraction module, used for importing the created DWG file on the second platform and extracting data information of the OLE object from the DWG file; The reconstruction display module is used to reconstruct the OLE object according to the data information of the OLE object, so as to reversely restore and display the OLE object.
[0021] Beneficial effects: The present invention first creates a DWG file containing several OLE objects in a first platform, such as a Windows operating system, then imports the DWG file in a second platform, such as a LINUX operating system, and extracts data information of the OLE objects from the DWG file; finally, the OLE objects are reconstructed according to the data information of the OLE objects, thereby reversely restoring the OLE objects for display, and no data structure conversion is required in the process. The present invention realizes cross-platform display of OLE objects, so that the OLE objects nested in the DWG file can be displayed normally in other systems that originally do not support OLE objects.
[0022] In order to improve the efficiency of OLE object reconstruction, the present invention obtains data information of multiple OLE objects, groups several OLE objects in the DWG file, and reconstructs the OLE objects in the group according to the group configuration threads, thereby realizing multi-threaded parallel processing, greatly shortening the reconstruction time, and improving the user experience.
[0023] In order to further improve the efficiency, the present invention also divides the OLD objects with larger data volume in the group into data blocks, and configures threads according to the number of data blocks, further optimizing the thread configuration strategy, so that the OLE object reconstruction efficiency is further improved.
[0024] The present invention realizes the cross-platform display of dwg files generated by CAD software under different operating system platforms. This function is very practical in actual use. It can display CAD generated files across platforms and can be modified according to user needs. The present invention can be widely used in the fields of mechanical design, architectural design, industrial design, etc. It can facilitate the staff to use CAD for design, and the generated dwg files can be used across platforms, which has broad application prospects and huge market value. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, each element or part is not necessarily drawn according to the actual scale. Obviously, the drawings described below are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without paying creative labor.
[0026] Figure 1 The present invention is a sample diagram of the prior art that a DWG file cannot be displayed when a CAD is used to open the DWG file on a Linux platform; Figure 2 A sample diagram of opening a DWG file using CAD on a Linux platform and displaying the nested OLE objects based on the cross-platform display method of the present invention; Figure 3 To reflect the format examples of native WMF and placeable WMF; Figure 4 This is an example diagram showing that the header lengths of three EMF files are different; Figure 5 A schematic diagram showing how to divide a large OLE object into blocks; Fig. 6A This is a flow chart of a cross-platform display method of an OLE object nested in a DWG file according to a first embodiment of the present invention; Figure 6B It is a flowchart of a cross-platform display method of nested OLE objects in a DWG file according to a third embodiment of the present invention; Fig. 7A This is a functional module diagram of a cross-platform display system for nested OLE objects of DWG files according to a second embodiment of the present invention; Figure 7B This is a functional module diagram of a cross-platform display device for nesting OLE objects in a DWG file according to a fourth embodiment of the present invention. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0028] Herein, suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present invention, and have no specific meanings by themselves. Therefore, "module", "component" or "unit" can be used mixedly.
[0029] In this document, the terms "upper", "lower", "inner", "outer", "front", "back", "one end", "the other end" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance.
[0030] In this document, unless otherwise clearly specified and limited, the terms "installed", "provided with", "connected", etc. should be understood in a broad sense. For example, "connected" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, a direct connection, or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0031] Herein "and / or" includes any and all combinations of one or more of the associated listed items.
[0032] Herein, "plurality" means two or more than two, ie, it includes two, three, four, five, etc.
[0033] Definition of noun: "Linux": is a free and open source Unix-like operating system. It is released under the GNU General Public License and is free to obtain and use. The Linux operating system kernel was first released by Linus Torvalds in 1991.
[0034] "Windows": is an operating system developed by Microsoft Corporation. It was first released in 1985 and has become one of the most widely used desktop operating systems in the world.
[0035] "CAD (Computer-Aided Design)" refers to the process of designing, analyzing and manufacturing using computer technology. CAD software is widely used in engineering, architecture, product design and other fields. CAD software can run under Windows system (such as AutoCAD) or Linux system (such as GstarCAD).
[0036] "DWG file": refers to the native file format used by CAD software, and its full name is "Drawing" file. It is a standard format for storing 2D and 3D design data, and is used to save graphics and design information in various engineering and design fields such as architectural design, mechanical drawing, and circuit design.
[0037] "OLE (Object Linking and Embedding) Object Linking and Embedding" refers to a technology that allows data to be shared between different applications. It was originally developed by Microsoft to support data exchange between applications in the Windows operating system. OLE object data is stored in binary format, including the object data itself and source data about the source of the object. Usually in CAD design software, other types of files or programs, such as documents, images, spreadsheets or other multimedia files, can be inserted into CAD drawings in the form of OLE objects. When using OLE, there are two important roles: the source application and the target application; among them, the source application is the application that contains the object to be embedded or linked, and the target application is the application that receives and displays the embedded or linked object. For example, when inserting a word document into a DWG drawing, CAD is the target application and word is the source application.
[0038] Embodiment 1: Fig. 6A As shown, the present invention provides a cross-platform display method for OLE objects nested in a DWG file.
[0039] The "cross-platform" mentioned in the present invention refers to the transition from one operating system to another, such as from Windows to Linux. Since OLE objects are targeted at Windows environments, they cannot be displayed under Linux systems. The problem to be solved by the present invention is to achieve the cross-platform display of OLE objects in DWG files. The specific steps include: S1 creates a DWG file on a first platform, and embeds a plurality of OLE objects in the DWG file.
[0040] In some embodiments, the first platform is an operating system capable of supporting multiple file formats, such as Windows.
[0041] Exemplarily, in a Windows environment, a dwg file is created using a CAD system (such as AutoCAD, Haochen CAD, etc.); wherein the OLE object refers to a DWG file in which several external files are nested in the DWG file in the CAD software in the Windows environment, thereby obtaining a DWG file in which multiple OLE objects are nested. Among them, the external file may specifically include: wmf, emf, bmp, doc, docx, ppt, xls, rtf, dwg, vsd, png and other file formats. Of course, each external file may also have a corresponding OLE object inserted into it. For example, a doc file or xls file is inserted into a DWG file, and a picture (i.e., an OLE object) or a chart (i.e., an OLE object) is inserted into the doc file or xls file, that is, there is multi-level nesting of OLE objects.
[0042] S2 imports the created DWG file on the second platform and extracts data information of the OLE object from the DWG file.
[0043] In some embodiments, the second platform is an operating system different from the first platform, which may only support part of the external files. Exemplarily, the second platform is a platform on which Linux or other CAD systems can run, so the DWG file created in step S1 can be imported into the CAD system under the second platform. Of course, the CAD system can be software or a web page, for example, the imported DWG file can be viewed in the web version of DWG, etc.
[0044] S3 reconstructs the OLE object according to the data information of the OLE object, thereby reversely restoring and displaying the OLE object.
[0045] The "reverse restoration" mentioned in the present invention refers to reconstructing the content in the source file corresponding to the OLE object based on the data information of the OLE object. For example, when a DWG file with multiple nested OLE objects (each OLE object corresponds to an external file) is imported on the second platform, the data information or data stream of each OLE object is obtained from the binary data stream of the DWG file, and the specific format of the source file (i.e., the external file) corresponding to the OLE object is analyzed, and then the OLE object is reversely restored according to the specific format obtained by the analysis, that is, the specific content in the file is reconstructed and displayed, see Figure 2 .
[0046] For example, embed a word file in the format of doc or docx into a DWG drawing (i.e., the first file) under the Windows system, then open the DWG drawing under the Linux system (i.e., the second platform), and extract the data streams of all OLE objects in the DWG drawing (including the data streams of the OLE objects corresponding to the word file), and regenerate a word file with the suffix .doc or .docx (i.e., the second file) according to the data streams of the OLE objects corresponding to the word file (i.e., the second file), that is, reversely restore to obtain a file in the format of .doc or .docx. Although Microsoft word (i.e., the first application office) cannot be used under Linux, wps (i.e., the second application that supports word files) can be used, and the word file can also be opened and displayed (correspondingly, if the word file also contains OLE objects such as charts, wps can also open and display the charts accordingly), and of course, it can also be opened under Windows. In other words, after parsing the binary data stream of the OLE object, the type / format of the file contained in it is generated according to the type / format of the file. That is, when an OLE object (such as an external file generated based on a first application, i.e., a second file) is nested in a first file (such as a dwg file) on a first platform, and then the first file is imported into a second platform and the first file is obtained by reverse restoration, since the second platform has an application that supports the external file (i.e., a second application that can open, display, or even edit the external file), the first file obtained by reverse restoration can be displayed on the second platform, i.e., the OLE object can be displayed.
[0047] In some embodiments, different types of OLE objects are nested in the DWG file. Therefore, in order to improve reconstruction efficiency, after obtaining data information of multiple OLE objects, several OLE objects in the DWG file are grouped, and the OLE objects in the group are reconstructed according to the group configuration thread.
[0048] This embodiment provides multiple grouping methods.
[0049] The first is to group them according to the type of OLE objects, including native WMF group, placeable WMF group, native EMF group, enhanced type 1 EMF group, and enhanced type 2 EMF group.
[0050] OLE objects are mainly divided into two categories: WMF (Windows Metafile Format) and EMF (Enhanced Metafile Format). WMF is divided into two categories: Original WMF and Placeable WMF. EMF is divided into three categories: Original EMF, Extension 1 EMF and Extension 2 EMF.
[0051] The format of the WMF file is composed of a header, a record, and an end-of-file record. The header contains the summary information of the file, and the last one is the end-of-file record. The specific records of the information contained in the WMF file are between the header record and the end-of-file record. The difference between native WMF and placeable WMF is that placeable WMF has one more header record than native WMF, such as Figure 3 shown.
[0052] EMF files are enhanced versions of WMF files, so the structure of EMF files is similar to that of WMF files, and is also composed of a header, a record, and an end-of-file record. The header of a file is also a type of record, so EMF files are all composed of records. The header record of an EMF file is the key to distinguishing the three types of EMF files. The main difference is that the header lengths of the three types of EMF files are different. See Figure 4 .
[0053] In summary, the classification rules for extracting the data information corresponding to each OLE from the DWG file are as follows: According to the value of the first preset threshold bytes in the header of the data stream, native WMF, placeable WMF and EMF can be identified, as shown in Table 1: Table 1 Distinguishing OLE types based on the values of the first 4 bytes in the data stream (2) After determining that it is EMF, the specific category of the EMF type is identified based on the head length, as shown in Table 2: Table 2 Classification of EMF types based on head length In some embodiments, corresponding multi-threads are allocated to each of the native WMF group, the placeable WMF group, the native EMF group, the enhanced type 1 EMF group, and the enhanced type 2 EMF group for parallel processing.
[0054] The second is to group them according to the file format of OLE objects. Then allocate the number of threads according to the amount of data in each group. Allocating the number of threads according to the amount of data in each group can, on the one hand, reasonably allocate resources, and on the other hand, to a certain extent, keep the redrawing speed of groups with small size differences consistent or not much different, so that users can see a certain degree of coherence and avoid a large number of redraws in a short period of time. Figure 1 Shown as blank or loading.
[0055] In this embodiment, whether grouping is performed according to the type of OLE objects or according to the file format of the external files corresponding to the OLE objects, the specific steps of configuring threads according to the amount of data in each group include: When the total amount of OLE object data in a certain group is greater than or equal to a first preset threshold, a first preset number of threads is configured for the group.
[0056] For example, the total amount of OLE object data in the first group is 60 MB, which is greater than the first preset threshold of 50 MB, so a first preset number (eg, 10) of threads is configured for the group.
[0057] When the total amount of OLE object data in a group is less than a first preset threshold, a second preset number of threads is configured for the group, wherein the second preset number is less than the first preset number.
[0058] The total amount of OLE object data in the second group is 40 MB, which is less than a preset threshold of 50 MB. Therefore, a second preset number (eg, 5) of threads is configured for the group.
[0059] If at least one thread of any group completes a task, it will be merged into the thread of another group for parallel processing. In other words, if a thread in the first group has completed all tasks in the task list and is idle, it will be merged into the small group of the second group to help the second group continue to complete the task of reconstructing the OLE object.
[0060] Of course, in other embodiments, a machine learning algorithm can be used to automatically allocate the number of threads for each group. Specifically, a training sample set is pre-constructed, and the training sample set is used for training to obtain a task distributor that can automatically allocate the corresponding number of threads for each group according to the number and size of the groups. For example, the number of groups, the total amount of OLE object data of each group, the current memory usage rate, the current CPU occupancy rate, and the number of threads for each group are input as input parameters into a pre-constructed machine training model, and then the task distributor is obtained, so that the task distributor (or thread manager) can automatically allocate and open the corresponding number of threads for each group according to the number of groups, the total amount of OLE object data of each group, the current memory usage rate, and the current CPU occupancy rate. Ideally, allocating a thread to each OLE object can increase the processing speed, but such an operation not only greatly increases the system power consumption, but also occupies a large amount of system resources, which may cause jamming and reduce the drawing speed. Therefore, by reasonably allocating the corresponding number of threads to each group, under the premise of reasonable use of system resources, the drawing efficiency is improved, jamming is avoided, or the user sees the state of "loading" for a long time in the interface.
[0061] In addition, after grouping, the size of each OLE object in the group is also different.
[0062] In order to further reasonably configure threads, in some embodiments, each OLE object in the group can also be divided into data blocks, and threads can be configured according to the data blocks. That is, the OLE objects in the group whose data volume is greater than the second preset threshold are divided into several data blocks; for example, the size of a certain OLE object is 200MB, and the size of another OLE object is 20MB. If a thread is assigned to both OLE objects, it is obviously unfair, and the OLE object with a large data volume will take more time to reconstruct. It may cause other OLE objects to be realized, while the larger OLE object is always in a reconstructing state, so that the user sees a blank, creating a false impression that the OLE has no data (especially when a large number of OLEs are displayed, because the user does not know the size of the OLE, it is easy to cause misjudgment), or the loading state is always seen, thereby reducing the user experience.
[0063] Therefore, in this embodiment, for a large OLE object larger than the second preset threshold, such as 200MB, data blocks are divided into several data blocks. The size of the data block is determined according to the processing capability of the thread, and the data block is usually of a fixed size.
[0064] In addition, the steps of identifying a larger OLE object in this embodiment include: When the data size of the OLE object exceeds a second preset threshold, the OLE object is marked as a large OLE object, such as the above-mentioned 200 MB.
[0065] Alternatively, when an OLE object is loaded into memory, if the memory occupied by the OLE exceeds a preset proportion of the system available memory, the OLE object is marked as a large OLE object, for example, exceeding 5% of the available memory.
[0066] In addition, you can also identify large OLE objects based on processing performance. Large OLE objects may affect the processing performance of the application, such as opening, editing, saving, etc., which takes longer time.
[0067] In summary, when an OLE object exceeds certain limits in terms of file size, memory usage, and processing performance, it can be considered a large OLE object.
[0068] By dividing a larger object into multiple blocks, each containing data of a specific size, this block mechanism helps reduce memory usage and improve performance, while also facilitating transmission, storage, and redrawing, improving drawing efficiency.
[0069] After dividing the data blocks, the steps to configure the threads include: When the number of data blocks in a certain group is greater than or equal to the number threshold, a third preset number of threads is configured for the group.
[0070] For example, the number of data blocks in the first group is 12, which is greater than the number threshold of 10. Therefore, a third preset number (eg, 8) of threads is allocated to the group.
[0071] When the number of data blocks in a certain group is less than the number threshold, a fourth preset number of threads is configured for the group; the fourth preset number is less than the third preset number.
[0072] In the second group, the number of data blocks is 7, which is less than the number threshold of 10. Therefore, a fourth preset number (eg, 5) of threads is allocated to the group.
[0073] It can be foreseen that, since the sizes of data blocks are consistent, the data blocks are distributed evenly to each thread as much as possible, thereby achieving multi-threaded parallel processing.
[0074] In addition, if an OLE object is usually small, it may be assigned to a task queue of a drawing thread. Therefore, the OLE files in the task queue can be further prioritized according to certain rules, for example, by size, the smaller the higher the priority. In this way, part of the content can be displayed as soon as possible, presenting a gradual loading scene, which is easier to increase the user's patience.
[0075] Of course, after dividing the data blocks, the machine learning algorithm can also be used to configure the threads. When configuring the number of threads for each group, new parameters can be further introduced, that is, the number of larger OLE objects in each group, the number of blocks and the number of threads for each larger OLE object, so that the corresponding number of threads can be automatically allocated and opened for each group and each larger OLE in the group according to the number of groups, the total size of OLE objects in each group, the number of larger OLEs in each group and the number of blocks for each larger OLE, the current memory usage rate, and the current CPU occupancy rate. By reasonably allocating the corresponding number of threads to each group, the drawing efficiency is improved. As mentioned above, for smaller OLE objects, they may be assigned to the task queue of a thread, that is, multiple OLE objects share one thread. However, for larger OLE objects, it is less efficient to use one thread to draw. Therefore, by dividing them into blocks and then assigning multiple threads to draw them in parallel, users are prevented from seeing the "loading state" for a long time.
[0076] In addition, the steps of identifying a larger OLE object in this embodiment include: When the data volume of the OLE object exceeds the data volume threshold, the OLE object is marked as a large OLE object; Alternatively, when an OLE object is loaded into the memory, if the memory occupied by the OLE object exceeds a preset proportion of the system available memory, the OLE object is marked as a large OLE object.
[0077] In some embodiments, for the convenience of management, a data block index table can also be established to assign a unique ID to each data block; the index record of the index table includes the data block ID and the corresponding address and data size. The index table can be stored in the file header or in a separate area for quick search.
[0078] OLE objects are divided into multiple data blocks, and the index table records the location and size information of each data block. This block structure allows the system to dynamically load and process data blocks as needed, thereby managing larger OLE objects more efficiently.
[0079] For example, when the blocks are divided, the dynamic loading is carried out with the cursor focus (whose position can be specified by the user) as the center point and spreads to the surroundings in an orderly manner, such as Figure 5 As shown in the figure: 0, 1, 2, and 3 represent the individual blocks after OLE segmentation, starting from 0, then to 1, then to 2, and finally to 3, and so on until the segmentation is completed. When processing OLE objects, it is usually considered to segment larger OLE objects into blocks in order to effectively manage and process data.
[0080] As mentioned above, since OLE objects may also be inserted into each external file, for example, a viso flowchart (i.e., a second-level nested OLE object) is inserted into a word document inserted into a DWG file (i.e., a first-level OLE object inserted into the DWG file). Therefore, in other embodiments, when parsing the data stream of any OLE object in the DWG file and obtaining the data information of the OLE object, the data information also includes the data information of the second-level OLE object nested in the OLE object, and it is used as the OLE object to be grouped. That is, when grouping OLE objects and configuring threads, both the first-level OLE objects and the second-level OLE objects are regarded as OLE objects to be processed, and are grouped according to the same grouping rules as mentioned above, and the threads are configured according to the above-mentioned rules for configuring threads.
[0081] Embodiment 2: Fig. 7A As shown, the present invention also provides a cross-platform display system for OLE objects nested in DWG files, comprising: A DWG file creation module, used for creating a DWG file on the first platform and embedding a plurality of OLE objects in the DWG file; A data information extraction module, used for importing the created DWG file on the second platform and extracting data information of the OLE object from the DWG file; The reconstruction display module is used to reconstruct the OLE object according to the data information of the OLE object, so as to reversely restore and display the OLE object.
[0082] The reconstruction display module specifically includes: A file type identification unit, used for identifying the file format of each OLE object according to the extracted data information; The file reconstruction unit is used to restore the extracted data stream from binary to the corresponding file format.
[0083] In some embodiments, the reconstruction display module further includes: a grouping unit, which is used to group the OLE objects based on the file format when the file type identification unit identifies the file format, to obtain multiple groups, each group is a file format, that is, each file format group includes multiple OLE objects; accordingly, the file reconstruction unit specifically allocates a corresponding number of threads to each group according to the number of groups and the size of each group. Of course, in other embodiments, the grouping unit can also group according to the type of OLE objects, and also allocate a corresponding number of threads according to the number of groups and the size of each group.
[0084] In some other embodiments, the reconstruction display module further includes: a multi-thread allocation unit, configured to allocate a corresponding number of threads according to the number of groups and the sum of the file sizes of each group.
[0085] In other embodiments, as described in the above embodiments, the multi-thread allocation unit is trained using a pre-constructed training sample set, and can automatically allocate and start a corresponding number of threads for each group based on the number of groups, the total size of OLE objects in each group, the current memory usage, and the current CPU occupancy; or, can automatically allocate and start a corresponding number of threads for each group (or even for each larger OLE object) based on the number of groups, the total size of OLE objects in each group, the number of larger OLEs in each group and the number of blocks of each larger OLE, the current memory usage, and the current CPU occupancy.
[0086] Example 3: See Figure 6B The present invention provides a cross-platform display method for nested OLE objects in a DWG file, specifically, the method comprises the steps of: S101, creating a DWG file using CAD on a first platform, and then importing at least one first file and storing it as at least one OLE object.
[0087] In some embodiments, the first platform is Windows, that is, in a Windows environment, a dwg file is created using a CAD system; wherein the OLE object is to nest multiple formats of first files in the dwg file in a CAD system in a Windows environment, thereby obtaining a DWG file with multiple OLE objects nested therein.
[0088] The format of the first file can be various, including: wmf, emf, bmp, doc, docx, ppt, xls, rtf, dwg, vsd, png and other file formats.
[0089] S102, importing the created DWG file on the second platform, and extracting data information of multiple OLE objects from the DWG file.
[0090] In some embodiments, the second platform is a platform that can run Linux or other CAD systems, so the DWG file can be imported using CAD. The second platform can also be a web page, for example, the DWG file can be imported into a web version of the DWG viewing platform, etc.
[0091] S103, using a multi-thread mechanism, redrawing according to the data information of each OLE object to reversely restore and display.
[0092] In some embodiments, different types of OLE objects are nested in each DWG file. Therefore, in order to improve drawing efficiency, after obtaining data information of multiple OLE objects, they are grouped according to the type of OLE objects, and each group starts multiple threads for parallel drawing.
[0093] In this embodiment, reverse restoration is to redraw the corresponding content according to the acquired data information of the OLE object. Figure 2 The OLE object is displayed after reverse restoration. Specifically, the specific file format of the OLE object is determined according to the extracted data information, and then the file of the specific file format is redrawn and restored, and then displayed.
[0094] In this embodiment, OLE objects are mainly divided into two categories: WMF (Windows Metafile Format) and EMF (Enhanced Metafile Format). WMF is further divided into two categories: Original WMF and Placeable WMF. EMF is further divided into three categories: Original EMF, Extension 1 EMF, and Extension 2 EMF.
[0095] The format of the WMF file is composed of a header, a record, and an end-of-file record. The header contains the summary information of the file, and the last one is the end-of-file record. The specific records of the information contained in the WMF file are between the header record and the end-of-file record. The difference between native WMF and placeable WMF is that placeable WMF has one more header record than native WMF, such as Figure 3 shown.
[0096] EMF files are enhanced versions of WMF files, so the structure of EMF files is similar to that of WMF files, and is also composed of a header, a record, and an end-of-file record. The header of a file is also a type of record, so EMF files are all composed of records. The header record of an EMF file is the key to distinguishing the three types of EMF files. The main difference is that the header lengths of the three types of EMF files are different. See Figure 4 .
[0097] In summary, the classification rules for extracting the data information corresponding to each OLE from the DWG file are as follows: (1) Based on the values of the first 4 bytes in the data stream, native WMF, placeable WMF and EMF can be distinguished, as shown in Table 1 below: Table 1 Distinguishing OLE types based on the values of the first 4 bytes in the data stream (2) After determining that it is EMF, the specific EMF type is determined based on the head length, as shown in Table 2 below: Table 2 Classification of EMF types based on head length In some embodiments, corresponding multi-threads are allocated to each of the native WMF, the placeable WMF, the native EMF, the enhanced type 1 EMF and the enhanced type 2 EMF for parallel processing.
[0098] Of course, in other embodiments, the groups may be grouped according to the specific format of the first file corresponding to the OLE object instead of the type of OLE, and then the number of threads may be allocated according to the total file size of each group. Allocating the number of threads according to the size of each group can, on the one hand, reasonably allocate resources, and on the other hand, can, to a certain extent, keep the redrawing speeds of groups with small size differences consistent or not much different, so that the user can see a certain degree of coherence and avoid a large number of threads appearing in a short period of time. Figure 1 Shown as blank or loading.
[0099] Furthermore, there are multiple OLEs in the same group (for example, obtained by grouping according to OLE type, or obtained by grouping according to the first file type), and different OLEs have different sizes. Therefore, when configuring the number of threads for each group, it is also necessary to allocate them according to the size of the OLE in each group. Specifically, if the sum of the file sizes of the OLE objects in a group exceeds a preset threshold, a first preset number of threads is opened for this group; if it is less than the preset threshold, a second preset number of threads is opened for this group; wherein the second preset number is less than the first preset number. If at least one thread of any group is idle after completing a task, it can be merged into the thread of another group for parallel processing, thereby avoiding the situation where the overall drawing time is too long while there are idle threads at the same time, thereby improving the overall drawing efficiency, avoiding freezes, or the problem that the user sees the "loading" status in the interface for a long time, resulting in a poor user experience.
[0100] Of course, in other embodiments, a machine learning algorithm can be used to automatically allocate the number of threads for each group. Specifically, a training sample set is pre-constructed, and the training sample set is used for training to obtain a task allocator that can automatically allocate the corresponding number of threads for each group according to the number and size of the groups. For example, the number of groups, the sum of the OLE object sizes of each group, the current memory usage rate, the current CPU occupancy rate, and the number of threads for each group are input as input parameters into a pre-constructed machine training model, and then the task allocator is obtained, so that the task allocator (or thread manager) can automatically allocate and open the corresponding number of threads for each group according to the number of groups, the sum of the OLE object sizes of each group, the current memory usage rate, and the current CPU occupancy rate. Ideally, allocating a thread to each OLE object can increase the processing speed, but such an operation not only greatly increases the system power consumption, but also occupies a large amount of system resources, which may cause jamming and reduce the drawing speed. Therefore, by reasonably allocating the corresponding number of threads to each group, under the premise of reasonable use of system resources, the drawing efficiency is improved, jamming is avoided, or the user sees the state of "loading" for a long time in the interface.
[0101] Furthermore, the size of each OLE in each group is also different, so a larger OLE can also be divided into blocks, and the corresponding number of threads can be allocated according to the number of blocks. For example, when the number of blocks reaches a preset threshold, a third preset number of threads are simultaneously opened for it, otherwise, if the number of blocks is less than the preset threshold, a fourth preset number of threads are started for it; wherein the fourth preset number is less than the third preset number. For a larger OLE object, if the same thread is allocated for processing with other smaller OLE objects, it may cause other OLE objects to appear, while the larger OLE object is not displayed, causing the user to see a blank, creating a false impression that the OLE has no data (especially when a large number of OLEs appear, since the user does not know the size of the OLE, it is easy to cause such a misjudgment), or always see the loading state, thereby reducing the user experience. Usually, if an OLE object is small, it may be assigned to a task queue of a drawing thread for queuing, so the OLE files in the task queue can be further prioritized according to certain rules, for example, sorted by size, the smaller the higher the priority.
[0102] Of course, in other embodiments, when using the above-mentioned machine learning algorithm to automatically distribute the number of threads for each group, new parameters can be further introduced, that is, the number of larger OLE objects in each group, and the number of blocks and threads of each larger OLE object, so that the corresponding number of threads can be automatically distributed and opened for each group and each larger OLE in the group according to the number of groups, the sum of the OLE object sizes of each group, the number of larger OLEs in each group and the number of blocks of each larger OLE, the current memory usage rate, and the current CPU occupancy rate. By reasonably distributing the corresponding number of threads to each group, the drawing efficiency is improved. As mentioned above, for smaller OLE objects, they may be distributed in the task queue of a certain thread, that is, multiple OLE objects share one thread, however, for larger OLE objects, it is less efficient to use one thread to draw, therefore, by dividing it into blocks, and then distributing multiple threads to draw in parallel, it is avoided that the user sees the "loading state" for a long time.
[0103] By dividing a larger object into multiple blocks, each containing data of a specific size, this block mechanism helps reduce memory usage and improve performance, while also facilitating transmission, storage, and redrawing, improving drawing efficiency.
[0104] Preferably, the OLE block mechanism: assigns a unique ID to each data block for identification and indexing in the index table; The index table records the location and size of each data block. The index table can be stored in the file header or in a separate area for quick search.
[0105] The size of the data block can be set according to actual conditions, and usually a suitable fixed size is selected.
[0106] OLE objects are divided into multiple data blocks, and the index table records the location and size information of each data block. This block structure allows the system to dynamically load and process data blocks as needed, thereby managing larger OLE objects more efficiently.
[0107] For example, when the blocks are divided, the dynamic loading is carried out with the mouse focus as the center point and spreads to the surroundings in an orderly manner, such as Figure 5 As shown in the figure: 0, 1, 2, and 3 represent the individual blocks after OLE segmentation, starting from 0, then to 1, then to 2, and finally to 3, and so on until the segmentation is completed. When processing OLE objects, it is usually considered to segment larger OLE objects into blocks in order to effectively manage and process data.
[0108] In some embodiments, the step of determining the OLE size specifically includes: determining whether the file size of the OLE object exceeds a preset threshold (for example, several megabytes or even tens of megabytes), and if so, marking it as a larger OLE object; or, when loading an OLE object into memory, determining whether the memory consumed by the OLE object exceeds a preset proportion of the system's available memory, and if so, marking it as a larger OLE object.
[0109] In addition, processing performance: Large OLE objects may affect the processing performance of the application, such as opening, editing, saving and other operations taking more time.
[0110] In summary, when an OLE object exceeds certain limits in terms of file size, memory usage, and processing performance, it can be considered a large OLE object.
[0111] Example 4: See Figure 7B The present invention also provides a cross-platform display device for nesting OLE objects in a DWG file, specifically, comprising: A file import module, used for importing a DWG file previously created by using CAD on a first platform (such as Windows) on a second platform (such as Linux), wherein the DWG file has a plurality of OLE objects embedded therein; A data extraction module is used to extract data from the imported DWG file to obtain data information of multiple OLE objects (including basic information such as the format of the original first file corresponding to the OLE object); The file restoration module is used to adopt a multi-thread mechanism to redraw according to the data information of each OLE object for reverse restoration; The display module is used to display the content redrawn by the redrawing module, that is, to display the restored file.
[0112] In some embodiments, the file restoration module specifically includes: A file type identification unit, used to identify a specific file format according to the extracted data stream; The file restoration unit is used to restore the extracted data stream from binary to a corresponding file format.
[0113] In some embodiments, the file restoration module further includes: a grouping unit, which is used to group the OLE objects based on the file format when the file type identification unit identifies the file format, to obtain multiple groups, each group is a file format, that is, each file format group includes multiple OLE objects; accordingly, the file restoration module specifically allocates a corresponding number of threads to each group according to the number of groups and the size of each group. Of course, in other embodiments, the grouping unit can also group according to the type of OLE objects, and also allocate a corresponding number of threads according to the number of groups and the size of each group.
[0114] In some other embodiments, the file restoration module further includes: a multi-thread allocation module, which is used to allocate a corresponding number of threads according to the number of groups and the total file size of each group.
[0115] In other embodiments, as described in the above embodiments, the multi-thread allocation module is trained using a pre-constructed training sample set, and can automatically allocate and start a corresponding number of threads for each group based on the number of groups, the total size of OLE objects in each group, the current memory usage, and the current CPU occupancy rate; or, can automatically allocate and start a corresponding number of threads for each group (or even for each larger OLE object) based on the number of groups, the total size of OLE objects in each group, the number of larger OLEs in each group and the number of blocks of each larger OLE, the current memory usage, and the current CPU occupancy rate.
[0116] Embodiment 5: The present invention also provides a cross-platform display system for nested OLE objects in a DWG file, which comprises: The first terminal is used to create a DWG file on the first platform; the DWG file is embedded with multiple OLE objects; The second terminal is used to import the DWG file created by the first terminal on the second platform, and extract data information of multiple OLE objects from the DWG file, and adopt a multi-threading mechanism to redraw according to the data information of each OLE object to reversely restore each OLE object.
[0117] Specifically, the second terminal includes the display device of the above embodiment, and its working principle is the same, which will not be described here.
[0118] The method of the present invention is described in detail below with reference to a specific example. The method comprises the following steps: importing a dwg file created by CAD under Windows when it is cross-platform; extracting the data stream of the imported dwg file to obtain a related data stream; analyzing and judging the extracted binary data stream to determine its specific file format; performing reverse restoration according to the determined file format; and displaying the restored file.
[0119] The system of the present invention comprises the following modules: a data extraction module: responsible for extracting data contained in a dwg file created by CAD under Windows; a file type judgment module: responsible for determining a specific file format from the extracted data stream; a file restoration module: responsible for restoring the extracted data stream from binary to a corresponding file format; and a file display module: responsible for displaying the restoration result to a CAD user and receiving the user's modification.
[0120] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0121] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a computer terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0122] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
Claims
1. A cross-platform display method for nested OLE objects in DWG files, characterized in that include: Creating a DWG file on the first platform, and embedding a plurality of OLE objects in the DWG file; Importing the DWG file on the second platform, and extracting data information of the OLE object from the DWG file; Grouping a plurality of OLE objects in the DWG file according to data information of the OLE objects, and reconstructing the OLE objects in the group according to the group configuration thread, so as to reversely restore and display the OLE objects; The steps of configuring threads according to groups include: When the total amount of OLE object data in a group is greater than or equal to a first preset threshold, configuring a first preset number of threads for the group; When the total amount of OLE object data in a group is less than a first preset threshold, configuring a second preset number of threads for the group; If at least one thread of any group completes its task, it will be merged into the thread of another group for parallel processing; The second preset number is smaller than the first preset number.
2. The method for displaying a DWG file nested OLE object across platforms according to claim 1, characterized in that: The data information includes: the type of the OLE object, and the file format of the external file corresponding to the OLE object; grouping is performed according to the type of the OLE object, or grouping is performed according to the file format of the external file corresponding to the OLE object.
3. The cross-platform display method of a DWG file nested OLE object according to claim 2, characterized in that: The OLE objects are grouped according to their types, including a native WMF group, a placeable WMF group, a native EMF group, an enhanced type 1 EMF group, and an enhanced type 2 EMF group; Accordingly, when extracting the OLE object data information, identifying the type of the OLE object specifically includes: According to the value of the first preset threshold bytes in the header of the data stream of the OLE object, the native WMF type, the placeable WMF type and the EMF type are identified; After identifying that the OLE object is of EMF type, the specific category of the EMF type is identified according to the header length; wherein the header length of the native EMF is a second preset threshold byte, the header length of the enhanced type 1 EMF is a third preset threshold byte, and the header length of the enhanced type 2 EMF is a fourth preset threshold byte, the second preset threshold is less than the third preset threshold, and the third preset threshold is less than the fourth preset threshold.
4. The method for displaying a DWG file nested OLE object across platforms according to claim 2, characterized in that: Identify the OLE objects in each group whose data volume exceeds a second preset threshold value, or whose memory occupation exceeds a preset proportion of the available memory, and mark them as large OLE objects; Divide the larger OLE objects in each group into several data blocks.
5. A cross-platform display method for OLE objects nested in a DWG file according to claim 4, characterized in that: The steps to configure threads by group also include: When the number of data blocks in a certain group is greater than or equal to the number threshold, configuring a third preset number of threads for the group; When the number of data blocks in a certain group is less than the number threshold, a fourth preset number of threads is configured for the group; the fourth preset number is less than the third preset number.
6. The method for displaying a DWG file nested OLE object across platforms according to claim 5, characterized in that: Sort the thread task queue. The smaller the OLE object data size, the higher its priority.
7. The cross-platform display method of OLE objects nested in DWG files according to claim 5, characterized in that: A data block index table is established to assign a unique ID to each data block; the index record of the index table includes the data block ID and the corresponding address and data size.
8. The cross-platform display method of OLE objects nested in DWG files according to claim 7, characterized in that: When dividing the OLE object into data blocks, the data blocks are spread out in an orderly manner around the cursor focus.
9. A cross-platform display system for nested OLE objects of DWG files, characterized in that include: A DWG file creation module is configured to create a DWG file on the first platform and embed a plurality of OLE objects in the DWG file; A data information extraction module is configured to import the DWG file on the second platform and extract the data information of the OLE object from the DWG file; The reconstruction display module is configured to group several OLE objects in the DWG file according to the data information of the OLE objects, and reconstruct the OLE objects in the group according to the group configuration thread, so as to reversely restore and display the OLE objects.
10. The cross-platform display system of DWG file nested OLE objects according to claim 9, characterized in that: The reconstruction display module specifically includes: A file type identification unit is configured to identify the file format of the external file corresponding to each of the OLE objects according to the extracted data stream; a grouping unit configured to group all OLE objects in the DWG file based on the file format to obtain a plurality of groups, each group being a file format, when the file type identification unit identifies the file format of the external file corresponding to each of the OLE objects; or to group all OLE objects in the DWG file based on the type of the OLE objects to obtain a plurality of groups, each group being a type of OLE object; The multi-thread allocation unit is configured to allocate a corresponding number of threads according to the number of groups and the total file size of each group; The file reconstruction unit is configured to restore each of the OLE objects to a corresponding file format using a multi-threading mechanism.
Citation Information
Patent Citations
Converting method of object linking and embedded object
CN1862498A
File scanner to detect malicious electronic files
US11184379B1
Signatureless detection of malicious ms office documents
WO2022182919A1