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