From: nds Date: Fri, 21 Sep 2007 12:38:30 +0000 (+0000) Subject: The class addition. X-Git-Tag: TG_Saint_Valentine-Day~53 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b824bd46ab30878e07961c1d8cba14dce14b7a10;p=modules%2Fgui.git The class addition. --- diff --git a/src/HTMLService/HTMLService.hxx b/src/HTMLService/HTMLService.hxx new file mode 100755 index 000000000..a5bd3b25b --- /dev/null +++ b/src/HTMLService/HTMLService.hxx @@ -0,0 +1,56 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library 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 for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef HTMLSERVICE_H +#define HTMLSERVICE_H + +#if defined HTMLSERVICE_EXPORTS +#if defined WIN32 +#define HTMLSERVICE_EXPORT __declspec( dllexport ) +#else +#define HTMLSERVICE_EXPORT +#endif +#else +#if defined WIN32 +#define HTMLSERVICE_EXPORT __declspec( dllimport ) +#else +#define HTMLSERVICE_EXPORT +#endif +#endif + +#if defined SOLARIS +#define bool int +#define false 0 +#define true 1 +#endif + +#if defined WIN32 +#pragma warning ( disable: 4251 ) +#endif + +#if defined ( _DEBUG ) || defined ( DEBUG ) +#include +#define HTMLSERVICE_VERIFY(x) (assert(x)) +#define HTMLSERVICE_ASSERT(x) (assert(x)) +#else +#define HTMLSERVICE_VERIFY(x) (x) +#define HTMLSERVICE_ASSERT(x) +#endif + + +#endif diff --git a/src/HTMLService/HTMLService.pro b/src/HTMLService/HTMLService.pro new file mode 100755 index 000000000..1bb6e336e --- /dev/null +++ b/src/HTMLService/HTMLService.pro @@ -0,0 +1,30 @@ +TEMPLATE = lib + +DESTDIR = ../../$(CONFIG_ID)/lib +MOC_DIR = ../../moc +OBJECTS_DIR = ../../$(CONFIG_ID)/obj/$$TARGET + +CASROOT = $$(CASROOT) +CAS_CPPFLAGS = $${CASROOT}/inc + +CAS_KERNEL = -L$${CASROOT}/Linux/lib -lTKernel + +CAS_VIEWER = -L$${CASROOT}/Linux/lib -lTKV3d -lTKService + +INCLUDEPATH += ../../include $${CAS_CPPFLAGS} +LIBS += -L../../$(CONFIG_ID)/lib $${CAS_KERNEL} $${CAS_VIEWER} + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 +DEFINES += HTMLSERVICE_EXPORTS OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS + +HEADERS = *.hxx + +SOURCES = *.cxx + +includes.files = $$HEADERS +includes.path = ../../include + +INSTALLS += includes diff --git a/src/HTMLService/HTMLService_HTML.cxx b/src/HTMLService/HTMLService_HTML.cxx new file mode 100755 index 000000000..70b4773c6 --- /dev/null +++ b/src/HTMLService/HTMLService_HTML.cxx @@ -0,0 +1,279 @@ +// File: HTMLService_HTML.cxx +// Created: 12.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#include + +#include + +#include +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE(HTMLService_HTML, MMgt_TShared) +IMPLEMENT_STANDARD_RTTIEXT(HTMLService_HTML, MMgt_TShared) + +HTMLService_HTML::HTMLService_HTML() +: myVisible( Standard_True ) +{ +} + +HTMLService_HTML::HTMLService_HTML( const Handle(HTMLService_HTML)& parent ) +: myVisible( Standard_True ) +{ + if ( !parent.IsNull() ) + parent->InsertSubItem( this ); +} + +HTMLService_HTML::~HTMLService_HTML() +{ +} + +TCollection_ExtendedString HTMLService_HTML::GetTitle() const +{ + return myTitle; +} + +void HTMLService_HTML::SetTitle( const TCollection_ExtendedString& title ) +{ + myTitle = title; +} + +Standard_Boolean HTMLService_HTML::GenerateFile( const TCollection_ExtendedString& aFileName, + const Standard_Boolean fullDoc ) const +{ + if ( !aFileName.Length() ) + return Standard_False; + + TCollection_AsciiString aFName( aFileName ); + OSD_File aFile( aFName ); + aFile.Build( OSD_WriteOnly, OSD_Protection() ); + if ( !aFile.IsOpen() ) + return Standard_False; + + SequenceOfHTMLLine aHTML = GenerateText( fullDoc ); + + TCollection_AsciiString endL( "\n" ); + for ( Standard_Integer i = 1; i <= aHTML.Length(); i++ ) + { + TCollection_ExtendedString aLine = aHTML.Value( i ); + TCollection_AsciiString aAsciiLine; + if ( aLine.IsAscii() ) + aAsciiLine = TCollection_AsciiString( aLine ); + else + { + for ( Standard_Integer j = 1; j <= aLine.Length(); j++ ) + { + Standard_ExtCharacter curExt = aLine.Value(j); + if ( IsAnAscii( curExt ) ) + aAsciiLine += TCollection_AsciiString( ToCharacter( curExt ) ); + else + { + char buf[256]; + sprintf( buf, "&#%d;", curExt ); + aAsciiLine+= TCollection_AsciiString( buf ); + } + } + } + aFile.Write( aAsciiLine, aAsciiLine.Length() ); + aFile.Write( endL, 1 ); + } + aFile.Close(); + + return Standard_True; +} + +SequenceOfHTMLLine HTMLService_HTML::GenerateText( const Standard_Boolean fullDoc ) const +{ + SequenceOfHTMLLine aHTML; + + if ( fullDoc ) + BeginDocument( aHTML ); + + SequenceOfHTMLLine aBody; + Generate( aBody ); + if ( fullDoc ) + AppendIndent( aBody ); + + for ( Standard_Integer i = 1; i <= aBody.Length(); i++ ) + aHTML.Append( aBody.Value( i ) ); + + if ( fullDoc ) + EndDocument( aHTML ); + + return aHTML; +} + +Standard_Boolean HTMLService_HTML::IsVisible() const +{ + return myVisible; +} + +void HTMLService_HTML::SetVisible( const Standard_Boolean vis ) +{ + myVisible = vis; +} + +void HTMLService_HTML::SubItemsHTML( SequenceOfHTMLLine& theHTML ) const +{ + for ( Standard_Integer i = 1; i <= mySubItems.Length(); i++ ) + { + Handle(HTMLService_HTML) item = mySubItems.Value( i ); + if ( !item->IsVisible() ) + continue; + + SequenceOfHTMLLine aLines; + item->Generate( aLines ); + AppendIndent( aLines ); + Concatenate( theHTML, aLines ); + } +} + +void HTMLService_HTML::AppendIndent( SequenceOfHTMLLine& aHTML ) const +{ + for ( Standard_Integer i = 1; i <= aHTML.Length(); i++ ) + AppendIndent( aHTML.ChangeValue( i ) ); +} + +void HTMLService_HTML::AppendIndent( TCollection_ExtendedString& aLine ) const +{ + Standard_Integer ident = 2; + TCollection_ExtendedString identString( ident, ' ' ); + aLine.Insert( 1, identString ); +} + +void HTMLService_HTML::Concatenate( SequenceOfHTMLLine& aTrg, const SequenceOfHTMLLine& aSrc ) const +{ + for ( Standard_Integer i = 1; i <= aSrc.Length(); i++ ) + aTrg.Append( aSrc.Value( i ) ); +} + +void HTMLService_HTML::BeginDocument( SequenceOfHTMLLine& theHTML ) const +{ + theHTML.Append( "" ); + theHTML.Append( "" ); + theHTML.Append( TCollection_ExtendedString( "" ) + GetTitle() + TCollection_ExtendedString( "" ) ); + theHTML.Append( "" ); + theHTML.Append( "" ); +} + +void HTMLService_HTML::EndDocument( SequenceOfHTMLLine& theHTML ) const +{ + theHTML.Append( "" ); + theHTML.Append( "" ); +} + +void HTMLService_HTML::InsertSubItem( const Handle(HTMLService_HTML)& item ) +{ + if ( item.IsNull() ) + return; + + Standard_Boolean found = Standard_False; + for ( Standard_Integer i = 1; i <= mySubItems.Length() && !found; i++ ) + found = mySubItems.Value( i ) == item; + + if ( !found ) + mySubItems.Append( item ); +} + +void HTMLService_HTML::RemoveSubItem( const Handle(HTMLService_HTML)& item ) +{ + if ( item.IsNull() ) + return; + + Standard_Integer idx = -1; + for ( Standard_Integer i = 1; i <= mySubItems.Length() && idx == -1; i++ ) + { + if ( mySubItems.Value( i ) == item ) + idx = i; + } + + if ( idx != -1 ) + mySubItems.Remove( idx ); +} + +void HTMLService_HTML::ClearSubItems() +{ + mySubItems.Clear(); +} + +TCollection_ExtendedString HTMLService_HTML::ColorString( const Quantity_Color& c ) +{ + Standard_Integer r = (Standard_Integer)( c.Red() * 255 ); + Standard_Integer g = (Standard_Integer)( c.Green() * 255 ); + Standard_Integer b = (Standard_Integer)( c.Blue() * 255 ); + + char buf[255]; + sprintf( buf, "#%02X%02X%02X", r, g, b ); + return TCollection_ExtendedString( buf ); +} + +TCollection_ExtendedString HTMLService_HTML::AlignString( const Standard_Integer flags ) +{ + TCollection_ExtendedString hRes; + switch ( flags & HAlignment ) + { + case Left: + hRes = TCollection_ExtendedString( "left" ); + break; + case Right: + hRes = TCollection_ExtendedString( "right" ); + break; + case Center: + hRes = TCollection_ExtendedString( "center" ); + break; + } + + if ( hRes.Length() ) + hRes = TCollection_ExtendedString( "align=" ) + hRes; + + TCollection_ExtendedString vRes; + switch ( flags & VAlignment ) + { + case Top: + vRes = TCollection_ExtendedString( "top" ); + break; + case Bottom: + vRes = TCollection_ExtendedString( "bottom" ); + break; + case Middle: + vRes = TCollection_ExtendedString( "middle" ); + break; + } + + if ( vRes.Length() ) + vRes = TCollection_ExtendedString( "valign=" ) + hRes; + + TCollection_ExtendedString res; + if ( hRes.Length() ) + res += hRes; + if ( vRes.Length() ) + { + if ( res.Length() ) + res += TCollection_ExtendedString( " " ); + res += vRes; + } + + return res; +} + +TCollection_ExtendedString HTMLService_HTML::EncloseToTag( const TCollection_ExtendedString& txt, + const TCollection_ExtendedString& tag, + const TCollection_ExtendedString& attribs ) const +{ + TCollection_ExtendedString res; + if ( tag.Length() ) + { + res = TCollection_ExtendedString ( "<" ) + tag; + if ( attribs.Length() ) + res += TCollection_ExtendedString( " " ) + attribs; + res += TCollection_ExtendedString( ">" ) + txt + TCollection_ExtendedString( "" ); + } + else + res = txt; + + return res; +} diff --git a/src/HTMLService/HTMLService_HTML.hxx b/src/HTMLService/HTMLService_HTML.hxx new file mode 100755 index 000000000..083e6ef0c --- /dev/null +++ b/src/HTMLService/HTMLService_HTML.hxx @@ -0,0 +1,84 @@ +// File: HTMLService_HTML.hxx +// Created: 12.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#ifndef HTMLSERVICE_HTML_H +#define HTMLSERVICE_HTML_H + +#include + +#include +#include + +#include +#include + +class Quantity_Color; +class Handle(HTMLService_HTML); + +typedef NCollection_Sequence SequenceOfHTMLLine; + +/*! + Class HTMLService_HTML. Base class for HTML generation. +*/ + +class HTMLSERVICE_EXPORT HTMLService_HTML : public MMgt_TShared +{ +public: + enum { Left = 0x01, Right = 0x02, Center = 0x04, + Top = 0x08, Bottom = 0x10, Middle = 0x20, + HAlignment = Left | Right | Center, VAlignment = Top | Bottom | Middle } AlignmentFlags; + +public: + Standard_EXPORT HTMLService_HTML(); + Standard_EXPORT HTMLService_HTML( const Handle(HTMLService_HTML)& ); + Standard_EXPORT ~HTMLService_HTML(); + + Standard_EXPORT TCollection_ExtendedString GetTitle() const; + Standard_EXPORT void SetTitle( const TCollection_ExtendedString& ); + + Standard_EXPORT Standard_Boolean GenerateFile( const TCollection_ExtendedString&, + const Standard_Boolean = Standard_False ) const; + Standard_EXPORT SequenceOfHTMLLine GenerateText( const Standard_Boolean = Standard_False ) const; + + Standard_EXPORT static TCollection_ExtendedString ColorString( const Quantity_Color& ); + Standard_EXPORT static TCollection_ExtendedString AlignString( const Standard_Integer ); + + Standard_EXPORT Standard_Boolean IsVisible() const; + Standard_EXPORT void SetVisible( const Standard_Boolean ); + +protected: + Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const = 0; + Standard_EXPORT virtual void SubItemsHTML( SequenceOfHTMLLine& ) const; + + Standard_EXPORT TCollection_ExtendedString EncloseToTag( const TCollection_ExtendedString&, const TCollection_ExtendedString&, + const TCollection_ExtendedString& = TCollection_ExtendedString() ) const; + + Standard_EXPORT void ClearSubItems(); + Standard_EXPORT void InsertSubItem( const Handle(HTMLService_HTML)& ); + Standard_EXPORT void RemoveSubItem( const Handle(HTMLService_HTML)& ); + + void AppendIndent( SequenceOfHTMLLine& ) const; + void AppendIndent( TCollection_ExtendedString& ) const; + void Concatenate( SequenceOfHTMLLine&, const SequenceOfHTMLLine& ) const; + +private: + void BeginDocument( SequenceOfHTMLLine& ) const; + void EndDocument( SequenceOfHTMLLine& ) const; + +private: + typedef NCollection_Sequence HTMLSequence; + +private: + TCollection_ExtendedString myTitle; + Standard_Boolean myVisible; + HTMLSequence mySubItems; + +public: + DEFINE_STANDARD_RTTI(HTMLService_HTML) +}; + +DEFINE_STANDARD_HANDLE(HTMLService_HTML, MMgt_TShared) + +#endif diff --git a/src/HTMLService/HTMLService_HTMLImage.cxx b/src/HTMLService/HTMLService_HTMLImage.cxx new file mode 100755 index 000000000..b379832a6 --- /dev/null +++ b/src/HTMLService/HTMLService_HTMLImage.cxx @@ -0,0 +1,123 @@ +// File: HTMLService_HTMLImage.cxx +// Created: 13.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#include + +IMPLEMENT_STANDARD_HANDLE(HTMLService_HTMLImage, HTMLService_HTML) +IMPLEMENT_STANDARD_RTTIEXT(HTMLService_HTMLImage, HTMLService_HTML) + +HTMLService_HTMLImage::HTMLService_HTMLImage( const TCollection_ExtendedString& img ) +: HTMLService_HTML(), +myAlign( -1 ), +myWidth( -1 ), +myHeight( -1 ), +mySource( img ), +mySrcProto( SP_File ) +{ +} + +HTMLService_HTMLImage::HTMLService_HTMLImage( const Handle(HTMLService_HTML)& parent, + const TCollection_ExtendedString& img ) +: HTMLService_HTML( parent ), +myAlign( -1 ), +myWidth( -1 ), +myHeight( -1 ), +mySource( img ), +mySrcProto( SP_File ) +{ +} + +HTMLService_HTMLImage::~HTMLService_HTMLImage() +{ +} + +TCollection_ExtendedString HTMLService_HTMLImage::GetSource() const +{ + return mySource; +} + +Standard_Integer HTMLService_HTMLImage::GetAlignment() const +{ + return myAlign; +} + +Standard_Integer HTMLService_HTMLImage::GetWidth() const +{ + return myWidth; +} + +Standard_Integer HTMLService_HTMLImage::GetHeight() const +{ + return myHeight; +} + +Standard_Integer HTMLService_HTMLImage::GetSourceProtocol() const +{ + return mySrcProto; +} + +void HTMLService_HTMLImage::SetSource( const TCollection_ExtendedString& src ) +{ + mySource = src; +} + +void HTMLService_HTMLImage::SetAlignment( const Standard_Integer align ) +{ + myAlign = align; +} + +void HTMLService_HTMLImage::SetWidth( const Standard_Integer val ) +{ + myWidth = val; +} + +void HTMLService_HTMLImage::SetHeight( const Standard_Integer val ) +{ + myHeight = val; +} + +void HTMLService_HTMLImage::SetSourceProtocol( const Standard_Integer& sp ) +{ + mySrcProto = sp; +} + +void HTMLService_HTMLImage::Generate( SequenceOfHTMLLine& aHTML ) const +{ + TCollection_ExtendedString aLine( "= 0 ) + aLine += TCollection_ExtendedString( " width=" ) + TCollection_ExtendedString( GetWidth() ); + if ( GetHeight() >= 0 ) + aLine += TCollection_ExtendedString( " height=" ) + TCollection_ExtendedString( GetHeight() ); + + TCollection_ExtendedString align = AlignString( GetAlignment() ); + if ( align.Length() ) + aLine += TCollection_ExtendedString( " " ) + align; + + aLine += TCollection_ExtendedString( ">" ); + + aHTML.Append( aLine ); +} + +TCollection_ExtendedString HTMLService_HTMLImage::SourcePrefix() const +{ + TCollection_ExtendedString prefix; + switch ( GetSourceProtocol() ) + { + case SP_File: + prefix = TCollection_ExtendedString( "file://" ); + break; + case SP_HTTP: + prefix = TCollection_ExtendedString( "http://" ); + break; + case SP_FTP: + prefix = TCollection_ExtendedString( "ftp://" ); + break; + } + return prefix; +} diff --git a/src/HTMLService/HTMLService_HTMLImage.hxx b/src/HTMLService/HTMLService_HTMLImage.hxx new file mode 100755 index 000000000..95bae3c1d --- /dev/null +++ b/src/HTMLService/HTMLService_HTMLImage.hxx @@ -0,0 +1,60 @@ +// File: HTMLService_HTMLImage.hxx +// Created: 13.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#ifndef HTMLSERVICE_HTMLIMAGE_H +#define HTMLSERVICE_HTMLIMAGE_H + +#include +#include + +#include + +/*! + Class HTMLService_HTMLImage. Generator of the HTML image. +*/ + +class HTMLSERVICE_EXPORT HTMLService_HTMLImage : public HTMLService_HTML +{ +public: + enum { SP_Unknown, SP_File, SP_HTTP, SP_FTP } SourceProtocol; + +public: + Standard_EXPORT HTMLService_HTMLImage( const TCollection_ExtendedString& = TCollection_ExtendedString() ); + Standard_EXPORT HTMLService_HTMLImage( const Handle(HTMLService_HTML)&, + const TCollection_ExtendedString& = TCollection_ExtendedString() ); + Standard_EXPORT virtual ~HTMLService_HTMLImage(); + + Standard_EXPORT Standard_Integer GetWidth() const; + Standard_EXPORT Standard_Integer GetHeight() const; + Standard_EXPORT TCollection_ExtendedString GetSource() const; + Standard_EXPORT Standard_Integer GetAlignment() const; + Standard_EXPORT Standard_Integer GetSourceProtocol() const; + + Standard_EXPORT void SetWidth( const Standard_Integer ); + Standard_EXPORT void SetHeight( const Standard_Integer ); + Standard_EXPORT void SetAlignment( const Standard_Integer ); + Standard_EXPORT void SetSource( const TCollection_ExtendedString& ); + Standard_EXPORT void SetSourceProtocol( const Standard_Integer& ); + +protected: + Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const; + +private: + TCollection_ExtendedString SourcePrefix() const; + +private: + Standard_Integer myAlign; + Standard_Integer myWidth; + Standard_Integer myHeight; + TCollection_ExtendedString mySource; + Standard_Integer mySrcProto; + +public: + DEFINE_STANDARD_RTTI(HTMLService_HTMLImage) +}; + +DEFINE_STANDARD_HANDLE(HTMLService_HTMLImage, HTMLService_HTML) + +#endif diff --git a/src/HTMLService/HTMLService_HTMLParagraph.cxx b/src/HTMLService/HTMLService_HTMLParagraph.cxx new file mode 100755 index 000000000..641fee6e2 --- /dev/null +++ b/src/HTMLService/HTMLService_HTMLParagraph.cxx @@ -0,0 +1,92 @@ +// File: HTMLService_HTMLParagraph.cxx +// Created: 13.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#include + +#include + +IMPLEMENT_STANDARD_HANDLE(HTMLService_HTMLParagraph, HTMLService_HTMLText) +IMPLEMENT_STANDARD_RTTIEXT(HTMLService_HTMLParagraph, HTMLService_HTMLText) + +HTMLService_HTMLParagraph::HTMLService_HTMLParagraph() +: HTMLService_HTMLText(), +myNoBr( Standard_False ) +{ +} + +HTMLService_HTMLParagraph::HTMLService_HTMLParagraph( const Handle(HTMLService_HTML)& parent ) +: HTMLService_HTMLText( parent ), +myNoBr( Standard_False ) +{ +} + +HTMLService_HTMLParagraph::~HTMLService_HTMLParagraph() +{ +} + +Standard_Boolean HTMLService_HTMLParagraph::GetNoBreak() const +{ + return myNoBr; +} + +void HTMLService_HTMLParagraph::SetNoBreak( const Standard_Boolean& on ) +{ + myNoBr = on; +} + +void HTMLService_HTMLParagraph::Clear() +{ + ClearSubItems(); +} + +void HTMLService_HTMLParagraph::Insert( const Handle(HTMLService_HTML)& item ) +{ + InsertSubItem( item ); +} + +void HTMLService_HTMLParagraph::InsertText( const TCollection_ExtendedString& text ) +{ + Insert( new HTMLService_HTMLText( this, text ) ); +} + +void HTMLService_HTMLParagraph::InsertImage( const TCollection_ExtendedString& img, + const Standard_Integer w, const Standard_Integer h ) +{ + Handle(HTMLService_HTMLImage) image = new HTMLService_HTMLImage( this, img ); + if ( w > 0 ) + image->SetWidth( w ); + if ( h > 0 ) + image->SetHeight( h ); + + Insert( image ); +} + +void HTMLService_HTMLParagraph::Generate( SequenceOfHTMLLine& aHTML ) const +{ + SequenceOfHTMLLine aLines; + HTMLService_HTMLText::Generate( aLines ); + + TCollection_ExtendedString aText; + for ( Standard_Integer i = 1; i <= aLines.Length(); i++ ) + aText += aLines.Value( i ); + + if ( GetNoBreak() ) + aText = EncloseToTag( aText, "nobr" ); + + aText = EncloseToTag( aText, "p" ); + + TCollection_ExtendedString aHead( aText ), aTail; + Standard_Integer idx = aHead.Search( " +#include + +/*! + Class HTMLService_HTMLParagraph. Generator of the HTML paragraph text. +*/ + +class HTMLSERVICE_EXPORT HTMLService_HTMLParagraph : public HTMLService_HTMLText +{ +public: + Standard_EXPORT HTMLService_HTMLParagraph(); + Standard_EXPORT HTMLService_HTMLParagraph( const Handle(HTMLService_HTML)& ); + Standard_EXPORT virtual ~HTMLService_HTMLParagraph(); + + Standard_EXPORT Standard_Boolean GetNoBreak() const; + Standard_EXPORT void SetNoBreak( const Standard_Boolean& ); + + Standard_EXPORT void Clear(); + Standard_EXPORT void Insert( const Handle(HTMLService_HTML)& ); + Standard_EXPORT void InsertText( const TCollection_ExtendedString& ); + Standard_EXPORT void InsertImage( const TCollection_ExtendedString&, + const Standard_Integer = -1, const Standard_Integer = -1 ); + +protected: + Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const; + +private: + Standard_Boolean myNoBr; + +public: + DEFINE_STANDARD_RTTI(HTMLService_HTMLParagraph) +}; + +DEFINE_STANDARD_HANDLE(HTMLService_HTMLParagraph, HTMLService_HTMLText) + +#endif diff --git a/src/HTMLService/HTMLService_HTMLTable.cxx b/src/HTMLService/HTMLService_HTMLTable.cxx new file mode 100755 index 000000000..ff414e7ba --- /dev/null +++ b/src/HTMLService/HTMLService_HTMLTable.cxx @@ -0,0 +1,255 @@ +// File: HTMLService_HTMLTable.cxx +// Created: 12.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#include + +IMPLEMENT_STANDARD_HANDLE(HTMLService_HTMLTable, HTMLService_HTML) +IMPLEMENT_STANDARD_RTTIEXT(HTMLService_HTMLTable, HTMLService_HTML) + +HTMLService_HTMLTable::HTMLService_HTMLTable( const Standard_Integer rows, const Standard_Integer cols ) +: HTMLService_HTML(), +myWidth( -1 ), +myBorder( -1 ), +mySpacing( -1 ), +myPadding( -1 ), +myUseBC( Standard_False ), +myPercent( Standard_False ) +{ + Initialize( rows, cols ); +} + +HTMLService_HTMLTable::HTMLService_HTMLTable( const Handle(HTMLService_HTML)& parent, + const Standard_Integer rows, const Standard_Integer cols ) +: HTMLService_HTML( parent ), +myWidth( -1 ), +myBorder( -1 ), +mySpacing( -1 ), +myPadding( -1 ), +myUseBC( Standard_False ), +myPercent( Standard_False ) +{ + Initialize( rows, cols ); +} + +HTMLService_HTMLTable::~HTMLService_HTMLTable() +{ +} + +Standard_Integer HTMLService_HTMLTable::GetNumRows() const +{ + if ( myRows.IsNull() ) + return 0; + + return myRows->Length(); +} + +Standard_Integer HTMLService_HTMLTable::GetNumCols() const +{ + if ( myRows.IsNull() ) + return 0; + + Handle(HTMLService_HTMLTableRow) row = Handle(HTMLService_HTMLTableRow)::DownCast(myRows->Value( myRows->Lower() )); + if ( row.IsNull() ) + return 0; + + return row->GetSize(); +} + +Handle(HTMLService_HTMLTableRow) HTMLService_HTMLTable::GetRow( const Standard_Integer index ) const +{ + Handle(HTMLService_HTMLTableRow) row; + if ( !myRows.IsNull() ) + { + Standard_Integer idx = index + myRows->Lower(); + if ( idx >= myRows->Lower() && idx <= myRows->Upper() ) + row = Handle(HTMLService_HTMLTableRow)::DownCast(myRows->Value( idx )); + } + return row; +} + +Handle(HTMLService_HTMLTableCell) HTMLService_HTMLTable::GetCell( const Standard_Integer r, const Standard_Integer c ) const +{ + Handle(HTMLService_HTMLTableCell) cell; + Handle(HTMLService_HTMLTableRow) row = GetRow( r ); + if ( !row.IsNull() ) + cell = row->GetCell( c ); + return cell; +} + +Standard_Integer HTMLService_HTMLTable::GetBorder() const +{ + return myBorder; +} + +Standard_Integer HTMLService_HTMLTable::GetCellSpacing() const +{ + return mySpacing; +} + +Standard_Integer HTMLService_HTMLTable::GetCellPadding() const +{ + return myPadding; +} + +Quantity_Color HTMLService_HTMLTable::GetBackgroundColor() const +{ + return myBgColor; +} + +Standard_Integer HTMLService_HTMLTable::GetWidth( Standard_Boolean* percent ) const +{ + if ( percent ) + *percent = myPercent; + return myWidth; +} + +void HTMLService_HTMLTable::SetBorder( const Standard_Integer val ) +{ + myBorder = val; +} + +void HTMLService_HTMLTable::SetCellSpacing( const Standard_Integer val ) +{ + mySpacing = val; +} + +void HTMLService_HTMLTable::SetCellPadding( const Standard_Integer val ) +{ + myPadding = val; +} + +void HTMLService_HTMLTable::SetBackgroundColor( const Quantity_Color& c ) +{ + myBgColor = c; + myUseBC = Standard_True; +} + +void HTMLService_HTMLTable::SetWidth( const Standard_Integer width, const Standard_Boolean percent ) +{ + myWidth = width; + myPercent = percent; +} + +void HTMLService_HTMLTable::SetColumnWidth( const Standard_Integer col, + const Standard_Integer w, const Standard_Boolean percent ) +{ + for ( Standard_Integer r = myRows->Lower(); r <= myRows->Upper(); r++ ) + { + Handle(HTMLService_HTMLTableRow) row = Handle(HTMLService_HTMLTableRow)::DownCast(myRows->Value( r )); + if ( !row.IsNull() ) + { + Handle(HTMLService_HTMLTableCell) cell = row->GetCell( col ); + if ( !cell.IsNull() ) + cell->SetWidth( w, percent ); + } + } +} + +void HTMLService_HTMLTable::SetRowSpan( const Standard_Integer row, const Standard_Integer span ) +{ + Handle(HTMLService_HTMLTableRow) aRow = GetRow( row ); + if ( !aRow.IsNull() ) + { + for ( Standard_Integer i = 0; i < aRow->GetSize(); i++ ) + aRow->GetCell( i )->SetRowSpan( span ); + } +} + +void HTMLService_HTMLTable::SetColumnSpan( const Standard_Integer col, const Standard_Integer span ) +{ + for ( Standard_Integer r = myRows->Lower(); r <= myRows->Upper(); r++ ) + { + Handle(HTMLService_HTMLTableRow) row = Handle(HTMLService_HTMLTableRow)::DownCast(myRows->Value( r )); + if ( !row.IsNull() ) + { + Handle(HTMLService_HTMLTableCell) cell = row->GetCell( col ); + if ( !cell.IsNull() ) + cell->SetColSpan( span ); + } + } +} + +void HTMLService_HTMLTable::Initialize( const Standard_Integer rows, const Standard_Integer cols ) +{ + if ( rows > 0 ) + myRows = new TColStd_HArray1OfTransient( 1, rows ); + + if ( myRows.IsNull() ) + return; + + for ( Standard_Integer i = myRows->Lower(); i <= myRows->Upper(); i++ ) + { + Handle(HTMLService_HTMLTableRow) row = new HTMLService_HTMLTableRow( cols ); + myRows->SetValue( i, row ); + InsertSubItem( row ); + } +} + +void HTMLService_HTMLTable::Generate( SequenceOfHTMLLine& aHTML ) const +{ + PrepareCells(); + + TCollection_ExtendedString aLine( "= 0 ) + { + aLine += TCollection_ExtendedString( " width=" ) + TCollection_ExtendedString( GetWidth() ); + if ( percent ) + aLine += TCollection_ExtendedString( "%" ); + } + if ( GetBorder() >= 0 ) + aLine += TCollection_ExtendedString( " border=" ) + TCollection_ExtendedString( GetBorder() ); + if ( GetCellSpacing() > 1 ) + aLine += TCollection_ExtendedString( " cellspacing=" ) + TCollection_ExtendedString( GetCellSpacing() ); + if ( GetCellPadding() > 1 ) + aLine += TCollection_ExtendedString( " cellpadding=" ) + TCollection_ExtendedString( GetCellPadding() ); + + if ( myUseBC ) + aLine += TCollection_ExtendedString( " bgcolor=" ) + ColorString( GetBackgroundColor() ); + + aLine += TCollection_ExtendedString( ">" ); + aHTML.Append( aLine ); + SubItemsHTML( aHTML ); + + aHTML.Append( TCollection_ExtendedString( "" ) ); +} + +void HTMLService_HTMLTable::PrepareCells() const +{ + for ( Standard_Integer row = 0; row < GetNumRows(); row++ ) + { + for ( Standard_Integer col = 0; col < GetNumCols(); col++ ) + { + Handle(HTMLService_HTMLTableCell) cell = GetCell( row, col ); + if ( !cell.IsNull() ) + cell->SetVisible( Standard_True ); + } + } + + for ( Standard_Integer r = 0; r < GetNumRows(); r++ ) + { + for ( Standard_Integer c = 0; c < GetNumCols(); c++ ) + { + Handle(HTMLService_HTMLTableCell) cell = GetCell( r, c ); + if ( !cell->IsVisible() ) + continue; + + Standard_Integer rowSpan = cell->GetRowSpan(); + Standard_Integer colSpan = cell->GetColSpan(); + if ( rowSpan < 2 && colSpan < 2 ) + continue; + + for ( Standard_Integer sr = r; sr < r + rowSpan; sr++ ) + { + for ( Standard_Integer sc = c; sc < c + colSpan; sc++ ) + { + Handle(HTMLService_HTMLTableCell) spanedCell = GetCell( sr, sc ); + if ( !spanedCell.IsNull() && spanedCell != cell ) + spanedCell->SetVisible( Standard_False ); + } + } + } + } +} diff --git a/src/HTMLService/HTMLService_HTMLTable.hxx b/src/HTMLService/HTMLService_HTMLTable.hxx new file mode 100755 index 000000000..840f0aa04 --- /dev/null +++ b/src/HTMLService/HTMLService_HTMLTable.hxx @@ -0,0 +1,77 @@ +// File: HTMLService_HTMLTable.hxx +// Created: 12.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#ifndef HTMLSERVICE_HTMLTABLE_H +#define HTMLSERVICE_HTMLTABLE_H + +#include +#include + +#include + +#include + +#include + +/*! + Class HTMLService_HTMLTable. Generator of the HTML Table text. +*/ + +class HTMLSERVICE_EXPORT HTMLService_HTMLTable : public HTMLService_HTML +{ +public: + Standard_EXPORT HTMLService_HTMLTable( const Standard_Integer = 0, const Standard_Integer = 0 ); + Standard_EXPORT HTMLService_HTMLTable( const Handle(HTMLService_HTML)&, const Standard_Integer = 0, const Standard_Integer = 0 ); + Standard_EXPORT virtual ~HTMLService_HTMLTable(); + + Standard_EXPORT Standard_Integer GetNumRows() const; + Standard_EXPORT Standard_Integer GetNumCols() const; + + Standard_EXPORT Handle(HTMLService_HTMLTableRow) GetRow( const Standard_Integer ) const; + Standard_EXPORT Handle(HTMLService_HTMLTableCell) GetCell( const Standard_Integer, const Standard_Integer ) const; + + Standard_EXPORT Standard_Integer GetBorder() const; + Standard_EXPORT Standard_Integer GetCellSpacing() const; + Standard_EXPORT Standard_Integer GetCellPadding() const; + Standard_EXPORT Quantity_Color GetBackgroundColor() const; + Standard_EXPORT Standard_Integer GetWidth( Standard_Boolean* = 0 ) const; + + Standard_EXPORT void SetBorder( const Standard_Integer ); + Standard_EXPORT void SetCellSpacing( const Standard_Integer ); + Standard_EXPORT void SetCellPadding( const Standard_Integer ); + Standard_EXPORT void SetBackgroundColor( const Quantity_Color& ); + Standard_EXPORT void SetWidth( const Standard_Integer, + const Standard_Boolean = Standard_False ); + + Standard_EXPORT void SetRowSpan( const Standard_Integer, const Standard_Integer ); + Standard_EXPORT void SetColumnSpan( const Standard_Integer, const Standard_Integer ); + Standard_EXPORT void SetColumnWidth( const Standard_Integer, const Standard_Integer, + const Standard_Boolean = Standard_False ); + +protected: + Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const; + +private: + void PrepareCells() const; + void Initialize( const Standard_Integer, const Standard_Integer ); + +private: + Handle(TColStd_HArray1OfTransient) myRows; + + Standard_Boolean myUseBC; + Standard_Integer myWidth; + Standard_Integer myBorder; + Standard_Boolean myPercent; + Quantity_Color myBgColor; + Standard_Integer mySpacing; + Standard_Integer myPadding; + +public: + DEFINE_STANDARD_RTTI(HTMLService_HTMLTable) +}; + +DEFINE_STANDARD_HANDLE(HTMLService_HTMLTable, HTMLService_HTML) + +#endif diff --git a/src/HTMLService/HTMLService_HTMLTableCell.cxx b/src/HTMLService/HTMLService_HTMLTableCell.cxx new file mode 100755 index 000000000..876b81b15 --- /dev/null +++ b/src/HTMLService/HTMLService_HTMLTableCell.cxx @@ -0,0 +1,162 @@ +// File: HTMLService_HTMLTableCell.cxx +// Created: 12.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#include + +IMPLEMENT_STANDARD_HANDLE(HTMLService_HTMLTableCell, HTMLService_HTMLParagraph) +IMPLEMENT_STANDARD_RTTIEXT(HTMLService_HTMLTableCell, HTMLService_HTMLParagraph) + +HTMLService_HTMLTableCell::HTMLService_HTMLTableCell() +: HTMLService_HTMLParagraph(), +myRowSpan( 1 ), +myColSpan( 1 ), +myWidth( -1 ), +myAlign( -1 ), +myUseBC( Standard_False ), +myPercent( Standard_False ), +myIsHeader( Standard_False ) +{ +} + +HTMLService_HTMLTableCell::HTMLService_HTMLTableCell( const Handle(HTMLService_HTML)& parent ) +: HTMLService_HTMLParagraph( parent ), +myRowSpan( 1 ), +myColSpan( 1 ), +myWidth( -1 ), +myAlign( -1 ), +myUseBC( Standard_False ), +myPercent( Standard_False ), +myIsHeader( Standard_False ) +{ +} + +HTMLService_HTMLTableCell::~HTMLService_HTMLTableCell() +{ +} + +Standard_Integer HTMLService_HTMLTableCell::GetColSpan() const +{ + return myColSpan; +} + +Standard_Integer HTMLService_HTMLTableCell::GetRowSpan() const +{ + return myRowSpan; +} + +Standard_Integer HTMLService_HTMLTableCell::GetAlignment() const +{ + return myAlign; +} + +Standard_Integer HTMLService_HTMLTableCell::GetWidth( Standard_Boolean* percent ) const +{ + if ( percent ) + *percent = myPercent; + return myWidth; +} + +Quantity_Color HTMLService_HTMLTableCell::GetBackgroundColor() const +{ + return myBgColor; +} + +Standard_Boolean HTMLService_HTMLTableCell::IsHeaderCell() const +{ + return myIsHeader; +} + +void HTMLService_HTMLTableCell::SetColSpan( const Standard_Integer span ) +{ + myColSpan = span; +} + +void HTMLService_HTMLTableCell::SetRowSpan( const Standard_Integer span ) +{ + myRowSpan = span; +} + +void HTMLService_HTMLTableCell::SetAlignment( const Standard_Integer align ) +{ + myAlign = align; +} + +void HTMLService_HTMLTableCell::SetWidth( const Standard_Integer width, const Standard_Boolean percent ) +{ + myWidth = width; + myPercent = percent; +} + +void HTMLService_HTMLTableCell::SetBackgroundColor( const Quantity_Color& c ) +{ + myBgColor = c; + myUseBC = Standard_True; +} + +void HTMLService_HTMLTableCell::SetHeaderCell( const Standard_Boolean on ) +{ + myIsHeader = on; +} + +void HTMLService_HTMLTableCell::Generate( SequenceOfHTMLLine& aHTML ) const +{ + TCollection_ExtendedString aLine; + if ( IsHeaderCell() ) + aLine = TCollection_ExtendedString( "= 0 ) + { + aLine += TCollection_ExtendedString( " width=" ) + TCollection_ExtendedString( GetWidth() ); + if ( percent ) + aLine += TCollection_ExtendedString( "%" ); + } + if ( GetRowSpan() > 1 ) + aLine += TCollection_ExtendedString( " rowspan=" ) + TCollection_ExtendedString( GetRowSpan() ); + if ( GetColSpan() > 1 ) + aLine += TCollection_ExtendedString( " colspan=" ) + TCollection_ExtendedString( GetColSpan() ); + + TCollection_ExtendedString align = AlignString( GetAlignment() ); + if ( align.Length() ) + aLine += align; + + if ( myUseBC ) + aLine += TCollection_ExtendedString( " bgcolor=" ) + ColorString( GetBackgroundColor() ); + + aLine += TCollection_ExtendedString( ">" ); + aHTML.Append( aLine ); + + HTMLService_HTMLParagraph::Generate( aHTML ); + if ( IsHeaderCell() ) + aHTML.Append( "" ); + else + aHTML.Append( "" ); +} + +TCollection_ExtendedString HTMLService_HTMLTableCell::CellString() const +{ + TCollection_ExtendedString txt = GetText(); + + if ( GetHeadingLevel() >= 0 ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "h" ) + TCollection_ExtendedString( GetHeadingLevel() ) ); + + if ( GetFontFlags() & Bold ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "b" ) ); + + if ( GetFontFlags() & Italic ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "i" ) ); + + if ( GetFontFlags() & Underline ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "u" ) ); + + if ( GetFontFlags() & Subscript ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "sub" ) ); + + if ( GetFontFlags() & Superscript ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "sup" ) ); + + return txt; +} diff --git a/src/HTMLService/HTMLService_HTMLTableCell.hxx b/src/HTMLService/HTMLService_HTMLTableCell.hxx new file mode 100755 index 000000000..c90c0caae --- /dev/null +++ b/src/HTMLService/HTMLService_HTMLTableCell.hxx @@ -0,0 +1,63 @@ +// File: HTMLService_HTMLTableCell.hxx +// Created: 12.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#ifndef HTMLService_HTMLTABLECELL_H +#define HTMLService_HTMLTABLECELL_H + +#include +#include + +#include + +/*! + Class HTMLService_HTMLTableCell. Generator of the HTML Table cell text. +*/ + +class HTMLSERVICE_EXPORT HTMLService_HTMLTableCell : public HTMLService_HTMLParagraph +{ +public: + Standard_EXPORT HTMLService_HTMLTableCell(); + Standard_EXPORT HTMLService_HTMLTableCell( const Handle(HTMLService_HTML)& ); + Standard_EXPORT virtual ~HTMLService_HTMLTableCell(); + + Standard_EXPORT Standard_Integer GetColSpan() const; + Standard_EXPORT Standard_Integer GetRowSpan() const; + Standard_EXPORT Standard_Integer GetAlignment() const; + Standard_EXPORT Standard_Integer GetWidth( Standard_Boolean* = 0 ) const; + + Standard_EXPORT Quantity_Color GetBackgroundColor() const; + Standard_EXPORT Standard_Boolean IsHeaderCell() const; + + Standard_EXPORT void SetColSpan( const Standard_Integer ); + Standard_EXPORT void SetRowSpan( const Standard_Integer ); + Standard_EXPORT void SetAlignment( const Standard_Integer ); + Standard_EXPORT void SetWidth( const Standard_Integer, + const Standard_Boolean = Standard_False ); + Standard_EXPORT void SetBackgroundColor( const Quantity_Color& ); + Standard_EXPORT void SetHeaderCell( const Standard_Boolean ); + +protected: + Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const; + +private: + TCollection_ExtendedString CellString() const; + +private: + Standard_Integer myWidth; + Standard_Integer myAlign; + Standard_Boolean myUseBC; + Standard_Boolean myPercent; + Standard_Integer myColSpan; + Standard_Integer myRowSpan; + Quantity_Color myBgColor; + Standard_Boolean myIsHeader; + +public: + DEFINE_STANDARD_RTTI(HTMLService_HTMLTableCell) +}; + +DEFINE_STANDARD_HANDLE(HTMLService_HTMLTableCell, HTMLService_HTMLParagraph) + +#endif diff --git a/src/HTMLService/HTMLService_HTMLTableRow.cxx b/src/HTMLService/HTMLService_HTMLTableRow.cxx new file mode 100755 index 000000000..d95376610 --- /dev/null +++ b/src/HTMLService/HTMLService_HTMLTableRow.cxx @@ -0,0 +1,86 @@ +// File: HTMLService_HTMLTableRow.cxx +// Created: 12.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#include + +IMPLEMENT_STANDARD_HANDLE(HTMLService_HTMLTableRow, HTMLService_HTML) +IMPLEMENT_STANDARD_RTTIEXT(HTMLService_HTMLTableRow, HTMLService_HTML) + +HTMLService_HTMLTableRow::HTMLService_HTMLTableRow( const Standard_Integer cells ) +: HTMLService_HTML(), +myUseBC( Standard_False ) +{ + Initialize( cells ); +} + +HTMLService_HTMLTableRow::HTMLService_HTMLTableRow( const Handle(HTMLService_HTML)& parent, const Standard_Integer cells ) +: HTMLService_HTML( parent ), +myUseBC( Standard_False ) +{ + Initialize( cells ); +} + +HTMLService_HTMLTableRow::~HTMLService_HTMLTableRow() +{ +} + +Standard_Integer HTMLService_HTMLTableRow::GetSize() const +{ + if ( myCells.IsNull() ) + return 0; + + return myCells->Length(); +} + +Handle(HTMLService_HTMLTableCell) HTMLService_HTMLTableRow::GetCell( const Standard_Integer index ) const +{ + Handle(HTMLService_HTMLTableCell) cell; + if ( !myCells.IsNull() ) + { + Standard_Integer idx = index + myCells->Lower(); + if ( idx >= myCells->Lower() && idx <= myCells->Upper() ) + cell = Handle(HTMLService_HTMLTableCell)::DownCast(myCells->Value( idx )); + } + return cell; +} + +Quantity_Color HTMLService_HTMLTableRow::GetBackgroundColor() const +{ + return myBgColor; +} + +void HTMLService_HTMLTableRow::SetBackgroundColor( const Quantity_Color& c ) +{ + myBgColor = c; + myUseBC = Standard_True; +} + +void HTMLService_HTMLTableRow::Initialize( const Standard_Integer num ) +{ + if ( num > 0 ) + myCells = new TColStd_HArray1OfTransient( 0, num - 1 ); + + if ( myCells.IsNull() ) + return; + + for ( Standard_Integer i = myCells->Lower(); i <= myCells->Upper(); i++ ) + { + Handle(HTMLService_HTMLTableCell) cell = new HTMLService_HTMLTableCell(); + myCells->SetValue( i, cell ); + InsertSubItem( cell ); + } +} + +void HTMLService_HTMLTableRow::Generate( SequenceOfHTMLLine& aHTML ) const +{ + TCollection_ExtendedString aLine( "" ); + aHTML.Append( aLine ); + SubItemsHTML( aHTML ); + aHTML.Append( TCollection_ExtendedString( "" ) ); +} diff --git a/src/HTMLService/HTMLService_HTMLTableRow.hxx b/src/HTMLService/HTMLService_HTMLTableRow.hxx new file mode 100755 index 000000000..6dd714e27 --- /dev/null +++ b/src/HTMLService/HTMLService_HTMLTableRow.hxx @@ -0,0 +1,50 @@ +// File: HTMLService_HTMLTableRow.hxx +// Created: 12.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#ifndef HTMLService_HTMLTABLEROW_H +#define HTMLService_HTMLTABLEROW_H + +#include +#include + +#include + +#include + +/*! + Class HTMLService_HTMLTableRow. Generator of the HTML Table row text. +*/ + +class HTMLSERVICE_EXPORT HTMLService_HTMLTableRow : public HTMLService_HTML +{ +public: + Standard_EXPORT HTMLService_HTMLTableRow( const Standard_Integer = 0 ); + Standard_EXPORT HTMLService_HTMLTableRow( const Handle(HTMLService_HTML)&, const Standard_Integer = 0 ); + Standard_EXPORT virtual ~HTMLService_HTMLTableRow(); + + Standard_EXPORT Standard_Integer GetSize() const; + Standard_EXPORT Handle(HTMLService_HTMLTableCell) GetCell( const Standard_Integer ) const; + + Standard_EXPORT Quantity_Color GetBackgroundColor() const; + Standard_EXPORT void SetBackgroundColor( const Quantity_Color& ); + +protected: + Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const; + +private: + void Initialize( const Standard_Integer ); + +private: + Handle(TColStd_HArray1OfTransient) myCells; + Standard_Boolean myUseBC; + Quantity_Color myBgColor; + +public: + DEFINE_STANDARD_RTTI(HTMLService_HTMLTableRow) +}; + +DEFINE_STANDARD_HANDLE(HTMLService_HTMLTableRow, HTMLService_HTML) + +#endif diff --git a/src/HTMLService/HTMLService_HTMLText.cxx b/src/HTMLService/HTMLService_HTMLText.cxx new file mode 100755 index 000000000..1af7fce5c --- /dev/null +++ b/src/HTMLService/HTMLService_HTMLText.cxx @@ -0,0 +1,105 @@ +// File: HTMLService_HTMLText.cxx +// Created: 13.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#include + +IMPLEMENT_STANDARD_HANDLE(HTMLService_HTMLText, HTMLService_HTML) +IMPLEMENT_STANDARD_RTTIEXT(HTMLService_HTMLText, HTMLService_HTML) + +HTMLService_HTMLText::HTMLService_HTMLText( const TCollection_ExtendedString& text, const Standard_Integer fontFlags ) +: HTMLService_HTML(), +myText( text ), +myHeading( -1 ), +myFontFlags( fontFlags ), +myUseColor( Standard_False ) +{ +} + +HTMLService_HTMLText::HTMLService_HTMLText( const Handle(HTMLService_HTML)& parent, + const TCollection_ExtendedString& text, const Standard_Integer fontFlags ) +: HTMLService_HTML( parent ), +myText( text ), +myHeading( -1 ), +myFontFlags( fontFlags ), +myUseColor( Standard_False ) +{ +} + +HTMLService_HTMLText::~HTMLService_HTMLText() +{ +} + +TCollection_ExtendedString HTMLService_HTMLText::GetText() const +{ + return myText; +} + +Quantity_Color HTMLService_HTMLText::GetForegroundColor() const +{ + return myColor; +} + +Standard_Integer HTMLService_HTMLText::GetFontFlags() const +{ + return myFontFlags; +} + +Standard_Integer HTMLService_HTMLText::GetHeadingLevel() const +{ + return myHeading; +} + +void HTMLService_HTMLText::SetText( const TCollection_ExtendedString& text ) +{ + myText = text; +} + +void HTMLService_HTMLText::SetForegroundColor( const Quantity_Color& c ) +{ + myColor = c; + myUseColor = Standard_True; +} + +void HTMLService_HTMLText::SetFontFlags( const Standard_Integer flags ) +{ + myFontFlags = flags; +} + +void HTMLService_HTMLText::SetHeadingLevel( const Standard_Integer level ) +{ + myHeading = level; +} + +void HTMLService_HTMLText::Generate( SequenceOfHTMLLine& aHTML ) const +{ + TCollection_ExtendedString txt = GetText(); + + if ( GetHeadingLevel() >= 0 ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "h" ) + TCollection_ExtendedString( GetHeadingLevel() ) ); + + if ( GetFontFlags() & Bold ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "b" ) ); + + if ( GetFontFlags() & Italic ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "i" ) ); + + if ( GetFontFlags() & Underline ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "u" ) ); + + if ( GetFontFlags() & StrikeOut ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "s" ) ); + + if ( GetFontFlags() & Subscript ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "sub" ) ); + + if ( GetFontFlags() & Superscript ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "sup" ) ); + + if ( myUseColor ) + txt = EncloseToTag( txt, TCollection_ExtendedString( "font" ), + TCollection_ExtendedString ( "color=" ) + ColorString( GetForegroundColor() ) ); + + aHTML.Append( txt ); +} diff --git a/src/HTMLService/HTMLService_HTMLText.hxx b/src/HTMLService/HTMLService_HTMLText.hxx new file mode 100755 index 000000000..4cd110102 --- /dev/null +++ b/src/HTMLService/HTMLService_HTMLText.hxx @@ -0,0 +1,58 @@ +// File: HTMLService_HTMLText.hxx +// Created: 13.10.2006 +// Author: Sergey TELKOV +// Copyright (C) AREVA NP 2006 + +#ifndef HTMLSERVICE_HTMLTEXT_H +#define HTMLSERVICE_HTMLTEXT_H + +#include +#include + +#include + +/*! + Class HTMLService_HTMLText. Generator of the simple HTML text. +*/ + +class HTMLSERVICE_EXPORT HTMLService_HTMLText : public HTMLService_HTML +{ +public: + enum { Normal = 0x00, Bold = 0x01, Italic = 0x02, Underline = 0x04, + StrikeOut = 0x08, Subscript = 0x10, Superscript = 0x20 } FontFlags; + +public: + Standard_EXPORT HTMLService_HTMLText( const TCollection_ExtendedString& = TCollection_ExtendedString(), + const Standard_Integer = Normal ); + Standard_EXPORT HTMLService_HTMLText( const Handle(HTMLService_HTML)&, + const TCollection_ExtendedString& = TCollection_ExtendedString(), + const Standard_Integer = Normal ); + Standard_EXPORT virtual ~HTMLService_HTMLText(); + + Standard_EXPORT TCollection_ExtendedString GetText() const; + Standard_EXPORT Standard_Integer GetFontFlags() const; + Standard_EXPORT Standard_Integer GetHeadingLevel() const; + Standard_EXPORT Quantity_Color GetForegroundColor() const; + + Standard_EXPORT void SetFontFlags( const Standard_Integer ); + Standard_EXPORT void SetHeadingLevel( const Standard_Integer ); + Standard_EXPORT void SetForegroundColor( const Quantity_Color& ); + Standard_EXPORT void SetText( const TCollection_ExtendedString& ); + +protected: + Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const; + +private: + TCollection_ExtendedString myText; + Quantity_Color myColor; + Standard_Integer myHeading; + Standard_Boolean myUseColor; + Standard_Integer myFontFlags; + +public: + DEFINE_STANDARD_RTTI(HTMLService_HTMLText) +}; + +DEFINE_STANDARD_HANDLE(HTMLService_HTMLText, HTMLService_HTML) + +#endif