Exemplo n.º 1
0
/*++

Routine Name:

    CRemoteDictionary::GetResURI

Routine Description:

    Method to obtain the URI of the resource being handled

Arguments:

    pbstrResURI - Pointer to a string to hold the resource URI

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CRemoteDictionary::GetResURI(
    _Outptr_ BSTR* pbstrResURI
    )
{
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(pbstrResURI, E_POINTER)))
    {
        *pbstrResURI = NULL;

        try
        {
            //
            // Create a unique name for the dictionary for this print session
            //
            CStringXDW cstrURI;
            cstrURI.Format(L"%s_%u.dict", m_bstrDictionaryURI, GetUniqueNumber());

            *pbstrResURI = cstrURI.AllocSysString();
        }
        catch (CXDException& e)
        {
            hr = e;
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Exemplo n.º 2
0
/*++

Routine Name:

    CColorManagedImage::GetResURI

Routine Description:

    Method to obtain the URI of the resource being handled

Arguments:

    pbstrResURI - Pointer to a string to hold the resource URI

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CColorManagedImage::GetResURI(
    _Outptr_ BSTR* pbstrResURI
    )
{
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(pbstrResURI, E_POINTER)))
    {
        *pbstrResURI = NULL;

        if (m_bstrBitmapURI.Length() > 0)
        {
            try
            {
                //
                // Create a URI from the original bitmap URI and the current tick count
                //
                CStringXDW cstrFileName(m_bstrBitmapURI);
                CStringXDW cstrFileExt(PathFindExtension(cstrFileName));

                INT indFileExt = cstrFileName.Find(cstrFileExt);

                if (indFileExt > -1)
                {
                    cstrFileName.Delete(indFileExt, cstrFileExt.GetLength());
                }

                //
                // Create a unique name for the bitmap for this print session
                //
                CStringXDW cstrURI;
                cstrURI.Format(L"%s_%u.wdp", cstrFileName, GetUniqueNumber());

                SysFreeString(*pbstrResURI);
                *pbstrResURI = cstrURI.AllocSysString();
            }
            catch (CXDException& e)
            {
                hr = e;
            }
        }
        else
        {
            hr = E_PENDING;
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Exemplo n.º 3
0
/*++

Routine Name:

    CNUpTransform::MatrixToXML

Routine Description:

    Method to create xml markup representing a transformation matrix

Arguments:

    pMatrix          - Pointer to a transformation matrix to convert to markup
    pbstrMatrixXForm - Pointer to a string to contain the matrix markup

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CNUpTransform::MatrixToXML(
    _In_        CONST Matrix* pMatrix,
    _Outptr_ BSTR*         pbstrMatrixXForm
    )
{
    //
    // Construct the matric mark-up from a GDI+ matrix
    //
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(pbstrMatrixXForm, E_POINTER)) &&
        SUCCEEDED(hr = CHECK_POINTER(pMatrix, E_POINTER)))
    {
        *pbstrMatrixXForm = NULL;
        REAL matElems[6];

        if (Ok == pMatrix->GetElements(matElems))
        {
            CStringXDW cstrMatrix;

            try
            {
                cstrMatrix.Format(L"%.2f,%.2f,%.2f,%.2f,%.2f,%.2f",
                                  matElems[0],
                                  matElems[1],
                                  matElems[2],
                                  matElems[3],
                                  matElems[4],
                                  matElems[5]);

                *pbstrMatrixXForm = cstrMatrix.AllocSysString();
            }
            catch (CXDException& e)
            {
                hr = e;
            }
        }
        else
        {
            *pbstrMatrixXForm = NULL;
            hr = E_FAIL;
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Exemplo n.º 4
0
/*++

Routine Name:

    CPSHandler::CreateScoredProperty

Routine Description:

    This routine creates a scored property of type REAL.

Arguments:

    bstrPropName        - The name of the property element to be created
    realValue           - The REAL value to be set
    ppScoredPropElement - Pointer to an IXMLDOMElement that recieves the new element

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CPSHandler::CreateScoredProperty(
    _In_        CONST BSTR       bstrPropName,
    _In_        CONST REAL       realValue,
    _Outptr_ IXMLDOMElement** ppScoredPropElement
    )
{
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(ppScoredPropElement, E_POINTER)))
    {
        if (SysStringLen(bstrPropName) <= 0)
        {
            hr = E_INVALIDARG;
        }
    }

    if (SUCCEEDED(hr))
    {
        try
        {
            //
            // Construct the value string
            //
            CStringXDW cstrValue;
            cstrValue.Format(L"%.2f", realValue);

            //
            // Create the scored property and value node
            //
            hr = CreateScoredProperty(bstrPropName,
                                      CComBSTR(SCHEMA_DECIMAL),
                                      CComBSTR(cstrValue.AllocSysString()),
                                      ppScoredPropElement);
        }
        catch (CXDException& e)
        {
            hr = e;
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Exemplo n.º 5
0
/*++

Routine Name:

    CPTHandler::CreateParamRefInitPair

Routine Description:

    This routine create a pair of DOM elements corresponding to the ParameterRef and
    the ParameterInit that describe a ScoredProperty value. This overload is INT specific

Arguments:

    bstrParam   - The name of the property
    intValue    - The integer value of the scored property
    ppParamRef  - Pointer to a IXMLDOMElement pointer that recives the new ParameterRef
    ppParamInit - Pointer to a IXMLDOMElement pointer that recives the new ParameterInit

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CPTHandler::CreateParamRefInitPair(
    _In_        CONST BSTR       bstrParam,
    _In_        CONST INT        intValue,
    _Outptr_ IXMLDOMElement** ppParamRef,
    _Outptr_ IXMLDOMElement** ppParamInit
    )
{
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(ppParamRef, E_POINTER)) &&
        SUCCEEDED(hr = CHECK_POINTER(ppParamInit, E_POINTER)))
    {
        if (SysStringLen(bstrParam) <= 0)
        {
            hr = E_INVALIDARG;
        }
    }

    if (SUCCEEDED(hr))
    {
        try
        {
            CStringXDW cstrValue;
            cstrValue.Format(L"%i", intValue);

            hr = CreateParamRefInitPair(bstrParam,
                                        CComBSTR(SCHEMA_INTEGER),
                                        CComBSTR(cstrValue.AllocSysString()),
                                        ppParamRef,
                                        ppParamInit);
        }
        catch (CXDException& e)
        {
            hr = e;
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Exemplo n.º 6
0
/*++

Routine Name:

    CWatermarkDMPTConv::GetPTDataSettingsFromDM

Routine Description:

    Populates the watermark data structure from the Devmode passed in.

Arguments:

    pDevmode - pointer to input devmode buffer.
    cbDevmode - size in bytes of full input devmode.
    pPrivateDevmode - pointer to input private devmode buffer.
    cbDrvPrivateSize - size in bytes of private devmode.
    pDataSettings - Pointer to watermark data structure to be updated.

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CWatermarkDMPTConv::GetPTDataSettingsFromDM(
    _In_  PDEVMODE       pDevmode,
    _In_  ULONG          cbDevmode,
    _In_  PVOID          pPrivateDevmode,
    _In_  ULONG          cbDrvPrivateSize,
    _Out_ WatermarkData* pDataSettings
    )
{
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(pDevmode, E_POINTER)) &&
        SUCCEEDED(hr = CHECK_POINTER(pPrivateDevmode, E_POINTER)) &&
        SUCCEEDED(hr = CHECK_POINTER(pDataSettings, E_POINTER)))
    {
        if (cbDevmode < sizeof(DEVMODE) ||
            cbDrvPrivateSize == 0)
        {
            hr = E_INVALIDARG;
        }
    }

    //
    // Retrieve the GPD and devmode controlled settings
    //
    CUIProperties uiProperties(static_cast<POEMDEV>(pPrivateDevmode));

    DWORD dwTextColor = 0;
    if (SUCCEEDED(hr) &&
        SUCCEEDED(hr = GetOptionFromGPDString<EWatermarkOption>(pDevmode,
                                                                cbDevmode,
                                                                g_pszWatermarkTypeFeature,
                                                                g_watermarkTypeOption,
                                                                g_cWatermarkTypeOption,
                                                                pDataSettings->type)) &&
        SUCCEEDED(hr = GetOptionFromGPDString<ELayeringOption>(pDevmode,
                                                               cbDevmode,
                                                               g_pszLayeringFeature,
                                                               g_watermarkLayeringOption,
                                                               g_cLayeringOption,
                                                               pDataSettings->layering)) &&
        SUCCEEDED(hr = uiProperties.GetItem(g_pszWMOffsetWidth, &pDataSettings->widthOrigin, sizeof(pDataSettings->widthOrigin))) &&
        SUCCEEDED(hr = uiProperties.GetItem(g_pszWMOffsetHeight, &pDataSettings->heightOrigin, sizeof(pDataSettings->heightOrigin))) &&
        SUCCEEDED(hr = uiProperties.GetItem(g_pszWMSizeWidth, &pDataSettings->widthExtent, sizeof(pDataSettings->widthExtent))) &&
        SUCCEEDED(hr = uiProperties.GetItem(g_pszWMSizeHeight, &pDataSettings->heightExtent, sizeof(pDataSettings->heightExtent))) &&
        SUCCEEDED(hr = uiProperties.GetItem(g_pszWMTransparency, &pDataSettings->transparency, sizeof(pDataSettings->transparency))) &&
        SUCCEEDED(hr = uiProperties.GetItem(g_pszWMAngle, &pDataSettings->angle, sizeof(pDataSettings->angle))) &&
        SUCCEEDED(hr = uiProperties.GetItem(g_pszWMFontSize, &pDataSettings->txtData.fontSize, sizeof(pDataSettings->txtData.fontSize))) &&
        SUCCEEDED(hr = uiProperties.GetItem(g_pszWMFontColor, &dwTextColor, sizeof(dwTextColor))))
    {
        //
        // Convert the color to the txtData BSTR
        //
        try
        {
            CStringXDW cstrColor;
            cstrColor.Format(L"#%08X", dwTextColor);
            pDataSettings->txtData.bstrFontColor.Empty();
            pDataSettings->txtData.bstrFontColor.Attach(cstrColor.AllocSysString());
        }
        catch (CXDException& e)
        {
            hr = e;
        }

        TCHAR text[MAX_WATERMARK_TEXT + 1] = {0};

        if (SUCCEEDED(hr) &&
            SUCCEEDED(hr = uiProperties.GetItem(g_pszWMText, text, MAX_WATERMARK_TEXT * sizeof(TCHAR))))
        {
            pDataSettings->txtData.bstrText = text;

            //
            // Convert measurements from 100ths of an inch to microns
            //
            pDataSettings->widthOrigin  = HUNDREDTH_OFINCH_TO_MICRON(pDataSettings->widthOrigin);
            pDataSettings->heightOrigin = HUNDREDTH_OFINCH_TO_MICRON(pDataSettings->heightOrigin);
            pDataSettings->widthExtent  = HUNDREDTH_OFINCH_TO_MICRON(pDataSettings->widthExtent);
            pDataSettings->heightExtent = HUNDREDTH_OFINCH_TO_MICRON(pDataSettings->heightExtent);
        }
    }

    ERR_ON_HR(hr);
    return hr;
}