Many different types of application programs deal with the problem of determining the appropriate layout for rich content contained on a page of a document. For instance, word processing application programs must lay out content on a finite page that potentially includes text, graphics, headers, footers, footnotes, endnotes, tables, and other types of content. Other types of application programs such as World Wide Web (“Web”) browsers deal with similar problems in the context of “bottomless” document pages that do not necessarily have a fixed bottom margin.
Because application programs typically implement their own program code for performing page layout, a number of problems can arise. In particular, the code that is developed for these applications is often operating system or application dependent, thereby making reuse of the code very difficult. Moreover, because layout code is typically implemented separately by each application program, different application programs can lay out similar content in dissimilar ways. Inconsistent results as a consequence of different page layout routines in different application programs can be frustrating to a user.
Application page layout code is also often developed for utilization with only one natural language and extension to other natural languages is very difficult. Moreover, this code is often developed with one particular document file format in mind. The extension of the program code to other file formats can be very difficult. In a similar vein, it can also be very difficult to extend the page layout code provided by an application program to other types of page objects other than those initially supported by the application.
Most page layout code also works only with page geometries that have been predefined. For instance, in most application programs it is necessary for the end user to specifically define the geometry of the page by drawing boxes on the page. As an example, a user may be required to draw a box for the page header, a box first column, a box for footnotes, etc. The application program then fills the boxes with content. The user may then look at the result and adjust the geometry of the boxes. While laying content out in predefined geometries is much easier for the application program, it makes the layout process much more difficult for the user.
Another challenge to page layout code is the ability to lay out pages of a document and to provide information necessary to layout each of the resulting pages independently at a later time. This is important because a small edit to one page of a document cannot require the entire document to be re-laid out. Another feature that is lacking in page layout routines is the ability to efficiently update bottomless pages. Even when only a small portion of a bottomless page is modified, previous algorithms update the entire page. Because bottomless pages have a potentially infinite bottom margin, updating the layout of a bottomless page can be very time consuming. Long update times can be very frustrating for a computer user.
It is with respect to these considerations and others that the various embodiments of the present invention have been made.
In accordance with the present invention, the above and other problems are solved by a method and computer-readable medium for providing page and table layout services. According to embodiments of the invention, an application-independent, operating system-independent, and reusable layout manager program is provided that provides layout services to application programs. Through the use of the layout manager, virtually any type of rich document content can be laid out as a sequence of finite pages or a bottomless page, including content utilizing any foreign language and corresponding writing direction. Because the same layout manager program may be utilized by any number of application programs, similar formatting results are provided by different application programs. Moreover, mechanisms are provided for each application to customize the formatting result.
According to one embodiment of the invention, a computer-implemented method and computer-readable medium are provided for providing page and table layout services. According to the method, a layout manager program is provided that provides layout services to client application programs, such as word processing application programs. The services provided by the layout manager are for laying out page headers and footers, figures (also referred to herein as absolutely positioned objects), floating objects, balanced columns, pagenotes and endnotes, tables, and text formatted according to different writing direction geometries. Rather than requiring a user to specify the geometry for a page, the layout manager receives requirements for the page from the client application. The layout manager then lays out the page in a manner consistent with the requirements by calculating the geometrical dimensions of the various page objects necessary to satisfy the requirements. The layout manager then returns the generated layout to the client application.
According to an embodiment of the invention, the layout manager receives a request from a client application program to format document content. The request includes formatting requirements for the document content. For instance, the client application may specify that it needs the resulting layout to include a page header containing certain text. The layout manager is responsible for calculating the size of the header. As another example, the client application may specify that certain content should be laid out in a multiple column format. The layout manager is then responsible for determining the actual height of the columns into which the content is laid out.
In response to the request from the client application, the layout manager performs one or more callback operations to the client application to retrieve portions of the content to be laid out. Once the portions of the document to be laid out have been retrieved through the callback operations, the layout manager calculates which parts of the content fits on a current page, arranges those parts on the page, and returns to the client application program a break record that allows portions of the document to be laid out on the next page. The client application program then transmits to the layout manager one or more requests for the formatting result. The layout manager then responds to the request from the client application with the result and the client application updates a display tree to reflect the page layout.
According to one embodiment of the invention, the layout manager is operative to define and impose on the client application a particular logical document structure. The logical document structure is different than the native document structure utilized by a client application to store a document on a backing store. The document structure is general enough so that a client application can easily translate from its native structure to the logical structure. When the layout manager utilizes the callback operations to retrieve the portions of the document to be laid out, the client application responds with portions of the document that are formatted according to the defined logical document structure. Because the layout manager imposes the document structure on all of its clients, the layout manager is freed from having to understand the different data structures that may be utilized by different application programs to store documents on their backing stores. In an embodiment, the document structure defined by the layout manager is different than the native document structure utilized by a client application to store a document on a backing store.
According to another embodiment of the invention, the layout manager can lay out the portions of the page provided by a client application in any possible writing direction geometry. A writing direction geometry defines a direction for the addition of new words to a page and also the direction for the addition of new lines to a page. In this manner, the layout manager is operative to lay out text in virtually any written language. The client application specifies which of the possible writing direction geometries to be utilized for a given page.
According to another embodiment of the invention, an extensibility feature is provided whereby a client application can define and lay out the contents of a client application program defined paragraph. When the layout manager encounters a client defined paragraph, it executes a client-provided method to lay out the contents of the paragraph. The client application then provides an indication to the layout manager of the formatting that was performed by the client-provided method. In this manner, a client application is free to define custom paragraph types by providing code to lay out the custom paragraphs.
According to another embodiment, the layout manager provides a process for incrementally updating the layout of a bottomless page. In particular, a client application may request that the layout manager update the layout of a bottomless page, such as in response to an edit being made to the page. As a part of the request, the client application may provide the location of the change to the layout manager. In response to the request, the layout manager is operative to locate the line that includes the location that was changed within the bottomless page. Once the changed line has been located, the layout manager reformats the changed line. The layout manager also determines if the next line was modified as a result of the reformatting. If the next line was changed, the layout manager reformats each subsequent line until no further changes are detected and the geometry after the line is the same as it was prior to the change. The layout manager then returns only the changed portion of the bottomless page to the client application. In this manner, a new layout may be generated only for the changed portion of a bottomless page, thereby reducing the amount of time necessary to lay out the page as compared to generating a completely new layout in response to an edit.
The invention may be implemented as a computer process, a computing system, or as an article of manufacture such as a computer program product or computer readable media. The computer program product may be a computer storage media readable by a computer system and encoding a computer program of instructions for executing a computer process. The computer program product may also be a propagated signal on a carrier readable by a computing system and encoding a computer program of instructions for executing a computer process.
These and various other features, as well as advantages, which characterize the present invention, will be apparent from a reading of the following detailed description and a review of the associated drawings.
Referring now to the drawings, in which like numerals represent like elements, various aspects of the present invention will be described. In particular,
Generally, program modules include routines, programs, components, data structures, and other types of structures that perform particular tasks or implement particular abstract data types. Moreover, those skilled in the art will appreciate that the invention may be practiced with other computer system configurations, including hand-held devices, multiprocessor systems, microprocessor-based or programmable consumer electronics, minicomputers, mainframe computers, and the like. The invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote memory storage devices.
Referring now to
The mass storage device 14 is connected to the CPU 5 through a mass storage controller (not shown) connected to the bus 12. The mass storage device 14 and its associated computer-readable media provide non-volatile storage for the computer 2. Although the description of computer-readable media contained herein refers to a mass storage device, such as a hard disk or CD-ROM drive, it should be appreciated by those skilled in the art that computer-readable media can be any available media that can be accessed by the computer 2.
By way of example, and not limitation, computer-readable media may comprise computer storage media and communication media. Computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EPROM, EEPROM, flash memory or other solid state memory technology, CD-ROM, digital versatile disks (“DVD”), or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by the computer 2.
According to various embodiments of the invention, the computer 2 may operate in a networked environment using logical connections to remote computers through a network 18, such as the Internet. The computer 2 may connect to the network 18 through a network interface unit 20 connected to the bus 12. It should be appreciated that the network interface unit 20 may also be utilized to connect to other types of networks and remote computer systems. The computer 2 may also include an input/output controller 22 for receiving and processing input from a number of other devices, including a keyboard, mouse, or electronic stylus (not shown in
As mentioned briefly above, a number of program modules and data files may be stored in the mass storage device 14 and RAM 9 of the computer 2, including an operating system 16 suitable for controlling the operation of a networked personal computer, such as the WINDOWS XP operating system from MICROSOFT CORPORATION of Redmond, Wash. The mass storage device 14 and RAM 9 may also store one or more program modules. In particular, the mass storage device 14 and the RAM 9 may store a word processing application program 10. As known to those skilled in the art, the word processing application program 10 is operative to provide functionality for creating and editing electronic documents, such as the document 24.
According to one embodiment of the invention, the word processing application program 10 comprises the MICROSOFT WORD word processing application program from MICROSOFT CORPORATION. It should be appreciated, however, that other word processing application programs from other manufacturers may be utilized to embody the various aspects of the present invention. It should also be appreciated that other types of application programs that perform document layout functions may be utilized with the aspects of the present invention. For instance, the embodiments of the present invention may be utilized with desktop publishing programs, presentation programs, web browsers, and any other type of program that lays out text and other information in a document.
In conjunction with the editing of a word processing document, the word processing application program 10 provides functionality for laying out paragraphs of text and other types of objects in a document 24. The word processing application program 10 may communicate with a layout manager 26 to assist in the formatting of the document 24, including the lay out of text paragraphs and other objects. As will be described in greater detail below, the layout manager 26 provides layout services to the word processing application program 10, and to any other program executing on the computer 2. In particular, the layout manager 26 performs various algorithms to lay out text and other objects in a document. Additional details regarding the operation of the layout manager 26 will be provided below with respect to
Turning now to
As will be described in greater detail below, the layout manager 26 provides facilities for laying out paragraphs of text and other objects on a page. The layout manager 26 provides these facilities in response to a request from the application program 10 to generate a page layout. The document manager 30 of the application program 10 may communicate with the layout manager 26 to request that a page be laid out. The document manager 30 may also provide to the layout manager 26 the text and other content from the document that should be laid into the paragraph. The document manager 30 may initially provide some of the content to the layout manager 26. The layout manager 26 may then request additional content from the callback code 32 as needed to lay out the page. The document manager 30 may also indicate to the layout manager 26 the style of the text or other object to be laid out. For instance, the document manager 30 may indicate the typestyle, size, and other information necessary to lay out a text paragraph to the layout manager 26.
Once the layout manager 26 has laid out a page in the manner described herein, a formatting result 36 is passed back to the document manager 30. In response to receiving the formatting result 36, the document manager 30 is operative to update the display tree 38 maintained by the application program 10. Based on the changes to the display tree 38, the application program 10 may update its rendered output 40 to display the formatting result to a user. Additional details regarding the operation of the application 10 and the layout manager 26 are provided below with respect to
Referring now to
When the track module 52 receives content from the client application, it dispatches it to an appropriate paragraph formatter. A text module 54, a figure module 56, a floater module 58, a table module 60, and a client defined paragraph module 62 are the paragraph formatters provided according to an embodiment of the invention. Other paragraph formatters may also be provided. Each of the paragraph formatters may then utilize callbacks 32 to request additional attributes and content from the client application. This information may be utilized by the paragraph formatters to determine whether the content fits on the page or should be broken, the size and location of the content. This information is then returned to the track module 52.
Three types of services are also made available to client applications in the various embodiments of the invention: geometry services 64, subpage services 66, subtrack services 70, and multi-column layout services 68. These services may be utilized by clients using client-defined paragraphs or by paragraph level objects utilized provided by the layout manager 26. Geometry services 64 maintains and provides information regarding the current state of the geometry of a page. Subpage services 66 allows clients to create subpages that share most of the features of a page but that have their own page geometry independent of the surrounding page geometry. Subpages can also be multi-column and contain column span areas. Subpages can be used to format the contents of table cells, floaters (e.g. text boxes), and client-defined paragraphs.
Subtrack services 70 may be used from within an implementation of a client-defined paragraph when the client application desires that the content of the paragraph should flow in the same geometry as the surrounding text. This allows text within a client-defined paragraph to flow around obstacles not present in the object itself, different content to flow around the same obstacles, and allows obstacles anchored inside the subtrack to influence the flow of text outside the subtrack. Multi-column layout services 68 provide functions for laying out text and other objects in multiple columns. Subtrack services 70 and subpage services 66 introduce recursion by calling into the track module 52.
It should be appreciated that as a result of the various integrated software components described above with respect to
Turning now to
The document structure shown in
Referring now to
When reading the discussion of the routines presented herein, it should be appreciated that the logical operations of various embodiments of the present invention are implemented (1) as a sequence of computer implemented acts or program modules running on a computing system and/or (2) as interconnected machine logic circuits or circuit modules within the computing system. The implementation is a matter of choice dependent on the performance requirements of the computing system implementing the invention. Accordingly, the logical operations illustrated in
The routine 500 begins at operation 502, where a client application program calls the layout manager 26 with a request to create a new document context for a page layout. The routine 500 then continues to operation 504, where the client application program calls the layout manager 26 with a request to create a new page within the newly created document context. From operation 504, the routine 500 continues to operation 506.
At operation 506, the layout manager 26 iteratively fetches the content and other client document data necessary to lay out the page utilizing the callbacks 32. When responding to the callbacks, the client application program converts its native data structures into the document structure defined by the layout manager and described above with respect to
When the layout manager 26 has completed the page layout, the layout manager 26 indicates to the client application program that the layout has been completed and provides a formatting summary to the client at operation 510. The routine 500 then continues to operation 512, where the client application program repeatedly calls the layout manager 26 to retrieve the formatting result 36. At operation 514, the client application utilizes the formatting result 36 to update the display tree 38 and the rendered output 40. The routine 500 then continues to operation 516, where the client application instructs the layout manager 26 to destroy the page.
From operation 516, the routine 500 continues to operation 517, where a determination is made as to whether the current page is the last page. If the current page is not the last page, the routine 500 returns to operation 504, where the page break record from the current page is utilized to format the next page in a manner similar to that described above with respect to operations 504-516. The page break record indicates to the client application where the layout ended for the current page. By using the page break record, the client application can determine where in the backing store formatting of the next page should begin. In this manner, the page break record for any page can be utilized to lay out the next consecutive page. This may be useful, for example, to re-lay out a page in the middle of a document without reformatting other previous or subsequent pages. If the current page is the last page, the routine 500 continues to operation 518, where the client application instructs the layout manager 26 to destroy the created document context. The routine 500 then continues from operation 518 to operation 520, where it ends.
Referring now to
The four coordinate systems 100A, 100B, 100E, and 100F represent the writing geometries utilized by most languages. For instance, the English language utilizes the coordinate system 100A. It should be appreciated, however, that other coordinate systems may be utilized and supported by the layout manager 26. In this manner, the layout manager is operative to lay out text in any written language. The client application specifies which of the possible writing direction geometries to be utilized for a given page. Additionally, it is possible for different geometries to be utilized within different paragraphs on the same page.
Referring now to
At operation 704, the layout manager 26 receives from the client application an indication as to where on the page a change occurred. The routine 700 then continues to operation 706, where the layout manager 26 locates within the page the line at which the change occurred. The routine 700 then continues to operation 708, where the layout manager reformats only the line on which the change occurred. The routine 700 then continues to operation 710.
At operation 710, the layout manager 26 determines whether the reformatting of the line on which the change occurred resulted in a change to the line break for the line. If a changed line break did occur, the routine continues to operation 712, where the next line following the line in which the change occurred is also reformatted. The routine 700 then returns to operation 710, where a determination is made as to whether the reformatting of the next line caused a new line break. This process continues until the reformatting of a line does not result in a new line break. When this occurs, the routine 700 branches from operation 710 to operation 714.
At operation 714, the layout manager 26 provides only the changes to the page that were made as a result of the reformatting to the client application. At operation 716, the client updates the display tree 38 with the changes. The routine 700 then continues to operation 718, where it ends.
According to another embodiment, the routine 700 may be performed when a simple bottomless page is present. When a complex page is present, the layout manager 26 may reformat the entire page and do a comparison between the previous page and the newly reformatted page to identify any differences. The layout manager 26 may then identify to the client application only the differences between the two pages.
Based on the foregoing, it should be appreciated that the various embodiments of the invention include a method, system, apparatus, and computer-readable medium for providing page and table layout services. The above specification, examples and data provide a complete description of the manufacture and use of the composition of the invention. Since many embodiments of the invention can be made without departing from the spirit and scope of the invention, the invention resides in the claims hereinafter appended.