LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/drawfunc - drtxtob2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 118 2.5 %
Date: 2013-07-09 Functions: 3 9 33.3 %
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 "scitems.hxx"
      22             : #include <editeng/adjustitem.hxx>
      23             : #include <svx/drawitem.hxx>
      24             : #include <svx/fontwork.hxx>
      25             : #include <editeng/frmdiritem.hxx>
      26             : #include <editeng/outlobj.hxx>
      27             : #include <svx/svdocapt.hxx>
      28             : #include <svx/xtextit.hxx>
      29             : #include <editeng/writingmodeitem.hxx>
      30             : #include <sfx2/bindings.hxx>
      31             : #include <sfx2/viewfrm.hxx>
      32             : #include <sfx2/objsh.hxx>
      33             : #include <sfx2/request.hxx>
      34             : #include <sot/formats.hxx>
      35             : #include <svl/whiter.hxx>
      36             : #include <svx/svdoashp.hxx>
      37             : #include "sc.hrc"
      38             : #include "drtxtob.hxx"
      39             : #include "viewdata.hxx"
      40             : #include "drawview.hxx"
      41             : #include "tabvwsh.hxx"
      42             : #include "impex.hxx"
      43             : #include "docsh.hxx"
      44             : #include "transobj.hxx"
      45             : #include "drwtrans.hxx"
      46             : #include "drwlayer.hxx"
      47             : 
      48             : //------------------------------------------------------------------------
      49             : 
      50          31 : sal_uInt16 ScGetFontWorkId()
      51             : {
      52          31 :     return SvxFontWorkChildWindow::GetChildWindowId();
      53             : }
      54             : 
      55           0 : sal_Bool ScDrawTextObjectBar::IsNoteEdit()
      56             : {
      57           0 :     return ScDrawLayer::IsNoteCaption( pViewData->GetView()->GetSdrView()->GetTextEditObject() );
      58             : }
      59             : 
      60             : //  wenn kein Text editiert wird, Funktionen wie in drawsh
      61             : 
      62           0 : void ScDrawTextObjectBar::ExecuteGlobal( SfxRequest &rReq )
      63             : {
      64           0 :     ScTabView*   pTabView  = pViewData->GetView();
      65           0 :     ScDrawView*  pView     = pTabView->GetScDrawView();
      66             : 
      67           0 :     sal_uInt16 nSlot = rReq.GetSlot();
      68           0 :     switch ( nSlot )
      69             :     {
      70             :         case SID_COPY:
      71           0 :             pView->DoCopy();
      72           0 :             break;
      73             : 
      74             :         case SID_CUT:
      75           0 :             pView->DoCut();
      76           0 :             pViewData->GetViewShell()->UpdateDrawShell();
      77           0 :             break;
      78             : 
      79             :         case SID_PASTE:
      80             :         case SID_PASTE_SPECIAL:
      81             :         case SID_CLIPBOARD_FORMAT_ITEMS:
      82             :         case SID_HYPERLINK_SETLINK:
      83             :             {
      84             :                 //  cell methods are at cell shell, which is not available if
      85             :                 //  ScDrawTextObjectBar is active
      86             :                 //! move paste etc. to view shell?
      87             :             }
      88           0 :             break;
      89             : 
      90             :         case SID_SELECTALL:
      91           0 :             pView->MarkAll();
      92           0 :             break;
      93             : 
      94             :         case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
      95             :         case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
      96             :             {
      97           0 :                 SfxItemSet aAttr( pView->GetModel()->GetItemPool(), SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, 0 );
      98             :                 aAttr.Put( SvxWritingModeItem(
      99             :                     nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
     100             :                         com::sun::star::text::WritingMode_LR_TB : com::sun::star::text::WritingMode_TB_RL,
     101           0 :                         SDRATTR_TEXTDIRECTION ) );
     102           0 :                 pView->SetAttributes( aAttr );
     103           0 :                 pViewData->GetScDrawView()->InvalidateDrawTextAttrs();  // Bidi slots may be disabled
     104           0 :                 rReq.Done( aAttr );
     105             :             }
     106           0 :             break;
     107             : 
     108             :         case SID_ENABLE_HYPHENATION:
     109             :             {
     110           0 :                 SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, false);
     111           0 :                 if( pItem )
     112             :                 {
     113           0 :                     SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
     114           0 :                     sal_Bool bValue = ( (const SfxBoolItem*) pItem)->GetValue();
     115           0 :                     aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
     116           0 :                     pView->SetAttributes( aSet );
     117             :                 }
     118           0 :                 rReq.Done();
     119             :             }
     120           0 :             break;
     121             :     }
     122           0 : }
     123             : 
     124           0 : void ScDrawTextObjectBar::GetGlobalClipState( SfxItemSet& rSet )
     125             : {
     126             :     //  cell methods are at cell shell, which is not available if
     127             :     //  ScDrawTextObjectBar is active -> disable everything
     128             :     //! move paste etc. to view shell?
     129             : 
     130           0 :     SfxWhichIter aIter(rSet);
     131           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     132           0 :     while (nWhich)
     133             :     {
     134           0 :         rSet.DisableItem( nWhich );
     135           0 :         nWhich = aIter.NextWhich();
     136           0 :     }
     137           0 : }
     138             : 
     139           0 : void ScDrawTextObjectBar::ExecuteExtra( SfxRequest &rReq )
     140             : {
     141           0 :     ScTabView*   pTabView  = pViewData->GetView();
     142           0 :     ScDrawView*  pView     = pTabView->GetScDrawView();
     143             : 
     144           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     145           0 :     switch ( nSlot )
     146             :     {
     147             :         case SID_FONTWORK:
     148             :             {
     149           0 :                 sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
     150           0 :                 SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
     151             : 
     152           0 :                 if ( rReq.GetArgs() )
     153             :                     pViewFrm->SetChildWindow( nId,
     154             :                                                ((const SfxBoolItem&)
     155           0 :                                                 (rReq.GetArgs()->Get(SID_FONTWORK))).
     156           0 :                                                     GetValue() );
     157             :                 else
     158           0 :                     pViewFrm->ToggleChildWindow( nId );
     159             : 
     160           0 :                 pViewFrm->GetBindings().Invalidate( SID_FONTWORK );
     161           0 :                 rReq.Done();
     162             :             }
     163           0 :             break;
     164             : 
     165             :         case SID_ATTR_PARA_LEFT_TO_RIGHT:
     166             :         case SID_ATTR_PARA_RIGHT_TO_LEFT:
     167             :             {
     168           0 :                 SfxItemSet aAttr( pView->GetModel()->GetItemPool(),
     169             :                                     EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
     170             :                                     EE_PARA_JUST, EE_PARA_JUST,
     171           0 :                                     0 );
     172           0 :                 sal_Bool bLeft = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT );
     173             :                 aAttr.Put( SvxFrameDirectionItem(
     174             :                                 bLeft ? FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP,
     175           0 :                                 EE_PARA_WRITINGDIR ) );
     176             :                 aAttr.Put( SvxAdjustItem(
     177             :                                 bLeft ? SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT,
     178           0 :                                 EE_PARA_JUST ) );
     179           0 :                 pView->SetAttributes( aAttr );
     180           0 :                 pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
     181           0 :                 rReq.Done();        //! Done(aAttr) ?
     182             : 
     183             :             }
     184           0 :             break;
     185             :     }
     186           0 : }
     187             : 
     188           0 : void ScDrawTextObjectBar::ExecFormText(SfxRequest& rReq)
     189             : {
     190           0 :     ScTabView*          pTabView    = pViewData->GetView();
     191           0 :     ScDrawView*         pDrView     = pTabView->GetScDrawView();
     192           0 :     const SdrMarkList&  rMarkList   = pDrView->GetMarkedObjectList();
     193             : 
     194           0 :     if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
     195             :     {
     196           0 :         const SfxItemSet& rSet = *rReq.GetArgs();
     197             : 
     198           0 :         if ( pDrView->IsTextEdit() )
     199           0 :             pDrView->ScEndTextEdit();
     200             : 
     201           0 :         pDrView->SetAttributes(rSet);
     202             :     }
     203           0 : }
     204             : 
     205           0 : void ScDrawTextObjectBar::GetFormTextState(SfxItemSet& rSet)
     206             : {
     207           0 :     const SdrObject*    pObj        = NULL;
     208           0 :     SvxFontWorkDialog*  pDlg        = NULL;
     209           0 :     ScDrawView*         pDrView     = pViewData->GetView()->GetScDrawView();
     210           0 :     const SdrMarkList&  rMarkList   = pDrView->GetMarkedObjectList();
     211           0 :     sal_uInt16              nId = SvxFontWorkChildWindow::GetChildWindowId();
     212             : 
     213           0 :     SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
     214           0 :     if ( pViewFrm->HasChildWindow(nId) )
     215           0 :         pDlg = (SvxFontWorkDialog*)(pViewFrm->GetChildWindow(nId)->GetWindow());
     216             : 
     217           0 :     if ( rMarkList.GetMarkCount() == 1 )
     218           0 :         pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     219             : 
     220           0 :     const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
     221             :     const bool bDeactivate(
     222           0 :         !pObj ||
     223           0 :         !pTextObj ||
     224           0 :         !pTextObj->HasText() ||
     225           0 :         dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
     226             : 
     227           0 :     if(bDeactivate)
     228             :     {
     229           0 :         if ( pDlg )
     230           0 :             pDlg->SetActive(false);
     231             : 
     232           0 :         rSet.DisableItem(XATTR_FORMTXTSTYLE);
     233           0 :         rSet.DisableItem(XATTR_FORMTXTADJUST);
     234           0 :         rSet.DisableItem(XATTR_FORMTXTDISTANCE);
     235           0 :         rSet.DisableItem(XATTR_FORMTXTSTART);
     236           0 :         rSet.DisableItem(XATTR_FORMTXTMIRROR);
     237           0 :         rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
     238           0 :         rSet.DisableItem(XATTR_FORMTXTOUTLINE);
     239           0 :         rSet.DisableItem(XATTR_FORMTXTSHADOW);
     240           0 :         rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
     241           0 :         rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
     242           0 :         rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
     243             :     }
     244             :     else
     245             :     {
     246           0 :         if ( pDlg )
     247             :         {
     248           0 :             SfxObjectShell* pDocSh = SfxObjectShell::Current();
     249             : 
     250           0 :             if ( pDocSh )
     251             :             {
     252           0 :                 const SfxPoolItem*  pItem = pDocSh->GetItem( SID_COLOR_TABLE );
     253           0 :                 XColorListRef pColorList;
     254             : 
     255           0 :                 if ( pItem )
     256           0 :                     pColorList = ((SvxColorListItem*)pItem)->GetColorList();
     257             : 
     258           0 :                 pDlg->SetActive();
     259             : 
     260           0 :                 if ( pColorList.is() )
     261           0 :                     pDlg->SetColorList( pColorList );
     262             :             }
     263             :         }
     264           0 :         SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool());
     265           0 :         pDrView->GetAttributes(aViewAttr);
     266           0 :         rSet.Set(aViewAttr);
     267             :     }
     268          93 : }
     269             : 
     270             : 
     271             : 
     272             : 
     273             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10