LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/drawfunc - drtxtob2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 124 2.4 %
Date: 2012-12-27 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/adjitem.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             : 
      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           5 : sal_uInt16 ScGetFontWorkId()
      51             : {
      52           5 :     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             :         const SfxPoolItem* pItem;
     198             : 
     199           0 :         if ( pDrView->IsTextEdit() )
     200           0 :             pDrView->ScEndTextEdit();
     201             : 
     202           0 :         if (    SFX_ITEM_SET ==
     203           0 :                 rSet.GetItemState(XATTR_FORMTXTSTDFORM, sal_True, &pItem)
     204             :              && XFTFORM_NONE !=
     205           0 :                 ((const XFormTextStdFormItem*) pItem)->GetValue() )
     206             :         {
     207             : 
     208           0 :             sal_uInt16 nId              = SvxFontWorkChildWindow::GetChildWindowId();
     209           0 :             SfxViewFrame* pViewFrm  = pViewData->GetViewShell()->GetViewFrame();
     210             :             SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)
     211             :                                        (pViewFrm->
     212           0 :                                             GetChildWindow(nId)->GetWindow());
     213             : 
     214           0 :             pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(),
     215           0 :                                     rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(),
     216             :                                    ((const XFormTextStdFormItem*) pItem)->
     217           0 :                                    GetValue());
     218             :         }
     219             :         else
     220           0 :             pDrView->SetAttributes(rSet);
     221             :     }
     222           0 : }
     223             : 
     224           0 : void ScDrawTextObjectBar::GetFormTextState(SfxItemSet& rSet)
     225             : {
     226           0 :     const SdrObject*    pObj        = NULL;
     227           0 :     SvxFontWorkDialog*  pDlg        = NULL;
     228           0 :     ScDrawView*         pDrView     = pViewData->GetView()->GetScDrawView();
     229           0 :     const SdrMarkList&  rMarkList   = pDrView->GetMarkedObjectList();
     230           0 :     sal_uInt16              nId = SvxFontWorkChildWindow::GetChildWindowId();
     231             : 
     232           0 :     SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
     233           0 :     if ( pViewFrm->HasChildWindow(nId) )
     234           0 :         pDlg = (SvxFontWorkDialog*)(pViewFrm->GetChildWindow(nId)->GetWindow());
     235             : 
     236           0 :     if ( rMarkList.GetMarkCount() == 1 )
     237           0 :         pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     238             : 
     239           0 :     if ( pObj == NULL || !pObj->ISA(SdrTextObj) ||
     240           0 :         !((SdrTextObj*) pObj)->HasText() )
     241             :     {
     242           0 :         if ( pDlg )
     243           0 :             pDlg->SetActive(false);
     244             : 
     245           0 :         rSet.DisableItem(XATTR_FORMTXTSTYLE);
     246           0 :         rSet.DisableItem(XATTR_FORMTXTADJUST);
     247           0 :         rSet.DisableItem(XATTR_FORMTXTDISTANCE);
     248           0 :         rSet.DisableItem(XATTR_FORMTXTSTART);
     249           0 :         rSet.DisableItem(XATTR_FORMTXTMIRROR);
     250           0 :         rSet.DisableItem(XATTR_FORMTXTSTDFORM);
     251           0 :         rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
     252           0 :         rSet.DisableItem(XATTR_FORMTXTOUTLINE);
     253           0 :         rSet.DisableItem(XATTR_FORMTXTSHADOW);
     254           0 :         rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
     255           0 :         rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
     256           0 :         rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
     257             :     }
     258             :     else
     259             :     {
     260           0 :         if ( pDlg )
     261             :         {
     262           0 :             SfxObjectShell* pDocSh = SfxObjectShell::Current();
     263             : 
     264           0 :             if ( pDocSh )
     265             :             {
     266           0 :                 const SfxPoolItem*  pItem = pDocSh->GetItem( SID_COLOR_TABLE );
     267           0 :                 XColorListRef pColorList;
     268             : 
     269           0 :                 if ( pItem )
     270           0 :                     pColorList = ((SvxColorListItem*)pItem)->GetColorList();
     271             : 
     272           0 :                 pDlg->SetActive();
     273             : 
     274           0 :                 if ( pColorList.is() )
     275           0 :                     pDlg->SetColorList( pColorList );
     276             :             }
     277             :         }
     278           0 :         SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool());
     279           0 :         pDrView->GetAttributes(aViewAttr);
     280           0 :         rSet.Set(aViewAttr);
     281             :     }
     282          15 : }
     283             : 
     284             : 
     285             : 
     286             : 
     287             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10