Developers of many application programs (“applications”) implement the applications so that they can be customized by third parties. To customize an application, a third party develops custom code (e.g., add-ins and document-level customizations) that uses functionality exposed by the application. The custom code may improve the usability of the applications or provide additional functionality (e.g., domain-specific functionality). Such applications are referred to as “host applications” because the custom code is hosted within the process of the application. Developers of applications typically want to encourage the development of custom code for their applications to increase the demand for their applications. As a result, such developers may provide “runtimes” that facilitate the development of custom code. A runtime is code that is loaded along with custom code and provides services to the custom code. These services may include higher-level functionality than exposed by the application or may include domain-specific functionality. When an application is to load and start the execution of custom code, the application may load the runtime and direct the runtime to load and start the execution of the custom code.
Because of the ease of developing custom code as “managed code,” many applications support the execution of custom code in the .NET Framework provided by Microsoft Corporation. The .NET Framework provides a common language runtime (“CLR”) that provides high-level operating system type services to the managed programs (including custom code and applications) and serves as an execution engine for managed programs. The CLR ensures that managed programs do not take any unauthorized action. As such, the CLR acts as a “sandbox” within which managed programs execute. The CLR provides application domains (“appdomains”) in which different managed programs can execute to help ensure that an errant managed program will not unduly affect the execution of another managed program.
The Microsoft Office suite of applications introduces a new user interface called the Ribbon. The Ribbon replaces menus and toolbars in several Office applications. The Ribbon provides an XML/callback model that allows developers to create a custom Ribbon user interface for Office documents and applications by extending the standard Ribbon user interface. The XML/callback model requires a developer to generate an XML document that describes the custom user interface. Table 1 illustrates a sample XML document describing a custom user interface.
Lines 1 and 11 are “customUI” tags that delimit the description of the user interface. Lines 2 and 10 are “ribbon” tags that delimit the description of the Ribbon elements to extend the Ribbon. Lines 3 and 9 are “tabs” tags that delimit the description of multiple tabs of the extended user interface. Lines 4 and 8 are “tab” tags that delimit the description of a tab. The described tab has an “id” of “Tab1 ” and a label of “Tab1 ” as attributes. Lines 5 and 7 are “group” tags that delimit the description of a group within the tab. The described group has an “id” of “Group1 ” and a label of “Group 1 ” as attributes. Line 6 is a “button” tag that defines a button within a group. The button has an “id” of “Button1,” an “on Action” of “Button1_OnAction,” and a label of “Button1 ” as attributes. The extended user interface thus has one tab with a group that contains one button. When a user takes some action directed to (e.g., clicks on) “Button1,” the Office application calls back to the add-in using the IDispatch interface of Microsoft's Component Object Model (“COM”) passing an indication of “Button1_OnAction.” The add-in can then handle the user action as appropriate.
Table 2 illustrates code generated by a developer using the XML/callback model to extend a Ribbon user interface.
Line 3 indicates that the class Ribbon implements the IRibbonExtensibility interface. The IRibbonExtensibility interface includes a GetCustomUI function. When an Office application initially loads an add-in, it requests the IRibbonExtensibility interface from the add-in. The Office application then calls the GetCustomUI function to retrieve the XML string describing the extended user interface. The Office application also calls an OnLoad function, which is defined by the top level XML element—customUI, to provide an IRibbonUI interface to the add-in. Lines 11-14 illustrate that the GetCustomUI function implemented by a developer invokes a GetResourceText function to retrieve the XML file to return to the Office application. Lines 16-19 illustrate that the OnLoad function implemented by a developer stores a reference to the IRibbonUI interface passed by the Office application. The IRibbonUI interface includes an InvalidateControl function for notifying the Office application that a component of the extended user interface has been modified (e.g., a new label has been defined for a button). Lines 21-25 illustrate the “Button1_OnAction” callback method. When a user performs some action directed to “Button1,” as described in Table 1, the Office application invokes the Invoke function of the IDispatch interface passing as a parameter “Button1_OnAction.” The Invoke function then invokes the method of lines 21-25. The Office application retrieves a reference to the IDispatch interface by invoking the QueryInterface function of the (Unknown interface of the COM model. Lines 27-44 illustrate an implementation of the GetResourceText function. The GetResourceText function is one way that the GetCustomUI function may return the XML string. The GetCustomUI function may alternatively return the XML string in another manner.
This XML/callback model for Ribbon customization, which requires creating an XML document and constructing callback methods, may not be familiar or intuitive to all developers. In particular, the XML/callback model for Ribbon customization is not intuitive to developers familiar with standard .NET programming. The .NET programming experience is generally characterized by utilization of a class library, operating on objects through properties and events, and other features.
An object model is provided that allows .NET developers to customize the Office Ribbon user interface according to a .NET Ribbon model rather than the Ribbon XML/callback model of Office applications. The .NET Ribbon model implements the IRibbonExtensibility interface and provides properties and events for Ribbon components. At runtime, the .NET Ribbon model generates and provides an Office application or document with the XML needed to render the custom Ribbon user interface. A visual designer tool uses the .NET Ribbon model to provide .NET developers with a component view architecture that allows developers to set component properties and generate event handlers. The visual designer tool enables developers to add controls representing Ribbon components to a design surface to define a Ribbon layout. Some of the controls available for use by the developer may be complex controls, which represent Ribbon components that may contain other Ribbon components as items. The visual designer provides the developer with a complex control architecture, displaying a nested design surface for the complex control into which the developer may add controls just as in the primary design surface.
This Summary is provided to introduce a selection of concepts in a simplified form that are further described in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
An object model is provided that allows .NET developers to customize the Office Ribbon user interface according to a .NET Ribbon model rather than the Ribbon XML/callback model of Office applications. The .NET Ribbon model implements the IRibbonExtensibility interface and provides properties and events for Ribbon components. At runtime, the .NET Ribbon model generates and provides an Office application or document with the XML needed to render the custom Ribbon user interface. A visual designer tool uses the .NET Ribbon model to provide .NET developers with a component view architecture that allows developers to set component properties and generate events. The visual designer tool enables developers to add controls representing Ribbon components to a design surface to define a Ribbon layout.
Some of the controls available for use by the developer may be complex controls, which represent Ribbon components that may contain other Ribbon components as items. The visual designer tool provides the developer with a complex control architecture, displaying a nested design surface for the complex control into which the developer may add controls just as in the primary design surface.
.NET Ribbon Model
A system for providing an alternate model (e.g., .NET Ribbon model) for a primary model (e.g., XML/callback model) for extending a user interface of a host application by custom code is provided. The primary model uses a non-programmatic (e.g., XML-based) description of the relationship between components of the user interface and uses a callback mechanism to provide notifications to the custom code. The system provides, for each component type of the user interface, a class definition including an implementation of a get description method for dynamically generating a non-programmatic description of the component from a programmatic description of the component and its relationship to other components. The system also provides a specification of the relationship between the components. The system provides an implementation of a get user interface function to be invoked by the host application to get the non-programmatic description of the user interface. The get user interface function invokes the get description method of the user interface component for dynamically generating the non-programmatic description from the programmatic description. The system also provides an implementation of an invoke function to be invoked by the host application to provide notifications to the custom code. The invoke function converts an invocation to an event notification for a component of the user interface.
An object model is provided that allows .NET developers to customize the Office Ribbon user interface according to a .NET Ribbon model rather than the Ribbon XML/callback model of Office applications. The .NET Ribbon model implements the IRibbonExtensibility interface and provides properties and events for Ribbon components.
The Office application add-in creates a Ribbon object comprised of Ribbon components. The .NET Ribbon model provides implementations of classes for various components that can be used to extend the Ribbon user interface. For example, the components may include a ribbon, a tab, a group, a button, and other components. The add-in instantiates a Ribbon object of a class implemented by the developer of the add-in. The Ribbon class may inherit a base class provided by the .NET Ribbon model that provides functionality to implement the .NET Ribbon model. The add-in then initializes each of the components that define the extended Ribbon user interface. The add-in may initialize the components by invoking an InitializeComponent method of the instantiated Ribbon object, invoking code written by a developer, deserializing components from a file, or other means. Returning to
At runtime, the Office application calls the IRibbonExtensibility.GetCustomUI function to retrieve the XML that describes the extension to the Ribbon user interface. The GetCustomUI function may instantiate an object to represent the XML document. The GetCustomUI function invokes the WriteXml method of the Ribbon object to create an XML description of the extended Ribbon user interface. The WriteXml method is a functionality provided by the base class inherited by a Ribbon class provided by a developer. The WriteXml method receives an instance of the XmlWriter class as a parameter. XmlWriter is a base abstract class defined by the .NET Framework, which supports the quick and efficient creation of an XML document. The .NET Ribbon model provides an implementation of the WriteXml method for each class of component. The WriteXml method of the Ribbon class invokes the WriteXml method of each tab object within a Ribbon object to allow each tab object to add its XML description to the XML document object. Each WriteXml method of each tab object invokes the WriteXml method of its constituent objects. This process continues to the leaf objects of the extended Ribbon user interface.
If a property of a Ribbon component changes at runtime, the implementation of the class provided by the .NET Ribbon model notifies the Office application by invoking the InvalidateControl function of the IRibbonUI interface to provide notification of the component that has changed. For example, a Microsoft Excel document may contain a listing of stock quotes that are updated periodically, based on the most recent information. The add-in that provides the stock quotes may monitor an RSS feed of stock quotes and update the label of a button representing the price of a stock whenever the price changes. When the add-in sets the label of the button object, the implementation of the button object invokes the InvalidateControl function of the IRibbonUI interface passing an indication of the button object. The InvalidateControl function notifies the Office application that the values acquired for the button object through callback methods are invalid. The Office application calls the callback methods corresponding to the changed button object to get new values for the button object. The Office application invokes the Invoke function of the IDispatch interface passing an indication of the button object and an indication of a get label method of the button object. (The invocation of the Invoke function of the IDispatch interface is converted by the .NET Framework into an invocation of the InvokeMember function of the IReflect interface of the .NET Framework.) The InvokeMember function invokes the getLabel method of the button object to get the new label and returns the new label to the Office application. The Office application then updates the label of the displayed button. The Office application also calls all other callback methods defined for the button, such as getlmage, getDescription, getEnabled, and other callback methods.
At runtime, the .NET Ribbon model provides event notifications relating to the extended Ribbon user interface to the add-in. Each constituent object of a component class implemented by the .NET Ribbon model registers a virtual callback method with the Office application when it is initialized. For example, a button object Button1 might register callback methods including Button1_OnGetLabel and Button1_OnAction. When the Office application detects a user interaction with one of the components of the extended Ribbon user interface, it invokes the appropriate virtual callback method via the Invoke function of the IDispatch interface. For example, if a user has clicked on Button1, the Invoke function passes an indication of the registered callback method, Button1_OnAction. The invocation of the Invoke function is converted by the .NET Framework into an invocation of the InvokeMember function of the IReflect interface. The InvokeMember method examines the callback method name and determines from the name that it should invoke the OnAction method of the object Button1. In this manner, virtual callbacks are registered to allow a Ribbon component to map the callback name invoked by Office to the actual method implementing the functionality. When the actual method is implemented on a Ribbon component, an event notification is raised for that component.
Table 3 illustrates code generated by a developer that uses .NET Ribbon model to extend the Ribbon.
Lines 3-5 define the data members of the class Ribbon1 to include the tab, group, and button of Table 1. Lines 11-48 illustrate the defining of the extended Ribbon user interface within an InitializeComponent method. Lines 13-15 instantiate objects for the tab, group, and button. Lines 22-24 set the label and name attributes for the tab and add the group to the tab. Lines 28-30 set the label and name attributes for the group and add the button to the group. Lines 34-36 set the label and name attributes for the button and define that the “button1_OnAction” event handler should be invoked to handle events related to the button. Lines 40-41 set the name of the Ribbon extension and add the tab to the Ribbon. Lines 49-52 illustrate the event handler for the button.
Table 4 illustrates code for a button object under the .NET Ribbon model.
Lines 8-15 illustrate the set method that sets of the value for the button. Line 13 illustrates that an Invalidate function is invoked to notify the Office application that the label of the button has changed. When the button generates its XML description it specifies “<button getLabel=“buttonID_OnGetLabel”/>,” where buttonID is the identifier for the button object. When the Office application is notified that the label of the button has changed, it invokes the buttonID_OnGetLabel method via the IDispatch interface to get the new label.
An Office application or document expects an add-in to return an XML document that describes the custom Ribbon user interface. Each Ribbon object generates an XML description of its object and an XML description of all of its child objects. For example, a group provides the XML description of the group and the XML description of all of the objects that compose the group. A root Ribbon object may therefore generate an XML document that describes the entire custom Ribbon user interface. At runtime, the .NET Ribbon model automatically generates an XML document that represents the custom Ribbon user interface. The add-in calls the GetCustomUI function defined by the IRibbonExtensibility interface, which retrieves the XML for the custom Ribbon user interface.
Table 5 illustrates how the .NET Ribbon model automatically generates the XML description of the extended Ribbon user interface.
Lines 5-14 illustrate the processing of the GetCustomUI function of the IRibbonExtensibility interface. The function dynamically generates the XML description of the Ribbon object. Line 10 illustrates an instantiation of an object to represent the XML document. Line 11 illustrates the invocation of the WriteXml method that adds an XML description of the extended Ribbon. Line 13 illustrates the returning of the XML description to the Office application. Lines 20-36 illustrate the processing of the WriteXml method. Line 23 adds the “ribbon” tag to the XML description. Line 27 adds the “tabs” tag to the XML description. Lines 29-33 illustrate the invocation of the WriteXml method of each tab component. Line 34 adds the closing “tabs” tag to the XML description.
An extended Ribbon user interface may include multiple objects of the same type. For example, a custom Ribbon may contain several buttons. Accordingly, in the .NET Ribbon model each callback method may be implemented by a collection of Ribbon objects. The Ribbon implementation differentiates the callback names in order to dispatch the call from Office to the proper object. The .NET Ribbon model customizes the IDispatch interface to call back to the appropriate methods of the components. An object identification method is used to differentiate Ribbon objects and their corresponding callback methods. When the object is created, the .NET Ribbon model generates a unique identifier for each object representing a component of the extended Ribbon. The .NET Ribbon model adds the unique identifier to the callback name provided by each object in the XML description of the object. For example, the callback method names of a Ribbon object Button1 may include Button l_OnGetLabel and Button1_OnAction. Thus, when the Office application calls back via the IDispatch interface, it passes the callback name with the object identifier. The object identifiers are stored in a dictionary that matches each object identifier to its callback methods. The .NET Ribbon model consults the dictionary to determine to which object the callback should be directed.
Users may interact with a custom Ribbon user interface via an Office application or document.
Designer—Component View Architecture
A visual designer tool provides .NET developers a component view architecture that allows developers to develop an extended Ribbon user interface based on the .NET Ribbon model. The visual designer tool enables developers to add visual representations of Ribbon components to a design surface to define a Ribbon layout. The developer can set the properties of the components and define event handlers for the components. When the developer completes the design, the visual designer tool generates the implementation of the code based on the design. For example, the visual designer tool may generate code like that of Table 3.
The visual designer tool leverages existing Microsoft .NET, WinForms (the System.Windows.Forms class library and namespace that is part of the .NET Framework), and Visual Studio technologies and infrastructures to provide the developer with an interface for customizing the Office Ribbon user interface. However, these existing technologies and infrastructures are designed to provide a programming interface for control-derived components, and Ribbon objects are not controls. To overcome this design difference, the visual designer tool uses a component view architecture. At design time, a control-derived view object is defined for each Ribbon object. A view object is a custom WinForms control that appears to the developer to be a Ribbon object. Each view object uses a custom TypeDescriptionProvider class to expose only the properties and events of the Ribbon component it represents, hiding any properties or events not associated with the Ribbon component it represents. When the design is complete, the visual designer tool generates the code to implement the extended Ribbon user interface from the view objects.
The visual designer tool enables developers to add controls, or view objects, representing the Ribbon components from a toolbox or another design surface to a design surface to define the Ribbon layout. Controls may be added by dragging and dropping, copying and pasting, click-draw, double-clicking, and other ways.
Returning to
Using the visual designer tool to extend the Ribbon user interface, the developer need only add controls to the design surface, arrange the controls as desired, and set the properties of the controls. The visual designer tool generates the code for the developers Ribbon extension according to the .NET Ribbon model, as in Table 3 above.
Designer—Complex Control Architecture
Some of the controls displayed in the toolbox and available for use by the developer may be complex controls. These controls represent complex Ribbon components. A complex Ribbon component is a component that may contain other Ribbon components as items. An example of a complex component is a menu, which may contain other components, such as buttons and sub-menus. The visual designer tool provides the developer with a complex control architecture that provides a nested design surface for the complex control into which the developer may drag and drop controls just as in the primary design surface. For example, the developer may add a menu to the design surface. The visual designer tool will provide the designer with a design surface that is exclusive to the menu; this design surface is provided within the primary design surface. The developer may then add buttons, sub-menus, and other controls into the menu's design surface.
Each complex control implements a ToolStripDropDown class which contains a ToolStripControlHost class. The ToolStripDropDown class represents a control that allows a user to select a single item from a list that is displayed. The ToolStripDropDown class replaces and adds functionality to the Menu class of previous versions of the .NET Framework. The ToolStripControlHost class, which hosts customized controls, comprises a container component that contains the complex control's items. At design time, a drop down icon may be added to the complex control that allows the developer to open and hide the container, or nested design surface. Once a complex control has been added to the design surface and the container has been opened, the visual designer tool provides the developer with a nested design surface that is specific to the complex control. The developer may add controls to this nested design surface just as in the primary design surface.
The computing devices on which the .NET Ribbon model and the visual designer tool may be implemented may include a central processing unit, memory, input devices (e.g., keyboard and pointing devices), output devices (e.g., display devices), and storage devices (e.g., disk drives). The memory and storage devices are computer-readable media that may contain instructions that implement the .NET Ribbon model and the visual designer tool. In addition, the data structures and message structures may be stored or transmitted via a data transmission medium, such as a signal on a communications link. Various communications links may be used, such as the Internet, a local area network, a wide area network, or a point-to-point dial-up connection.
The .NET Ribbon model and the visual designer tool may be implemented on various computing systems or devices including personal computers, server computers, hand-held or laptop devices, multiprocessor systems, microprocessor-based systems, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.
The .NET Ribbon model and the visual designer tool may be described in the general context of computer-executable instructions, such as program modules, executed by one or more computers or other devices. Generally, program modules include routines, programs, objects, components, data structures, and so on that perform particular tasks or implement particular abstract data types. Typically, the functionality of the program modules may be combined or distributed as desired in various embodiments.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. Accordingly, the invention is not limited except as by the appended claims.
This application is a divisional application of U.S. patent application Ser. No. 11/692,825, filed on Mar. 28, 2007, and entitled “.NET RIBBON MODEL FOR A RIBBON USER INTERFACE,” which is incorporated herein in its entirety by reference.
Number | Name | Date | Kind |
---|---|---|---|
5872973 | Mitchell et al. | Feb 1999 | A |
6038395 | Chow et al. | Mar 2000 | A |
6237135 | Timbol | May 2001 | B1 |
6385769 | Lewallen | May 2002 | B1 |
6434598 | Gish | Aug 2002 | B1 |
6484180 | Lyons et al. | Nov 2002 | B1 |
6701513 | Bailey | Mar 2004 | B1 |
6990652 | Parthasarathy et al. | Jan 2006 | B1 |
7069538 | Renshaw | Jun 2006 | B1 |
7340721 | Bailey | Mar 2008 | B1 |
20040030993 | Hong Huey et al. | Feb 2004 | A1 |
20050055449 | Rappold | Mar 2005 | A1 |
20050251757 | Farn | Nov 2005 | A1 |
20060117302 | Mercer et al. | Jun 2006 | A1 |
20060282817 | Darst et al. | Dec 2006 | A1 |
20060294526 | Hambrick et al. | Dec 2006 | A1 |
20080109785 | Bailey | May 2008 | A1 |
20080134138 | Chamieh et al. | Jun 2008 | A1 |
20080155555 | Kwong | Jun 2008 | A1 |
Number | Date | Country | |
---|---|---|---|
20110154286 A1 | Jun 2011 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 11692825 | Mar 2007 | US |
Child | 12984513 | US |