diff options
Diffstat (limited to 'udm/source')
-rw-r--r-- | udm/source/html/htmlitem.cxx | 243 | ||||
-rw-r--r-- | udm/source/html/makefile.mk | 56 | ||||
-rw-r--r-- | udm/source/inc/precomp.h | 66 | ||||
-rw-r--r-- | udm/source/mkinc/fullcpp.mk | 60 | ||||
-rw-r--r-- | udm/source/unittest/makefile.mk | 77 | ||||
-rw-r--r-- | udm/source/unittest/test.cxx | 112 | ||||
-rw-r--r-- | udm/source/xml/makefile.mk | 56 | ||||
-rw-r--r-- | udm/source/xml/xmlitem.cxx | 614 |
8 files changed, 1284 insertions, 0 deletions
diff --git a/udm/source/html/htmlitem.cxx b/udm/source/html/htmlitem.cxx new file mode 100644 index 000000000000..bf548a7fa6df --- /dev/null +++ b/udm/source/html/htmlitem.cxx @@ -0,0 +1,243 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <precomp.h> +#include <udm/html/htmlitem.hxx> + +// NOT FULLY DECLARED SERVICES + + +namespace csi +{ +namespace html +{ + +using namespace csi::xml; + +template <class ELEM> +inline ELEM & +PushElem( Element & i_rMain, + DYN ELEM * let_dpSub, + DYN Item * let_dpItem ) +{ + i_rMain << let_dpSub; + if ( let_dpItem != 0 ) + *let_dpSub << let_dpItem; + return *let_dpSub; +} + + +bool +Body::LineBreakAfterBeginTag() const +{ + return true; +} + +#ifndef COMPATIBLE_NETSCAPE_47 +bool +HorizontalLine::LineBreakAfterBeginTag() const +{ + return true; +} +#endif + + +Image::Image( const String & i_sSrc, + const String & i_sWidth, + const String & i_sHeight, + const String & i_sAlign, + const String & i_sBorder ) + : AnEmptyElement( "img" ) +{ + *this << new AnAttribute(String("src"),i_sSrc) + << new AnAttribute(String("width"),i_sWidth) + << new AnAttribute(String("height"),i_sHeight) + << new AnAttribute(String("align"),i_sAlign) + << new AnAttribute(String("border"),i_sBorder); +} + +bool +Paragraph::LineBreakAfterEndTag() const +{ + return true; +} + +const char * +Headline::sTags[6] = { "h1", "h2", "h3", "h4", "h5", "h6" }; + +bool +Headline::LineBreakAfterEndTag() const +{ + return true; +} + +#ifndef COMPATIBLE_NETSCAPE_47 +bool +LineBreak::LineBreakAfterBeginTag() const +{ + return true; +} +#endif + + +bool +TableCell::LineBreakAfterEndTag() const +{ + return true; +} + + + +TableCell & +TableRow::AddCell( DYN Item * let_dpItem ) +{ + return PushElem( *this, new TableCell, let_dpItem ); +} + +bool +TableRow::LineBreakAfterBeginTag() const +{ + return true; +} + + +Table::Table( const String & i_sBorder, + const String & i_sWidth, + const String & i_sCellPadding, + const String & i_sCellSpacing ) + : csi::xml::AnElement("table") +{ + if ( i_sBorder.length() > 0 ) + *this << new AnAttribute(String("border"),i_sBorder); + if ( i_sBorder.length() > 0 ) + *this << new AnAttribute(String("width"),i_sWidth); + if ( i_sBorder.length() > 0 ) + *this << new AnAttribute(String("cellpadding"),i_sCellPadding); + if ( i_sBorder.length() > 0 ) + *this << new AnAttribute(String("cellspacing"),i_sCellSpacing); +} + +TableRow & +Table::AddRow() +{ + TableRow * ret = new TableRow; + *this << ret; + return *ret; +} + +bool +Table::FinishEmptyTag_XmlStyle() const +{ + return false; +} + +bool +Table::LineBreakAfterBeginTag() const +{ + return true; +} + + + +bool +DefListTerm::LineBreakAfterEndTag() const +{ + return true; +} + +bool +DefListDefinition::LineBreakAfterEndTag() const +{ + return true; +} + + + + + +DefListTerm & +DefList::AddTerm( DYN csi::xml::Item* let_dpItem ) +{ + return PushElem( *this, new DefListTerm, let_dpItem ); +} + +DefListDefinition & +DefList::AddDefinition( DYN csi::xml::Item* let_dpItem ) +{ + return PushElem( *this, new DefListDefinition, let_dpItem ); +} + +bool +DefList::LineBreakAfterBeginTag() const +{ + return true; +} + +bool +DefList::FinishEmptyTag_XmlStyle() const +{ + return false; +} + +bool +ListItem::LineBreakAfterEndTag() const +{ + return true; +} + + + + +ListItem & +NumeratedList::AddItem( DYN csi::xml::Item* let_dpItem ) +{ + return PushElem( *this, new ListItem, let_dpItem ); +} + +bool +NumeratedList::LineBreakAfterBeginTag() const +{ + return true; +} + + +ListItem & +SimpleList::AddItem( DYN csi::xml::Item* let_dpItem ) +{ + return PushElem( *this, new ListItem, let_dpItem ); +} + +bool +SimpleList::LineBreakAfterBeginTag() const +{ + return true; +} + + + +} // namespace html +} // namespace csi diff --git a/udm/source/html/makefile.mk b/udm/source/html/makefile.mk new file mode 100644 index 000000000000..73eba36da9a3 --- /dev/null +++ b/udm/source/html/makefile.mk @@ -0,0 +1,56 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# 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=udm +TARGET=csi_html + + +# --- Settings ----------------------------------------------------- + +ENABLE_EXCEPTIONS=true + + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/source$/mkinc$/fullcpp.mk + + +# --- Files -------------------------------------------------------- + +OBJFILES= \ + $(OBJ)$/htmlitem.obj + + + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + + diff --git a/udm/source/inc/precomp.h b/udm/source/inc/precomp.h new file mode 100644 index 000000000000..e5d1c5e40c33 --- /dev/null +++ b/udm/source/inc/precomp.h @@ -0,0 +1,66 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 UDM_PRECOMP_H +#define UDM_PRECOMP_H + +// For en/disabling csv_assertions: +#ifndef DEBUG +#define CSV_NO_ASSERTIONS +#endif + + +#include <cosv/csv_precomp.h> +#include <vector> +#include <map> + + + +// Shortcuts to access csv::-types: +using csv::String; +using csv::StringVector; +using csv::StreamStr; +using csv::c_str; +typedef csv::StreamStrLock StreamLock; + + + +inline std::ostream & +Cout() { return std::cout; } + +inline std::ostream & +Cerr() { return std::cerr; } + + +inline csv::F_FLUSHING_FUNC +Endl() { return csv::Endl; } +inline csv::F_FLUSHING_FUNC +Flush() { return csv::Flush; } + + + + +#endif diff --git a/udm/source/mkinc/fullcpp.mk b/udm/source/mkinc/fullcpp.mk new file mode 100644 index 000000000000..3452d4bcd43a --- /dev/null +++ b/udm/source/mkinc/fullcpp.mk @@ -0,0 +1,60 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# 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. +# +#************************************************************************* + + + +# --- Settings ----------------------------------------------------- +# Has to be included AFTER settings.mk ! + + +# Precompiled header: + + +.IF "$(GUI)"=="WNT" + +# RTTI +CFLAGS+= -GR + +.IF "$(NP_LOCALBUILD)"!="" + + +# Precompiled Headers +PCH_NAME= udm +.IF "$(DBG_LEVEL)"<"2" +CFLAGS+= -YX"precomp.h" /Fp$(PRJ)$/$(INPATH)$/misc$/$(PCH_NAME).pch +.ELSE +CFLAGS+= -YX"precomp.h" /Fp$(PRJ)$/$(INPATH)$/misc$/$(PCH_NAME).pcd -DNP_LOCALBUILD +.ENDIF + +.ENDIF + +.ENDIF + +.IF "$(OS)"=="LINUX" || "$(OS)"=="FREEBSD" || "$(OS)"=="NETBSD" +CFLAGSCXX+= -frtti +.ENDIF + diff --git a/udm/source/unittest/makefile.mk b/udm/source/unittest/makefile.mk new file mode 100644 index 000000000000..deba241f03bd --- /dev/null +++ b/udm/source/unittest/makefile.mk @@ -0,0 +1,77 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# 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=cosv +TARGET=udm_unittest +TARGETTYPE=CUI + +# --- Settings ----------------------------------------------------- + +ENABLE_EXCEPTIONS=true +PRJINC=$(PRJ)$/source + +.INCLUDE : settings.mk +.INCLUDE : static.mk + +.INCLUDE : $(PRJ)$/source$/mkinc$/fullcpp.mk + + + + +# --- Files -------------------------------------------------------- + +OBJFILES= \ + $(OBJ)$/test.obj + + + + +APP1TARGET= $(TARGET) +APP1STACK= 1000000 +APP1OBJS= $(OBJ)$/test.obj + +.IF "$(COMEX)"=="10" +APP1STDLIBS= $(STATIC_LIBS) cosv.lib +.ELSE +APP1STDLIBS= $(STATIC_LIBS) msvcirt.lib cosv.lib +.ENDIF + + +APP1LIBS= $(LB)$/$(TARGET).lib + + +APP1DEPN= $(LB)$/$(TARGET).lib $(L)$/cosv.lib + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + + diff --git a/udm/source/unittest/test.cxx b/udm/source/unittest/test.cxx new file mode 100644 index 000000000000..b39ab6ea7004 --- /dev/null +++ b/udm/source/unittest/test.cxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <precomp.h> + + +// NOT FULLY DEFINED SERVICES +#include <udm/integer_i.hxx> +#include <udm/string_i.hxx> + +using namespace udm; + +// TypeSystem aTypeSys; + + +class Function +{ + public: + + intt nId; +}; + +class Ctor : public Function +{ + public: + + csv::String sClassName; +}; + +class Method : public Function +{ + public: + + csv::String sFunctionName; + std::vector< std::pair< intt, String > > + aParameters; +}; + + +class PrObj +{ + public: + intt nId; + csv::String sName; + std::vector< PrObj* > + aMethods; + std::vector< PrObj* > + aData; +}; + + + + +void fx() +{ + intt n = 5; + Dyn<Integer_i> px = new Integer_i(n); + Integer & x = *px; + + csv::String s; + Dyn<String_i> ps = new String_i(s); + String & xs = *ps; + + xs = "Hallo"; + + int dev01 = 2; + + xs = csv::String("Haha"); + + dev01 = 2; + + csv::String s2 = xs; + + + dev01 = 2; + +// const char * pc = xs; + + + intt a = x; + x = 15; + + Cout() << a << " " << x << Endl(); // Must be: 5 15 +} + + + + diff --git a/udm/source/xml/makefile.mk b/udm/source/xml/makefile.mk new file mode 100644 index 000000000000..a90d71be0649 --- /dev/null +++ b/udm/source/xml/makefile.mk @@ -0,0 +1,56 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# 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=udm +TARGET=csi_xml + + +# --- Settings ----------------------------------------------------- + +ENABLE_EXCEPTIONS=true + + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/source$/mkinc$/fullcpp.mk + + +# --- Files -------------------------------------------------------- + +OBJFILES= \ + $(OBJ)$/xmlitem.obj + + + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + + diff --git a/udm/source/xml/xmlitem.cxx b/udm/source/xml/xmlitem.cxx new file mode 100644 index 000000000000..382106113980 --- /dev/null +++ b/udm/source/xml/xmlitem.cxx @@ -0,0 +1,614 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <precomp.h> +#include <udm/xml/xmlitem.hxx> + +// NOT FULLY DECLARED SERVICES +#include <cosv/file.hxx> + + +namespace csi +{ +namespace xml +{ + +char cReplacable[256] = + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 49 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, // ", & + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 50 - 99 + 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, // <, > + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 100 - 149 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 1 // + }; + + +class MultiItem : public Item +{ + public: + MultiItem(); + ~MultiItem(); + + void Add( + DYN Item * let_dpDatum ) + { csv_assert( let_dpDatum != 0 ); + aItems.push_back(let_dpDatum); } + void Erase() { aItems.erase_all(); } + + private: + virtual void do_WriteOut( + csv::bostream & io_aFile ) const; + // DATA + ItemList aItems; +}; + + +void StreamOut( + Dyn< Item > & o_rContent, + DYN Item * let_dpItem ); +inline void +StreamOut( AttrList & o_rAttrs, + DYN Attribute * let_dpAttr ) +{ + csv_assert( let_dpAttr != 0 ); + o_rAttrs.push_back( let_dpAttr ); +} + + +inline void +Impl_SetContent( Dyn< Item > & o_rContent, + DYN Item * let_dpItem ) +{ + o_rContent = let_dpItem; +} + + +//********************* Attribute ****************************// + +const String attrValueBegin("=\""); +const String attrValueEnd("\""); + +void +Attribute::WriteOut( csv::bostream & io_aFile ) const +{ + io_aFile.write( Name() ); + if ( Value().length() > 0 ) + { + io_aFile.write( attrValueBegin ); + io_aFile.write( Value() ); + io_aFile.write( attrValueEnd ); + } +} + + + +//************************ Element ****************************// + +const String newline("\n"); +const String space(" "); +const String beginTagBegin("<"); +const String endTagBegin("</"); +const String tagEnd(">"); +const String emptyTagEnd("/>"); + +void +Element::do_WriteOut( csv::bostream & io_aFile ) const +{ + io_aFile.write( beginTagBegin ); + io_aFile.write( inq_TagName() ); + + const AttrList * pAttrs = inq_Attrs(); + if ( pAttrs != 0 ) + { + for ( AttrList::iterator it = pAttrs->begin(); + it != pAttrs->end(); + ++it ) + { + + io_aFile.write( space ); + (*it)->WriteOut( io_aFile ); + } + } + + const Item * pContent = inq_Content(); + if ( pContent != 0 ) + io_aFile.write( tagEnd ); + else + { + if (FinishEmptyTag_XmlStyle()) + io_aFile.write( emptyTagEnd ); + else + { + io_aFile.write( tagEnd ); + io_aFile.write( endTagBegin ); + io_aFile.write( inq_TagName() ); + io_aFile.write( tagEnd ); + } + } + if ( LineBreakAfterBeginTag() ) + io_aFile.write( newline ); + if ( pContent == 0 ) + return; + + pContent->WriteOut( io_aFile ); + io_aFile.write( endTagBegin ); + io_aFile.write( inq_TagName() ); + io_aFile.write( tagEnd ); + if ( LineBreakAfterEndTag() ) + io_aFile.write( newline ); +} + +bool +Element::FinishEmptyTag_XmlStyle() const +{ + return true; +} + +bool +Element::LineBreakAfterBeginTag() const +{ + return false; +} + +bool +Element::LineBreakAfterEndTag() const +{ + return LineBreakAfterBeginTag(); +} + + +//************************ EmptyElement ****************************// + +void +EmptyElement::op_streamout( DYN Item * ) +{ + // Does nothing. +} + +void +EmptyElement::op_streamout( DYN Attribute * let_dpAttr ) +{ + StreamOut( inq_RefAttrs(), let_dpAttr ); +} + +void +EmptyElement::do_SetContent( DYN Item * ) +{ + // Does nothing. +} + +const Item * +EmptyElement::inq_Content() const +{ + return 0; +} + +const AttrList * +EmptyElement::inq_Attrs() const +{ + return & const_cast< EmptyElement* >(this)->inq_RefAttrs(); +} + + +//************************ PureElement ****************************// + +void +PureElement::op_streamout( DYN Item * let_dpItem ) +{ + StreamOut( inq_RefContent(), let_dpItem ); +} + +void +PureElement::op_streamout( DYN Attribute * ) +{ + // Does nothing. +} + +void +PureElement::do_SetContent( DYN Item * let_dpItem ) +{ + Impl_SetContent( inq_RefContent(), let_dpItem ); +} + +const Item * +PureElement::inq_Content() const +{ + return const_cast< PureElement* >(this)->inq_RefContent().Ptr(); +} + +const AttrList * +PureElement::inq_Attrs() const +{ + return 0; +} + + +//*************************** SglTag **************************// + +void +SglTag::op_streamout( DYN Item * ) +{ + // Does nothing. +} + +void +SglTag::op_streamout( DYN Attribute * ) +{ + // Does nothing. +} + +void +SglTag::do_SetContent( DYN Item *) +{ + // Does nothing. +} + +const Item * +SglTag::inq_Content() const +{ + return 0; +} + +const AttrList * +SglTag::inq_Attrs() const +{ + return 0; +} + + +//*************************** AnElement **************************// + +AnElement::AnElement( const String & i_sTagName ) + : sTagName( i_sTagName ) + // pContent, + // aAttrs +{ +} + +AnElement::AnElement( const char * i_sTagName ) + : sTagName( i_sTagName ) + // pContent, + // aAttrs +{ +} + +AnElement::~AnElement() +{ +} + +void +AnElement::op_streamout( DYN Item * let_dpItem ) +{ + StreamOut( pContent, let_dpItem ); +} + +void +AnElement::op_streamout( DYN Attribute * let_dpAttr ) +{ + StreamOut( aAttrs, let_dpAttr ); +} + +void +AnElement::do_SetContent( DYN Item * let_dpItem ) +{ + Impl_SetContent( pContent, let_dpItem ); +} + +const String & +AnElement::inq_TagName() const +{ + return sTagName; +} + +const Item * +AnElement::inq_Content() const +{ + return pContent.Ptr(); +} + +const AttrList * +AnElement::inq_Attrs() const +{ + return &aAttrs; +} + + +//*************************** AnEmptyElement **************************// + +AnEmptyElement::AnEmptyElement( const String & i_sTagName ) + : sTagName( i_sTagName ) + // aAttrs +{ +} + +AnEmptyElement::AnEmptyElement( const char * i_sTagName ) + : sTagName( i_sTagName ) + // aAttrs +{ +} + +AnEmptyElement::~AnEmptyElement() +{ + +} + +const String & +AnEmptyElement::inq_TagName() const +{ + return sTagName; +} + +AttrList & +AnEmptyElement::inq_RefAttrs() +{ + return aAttrs; +} + + +//*************************** APureElement **************************// + +APureElement::APureElement( const String & i_sTagName ) + : sTagName( i_sTagName ) + // pContent +{ +} + +APureElement::APureElement( const char * i_sTagName ) + : sTagName( i_sTagName ) + // pContent +{ +} + +APureElement::~APureElement() +{ +} + +const String & +APureElement::inq_TagName() const +{ + return sTagName; +} + +Dyn< Item > & +APureElement::inq_RefContent() +{ + return pContent; +} + + + +//*************************** ASglTag **************************// + +ASglTag::ASglTag( const String & i_sTagName ) + : sTagName( i_sTagName ) +{ +} + +ASglTag::ASglTag( const char * i_sTagName ) + : sTagName( i_sTagName ) +{ +} + +ASglTag::~ASglTag() +{ +} + +const String & +ASglTag::inq_TagName() const +{ + return sTagName; +} + + +//*************************** AnAttribute **************************// +AnAttribute::AnAttribute( const String & i_sName, + const String & i_sValue ) + : sName(i_sName), + sValue(i_sValue) +{ +} + +AnAttribute::AnAttribute( const char * i_sName, + const char * i_sValue ) + : sName(i_sName), + sValue(i_sValue) +{ +} + +AnAttribute::~AnAttribute() +{ +} + +const String & +AnAttribute::inq_Name() const +{ + return sName; +} + +const String & +AnAttribute::inq_Value() const +{ + return sValue; +} + + + +//*************************** Text **************************// + +Text::Text( const String & i_sText ) + : sText(i_sText) +{ +} + +Text::Text( const char * i_sText ) + : sText(i_sText) +{ +} + +Text::~Text() +{ +} + +void +Text::do_WriteOut( csv::bostream & io_aFile ) const +{ + const unsigned char * + pStart = reinterpret_cast< const unsigned char* >(sText.c_str()); + const unsigned char * + pOut = pStart; + + for ( ; *pOut != '\0'; ++pOut ) + { + if ( cReplacable[*pOut] ) + { + if ( pOut != pStart ) + { + io_aFile.write( pStart, pOut-pStart ); + } + + switch (*pOut) + { + case '<': io_aFile.write("<"); break; + case '>': io_aFile.write(">"); break; + case '"': io_aFile.write("""); break; + case '&': io_aFile.write("&"); break; + case 255: io_aFile.write(" "); break; + } + + pStart = pOut+1; + } // endif (cReplacable[*pOut]) + } // end for + + if ( pOut != pStart ) + { + io_aFile.write( pStart, pOut-pStart ); + } +} + + +//*************************** XmlCode **************************// + +XmlCode::XmlCode( const String & i_sText ) + : sText(i_sText) +{ +} + +XmlCode::XmlCode( const char * i_sText ) + : sText(i_sText) +{ +} + +XmlCode::~XmlCode() +{ +} + +void +XmlCode::do_WriteOut( csv::bostream & io_aFile ) const +{ + io_aFile.write(sText); +} + + +//*************************** MultiItem **************************// + +MultiItem::MultiItem() +{ +} + +MultiItem::~MultiItem() +{ +} + +void +MultiItem::do_WriteOut( csv::bostream & io_aFile ) const +{ + ItemList::iterator itEnd = aItems.end(); + + for ( ItemList::iterator it = aItems.begin(); + it != itEnd; + ++it ) + { + (*it)->WriteOut( io_aFile ); + } + +} + + + +//*************************** Helpers **************************// + +void +StreamOut( Dyn< Item > & o_rContent, + DYN Item * let_dpItem ) +{ + MultiItem * pContent = 0; + if ( bool(o_rContent) ) + { + pContent = static_cast< MultiItem* >( o_rContent.MutablePtr() ); + csv_assert( dynamic_cast< MultiItem* >( o_rContent.MutablePtr() ) != 0 ); + } + else + { + pContent = new MultiItem; + o_rContent = pContent; + } + + csv_assert( let_dpItem != 0 ); + pContent->Add( let_dpItem ); +} + + + + +} // namespace xml +} // namespace csi |