Property Containers
A property container is an object that has properties. Property containers implement the IODPropertyContainer interface, which is derived from SFL’s IPropertyContainer interface. The IPropertyContainer interface is shown in Example 8.
Example 8 – IPropertyContainer interface
class IPropertyContainer : public IQueryGuid, public IRefCount
{
public:
/* Get the number of properties in the container. */
virtual int GetPropertyCount() const = 0;
/* Get the property using an index into the container. */
virtual IProperty* GetPropertyAt(const int nPropIdx) = 0;
/* Retrieve a property by unique identifier. */
virtual IProperty* GetProperty(const PropertyId propId) = 0;
/* Retrieve a property by name. */
virtual IProperty* GetPropertyByName(OLECHAR* propName) = 0;
/* Return the string name of a property category. */
virtual bool GetCategoryName(const int nCatId,
BSTR& catName) = 0;
/* Get a property value using the property ID. */
virtual bool GetPropertyValue(const PropertyId propId,
VARIANT& propVal) = 0;
/* Get a property value as a string using the property ID. */
virtual bool GetPropertyString(const PropertyId propId,
BSTR& propVal) = 0;
/* Set a property value using the property ID. */
virtual bool PutPropertyValue(const PropertyId propId,
VARIANT& propVal) = 0;
/* Set a property value as string using the property ID. */
virtual bool PutPropertyString(const PropertyId propId,
const BSTR& propVal) = 0;
};
The IODPropertyContainer interface extends IPropertyContainer with a set of GetValue() and SetValue() methods that are overloaded for several common data types. The IODPropertyContainer interface is shown in Example 9.
Example 9 – IODPropertyContainer interface
class IODPropertyContainer : public sfl::IPropertyContainer
{
public:
/* Gets the value of the given string property. */
virtual BOOL GetValue(const int nPropId, CString& strValue) const=0;
/* Gets the value of the given integer property. */
virtual BOOL GetValue(const int nPropId, int& nValue) const = 0;
/* Gets the value of the given unsigned integer property. */
virtual BOOL GetValue(const int nPropId, UINT& nValue) const = 0;
/* Gets the value of the given DWORD property. */
virtual BOOL GetValue(const int nPropId,
DWORD& dwValue) const = 0;
/* Gets the value of the given float property. */
virtual BOOL GetValue(const int nPropId,
float& fValue) const = 0;
 
/* Sets the value of the given string property. */
virtual BOOL SetValue(const int nPropId, LPCTSTR lpszValue) = 0;
/* Sets the value of the given integer property. */
virtual BOOL SetValue(const int nPropId, const int nValue) = 0;
/* Sets the value of the given unsigned integer property. */
virtual BOOL SetValue(const int nPropId, const UINT nValue) = 0;
/* Sets the value of the given unsigned DWORD property. */
virtual BOOL SetValue(const int nPropId,
const DWORD dwValue) = 0;
/* Sets the value of the given float property. */
virtual BOOL SetValue(const int nPropId, const float fValue) = 0;
};
The GetPropertyValue() and PutPropertyValue() methods in the sfl::IPropertyContainer interface store and retrieve property values as VARIANTs. The GetValue() and SetValue() methods in the IODPropertyContainer also set property values, but are usually more convenient to use since simple data types can be used instead of VARIANTs.
Components are property containers. Nested properties, such as CODFontProperties and CODLineProperties, are also property containers. The CODPropertyContainer class provides an implementation of the IODPropertyContainer interface and is mixed into the CODComponent class and into the nested property classes, such as CODFontProperties and CODLineProperties.