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