LCOV - code coverage report
Current view: top level - sw/source/uibase/shells - drawdlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 91 1.1 %
Date: 2015-06-13 12:38:46 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             : #include <boost/scoped_ptr.hpp>
      37             : 
      38           0 : void SwDrawShell::ExecDrawDlg(SfxRequest& rReq)
      39             : {
      40           0 :     SwWrtShell*     pSh     = &GetShell();
      41           0 :     SdrView*        pView   = pSh->GetDrawView();
      42           0 :     SdrModel*       pDoc    = pView->GetModel();
      43           0 :     bool            bChanged = pDoc->IsChanged();
      44           0 :     pDoc->SetChanged(false);
      45             : 
      46           0 :     SfxItemSet aNewAttr( pDoc->GetItemPool() );
      47           0 :     pView->GetAttributes( aNewAttr );
      48             : 
      49           0 :     GetView().NoRotate();
      50             : 
      51           0 :     switch (rReq.GetSlot())
      52             :     {
      53             :         case FN_DRAWTEXT_ATTR_DLG:
      54             :         {
      55           0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
      56           0 :             if ( pFact )
      57             :             {
      58           0 :                 boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateTextTabDialog( NULL, &aNewAttr, pView ));
      59           0 :                 sal_uInt16 nResult = pDlg->Execute();
      60             : 
      61           0 :                 if (nResult == RET_OK)
      62             :                 {
      63           0 :                     if (pView->AreObjectsMarked())
      64             :                     {
      65           0 :                         pSh->StartAction();
      66           0 :                         pView->SetAttributes(*pDlg->GetOutputItemSet());
      67           0 :                         rReq.Done(*(pDlg->GetOutputItemSet()));
      68           0 :                         pSh->EndAction();
      69             :                     }
      70           0 :                 }
      71             :             }
      72             :         }
      73           0 :         break;
      74             : 
      75             :         case SID_ATTRIBUTES_AREA:
      76             :         {
      77           0 :             bool bHasMarked = pView->AreObjectsMarked();
      78             : 
      79           0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
      80             :             boost::scoped_ptr<AbstractSvxAreaTabDialog> pDlg(pFact->CreateSvxAreaTabDialog( NULL,
      81             :                                                                             &aNewAttr,
      82             :                                                                             pDoc,
      83           0 :                                                                             true));
      84           0 :             if (pDlg->Execute() == RET_OK)
      85             :             {
      86           0 :                 pSh->StartAction();
      87           0 :                 if (bHasMarked)
      88           0 :                     pView->SetAttributes(*pDlg->GetOutputItemSet());
      89             :                 else
      90           0 :                     pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), false);
      91           0 :                 pSh->EndAction();
      92             : 
      93             :                 static sal_uInt16 aInval[] =
      94             :                 {
      95             :                     SID_ATTR_FILL_STYLE,
      96             :                     SID_ATTR_FILL_COLOR,
      97             :                     SID_ATTR_FILL_TRANSPARENCE,
      98             :                     SID_ATTR_FILL_FLOATTRANSPARENCE,
      99             :                     0
     100             :                 };
     101           0 :                 SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
     102           0 :                 rBnd.Invalidate(aInval);
     103           0 :                 rBnd.Update(SID_ATTR_FILL_STYLE);
     104           0 :                 rBnd.Update(SID_ATTR_FILL_COLOR);
     105           0 :                 rBnd.Update(SID_ATTR_FILL_TRANSPARENCE);
     106           0 :                 rBnd.Update(SID_ATTR_FILL_FLOATTRANSPARENCE);
     107           0 :             }
     108             :         }
     109           0 :         break;
     110             : 
     111             :         case SID_ATTRIBUTES_LINE:
     112             :         {
     113           0 :             bool bHasMarked = pView->AreObjectsMarked();
     114             : 
     115           0 :             const SdrObject* pObj = NULL;
     116           0 :             const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     117           0 :             if( rMarkList.GetMarkCount() == 1 )
     118           0 :                 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     119             : 
     120           0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     121             :             OSL_ENSURE(pFact, "Dialog creation failed!");
     122             :             boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxLineTabDialog( NULL,
     123             :                     &aNewAttr,
     124             :                 pDoc,
     125             :                 pObj,
     126           0 :                 bHasMarked));
     127             :             OSL_ENSURE(pDlg, "Dialog creation failed!");
     128           0 :             if (pDlg->Execute() == RET_OK)
     129             :             {
     130           0 :                 pSh->StartAction();
     131           0 :                 if(bHasMarked)
     132           0 :                     pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), false);
     133             :                 else
     134           0 :                     pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), false);
     135           0 :                 pSh->EndAction();
     136             : 
     137             :                 static sal_uInt16 aInval[] =
     138             :                 {
     139             :                     SID_ATTR_LINE_STYLE,                // ( SID_SVX_START + 169 )
     140             :                     SID_ATTR_LINE_DASH,                 // ( SID_SVX_START + 170 )
     141             :                     SID_ATTR_LINE_WIDTH,                // ( SID_SVX_START + 171 )
     142             :                     SID_ATTR_LINE_COLOR,                // ( SID_SVX_START + 172 )
     143             :                     SID_ATTR_LINE_START,                // ( SID_SVX_START + 173 )
     144             :                     SID_ATTR_LINE_END,                  // ( SID_SVX_START + 174 )
     145             :                     SID_ATTR_LINE_TRANSPARENCE,         // (SID_SVX_START+1107)
     146             :                     SID_ATTR_LINE_JOINT,                // (SID_SVX_START+1110)
     147             :                     SID_ATTR_LINE_CAP,                  // (SID_SVX_START+1111)
     148             :                     0
     149             :                 };
     150             : 
     151           0 :                 GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
     152           0 :             }
     153             :         }
     154           0 :         break;
     155             : 
     156             :         default:
     157           0 :             break;
     158             :     }
     159             : 
     160           0 :     if (pDoc->IsChanged())
     161           0 :         GetShell().SetModified();
     162             :     else
     163           0 :         if (bChanged)
     164           0 :             pDoc->SetChanged(true);
     165           0 : }
     166             : 
     167           0 : void SwDrawShell::ExecDrawAttrArgs(SfxRequest& rReq)
     168             : {
     169           0 :     SwWrtShell* pSh   = &GetShell();
     170           0 :     SdrView*    pView = pSh->GetDrawView();
     171           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     172           0 :     bool        bChanged = pView->GetModel()->IsChanged();
     173           0 :     pView->GetModel()->SetChanged(false);
     174             : 
     175           0 :     GetView().NoRotate();
     176             : 
     177           0 :     if (pArgs)
     178             :     {
     179           0 :         if(pView->AreObjectsMarked())
     180           0 :             pView->SetAttrToMarked(*rReq.GetArgs(), false);
     181             :         else
     182           0 :             pView->SetDefaultAttr(*rReq.GetArgs(), false);
     183             :     }
     184             :     else
     185             :     {
     186           0 :         SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher();
     187           0 :         switch (rReq.GetSlot())
     188             :         {
     189             :             case SID_ATTR_FILL_STYLE:
     190             :             case SID_ATTR_FILL_COLOR:
     191             :             case SID_ATTR_FILL_GRADIENT:
     192             :             case SID_ATTR_FILL_HATCH:
     193             :             case SID_ATTR_FILL_BITMAP:
     194             :             case SID_ATTR_FILL_TRANSPARENCE:
     195             :             case SID_ATTR_FILL_FLOATTRANSPARENCE:
     196           0 :                 pDis->Execute(SID_ATTRIBUTES_AREA);
     197           0 :                 break;
     198             :             case SID_ATTR_LINE_STYLE:
     199             :             case SID_ATTR_LINE_DASH:
     200             :             case SID_ATTR_LINE_WIDTH:
     201             :             case SID_ATTR_LINE_COLOR:
     202             :             case SID_ATTR_LINE_TRANSPARENCE:
     203             :             case SID_ATTR_LINE_JOINT:
     204             :             case SID_ATTR_LINE_CAP:
     205           0 :                 pDis->Execute(SID_ATTRIBUTES_LINE);
     206           0 :                 break;
     207             :         }
     208             :     }
     209           0 :     if (pView->GetModel()->IsChanged())
     210           0 :         GetShell().SetModified();
     211             :     else
     212           0 :         if (bChanged)
     213           0 :             pView->GetModel()->SetChanged(true);
     214           0 : }
     215             : 
     216           0 : void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet)
     217             : {
     218           0 :     SdrView* pSdrView = GetShell().GetDrawView();
     219             : 
     220           0 :     if (pSdrView->AreObjectsMarked())
     221             :     {
     222           0 :         bool bDisable = Disable( rSet );
     223             : 
     224           0 :         if( !bDisable )
     225           0 :             pSdrView->GetAttributes( rSet );
     226             :     }
     227             :     else
     228           0 :         rSet.Put(pSdrView->GetDefaultAttr());
     229         177 : }
     230             : 
     231             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11