00001 // $Id: styles.cpp 1688 2006-08-10 12:05:20Z gerry $ 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 00102 #include "camtypes.h" 00103 //#include "doccomp.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00104 //#include "cxfrech.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00105 #include "styles.h" 00106 00107 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00108 //#include "basedoc.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00109 //#include "camfiltr.h" // BaseCamelotFilter - version 2 native filter - in camtypes.h [AUTOMATICALLY REMOVED] 00110 #include "cxftags.h" // TAG_... 00111 //#include "cxfdefs.h" // - in camtypes.h [AUTOMATICALLY REMOVED] 00112 #include "cxfile.h" // CXF_UNKNOWN_SIZE 00113 //#include "cxfrec.h" // CXaraFileRecord handler - in camtypes.h [AUTOMATICALLY REMOVED] 00114 #include "userattr.h" 00115 #include "tmpltatr.h" 00116 #include "tmpltarg.h" 00117 //#include "tmpltdlg.h" 00118 00119 //#include "tmpltres.h" 00120 //#include "tim.h" // _R(IDE_FILE_READ_ERROR) 00121 00122 /******************************************************************************************** 00123 00124 > class RecordReferenceItem : public ListItem 00125 00126 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00127 Created: 15/07/96 00128 00129 Purpose: When importing & exporting we want to hang on to references of the records 00130 we've written or read and the objects they represent, so that referencing 00131 records can pick up the associated item. 00132 This abstract class provides just the record reference (XFileRef). 00133 Derived classes should provide the object. 00134 00135 SeeAlso: StyleRecordReference 00136 00137 ********************************************************************************************/ 00138 class RecordReferenceItem : public ListItem 00139 { 00140 CC_DECLARE_MEMDUMP(RecordReferenceItem) 00141 00142 public: 00143 virtual BOOL operator==(const RecordReferenceItem& Other) const = 0; 00144 virtual RecordReferenceItem* CreateCopy(const XFileRef& NewReference) const = 0; 00145 00146 // Data access 00147 XFileRef GetRecordRef() const { return m_RecordRef; } 00148 00149 protected: 00150 // only derived classes can "construct" one of these 00151 RecordReferenceItem(XFileRef Ref = XFILEREF_ERROR) : m_RecordRef(Ref) {} 00152 00153 00154 private: 00155 XFileRef m_RecordRef; 00156 }; 00157 00158 00159 00160 /******************************************************************************************** 00161 00162 > class StyleRecordReference : public RecordReferenceItem 00163 00164 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00165 Created: 15/07/96 00166 00167 Purpose: Represents an association twixt Style and Record reference 00168 00169 SeeAlso: StylesExporter, WizOpStyleRecordHandler 00170 00171 ********************************************************************************************/ 00172 class StyleRecordReference : public RecordReferenceItem 00173 { 00174 CC_DECLARE_MEMDUMP(StyleRecordReference) 00175 00176 public: 00177 StyleRecordReference(const Style& StyleExported, XFileRef Ref = XFILEREF_ERROR) : 00178 RecordReferenceItem(Ref), 00179 m_StyleExported(StyleExported) {} 00180 00181 RecordReferenceItem* CreateCopy(const XFileRef& NewReference) const; 00182 virtual BOOL operator==(const RecordReferenceItem& Other) const; 00183 00184 const Style& GetStyle() const { return m_StyleExported; } 00185 00186 private: 00187 const Style& m_StyleExported; 00188 }; 00189 00190 00191 /******************************************************************************************** 00192 00193 > class StyleContainerItem : public ListItem 00194 00195 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00196 Created: 15/07/96 00197 00198 Purpose: Provides an item for the container of a load of Style's 00199 00200 SeeAlso: StyleContainer 00201 00202 ********************************************************************************************/ 00203 class StyleContainerItem : public ListItem 00204 { 00205 CC_DECLARE_MEMDUMP(StyleContainerItem) 00206 00207 public: 00208 StyleContainerItem(Style& TheStyle) : m_Style(TheStyle) {} 00209 virtual ~StyleContainerItem() { delete &m_Style; } 00210 00211 Style& GetStyle() { return m_Style; } 00212 00213 00214 StyleContainerItem(StyleContainerItem& Other) : m_Style(Other.m_Style) 00215 { 00216 TRACE( _T("StyleContainerItem - Copy constructor not implemented")); 00217 } 00218 StyleContainerItem& operator=(StyleContainerItem& Other) 00219 { 00220 TRACE( _T("StyleContainerItem - Assignment operator not implemented")); 00221 return *this; 00222 } 00223 00224 private: 00225 Style& m_Style; 00226 }; 00227 00228 00229 /******************************************************************************************** 00230 00231 > class StyleContainer : public List 00232 00233 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00234 Created: 15/07/96 00235 00236 Purpose: Provides a container for a load of Style's 00237 00238 SeeAlso: Styles 00239 00240 Notes: At present this is a list. Someone might want a more efficient data 00241 structure for searching... 00242 00243 ********************************************************************************************/ 00244 class StyleContainer : public List 00245 { 00246 CC_DECLARE_MEMDUMP(StyleContainer) 00247 public: 00248 ~StyleContainer() { DeleteAll(); } 00249 00250 BOOL AddStyle(Style& TheStyle); 00251 00252 }; 00253 00254 00255 00256 00257 00258 00259 00260 00261 DECLARE_SOURCE("$Revision: 1688 $"); 00262 00263 #define ENSURE_KIND(pInstance, Class) ERROR3IF(!pInstance->IS_KIND_OF(Class), #pInstance" is not kind of "#Class); 00264 00265 00266 CC_IMPLEMENT_MEMDUMP(StyleContainerItem, ListItem) 00267 CC_IMPLEMENT_MEMDUMP(StyleContainer, List) 00268 00269 CC_IMPLEMENT_DYNAMIC(StylesMessage, Msg) 00270 00271 CC_IMPLEMENT_MEMDUMP(Style, CC_CLASS_MEMDUMP) 00272 CC_IMPLEMENT_DYNAMIC(Styles, DocComponent) 00273 00274 CC_IMPLEMENT_DYNAMIC(WizOpStyleComponentClass, DocComponentClass) 00275 CC_IMPLEMENT_MEMDUMP(WizOpStyle, Style) 00276 CC_IMPLEMENT_DYNAMIC(WizOpStyles, Styles) 00277 00278 CC_IMPLEMENT_MEMDUMP(RecordReferenceItem, ListItem) 00279 CC_IMPLEMENT_MEMDUMP(StyleRecordReference, RecordReferenceItem) 00280 00281 CC_IMPLEMENT_DYNAMIC(WizOpStyleRecordHandler, CamelotRecordHandler) 00282 00283 CC_IMPLEMENT_MEMDUMP(RecordReferencingExporter, CC_CLASS_MEMDUMP) 00284 CC_IMPLEMENT_MEMDUMP(StylesExporter, RecordReferencingExporter) 00285 00286 // This should come after the IMPLEMENT macros 00287 // Declare smart memory handling in Debug builds 00288 #define new CAM_DEBUG_NEW 00289 00290 00291 00292 BOOL StyleContainer::AddStyle(Style& TheStyle) 00293 { 00294 BOOL Ok = TRUE; 00295 00296 StyleContainerItem* const pLink = new StyleContainerItem(TheStyle); 00297 Ok = (pLink != NULL); 00298 00299 if (Ok) 00300 { 00301 AddTail(pLink); 00302 } 00303 00304 return Ok; 00305 } 00306 00307 00308 StyleIterator::StyleIterator(StyleContainer& Container, StyleContainerItem* const pPosition) : 00309 m_CurrentItem(pPosition), 00310 m_Container(Container) 00311 { 00312 } 00313 00314 00315 00316 StyleIterator& StyleIterator::operator++() 00317 { 00318 m_CurrentItem = (StyleContainerItem*)m_Container.GetNext(m_CurrentItem); 00319 00320 return *this; 00321 } 00322 00323 00324 BOOL StyleIterator::operator!=(const StyleIterator& Other) 00325 { 00326 return m_CurrentItem != Other.m_CurrentItem; 00327 } 00328 00329 00330 Style& StyleIterator::operator*() 00331 { 00332 ASSERT(m_CurrentItem != NULL); 00333 00334 return m_CurrentItem->GetStyle(); 00335 } 00336 00337 00338 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 00339 // S T Y L E 00340 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 00341 00342 00343 00344 00345 00346 00347 /******************************************************************************************** 00348 00349 > Style::Style(const StringBase& Name) 00350 00351 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00352 Created: 11/07/97 00353 00354 Purpose: Constructs a Style of the given Name and thereby makes sure this Style has 00355 a name (unless you give it an empty string) 00356 00357 ********************************************************************************************/ 00358 Style::Style(const StringBase& Name) 00359 { 00360 SetName(Name); 00361 } 00362 00363 00364 00365 /******************************************************************************************** 00366 00367 > Style::~Style() 00368 00369 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00370 Created: 11/07/97 00371 00372 Purpose: Bizzaro pure implementation 00373 00374 ********************************************************************************************/ 00375 Style::~Style() 00376 { 00377 } 00378 00379 00380 /******************************************************************************************** 00381 00382 > BOOL Style::operator==(const Style& OtherStyle) const 00383 00384 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00385 Created: 11/07/97 00386 00387 Purpose: Compares two Style's 00388 00389 Returns: TRUE if the names are the same, FALSe if not 00390 00391 ********************************************************************************************/ 00392 BOOL Style::operator==(const Style& OtherStyle) const 00393 { 00394 return GetName() == OtherStyle.GetName(); 00395 } 00396 00397 00398 00399 /******************************************************************************************** 00400 00401 > const StringBase& Style::GetName() const 00402 BOOL Style::SetName(const StringBase& Name) 00403 00404 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00405 Created: 11/07/97 00406 00407 Purpose: Derived class data member access 00408 00409 ********************************************************************************************/ 00410 const StringBase& Style::GetName() const 00411 { 00412 return m_Name; 00413 } 00414 00415 00416 BOOL Style::SetName(const StringBase& Name) 00417 { 00418 m_Name = Name; 00419 00420 return TRUE; 00421 } 00422 00423 00424 00425 00426 00427 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 00428 // S T Y L E S 00429 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 00430 00431 00432 00433 00434 00435 00436 /******************************************************************************************** 00437 00438 > Styles::Styles() 00439 00440 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00441 Created: 11/07/97 00442 00443 Purpose: Default constructor would fail, so use an Init() if you don't want a lot 00444 of ERROR2's 00445 00446 ********************************************************************************************/ 00447 Styles::Styles() 00448 { 00449 m_pStyleContainer = NULL; // we'll fill this in in init() 00450 m_pCurrentExporter = NULL; // we create an exporter when we need one 00451 m_pStylesToAdd = NULL; // this is used during a Component Copy 00452 } 00453 00454 00455 /******************************************************************************************** 00456 00457 > BOOL Styles::Init() 00458 00459 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00460 Created: 11/07/97 00461 00462 Purpose: Default constructor would fail, so use an Init() if you don't want a lot 00463 of ERROR2's 00464 00465 ********************************************************************************************/ 00466 BOOL Styles::Init() 00467 { 00468 m_pStyleContainer = new StyleContainer; 00469 00470 return (m_pStyleContainer != NULL); 00471 } 00472 00473 00474 /******************************************************************************************** 00475 00476 > Styles::~Styles() 00477 00478 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00479 Created: 11/07/97 00480 Purpose: Clean up a colour list component's data structures - deletes the colour 00481 list. 00482 Errors: ENSURE if IndexedColour copying stuff has not been cleaned up (this will 00483 occur if End/AbortComponentCopy is not called after a component copy) 00484 SeeAlso: WizOpStyles 00485 00486 ********************************************************************************************/ 00487 Styles::~Styles() 00488 { 00489 if (m_pCurrentExporter) 00490 { 00491 // This should have been deleted in EndExport() 00492 TRACE( _T("Styles::~Styles() - m_pCurrentExporter not gone")); 00493 delete m_pCurrentExporter; 00494 m_pCurrentExporter = NULL; 00495 } 00496 00497 delete m_pStyleContainer; 00498 m_pStyleContainer = NULL; 00499 } 00500 00501 00502 /******************************************************************************************** 00503 00504 > Styles::Styles(const Styles&) 00505 Styles& Styles::operator=(const Styles&) 00506 00507 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00508 Created: 11/07/97 00509 00510 Purpose: Warns us that we've done a destructor but we haven't done either of these 00511 00512 ********************************************************************************************/ 00513 Styles::Styles(const Styles&) 00514 { 00515 TRACE( _T("Styles - Copy constructor not implemented")); 00516 } 00517 00518 Styles& Styles::operator=(const Styles&) 00519 { 00520 TRACE( _T("Styles - Assignment operator not implemented")); 00521 00522 return *this; 00523 } 00524 00525 00526 /******************************************************************************************** 00527 00528 > StyleContainer& Styles::GetContainer() const 00529 00530 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00531 Created: 11/07/97 00532 00533 Purpose: The actual styles are held in an internal container. This member provides 00534 access to them. 00535 00536 ********************************************************************************************/ 00537 StyleContainer& Styles::GetContainer() const 00538 { 00539 // This static dummy object is used for returning in the ERROR2 case 00540 // The original used to return a ptr to a local variable, which is a tad dangerous. 00541 // This solution is not ideal, because there's a permanent instance of an object 00542 // that will probably never be used. 00543 static StyleContainer Dummy; 00544 00545 ERROR2IF(m_pStyleContainer == NULL, Dummy, "NULL Member"); 00546 00547 return *m_pStyleContainer; 00548 } 00549 00550 00551 00552 /******************************************************************************************** 00553 00554 > virtual Style* Styles::AddStyle(const Style& NewStyle) 00555 00556 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00557 Created: 11/07/97 00558 00559 Purpose: Adds the given style to this Styles collection, ensuring that there's only 00560 one with the style's name. 00561 00562 Inputs: NewStyle - the style to add 00563 Returns: A pointer to the style contained in this collection or NULL if it didn't 00564 work. 00565 00566 ********************************************************************************************/ 00567 Style* Styles::AddStyle(const Style& NewStyle) 00568 { 00569 ENSURE_NOT_NULL(m_pStyleContainer); 00570 00571 // Look for an existing one which we could return 00572 Style* pStyleToUse = FindStyleFromName(NewStyle.GetName()); 00573 if (pStyleToUse == NULL) 00574 { 00575 // didn't find one so create a spanking new version 00576 Style* pNewStyleCopy = NewStyle.CreateCopy(NewStyle.GetName()); 00577 if (pNewStyleCopy != NULL) 00578 { 00579 if (!GetContainer().AddStyle(*pNewStyleCopy)) 00580 { 00581 delete pNewStyleCopy; 00582 pNewStyleCopy = NULL; 00583 } 00584 } 00585 pStyleToUse = pNewStyleCopy; 00586 } 00587 00588 return pStyleToUse; 00589 } 00590 00591 /******************************************************************************************** 00592 00593 > virtual StyleIterator Styles::Begin() const 00594 00595 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00596 Created: 11/07/97 00597 00598 Purpose: Allows access to individual members of the Styles collection 00599 00600 Returns: An iterator which will run through to the End() of the styles collection. 00601 00602 ********************************************************************************************/ 00603 StyleIterator Styles::Begin() const 00604 { 00605 if (m_pStyleContainer != NULL) 00606 { 00607 return StyleIterator(*m_pStyleContainer, (StyleContainerItem*)(GetContainer().GetHead())); 00608 } 00609 else 00610 { 00611 StyleContainer Container; 00612 return StyleIterator( Container, NULL ); 00613 } 00614 } 00615 00616 00617 /******************************************************************************************** 00618 00619 > const StyleIterator& Styles::End() const 00620 00621 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00622 Created: 11/07/97 00623 00624 Purpose: Allows access to individual members of the Styles collection 00625 00626 Returns: A reference to a constant iterator which marks the end of the collection 00627 00628 ********************************************************************************************/ 00629 const StyleIterator& Styles::End() const 00630 { 00631 StyleContainer Container; 00632 static const StyleIterator TheEnd( Container, NULL); 00633 00634 return TheEnd; 00635 } 00636 00637 00638 /******************************************************************************************** 00639 00640 > virtual Style* Styles::AddStyle(const Style& NewStyle) 00641 00642 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00643 Created: 11/07/97 00644 00645 Purpose: Adds the given style to this Styles collection, ensuring that there's only 00646 one with the style's name. 00647 00648 Inputs: NewStyle - the style to add 00649 Returns: A pointer to the style contained in this collection or NULL if it didn't 00650 work. 00651 00652 ********************************************************************************************/ 00653 Style* Styles::FindStyleFromName(const StringBase& StyleName) const 00654 { 00655 ENSURE_NOT_NULL(m_pStyleContainer); 00656 00657 Style* pStyleFound = NULL; // return this 00658 00659 StyleContainerItem* pCurrentStyle = (StyleContainerItem*)m_pStyleContainer->GetHead(); 00660 while (pCurrentStyle != NULL && pStyleFound == NULL) 00661 { 00662 if (pCurrentStyle->GetStyle().GetName() == StyleName) 00663 { 00664 pStyleFound = &(pCurrentStyle->GetStyle()); 00665 } 00666 else 00667 { 00668 pCurrentStyle = (StyleContainerItem*)m_pStyleContainer->GetNext(pCurrentStyle); 00669 } 00670 } 00671 00672 return pStyleFound; 00673 } 00674 00675 00676 /******************************************************************************************** 00677 00678 > virtual BOOL Styles::MergeStyles(const Styles& OtherStyles) 00679 00680 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00681 Created: 11/07/97 00682 00683 Purpose: Removes the styles in the given styles container and adds them to this one. 00684 Duplicates are ignored, so be careful. 00685 00686 Inputs: OtherStyles - the styles to merge 00687 Returns: TRUE if it worked 00688 00689 ********************************************************************************************/ 00690 BOOL Styles::MergeStyles(Styles& OtherStyles) 00691 { 00692 BOOL Ok = TRUE; 00693 00694 StyleContainer& OtherContainer = OtherStyles.GetContainer(); 00695 StyleContainer& ThisContainer = GetContainer(); 00696 00697 ListItem* pLink = OtherContainer.RemoveHead(); 00698 while (pLink != NULL && Ok) 00699 { 00700 ThisContainer.AddTail(pLink); 00701 00702 pLink = OtherContainer.RemoveHead(); 00703 } 00704 00705 return Ok; 00706 } 00707 00708 00709 /******************************************************************************************** 00710 00711 > virtual BOOL Styles::StartComponentCopy() 00712 00713 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00714 Created: 11/07/97 00715 00716 Purpose: This function gets called to prepare for an inter-document styles copy. 00717 00718 Returns: TRUE if it succeeded. FALSE if the copy must be aborted 00719 00720 SeeAlso: WizOpStyles::EndComponentCopy; 00721 WizOpStyles::AbortComponentCopy; 00722 WizOpStyles::CopyComponentData 00723 00724 ********************************************************************************************/ 00725 BOOL Styles::StartComponentCopy() 00726 { 00727 ERROR2IF(m_pStylesToAdd != NULL, FALSE, "Styles::StartComponentCopy() - Copy already in progress?\n"); 00728 00729 BOOL Ok = TRUE; 00730 00731 m_pStylesToAdd = new Styles(); 00732 Ok = (m_pStylesToAdd != NULL); 00733 00734 if (Ok) 00735 { 00736 m_pStylesToAdd->Init(); 00737 } 00738 00739 return Ok; 00740 } 00741 00742 00743 /******************************************************************************************** 00744 00745 > virtual Style* Styles::CopyComponentData(const Style& StyleToCopy) 00746 00747 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00748 Created: 11/07/97 00749 00750 Purpose: In between StartComponentCopy() & EndComponentCopy() this function is called 00751 by StyleReferenceAttribute::CopyComponentData() to ensure that styles are 00752 merged between documents. 00753 00754 Inputs: The style that should be used by any reference. 00755 Returns: The style that should be used by any reference. 00756 00757 00758 ********************************************************************************************/ 00759 Style* Styles::CopyComponentData(const Style& StyleToCopy) 00760 { 00761 // it would be helpful if one of these were set up in StartComponentCopy() 00762 ENSURE_NOT_NULL(m_pStylesToAdd); 00763 00764 Style* pStyleToUse = NULL; // return this 00765 00766 // If we've already got a style of the same name 00767 // If the style definitions are the same then use the existing one 00768 // If they're different, rename the style, and add it to the list to add at the end 00769 00770 Style* pStyleToAdd = NULL; // if any 00771 Style* const pExistingStyle = FindStyleFromName(StyleToCopy.GetName()); 00772 if (pExistingStyle != NULL) 00773 { 00774 if (StyleToCopy == *pExistingStyle) 00775 { 00776 pStyleToUse = pExistingStyle; 00777 } 00778 else // conflicting style names so create a new one 00779 { 00780 String_64 NewStyleName = StyleToCopy.GetName(); 00781 GenerateUniqueName(NewStyleName, &NewStyleName); 00782 pStyleToAdd = StyleToCopy.CreateCopy(NewStyleName); 00783 } 00784 } 00785 else 00786 { 00787 // there was no existing style so add the style to the list of styles to add at the end 00788 pStyleToAdd = StyleToCopy.CreateCopy(StyleToCopy.GetName()); 00789 } 00790 00791 // We may need to add a new style to the list to merge at the end 00792 if (pStyleToAdd != NULL) 00793 { 00794 pStyleToUse = GetStylesToAdd().AddStyle(*pStyleToAdd); 00795 // AddStyle copies the one we give it, so delete it 00796 delete pStyleToAdd; 00797 } 00798 00799 return pStyleToUse; 00800 } 00801 00802 00803 /******************************************************************************************** 00804 00805 > virtual BOOL Styles::EndComponentCopy() 00806 00807 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00808 Created: 11/07/97 00809 00810 Purpose: Will commit all changes made by doing the component copy, returning TRUE. 00811 Any new colours will be inserted as instructed by the InsertBefore parameter. 00812 If some colours will not be insterted because they were merged, then a report 00813 to this effect can be given if desired. 00814 00815 Returns: TRUE if it succeeded 00816 00817 00818 ********************************************************************************************/ 00819 BOOL Styles::EndComponentCopy() 00820 { 00821 // it would be helpful if one of these were set up in StartComponentCopy() 00822 // Unfortunately Undo'ing a Copy will just call this without a Start...we'll do nothing 00823 // then 00824 if (m_pStylesToAdd != NULL) 00825 { 00826 MergeStyles(GetStylesToAdd()); 00827 delete m_pStylesToAdd; 00828 m_pStylesToAdd = NULL; 00829 00830 SendStylesChangeMessage(); 00831 } 00832 00833 return TRUE; 00834 } 00835 00836 00837 00838 /******************************************************************************************** 00839 00840 > void Styles::AbortComponentCopy() 00841 00842 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00843 Created: 11/07/97 00844 00845 Purpose: Will abort all changes made for component copies. 00846 This means that things such as the colours referenced by the nodes 00847 you have just copied do not exist, so you must clean up to the state 00848 the document was in before you strated copying. 00849 00850 Notes: May be called even if StartComponentCopy has not been called. 00851 May be called multiple times 00852 00853 SeeAlso: WizOpStyles::EndComponentCopy; 00854 WizOpStyles::AbortComponentCopy; 00855 WizOpStyles::CopyColourAcross 00856 00857 ********************************************************************************************/ 00858 void Styles::AbortComponentCopy() 00859 { 00860 delete m_pStylesToAdd; 00861 m_pStylesToAdd = NULL; 00862 } 00863 00864 00865 /******************************************************************************************** 00866 00867 > Styles& Styles::GetStylesToAdd() const 00868 00869 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00870 Created: 11/07/97 00871 00872 Purpose: During a component copy (or import) we have some styles to add at the end 00873 (although they maybe empty). 00874 This function provides access to them. 00875 00876 Errors: If you call this at the wrong time an ERROR2 will result. 00877 00878 ********************************************************************************************/ 00879 Styles& Styles::GetStylesToAdd() const 00880 { 00881 // This static dummy object is used for returning in the ERROR2 case 00882 // The original used to return a ptr to a local variable, which is a tad dangerous. 00883 // This solution is not ideal, because there's a permanent instance of an object 00884 // that will probably never be used. 00885 static Styles Dummy; 00886 00887 ERROR2IF(m_pStylesToAdd == NULL, Dummy, "NULL Member"); 00888 00889 return *m_pStylesToAdd; 00890 } 00891 00892 00893 /******************************************************************************************** 00894 00895 > BOOL Styles::NameExists(const StringBase& Name) const 00896 00897 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00898 Created: 11/07/97 00899 00900 Purpose: Tells us if the given name exists in this Styles collection or the Styles 00901 we're adding (cos we only want to eliminate duplicates when we're adding 00902 styles see). 00903 00904 Inputs: Name: the name of the style we want to add 00905 Returns: TRUE if there's a style in here with that Name, FALSE if not 00906 00907 Notes: Used by GenerateUniqueName() during ComponentCopy 00908 00909 ********************************************************************************************/ 00910 BOOL Styles::NameExists(const StringBase& Name) const 00911 { 00912 return (FindStyleFromName(Name) != NULL || 00913 GetStylesToAdd().FindStyleFromName(Name) != NULL); 00914 } 00915 00916 00917 /******************************************************************************************** 00918 00919 > BOOL Styles::GenerateUniqueName(const StringBase& Prefix, StringBase* pResult) 00920 00921 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Jason (From code by Tim)) 00922 Created: 11/07/97 (16/12/94 (8/8/94)) 00923 00924 Purpose: Scans the styles to determine if the suggested name is unique 00925 within this collection. If it is not, the name is altered (currently by 00926 removing the last 14 characters and appending a decimal number) to provide 00927 a unique name, which is returned in the supplied string. 00928 00929 Inputs: pPrefix - Points to the suggested name for this style. 00930 00931 Outputs: pResult - is filled in with a unique name 00932 00933 Returns: TRUE if the pResult contains a different string from that supplied in 00934 pPrefix. (pResult will always contain a valid result, but checking this flag 00935 may save you the bother of copying the string over) 00936 00937 00938 Notes: This method should only be called when importing or copying styles. 00939 Name matching is done using StringBase::IsIdentical, so see that method 00940 to determine the rules by which strings are matched 00941 00942 ********************************************************************************************/ 00943 BOOL Styles::GenerateUniqueName(const StringBase& Prefix, StringBase* pResult) 00944 { 00945 ENSURE_NOT_NULL(pResult); 00946 00947 // Either the List is empty, or this name is unique, so return it (ensuring < 64 chars) 00948 Prefix.Left(pResult, pResult->MaxLength()); 00949 if (!NameExists(*pResult)) 00950 { 00951 return(FALSE); 00952 } 00953 00954 Prefix.Left(pResult, pResult->MaxLength() - 14); // Copy into NewName, truncating 00955 INT32 PrefixLen = pResult->Length(); 00956 00957 LPTSTR pPrefixEnd = (TCHAR*)(*pResult); 00958 pPrefixEnd += PrefixLen; 00959 00960 INT32 i = 2; 00961 00962 do 00963 { 00964 camSnprintf( pPrefixEnd, 256, _T(" %ld"), i++ ); 00965 } 00966 while (NameExists(*pResult)); 00967 00968 return TRUE; 00969 } 00970 00971 00972 00973 void Styles::SendStylesChangeMessage() 00974 { 00975 PORTNOTETRACE("other","Styles::SendStylesChangeMessage - do nothing - using TemplateDialog"); 00976 #ifndef EXCLUDE_FROM_XARALX 00977 if (MessageHandler::MessageHandlerExists(CC_RUNTIME_CLASS(TemplateDialog))) 00978 { 00979 BROADCAST_TO_CLASS(StylesMessage(*this), DialogOp); 00980 } 00981 #endif 00982 } 00983 00984 00985 00986 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 00987 // V I S I B L E T E M P L A T E A T T R I B U T E 00988 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 00989 00990 00991 00992 WizOpStyle::WizOpStyle( const StringBase& Name, const StringBase& Question, 00993 const WizOp& WizOpRef, const StringBase& Param) : 00994 Style(Name), 00995 m_WizOp(WizOpRef) 00996 { 00997 SetQuestion(Question); 00998 00999 SetParam(Param); 01000 } 01001 01002 01003 01004 Style* WizOpStyle::CreateCopy(const StringBase& NewName) const 01005 { 01006 return new WizOpStyle(NewName, GetQuestion(), GetWizOp(), GetParam()); 01007 } 01008 01009 01010 BOOL WizOpStyle::operator==(const Style& OtherStyle) const 01011 { 01012 ERROR3IF(!OtherStyle.IsKindOf(CC_RUNTIME_CLASS(WizOpStyle)), "OtherStyle isn't a WizOpStyle"); 01013 01014 const WizOpStyle& OtherWizOpStyle = (const WizOpStyle&)OtherStyle; 01015 01016 return (Style::operator==(OtherStyle) && 01017 m_Question == OtherWizOpStyle.m_Question && 01018 &m_WizOp == &(OtherWizOpStyle.m_WizOp) && 01019 m_Param == OtherWizOpStyle.m_Param); 01020 } 01021 01022 01023 BOOL WizOpStyle::SetQuestion(const StringBase& NewQuestion) 01024 { 01025 if (NewQuestion.Length() > m_Question.MaxLength()) 01026 { 01027 TRACE( _T("WizOpStyle::SetQuestion - Couldn't you ask a shorter question?\n")); 01028 } 01029 NewQuestion.Left(&m_Question, m_Question.MaxLength()); 01030 01031 return TRUE; 01032 } 01033 01034 BOOL WizOpStyle::SetParam(const StringBase& NewParam) 01035 { 01036 BOOL AllCopied = TRUE; 01037 01038 if (NewParam.Length() > m_Param.MaxLength()) 01039 { 01040 TRACE( _T("WizOpStyle::SetParam - That param's too long!\n")); 01041 AllCopied = FALSE; 01042 } 01043 NewParam.Left(&m_Param, m_Param.MaxLength()); 01044 01045 return AllCopied; 01046 } 01047 01048 01049 const StringBase& WizOpStyle::GetQuestion() const 01050 { 01051 return m_Question; 01052 } 01053 01054 const WizOp& WizOpStyle::GetWizOp() const 01055 { 01056 return m_WizOp; 01057 } 01058 01059 const StringBase& WizOpStyle::GetParam() const 01060 { 01061 return m_Param; 01062 } 01063 01064 01065 01066 /******************************************************************************************** 01067 01068 > BOOL WizOpStyles::StartImport(BaseCamelotFilter *pFilter) 01069 01070 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01071 Created: 11/07/97 01072 Inputs: pFilter - the BaseCamelotFilter filter that is being used to import a file. 01073 Returns: TRUE if the component was able to prepare for importing; 01074 FALSE if not (e.g. out of memory) 01075 Purpose: Inform the colour list document component that a Native or Web import is 01076 about to start. 01077 SeeAlso: DocComponent 01078 01079 ********************************************************************************************/ 01080 BOOL WizOpStyles::StartImport(BaseCamelotFilter* pFilter) 01081 { 01082 ENSURE_NOT_NULL(pFilter); 01083 01084 BOOL Ok = StartComponentCopy(); 01085 01086 return Ok; 01087 } 01088 01089 01090 01091 /******************************************************************************************** 01092 01093 > WizOpStyle* WizOpStyles::FindStyleFromRecordReference(XFileRef RecordRef) const 01094 01095 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01096 Created: 11/07/97 01097 01098 Purpose: In between StartImport & EndImport this function is called by 01099 WizOpStyleRefRecordHandler::HandleRecord so it knows which WizOpStyle to use 01100 for its StyleRefAttribute. 01101 01102 ********************************************************************************************/ 01103 WizOpStyle* WizOpStyles::FindStyleFromRecordReference(XFileRef RecordRef) const 01104 { 01105 return GetRecordHandler().FindStyleFromRecordReference(RecordRef); 01106 } 01107 01108 01109 /******************************************************************************************** 01110 01111 > BOOL WizOpStyles::EndImport(BaseCamelotFilter *pFilter, BOOL Success) 01112 01113 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01114 Created: 11/07/97 01115 01116 Purpose: Inform the component that a Native or Web import has just finished. 01117 Calls EndCopyComponent(q.v) 01118 01119 Inputs: pFilter - the BaseCamelotFilter filter that is being used to import a file. 01120 Success - TRUE => The import was successful; 01121 FALSE => The import failed - abandon any changes. 01122 Returns: TRUE if the component was able to end the importing; 01123 FALSE if not (e.g. out of memory) 01124 01125 ********************************************************************************************/ 01126 BOOL WizOpStyles::EndImport(BaseCamelotFilter *pFilter, BOOL Success) 01127 { 01128 ENSURE_NOT_NULL(pFilter); 01129 01130 BOOL Ok = EndComponentCopy(); 01131 01132 m_pImporter = NULL; 01133 01134 return Ok; 01135 } 01136 01137 01138 BOOL WizOpStyles::SetRecordHandler(WizOpStyleRecordHandler& RecordHandler) 01139 { 01140 #ifdef _DEBUG 01141 /*Styles& ThisShouldWork =*/ GetStylesToAdd(); // there should be some styles that we can add to 01142 #endif 01143 01144 m_pImporter = &RecordHandler; 01145 01146 return TRUE; 01147 } 01148 01149 01150 WizOpStyleRecordHandler& WizOpStyles::GetRecordHandler() const 01151 { 01152 // This static dummy object is used for returning in the ERROR2 case 01153 // The original used to return a ptr to a local variable, which is a tad dangerous. 01154 // This solution is not ideal, because there's a permanent instance of an object 01155 // that will probably never be used. 01156 static WizOpStyleRecordHandler Dummy; 01157 01158 ERROR2IF(m_pImporter == NULL, Dummy, "NULL Member"); 01159 01160 return *m_pImporter; 01161 } 01162 01163 01164 /******************************************************************************************** 01165 01166 > BOOL WizOpStyles::StartExport(BaseCamelotFilter *pFilter) 01167 01168 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01169 Created: 11/07/97 01170 Returns: TRUE if the component was able to prepare for exporting; 01171 FALSE if not (e.g. out of memory) 01172 Inputs: pFilter - the BaseCamelotFilter filter that is being used to export a file. 01173 Purpose: Inform the colour list document component that a WEb or Native export is 01174 about to start. 01175 SeeAlso: DocComponent 01176 01177 ********************************************************************************************/ 01178 BOOL WizOpStyles::StartExport(BaseCamelotFilter *pFilter) 01179 { 01180 #ifdef DO_EXPORT 01181 ENSURE_NOT_NULL(pFilter); 01182 01183 // We don't support multi-threading 01184 ERROR2IF(m_pCurrentExporter != NULL, FALSE, "Current exporter already exists"); 01185 01186 // Create an exporter for the styles 01187 m_pCurrentExporter = new StylesExporter(*this, *pFilter); 01188 if (m_pCurrentExporter == NULL) 01189 return FALSE; 01190 #endif 01191 return TRUE; 01192 } 01193 01194 01195 /******************************************************************************************** 01196 01197 > virtual XFileRef WizOpStyles::GetRecordRefForStyle(const WizOpStyle& Style) 01198 01199 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01200 Created: 11/07/97 01201 01202 Purpose: Writes out a WizOpStyle record 01203 01204 Inputs: Style - The document colour to save 01205 01206 Returns: A record reference to be used for the style. 01207 This will be zero if a problem has occurred. 01208 01209 Notes: In the process of getting a record reference for the style the style itself 01210 may be written to the record stream. As this does save information, it 01211 *MUST* be called before the caller has called StartRecord() as otherwise 01212 the records will become intertwined! 01213 01214 ********************************************************************************************/ 01215 XFileRef WizOpStyles::GetRecordRefForStyle(const WizOpStyle& Style) 01216 { 01217 #ifdef DO_EXPORT 01218 // We should only be here after a StartExport 01219 ENSURE_NOT_NULL(m_pCurrentExporter); 01220 01221 INT32 RecordNumber = m_pCurrentExporter->WriteStyle(Style); 01222 01223 return RecordNumber; 01224 #endif 01225 return 0L; 01226 } 01227 01228 01229 01230 /******************************************************************************************** 01231 01232 > BOOL WizOpStyles::EndExport(BaseCamelotFilter *pFilter, BOOL Success) 01233 01234 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01235 Created: 11/07/97 01236 01237 Inputs: pFilter - the BaseCamelotFilter filter that is being used to import a file. 01238 Success - True if everything went swimmingly, False if just a clean up is required. 01239 Purpose: Inform the colour list document component that a Web or Native export has 01240 just finished. 01241 Returns: TRUE if the component was able to end the importing; 01242 FALSE if not (e.g. out of memory) 01243 SeeAlso: DocComponent 01244 01245 ********************************************************************************************/ 01246 BOOL WizOpStyles::EndExport(BaseCamelotFilter *pFilter, BOOL Success) 01247 { 01248 #ifdef DO_EXPORT 01249 ENSURE_NOT_NULL(pFilter); 01250 ENSURE_NOT_NULL(m_pCurrentExporter); 01251 01252 delete m_pCurrentExporter; 01253 m_pCurrentExporter = NULL; 01254 01255 return TRUE; 01256 #endif 01257 return TRUE; 01258 } 01259 01260 01261 01262 01263 01264 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 01265 // V I S I B L E T E M P L A T E A T T R I B U T E 01266 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 01267 01268 01269 01270 01271 01272 /******************************************************************************************** 01273 01274 > BOOL WizOpStyleComponentClass::Init() 01275 01276 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01277 Created: 09/07/97 01278 01279 Purpose: Registers this WizOpStyleComponentClass with the main application. It should 01280 be called at start-up, somewhere in main3.cpp would be nice. 01281 01282 Returns: TRUE if all went well; 01283 FALSE if not. 01284 01285 ********************************************************************************************/ 01286 BOOL WizOpStyleComponentClass::Init() 01287 { 01288 // Instantiate a component class to register with the application. 01289 WizOpStyleComponentClass *pClass = new WizOpStyleComponentClass; 01290 if (pClass == NULL) 01291 return FALSE; 01292 01293 // Register it 01294 GetApplication()->RegisterDocComponent(pClass); 01295 01296 // All ok 01297 return TRUE; 01298 } 01299 01300 01301 /******************************************************************************************** 01302 01303 > BOOL WizOpStyleComponentClass::AddComponent(BaseDocument *pDocument) 01304 01305 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01306 Created: 09/07/97 01307 01308 Purpose: Adds the WizOpStyleComponent to the specified document. 01309 01310 Inputs: pDocument - the document to add the WizOpStyleComponent to. 01311 01312 Returns: TRUE if the unit list was added ok; 01313 FALSE if not. 01314 01315 ********************************************************************************************/ 01316 BOOL WizOpStyleComponentClass::AddComponent(BaseDocument* pDocument) 01317 { 01318 BOOL Ok = TRUE; 01319 01320 // Check to see if this document already has a WizOp Style list; if so, leave it alone. 01321 if (pDocument->GetDocComponent(CC_RUNTIME_CLASS(WizOpStyles)) != NULL) 01322 return TRUE; 01323 01324 // Ok - create the WizOp Style component using this list. 01325 WizOpStyles* pComponent = new WizOpStyles(); 01326 Ok = (pComponent != NULL); 01327 01328 if (Ok) 01329 { 01330 Ok = pComponent->Init(); 01331 } 01332 01333 01334 if (Ok) 01335 { 01336 // All ok - add the component to the document. 01337 pDocument->AddDocComponent(pComponent); 01338 } 01339 01340 return Ok; 01341 } 01342 01343 01344 01345 01346 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 01347 // V I S I B L E T E M P L A T E A T T R I B U T E 01348 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 01349 01350 01351 01352 01353 /******************************************************************************************** 01354 01355 > WizOpStyleRecordHandler::WizOpStyleRecordHandler() 01356 01357 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01358 Created: 10/07/97 01359 01360 Purpose: Makes sure data members are initialized to safe values. 01361 01362 ********************************************************************************************/ 01363 WizOpStyleRecordHandler::WizOpStyleRecordHandler() : 01364 m_pTentativeStyles(NULL) 01365 { 01366 } 01367 01368 01369 /******************************************************************************************** 01370 01371 > WizOpStyleRecordHandler::~WizOpStyleRecordHandler() 01372 01373 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01374 Created: 10/07/97 01375 01376 Purpose: Makes sure data members are unheaped properly 01377 01378 ********************************************************************************************/ 01379 WizOpStyleRecordHandler::~WizOpStyleRecordHandler() 01380 { 01381 if (!m_ImportedItems.IsEmpty()) 01382 { 01383 TRACE( _T("WizOpStyleRecordHandler - Imported items left over\n")); 01384 } 01385 } 01386 01387 01388 /******************************************************************************************** 01389 01390 > WizOpStyleRecordHandler::WizOpStyleRecordHandler(const WizOpStyleRecordHandler& Other) 01391 WizOpStyleRecordHandler& WizOpStyleRecordHandler::operator=(const WizOpStyleRecordHandler& Other) 01392 01393 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01394 Created: 10/07/97 01395 01396 Purpose: Warns us that we've done a destructor but we haven't done either of these 01397 01398 ********************************************************************************************/ 01399 WizOpStyleRecordHandler::WizOpStyleRecordHandler(const WizOpStyleRecordHandler& Other) 01400 { 01401 TRACE( _T("WizOpStyleRecordHandler - Copy constructor not implemented")); 01402 } 01403 01404 WizOpStyleRecordHandler& WizOpStyleRecordHandler::operator=(const WizOpStyleRecordHandler& Other) 01405 { 01406 TRACE( _T("WizOpStyleRecordHandler - Assignment operator not implemented")); 01407 return *this; 01408 } 01409 01410 01411 /******************************************************************************************** 01412 01413 > virtual UINT32* WizOpStyleRecordHandler::GetTagList() 01414 01415 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01416 Created: 10/07/97 01417 01418 Purpose: Provides the record handler system with a list of records handled by this 01419 handler 01420 01421 Returns: Ptr to a list of tag values, terminated by CXFRH_TAG_LIST_END 01422 01423 ********************************************************************************************/ 01424 UINT32* WizOpStyleRecordHandler::GetTagList() 01425 { 01426 static UINT32 TagList[] = {TAG_WIZOP_STYLE, 01427 CXFRH_TAG_LIST_END}; 01428 01429 return (UINT32*)&TagList; 01430 } 01431 01432 01433 /******************************************************************************************** 01434 01435 > virtual BOOL WizOpStyleRecordHandler::Init(BaseCamelotFilter* pFilter) 01436 01437 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01438 Created: 10/07/97 01439 01440 Purpose: Initialises the WizOpStyleRecordHandler 01441 01442 Returns: TRUE if ok 01443 FALSE otherwise 01444 01445 ********************************************************************************************/ 01446 BOOL WizOpStyleRecordHandler::Init(BaseCamelotFilter* pFilter) 01447 { 01448 BOOL Ok = TRUE; 01449 01450 Ok = CamelotRecordHandler::Init(pFilter); 01451 01452 Document* const pDoc = GetDocument(); 01453 Ok = (pDoc != NULL); 01454 01455 if (Ok) 01456 { 01457 m_pTentativeStyles = (WizOpStyles*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(WizOpStyles)); 01458 Ok = (m_pTentativeStyles != NULL); 01459 } 01460 01461 // give this WizOpStyleRecordHandler to the style component so it can call us back 01462 if (Ok) 01463 { 01464 Ok = m_pTentativeStyles->SetRecordHandler(*this); 01465 } 01466 01467 return Ok; 01468 } 01469 01470 01471 01472 /******************************************************************************************** 01473 01474 > virtual BOOL WizOpStyleRecordHandler::EndImport() 01475 01476 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01477 Created: 10/07/97 01478 01479 Purpose: Informs the record handler that importing is over 01480 Reverses all the stuff done in Init(). Should it be done in BeginImport? 01481 01482 Returns: TRUE if ok 01483 FALSE otherwise 01484 01485 Notes: If you override this func, be sure to call the base class varient 01486 01487 ********************************************************************************************/ 01488 BOOL WizOpStyleRecordHandler::EndImport() 01489 { 01490 BOOL Ok = TRUE; 01491 01492 m_ImportedItems.DeleteAll(); 01493 01494 Ok = CXaraFileRecordHandler::EndImport(); 01495 01496 return Ok; 01497 } 01498 01499 01500 /******************************************************************************************** 01501 01502 > virtual BOOL WizOpStyleRecordHandler::HandleRecord(CXaraFileRecord* pCXaraFileRecord) 01503 01504 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01505 Created: 10/07/97 01506 Inputs: pCXaraFileRecord = ptr to record to handle 01507 Returns: TRUE if handled successfuly 01508 FALSE otherwise 01509 Purpose: Handles the given record. 01510 01511 ********************************************************************************************/ 01512 BOOL WizOpStyleRecordHandler::HandleRecord(CXaraFileRecord* pRecord) 01513 { 01514 ENSURE_NOT_NULL(pRecord); 01515 ERROR2IF(pRecord->GetTag() != TAG_WIZOP_STYLE, FALSE, "I don't handle this tag type"); 01516 01517 String_64 OpName; 01518 String_256 Question; 01519 String_256 Param; 01520 String_256 StyleName; 01521 01522 BOOL ok = pRecord->ReadUnicode(OpName, 64); 01523 01524 if (ok) 01525 { 01526 ok = pRecord->ReadUnicode(Question, 256); 01527 } 01528 01529 if (ok) 01530 { 01531 ok = pRecord->ReadUnicode(Param, 256); 01532 } 01533 01534 if (ok) 01535 { 01536 ok = pRecord->ReadUnicode(StyleName, 256); 01537 } 01538 01539 if (ok) 01540 { 01541 // We managed to read it all OK so add a new Style to the styles we've imported 01542 // and remember its record number for reference purposes 01543 WizOpStyle* pStyleToUse = AddStyle(StyleName, Question, OpName, Param); 01544 if (pStyleToUse == NULL) 01545 { 01546 BaseCamelotFilter* const pFilter = GetBaseCamelotFilter(); 01547 ENSURE_NOT_NULL(pFilter); 01548 pFilter->AppendWarning(_R(IDS_STYLE_OF_UNKNOWN_WIZOP)); 01549 } 01550 else 01551 { 01552 ok = AddRecordReference(pRecord->GetRecordNumber(), *pStyleToUse); 01553 } 01554 01555 } 01556 01557 if (!ok) 01558 { 01559 BaseCamelotFilter* const pFilter = GetBaseCamelotFilter(); 01560 ENSURE_NOT_NULL(pFilter); 01561 pFilter->GotError(_R(IDE_FILE_READ_ERROR)); 01562 } 01563 01564 return ok; 01565 } 01566 01567 01568 /******************************************************************************************** 01569 01570 > WizOpStyle* WizOpStyleRecordHandler::AddStyle( const StringBase& Name, 01571 const StringBase& Question, 01572 const StringBase& WizOpName, 01573 const StringBase& Param) 01574 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01575 Created: 10/07/97 01576 01577 Purpose: Adds a WizOpStyle to the importing document's WizOpStyles component 01578 01579 Inputs: Name, Question, Param: Passed on to the WizOpStyle 01580 WizOpName: The name of the WizOp that the style refers to 01581 01582 Returns: A pointer to the WizOpStyle to use in any reference 01583 NULL if it failed 01584 01585 ********************************************************************************************/ 01586 WizOpStyle* WizOpStyleRecordHandler::AddStyle( const StringBase& Name, const StringBase& Question, 01587 const StringBase& WizOpName, const StringBase& Param) 01588 { 01589 WizOpStyle* pStyleToUse = NULL; 01590 01591 WizOp* const pWizOp = GetWizOps().FindWizOpFromInternalName(WizOpName); 01592 01593 if (pWizOp != NULL) 01594 { 01595 WizOpStyle NewStyle(Name, Question, *pWizOp, Param); 01596 pStyleToUse = (WizOpStyle*)GetTentativeStyles().CopyComponentData(NewStyle); 01597 } 01598 01599 return pStyleToUse; 01600 } 01601 01602 01603 /******************************************************************************************** 01604 01605 > BOOL WizOpStyleRecordHandler::AddRecordReference( XFileRef RecordRef, 01606 const WizOpStyle& ImportedStyle) 01607 01608 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01609 Created: 10/07/97 01610 01611 Purpose: We need to remember the record numbers of the styles so that Style References 01612 can find the style they want. This function associates a record number 01613 with the newly imported style to that end. 01614 01615 Inputs: RecordRef: The record number of the newly imported style 01616 ImportedStyle: The newly imported style 01617 01618 Returns: TRUE if it managed to add the reference 01619 FALSE if not 01620 01621 See Also: WizOpStyleRefRecordHandler::HandleRecord 01622 01623 ********************************************************************************************/ 01624 BOOL WizOpStyleRecordHandler::AddRecordReference(XFileRef RecordRef, const WizOpStyle& ImportedStyle) 01625 { 01626 BOOL Ok = TRUE; 01627 01628 StyleRecordReference* pNewRecRef = new StyleRecordReference(ImportedStyle, RecordRef); 01629 01630 Ok = (pNewRecRef != NULL); 01631 01632 if (Ok) 01633 { 01634 m_ImportedItems.AddHead(pNewRecRef); 01635 } 01636 01637 return Ok; 01638 } 01639 01640 01641 /******************************************************************************************** 01642 01643 > virtual WizOpStyle* WizOpStyleRecordHandler::FindStyleFromRecordReference( 01644 XFileRef RecordRef) const 01645 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01646 Created: 10/07/97 01647 01648 Purpose: Finds an imported style, given the record number. 01649 01650 Inputs: RecordRef: The number of the record in which the style was. 01651 01652 ********************************************************************************************/ 01653 WizOpStyle* WizOpStyleRecordHandler::FindStyleFromRecordReference(XFileRef RecordRef) const 01654 { 01655 WizOpStyle* pFoundStyle = NULL; 01656 01657 StyleRecordReference* pCurrentSRR = (StyleRecordReference*)m_ImportedItems.GetHead(); 01658 01659 while (pCurrentSRR != NULL) 01660 { 01661 if (pCurrentSRR->GetRecordRef() == RecordRef) 01662 { 01663 pFoundStyle = (WizOpStyle*)&(pCurrentSRR->GetStyle()); 01664 break; 01665 } 01666 else 01667 { 01668 pCurrentSRR = (StyleRecordReference*)m_ImportedItems.GetNext(pCurrentSRR); 01669 } 01670 } 01671 01672 return pFoundStyle; 01673 } 01674 01675 01676 /******************************************************************************************** 01677 01678 > virtual void WizOpStyleRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord,StringBase* pStr) 01679 01680 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01681 Created: 10/07/97 01682 01683 Purpose: This provides descriptions for the define units records. 01684 01685 Inputs: pRecord = ptr to a record 01686 pStr = ptr to string to update 01687 01688 ********************************************************************************************/ 01689 #ifdef XAR_TREE_DIALOG 01690 void WizOpStyleRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord,StringBase* pStr) 01691 { 01692 if (pStr == NULL || pRecord == NULL) 01693 { 01694 TRACE( _T("WizOpStyleRecordHandler::GetRecordDescriptionText - NULL Args\n")); 01695 return; 01696 } 01697 if (pRecord->GetTag() != TAG_WIZOP_STYLE) 01698 { 01699 TRACE( _T("WizOpStyleRecordHandler::GetRecordDescriptionText - Incorrect record\n")); 01700 return; 01701 } 01702 01703 // Call base class first 01704 CamelotRecordHandler::GetRecordDescriptionText(pRecord, pStr); 01705 01706 TCHAR OpName[64] = {0}; 01707 TCHAR Question[256] = {0}; 01708 TCHAR Param[256] = {0}; 01709 TCHAR StyleName[256] = {0}; 01710 01711 BOOL ok = pRecord->ReadUnicode(OpName, 64); 01712 01713 if (ok) 01714 { 01715 *pStr += TEXT("OpName = "); 01716 *pStr += OpName; 01717 01718 ok = pRecord->ReadUnicode(Question, 256); 01719 } 01720 01721 if (ok) 01722 { 01723 *pStr += TEXT("\r\nQuestion = "); 01724 *pStr += Question; 01725 01726 ok = pRecord->ReadUnicode(Param, 256); 01727 } 01728 01729 if (ok) 01730 { 01731 *pStr += TEXT("\r\nParam = "); 01732 *pStr += Param; 01733 01734 ok = pRecord->ReadUnicode(StyleName, 256); 01735 } 01736 01737 if (ok) 01738 { 01739 *pStr += TEXT("\r\nStyleName = "); 01740 *pStr += StyleName; 01741 } 01742 } 01743 01744 01745 /******************************************************************************************** 01746 01747 > virtual void WizOpStyleRecordHandler::GetTagText(UINT32 Tag,String_256& Str) 01748 01749 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01750 Created: 27/06/97 01751 01752 Purpose: A debug function that gives the tag description. 01753 01754 Inputs: Tag = the tag value 01755 Outputs: Str = place to put textual description of the tag 01756 01757 ********************************************************************************************/ 01758 void WizOpStyleRecordHandler::GetTagText(UINT32 Tag,String_256& Str) 01759 { 01760 Str = TEXT("TAG_WIZOP_STYLE"); 01761 } 01762 #endif // _DEBUG 01763 01764 01765 01766 /******************************************************************************************** 01767 01768 > WizOpStyles& WizOpStyleRecordHandler::GetTentativeStyles() 01769 01770 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01771 Created: 27/06/97 01772 01773 Purpose: Data Access 01774 01775 ********************************************************************************************/ 01776 WizOpStyles& WizOpStyleRecordHandler::GetTentativeStyles() 01777 { 01778 // This static dummy object is used for returning in the ERROR2 case 01779 // The original used to return a ptr to a local variable, which is a tad dangerous. 01780 // This solution is not ideal, because there's a permanent instance of an object 01781 // that will probably never be used. 01782 static WizOpStyles Dummy; 01783 01784 ERROR2IF(m_pTentativeStyles == NULL, Dummy, "NULL Member"); 01785 01786 return *m_pTentativeStyles; 01787 } 01788 01789 01790 01791 01792 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 01793 // E X P O R T I T E M 01794 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 01795 01796 01797 01798 01799 01800 01801 01802 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 01803 // R E C O R D R E F E R E N C I N G E X P O R T E R 01804 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 01805 01806 01807 01808 01809 const INT32 XFILEREF_ERROR = 0L; 01810 01811 01812 /******************************************************************************************** 01813 01814 > RecordReferencingExporter::~RecordReferencingExporter() 01815 01816 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01817 Created: 11/07/97 01818 01819 Purpose: Deletes the internal data structures 01820 01821 ********************************************************************************************/ 01822 RecordReferencingExporter::~RecordReferencingExporter() 01823 { 01824 m_ExportedItems.DeleteAll(); 01825 } 01826 01827 01828 01829 /******************************************************************************************** 01830 01831 > RecordReferencingExporter::RecordReferencingExporter(const RecordReferencingExporter& Other) 01832 const RecordReferencingExporter& RecordReferencingExporter::operator=(const RecordReferencingExporter& Other) 01833 01834 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01835 Created: 11/07/97 01836 01837 Purpose: Let's us know we should be copying this 01838 01839 ********************************************************************************************/ 01840 RecordReferencingExporter::RecordReferencingExporter(const RecordReferencingExporter& Other) : 01841 m_Filter(Other.m_Filter) 01842 { 01843 TRACE( _T("RecordReferencingExporter - Copy constructor not implemented")); 01844 } 01845 01846 const RecordReferencingExporter& RecordReferencingExporter::operator=(const RecordReferencingExporter& Other) 01847 { 01848 TRACE( _T("RecordReferencingExporter - Assignment operator not implemented")); 01849 return *this; 01850 } 01851 01852 01853 /******************************************************************************************** 01854 01855 > virtual BOOL RecordReferencingExporter::AddExportedItem(RecordReferenceItem& NewItem) 01856 01857 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01858 Created: 11/07/97 01859 01860 Purpose: Adds the RecordReferenceItem to the list of exported items. 01861 You can override it if you want. 01862 01863 ********************************************************************************************/ 01864 BOOL RecordReferencingExporter::AddExportedItem(RecordReferenceItem& NewItem) 01865 { 01866 m_ExportedItems.AddHead(&NewItem); 01867 01868 return TRUE; 01869 } 01870 01871 /******************************************************************************************** 01872 01873 > const RecordReferenceItem* RecordReferencingExporter::FindExportedItem(const RecordReferenceItem& ItemToFind) 01874 01875 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01876 Created: 11/07/97 01877 01878 Purpose: Looks for the given item in the list of exported items. 01879 If you're worried about efficiency override it. 01880 01881 ********************************************************************************************/ 01882 const RecordReferenceItem* RecordReferencingExporter::FindExportedItem(const RecordReferenceItem& ItemToFind) 01883 { 01884 const RecordReferenceItem* pFoundItem = NULL; // return this 01885 01886 RecordReferenceItem* pCurrentItem = (RecordReferenceItem*)m_ExportedItems.GetHead(); 01887 01888 while (pCurrentItem != NULL && pFoundItem == NULL) 01889 { 01890 if (ItemToFind == *pCurrentItem) 01891 { 01892 pFoundItem = pCurrentItem; 01893 } 01894 else 01895 { 01896 pCurrentItem = (RecordReferenceItem*)m_ExportedItems.GetNext(pCurrentItem); 01897 } 01898 } 01899 01900 return pFoundItem; 01901 } 01902 01903 01904 /******************************************************************************************** 01905 01906 > XFileRef RecordReferencingExporter::WriteItem(const RecordReferenceItem& TentativeExportItem) 01907 01908 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01909 Created: 11/07/97 01910 01911 Purpose: Provides support for derived classes using record references. 01912 Attempts to write out an export item, but will just return an XFileRef if the 01913 record has already been written for the item. 01914 Derived classes should create a suitable item on the stack, and call this 01915 function to do the spade work. 01916 01917 Inputs: TentativeExportItem: The item to be exported that will be copied if it 01918 needs to be written out. 01919 01920 Returns: The record number for the given RecordReferenceItem 01921 XFILEREF_ERROR if an error occurred. 01922 01923 ********************************************************************************************/ 01924 XFileRef RecordReferencingExporter::WriteItem(const RecordReferenceItem& TentativeExportItem) 01925 { 01926 #ifdef DO_EXPORT 01927 XFileRef RecordReference = XFILEREF_ERROR; // return this 01928 01929 const RecordReferenceItem* const pExistingItem = FindExportedItem(TentativeExportItem); 01930 if (pExistingItem == NULL) 01931 { 01932 // The item hasn't been exported, so do it now 01933 RecordReference = WriteRecord(TentativeExportItem); 01934 if (RecordReference != XFILEREF_ERROR) 01935 { 01936 RecordReferenceItem* pNewItem = TentativeExportItem.CreateCopy(RecordReference); 01937 if (pNewItem != NULL) 01938 { 01939 AddExportedItem(*pNewItem); 01940 } 01941 else 01942 { 01943 RecordReference = XFILEREF_ERROR; 01944 } 01945 } 01946 } 01947 else // the record has already been written, so just get the reference 01948 { 01949 RecordReference = pExistingItem->GetRecordRef(); 01950 } 01951 01952 return RecordReference; 01953 #else 01954 return 0L; 01955 #endif 01956 } 01957 01958 01959 01960 01961 01962 01963 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 01964 // S T Y L E R E C O R D R E F E R E N C E 01965 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 01966 01967 01968 01969 01970 01971 01972 01973 01974 01975 /******************************************************************************************** 01976 01977 > RecordReferenceItem* StyleRecordReference::CreateCopy(const XFileRef& NewReference) const 01978 01979 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01980 Created: 11/07/97 01981 01982 Purpose: Creates a copy of this StyleRecordReference with the given NewReference 01983 01984 ********************************************************************************************/ 01985 RecordReferenceItem* StyleRecordReference::CreateCopy(const XFileRef& NewReference) const 01986 { 01987 return new StyleRecordReference(m_StyleExported, NewReference); 01988 } 01989 01990 01991 01992 /******************************************************************************************** 01993 01994 > BOOL StyleRecordReference::operator==(const RecordReferenceItem& Other) 01995 01996 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 01997 Created: 11/07/97 01998 01999 Purpose: Two StyleRecordReference's are equal if the addresses of the Style's they 02000 represent are equal 02001 02002 ********************************************************************************************/ 02003 BOOL StyleRecordReference::operator==(const RecordReferenceItem& Other) const 02004 { 02005 ENSURE_KIND((&Other), StyleRecordReference); 02006 StyleRecordReference& OtherStyle = (StyleRecordReference&) Other; 02007 02008 return &(GetStyle()) == &(OtherStyle.GetStyle()); 02009 } 02010 02011 02012 02013 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 02014 // S T Y L E S E X P O R T E R 02015 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 02016 02017 02018 02019 02020 02021 /******************************************************************************************** 02022 02023 > StylesExporter::StylesExporter(Styles& StylesToExport, BaseCamelotFilter& FilterToUse) 02024 02025 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 02026 Created: 11/07/97 02027 02028 Purpose: Default constructor to ensure the data members are set up correctly. 02029 We need a Styles collection and a Filter to export by. 02030 02031 ********************************************************************************************/ 02032 StylesExporter::StylesExporter(Styles& StylesToExport, BaseCamelotFilter& FilterToUse) : 02033 RecordReferencingExporter(FilterToUse), 02034 m_Styles(StylesToExport) 02035 { 02036 } 02037 02038 02039 02040 /******************************************************************************************** 02041 02042 > virtual XFileRef StylesExporter::WriteStyle(const WizOpStyle& StyleToWrite) 02043 02044 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 02045 Created: 11/07/97 02046 02047 Purpose: Attempts to write a WizOpStyle via the filter given in this object's 02048 constructor. 02049 02050 Returns: A Record Number to use as a reference (or XFILEREF_ERROR if it failed) 02051 02052 See Also: Styles::GetRecordRefForStyle which delegates all responsibility to this 02053 member. 02054 02055 ********************************************************************************************/ 02056 XFileRef StylesExporter::WriteStyle(const WizOpStyle& StyleToWrite) 02057 { 02058 XFileRef RecordReference = XFILEREF_ERROR; // return this 02059 02060 StyleRecordReference RecordReferenceItem(StyleToWrite); 02061 02062 RecordReference = WriteItem(RecordReferenceItem); 02063 02064 return RecordReference; 02065 } 02066 02067 02068 /******************************************************************************************** 02069 02070 > XFileRef StylesExporter::WriteRecord(const RecordReferenceItem& ItemToExport) 02071 02072 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 02073 Created: 11/07/97 02074 02075 Purpose: Provides implementation for the base class pure function to write the given 02076 RecordReferenceItem (i.e. StyleRecordReference) via the filter given in this object's 02077 constructor. 02078 02079 Notes: Called from RecordReferencingExporter::WriteItem, so look there for further 02080 info. 02081 02082 ********************************************************************************************/ 02083 XFileRef StylesExporter::WriteRecord(const RecordReferenceItem& ItemToExport) 02084 { 02085 #ifdef DO_EXPORT 02086 XFileRef RecordNumber = XFILEREF_ERROR; // return this (initialized to error) 02087 02088 ENSURE_KIND((&ItemToExport), StyleRecordReference); 02089 02090 // Add a description of the TAG_WIZOP_STYLE record for older importers 02091 GetFilter().AddTagDescription(TAG_WIZOP_STYLE, _R(IDS_TAG_WIZOP_STYLE)); 02092 02093 CamelotFileRecord Rec(&GetFilter(), TAG_WIZOP_STYLE, CXF_UNKNOWN_SIZE); 02094 02095 BOOL ok = Rec.Init(); 02096 02097 WizOpStyle& StyleToExport = (WizOpStyle&)((StyleRecordReference&)ItemToExport).GetStyle(); 02098 02099 if (ok) 02100 { 02101 String_64 InternalName = StyleToExport.GetWizOp().GetInternalName(); 02102 ok = Rec.WriteUnicode((TCHAR*)InternalName); 02103 } 02104 if (ok) 02105 { 02106 String_256 Question = StyleToExport.GetQuestion(); 02107 ok = Rec.WriteUnicode((TCHAR*)Question); 02108 } 02109 if (ok) 02110 { 02111 String_64 Param = StyleToExport.GetParam(); 02112 ok = Rec.WriteUnicode((TCHAR*)Param); 02113 } 02114 if (ok) 02115 { 02116 String_64 StyleName = StyleToExport.GetName(); 02117 ok = Rec.WriteUnicode((TCHAR*)StyleName); 02118 } 02119 02120 if (ok) 02121 { 02122 RecordNumber = GetFilter().WriteDefinitionRecord(&Rec); 02123 } 02124 return RecordNumber; 02125 #else 02126 return XFILEREF_ERROR; 02127 #endif 02128 } 02129 02130