1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/textrendering/texthandling/stext/TxtWriter.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,137 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#ifndef __TXTWRITER_H__
1.23 +#define __TXTWRITER_H__
1.24 +
1.25 +#include <e32std.h>
1.26 +
1.27 +//////////////////////////////////////////////////////////////////////////////////////////////
1.28 +//////////////////////////////////////////////////////////////////////////////////////////////
1.29 +// MTextWriter interface
1.30 +
1.31 +/**
1.32 +MTextWriter class is an interface, implemented by TParagraphTextWriter and
1.33 +TLineTextWriter classes. It offers two functions:
1.34 +1) void WriteL(TText aChar) - to output a single character.
1.35 +2) void FlushL() - if the implementations have stored some of the incomming characters
1.36 + for further processing, they will be immediately flushed to the output.
1.37 +They are not supposed to be called directly. MTextWriter class, together with TSLBTransaltor,
1.38 +MOutputChar, TParagraphTextWriter and TLineTextWriter classes builds a framework, used for
1.39 +correct filtering of the 0x0D and 0x0A characters and translating them to line breaks or spaces,
1.40 +depending of the text file organisation.
1.41 +@internalComponent
1.42 +*/
1.43 +class MTextWriter
1.44 + {
1.45 +public:
1.46 + virtual void WriteL(TText aChar) = 0;
1.47 + virtual void FlushL()
1.48 + {
1.49 + }
1.50 + };
1.51 +
1.52 +//////////////////////////////////////////////////////////////////////////////////////////////
1.53 +//////////////////////////////////////////////////////////////////////////////////////////////
1.54 +// MOutputChar interface
1.55 +
1.56 +/**
1.57 +MOutputChar interface offers "void OutputCharL(TText aChar)" method, which gets as an input
1.58 +character, which may be a line break or something else, but not 0x0D or 0x0A characters, which
1.59 +were filtered earlier.
1.60 +@internalComponent
1.61 +*/
1.62 +class MOutputChar
1.63 + {
1.64 +public:
1.65 + virtual void OutputCharL(TText aChar) = 0;
1.66 + };
1.67 +
1.68 +//////////////////////////////////////////////////////////////////////////////////////////////
1.69 +//////////////////////////////////////////////////////////////////////////////////////////////
1.70 +// TSLBTransaltor class
1.71 +
1.72 +/**
1.73 +TSLBTransaltor class offers functionality for processing a stream of characters, filtering
1.74 +0x0D and 0x0A characters or (0x0D 0x0A) combination, and transating them to single line breaks.
1.75 +It sends translated characters for a further processing using MTextWriter::WriteL() call.
1.76 +The translation rules are:
1.77 + - 0x0D - line break;
1.78 + - 0x0A - line break;
1.79 + - 0x0D 0x0A - line break;
1.80 +@internalComponent
1.81 +*/
1.82 +class TSLBTransaltor
1.83 + {
1.84 +public:
1.85 + inline TSLBTransaltor(MTextWriter& aTextWriter);
1.86 + void ProcessL(TText aChar);
1.87 + void FlushL();
1.88 +private:
1.89 + MTextWriter& iTextWriter;
1.90 + TText iPrevChar;
1.91 + };
1.92 +
1.93 +//////////////////////////////////////////////////////////////////////////////////////////////
1.94 +//////////////////////////////////////////////////////////////////////////////////////////////
1.95 +// TParagraphTextWriter class
1.96 +
1.97 +/**
1.98 +TParagraphTextWriter class is a concrete implementation of MTextWriter interface.
1.99 +It is used to translate line breaks in the input sequence to paragraph delimiters.
1.100 +Every line break from the input is replaced with paragraph delimiter in the output.
1.101 +MOutputChar interface is used for the output.
1.102 +@internalComponent
1.103 +*/
1.104 +NONSHARABLE_CLASS(TParagraphTextWriter) : public MTextWriter
1.105 + {
1.106 +public:
1.107 + inline TParagraphTextWriter(MOutputChar& aOutputChar);
1.108 + virtual void WriteL(TText aChar);
1.109 +private:
1.110 + MOutputChar& iOutputChar;
1.111 + };
1.112 +
1.113 +//////////////////////////////////////////////////////////////////////////////////////////////
1.114 +//////////////////////////////////////////////////////////////////////////////////////////////
1.115 +// TLineTextWriter class
1.116 +
1.117 +/**
1.118 +TLineTextWriter class is a concrete implementation of MTextWriter interface.
1.119 +It is used to translate line breaks in the input sequence to paragraph delimiters or spaces.
1.120 +The translation rules are:
1.121 + - single line break - space;
1.122 + - double line break - paragraph delimiter;
1.123 +MOutputChar interface is used for the output.
1.124 +@internalComponent
1.125 +*/
1.126 +NONSHARABLE_CLASS(TLineTextWriter) : public MTextWriter
1.127 + {
1.128 +public:
1.129 + inline TLineTextWriter(MOutputChar& aOutputChar);
1.130 + virtual void WriteL(TText aChar);
1.131 + virtual void FlushL();
1.132 +private:
1.133 + MOutputChar& iOutputChar;
1.134 + TText iPrevChar;
1.135 + };
1.136 +
1.137 +
1.138 +#include "TxtWriter.inl"
1.139 +
1.140 +#endif //__TXTWRITER_H__