Skip to main content
Version: Next

WP Get style sheet

WP Get style sheet ( wpDoc : Object ; styleSheetName : Text {; listLevelIndex : Integer } ) : Object

ParameterTypeDescription
wpDocObject4D Write Pro document
styleSheetNameTextStyle sheet name
listLevelIndexIntegerLevel of the style sheet in the hierarchy
Function resultObjectStyle sheet object
History
ReleaseChanges
4D 18Created
4D 21 R3listLevelIndex parameter added

Description

The WP Get style sheet command returns the style sheet object designated by the styleSheetName or by the style sheet name and the listLevelIndex in the case of a hierarchical list style sheet.

In wpDoc, pass the 4D Write Pro document that contains the style sheet.

The styleSheetName parameter allows you to specify the name of the style sheet to return. If the style sheet name does not exist in wpDoc, an null object is returned.

If the style sheet is part of a hierarchical list style sheet, you can optionally specify the listLevelIndex parameter to retrieve a specific level of the hierarchy.

  • listLevelIndex represents the level of the style sheet in the hierarchy (1 = root level, 2 = first sub-level, etc.).
  • If the parameter is omitted and the style sheet is hierarchical, the root-level style sheet is returned.
  • If the requested level does not exist, a null object is returned.
  • If the style sheet is not a hierarchical list style sheet and listLevelIndex is greater than 1, a null object is returned.

Example 1

To retrieve the "Main title" style sheet:

 var $styleSheet : Object

$styleSheet:=WP Get style sheet(wpArea;"Main title")
If($styleSheet=Null) // check if the style sheet exists//if not create it
$styleSheet:=WP New style sheet(wpArea;wk type paragraph;"Main title")
End if

Example 2

To retrieve a specific level of a hierarchical list style sheet:

var $rootStyle : Object
var $subLevelStyle : Object

// Retrieve root-level style sheet
$rootStyle:=WP Get style sheet(wpArea;"MainList")

// Retrieve second level (first sub-level)
$subLevelStyle:=WP Get style sheet(wpArea;"MainList";2)

If($subLevelStyle=Null)
ALERT("Requested level does not exist.")
End if

See also

Style sheets
WP DELETE STYLE SHEET
WP Get style sheets WP IMPORT STYLE SHEETS
WP New style sheet