Saltar al contenido principal
Versión: Siguiente

WP New style sheet

WP New style sheet ( wpDoc : Object ; styleSheetType : Integer ; styleSheetName : Text {; listLevelCount : Integer} ) : Object

ParámetrosTipoDescripción
wpDocObjectDocumento 4D Write Pro
styleSheetTypeIntegerTipo de hoja de estilo
styleSheetNameTextNombre de la hoja de estilo
listLevelCountIntegerNúmero total de niveles jerárquicos
ResultadoObjectObjeto hoja de estilo
Historia
LanzamientoModificaciones
4D 18Created
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.

In the wpDoc parameter, pass a 4D Write Pro document.

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: Applies style attributes to characters.
  • 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. The style sheet name must comply with the following rules:

  • 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.
  • Any style attributes not defined in the new style sheet will automatically use the Normal style. For more information, see the Style sheets page.

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.

The listLevelCount parameter defines the total number of levels in the hierarchy. 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 type se establece en wk decimal
  • wk list level index is automatically assigned (1 for the root level, incremented for sub-levels)
  • wk list level count se fija en el valor especificado para todos los niveles
  • El margen izquierdo se calcula automáticamente (0,75 cm × índice de nivel)

If the parameter is omitted or set to 0, a standard (non-list) paragraph style sheet is created.

Ejemplo 1

The following code creates and defines a paragraph style sheet:

 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 = 1
    • wk list level count = 3
    • wk list style type = wk decimal
  • Las hojas de estilo de los subniveles:

    • have incremented wk list level index values (2 and 3)
    • comparte la misma wk list level count
    • se indentarán automáticamente (0,75 cm × índice de nivel)
    • reference the root style sheet through wk root style

Ver también

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