473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Read a compound document

Hi,

We developped an application that save files as a compound document.

Now we developp a new version in net and we would like to import old file
format. What is the best way. A sample or a link is welcome

Thank's in advance

Polo
Nov 17 '05 #1
3 3601
HI,

I think that depends of the document itself, in .net you can read a binary
file so in principle you can recreate the same structure. it's up the app to
interprete the bytes properly though.

How was the document created?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Polo" <pb@rtech.be> wrote in message
news:43**********************@news.skynet.be...
Hi,

We developped an application that save files as a compound document.

Now we developp a new version in net and we would like to import old file
format. What is the best way. A sample or a link is welcome

Thank's in advance

Polo

Nov 17 '05 #2
Hi,

The partail code below is used to generate the compound file

STDMETHODIMP CProject::SaveCompound(BSTR FileName)
{
CComPtr<IStorage> pRootStorage;
if (StgIsStorageFile(FileName) == S_OK)
{
_RTVH(StgOpenStorage(FileName, NULL, STGM_DIRECT | STGM_READWRITE |
STGM_SHARE_EXCLUSIVE, NULL, 0, &pRootStorage));
}
else
{
_RTVH(StgCreateDocfile(FileName, STGM_DIRECT | STGM_READWRITE |
STGM_CREATE | STGM_SHARE_EXCLUSIVE, 0, &pRootStorage));
}
CComPtr<IPersistStorage> pPersistStorage;
_RTVH(QueryInterface(IID_IPersistStorage,
reinterpret_cast<void**>(&pPersistStorage)));
_RTVH(pPersistStorage->Save(pRootStorage, FALSE));
return S_OK;
}

HRESULT CProject::Save(IStorage* pStorage, BOOL fSameAsLoad)
{
CComPtr<IStorage> pProjectStorage;
_RTVH(pStorage->CreateStorage(OLESTR("IProject"), STGM_DIRECT |
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, 0,0,
&pProjectStorage));
CComPtr<IStream> pStream;
_RTVH(pProjectStorage->CreateStream(OLESTR("Contents"), STGM_DIRECT |
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, 0,0, &pStream));
CComPtr<IPersistStreamInit> pPersistStreamInit;
_RTVH(QueryInterface(IID_IPersistStreamInit,
reinterpret_cast<void**>(&pPersistStreamInit)));
_RTVH(pPersistStreamInit->Save(pStream, FALSE));
return S_OK;
}
HRESULT CProject::Save(LPSTREAM pStm, BOOL fClearDirty)
{
ULONG lWrite;
_RTVH(m_bstrVersion.WriteToStream(pStm));
_RTVH(m_bstrDescription.WriteToStream(pStm));
_RTVH(m_bstrShortDescription.WriteToStream(pStm));
_RTVH(m_bstrOwner.WriteToStream(pStm));
_RTVH(pStm->Write((void*)&m_eInterpolationMethod,
sizeof(m_eInterpolationMethod), &lWrite));
_RTVF(lWrite != sizeof(m_eInterpolationMethod));
....
}
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> a
écrit dans le message de news:On*************@tk2msftngp13.phx.gbl...
HI,

I think that depends of the document itself, in .net you can read a binary file so in principle you can recreate the same structure. it's up the app to interprete the bytes properly though.

How was the document created?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Polo" <pb@rtech.be> wrote in message
news:43**********************@news.skynet.be...
Hi,

We developped an application that save files as a compound document.

Now we developp a new version in net and we would like to import old file format. What is the best way. A sample or a link is welcome

Thank's in advance

Polo


Nov 17 '05 #3
Hi,
You will have to reverse engineer it, if you have the source code you can
follow it and see how it saves the pieces, you will have to duplicate it in
..NET , most probably you will have to recreate the same struct currently
being used.

I cant think of another solution less cumbersome :(

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"Polo" <pb@rtech.be> wrote in message
news:43***********************@news.skynet.be...
Hi,

The partail code below is used to generate the compound file

STDMETHODIMP CProject::SaveCompound(BSTR FileName)
{
CComPtr<IStorage> pRootStorage;
if (StgIsStorageFile(FileName) == S_OK)
{
_RTVH(StgOpenStorage(FileName, NULL, STGM_DIRECT | STGM_READWRITE |
STGM_SHARE_EXCLUSIVE, NULL, 0, &pRootStorage));
}
else
{
_RTVH(StgCreateDocfile(FileName, STGM_DIRECT | STGM_READWRITE |
STGM_CREATE | STGM_SHARE_EXCLUSIVE, 0, &pRootStorage));
}
CComPtr<IPersistStorage> pPersistStorage;
_RTVH(QueryInterface(IID_IPersistStorage,
reinterpret_cast<void**>(&pPersistStorage)));
_RTVH(pPersistStorage->Save(pRootStorage, FALSE));
return S_OK;
}

HRESULT CProject::Save(IStorage* pStorage, BOOL fSameAsLoad)
{
CComPtr<IStorage> pProjectStorage;
_RTVH(pStorage->CreateStorage(OLESTR("IProject"), STGM_DIRECT |
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, 0,0,
&pProjectStorage));
CComPtr<IStream> pStream;
_RTVH(pProjectStorage->CreateStream(OLESTR("Contents"), STGM_DIRECT |
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, 0,0, &pStream));
CComPtr<IPersistStreamInit> pPersistStreamInit;
_RTVH(QueryInterface(IID_IPersistStreamInit,
reinterpret_cast<void**>(&pPersistStreamInit)));
_RTVH(pPersistStreamInit->Save(pStream, FALSE));
return S_OK;
}
HRESULT CProject::Save(LPSTREAM pStm, BOOL fClearDirty)
{
ULONG lWrite;
_RTVH(m_bstrVersion.WriteToStream(pStm));
_RTVH(m_bstrDescription.WriteToStream(pStm));
_RTVH(m_bstrShortDescription.WriteToStream(pStm));
_RTVH(m_bstrOwner.WriteToStream(pStm));
_RTVH(pStm->Write((void*)&m_eInterpolationMethod,
sizeof(m_eInterpolationMethod), &lWrite));
_RTVF(lWrite != sizeof(m_eInterpolationMethod));
....
}
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> a
écrit dans le message de news:On*************@tk2msftngp13.phx.gbl...
HI,

I think that depends of the document itself, in .net you can read a

binary
file so in principle you can recreate the same structure. it's up the app

to
interprete the bytes properly though.

How was the document created?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Polo" <pb@rtech.be> wrote in message
news:43**********************@news.skynet.be...
> Hi,
>
> We developped an application that save files as a compound document.
>
> Now we developp a new version in net and we would like to import old file > format. What is the best way. A sample or a link is welcome
>
> Thank's in advance
>
> Polo
>
>



Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Sonia | last post by:
I have been looking for a definition of a compound class but cannot find it anywhere ? What exactly is a compound class ? Thanks
6
by: David W. Fenton | last post by:
I'm generally against using compound keys, except in join tables, but I'm currently mapping out a schema where the join table has child records. The application is for fund-raising and I have four...
6
by: William Ahern | last post by:
So, GCC 4.01 is giving errors that GCC 3.3 did not, and I'm thinking they've gone overboard with their new type checking infrastructure. Here's the supposedly offending code (no laughing or...
7
by: Eric Laberge | last post by:
Aloha! This question is meant to be about C99 and unnamed compound objects. As I read, if such a construct as int *p = (int){0}; is used within a function, then it has "automatic storage...
0
by: Anthony Shorrock | last post by:
I'd like to be able to read a compound document ( a word, or an excel file) using csharp. Could someone set me off in the right direction? I've seen lot's of VC++ examples but I can't convert...
7
by: Timo Haberkern | last post by:
Hi there, i have some troubles with my TSearch2 Installation. I have done this installation as described in http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_compound_words...
0
by: kath | last post by:
Hi.... XLRDError: Can't find workbook in OLE2 compound document What does this error means? When I try to open some excel files using XLRD, I encounter this error. Not with every excel, but...
3
by: KWienhold | last post by:
I'm currently writing an application (using Visual Studio 2003 SP1 and C#) that stores files and additional information in a single compound file using IStorage/IStream. Since files in a compound...
27
by: Nate Eldredge | last post by:
Consider the following pseudo-code: #include <opaque.h> struct foo { int a; opaque_t op; int b; };
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.