// ************************************************************************************************************
// Author: Marcin Załęczny
// Release Date: 2010-11-08
// Licence: The GNU Lesser General Public License, version 3.0 (LGPLv3)
// ************************************************************************************************************
#ifndef __MZSTDXPS_XPS_DOCUMENT_H__
#define __MZSTDXPS_XPS_DOCUMENT_H__

#include "mzstdxpsCommon.h"
#include "mzXpsRelationships.h"
#include "mzXpsFixedDocument.h"
#include "mzXpsMetadata.h"
#include "mzXpsPage.h"
#include "mzObject.h"
#include "mzTypedArrayList.h"
#include "mzStringList.h"


class DECLSPEC_MZSTDXPS CXpsDocument : public CObject {
public:
	WINAPI CXpsDocument(UINT docNumber);
    virtual WINAPI ~CXpsDocument();
    BOOL WINAPI saveToFiles(CString docDir);
    VOID WINAPI addPageThumbnail(INT pagenum, BYTE* imageBuffer, DWORD bufferSize);
    VOID WINAPI addFontResource(CString fontFilename, BYTE* fontdataBuffer, DWORD bufferSize);
    // adds default font resource and returns its name
    CString WINAPI addDefFontResource();
    
    inline UINT WINAPI getNumber() { return this->_number; }
    CString WINAPI getDocumentInternalDirectory();
    VOID WINAPI addPagePT(INT pagenum, CString PageMediaSize = L"A4", CString PageOrientation = L"Portrait", CString PageResolutionX = L"600", CString PageResolutionY = L"600");
    VOID WINAPI getAvailableFonts(CStringList* lst);

    CXpsPage* WINAPI addPage();
    CXpsPage* WINAPI addPage(float width, float height);
    CXpsPage* WINAPI addPage(CString PageMediaSize, CString PageOrientation, CString PageResolutionX, CString PageResolutionY);
    
protected:
    UINT _number;
    CXpsRelationships* _fixedDocumentFdocRel;      // File 'XPS_HOME/Documents/[_number]/_rels/FixedDocument.fdoc.rels'
    CXpsFixedDocument* _fixedDocumentFdoc;         // File 'XPS_HOME/Documents/[_number]/FixedDocument.fdoc'
    CXpsMetadata* _metadata;                       // Holds files in directory 'XPS_HOME/Documents/[_number]/Metadata'
    CTypedArrayList* _inMemoryResources;           // Holds files in directory 'XPS_HOME/Documents/[_number]/Resources'
    CArrayList* _pages;                            // Holds files in directory 'XPS_HOME/Documents/[_number]/Pages'
    
    VOID WINAPI _releaseResources();
    VOID WINAPI _releasePages();
};

#endif
