summaryrefslogtreecommitdiff
path: root/xml2cmp/source/xcd
diff options
context:
space:
mode:
Diffstat (limited to 'xml2cmp/source/xcd')
-rw-r--r--xml2cmp/source/xcd/cr_html.cxx271
-rw-r--r--xml2cmp/source/xcd/cr_html.hxx102
-rw-r--r--xml2cmp/source/xcd/cr_index.cxx278
-rw-r--r--xml2cmp/source/xcd/cr_index.hxx95
-rw-r--r--xml2cmp/source/xcd/cr_metho.cxx109
-rw-r--r--xml2cmp/source/xcd/cr_metho.hxx40
-rw-r--r--xml2cmp/source/xcd/filebuff.cxx66
-rw-r--r--xml2cmp/source/xcd/filebuff.hxx57
-rw-r--r--xml2cmp/source/xcd/main.cxx329
-rw-r--r--xml2cmp/source/xcd/makefile.mk83
-rw-r--r--xml2cmp/source/xcd/parse.cxx455
-rw-r--r--xml2cmp/source/xcd/parse.hxx146
-rw-r--r--xml2cmp/source/xcd/xmlelem.cxx277
-rw-r--r--xml2cmp/source/xcd/xmlelem.hxx244
-rw-r--r--xml2cmp/source/xcd/xmltree.cxx289
-rw-r--r--xml2cmp/source/xcd/xmltree.hxx149
16 files changed, 2990 insertions, 0 deletions
diff --git a/xml2cmp/source/xcd/cr_html.cxx b/xml2cmp/source/xcd/cr_html.cxx
new file mode 100644
index 000000000000..1b28c6facb82
--- /dev/null
+++ b/xml2cmp/source/xcd/cr_html.cxx
@@ -0,0 +1,271 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cr_html.cxx,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <fstream>
+#include "cr_html.hxx"
+#include "xmltree.hxx"
+#include "../support/syshelp.hxx"
+
+
+
+
+char C_sHtmlFileHeader1[] =
+ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"
+ "<HTML>\n"
+ "<HEAD>\n"
+ " <TITLE>";
+
+char C_sHtmlFileHeader2[] =
+ "</TITLE>\n"
+ " <META NAME=\"GENERATOR\" CONTENT=\"xml2cmp\">\n"
+ "</HEAD>\n"
+ "<BODY BGCOLOR=\"#ffffff\">\n<P><BR></P>";
+
+
+char C_sHtmlFileFoot[] = "</BODY>\n</HTML>\n";
+
+
+HtmlCreator::HtmlCreator( const char * i_pOutputFileName,
+ const XmlElement & i_rDocument,
+ const Simstr & i_sIDL_BaseDirectory )
+ : aFile(i_pOutputFileName, std::ios::out
+#if defined(WNT) || defined(OS2)
+ | std::ios::binary
+#endif
+ ),
+ rDocument(i_rDocument),
+ sIdl_BaseDirectory(i_sIDL_BaseDirectory)
+{
+ if ( !aFile )
+ {
+ std::cerr << "Error: " << i_pOutputFileName << " could not be created." << std::endl;
+ exit(0);
+ }
+}
+
+HtmlCreator::~HtmlCreator()
+{
+ aFile.close();
+}
+
+void
+HtmlCreator::Run()
+{
+ WriteStr( C_sHtmlFileHeader1 );
+ WriteStr( "ModuleDescription" );
+ WriteStr( C_sHtmlFileHeader2 );
+
+ rDocument.Write2Html(*this);
+
+ WriteStr( "<P><BR><BR></P>\n" );
+ WriteStr( C_sHtmlFileFoot );
+}
+
+void
+HtmlCreator::StartTable()
+{
+ WriteStr( "<P><BR></P>\n" );
+ WriteStr(
+ "<TABLE WIDTH=95% BORDER=1 CELLSPACING=0 CELLPADDING=4>\n"
+ " <TBODY>\n" );
+}
+
+void
+HtmlCreator::FinishTable()
+{
+ WriteStr( " </TBODY>\n"
+ "</TABLE>\n\n" );
+}
+
+void
+HtmlCreator::StartBigCell( const char * i_sTitle )
+{
+ WriteStr( "<TR><TD COLSPAN=2>\n"
+ "<H4><BR>" );
+ WriteStr( i_sTitle );
+ WriteStr( "</H4>\n" );
+
+}
+
+void
+HtmlCreator::FinishBigCell()
+{
+ WriteStr( "</TD><TR>\n" );
+}
+
+void
+HtmlCreator::Write_SglTextElement( const SglTextElement & i_rElement,
+ bool i_bStrong )
+{
+ StartRow();
+
+ WriteElementName( i_rElement.Name(), i_bStrong );
+
+ StartCell( "77%");
+ if (i_bStrong)
+ {
+ WriteStr( "<H4><A NAME=\"" );
+ unsigned nLen = strlen(i_rElement.Data());
+ if ( i_rElement.IsReversedName())
+ {
+ const char * pEnd = strchr(i_rElement.Data(), ' ');
+ nLen = (unsigned)( pEnd - i_rElement.Data() );
+ }
+ aFile.write( i_rElement.Data(), (int) nLen );
+ WriteStr( "\">" );
+ }
+
+ WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(),
+ i_bStrong ? lt_nolink : i_rElement.LinkType() );
+
+ if (i_bStrong)
+ WriteStr( "</A></H4>" );
+ FinishCell();
+
+ FinishRow();
+}
+
+void
+HtmlCreator::Write_MultiTextElement( const MultipleTextElement & i_rElement )
+{
+ StartRow();
+
+ WriteElementName( i_rElement.Name(), false );
+
+ StartCell( "77%");
+ unsigned i_max = i_rElement.Size();
+ for ( unsigned i = 0; i < i_max; ++i )
+ {
+ if (i > 0)
+ WriteStr( "<BR>\n" );
+ WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(i), i_rElement.LinkType() );
+ } // end for
+ FinishCell();
+
+ FinishRow();
+}
+
+void
+HtmlCreator::Write_SglText( const Simstr & i_sName,
+ const Simstr & i_sValue )
+{
+ StartRow();
+
+ WriteElementName( i_sName, false );
+
+ StartCell( "77%");
+ WriteStr( i_sValue );
+ FinishCell();
+
+ FinishRow();
+}
+
+void
+HtmlCreator::Write_ReferenceDocu( const Simstr & i_sName,
+ const Simstr & i_sRef,
+ const Simstr & i_sRole,
+ const Simstr & i_sTitle )
+{
+ StartRow();
+
+ StartCell( "23%" );
+ WriteStr(i_sName);
+ FinishCell();
+
+ StartCell( "77%" );
+ if ( !i_sRef.is_empty() )
+ {
+ WriteStr("<A href=\"");
+ WriteStr(i_sRef);
+ WriteStr("\">");
+ if ( !i_sTitle.is_empty() )
+ WriteStr( i_sTitle );
+ else
+ WriteStr(i_sRef);
+ WriteStr("</A><BR>\n");
+ }
+ else if ( !i_sTitle.is_empty() )
+ {
+ WriteStr("Title: ");
+ WriteStr( i_sTitle );
+ WriteStr("<BR>\n");
+ }
+ if ( !i_sRole.is_empty() )
+ {
+ WriteStr("Role: ");
+ WriteStr( i_sRole );
+ }
+ FinishCell();
+
+ FinishRow();
+}
+
+
+void
+HtmlCreator::StartRow()
+{
+ WriteStr( " <TR VALIGN=TOP>\n" );
+}
+
+void
+HtmlCreator::FinishRow()
+{
+ WriteStr( " </TR>\n" );
+}
+
+void
+HtmlCreator::StartCell( const char * i_pWidth)
+{
+ WriteStr( " <TD WIDTH=" );
+ WriteStr( i_pWidth );
+ WriteStr( ">\n <P>" );
+}
+
+void
+HtmlCreator::FinishCell()
+{
+ WriteStr( "</P>\n </TD>\n" );
+}
+
+void
+HtmlCreator::WriteElementName( const Simstr & i_sName,
+ bool i_bStrong )
+{
+ StartCell( "23%" );
+ if (i_bStrong)
+ WriteStr( "<H4>" );
+ WriteStr(i_sName);
+ if (i_bStrong)
+ WriteStr( "</H4>" );
+ FinishCell();
+}
+
+
+
diff --git a/xml2cmp/source/xcd/cr_html.hxx b/xml2cmp/source/xcd/cr_html.hxx
new file mode 100644
index 000000000000..0b0d07ff48f1
--- /dev/null
+++ b/xml2cmp/source/xcd/cr_html.hxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cr_html.hxx,v $
+ * $Revision: 1.10 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef X2C_CR_HTML_HXX
+#define X2C_CR_HTML_HXX
+
+
+#include <string.h>
+#include <fstream>
+#include "../support/sistr.hxx"
+#include "../support/syshelp.hxx"
+
+
+class XmlElement;
+class SglTextElement;
+class MultipleTextElement;
+
+
+class HtmlCreator
+{
+ public:
+ HtmlCreator(
+ const char * i_pOutputFileName,
+ const XmlElement & i_rDocument,
+ const Simstr & i_sIDL_BaseDirectory );
+ ~HtmlCreator();
+
+ void Run();
+
+ void StartTable();
+ void FinishTable();
+ void StartBigCell(
+ const char * i_sTitle );
+ void FinishBigCell();
+
+ void Write_SglTextElement(
+ const SglTextElement &
+ i_rElement,
+ bool i_bStrong = false );
+ void Write_MultiTextElement(
+ const MultipleTextElement &
+ i_rElement );
+ void Write_SglText(
+ const Simstr & i_sName,
+ const Simstr & i_sValue );
+ void Write_ReferenceDocu(
+ const Simstr & i_sName,
+ const Simstr & i_sRef,
+ const Simstr & i_sRole,
+ const Simstr & i_sTitle );
+ private:
+ void StartRow();
+ void FinishRow();
+ void StartCell(
+ const char * i_pWidth );
+ void FinishCell();
+
+ void WriteElementName(
+ const Simstr & i_sName,
+ bool i_bStrong );
+ void WriteStr(
+ const char * i_sStr )
+ { aFile.write( i_sStr, (int) strlen(i_sStr) ); }
+ // DATA
+ std::ofstream aFile;
+ const XmlElement & rDocument;
+ Simstr sIdl_BaseDirectory;
+};
+
+
+
+
+#endif
+
+
diff --git a/xml2cmp/source/xcd/cr_index.cxx b/xml2cmp/source/xcd/cr_index.cxx
new file mode 100644
index 000000000000..42721f8b6804
--- /dev/null
+++ b/xml2cmp/source/xcd/cr_index.cxx
@@ -0,0 +1,278 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cr_index.cxx,v $
+ * $Revision: 1.12 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "cr_index.hxx"
+
+#include <string.h>
+#include <fstream>
+#include "../support/syshelp.hxx"
+#include "xmltree.hxx"
+#include "parse.hxx"
+#include "cr_html.hxx"
+
+
+extern unsigned C_nSupportedServicesIndex;
+
+char C_sLineEnd[] = "\n";
+
+char C_sFileBegin[] = "<HTML><HEAD></HEAD><BODY bgcolor=\"#ffffff\">\n";
+char C_sFileEnd[] = "</BODY></HTML>\n";
+char C_sTableBegin[] = "<TABLE WIDTH=100% BORDER=1 CELLPADDING=4 CELLSPACING=0><TBODY>\n";
+char C_sTableEnd[] = "</TBODY></TABLE>\n";
+char C_sService[] = "SupportedService";
+char C_sModule[] = "ModuleName";
+char C_sComponentname[] = "ComponentName";
+
+
+
+Simstr sIdlRootPath;
+
+
+Index::Index( const char * i_sOutputDirectory,
+ const char * i_sIdlRootPath,
+ const List<Simstr> & )
+ : aService2Module(20),
+ aModule2Service(20),
+ sOutputDirectory(i_sOutputDirectory),
+ sIdlRootPath(i_sIdlRootPath)
+ // sCurModule
+{
+ ::sIdlRootPath = i_sIdlRootPath;
+}
+
+Index::~Index()
+{
+}
+
+void
+Index::GatherData( const List<Simstr> & i_rInputFileList )
+{
+ for ( unsigned i = 0; i < i_rInputFileList.size(); ++i )
+ {
+ ReadFile( i_rInputFileList[i].str() );
+ }
+}
+
+void
+Index::WriteOutput( const char * i_sOuputFile )
+{
+ std::ofstream aOut( i_sOuputFile, std::ios::out );
+ if (! aOut)
+ {
+ std::cerr << "Error: Indexfile \""
+ << i_sOuputFile
+ << "\" could not be created."
+ << std::endl;
+ return;
+ }
+
+ WriteStr(aOut, C_sFileBegin);
+
+ WriteStr(aOut, "<H2>Module Descriptions Index</H2>");
+ WriteStr(aOut, C_sLineEnd );
+
+
+ WriteTableFromHeap( aOut, aService2Module, C_sService, C_sModule, lt_html );
+ WriteTableFromHeap( aOut, aModule2Service, C_sModule, C_sService, lt_idl );
+
+ WriteStr( aOut, C_sFileEnd );
+ aOut.close();
+}
+
+void
+Index::InsertSupportedService( const Simstr & i_sService )
+{
+ aService2Module.InsertValue( i_sService, sCurModule );
+ aModule2Service.InsertValue( sCurModule, i_sService );
+}
+
+void
+Index::ReadFile( const char * i_sFilename )
+{
+ static char sOutputHtml[1020];
+
+ ModuleDescription aModule;
+ X2CParser aParser(aModule);
+
+ // Parse
+ bool bResult = aParser.Parse(i_sFilename);
+ if (! bResult)
+ {
+ std::cerr << "Error: File \""
+ << i_sFilename
+ << "\" could not be parsed."
+ << std::endl;
+ return;
+ }
+
+ // Create Html:
+ CreateHtmlFileName( sOutputHtml, aModule );
+ HtmlCreator aHtmlCreator( sOutputHtml, aModule, sIdlRootPath );
+ aHtmlCreator.Run();
+
+ // GetResults:
+ sCurModule = aModule.ModuleName();
+
+ List< const MultipleTextElement* > aSupportedServices;
+ aModule.Get_SupportedServices(aSupportedServices);
+
+ for ( unsigned s = 0; s < aSupportedServices.size(); ++s )
+ {
+ aSupportedServices[s]->Insert2Index(*this);
+ }
+}
+
+void
+Index::CreateHtmlFileName( char * o_sOutputHtml,
+ const ModuleDescription & i_rModule )
+{
+ if ( strlen(sOutputDirectory.str()) + strlen(i_rModule.ModuleName()) > 1000 )
+ {
+ strcpy( o_sOutputHtml, "too-long-filename.html"); // STRCPY SAFE HERE
+ return;
+ }
+
+ strcpy( o_sOutputHtml, sOutputDirectory.str() ); // STRCPY SAFE HERE
+#if defined(WNT) || defined(OS2)
+ strcat(o_sOutputHtml, "\\"); // STRCAT SAFE HERE
+#elif defined(UNX)
+ strcat(o_sOutputHtml, "/"); // STRCAT SAFE HERE
+#else
+#error WNT or UNX have to be defined.
+#endif
+ strcat( o_sOutputHtml, i_rModule.ModuleName() ); // STRCAT SAFE HERE
+ strcat( o_sOutputHtml, ".html" ); // STRCAT SAFE HERE
+}
+
+
+void
+Index::WriteTableFromHeap( std::ostream & o_rOut,
+ Heap & i_rHeap,
+ const char * i_sIndexValue,
+ const char * i_sIndexReference,
+ E_LinkType i_eLinkType )
+{
+ WriteStr(o_rOut, "<H3><BR>");
+ WriteStr(o_rOut, i_sIndexValue );
+ WriteStr(o_rOut, " -> ");
+ WriteStr(o_rOut, i_sIndexReference );
+ WriteStr(o_rOut, "</H3>\n");
+
+ WriteStr(o_rOut, C_sTableBegin);
+ WriteHeap( o_rOut, i_rHeap, i_eLinkType );
+ WriteStr(o_rOut, C_sTableEnd);
+}
+
+
+void
+Index::WriteHeap( std::ostream & o_rOut,
+ Heap & i_rHeap,
+ E_LinkType i_eLinkType )
+{
+ static Simstr S_sKey;
+ static char C_sSpaceInName[] = "&nbsp;&nbsp;&nbsp;";
+ S_sKey = "";
+
+
+ WriteStr( o_rOut, "<TR><TD width=33% valign=\"top\">" );
+
+ for ( HeapItem * pHeapTop = i_rHeap.ReleaseTop();
+ pHeapTop != 0;
+ pHeapTop = i_rHeap.ReleaseTop() )
+ {
+ if ( S_sKey != pHeapTop->Key() )
+ {
+ const char * pStart = pHeapTop->Key().str();
+ const char * pBreak = strstr( pStart, " in ");
+
+ if (S_sKey.l()>0)
+ {
+ WriteStr( o_rOut, "</TD></TR>\n" );
+ WriteStr( o_rOut, "<TR><TD width=33% valign=\"top\">" );
+ }
+
+ if ( pBreak == 0 )
+ WriteStr( o_rOut, pStart );
+ else
+ {
+ o_rOut.write( pStart, pBreak - pStart );
+ WriteStr( o_rOut, C_sSpaceInName );
+ WriteStr( o_rOut, pBreak );
+ }
+ WriteStr( o_rOut, "</TD><TD width=66%>" );
+ S_sKey = pHeapTop->Key();
+ }
+ else
+ {
+ WriteStr( o_rOut, "<BR>" );
+ }
+ WriteName( o_rOut, sIdlRootPath, pHeapTop->Value(), i_eLinkType );
+ delete pHeapTop;
+ }
+
+ WriteStr( o_rOut, "</TD></TR>\n" );
+}
+
+
+
+/** Übersicht der Struktur
+
+MODULEDESCRIPTION
+{
+ ModuleName,
+ COMPONENTDESCRIPTION
+ {
+ Author,
+ Name,
+ Description,
+ LoaderName,
+ Language,
+ Status,
+ SupportedService+,
+ ReferenceDocu*
+ ServiceDependency*
+ Type*
+ }
+ ProjectBuildDependency*
+ RuntimeModuleDependency*
+ ReferenceDocu*
+ ServiceDependency*
+ Type*
+}
+
+
+*/
+
+
+
+
+
+
diff --git a/xml2cmp/source/xcd/cr_index.hxx b/xml2cmp/source/xcd/cr_index.hxx
new file mode 100644
index 000000000000..83d38e6ff21a
--- /dev/null
+++ b/xml2cmp/source/xcd/cr_index.hxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cr_index.hxx,v $
+ * $Revision: 1.7 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef X2C_CR_INDEX_HXX
+#define X2C_CR_INDEX_HXX
+
+#include "../support/sistr.hxx"
+#include "../support/heap.hxx"
+#include "../support/list.hxx"
+#include "../support/syshelp.hxx"
+
+
+class ModuleDescription;
+
+
+class Index
+{
+ public:
+ Index(
+ const char * i_sOutputDirectory,
+ const char * i_sIdlRootPath,
+ const List<Simstr> &
+ i_rTagList );
+ ~Index();
+
+ void GatherData(
+ const List<Simstr> &
+ i_rInputFileList );
+ void WriteOutput(
+ const char * i_sOuputFile );
+
+ void InsertSupportedService(
+ const Simstr & i_sService );
+ private:
+ void ReadFile(
+ const char * i_sFilename );
+ void CreateHtmlFileName(
+ char * o_sOutputHtml,
+ const ModuleDescription &
+ i_rModule );
+ void WriteTableFromHeap(
+ std::ostream & o_rOut,
+ Heap & i_rHeap,
+ const char * i_sIndexKey,
+ const char * i_sIndexReference,
+ E_LinkType i_eLinkType );
+ void WriteHeap(
+ std::ostream & o_rOut,
+ Heap & i_rHeap,
+ E_LinkType i_eLinkType );
+
+ // DATA
+ Heap aService2Module;
+ Heap aModule2Service;
+
+ Simstr sOutputDirectory;
+ Simstr sIdlRootPath;
+
+ // Temporary Data
+ Simstr sCurModule;
+};
+
+
+
+
+#endif
+
+
diff --git a/xml2cmp/source/xcd/cr_metho.cxx b/xml2cmp/source/xcd/cr_metho.cxx
new file mode 100644
index 000000000000..d061b8a296e6
--- /dev/null
+++ b/xml2cmp/source/xcd/cr_metho.cxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cr_metho.cxx,v $
+ * $Revision: 1.10 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "cr_metho.hxx"
+
+#include <string.h>
+#include <fstream>
+#include <iostream>
+
+
+
+const char C_sFileHeader1[]
+ = "/* ";
+const char C_sFileHeader2[]
+ = " */\r\n/* Implementation of component_getDescriptionFunc() */\r\n\r\n"
+ "#include <sal/types.h>\r\n\r\n";
+const char C_sFuncBegin[]
+ = "#ifdef __cplusplus\r\n"
+ "extern \"C\" {\r\n"
+ "#endif\r\n\r\n"
+ "const sal_Char * SAL_CALL\r\ncomponent_getDescriptionFunc()\r\n"
+ "{\r\n"
+ " return (const sal_Char*) \r\n"
+ " \"";
+const char C_sFuncEnd[] = "\";\r\n"
+ "}\r\n\r\n"
+ "#ifdef __cplusplus\r\n"
+ "} /* end of extern \"C\" */\r\n"
+ "#endif\r\n";
+
+
+void
+Create_AccessMethod( const char * i_pOutputFileName,
+ const char * i_sText )
+{
+ const char * pText = i_sText;
+ const char * pTrans = 0;
+ const char sDescrLineChange[] = "\"\r\n \"";
+ int sDescrLen = (int) strlen(sDescrLineChange);
+
+ std::ofstream aFile(i_pOutputFileName, std::ios::out
+#if defined(WNT) || defined(OS2)
+ | std::ios::binary
+#endif
+ );
+
+
+ if ( !aFile )
+ {
+ std::cerr << "Error: " << i_pOutputFileName << " could not be created." << std::endl;
+ return;
+ }
+
+ aFile.write( C_sFileHeader1, (int) strlen(C_sFileHeader1) );
+ aFile.write( i_pOutputFileName, (int) strlen(i_pOutputFileName) );
+ aFile.write( C_sFileHeader2, (int) strlen(C_sFileHeader2) );
+ aFile.write( C_sFuncBegin, (int) strlen(C_sFuncBegin) );
+
+ for ( pTrans = pText; *pTrans != '\0'; pTrans++ )
+ {
+ switch (*pTrans)
+ {
+ case '"': aFile.write( "\\\"", 2);
+ break;
+ case '\n': aFile.write( "\\n", 2);
+ aFile.write( sDescrLineChange, sDescrLen);
+ break;
+ case '\r': aFile.write( "\\r", 2);
+ break;
+// case '\t': aFile.write( "\\t", 2);
+// break;
+ default: aFile.write( pTrans, 1);
+ }
+ } /* end for */
+
+ aFile.write( C_sFuncEnd, (int) strlen(C_sFuncEnd) );
+
+
+ aFile.close();
+}
+
+
diff --git a/xml2cmp/source/xcd/cr_metho.hxx b/xml2cmp/source/xcd/cr_metho.hxx
new file mode 100644
index 000000000000..1c65725fe05e
--- /dev/null
+++ b/xml2cmp/source/xcd/cr_metho.hxx
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cr_metho.hxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CPV_CR_METHOD_H
+#define CPV_CR_METHOD_H
+
+
+
+void Create_AccessMethod(
+ const char * i_pOutputFileName,
+ const char * i_sText );
+
+#endif
diff --git a/xml2cmp/source/xcd/filebuff.cxx b/xml2cmp/source/xcd/filebuff.cxx
new file mode 100644
index 000000000000..8035d697ae4d
--- /dev/null
+++ b/xml2cmp/source/xcd/filebuff.cxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: filebuff.cxx,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "filebuff.hxx"
+
+#include <string.h>
+#include <fstream>
+#include <ctype.h>
+
+
+bool
+LoadXmlFile( Buffer & o_rBuffer,
+ const char * i_sXmlFilePath )
+{
+ std::ifstream aXmlFile;
+
+ aXmlFile.open(i_sXmlFilePath, std::ios::in
+#if defined(WNT) || defined(OS2)
+ | std::ios::binary
+#endif // WNT
+ );
+
+ if (! aXmlFile)
+ return false;
+
+ // Prepare buffer:
+ aXmlFile.seekg(0, std::ios::end);
+ unsigned long nBufferSize = (unsigned long) aXmlFile.tellg();
+ o_rBuffer.SetSize(nBufferSize + 1);
+ o_rBuffer.Data()[nBufferSize] = '\0';
+ aXmlFile.seekg(0);
+
+ // Read file:
+ aXmlFile.read(o_rBuffer.Data(), (int) nBufferSize);
+ bool ret = aXmlFile.good() != 0;
+ aXmlFile.close();
+ return ret;
+}
+
diff --git a/xml2cmp/source/xcd/filebuff.hxx b/xml2cmp/source/xcd/filebuff.hxx
new file mode 100644
index 000000000000..a6b177ae04b1
--- /dev/null
+++ b/xml2cmp/source/xcd/filebuff.hxx
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: filebuff.hxx,v $
+ * $Revision: 1.7 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef X2C_FILEBUFF_HXX
+#define X2C_FILEBUFF_HXX
+
+
+class Buffer
+{
+ public:
+ Buffer() : s(0) {}
+ ~Buffer() { if (s) delete [] s; }
+ operator const char *() const
+ { return s; }
+ char * Data() { return s; }
+ void SetSize(
+ unsigned long i_size )
+ { if (s) delete [] s; s = new char [i_size]; }
+ private:
+ char * s;
+};
+
+
+bool LoadXmlFile(
+ Buffer & o_rBuffer,
+ const char * i_sXmlFilePath );
+
+
+
+#endif
diff --git a/xml2cmp/source/xcd/main.cxx b/xml2cmp/source/xcd/main.cxx
new file mode 100644
index 000000000000..7ff083712204
--- /dev/null
+++ b/xml2cmp/source/xcd/main.cxx
@@ -0,0 +1,329 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: main.cxx,v $
+ * $Revision: 1.12 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <iostream>
+#include <fstream>
+#include <stdio.h>
+
+
+#include <string.h>
+#include "../support/cmdline.hxx"
+#include "cr_metho.hxx"
+#include "cr_html.hxx"
+#include "cr_index.hxx"
+#include "xmlelem.hxx"
+#include "xmltree.hxx"
+#include "parse.hxx"
+#include "../support/syshelp.hxx"
+#include "../support/heap.hxx"
+
+
+
+int Do_IndexCommandLine(
+ const CommandLine & i_rCommandLine );
+int Do_SingleFileCommandLine(
+ const CommandLine & i_rCommandLine );
+void Create_TypeInfo(
+ const char * o_sOutputFile,
+ ModuleDescription & i_rData );
+
+
+int
+#ifdef WNT
+_cdecl
+#endif
+main( int argc,
+ char * argv[] )
+{
+ // Variables
+ CommandLine aCommandLine(argc, argv);
+ int ret = 0;
+
+ if (! aCommandLine.IsOk())
+ {
+ std::cerr << aCommandLine.ErrorText() << std::endl ;
+ return 1;
+ }
+
+ if ( aCommandLine.IsIndexCommand() )
+ ret = Do_IndexCommandLine(aCommandLine);
+ else
+ ret = Do_SingleFileCommandLine(aCommandLine);
+
+ return ret;
+}
+
+
+int
+Do_SingleFileCommandLine(const CommandLine & i_rCommandLine)
+{
+ ModuleDescription aDescr;
+ X2CParser aParser(aDescr);
+
+ // Load file and create Function-file
+ bool bLoadResult = aParser.LoadFile(i_rCommandLine.XmlSrcFile());
+ if (! bLoadResult)
+ {
+ std::cerr << "Error: File %s could not be loaded." << i_rCommandLine.XmlSrcFile() << std::endl;
+ return 1;
+ }
+
+ if ( strlen(i_rCommandLine.FuncFile()) > 0 )
+ {
+ Create_AccessMethod( i_rCommandLine.FuncFile(),
+ aParser.PureText() );
+
+ std::cout << "File "
+ << i_rCommandLine.FuncFile()
+ << " with component_getDescriptionFunc() is created now."
+ << std::endl;
+ }
+
+ // Parse
+ aParser.Parse();
+
+ // Produce output
+ if ( strlen(i_rCommandLine.HtmlFile()) > 0 )
+ {
+ HtmlCreator aHtmlCreator( i_rCommandLine.HtmlFile(),
+ aDescr,
+ i_rCommandLine.IdlRootPath() );
+ aHtmlCreator.Run();
+ }
+
+ if (strlen(i_rCommandLine.TypeInfoFile()) > 0)
+ {
+ Create_TypeInfo( i_rCommandLine.TypeInfoFile(),
+ aDescr );
+ }
+
+ return 0;
+};
+
+int
+Do_IndexCommandLine(const CommandLine & i_rCommandLine)
+{
+ // Parsen files:
+ List<Simstr> aFiles;
+ Index aIndex( i_rCommandLine.OutputDirectory(),
+ i_rCommandLine.IdlRootPath(),
+ i_rCommandLine.IndexedTags() );
+
+ std::cout << "Gather xml-files ..." << std::endl;
+ GatherFileNames( aFiles, i_rCommandLine.XmlSrcDirectory() );
+
+ std::cout << "Create output ..." << std::endl;
+ aIndex.GatherData(aFiles);
+ aIndex.WriteOutput( i_rCommandLine.IndexOutputFile() );
+
+ std::cout << "... done." << std::endl;
+
+ return 0;
+};
+
+
+
+//******************** Creating of typeinfo ********************//
+
+
+void Put2StdOut_TypeInfo(
+ ModuleDescription & i_rData );
+void Put2File_TypeInfo(
+ const char * i_sOutputFile,
+ ModuleDescription & i_rData );
+void StreamOut_TypeInfo(
+ std::ostream & o_rOut,
+ ModuleDescription & i_rData,
+ const char * i_sSeparator );
+
+
+
+
+void
+Create_TypeInfo( const char * o_sOutputFile,
+ ModuleDescription & i_rData )
+{
+ if ( strcmp(o_sOutputFile, "stdout") == 0 )
+ Put2StdOut_TypeInfo(i_rData);
+ else
+ Put2File_TypeInfo(o_sOutputFile,i_rData);
+
+#if 0
+ std::ofstream aOut(o_sOutputFile, std::ios::out
+#if defined(WNT) || defined(OS2)
+ | std::ios::binary
+#endif
+ );
+ if ( !aOut )
+ {
+ std::cerr << "Error: " << o_sOutputFile << " could not be created." << std::endl;
+ return;
+ }
+
+ Heap aTypesHeap(12);
+ Simstr sLibPrefix = i_rData.ModuleName();
+
+ // Gather types:
+ List< const MultipleTextElement * > aTypes;
+ i_rData.Get_Types(aTypes);
+
+ for ( unsigned t = 0; t < aTypes.size(); ++t )
+ {
+ unsigned i_max = aTypes[t]->Size();
+ for ( unsigned i = 0; i < i_max; ++i )
+ {
+ aTypesHeap.InsertValue( aTypes[t]->Data(i), "" );
+ } // end for
+ }
+
+ // Write types:
+ WriteStr( aOut, sLibPrefix );
+ WriteStr( aOut, "_XML2CMPTYPES= ");
+
+ HeapItem * pLastHeapTop = 0;
+ for ( HeapItem * pHeapTop = aTypesHeap.ReleaseTop(); pHeapTop != 0; pHeapTop = aTypesHeap.ReleaseTop() )
+ {
+ if (pLastHeapTop != 0)
+ {
+ if ( 0 == strcmp(pHeapTop->Key(), pLastHeapTop->Key()) )
+ continue;
+ delete pLastHeapTop;
+ // pLastHeapTop = 0;
+ }
+ pLastHeapTop = pHeapTop;
+
+ WriteStr( aOut, "\t\\\n\t\t" );
+
+ const char * sEnd = strchr( pHeapTop->Key(), ' ' );
+ if (sEnd != 0)
+ {
+ const char * sQuali = strrchr( pHeapTop->Key(), ' ' )+1;
+ WriteStr( aOut, sQuali );
+ WriteStr( aOut, "." );
+ aOut.write( pHeapTop->Key(), sEnd - pHeapTop->Key() );
+ }
+ else
+ WriteStr( aOut, pHeapTop->Key() );
+ } // end for
+
+ if (pLastHeapTop != 0)
+ {
+ delete pLastHeapTop;
+ pLastHeapTop = 0;
+ }
+
+ aOut.close();
+#endif // 0
+}
+
+void
+Put2StdOut_TypeInfo( ModuleDescription & i_rData )
+{
+ StreamOut_TypeInfo(std::cout, i_rData, " ");
+}
+
+void
+Put2File_TypeInfo( const char * i_sOutputFile,
+ ModuleDescription & i_rData )
+{
+ std::ofstream aOut(i_sOutputFile, std::ios::out
+#if defined(WNT) || defined(OS2)
+ | std::ios::binary
+#endif
+ );
+ if ( !aOut )
+ {
+ std::cerr << "Error: " << i_sOutputFile << " could not be created." << std::endl;
+ return;
+ }
+
+ Simstr sLibPrefix = i_rData.ModuleName();
+ WriteStr( aOut, sLibPrefix );
+ WriteStr( aOut, "_XML2CMPTYPES= ");
+
+ StreamOut_TypeInfo(aOut, i_rData, "\t\\\n\t\t");
+
+ aOut.close();
+}
+
+void
+StreamOut_TypeInfo( std::ostream & o_rOut,
+ ModuleDescription & i_rData,
+ const char * i_sSeparator )
+{
+ Heap aTypesHeap(12);
+
+ // Gather types:
+ List< const MultipleTextElement * > aTypes;
+ i_rData.Get_Types(aTypes);
+
+ for ( unsigned t = 0; t < aTypes.size(); ++t )
+ {
+ unsigned i_max = aTypes[t]->Size();
+ for ( unsigned i = 0; i < i_max; ++i )
+ {
+ aTypesHeap.InsertValue( aTypes[t]->Data(i), "" );
+ } // end for
+ }
+
+ // Write types:
+ HeapItem * pLastHeapTop = 0;
+ for ( HeapItem * pHeapTop = aTypesHeap.ReleaseTop(); pHeapTop != 0; pHeapTop = aTypesHeap.ReleaseTop() )
+ {
+ if (pLastHeapTop != 0)
+ {
+ if ( 0 == strcmp(pHeapTop->Key(), pLastHeapTop->Key()) )
+ continue;
+ delete pLastHeapTop;
+ // pLastHeapTop = 0;
+ }
+ pLastHeapTop = pHeapTop;
+
+ WriteStr( o_rOut, i_sSeparator );
+
+ const char * sEnd = strchr( pHeapTop->Key(), ' ' );
+ if (sEnd != 0)
+ {
+ const char * sQuali = strrchr( pHeapTop->Key(), ' ' ) + 1;
+ WriteStr( o_rOut, sQuali );
+ WriteStr( o_rOut, "." );
+ o_rOut.write( pHeapTop->Key(), sEnd - pHeapTop->Key() );
+ }
+ else
+ WriteStr( o_rOut, pHeapTop->Key() );
+ } // end for
+
+ if (pLastHeapTop != 0)
+ {
+ delete pLastHeapTop;
+ pLastHeapTop = 0;
+ }
+}
+
diff --git a/xml2cmp/source/xcd/makefile.mk b/xml2cmp/source/xcd/makefile.mk
new file mode 100644
index 000000000000..b97be25b786a
--- /dev/null
+++ b/xml2cmp/source/xcd/makefile.mk
@@ -0,0 +1,83 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.8 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=xml2cmp
+TARGET=x2c_xcd
+TARGETTYPE=CUI
+
+LIBTARGET=NO
+
+
+
+# --- Settings -----------------------------------------------------
+
+ENABLE_EXCEPTIONS=TRUE
+
+.INCLUDE : settings.mk
+
+
+
+# --- Files --------------------------------------------------------
+
+
+LIBONLYFILES=\
+ $(OBJ)$/cr_html.obj \
+ $(OBJ)$/cr_index.obj \
+ $(OBJ)$/cr_metho.obj \
+ $(OBJ)$/filebuff.obj \
+ $(OBJ)$/parse.obj \
+ $(OBJ)$/xmlelem.obj \
+ $(OBJ)$/xmltree.obj
+
+
+OBJFILES=\
+ $(OBJ)$/main.obj \
+ $(LIBONLYFILES)
+
+
+LIB1TARGET=$(LB)$/$(TARGET).lib
+LIB1OBJFILES=\
+ $(OBJFILES)
+
+
+LIB2TARGET=$(LB)$/$(TARGET)l.lib
+LIB2OBJFILES=\
+ $(LIBONLYFILES)
+
+
+
+
+# --- Targets ------------------------------------------------------
+
+
+.INCLUDE : target.mk
diff --git a/xml2cmp/source/xcd/parse.cxx b/xml2cmp/source/xcd/parse.cxx
new file mode 100644
index 000000000000..f4ada7a00c09
--- /dev/null
+++ b/xml2cmp/source/xcd/parse.cxx
@@ -0,0 +1,455 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: parse.cxx,v $
+ * $Revision: 1.12 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include <parse.hxx>
+
+#include <string.h>
+#include <iostream>
+#include <xmlelem.hxx>
+
+#if (_MSC_VER >=1400)
+#pragma warning(disable:4365)
+#endif
+
+#ifdef UNX
+#define strnicmp strncasecmp
+#endif
+
+
+
+// NOT FULLY DEFINED SERVICES
+
+
+
+#define AssertionOf(x) \
+ {if (!(x)) {std::cerr << "Assertion failed: " << #x << __FILE__ << __LINE__ << std::endl; exit(3); }}
+
+
+
+X2CParser::X2CParser( XmlElement & o_rDocumentData )
+ : // sFileName,
+ nFileLine(0),
+ pDocumentData(&o_rDocumentData),
+ // sWord,
+ text(0)
+{
+}
+
+X2CParser::~X2CParser()
+{
+}
+
+
+bool
+X2CParser::LoadFile( const char * i_sFilename )
+{
+ sFileName = i_sFilename;
+ nFileLine = 1;
+
+ // Load file:
+ if ( ! LoadXmlFile( aFile, i_sFilename ) )
+ return false;
+
+ // Test correct end:
+ const char * pLastTag = strrchr(aFile.operator const char *(),'<');
+ if (pLastTag == 0)
+ return false;
+ if ( strnicmp(pLastTag+2, pDocumentData->Name().str(), pDocumentData->Name().l()) != 0
+ || strnicmp(pLastTag, "</", 2) != 0 )
+ return false;
+ if (strchr(pLastTag,'>') == 0)
+ return false;
+ return true;
+}
+
+void
+X2CParser::Parse()
+{
+ // Parse:
+ text = aFile.operator const char *();
+
+ Parse_XmlDeclaration();
+ Parse_Doctype();
+
+ pDocumentData->Parse(*this);
+}
+
+bool
+X2CParser::Parse( const char * i_sFilename )
+{
+ bool ret = LoadFile(i_sFilename);
+ if (ret)
+ Parse();
+ return ret;
+}
+
+void
+X2CParser::Parse_XmlDeclaration()
+{
+ Goto('<');
+ if ( IsText("<?xml") )
+ {
+ Goto_And_Pass('>');
+ }
+}
+
+void
+X2CParser::Parse_Doctype()
+{
+ Goto('<');
+ if ( IsText("<!DOCTYPE") )
+ Goto_And_Pass('>');
+}
+
+void
+X2CParser::Parse_Sequence( DynamicList<XmlElement> & o_rElements,
+ const Simstr & i_sElementName )
+{
+ CheckAndPassBeginTag(i_sElementName.str());
+
+ unsigned int i_max = o_rElements.size();
+ for (unsigned i = 0; i < i_max; ++i)
+ {
+ o_rElements[i]->Parse(*this);
+ } // end for
+
+ CheckAndPassEndTag(i_sElementName.str());
+}
+
+void
+X2CParser::Parse_FreeChoice( DynamicList<XmlElement> & o_rElements )
+{
+ unsigned nSize = o_rElements.size();
+
+ for ( bool bBreak = false; !bBreak; )
+ {
+ bBreak = true;
+ for ( unsigned i = 0; i < nSize; ++i )
+ {
+ Goto('<');
+ if ( IsBeginTag(o_rElements[i]->Name().str()) )
+ {
+ o_rElements[i]->Parse(*this);
+ bBreak = false;
+ break;
+ }
+ } // end for i
+ } // end for !bBreak
+}
+
+void
+X2CParser::Parse_List( ListElement & o_rListElem )
+{
+
+ for ( Goto('<'); IsBeginTag(o_rListElem.Name().str()); Goto('<') )
+ {
+ XmlElement * pNew = o_rListElem.Create_and_Add_NewElement();
+ pNew->Parse(*this);
+ }
+}
+
+void
+X2CParser::Parse_Text( Simstr & o_sText,
+ const Simstr & i_sElementName,
+ bool i_bReverseName )
+{
+
+ if ( ! CheckAndPassBeginTag(i_sElementName.str()) )
+ return;
+
+ // Add new Element
+ GetTextTill( o_sText, '<', i_bReverseName );
+ o_sText.remove_trailing_blanks();
+
+ CheckAndPassEndTag(i_sElementName.str());
+}
+
+void
+X2CParser::Parse_MultipleText( List<Simstr> & o_rTexts,
+ const Simstr & i_sElementName,
+ bool i_bReverseName )
+{
+ for ( Goto('<'); IsBeginTag(i_sElementName.str()); Goto('<') )
+ {
+ Simstr sNew;
+ Parse_Text(sNew, i_sElementName, i_bReverseName);
+ if (sNew.l() > 0)
+ o_rTexts.push_back(sNew);
+ }
+}
+
+void
+X2CParser::Parse_SglAttr( Simstr & o_sAttrValue,
+ const Simstr & i_sElementName,
+ const Simstr & i_sAttrName )
+{
+ Goto('<');
+ if ( !IsBeginTag(i_sElementName.str()) )
+ SyntaxError("unexpected element");
+ Move( i_sElementName.l() + 1 );
+
+ Pass_White();
+ if (*text == '>')
+ SyntaxError("no attribute found, where one was expected");
+ Simstr sAttrName;
+ Get_Attribute(o_sAttrValue, sAttrName);
+ if (sAttrName != i_sAttrName)
+ SyntaxError("unknown attribute found");
+ Pass_White();
+ if (strncmp(text,"/>",2) != 0)
+ SyntaxError("missing \"/>\" at end of empty element");
+ Move(2);
+}
+
+void
+X2CParser::Parse_MultipleAttr( List<Simstr> & o_rAttrValues,
+ const Simstr & i_sElementName,
+ const List<Simstr> & i_rAttrNames )
+{
+ Goto('<');
+ if ( !IsBeginTag(i_sElementName.str()) )
+ SyntaxError("unexpected element");
+ Move( i_sElementName.l() + 1 );
+ Simstr sAttrName;
+ Simstr sAttrValue;
+ unsigned nSize = i_rAttrNames.size();
+ unsigned i;
+
+ for ( Pass_White(); *text != '/'; Pass_White() )
+ {
+
+ Get_Attribute(sAttrValue, sAttrName);
+
+ for ( i = 0; i < nSize; ++i )
+ {
+ if ( i_rAttrNames[i] == sAttrName )
+ {
+ o_rAttrValues[i] = sAttrValue;
+ break;
+ }
+ }
+ if (i == nSize)
+ SyntaxError("unknown attribute found");
+ }
+ Move(2);
+}
+
+
+void
+X2CParser::Get_Attribute( Simstr & o_rAttrValue,
+ Simstr & o_rAttrName )
+{
+ GetTextTill( o_rAttrName, '=');
+
+ while (*(++text) != '"')
+ {
+ if (*text == '\0')
+ SyntaxError("unexpected end of file");
+ }
+
+ ++text;
+ GetTextTill( o_rAttrValue, '"');
+ ++text;
+}
+
+bool
+X2CParser::IsText( const char * i_sComparedText )
+{
+ return strnicmp( text, i_sComparedText, strlen(i_sComparedText) ) == 0;
+}
+
+bool
+X2CParser::IsBeginTag( const char * i_sTagName )
+{
+ return strnicmp( text+1, i_sTagName, strlen(i_sTagName) ) == 0
+ && *text == '<';
+}
+
+bool
+X2CParser::IsEndTag( const char * i_sTagName )
+{
+ return strnicmp( text+2, i_sTagName, strlen(i_sTagName) ) == 0
+ && strnicmp( text, "</", 2 ) == 0;
+}
+
+void
+X2CParser::Goto( char i_cNext )
+{
+ while (*text != i_cNext)
+ {
+ TestCurChar();
+ ++text;
+ }
+}
+
+void
+X2CParser::Goto_And_Pass( char i_cNext )
+{
+ Goto(i_cNext);
+ ++text;
+}
+
+void
+X2CParser::Move( int i_nForward )
+{
+ text += i_nForward;
+}
+
+void
+X2CParser::Pass_White()
+{
+ while (*text <= 32)
+ {
+ TestCurChar();
+ ++text;
+ }
+}
+
+void
+X2CParser::GetTextTill( Simstr & o_rText,
+ char i_cEnd,
+ bool i_bReverseName )
+{
+ char * pResult = &sWord[0];
+ char * pSet;
+
+ for ( pSet = pResult;
+ *text != i_cEnd;
+ ++text )
+ {
+ TestCurChar();
+ *pSet++ = *text;
+ }
+
+ while ( *pResult < 33 && *pResult > 0 )
+ ++pResult;
+ while ( pSet > pResult ? *(pSet-1) < 33 : false )
+ pSet--;
+ *pSet = '\0';
+
+
+ if (i_bReverseName)
+ {
+ const unsigned int nMaxLen = 1000;
+ if (strlen(pResult) < nMaxLen)
+ {
+ char * sBreak = strrchr(pResult,'.');
+ if (sBreak != 0)
+ {
+ static char sScope[nMaxLen+10];
+ static char sName[nMaxLen+10];
+
+ unsigned nScopeLen = sBreak - pResult;
+ strncpy ( sScope, pResult, nScopeLen ); // STRNCPY SAFE HERE
+ sScope[nScopeLen] = '\0';
+ strcpy( sName, sBreak + 1 ); // STRCPY SAFE HERE
+ strcat( sName, " in " ); // STRCAT SAFE HERE
+ strcat( sName, sScope ); // STRCAT SAFE HERE
+
+ o_rText = sName;
+ return;
+ }
+ }
+ } // endif (i_bReverseName)
+
+ o_rText = &sWord[0];
+}
+
+bool
+X2CParser::CheckAndPassBeginTag( const char * i_sElementName )
+{
+ bool ret = true;
+ Goto('<');
+ if ( ! IsBeginTag(i_sElementName) )
+ SyntaxError( "unexpected element");
+ if (IsAbsoluteEmpty())
+ ret = false;
+ Goto_And_Pass('>');
+ if (ret)
+ Pass_White();
+ return ret;
+}
+
+void
+X2CParser::CheckAndPassEndTag( const char * i_sElementName )
+{
+ Pass_White();
+ if ( !IsEndTag(i_sElementName) )
+ SyntaxError("missing or not matching end tag");
+ Goto_And_Pass('>');
+}
+
+bool
+X2CParser::IsAbsoluteEmpty() const
+{
+ const char * pEnd = strchr(text+1, '>');
+ if (pEnd != 0)
+ {
+ if ( *(pEnd-1) == '/' )
+ {
+ const char * pAttr = strchr(text+1, '"');
+ if (pAttr == 0)
+ return true;
+ else if ( (pAttr-text) > (pEnd-text) )
+ return true;
+ }
+ }
+ return false;
+}
+
+void
+X2CParser::SyntaxError( const char * i_sText )
+{
+ std::cerr
+ << "Syntax error "
+ << i_sText
+ << " in file: "
+ << sFileName.str()
+ << " in line "
+ << nFileLine
+ << "."
+ << std::endl;
+
+ exit(3);
+}
+
+void
+X2CParser::TestCurChar()
+{
+// if (*text == '\0')
+// SyntaxError("unexpected end of file");
+// else
+
+ if (*text == '\n')
+ nFileLine++;
+}
+
+
diff --git a/xml2cmp/source/xcd/parse.hxx b/xml2cmp/source/xcd/parse.hxx
new file mode 100644
index 000000000000..79d1fc7951c0
--- /dev/null
+++ b/xml2cmp/source/xcd/parse.hxx
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: parse.hxx,v $
+ * $Revision: 1.7 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef X2C_PARSE_HXX
+#define X2C_PARSE_HXX
+
+
+
+// USED SERVICES
+ // BASE CLASSES
+ // COMPONENTS
+#include "filebuff.hxx"
+#include "../support/sistr.hxx"
+#include "../support/list.hxx"
+ // PARAMETERS
+
+
+class XmlElement;
+class ListElement;
+
+class X2CParser
+{
+ public:
+ typedef XmlElement * (*F_CREATE)(const Simstr &);
+
+ X2CParser(
+ XmlElement & o_rDocumentData );
+ ~X2CParser();
+
+ bool LoadFile(
+ const char * i_sFilename );
+ void Parse();
+ bool Parse(
+ const char * i_sFilename );
+
+
+ const char * PureText() const { return aFile.operator const char*(); }
+
+ void Parse_Sequence(
+ DynamicList<XmlElement> &
+ o_rElements,
+ const Simstr & i_sElementName );
+ void Parse_FreeChoice(
+ DynamicList<XmlElement> &
+ o_rElements );
+ void Parse_List(
+ ListElement & o_rListElem );
+ void Parse_Text(
+ Simstr & o_sText,
+ const Simstr & i_sElementName,
+ bool i_bReverseName );
+ void Parse_MultipleText(
+ List<Simstr> & o_rTexts,
+ const Simstr & i_sElementName,
+ bool i_bReverseName );
+ void Parse_SglAttr(
+ Simstr & o_sAttrValue,
+ const Simstr & i_sElementName,
+ const Simstr & i_sAttrName );
+ void Parse_MultipleAttr(
+ List<Simstr> & o_rAttrValues,
+ const Simstr & i_sElementName,
+ const List<Simstr> &
+ i_rAttrNames );
+
+ private:
+ void Parse_XmlDeclaration();
+ void Parse_Doctype();
+
+ void Get_Attribute(
+ Simstr & o_rAttrValue,
+ Simstr & o_rAttrName );
+ bool IsText(
+ const char * i_sComparedText );
+ bool IsBeginTag(
+ const char * i_sTagName );
+ bool IsEndTag(
+ const char * i_sTagName );
+ void Goto(
+ char i_cNext );
+ void Goto_And_Pass(
+ char i_cNext );
+ void Move(
+ int i_nForward );
+ void Pass_White();
+ void GetTextTill(
+ Simstr & o_rText,
+ char i_cEnd,
+ bool i_bReverseName = false );
+ /// @return false in case of empty tag with no attributes.
+ bool CheckAndPassBeginTag(
+ const char * i_sElementName );
+ void CheckAndPassEndTag(
+ const char * i_sElementName );
+ /// @precond IsBeginTag() == true.
+ bool IsAbsoluteEmpty() const;
+
+
+ void SyntaxError(
+ const char * i_sText );
+ void TestCurChar();
+
+ // DATA
+ Simstr sFileName;
+ unsigned nFileLine;
+
+ Buffer aFile;
+ XmlElement * pDocumentData;
+
+ char sWord[8192];
+ const char * text;
+};
+
+
+
+// IMPLEMENTATION
+
+#endif
+
diff --git a/xml2cmp/source/xcd/xmlelem.cxx b/xml2cmp/source/xcd/xmlelem.cxx
new file mode 100644
index 000000000000..4b642e1d30cc
--- /dev/null
+++ b/xml2cmp/source/xcd/xmlelem.cxx
@@ -0,0 +1,277 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: xmlelem.cxx,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include <xmlelem.hxx>
+
+
+// NOT FULLY DEFINED SERVICES
+#include <parse.hxx>
+#include <cr_html.hxx>
+
+#if OSL_DEBUG_LEVEL == 0
+# ifndef NDEBUG
+# define NDEBUG
+# endif
+#endif
+#include <assert.h>
+
+
+
+XmlElement::XmlElement( const char * i_sName )
+ : sName(i_sName)
+{
+}
+
+void
+XmlElement::Insert2Index( Index & ) const
+{
+ // Default version. Does nothing.
+}
+
+XmlElement *
+MultipleElement::FindChild( const Simstr & i_sChildName )
+{
+ unsigned i_max = aChildren.size();
+ for ( unsigned i = 0; i < i_max; ++i )
+ {
+ if ( aChildren[i]->Name() == i_sChildName )
+ return aChildren[i];
+ }
+
+ return 0;
+}
+
+MultipleElement::~MultipleElement()
+{
+}
+
+MultipleElement::MultipleElement( const char * i_sName )
+ : XmlElement(i_sName)
+{
+}
+
+void
+MultipleElement::AddChild( XmlElement & let_drElement )
+{
+ aChildren.push_back(&let_drElement);
+}
+
+void
+SequenceElement::Parse( X2CParser & io_rParser )
+{
+ io_rParser.Parse_Sequence( Children(), Name() );
+}
+
+void
+SequenceElement::Write2Html( HtmlCreator & io_rHC ) const
+{
+ io_rHC.StartTable();
+
+ Children()[nIndexNameElement]->Write2Html(io_rHC);
+ for ( unsigned i = 0; i < Children().size(); ++i )
+ {
+ if (i != nIndexNameElement)
+ {
+ Children()[i]->Write2Html(io_rHC);
+ }
+ } // end for
+
+ io_rHC.FinishTable();
+}
+
+
+SequenceElement::SequenceElement( const char * i_sName,
+ unsigned i_nIndexNameElement )
+ : MultipleElement(i_sName),
+ nIndexNameElement(i_nIndexNameElement)
+{
+}
+
+FreeChoiceElement::FreeChoiceElement()
+ : MultipleElement("")
+{
+}
+
+void
+FreeChoiceElement::Parse( X2CParser & io_rParser )
+{
+ io_rParser.Parse_FreeChoice(Children());
+}
+
+void
+FreeChoiceElement::Write2Html( HtmlCreator & io_rHC ) const
+{
+ for ( unsigned i = 0; i < Children().size(); ++i )
+ {
+ Children()[i]->Write2Html(io_rHC);
+ } // end for
+}
+
+ListElement::ListElement( const char * i_sElementsName,
+ F_CREATE i_fCreateNewElement )
+ : MultipleElement(i_sElementsName),
+ fCreateNewElement(i_fCreateNewElement)
+{
+}
+
+void
+ListElement::Parse( X2CParser & io_rParser )
+{
+ io_rParser.Parse_List( *this );
+}
+
+void
+ListElement::Write2Html( HtmlCreator & io_rHC ) const
+{
+ for ( unsigned i = 0; i < Children().size(); ++i )
+ {
+ Children()[i]->Write2Html(io_rHC);
+ } // end for
+}
+
+XmlElement *
+ListElement::Create_and_Add_NewElement()
+{
+ assert(fCreateNewElement != 0);
+ XmlElement * pNew = (*fCreateNewElement)(Name());
+ Children().push_back( pNew );
+ return pNew;
+}
+
+TextElement::TextElement( const char * i_sName,
+ E_LinkType i_eLinkType,
+ bool i_bReverseName )
+ : XmlElement(i_sName),
+ eLinkType(i_eLinkType),
+ bReverseName(i_bReverseName)
+{
+}
+
+SglTextElement::SglTextElement( const char * i_sName,
+ E_LinkType i_eLinkType,
+ bool i_bReverseName )
+ : TextElement(i_sName, i_eLinkType, i_bReverseName)
+{
+}
+
+void
+SglTextElement::Parse( X2CParser & io_rParser )
+{
+ io_rParser.Parse_Text(sContent, Name(), IsReversedName());
+}
+
+void
+SglTextElement::Write2Html( HtmlCreator & io_rHC ) const
+{
+ if ( !sContent.is_no_text() )
+ io_rHC.Write_SglTextElement( *this );
+}
+
+MultipleTextElement::MultipleTextElement( const char * i_sName,
+ E_LinkType i_eLinkType,
+ bool i_bReverseName )
+ : TextElement(i_sName, i_eLinkType, i_bReverseName)
+{
+}
+
+void
+MultipleTextElement::Parse( X2CParser & io_rParser )
+{
+ io_rParser.Parse_MultipleText(aContent, Name(), IsReversedName());
+}
+
+void
+MultipleTextElement::Write2Html( HtmlCreator & io_rHC ) const
+{
+ if (Size() > 0)
+ io_rHC.Write_MultiTextElement( *this );
+}
+
+const Simstr &
+MultipleTextElement::Data( unsigned i_nNr ) const
+{
+ static const Simstr sNull_;
+
+ if (aContent.is_valid_index(i_nNr))
+ return aContent[i_nNr];
+ return sNull_;
+}
+
+EmptyElement::EmptyElement( const char * i_sName )
+ : XmlElement(i_sName)
+{
+}
+
+SglAttrElement::SglAttrElement( const char * i_sName,
+ const char * i_sAttrName )
+ : EmptyElement(i_sName),
+ sAttrName(i_sAttrName)
+{
+}
+
+void
+SglAttrElement::Parse( X2CParser & io_rParser )
+{
+ io_rParser.Parse_SglAttr(sAttrValue, Name(), sAttrName);
+}
+
+void
+SglAttrElement::Write2Html( HtmlCreator & io_rHC ) const
+{
+ io_rHC.Write_SglText( Name(), sAttrValue );
+}
+
+MultipleAttrElement::MultipleAttrElement( const char * i_sName,
+ const char ** i_sAttrNames,
+ unsigned i_nSize )
+ : EmptyElement(i_sName)
+{
+ for ( unsigned i = 0; i < i_nSize; ++i )
+ {
+ aAttrNames.push_back(Simstr(i_sAttrNames[i]));
+ aAttrValues.push_back(Simstr(""));
+ }
+}
+
+void
+MultipleAttrElement::Parse( X2CParser & io_rParser )
+{
+ io_rParser.Parse_MultipleAttr(aAttrValues, Name(), aAttrNames);
+}
+
+void
+MultipleAttrElement::Write2Html( HtmlCreator & io_rHC ) const
+{
+ if ( ! aAttrValues[0].is_no_text() )
+ io_rHC.Write_ReferenceDocu( Name(), aAttrValues[0], aAttrValues[1], aAttrValues[2] );
+}
+
+
diff --git a/xml2cmp/source/xcd/xmlelem.hxx b/xml2cmp/source/xcd/xmlelem.hxx
new file mode 100644
index 000000000000..16df659cf0cf
--- /dev/null
+++ b/xml2cmp/source/xcd/xmlelem.hxx
@@ -0,0 +1,244 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: xmlelem.hxx,v $
+ * $Revision: 1.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef X2C_XMLELEM_HXX
+#define X2C_XMLELEM_HXX
+
+
+
+// USED SERVICES
+ // BASE CLASSES
+ // COMPONENTS
+#include "../support/sistr.hxx"
+#include "../support/list.hxx"
+#include "../support/syshelp.hxx"
+ // PARAMETERS
+
+
+class X2CParser;
+class HtmlCreator;
+class Index;
+
+class XmlElement
+{
+ public:
+ virtual ~XmlElement() {}
+ virtual void Parse(
+ X2CParser & io_rParser ) = 0;
+ virtual void Write2Html(
+ HtmlCreator & io_rHC ) const = 0;
+ virtual void Insert2Index(
+ Index & o_rIndex ) const; // Default: Does nothing, but can be overwritten.
+
+// virtual void Put2Dependy() = 0;
+
+ const Simstr & Name() const { return sName; }
+
+ protected:
+ XmlElement(
+ const char * i_sName );
+ private:
+ Simstr sName;
+};
+
+
+class MultipleElement : public XmlElement
+{
+ public:
+ ~MultipleElement();
+
+ virtual XmlElement *
+ FindChild(
+ const Simstr & i_sChildName );
+
+
+ protected:
+ typedef DynamicList<XmlElement> ChildList;
+
+ MultipleElement(
+ const char * i_sName );
+
+ void AddChild(
+ XmlElement & let_drElement );
+
+ const ChildList & Children() const { return aChildren; }
+ ChildList & Children() { return aChildren; }
+
+ private:
+ ChildList aChildren;
+};
+
+class SequenceElement : public MultipleElement
+{
+ public:
+ virtual void Parse(
+ X2CParser & io_rParser );
+ virtual void Write2Html(
+ HtmlCreator & io_rHC ) const;
+
+ protected:
+ SequenceElement(
+ const char * i_sName,
+ unsigned i_nIndexNameElement = 0 );
+ private:
+ unsigned nIndexNameElement;
+};
+
+class FreeChoiceElement : public MultipleElement
+{
+ public:
+ FreeChoiceElement();
+ using MultipleElement::AddChild;
+
+ virtual void Parse(
+ X2CParser & io_rParser );
+ virtual void Write2Html(
+ HtmlCreator & io_rHC ) const;
+};
+
+class ListElement : public MultipleElement
+{
+ public:
+ typedef XmlElement * (*F_CREATE)(const Simstr &);
+
+ ListElement(
+ const char * i_sElementsName,
+ F_CREATE i_fCreateNewElement );
+
+ virtual void Parse(
+ X2CParser & io_rParser );
+ virtual void Write2Html(
+ HtmlCreator & io_rHC ) const;
+ virtual XmlElement *
+ Create_and_Add_NewElement();
+ private:
+ F_CREATE fCreateNewElement;
+};
+
+class TextElement : public XmlElement
+{
+ public:
+ E_LinkType LinkType() const { return eLinkType; }
+ bool IsReversedName() const { return bReverseName; }
+ protected:
+ TextElement(
+ const char * i_sName,
+ E_LinkType i_eLinkType,
+ bool i_bReverseName );
+ private:
+ E_LinkType eLinkType;
+ bool bReverseName;
+};
+
+class SglTextElement : public TextElement
+{
+ public:
+ SglTextElement(
+ const char * i_sName,
+ E_LinkType i_eLinkType,
+ bool i_bReverseName );
+
+ virtual void Parse(
+ X2CParser & io_rParser );
+ virtual void Write2Html(
+ HtmlCreator & io_rHC ) const;
+ virtual const Simstr &
+ Data() const { return sContent; }
+ private:
+ Simstr sContent;
+};
+
+class MultipleTextElement : public TextElement
+{
+ public:
+ MultipleTextElement(
+ const char * i_sName,
+ E_LinkType i_eLinkType,
+ bool i_bReverseName );
+
+ virtual void Parse(
+ X2CParser & io_rParser );
+ virtual void Write2Html(
+ HtmlCreator & io_rHC ) const;
+ virtual const Simstr &
+ Data(
+ unsigned i_nNr ) const;
+ virtual unsigned Size() const { return aContent.size(); }
+
+ private:
+ List<Simstr> aContent;
+};
+
+class EmptyElement : public XmlElement
+{
+ protected:
+ EmptyElement(
+ const char * i_sName );
+};
+
+class SglAttrElement : public EmptyElement
+{
+ public:
+ SglAttrElement(
+ const char * i_sName,
+ const char * i_sAttrName );
+
+ virtual void Parse(
+ X2CParser & io_rParser );
+ virtual void Write2Html(
+ HtmlCreator & io_rHC ) const;
+ private:
+ Simstr sAttrName;
+ Simstr sAttrValue;
+};
+
+
+class MultipleAttrElement : public EmptyElement
+{
+ public:
+ MultipleAttrElement(
+ const char * i_sName,
+ const char ** i_sAttrNames,
+ unsigned i_nSize );
+
+ virtual void Parse(
+ X2CParser & io_rParser );
+ virtual void Write2Html(
+ HtmlCreator & io_rHC ) const;
+ private:
+ List<Simstr> aAttrNames;
+ List<Simstr> aAttrValues;
+};
+
+// IMPLEMENTATION
+
+
+#endif
+
diff --git a/xml2cmp/source/xcd/xmltree.cxx b/xml2cmp/source/xcd/xmltree.cxx
new file mode 100644
index 000000000000..01798806f1db
--- /dev/null
+++ b/xml2cmp/source/xcd/xmltree.cxx
@@ -0,0 +1,289 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: xmltree.cxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include <xmltree.hxx>
+
+
+// NOT FULLY DEFINED SERVICES
+#include <cr_html.hxx>
+#include <cr_index.hxx>
+
+
+char C_sMODULEDESCRIPTION[] = "module-description";
+char C_sCOMPONENTDESCRIPTION[] = "component-description";
+char C_sAuthor[] = "author";
+char C_sName[] = "name";
+char C_sDescription[] = "description";
+char C_sReferenceDocu[] = "reference-docu";
+char C_sModuleName[] = "module-name";
+char C_sLoaderName[] = "loader-name";
+char C_sSupportedService[] = "supported-service";
+char C_sServiceDependency[] = "service-dependency";
+char C_sProjectBuildDependency[] = "project-build-dependency";
+char C_sRuntimeModuleDependency[] = "runtime-module-dependency";
+char C_sLanguage[] = "language";
+char C_sStatus[] = "status";
+char C_sType[] = "type";
+char C_sAttr_value[] = "value";
+char C_sAttr_xl_href[] = "xlink:href";
+char C_sAttr_xl_role[] = "xlink:role";
+char C_sAttr_xl_title[] = "xlink:title";
+char C_sAttr_xmlns[] = "xmlns:xlink";
+char C_sAttr_xl_type[] = "xlink:type";
+char C_sCompDescrListTitle[] = "Component Descriptions";
+
+
+FreeChoiceElement * Create_ModuleDescrOptional_Element(
+ MultipleTextElement * &
+ o_rTypes,
+ MultipleTextElement * &
+ o_rServiceDependencies );
+FreeChoiceElement * Create_CompDescrOptional_Element(
+ MultipleTextElement * &
+ o_rTypes,
+ MultipleTextElement * &
+ o_rServiceDependencies );
+
+
+
+ModuleDescription::ModuleDescription()
+ : SequenceElement(C_sMODULEDESCRIPTION),
+ pModuleName(0),
+ pCdList(0),
+ pTypes(0),
+ pServiceDependencies(0)
+{
+ pModuleName = new MdName;
+ AddChild( *pModuleName );
+ pCdList = new CompDescrList;
+ AddChild( *pCdList );
+ AddChild( *Create_ModuleDescrOptional_Element( pTypes, pServiceDependencies ) );
+}
+
+const Simstr &
+ModuleDescription::ModuleName() const
+{
+ return pModuleName->Data();
+}
+
+void
+ModuleDescription::Get_SupportedServices( List< const MultipleTextElement * > & o_rServices ) const
+{
+ o_rServices.push_back(pServiceDependencies);
+ pCdList->Get_SupportedServices( o_rServices );
+}
+
+void
+ModuleDescription::Get_Types( List< const MultipleTextElement * > & o_rTypes ) const
+{
+ o_rTypes.push_back(pTypes);
+ pCdList->Get_Types( o_rTypes );
+}
+
+void
+ModuleDescription::Get_ServiceDependencies( List< const MultipleTextElement * > & o_rServices ) const
+{
+ pCdList->Get_ServiceDependencies( o_rServices );
+}
+
+ComponentDescription::ComponentDescription()
+ : SequenceElement(C_sCOMPONENTDESCRIPTION,1),
+ pComponentName(0),
+ pSupportedServices(0),
+ pTypes(0),
+ pServiceDependencies(0)
+{
+ AddChild( *new SglTextElement(C_sAuthor, lt_nolink, false) );
+ pComponentName = new CdName;
+ AddChild( *pComponentName );
+ AddChild( *new SglTextElement(C_sDescription, lt_nolink, false) );
+ AddChild( *new SglTextElement(C_sLoaderName, lt_idl, true) );
+ AddChild( *new SglTextElement(C_sLanguage, lt_nolink, false) );
+ AddChild( *new SglAttrElement(C_sStatus, C_sAttr_value) );
+ pSupportedServices = new SupportedService;
+ AddChild( *pSupportedServices );
+ AddChild( *Create_CompDescrOptional_Element( pTypes, pServiceDependencies ) );
+}
+
+CompDescrList::CompDescrList()
+ : ListElement(C_sCOMPONENTDESCRIPTION, 0)
+{
+}
+
+void
+CompDescrList::Write2Html( HtmlCreator & io_rHC ) const
+{
+ io_rHC.StartBigCell(C_sCompDescrListTitle);
+ ListElement::Write2Html(io_rHC);
+ io_rHC.FinishBigCell();
+}
+
+XmlElement *
+CompDescrList::Create_and_Add_NewElement()
+{
+ ComponentDescription * pCD = new ComponentDescription;
+ Children().push_back(pCD);
+ aCDs.push_back(pCD);
+ return pCD;
+}
+
+void
+CompDescrList::Get_SupportedServices( List< const MultipleTextElement * > & o_rResult ) const
+{
+ unsigned i_max = aCDs.size();;
+ for (unsigned i = 0; i < i_max; ++i)
+ {
+ o_rResult.push_back(& aCDs[i]->SupportedServices());
+ } // end for
+}
+
+void
+CompDescrList::Get_Types( List< const MultipleTextElement * > & o_rResult ) const
+{
+ unsigned i_max = aCDs.size();;
+ for (unsigned i = 0; i < i_max; ++i)
+ {
+ o_rResult.push_back(& aCDs[i]->Types());
+ } // end for
+}
+
+void
+CompDescrList::Get_ServiceDependencies( List< const MultipleTextElement * > & o_rResult ) const
+{
+ unsigned i_max = aCDs.size();;
+ for (unsigned i = 0; i < i_max; ++i)
+ {
+ o_rResult.push_back(& aCDs[i]->ServiceDependencies());
+ } // end for
+}
+
+MdName::MdName()
+ : SglTextElement(C_sModuleName, lt_html, false)
+{
+}
+
+void
+MdName::Write2Html( HtmlCreator & io_rHC ) const
+{
+ io_rHC.Write_SglTextElement( *this, true );
+}
+
+CdName::CdName()
+ : SglTextElement(C_sName, lt_html, true)
+{
+}
+
+void
+CdName::Write2Html( HtmlCreator & io_rHC ) const
+{
+ io_rHC.Write_SglTextElement( *this, true );
+}
+
+SupportedService::SupportedService()
+ : MultipleTextElement(C_sSupportedService, lt_idl, true)
+{
+}
+
+void
+SupportedService::Insert2Index( Index & o_rIndex ) const
+{
+ for ( unsigned i = 0; i < Size(); ++i )
+ {
+ o_rIndex.InsertSupportedService( Data(i) );
+ }
+}
+
+FreeChoiceElement *
+Create_ModuleDescrOptional_Element( MultipleTextElement * & o_rTypes,
+ MultipleTextElement * & o_rServiceDependencies )
+{
+ FreeChoiceElement * ret = Create_CompDescrOptional_Element( o_rTypes, o_rServiceDependencies );
+
+ ret->AddChild( *new MultipleTextElement(C_sProjectBuildDependency, lt_nolink, false) );
+ ret->AddChild( *new MultipleTextElement(C_sRuntimeModuleDependency, lt_nolink, false) );
+ return ret;
+}
+
+FreeChoiceElement *
+Create_CompDescrOptional_Element( MultipleTextElement * & o_rTypes,
+ MultipleTextElement * & o_rServiceDependencies )
+{
+ FreeChoiceElement * ret = new FreeChoiceElement;
+ const unsigned C_sRefDocuAttrNumber = 5;
+ static const char * C_sRefDocuAttrNames[C_sRefDocuAttrNumber]
+ = { C_sAttr_xl_href, C_sAttr_xl_role, C_sAttr_xl_title, C_sAttr_xmlns, C_sAttr_xl_type };
+
+ ret->AddChild( *new MultipleAttrElement(C_sReferenceDocu, C_sRefDocuAttrNames, C_sRefDocuAttrNumber) );
+ o_rServiceDependencies = new MultipleTextElement(C_sServiceDependency, lt_idl, true);
+ ret->AddChild( *o_rServiceDependencies );
+ o_rTypes = new MultipleTextElement(C_sType, lt_idl, true);
+ ret->AddChild( *o_rTypes );
+ return ret;
+}
+
+
+#if 0
+
+const TextElement *
+ModuleDescription::ServiceDependencies() const
+{
+ const unsigned nEarliestPossibleServiceDependenciesIndexInModules = 1;
+
+ for ( unsigned i = nEarliestPossibleServiceDependenciesIndexInModules;
+ i < Children().size();
+ ++i )
+ {
+ if ( strcmp(Children()[i]->Name(), C_sServiceDependency) == 0 )
+ return Children()[i];
+ }
+ return 0;
+}
+
+const TextElement &
+ComponentDescription::SupportedServices() const
+{
+ return *Children()[C_nSupportedServicesIndex];
+}
+
+const TextElement *
+ComponentDescription::ServiceDependencies() const
+{
+ for ( unsigned i = C_nEarliestPossibleServiceDependenciesIndex; i < Children().size(); ++i )
+ {
+ if ( strcmp(Children()[i]->Name(),C_sServiceDependency) == 0)
+ return Children()[i];
+ }
+ return 0;
+}
+
+#endif
+
+
diff --git a/xml2cmp/source/xcd/xmltree.hxx b/xml2cmp/source/xcd/xmltree.hxx
new file mode 100644
index 000000000000..ccbcf3714d04
--- /dev/null
+++ b/xml2cmp/source/xcd/xmltree.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: xmltree.hxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef X2C_XMLTREE_HXX
+#define X2C_XMLTREE_HXX
+
+
+
+// USED SERVICES
+ // BASE CLASSES
+#include "xmlelem.hxx"
+ // COMPONENTS
+#include "../support/sistr.hxx"
+#include "../support/list.hxx"
+ // PARAMETERS
+
+
+class CompDescrList;
+
+class ModuleDescription : public SequenceElement
+{
+ public:
+ ModuleDescription();
+
+ const Simstr & ModuleName() const;
+ void Get_SupportedServices( /// @return also the children of component-description.
+ List< const MultipleTextElement * > &
+ o_rServices ) const;
+ void Get_Types(
+ List< const MultipleTextElement * > &
+ o_rTypes ) const;
+ void Get_ServiceDependencies(
+ List< const MultipleTextElement * > &
+ o_rServices ) const;
+ private:
+ SglTextElement * pModuleName;
+ CompDescrList * pCdList;
+ MultipleTextElement *
+ pTypes;
+ MultipleTextElement *
+ pServiceDependencies;
+};
+
+
+class ComponentDescription : public SequenceElement
+{
+ public:
+ ComponentDescription();
+
+ const Simstr & ComponentName() const { return pComponentName->Data(); }
+ const MultipleTextElement &
+ SupportedServices() const
+ { return *pSupportedServices; }
+ const MultipleTextElement &
+ Types() const { return *pTypes; }
+ const MultipleTextElement &
+ ServiceDependencies() const
+ { return *pServiceDependencies; }
+ private:
+ SglTextElement * pComponentName;
+ MultipleTextElement *
+ pSupportedServices;
+ MultipleTextElement *
+ pTypes;
+ MultipleTextElement *
+ pServiceDependencies;
+};
+
+class CompDescrList : public ListElement
+{
+ public:
+ CompDescrList();
+ virtual void Write2Html(
+ HtmlCreator & io_rHC ) const;
+ virtual XmlElement *
+ Create_and_Add_NewElement();
+
+ void Get_SupportedServices(
+ List< const MultipleTextElement * > &
+ o_rResult ) const;
+ void Get_Types(
+ List< const MultipleTextElement * > &
+ o_rResult ) const;
+ void Get_ServiceDependencies(
+ List< const MultipleTextElement * > &
+ o_rResult ) const;
+ private:
+ List< ComponentDescription * >
+ aCDs;
+};
+
+class MdName : public SglTextElement
+{
+ public:
+ MdName();
+ virtual void Write2Html(
+ HtmlCreator & io_rHC ) const;
+};
+
+class CdName : public SglTextElement
+{
+ public:
+ CdName();
+ virtual void Write2Html(
+ HtmlCreator & io_rHC ) const;
+};
+
+class SupportedService : public MultipleTextElement
+{
+ public:
+ SupportedService();
+
+ virtual void Insert2Index(
+ Index & o_rIndex ) const;
+};
+
+
+// IMPLEMENTATION
+
+
+#endif
+