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