cxftext.cpp

Go to the documentation of this file.
00001 // $Id: cxftext.cpp 1445 2006-07-14 20:15:02Z phil $
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 /********************************************************************************************
00100 
00101 >   cxftext.cpp
00102 
00103     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00104     Created:    09/07/96
00105     Purpose:    Exporting functions for text related objects
00106 
00107 ********************************************************************************************/
00108 
00109 #include "camtypes.h"
00110 
00111 #ifdef DO_EXPORT
00112 
00113 #include "fontman.h"
00114 #include "nodetext.h"
00115 #include "nodetxtl.h"
00116 #include "nodetxts.h"
00117 #include "cxftags.h"
00118 //#include "cxfdefs.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00119 //#include "camfiltr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00120 //#include "cxfrec.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00121 #include "cxftext.h"
00122 #include "keypress.h"
00123 #include "vkextra.h"
00124 //#include "becomea.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00125 //#include "group.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00126 #include "attrmap.h"
00127 //#include "filtrres.h"
00128 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00129 
00130 
00131 /***********************************************************************************************
00132 
00133 >   class TextToOutlinesBecomeA: public BecomeA
00134 
00135     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00136     Created:    29/8/96
00137     Purpose:    The class that handles the convertion of text to outlines.
00138                 It receives all the paths passed back from the text story, and appends them 
00139                 to a group object.
00140 
00141 ***********************************************************************************************/
00142 
00143 // WEBSTER - markn 31/1/97
00144 // Replaced with general system
00145 /*
00146 class TextToOutlinesBecomeA : public BecomeA
00147 {
00148 CC_DECLARE_MEMDUMP(TextToOutlinesBecomeA);
00149 public:
00150     TextToOutlinesBecomeA(NodeGroup* pThisGroup) :  pGroup(pThisGroup), BecomeA(BECOMEA_PASSBACK,CC_RUNTIME_CLASS(NodePath),NULL) {};
00151     ~TextToOutlinesBecomeA();
00152 
00153     // This function should be called when Reason == BECOMEA_PASSBACK 
00154     virtual BOOL PassBack(NodeRenderableInk* pNewNode,NodeRenderableInk* pCreatedByNode,CCAttrMap* pAttrMap);
00155 
00156 private:
00157     NodeGroup* pGroup;
00158 };
00159 
00160 CC_IMPLEMENT_MEMDUMP(TextToOutlinesBecomeA,BecomeA);
00161 */
00162 
00163 //--------------------------------------------------------------------------------------
00164 
00165 // This will get Camelot to display the filename and linenumber of any memory allocations
00166 // that are not released at program exit
00167 // Declare smart memory handling in Debug builds
00168 #define new CAM_DEBUG_NEW
00169 
00170 
00171 /********************************************************************************************
00172 
00173 >   TextToOutlinesBecomeA::~TextToOutlinesBecomeA()
00174 
00175     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00176     Created:    29/8/96
00177     Inputs:     
00178     Outputs:    -
00179     Returns:    -
00180     Purpose:    The default destructor.
00181     Errors:     -
00182     SeeAlso:    -
00183 
00184 ********************************************************************************************/
00185 
00186 // WEBSTER - markn 31/1/97
00187 // Replaced with general system
00188 /*
00189 TextToOutlinesBecomeA::~TextToOutlinesBecomeA()
00190 {
00191 }
00192 */
00193 /********************************************************************************************
00194 
00195 >   BOOL TextToOutlinesBecomeA::PassBack(NodeRenderableInk* pNewNode,NodeRenderableInk* pCreatedByNode,CCAttrMap* pAttrMap)
00196 
00197     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00198     Created:    29/8/96
00199     Inputs:     pNewNode = the node created by the object being made into shapes
00200                 pCreatedByNode = ptr to the node that created the new node
00201                 pAttrMap = ptr to attrs (can be NULL)
00202     Outputs:    -
00203     Returns:    TRUE if the new path was used successfully, FALSE if op should be aborted
00204     Purpose:    This receives the paths from the selected objects and joins them to pJoinedPath.
00205     Errors:     -
00206     SeeAlso:    -
00207 
00208 ********************************************************************************************/
00209 
00210 // WEBSTER - markn 31/1/97
00211 // Replaced with general system
00212 /*
00213 BOOL TextToOutlinesBecomeA::PassBack(NodeRenderableInk* pNewNode,NodeRenderableInk* pCreatedByNode,CCAttrMap* pAttrMap)
00214 {
00215 #ifdef DO_EXPORT
00216     ERROR2IF(pGroup == NULL,FALSE,"NULL group");
00217     ERROR2IF(pNewNode == NULL,FALSE,"NULL new path");
00218 
00219     // We only expect to get paths, so do a check
00220     if (!pNewNode->IsNodePath())
00221     {
00222         ERROR3("Received a node that's not a NodePath");
00223         return TRUE;
00224     }
00225 
00226     BOOL ok = TRUE;
00227 
00228     // Attach the next path as the last child of the group node
00229     pNewNode->AttachNode(pGroup,LASTCHILD);
00230 
00231     // Apply the supplied attrs, if there are any
00232     if (pAttrMap != NULL)
00233         ok = pNewNode->ApplyAttributes(pAttrMap,TRUE);
00234     else
00235     {
00236         // No supplied attrs, so we need to apply the applied attrs of the node that created the
00237         // path to the path itself, so that it will have the same appearence
00238 
00239         ok = FALSE; // Assume failure (as we do when promised a bonus)
00240 
00241         // Create an attr map with the applied attrs of the "created by" node
00242         pAttrMap = CCAttrMap::MakeAppliedAttrMap(pCreatedByNode);
00243         if (pAttrMap != NULL)
00244         {
00245             ok = pNewNode->ApplyAttributes(pAttrMap,TRUE);      // Apply these attrs to the path
00246             // Delete the attr map
00247             delete pAttrMap;
00248             pAttrMap = NULL;
00249         }
00250     }
00251 
00252     return ok;
00253 #else
00254     return FALSE;
00255 #endif
00256 }
00257 */
00258 //-------------------------------------------------------------------------
00259 //-------------------------------------------------------------------------
00260 //-------------------------------------------------------------------------
00261 
00262 /********************************************************************************************
00263 
00264 >   static BOOL CXaraFileTxtStory::WriteTextStoryAsOutlines(BaseCamelotFilter *pFilter, TextStory *pStory)
00265 
00266     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00267     Created:    29/8/96
00268     Inputs:     pFilter = filter to write records to
00269                 pStory  = the text story to convert to paths
00270     Returns:    TRUE if one or more records were written, FALSE otherwise
00271     Purpose:    Converts the text story into a group of paths, and then outputs that group
00272                 to the filter
00273     Errors:     Errors via pFilter->GotError() if if fails to create the group of paths properly.
00274 
00275 ********************************************************************************************/
00276 
00277 // WEBSTER - markn 31/1/97
00278 // Replaced with general system
00279 /*
00280 BOOL CXaraFileTxtStory::WriteTextStoryAsOutlines(BaseCamelotFilter *pFilter, TextStory *pStory)
00281 {
00282     ERROR3("Shouldn't call this,  Use BaseCamelotFilter::WriteNodeAsOutlines() instead");
00283 
00284 #ifdef DO_EXPORT
00285     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00286     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00287 
00288     BOOL ok = TRUE;
00289 
00290     NodeGroup* pGroup = pFilter->FindTextStoryGroupRefGroup(pStory);
00291 
00292     if (pGroup == NULL)
00293     {
00294         // Create a group to hold all the outlines
00295         pGroup = new NodeGroup;
00296         ok = ok && (pGroup != NULL);
00297 
00298         // Create a BecomeA object that will receive all the outlines and attach them as children
00299         // of the group
00300         TextToOutlinesBecomeA* pBecomeA = new TextToOutlinesBecomeA(pGroup);
00301         ok = ok && (pBecomeA != NULL);
00302 
00303         // Collect all the outlines
00304         if (ok) ok = pStory->DoBecomeA(pBecomeA);
00305 
00306         // This code factors out the unnecessary attributes by placing the group in the tree, normalising
00307         // the attrs for all the paths in the group, then removing the group from the tree again
00308         if (ok)
00309         {
00310             // Attach it next to the text story
00311             pGroup->AttachNode(pStory,NEXT);
00312 
00313             // Ask all the child objects in the group to normalise the attributes
00314             Node* pNode = pGroup->FindFirstChild();
00315             while (pNode != NULL)
00316             {
00317                 if (pNode->IsAnObject())
00318                     ((NodeRenderableInk*)pNode)->NormaliseAttributes();
00319                 pNode = pNode->FindNext();
00320             }
00321 
00322             // Unlink the group from the tree
00323             pGroup->UnlinkNodeFromTree();
00324         }
00325 
00326         // Add it to the list of textstory/groups ref list items
00327         if (ok) pFilter->AddTextStoryGroupRefToList(pStory,pGroup);
00328 
00329         // Tidy up
00330         if (pBecomeA != NULL)
00331         {
00332             delete pBecomeA;
00333             pBecomeA = NULL;
00334         }
00335     }
00336 
00337     // Now write out the group to the file
00338     if (ok) ok = pFilter->WriteNodes(pGroup);
00339 
00340     // Report a general error if necessary
00341     if (!ok)
00342         pFilter->GotError(_R(IDS_EXPORT_ERROR_TEXTTOOUTLINE));
00343 
00344     return ok;
00345 #else
00346     return FALSE;
00347 #endif
00348 }
00349 */
00350 //-----------------------------------------------------------------------------------
00351 //-----------------------------------------------------------------------------------
00352 //-----------------------------------------------------------------------------------
00353 //-----------------------------------------------------------------------------------
00354 
00355 /********************************************************************************************
00356 
00357 >   static BOOL CXaraFileTxtStory::IsGuaranteedFont(BaseCamelotFilter *pFilter,String_64* pFontName)
00358 
00359     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00360     Created:    29/8/96
00361     Inputs:     pFilter = ptr to filter
00362                 pFontName = ptr to a string containing the font name
00363     Returns:    TRUE if the given font name is in the list of guaranteed font names
00364                 FALSE otherwise
00365     Purpose:    This scans the list of guaranteed font names.
00366                 If the font name given matches one in the list, then TRUE is returned
00367 
00368     Errors:     -
00369 
00370 ********************************************************************************************/
00371 
00372 BOOL CXaraFileTxtStory::IsGuaranteedFont(BaseCamelotFilter *pFilter,String_64* pFontName)
00373 {
00374 #ifdef DO_EXPORT
00375     ERROR2IF(pFontName == NULL,FALSE,"NULL font name ptr");
00376 
00377     String_256 GuaranteedFonts = pFilter->GetDontConvertTheseFontsToOutlinesString();
00378     String_64  GuaranteedFontName;
00379     String_64  Delimiters = _T(";");
00380     String_64  Str;
00381 
00382     TCHAR* pTchar = cc_lstrtok(GuaranteedFonts,Delimiters);
00383     while (pTchar != NULL)
00384     {
00385         Str = pTchar;
00386         if (*pFontName == Str)
00387             return TRUE;
00388 
00389         pTchar = cc_lstrtok(NULL,Delimiters);
00390     }
00391 
00392     return FALSE;
00393 #else
00394     return FALSE;
00395 #endif
00396 }
00397 
00398 /********************************************************************************************
00399 
00400 >   static BOOL CXaraFileTxtStory::SiblingAndChildTypefaceAttrsAllGuaranteedFonts(BaseCamelotFilter *pFilter,Node* pNode)
00401 
00402     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00403     Created:    29/8/96
00404     Inputs:     pFilter = ptr to filter
00405                 pNode = ptr to a node tree
00406     Returns:    TRUE if all sibling & child typeface attrs define guaranteed fonts
00407                 FALSE otherwise
00408     Purpose:    This func does a sibling scan and depth-first traversal from the point of the
00409                 given node, hunting for typeface attrs.
00410 
00411                 If it finds one attr that does *not* define a guaranteed font, then FALSE is returned.
00412 
00413                 Otherwise TRUE is returned
00414 
00415     Errors:     -
00416 
00417 ********************************************************************************************/
00418 
00419 BOOL CXaraFileTxtStory::SiblingAndChildTypefaceAttrsAllGuaranteedFonts(BaseCamelotFilter *pFilter,Node* pNode)
00420 {
00421 #ifdef DO_EXPORT
00422     if (pNode == NULL)
00423         return TRUE;
00424 
00425     String_64 FontName;
00426 
00427     while (pNode != NULL)
00428     {
00429         // Only check the child nodes if the node is not a Caret or EOL node.
00430         if (!IS_A(pNode,CaretNode) && !IS_A(pNode,EOLNode))
00431         {
00432             if (!SiblingAndChildTypefaceAttrsAllGuaranteedFonts(pFilter,pNode->FindFirstChild()))
00433                 return FALSE;
00434         }
00435 
00436         if (IS_A(pNode,AttrTxtFontTypeface))
00437         {
00438             AttrTxtFontTypeface* pTypefaceAttr = (AttrTxtFontTypeface*)pNode;
00439 
00440             if (FONTMANAGER->GetFontName(pTypefaceAttr->Value.HTypeface, FontName))
00441             {
00442                 if (!IsGuaranteedFont(pFilter,&FontName))
00443                     return FALSE;
00444             }
00445         }
00446 
00447         pNode = pNode->FindNext();
00448     }
00449 
00450     return TRUE;
00451 #else
00452     return FALSE;
00453 #endif
00454 }
00455 
00456 /********************************************************************************************
00457 
00458 >   static BOOL CXaraFileTxtStory::MustConvertToOutlines(BaseCamelotFilter *pFilter, TextStory *pStory)
00459 
00460     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00461     Created:    29/8/96
00462     Inputs:     pFilter = filter to write records to
00463                 pStory  = the text story to convert to paths
00464     Returns:    TRUE if it has to be written out as paths, FALSE otherwise
00465     Purpose:    Checks to see if the given text story has to be written out as paths.
00466 
00467                 Some text stories don't have to be written out as outlines, because they only
00468                 contain fonts that are deemed to be guaranteed to be available.
00469 
00470                 The default guaranteed font list is:
00471                     Times New Roman
00472                     Arial
00473                     Courier New
00474 
00475     Errors:     -
00476 
00477 ********************************************************************************************/
00478 
00479 BOOL CXaraFileTxtStory::MustConvertToOutlines(BaseCamelotFilter *pFilter, TextStory *pStory)
00480 {
00481 #ifdef DO_EXPORT
00482     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00483     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00484 
00485     // Do a fast check - if there are no font names in the list, then don't bother doing any checking
00486     // because all fonts must have to be converted to outlines
00487     String_256 GuaranteedFonts = pFilter->GetDontConvertTheseFontsToOutlinesString();
00488     if (GuaranteedFonts.IsEmpty())
00489         return TRUE;
00490 
00491     BOOL Must = FALSE;
00492 
00493     String_64 FontName;
00494 
00495     CCAttrMap* pAttrMap = CCAttrMap::MakeAppliedAttrMap(pStory);
00496 
00497     if (pAttrMap != NULL)
00498     {
00499         void* pValue=NULL;
00500         pAttrMap->Lookup(CC_RUNTIME_CLASS(AttrTxtFontTypeface),pValue);
00501         if (pValue != NULL)
00502         {
00503             AttrTxtFontTypeface* pTypefaceAttr = (AttrTxtFontTypeface*)pValue;
00504 
00505             if (IS_A(pTypefaceAttr,AttrTxtFontTypeface))
00506             {
00507                 if (FONTMANAGER->GetFontName(pTypefaceAttr->Value.HTypeface, FontName))
00508                 {
00509                     if (!IsGuaranteedFont(pFilter,&FontName))
00510                         Must = TRUE;
00511                 }
00512             }
00513         }
00514 
00515         // Delete the attr map
00516         delete pAttrMap;
00517         pAttrMap = NULL;
00518     }
00519 
00520     if (!Must)
00521         Must = !SiblingAndChildTypefaceAttrsAllGuaranteedFonts(pFilter,pStory->FindFirstChild());
00522 
00523     return Must;
00524 #else
00525     return FALSE;
00526 #endif
00527 }
00528 
00529 
00530 /********************************************************************************************
00531 
00532 >   BOOL CXaraFileTxtStory::WritePreChildrenWeb(BaseCamelotFilter *pFilter, TextStory *pStory);
00533     BOOL CXaraFileTxtStory::WritePreChildrenNative(BaseCamelotFilter *pFilter, TextStory *pStory);
00534     BOOL CXaraFileTxtStory::WriteTextStory(BaseCamelotFilter *pFilter, TextStory *pStory);
00535 
00536     BOOL CXaraFileTxtStory::WriteTextStorySimple(BaseCamelotFilter *pFilter, TextStory *pStory);
00537     BOOL CXaraFileTxtStory::WriteTextStoryComplex(BaseCamelotFilter *pFilter, TextStory *pStory);
00538     BOOL CXaraFileTxtStory::WriteTextStorySimpleStartLeft(BaseCamelotFilter *pFilter, TextStory *pStory);
00539     BOOL CXaraFileTxtStory::WriteTextStorySimpleStartRight(BaseCamelotFilter *pFilter, TextStory *pStory);
00540     BOOL CXaraFileTxtStory::WriteTextStorySimpleEndLeft(BaseCamelotFilter *pFilter, TextStory *pStory);
00541     BOOL CXaraFileTxtStory::WriteTextStorySimpleEndRight(BaseCamelotFilter *pFilter, TextStory *pStory);
00542     BOOL CXaraFileTxtStory::WriteTextStoryComplexStartLeft(BaseCamelotFilter *pFilter, TextStory *pStory);
00543     BOOL CXaraFileTxtStory::WriteTextStoryComplexStartRight(BaseCamelotFilter *pFilter, TextStory *pStory);
00544     BOOL CXaraFileTxtStory::WriteTextStoryComplexEndLeft(BaseCamelotFilter *pFilter, TextStory *pStory);
00545     BOOL CXaraFileTxtStory::WriteTextStoryComplexEndRight(BaseCamelotFilter *pFilter, TextStory *pStory);
00546     
00547     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00548     Created:    10/07/96
00549     Inputs:     pFilter     - new file format to save record to
00550                 pStory      - TextStory node to save
00551     Returns:    TRUE if successful, FALSE otherwise
00552     Purpose:    Exports text story records to the new file format
00553 
00554 ********************************************************************************************/
00555 
00556 BOOL CXaraFileTxtStory::WritePreChildrenWeb(BaseCamelotFilter *pFilter, TextStory *pStory)
00557 {
00558 #ifdef DO_EXPORT
00559     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00560     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00561 
00562     // If this story should not be exported for what ever reason (e.g. it contains no characters)
00563     // then just return FALSE (see also CanWriteChildren...)
00564     if (!pStory->OKToExport())
00565         return FALSE;
00566 
00567     // WEBSTER - markn 29/1/97
00568     // Part of the general form of the system used to convert text to outlines in v1.5
00569     if (pFilter->GetConvertTextToOutlines() && MustConvertToOutlines(pFilter,pStory))
00570         return pFilter->WriteNodeAsOutlines(pStory);
00571 
00572 //  if (pFilter->GetConvertTextToOutlines() && MustConvertToOutlines(pFilter,pStory))
00573 //      return WriteTextStoryAsOutlines(pFilter,pStory);
00574 
00575     return WriteTextStory(pFilter, pStory);
00576 #else
00577     return FALSE;
00578 #endif
00579 }
00580 
00581 BOOL CXaraFileTxtStory::WritePreChildrenNative(BaseCamelotFilter *pFilter, TextStory *pStory)
00582 {
00583 #ifdef DO_EXPORT
00584     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00585     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00586 
00587     // If this story should not be exported for what ever reason (e.g. it contains no characters)
00588     // then just return FALSE (see also CanWriteChildren...)
00589     if (!pStory->OKToExport())
00590         return FALSE;
00591 
00592     if (pFilter->IsCompactNativeFilter())
00593     {
00594         // WEBSTER - markn 29/1/97
00595         // Part of the general form of the system used to convert text to outlines in v1.5
00596         if (pFilter->GetConvertTextToOutlines() && MustConvertToOutlines(pFilter,pStory))
00597             return pFilter->WriteNodeAsOutlines(pStory);
00598 
00599         //  if (pFilter->GetConvertTextToOutlines() && MustConvertToOutlines(pFilter,pStory))
00600         //      return WriteTextStoryAsOutlines(pFilter,pStory);
00601     }
00602 
00603     return WriteTextStory(pFilter, pStory);
00604 #else
00605     return FALSE;
00606 #endif
00607 }
00608 
00609 BOOL CXaraFileTxtStory::CanWriteChildrenWeb(BaseCamelotFilter* pFilter,TextStory *pStory)
00610 {
00611 #ifdef DO_EXPORT
00612     if (!pStory->OKToExport())
00613         return FALSE;
00614 
00615     if (pFilter->GetConvertTextToOutlines() && MustConvertToOutlines(pFilter,pStory))
00616         return FALSE;
00617 
00618     return TRUE;
00619 #else
00620     return FALSE;
00621 #endif
00622 }
00623 
00624 BOOL CXaraFileTxtStory::CanWriteChildrenNative(BaseCamelotFilter* pFilter,TextStory *pStory)
00625 {
00626 #ifdef DO_EXPORT
00627     if (!pStory->OKToExport())
00628         return FALSE;
00629 
00630     if (pFilter->IsCompactNativeFilter())
00631     {
00632         if (pFilter->GetConvertTextToOutlines() && MustConvertToOutlines(pFilter,pStory))
00633             return FALSE;
00634     }
00635 
00636     return TRUE;
00637 #else
00638     return FALSE;
00639 #endif
00640 }
00641 
00642 BOOL CXaraFileTxtStory::WriteTextStory(BaseCamelotFilter *pFilter, TextStory *pStory)
00643 {
00644 #ifdef DO_EXPORT
00645     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00646     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00647 
00648     BOOL ok;
00649 
00650     // we break text stories into 10 different types, depending on how the text has been
00651     // transformed and how it is fitted to a path. using this information we jump to one
00652     // of the following functions to write the information out for us.
00653 
00654     if (pStory->GetTextPath() == NULL)
00655     {
00656         // this text story is _not_ fitted to a path, which makes a few things easier.
00657         // find out whether the associated matrix is the identity or not.
00658         Matrix MyMatrix = pStory->GetStoryMatrix();
00659 
00660         if (MyMatrix.IsTranslation(mEpsilon))
00661         {
00662             ok = WriteTextStorySimple(pFilter, pStory);
00663         }
00664         else
00665         {
00666             ok = WriteTextStoryComplex(pFilter, pStory);
00667         }
00668     }
00669     else
00670     {
00671         const INT32 COMPLEX = 0x1;
00672         const INT32 REVERSED = 0x2;
00673         const INT32 Y_REFLECTED = 0x4;
00674 
00675         INT32 TextStoryType = 0;
00676 
00677         {
00678             Matrix MyMatrix = pStory->GetStoryMatrix();
00679             ANGLE MyRotation = pStory->GetCharsRotation();
00680             ANGLE MyShear = pStory->GetCharsShear();
00681 
00682             if (MyMatrix.IsTranslation(mEpsilon)==FALSE
00683                 || MyRotation!=0
00684                 || MyShear!=0) TextStoryType |= COMPLEX;
00685         }
00686 
00687         if (pStory->IsTextOnPathReversed()) TextStoryType |= REVERSED;
00688 
00689         if (pStory->GetCharsScale() < 0) TextStoryType |= Y_REFLECTED;
00690 
00691         switch (TextStoryType)
00692         {
00693             case 0                              : ok = WriteTextStorySimpleStartLeft(pFilter, pStory); break;
00694             case REVERSED                       : ok = WriteTextStorySimpleEndRight(pFilter, pStory); break;
00695             case Y_REFLECTED                    : ok = WriteTextStorySimpleStartRight(pFilter, pStory); break;
00696             case REVERSED|Y_REFLECTED           : ok = WriteTextStorySimpleEndLeft(pFilter, pStory); break;
00697             case COMPLEX                        : ok = WriteTextStoryComplexStartLeft(pFilter, pStory); break;
00698             case COMPLEX|REVERSED               : ok = WriteTextStoryComplexEndRight(pFilter, pStory); break;
00699             case COMPLEX|Y_REFLECTED            : ok = WriteTextStoryComplexStartRight(pFilter, pStory); break;
00700             case COMPLEX|REVERSED|Y_REFLECTED   : ok = WriteTextStoryComplexEndLeft(pFilter, pStory); break;
00701             default                             : ok = WriteTextStoryInvalid(pFilter, pStory); break;
00702         }
00703     }
00704 
00705     return ok;
00706 #else
00707     return FALSE;
00708 #endif
00709 }
00710 
00711 BOOL CXaraFileTxtStory::WriteTextStorySimple(BaseCamelotFilter *pFilter, TextStory *pStory)
00712 {
00713 #ifdef DO_EXPORT
00714     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00715     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00716 
00717     BOOL ok;
00718 
00719     Matrix MyMatrix;
00720     DocCoord MyTranslation;
00721 
00722     MyMatrix = pStory->GetStoryMatrix();
00723     MyMatrix.GetTranslation(MyTranslation);
00724 
00725     CamelotFileRecord Rec(pFilter, TAG_TEXT_STORY_SIMPLE, TAG_TEXT_STORY_SIMPLE_SIZE);
00726     ok = Rec.Init();
00727     if (ok) ok = Rec.WriteCoord(MyTranslation);
00728     if (ok) ok = Rec.WriteINT32 ((INT32) pStory->IsAutoKerning ());
00729     if (ok) ok = pFilter->Write(&Rec);
00730 
00731     return ok;
00732 #else
00733     return FALSE;
00734 #endif
00735 }
00736 
00737 BOOL CXaraFileTxtStory::WriteTextStoryComplex(BaseCamelotFilter *pFilter, TextStory *pStory)
00738 {
00739 #ifdef DO_EXPORT
00740     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00741     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00742 
00743     BOOL ok;
00744 
00745     CamelotFileRecord Rec(pFilter, TAG_TEXT_STORY_COMPLEX, TAG_TEXT_STORY_COMPLEX_SIZE);
00746     ok = Rec.Init();
00747     if (ok) ok = Rec.WriteMatrix(pStory->GetStoryMatrix());
00748     if (ok) ok = Rec.WriteINT32 ((INT32) pStory->IsAutoKerning ());
00749     if (ok) ok = pFilter->Write(&Rec);
00750 
00751     return ok;
00752 #else
00753     return FALSE;
00754 #endif
00755 }
00756 
00757 BOOL CXaraFileTxtStory::WriteTextStorySimpleStartLeft(BaseCamelotFilter *pFilter, TextStory *pStory)
00758 {
00759 #ifdef DO_EXPORT
00760     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00761     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00762 
00763     BOOL ok;
00764 
00765     Matrix MyMatrix;
00766     DocCoord MyTranslation;
00767 
00768     MyMatrix = pStory->GetStoryMatrix();
00769     MyMatrix.GetTranslation(MyTranslation);
00770 
00771     CamelotFileRecord Rec(pFilter, TAG_TEXT_STORY_SIMPLE_START_LEFT, TAG_TEXT_STORY_SIMPLE_START_LEFT_SIZE);
00772     ok = Rec.Init();
00773 
00774     if (ok) ok = Rec.WriteCoord(MyTranslation);
00775     if (ok) ok = Rec.WriteINT32 ((INT32) pStory->IsAutoKerning ());
00776     if (ok) ok = pFilter->Write(&Rec);
00777 
00778     return ok;
00779 #else
00780     return FALSE;
00781 #endif
00782 }
00783 
00784 BOOL CXaraFileTxtStory::WriteTextStorySimpleStartRight(BaseCamelotFilter *pFilter, TextStory *pStory)
00785 {
00786 #ifdef DO_EXPORT
00787     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00788     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00789 
00790     BOOL ok;
00791 
00792     Matrix MyMatrix;
00793     DocCoord MyTranslation;
00794 
00795     MyMatrix = pStory->GetStoryMatrix();
00796     MyMatrix.GetTranslation(MyTranslation);
00797 
00798     CamelotFileRecord Rec(pFilter, TAG_TEXT_STORY_SIMPLE_START_RIGHT, TAG_TEXT_STORY_SIMPLE_START_RIGHT_SIZE);
00799     ok = Rec.Init();
00800 
00801     if (ok) ok = Rec.WriteCoord(MyTranslation);
00802     if (ok) ok = Rec.WriteINT32 ((INT32) pStory->IsAutoKerning ());
00803     if (ok) ok = pFilter->Write(&Rec);
00804 
00805     return ok;
00806 #else
00807     return FALSE;
00808 #endif
00809 }
00810 
00811 BOOL CXaraFileTxtStory::WriteTextStorySimpleEndLeft(BaseCamelotFilter *pFilter, TextStory *pStory)
00812 {
00813 #ifdef DO_EXPORT
00814     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00815     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00816 
00817     BOOL ok;
00818 
00819     Matrix MyMatrix;
00820     DocCoord MyTranslation;
00821 
00822     MyMatrix = pStory->GetStoryMatrix();
00823     MyMatrix.GetTranslation(MyTranslation);
00824 
00825     CamelotFileRecord Rec(pFilter, TAG_TEXT_STORY_SIMPLE_END_LEFT, TAG_TEXT_STORY_SIMPLE_END_LEFT_SIZE);
00826     ok = Rec.Init();
00827 
00828     if (ok) ok = Rec.WriteCoord(MyTranslation);
00829     if (ok) ok = Rec.WriteINT32 ((INT32) pStory->IsAutoKerning ());
00830     if (ok) ok = pFilter->Write(&Rec);
00831 
00832     return ok;
00833 #else
00834     return FALSE;
00835 #endif
00836 }
00837 
00838 BOOL CXaraFileTxtStory::WriteTextStorySimpleEndRight(BaseCamelotFilter *pFilter, TextStory *pStory)
00839 {
00840 #ifdef DO_EXPORT
00841     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00842     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00843 
00844     BOOL ok;
00845 
00846     Matrix MyMatrix;
00847     DocCoord MyTranslation;
00848 
00849     MyMatrix = pStory->GetStoryMatrix();
00850     MyMatrix.GetTranslation(MyTranslation);
00851 
00852     CamelotFileRecord Rec(pFilter, TAG_TEXT_STORY_SIMPLE_END_RIGHT, TAG_TEXT_STORY_SIMPLE_END_RIGHT_SIZE);
00853     ok = Rec.Init();
00854 
00855     if (ok) ok = Rec.WriteCoord(MyTranslation);
00856     if (ok) ok = Rec.WriteINT32 ((INT32) pStory->IsAutoKerning ());
00857     if (ok) ok = pFilter->Write(&Rec);
00858 
00859     return ok;
00860 #else
00861     return FALSE;
00862 #endif
00863 }
00864 
00865 BOOL CXaraFileTxtStory::WriteTextStoryComplexStartLeft(BaseCamelotFilter *pFilter, TextStory *pStory)
00866 {
00867 #ifdef DO_EXPORT
00868     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00869     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00870 
00871     BOOL ok;
00872 
00873     CamelotFileRecord Rec(pFilter, TAG_TEXT_STORY_COMPLEX_START_LEFT, TAG_TEXT_STORY_COMPLEX_START_LEFT_SIZE);
00874     ok = Rec.Init();
00875 
00876     if (ok) ok = Rec.WriteMatrix(pStory->GetStoryMatrix());
00877     if (ok) ok = Rec.WriteANGLE(pStory->GetCharsRotation());
00878     if (ok) ok = Rec.WriteANGLE(pStory->GetCharsShear());
00879     if (ok) ok = Rec.WriteINT32 ((INT32) pStory->IsAutoKerning ());
00880 
00881     if (ok) ok = pFilter->Write(&Rec);
00882 
00883     return ok;
00884 #else
00885     return FALSE;
00886 #endif
00887 }
00888 
00889 BOOL CXaraFileTxtStory::WriteTextStoryComplexStartRight(BaseCamelotFilter *pFilter, TextStory *pStory)
00890 {
00891 #ifdef DO_EXPORT
00892     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00893     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00894 
00895     BOOL ok;
00896 
00897     CamelotFileRecord Rec(pFilter, TAG_TEXT_STORY_COMPLEX_START_RIGHT, TAG_TEXT_STORY_COMPLEX_START_RIGHT_SIZE);
00898     ok = Rec.Init();
00899 
00900     if (ok) ok = Rec.WriteMatrix(pStory->GetStoryMatrix());
00901     if (ok) ok = Rec.WriteANGLE(pStory->GetCharsRotation());
00902     if (ok) ok = Rec.WriteANGLE(pStory->GetCharsShear());
00903     if (ok) ok = Rec.WriteINT32 ((INT32) pStory->IsAutoKerning ());
00904 
00905     if (ok) ok = pFilter->Write(&Rec);
00906 
00907     return ok;
00908 #else
00909     return FALSE;
00910 #endif
00911 }
00912 
00913 BOOL CXaraFileTxtStory::WriteTextStoryComplexEndLeft(BaseCamelotFilter *pFilter, TextStory *pStory)
00914 {
00915 #ifdef DO_EXPORT
00916     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00917     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00918 
00919     BOOL ok;
00920 
00921     CamelotFileRecord Rec(pFilter, TAG_TEXT_STORY_COMPLEX_END_LEFT, TAG_TEXT_STORY_COMPLEX_END_LEFT_SIZE);
00922     ok = Rec.Init();
00923 
00924     if (ok) ok = Rec.WriteMatrix(pStory->GetStoryMatrix());
00925     if (ok) ok = Rec.WriteANGLE(pStory->GetCharsRotation());
00926     if (ok) ok = Rec.WriteANGLE(pStory->GetCharsShear());
00927     if (ok) ok = Rec.WriteINT32 ((INT32) pStory->IsAutoKerning ());
00928 
00929     if (ok) ok = pFilter->Write(&Rec);
00930 
00931     return ok;
00932 #else
00933     return FALSE;
00934 #endif
00935 }
00936 
00937 BOOL CXaraFileTxtStory::WriteTextStoryComplexEndRight(BaseCamelotFilter *pFilter, TextStory *pStory)
00938 {
00939 #ifdef DO_EXPORT
00940     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00941     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00942 
00943     BOOL ok;
00944 
00945     CamelotFileRecord Rec(pFilter, TAG_TEXT_STORY_COMPLEX_END_RIGHT, TAG_TEXT_STORY_COMPLEX_END_RIGHT_SIZE);
00946     ok = Rec.Init();
00947 
00948     if (ok) ok = Rec.WriteMatrix(pStory->GetStoryMatrix());
00949     if (ok) ok = Rec.WriteANGLE(pStory->GetCharsRotation());
00950     if (ok) ok = Rec.WriteANGLE(pStory->GetCharsShear());
00951     if (ok) ok = Rec.WriteINT32 ((INT32) pStory->IsAutoKerning ());
00952 
00953     if (ok) ok = pFilter->Write(&Rec);
00954 
00955     return ok;
00956 #else
00957     return FALSE;
00958 #endif
00959 }
00960 
00961 BOOL CXaraFileTxtStory::WriteTextStoryWordWrapInfo(BaseCamelotFilter *pFilter, TextStory *pStory)
00962 {
00963 #ifdef DO_EXPORT
00964     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00965     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00966 
00967     CamelotFileRecord Rec(pFilter, TAG_TEXT_STORY_WORD_WRAP_INFO, TAG_TEXT_STORY_WORD_WRAP_INFO_SIZE);
00968 
00969     BOOL ok = Rec.Init();
00970     if (ok) ok = Rec.WriteINT32(pStory->GetStoryWidth());
00971     if (ok) ok = Rec.WriteBYTE(BYTE(pStory->IsWordWrapping() != 0));
00972     if (ok) ok = pFilter->Write(&Rec);
00973 
00974     return ok;
00975 #else
00976     return FALSE;
00977 #endif
00978 }
00979 
00980 BOOL CXaraFileTxtStory::WriteTextStoryIndentInfo(BaseCamelotFilter *pFilter, TextStory *pStory)
00981 {
00982 #ifdef DO_EXPORT
00983     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
00984     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
00985 
00986     CamelotFileRecord Rec(pFilter, TAG_TEXT_STORY_INDENT_INFO, TAG_TEXT_STORY_INDENT_INFO_SIZE);
00987 
00988     MILLIPOINT LeftIndent  = pStory->GetLeftIndent();
00989     MILLIPOINT RightIndent = pStory->GetRightIndent();
00990 
00991     BOOL ok = Rec.Init();
00992     if (ok) ok = Rec.WriteINT32(LeftIndent);
00993     if (ok) ok = Rec.WriteINT32(RightIndent);
00994     if (ok) ok = pFilter->Write(&Rec);
00995 
00996     return ok;
00997 #else
00998     return FALSE;
00999 #endif
01000 }
01001 
01002 BOOL CXaraFileTxtStory::WriteTextStoryInvalid(BaseCamelotFilter *pFilter, TextStory *pStory)
01003 {
01004 #ifdef DO_EXPORT
01005     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01006     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
01007 
01008     ERROR3("Unable to determine type of text story to write out - help!");
01009 
01010     return FALSE;
01011 #else
01012     return FALSE;
01013 #endif
01014 }
01015 
01016 //--------------------------------
01017 
01018 BOOL CXaraFileTxtStory::WriteBeginChildRecordsWeb(BaseCamelotFilter *pFilter, TextStory *pStory)
01019 {
01020 #ifdef DO_EXPORT
01021     return WriteBeginChildRecordsNative(pFilter, pStory);
01022 #else
01023     return FALSE;
01024 #endif
01025 }
01026 
01027 BOOL CXaraFileTxtStory::WriteBeginChildRecordsNative(BaseCamelotFilter *pFilter, TextStory *pStory)
01028 {
01029 #ifdef DO_EXPORT
01030     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01031     ERROR2IF(pStory==NULL, FALSE, "Parameter pFilter == NULL.");
01032 
01033     // First thing to do is write out the Down record
01034     BOOL ok = (pFilter->WriteZeroSizedRecord(TAG_DOWN));
01035     if (ok) ok = WriteTextStoryWordWrapInfo(pFilter,pStory);
01036     if (ok) ok = WriteTextStoryIndentInfo(pFilter,pStory);
01037 
01038     // Write out the bounds record
01039     if (ok && pFilter->GetBoundsWriteLevel() >= BWL_COMPOUND)
01040     {
01041         DocRect Rect = pStory->GetBoundingRect();
01042 
01043         CamelotFileRecord Rec(pFilter, TAG_OBJECTBOUNDS, TAG_OBJECTBOUNDS_SIZE);
01044         ok = Rec.Init();
01045         if (ok) ok = Rec.WriteCoord(Rect.lo);
01046         if (ok) ok = Rec.WriteCoord(Rect.hi);
01047         if (ok) ok = pFilter->Write(&Rec);
01048     }
01049 
01050     // Write out the bounds record
01051     if (ok && pFilter->GetBoundsWriteLevel() >= BWL_COMPOUND)
01052     {
01053         DocRect Rect = pStory->GetBoundingRect();
01054 
01055         CamelotFileRecord Rec(pFilter, TAG_OBJECTBOUNDS, TAG_OBJECTBOUNDS_SIZE);
01056         ok = Rec.Init();
01057         if (ok) ok = Rec.WriteCoord(Rect.lo);
01058         if (ok) ok = Rec.WriteCoord(Rect.hi);
01059         if (ok) ok = pFilter->Write(&Rec);
01060     }
01061 
01062     return ok;
01063 #else
01064     return FALSE;
01065 #endif
01066 }
01067 
01068 BOOL CXaraFileTxtStory::WriteEndChildRecordsWeb(BaseCamelotFilter *pFilter, TextStory *pStory)
01069 {
01070 #ifdef DO_EXPORT
01071     return WriteEndChildRecordsNative(pFilter, pStory);
01072 #else
01073     return FALSE;
01074 #endif
01075 }
01076 
01077 BOOL CXaraFileTxtStory::WriteEndChildRecordsNative(BaseCamelotFilter *pFilter, TextStory *pStory)
01078 {
01079 #ifdef DO_EXPORT
01080     ERROR2IF(pFilter == NULL,FALSE,"NULL filter param");
01081     return pFilter->WriteZeroSizedRecord(TAG_UP);
01082 #else
01083     return FALSE;
01084 #endif
01085 }
01086 
01087 /********************************************************************************************
01088 
01089 >   const double CXaraFileTextStory::mEpsilon
01090 
01091     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 
01092     Created:    15/07/96
01093     Purpose:    Epsilon value used for checking matrix type
01094 
01095 ********************************************************************************************/
01096 
01097 const double CXaraFileTxtStory::mEpsilon = 0.000016;
01098 
01099 /********************************************************************************************
01100 
01101 >   BOOL CXaraFileTxtLine::WritePreChildrenWeb(BaseCamelotFilter *pFilter, TextLine *pLine)
01102     BOOL CXaraFileTxtLine::WritePreChildrenNative(BaseCamelotFilter *pFilter, TextLine *pLine)
01103     BOOL CXaraFileTxtLine::WriteTextLine(BaseCamelotFilter *pFilter, TextLine *pLine)
01104 
01105     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
01106     Created:    10/07/96
01107     Inputs:     pFilter - new file format filter to write record to
01108                 pLine   - text line object to export
01109     Returns:    TRUE if successful, FALSE otherwise
01110     Purpose:    Exports a text line object record to the new file format
01111 
01112 ********************************************************************************************/
01113 
01114 BOOL CXaraFileTxtLine::WritePreChildrenWeb(BaseCamelotFilter *pFilter, TextLine *pLine)
01115 {
01116 #ifdef DO_EXPORT
01117     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01118     ERROR2IF(pLine==NULL, FALSE, "Parameter pLine==NULL");
01119 
01120     return WriteTextLine(pFilter, pLine);
01121 #else
01122     return FALSE;
01123 #endif
01124 }
01125 
01126 BOOL CXaraFileTxtLine::WritePreChildrenNative(BaseCamelotFilter *pFilter, TextLine *pLine)
01127 {
01128 #ifdef DO_EXPORT
01129     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01130     ERROR2IF(pLine==NULL, FALSE, "Parameter pLine==NULL");
01131 
01132     return WriteTextLine(pFilter, pLine);
01133 #else
01134     return FALSE;
01135 #endif
01136 }
01137 
01138 BOOL CXaraFileTxtLine::WriteTextLine(BaseCamelotFilter *pFilter, TextLine *pLine)
01139 {
01140 #ifdef DO_EXPORT
01141     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01142     ERROR2IF(pLine==NULL, FALSE, "Parameter pLine==NULL");
01143 
01144     // using our current plans, we don't actually need to write out text line objects, they're
01145     // explicit because of a newline in the character string
01146 
01147     BOOL ok;
01148 
01149     CamelotFileRecord Rec(pFilter, TAG_TEXT_LINE, TAG_TEXT_LINE_SIZE);
01150     ok = Rec.Init();
01151     if (ok) ok = pFilter->Write(&Rec);
01152 
01153     return ok;
01154 #else
01155     return FALSE;
01156 #endif
01157 }
01158 
01159 //-----------------------------------------------------------------
01160 
01161 BOOL CXaraFileTxtLine::WriteBeginChildRecordsWeb(BaseCamelotFilter *pFilter, TextLine *pLine)
01162 {
01163 #ifdef DO_EXPORT
01164     return WriteBeginChildRecordsNative(pFilter,pLine);
01165 #else
01166     return FALSE;
01167 #endif
01168 }
01169 
01170 BOOL CXaraFileTxtLine::WriteBeginChildRecordsNative(BaseCamelotFilter *pFilter, TextLine *pLine)
01171 {
01172 #ifdef DO_EXPORT
01173     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01174     ERROR2IF(pLine==NULL, FALSE, "Parameter pLine==NULL");
01175 
01176     // First thing to do is write out the Down record
01177     BOOL ok = (pFilter->WriteZeroSizedRecord(TAG_DOWN));
01178 
01179     // Calc dist between this line & the previous line
01180     MILLIPOINT DistFromPreviousLine = pLine->GetPosInStory();
01181     TextLine* pPrevLine = pLine->FindPrevLine();
01182     if (pPrevLine != NULL)
01183         DistFromPreviousLine -= pPrevLine->GetPosInStory();
01184 
01185     DocRect Rect = pLine->GetBoundingRect();
01186 
01187     CamelotFileRecord Rec(pFilter,TAG_TEXT_LINE_INFO,TAG_TEXT_LINE_INFO_SIZE);
01188 
01189     if (ok) ok = Rec.Init();
01190     if (ok) ok = Rec.WriteINT32(Rect.Width());
01191     if (ok) ok = Rec.WriteINT32(Rect.Height());
01192     if (ok) ok = Rec.WriteINT32(DistFromPreviousLine);
01193     if (ok) ok = pFilter->Write(&Rec);
01194 
01195     return ok;
01196 #else
01197     return FALSE;
01198 #endif
01199 }
01200 
01201 BOOL CXaraFileTxtLine::WriteEndChildRecordsWeb(BaseCamelotFilter *pFilter, TextLine *pLine)
01202 {
01203 #ifdef DO_EXPORT
01204     return WriteEndChildRecordsNative(pFilter,pLine);
01205 #else
01206     return FALSE;
01207 #endif
01208 }
01209 
01210 BOOL CXaraFileTxtLine::WriteEndChildRecordsNative(BaseCamelotFilter *pFilter, TextLine *pLine)
01211 {
01212 #ifdef DO_EXPORT
01213     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01214     return (pFilter->WriteZeroSizedRecord(TAG_UP));
01215 #else
01216     return FALSE;
01217 #endif
01218 }
01219 
01220 /********************************************************************************************
01221 
01222 >   BOOL CXaraFileTxtChar::WritePreChildrenWeb(BaseCamelotFilter *pFilter, TextChar *pChar);
01223     BOOL CXaraFileTxtChar::WritePreChildrenNative(BaseCamelotFilter *pFilter, TextChar *pChar);
01224     BOOL CXaraFileTxtChar::WriteTextChar(BaseCamelotFilter *pFilter, TextChar *pChar);
01225 
01226     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
01227     Created:    10/07/96
01228     Inputs:     pFilter - new file format filter to write the record to.
01229                 pLine   - TextLine object to export
01230     Returns:    TRUE if a record has been written , FALSE otherwise
01231     Purpose:    Writes a text char record to the filter
01232     See Also:   <???>
01233 
01234 ********************************************************************************************/
01235 
01236 BOOL CXaraFileTxtChar::WritePreChildrenWeb(BaseCamelotFilter *pFilter, TextChar *pChar)
01237 {
01238 #ifdef DO_EXPORT
01239     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01240     ERROR2IF(pChar==NULL, FALSE, "Parameter pChar==NULL");
01241 
01242     return WriteTextChar(pFilter, pChar);
01243 #else
01244     return FALSE;
01245 #endif
01246 }
01247 
01248 BOOL CXaraFileTxtChar::WritePreChildrenNative(BaseCamelotFilter *pFilter, TextChar *pChar)
01249 {
01250 #ifdef DO_EXPORT
01251     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01252     ERROR2IF(pChar==NULL, FALSE, "Parameter pChar==NULL");
01253 
01254     return WriteTextChar(pFilter, pChar);
01255 #else
01256     return FALSE;
01257 #endif
01258 }
01259 
01260 BOOL CXaraFileTxtChar::WriteTextChar(BaseCamelotFilter *pFilter, TextChar *pChar)
01261 {
01262 #ifdef DO_EXPORT
01263     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01264     ERROR2IF(pChar==NULL, FALSE, "Parameter pChar==NULL");
01265 
01266     BOOL ok = TRUE;
01267     BOOL TryAString = TRUE;
01268 
01269     // This function will work out whether it has to save this char as an atomic TAG_TEXT_CHAR record,
01270     // or whether it can be saved as part of a TAG_TEXT_STRING record along with it's immediate
01271     // neighbours.
01272 
01273     // Already been written to the file? (I.e. was it included in a previous string?)
01274     // If so return now (this flag is reset in TextChar::WritePostChildenX )
01275     if (pChar->AlreadyWritten())
01276         return FALSE;
01277 
01278     // Start a string record up, and make the first char in the string this char
01279     CamelotFileRecord Rec(pFilter, TAG_TEXT_STRING, TAG_TEXT_STRING_SIZE);
01280     if (ok) ok = Rec.Init();
01281     if (ok) ok = Rec.WriteWCHAR(pChar->GetUnicodeValue());
01282 
01283 
01284     // In debug builds you can force text to be saved out as single chars by holding down the 'S' key
01285     #ifdef _DEBUG
01286     if (KeyPress::IsKeyPressed(CAMKEY(S)))
01287         TryAString = FALSE;
01288     #endif
01289     
01290 
01291     if (ok && TryAString)
01292     {
01293         // See how many child nodes the char's got, and also how many of these are children
01294         UINT32 ChildCount, ChildAttrCount;
01295         pChar->CountChildNodes(&ChildCount,&ChildAttrCount);
01296 
01297         // Only proceed if all the child nodes are attributes
01298         // (if not all the child nodes are attrs, then this is an unexpected state, so best not to proceed)
01299         if (ChildCount == ChildAttrCount)
01300         {
01301             BOOL CharWritten = TRUE;                // We have successfully written the previous char
01302             Node* pNextNode = pChar->FindNext();    // Find the next node
01303 
01304             // The While loop will continue if all the following are true:
01305             //      The current char has been written successfully
01306             //      There is a node next to the current char (i.e. not the last not in sibling list)
01307             //      The next node is a TextChar node.
01308 
01309             while (ok && CharWritten && pNextNode != NULL && pNextNode->IsATextChar())
01310             {
01311                 CharWritten = FALSE;                            // The next char has not been written out yet
01312                 TextChar* pNextChar = (TextChar*)pNextNode;     // The next node is a TextChar, so safe to cast
01313 
01314                 // Count the number of child nodes, and num child attrs
01315                 UINT32 NextChildCount, NextChildAttrCount;
01316                 pNextChar->CountChildNodes(&NextChildCount,&NextChildAttrCount);
01317 
01318                 // If the next node only has child attrs  (NextChildCount == NextChildAttrCount)
01319                 // and has the same number of child atrrs as pChar (NextChildAttrCount == ChildAttrCount)
01320                 // then proceed
01321                 if (NextChildCount == NextChildAttrCount && NextChildAttrCount == ChildAttrCount)
01322                 {
01323                     // are the child attrs of the next char identical to the first char in the string?
01324                     // I.e. do both of these characters look the same?
01325                     if (pChar->AreChildAttrsIdentical(pNextChar))
01326                     {
01327                         // If so, add the next char's code to the string record
01328                         CharWritten = ok = Rec.WriteWCHAR(pNextChar->GetUnicodeValue());
01329 
01330                         // Make sure the newly added char doesn't get written out later
01331                         pNextChar->SetAlreadyWritten(CharWritten);
01332                     }
01333                 }
01334 
01335                 // Find the next node
01336                 pNextNode = pNextChar->FindNext();              
01337             }
01338         }
01339     }
01340 
01341     // If only one character ended up in the string, write out a TAG_TEXT_CHAR record instead of a string rec.
01342     // There's no important reason for this.  I've done it so it's clear when looking at the file
01343     // what has happened to text when it's been exported
01344     // Also, text char records are fixed-sized records, allowing a precompressor to drop the size field if it wants.
01345     if (ok && Rec.GetSize() == 2)
01346     {
01347                 ok = Rec.Reinit(TAG_TEXT_CHAR,TAG_TEXT_CHAR_SIZE);
01348         if (ok) ok = Rec.WriteWCHAR(pChar->GetUnicodeValue());
01349     }
01350 
01351     if (ok) ok = (pFilter->Write(&Rec) != 0);
01352 
01353     return ok;
01354 #else
01355     return FALSE;
01356 #endif
01357 }
01358 
01359 /********************************************************************************************
01360 
01361 >   BOOL CXaraFileTxtKern::WritePreChildrenWeb(BaseCamelotFilter *pFilter, KernCode *pKern);
01362     BOOL CXaraFileTxtKern::WritePreChildrenNative(BaseCamelotFilter *pFilter, KernCode *pKern);
01363     BOOL CXaraFileTxtKern::WriteTextKern(BaseCamelotFilter *pFilter, KernCode *pKern);
01364 
01365     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
01366     Created:    10/07/96
01367     Inputs:     pFilter - New file format filter to write the record to
01368                 pKern   - kern code node to export
01369     Returns:    TRUE if successful, FALSE otherwise
01370     Purpose:    Writes a kern code record to the filter
01371 
01372 ********************************************************************************************/
01373 
01374 BOOL CXaraFileTxtKern::WritePreChildrenWeb(BaseCamelotFilter *pFilter, KernCode *pKern)
01375 {
01376 #ifdef DO_EXPORT
01377     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01378     ERROR2IF(pKern==NULL, FALSE, "Parameter pKern==NULL");
01379 
01380     return WriteTextKern(pFilter, pKern);
01381 #else
01382     return FALSE;
01383 #endif
01384 }
01385 
01386 BOOL CXaraFileTxtKern::WritePreChildrenNative(BaseCamelotFilter *pFilter, KernCode *pKern)
01387 {
01388 #ifdef DO_EXPORT
01389     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01390     ERROR2IF(pKern==NULL, FALSE, "Parameter pKern==NULL");
01391 
01392     return WriteTextKern(pFilter, pKern);
01393 #else
01394     return FALSE;
01395 #endif
01396 }
01397 
01398 BOOL CXaraFileTxtKern::WriteTextKern(BaseCamelotFilter *pFilter, KernCode *pKern)
01399 {
01400 #ifdef DO_EXPORT
01401     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01402     ERROR2IF(pKern==NULL, FALSE, "Parameter pChar==NULL");
01403 
01404     BOOL ok;
01405 
01406     CamelotFileRecord Rec(pFilter, TAG_TEXT_KERN, TAG_TEXT_KERN_SIZE);
01407     ok = Rec.Init();
01408     if (ok) ok = Rec.WriteCoordTrans(pKern->GetValue(),0,0);        // Kerns are relative, so ensure they don't get translated when output
01409     if (ok) ok = pFilter->Write(&Rec);
01410 
01411     return ok;
01412 #else
01413     return FALSE;
01414 #endif
01415 }
01416 
01417 /********************************************************************************************
01418 
01419 >   BOOL CXaraFileTxtTab::WritePreChildrenWeb(BaseCamelotFilter *pFilter, HorizontalTab *pTab);
01420     BOOL CXaraFileTxtTab::WritePreChildrenNative(BaseCamelotFilter *pFilter, HorizontalTab *pTab);
01421     BOOL CXaraFileTxtTab::WriteTextTab(BaseCamelotFilter *pFilter, HorizontalTab *pTab);
01422 
01423     Author:     Martin Wuerthner <xara@mw-software.com>
01424     Created:    29/06/06
01425     Inputs:     pFilter - New file format filter to write the record to
01426                 pTab    - tab character to export
01427     Returns:    TRUE if successful, FALSE otherwise
01428     Purpose:    Writes a tab record to the filter
01429 
01430 ********************************************************************************************/
01431 
01432 BOOL CXaraFileTxtTab::WritePreChildrenWeb(BaseCamelotFilter *pFilter, HorizontalTab *pTab)
01433 {
01434 #ifdef DO_EXPORT
01435     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01436     ERROR2IF(pTab==NULL, FALSE, "Parameter pTab==NULL");
01437 
01438     return WriteTextTab(pFilter, pTab);
01439 #else
01440     return FALSE;
01441 #endif
01442 }
01443 
01444 BOOL CXaraFileTxtTab::WritePreChildrenNative(BaseCamelotFilter *pFilter, HorizontalTab *pTab)
01445 {
01446 #ifdef DO_EXPORT
01447     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01448     ERROR2IF(pTab==NULL, FALSE, "Parameter pTab==NULL");
01449 
01450     return WriteTextTab(pFilter, pTab);
01451 #else
01452     return FALSE;
01453 #endif
01454 }
01455 
01456 BOOL CXaraFileTxtTab::WriteTextTab(BaseCamelotFilter *pFilter, HorizontalTab *pTab)
01457 {
01458 #ifdef DO_EXPORT
01459     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01460     ERROR2IF(pTab==NULL, FALSE, "Parameter pChar==NULL");
01461 
01462     BOOL ok;
01463 
01464     CamelotFileRecord Rec(pFilter, TAG_TEXT_TAB, TAG_TEXT_TAB_SIZE);
01465     ok = Rec.Init();
01466     if (ok) ok = pFilter->Write(&Rec);
01467 
01468     return ok;
01469 #else
01470     return FALSE;
01471 #endif
01472 }
01473 
01474 /********************************************************************************************
01475 
01476 >   BOOL CXaraFileTxtCaret::WritePreChildrenWeb(BaseCamelotFilter *pFilter, CaretNode *pCaret);
01477     BOOL CXaraFileTxtCaret::WritePreChildrenNative(BaseCamelotFilter *pFilter, CaretNode *pCaret);
01478     BOOL CXaraFileTxtCaret::WriteTextCaret(BaseCamelotFilter *pFilter, CaretNode *pCaret);
01479 
01480     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
01481     Created:    10/07/96
01482     Inputs:     pFilter - New file format filter to write record to
01483                 pCaret  - Caret node to write out
01484     Returns:    TRUE if record written, FALSE otherwise
01485     Purpose:    Writes a caret record to the filter
01486 
01487 ********************************************************************************************/
01488 
01489 BOOL CXaraFileTxtCaret::WritePreChildrenWeb(BaseCamelotFilter *pFilter, CaretNode *pCaret)
01490 {
01491 /*
01492     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01493     ERROR2IF(pCaret==NULL, FALSE, "Parameter pCaret==NULL");
01494 
01495     return WriteTextCaret(pFilter, pCaret);
01496 */
01497     return FALSE;
01498 }
01499 
01500 BOOL CXaraFileTxtCaret::WritePreChildrenNative(BaseCamelotFilter *pFilter, CaretNode *pCaret)
01501 {
01502 /*
01503     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01504     ERROR2IF(pCaret==NULL, FALSE, "Parameter pCaret==NULL");
01505 
01506     return WriteTextCaret(pFilter, pCaret);
01507 */
01508     return FALSE;
01509 }
01510 
01511 BOOL CXaraFileTxtCaret::WriteTextCaret(BaseCamelotFilter *pFilter, CaretNode *pCaret)
01512 {
01513 /*
01514     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01515     ERROR2IF(pCaret==NULL, FALSE, "Parameter pCaret==NULL");
01516 
01517     BOOL ok;
01518     
01519     CamelotFileRecord Rec(pFilter, TAG_TEXT_CARET, TAG_TEXT_CARET_SIZE);
01520     ok = Rec.Init();
01521     if (ok) ok = pFilter->Write(&Rec);
01522 
01523     return ok;
01524 */
01525     return FALSE;
01526 }
01527 
01528 /********************************************************************************************
01529 
01530 >   BOOL CXaraFileTxtEOL::WritePreChildrenWeb(BaseCamelotFilter *pFilter, EOLNode *pEOL)
01531     BOOL CXaraFileTxtEOL::WritePreChildrenNative(BaseCamelotFilter *pFilter, EOLNode *pEOL)
01532     BOOL CXaraFileTxtEOL::WriteTextEOL(BaseCamelotFilter *pFilter, EOLNode *pEOL)
01533 
01534     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
01535     Created:    10/07/96
01536     Inputs:     pFilter - New file format filter to use
01537                 pEOL    - EOL node to write to filter
01538     Returns:    TRUE if successful, FALSE otherwise
01539     Purpose:    Writes an EOL Node record to the filter
01540 
01541 ********************************************************************************************/
01542 
01543 BOOL CXaraFileTxtEOL::WritePreChildrenWeb(BaseCamelotFilter *pFilter, EOLNode *pEOL)
01544 {
01545 #ifdef DO_EXPORT
01546     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01547     ERROR2IF(pEOL==NULL, FALSE, "Parameter pEOL==NULL");
01548 
01549     return WriteTextEOL(pFilter, pEOL);
01550 #else
01551     return FALSE;
01552 #endif
01553 }
01554 
01555 BOOL CXaraFileTxtEOL::WritePreChildrenNative(BaseCamelotFilter *pFilter, EOLNode *pEOL)
01556 {
01557 #ifdef DO_EXPORT
01558     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01559     ERROR2IF(pEOL==NULL, FALSE, "Parameter pEOL==NULL");
01560 
01561     return WriteTextEOL(pFilter, pEOL);
01562 #else
01563     return FALSE;
01564 #endif
01565 }
01566 
01567 BOOL CXaraFileTxtEOL::WriteTextEOL(BaseCamelotFilter *pFilter, EOLNode *pEOL)
01568 {
01569 #ifdef DO_EXPORT
01570     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter==NULL");
01571     ERROR2IF(pEOL==NULL, FALSE, "Parameter pEOL==NULL");
01572 
01573     BOOL ok;
01574 
01575     CamelotFileRecord Rec(pFilter, TAG_TEXT_EOL, TAG_TEXT_EOL_SIZE);
01576     ok = Rec.Init();
01577     if (ok) ok = pFilter->Write(&Rec);
01578 
01579 //  WCHAR MyWChar = '\n';
01580 //  pFilter->StartRecord(TAG_TEXT_STRING, TAG_TEXT_STRING_SIZE);
01581 //  if (ok) ok = pFilter->WriteWCHAR(MyWChar);
01582 
01583     return ok;
01584 #else
01585     return FALSE;
01586 #endif
01587 }
01588 
01589 /********************************************************************************************
01590 
01591 >   BOOL CXaraFileTxtBold::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtBold *pAttr);
01592     BOOL CXaraFileTxtBold::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtBold *pAttr);
01593     BOOL CXaraFileTxtBold::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtBold *pAttr);
01594 
01595     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
01596     Created:    09/07/96
01597     Inputs:     pFilter - camelot filter to use
01598                 pAttr   - attribute to save
01599     Returns:    TRUE if successful, FALSE otherwise
01600     Purpose:    Saves the text bold attribute to the filter
01601 
01602 ********************************************************************************************/
01603 
01604 BOOL CXaraFileTxtBold::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtBold *pAttr)
01605 {
01606 #ifdef DO_EXPORT
01607     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01608     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01609 
01610     return WritePreChildrenAux(pFilter, pAttr);
01611 #else
01612     return FALSE;
01613 #endif
01614 }
01615 
01616 BOOL CXaraFileTxtBold::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtBold *pAttr)
01617 {
01618 #ifdef DO_EXPORT
01619     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01620     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01621 
01622     return WritePreChildrenAux(pFilter, pAttr);
01623 #else
01624     return FALSE;
01625 #endif
01626 }
01627 
01628 BOOL CXaraFileTxtBold::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtBold *pAttr)
01629 {
01630 #ifdef DO_EXPORT
01631     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01632     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01633 
01634     BOOL ok;
01635 
01636     if (pAttr->Value.BoldOn != FALSE)
01637     {
01638         CamelotFileRecord Rec(pFilter, TAG_TEXT_BOLD_ON, TAG_TEXT_BOLD_ON_SIZE);
01639         ok = Rec.Init();
01640         if (ok) ok = pFilter->Write(&Rec);
01641     }
01642     else
01643     {
01644         CamelotFileRecord Rec(pFilter, TAG_TEXT_BOLD_OFF, TAG_TEXT_BOLD_OFF_SIZE);
01645         ok = Rec.Init();
01646         if (ok) ok = pFilter->Write(&Rec);
01647     }
01648 
01649     return ok;
01650 #else
01651     return FALSE;
01652 #endif
01653 }
01654 
01655 /********************************************************************************************
01656 
01657 >   BOOL CXaraFileTxtFontTypeface::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtFontTypeface *pAttr);
01658     BOOL CXaraFileTxtFontTypeface::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtFontTypeface *pAttr);
01659     BOOL CXaraFileTxtFontTypeface::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtFontTypeface *pAttr);
01660 
01661     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
01662     Created:    09/07/96
01663     Inputs:     pFilter - camelot filter to use
01664                 pAttr   - attribute to save
01665     Returns:    TRUE if successful, FALSE otherwise
01666     Purpose:    Saves the text font typeface attribute to the filter
01667 
01668 ********************************************************************************************/
01669 
01670 BOOL CXaraFileTxtFontTypeface::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtFontTypeface *pAttr)
01671 {
01672 #ifdef DO_EXPORT
01673     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01674     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01675 
01676     return WritePreChildrenAux(pFilter, pAttr);
01677 #else
01678     return FALSE;
01679 #endif
01680 }
01681 
01682 BOOL CXaraFileTxtFontTypeface::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtFontTypeface *pAttr)
01683 {
01684 #ifdef DO_EXPORT
01685     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01686     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01687 
01688     return WritePreChildrenAux(pFilter, pAttr);
01689 #else
01690     return FALSE;
01691 #endif
01692 }
01693 
01694 BOOL CXaraFileTxtFontTypeface::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtFontTypeface *pAttr)
01695 {
01696 #ifdef DO_EXPORT
01697     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01698     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01699 
01700     BOOL ok;
01701 
01702     INT32 FontRecordRef = pFilter->WriteFontDefinition(pAttr->Value.HTypeface, pAttr->Value.IsBold, pAttr->Value.IsItalic);
01703 
01704     if (FontRecordRef == 0)
01705     {
01706         ok = FALSE;
01707     }
01708     else
01709     {
01710         CamelotFileRecord Rec(pFilter, TAG_TEXT_FONT_TYPEFACE, TAG_TEXT_FONT_TYPEFACE_SIZE);
01711         ok = Rec.Init();
01712         if (ok) ok = Rec.WriteReference(FontRecordRef);
01713         if (ok) ok = pFilter->Write(&Rec);
01714     }
01715 
01716     return ok;
01717 #else
01718     return FALSE;
01719 #endif
01720 }
01721 
01722 /********************************************************************************************
01723 
01724 >   BOOL CXaraFileTxtItalic::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtItalic *pAttr);
01725     BOOL CXaraFileTxtItalic::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtItalic *pAttr);
01726     BOOL CXaraFileTxtItalic::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtItalic *pAttr);
01727 
01728     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
01729     Created:    09/07/96
01730     Inputs:     pFilter - camelot filter to use
01731                 pAttr   - attribute to save
01732     Returns:    TRUE if successful, FALSE otherwise
01733     Purpose:    Saves the text italic attribute to the filter
01734 
01735 ********************************************************************************************/
01736 
01737 BOOL CXaraFileTxtItalic::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtItalic *pAttr)
01738 {
01739 #ifdef DO_EXPORT
01740     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01741     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01742 
01743     return WritePreChildrenAux(pFilter, pAttr);
01744 #else
01745     return FALSE;
01746 #endif
01747 }
01748 
01749 BOOL CXaraFileTxtItalic::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtItalic *pAttr)
01750 {
01751 #ifdef DO_EXPORT
01752     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01753     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01754 
01755     return WritePreChildrenAux(pFilter, pAttr);
01756 #else
01757     return FALSE;
01758 #endif
01759 }
01760 
01761 BOOL CXaraFileTxtItalic::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtItalic *pAttr)
01762 {
01763 #ifdef DO_EXPORT
01764     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01765     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01766 
01767     BOOL ok;
01768 
01769     if (pAttr->Value.ItalicOn != FALSE)
01770     {
01771         CamelotFileRecord Rec(pFilter, TAG_TEXT_ITALIC_ON, TAG_TEXT_ITALIC_ON_SIZE);
01772         ok = Rec.Init();
01773         if (ok) ok = pFilter->Write(&Rec);
01774     }
01775     else
01776     {
01777         CamelotFileRecord Rec(pFilter, TAG_TEXT_ITALIC_OFF, TAG_TEXT_ITALIC_OFF_SIZE);
01778         ok = Rec.Init();
01779         if (ok) ok = pFilter->Write(&Rec);
01780     }
01781 
01782     return ok;
01783 #else
01784     return FALSE;
01785 #endif
01786 }
01787 
01788 /********************************************************************************************
01789 
01790 >   BOOL CXaraFileTxtUnderline::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtUnderline *pAttr);
01791     BOOL CXaraFileTxtUnderline::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtUnderline *pAttr);
01792     BOOL CXaraFileTxtUnderline::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtUnderline *pAttr);
01793 
01794     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
01795     Created:    09/07/96
01796     Inputs:     pFilter - camelot filter to use
01797                 pAttr   - attribute to save
01798     Returns:    TRUE if successful, FALSE otherwise
01799     Purpose:    Saves the text underline attribute to the filter
01800 
01801 ********************************************************************************************/
01802 
01803 BOOL CXaraFileTxtUnderline::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtUnderline *pAttr)
01804 {
01805 #ifdef DO_EXPORT
01806     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01807     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01808 
01809     return WritePreChildrenAux(pFilter, pAttr);
01810 #else
01811     return FALSE;
01812 #endif
01813 }
01814 
01815 BOOL CXaraFileTxtUnderline::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtUnderline *pAttr)
01816 {
01817 #ifdef DO_EXPORT
01818     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01819     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01820 
01821     return WritePreChildrenAux(pFilter, pAttr);
01822 #else
01823     return FALSE;
01824 #endif
01825 }
01826 
01827 BOOL CXaraFileTxtUnderline::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtUnderline *pAttr)
01828 {
01829 #ifdef DO_EXPORT
01830     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01831     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01832 
01833 //  BOOL ok;
01834 //
01835 //  if (pAttr->Value.Underlined != FALSE)
01836 //  {
01837 //      CamelotFileRecord Rec(pFilter, TAG_TEXT_UNDERLINE_ON, TAG_TEXT_UNDERLINE_ON_SIZE);
01838 //      ok = Rec.Init();
01839 //      if (ok) ok = pFilter->Write(&Rec);
01840 //  }
01841 //  else
01842 //  {
01843 //      CamelotFileRecord Rec(pFilter, TAG_TEXT_UNDERLINE_OFF, TAG_TEXT_UNDERLINE_OFF_SIZE);
01844 //      ok = Rec.Init();
01845 //      if (ok) ok = pFilter->Write(&Rec);
01846 //  }
01847 //
01848 //  return ok;
01849 
01850     // we don't support underline attributes yet; they can exist in the tree but
01851     // aren't used by anybody. hence we don't save anything out.
01852 
01853     return TRUE;
01854 #else
01855     return FALSE;
01856 #endif
01857 }
01858 
01859 /********************************************************************************************
01860 
01861 >   BOOL CXaraFileTxtAspectRatio::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtAspectRatio *pAttr);
01862     BOOL CXaraFileTxtAspectRatio::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtAspectRatio *pAttr);
01863     BOOL CXaraFileTxtAspectRatio::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtAspectRatio *pAttr);
01864 
01865     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
01866     Created:    09/07/96
01867     Inputs:     pFilter - camelot filter to use
01868                 pAttr   - attribute to save
01869     Returns:    TRUE if successful, FALSE otherwise
01870     Purpose:    Saves the text aspect ratio attribute to the filter
01871 
01872 ********************************************************************************************/
01873 
01874 BOOL CXaraFileTxtAspectRatio::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtAspectRatio *pAttr)
01875 {
01876 #ifdef DO_EXPORT
01877     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01878     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01879 
01880     return WritePreChildrenAux(pFilter, pAttr);
01881 #else
01882     return FALSE;
01883 #endif
01884 }
01885 
01886 BOOL CXaraFileTxtAspectRatio::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtAspectRatio *pAttr)
01887 {
01888 #ifdef DO_EXPORT
01889     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01890     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01891 
01892     return WritePreChildrenAux(pFilter, pAttr);
01893 #else
01894     return FALSE;
01895 #endif
01896 }
01897 
01898 BOOL CXaraFileTxtAspectRatio::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtAspectRatio *pAttr)
01899 {
01900 #ifdef DO_EXPORT
01901     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01902     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01903 
01904     BOOL ok;
01905 
01906     CamelotFileRecord Rec(pFilter, TAG_TEXT_ASPECT_RATIO, TAG_TEXT_ASPECT_RATIO_SIZE);
01907     ok = Rec.Init();
01908     if (ok) ok = Rec.WriteFIXED16(pAttr->Value.AspectRatio);
01909     if (ok) ok = pFilter->Write(&Rec);
01910 
01911     return ok;
01912 #else
01913     return FALSE;
01914 #endif
01915 }
01916 
01917 /********************************************************************************************
01918 
01919 >   BOOL CXaraFileTxtJustification::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtJustification *pAttr);
01920     BOOL CXaraFileTxtJustification::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtJustification *pAttr);
01921     BOOL CXaraFileTxtJustification::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtJustification *pAttr);
01922 
01923     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
01924     Created:    09/07/96
01925     Inputs:     pFilter - camelot filter to use
01926                 pAttr   - attribute to save
01927     Returns:    TRUE if successful, FALSE otherwise
01928     Purpose:    Saves the text justification attribute to the filter
01929 
01930 ********************************************************************************************/
01931 
01932 BOOL CXaraFileTxtJustification::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtJustification *pAttr)
01933 {
01934 #ifdef DO_EXPORT
01935     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01936     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01937 
01938     return WritePreChildrenAux(pFilter, pAttr);
01939 #else
01940     return FALSE;
01941 #endif
01942 }
01943 
01944 BOOL CXaraFileTxtJustification::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtJustification *pAttr)
01945 {
01946 #ifdef DO_EXPORT
01947     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01948     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01949 
01950     return WritePreChildrenAux(pFilter, pAttr);
01951 #else
01952     return FALSE;
01953 #endif
01954 }
01955 
01956 BOOL CXaraFileTxtJustification::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtJustification *pAttr)
01957 {
01958 #ifdef DO_EXPORT
01959     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
01960     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
01961 
01962     BOOL ok;
01963 
01964     switch (pAttr->Value.justification)
01965     {
01966         case JLEFT :
01967             {
01968                 CamelotFileRecord Rec(pFilter, TAG_TEXT_JUSTIFICATION_LEFT, TAG_TEXT_JUSTIFICATION_LEFT_SIZE);
01969                 ok = Rec.Init();
01970                 if (ok) ok = pFilter->Write(&Rec);
01971             }
01972             break;
01973         case JRIGHT :
01974             {
01975                 CamelotFileRecord Rec(pFilter, TAG_TEXT_JUSTIFICATION_RIGHT, TAG_TEXT_JUSTIFICATION_RIGHT_SIZE);
01976                 ok = Rec.Init();
01977                 if (ok) ok = pFilter->Write(&Rec);
01978             }
01979             break;
01980         case JCENTRE :
01981             {
01982                 CamelotFileRecord Rec(pFilter, TAG_TEXT_JUSTIFICATION_CENTRE, TAG_TEXT_JUSTIFICATION_CENTRE_SIZE);
01983                 ok = Rec.Init();
01984                 if (ok) ok = pFilter->Write(&Rec);
01985             }
01986             break;
01987         case JFULL :
01988             {
01989                 CamelotFileRecord Rec(pFilter, TAG_TEXT_JUSTIFICATION_FULL, TAG_TEXT_JUSTIFICATION_FULL_SIZE);
01990                 ok = Rec.Init();
01991                 if (ok) ok = pFilter->Write(&Rec);
01992             }
01993             break;
01994         default :
01995             ERROR3("Unknown justification attribute.");
01996             ok = FALSE;
01997             break;
01998     }
01999 
02000     return ok;
02001 #else
02002     return FALSE;
02003 #endif
02004 }
02005 
02006 /********************************************************************************************
02007 
02008 >   BOOL CXaraFileTxtTracking::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtTracking *pAttr);
02009     BOOL CXaraFileTxtTracking::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtTracking *pAttr);
02010     BOOL CXaraFileTxtTracking::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtTracking *pAttr);
02011 
02012     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
02013     Created:    09/07/96
02014     Inputs:     pFilter - camelot filter to use
02015                 pAttr   - attribute to save
02016     Returns:    TRUE if successful, FALSE otherwise
02017     Purpose:    Saves the text tracking attribute to the filter
02018 
02019 ********************************************************************************************/
02020 
02021 BOOL CXaraFileTxtTracking::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtTracking *pAttr)
02022 {
02023 #ifdef DO_EXPORT
02024     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02025     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02026 
02027     return WritePreChildrenAux(pFilter, pAttr);
02028 #else
02029     return FALSE;
02030 #endif
02031 }
02032 
02033 BOOL CXaraFileTxtTracking::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtTracking *pAttr)
02034 {
02035 #ifdef DO_EXPORT
02036     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02037     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02038 
02039     return WritePreChildrenAux(pFilter, pAttr);
02040 #else
02041     return FALSE;
02042 #endif
02043 }
02044 
02045 BOOL CXaraFileTxtTracking::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtTracking *pAttr)
02046 {
02047 #ifdef DO_EXPORT
02048     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02049     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02050 
02051     BOOL ok;
02052 
02053     CamelotFileRecord Rec(pFilter, TAG_TEXT_TRACKING, TAG_TEXT_TRACKING_SIZE);
02054     ok = Rec.Init();
02055     if (ok) ok = Rec.WriteINT32(pAttr->Value.Tracking);
02056     if (ok) ok = pFilter->Write(&Rec);
02057 
02058     return ok;
02059 #else
02060     return FALSE;
02061 #endif
02062 }
02063 
02064 /********************************************************************************************
02065 
02066 >   BOOL CXaraFileTxtFontSize::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtFontSize *pAttr);
02067     BOOL CXaraFileTxtFontSize::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtFontSize *pAttr);
02068     BOOL CXaraFileTxtFontSize::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtFontSize *pAttr);
02069 
02070     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
02071     Created:    09/07/96
02072     Inputs:     pFilter - camelot filter to use
02073                 pAttr   - attribute to save
02074     Returns:    TRUE if successful, FALSE otherwise
02075     Purpose:    Saves the text font size attribute to the filter
02076 
02077 ********************************************************************************************/
02078 
02079 BOOL CXaraFileTxtFontSize::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtFontSize *pAttr)
02080 {
02081 #ifdef DO_EXPORT
02082     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02083     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02084 
02085     return WritePreChildrenAux(pFilter, pAttr);
02086 #else
02087     return FALSE;
02088 #endif
02089 }
02090 
02091 BOOL CXaraFileTxtFontSize::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtFontSize *pAttr)
02092 {
02093 #ifdef DO_EXPORT
02094     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02095     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02096 
02097     return WritePreChildrenAux(pFilter, pAttr);
02098 #else
02099     return FALSE;
02100 #endif
02101 }
02102 
02103 BOOL CXaraFileTxtFontSize::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtFontSize *pAttr)
02104 {
02105 #ifdef DO_EXPORT
02106     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02107     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02108 
02109     BOOL ok;
02110 
02111     CamelotFileRecord Rec(pFilter, TAG_TEXT_FONT_SIZE, TAG_TEXT_FONT_SIZE_SIZE);
02112     ok = Rec.Init();
02113     if (ok) ok = Rec.WriteINT32(pAttr->Value.FontSize);
02114     if (ok) ok = pFilter->Write(&Rec);
02115 
02116     return ok;
02117 #else
02118     return FALSE;
02119 #endif
02120 }
02121 
02122 /********************************************************************************************
02123 
02124 >   BOOL CXaraFileTxtScript::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtScript *pAttr);
02125     BOOL CXaraFileTxtScript::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtScript *pAttr);
02126     BOOL CXaraFileTxtScript::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtScript *pAttr);
02127 
02128     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
02129     Created:    09/07/96
02130     Inputs:     pFilter - camelot filter to use
02131                 pAttr   - attribute to save
02132     Returns:    TRUE if successful, FALSE otherwise
02133     Purpose:    Saves the text script attribute to the filter
02134 
02135 ********************************************************************************************/
02136 
02137 BOOL CXaraFileTxtScript::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtScript *pAttr)
02138 {
02139 #ifdef DO_EXPORT
02140     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02141     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02142 
02143     return WritePreChildrenAux(pFilter, pAttr);
02144 #else
02145     return FALSE;
02146 #endif
02147 }
02148 
02149 BOOL CXaraFileTxtScript::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtScript *pAttr)
02150 {
02151 #ifdef DO_EXPORT
02152     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02153     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02154 
02155     return WritePreChildrenAux(pFilter, pAttr);
02156 #else
02157     return FALSE;
02158 #endif
02159 }
02160 
02161 BOOL CXaraFileTxtScript::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtScript *pAttr)
02162 {
02163 #ifdef DO_EXPORT
02164     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02165     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02166 
02167     BOOL ok;
02168 
02169     if (pAttr->Value.Offset == 0 && pAttr->Value.Size == 1)
02170     {
02171         CamelotFileRecord Rec(pFilter, TAG_TEXT_SCRIPT_OFF, TAG_TEXT_SCRIPT_OFF_SIZE);
02172         ok = Rec.Init();
02173         if (ok) ok = pFilter->Write(&Rec);
02174     }
02175     else if (pAttr->Value.Offset == FIXED16(Text_SuperScriptOffset)
02176                 && pAttr->Value.Size == FIXED16(Text_SuperScriptSize))
02177     {
02178         CamelotFileRecord Rec(pFilter, TAG_TEXT_SUPERSCRIPT_ON, TAG_TEXT_SUPERSCRIPT_ON_SIZE);
02179         ok = Rec.Init();
02180         if (ok) ok = pFilter->Write(&Rec);
02181     }
02182     else if (pAttr->Value.Offset == FIXED16(Text_SubScriptOffset)
02183                 && pAttr->Value.Size == FIXED16(Text_SubScriptSize))
02184     {
02185         CamelotFileRecord Rec(pFilter, TAG_TEXT_SUBSCRIPT_ON, TAG_TEXT_SUBSCRIPT_ON_SIZE);
02186         ok = Rec.Init();
02187         if (ok) ok = pFilter->Write(&Rec);
02188     }
02189     else
02190     {
02191         CamelotFileRecord Rec(pFilter, TAG_TEXT_SCRIPT_ON, TAG_TEXT_SCRIPT_ON_SIZE);
02192         ok = Rec.Init();
02193         if (ok) ok = Rec.WriteFIXED16(pAttr->Value.Offset);
02194         if (ok) ok = Rec.WriteFIXED16(pAttr->Value.Size);
02195         if (ok) ok = pFilter->Write(&Rec);
02196     }
02197 
02198     return ok;
02199 #else
02200     return FALSE;
02201 #endif
02202 }
02203 
02204 /********************************************************************************************
02205 
02206 >   BOOL CXaraFileTxtBaseLine::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtBaseLine *pAttr);
02207     BOOL CXaraFileTxtBaseLine::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtBaseLine *pAttr);
02208     BOOL CXaraFileTxtBaseLine::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtBaseLine *pAttr);
02209 
02210     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
02211     Created:    09/07/96
02212     Inputs:     pFilter - camelot filter to use
02213                 pAttr   - attribute to save
02214     Returns:    TRUE if successful, FALSE otherwise
02215     Purpose:    Saves the text base line attribute to the filter
02216 
02217 ********************************************************************************************/
02218 
02219 BOOL CXaraFileTxtBaseLine::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtBaseLine *pAttr)
02220 {
02221 #ifdef DO_EXPORT
02222     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02223     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02224 
02225     return WritePreChildrenAux(pFilter, pAttr);
02226 #else
02227     return FALSE;
02228 #endif
02229 }
02230 
02231 BOOL CXaraFileTxtBaseLine::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtBaseLine *pAttr)
02232 {
02233 #ifdef DO_EXPORT
02234     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02235     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02236 
02237     return WritePreChildrenAux(pFilter, pAttr);
02238 #else
02239     return FALSE;
02240 #endif
02241 }
02242 
02243 BOOL CXaraFileTxtBaseLine::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtBaseLine *pAttr)
02244 {
02245 #ifdef DO_EXPORT
02246     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02247     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02248 
02249     BOOL ok;
02250 
02251     CamelotFileRecord Rec(pFilter, TAG_TEXT_BASELINE, TAG_TEXT_BASELINE_SIZE);
02252     ok = Rec.Init();
02253     if (ok) ok = Rec.WriteINT32(pAttr->Value.Value);
02254     if (ok) ok = pFilter->Write(&Rec);
02255 
02256     return ok;
02257 #else
02258     return FALSE;
02259 #endif
02260 }
02261 
02262 /********************************************************************************************
02263 
02264 >   BOOL CXaraFileTxtLeftMargin::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtLeftMargin *pAttr);
02265     BOOL CXaraFileTxtLeftMargin::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtLeftMargin *pAttr);
02266     BOOL CXaraFileTxtLeftMargin::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtLeftMargin *pAttr);
02267 
02268     Author:     Martin Wuerthner <xara@mw-software.com>
02269     Created:    04/07/06
02270     Inputs:     pFilter - camelot filter to use
02271                 pAttr   - attribute to save
02272     Returns:    TRUE if successful, FALSE otherwise
02273     Purpose:    Saves the text left margin attribute to the filter
02274 
02275 ********************************************************************************************/
02276 
02277 BOOL CXaraFileTxtLeftMargin::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtLeftMargin *pAttr)
02278 {
02279 #ifdef DO_EXPORT
02280     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02281     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02282 
02283     return WritePreChildrenAux(pFilter, pAttr);
02284 #else
02285     return FALSE;
02286 #endif
02287 }
02288 
02289 BOOL CXaraFileTxtLeftMargin::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtLeftMargin *pAttr)
02290 {
02291 #ifdef DO_EXPORT
02292     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02293     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02294 
02295     return WritePreChildrenAux(pFilter, pAttr);
02296 #else
02297     return FALSE;
02298 #endif
02299 }
02300 
02301 BOOL CXaraFileTxtLeftMargin::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtLeftMargin *pAttr)
02302 {
02303 #ifdef DO_EXPORT
02304     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02305     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02306 
02307     BOOL ok;
02308 
02309     CamelotFileRecord Rec(pFilter, TAG_TEXT_LEFT_INDENT, TAG_TEXT_LEFT_INDENT_SIZE);
02310     ok = Rec.Init();
02311     if (ok) ok = Rec.WriteINT32(pAttr->Value.Value);
02312     if (ok) ok = pFilter->Write(&Rec);
02313 
02314     return ok;
02315 #else
02316     return FALSE;
02317 #endif
02318 }
02319 
02320 /********************************************************************************************
02321 
02322 >   BOOL CXaraFileTxtRightMargin::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtRightMargin *pAttr);
02323     BOOL CXaraFileTxtRightMargin::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtRightMargin *pAttr);
02324     BOOL CXaraFileTxtRightMargin::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtRightMargin *pAttr);
02325 
02326     Author:     Martin Wuerthner <xara@mw-software.com>
02327     Created:    04/07/06
02328     Inputs:     pFilter - camelot filter to use
02329                 pAttr   - attribute to save
02330     Returns:    TRUE if successful, FALSE otherwise
02331     Purpose:    Saves the text left margin attribute to the filter
02332 
02333 ********************************************************************************************/
02334 
02335 BOOL CXaraFileTxtRightMargin::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtRightMargin *pAttr)
02336 {
02337 #ifdef DO_EXPORT
02338     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02339     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02340 
02341     return WritePreChildrenAux(pFilter, pAttr);
02342 #else
02343     return FALSE;
02344 #endif
02345 }
02346 
02347 BOOL CXaraFileTxtRightMargin::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtRightMargin *pAttr)
02348 {
02349 #ifdef DO_EXPORT
02350     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02351     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02352 
02353     return WritePreChildrenAux(pFilter, pAttr);
02354 #else
02355     return FALSE;
02356 #endif
02357 }
02358 
02359 BOOL CXaraFileTxtRightMargin::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtRightMargin *pAttr)
02360 {
02361 #ifdef DO_EXPORT
02362     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02363     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02364 
02365     BOOL ok;
02366 
02367     CamelotFileRecord Rec(pFilter, TAG_TEXT_RIGHT_INDENT, TAG_TEXT_RIGHT_INDENT_SIZE);
02368     ok = Rec.Init();
02369     if (ok) ok = Rec.WriteINT32(pAttr->Value.Value);
02370     if (ok) ok = pFilter->Write(&Rec);
02371 
02372     return ok;
02373 #else
02374     return FALSE;
02375 #endif
02376 }
02377 
02378 /********************************************************************************************
02379 
02380 >   BOOL CXaraFileTxtFirstIndent::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtFirstIndent *pAttr);
02381     BOOL CXaraFileTxtFirstIndent::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtFirstIndent *pAttr);
02382     BOOL CXaraFileTxtFirstIndent::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtFirstIndent *pAttr);
02383 
02384     Author:     Martin Wuerthner <xara@mw-software.com>
02385     Created:    04/07/06
02386     Inputs:     pFilter - camelot filter to use
02387                 pAttr   - attribute to save
02388     Returns:    TRUE if successful, FALSE otherwise
02389     Purpose:    Saves the text left margin attribute to the filter
02390 
02391 ********************************************************************************************/
02392 
02393 BOOL CXaraFileTxtFirstIndent::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtFirstIndent *pAttr)
02394 {
02395 #ifdef DO_EXPORT
02396     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02397     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02398 
02399     return WritePreChildrenAux(pFilter, pAttr);
02400 #else
02401     return FALSE;
02402 #endif
02403 }
02404 
02405 BOOL CXaraFileTxtFirstIndent::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtFirstIndent *pAttr)
02406 {
02407 #ifdef DO_EXPORT
02408     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02409     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02410 
02411     return WritePreChildrenAux(pFilter, pAttr);
02412 #else
02413     return FALSE;
02414 #endif
02415 }
02416 
02417 BOOL CXaraFileTxtFirstIndent::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtFirstIndent *pAttr)
02418 {
02419 #ifdef DO_EXPORT
02420     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02421     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02422 
02423     BOOL ok;
02424 
02425     CamelotFileRecord Rec(pFilter, TAG_TEXT_FIRST_INDENT, TAG_TEXT_FIRST_INDENT_SIZE);
02426     ok = Rec.Init();
02427     if (ok) ok = Rec.WriteINT32(pAttr->Value.Value);
02428     if (ok) ok = pFilter->Write(&Rec);
02429 
02430     return ok;
02431 #else
02432     return FALSE;
02433 #endif
02434 }
02435 
02436 /********************************************************************************************
02437 
02438 >   BOOL CXaraFileTxtRuler::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtRuler *pAttr);
02439     BOOL CXaraFileTxtRuler::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtRuler *pAttr);
02440     BOOL CXaraFileTxtRuler::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtRuler *pAttr);
02441 
02442     Author:     Martin Wuerthner <xara@mw-software.com>
02443     Created:    04/07/06
02444     Inputs:     pFilter - camelot filter to use
02445                 pAttr   - attribute to save
02446     Returns:    TRUE if successful, FALSE otherwise
02447     Purpose:    Saves the text left margin attribute to the filter
02448 
02449 ********************************************************************************************/
02450 
02451 BOOL CXaraFileTxtRuler::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtRuler *pAttr)
02452 {
02453 #ifdef DO_EXPORT
02454     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02455     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02456 
02457     return WritePreChildrenAux(pFilter, pAttr);
02458 #else
02459     return FALSE;
02460 #endif
02461 }
02462 
02463 BOOL CXaraFileTxtRuler::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtRuler *pAttr)
02464 {
02465 #ifdef DO_EXPORT
02466     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02467     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02468 
02469     return WritePreChildrenAux(pFilter, pAttr);
02470 #else
02471     return FALSE;
02472 #endif
02473 }
02474 
02475 BOOL CXaraFileTxtRuler::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtRuler *pAttr)
02476 {
02477 #ifdef DO_EXPORT
02478     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02479     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02480 
02481     BOOL ok;
02482 
02483     CamelotFileRecord Rec(pFilter, TAG_TEXT_RULER, TAG_TEXT_RULER_SIZE);
02484     ok = Rec.Init();
02485     if (ok)
02486     {
02487         TxtRuler* pRuler = pAttr->Value.Value;
02488         UINT32 NumEntries = pRuler->size();
02489         ERROR2IF(NumEntries > 65535, FALSE, "too many tab stops");
02490         TRACEUSER("wuerthne", _T("saving ruler attribute with %d entries"), NumEntries);
02491         ok = Rec.WriteUINT16(NumEntries);
02492         for (TxtTabStopIterator it = pRuler->begin(); ok && it != pRuler->end(); ++it)
02493         {
02494             // we only write the tab filler when there is one, so if there is one,
02495             // set a flag in the type field to indicate that the char has been saved
02496             BOOL HasTabFiller = ((*it).GetTabFillerChar() != WCHAR(0));
02497             BYTE TypeAndFlags = (*it).GetType() | (HasTabFiller ? 4 : 0);
02498             ok = Rec.WriteBYTE(TypeAndFlags);
02499             if (ok) ok = Rec.WriteINT32((*it).GetPosition());
02500             // the decimal tab character is only defined for decimal tabs
02501             if ((*it).GetType() == DecimalTab)
02502                 if (ok) ok = Rec.WriteWCHAR((*it).GetDecimalPointChar());
02503             // the tab filler character is only written when there is one
02504             if (HasTabFiller)
02505                 if (ok) ok = Rec.WriteWCHAR((*it).GetTabFillerChar());
02506         }
02507     }
02508     if (ok) ok = pFilter->Write(&Rec);
02509 
02510     return ok;
02511 #else
02512     return FALSE;
02513 #endif
02514 }
02515 
02516 /********************************************************************************************
02517 
02518 >   BOOL CXaraFileTxtLineSpace::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtLineSpace *pAttr);
02519     BOOL CXaraFileTxtLineSpace::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtLineSpace *pAttr);
02520     BOOL CXaraFileTxtLineSpace::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtLineSpace *pAttr);
02521 
02522     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
02523     Created:    09/07/96
02524     Inputs:     pFilter - camelot filter to use
02525                 pAttr   - attribute to save
02526     Returns:    TRUE if successful, FALSE otherwise
02527     Purpose:    Saves the text line space attribute to the filter
02528 
02529 ********************************************************************************************/
02530 
02531 BOOL CXaraFileTxtLineSpace::WritePreChildrenWeb(BaseCamelotFilter *pFilter, AttrTxtLineSpace *pAttr)
02532 {
02533 #ifdef DO_EXPORT
02534     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02535     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02536 
02537     return WritePreChildrenAux(pFilter, pAttr);
02538 #else
02539     return FALSE;
02540 #endif
02541 }
02542 
02543 BOOL CXaraFileTxtLineSpace::WritePreChildrenNative(BaseCamelotFilter *pFilter, AttrTxtLineSpace *pAttr)
02544 {
02545 #ifdef DO_EXPORT
02546     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02547     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02548 
02549     return WritePreChildrenAux(pFilter, pAttr);
02550 #else
02551     return FALSE;
02552 #endif
02553 }
02554 
02555 BOOL CXaraFileTxtLineSpace::WritePreChildrenAux(BaseCamelotFilter *pFilter, AttrTxtLineSpace *pAttr)
02556 {
02557 #ifdef DO_EXPORT
02558     ERROR2IF(pFilter==NULL, FALSE, "Parameter pFilter == NULL.");
02559     ERROR2IF(pAttr==NULL, FALSE, "Parameter pAttr == NULL.");
02560 
02561     BOOL ok;
02562 
02563     if (pAttr->Value.IsARatio())
02564     {
02565         // its a ratio linespace node
02566         CamelotFileRecord Rec(pFilter, TAG_TEXT_LINESPACE_RATIO, TAG_TEXT_LINESPACE_RATIO_SIZE);
02567         ok = Rec.Init();
02568         if (ok) ok = Rec.WriteFIXED16(pAttr->Value.Ratio);
02569         if (ok) ok = pFilter->Write(&Rec);
02570     }
02571     else
02572     {
02573         // its an absolute linespace node
02574         CamelotFileRecord Rec(pFilter, TAG_TEXT_LINESPACE_ABSOLUTE, TAG_TEXT_LINESPACE_ABSOLUTE_SIZE);
02575         ok = Rec.Init();
02576         if (ok) ok = Rec.WriteINT32(pAttr->Value.Value);
02577         if (ok) ok = pFilter->Write(&Rec);
02578     }
02579 
02580     return ok;
02581 #else
02582     return FALSE;
02583 #endif
02584 }
02585 
02586 #endif  // DO_EXPORT

Generated on Sat Nov 10 03:44:59 2007 for Camelot by  doxygen 1.4.4