How to copy-paste frames from one document to other with there respective layers intact?


hi all,

 

     facing issue while copy paste frames 1 document other. have 3 frames in first documents each 1 on different layer. first document has 3 layers. second document have 3 layers , copying frames first document scrapdata using 'icopycmddata ' , 'kcopycmdboss'. have 'paste remembers layers' menu 'checked' on layer panel. using following function copy frames scrapdata.

 

bool16 copystencilsfromthetemplatedocumentintoscrapdata(pmstring & templatefilepath)
{
     bool16 result = kfalse;
    do
    {
        sdklayouthelper sdklhelp;

 

        pmstring filepathitemstobecopiedfrom(templatefilepath);  //("c:\\test\\aa.indt");
        idfile templateidfile(filepathitemstobecopiedfrom);
        uidref templatedocuidref = sdklhelp.opendocument(templateidfile);

        if(templatedocuidref == uidref ::gnull)                 
            break;

 

        errorcode err = sdklhelp.openlayoutwindow(templatedocuidref);
        if(err == kfailure)                 
            break;

 

        interfaceptr<idocument> templatedoc(templatedocuidref,usedefaultiid());
        if(templatedoc == nil)               
            break;
       
        interfaceptr<ispreadlist>templatespreaduidlist(templatedoc,usedefaultiid());
        if(templatespreaduidlist == nil)                  
            break;
      
        idatabase * templatedocdatabase = templatedocuidref.getdatabase();
        if(templatedocdatabase == nil)                  
            break;

 

        uidref templatedocfirstspreaduidref(templatedocdatabase, templatespreaduidlist->getnthspreaduid(0));
        interfaceptr<ispread> templatespread(templatedocfirstspreaduidref, iid_ispread);
        if(templatespread == nil)                 
            break;
      
        uidlist templateframeuidlist(templatedocdatabase);
        if(templatespread->getnthpageuid(0)== kinvaliduid)                  
            break;      
       
        templatespread->getitemsonpage(0,&templateframeuidlist,kfalse,ktrue);  

 

        interfaceptr<icommand> copystencilscmd(cmdutils::createcommand(kcopycmdboss));
        if(copystencilscmd == nil)                

            break;

     
        interfaceptr<icopycmddata> cmddata(copystencilscmd, iid_icopycmddata);
        if(cmddata == nil)                 
            break;
      
        // copy cmd own list

 

        uidlist* listcopy = new uidlist(templateframeuidlist);
        interfaceptr<iclipboardcontroller> clipboardcontroller(gsession,usedefaultiid());
        if(clipboardcontroller == nil)              

            break;

      
        errorcode status = clipboardcontroller->prepareforcopy();
        if(status == kfailure)                  
            break;
       
        interfaceptr<idataexchangehandler> scraphandler(clipboardcontroller->queryhandler(kpageitemflavor));
        if(scraphandler == nil)                 
            break;

 

        clipboardcontroller->setactivescraphandler(scraphandler);

 

        interfaceptr<ipageitemscrapdata> scrapdata(scraphandler, usedefaultiid());
        if(scrapdata== nil)                
            break;

 

        uidref parent = scrapdata->getrootnode();

        cmddata->set(copystencilscmd, listcopy, parent, scraphandler);

 

        if(templateframeuidlist.length() == 0)       
            return kfalse;      
        else      
            status = cmdutils::processcommand(copystencilscmd);    

 

        if(status != kfailure)

          result = ktrue;

 

        sdklhelp.closedocument(templatedocuidref,kfalse,k2::ksuppressui, kfalse);

 

    }while(kfalse);

    return result;

}

 

after need close first document. opening second document indt file has same number of layers first document. trying paste frames scrap data second document using '' 'icopycmddata ' , 'kpastecmdboss' shown in follwoing function

 

bool16 pastetheitemsfromscrapdataontoopendocument(uidref &documentdocuidref )
{
    bool16 result = kfalse;
    do
    {
           interfaceptr<iclipboardcontroller> clipboardcontroller(gsession,usedefaultiid());
            if(clipboardcontroller == nil)
                break;

 

           interfaceptr<idataexchangehandler> scraphandler(clipboardcontroller->queryhandler(kpageitemflavor));
           if(scraphandler == nil)               
                break;
        
           interfaceptr<ipageitemscrapdata> scrapdata(scraphandler, usedefaultiid());
            if(scrapdata == nil)
               break;
          
                 //this give list of items present on scrap
            uidlist* scrapcontents = scrapdata->createuidlist();
            if (scrapcontents->length() >= 1)
            {  
                interfaceptr<idocument> datatobesprayeddocument(documentdocuidref,usedefaultiid());
                if(datatobesprayeddocument == nil)
                   break;
              
                interfaceptr<ispreadlist>datatobesprayeddocumentspreadlist(datatobesprayeddocument,usedef aultiid());
                if(datatobesprayeddocumentspreadlist == nil)
                     break;
               
                idatabase * datatobesprayeddocdatabase = documentdocuidref.getdatabase();
                if(datatobesprayeddocdatabase == nil)
                     break;    

 

                uidref spreaduidref(datatobesprayeddocdatabase, datatobesprayeddocumentspreadlist->getnthspreaduid(0));               
                sdklayouthelper sdklhelp;
                uidref parentlayeruidref = sdklhelp.getspreadlayerref(spreaduidref);
           
                interfaceptr<ipageitemscrapdata> localscrapdata(scraphandler, usedefaultiid());
                if(localscrapdata == nil)
                    break;
                   
                if(parentlayeruidref.getuid() == kinvaliduid)
                    break;
               
                interfaceptr<icommand> pastetoclipboardcmd (cmdutils::createcommand(kpastecmdboss));
                if(pastetoclipboardcmd == nil)
                    break;
              
                interfaceptr<icopycmddata> cmddata(pastetoclipboardcmd, usedefaultiid());
                if(cmddata == nil)
                    break;
               
                if(scrapcontents == nil)
                    break;               
                               
                pmpoint offset(0.0, 0.0);
                cmddata->setoffset(offset);

 

                cmddata->set(pastetoclipboardcmd, scrapcontents, parentlayeruidref );
                errorcode status = cmdutils::processcommand(pastetoclipboardcmd);
                if(status == ksuccess)
                {
                    ca("result = ktrue");
                    result = ktrue;
                }
            }//end if (scrapcontents->length() >= 1)       
    }while(kfalse);
    return result;
}

 

     here in above function required set parent layer uidref , because of frames getting paste in 1 layer.

is there way can paste frame in there respective layers?

     need work code cs4 server , desktop indesign.

 

thanks in advance,

rahul dalvi



More discussions in InDesign SDK


adobe

Comments

Popular posts from this blog

Installation database is corrupt

Nogen der kender et simpelt hvidt template med topmenu kun - Joomla! Forum - community, help and support

Error compiling for board Arduino/Genuino Uno.