htmlexp.cpp

Go to the documentation of this file.
00001 // $Id: htmlexp.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 #include "camtypes.h"
00100 #include "htmlexp.h"
00101 
00102 //#include "filters.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00103 
00104 //#include "resimmap.h"     // For all the HTML tag resources
00105 
00106 //#include "ccfile.h"           //For CCLexFile - in camtypes.h [AUTOMATICALLY REMOVED]
00107 
00108 //#include "paths.h"            //For writing out paths - in camtypes.h [AUTOMATICALLY REMOVED]
00109 
00110 
00111 CC_IMPLEMENT_DYNAMIC(HTMLExportFilter, Filter)
00112 
00113 
00114 /********************************************************************************************
00115 
00116   Constructor
00117 
00118 *********************************************************************************************/
00119 
00120 /********************************************************************************************
00121 
00122   > INT32 HTMLExportFilter::HTMLExportFilter()
00123 
00124     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00125     Created:    9/4/97
00126     Purpose:    Default constructor
00127 
00128 ********************************************************************************************/
00129 
00130 HTMLExportFilter::HTMLExportFilter()
00131 {
00132     //Set all member variables to defaults
00133     m_lCharsOnThisLine=0;
00134     m_lWordWrap=HTMLEXPORT_DEFAULTWORDWRAP;
00135     m_lIndent=0;
00136     m_fShouldWordWrap=TRUE;
00137 }
00138 
00139 
00140 /********************************************************************************************
00141 
00142   Write functions
00143 
00144 *********************************************************************************************/
00145 
00146 /********************************************************************************************
00147 
00148   > INT32 HTMLExportFilter::Write(UINT32 uiResource, CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00149 
00150     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00151     Created:    9/4/97
00152     Inputs:     uiResource      The resource to write
00153                 pfileToWrite    The file to write to (may be NULL)
00154                 pcBuffer        Pointer to the text buffer to write to (may be NULL)
00155                 fWrap           Whether to do word wrapping or not
00156                                 Set to FALSE if you want to write something
00157                                 (e.g. a tag) without this function putting
00158                                 word wrapping end of lines in.
00159 
00160     Returns:    The number of TCHARs written
00161     Purpose:    Writes the specified uiResource to the file, or the text buffer,
00162                 or both, or neither.
00163 
00164                 This function returns the number of TCHARS written. So you
00165                 can call this function first with all parameters NULL to find out
00166                 the length of the text buffer you need, then set up that text buffer,
00167                 then call this function again to write to that text buffer.
00168 
00169 ********************************************************************************************/
00170 INT32 HTMLExportFilter::Write(UINT32 uiResource, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00171 {
00172     //Construct our string
00173     String_256 strToWrite(uiResource);
00174 
00175     //Then call our sister function to write out the string
00176     return Write(strToWrite, pfileToWrite, pcBuffer);
00177 }
00178 
00179 /********************************************************************************************
00180 
00181   > INT32 HTMLExportFilter::Write(TCHAR* pcToWrite, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00182 
00183     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00184     Created:    9/4/97
00185     Inputs:     pcToWrite       The string to write
00186                 pfileToWrite    The file to write to (may be NULL)
00187                 pcBuffer        The text buffer to write to (may be NULL)
00188 
00189     Returns:    The number of TCHARs written
00190     Purpose:    Writes the specified string to the file, or the text buffer,
00191                 or both, or neither.
00192 
00193                 This function returns the number of TCHARS written. So you
00194                 can call this function first with all parameters NULL to find out
00195                 the length of the text buffer you need, then set up that text buffer,
00196                 then call this function again to write to that text buffer.
00197 
00198                 Note that this should be the *only* function that actually writes
00199                 to the file. All other write functions must call this one. That's
00200                 because this function handles the word wrapping.
00201 
00202   Notes:        This is how the word wrapping works:
00203 
00204                 First this function writes out the string passed to it (e.g. "<HTML>").
00205                 It does not put any EOLs in the middle of this string.
00206 
00207                 Then it checks to see if word wrapping is turned on (from our 
00208                 member flag m_fShouldWordWrap).
00209 
00210                 If so, it checks to see if the number of characters written on the
00211                 line so far is greater than the word wrap limit.
00212 
00213                 If so, this function puts an EOL line after the string that has
00214                 been written.
00215 
00216                 Note that, if you write an end of line string ("\r\n") directly to
00217                 the write function without calling WriteEOL, the word wrapping
00218                 will not work properly.
00219 
00220 
00221 ********************************************************************************************/
00222 INT32 HTMLExportFilter::Write(TCHAR* pcToWrite, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00223 {
00224     //If we've been passed a NULL pointer, then simply write nothing
00225     if (pcToWrite==NULL)
00226         return 0;
00227 
00228     //If we have a file, then write to it
00229     if (pfileToWrite)
00230         pfileToWrite->write(pcToWrite, camStrlen(pcToWrite));
00231 
00232     //If we have a text buffer, then write to it
00233     if (pcBuffer)
00234     {
00235         //We want to start writing at the NULL character where the text
00236         //buffer ends at the moment.
00237         
00238         //So find the length of the buffer
00239         INT32 lBufLen=camStrlen(pcBuffer);
00240 
00241         //And start writing at the NULL character
00242         camStrcpy(pcBuffer+lBufLen*sizeof(TCHAR), pcToWrite);
00243     }
00244 
00245     //So, the number of characters written is equal to the length of the string
00246     INT32 lCharsWritten= camStrlen(pcToWrite);
00247 
00248     //Now, if we should be doing word wrapping
00249     if (m_fShouldWordWrap)
00250     {
00251         //Then update the number of characters on this line
00252         m_lCharsOnThisLine+=lCharsWritten;
00253 
00254         //And if we have now exceeded the maximum number of characters
00255         //that should be written on this line
00256         if (m_lCharsOnThisLine > m_lWordWrap)
00257         {
00258             //Then write out an end of line
00259             //This will also reset m_lCharsOnThisLine to zero
00260             lCharsWritten+=WriteEOL(pfileToWrite, pcBuffer);
00261         }
00262     }
00263 
00264     //And return the number of characters written
00265     return lCharsWritten;
00266 }
00267 
00268 /********************************************************************************************
00269 
00270   > INT32 HTMLExportFilter::Write(INT32 lToWrite, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00271 
00272     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00273     Created:    9/4/97
00274     Inputs:     lToWrite        The number to write
00275                 pfileToWrite    The file to write to (may be NULL)
00276                 pcBuffer        The text buffer to write to (may be NULL)
00277     Returns:    The number of TCHARs written
00278     Purpose:    Writes the number to the file
00279 
00280 ********************************************************************************************/
00281 INT32 HTMLExportFilter::WriteNumber(INT32 lToWrite, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00282 {
00283     //Format our number
00284     String_256 strFormat;
00285 
00286     strFormat.MakeMsg(_R(IDS_HTMLEXPORT_NUMBERFORMAT), lToWrite);
00287 
00288     //And write it out
00289     return Write(strFormat, pfileToWrite, pcBuffer);
00290 }
00291 
00292 /********************************************************************************************
00293 
00294   > INT32 HTMLExportFilter::Write(DocCoord dcToWrite, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00295 
00296     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00297     Created:    9/4/97
00298     Inputs:     pcToWrite       The coordinate to write
00299                 pfileToWrite    The file to write to (may be NULL)
00300                 pcBuffer        The text buffer to write to (may be NULL)
00301     Returns:    The number of TCHARs written
00302     Purpose:    Writes the coordinate to the file, separated by
00303                 a comma:
00304 
00305                 200,100
00306 
00307 ********************************************************************************************/
00308 INT32 HTMLExportFilter::Write(DocCoord dcToWrite, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00309 {
00310     //Format our coords
00311     String_256 strFormat;
00312 
00313     strFormat.MakeMsg(_R(IDS_HTMLEXPORT_COORDFORMAT), dcToWrite.x, dcToWrite.y);
00314 
00315     //And write it out
00316     return Write(strFormat, pfileToWrite, pcBuffer);
00317 }
00318 
00319 
00320 /********************************************************************************************
00321 
00322   > INT32 HTMLExportFilter::WriteTag(UINT32 uiResource, CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00323 
00324     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00325     Created:    9/4/97
00326     Inputs:     uiResource      The resource to write
00327                 pfileToWrite    The file to write to (may be NULL)
00328                 pcBuffer        The text buffer to write to (may be NULL)
00329     Returns:    The number of TCHARs written
00330     Purpose:    Writes out the specified UI resource enclosed by < and >.
00331 
00332 ********************************************************************************************/
00333 INT32 HTMLExportFilter::WriteTag(UINT32 uiResource, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00334 {
00335     //Get our tag string
00336     String_256 strToWrite=GetTagString(uiResource);
00337 
00338     //Then call our sister function to write out the string
00339     return Write(strToWrite, pfileToWrite, pcBuffer);
00340 }
00341 
00342 /********************************************************************************************
00343 
00344   > INT32 HTMLExportFilter::WriteCloseTag(UINT32 uiResource, CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00345 
00346     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00347     Created:    18/4/97
00348     Inputs:     uiResource      The resource to write
00349                 pfileToWrite    The file to write to (may be NULL)
00350                 pcBuffer        The text buffer to write to (may be NULL)
00351     Returns:    The number of TCHARs written
00352     Purpose:    Writes out the specified UI resource enclosed by </ and >.
00353 
00354 ********************************************************************************************/
00355 INT32 HTMLExportFilter::WriteCloseTag(UINT32 uiResource, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00356 {
00357     //Get our close tag string
00358     String_256 strToWrite=GetCloseTagString(uiResource);
00359 
00360     //Then call our sister function to write out the string
00361     return Write(strToWrite, pfileToWrite, pcBuffer);
00362 }
00363 
00364 /********************************************************************************************
00365 
00366   > INT32 HTMLExportFilter::WriteStartOfTag(UINT32 uiResource, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00367 
00368     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00369     Created:    18/4/97
00370     Inputs:     uiResource      The resource to write after the start of the tag
00371                 pfileToWrite    The file to write to (may be NULL)
00372                 pcBuffer        The text buffer to write to (may be NULL)
00373     Returns:    The number of TCHARs written
00374     Purpose:    Writes out a < followed by a resource (e.g. "<IMG")
00375 
00376 ********************************************************************************************/
00377 INT32 HTMLExportFilter::WriteStartOfTag(UINT32 uiResource, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00378 {
00379     //Get our start tag string
00380     String_256 strToWrite(_R(IDS_HTMLEXPORT_TAGSTART));
00381 
00382     //Add the resource string to the end of it
00383     strToWrite+=String_256(uiResource);
00384 
00385     //Then call our sister function to write out the string
00386     //making sure the write function doesn't put an EOL
00387     //after it
00388     return Write(strToWrite, pfileToWrite, pcBuffer);
00389 }
00390 
00391 /********************************************************************************************
00392 
00393   > INT32 HTMLExportFilter::WriteStartOfTag(TCHAR* pcTag, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00394 
00395     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00396     Created:    18/4/97
00397     Inputs:     pcTag           The string to write after the start of the tag
00398                 pfileToWrite    The file to write to (may be NULL)
00399                 pcBuffer        The text buffer to write to (may be NULL)
00400     Returns:    The number of TCHARs written
00401     Purpose:    Writes out a < followed by a resource (e.g. "<IMG")
00402 
00403 ********************************************************************************************/
00404 INT32 HTMLExportFilter::WriteStartOfTag(TCHAR* pcTag, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00405 {
00406     //Get our start tag string
00407     String_256 strToWrite(_R(IDS_HTMLEXPORT_TAGSTART));
00408 
00409     //Add the resource string to the end of it
00410     strToWrite+=pcTag;
00411 
00412     //Then call our sister function to write out the string
00413     //making sure the write function doesn't put an EOL
00414     //after it
00415     return Write(strToWrite, pfileToWrite, pcBuffer);
00416 }
00417 
00418 
00419 
00420 
00421 /********************************************************************************************
00422 
00423   > INT32 HTMLExportFilter::WriteStartOfTag(CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00424 
00425     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00426     Created:    18/4/97
00427     Inputs:     uiResource      The resource to write
00428                 pfileToWrite    The file to write to (may be NULL)
00429                 pcBuffer        The text buffer to write to (may be NULL)
00430     Returns:    The number of TCHARs written
00431     Purpose:    Writes out a <
00432 
00433 ********************************************************************************************/
00434 INT32 HTMLExportFilter::WriteStartOfTag(CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00435 {
00436     //Get our close tag string
00437     String_256 strToWrite(_R(IDS_HTMLEXPORT_TAGSTART));
00438 
00439     //Then call our sister function to write out the string
00440     //making sure the write function doesn't put an EOL
00441     //after it
00442     return Write(strToWrite, pfileToWrite, pcBuffer);
00443 }
00444 
00445 /********************************************************************************************
00446 
00447   > INT32 HTMLExportFilter::WriteStartOfCloseTag(CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00448 
00449     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00450     Created:    18/4/97
00451     Inputs:     uiResource      The resource to write
00452                 pfileToWrite    The file to write to (may be NULL)
00453                 pcBuffer        The text buffer to write to (may be NULL)
00454     Returns:    The number of TCHARs written
00455     Purpose:    Writes out a <\
00456 
00457 ********************************************************************************************/
00458 INT32 HTMLExportFilter::WriteStartOfCloseTag(CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00459 {
00460     //Get our close tag string
00461     String_256 strToWrite(_R(IDS_HTMLEXPORT_CLOSETAGSTART));
00462 
00463     //Then call our sister function to write out the string
00464     //making sure the write function doesn't put an EOL
00465     //after it
00466     return Write(strToWrite, pfileToWrite, pcBuffer);
00467 }
00468 
00469 /********************************************************************************************
00470 
00471   > INT32 HTMLExportFilter::WriteEndOfTag(CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00472 
00473     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00474     Created:    18/4/97
00475     Inputs:     pfileToWrite    The file to write to (may be NULL)
00476                 pcBuffer        The text buffer to write to (may be NULL)
00477     Returns:    The number of TCHARs written
00478     Purpose:    Writes out a >
00479 
00480 ********************************************************************************************/
00481 INT32 HTMLExportFilter::WriteEndOfTag(CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00482 {
00483     //Get our close tag string
00484     String_256 strToWrite(_R(IDS_HTMLEXPORT_TAGEND));
00485 
00486     //Then call our sister function to write out the string
00487     return Write(strToWrite, pfileToWrite, pcBuffer);
00488 }
00489 
00490 
00491 /********************************************************************************************
00492 
00493   > INT32 HTMLExportFilter::WriteParameter(UINT32 uiParameter, UINT32 uiValue, CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00494 
00495     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00496     Created:    18/4/97
00497     Inputs:     uiParameter     The resource of the parameter to write (e.g. SHAPE)
00498                 uiValue         The resource of the value of the parameter (e.g. RECTANGLE)
00499                 pfileToWrite    The file to write to (may be NULL)
00500                 pcBuffer        The text buffer to write to (may be NULL)
00501     Returns:    The number of TCHARs written
00502     Purpose:    Writes out a parameter, e.g. SHAPE=RECTANGLE
00503 
00504 ********************************************************************************************/
00505 INT32 HTMLExportFilter::WriteParameter(UINT32 uiParameter, UINT32 uiValue, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00506 {
00507     //Get our two strings
00508     String_256 strParameterToWrite(uiParameter);
00509     String_256 strValueToWrite(uiValue);
00510     
00511     //Then call our sister function to write out the string
00512     return WriteParameter((TCHAR*) strParameterToWrite, (TCHAR*) strValueToWrite, pfileToWrite, pcBuffer);
00513 }
00514 
00515 /********************************************************************************************
00516 
00517   > INT32 HTMLExportFilter::WriteParameter(UINT32 uiParameter, TCHAR* pcValue, CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00518 
00519     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00520     Created:    18/4/97
00521     Inputs:     uiParameter The parameter to write (e.g. SHAPE)
00522                 pcValue         The value of the parameter (e.g. RECTANGLE)
00523                 pfileToWrite    The file to write to (may be NULL)
00524                 pcBuffer        The text buffer to write to (may be NULL)
00525     Returns:    The number of TCHARs written
00526     Purpose:    Writes out a parameter, e.g. SHAPE=RECTANGLE
00527 
00528 ********************************************************************************************/
00529 INT32 HTMLExportFilter::WriteParameter(UINT32 uiParameter, TCHAR* pcValue, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00530 {
00531     //This is the value we will return
00532     INT32 lCharsWritten=0;
00533 
00534     //First write out a space, to separate this parameter from the one before
00535     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_SPACE), pfileToWrite, pcBuffer);
00536 
00537     //Now write out the parameter
00538     lCharsWritten+=Write(uiParameter, pfileToWrite, pcBuffer);
00539                    
00540     //And an equals sign
00541     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_EQUALS), pfileToWrite, pcBuffer);
00542 
00543     //And the value
00544     lCharsWritten+=Write(pcValue, pfileToWrite, pcBuffer);
00545 
00546     //And return the number of characters written
00547     return lCharsWritten;
00548 }
00549 
00550 /********************************************************************************************
00551 
00552   > INT32 HTMLExportFilter::WriteParameter(TCHAR* pcParameter, TCHAR* pcValue, CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00553 
00554     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00555     Created:    18/4/97
00556     Inputs:     pcParameter The parameter to write (e.g. SHAPE)
00557                 pcValue         The value of the parameter (e.g. RECTANGLE)
00558                 pfileToWrite    The file to write to (may be NULL)
00559                 pcBuffer        The text buffer to write to (may be NULL)
00560     Returns:    The number of TCHARs written
00561     Purpose:    Writes out a parameter, e.g. SHAPE=RECTANGLE
00562 
00563 ********************************************************************************************/
00564 INT32 HTMLExportFilter::WriteParameter(TCHAR* pcParameter, TCHAR* pcValue, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00565 {
00566     //This is the value we will return
00567     INT32 lCharsWritten=0;
00568 
00569     //First write out a space, to separate this parameter from the one before
00570     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_SPACE), pfileToWrite, pcBuffer);
00571 
00572     //Now write out the parameter
00573     lCharsWritten+=Write(pcParameter, pfileToWrite, pcBuffer);
00574                    
00575     //And an equals sign
00576     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_EQUALS), pfileToWrite, pcBuffer);
00577 
00578     //And the value
00579     lCharsWritten+=Write(pcValue, pfileToWrite, pcBuffer);
00580 
00581     //And return the number of characters written
00582     return lCharsWritten;
00583 }
00584 
00585 /********************************************************************************************
00586 
00587   > INT32 HTMLExportFilter::WriteParameterWithQuotes(UINT32 uiParameter, UINT32 uiValue, CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00588 
00589     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00590     Created:    18/4/97
00591     Inputs:     uiParameter     The resource of the parameter to write (e.g. SHAPE)
00592                 uiValue         The resource of the value of the parameter (e.g. RECTANGLE)
00593                 pfileToWrite    The file to write to (may be NULL)
00594                 pcBuffer        The text buffer to write to (may be NULL)
00595     Returns:    The number of TCHARs written
00596     Purpose:    Writes out a parameter, putting the value in quotes,
00597                 e.g. COORDS="146, 145, 234, 132, 12, 456"
00598 
00599 ********************************************************************************************/
00600 INT32 HTMLExportFilter::WriteParameterInQuotes(UINT32 uiParameter, UINT32 uiValue, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00601 {
00602     //Get our two strings
00603     String_256 strParameterToWrite(uiParameter);
00604     String_256 strValueToWrite(uiValue);
00605     
00606     //Then call our sister function to write out the string
00607     return WriteParameterInQuotes(strParameterToWrite, strValueToWrite, pfileToWrite, pcBuffer);
00608 }
00609 
00610 /********************************************************************************************
00611 
00612   > INT32 HTMLExportFilter::WriteParameterInQuotes(UINT32 uiParameter, TCHAR* pcValue, CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00613 
00614     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00615     Created:    18/4/97
00616     Inputs:     uiParameter The parameter to write (e.g. SHAPE)
00617                 pcValue         The value of the parameter (e.g. RECTANGLE)
00618                 pfileToWrite    The file to write to (may be NULL)
00619                 pcBuffer        The text buffer to write to (may be NULL)
00620     Returns:    The number of TCHARs written
00621     Purpose:    Writes out a parameter with the value in quotes, e.g.
00622                 HREF="http://www.xara.com"
00623 
00624 ********************************************************************************************/
00625 INT32 HTMLExportFilter::WriteParameterInQuotes(UINT32 uiParameter, TCHAR* pcValue, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00626 {
00627     //This is the value we will return
00628     INT32 lCharsWritten=0;
00629 
00630     //First write out a space, to separate this parameter from the one before
00631     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_SPACE), pfileToWrite, pcBuffer);
00632 
00633     //Now write out the parameter
00634     lCharsWritten+=Write(uiParameter, pfileToWrite, pcBuffer);
00635                    
00636     //And an equals sign
00637     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_EQUALS), pfileToWrite, pcBuffer);
00638 
00639     //And an opening quote
00640     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_QUOTES), pfileToWrite, pcBuffer);
00641 
00642     //And the value
00643     lCharsWritten+=Write(pcValue, pfileToWrite, pcBuffer);
00644 
00645     //And a closing quote
00646     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_QUOTES), pfileToWrite, pcBuffer);
00647 
00648     //And return the number of characters written
00649     return lCharsWritten;
00650 }
00651 
00652 
00653 /********************************************************************************************
00654 
00655   > INT32 HTMLExportFilter::WriteParameterInQuotes(TCHAR* pcParameter, TCHAR* pcValue, CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00656 
00657     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00658     Created:    18/4/97
00659     Inputs:     pcParameter The parameter to write (e.g. SHAPE)
00660                 pcValue         The value of the parameter (e.g. RECTANGLE)
00661                 pfileToWrite    The file to write to (may be NULL)
00662                 pcBuffer        The text buffer to write to (may be NULL)
00663     Returns:    The number of TCHARs written
00664     Purpose:    Writes out a parameter with the value in quotes, e.g.
00665                 HREF="http://www.xara.com"
00666 
00667 ********************************************************************************************/
00668 INT32 HTMLExportFilter::WriteParameterInQuotes(TCHAR* pcParameter, TCHAR* pcValue, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00669 {
00670     //This is the value we will return
00671     INT32 lCharsWritten=0;
00672 
00673     //First write out a space, to separate this parameter from the one before
00674     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_SPACE), pfileToWrite, pcBuffer);
00675 
00676     //Now write out the parameter
00677     lCharsWritten+=Write(pcParameter, pfileToWrite, pcBuffer);
00678                    
00679     //And an equals sign
00680     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_EQUALS), pfileToWrite, pcBuffer);
00681 
00682     //And an opening quote
00683     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_QUOTES), pfileToWrite, pcBuffer);
00684 
00685     //And the value
00686     lCharsWritten+=Write(pcValue, pfileToWrite, pcBuffer);
00687 
00688     //And a closing quote
00689     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_QUOTES), pfileToWrite, pcBuffer);
00690 
00691     //And return the number of characters written
00692     return lCharsWritten;
00693 }
00694 
00695 /********************************************************************************************
00696 
00697 INT32 HTMLExportFilter::WriteCoords(DocRect rectToWrite, TCHAR* pcValue, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00698 
00699     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00700     Created:    18/4/97
00701     Inputs:     rectToWrite     The rectangle to write
00702                 pfileToWrite    The file to write to (may be NULL)
00703                 pcBuffer        The text buffer to write to (may be NULL)
00704     Returns:    The number of TCHARs written
00705     Purpose:    Writes out the coordinates of a rectangular area,
00706                 e.g. COORDS="0,0,100,100"
00707 
00708 ********************************************************************************************/
00709 INT32 HTMLExportFilter::WriteCoords(DocRect rectToWrite, TCHAR* pcValue, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00710 {
00711     //This is the value we will return
00712     INT32 lCharsWritten=0;
00713 
00714     //First write out a space
00715     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_SPACE), pfileToWrite, pcBuffer);
00716 
00717     //Now write out COORDS
00718     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_COORDS), pfileToWrite, pcBuffer);
00719                    
00720     //And an equals sign
00721     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_EQUALS), pfileToWrite, pcBuffer);
00722 
00723     //And an opening quote
00724     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_QUOTES), pfileToWrite, pcBuffer);
00725 
00726     //And the coords
00727     lCharsWritten+=Write(rectToWrite.lo, pfileToWrite, pcBuffer);
00728     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_COMMA), pfileToWrite, pcBuffer);
00729     lCharsWritten+=Write(rectToWrite.hi, pfileToWrite, pcBuffer);
00730     
00731     //And a closing quote
00732     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_QUOTES), pfileToWrite, pcBuffer);
00733 
00734     //And return the number of characters written
00735     return lCharsWritten;
00736 }
00737 
00738 /********************************************************************************************
00739 
00740     INT32 HTMLExportFilter::WriteCoords(Path* ppthToWrite, TCHAR* pcValue, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00741 
00742     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00743     Created:    18/4/97
00744     Inputs:     ppthToWrite     Pointer to the path to write
00745                 pfileToWrite    The file to write to (may be NULL)
00746                 pcBuffer        The text buffer to write to (may be NULL)
00747     Returns:    The number of TCHARs written
00748     Purpose:    Writes out the coordinates of a polygon
00749                 e.g. COORDS="0,0,0,100,100,100,100,0"
00750 
00751 ********************************************************************************************/
00752 INT32 HTMLExportFilter::WriteCoords(Path* ppthToWrite, TCHAR* pcValue, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00753 {
00754     //This is the value we will return
00755     INT32 lCharsWritten=0;
00756 
00757     //First write out a space
00758     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_SPACE), pfileToWrite, pcBuffer);
00759 
00760     //Now write out COORDS
00761     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_COORDS), pfileToWrite, pcBuffer);
00762                    
00763     //And an equals sign
00764     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_EQUALS), pfileToWrite, pcBuffer);
00765 
00766     //And an opening quote
00767     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_QUOTES), pfileToWrite, pcBuffer);
00768 
00769     //Now we must write out the path's coordinates. So find out how
00770     //INT32 the path is
00771     INT32 lNumCoords=ppthToWrite->GetNumCoords();
00772 
00773     //And get its coordinate and verb arrays
00774     DocCoord* pdcCoords=ppthToWrite->GetCoordArray();
00775 //  PathVerb* ppvVerbs=ppthToWrite->GetVerbArray();
00776 
00777     //Keep a copy of the last coordinate written, to make sure
00778     //we don't write out two consecutive identical coordinates
00779     DocCoord dcLastWritten=DocCoord(-1, -1);
00780 
00781     //Now do the following for every coordinate in the path
00782     //EXCEPT the last, which will be the same as the first
00783     INT32 lThisCoord=0;
00784 
00785     do
00786     {
00787         //If this coordinate isn't the same as the last one we wrote
00788         if (pdcCoords[lThisCoord]!=dcLastWritten)
00789         {
00790             //Write out a comma, unless this is the first coord to be written
00791             if (lThisCoord>0)
00792                 lCharsWritten+=Write(_R(IDS_HTMLEXPORT_COMMA), pfileToWrite, pcBuffer);
00793 
00794             //Write it out, followed by a comma
00795             lCharsWritten+=Write(pdcCoords[lThisCoord], pfileToWrite, pcBuffer);
00796         }
00797 
00798         //Keep a copy of this coordinate
00799         dcLastWritten=pdcCoords[lThisCoord];
00800 
00801         //And move on to the next coordinate
00802         ppthToWrite->FindNextEndPoint(&lThisCoord);
00803                 
00804     }
00805     while (lThisCoord<lNumCoords-1);
00806 
00807 
00808     //Write a closing quote
00809     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_QUOTES), pfileToWrite, pcBuffer);
00810 
00811     //And return the number of characters written
00812     return lCharsWritten;
00813 }
00814 
00815 /********************************************************************************************
00816 
00817     INT32 HTMLExportFilter::WriteCircleCoords(DocCoord dcCentre, INT32 lRadius, TCHAR* pcValue, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00818 
00819     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00820     Created:    18/4/97
00821     Inputs:     dcCentre        Centre of the circle to write
00822                 lRadius         Radius of the circle to write
00823                 pfileToWrite    The file to write to (may be NULL)
00824                 pcBuffer        The text buffer to write to (may be NULL)
00825     Returns:    The number of TCHARs written
00826     Purpose:    Writes out the coordinates of a circle
00827                 e.g. COORDS="200,200,100"
00828 
00829 ********************************************************************************************/
00830 INT32 HTMLExportFilter::WriteCircleCoords(DocCoord dcCentre, INT32 lRadius, TCHAR* pcValue, CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00831 {
00832     //This is the value we will return
00833     INT32 lCharsWritten=0;
00834 
00835     //First write out a space
00836     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_SPACE), pfileToWrite, pcBuffer);
00837 
00838     //Now write out COORDS
00839     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_COORDS), pfileToWrite, pcBuffer);
00840                    
00841     //And an equals sign
00842     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_EQUALS), pfileToWrite, pcBuffer);
00843 
00844     //And an opening quote
00845     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_QUOTES), pfileToWrite, pcBuffer);
00846 
00847     //The centre
00848     lCharsWritten+=Write(dcCentre, pfileToWrite, pcBuffer);
00849 
00850     //A comma
00851     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_COMMA), pfileToWrite, pcBuffer);
00852 
00853     //The radius
00854     lCharsWritten+=WriteNumber(lRadius, pfileToWrite, pcBuffer);
00855 
00856     //Write a closing quote
00857     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_QUOTES), pfileToWrite, pcBuffer);
00858 
00859     //And return the number of characters written
00860     return lCharsWritten;
00861 }
00862 
00863 
00864 
00865 
00866 /********************************************************************************************
00867 
00868   > INT32 HTMLExportFilter::WriteEOL(CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00869 
00870     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00871     Created:    18/4/97
00872     Inputs:     pfileToWrite    The file to write to (may be NULL)
00873                 pcBuffer        The text buffer to write to (may be NULL)
00874     Returns:    The number of TCHARs written
00875     Purpose:    Writes out an end of line character
00876 
00877                 Also writes out the appropriate number of tabs, according to
00878                 how much the current text is indented.
00879 
00880 ********************************************************************************************/
00881 INT32 HTMLExportFilter::WriteEOL(CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00882 {
00883     //Keep a count of the number of characters we write
00884     INT32 lCharsWritten=0;
00885 
00886     //Now, while we write out the following characters, we must turn
00887     //off word wrapping, so we don't write out an end of line and then
00888     //do word wrapping (for instance)
00889     EnableWordWrap(FALSE);
00890 
00891     //Write an end of line
00892     lCharsWritten+=Write(_R(IDS_HTMLEXPORT_EOL), pfileToWrite, pcBuffer);
00893 
00894     //Now write out the indent
00895     lCharsWritten+=WriteIndent(pfileToWrite, pcBuffer);
00896 
00897     //Set the number of characters written on this line to zero
00898     m_lCharsOnThisLine=0;
00899 
00900     //Turn word wrapping back on
00901     EnableWordWrap(TRUE);
00902 
00903     //And return the number of characters written
00904     return lCharsWritten;
00905 }
00906 
00907 /********************************************************************************************
00908 
00909   > INT32 HTMLExportFilter::WriteTab(CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00910 
00911     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00912     Created:    18/4/97
00913     Inputs:     pfileToWrite    The file to write to (may be NULL)
00914                 pcBuffer        The text buffer to write to (may be NULL)
00915     Returns:    The number of TCHARs written
00916     Purpose:    Writes out a tab character
00917 
00918 ********************************************************************************************/
00919 INT32 HTMLExportFilter::WriteTab(CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00920 {
00921     return Write(_R(IDS_HTMLEXPORT_TAB), pfileToWrite, pcBuffer);
00922 }
00923 
00924 /********************************************************************************************
00925 
00926   > INT32 HTMLExportFilter::WriteIndent(CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)
00927 
00928     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00929     Created:    18/4/97
00930     Inputs:     pfileToWrite    The file to write to (may be NULL)
00931                 pcBuffer        The text buffer to write to (may be NULL)
00932     Returns:    The number of TCHARs written
00933     Purpose:    Writes a number of tab characters equal to the current
00934                 indent level.
00935 
00936 ********************************************************************************************/
00937 INT32 HTMLExportFilter::WriteIndent(CCLexFile* pfileToWrite, TCHAR* pcBuffer)
00938 {
00939     //Keep a count of the number of characters written
00940     INT32 lCharsWritten=0;
00941 
00942     //And write out one tab for every indent level
00943     for (INT32 i=0; i<m_lIndent; i++)
00944     {
00945         lCharsWritten+=Write(_R(IDS_HTMLEXPORT_TAB), pfileToWrite, pcBuffer);
00946     }
00947 
00948     //And return the number of characters written
00949     return lCharsWritten;
00950 }
00951 
00952 
00953 
00954 
00955 /********************************************************************************************
00956 
00957   > String_256 HTMLExportFilter::GetTagString(UINT32 uiResource)
00958 
00959     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00960     Created:    9/4/97
00961     Inputs:     uiResource      The resource to convert to a tag
00962                 
00963     Returns:    The resource string enclosed in < and >.
00964     Purpose:    Gets the specified UI resource enclosed by < and >.
00965 
00966 ********************************************************************************************/
00967 String_256 HTMLExportFilter::GetTagString(UINT32 uiResource)
00968 {
00969     String_256 strStart(_R(IDS_HTMLEXPORT_TAGSTART));
00970     strStart+=String_256(uiResource);
00971     strStart+=String_256(_R(IDS_HTMLEXPORT_TAGEND));
00972 
00973     return strStart;
00974 }
00975 
00976 /********************************************************************************************
00977 
00978   > String_256 HTMLExportFilter::GetCloseTagString(UINT32 uiResource)
00979 
00980     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00981     Created:    9/4/97
00982     Inputs:     uiResource      The resource to convert to a tag
00983                 
00984     Returns:    The resource string enclosed in < and >.
00985     Purpose:    Gets the specified UI resource enclosed by < and >.
00986 
00987 ********************************************************************************************/
00988 String_256 HTMLExportFilter::GetCloseTagString(UINT32 uiResource)
00989 {
00990     String_256 strStart(_R(IDS_HTMLEXPORT_CLOSETAGSTART));
00991     strStart+=String_256(uiResource);
00992     strStart+=String_256(_R(IDS_HTMLEXPORT_TAGEND));
00993 
00994     return strStart;
00995 }
00996 
00997 
00998 
00999 
01000 
01001 

Generated on Sat Nov 10 03:45:31 2007 for Camelot by  doxygen 1.4.4