ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Controls, pages and windows / Word Processing functions / Types of variables
  • Properties specific to docFragment variables
  • WLanguage functions that use docFragment variables
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
The docFragment type is used to define the characteristics of a fragment found in a "docx" document. You can define and change the characteristics of this fragment using different WLanguage properties.
A fragment is defined by its start and end positions. Therefore, it can:
  • extend on several paragraphs,
  • start in the middle of any ordinary word,
  • end in the middle of any ordinary word.
Note: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
// Changement de la couleur de la sélection
// Récupération de la sélection actuelle
MaSélection is docFragment(TT_MonDocument, TT_MonDocument.Curseur, ...
		TT_MonDocument.LongueurSélection)
// Changement de la couleur
MaSélection.MiseEnForme.CouleurTexte = PastelRed
// Chargement du document
MonDoc is Document = "c:\temp\doc.docx"

// Ajoute du texte à la fin du document
FragmentFin is docFragment(MonDoc, -1 , 0)
FragmentFin.Text += "Fin de document"
Syntax

Declaring a document fragment that is not described Hide the details

MyVariable is docFragment
In this case, the document fragment is not described. The variable will have to be assigned with an existing fragment or with the result of one of the functions for handling documents (DocFind for example).

Declaring and describing a fragment Hide the details

MyVariable is docFragment([<Document> [, <Start of fragment> [, <Length>]]])
<Document>: Optional Document variable or character string
Document from which a fragment will be extracted. This document corresponds to:
  • WINDEV the name of a Word Processing control.
  • a variable of type Document.
<Start of fragment>: Optional integer
Start position of the document fragment to use. This position is given in number of characters:
  • from the start of document (positive number).
  • from the end of document (negative number).
<Length>: Optional integer
Length of fragment to use, expressed in number of characters.
Note: a negative number is used to take a number of characters from the end: '-1' = to the end, '-2' = to 1 character before the end, etc.
Properties

Properties specific to docFragment variables

The following properties can be used to handle docFragment variables:
Property nameType usedEffect
ElementArray of docElementElements making up the document fragment used. The fragment elements can be browsed via the FOR EACH statement.
RangeIntegerNumber of characters in the fragment. Corresponds to the end position minus the start position.
The extent can correspond to a positive, negative or zero value.
Remarks:
  • If the fragment contains a table or a section of a table, all characters in it are counted..
  • If the fragment contains an image or a text area, each one corresponds to 1 character.
SubDocumentIdentifierIntegerIdentifier corresponding to the subdocument associated with the fragment. This property is intended for an advanced use.
LanguageSpellingCharacter stringLanguage of fragment. The notation used corresponds to the 639-1 standard. For example "FR-fr".
In read mode, this property returns a valid information only if the fragment corresponds to a single language.
Remark: To perform the spelling correction corresponding to the language of the fragment, it is necessary to load the dictionary for this language with function DictionaryLoad.
FormattingdocFormatting variableFormatting information for all the elements making up the document fragment used.
PageLayoutLayout of current fragment.
PageLayout.BackgroundColorIntegerBackground color of fragment. This color can correspond to:
PageLayout.BackgroundPatternBackground variableCharacteristics of fragment background.
WordArray of docFragmentWords making up the document fragment used. The fragment words can be browsed via the FOR EACH statement.
ParagraphArray of docParagraphParagraphs affected by the fragment (if a fragment includes several paragraphs). The paragraphs can be browsed via the FOR EACH statement.
StartPositionIntegerStart position of fragment. This position is relative to the entire document.
EndPositionIntegerEnd position of fragment. This position is relative to the entire document.
StyleIDCharacter stringIdentifier of style applied to the fragment. This identifier must exist among the styles linked to the document.
Note: changing the style of a paragraph or fragment automatically applies the linked paragraph style and character style if they exist.
TextCharacter stringRough text corresponding to the content of fragment used.
TypeSubDocumentInteger constantSection of document to which the fragment belongs. The possible values are:
  • typeSousDocCanvas: Image container.
  • typeSousDocCorps: Document body.
  • typeSousDocEnTêtePageImpaire: Odd page header.
  • typeSousDocEnTêtePagePaire: Even page header.
  • typeSousDocEnTêtePremièrePage: Header for the first page.
  • typeOddFooter: Odd footer.
  • typeSousDocPiedPageFooter: Even page footer.
  • typeFirstPageFooter: First page footer.
  • typeSousDocZoneDeTexte: Text area.
This property is read-only.
Remarks

WLanguage functions that use docFragment variables

docFragment variables are handled by several WLanguage functions:
  • WLanguage functions that use standard syntax:
    DocAddAdds:
    • at the end of a word processing document: an element, document, paragraph, text, image or fragment.
    • at the end of a fragment: an element, text or image.
    DocFindFinds a character string:
    • in an entire Word Processing document.
    • in a fragment.
    DocInsertInserts an object into a Word Processing document or replaces the content of the current fragment. The objects that can be used are:
    • an element,
    • a document,
    • a paragraph,
    • a text,
    • an image,
    • a fragment.
    DocInsertTableInserts a table into a Word Processing document.
    DocSelectSelects a fragment in a Word Processing control.
  • WLanguage functions that use prefix syntax:
    <docFragment variable>.AddAdds an element, text or image at the end of a docFragment variable.
    <docFragment variable>.InsertReplaces the content of the current fragment. The objects that can be used are:
    • an element,
    • a document,
    • a paragraph,
    • a text,
    • an image,
    • a fragment.
    <docFragment variable>.InsertTableReplaces the specified fragment with a table.
Minimum version required
  • Version 22
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/20/2024

Send a report | Local help