Notes

 view release on metacpan or  search on metacpan

ViewColumn/ViewColumn.xs  view on Meta::CPAN

#define BLOCK Perl_BLOCK

#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "notesviewcolumn.h"

MODULE = Notes::ViewColumn   PACKAGE = Notes::View

PROTOTYPES: DISABLE


void
columns( view, index = 1 )
      LN_View *   view;
      UV	      index;
   PREINIT:
      d_LN_XSVARS;
      NOTEHANDLE           hNote = NULLHANDLE;
      STATUS               ln_rc   = NOERROR;
	  HV  			     * ln_hash = (HV *) NULL;
	  SV 			     * sv      = (SV *) NULL;
	  WORD			       wDataType;
	  DWORD			       dwLength;
	  BLOCKID              ValueBlockID;
	  char                 szData[128];
	  char far           * pData;
	  char far           * pPackedData;
	  VIEW_FORMAT_HEADER * pHeaderFormat;
	  VIEW_TABLE_FORMAT  * pTableFormat;
	  VIEW_TABLE_FORMAT2 * pTableFormat2;
	  VIEW_COLUMN_FORMAT * pColumnFormat;
	  VIEW_COLUMN_FORMAT * pColumnFormat2;
	  VIEW_FORMAT_HEADER   formatHeader;
	  VIEW_TABLE_FORMAT    tableFormat;
	  VIEW_TABLE_FORMAT2   tableFormat2;
	  VIEW_COLUMN_FORMAT   viewColumn;
	  VIEW_COLUMN_FORMAT   viewColumn2;
	  void               * tempPtr;
	  WORD                 wColumn;
	  char far           * pFormula;
	  char far           * pFormulaText, *pTemp;
	  WORD                 wFormulaTextLen;
      HANDLE               hFormulaText;
   PPCODE:

       ln_hash = (HV *)sv_2mortal((SV *)newHV());

	   if (ln_rc = NSFNoteOpen(LN_DB_HANDLE(NOTESVIEW,view), LN_NOTE_ID(NOTESVIEW,view), 0, &hNote))
       {
           DEBUG(("Notes::ViewColumn object returning error %d at line %d", ln_rc, __LINE__));
           DEBUG(("DBHANDLE = %ld, NOTEID = %ld", LN_DB_HANDLE(NOTESVIEW,view), LN_NOTE_ID(NOTESVIEW,view)));
           LN_SET_IVX(view, ln_rc);
	       XSRETURN_NOT_OK;
	   }

   	   ln_rc = NSFItemInfo(hNote,
	                            VIEW_VIEW_FORMAT_ITEM,
	                            sizeof(VIEW_VIEW_FORMAT_ITEM) - 1,
	                            NULL,
	                            &wDataType,
	                            &ValueBlockID,
	                            &dwLength);

	   if (ln_rc || wDataType != TYPE_VIEW_FORMAT)
	   {
		   DEBUG(("Notes::ViewColumn object returning error %d at line %d", ln_rc, __LINE__));
	       NSFNoteClose(hNote);
		   LN_SET_IVX(view, ln_rc);
	       XSRETURN_NOT_OK;
	   }

	   /*
	    *  Lock the block returned, Get the view format and check the version.
	    *  We need to do ODSMemory calls to ensure cross-platform compatibility.
	    */

	   pData = OSLockBlock(char, ValueBlockID);
	   pData += sizeof(WORD);

	   tempPtr = pData;
	   ODSReadMemory( &tempPtr, _VIEW_FORMAT_HEADER, &formatHeader, 1 );
	   pHeaderFormat = &formatHeader;

	   if (pHeaderFormat->Version != VIEW_FORMAT_VERSION)
	   {
	       DEBUG(("Notes::ViewColumn object returning error %d at line %d", ln_rc, __LINE__));
	       OSUnlockBlock(ValueBlockID);
	       NSFNoteClose(hNote);
	       LN_SET_IVX(view, ln_rc);
           XSRETURN_NOT_OK;
       }

	   /*
	    *  Read the table format ( which includes the view format header )
	    */

	   if ((pHeaderFormat->ViewStyle & VIEW_CLASS_MASK) == VIEW_CLASS_TABLE)
	   {
	       tempPtr = pData;
	       ODSReadMemory( &tempPtr, _VIEW_TABLE_FORMAT, &tableFormat, 1 );
	       pTableFormat = &tableFormat;

	       /*
	        * Make sure requested column index exists.

ViewColumn/ViewColumn.xs  view on Meta::CPAN

				   	  sv = newSViv(1);
				  else
				   	  sv = newSViv(0);

				  SvREADONLY_on(sv);
				  hv_store(ln_hash, "IsResortAscending", 17, sv, 0);
	          }

	          /*
	           *  See if this column is a secondary sort column
	           */

	          if (pColumnFormat->Flags1 & VCF1_M_SecondResort)
			   	  sv = newSViv(1);
			  else
  		      	  sv = newSViv(0);

			  SvREADONLY_on(sv);
			  hv_store(ln_hash, "IsSecondaryResort", 17, sv, 0);

	          /*
	           *  See if this column is sorted as secondary descending
	           */

	          if (pColumnFormat->Flags1 & VCF1_M_SecondResortDescending)
			   	  sv = newSViv(1);
			  else
  		      	  sv = newSViv(0);

			  SvREADONLY_on(sv);
			  hv_store(ln_hash, "IsSecondaryResortDescending", 27, sv, 0);

			  /*
	           *  See if this column is sorted as secondary ascending
	           */

	          if (pColumnFormat->Flags1 & VCF1_M_SecondResortDescending)
			   	  sv = newSViv(0);
			  else
  		      	  sv = newSViv(1);

			  SvREADONLY_on(sv);
			  hv_store(ln_hash, "IsSecondaryResortAscending", 26, sv, 0);

	       //} /*  End of for loop.  */
  	  }

	  OSUnlockBlock(ValueBlockID);
      NSFNoteClose(hNote);

	  LN_PUSH_NEW_HASH_OBJ( "Notes::ViewColumn", view );
	  LN_SET_OK( view );
	  XSRETURN ( 1 );


MODULE = Notes::ViewColumn	 PACKAGE = Notes::ViewColumn

void
DESTROY( col )
      LN_ViewColumn *   col;
   PPCODE:
      XSRETURN( 0 );



( run in 0.447 second using v1.01-cache-2.11-cpan-5511b514fd6 )