LCOV - code coverage report
Current view: top level - sw/source/uibase/shells - drawsh.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 7 286 2.4 %
Date: 2014-11-03 Functions: 5 18 27.8 %
Legend: Lines: hit not hit

          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 <svx/svdview.hxx>
      21             : #include <svx/svdotext.hxx>
      22             : #include <svl/whiter.hxx>
      23             : #include <svx/fontwork.hxx>
      24             : #include <sfx2/docfile.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/extrusionbar.hxx>
      31             : #include <svx/fontworkbar.hxx>
      32             : #include <svx/tbxcustomshapes.hxx>
      33             : #include <uitool.hxx>
      34             : #include <dcontact.hxx>
      35             : #include <textboxhelper.hxx>
      36             : #include <wview.hxx>
      37             : #include <swmodule.hxx>
      38             : #include <swwait.hxx>
      39             : #include <doc.hxx>
      40             : #include <docsh.hxx>
      41             : #include <docstat.hxx>
      42             : #include <IDocumentStatistics.hxx>
      43             : #include <tools/diagnose_ex.h>
      44             : 
      45             : #include <comphelper/processfactory.hxx>
      46             : #include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
      47             : 
      48             : #include <svx/svdoashp.hxx>
      49             : #include <svx/xtable.hxx>
      50             : #include <sfx2/sidebar/EnumContext.hxx>
      51             : #include <svx/svdoole2.hxx>
      52             : #include <sfx2/opengrf.hxx>
      53             : #include <svx/svdograf.hxx>
      54             : #include <svx/svdundo.hxx>
      55             : #include <svx/xbtmpit.hxx>
      56             : 
      57             : #include "swundo.hxx"
      58             : #include "wrtsh.hxx"
      59             : #include "cmdid.h"
      60             : #include "globals.hrc"
      61             : #include "helpid.h"
      62             : #include "popup.hrc"
      63             : #include "shells.hrc"
      64             : #include "drwbassh.hxx"
      65             : #include "drawsh.hxx"
      66             : 
      67             : #define SwDrawShell
      68             : #include <sfx2/msg.hxx>
      69             : #include "swslots.hxx"
      70             : #include "swabstdlg.hxx"
      71             : #include <wordcountdialog.hxx>
      72             : #include "misc.hrc"
      73             : #include <boost/scoped_ptr.hpp>
      74             : 
      75             : using namespace ::com::sun::star;
      76             : using namespace ::com::sun::star::uno;
      77             : 
      78         450 : SFX_IMPL_INTERFACE(SwDrawShell, SwDrawBaseShell, SW_RES(STR_SHELLNAME_DRAW))
      79             : 
      80          90 : void SwDrawShell::InitInterface_Impl()
      81             : {
      82          90 :     GetStaticInterface()->RegisterPopupMenu(SW_RES(MN_DRAW_POPUPMENU));
      83             : 
      84          90 :     GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TOOLBOX));
      85             : 
      86          90 :     GetStaticInterface()->RegisterChildWindow(SvxFontWorkChildWindow::GetChildWindowId());
      87          90 : }
      88             : 
      89           0 : TYPEINIT1(SwDrawShell,SwDrawBaseShell)
      90             : 
      91             : // #i123922# check as the name implies
      92           0 : SdrObject* SwDrawShell::IsSingleFillableNonOLESelected()
      93             : {
      94           0 :     SwWrtShell &rSh = GetShell();
      95           0 :     SdrView* pSdrView = rSh.GetDrawView();
      96             : 
      97           0 :     if(!pSdrView)
      98             :     {
      99           0 :         return 0;
     100             :     }
     101             : 
     102           0 :     if(1 != pSdrView->GetMarkedObjectCount())
     103             :     {
     104           0 :         return 0;
     105             :     }
     106             : 
     107           0 :     SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
     108             : 
     109           0 :     if(!pPickObj)
     110             :     {
     111           0 :         return 0;
     112             :     }
     113             : 
     114           0 :     if(!pPickObj->IsClosedObj())
     115             :     {
     116           0 :         return 0;
     117             :     }
     118             : 
     119           0 :     if(dynamic_cast< SdrOle2Obj* >(pPickObj))
     120             :     {
     121           0 :         return 0;
     122             :     }
     123             : 
     124           0 :     return pPickObj;
     125             : }
     126             : 
     127             : // #i123922# insert given graphic data dependent of the object type in focus
     128           0 : void SwDrawShell::InsertPictureFromFile(SdrObject& rObject)
     129             : {
     130           0 :     SwWrtShell &rSh = GetShell();
     131           0 :     SdrView* pSdrView = rSh.GetDrawView();
     132             : 
     133           0 :     if(pSdrView)
     134             :     {
     135           0 :         SvxOpenGraphicDialog aDlg(SW_RESSTR(STR_INSERT_GRAPHIC));
     136             : 
     137           0 :         if(GRFILTER_OK == aDlg.Execute())
     138             :         {
     139           0 :             Graphic aGraphic;
     140           0 :             int nError(aDlg.GetGraphic(aGraphic));
     141             : 
     142           0 :             if(GRFILTER_OK == nError)
     143             :             {
     144           0 :                 const bool bAsLink(aDlg.IsAsLink());
     145           0 :                 SdrObject* pResult = &rObject;
     146             : 
     147           0 :                 rSh.StartUndo(UNDO_PASTE_CLIPBOARD);
     148             : 
     149           0 :                 if(dynamic_cast< SdrGrafObj* >(&rObject))
     150             :                 {
     151           0 :                     SdrGrafObj* pNewGrafObj = (SdrGrafObj*)rObject.Clone();
     152             : 
     153           0 :                     pNewGrafObj->SetGraphic(aGraphic);
     154             : 
     155             :                     // #i123922#  for handling MasterObject and virtual ones correctly, SW
     156             :                     // wants us to call ReplaceObject at the page, but that also
     157             :                     // triggers the same assertion (I tried it), so stay at the view method
     158           0 :                     pSdrView->ReplaceObjectAtView(&rObject, *pSdrView->GetSdrPageView(), pNewGrafObj);
     159             : 
     160           0 :                     OUString aReferer;
     161           0 :                     SwDocShell *pDocShell = rSh.GetDoc()->GetDocShell();
     162           0 :                     if (pDocShell->HasName()) {
     163           0 :                         aReferer = pDocShell->GetMedium()->GetName();
     164             :                     }
     165             : 
     166             :                     // set in all cases - the Clone() will have copied an existing link (!)
     167             :                     pNewGrafObj->SetGraphicLink(
     168             :                         bAsLink ? aDlg.GetPath() : OUString(),
     169             :                         aReferer,
     170           0 :                         bAsLink ? aDlg.GetCurrentFilter() : OUString());
     171             : 
     172           0 :                     pResult = pNewGrafObj;
     173             :                 }
     174             :                 else // if(rObject.IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(&rObject))
     175             :                 {
     176           0 :                     pSdrView->AddUndo(new SdrUndoAttrObj(rObject));
     177             : 
     178           0 :                     SfxItemSet aSet(pSdrView->GetModel()->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP);
     179             : 
     180           0 :                     aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP));
     181           0 :                     aSet.Put(XFillBitmapItem(OUString(), aGraphic));
     182           0 :                     rObject.SetMergedItemSetAndBroadcast(aSet);
     183             :                 }
     184             : 
     185           0 :                 rSh.EndUndo( UNDO_END );
     186             : 
     187           0 :                 if(pResult)
     188             :                 {
     189             :                     // we are done; mark the modified/new object
     190           0 :                     pSdrView->MarkObj(pResult, pSdrView->GetSdrPageView());
     191             :                 }
     192           0 :             }
     193           0 :         }
     194             :     }
     195           0 : }
     196             : 
     197           0 : void SwDrawShell::Execute(SfxRequest &rReq)
     198             : {
     199           0 :     SwWrtShell          &rSh = GetShell();
     200           0 :     SdrView             *pSdrView = rSh.GetDrawView();
     201           0 :     const SfxItemSet    *pArgs = rReq.GetArgs();
     202           0 :     SfxBindings         &rBnd  = GetView().GetViewFrame()->GetBindings();
     203           0 :     sal_uInt16               nSlotId = rReq.GetSlot();
     204           0 :     bool                 bChanged = pSdrView->GetModel()->IsChanged();
     205             : 
     206           0 :     pSdrView->GetModel()->SetChanged(false);
     207             : 
     208             :     const SfxPoolItem* pItem;
     209           0 :     if(pArgs)
     210           0 :         pArgs->GetItemState(nSlotId, false, &pItem);
     211             : 
     212           0 :     bool bMirror = true;
     213             : 
     214           0 :     switch (nSlotId)
     215             :     {
     216             :         case SID_OBJECT_ROTATE:
     217           0 :             if (rSh.IsObjSelected() && pSdrView->IsRotateAllowed())
     218             :             {
     219           0 :                 if (GetView().IsDrawRotate())
     220           0 :                     rSh.SetDragMode(SDRDRAG_MOVE);
     221             :                 else
     222           0 :                     rSh.SetDragMode(SDRDRAG_ROTATE);
     223             : 
     224           0 :                 GetView().FlipDrawRotate();
     225             :             }
     226           0 :             break;
     227             : 
     228             :         case SID_BEZIER_EDIT:
     229           0 :             if (GetView().IsDrawRotate())
     230             :             {
     231           0 :                 rSh.SetDragMode(SDRDRAG_MOVE);
     232           0 :                 GetView().FlipDrawRotate();
     233             :             }
     234           0 :             GetView().FlipDrawSelMode();
     235           0 :             pSdrView->SetFrameDragSingles(GetView().IsDrawSelMode());
     236           0 :             GetView().AttrChangedNotify(&rSh); // Shell switch
     237           0 :             break;
     238             : 
     239             :         case SID_OBJECT_HELL:
     240           0 :             if (rSh.IsObjSelected())
     241             :             {
     242           0 :                 rSh.StartUndo( UNDO_START );
     243           0 :                 SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP);
     244           0 :                 rSh.SelectionToHell();
     245           0 :                 rSh.EndUndo( UNDO_END );
     246           0 :                 rBnd.Invalidate(SID_OBJECT_HEAVEN);
     247             :             }
     248           0 :             break;
     249             : 
     250             :         case SID_OBJECT_HEAVEN:
     251           0 :             if (rSh.IsObjSelected())
     252             :             {
     253           0 :                 rSh.StartUndo( UNDO_START );
     254           0 :                 SetWrapMode(FN_FRAME_WRAPTHRU);
     255           0 :                 rSh.SelectionToHeaven();
     256           0 :                 rSh.EndUndo( UNDO_END );
     257           0 :                 rBnd.Invalidate(SID_OBJECT_HELL);
     258             :             }
     259           0 :             break;
     260             : 
     261             :         case FN_TOOL_HIERARCHIE:
     262           0 :             if (rSh.IsObjSelected())
     263             :             {
     264           0 :                 rSh.StartUndo( UNDO_START );
     265           0 :                 if (rSh.GetLayerId() == 0)
     266             :                 {
     267           0 :                     SetWrapMode(FN_FRAME_WRAPTHRU);
     268           0 :                     rSh.SelectionToHeaven();
     269             :                 }
     270             :                 else
     271             :                 {
     272           0 :                     SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP);
     273           0 :                     rSh.SelectionToHell();
     274             :                 }
     275           0 :                 rSh.EndUndo( UNDO_END );
     276           0 :                 rBnd.Invalidate( SID_OBJECT_HELL );
     277           0 :                 rBnd.Invalidate( SID_OBJECT_HEAVEN );
     278             :             }
     279           0 :             break;
     280             : 
     281             :         case SID_FLIP_VERTICAL:
     282           0 :             bMirror = false;
     283             :             /* no break */
     284             :         case SID_FLIP_HORIZONTAL:
     285           0 :             rSh.MirrorSelection( bMirror );
     286           0 :             break;
     287             : 
     288             :         case SID_FONTWORK:
     289             :         {
     290           0 :             FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView()));
     291           0 :             SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
     292           0 :             SfxViewFrame* pVFrame = GetView().GetViewFrame();
     293           0 :             if (pArgs)
     294             :             {
     295           0 :                 pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(),
     296           0 :                     ((const SfxBoolItem&)(pArgs->Get(SID_FONTWORK))).GetValue());
     297             :             }
     298             :             else
     299           0 :                 pVFrame->ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() );
     300           0 :             pVFrame->GetBindings().Invalidate(SID_FONTWORK);
     301             :         }
     302           0 :         break;
     303             :         case FN_FORMAT_FOOTNOTE_DLG:
     304             :         {
     305           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     306             :             OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     307             : 
     308           0 :             boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateSwFootNoteOptionDlg(GetView().GetWindow(), GetView().GetWrtShell()));
     309             :             OSL_ENSURE(pDlg, "Dialog creation failed!");
     310           0 :             pDlg->Execute();
     311           0 :             break;
     312             :         }
     313             :         case FN_NUMBERING_OUTLINE_DLG:
     314             :         {
     315           0 :             SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
     316           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     317             :             OSL_ENSURE(pFact, "Dialog creation failed!");
     318             :             boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
     319           0 :                                                         GetView().GetWindow(), &aTmp, GetView().GetWrtShell()));
     320             :             OSL_ENSURE(pDlg, "Dialog creation failed!");
     321           0 :             pDlg->Execute();
     322           0 :             pDlg.reset();
     323           0 :             rReq.Done();
     324             :         }
     325           0 :         break;
     326             :         case SID_OPEN_XML_FILTERSETTINGS:
     327             :         {
     328             :             try
     329             :             {
     330           0 :                 uno::Reference < ui::dialogs::XExecutableDialog > xDialog = ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
     331           0 :                 xDialog->execute();
     332             :             }
     333           0 :             catch (const uno::Exception&)
     334             :             {
     335             :             }
     336           0 :             rReq.Ignore ();
     337             :         }
     338           0 :         break;
     339             :         case FN_WORDCOUNT_DIALOG:
     340             :         {
     341           0 :             SfxViewFrame* pVFrame = GetView().GetViewFrame();
     342           0 :             if (pVFrame != NULL)
     343             :             {
     344           0 :                 pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
     345           0 :                 Invalidate(rReq.GetSlot());
     346             : 
     347           0 :                 SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
     348           0 :                 if (pWrdCnt)
     349           0 :                     pWrdCnt->UpdateCounts();
     350             :             }
     351             :         }
     352           0 :         break;
     353             :         case SID_EXTRUSION_TOOGLE:
     354             :         case SID_EXTRUSION_TILT_DOWN:
     355             :         case SID_EXTRUSION_TILT_UP:
     356             :         case SID_EXTRUSION_TILT_LEFT:
     357             :         case SID_EXTRUSION_TILT_RIGHT:
     358             :         case SID_EXTRUSION_3D_COLOR:
     359             :         case SID_EXTRUSION_DEPTH:
     360             :         case SID_EXTRUSION_DIRECTION:
     361             :         case SID_EXTRUSION_PROJECTION:
     362             :         case SID_EXTRUSION_LIGHTING_DIRECTION:
     363             :         case SID_EXTRUSION_LIGHTING_INTENSITY:
     364             :         case SID_EXTRUSION_SURFACE:
     365             :         case SID_EXTRUSION_DEPTH_FLOATER:
     366             :         case SID_EXTRUSION_DIRECTION_FLOATER:
     367             :         case SID_EXTRUSION_LIGHTING_FLOATER:
     368             :         case SID_EXTRUSION_SURFACE_FLOATER:
     369             :         case SID_EXTRUSION_DEPTH_DIALOG:
     370           0 :             svx::ExtrusionBar::execute( pSdrView, rReq, rBnd );
     371           0 :             rReq.Ignore ();
     372           0 :             break;
     373             : 
     374             :         case SID_FONTWORK_SHAPE:
     375             :         case SID_FONTWORK_SHAPE_TYPE:
     376             :         case SID_FONTWORK_ALIGNMENT:
     377             :         case SID_FONTWORK_SAME_LETTER_HEIGHTS:
     378             :         case SID_FONTWORK_CHARACTER_SPACING:
     379             :         case SID_FONTWORK_KERN_CHARACTER_PAIRS:
     380             :         case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
     381             :         case SID_FONTWORK_ALIGNMENT_FLOATER:
     382             :         case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
     383           0 :             svx::FontworkBar::execute( pSdrView, rReq, rBnd );
     384           0 :             rReq.Ignore ();
     385           0 :             break;
     386             : 
     387             :         case SID_INSERT_GRAPHIC:
     388             :         {
     389             :             // #i123922# check if we can do something
     390           0 :             SdrObject* pObj = IsSingleFillableNonOLESelected();
     391             : 
     392           0 :             if(pObj)
     393             :             {
     394             :                 // ...and if yes, do something
     395           0 :                 InsertPictureFromFile(*pObj);
     396             :             }
     397             : 
     398           0 :             break;
     399             :         }
     400             : 
     401             :         case FN_ADD_TEXT_BOX:
     402             :         {
     403           0 :             if (SdrObject* pObj = IsSingleFillableNonOLESelected())
     404             :             {
     405           0 :                 SwFrmFmt* pFrmFmt = ::FindFrmFmt(pObj);
     406           0 :                 if (pFrmFmt)
     407           0 :                     SwTextBoxHelper::create(pFrmFmt);
     408             :             }
     409           0 :             break;
     410             :         }
     411             :         case FN_REMOVE_TEXT_BOX:
     412             :         {
     413           0 :             if (SdrObject* pObj = IsSingleFillableNonOLESelected())
     414             :             {
     415           0 :                 SwFrmFmt* pFrmFmt = ::FindFrmFmt(pObj);
     416           0 :                 if (pFrmFmt)
     417           0 :                     SwTextBoxHelper::destroy(pFrmFmt);
     418             :             }
     419           0 :             break;
     420             :         }
     421             :         default:
     422             :             OSL_ENSURE(false, "wrong dispatcher");
     423           0 :             return;
     424             :     }
     425           0 :     if (pSdrView->GetModel()->IsChanged())
     426           0 :         rSh.SetModified();
     427           0 :     else if (bChanged)
     428           0 :         pSdrView->GetModel()->SetChanged(true);
     429             : }
     430             : 
     431           0 : void SwDrawShell::GetState(SfxItemSet& rSet)
     432             : {
     433           0 :     SwWrtShell &rSh = GetShell();
     434           0 :     SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
     435           0 :     SfxWhichIter aIter( rSet );
     436           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     437           0 :     bool bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT);
     438             : 
     439           0 :     if (!bProtected)    // Check the parent
     440           0 :         bProtected |= rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
     441             : 
     442           0 :     while( nWhich )
     443             :     {
     444           0 :         switch( nWhich )
     445             :         {
     446             :             case SID_OBJECT_HELL:
     447           0 :                 if ( !rSh.IsObjSelected() || rSh.GetLayerId() == 0 || bProtected )
     448           0 :                     rSet.DisableItem( nWhich );
     449           0 :                 break;
     450             : 
     451             :             case SID_OBJECT_HEAVEN:
     452           0 :                 if ( !rSh.IsObjSelected() || rSh.GetLayerId() == 1 || bProtected )
     453           0 :                     rSet.DisableItem( nWhich );
     454           0 :                 break;
     455             : 
     456             :             case FN_TOOL_HIERARCHIE:
     457           0 :                 if ( !rSh.IsObjSelected() || bProtected )
     458           0 :                     rSet.DisableItem( nWhich );
     459           0 :                 break;
     460             : 
     461             :             case SID_OBJECT_ROTATE:
     462             :             {
     463           0 :                 const bool bIsRotate = GetView().IsDrawRotate();
     464           0 :                 if ( (!bIsRotate && !pSdrView->IsRotateAllowed()) || bProtected )
     465           0 :                     rSet.DisableItem( nWhich );
     466             :                 else
     467           0 :                     rSet.Put( SfxBoolItem( nWhich, bIsRotate ) );
     468             :             }
     469           0 :             break;
     470             : 
     471             :             case SID_BEZIER_EDIT:
     472           0 :                 if (!Disable(rSet, nWhich))
     473           0 :                     rSet.Put( SfxBoolItem( nWhich, !GetView().IsDrawSelMode()));
     474           0 :             break;
     475             : 
     476             :             case SID_FLIP_VERTICAL:
     477           0 :                 if ( !pSdrView->IsMirrorAllowed() || bProtected )
     478             :                 {
     479           0 :                     rSet.DisableItem( nWhich );
     480             :                 }
     481             :                 else
     482             :                 {
     483             :                     // TTTT - needs to be adapted in aw080:
     484             :                     // state is not kept for drawing objects --> provide not flipped state
     485           0 :                     rSet.Put( SfxBoolItem( nWhich, false ) );
     486             :                 }
     487           0 :                 break;
     488             : 
     489             :             case SID_FLIP_HORIZONTAL:
     490           0 :                 if ( !pSdrView->IsMirrorAllowed() || bProtected )
     491             :                 {
     492           0 :                     rSet.DisableItem( nWhich );
     493             :                 }
     494             :                 else
     495             :                 {
     496             :                     // TTTT - needs to be adapted in aw080:
     497             :                     // state is not kept for drawing objects --> provide not flipped state
     498           0 :                     rSet.Put( SfxBoolItem( nWhich, false ) );
     499             :                 }
     500           0 :                 break;
     501             : 
     502             :             case SID_FONTWORK:
     503             :             {
     504           0 :                 if (bProtected)
     505           0 :                     rSet.DisableItem( nWhich );
     506             :                 else
     507             :                 {
     508           0 :                     const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
     509           0 :                     rSet.Put(SfxBoolItem( nWhich , GetView().GetViewFrame()->HasChildWindow(nId)));
     510             :                 }
     511             :             }
     512           0 :             break;
     513             : 
     514             :             case SID_INSERT_GRAPHIC:
     515             :             {
     516             :                 // #i123922# check if we can do something
     517           0 :                 SdrObject* pObj = IsSingleFillableNonOLESelected();
     518             : 
     519           0 :                 if(!pObj)
     520             :                 {
     521           0 :                     rSet.DisableItem(nWhich);
     522             :                 }
     523             : 
     524           0 :                 break;
     525             :             }
     526             :             case FN_ADD_TEXT_BOX:
     527             :             {
     528           0 :                 bool bDisable = true;
     529           0 :                 if (SdrObject* pObj = IsSingleFillableNonOLESelected())
     530             :                 {
     531           0 :                     SwFrmFmt* pFrmFmt = ::FindFrmFmt(pObj);
     532             :                     // Allow creating a TextBox only in case this is a draw format without a TextBox so far.
     533           0 :                     if (pFrmFmt && pFrmFmt->Which() == RES_DRAWFRMFMT && !SwTextBoxHelper::findTextBox(pFrmFmt))
     534           0 :                         bDisable = false;
     535             :                 }
     536             : 
     537           0 :                 if (bDisable)
     538           0 :                     rSet.DisableItem(nWhich);
     539           0 :                 break;
     540             :             }
     541             :             case FN_REMOVE_TEXT_BOX:
     542             :             {
     543           0 :                 bool bDisable = true;
     544           0 :                 if (SdrObject* pObj = IsSingleFillableNonOLESelected())
     545             :                 {
     546           0 :                     SwFrmFmt* pFrmFmt = ::FindFrmFmt(pObj);
     547             :                     // Allow removing a TextBox only in case it has one.
     548           0 :                     if (pFrmFmt && SwTextBoxHelper::findTextBox(pFrmFmt))
     549           0 :                         bDisable = false;
     550             :                 }
     551             : 
     552           0 :                 if (bDisable)
     553           0 :                     rSet.DisableItem(nWhich);
     554           0 :                 break;
     555             :             }
     556             :         }
     557           0 :         nWhich = aIter.NextWhich();
     558             :     }
     559           0 :     svx::ExtrusionBar::getState( pSdrView, rSet );
     560           0 :     svx::FontworkBar::getState( pSdrView, rSet );
     561           0 : }
     562             : 
     563           0 : SwDrawShell::SwDrawShell(SwView &_rView) :
     564           0 :     SwDrawBaseShell(_rView)
     565             : {
     566           0 :     SetHelpId(SW_DRAWSHELL);
     567           0 :     SetName(OUString("Draw"));
     568             : 
     569           0 :     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Draw));
     570           0 : }
     571             : 
     572             : // Edit SfxRequests for FontWork
     573             : 
     574           0 : void SwDrawShell::ExecFormText(SfxRequest& rReq)
     575             : {
     576           0 :     SwWrtShell &rSh = GetShell();
     577           0 :     SdrView*    pDrView = rSh.GetDrawView();
     578           0 :     bool        bChanged = pDrView->GetModel()->IsChanged();
     579           0 :     pDrView->GetModel()->SetChanged(false);
     580             : 
     581           0 :     const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     582             : 
     583           0 :     if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
     584             :     {
     585           0 :         const SfxItemSet& rSet = *rReq.GetArgs();
     586             : 
     587           0 :         if ( pDrView->IsTextEdit() )
     588             :         {
     589           0 :             pDrView->SdrEndTextEdit( true );
     590           0 :             GetView().AttrChangedNotify(&rSh);
     591             :         }
     592             : 
     593           0 :         pDrView->SetAttributes(rSet);
     594             :     }
     595           0 :     if (pDrView->GetModel()->IsChanged())
     596           0 :         rSh.SetModified();
     597             :     else
     598           0 :         if (bChanged)
     599           0 :             pDrView->GetModel()->SetChanged(true);
     600           0 : }
     601             : 
     602             : //Return status values for FontWork
     603             : 
     604           0 : void SwDrawShell::GetFormTextState(SfxItemSet& rSet)
     605             : {
     606           0 :     SwWrtShell &rSh = GetShell();
     607           0 :     SdrView* pDrView = rSh.GetDrawView();
     608           0 :     const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     609           0 :     const SdrObject* pObj = NULL;
     610           0 :     SvxFontWorkDialog* pDlg = NULL;
     611             : 
     612           0 :     const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
     613             : 
     614           0 :     SfxViewFrame* pVFrame = GetView().GetViewFrame();
     615           0 :     if ( pVFrame->HasChildWindow(nId) )
     616           0 :         pDlg = (SvxFontWorkDialog*)(pVFrame->GetChildWindow(nId)->GetWindow());
     617             : 
     618           0 :     if ( rMarkList.GetMarkCount() == 1 )
     619           0 :         pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     620             : 
     621           0 :     const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
     622             :     const bool bDeactivate(
     623           0 :         !pObj ||
     624           0 :         !pTextObj ||
     625           0 :         !pTextObj->HasText() ||
     626           0 :         dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
     627             : 
     628           0 :     if(bDeactivate)
     629             :     {
     630           0 :         rSet.DisableItem(XATTR_FORMTXTSTYLE);
     631           0 :         rSet.DisableItem(XATTR_FORMTXTADJUST);
     632           0 :         rSet.DisableItem(XATTR_FORMTXTDISTANCE);
     633           0 :         rSet.DisableItem(XATTR_FORMTXTSTART);
     634           0 :         rSet.DisableItem(XATTR_FORMTXTMIRROR);
     635           0 :         rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
     636           0 :         rSet.DisableItem(XATTR_FORMTXTOUTLINE);
     637           0 :         rSet.DisableItem(XATTR_FORMTXTSHADOW);
     638           0 :         rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
     639           0 :         rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
     640           0 :         rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
     641             :     }
     642             :     else
     643             :     {
     644           0 :         if ( pDlg )
     645           0 :             pDlg->SetColorList(XColorList::GetStdColorList());
     646             : 
     647           0 :         pDrView->GetAttributes( rSet );
     648             :     }
     649         270 : }
     650             : 
     651             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10