1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_starmath.hxx"
26 #include "eqnolefilehdr.hxx"
27 #include <sot/storage.hxx>
28 
29 //////////////////////////////////////////////////////////////////////
30 
Read(SvStorageStream * pS)31 void EQNOLEFILEHDR::Read(SvStorageStream *pS)
32 {
33     *pS >> nCBHdr;
34     *pS >> nVersion;
35     *pS >> nCf;
36     *pS >> nCBObject;
37     *pS >> nReserved1;
38     *pS >> nReserved2;
39     *pS >> nReserved3;
40     *pS >> nReserved4;
41 }
42 
43 
Write(SvStorageStream * pS)44 void EQNOLEFILEHDR::Write(SvStorageStream *pS)
45 {
46     *pS << nCBHdr;
47     *pS << nVersion;
48     *pS << nCf;
49     *pS << nCBObject;
50     *pS << nReserved1;
51     *pS << nReserved2;
52     *pS << nReserved3;
53     *pS << nReserved4;
54 }
55 
56 
GetMathTypeVersion(SotStorage * pStor,sal_uInt8 & nVersion)57 sal_Bool GetMathTypeVersion( SotStorage* pStor, sal_uInt8 &nVersion )
58 {
59     sal_uInt8 nVer = 0;
60     sal_Bool bSuccess = sal_False;
61 
62     //
63     // code sniplet copied from MathType::Parse
64     //
65     SvStorageStreamRef xSrc = pStor->OpenSotStream(
66         String::CreateFromAscii("Equation Native"),
67         STREAM_STD_READ | STREAM_NOCREATE);
68     if ( (!xSrc.Is()) || (SVSTREAM_OK != xSrc->GetError()))
69         return bSuccess;
70     SvStorageStream *pS = &xSrc;
71     pS->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
72     //
73     EQNOLEFILEHDR aHdr;
74     aHdr.Read(pS);
75     *pS >> nVer;
76 
77     if (!pS->GetError())
78     {
79         nVersion = nVer;
80         bSuccess = sal_True;
81     }
82     return bSuccess;
83 }
84 
85 //////////////////////////////////////////////////////////////////////
86 
87