---------------------------------------------- ---------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . D I A . P R I N T E R -- -- -- -- B o d y -- -- -- -- Copyright (C) 2005-2006, GET-Telecom Paris. -- -- -- -- Ocarina is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 2, or (at your option) any -- -- later version. Ocarina is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with Ocarina; see file COPYING. -- -- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth -- -- Floor, Boston, MA 02111-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- Ocarina is maintained by the Ocarina team -- -- (ocarina-users@listes.enst.fr) -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Output; use Output; with DOM.Core.Nodes; with DOM.Core.Documents; with DOM.Core.Elements; with Ocarina.Dia.Printer.Misc; with Ocarina.Dia.Printer.Diagramdata; with Ocarina.Dia.Printer.Layer; with Ocarina.Dia.Printer.Optimize; package body Ocarina.Dia.Printer is ---------- -- Init -- ---------- procedure Init is use Ocarina.Printer; begin Register_Printer ("dia", Print_Node'Access); end Init; ------------------- -- Create_Header -- ------------------- procedure Create_Header (Doc : DOM.Core.Document; Parent_Node : DOM.Core.Node) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; XML_Node : DOM.Core.Node; pragma Warnings (Off, XML_Node); XML_Processing : constant Processing_Instruction := Create_Processing_Instruction (Doc, "xml", "version=""1.0"" encoding=""" & "UTF-8" & """"); -- TODO : put the right encoding set instead of "UTF-8" begin Ada.Text_IO.Put_Line ("Creating Header"); XML_Node := Append_Child (Parent_Node, XML_Processing); end Create_Header; -------------------- -- Create_Diagram -- -------------------- procedure Create_Diagram (Doc : DOM.Core.Document; Parent_Node : DOM.Core.Node; Node : Node_Id) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; use Ocarina.Dia.Printer.Diagramdata; use Ocarina.Dia.Printer.Layer; XML_Node : DOM.Core.Node; XML_Element : constant DOM.Core.Element := Create_Element (Doc, "dia:diagram"); begin Ada.Text_IO.Put_Line ("Creating Diagram"); Set_Attribute_NS (XML_Element, "xmlns", "dia", "http://www.lysator.liu.se/~alla/dia/"); XML_Node := Append_Child (Parent_Node, XML_Element); Create_Diagram_Data (Doc, XML_Node); Create_Layer (Doc, XML_Node, Node); end Create_Diagram; ------------------ -- Analyse_Node -- ------------------ procedure Analyse_Node (Doc : DOM.Core.Document; Parent_Node : DOM.Core.Node; Node : Node_Id) is begin Create_Header (Doc, Parent_Node); Create_Diagram (Doc, Parent_Node, Node); end Analyse_Node; ---------------- -- Print_Node -- ---------------- procedure Print_Node (Node : Node_Id; Options : Ocarina.Printer.Output_Options := Ocarina.Printer.Default_Output_Options) is use DOM.Core.Nodes; use DOM.Core.Documents; use Ada.Text_IO; use Ocarina.Dia; use Ocarina.Printer; Implementation : DOM_Implementation; Doc : DOM.Core.Document; G : Printer.Optimize.Compound_Graph; pragma Warnings (Off, G); begin Doc := Create_Document (Implementation); Analyse_Node (Doc, Doc, Node); Set_Output (Create_Output_File (Options)); -- Optimization phase G := Printer.Optimize.XML_To_Graph (Doc); Printer.Optimize.Dump_Graph (G); Printer.Optimize.Optimize (G); Printer.Optimize.Graph_To_XML (Doc, G); -- Printing phase Ocarina.Dia.Printer.Misc.Print ("", Doc, True, True, True); Free (Doc); Set_Standard_Output; end Print_Node; end Ocarina.Dia.Printer;