Chapter 9. Adding New SmartArt Graphics Layouts

Microsoft Office 2007 ships with 84 built-in SmartArt graphics layouts. It is possible to create new template files to add new styles to your SmartArt graphics gallery.

I must caution you that this is not an easy process. You should be comfortable with finding files using Windows Explorer, as well as zipping (compressing) and unzipping files. You will also be editing some fairly complex markup language to achieve the new style.

Despite the caution, the process of taking an existing layout and changing it slightly is fairly straightforward. This chapter walks through two case studies:

  • Changing the shapes used in a layout. This example takes an existing layout and changes the shapes from rounded rectangles to another shape.
  • Removing picture placeholders from the Bending Picture Accent List. During the Office beta, someone at the beta newsgroups noted that the Bending Picture Accent List is a fantastic layout, if Microsoft would just get rid of the image placeholders. This chapter shows you how to create a new style named Bending Accent List without the picture placeholders.

Both of these changes are relatively simple. They involve taking a current definition and changing a few words in the specification. They are designed to be enough to get your feet wet, to introduce you to the topic of SmartArt extensibility.

If you are the graphics design guru for a corporation, you might want to completely design your own new layouts. The concepts of building a layout from scratch are complex; you have to deal with scalability and aspect ratios. This topic alone is worthy of a book.

Customizing Your First SmartArt Graphics Layout

Now it’s time to customize an existing layout by changing the primary shape used in the graphic. The images in this example walk you through changing the Basic Process layout to have hexagon shapes instead of rounded rectangles.

If you want to follow along, try using a slightly different example. Select a different layout as a starting point and attempt to change to another shape.

Step 1: Finding a Similar Built-In Layout

The first step is to find a built-in layout that is already close to matching your desired layout:

  1. Open a blank Excel, Word, or PowerPoint document. From the ribbon, choose Insert, SmartArt.
  2. Browse through the gallery to find a layout that you would like to copy.

As you click on the icons in the gallery, the right side of the Choose a SmartArt Graphic dialog box shows a thumbnail of the layout. It also shows a name in bold and a description. Make a note of these values, because you will be changing them in step 4 of this process.

Step 2: Creating an Office Document with the Built-In Layout

Note

If you’ve obtained the Office 2007 Software Development Kit, the XML files for all 84 SmartArt graphics layouts are in the kit. You can skip steps 2and 3 if you already have the XML file.


After you identify a layout in step 1, click OK to insert that layout into the document. You don’t need to edit the layout in any way. Leave it in the default state with [Text] placeholders, as shown in Figure 9.1.

Image

Figure 9.1 Insert a blank graphic using the similar built-in layout.

Save the file as an Office 2007 document. For Excel, this means using either the .xlsx or .xlsm extension. Do not use the .xlsb binary format, because it does not allow you to edit the document.

Note the path and filename of the document, because you will need this information in step 3, and close the file.

Step 3: Unzipping the Office Document

Although Office 2007 documents have file extensions such as .xlsx, .docx, and .pptx, they are actually stored as zip files. If you rename the document with a .zip extension, you can use any compression utility such as WinZip to access the contents of the file. Follow these steps to rename and open the document as a zip file:

  1. Open Windows Explorer. If your keyboard has a “flying window” key or a Start key, you can press that key in combination with the E key to open Windows Explorer. Otherwise, choose Start, My Computer.
  2. Browse to the folder where you stored the document from step 2.
  3. If you do not see the file extension at the end of the name, enable the display of file extensions. In Windows XP, choose Tools, Folder Options. In Windows Vista, choose Organize, Folder Options. In the Folder Options dialog box, select the View tab and uncheck the box labeled Hide Extensions for Known File Types.
  4. Right-click on your filename and choose Rename, as shown in Figure 9.2.

    Image

    Figure 9.2 Find the file in Windows Explorer and choose Rename.

  5. The filename is now editable. Change the .xlsm extension to .zip and press Enter.
  6. Windows warns you that the file might become unusable (see Figure 9.3). Click OK.

    Image

    Figure 9.3 Windows warns you that changing file extensions is dangerous. Click OK.

  7. Extract layout1.xml from the zip file. The steps for this procedure are different if you are using WinZip or the native Windows Vista zip functionality.

Extracting Using Windows

If you are using Windows’ built-in compressed folder utility, you might initially see that the zip file contains folders such as _rels, docProps, and xl, as shown in Figure 9.4.

Image

Figure 9.4 Windows Vista shows only the top level of the zip file here.

If this is the view that you see, follow these steps:

  1. Double-click the xl folder.
  2. Double-click the diagrams folder.
  3. Right-click layout1.xml and choose Copy.
  4. Click the Back button three times to return to your original folder.
  5. Press Ctrl+V to paste layout1.xml to your folder.

Extracting Using WinZip

If you are using WinZip or a similar utility, the window probably shows you the complete file structure. Folders are listed on the right side, as shown in Figure 9.5.

Image

Figure 9.5 WinZip shows you the complete file contents.

To extract the file, follow these steps:

  1. Right-click the layout1.xml entry and choose Extract (refer to Figure 9.5).
  2. In the Extract dialog box, browse to the folder where the original document is stored. Click the Extract button.
  3. Close WinZip.

Step 4: Editing the Definition in Notepad

When creating a new layout, you should provide a name and description for the layout. This information will be visible in the gallery of SmartArt graphics. You also have to choose a unique ID for the layout style. The UniqueID should contain no spaces and not match any other SmartArt graphic layout IDs.

For my example, these values work:

  • Title—Hexagon Process.
  • Description—A process chart using hexagons. Suitable for Level 1 and Level 2 text. Created by MrExcel.
  • UniqueID—HexProcess.

However, before doing that, you need to open the XML file for editing. You should now have layout1.xml available in Windows Explorer. Right-click the file and choose Open With, Notepad, as shown in Figure 9.6.

Image

Figure 9.6 Choose to open the file with Notepad.

Note

If you are a developer and already have an XML editor, by all means, use it instead of Notepad.


In Notepad, choose Format, Word Wrap so that the XML file is visible in the width of the Notepad window.

Do not be alarmed at the apparent jumble of XML codes in the file, as shown in Figure 9.7. You will be surgically editing four items in the file. Editing is not as overwhelming as it seems.

Image

Figure 9.7 Despite the appearances, editing this file is not overwhelming.

Finding and Changing the UniqueID

Choose Edit, Find to search for the UniqueID tag. The current value for the UniqueID tag should be something like

uniqueId="urn:microsoft.com/office/officeart/2005/8/layout/process1"

Change this line to use your chosen UniqueID. It is important that each UniqueID be unique. Don’t save several templates with different filenames and identical UniqueIDs and expect it to work.

Finding and Adding a Title

Choose Edit, Find to search for title. Depending on the author of the original layout, this tag might be filled in or blank. For example, the following tag has a blank value:

<dgm:title lang="" val=""/>

Edit the tag to include your title, such as this:

<dgm:title lang="" val="Hexagon Process"/>

Finding and Adding a Description

Choose Edit, Find to search for dgm:desc. This tag is currently blank. The tag looks like this:

<dgm:desc lang="" val=""/>

Edit the tag to include your description, such as this:

<dgm:desc lang="" val=" A process chart using hexagons.
Suitable for Level 1 and Level 2 text. Created by MrExcel."/>

Editing the Category and Priority

The SmartArt graphics gallery contains seven categories. An eighth category called “Other” is available for your use. You can place your new layout in one or more categories. On the same line of code, each layout is also assigned a priority, from 1 to 32000. Your current layout1.xml file might have a tag like this:

<dgm:cat type="process" pri="1000"/>

If you want your custom layout to appear just after the original layout, edit that tag to change the priority to 1001. If you want your custom layout to appear first, use pri=1. If you want your layout to appear in two different categories, edit the file to have two tags, like this:

<dgm:cat type="process" pri="1"/><dgm:cat type="list" pri="1"/>

Remember, the valid values for categories are list, process, cycle, hierarchy, relationship, matrix, pyramid, and other.

Note

You may find a dgm:cat tag where the type is convert. Leave this tag alone. Editing this tag will not have any impact on your layout.


Changing the Shape

In the current example, my file uses a rounded rectangle as the current shape. There could be many shapes in your current layout. Choose Edit, Find to locate all occurrences of <dgm:shape type.

This example has three such tags. One occurs after <LayoutNode Name="node". This is the definition for the main shape. Other occurrences might appear after node="SibTrans" for the connector shapes.

In this case, the type="RoundRect" should be enough of a clue that this is the tag you are trying to edit.

To change to a hexagon, change

<dgm:shape type="roundRect"

to

<dgm:shape type="hexagon"

Note

A complete list of shapes is shown in Table 9.1.


Choose File, Save to save layout1.xml.

Step 5: Wrapping Layout1.xml in a .Glox File

To use the SmartArt graphics custom definition, you have to wrap the Layout1.xmls file in a glox file. Microsoft provides one sample .glox file, but at press time, they had not decided where Sample.glox would be available. If you visit http://www.MrExcel.com/SmartArtFiles.html, I specify where you can find this file.

The Sample.glox file is really a zipped archive. Follow these steps to unzip it:

  1. In Windows Explorer, right-click Sample.glox. Choose Open With…and select Winzip.
  2. In WinZip, you see a layout1.xml file in the archive. Click on this file and press the Delete key to remove the existing layout1.xml.
  3. Drag your new layout1.xml file into the Winzip window.
  4. Close Winzip.
  5. In Windows Explorer, right-click Sample.zip and choose Rename. Give the file a meaningful name, such as HexProcess.glox.

Step 6: Copying the File to the Templates Folder

Figuring out the location of your templates folder is frustrating. It is in a different location if you are using Windows XP than it is if you use Windows Vista. If you can remember an arcane code, you can force Windows Explorer to navigate to this folder. Follow these steps:

  1. Open Windows Explorer.
  2. In the address bar, type %appdata%MicrosoftTemplates
  3. If you are using a production version of Office 2007, you see a folder named SmartArt graphics. If this folder is not present, create a folder with this name.
  4. Navigate to the SmartArt graphics folder.
  5. Drag your custom .glox file to this folder.

Step 7: Restarting Office and Using the Layout

Any changes you make to .glox files in the SmartArt graphics folder will not be recognized by Office 2007 until you restart the application as follows:

  1. Close all open instances of Microsoft Office.
  2. Reopen the Office application of your choosing.
  3. From the Insert tab, choose SmartArt.
  4. Select the appropriate category.
  5. As shown in Figure 9.8, the new style appears in the gallery.

    Image

    Figure 9.8 Success! The new style is available in the gallery.

  6. Choose the layout and create a SmartArt graphic as usual.

Figure 9.9 shows a SmartArt diagram created with the new style.

Image

Figure 9.9 A diagram created with the new layout.

Additional Easy Changes to the .Glo Specification

The following sections introduce additional tags in the .glo file. However, this is by no means an exhaustive list.

Changing the Height of the Shape

In the previous example, you found the dgm:shape type tag to change the shape from rounded rectangles to hexagons. This time, open the .XML file for editing and locate the dgm:shape type tag:

<dgm:shape type="roundRect"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
relationships" r:blip="">

Shortly after this tag is a dgm:constr tag. This tag says that the height of the shape will be 60% of the width of the shape:

<dgm:constr type="h" forName="" refType="w" refForName=""
fact="0.6"/>

Say that you want the shape to be more square instead of oblong. If you want to make the height of the shape to be 100% as wide as the shape, convert the tag to

<dgm:constr type="h" forName="" refType="w" refForName=""
fact="1.0"/>

If you want to make the initial shape be a certain number of millimeters tall, remove the refType="w" value from the tag. Enter the number of millimeters as the fact. In the following example, the hexagons always start as 50 millimeters tall:

<dgm:constr type="h" forName="" refForName="" fact="50"/>

Changing the Rotation of the Shape

In the .glo file, three shapes are defined with <dgm:shape type. The first shape is the main node shape. The next shape is a type Conn and appears after the LayoutNode name="SibTrans" tag. This refers to the arrows between the shapes. The final shape is also a type Conn and appears after the LayoutNode name="connectorText" tag. If you follow the complete text of this tag, you see the parameter hideGeom="1". This parameter means that the shape is hidden.

The current diagram has three shapes, although one is hidden. To rotate the shapes, add a rot parameter to the dgm:shape type tag. This parameter can go after the blip="" parameter.

The following code rotates the hexagons by 60 degrees:

<dgm:shape type="roundRect"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
relationships" r:blip="" rot="60">

The following code rotates the connector arrows by 180 degrees:

<dgm:shape type="conn"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
relationships" r:blip="" rot="180">

After you make these changes to layout1.xml, wrap it in the Sample.glox file and save it to the templates folder. Then exit and restart the application. Figure 9.10 shows the result of rotating the shapes.

Image

Figure 9.10 This diagram has the arrows rotated 180 degrees and the hexagons rotated 60 degrees.

Removing the Image Placeholders from a Layout

Early in the beta process for Microsoft Office 2007, several beta testers and I were discussing SmartArt graphics in the beta newsgroups. One of the conversations noted that the Bending Picture Accent List layout is a great layout, but the picture placeholders are annoying (see Figure 9.11).

Image

Figure 9.11 This layout would be great if there were a version without the picture icons.

The intuitive way to remove the placeholder circles does not work. Go ahead and try it. Click on a circle (outside the picture icon) to select it and press the Delete key. Nothing happens.

The posts in the newsgroup expressed frustration that there is not an easy way to delete the images from the built-in style. The desire to produce a Bending Picture Accent List without pictures actually drove a number of people to figure out the extensibility documentation.

The following instructions assume that you followed the first example in the chapter. Only step 4 has the necessary details:

  1. The Bending Picture Accent list is the closest style to the one you want to create.
  2. Create a new Office document with a Bending Picture Accent diagram and save the file. Close the application.
  3. Rename the file from .xlsm to .zip. Extract layout1.xml from the zip file.
  4. Edit layout1.xml in Notepad. The image placeholders are called a blip. Choose Edit, Find to search for blipph. Expand the selection in both directions to encompass these lines:

    <dgm:shape type="ellipse"
    xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
    relationships" r:blip="" blipPhldr="1"><dgm:adjLst/></dgm:shape>

    Delete the preceding text and replace it with this text:

    <dgm:shape/>.

    Edit the UniqueID, Name, Description, and Priority as described earlier. Change the priority from 5000 to 5001.

  5. Save layout1.xml. Wrap it in Sample.glox and save the file as BList3.glox in the templatesSmartArt graphics folder.
  6. Restart Excel. Insert a SmartArt graphic. In the List category, right after the Bending Picture Accent List, your new style is shown (see Figure 9.12).

Image

Figure 9.12 The new layout is available in the gallery.

Figure 9.13 shows the completed diagram with the new layout.

Image

Figure 9.13 This diagram is created with the new bending list layout.

The customizations described here are only the tip of the iceberg of what can be accomplished. The complete specification spans 4,000 printed pages.

Using Only Custom Layouts

If you need to limit the layouts available in your organization, it is possible to modify Office’s SmartArt functionality to show only custom layouts. Microsoft provides a Registry key that instructs Office not to offer any of the 84 built-in styles.

The key is located at: HKEY_CURRENT_USERSoftwareMicrosoftOffice12.0CommonSmartArt Graphics.

  • HideBuiltInDiagrams—dword:1
  • HideBuiltInDiagramStyles—dword:1
  • HideBuiltInDiagramColors—dword:1

You can then populate your templates folder with custom layout .glox files.

The Office Software Development Kit (SDK), which is available from MSDN, offers the individual .glox files for the 84 built-in styles. If you want to offer only a subset of the 84 styles, you could follow these steps:

  1. Set the Registry key not to show built-in styles.
  2. Obtain the 84 .glox files from the SDK.
  3. Copy the desired styles from the SDK to the templates folder.
  4. Optionally, add any new custom .glox files to the templates folder.

List of Shapes Available in SmartArt Graphics Definitions

Table 9.1 lists all the shape names available in SmartArt definitions.

Table 9.1 Shape Codes Valid in SmartArt Graphics Layout Files

Image

Image

Next Steps

This is the end of the discussion of SmartArt graphics. The next two chapters cover the other drawing tools available in Office: WordArt and Shapes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset