class CCL::Document

Overview

#include <document.h>

class Document:
    public CCL::Object,
    public CCL::IDocument,
    public CCL::IViewFactory,
    public CCL::IActionContext
{
public:
    // enums

    enum Flags;

    // structs

    struct SilentPreviewScope;

    // fields

     documentView;
     kOlderFormat;
    isOlderFormat kCanceled;
    isOlderFormat isCanceled kIsSaveToNewFolder;
    isOlderFormat isCanceled isSaveToNewFolder kSafeMode;
    isOlderFormat isCanceled isSaveToNewFolder isSafeModeEnabled kIsLoadingTemplate;
    isOlderFormat isCanceled isSaveToNewFolder isSafeModeEnabled isLoadingTemplate kSavingSuspended;

    // methods

    DECLARE_CLASS (Document, Object);
    PROPERTY_SHARED (DocumentClass, documentClass, DocumentClass);
    virtual DocumentView void setTitle (StringRef title);
    virtual void setPath (UrlRef path);
    virtual void setDirty (bool dirty = true);
    PROPERTY_FLAG (flags, kImported, isImported);
    isOlderFormat PROPERTY_FLAG (flags, kSilent, isSilent);
    isOlderFormat isCanceled PROPERTY_FLAG (flags, kIsAutoSave, isAutoSave);

    isOlderFormat isCanceled isSaveToNewFolder PROPERTY_FLAG (
        flags,
        kIsExportToNewFolder,
        isExportToNewFolder
    );

    isOlderFormat isCanceled isSaveToNewFolder isSafeModeEnabled PROPERTY_FLAG (
        flags,
        kIsExport,
        isExport
    );

    isOlderFormat isCanceled isSaveToNewFolder isSafeModeEnabled isLoadingTemplate PROPERTY_FLAG (
        flags,
        kIgnoreDirtyUI,
        ignoreDirtyUI
    );

    isOlderFormat isCanceled isSaveToNewFolder isSafeModeEnabled isLoadingTemplate isSavingSuspended PROPERTY_FLAG (
        flags,
        kIsTemporary,
        isTemporary
    );

    isOlderFormat isCanceled isSaveToNewFolder isSafeModeEnabled isLoadingTemplate isSavingSuspended PreviewMode PROPERTY_OBJECT (
        Url,
        createdFolder,
        CreatedFolder
    );

    isOlderFormat isCanceled isSaveToNewFolder isSafeModeEnabled isLoadingTemplate isSavingSuspended PreviewMode SourceTemplateID bool needsAutoSave () const;
    void setAutoSavedNow ();
    virtual void initialize ();
    virtual void terminate ();
    virtual bool prepare (const Attributes* args = nullptr);
    virtual bool prepareImport ();
    virtual bool prepareLoading ();
    virtual bool load ();
    virtual bool save ();
    virtual bool saveAs (UrlRef newPath);
    virtual bool prepareSaveToNewFolder (UrlRef newDocumentPath);
    virtual void finishSaveToNewFolder (UrlRef newDocumentPath);
    virtual Renamer* createRenamer ();
    virtual bool canClose () const;
    virtual bool canRemoveFolder (UrlRef folder) const;
    virtual void onEvent (int eventCode);
    void setEventHandler (IDocumentEventHandler* newHandler);
    IDocumentEventHandler* getEventHandler () const;
    virtual void onLoadFinished (bool failed);
    virtual void onBeforeSave ();
    virtual void onSaveFinished ();
    virtual void onActivate (bool state);
    virtual void onViewActivated ();
    virtual void onClose ();
    virtual void onDestroyed ();
    virtual StringRef CCL_API getTitle () const;
    virtual UrlRef CCL_API getPath () const;
    virtual tbool CCL_API isDirty () const;
    virtual IUnknown*CCL_API getModel () const;
    virtual IUnknown*CCL_API getView () const;
    virtual IUnknown*CCL_API getController () const;
    virtual IUnknown*CCL_API getMetaInfo () const;
    virtual const IDocumentClass*CCL_API getIDocumentClass () const;
    virtual IActionJournal*CCL_API getIActionJournal () const;

    virtual IView*CCL_API createView (
        StringID name,
        VariantRef data,
        const Rect& bounds
    );

    virtual ActionJournal* getActionJournal () const;
    virtual bool toString (String& string, int flags = 0) const;
    virtual void CCL_API notify (ISubject* subject, MessageRef msg);
    CLASS_INTERFACES (Object);
    static bool isSilentPreview ();
};

Inherited Members

public:
    // typedefs

    typedef CStringRef MemberID;

    // enums

    enum EventCode;

    // methods

    virtual tresult CCL_API queryInterface (UIDRef iid, void** ptr) = 0;
    virtual unsigned int CCL_API retain () = 0;
    virtual unsigned int CCL_API release () = 0;
    Unknown& operator = (const Unknown&);
    unsigned int getRetainCount () const;
    virtual Object*CCL_API revealObject (const void* moduleAddress) = 0;
    virtual void CCL_API addObserver (IObserver* observer) = 0;
    virtual void CCL_API removeObserver (IObserver* observer) = 0;
    virtual void CCL_API signal (MessageRef msg) = 0;
    virtual void CCL_API deferSignal (IMessage* msg) = 0;
    static ISubject void addObserver (IUnknown* unknown, IObserver* observer);
    static void removeObserver (IUnknown* unknown, IObserver* observer);
    virtual void CCL_API notify (ISubject* subject, MessageRef msg) = 0;

    static IObserver void notify (
        IUnknown* unknown,
        ISubject* subject,
        MessageRef msg
    );

    virtual const ITypeInfo&CCL_API getTypeInfo () const = 0;
    virtual tbool CCL_API getProperty (Variant& var, MemberID propertyId) const = 0;
    virtual tbool CCL_API setProperty (MemberID propertyId, const Variant& var) = 0;
    virtual tbool CCL_API getPropertyNames (IPropertyCollector& collector) const = 0;
    virtual tbool CCL_API invokeMethod (Variant& returnValue, MessageRef msg) = 0;
    DECLARE_BASE_CLASS (Object);
    virtual void CCL_API removeObserver (IObserver* observer);
    virtual void CCL_API signal (MessageRef msg);
    virtual void CCL_API deferSignal (IMessage* msg);
    virtual void deferChanged ();
    virtual void CCL_API notify (ISubject* subject, MessageRef msg);
    virtual bool equals (const Object& obj) const;
    virtual int compare (const Object& obj) const;
    virtual bool load (const Storage& storage);
    virtual bool save (const Storage& storage) const;
    virtual bool save (const OutputStorage& storage) const;
    virtual bool toString (String& string, int flags = 0) const;
    virtual int getHashCode (int size) const;
    IUnknown* asUnknown ();
    static void addGarbageCollected (Object* obj, bool globalScope = true);
    static void deferDestruction (Object* obj);
    static const void* getModuleAddress ();
    virtual StringRef CCL_API getTitle () const = 0;
    virtual UrlRef CCL_API getPath () const = 0;
    virtual tbool CCL_API isDirty () const = 0;
    virtual IUnknown*CCL_API getModel () const = 0;
    virtual IUnknown*CCL_API getView () const = 0;
    virtual IUnknown*CCL_API getController () const = 0;
    virtual IUnknown*CCL_API getMetaInfo () const = 0;
    virtual const IDocumentClass*CCL_API getIDocumentClass () const = 0;
    virtual IActionJournal*CCL_API getIActionJournal () const = 0;
    DECLARE_STRINGID_MEMBER (kPathChanged);

    virtual IView*CCL_API createView (
        StringID name,
        VariantRef data,
        const Rect& bounds
    ) = 0;

    virtual ActionJournal* getActionJournal () const = 0;

Detailed Documentation

Methods

isOlderFormat isCanceled isSaveToNewFolder isSafeModeEnabled isLoadingTemplate isSavingSuspended PreviewMode SourceTemplateID bool needsAutoSave () const

Auto save.

virtual void initialize ()

Called after ctor (new/load/import).

virtual void terminate ()

Called before dtor.

virtual bool prepare (const Attributes* args = nullptr)

Prepare new document.

virtual bool prepareImport ()

Prepare document for import.

virtual bool prepareLoading ()

Prepare document for loading.

virtual bool load ()

Load document.

virtual bool save ()

Save document.

virtual bool saveAs (UrlRef newPath)

Save document to new loaction.

virtual bool prepareSaveToNewFolder (UrlRef newDocumentPath)

Prepare saving to a new folder.

saveAs () will be called afterwards.

virtual void finishSaveToNewFolder (UrlRef newDocumentPath)

Finish saving to a new folder.

Called after saving is done.

virtual Renamer* createRenamer ()

Rename the document.

virtual bool canClose () const

Check if document can be closed.

virtual bool canRemoveFolder (UrlRef folder) const

Check if document folder can be removed.

virtual void onEvent (int eventCode)

Handle document event.

virtual void onLoadFinished (bool failed)

kLoadFinished/kLoadFailed

virtual void onBeforeSave ()

kBeforeSave

virtual void onSaveFinished ()

kSaveFinished

virtual void onActivate (bool state)

kActivate/kDeactivate

virtual void onViewActivated ()

kViewActivated

virtual void onClose ()

kClose

virtual void onDestroyed ()

kDestroyed

virtual void CCL_API notify (ISubject* subject, MessageRef msg)

Receive notification from subject.

CLASS_INTERFACES (Object)

Helper to keep cancellation state.