Sdílet prostřednictvím


SmartTag.ParagraphText-Eigenschaft (2007 System)

Aktualisiert: November 2007

Ruft den Text aus dem Absatz ab, der an die Erkennung gesendet wird.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)

Syntax

'Declaration
Protected ReadOnly Property ParagraphText As String
'Usage
Dim value As String

value = Me.ParagraphText
protected string ParagraphText { get; }

Eigenschaftenwert

Typ: System.String

Der Text aus dem Absatz, der an die Erkennung gesendet wird.

Hinweise

Diese Eigenschaft ist nur zur Verwendung durch die Recognize-Methode vorgesehen.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie die Recognize-Methode innerhalb einer Klasse überschrieben wird, die von Microsoft.Office.Tools.Word.SmartTag abgeleitet ist. Bei dieser Implementierung von Recognize wird jeder Smarttagbegriff mit dem Inhalt des Absatzes verglichen. Im Code wird für jeden Smarttagbegriff im Absatz eine benutzerdefinierte Smarttageigenschaft hinzugefügt, und dann wird die PersistTag(Int32, Int32, ISmartTagProperties)-Methode zum Erkennen des Smarttags verwendet. In diesem Beispiel wird davon ausgegangen, dass Sie im Dialogfeld Verweis hinzufügen auf der Registerkarte COM einen Verweis auf die Microsoft Smart Tags 2.0-Typbibliothek hinzugefügt haben. Dieses Codebeispiel ist Teil eines umfangreicheren Beispiels, das sich auf die SmartTag-Klasse bezieht.

Protected Overrides Sub Recognize(ByVal text As String, _
    ByVal site As ISmartTagRecognizerSite, _
    ByVal tokenList As ISmartTagTokenList)

    ' Determine whether each smart tag term exists in 
    ' the document text.
    Dim Term As String
    For Each Term In Me.Terms

        ' Search the text for the current smart tag term.
        Dim index As Integer = Me.ParagraphText.IndexOf(Term, 0)

        While (index >= 0)

            ' Create a smart tag token and a property bag for the 
            ' recognized term.
            Dim propertyBag As ISmartTagProperties = _
                site.GetNewPropertyBag()

            ' Write a new property value.
            Dim key As String = "Key1"
            propertyBag.Write(key, DateTime.Now)

            ' Attach the smart tag to the term in the document
            Me.PersistTag(index, Term.Length, propertyBag)

            ' Increment the index and then find the next
            ' instance of the smart tag term.
            index += Term.Length
            index = ParagraphText.IndexOf(Term, index)
        End While
    Next
End Sub
protected override void Recognize(string text, 
    ISmartTagRecognizerSite site, ISmartTagTokenList tokenList)
{
    foreach (string term in this.Terms)
    {
        // Search the text for the current smart tag term.
        int index = this.ParagraphText.IndexOf(term, 0);

        while (index >= 0)
        {
            // Create a smart tag token and a property bag for the 
            // recognized term.
            ISmartTagProperties propertyBag = 
                site.GetNewPropertyBag();

            // Write a new property value.
            string key = "Key1";
            propertyBag.Write(key, DateTime.Now.ToString());

            // Attach the smart tag to the term in the document
            this.PersistTag(index, term.Length, propertyBag);

            // Increment the index and then find the next
            // instance of the smart tag term.
            index += term.Length;
            index = ParagraphText.IndexOf(term, index);
        }
    }
}

Berechtigungen

Siehe auch

Referenz

SmartTag-Klasse

SmartTag-Member

Microsoft.Office.Tools.Word-Namespace