none
The difference between IXpsDocument and XpsDocument RRS feed

  • Question

  •  

    I just study the WDK(6000), xpsdrvsmpl sample code, I do not understand the IXpsDocument interface, the following is the source code.

    HRESULT
    CXDXpsFilter:rocessPart(
        __inout IXpsDocument* pXD
        )
    {
        VERBOSE("Processing XPS Document part with default handler\n");

        HRESULT hr = S_OK;

        if (SUCCEEDED(hr = CHECK_POINTER(pXD, E_POINTER)))
        {
            hr = m_pXDWriter->SendXpsDocument(pXD);
        }

        ERR_ON_HR(hr);
        return hr;
    }

     

    as we see above, the IXpsDocument interface belongs to the DOM Document. but i just see another source code following the below.

     

    using namespace System;
    using namespace System::IO;
    using namespace System::Collections::Generic;
    using namespace System::IO:ackaging;
    using namespace System::Xml;
    using namespace System::Windows::Forms;
    using namespace System::Windows::Xps;
    using namespace System::Windows::Xps:ackaging;
    using namespace System:rinting;

             Package^ package = PackageStick out tongueen(packageName);
             try
             {
                XpsDocument^ xpsDocument = gcnew XpsDocument(package);

                // Add the package content (false=without PrintTicket).
                AddPackageContent(xpsDocument, false);

                // Close the package.
                xpsDocument->Close();
             } finally
             {
                delete package;
             }

     

    those source code is just use in Visual Studio C++ .NET 2003 or above, and just use those Namespace.

     

    as we all see, who can tell me the difference between them, and tell my how to use the IXpsDocument interface to replace the XpsDocument interface.

     

     

    Thanks.

     

    Friday, November 9, 2007 6:09 AM

Answers

  • I will try to explain this as an interface is a contract how an object can communicate with other objects, it does not imply any restrictions. An object can implement several interfaces. A reference to an interface does not reveal whatever object it is that implements the interface, it only guarantees that the interface reference implements the properties and methods it say it implements.

     

    In your case XpsDocument may imply that it implements the IXpsDocument interface which means that XpsDocument can be seen as IXpsDocument though this is only my guess.

     

    XpsDocument = IXpsDocument if XpsDocument implements IXpsDocument

    IXpsDocument = XpsDocument is it implements IXpsDocument

     

    Thinking abstract about interfaces is not that easy and it may take some time before you really get it.
    Saturday, November 10, 2007 3:02 AM
    Moderator