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

Generated by: LCOV version 1.10