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 <vcl/svapp.hxx>
29 #include <vcl/wrkwin.hxx>
30 #include <vcl/msgbox.hxx>
31
32 #include <sot/storage.hxx>
33
34 // globale Vars
35
36 char** pPara;
37
38 // Deklarationen
39
40 int PrepareConvert( String& rName, String& rOutName, String& rMess );
41 int DoConvert( const String& rName, sal_uInt8 nVersion );
42 void DeInit();
43
44
45
46 // -----------------------------------------------------------------------
47
48 class MyApp : public Application
49 {
50 public:
51 void Main();
52 };
53
54 // -----------------------------------------------------------------------
55
56 MyApp aMyApp;
57
58 // -----------------------------------------------------------------------
59
60 class MyWin : public WorkWindow
61 {
62 String& rMessg;
63 public:
MyWin(Window * pParent,WinBits aWinStyle,String & rMess)64 MyWin( Window* pParent, WinBits aWinStyle, String& rMess ) :
65 WorkWindow(pParent, aWinStyle), rMessg( rMess ) {}
66
67 void Paint( const Rectangle& );
68 void Resize();
69
70 void MouseButtonDown( const MouseEvent& rMEvt );
71 void KeyInput( const KeyEvent& rKEvt );
72 };
73
74 // -----------------------------------------------------------------------
75
76 extern SvStorageStreamRef xStrm;
77
Main()78 void MyApp::Main()
79 {
80 SvFactory::Init();
81 String aMess, aName, aOutName;
82 sal_uInt8 nVersion = 8;
83
84 int nArgs = GetCommandLineParamCount();
85 if (nArgs)
86 {
87 aName = GetCommandLineParam( 0 );
88 if (aName.Search('.') == STRING_NOTFOUND)
89 aName.AppendAscii( ".doc" );
90 if (nArgs >= 2)
91 {
92 aOutName = GetCommandLineParam( 1 );
93 if (nArgs > 2)
94 {
95 nVersion = GetCommandLineParam( 2 ).ToInt32();
96 if( 6 > nVersion || 8 < nVersion )
97 {
98 aMess.AssignAscii( "Aufruf: Dump1 InFile [OutFile] [6|7|8]" );
99 }
100 }
101 }
102 else
103 {
104 aOutName = aName;
105 aOutName.Erase(aOutName.Search('.'));
106 aOutName.AppendAscii( ".dmp" );
107 }
108 }
109
110 sal_Bool bOk = !aMess.Len()
111 && !PrepareConvert( aName, aOutName, aMess )
112 && !DoConvert( aName, nVersion );
113
114 if( !bOk )
115 {
116 MyWin aMainWin( NULL, WB_APP | WB_STDWORK, aMess );
117
118 aMainWin.SetText( String::CreateFromAscii( "WW8-Dumper" ));
119 aMainWin.Show();
120 aMainWin.Invalidate();
121
122 Execute();
123 }
124 DeInit();
125 // SvFactory::DeInit();
126 }
127
128 // -----------------------------------------------------------------------
129
Paint(const Rectangle &)130 void MyWin::Paint( const Rectangle& )
131 {
132 String aText( String::CreateFromAscii( "Dumper fuer WinWord-Dateien !\n"
133 "Die Wandlung ging schief. Ist es wirklich ein WW-File ?" ));
134
135 Size aWinSize = GetOutputSizePixel();
136 Size aTextSize( GetTextWidth( aText ), GetTextHeight());
137 Point aPos( aWinSize.Width() / 2 - aTextSize.Width() / 2,
138 aWinSize.Height() / 2 - aTextSize.Height() / 2 );
139
140 DrawText( aPos, aText );
141
142 aPos.Y() += 20;
143 DrawText( aPos, rMessg );
144 }
145
146 // -----------------------------------------------------------------------
147
Resize()148 void MyWin::Resize()
149 {
150 Invalidate();
151 }
152
153 // -----------------------------------------------------------------------
154
MouseButtonDown(const MouseEvent &)155 void MyWin::MouseButtonDown( const MouseEvent& )
156 {
157 }
158
159 // -----------------------------------------------------------------------
160
KeyInput(const KeyEvent & rKEvt)161 void MyWin::KeyInput( const KeyEvent& rKEvt )
162 {
163 WorkWindow::KeyInput( rKEvt );
164 }
165
166
167
168