Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
31 :
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>
49 :
50 : // TECHNICALLY not possible !!
51 : #include <beziersh.hxx>
52 : #include <drawsh.hxx>
53 : #include <drwtxtsh.hxx>
54 : #include <annotsh.hxx>
55 :
56 : #include <wview.hxx>
57 : #include <wdocsh.hxx>
58 : #include <web.hrc>
59 : #include <shells.hrc>
60 :
61 : #define SwWebView
62 : #define Text
63 : #define TextInTable
64 : #define ListInText
65 : #define ListInTable
66 : #include <swslots.hxx>
67 :
68 :
69 68 : SFX_IMPL_NAMED_VIEWFACTORY(SwWebView, "Default")
70 : {
71 33 : SFX_VIEW_REGISTRATION(SwWebDocShell);
72 33 : }
73 :
74 661 : SFX_IMPL_INTERFACE( SwWebView, SwView, SW_RES(RID_WEBTOOLS_TOOLBOX) )
75 : {
76 33 : SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId());
77 33 : SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
78 33 : SFX_CHILDWINDOW_REGISTRATION(SfxInfoBarContainerChild::GetChildWindowId());
79 66 : SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS|
80 : SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
81 33 : SW_RES(RID_WEBTOOLS_TOOLBOX) );
82 33 : }
83 :
84 6728 : TYPEINIT1(SwWebView,SwView)
85 :
86 2 : SwWebView::SwWebView(SfxViewFrame* _pFrame, SfxViewShell* _pShell) :
87 2 : SwView(_pFrame, _pShell)
88 : {
89 2 : }
90 :
91 4 : SwWebView::~SwWebView()
92 : {
93 4 : }
94 :
95 4 : void SwWebView::SelectShell()
96 : {
97 : // Decision whether UpdateTable must be called
98 4 : bool bUpdateTable = false;
99 4 : const SwFrmFmt* pCurTableFmt = GetWrtShell().GetTableFmt();
100 4 : if(pCurTableFmt && pCurTableFmt != GetLastTblFrmFmt())
101 : {
102 0 : bUpdateTable = true; // can only be executed later
103 : }
104 4 : SetLastTblFrmFmt(pCurTableFmt);
105 : //SEL_TBL and SEL_TBL_CELLS can be ored!
106 4 : int nNewSelectionType = (GetWrtShell().GetSelectionType()
107 4 : & ~nsSelectionType::SEL_TBL_CELLS);
108 :
109 4 : int _nSelectionType = GetSelectionType();
110 4 : if ( nNewSelectionType == _nSelectionType )
111 : {
112 2 : GetViewFrame()->GetBindings().InvalidateAll( sal_False );
113 4 : if ( _nSelectionType & nsSelectionType::SEL_OLE ||
114 2 : _nSelectionType & nsSelectionType::SEL_GRF )
115 : //The verb may of course change for graphics and OLE!
116 0 : ImpSetVerb( nNewSelectionType );
117 : }
118 : else
119 : {
120 2 : SfxDispatcher &rDispatcher = *GetViewFrame()->GetDispatcher();
121 2 : SwToolbarConfigItem *pBarCfg = SW_MOD()->GetWebToolbarConfig();
122 :
123 2 : if( GetCurShell() )
124 : {
125 0 : rDispatcher.Flush(); // really delete all cached shells
126 :
127 : //Additonal to the old selection remember which toolbar was visible.
128 0 : sal_Int32 nId = rDispatcher.GetObjectBarId( SFX_OBJECTBAR_OBJECT );
129 0 : if ( nId )
130 0 : pBarCfg->SetTopToolbar( _nSelectionType, nId );
131 :
132 : SfxShell *pSfxShell;
133 : sal_uInt16 i;
134 0 : for ( i = 0; sal_True; ++i )
135 : {
136 0 : pSfxShell = rDispatcher.GetShell( i );
137 0 : if ( !( pSfxShell->ISA( SwBaseShell ) ||
138 0 : pSfxShell->ISA( SwDrawTextShell ) || pSfxShell->ISA( SwAnnotationShell ) ) )
139 0 : break;
140 : }
141 0 : pSfxShell = rDispatcher.GetShell( --i );
142 : OSL_ENSURE( pSfxShell, "My Shell ist lost in space" );
143 0 : rDispatcher.Pop( *pSfxShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE);
144 : }
145 :
146 2 : bool bInitFormShell = false;
147 2 : if( !GetFormShell() )
148 : {
149 2 : bInitFormShell = true;
150 2 : SetFormShell( new FmFormShell( this ) );
151 2 : rDispatcher.Push( *GetFormShell() );
152 : }
153 :
154 2 : bool bSetExtInpCntxt = false;
155 2 : _nSelectionType = nNewSelectionType;
156 2 : SetSelectionType( _nSelectionType );
157 : ShellModes eShellMode;
158 :
159 2 : if ( _nSelectionType & nsSelectionType::SEL_OLE )
160 : {
161 0 : eShellMode = SHELL_MODE_OBJECT;
162 0 : SetShell( new SwWebOleShell( *this ));
163 0 : rDispatcher.Push( *GetCurShell() );
164 : }
165 2 : else if ( _nSelectionType & nsSelectionType::SEL_FRM
166 2 : || _nSelectionType & nsSelectionType::SEL_GRF)
167 : {
168 0 : eShellMode = SHELL_MODE_FRAME;
169 0 : SetShell( new SwWebFrameShell( *this ));
170 0 : rDispatcher.Push( *GetCurShell() );
171 0 : if(_nSelectionType & nsSelectionType::SEL_GRF )
172 : {
173 0 : eShellMode = SHELL_MODE_GRAPHIC;
174 0 : SetShell( new SwWebGrfShell( *this ));
175 0 : rDispatcher.Push( *GetCurShell() );
176 : }
177 : }
178 2 : else if ( _nSelectionType & nsSelectionType::SEL_FRM )
179 : {
180 0 : eShellMode = SHELL_MODE_FRAME;
181 0 : SetShell( new SwWebFrameShell( *this ));
182 0 : rDispatcher.Push( *GetCurShell() );
183 : }
184 2 : else if ( _nSelectionType & nsSelectionType::SEL_DRW )
185 : {
186 0 : eShellMode = SHELL_MODE_DRAW;
187 0 : SetShell( new svx::ExtrusionBar( this ) );
188 0 : rDispatcher.Push( *GetCurShell() );
189 :
190 0 : SetShell( new svx::FontworkBar( this ) );
191 0 : rDispatcher.Push( *GetCurShell() );
192 :
193 0 : SetShell( new SwDrawShell( *this ));
194 0 : rDispatcher.Push( *GetCurShell() );
195 0 : if ( _nSelectionType & nsSelectionType::SEL_BEZ )
196 : {
197 0 : eShellMode = SHELL_MODE_BEZIER;
198 0 : SetShell( new SwBezierShell( *this ));
199 0 : rDispatcher.Push( *GetCurShell() );
200 : }
201 :
202 : }
203 2 : else if ( _nSelectionType & nsSelectionType::SEL_DRW_FORM )
204 : {
205 0 : eShellMode = SHELL_MODE_DRAW_FORM;
206 0 : SetShell( new SwWebDrawFormShell( *this ));
207 :
208 0 : rDispatcher.Push( *GetCurShell() );
209 : }
210 2 : else if ( _nSelectionType & nsSelectionType::SEL_DRW_TXT )
211 : {
212 0 : eShellMode = SHELL_MODE_DRAWTEXT;
213 0 : rDispatcher.Push( *(new SwBaseShell( *this )) );
214 0 : SetShell( new SwDrawTextShell( *this ));
215 0 : rDispatcher.Push( *GetCurShell() );
216 : }
217 2 : else if ( _nSelectionType & nsSelectionType::SEL_POSTIT )
218 : {
219 0 : eShellMode = SHELL_MODE_POSTIT;
220 0 : SetShell( new SwAnnotationShell( *this ) );
221 0 : rDispatcher.Push( *GetCurShell() );
222 : }
223 : else
224 : {
225 2 : bSetExtInpCntxt = true;
226 2 : eShellMode = SHELL_MODE_TEXT;
227 2 : if ( _nSelectionType & nsSelectionType::SEL_NUM )
228 : {
229 0 : eShellMode = SHELL_MODE_LIST_TEXT;
230 0 : SetShell( new SwWebListShell( *this ));
231 0 : rDispatcher.Push( *GetCurShell() );
232 : }
233 2 : SetShell( new SwWebTextShell(*this));
234 2 : rDispatcher.Push( *GetCurShell() );
235 2 : if ( _nSelectionType & nsSelectionType::SEL_TBL )
236 : {
237 : eShellMode = eShellMode == SHELL_MODE_LIST_TEXT ? SHELL_MODE_TABLE_LIST_TEXT
238 0 : : SHELL_MODE_TABLE_TEXT;
239 0 : SetShell( new SwWebTableShell( *this ));
240 0 : rDispatcher.Push( *GetCurShell() );
241 : }
242 : }
243 2 : ImpSetVerb( _nSelectionType );
244 2 : GetViewImpl()->SetShellMode(eShellMode);
245 :
246 2 : if( !GetDocShell()->IsReadOnly() )
247 : {
248 2 : if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
249 0 : bSetExtInpCntxt = false;
250 :
251 2 : InputContext aCntxt( GetEditWin().GetInputContext() );
252 : aCntxt.SetOptions( bSetExtInpCntxt
253 2 : ? (aCntxt.GetOptions() |
254 : ( INPUTCONTEXT_TEXT |
255 : INPUTCONTEXT_EXTTEXTINPUT ))
256 0 : : (aCntxt.GetOptions() & ~
257 : ( INPUTCONTEXT_TEXT |
258 4 : INPUTCONTEXT_EXTTEXTINPUT )) );
259 2 : GetEditWin().SetInputContext( aCntxt );
260 : }
261 :
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 2 : rDispatcher.Flush();
268 :
269 2 : Point aPnt = GetEditWin().GetPointerPosPixel();
270 2 : aPnt = GetEditWin().PixelToLogic(aPnt);
271 2 : GetEditWin().UpdatePointer(aPnt);
272 :
273 2 : if ( bInitFormShell && GetWrtShell().GetDrawView() )
274 4 : GetFormShell()->SetView( PTR_CAST( FmFormView,
275 4 : GetWrtShell().GetDrawView()));
276 :
277 :
278 : }
279 4 : GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
280 :
281 : //Opportune time for the communication with OLE objects?
282 4 : if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
283 0 : GetDocShell()->GetDoc()->PrtOLENotify( sal_False );
284 :
285 : //now the table update
286 4 : if(bUpdateTable)
287 0 : GetWrtShell().UpdateTable();
288 103 : }
289 :
290 :
291 :
292 :
293 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|