xref: /trunk/main/sw/source/ui/web/wview.cxx (revision efeef26f)
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 <sfx2/msg.hxx>
29 #include <svl/srchitem.hxx>
30 #include <sfx2/dispatch.hxx>
31 #include <sfx2/templdlg.hxx>
32 #include <svx/srchdlg.hxx>
33 #include <basic/sbxobj.hxx>
34 #include <uivwimp.hxx>
35 #include <svx/fmshell.hxx>
36 #include <svx/extrusionbar.hxx>
37 #include <svx/fontworkbar.hxx>
38 
39 #include <sfx2/objface.hxx>
40 #include <swmodule.hxx>
41 #include <unotxvw.hxx>
42 #include <swtypes.hxx>
43 #include <cmdid.h>
44 #include <globals.hrc>
45 #include <wrtsh.hxx>
46 #include <edtwin.hxx>
47 #include <wgrfsh.hxx>
48 #include <wfrmsh.hxx>
49 #include <wolesh.hxx>
50 #include <wtabsh.hxx>
51 #include <wlistsh.hxx>
52 #include <wformsh.hxx>
53 #include <wtextsh.hxx>
54 #include <barcfg.hxx>
55 #include <doc.hxx>
56 
57 // EIGENTLICH nicht moeglich !!
58 #include <beziersh.hxx>
59 #include <drawsh.hxx>
60 #include <drwtxtsh.hxx>
61 #include <annotsh.hxx>
62 
63 #include <wview.hxx>
64 #include <wdocsh.hxx>
65 #include <web.hrc>
66 #include <shells.hrc>
67 
68 #define SwWebView
69 #define Frames
70 #define Graphics
71 #define OLEObjects
72 #define Controls
73 #define Text
74 #define Frame
75 #define Graphic
76 #define Object
77 #define Draw
78 #define DrawText
79 #define TextInTable
80 #define ListInText
81 #define ListInTable
82 #define Page
83 #include <swslots.hxx>
84 
85 
86 SFX_IMPL_NAMED_VIEWFACTORY(SwWebView, "Default")
87 {
88 	SFX_VIEW_REGISTRATION(SwWebDocShell);
89 }
90 
SFX_IMPL_INTERFACE(SwWebView,SwView,SW_RES (RID_WEBTOOLS_TOOLBOX))91 SFX_IMPL_INTERFACE( SwWebView, SwView, SW_RES(RID_WEBTOOLS_TOOLBOX) )
92 {
93 	SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId());
94 	SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
95 	SFX_OBJECTBAR_REGISTRATION(	SFX_OBJECTBAR_TOOLS|
96 								SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
97 								SW_RES(RID_WEBTOOLS_TOOLBOX) );
98 }
99 
TYPEINIT1(SwWebView,SwView)100 TYPEINIT1(SwWebView,SwView)
101 
102 /*-----------------22.01.97 14.27-------------------
103 
104 --------------------------------------------------*/
105 
106 
107 SwWebView::SwWebView(SfxViewFrame* _pFrame, SfxViewShell* _pShell) :
108     SwView(_pFrame, _pShell)
109 {
110 }
111 
112 /*-----------------22.01.97 14.27-------------------
113 
114 --------------------------------------------------*/
115 
116 
~SwWebView()117 SwWebView::~SwWebView()
118 {
119 }
120 
121 /*-----------------23.01.97 09.01-------------------
122 
123 --------------------------------------------------*/
124 
125 
SelectShell()126 void SwWebView::SelectShell()
127 {
128 	// Entscheidung, ob UpdateTable gerufen werden muss
129 	sal_Bool bUpdateTable = sal_False;
130 	const SwFrmFmt* pCurTableFmt = GetWrtShell().GetTableFmt();
131 	if(pCurTableFmt && pCurTableFmt != GetLastTblFrmFmt())
132 	{
133 		bUpdateTable = sal_True; // kann erst spaeter ausgefuehrt werden
134 	}
135 	SetLastTblFrmFmt(pCurTableFmt);
136 	//SEL_TBL und SEL_TBL_CELLS koennen verodert sein!
137 	int nNewSelectionType = (GetWrtShell().GetSelectionType()
138 								& ~nsSelectionType::SEL_TBL_CELLS);
139 
140     int _nSelectionType = GetSelectionType();
141     if ( nNewSelectionType == _nSelectionType )
142 	{
143 		GetViewFrame()->GetBindings().InvalidateAll( sal_False );
144         if ( _nSelectionType & nsSelectionType::SEL_OLE ||
145              _nSelectionType & nsSelectionType::SEL_GRF )
146 			//Fuer Grafiken und OLE kann sich natuerlich das Verb aendern!
147 			ImpSetVerb( nNewSelectionType );
148 	}
149 	else
150 	{
151 
152 	//	DELETEZ(pxSelectionObj); //Selektionsobjekt loeschen
153 		SfxDispatcher &rDispatcher = *GetViewFrame()->GetDispatcher();
154 		SwToolbarConfigItem *pBarCfg = SW_MOD()->GetWebToolbarConfig();
155 
156 		if( GetCurShell() )
157 		{
158 			rDispatcher.Flush();		// alle gecachten Shells wirklich loeschen
159 
160 			//Zur alten Selektion merken welche Toolbar sichtbar war
161             sal_Int32 nId = rDispatcher.GetObjectBarId( SFX_OBJECTBAR_OBJECT );
162 			if ( nId )
163                 pBarCfg->SetTopToolbar( _nSelectionType, nId );
164 
165 			SfxShell *pSfxShell;
166 			sal_uInt16 i;
167 			for ( i = 0; sal_True; ++i )
168 			{
169 				pSfxShell = rDispatcher.GetShell( i );
170 				if ( !( pSfxShell->ISA( SwBaseShell ) ||
171 					pSfxShell->ISA( SwDrawTextShell ) || pSfxShell->ISA( SwAnnotationShell ) ) )
172 					break;
173 			}
174 			pSfxShell = rDispatcher.GetShell( --i );
175 			ASSERT( pSfxShell, "My Shell ist lost in space" );
176 			rDispatcher.Pop( *pSfxShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE);
177 		}
178 
179 		sal_Bool bInitFormShell = sal_False;
180 		if( !GetFormShell() )
181 		{
182 			bInitFormShell = sal_True;
183 			SetFormShell( new FmFormShell( this ) );
184 			rDispatcher.Push( *GetFormShell() );
185 		}
186 
187 		sal_Bool bSetExtInpCntxt = sal_False;
188         _nSelectionType = nNewSelectionType;
189         SetSelectionType( _nSelectionType );
190 		ShellModes eShellMode;
191 
192         if ( _nSelectionType & nsSelectionType::SEL_OLE )
193 		{
194             eShellMode = SHELL_MODE_OBJECT;
195 			SetShell( new SwWebOleShell( *this ));
196 			rDispatcher.Push( *GetCurShell() );
197 		}
198         else if ( _nSelectionType & nsSelectionType::SEL_FRM
199             || _nSelectionType & nsSelectionType::SEL_GRF)
200 		{
201             eShellMode = SHELL_MODE_FRAME;
202 			SetShell( new SwWebFrameShell( *this ));
203 			rDispatcher.Push( *GetCurShell() );
204             if(_nSelectionType & nsSelectionType::SEL_GRF )
205 			{
206                 eShellMode = SHELL_MODE_GRAPHIC;
207 				SetShell( new SwWebGrfShell( *this ));
208 				rDispatcher.Push( *GetCurShell() );
209 			}
210 		}
211         else if ( _nSelectionType & nsSelectionType::SEL_FRM )
212 		{
213             eShellMode = SHELL_MODE_FRAME;
214 			SetShell( new SwWebFrameShell( *this ));
215 			rDispatcher.Push( *GetCurShell() );
216 		}
217         else if ( _nSelectionType & nsSelectionType::SEL_DRW )
218 		{
219             eShellMode = SHELL_MODE_DRAW;
220 			SetShell( new svx::ExtrusionBar( this ) );
221 			rDispatcher.Push( *GetCurShell() );
222 
223             eShellMode = SHELL_MODE_DRAW;
224 			SetShell( new svx::FontworkBar( this ) );
225 			rDispatcher.Push( *GetCurShell() );
226 
227 			SetShell( new SwDrawShell( *this ));
228 			rDispatcher.Push( *GetCurShell() );
229             if ( _nSelectionType & nsSelectionType::SEL_BEZ )
230 			{
231                 eShellMode = SHELL_MODE_BEZIER;
232 				SetShell( new SwBezierShell( *this ));
233 				rDispatcher.Push( *GetCurShell() );
234 			}
235 
236 		}
237         else if ( _nSelectionType & nsSelectionType::SEL_DRW_FORM )
238 		{
239             eShellMode = SHELL_MODE_DRAW_FORM;
240 			SetShell( new SwWebDrawFormShell( *this ));
241 
242 			rDispatcher.Push( *GetCurShell() );
243 		}
244         else if ( _nSelectionType & nsSelectionType::SEL_DRW_TXT )
245 		{
246             eShellMode = SHELL_MODE_DRAWTEXT;
247 			rDispatcher.Push( *(new SwBaseShell( *this )) );
248 			SetShell( new SwDrawTextShell( *this ));
249 			rDispatcher.Push( *GetCurShell() );
250 		}
251 		else if ( _nSelectionType & nsSelectionType::SEL_POSTIT )
252 		{
253 			eShellMode = SHELL_MODE_POSTIT;
254 			SetShell( new SwAnnotationShell( *this ) );
255 			rDispatcher.Push( *GetCurShell() );
256 		}
257 		else
258 		{
259 			bSetExtInpCntxt = sal_True;
260             eShellMode = SHELL_MODE_TEXT;
261             if ( _nSelectionType & nsSelectionType::SEL_NUM )
262 			{
263                 eShellMode = SHELL_MODE_LIST_TEXT;
264 				SetShell( new SwWebListShell( *this ));
265 				rDispatcher.Push( *GetCurShell() );
266 			}
267 			SetShell( new SwWebTextShell(*this));
268 			rDispatcher.Push( *GetCurShell() );
269             if ( _nSelectionType & nsSelectionType::SEL_TBL )
270 			{
271                 eShellMode = eShellMode == SHELL_MODE_LIST_TEXT ? SHELL_MODE_TABLE_LIST_TEXT
272                                                         : SHELL_MODE_TABLE_TEXT;
273 				SetShell( new SwWebTableShell( *this ));
274 				rDispatcher.Push( *GetCurShell() );
275 			}
276 		}
277         ImpSetVerb( _nSelectionType );
278 		GetViewImpl()->SetShellMode(eShellMode);
279 
280 		if( !GetDocShell()->IsReadOnly() )
281 		{
282 			if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
283 				bSetExtInpCntxt = sal_False;
284 
285 			InputContext aCntxt( GetEditWin().GetInputContext() );
286 			aCntxt.SetOptions( bSetExtInpCntxt
287 								? (aCntxt.GetOptions() |
288 										( INPUTCONTEXT_TEXT |
289 											INPUTCONTEXT_EXTTEXTINPUT ))
290 								: (aCntxt.GetOptions() & ~
291 										( INPUTCONTEXT_TEXT |
292 											INPUTCONTEXT_EXTTEXTINPUT )) );
293 			GetEditWin().SetInputContext( aCntxt );
294 		}
295 
296 		//Zur neuen Selektion die Toolbar aktivieren, die auch beim letzten Mal
297 		//aktiviert war
298 		//Vorher muss ein Flush() sein, betrifft aber lt. MBA nicht das UI und ist
299 		//kein Performance-Problem
300         // TODO/LATER: maybe now the Flush() command is superfluous?!
301 		rDispatcher.Flush();
302 
303 		Point aPnt = GetEditWin().GetPointerPosPixel();
304 		aPnt = GetEditWin().PixelToLogic(aPnt);
305 		GetEditWin().UpdatePointer(aPnt);
306 
307 		if ( bInitFormShell && GetWrtShell().GetDrawView() )
308 			GetFormShell()->SetView( PTR_CAST( FmFormView,
309 												GetWrtShell().GetDrawView()));
310 
311 
312 	}
313 	GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
314 
315 	//Guenstiger Zeitpunkt fuer die Kommunikation mit OLE-Objekten?
316 	if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
317 		GetDocShell()->GetDoc()->PrtOLENotify( sal_False );
318 
319 	//jetzt das Tabellen-Update
320 	if(bUpdateTable)
321 		GetWrtShell().UpdateTable();
322 }
323 
324 
325 
326 
327