You are on page 1of 1

CHAPTER 1: Layout Layers 22

Acquiring a reference to a document layer

Solution

A document layer (kDocumentLayerBoss) is characterized by the IDocumentLayer interface. A UIDRef that


can instantiate an IDocumentLayer interface is a document layer.

If you have a document (see “Acquiring a reference to a document”) and want to examine all the
document layers, use ILayerList.

If you have a document and want to find the document layer targeted for edit operations, use
ILayerUtils::QueryDocumentActiveLayer.

If you have a spread layer and want to find its associated document layer, use
ISpreadLayer::QueryDocLayer.

If you have a reference to a page item and want to find its associated document layer, Call
ILayerUtils::GetLayerUID to get the spread layer that owns the page item, then call
ISpreadLayer::QueryDocLayer.

If you have a layout view and want to find the document layer targeted for edit, use
ILayoutControlData::QueryActiveDocLayer or ILayoutControlData::GetActiveDocLayerUID give the active
document layer.

If you have an IActiveContext interface, use ILayerUIUtils::QueryContextActiveLayer.

Sample code

 SDKLayoutHelper

 SnpInspectLayoutModel

Related API

kDocumentLayer

Acquiring a reference to a spread layer

Solution

A spread layer (kSpreadLayerBoss) is characterized by the ISpreadLayer interface. A UIDRef that can
instantiate an ISpreadLayer interface is a spread layer.

If you have a spread (see “Acquiring a reference to a spread”) and a document layer (see “Acquiring a
reference to a document layer”), use ISpread::QueryLayer to get the content or guide spread layer
(kSpreadLayerBoss) associated with the document layer.

If you have a page item and want to know the spread layer that owns it, use IHierarchy::GetLayerUID.

NOTE: Some hierarchies, like those for an inline frame (kInlineBoss), return kInvalidUID. If you are working
with inline frames, use IPageItemUtils::QueryInlineParentPageItem to find the page item in the layout
hierarchy first, then find the spread layer.

If you have a layout view and want to find the spread layer targeted for edit operations, use
ILayoutControlData::QueryActiveLayer or ILayoutControlData::GetActiveLayerUID to get the active spread

You might also like