Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <pam.hxx> // fuer SwPam
30 : : #include <doc.hxx>
31 : : #include <ndtxt.hxx> // class SwTxtNode
32 : : #include <fltini.hxx> // Ww1Reader
33 : : #include <w1par.hxx>
34 : : #include <swfltopt.hxx>
35 : : #include <mdiexp.hxx> // StatLine...()
36 : : #include <swerror.h> // ERR_WW1_...
37 : : #include <statstr.hrc> // ResId fuer Statusleiste
38 : :
39 : : //----------------------------------------
40 : : // Initialisieren der Feld-FilterFlags
41 : : //----------------------------------------
42 : :
43 : 0 : static sal_uLong WW1_Read_FieldIniFlags()
44 : : {
45 : : // sal_uInt16 i;
46 : : static const sal_Char* aNames[ 1 ] = { "WinWord/WW1F" };
47 : : sal_uInt32 aVal[ 1 ];
48 [ # # ]: 0 : SwFilterOptions aOpt( 1, aNames, aVal );
49 : 0 : sal_uLong nFieldFlags = aVal[ 0 ];
50 : :
51 [ # # ]: 0 : if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO ) )
52 : : {
53 : 0 : SwFltSetFlag( nFieldFlags, SwFltControlStack::BOOK_TO_VAR_REF );
54 : 0 : SwFltSetFlag( nFieldFlags, SwFltControlStack::TAGS_DO_ID );
55 : 0 : SwFltSetFlag( nFieldFlags, SwFltControlStack::TAGS_IN_TEXT );
56 : 0 : SwFltSetFlag( nFieldFlags, SwFltControlStack::ALLOW_FLD_CR );
57 : : }
58 [ # # ]: 0 : return nFieldFlags;
59 : : }
60 : :
61 : : ////////////////////////////////////////////////// StarWriter-Interface
62 : : //
63 : : // Eine Methode liefern die call-Schnittstelle fuer den Writer.
64 : : // Read() liest eine Datei. hierzu werden zwei Objekte erzeugt, die Shell,
65 : : // die die Informationen aufnimmt und der Manager der sie aus der Datei liest.
66 : : // Diese werden dann einfach per Pipe 'uebertragen'.
67 : : //
68 : :
69 : 0 : sal_uLong WW1Reader::Read(SwDoc& rDoc, const String& rBaseURL, SwPaM& rPam, const String& /*cName*/)
70 : : {
71 : 0 : sal_uLong nRet = ERR_SWG_READ_ERROR;
72 : : OSL_ENSURE(pStrm!=NULL, "W1-Read ohne Stream");
73 [ # # ]: 0 : if (pStrm != NULL)
74 : : {
75 : 0 : sal_Bool bNew = !bInsertMode; // Neues Doc ( kein Einfuegen )
76 : :
77 : : // erstmal eine shell konstruieren: die ist schnittstelle
78 : : // zum writer-dokument
79 : 0 : sal_uLong nFieldFlags = WW1_Read_FieldIniFlags();
80 [ # # ]: 0 : Ww1Shell* pRdr = new Ww1Shell( rDoc, rPam, rBaseURL, bNew, nFieldFlags );
81 [ # # ]: 0 : if( pRdr )
82 : : {
83 : : // dann den manager, der liest die struktur des word-streams
84 [ # # ]: 0 : Ww1Manager* pMan = new Ww1Manager( *pStrm, nFieldFlags );
85 [ # # ]: 0 : if( pMan )
86 : : {
87 [ # # ]: 0 : if( !pMan->GetError() )
88 : : {
89 : : ::StartProgress( STR_STATSTR_W4WREAD, 0, 100,
90 : 0 : rDoc.GetDocShell() );
91 : 0 : ::SetProgressState( 0, rDoc.GetDocShell() );
92 : : // jetzt nur noch alles rueberschieben
93 : 0 : *pRdr << *pMan;
94 [ # # ]: 0 : if( !pMan->GetError() )
95 : : // und nur hier, wenn kein fehler auftrat
96 : : // fehlerfreiheit melden
97 : 0 : nRet = 0; // besser waere: WARN_SWG_FEATURES_LOST;
98 : 0 : ::EndProgress( rDoc.GetDocShell() );
99 : : }
100 : : else
101 : : {
102 [ # # ]: 0 : if( pMan->GetFib().GetFIB().fComplexGet() )
103 : : //!!! ACHTUNG: hier muss eigentlich ein Error
104 : : // wegen Fastsave kommen, das der PMW-Filter
105 : : // das nicht unterstuetzt. Stattdessen temporaer
106 : : // nur eine Warnung, bis die entsprechende
107 : : // Meldung und Behandlung weiter oben eingebaut ist.
108 : : // nRet = WARN_WW6_FASTSAVE_ERR;
109 : : // Zum Einchecken mit neuem String:
110 : 0 : nRet = ERR_WW6_FASTSAVE_ERR;
111 : : }
112 : : }
113 [ # # ]: 0 : delete pMan;
114 : : }
115 [ # # ]: 0 : delete pRdr;
116 : : }
117 : 0 : Ww1Sprm::DeinitTab();
118 : 0 : return nRet;
119 : : }
120 : :
121 : : ///////////////////////////////////////////////////////////////// Shell
122 : : //
123 : : // Die Shell ist die Schnittstelle vom Filter zum Writer. Sie ist
124 : : // abgeleitet von der mit ww-filter gemeinsam benutzten Shell
125 : : // SwFltShell und enthaelt alle fuer ww1 noetigen Erweiterungen. Wie
126 : : // in einen Stream werden alle Informationen, die aus der Datei
127 : : // gelesen werden, in die shell ge'piped'.
128 : : //
129 : 0 : Ww1Shell::Ww1Shell( SwDoc& rD, SwPaM& rPam, const String& rBaseURL, sal_Bool bNew, sal_uLong nFieldFlags)
130 : 0 : : SwFltShell(&rD, rPam, rBaseURL, bNew, nFieldFlags)
131 : : {
132 : 0 : }
133 : :
134 : :
135 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|