xref: /trunk/main/sw/source/ui/shells/drawsh.cxx (revision 870262e3)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <tools/shl.hxx>
29cdf0e10cSrcweir #include <svx/svdview.hxx>
30cdf0e10cSrcweir #include <svx/svdotext.hxx>
31cdf0e10cSrcweir #include <svl/whiter.hxx>
32cdf0e10cSrcweir #include <svx/fontwork.hxx>
33cdf0e10cSrcweir #include <sfx2/request.hxx>
34cdf0e10cSrcweir #include <sfx2/bindings.hxx>
35cdf0e10cSrcweir #include <sfx2/objface.hxx>
36cdf0e10cSrcweir #include <svl/itemiter.hxx>
37cdf0e10cSrcweir #include <svl/srchitem.hxx>
38cdf0e10cSrcweir #include <svx/extrusionbar.hxx>
39cdf0e10cSrcweir #include <svx/fontworkbar.hxx>
40cdf0e10cSrcweir #include <svx/tbxcustomshapes.hxx>
41cdf0e10cSrcweir #include <uitool.hxx>
42cdf0e10cSrcweir #include <wview.hxx>
43cdf0e10cSrcweir #include <swmodule.hxx>
44cdf0e10cSrcweir #include <swwait.hxx>
45cdf0e10cSrcweir #include <docstat.hxx>
46cdf0e10cSrcweir #include <IDocumentStatistics.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
49cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include <svx/xtable.hxx>
52f120fe41SAndre Fischer #include <sfx2/sidebar/EnumContext.hxx>
53ef076a15SArmin Le Grand #include <svx/svdoashp.hxx>
5452f1c2eeSArmin Le Grand #include <svx/svdoole2.hxx>
5552f1c2eeSArmin Le Grand #include <sfx2/opengrf.hxx>
5652f1c2eeSArmin Le Grand #include <svx/svdograf.hxx>
5752f1c2eeSArmin Le Grand #include <svx/svdundo.hxx>
5852f1c2eeSArmin Le Grand #include <svx/xbtmpit.hxx>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #include "swundo.hxx"
61cdf0e10cSrcweir #include "wrtsh.hxx"
62cdf0e10cSrcweir #include "cmdid.h"
63cdf0e10cSrcweir #include "globals.hrc"
64cdf0e10cSrcweir #include "helpid.h"
65cdf0e10cSrcweir #include "popup.hrc"
66cdf0e10cSrcweir #include "shells.hrc"
67cdf0e10cSrcweir #include "drwbassh.hxx"
68cdf0e10cSrcweir #include "drawsh.hxx"
69cdf0e10cSrcweir 
70cdf0e10cSrcweir #define SwDrawShell
71cdf0e10cSrcweir #include <sfx2/msg.hxx>
72cdf0e10cSrcweir #include "swslots.hxx"
73cdf0e10cSrcweir #include "swabstdlg.hxx" //CHINA001
74cdf0e10cSrcweir #include "misc.hrc"
75cdf0e10cSrcweir 
76cdf0e10cSrcweir using namespace ::com::sun::star;
77cdf0e10cSrcweir using namespace ::com::sun::star::uno;
78cdf0e10cSrcweir 
SFX_IMPL_INTERFACE(SwDrawShell,SwDrawBaseShell,SW_RES (STR_SHELLNAME_DRAW))79cdf0e10cSrcweir SFX_IMPL_INTERFACE(SwDrawShell, SwDrawBaseShell, SW_RES(STR_SHELLNAME_DRAW))
80cdf0e10cSrcweir {
81cdf0e10cSrcweir 	SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRAW_POPUPMENU));
82cdf0e10cSrcweir 	SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TOOLBOX));
83cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(SvxFontWorkChildWindow::GetChildWindowId());
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
TYPEINIT1(SwDrawShell,SwDrawBaseShell)86cdf0e10cSrcweir TYPEINIT1(SwDrawShell,SwDrawBaseShell)
87cdf0e10cSrcweir 
88cdf0e10cSrcweir /*--------------------------------------------------------------------
89cdf0e10cSrcweir 	Beschreibung:
90cdf0e10cSrcweir  --------------------------------------------------------------------*/
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 
9352f1c2eeSArmin Le Grand // #123922# check as the name implies
9452f1c2eeSArmin Le Grand SdrObject* SwDrawShell::IsSingleFillableNonOLESelected()
9552f1c2eeSArmin Le Grand {
9652f1c2eeSArmin Le Grand     SwWrtShell &rSh = GetShell();
9752f1c2eeSArmin Le Grand     SdrView* pSdrView = rSh.GetDrawView();
9852f1c2eeSArmin Le Grand 
9952f1c2eeSArmin Le Grand     if(!pSdrView)
10052f1c2eeSArmin Le Grand     {
10152f1c2eeSArmin Le Grand         return 0;
10252f1c2eeSArmin Le Grand     }
10352f1c2eeSArmin Le Grand 
10452f1c2eeSArmin Le Grand     if(1 != pSdrView->GetMarkedObjectCount())
10552f1c2eeSArmin Le Grand     {
10652f1c2eeSArmin Le Grand         return 0;
10752f1c2eeSArmin Le Grand     }
10852f1c2eeSArmin Le Grand 
10952f1c2eeSArmin Le Grand     SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
11052f1c2eeSArmin Le Grand 
11152f1c2eeSArmin Le Grand     if(!pPickObj)
11252f1c2eeSArmin Le Grand     {
11352f1c2eeSArmin Le Grand         return 0;
11452f1c2eeSArmin Le Grand     }
11552f1c2eeSArmin Le Grand 
11652f1c2eeSArmin Le Grand     if(!pPickObj->IsClosedObj())
11752f1c2eeSArmin Le Grand     {
11852f1c2eeSArmin Le Grand         return 0;
11952f1c2eeSArmin Le Grand     }
12052f1c2eeSArmin Le Grand 
12152f1c2eeSArmin Le Grand     if(dynamic_cast< SdrOle2Obj* >(pPickObj))
12252f1c2eeSArmin Le Grand     {
12352f1c2eeSArmin Le Grand         return 0;
12452f1c2eeSArmin Le Grand     }
12552f1c2eeSArmin Le Grand 
12652f1c2eeSArmin Le Grand     return pPickObj;
12752f1c2eeSArmin Le Grand }
12852f1c2eeSArmin Le Grand 
12952f1c2eeSArmin Le Grand // #123922# insert given graphic data dependent of the object type in focus
InsertPictureFromFile(SdrObject & rObject)13052f1c2eeSArmin Le Grand void SwDrawShell::InsertPictureFromFile(SdrObject& rObject)
13152f1c2eeSArmin Le Grand {
13252f1c2eeSArmin Le Grand     SwWrtShell &rSh = GetShell();
13352f1c2eeSArmin Le Grand     SdrView* pSdrView = rSh.GetDrawView();
13452f1c2eeSArmin Le Grand 
13552f1c2eeSArmin Le Grand     if(pSdrView)
13652f1c2eeSArmin Le Grand     {
13752f1c2eeSArmin Le Grand         SvxOpenGraphicDialog aDlg(SW_RESSTR(STR_INSERT_GRAPHIC));
13852f1c2eeSArmin Le Grand 
13952f1c2eeSArmin Le Grand         if(GRFILTER_OK == aDlg.Execute())
14052f1c2eeSArmin Le Grand         {
14152f1c2eeSArmin Le Grand             Graphic aGraphic;
14252f1c2eeSArmin Le Grand             int nError(aDlg.GetGraphic(aGraphic));
14352f1c2eeSArmin Le Grand 
14452f1c2eeSArmin Le Grand             if(GRFILTER_OK == nError)
14552f1c2eeSArmin Le Grand             {
14652f1c2eeSArmin Le Grand                 const bool bAsLink(aDlg.IsAsLink());
14752f1c2eeSArmin Le Grand                 SdrObject* pResult = &rObject;
14852f1c2eeSArmin Le Grand 
14952f1c2eeSArmin Le Grand                 rSh.StartUndo(UNDO_PASTE_CLIPBOARD);
15052f1c2eeSArmin Le Grand 
15152f1c2eeSArmin Le Grand                 if(dynamic_cast< SdrGrafObj* >(&rObject))
15252f1c2eeSArmin Le Grand                 {
15352f1c2eeSArmin Le Grand                     SdrGrafObj* pNewGrafObj = (SdrGrafObj*)rObject.Clone();
15452f1c2eeSArmin Le Grand 
15552f1c2eeSArmin Le Grand                     pNewGrafObj->SetGraphic(aGraphic);
15652f1c2eeSArmin Le Grand 
15752f1c2eeSArmin Le Grand                     // #123922#  for handling MasterObject and virtual ones correctly, SW
15852f1c2eeSArmin Le Grand                     // wants us to call ReplaceObject at the page, but that also
15952f1c2eeSArmin Le Grand                     // triggers the same assertion (I tried it), so stay at the view method
16052f1c2eeSArmin Le Grand                     pSdrView->ReplaceObjectAtView(&rObject, *pSdrView->GetSdrPageView(), pNewGrafObj);
16152f1c2eeSArmin Le Grand 
16252f1c2eeSArmin Le Grand                     // set in all cases - the Clone() will have copied an existing link (!)
16352f1c2eeSArmin Le Grand                     pNewGrafObj->SetGraphicLink(
16452f1c2eeSArmin Le Grand                         bAsLink ? aDlg.GetPath() : String(),
16552f1c2eeSArmin Le Grand                         bAsLink ? aDlg.GetCurrentFilter() : String());
16652f1c2eeSArmin Le Grand 
16752f1c2eeSArmin Le Grand                     pResult = pNewGrafObj;
16852f1c2eeSArmin Le Grand                 }
16952f1c2eeSArmin Le Grand                 else // if(rObject.IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(&rObject))
17052f1c2eeSArmin Le Grand                 {
17152f1c2eeSArmin Le Grand                     pSdrView->AddUndo(new SdrUndoAttrObj(rObject));
17252f1c2eeSArmin Le Grand 
17352f1c2eeSArmin Le Grand                     SfxItemSet aSet(pSdrView->GetModel()->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP);
17452f1c2eeSArmin Le Grand 
17552f1c2eeSArmin Le Grand                     aSet.Put(XFillStyleItem(XFILL_BITMAP));
17652f1c2eeSArmin Le Grand                     aSet.Put(XFillBitmapItem(String(), aGraphic));
17752f1c2eeSArmin Le Grand                     rObject.SetMergedItemSetAndBroadcast(aSet);
17852f1c2eeSArmin Le Grand                 }
17952f1c2eeSArmin Le Grand 
18052f1c2eeSArmin Le Grand                 rSh.EndUndo( UNDO_END );
18152f1c2eeSArmin Le Grand 
18252f1c2eeSArmin Le Grand                 if(pResult)
18352f1c2eeSArmin Le Grand                 {
18452f1c2eeSArmin Le Grand                     // we are done; mark the modified/new object
18552f1c2eeSArmin Le Grand                     pSdrView->MarkObj(pResult, pSdrView->GetSdrPageView());
18652f1c2eeSArmin Le Grand                 }
18752f1c2eeSArmin Le Grand             }
18852f1c2eeSArmin Le Grand         }
18952f1c2eeSArmin Le Grand     }
19052f1c2eeSArmin Le Grand }
19152f1c2eeSArmin Le Grand 
Execute(SfxRequest & rReq)192cdf0e10cSrcweir void SwDrawShell::Execute(SfxRequest &rReq)
193cdf0e10cSrcweir {
194cdf0e10cSrcweir 	SwWrtShell			&rSh = GetShell();
195cdf0e10cSrcweir 	SdrView				*pSdrView = rSh.GetDrawView();
196cdf0e10cSrcweir 	const SfxItemSet	*pArgs = rReq.GetArgs();
197cdf0e10cSrcweir 	SfxBindings			&rBnd  = GetView().GetViewFrame()->GetBindings();
198cdf0e10cSrcweir 	sal_uInt16				 nSlotId = rReq.GetSlot();
199cdf0e10cSrcweir 	sal_Bool				 bChanged = pSdrView->GetModel()->IsChanged();
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 	pSdrView->GetModel()->SetChanged(sal_False);
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 	const SfxPoolItem* pItem;
204cdf0e10cSrcweir 	if(pArgs)
205cdf0e10cSrcweir 		pArgs->GetItemState(nSlotId, sal_False, &pItem);
206cdf0e10cSrcweir 
207cdf0e10cSrcweir     sal_Bool bMirror = sal_True;
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 	switch (nSlotId)
210cdf0e10cSrcweir 	{
211cdf0e10cSrcweir 		case SID_OBJECT_ROTATE:
212cdf0e10cSrcweir 			if (rSh.IsObjSelected() && pSdrView->IsRotateAllowed())
213cdf0e10cSrcweir 			{
214cdf0e10cSrcweir 				if (GetView().IsDrawRotate())
215cdf0e10cSrcweir 					rSh.SetDragMode(SDRDRAG_MOVE);
216cdf0e10cSrcweir 				else
217cdf0e10cSrcweir 					rSh.SetDragMode(SDRDRAG_ROTATE);
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 				GetView().FlipDrawRotate();
220cdf0e10cSrcweir 			}
221cdf0e10cSrcweir 			break;
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 		case SID_BEZIER_EDIT:
224cdf0e10cSrcweir 			if (GetView().IsDrawRotate())
225cdf0e10cSrcweir 			{
226cdf0e10cSrcweir 				rSh.SetDragMode(SDRDRAG_MOVE);
227cdf0e10cSrcweir 				GetView().FlipDrawRotate();
228cdf0e10cSrcweir 			}
229cdf0e10cSrcweir 			GetView().FlipDrawSelMode();
230cdf0e10cSrcweir 			pSdrView->SetFrameDragSingles(GetView().IsDrawSelMode());
231cdf0e10cSrcweir 			GetView().AttrChangedNotify(&rSh); // Shellwechsel...
232cdf0e10cSrcweir 			break;
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 		case SID_OBJECT_HELL:
235cdf0e10cSrcweir 			if (rSh.IsObjSelected())
236cdf0e10cSrcweir 			{
237cdf0e10cSrcweir 				rSh.StartUndo( UNDO_START );
238cdf0e10cSrcweir 				SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP);
239cdf0e10cSrcweir 				rSh.SelectionToHell();
240cdf0e10cSrcweir 				rSh.EndUndo( UNDO_END );
241cdf0e10cSrcweir 				rBnd.Invalidate(SID_OBJECT_HEAVEN);
242cdf0e10cSrcweir 			}
243cdf0e10cSrcweir 			break;
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 		case SID_OBJECT_HEAVEN:
246cdf0e10cSrcweir 			if (rSh.IsObjSelected())
247cdf0e10cSrcweir 			{
248cdf0e10cSrcweir 				rSh.StartUndo( UNDO_START );
249cdf0e10cSrcweir 				SetWrapMode(FN_FRAME_WRAPTHRU);
250cdf0e10cSrcweir 				rSh.SelectionToHeaven();
251cdf0e10cSrcweir 				rSh.EndUndo( UNDO_END );
252cdf0e10cSrcweir 				rBnd.Invalidate(SID_OBJECT_HELL);
253cdf0e10cSrcweir 			}
254cdf0e10cSrcweir 			break;
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 		case FN_TOOL_HIERARCHIE:
257cdf0e10cSrcweir 			if (rSh.IsObjSelected())
258cdf0e10cSrcweir 			{
259cdf0e10cSrcweir 				rSh.StartUndo( UNDO_START );
260cdf0e10cSrcweir 				if (rSh.GetLayerId() == 0)
261cdf0e10cSrcweir 				{
262cdf0e10cSrcweir 					SetWrapMode(FN_FRAME_WRAPTHRU);
263cdf0e10cSrcweir 					rSh.SelectionToHeaven();
264cdf0e10cSrcweir 				}
265cdf0e10cSrcweir 				else
266cdf0e10cSrcweir 				{
267cdf0e10cSrcweir 					SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP);
268cdf0e10cSrcweir 					rSh.SelectionToHell();
269cdf0e10cSrcweir 				}
270cdf0e10cSrcweir 				rSh.EndUndo( UNDO_END );
271cdf0e10cSrcweir                 rBnd.Invalidate( SID_OBJECT_HELL );
272cdf0e10cSrcweir                 rBnd.Invalidate( SID_OBJECT_HEAVEN );
273cdf0e10cSrcweir 			}
274cdf0e10cSrcweir 			break;
275cdf0e10cSrcweir 
276ee093554SAndre Fischer         case SID_FLIP_VERTICAL:
277261e9a4bSOliver-Rainer Wittmann             bMirror = sal_False;
278261e9a4bSOliver-Rainer Wittmann             /* no break */
279261e9a4bSOliver-Rainer Wittmann         case SID_FLIP_HORIZONTAL:
280261e9a4bSOliver-Rainer Wittmann             rSh.MirrorSelection( bMirror );
281261e9a4bSOliver-Rainer Wittmann             break;
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 		case SID_FONTWORK:
284cdf0e10cSrcweir 		{
285cdf0e10cSrcweir             FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView()));
286cdf0e10cSrcweir             SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
287cdf0e10cSrcweir             SfxViewFrame* pVFrame = GetView().GetViewFrame();
288cdf0e10cSrcweir 			if (pArgs)
289cdf0e10cSrcweir 			{
290cdf0e10cSrcweir 				pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(),
291cdf0e10cSrcweir 					((const SfxBoolItem&)(pArgs->Get(SID_FONTWORK))).GetValue());
292cdf0e10cSrcweir 			}
293cdf0e10cSrcweir 			else
294cdf0e10cSrcweir 				pVFrame->ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() );
295cdf0e10cSrcweir 			pVFrame->GetBindings().Invalidate(SID_FONTWORK);
296cdf0e10cSrcweir 		}
297cdf0e10cSrcweir 		break;
298cdf0e10cSrcweir 		case FN_FORMAT_FOOTNOTE_DLG:
299cdf0e10cSrcweir 		{
300cdf0e10cSrcweir             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
301cdf0e10cSrcweir             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
302cdf0e10cSrcweir 
303cdf0e10cSrcweir             VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), GetView().GetWrtShell(), DLG_DOC_FOOTNOTE );
304cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
305cdf0e10cSrcweir 			pDlg->Execute();
306cdf0e10cSrcweir 			delete pDlg;
307cdf0e10cSrcweir 			break;
308cdf0e10cSrcweir 		}
309cdf0e10cSrcweir 		case FN_NUMBERING_OUTLINE_DLG:
310cdf0e10cSrcweir 		{
311cdf0e10cSrcweir 			SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
312cdf0e10cSrcweir 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
313cdf0e10cSrcweir             DBG_ASSERT(pFact, "Dialogdiet fail!");
314cdf0e10cSrcweir             SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
315cdf0e10cSrcweir 														GetView().GetWindow(), &aTmp, GetView().GetWrtShell());
316cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
317cdf0e10cSrcweir 			pDlg->Execute();
318cdf0e10cSrcweir 			delete pDlg;
319cdf0e10cSrcweir 			rReq.Done();
320cdf0e10cSrcweir 		}
321cdf0e10cSrcweir 		break;
322cdf0e10cSrcweir 		case SID_OPEN_XML_FILTERSETTINGS:
323cdf0e10cSrcweir 		{
324cdf0e10cSrcweir 			try
325cdf0e10cSrcweir 			{
326cdf0e10cSrcweir 				uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY);
327cdf0e10cSrcweir 				if( xDialog.is() )
328cdf0e10cSrcweir 				{
329cdf0e10cSrcweir 					xDialog->execute();
330cdf0e10cSrcweir 				}
331cdf0e10cSrcweir 			}
332cdf0e10cSrcweir 			catch( uno::Exception& )
333cdf0e10cSrcweir 			{
334cdf0e10cSrcweir 			}
335cdf0e10cSrcweir 			rReq.Ignore ();
336cdf0e10cSrcweir 		}
337cdf0e10cSrcweir 		break;
338cdf0e10cSrcweir 		case FN_WORDCOUNT_DIALOG:
339cdf0e10cSrcweir 		{
340cdf0e10cSrcweir 			SwDocStat aCurr;
341cdf0e10cSrcweir 			SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
342cdf0e10cSrcweir 			{
3438ef2f12bSOliver-Rainer Wittmann 				SwWait aWait( *GetView().GetDocShell(), true );
344cdf0e10cSrcweir 				rSh.StartAction();
345cdf0e10cSrcweir 				rSh.CountWords( aCurr );
346cdf0e10cSrcweir 				rSh.UpdateDocStat( aDocStat );
347cdf0e10cSrcweir 				rSh.EndAction();
348cdf0e10cSrcweir 			}
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
351cdf0e10cSrcweir 			DBG_ASSERT(pFact, "Dialogdiet fail!");
352cdf0e10cSrcweir 			AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() );
353cdf0e10cSrcweir 			pDialog->SetValues(aCurr, aDocStat );
354cdf0e10cSrcweir 			pDialog->Execute();
355cdf0e10cSrcweir 			delete pDialog;
356cdf0e10cSrcweir 		}
357cdf0e10cSrcweir 		break;
358cdf0e10cSrcweir 		case SID_EXTRUSION_TOOGLE:
359cdf0e10cSrcweir 		case SID_EXTRUSION_TILT_DOWN:
360cdf0e10cSrcweir 		case SID_EXTRUSION_TILT_UP:
361cdf0e10cSrcweir 		case SID_EXTRUSION_TILT_LEFT:
362cdf0e10cSrcweir 		case SID_EXTRUSION_TILT_RIGHT:
363cdf0e10cSrcweir 		case SID_EXTRUSION_3D_COLOR:
364cdf0e10cSrcweir 		case SID_EXTRUSION_DEPTH:
365cdf0e10cSrcweir 		case SID_EXTRUSION_DIRECTION:
366cdf0e10cSrcweir 		case SID_EXTRUSION_PROJECTION:
367cdf0e10cSrcweir 		case SID_EXTRUSION_LIGHTING_DIRECTION:
368cdf0e10cSrcweir 		case SID_EXTRUSION_LIGHTING_INTENSITY:
369cdf0e10cSrcweir 		case SID_EXTRUSION_SURFACE:
370cdf0e10cSrcweir 		case SID_EXTRUSION_DEPTH_FLOATER:
371cdf0e10cSrcweir 		case SID_EXTRUSION_DIRECTION_FLOATER:
372cdf0e10cSrcweir 		case SID_EXTRUSION_LIGHTING_FLOATER:
373cdf0e10cSrcweir 		case SID_EXTRUSION_SURFACE_FLOATER:
374cdf0e10cSrcweir 		case SID_EXTRUSION_DEPTH_DIALOG:
375cdf0e10cSrcweir 			svx::ExtrusionBar::execute( pSdrView, rReq, rBnd );
376cdf0e10cSrcweir 			rReq.Ignore ();
377cdf0e10cSrcweir 			break;
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 		case SID_FONTWORK_SHAPE:
380cdf0e10cSrcweir 		case SID_FONTWORK_SHAPE_TYPE:
381cdf0e10cSrcweir 		case SID_FONTWORK_ALIGNMENT:
382cdf0e10cSrcweir 		case SID_FONTWORK_SAME_LETTER_HEIGHTS:
383cdf0e10cSrcweir 		case SID_FONTWORK_CHARACTER_SPACING:
384cdf0e10cSrcweir 		case SID_FONTWORK_KERN_CHARACTER_PAIRS:
385cdf0e10cSrcweir 		case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
386cdf0e10cSrcweir 		case SID_FONTWORK_ALIGNMENT_FLOATER:
387cdf0e10cSrcweir 		case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
388cdf0e10cSrcweir 			svx::FontworkBar::execute( pSdrView, rReq, rBnd );
389cdf0e10cSrcweir 			rReq.Ignore ();
390cdf0e10cSrcweir 			break;
391cdf0e10cSrcweir 
39252f1c2eeSArmin Le Grand         case SID_INSERT_GRAPHIC:
39352f1c2eeSArmin Le Grand         {
39452f1c2eeSArmin Le Grand             // #123922# check if we can do something
39552f1c2eeSArmin Le Grand             SdrObject* pObj = IsSingleFillableNonOLESelected();
39652f1c2eeSArmin Le Grand 
39752f1c2eeSArmin Le Grand             if(pObj)
39852f1c2eeSArmin Le Grand             {
39952f1c2eeSArmin Le Grand                 // ...and if yes, do something
40052f1c2eeSArmin Le Grand                 InsertPictureFromFile(*pObj);
40152f1c2eeSArmin Le Grand                 bool bBla = true;
40252f1c2eeSArmin Le Grand             }
40352f1c2eeSArmin Le Grand 
40452f1c2eeSArmin Le Grand             break;
40552f1c2eeSArmin Le Grand         }
40652f1c2eeSArmin Le Grand 
407cdf0e10cSrcweir 		default:
408*870262e3SDon Lewis 			DBG_ASSERT(sal_False, "wrong dispatcher");
409cdf0e10cSrcweir 			return;
410cdf0e10cSrcweir 	}
411cdf0e10cSrcweir 	if (pSdrView->GetModel()->IsChanged())
412cdf0e10cSrcweir 		rSh.SetModified();
413cdf0e10cSrcweir 	else if (bChanged)
414cdf0e10cSrcweir 		pSdrView->GetModel()->SetChanged(sal_True);
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
417cdf0e10cSrcweir /*--------------------------------------------------------------------
418cdf0e10cSrcweir 	Beschreibung:
419cdf0e10cSrcweir  --------------------------------------------------------------------*/
420cdf0e10cSrcweir 
GetState(SfxItemSet & rSet)421cdf0e10cSrcweir void SwDrawShell::GetState(SfxItemSet& rSet)
422cdf0e10cSrcweir {
423cdf0e10cSrcweir 	SwWrtShell &rSh = GetShell();
424cdf0e10cSrcweir 	SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
425cdf0e10cSrcweir 	SfxWhichIter aIter( rSet );
426cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
427cdf0e10cSrcweir 	sal_Bool bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT);
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 	if (!bProtected)	// Im Parent nachsehen
430cdf0e10cSrcweir 		bProtected |= rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 	while( nWhich )
433cdf0e10cSrcweir 	{
434cdf0e10cSrcweir 		switch( nWhich )
435cdf0e10cSrcweir 		{
436cdf0e10cSrcweir 			case SID_OBJECT_HELL:
437cdf0e10cSrcweir 				if ( !rSh.IsObjSelected() || rSh.GetLayerId() == 0 || bProtected )
438cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
439cdf0e10cSrcweir 				break;
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 			case SID_OBJECT_HEAVEN:
442cdf0e10cSrcweir 				if ( !rSh.IsObjSelected() || rSh.GetLayerId() == 1 || bProtected )
443cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
444cdf0e10cSrcweir 				break;
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 			case FN_TOOL_HIERARCHIE:
447cdf0e10cSrcweir 				if ( !rSh.IsObjSelected() || bProtected )
448cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
449cdf0e10cSrcweir 				break;
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 			case SID_OBJECT_ROTATE:
452cdf0e10cSrcweir 			{
453cdf0e10cSrcweir 				const sal_Bool bIsRotate = GetView().IsDrawRotate();
454cdf0e10cSrcweir 				if ( (!bIsRotate && !pSdrView->IsRotateAllowed()) || bProtected )
455cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
456cdf0e10cSrcweir 				else
457cdf0e10cSrcweir 					rSet.Put( SfxBoolItem( nWhich, bIsRotate ) );
458cdf0e10cSrcweir 			}
459cdf0e10cSrcweir 			break;
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 			case SID_BEZIER_EDIT:
462cdf0e10cSrcweir 				if (!Disable(rSet, nWhich))
463cdf0e10cSrcweir 					rSet.Put( SfxBoolItem( nWhich, !GetView().IsDrawSelMode()));
464cdf0e10cSrcweir 			break;
465cdf0e10cSrcweir 
466ee093554SAndre Fischer             case SID_FLIP_VERTICAL:
467261e9a4bSOliver-Rainer Wittmann                 if ( !pSdrView->IsMirrorAllowed() || bProtected )
468261e9a4bSOliver-Rainer Wittmann                 {
469261e9a4bSOliver-Rainer Wittmann                     rSet.DisableItem( nWhich );
470261e9a4bSOliver-Rainer Wittmann                 }
471261e9a4bSOliver-Rainer Wittmann                 else
472261e9a4bSOliver-Rainer Wittmann                 {
473261e9a4bSOliver-Rainer Wittmann                     // TTTT - needs to be adapted in aw080:
474261e9a4bSOliver-Rainer Wittmann                     // state is not kept for drawing objects --> provide not flipped state
475261e9a4bSOliver-Rainer Wittmann                     rSet.Put( SfxBoolItem( nWhich, sal_False ) );
476261e9a4bSOliver-Rainer Wittmann                 }
477261e9a4bSOliver-Rainer Wittmann                 break;
478261e9a4bSOliver-Rainer Wittmann 
479261e9a4bSOliver-Rainer Wittmann             case SID_FLIP_HORIZONTAL:
480261e9a4bSOliver-Rainer Wittmann                 if ( !pSdrView->IsMirrorAllowed() || bProtected )
481261e9a4bSOliver-Rainer Wittmann                 {
482261e9a4bSOliver-Rainer Wittmann                     rSet.DisableItem( nWhich );
483261e9a4bSOliver-Rainer Wittmann                 }
484261e9a4bSOliver-Rainer Wittmann                 else
485261e9a4bSOliver-Rainer Wittmann                 {
486261e9a4bSOliver-Rainer Wittmann                     // TTTT - needs to be adapted in aw080:
487261e9a4bSOliver-Rainer Wittmann                     // state is not kept for drawing objects --> provide not flipped state
488261e9a4bSOliver-Rainer Wittmann                     rSet.Put( SfxBoolItem( nWhich, sal_False ) );
489261e9a4bSOliver-Rainer Wittmann                 }
490261e9a4bSOliver-Rainer Wittmann                 break;
491cdf0e10cSrcweir 
492cdf0e10cSrcweir 			case SID_FONTWORK:
493cdf0e10cSrcweir 			{
494cdf0e10cSrcweir 				if (bProtected)
495cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
496cdf0e10cSrcweir 				else
497cdf0e10cSrcweir 				{
498cdf0e10cSrcweir 					const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
499cdf0e10cSrcweir 					rSet.Put(SfxBoolItem( nWhich , GetView().GetViewFrame()->HasChildWindow(nId)));
500cdf0e10cSrcweir 				}
501cdf0e10cSrcweir 			}
502cdf0e10cSrcweir 			break;
50352f1c2eeSArmin Le Grand 
50452f1c2eeSArmin Le Grand             case SID_INSERT_GRAPHIC:
50552f1c2eeSArmin Le Grand             {
50652f1c2eeSArmin Le Grand                 // #123922# check if we can do something
50752f1c2eeSArmin Le Grand                 SdrObject* pObj = IsSingleFillableNonOLESelected();
50852f1c2eeSArmin Le Grand 
50952f1c2eeSArmin Le Grand                 if(!pObj)
51052f1c2eeSArmin Le Grand                 {
51152f1c2eeSArmin Le Grand                     rSet.DisableItem(nWhich);
51252f1c2eeSArmin Le Grand                 }
51352f1c2eeSArmin Le Grand 
51452f1c2eeSArmin Le Grand                 break;
51552f1c2eeSArmin Le Grand             }
516cdf0e10cSrcweir 		}
517cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
518cdf0e10cSrcweir 	}
519cdf0e10cSrcweir 	svx::ExtrusionBar::getState( pSdrView, rSet );
520cdf0e10cSrcweir 	svx::FontworkBar::getState( pSdrView, rSet );
521cdf0e10cSrcweir }
522cdf0e10cSrcweir 
523cdf0e10cSrcweir /*--------------------------------------------------------------------
524cdf0e10cSrcweir 	Beschreibung:
525cdf0e10cSrcweir  --------------------------------------------------------------------*/
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 
SwDrawShell(SwView & _rView)529cdf0e10cSrcweir SwDrawShell::SwDrawShell(SwView &_rView) :
530cdf0e10cSrcweir     SwDrawBaseShell(_rView)
531cdf0e10cSrcweir {
532cdf0e10cSrcweir 	SetHelpId(SW_DRAWSHELL);
533cdf0e10cSrcweir 	SetName(String::CreateFromAscii("Draw"));
534f120fe41SAndre Fischer 
535f120fe41SAndre Fischer     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Draw));
536cdf0e10cSrcweir }
537cdf0e10cSrcweir 
538cdf0e10cSrcweir /*************************************************************************
539cdf0e10cSrcweir |*
540cdf0e10cSrcweir |* SfxRequests fuer FontWork bearbeiten
541cdf0e10cSrcweir |*
542cdf0e10cSrcweir \************************************************************************/
543cdf0e10cSrcweir 
544cdf0e10cSrcweir 
545cdf0e10cSrcweir 
ExecFormText(SfxRequest & rReq)546cdf0e10cSrcweir void SwDrawShell::ExecFormText(SfxRequest& rReq)
547cdf0e10cSrcweir {
548cdf0e10cSrcweir 	SwWrtShell &rSh = GetShell();
549cdf0e10cSrcweir 	SdrView*	pDrView = rSh.GetDrawView();
550cdf0e10cSrcweir 	sal_Bool		bChanged = pDrView->GetModel()->IsChanged();
551cdf0e10cSrcweir 	pDrView->GetModel()->SetChanged(sal_False);
552cdf0e10cSrcweir 
553cdf0e10cSrcweir 	const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 	if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
556cdf0e10cSrcweir 	{
557cdf0e10cSrcweir 		const SfxItemSet& rSet = *rReq.GetArgs();
558cdf0e10cSrcweir 
559cdf0e10cSrcweir 		if ( pDrView->IsTextEdit() )
560cdf0e10cSrcweir 		{
561cdf0e10cSrcweir 			pDrView->SdrEndTextEdit( sal_True );
562cdf0e10cSrcweir 			GetView().AttrChangedNotify(&rSh);
563cdf0e10cSrcweir 		}
564cdf0e10cSrcweir 
5651e9c32afSArmin Le Grand 		pDrView->SetAttributes(rSet);
566cdf0e10cSrcweir 	}
567cdf0e10cSrcweir 	if (pDrView->GetModel()->IsChanged())
568cdf0e10cSrcweir 		rSh.SetModified();
569cdf0e10cSrcweir 	else
570cdf0e10cSrcweir 		if (bChanged)
571cdf0e10cSrcweir 			pDrView->GetModel()->SetChanged(sal_True);
572cdf0e10cSrcweir }
573cdf0e10cSrcweir 
574cdf0e10cSrcweir /*************************************************************************
575cdf0e10cSrcweir |*
576cdf0e10cSrcweir |* Statuswerte fuer FontWork zurueckgeben
577cdf0e10cSrcweir |*
578cdf0e10cSrcweir \************************************************************************/
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 
GetFormTextState(SfxItemSet & rSet)582cdf0e10cSrcweir void SwDrawShell::GetFormTextState(SfxItemSet& rSet)
583cdf0e10cSrcweir {
584cdf0e10cSrcweir 	SwWrtShell &rSh = GetShell();
585cdf0e10cSrcweir 	SdrView* pDrView = rSh.GetDrawView();
586cdf0e10cSrcweir 	const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
587cdf0e10cSrcweir 	const SdrObject* pObj = NULL;
588cdf0e10cSrcweir 	SvxFontWorkDialog* pDlg = NULL;
589cdf0e10cSrcweir 
590cdf0e10cSrcweir 	const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
591cdf0e10cSrcweir 
592cdf0e10cSrcweir 	SfxViewFrame* pVFrame = GetView().GetViewFrame();
593cdf0e10cSrcweir 	if ( pVFrame->HasChildWindow(nId) )
594cdf0e10cSrcweir 		pDlg = (SvxFontWorkDialog*)(pVFrame->GetChildWindow(nId)->GetWindow());
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 	if ( rMarkList.GetMarkCount() == 1 )
597cdf0e10cSrcweir 		pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
598cdf0e10cSrcweir 
599ef076a15SArmin Le Grand     const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
600ef076a15SArmin Le Grand     const bool bDeactivate(
601ef076a15SArmin Le Grand         !pObj ||
602ef076a15SArmin Le Grand         !pTextObj ||
603ef076a15SArmin Le Grand         !pTextObj->HasText() ||
604ef076a15SArmin Le Grand         dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
605ef076a15SArmin Le Grand 
606ef076a15SArmin Le Grand     if(bDeactivate)
607cdf0e10cSrcweir 	{
608ef076a15SArmin Le Grand         rSet.DisableItem(XATTR_FORMTXTSTYLE);
609ef076a15SArmin Le Grand         rSet.DisableItem(XATTR_FORMTXTADJUST);
610ef076a15SArmin Le Grand         rSet.DisableItem(XATTR_FORMTXTDISTANCE);
611ef076a15SArmin Le Grand         rSet.DisableItem(XATTR_FORMTXTSTART);
612ef076a15SArmin Le Grand         rSet.DisableItem(XATTR_FORMTXTMIRROR);
613ef076a15SArmin Le Grand         rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
614ef076a15SArmin Le Grand         rSet.DisableItem(XATTR_FORMTXTOUTLINE);
615ef076a15SArmin Le Grand         rSet.DisableItem(XATTR_FORMTXTSHADOW);
616ef076a15SArmin Le Grand         rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
617ef076a15SArmin Le Grand         rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
618ef076a15SArmin Le Grand         rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
619cdf0e10cSrcweir 	}
620cdf0e10cSrcweir 	else
621cdf0e10cSrcweir 	{
622cdf0e10cSrcweir 		if ( pDlg )
62397e8a929SArmin Le Grand 			pDlg->SetColorTable(XColorList::GetStdColorList());
624cdf0e10cSrcweir 
625cdf0e10cSrcweir 		pDrView->GetAttributes( rSet );
626cdf0e10cSrcweir 	}
627cdf0e10cSrcweir }
628