Vwa.Shape.getShapeData Method

Última modificación: jueves, 21 de junio de 2012

Hace referencia a: apps for SharePoint | SharePoint Server 2013

Devuelve una matriz de objetos anónimos, cada uno de los cuales corresponde a un elemento de datos asociado a la forma.

var value = Shape.getShapeData()

Valor devuelto

Object[] Una matriz de objetos anónimos, cada uno de los cuales corresponde a un elemento de datos asociado a la forma.

Comentarios

Cada objeto anónimo en la matriz devuelta tiene las siguientes propiedades:

  • label Una cadena que especifica la etiqueta del elemento de datos de forma, que se corresponde con el valor de la celda etiqueta de una fila de datos de la forma de Microsoft Visio 2013.

  • value Una cadena que especifica el valor del elemento de datos de forma, que se corresponde con el valor de la celda del valor de una fila de datos de la forma de Visio 2013.

  • format Una cadena que especifica el formato del elemento de datos de forma, que se corresponde con el valor de la celda de formato de una fila de datos de la forma de Visio 2013.

  • formattedValue Una cadena que especifica el valor con formato del elemento de datos de forma, que se utiliza para mostrarlo.

Este método no devuelve los datos de forma que se oculta en Visio 2013 .

Si no hay ningún elemento de datos de formas asociado a la forma, el método devuelve una matriz vacía.

Para obtener más información acerca de cómo agregar un elemento Web de Visio Web Access a una página de elementos web de SharePoint, consulte Customizing Visio Web Drawings in the Visio Web Access Web Part.

Ejemplo

El ejemplo siguiente crea una etiqueta HTML o superposición de Silverlight con formas en un elemento Web de Visio Web Access cuando el mouse entra en el cuadro delimitador de la forma.

<script type="text/javascript">

// Declare global variables.
var vwaControl;
var vwaPage;
var vwaShapes;
var vwaShape;

// Hook into the AJAX Sys.Application.load event.
Sys.Application.add_load(onApplicationLoad)

// Capture a reference to the current session of the Visio Web Access Web Part.
function onApplicationLoad() {
    try{
        vwaControl= new Vwa.VwaControl(getVWAWebPartID());
        vwaControl.addHandler("diagramcomplete", onDiagramComplete);
    }
    catch(err){
        alert(err);
    }
}

// Search the SharePoint page to get the WebPartID# for the Visio Web Access Web Part.
function getVWAWebPartID() {

    // Get a NodesList of all the div tags on the page. 
    var divArray = document.getElementsByTagName("div");
    var webPartElementID;
    
    // Iterate through the NodesList to get the node with the class attribute "VisioWebAccess."
    for (var i = 0; i < divArray.length; i++) {
        var node = divArray[i];
        
        // Return the first instance of the Visio Web Access Web Part.
        if (node.className == "VisioWebAccess") {
            webPartElementID = node.parentNode.parentNode.id;
            break;
        }
    }
    return webPartElementID;
}

// Capture references to global variables and add event handlers.
function onDiagramComplete() {
    try{
        vwaPage = vwaControl.getActivePage();
        vwaShapes = vwaPage.getShapes();

        // Remove the handlers from the Visio Web Access Web Part before adding them back.
        vwaControl.removeHandler("shapemouseleave", onShapeMouseLeave);
        vwaControl.removeHandler("shapemouseenter", onShapeMouseEnter);
        vwaControl.addHandler("shapemouseleave", onShapeMouseLeave);
        vwaControl.addHandler("shapemouseenter", onShapeMouseEnter);
        
    }
    catch(err){
        alert(err);
    }
}

// Determine whether a shape contains data when the mouse hovers over it.
function onShapeMouseEnter(source, args) {
    try{
        // Get the shape that raised the event from the arguments passed in.
        var shapeId = args;
        vwaShape = vwaShapes.getItemById(shapeId);
        
        // Get the shape's data in an array of anonymous objects.
        var shapeDataArray = vwaShape.getShapeData();

        // Display the shape's data, if the shape has any.
        if (shapeDataArray.length > 0) {
            displayShapeData(shapeDataArray);
        }
    }
    catch(err){
        alert(err);
    }
}

// Display shape data over a shape.
function displayShapeData(dataArray) {

    // Get the value of the display mode for the Visio Web Access Web Part.
    var displayMode = vwaControl.getDisplayMode();

    // Test to see what the current display mode is.
    if (displayMode == 1) {
        // The display mode is Silverlight; add Silverlight graphic overlays.
        createOverlaySL(dataArray);
    }
    else {
            
        // The display mode is raster format; add HTML graphic overlays.
        createOverlayHTML(dataArray);
    }
}

// Create a Silverlight overlay over a shape.
function createOverlaySL(dataArray) {

    // Create formatted XAML fragment to contain the shape data.
    var xamlBuilder = "<TextBlock Height='100' Width='100' FontSize='10'>";

    // Add HTML to the fragment for each label/value pair in the array of shape data.
    for (var i = 0; i < dataArray.length; i++) {
        xamlBuilder += dataArray[i].label + ": " + dataArray[i].formattedValue + "<LineBreak/>";
    }
    xamlBuilder += "</TextBlock>";

    vwaShape.addOverlay(
        "overlay_" + vwaShape.getId(), 
        "<Canvas>" +
        "<Rectangle Height='100' Width='100' Fill='#880000FF' ></Rectangle>" + 
        xamlBuilder + 
        "</Canvas>",
        1, 
        1,
        100,
        100);
}

// Create an HTML overlay over a shape.
function createOverlayHTML(dataArray) {

    // Create the formatted HTML fragment to contain the shape data.
    var htmlBuilder = "<div style='font-family:Segoe;color:#000000'>";
    
    // Add HTML to the fragment for each label/value pair in the array of shape data.
    for (var i = 0; i < dataArray.length; i++) {
        htmlBuilder += dataArray[i].label + ": " + dataArray[i].formattedValue + "<br />";
    }
    htmlBuilder += "</div>";
    
    // Create a formatted div tag for visual overlay.
    vwaShape.addOverlay(
        "overlay_" + vwaShape.getId(), 
        "<div id=\"HTMLDiv\" style=\"width: 100%; height:" + 
        "100%;background-color:#0000FF;z-order:32;" + 
        "filter:alpha(opacity=30);\"><\/div>", 
        1, 
        1,
        100,
        100);

    // Display the HTML as a predefined text overlay, centered over the shape.
    vwaShape.addPredefinedOverlay(Vwa.OverlayType.text, 
                                "text_" + vwaShape.getId(), 
                                htmlBuilder,
                                1,
                                1,
                                100,
                                100);
}

// Dismiss the overlay from the shape two seconds after the mouse leaves the shape's bounding box.
onShapeMouseLeave = function (source, args) {
    try{
        var tmpShape = vwaShapes.getItemById(args); 
        setTimeout(
            function() {
                vwaShape.removeOverlay("text_" + tmpShape.getId()); 
                vwaShape.removeOverlay("overlay_" + tmpShape.getId());
            }, 
            2000);
    }
    catch(err){
        alert(err);
    }
}

</script>

Vea también

Referencia

Vwa.Shape Class

Vwa.Shape Class Methods