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

Generated by: LCOV version 1.10