Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <pam.hxx>
21 : #include <doc.hxx>
22 : #include <ndtxt.hxx>
23 : #include <fltini.hxx>
24 : #include <w1par.hxx>
25 : #include <swfltopt.hxx>
26 : #include <mdiexp.hxx>
27 : #include <swerror.h>
28 : #include <statstr.hrc>
29 :
30 : // Initializing the field FilterFlags
31 0 : static sal_uLong WW1_Read_FieldIniFlags()
32 : {
33 : // sal_uInt16 i;
34 : static const sal_Char* aNames[ 1 ] = { "WinWord/WW1F" };
35 : sal_uInt32 aVal[ 1 ];
36 0 : SwFilterOptions aOpt( 1, aNames, aVal );
37 0 : sal_uLong nFieldFlags = aVal[ 0 ];
38 :
39 0 : if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO ) )
40 : {
41 0 : SwFltSetFlag( nFieldFlags, SwFltControlStack::BOOK_TO_VAR_REF );
42 0 : SwFltSetFlag( nFieldFlags, SwFltControlStack::TAGS_DO_ID );
43 0 : SwFltSetFlag( nFieldFlags, SwFltControlStack::TAGS_IN_TEXT );
44 0 : SwFltSetFlag( nFieldFlags, SwFltControlStack::ALLOW_FLD_CR );
45 : }
46 0 : return nFieldFlags;
47 : }
48 :
49 : // StarWriter-Interface
50 : // One method returns the call interface for the Writer.
51 : // Read() reads a file. For this, two objects get created. The Shell,
52 : // which collects all information, and the manager, which reads it
53 : // from the file.
54 0 : sal_uLong WW1Reader::Read(SwDoc& rDoc, const OUString& rBaseURL, SwPaM& rPam, const OUString& /*cName*/)
55 : {
56 0 : sal_uLong nRet = ERR_SWG_READ_ERROR;
57 : OSL_ENSURE(pStrm!=NULL, "W1-Read without Stream");
58 0 : if (pStrm != NULL)
59 : {
60 0 : sal_Bool bNew = !bInsertMode; // New Doc ( no insert )
61 :
62 0 : sal_uLong nFieldFlags = WW1_Read_FieldIniFlags();
63 0 : Ww1Shell* pRdr = new Ww1Shell( rDoc, rPam, rBaseURL, bNew, nFieldFlags );
64 0 : if( pRdr )
65 : {
66 0 : Ww1Manager* pMan = new Ww1Manager( *pStrm, nFieldFlags );
67 0 : if( pMan )
68 : {
69 0 : if( !pMan->GetError() )
70 : {
71 : ::StartProgress( STR_STATSTR_W4WREAD, 0, 100,
72 0 : rDoc.GetDocShell() );
73 0 : ::SetProgressState( 0, rDoc.GetDocShell() );
74 : // just push everything over now
75 0 : *pRdr << *pMan;
76 0 : if( !pMan->GetError() )
77 : // signal absence of errors
78 0 : nRet = 0; // would be better: WARN_SWG_FEATURES_LOST;
79 0 : ::EndProgress( rDoc.GetDocShell() );
80 : }
81 : else
82 : {
83 0 : if( pMan->GetFib().GetFIB().fComplexGet() )
84 0 : nRet = ERR_WW6_FASTSAVE_ERR;
85 : }
86 : }
87 0 : delete pMan;
88 : }
89 0 : delete pRdr;
90 : }
91 0 : Ww1Sprm::DeinitTab();
92 0 : return nRet;
93 : }
94 :
95 : // The shell is the interface from filter to Writer. It is derived
96 : // from SwFltShell and contains all relevant extensions for ww1.
97 : // SwFltShell is used in common with ww-filter. Information read from
98 : // the file gets 'piped' into the shell, like would be done for a
99 : // stream.
100 0 : Ww1Shell::Ww1Shell( SwDoc& rD, SwPaM& rPam, const OUString& rBaseURL, sal_Bool bNew, sal_uLong nFieldFlags)
101 0 : : SwFltShell(&rD, rPam, rBaseURL, bNew, nFieldFlags)
102 : {
103 0 : }
104 :
105 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|