PageBase::GetEmbeddingInfo

Description

Returns the status of the PageBase object if embedded in a Datasheet.

Syntax

BOOL GetEmbeddingInfo( Datasheet & parentSheet = NULL, int * pnRow = NULL, int * pnCol = NULL, DWORD * pdw = NULL, string* pstrInfo = NULL )

Parameters

parentSheet
[output]If embedded, parentSheet receives the Datasheet where the PageBase is embedded.
pnRow
[output]If embedded, *pnRow receives the row index in the DataSheet where the PageBase is embedded.
pnCol
[output]If embedded, *pnCol receives the column index in the DataSheet where the PageBase is embedded.
pdw
[output]If embedded, *pdw receives the embedding bits info.
pstrInfo
[output]If embedded, *pstrInfo receives location info.

Return

TRUE if the object is embedded in a Datasheet, otherwise FALSE.

Examples

EX1

//Prepare some graphs and embed one into worksheet
void PageBase_GetEmbeddingInfo_ex1()
{
        WorksheetPage wksPg("Book1");  //Access the workbook named "Book1"
        foreach(GraphPage gp in Project.GraphPages) //go through all the graphs
        {
                if(gp.GetEmbeddingInfo()) //Output embed graph
                printf("%s is embedded", gp.GetName());
        }
}

EX2

//Prepare some graphs and embed one into worksheet
static bool _show_embedded(LPCSTR lpcszName)
{
    GraphPage gp(lpcszName);
    if(!gp)
        return false;
    Worksheet wks;
    int nRow, nCol;
    DWORD dwCntrl;
    if(gp.GetEmbeddingInfo(wks, &nRow, &nCol, &dwCntrl))
    {
        string strBooksheet = wks_get_book_sheet_name(wks);
        if(dwCntrl & EMBEDGRAPH_IN_LABELS)
            out_str("\tGraph is embeded in Column Label region");
        else
            out_str("\tGraph is embeded data region");
            
        printf("\tLocation: %s\n\tCol = %d\n\tRow = %d\n\tbits=%X\n", strBooksheet, nCol, nRow, dwCntrl);
        return true;
    }
    else
        out_str("\tNormal Graph");
    return false;
}

void PageBase_GetEmbeddingInfo_ex2()
{
    int nn = 1;
    foreach(GraphPage gp in Project.GraphPages)
    {
        string strName = gp.GetName();
        printf("%d:%s - %s\n", nn++, strName, gp.GetLongName());
        _show_embedded(strName);
    }
}

EX3

void PageBase_GetEmbeddingInfo_ex3()
{
        Project.Open();
        
        Worksheet wks;
        wks.Create("origin");
        
        GraphPage gpFloat;
        if( gpFloat.Create("bar") )
        {
                gpFloat.SetName("Insert");
                wks.InsertGraph(gpFloat);
        }
        
        GraphPage gpLink;
        if( gpLink.Create("column") )
        {
                gpLink.SetName("Link");
                string str = "graph://" + gpLink.GetName();
                wks.SetCell(2, 0, str);
        }     

        GraphPage gpEmbed;
        if( gpEmbed.Create("2Ys_Col") )
        {
                gpEmbed.SetName("Embed");
                wks.EmbedGraph(3, 1, gpEmbed);
        }
        
        out_str("page embedded location");
        foreach(GraphPage gp in Project.GraphPages)
    {
        printf("%s=", gp.GetName());
                string strInfo;
                if( gp.GetEmbeddingInfo(NULL, NULL, NULL, NULL, &strInfo) )
                        out_str(strInfo);
                else
                        out_str("null");
    }
}

Remark

See Also

Layer::InsertGraph
Worksheet::EmbedGraph

header to Include

origin.h