LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/shells - drawdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 89 1.1 %
Date: 2012-12-27 Functions: 2 5 40.0 %
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/svxids.hrc>
      21             : #include <vcl/msgbox.hxx>
      22             : #include <sfx2/request.hxx>
      23             : #include <sfx2/dispatch.hxx>
      24             : #include <svx/svdview.hxx>
      25             : #include <svx/drawitem.hxx>
      26             : 
      27             : #include <svx/xtable.hxx>
      28             : #include "view.hxx"
      29             : #include "wrtsh.hxx"
      30             : #include "docsh.hxx"
      31             : #include "cmdid.h"
      32             : 
      33             : #include "drawsh.hxx"
      34             : #include <svx/svxdlg.hxx>
      35             : #include <svx/dialogs.hrc>
      36             : 
      37           0 : void SwDrawShell::ExecDrawDlg(SfxRequest& rReq)
      38             : {
      39           0 :     SwWrtShell*     pSh     = &GetShell();
      40           0 :     SdrView*        pView   = pSh->GetDrawView();
      41           0 :     SdrModel*       pDoc    = pView->GetModel();
      42           0 :     sal_Bool            bChanged = pDoc->IsChanged();
      43           0 :     pDoc->SetChanged(sal_False);
      44             : 
      45           0 :     SfxItemSet aNewAttr( pDoc->GetItemPool() );
      46           0 :     pView->GetAttributes( aNewAttr );
      47             : 
      48           0 :     GetView().NoRotate();
      49             : 
      50           0 :     switch (rReq.GetSlot())
      51             :     {
      52             :         case FN_DRAWTEXT_ATTR_DLG:
      53             :         {
      54           0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
      55           0 :             if ( pFact )
      56             :             {
      57           0 :                 SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, pView );
      58           0 :                 sal_uInt16 nResult = pDlg->Execute();
      59             : 
      60           0 :                 if (nResult == RET_OK)
      61             :                 {
      62           0 :                     if (pView->AreObjectsMarked())
      63             :                     {
      64           0 :                         pSh->StartAction();
      65           0 :                         pView->SetAttributes(*pDlg->GetOutputItemSet());
      66           0 :                         rReq.Done(*(pDlg->GetOutputItemSet()));
      67           0 :                         pSh->EndAction();
      68             :                     }
      69             :                 }
      70             : 
      71           0 :                 delete( pDlg );
      72             :             }
      73             :         }
      74           0 :         break;
      75             : 
      76             :         case SID_ATTRIBUTES_AREA:
      77             :         {
      78           0 :             sal_Bool bHasMarked = pView->AreObjectsMarked();
      79             : 
      80           0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
      81             :             AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( NULL,
      82             :                                                                             &aNewAttr,
      83             :                                                                             pDoc,
      84           0 :                                                                             pView);
      85           0 :             if (pDlg->Execute() == RET_OK)
      86             :             {
      87           0 :                 pSh->StartAction();
      88           0 :                 if (bHasMarked)
      89           0 :                     pView->SetAttributes(*pDlg->GetOutputItemSet());
      90             :                 else
      91           0 :                     pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
      92           0 :                 pSh->EndAction();
      93             : 
      94             :                 static sal_uInt16 aInval[] =
      95             :                 {
      96             :                     SID_ATTR_FILL_STYLE, SID_ATTR_FILL_COLOR, 0
      97             :                 };
      98           0 :                 SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
      99           0 :                 rBnd.Invalidate(aInval);
     100           0 :                 rBnd.Update(SID_ATTR_FILL_STYLE);
     101           0 :                 rBnd.Update(SID_ATTR_FILL_COLOR);
     102             :             }
     103           0 :             delete pDlg;
     104             :         }
     105           0 :         break;
     106             : 
     107             :         case SID_ATTRIBUTES_LINE:
     108             :         {
     109           0 :             sal_Bool bHasMarked = pView->AreObjectsMarked();
     110             : 
     111           0 :             const SdrObject* pObj = NULL;
     112           0 :             const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     113           0 :             if( rMarkList.GetMarkCount() == 1 )
     114           0 :                 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     115             : 
     116           0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     117             :             OSL_ENSURE(pFact, "Dialogdiet Factory fail!");
     118             :             SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL,
     119             :                     &aNewAttr,
     120             :                 pDoc,
     121             :                 pObj,
     122           0 :                 bHasMarked);
     123             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
     124           0 :             if (pDlg->Execute() == RET_OK)
     125             :             {
     126           0 :                 pSh->StartAction();
     127           0 :                 if(bHasMarked)
     128           0 :                     pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), sal_False);
     129             :                 else
     130           0 :                     pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
     131           0 :                 pSh->EndAction();
     132             : 
     133             :                 static sal_uInt16 aInval[] =
     134             :                 {
     135             :                     SID_ATTR_LINE_STYLE, SID_ATTR_LINE_WIDTH,
     136             :                     SID_ATTR_LINE_COLOR, 0
     137             :                 };
     138             : 
     139           0 :                 GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
     140             :             }
     141           0 :             delete pDlg;
     142             :         }
     143           0 :         break;
     144             : 
     145             :         default:
     146           0 :             break;
     147             :     }
     148             : 
     149             : 
     150           0 :     if (pDoc->IsChanged())
     151           0 :         GetShell().SetModified();
     152             :     else
     153           0 :         if (bChanged)
     154           0 :             pDoc->SetChanged(sal_True);
     155           0 : }
     156             : 
     157           0 : void SwDrawShell::ExecDrawAttrArgs(SfxRequest& rReq)
     158             : {
     159           0 :     SwWrtShell* pSh   = &GetShell();
     160           0 :     SdrView*    pView = pSh->GetDrawView();
     161           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     162           0 :     sal_Bool        bChanged = pView->GetModel()->IsChanged();
     163           0 :     pView->GetModel()->SetChanged(sal_False);
     164             : 
     165           0 :     GetView().NoRotate();
     166             : 
     167           0 :     if (pArgs)
     168             :     {
     169           0 :         if(pView->AreObjectsMarked())
     170           0 :             pView->SetAttrToMarked(*rReq.GetArgs(), sal_False);
     171             :         else
     172           0 :             pView->SetDefaultAttr(*rReq.GetArgs(), sal_False);
     173             :     }
     174             :     else
     175             :     {
     176           0 :         SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher();
     177           0 :         switch (rReq.GetSlot())
     178             :         {
     179             :             case SID_ATTR_FILL_STYLE:
     180             :             case SID_ATTR_FILL_COLOR:
     181             :             case SID_ATTR_FILL_GRADIENT:
     182             :             case SID_ATTR_FILL_HATCH:
     183             :             case SID_ATTR_FILL_BITMAP:
     184           0 :                 pDis->Execute(SID_ATTRIBUTES_AREA, sal_False);
     185           0 :                 break;
     186             :             case SID_ATTR_LINE_STYLE:
     187             :             case SID_ATTR_LINE_DASH:
     188             :             case SID_ATTR_LINE_WIDTH:
     189             :             case SID_ATTR_LINE_COLOR:
     190           0 :                 pDis->Execute(SID_ATTRIBUTES_LINE, sal_False);
     191           0 :                 break;
     192             :         }
     193             :     }
     194           0 :     if (pView->GetModel()->IsChanged())
     195           0 :         GetShell().SetModified();
     196             :     else
     197           0 :         if (bChanged)
     198           0 :             pView->GetModel()->SetChanged(sal_True);
     199           0 : }
     200             : 
     201           0 : void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet)
     202             : {
     203           0 :     SdrView* pSdrView = GetShell().GetDrawView();
     204             : 
     205           0 :     if (pSdrView->AreObjectsMarked())
     206             :     {
     207           0 :         sal_Bool bDisable = Disable( rSet );
     208             : 
     209           0 :         if( !bDisable )
     210           0 :             pSdrView->GetAttributes( rSet );
     211             :     }
     212             :     else
     213           0 :         rSet.Put(pSdrView->GetDefaultAttr());
     214          30 : }
     215             : 
     216             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10