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 <tools/shl.hxx>
21 : #include <svx/svdview.hxx>
22 : #include <svx/svdotext.hxx>
23 : #include <svl/whiter.hxx>
24 : #include <svx/fontwork.hxx>
25 : #include <sfx2/request.hxx>
26 : #include <sfx2/bindings.hxx>
27 : #include <sfx2/objface.hxx>
28 : #include <svl/itemiter.hxx>
29 : #include <svl/srchitem.hxx>
30 : #include <svx/xftsfit.hxx>
31 : #include <svx/extrusionbar.hxx>
32 : #include <svx/fontworkbar.hxx>
33 : #include <svx/tbxcustomshapes.hxx>
34 : #include <uitool.hxx>
35 : #include <wview.hxx>
36 : #include <swmodule.hxx>
37 : #include <swwait.hxx>
38 : #include <docstat.hxx>
39 : #include <IDocumentStatistics.hxx>
40 :
41 : #include <comphelper/processfactory.hxx>
42 : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
43 :
44 : #include <svx/xtable.hxx>
45 :
46 : #include "swundo.hxx"
47 : #include "wrtsh.hxx"
48 : #include "cmdid.h"
49 : #include "globals.hrc"
50 : #include "helpid.h"
51 : #include "popup.hrc"
52 : #include "shells.hrc"
53 : #include "drwbassh.hxx"
54 : #include "drawsh.hxx"
55 :
56 : #define SwDrawShell
57 : #include <sfx2/msg.hxx>
58 : #include "swslots.hxx"
59 : #include "swabstdlg.hxx"
60 : #include <wordcountdialog.hxx>
61 : #include "misc.hrc"
62 :
63 : using namespace ::com::sun::star;
64 : using namespace ::com::sun::star::uno;
65 :
66 60 : SFX_IMPL_INTERFACE(SwDrawShell, SwDrawBaseShell, SW_RES(STR_SHELLNAME_DRAW))
67 : {
68 10 : SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRAW_POPUPMENU));
69 10 : SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TOOLBOX));
70 10 : SFX_CHILDWINDOW_REGISTRATION(SvxFontWorkChildWindow::GetChildWindowId());
71 10 : }
72 :
73 0 : TYPEINIT1(SwDrawShell,SwDrawBaseShell)
74 :
75 0 : void SwDrawShell::Execute(SfxRequest &rReq)
76 : {
77 0 : SwWrtShell &rSh = GetShell();
78 0 : SdrView *pSdrView = rSh.GetDrawView();
79 0 : const SfxItemSet *pArgs = rReq.GetArgs();
80 0 : SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
81 0 : sal_uInt16 nSlotId = rReq.GetSlot();
82 0 : sal_Bool bChanged = pSdrView->GetModel()->IsChanged();
83 :
84 0 : pSdrView->GetModel()->SetChanged(sal_False);
85 :
86 : const SfxPoolItem* pItem;
87 0 : if(pArgs)
88 0 : pArgs->GetItemState(nSlotId, sal_False, &pItem);
89 :
90 0 : sal_Bool bMirror = sal_True;
91 :
92 0 : switch (nSlotId)
93 : {
94 : case SID_OBJECT_ROTATE:
95 0 : if (rSh.IsObjSelected() && pSdrView->IsRotateAllowed())
96 : {
97 0 : if (GetView().IsDrawRotate())
98 0 : rSh.SetDragMode(SDRDRAG_MOVE);
99 : else
100 0 : rSh.SetDragMode(SDRDRAG_ROTATE);
101 :
102 0 : GetView().FlipDrawRotate();
103 : }
104 0 : break;
105 :
106 : case SID_BEZIER_EDIT:
107 0 : if (GetView().IsDrawRotate())
108 : {
109 0 : rSh.SetDragMode(SDRDRAG_MOVE);
110 0 : GetView().FlipDrawRotate();
111 : }
112 0 : GetView().FlipDrawSelMode();
113 0 : pSdrView->SetFrameDragSingles(GetView().IsDrawSelMode());
114 0 : GetView().AttrChangedNotify(&rSh); // Shellwechsel...
115 0 : break;
116 :
117 : case SID_OBJECT_HELL:
118 0 : if (rSh.IsObjSelected())
119 : {
120 0 : rSh.StartUndo( UNDO_START );
121 0 : SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP);
122 0 : rSh.SelectionToHell();
123 0 : rSh.EndUndo( UNDO_END );
124 0 : rBnd.Invalidate(SID_OBJECT_HEAVEN);
125 : }
126 0 : break;
127 :
128 : case SID_OBJECT_HEAVEN:
129 0 : if (rSh.IsObjSelected())
130 : {
131 0 : rSh.StartUndo( UNDO_START );
132 0 : SetWrapMode(FN_FRAME_WRAPTHRU);
133 0 : rSh.SelectionToHeaven();
134 0 : rSh.EndUndo( UNDO_END );
135 0 : rBnd.Invalidate(SID_OBJECT_HELL);
136 : }
137 0 : break;
138 :
139 : case FN_TOOL_HIERARCHIE:
140 0 : if (rSh.IsObjSelected())
141 : {
142 0 : rSh.StartUndo( UNDO_START );
143 0 : if (rSh.GetLayerId() == 0)
144 : {
145 0 : SetWrapMode(FN_FRAME_WRAPTHRU);
146 0 : rSh.SelectionToHeaven();
147 : }
148 : else
149 : {
150 0 : SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP);
151 0 : rSh.SelectionToHell();
152 : }
153 0 : rSh.EndUndo( UNDO_END );
154 0 : rBnd.Invalidate( SID_OBJECT_HELL );
155 0 : rBnd.Invalidate( SID_OBJECT_HEAVEN );
156 : }
157 0 : break;
158 :
159 : case FN_FLIP_HORZ_GRAFIC:
160 0 : bMirror = sal_False;
161 : /* no break */
162 : case FN_FLIP_VERT_GRAFIC:
163 0 : rSh.MirrorSelection( bMirror );
164 0 : break;
165 :
166 : case SID_FONTWORK:
167 : {
168 0 : FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView()));
169 0 : SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
170 0 : SfxViewFrame* pVFrame = GetView().GetViewFrame();
171 0 : if (pArgs)
172 : {
173 0 : pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(),
174 0 : ((const SfxBoolItem&)(pArgs->Get(SID_FONTWORK))).GetValue());
175 : }
176 : else
177 0 : pVFrame->ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() );
178 0 : pVFrame->GetBindings().Invalidate(SID_FONTWORK);
179 : }
180 0 : break;
181 : case FN_FORMAT_FOOTNOTE_DLG:
182 : {
183 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
184 : OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
185 :
186 0 : VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), GetView().GetWrtShell(), DLG_DOC_FOOTNOTE );
187 : OSL_ENSURE(pDlg, "Dialogdiet fail!");
188 0 : pDlg->Execute();
189 0 : delete pDlg;
190 0 : break;
191 : }
192 : case FN_NUMBERING_OUTLINE_DLG:
193 : {
194 0 : SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
195 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
196 : OSL_ENSURE(pFact, "Dialogdiet fail!");
197 : SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
198 0 : GetView().GetWindow(), &aTmp, GetView().GetWrtShell());
199 : OSL_ENSURE(pDlg, "Dialogdiet fail!");
200 0 : pDlg->Execute();
201 0 : delete pDlg;
202 0 : rReq.Done();
203 : }
204 0 : break;
205 : case SID_OPEN_XML_FILTERSETTINGS:
206 : {
207 : try
208 : {
209 0 : uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ui.XSLTFilterDialog"))), uno::UNO_QUERY);
210 0 : if( xDialog.is() )
211 : {
212 0 : xDialog->execute();
213 0 : }
214 : }
215 0 : catch (const uno::Exception&)
216 : {
217 : }
218 0 : rReq.Ignore ();
219 : }
220 0 : break;
221 : case FN_WORDCOUNT_DIALOG:
222 : {
223 0 : SfxViewFrame* pVFrame = GetView().GetViewFrame();
224 0 : if (pVFrame != NULL)
225 : {
226 0 : pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
227 0 : Invalidate(rReq.GetSlot());
228 :
229 0 : SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
230 0 : if (pWrdCnt)
231 0 : pWrdCnt->UpdateCounts();
232 : }
233 : }
234 0 : break;
235 : case SID_EXTRUSION_TOOGLE:
236 : case SID_EXTRUSION_TILT_DOWN:
237 : case SID_EXTRUSION_TILT_UP:
238 : case SID_EXTRUSION_TILT_LEFT:
239 : case SID_EXTRUSION_TILT_RIGHT:
240 : case SID_EXTRUSION_3D_COLOR:
241 : case SID_EXTRUSION_DEPTH:
242 : case SID_EXTRUSION_DIRECTION:
243 : case SID_EXTRUSION_PROJECTION:
244 : case SID_EXTRUSION_LIGHTING_DIRECTION:
245 : case SID_EXTRUSION_LIGHTING_INTENSITY:
246 : case SID_EXTRUSION_SURFACE:
247 : case SID_EXTRUSION_DEPTH_FLOATER:
248 : case SID_EXTRUSION_DIRECTION_FLOATER:
249 : case SID_EXTRUSION_LIGHTING_FLOATER:
250 : case SID_EXTRUSION_SURFACE_FLOATER:
251 : case SID_EXTRUSION_DEPTH_DIALOG:
252 0 : svx::ExtrusionBar::execute( pSdrView, rReq, rBnd );
253 0 : rReq.Ignore ();
254 0 : break;
255 :
256 : case SID_FONTWORK_SHAPE:
257 : case SID_FONTWORK_SHAPE_TYPE:
258 : case SID_FONTWORK_ALIGNMENT:
259 : case SID_FONTWORK_SAME_LETTER_HEIGHTS:
260 : case SID_FONTWORK_CHARACTER_SPACING:
261 : case SID_FONTWORK_KERN_CHARACTER_PAIRS:
262 : case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
263 : case SID_FONTWORK_ALIGNMENT_FLOATER:
264 : case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
265 0 : svx::FontworkBar::execute( pSdrView, rReq, rBnd );
266 0 : rReq.Ignore ();
267 0 : break;
268 :
269 : default:
270 : OSL_ENSURE(!this, "wrong dispatcher");
271 0 : return;
272 : }
273 0 : if (pSdrView->GetModel()->IsChanged())
274 0 : rSh.SetModified();
275 0 : else if (bChanged)
276 0 : pSdrView->GetModel()->SetChanged(sal_True);
277 : }
278 :
279 0 : void SwDrawShell::GetState(SfxItemSet& rSet)
280 : {
281 0 : SwWrtShell &rSh = GetShell();
282 0 : SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
283 0 : SfxWhichIter aIter( rSet );
284 0 : sal_uInt16 nWhich = aIter.FirstWhich();
285 0 : sal_Bool bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT);
286 :
287 0 : if (!bProtected) // Im Parent nachsehen
288 0 : bProtected |= rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
289 :
290 0 : while( nWhich )
291 : {
292 0 : switch( nWhich )
293 : {
294 : case SID_OBJECT_HELL:
295 0 : if ( !rSh.IsObjSelected() || rSh.GetLayerId() == 0 || bProtected )
296 0 : rSet.DisableItem( nWhich );
297 0 : break;
298 :
299 : case SID_OBJECT_HEAVEN:
300 0 : if ( !rSh.IsObjSelected() || rSh.GetLayerId() == 1 || bProtected )
301 0 : rSet.DisableItem( nWhich );
302 0 : break;
303 :
304 : case FN_TOOL_HIERARCHIE:
305 0 : if ( !rSh.IsObjSelected() || bProtected )
306 0 : rSet.DisableItem( nWhich );
307 0 : break;
308 :
309 : case SID_OBJECT_ROTATE:
310 : {
311 0 : const sal_Bool bIsRotate = GetView().IsDrawRotate();
312 0 : if ( (!bIsRotate && !pSdrView->IsRotateAllowed()) || bProtected )
313 0 : rSet.DisableItem( nWhich );
314 : else
315 0 : rSet.Put( SfxBoolItem( nWhich, bIsRotate ) );
316 : }
317 0 : break;
318 :
319 : case SID_BEZIER_EDIT:
320 0 : if (!Disable(rSet, nWhich))
321 0 : rSet.Put( SfxBoolItem( nWhich, !GetView().IsDrawSelMode()));
322 0 : break;
323 :
324 : case FN_FLIP_HORZ_GRAFIC:
325 0 : if ( !pSdrView->IsMirrorAllowed() || bProtected )
326 0 : rSet.DisableItem( nWhich );
327 0 : break;
328 :
329 : case FN_FLIP_VERT_GRAFIC:
330 0 : if ( !pSdrView->IsMirrorAllowed() || bProtected )
331 0 : rSet.DisableItem( nWhich );
332 0 : break;
333 :
334 : case SID_FONTWORK:
335 : {
336 0 : if (bProtected)
337 0 : rSet.DisableItem( nWhich );
338 : else
339 : {
340 0 : const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
341 0 : rSet.Put(SfxBoolItem( nWhich , GetView().GetViewFrame()->HasChildWindow(nId)));
342 : }
343 : }
344 0 : break;
345 : }
346 0 : nWhich = aIter.NextWhich();
347 : }
348 0 : svx::ExtrusionBar::getState( pSdrView, rSet );
349 0 : svx::FontworkBar::getState( pSdrView, rSet );
350 0 : }
351 :
352 0 : SwDrawShell::SwDrawShell(SwView &_rView) :
353 0 : SwDrawBaseShell(_rView)
354 : {
355 0 : SetHelpId(SW_DRAWSHELL);
356 0 : SetName(rtl::OUString("Draw"));
357 0 : }
358 :
359 : /*************************************************************************
360 : |*
361 : |* SfxRequests fuer FontWork bearbeiten
362 : |*
363 : \************************************************************************/
364 0 : void SwDrawShell::ExecFormText(SfxRequest& rReq)
365 : {
366 0 : SwWrtShell &rSh = GetShell();
367 0 : SdrView* pDrView = rSh.GetDrawView();
368 0 : sal_Bool bChanged = pDrView->GetModel()->IsChanged();
369 0 : pDrView->GetModel()->SetChanged(sal_False);
370 :
371 0 : const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
372 :
373 0 : if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
374 : {
375 0 : const SfxItemSet& rSet = *rReq.GetArgs();
376 : const SfxPoolItem* pItem;
377 :
378 0 : if ( pDrView->IsTextEdit() )
379 : {
380 0 : pDrView->SdrEndTextEdit( sal_True );
381 0 : GetView().AttrChangedNotify(&rSh);
382 : }
383 :
384 0 : if ( rSet.GetItemState(XATTR_FORMTXTSTDFORM, sal_True, &pItem) ==
385 : SFX_ITEM_SET &&
386 0 : ((const XFormTextStdFormItem*) pItem)->GetValue() != XFTFORM_NONE )
387 : {
388 :
389 0 : const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
390 :
391 0 : SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)(GetView().GetViewFrame()->
392 0 : GetChildWindow(nId)->GetWindow());
393 :
394 0 : pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(),
395 0 : rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(),
396 : ((const XFormTextStdFormItem*) pItem)->
397 0 : GetValue());
398 :
399 : }
400 : else
401 0 : pDrView->SetAttributes(rSet);
402 : }
403 0 : if (pDrView->GetModel()->IsChanged())
404 0 : rSh.SetModified();
405 : else
406 0 : if (bChanged)
407 0 : pDrView->GetModel()->SetChanged(sal_True);
408 0 : }
409 :
410 : /*************************************************************************
411 : |*
412 : |* Statuswerte fuer FontWork zurueckgeben
413 : |*
414 : \************************************************************************/
415 0 : void SwDrawShell::GetFormTextState(SfxItemSet& rSet)
416 : {
417 0 : SwWrtShell &rSh = GetShell();
418 0 : SdrView* pDrView = rSh.GetDrawView();
419 0 : const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
420 0 : const SdrObject* pObj = NULL;
421 0 : SvxFontWorkDialog* pDlg = NULL;
422 :
423 0 : const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
424 :
425 0 : SfxViewFrame* pVFrame = GetView().GetViewFrame();
426 0 : if ( pVFrame->HasChildWindow(nId) )
427 0 : pDlg = (SvxFontWorkDialog*)(pVFrame->GetChildWindow(nId)->GetWindow());
428 :
429 0 : if ( rMarkList.GetMarkCount() == 1 )
430 0 : pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
431 :
432 0 : if ( pObj == NULL || !pObj->ISA(SdrTextObj) ||
433 0 : !((SdrTextObj*) pObj)->HasText() )
434 : {
435 : #define XATTR_ANZ 12
436 : static const sal_uInt16 nXAttr[ XATTR_ANZ ] =
437 : {
438 : XATTR_FORMTXTSTYLE, XATTR_FORMTXTADJUST, XATTR_FORMTXTDISTANCE,
439 : XATTR_FORMTXTSTART, XATTR_FORMTXTMIRROR, XATTR_FORMTXTSTDFORM,
440 : XATTR_FORMTXTHIDEFORM, XATTR_FORMTXTOUTLINE, XATTR_FORMTXTSHADOW,
441 : XATTR_FORMTXTSHDWCOLOR, XATTR_FORMTXTSHDWXVAL, XATTR_FORMTXTSHDWYVAL
442 : };
443 0 : for( sal_uInt16 i = 0; i < XATTR_ANZ; )
444 0 : rSet.DisableItem( nXAttr[ i++ ] );
445 : }
446 : else
447 : {
448 0 : if ( pDlg )
449 0 : pDlg->SetColorList(XColorList::GetStdColorList());
450 :
451 0 : pDrView->GetAttributes( rSet );
452 : }
453 30 : }
454 :
455 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|