예제 #1
0
void TestSnapshotSaver::TestSavesCustomProperties()
{
    const CStdString sDocWithNoProperties = GET_TEST_FILE_PATH( _T("No Properties.doc") );
    const CStdString sCopyOfDoc = GET_TEST_TEMP_PATH( _T("CopyFile.doc") );
    CStdString sDestFile = GET_TEST_TEMP_PATH( _T("ResultsFile.doc") );

    ::DeleteFile( sCopyOfDoc.c_str() );
    ::DeleteFile( sDestFile.c_str() );
    assertTest( ::CopyFile( sDocWithNoProperties.c_str(), sCopyOfDoc.c_str(), FALSE ) );

    CustomPropertyStorage propStorage( sCopyOfDoc );
    propStorage.SetProperty( _T("Safe"), _T("Init") );

    Word::_ApplicationPtr pApp;
    pApp.CreateInstance( __uuidof( Word::Application ) );

    try
    {
        const Word::_DocumentPtr pDocument = pApp->Documents->Open( &_variant_t( sCopyOfDoc ) );

        SnapshotSaver saver( pDocument );
        saver.Save( sDestFile );

        CustomPropertyStorage destStorage( sDestFile );
        assertMessage( destStorage.GetProperty( _T("Safe") ) == CStdString( _T("Init") ), _T("Custom properties should be persisted in the snapshotted document") );
        pApp->Quit();
    }
    catch(...)
    {
        pApp->Quit();
        throw;
    }
}
예제 #2
0
void TestSnapshotSaver::TestSave()
{
    const CStdString sSourceFileName = CTestUtils::GetTestFileFolder() + _T("TestApplyChange_BinaryRead\\Synergy24TestDocuments\\FlagForFollowUp.doc");
    CStdString sDestFileName = CTestUtils::GetTestFileFolder() + _T("TestApplyChange_BinaryRead\\Synergy24TestDocuments\\rubbish.doc");

    ::DeleteFile( sDestFileName );
    assertFileNotExists( sDestFileName );

    Word::_ApplicationPtr pApp;
    pApp.CreateInstance( __uuidof( Word::Application ) );
    const Word::_DocumentPtr pDocument = pApp->Documents->Open( &_variant_t( sSourceFileName ) );

    try
    {
        SnapshotSaver snapshotSaver( pDocument );
        snapshotSaver.Save( sDestFileName );
    }
    catch(...)
    {
        pDocument->Close();
        pApp->Quit();
        throw;
    }

    pDocument->Close();
    pApp->Quit();

    assertFileExists( sDestFileName );
}
예제 #3
0
void WordOutputProcessor::Close()
{
	_variant_t vtFalse = VARIANT_FALSE;
	Word::_DocumentPtr pDoc = m_WordDoc;
	pDoc->Close(&vtFalse, &vtMissing, &vtFalse);
	m_hWndEditor = NULL;
	Word::_ApplicationPtr pApp = m_WordApp;
	m_WordApp = NULL;
	pApp->Quit();
}