#include <styles.h>
Inheritance diagram for Styles:
Public Member Functions | |
virtual BOOL | Init () |
Default constructor would fail, so use an Init() if you don't want a lot of ERROR2's. | |
virtual Style * | AddStyle (const Style &NewStyle) |
Adds the given style to this Styles collection, ensuring that there's only one with the style's name. | |
virtual BOOL | MergeStyles (Styles &OtherStyles) |
Removes the styles in the given styles container and adds them to this one. Duplicates are ignored, so be careful. | |
virtual StyleIterator | Begin () const |
Allows access to individual members of the Styles collection. | |
virtual const StyleIterator & | End () const |
Allows access to individual members of the Styles collection. | |
virtual Style * | FindStyleFromName (const StringBase &StyleName) const |
Adds the given style to this Styles collection, ensuring that there's only one with the style's name. | |
virtual BOOL | StartComponentCopy () |
This function gets called to prepare for an inter-document styles copy. | |
virtual BOOL | EndComponentCopy () |
Will commit all changes made by doing the component copy, returning TRUE. Any new colours will be inserted as instructed by the InsertBefore parameter. If some colours will not be insterted because they were merged, then a report to this effect can be given if desired. | |
virtual void | AbortComponentCopy () |
Will abort all changes made for component copies. This means that things such as the colours referenced by the nodes you have just copied do not exist, so you must clean up to the state the document was in before you strated copying. | |
virtual Style * | CopyComponentData (const Style &NewStyle) |
In between StartComponentCopy() & EndComponentCopy() this function is called by StyleReferenceAttribute::CopyComponentData() to ensure that styles are merged between documents. | |
virtual | ~Styles () |
Clean up a colour list component's data structures - deletes the colour list. | |
Protected Member Functions | |
Styles () | |
Default constructor would fail, so use an Init() if you don't want a lot of ERROR2's. | |
Styles (const Styles &OtherStyles) | |
Warns us that we've done a destructor but we haven't done either of these. | |
Styles & | operator= (const Styles &) |
BOOL | GenerateUniqueName (const StringBase &Prefix, StringBase *pResult) |
Scans the styles to determine if the suggested name is unique within this collection. If it is not, the name is altered (currently by removing the last 14 characters and appending a decimal number) to provide a unique name, which is returned in the supplied string. | |
BOOL | NameExists (const StringBase &Name) const |
Tells us if the given name exists in this Styles collection or the Styles we're adding (cos we only want to eliminate duplicates when we're adding styles see). | |
void | SendStylesChangeMessage () |
StyleContainer & | GetContainer () const |
The actual styles are held in an internal container. This member provides access to them. | |
Styles & | GetStylesToAdd () const |
During a component copy (or import) we have some styles to add at the end (although they maybe empty). This function provides access to them. | |
Protected Attributes | |
StylesExporter * | m_pCurrentExporter |
Private Attributes | |
StyleContainer * | m_pStyleContainer |
Styles * | m_pStylesToAdd |
Definition at line 186 of file styles.h.
|
Clean up a colour list component's data structures - deletes the colour list.
Definition at line 487 of file styles.cpp. 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 }
|
|
Default constructor would fail, so use an Init() if you don't want a lot of ERROR2's.
Definition at line 447 of file styles.cpp. 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 }
|
|
Warns us that we've done a destructor but we haven't done either of these.
Definition at line 513 of file styles.cpp. 00514 { 00515 TRACE( _T("Styles - Copy constructor not implemented")); 00516 }
|
|
Will abort all changes made for component copies. This means that things such as the colours referenced by the nodes you have just copied do not exist, so you must clean up to the state the document was in before you strated copying.
Reimplemented from DocComponent. Definition at line 858 of file styles.cpp. 00859 { 00860 delete m_pStylesToAdd; 00861 m_pStylesToAdd = NULL; 00862 }
|
|
Adds the given style to this Styles collection, ensuring that there's only one with the style's name.
Definition at line 567 of file styles.cpp. 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 }
|
|
Allows access to individual members of the Styles collection.
Definition at line 603 of file styles.cpp. 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 }
|
|
In between StartComponentCopy() & EndComponentCopy() this function is called by StyleReferenceAttribute::CopyComponentData() to ensure that styles are merged between documents.
Definition at line 759 of file styles.cpp. 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 }
|
|
Allows access to individual members of the Styles collection.
Definition at line 629 of file styles.cpp. 00630 { 00631 StyleContainer Container; 00632 static const StyleIterator TheEnd( Container, NULL); 00633 00634 return TheEnd; 00635 }
|
|
Will commit all changes made by doing the component copy, returning TRUE. Any new colours will be inserted as instructed by the InsertBefore parameter. If some colours will not be insterted because they were merged, then a report to this effect can be given if desired.
Reimplemented from DocComponent. Definition at line 819 of file styles.cpp. 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 }
|
|
Adds the given style to this Styles collection, ensuring that there's only one with the style's name.
Definition at line 653 of file styles.cpp. 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 }
|
|
Scans the styles to determine if the suggested name is unique within this collection. If it is not, the name is altered (currently by removing the last 14 characters and appending a decimal number) to provide a unique name, which is returned in the supplied string.
Definition at line 943 of file styles.cpp. 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 }
|
|
The actual styles are held in an internal container. This member provides access to them.
Definition at line 537 of file styles.cpp. 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 }
|
|
During a component copy (or import) we have some styles to add at the end (although they maybe empty). This function provides access to them.
Definition at line 879 of file styles.cpp. 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 }
|
|
Default constructor would fail, so use an Init() if you don't want a lot of ERROR2's.
Reimplemented from SimpleCCObject. Definition at line 466 of file styles.cpp. 00467 { 00468 m_pStyleContainer = new StyleContainer; 00469 00470 return (m_pStyleContainer != NULL); 00471 }
|
|
Removes the styles in the given styles container and adds them to this one. Duplicates are ignored, so be careful.
Definition at line 690 of file styles.cpp. 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 }
|
|
Tells us if the given name exists in this Styles collection or the Styles we're adding (cos we only want to eliminate duplicates when we're adding styles see).
Definition at line 910 of file styles.cpp. 00911 { 00912 return (FindStyleFromName(Name) != NULL || 00913 GetStylesToAdd().FindStyleFromName(Name) != NULL); 00914 }
|
|
Definition at line 518 of file styles.cpp. 00519 { 00520 TRACE( _T("Styles - Assignment operator not implemented")); 00521 00522 return *this; 00523 }
|
|
Definition at line 973 of file styles.cpp. 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 }
|
|
This function gets called to prepare for an inter-document styles copy.
Reimplemented from DocComponent. Definition at line 725 of file styles.cpp. 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 }
|
|
|
|
|
|
|