/*++ Routine Name: CXPSProcessor::GetRelsForPart Routine Description: This routine retrieves and populates the rels object with the relationships for the specified part Arguments: szPartName - The name of the part to retrieve the relationships for Return Value: HRESULT S_OK - On success E_* - On error --*/ HRESULT CXPSProcessor::GetRelsForPart( __in PCSTR szPartName ) { HRESULT hr = S_OK; if (SUCCEEDED(hr = CHECK_POINTER(szPartName, E_POINTER))) { try { CStringXDA cstrRelsPartName; CComPtr<ISequentialStream> pFileReader(NULL); // // Construct the rels part from the parent part name and parse for // relationships // if (SUCCEEDED(hr = MakeRelsPartName(szPartName, &cstrRelsPartName)) && SUCCEEDED(hr = m_contentTypes.ValidateContentType(cstrRelsPartName, ContentRelationships)) && SUCCEEDED(hr = m_xpsArchive.GetFileStream(cstrRelsPartName, &pFileReader)) && SUCCEEDED(hr = m_pSaxRdr->putContentHandler(&m_rels)) && SUCCEEDED(hr = m_rels.SetCurrentFileName(szPartName)) && SUCCEEDED(hr = m_pSaxRdr->parse(CComVariant(pFileReader)))) { // // We are done with the .rels part - send it on // hr = m_xpsArchive.SendCurrentFile(); } // // Close the curent file ready for the next // m_xpsArchive.CloseCurrent(); } catch (CXDException& e) { hr = e; } } ERR_ON_HR_EXC(hr, E_ELEMENT_NOT_FOUND); return hr; }
/*++ Routine Name: CXPSArchive::InitialiseFile Routine Description: This routine intialises the named file ready for processing or sending on. This entails locating all the PK archive files that constitute the XPS part. Arguments: szFileName - The name of the part to intialise Return Value: HRESULT S_OK - On success E_* - On error --*/ HRESULT CXPSArchive::InitialiseFile( _In_z_ PCSTR szFileName ) { HRESULT hr = S_OK; if (SUCCEEDED(hr = CHECK_POINTER(szFileName, E_POINTER))) { try { CStringXDA cstrFileName(szFileName); // // Open the file handler - if it is still in use this will fail // if (SUCCEEDED(hr = m_XpsFile.Open(szFileName))) { // // Find the record or the parts comprising the record // hr = AddFile(szFileName); } else { RIP("File handler has not been closed correctly\n"); } } catch (CXDException& e) { hr = e; } } ERR_ON_HR_EXC(hr, E_ELEMENT_NOT_FOUND); return hr; }