--------------------------------------------- ----------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . D I A . P R I N T E R . D I A G R A M D A T A -- -- -- -- 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; use Ada.Text_IO; with DOM.Core.Documents; with DOM.Core.Nodes; with DOM.Core.Elements; with Ocarina.Dia.Printer.Attribute; package body Ocarina.Dia.Printer.Diagramdata is --------------- -- Add_Paper -- --------------- procedure Add_Paper (Doc : DOM.Core.Document; Parent_Node : DOM.Core.Node) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; use Ocarina.Dia.Printer.Attribute; XML_Node : DOM.Core.Node; XML_Element : constant DOM.Core.Element := Create_Element (Doc, "dia:attribute"); XML_Element2 : constant DOM.Core.Element := Create_Element (Doc, "dia:composite"); begin Set_Attribute (XML_Element, "name", "paper"); Set_Attribute (XML_Element2, "type", "paper"); XML_Node := Append_Child (Parent_Node, XML_Element); XML_Node := Append_Child (XML_Node, XML_Element2); Add_Attr_String (Doc, XML_Node, "name", "#A4#"); Add_Attr_Real (Doc, XML_Node, "tmargin", 2.8); Add_Attr_Real (Doc, XML_Node, "bmargin", 2.8); Add_Attr_Real (Doc, XML_Node, "lmargin", 2.8); Add_Attr_Real (Doc, XML_Node, "rmargin", 2.8); Add_Attr_Boolean (Doc, XML_Node, "is_portrait", True); Add_Attr_Real (Doc, XML_Node, "scaling", 1.0); Add_Attr_Boolean (Doc, XML_Node, "fitto", False); Put_Line ("Paper Created"); end Add_Paper; -------------- -- Add_Grid -- -------------- procedure Add_Grid (Doc : DOM.Core.Document; Parent_Node : DOM.Core.Node) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; use Ocarina.Dia.Printer.Attribute; XML_Node : DOM.Core.Node; XML_Element : constant DOM.Core.Element := Create_Element (Doc, "dia:attribute"); XML_Element2 : constant DOM.Core.Element := Create_Element (Doc, "dia:composite"); begin Set_Attribute (XML_Element, "name", "grid"); Set_Attribute (XML_Element2, "type", "grid"); XML_Node := Append_Child (Parent_Node, XML_Element); XML_Node := Append_Child (XML_Node, XML_Element2); Add_Attr_Real (Doc, XML_Node, "width_x", 1.0); Add_Attr_Real (Doc, XML_Node, "width_y", 1.0); Add_Attr_Int (Doc, XML_Node, "visible_x", 1); Add_Attr_Int (Doc, XML_Node, "visible_y", 1); Put_Line ("Grid Created"); end Add_Grid; ---------------- -- Add_Guides -- ---------------- procedure Add_Guides (Doc : DOM.Core.Document; Parent_Node : DOM.Core.Node) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; use Ocarina.Dia.Printer.Attribute; XML_Node : DOM.Core.Node; XML_Node2 : DOM.Core.Node; pragma Warnings (Off, XML_Node2); XML_Element : constant DOM.Core.Element := Create_Element (Doc, "dia:attribute"); XML_Element2 : constant DOM.Core.Element := Create_Element (Doc, "dia:composite"); XML_Element3 : constant DOM.Core.Element := Create_Element (Doc, "dia:attribute"); XML_Element4 : constant DOM.Core.Element := Create_Element (Doc, "dia:attribute"); begin Set_Attribute (XML_Element, "name", "guides"); Set_Attribute (XML_Element2, "type", "guides"); Set_Attribute (XML_Element3, "name", "hguides"); Set_Attribute (XML_Element4, "name", "vguides"); XML_Node := Append_Child (Parent_Node, XML_Element); XML_Node := Append_Child (XML_Node, XML_Element2); XML_Node2 := Append_Child (XML_Node, XML_Element3); XML_Node2 := Append_Child (XML_Node, XML_Element4); Put_Line ("Guides Created"); end Add_Guides; ------------------------- -- Create_Diagram_Data -- ------------------------- procedure Create_Diagram_Data (Doc : DOM.Core.Document; Parent_Node : DOM.Core.Node) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; use Ocarina.Dia.Printer.Attribute; XML_Node : DOM.Core.Node; XML_Element : constant DOM.Core.Element := Create_Element (Doc, "dia:diagramdata"); begin XML_Node := Append_Child (Parent_Node, XML_Element); Ada.Text_IO.Put_Line ("Creating Diagram Data"); Add_Attr_Color (Doc, XML_Node, "background", "#ffffff"); Add_Attr_Color (Doc, XML_Node, "pagebreak", "#000099"); Add_Paper (Doc, XML_Node); Add_Grid (Doc, XML_Node); Add_Attr_Color (Doc, XML_Node, "color", "#d8e5e5"); Add_Guides (Doc, XML_Node); end Create_Diagram_Data; end Ocarina.Dia.Printer.Diagramdata;