update credits
[LibreOffice.git] / sw / source / ui / web / wview.cxx
blob68df58e95b88fa42ff34a85b4a3ea064a2277774
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/msg.hxx>
21 #include <svl/srchitem.hxx>
22 #include <sfx2/dispatch.hxx>
23 #include <sfx2/infobar.hxx>
24 #include <sfx2/templdlg.hxx>
25 #include <svx/srchdlg.hxx>
26 #include <basic/sbxobj.hxx>
27 #include <uivwimp.hxx>
28 #include <svx/fmshell.hxx>
29 #include <svx/extrusionbar.hxx>
30 #include <svx/fontworkbar.hxx>
32 #include <sfx2/objface.hxx>
33 #include <swmodule.hxx>
34 #include <unotxvw.hxx>
35 #include <swtypes.hxx>
36 #include <cmdid.h>
37 #include <globals.hrc>
38 #include <wrtsh.hxx>
39 #include <edtwin.hxx>
40 #include <wgrfsh.hxx>
41 #include <wfrmsh.hxx>
42 #include <wolesh.hxx>
43 #include <wtabsh.hxx>
44 #include <wlistsh.hxx>
45 #include <wformsh.hxx>
46 #include <wtextsh.hxx>
47 #include <barcfg.hxx>
48 #include <doc.hxx>
50 // TECHNICALLY not possible !!
51 #include <beziersh.hxx>
52 #include <drawsh.hxx>
53 #include <drwtxtsh.hxx>
54 #include <annotsh.hxx>
56 #include <wview.hxx>
57 #include <wdocsh.hxx>
58 #include <web.hrc>
59 #include <shells.hrc>
61 #define SwWebView
62 #define Text
63 #define TextInTable
64 #define ListInText
65 #define ListInTable
66 #include <swslots.hxx>
69 SFX_IMPL_NAMED_VIEWFACTORY(SwWebView, "Default")
71 SFX_VIEW_REGISTRATION(SwWebDocShell);
74 SFX_IMPL_INTERFACE( SwWebView, SwView, SW_RES(RID_WEBTOOLS_TOOLBOX) )
76 SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId());
77 SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
78 SFX_CHILDWINDOW_REGISTRATION(SfxInfoBarContainerChild::GetChildWindowId());
79 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS|
80 SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
81 SW_RES(RID_WEBTOOLS_TOOLBOX) );
84 TYPEINIT1(SwWebView,SwView)
86 SwWebView::SwWebView(SfxViewFrame* _pFrame, SfxViewShell* _pShell) :
87 SwView(_pFrame, _pShell)
91 SwWebView::~SwWebView()
95 void SwWebView::SelectShell()
97 // Decision whether UpdateTable must be called
98 bool bUpdateTable = false;
99 const SwFrmFmt* pCurTableFmt = GetWrtShell().GetTableFmt();
100 if(pCurTableFmt && pCurTableFmt != GetLastTblFrmFmt())
102 bUpdateTable = true; // can only be executed later
104 SetLastTblFrmFmt(pCurTableFmt);
105 //SEL_TBL and SEL_TBL_CELLS can be ored!
106 int nNewSelectionType = (GetWrtShell().GetSelectionType()
107 & ~nsSelectionType::SEL_TBL_CELLS);
109 int _nSelectionType = GetSelectionType();
110 if ( nNewSelectionType == _nSelectionType )
112 GetViewFrame()->GetBindings().InvalidateAll( sal_False );
113 if ( _nSelectionType & nsSelectionType::SEL_OLE ||
114 _nSelectionType & nsSelectionType::SEL_GRF )
115 //The verb may of course change for graphics and OLE!
116 ImpSetVerb( nNewSelectionType );
118 else
120 SfxDispatcher &rDispatcher = *GetViewFrame()->GetDispatcher();
121 SwToolbarConfigItem *pBarCfg = SW_MOD()->GetWebToolbarConfig();
123 if( GetCurShell() )
125 rDispatcher.Flush(); // really delete all cached shells
127 //Additonal to the old selection remember which toolbar was visible.
128 sal_Int32 nId = rDispatcher.GetObjectBarId( SFX_OBJECTBAR_OBJECT );
129 if ( nId )
130 pBarCfg->SetTopToolbar( _nSelectionType, nId );
132 SfxShell *pSfxShell;
133 sal_uInt16 i;
134 for ( i = 0; sal_True; ++i )
136 pSfxShell = rDispatcher.GetShell( i );
137 if ( !( pSfxShell->ISA( SwBaseShell ) ||
138 pSfxShell->ISA( SwDrawTextShell ) || pSfxShell->ISA( SwAnnotationShell ) ) )
139 break;
141 pSfxShell = rDispatcher.GetShell( --i );
142 OSL_ENSURE( pSfxShell, "My Shell ist lost in space" );
143 rDispatcher.Pop( *pSfxShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE);
146 bool bInitFormShell = false;
147 if( !GetFormShell() )
149 bInitFormShell = true;
150 SetFormShell( new FmFormShell( this ) );
151 rDispatcher.Push( *GetFormShell() );
154 bool bSetExtInpCntxt = false;
155 _nSelectionType = nNewSelectionType;
156 SetSelectionType( _nSelectionType );
157 ShellModes eShellMode;
159 if ( _nSelectionType & nsSelectionType::SEL_OLE )
161 eShellMode = SHELL_MODE_OBJECT;
162 SetShell( new SwWebOleShell( *this ));
163 rDispatcher.Push( *GetCurShell() );
165 else if ( _nSelectionType & nsSelectionType::SEL_FRM
166 || _nSelectionType & nsSelectionType::SEL_GRF)
168 eShellMode = SHELL_MODE_FRAME;
169 SetShell( new SwWebFrameShell( *this ));
170 rDispatcher.Push( *GetCurShell() );
171 if(_nSelectionType & nsSelectionType::SEL_GRF )
173 eShellMode = SHELL_MODE_GRAPHIC;
174 SetShell( new SwWebGrfShell( *this ));
175 rDispatcher.Push( *GetCurShell() );
178 else if ( _nSelectionType & nsSelectionType::SEL_FRM )
180 eShellMode = SHELL_MODE_FRAME;
181 SetShell( new SwWebFrameShell( *this ));
182 rDispatcher.Push( *GetCurShell() );
184 else if ( _nSelectionType & nsSelectionType::SEL_DRW )
186 eShellMode = SHELL_MODE_DRAW;
187 SetShell( new svx::ExtrusionBar( this ) );
188 rDispatcher.Push( *GetCurShell() );
190 SetShell( new svx::FontworkBar( this ) );
191 rDispatcher.Push( *GetCurShell() );
193 SetShell( new SwDrawShell( *this ));
194 rDispatcher.Push( *GetCurShell() );
195 if ( _nSelectionType & nsSelectionType::SEL_BEZ )
197 eShellMode = SHELL_MODE_BEZIER;
198 SetShell( new SwBezierShell( *this ));
199 rDispatcher.Push( *GetCurShell() );
203 else if ( _nSelectionType & nsSelectionType::SEL_DRW_FORM )
205 eShellMode = SHELL_MODE_DRAW_FORM;
206 SetShell( new SwWebDrawFormShell( *this ));
208 rDispatcher.Push( *GetCurShell() );
210 else if ( _nSelectionType & nsSelectionType::SEL_DRW_TXT )
212 eShellMode = SHELL_MODE_DRAWTEXT;
213 rDispatcher.Push( *(new SwBaseShell( *this )) );
214 SetShell( new SwDrawTextShell( *this ));
215 rDispatcher.Push( *GetCurShell() );
217 else if ( _nSelectionType & nsSelectionType::SEL_POSTIT )
219 eShellMode = SHELL_MODE_POSTIT;
220 SetShell( new SwAnnotationShell( *this ) );
221 rDispatcher.Push( *GetCurShell() );
223 else
225 bSetExtInpCntxt = true;
226 eShellMode = SHELL_MODE_TEXT;
227 if ( _nSelectionType & nsSelectionType::SEL_NUM )
229 eShellMode = SHELL_MODE_LIST_TEXT;
230 SetShell( new SwWebListShell( *this ));
231 rDispatcher.Push( *GetCurShell() );
233 SetShell( new SwWebTextShell(*this));
234 rDispatcher.Push( *GetCurShell() );
235 if ( _nSelectionType & nsSelectionType::SEL_TBL )
237 eShellMode = eShellMode == SHELL_MODE_LIST_TEXT ? SHELL_MODE_TABLE_LIST_TEXT
238 : SHELL_MODE_TABLE_TEXT;
239 SetShell( new SwWebTableShell( *this ));
240 rDispatcher.Push( *GetCurShell() );
243 ImpSetVerb( _nSelectionType );
244 GetViewImpl()->SetShellMode(eShellMode);
246 if( !GetDocShell()->IsReadOnly() )
248 if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
249 bSetExtInpCntxt = false;
251 InputContext aCntxt( GetEditWin().GetInputContext() );
252 aCntxt.SetOptions( bSetExtInpCntxt
253 ? (aCntxt.GetOptions() |
254 ( INPUTCONTEXT_TEXT |
255 INPUTCONTEXT_EXTTEXTINPUT ))
256 : (aCntxt.GetOptions() & ~
257 ( INPUTCONTEXT_TEXT |
258 INPUTCONTEXT_EXTTEXTINPUT )) );
259 GetEditWin().SetInputContext( aCntxt );
262 //Additional to the selection enable the toolbar, which was
263 //activated last time
264 //Before must be a Flush(), but concerns according to MBA not the
265 //user interface and is not a performance issue.
266 // TODO/LATER: maybe now the Flush() command is superfluous?!
267 rDispatcher.Flush();
269 Point aPnt = GetEditWin().GetPointerPosPixel();
270 aPnt = GetEditWin().PixelToLogic(aPnt);
271 GetEditWin().UpdatePointer(aPnt);
273 if ( bInitFormShell && GetWrtShell().GetDrawView() )
274 GetFormShell()->SetView( PTR_CAST( FmFormView,
275 GetWrtShell().GetDrawView()));
279 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
281 //Opportune time for the communication with OLE objects?
282 if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
283 GetDocShell()->GetDoc()->PrtOLENotify( sal_False );
285 //now the table update
286 if(bUpdateTable)
287 GetWrtShell().UpdateTable();
293 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */