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> // fuer SwPam
21 : #include <doc.hxx>
22 : #include <ndtxt.hxx> // class SwTxtNode
23 : #include <fltini.hxx> // Ww1Reader
24 : #include <w1par.hxx>
25 : #include <swfltopt.hxx>
26 : #include <mdiexp.hxx> // StatLine...()
27 : #include <swerror.h> // ERR_WW1_...
28 : #include <statstr.hrc> // ResId fuer Statusleiste
29 :
30 : //----------------------------------------
31 : // Initialisieren der Feld-FilterFlags
32 : //----------------------------------------
33 :
34 0 : static sal_uLong WW1_Read_FieldIniFlags()
35 : {
36 : // sal_uInt16 i;
37 : static const sal_Char* aNames[ 1 ] = { "WinWord/WW1F" };
38 : sal_uInt32 aVal[ 1 ];
39 0 : SwFilterOptions aOpt( 1, aNames, aVal );
40 0 : sal_uLong nFieldFlags = aVal[ 0 ];
41 :
42 0 : if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO ) )
43 : {
44 0 : SwFltSetFlag( nFieldFlags, SwFltControlStack::BOOK_TO_VAR_REF );
45 0 : SwFltSetFlag( nFieldFlags, SwFltControlStack::TAGS_DO_ID );
46 0 : SwFltSetFlag( nFieldFlags, SwFltControlStack::TAGS_IN_TEXT );
47 0 : SwFltSetFlag( nFieldFlags, SwFltControlStack::ALLOW_FLD_CR );
48 : }
49 0 : return nFieldFlags;
50 : }
51 :
52 : ////////////////////////////////////////////////// StarWriter-Interface
53 : //
54 : // Eine Methode liefern die call-Schnittstelle fuer den Writer.
55 : // Read() liest eine Datei. hierzu werden zwei Objekte erzeugt, die Shell,
56 : // die die Informationen aufnimmt und der Manager der sie aus der Datei liest.
57 : // Diese werden dann einfach per Pipe 'uebertragen'.
58 : //
59 :
60 0 : sal_uLong WW1Reader::Read(SwDoc& rDoc, const String& rBaseURL, SwPaM& rPam, const String& /*cName*/)
61 : {
62 0 : sal_uLong nRet = ERR_SWG_READ_ERROR;
63 : OSL_ENSURE(pStrm!=NULL, "W1-Read ohne Stream");
64 0 : if (pStrm != NULL)
65 : {
66 0 : sal_Bool bNew = !bInsertMode; // Neues Doc ( kein Einfuegen )
67 :
68 : // erstmal eine shell konstruieren: die ist schnittstelle
69 : // zum writer-dokument
70 0 : sal_uLong nFieldFlags = WW1_Read_FieldIniFlags();
71 0 : Ww1Shell* pRdr = new Ww1Shell( rDoc, rPam, rBaseURL, bNew, nFieldFlags );
72 0 : if( pRdr )
73 : {
74 : // dann den manager, der liest die struktur des word-streams
75 0 : Ww1Manager* pMan = new Ww1Manager( *pStrm, nFieldFlags );
76 0 : if( pMan )
77 : {
78 0 : if( !pMan->GetError() )
79 : {
80 : ::StartProgress( STR_STATSTR_W4WREAD, 0, 100,
81 0 : rDoc.GetDocShell() );
82 0 : ::SetProgressState( 0, rDoc.GetDocShell() );
83 : // jetzt nur noch alles rueberschieben
84 0 : *pRdr << *pMan;
85 0 : if( !pMan->GetError() )
86 : // und nur hier, wenn kein fehler auftrat
87 : // fehlerfreiheit melden
88 0 : nRet = 0; // besser waere: WARN_SWG_FEATURES_LOST;
89 0 : ::EndProgress( rDoc.GetDocShell() );
90 : }
91 : else
92 : {
93 0 : if( pMan->GetFib().GetFIB().fComplexGet() )
94 : //!!! ACHTUNG: hier muss eigentlich ein Error
95 : // wegen Fastsave kommen, das der PMW-Filter
96 : // das nicht unterstuetzt. Stattdessen temporaer
97 : // nur eine Warnung, bis die entsprechende
98 : // Meldung und Behandlung weiter oben eingebaut ist.
99 : // nRet = WARN_WW6_FASTSAVE_ERR;
100 : // Zum Einchecken mit neuem String:
101 0 : nRet = ERR_WW6_FASTSAVE_ERR;
102 : }
103 : }
104 0 : delete pMan;
105 : }
106 0 : delete pRdr;
107 : }
108 0 : Ww1Sprm::DeinitTab();
109 0 : return nRet;
110 : }
111 :
112 : ///////////////////////////////////////////////////////////////// Shell
113 : //
114 : // Die Shell ist die Schnittstelle vom Filter zum Writer. Sie ist
115 : // abgeleitet von der mit ww-filter gemeinsam benutzten Shell
116 : // SwFltShell und enthaelt alle fuer ww1 noetigen Erweiterungen. Wie
117 : // in einen Stream werden alle Informationen, die aus der Datei
118 : // gelesen werden, in die shell ge'piped'.
119 : //
120 0 : Ww1Shell::Ww1Shell( SwDoc& rD, SwPaM& rPam, const String& rBaseURL, sal_Bool bNew, sal_uLong nFieldFlags)
121 0 : : SwFltShell(&rD, rPam, rBaseURL, bNew, nFieldFlags)
122 : {
123 0 : }
124 :
125 :
126 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|