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

Generated by: LCOV version 1.10