with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IHTMLTxtRange_Interface is

   procedure Initialize (This : in out IHTMLTxtRange_Type) is
   begin
      Set_IID (This, IID_IHTMLTxtRange);
   end Initialize;

   function Pointer (This : IHTMLTxtRange_Type)
     return Pointer_To_IHTMLTxtRange
   is
   begin
      return To_Pointer_To_IHTMLTxtRange (Address (This));
   end Pointer;

   procedure Attach (This    : in out IHTMLTxtRange_Type;
                     Pointer : in     Pointer_To_IHTMLTxtRange)
   is
   begin
      Attach (This, GNATCOM.IInterface.To_Pointer_To_IUnknown
              (Pointer.all'Address));
   end Attach;

   function Get_htmlText
     (This : IHTMLTxtRange_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_htmlText
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_htmlText;

   procedure Put_text
     (This : IHTMLTxtRange_Type;
      p    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_text
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_text;

   function Get_text
     (This : IHTMLTxtRange_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_text
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_text;

   function parentElement
     (This   : IHTMLTxtRange_Type)
     return Pointer_To_IHTMLElement
   is
       RetVal : aliased Pointer_To_IHTMLElement;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.parentElement
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end parentElement;

   function duplicate
     (This      : IHTMLTxtRange_Type)
     return Pointer_To_IHTMLTxtRange
   is
       RetVal : aliased Pointer_To_IHTMLTxtRange;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.duplicate
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end duplicate;

   function inRange
     (This    : IHTMLTxtRange_Type;
      urange  : Pointer_To_IHTMLTxtRange)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.inRange
         (Pointer (This),
          urange,
          RetVal'Unchecked_Access));

      return RetVal;
   end inRange;

   function isEqual
     (This    : IHTMLTxtRange_Type;
      urange  : Pointer_To_IHTMLTxtRange)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.isEqual
         (Pointer (This),
          urange,
          RetVal'Unchecked_Access));

      return RetVal;
   end isEqual;

   procedure scrollIntoView
     (This   : IHTMLTxtRange_Type;
      fStart : GNATCOM.Types.VARIANT_BOOL)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.scrollIntoView
         (Pointer (This),
          fStart));

   end scrollIntoView;

   procedure collapse
     (This  : IHTMLTxtRange_Type;
      start : GNATCOM.Types.VARIANT_BOOL)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.collapse
         (Pointer (This),
          start));

   end collapse;

   function expand
     (This    : IHTMLTxtRange_Type;
      Unit    : GNATCOM.Types.BSTR;
      Free    : Boolean := True)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.expand
         (Pointer (This),
          Unit,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (Unit);
      
      end if;

      return RetVal;
   end expand;

   function move
     (This        : IHTMLTxtRange_Type;
      Unit        : GNATCOM.Types.BSTR;
      Count       : Interfaces.C.long;
      Free        : Boolean := True)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.move
         (Pointer (This),
          Unit,
          Count,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (Unit);
      
      end if;

      return RetVal;
   end move;

   function moveStart
     (This        : IHTMLTxtRange_Type;
      Unit        : GNATCOM.Types.BSTR;
      Count       : Interfaces.C.long;
      Free        : Boolean := True)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.moveStart
         (Pointer (This),
          Unit,
          Count,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (Unit);
      
      end if;

      return RetVal;
   end moveStart;

   function moveEnd
     (This        : IHTMLTxtRange_Type;
      Unit        : GNATCOM.Types.BSTR;
      Count       : Interfaces.C.long;
      Free        : Boolean := True)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.moveEnd
         (Pointer (This),
          Unit,
          Count,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (Unit);
      
      end if;

      return RetVal;
   end moveEnd;

   procedure uselect
     (This : IHTMLTxtRange_Type)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.uselect
         (Pointer (This)));

   end uselect;

   procedure pasteHTML
     (This : IHTMLTxtRange_Type;
      html : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.pasteHTML
         (Pointer (This),
          html));

      if Free then
               GNATCOM.IInterface.Free (html);
      
      end if;

   end pasteHTML;

   procedure moveToElementText
     (This    : IHTMLTxtRange_Type;
      element : Pointer_To_IHTMLElement)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.moveToElementText
         (Pointer (This),
          element));

   end moveToElementText;

   procedure setEndPoint
     (This        : IHTMLTxtRange_Type;
      how         : GNATCOM.Types.BSTR;
      sourceRange : Pointer_To_IHTMLTxtRange;
      Free        : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.setEndPoint
         (Pointer (This),
          how,
          sourceRange));

      if Free then
               GNATCOM.IInterface.Free (how);
      
      end if;

   end setEndPoint;

   function compareEndPoints
     (This        : IHTMLTxtRange_Type;
      how         : GNATCOM.Types.BSTR;
      sourceRange : Pointer_To_IHTMLTxtRange;
      Free        : Boolean := True)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.compareEndPoints
         (Pointer (This),
          how,
          sourceRange,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (how);
      
      end if;

      return RetVal;
   end compareEndPoints;

   function findText
     (This    : IHTMLTxtRange_Type;
      String  : GNATCOM.Types.BSTR;
      Count   : Interfaces.C.long;
      flags   : Interfaces.C.long;
      Free    : Boolean := True)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.findText
         (Pointer (This),
          String,
          Count,
          flags,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (String);
      
      end if;

      return RetVal;
   end findText;

   procedure moveToPoint
     (This : IHTMLTxtRange_Type;
      x    : Interfaces.C.long;
      y    : Interfaces.C.long)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.moveToPoint
         (Pointer (This),
          x,
          y));

   end moveToPoint;

   function getBookmark
     (This     : IHTMLTxtRange_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.getBookmark
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end getBookmark;

   function moveToBookmark
     (This     : IHTMLTxtRange_Type;
      Bookmark : GNATCOM.Types.BSTR;
      Free     : Boolean := True)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.moveToBookmark
         (Pointer (This),
          Bookmark,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (Bookmark);
      
      end if;

      return RetVal;
   end moveToBookmark;

   function queryCommandSupported
     (This  : IHTMLTxtRange_Type;
      cmdID : GNATCOM.Types.BSTR;
      Free  : Boolean := True)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.queryCommandSupported
         (Pointer (This),
          cmdID,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (cmdID);
      
      end if;

      return RetVal;
   end queryCommandSupported;

   function queryCommandEnabled
     (This  : IHTMLTxtRange_Type;
      cmdID : GNATCOM.Types.BSTR;
      Free  : Boolean := True)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.queryCommandEnabled
         (Pointer (This),
          cmdID,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (cmdID);
      
      end if;

      return RetVal;
   end queryCommandEnabled;

   function queryCommandState
     (This  : IHTMLTxtRange_Type;
      cmdID : GNATCOM.Types.BSTR;
      Free  : Boolean := True)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.queryCommandState
         (Pointer (This),
          cmdID,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (cmdID);
      
      end if;

      return RetVal;
   end queryCommandState;

   function queryCommandIndeterm
     (This  : IHTMLTxtRange_Type;
      cmdID : GNATCOM.Types.BSTR;
      Free  : Boolean := True)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.queryCommandIndeterm
         (Pointer (This),
          cmdID,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (cmdID);
      
      end if;

      return RetVal;
   end queryCommandIndeterm;

   function queryCommandText
     (This     : IHTMLTxtRange_Type;
      cmdID    : GNATCOM.Types.BSTR;
      Free     : Boolean := True)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.queryCommandText
         (Pointer (This),
          cmdID,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (cmdID);
      
      end if;

      return RetVal;
   end queryCommandText;

   function queryCommandValue
     (This      : IHTMLTxtRange_Type;
      cmdID     : GNATCOM.Types.BSTR;
      Free      : Boolean := True)
     return GNATCOM.Types.VARIANT
   is
       RetVal : aliased GNATCOM.Types.VARIANT;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.queryCommandValue
         (Pointer (This),
          cmdID,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (cmdID);
      
      end if;

      return RetVal;
   end queryCommandValue;

   function execCommand
     (This   : IHTMLTxtRange_Type;
      cmdID  : GNATCOM.Types.BSTR;
      showUI : GNATCOM.Types.VARIANT_BOOL;
      value  : GNATCOM.Types.VARIANT  := GNATCOM.Types.VARIANT_MISSING;
      Free   : Boolean := True)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.execCommand
         (Pointer (This),
          cmdID,
          showUI,
          value,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (cmdID);
               GNATCOM.IInterface.Free (value);
      
      end if;

      return RetVal;
   end execCommand;

   function execCommandShowHelp
     (This  : IHTMLTxtRange_Type;
      cmdID : GNATCOM.Types.BSTR;
      Free  : Boolean := True)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.execCommandShowHelp
         (Pointer (This),
          cmdID,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (cmdID);
      
      end if;

      return RetVal;
   end execCommandShowHelp;

end MSHTML.IHTMLTxtRange_Interface;

