LCOV - code coverage report
Current view: top level - sd/source/ui/table - tableobjectbar.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 7 79 8.9 %
Date: 2015-06-13 12:38:46 Functions: 6 19 31.6 %
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 <sfx2/msg.hxx>
      21             : #include <sfx2/app.hxx>
      22             : #include <sfx2/sfxsids.hrc>
      23             : #include <sfx2/request.hxx>
      24             : #include <sfx2/objface.hxx>
      25             : #include <sfx2/viewfrm.hxx>
      26             : #include <sfx2/dispatch.hxx>
      27             : #include <sfx2/msgpool.hxx>
      28             : #include <sfx2/sidebar/EnumContext.hxx>
      29             : #include <svl/whiter.hxx>
      30             : #include <svl/itempool.hxx>
      31             : #include <svx/svdomedia.hxx>
      32             : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
      33             : #include <svx/svxdlg.hxx>
      34             : #include <svx/dialogs.hrc>
      35             : #include <svx/svxids.hrc>
      36             : 
      37             : #include "app.hrc"
      38             : #include "createtableobjectbar.hxx"
      39             : #include "registerinterfaces.hxx"
      40             : #include "res_bmp.hrc"
      41             : #include "glob.hrc"
      42             : #include "strings.hrc"
      43             : #include "DrawDocShell.hxx"
      44             : #include "ViewShell.hxx"
      45             : #include "Window.hxx"
      46             : #include "drawview.hxx"
      47             : #include "sdresid.hxx"
      48             : #include "drawdoc.hxx"
      49             : #include "DrawViewShell.hxx"
      50             : 
      51             : #include "tableobjectbar.hxx"
      52             : 
      53             : #include <boost/scoped_ptr.hpp>
      54             : 
      55             : using namespace sd;
      56             : using namespace sd::ui::table;
      57             : 
      58             : #define TableObjectBar
      59             : #include "sdslots.hxx"
      60             : 
      61             : namespace sd { namespace ui { namespace table {
      62             : 
      63             : /** creates a table object bar for the given ViewShell */
      64           0 : SfxShell* CreateTableObjectBar( ViewShell& rShell, ::sd::View* pView )
      65             : {
      66           0 :     return new TableObjectBar( &rShell, pView );
      67             : }
      68             : 
      69             : /** registers the interfaces from the table ui */
      70          21 : void RegisterInterfaces(SfxModule* pMod)
      71             : {
      72          21 :     TableObjectBar::RegisterInterface(pMod);
      73          21 : }
      74             : 
      75             : // - TableObjectBar -
      76             : 
      77           0 : TYPEINIT1( TableObjectBar, SfxShell );
      78             : 
      79          42 : SFX_IMPL_INTERFACE(TableObjectBar, SfxShell)
      80             : 
      81          21 : void TableObjectBar::InitInterface_Impl()
      82             : {
      83          21 : }
      84             : 
      85           0 : TableObjectBar::TableObjectBar( ViewShell* pSdViewShell, ::sd::View* pSdView )
      86             : :   SfxShell( pSdViewShell->GetViewShell() )
      87             : ,   mpView( pSdView )
      88           0 : ,   mpViewSh( pSdViewShell )
      89             : {
      90           0 :     DrawDocShell* pDocShell = mpViewSh->GetDocSh();
      91           0 :     if( pDocShell )
      92             :     {
      93           0 :         SetPool( &pDocShell->GetPool() );
      94           0 :         SetUndoManager( pDocShell->GetUndoManager() );
      95             :     }
      96           0 :     SetRepeatTarget( mpView );
      97           0 :     SetHelpId( SD_IF_SDDRAWTABLEOBJECTBAR );
      98           0 :     SetName( SD_RESSTR( RID_DRAW_TABLE_TOOLBOX ) );
      99           0 :     SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Table));
     100           0 : }
     101             : 
     102           0 : TableObjectBar::~TableObjectBar()
     103             : {
     104           0 :     SetRepeatTarget( NULL );
     105           0 : }
     106             : 
     107           0 : void TableObjectBar::GetState( SfxItemSet& rSet )
     108             : {
     109           0 :     if( mpView )
     110             :     {
     111           0 :         rtl::Reference< sdr::SelectionController > xController( mpView->getSelectionController() );
     112           0 :         if( xController.is() )
     113             :         {
     114           0 :             xController->GetState( rSet );
     115           0 :         }
     116             :     }
     117           0 : }
     118             : 
     119           0 : void TableObjectBar::GetAttrState( SfxItemSet& rSet )
     120             : {
     121           0 :     DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpViewSh );
     122           0 :     if( pDrawViewShell )
     123           0 :         pDrawViewShell->GetAttrState( rSet );
     124           0 : }
     125             : 
     126           0 : void TableObjectBar::Execute( SfxRequest& rReq )
     127             : {
     128           0 :     if( mpView )
     129             :     {
     130           0 :         SdrView* pView = mpView;
     131           0 :         SfxBindings* pBindings = &mpViewSh->GetViewFrame()->GetBindings();
     132             : 
     133           0 :         rtl::Reference< sdr::SelectionController > xController( mpView->getSelectionController() );
     134           0 :         sal_uLong nSlotId = rReq.GetSlot();
     135           0 :         if( xController.is() )
     136             :         {
     137           0 :             switch( nSlotId )
     138             :             {
     139             :             case SID_TABLE_INSERT_ROW_DLG:
     140             :             case SID_TABLE_INSERT_COL_DLG:
     141             :             {
     142           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     143           0 :                 boost::scoped_ptr<SvxAbstractInsRowColDlg> pDlg( pFact ? pFact->CreateSvxInsRowColDlg( mpView->GetViewShell()->GetParentWindow(), nSlotId == SID_TABLE_INSERT_COL_DLG, SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommand()) : 0);
     144             : 
     145           0 :                 if( pDlg.get() && (pDlg->Execute() == 1) )
     146             :                 {
     147           0 :                     if( nSlotId == SID_TABLE_INSERT_ROW_DLG )
     148           0 :                         nSlotId = SID_TABLE_INSERT_ROW;
     149             :                     else
     150           0 :                         nSlotId = SID_TABLE_INSERT_COL;
     151             : 
     152           0 :                     rReq.AppendItem( SfxInt16Item( (sal_uInt16)nSlotId, (sal_uInt16)pDlg->getInsertCount() ) );
     153           0 :                     rReq.AppendItem( SfxBoolItem( SID_TABLE_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() ) );
     154             : 
     155           0 :                      rReq.SetSlot( (sal_uInt16)nSlotId );
     156           0 :                 }
     157             :             }
     158             :             }
     159             : 
     160           0 :             xController->Execute( rReq );
     161             :         }
     162             : 
     163             :         // note: we may be deleted at this point, no more member access possible
     164             : 
     165           0 :         switch( rReq.GetSlot() )
     166             :         {
     167             :         case SID_ATTR_BORDER:
     168             :         case SID_TABLE_MERGE_CELLS:
     169             :         case SID_TABLE_SPLIT_CELLS:
     170             :         case SID_OPTIMIZE_TABLE:
     171             :         case SID_TABLE_DELETE_ROW:
     172             :         case SID_TABLE_DELETE_COL:
     173             :         case SID_FORMAT_TABLE_DLG:
     174             :         case SID_TABLE_INSERT_ROW:
     175             :         case SID_TABLE_INSERT_COL:
     176             :         {
     177           0 :             pView->AdjustMarkHdl();
     178           0 :             pBindings->Invalidate( SID_TABLE_DELETE_ROW );
     179           0 :             pBindings->Invalidate( SID_TABLE_DELETE_COL );
     180           0 :             pBindings->Invalidate( SID_FRAME_LINESTYLE );
     181           0 :             pBindings->Invalidate( SID_FRAME_LINECOLOR );
     182           0 :             pBindings->Invalidate( SID_ATTR_BORDER );
     183           0 :             pBindings->Invalidate( SID_ATTR_FILL_STYLE );
     184           0 :             pBindings->Invalidate( SID_ATTR_FILL_TRANSPARENCE );
     185           0 :             pBindings->Invalidate( SID_ATTR_FILL_FLOATTRANSPARENCE );
     186           0 :             pBindings->Invalidate( SID_TABLE_MERGE_CELLS );
     187           0 :             pBindings->Invalidate( SID_TABLE_SPLIT_CELLS );
     188           0 :             pBindings->Invalidate( SID_OPTIMIZE_TABLE );
     189           0 :             pBindings->Invalidate( SID_TABLE_VERT_BOTTOM );
     190           0 :             pBindings->Invalidate( SID_TABLE_VERT_CENTER );
     191           0 :             pBindings->Invalidate( SID_TABLE_VERT_NONE );
     192           0 :             break;
     193             :         }
     194             :         case SID_TABLE_VERT_BOTTOM:
     195             :         case SID_TABLE_VERT_CENTER:
     196             :         case SID_TABLE_VERT_NONE:
     197             :         {
     198           0 :             pBindings->Invalidate( SID_TABLE_VERT_BOTTOM );
     199           0 :             pBindings->Invalidate( SID_TABLE_VERT_CENTER );
     200           0 :             pBindings->Invalidate( SID_TABLE_VERT_NONE );
     201           0 :             break;
     202             :         }
     203             :         }
     204             : 
     205           0 :         pBindings->Invalidate( SID_UNDO );
     206           0 :         pBindings->Invalidate( SID_REDO );
     207             :     }
     208           0 : }
     209             : 
     210          66 : } } }
     211             : 
     212             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11