/*
 * Copyright (C) 1999 Paul Quinn
 * Copyright (C) 2003 Alexandre Julliard
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

import "ocidl.idl";
import "objidl.idl";
import "oleidl.idl";
import "oaidl.idl";
import "servprov.idl";


interface IOleDocumentView;
interface IEnumOleDocumentViews;


/*****************************************************************************
 * IOleDocument interface
 */
[
    object,
    uuid(b722bcc5-4e68-101b-a2bc-00aa00404770),
    pointer_default(unique)
]
interface IOleDocument : IUnknown
{
    typedef [unique] IOleDocument *LPOLEDOCUMENT;

    typedef enum
    {
        DOCMISC_CANCREATEMULTIPLEVIEWS = 1,
        DOCMISC_SUPPORTCOMPLEXRECTANGLES = 2,
        DOCMISC_CANTOPENEDIT = 4,
        DOCMISC_NOFILESUPPORT = 8
    } DOCMISC;

    HRESULT CreateView(
        [in, unique] IOleInPlaceSite *pIPSite,
        [in, unique] IStream *pstm,
        [in] DWORD dwReserved,
        [out] IOleDocumentView **ppView);

    HRESULT GetDocMiscStatus(
        [out] DWORD *pdwStatus);

    HRESULT EnumViews(
        [out] IEnumOleDocumentViews **ppEnum,
        [out] IOleDocumentView **ppView);
}


/*****************************************************************************
 * IOleDocumentSite interface
 */
[
    object,
    uuid(b722bcc7-4e68-101b-a2bc-00aa00404770),
    pointer_default(unique)
]
interface IOleDocumentSite : IUnknown
{
    typedef [unique] IOleDocumentSite *LPOLEDOCUMENTSITE;

    HRESULT ActivateMe( [in] IOleDocumentView *pViewToActivate );
}


/*****************************************************************************
 * IOleDocumentView interface
 */
[
    object,
    uuid(b722bcc6-4e68-101b-a2bc-00aa00404770),
    pointer_default(unique)
]
interface IOleDocumentView : IUnknown
{
    typedef [unique] IOleDocumentView *LPOLEDOCUMENTVIEW;

    HRESULT SetInPlaceSite( [in, unique] IOleInPlaceSite *pIPSite );

    HRESULT GetInPlaceSite( [out] IOleInPlaceSite **ppIPSite );

    HRESULT GetDocument( [out] IUnknown **ppunk );

    HRESULT SetRect( [in] LPRECT prcView );

    HRESULT GetRect( [out] LPRECT prcView );

    HRESULT SetRectComplex(
        [in, unique] LPRECT prcView,
        [in, unique] LPRECT prcHScroll,
        [in, unique] LPRECT prcVScroll,
        [in, unique] LPRECT prcSizeBox);

    HRESULT Show( [in] BOOL fShow );

    HRESULT UIActivate( [in] BOOL fUIActivate );

    HRESULT Open();

    HRESULT CloseView( [in] DWORD dwReserved );

    HRESULT SaveViewState( [in] LPSTREAM pstm );

    HRESULT ApplyViewState( [in] LPSTREAM pstm );

    HRESULT Clone(
        [in] IOleInPlaceSite *pIPSiteNew,
        [out] IOleDocumentView **ppViewNew);
}


/*****************************************************************************
 * IEnumOleDocumentViews interface
 */
[
    object,
    uuid(b722bcc8-4e68-101b-a2bc-00aa00404770),
    pointer_default(unique)
]
interface IEnumOleDocumentViews : IUnknown
{
    typedef [unique] IEnumOleDocumentViews *LPENUMOLEDOCUMENTVIEWS;

    [local]
    HRESULT Next(
        [in] ULONG cViews,
        [out] IOleDocumentView **rgpView,
        [out] ULONG *pcFetched);

    [call_as(Next)]
    HRESULT RemoteNext(
        [in] ULONG cViews,
        [out, size_is(cViews), length_is(*pcFetched)] IOleDocumentView **rgpView,
        [out] ULONG *pcFetched);

    HRESULT Skip( [in] ULONG cViews );

    HRESULT Reset();

    HRESULT Clone( [out] IEnumOleDocumentViews **ppEnum );
}


/*****************************************************************************
 * IOleCommandTarget interface
 */
[
    object,
    uuid(b722bccb-4e68-101b-a2bc-00aa00404770),
    pointer_default(unique)
]
interface IOleCommandTarget : IUnknown
{
    typedef [unique] IOleCommandTarget *LPOLECOMMANDTARGET;

    typedef enum OLECMDF
    {
        OLECMDF_SUPPORTED = 0x1,
        OLECMDF_ENABLED = 0x2,
        OLECMDF_LATCHED = 0x4,
        OLECMDF_NINCHED = 0x8,
        OLECMDF_INVISIBLE = 0x10,
        OLECMDF_DEFHIDEONCTXTMENU = 0x20
    } OLECMDF;

    typedef struct _tagOLECMD
    {
        ULONG cmdID;
        DWORD cmdf;
    } OLECMD;

    typedef struct _tagOLECMDTEXT
    {
        DWORD cmdtextf;
        ULONG cwActual;
        ULONG cwBuf;
        [size_is(cwBuf)] WCHAR rgwz[];
    } OLECMDTEXT;

    typedef enum OLECMDTEXTF
    {
        OLECMDTEXTF_NONE = 0,
        OLECMDTEXTF_NAME = 1,
        OLECMDTEXTF_STATUS = 2
    } OLECMDTEXTF;

    typedef enum OLECMDEXECOPT
    {
        OLECMDEXECOPT_DODEFAULT = 0,
        OLECMDEXECOPT_PROMPTUSER = 1,
        OLECMDEXECOPT_DONTPROMPTUSER = 2,
        OLECMDEXECOPT_SHOWHELP = 3
    } OLECMDEXECOPT;

    typedef enum OLECMDID
    {
        OLECMDID_OPEN = 1,
        OLECMDID_NEW = 2,
        OLECMDID_SAVE = 3,
        OLECMDID_SAVEAS = 4,
        OLECMDID_SAVECOPYAS = 5,
        OLECMDID_PRINT = 6,
        OLECMDID_PRINTPREVIEW = 7,
        OLECMDID_PAGESETUP = 8,
        OLECMDID_SPELL = 9,
        OLECMDID_PROPERTIES = 10,
        OLECMDID_CUT = 11,
        OLECMDID_COPY = 12,
        OLECMDID_PASTE = 13,
        OLECMDID_PASTESPECIAL = 14,
        OLECMDID_UNDO = 15,
        OLECMDID_REDO = 16,
        OLECMDID_SELECTALL = 17,
        OLECMDID_CLEARSELECTION = 18,
        OLECMDID_ZOOM = 19,
        OLECMDID_GETZOOMRANGE = 20,
        OLECMDID_UPDATECOMMANDS = 21,
        OLECMDID_REFRESH = 22,
        OLECMDID_STOP = 23,
        OLECMDID_HIDETOOLBARS = 24,
        OLECMDID_SETPROGRESSMAX = 25,
        OLECMDID_SETPROGRESSPOS = 26,
        OLECMDID_SETPROGRESSTEXT = 27,
        OLECMDID_SETTITLE = 28,
        OLECMDID_SETDOWNLOADSTATE = 29,
        OLECMDID_STOPDOWNLOAD = 30,
        OLECMDID_ONTOOLBARACTIVATED = 31,
        OLECMDID_FIND = 32,
        OLECMDID_DELETE = 33,
        OLECMDID_HTTPEQUIV = 34,
        OLECMDID_HTTPEQUIV_DONE = 35,
        OLECMDID_ENABLE_INTERACTION = 36,
        OLECMDID_ONUNLOAD = 37,
        OLECMDID_PROPERTYBAG2 = 38,
        OLECMDID_PREREFRESH = 39,
        /* iexplorer uses ... 44 */
        OLECMDID_SHOWSCRIPTERROR = 40,
        OLECMDID_SHOWMESSAGE = 41,
        OLECMDID_SHOWFIND = 42,
        OLECMDID_SHOWPAGESETUP = 43,
        OLECMDID_SHOWPRINT = 44,
        OLECMDID_CLOSE = 45,
        OLECMDID_ALLOWUILESSSAVEAS = 46,
        OLECMDID_DONTDOWNLOADCSS = 47,
        OLECMDID_UPDATEPAGESTATUS = 48,
        OLECMDID_PRINT2 = 49,
        OLECMDID_PRINTPREVIEW2 = 50,
        OLECMDID_SETPRINTTEMPLATE = 51,
        OLECMDID_GETPRINTTEMPLATE = 52,
        OLECMDID_PAGEACTIONBLOCKED = 55,
        OLECMDID_PAGEACTIONUIQUERY = 56,
        OLECMDID_FOCUSVIEWCONTROLS = 57,
        OLECMDID_FOCUSVIEWCONTROLSQUERY = 58,
        OLECMDID_SHOWPAGEACTIONMENU = 59,
        OLECMDID_ADDTRAVELENTRY = 60,
        OLECMDID_UPDATETRAVELENTRY = 61,
        OLECMDID_UPDATEBACKFORWARDSTATE = 62,
        OLECMDID_OPTICAL_ZOOM = 63,
        OLECMDID_OPTICAL_GETZOOMRANGE = 64,
        OLECMDID_WINDOWSTATECHANGED = 65,
        OLECMDID_ACTIVEXINSTALLSCOPE = 66,
        OLECMDID_UPDATETRAVELENTRY_DATARECOVERY = 67,
        OLECMDID_SHOWTASKDLG = 68,
        OLECMDID_POPSTATEEVENT = 69,
        OLECMDID_VIEWPORT_MODE = 70,
        OLECMDID_LAYOUT_VIEWPORT_WIDTH = 71,
        OLECMDID_VISUAL_VIEWPORT_EXCLUDE_BOTTOM = 72,
        OLECMDID_USER_OPTICAL_ZOOM = 73,
        OLECMDID_PAGEAVAILABLE = 74,
        OLECMDID_GETUSERSCALABLE = 75,
        OLECMDID_UPDATE_CARET = 76,
        OLECMDID_ENABLE_VISIBILITY = 77,
        OLECMDID_MEDIA_PLAYBACK = 78
    } OLECMDID;

    HRESULT QueryStatus(
        [in, unique] const GUID *pguidCmdGroup,
        [in] ULONG cCmds,
        [in, out, size_is(cCmds)] OLECMD prgCmds[],
        [in, out, unique] OLECMDTEXT *pCmdText);

    HRESULT Exec(
        [in, unique] const GUID *pguidCmdGroup,
        [in] DWORD nCmdID,
        [in] DWORD nCmdexecopt,
        [in, unique] VARIANT *pvaIn,
        [in, out, unique] VARIANT *pvaOut);
}


/*****************************************************************************
 * IContinueCallback interface
 */
[
   object,
   uuid(b722bcca-4e68-101b-a2bc-00aa00404770),
   pointer_default(unique)
]
interface IContinueCallback : IUnknown
{
    typedef [unique] IContinueCallback *LPCONTINUECALLBACK;

    HRESULT FContinue();

    HRESULT FContinuePrinting(
        [in] LONG nCntPrinted,
        [in] LONG nCurPage,
        [in, unique] WCHAR *pwszPrintStatus);
}


/*****************************************************************************
 * IPrint interface
 */
[
   object,
   uuid(b722bcc9-4e68-101b-a2bc-00aa00404770),
   pointer_default(unique)
]
interface IPrint : IUnknown
{
    typedef [unique] IPrint *LPPRINT;

    typedef enum
    {
        PRINTFLAG_MAYBOTHERUSER = 1,
        PRINTFLAG_PROMPTUSER  = 2,
        PRINTFLAG_USERMAYCHANGEPRINTER  = 4,
        PRINTFLAG_RECOMPOSETODEVICE = 8,
        PRINTFLAG_DONTACTUALLYPRINT = 16,
        PRINTFLAG_FORCEPROPERTIES = 32,
        PRINTFLAG_PRINTTOFILE = 64
    } PRINTFLAG;

    typedef struct tagPAGERANGE
    {
        LONG nFromPage;
        LONG nToPage;
    } PAGERANGE;

    typedef struct tagPAGESET
    {
        ULONG cbStruct;
        BOOL fOddPages;
        BOOL fEvenPages;
        ULONG cPageRange;
        [size_is(cPageRange)] PAGERANGE rgPages[];
    } PAGESET;

    HRESULT SetInitialPageNum(
        [in] LONG nFirstPage);

    HRESULT GetPageInfo(
        [out] LONG *pnFirstPage,
        [out] LONG *pcPages);

    [local]
    HRESULT Print(
        [in] DWORD grfFlags,
        [in, out] DVTARGETDEVICE **pptd,
        [in, out] PAGESET **ppPageSet,
        [in, out, unique] STGMEDIUM *pstgmOptions,
        [in] IContinueCallback *pcallback,
        [in]  LONG nFirstPage,
        [out] LONG *pcPagesPrinted,
        [out] LONG *pnLastPage);

    [call_as(Print)]
    HRESULT RemotePrint(
        [in] DWORD grfFlags,
        [in, out] DVTARGETDEVICE **pptd,
        [in, out] PAGESET **pppageset,
        [in, out, unique] RemSTGMEDIUM *pstgmOptions,
        [in] IContinueCallback *pcallback,
        [in]  LONG nFirstPage,
        [out] LONG *pcPagesPrinted,
        [out] LONG *pnLastPage);
}


cpp_quote("#define OLECMDERR_E_FIRST            (OLE_E_LAST+1)")
cpp_quote("#define OLECMDERR_E_NOTSUPPORTED     (OLECMDERR_E_FIRST)")
cpp_quote("#define OLECMDERR_E_DISABLED         (OLECMDERR_E_FIRST+1)")
cpp_quote("#define OLECMDERR_E_NOHELP           (OLECMDERR_E_FIRST+2)")
cpp_quote("#define OLECMDERR_E_CANCELED         (OLECMDERR_E_FIRST+3)")
cpp_quote("#define OLECMDERR_E_UNKNOWNGROUP     (OLECMDERR_E_FIRST+4)")

cpp_quote("#define MSOCMDERR_E_FIRST OLECMDERR_E_FIRST")
cpp_quote("#define MSOCMDERR_E_NOTSUPPORTED OLECMDERR_E_NOTSUPPORTED")
cpp_quote("#define MSOCMDERR_E_DISABLED OLECMDERR_E_DISABLED")
cpp_quote("#define MSOCMDERR_E_NOHELP OLECMDERR_E_NOHELP")
cpp_quote("#define MSOCMDERR_E_CANCELED OLECMDERR_E_CANCELED")
cpp_quote("#define MSOCMDERR_E_UNKNOWNGROUP OLECMDERR_E_UNKNOWNGROUP")

cpp_quote("#define LPMSODOCUMENT                  LPOLEDOCUMENT")
cpp_quote("#define LPMSODOCUMENTSITE              LPOLEDOCUMENTSITE")
cpp_quote("#define LPMSOVIEW                      LPOLEDOCUMENTVIEW")
cpp_quote("#define LPENUMMSOVIEW                  LPENUMOLEDOCUMENTVIEWS")
cpp_quote("#define LPMSOCOMMANDTARGET             LPOLECOMMANDTARGET")
cpp_quote("#define IID_IMsoDocument               IID_IOleDocument")
cpp_quote("#define IID_IMsoDocumentSite           IID_IOleDocumentSite")
cpp_quote("#define IID_IMsoView                   IID_IOleDocumentView")
cpp_quote("#define IID_IEnumMsoView               IID_IEnumOleDocumentViews")
cpp_quote("#define IID_IMsoCommandTarget          IID_IOleCommandTarget")

cpp_quote("EXTERN_C const GUID SID_SContainerDispatch;")