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