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

Generated by: LCOV version 1.11