WP New style sheet
WP New style sheet ( wpDoc : Object ; styleSheetType : Integer ; styleSheetName : Text {; listLevelCount : Integer} ) : Object
| Parámetros | Tipo | Descripción | |
|---|---|---|---|
| wpDoc | Object | → | Documento 4D Write Pro |
| styleSheetType | Integer | → | Tipo de hoja de estilo |
| styleSheetName | Text | → | Nombre de la hoja de estilo |
| listLevelCount | Integer | → | Número total de niveles jerárquicos |
| Resultado | Object | ← | Objeto hoja de estilo |
Historia
| Lanzamiento | Modificaciones |
|---|---|
| 4D 18 | Created |
| 4D 21 R3 | *Se ha añadido el parámetro listLevelCount |
Descripción
El comando WP New style sheet crea un nuevo objeto (vacío) de hoja de estilo para el wpDoc designado.
En el parámetro wpDoc, pasa un documento 4D Write Pro.
The styleSheetType parameter lets you designate the type of the style sheet, i.e. the part of the wpDoc that will be affected by the style sheet. Hay dos tipos disponibles:
- wk type character: aplica atributos de estilo a los caracteres.
- wk type paragraph: Applies style attributes to paragraphs (required if you want to create hierarchical list style sheets).
Pase un nombre para la hoja de estilo en el parámetro styleSheetName. The style sheet's name is stored with the document and facilitates reusing or modifying the style. It can also be used with the WP Get style sheet and WP DELETE STYLE SHEET commands. El nombre de la hoja de estilo debe cumplir las siguientes reglas:
- debe empezar por una letra
- puede contener caracteres alfanuméricos, espacios en blanco, caracteres "-" o caracteres unicode >= 128
- debe ser único en el documento independientemente del tipo
- no debe empezar por "section", que está reservado
- el "_" se sustituye por un espacio y se eliminan los espacios finales.
You can specify the attributes of the style sheet using the WP SET ATTRIBUTES command or the object notation (see 4D Write Pro Attributes). For the list of available attributes, see the Style sheet attributes section.
Notas:
- Una hoja de estilo sólo modifica la visualización de un carácter o párrafo, no cómo se almacena en el documento. Si se elimina una hoja de estilo, el texto volverá al estilo por defecto.
- Todo atributo de estilo no definido en la nueva hoja de estilo utilizará automáticamente el estilo Normal. Para más información, consulte la página Hojas de estilo.
Hierarchical list style sheet
If the styleSheetType parameter is set to wk type paragraph, you can optionally pass the listLevelCount parameter to create a hierarchical list style sheet.
El parámetro listLevelCount define el número total de niveles de la jerarquía. When specified (value ≥ 1), the command automatically creates a root-level style sheet and the corresponding sub-level style sheets.
Se aplican los siguientes valores predefinidos:
wk list style typese establece enwk decimalwk list level indexis automatically assigned (1 for the root level, incremented for sub-levels)wk list level countse fija en el valor especificado para todos los niveleswk margin leftis automatically calculated (0.75 cm × level index or 0.25 inches * level index, depending on current layout unit): so offset may be different depending if layout unit is metric or inches (for better alignment on default with current Write ruler graduations)
Si el parámetro se omite o se establece en 0, se crea una hoja de estilo de párrafo estándar (no de lista).
Ejemplo 1
El siguiente código crea y define una hoja de estilo de párrafo:
var $styleSheet : Object
$styleSheet:=WP New style sheet(wpArea;wk type paragraph;"Main title")
//definir la configuración de la hoja de estilo
WP SET ATTRIBUTES($styleSheet;wk font family;"Papyrus")
WP SET ATTRIBUTES($styleSheet;wk font size;"48pt")
WP SET ATTRIBUTES($styleSheet;wk text color;"red")
WP SET ATTRIBUTES($styleSheet;wk text align;wk left)
//Aplicar la hoja de estilo al primer párrafo
var $Paragraphs : Collection
$Paragraphs:=WP Get elements(wpArea;wk type paragraph)
If($Paragraphs.length>0)
WP SET ATTRIBUTES($Paragraphs[0];wk style sheet;$styleSheet)
End if
Ejemplo 2
El siguiente código crea una hoja de estilo de lista jerárquica con 3 niveles:
var $mainList : Object
$mainList:=WP New style sheet(wpArea; wk type paragraph; "MainList"; 3)
// The command automatically creates:
// - 1 root-level style sheet ("MainList")
// - 2 sub-level style sheets ("MainList lvl 2" and "MainList lvl 3")
Resultado:
-
The root style sheet has:
wk list level index= 1wk list level count= 3wk list style type=wk decimal
-
Las hojas de estilo de los subniveles:
- han incrementado los valores de
wk list level index(2 y 3) - comparte la misma
wk list level count - se indentarán automáticamente (0,75 cm × índice de nivel)
- hacer referencia a la hoja de estilo raíz mediante
wk root style
- han incrementado los valores de
Ver también
Style sheets
WP DELETE STYLE SHEET
WP Get style sheet
WP Get style sheets
WP IMPORT STYLE SHEETS