LCOV - code coverage report
Current view: top level - sw/source/core/uibase/uiview - viewdraw.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 370 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             : #include "hintids.hxx"
      21             : #include <svl/aeitem.hxx>
      22             : #include <svl/itempool.hxx>
      23             : #include <svx/svdobj.hxx>
      24             : #include <svx/svdview.hxx>
      25             : #include <svx/svdpage.hxx>
      26             : #include <editeng/editview.hxx>
      27             : #include <editeng/editeng.hxx>
      28             : #include <editeng/outliner.hxx>
      29             : #include <svx/fmview.hxx>
      30             : #include <svx/dataaccessdescriptor.hxx>
      31             : #include <sfx2/viewfrm.hxx>
      32             : #include <doc.hxx>
      33             : #include <editeng/langitem.hxx>
      34             : #include <linguistic/lngprops.hxx>
      35             : #include <editeng/unolingu.hxx>
      36             : #include <svx/fontworkbar.hxx>
      37             : #include <svx/fontworkgallery.hxx>
      38             : #include <editeng/eeitem.hxx>
      39             : #include <svx/svdogrp.hxx>
      40             : #include <svx/svdetc.hxx>
      41             : #include <editeng/editstat.hxx>
      42             : #include <sfx2/request.hxx>
      43             : #include <sfx2/bindings.hxx>
      44             : #include <sfx2/printer.hxx>
      45             : #include <svx/fmglob.hxx>
      46             : #include <sfx2/dispatch.hxx>
      47             : #include <svx/svdoutl.hxx>
      48             : 
      49             : #include "view.hxx"
      50             : #include "wrtsh.hxx"
      51             : #include "viewopt.hxx"
      52             : #include "cmdid.h"
      53             : #include "drawsh.hxx"
      54             : #include "drwbassh.hxx"
      55             : #include "beziersh.hxx"
      56             : #include "conrect.hxx"
      57             : #include "conpoly.hxx"
      58             : #include "conarc.hxx"
      59             : #include "conform.hxx"
      60             : #include "concustomshape.hxx"
      61             : #include "dselect.hxx"
      62             : #include "edtwin.hxx"
      63             : 
      64             : #include <dcontact.hxx>
      65             : 
      66             : #include <svx/svdpagv.hxx>
      67             : #include <svx/extrusionbar.hxx>
      68             : #include <vcl/svapp.hxx>
      69             : 
      70             : using namespace ::com::sun::star;
      71             : 
      72             : // Execute Drawing-Ids
      73             : 
      74           0 : void SwView::ExecDraw(SfxRequest& rReq)
      75             : {
      76           0 :     const SfxItemSet *pArgs = rReq.GetArgs();
      77             :     const SfxPoolItem* pItem;
      78           0 :     const SfxAllEnumItem* pEItem = 0;
      79           0 :     const SfxStringItem* pStringItem = 0;
      80           0 :     SdrView *pSdrView = m_pWrtShell->GetDrawView();
      81           0 :     sal_Bool bDeselect = sal_False;
      82             : 
      83           0 :     sal_uInt16 nSlotId = rReq.GetSlot();
      84           0 :     if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(GetPool().GetWhich(nSlotId), false, &pItem))
      85             :     {
      86           0 :         pEItem = dynamic_cast< const SfxAllEnumItem*>(pItem);
      87           0 :         pStringItem = dynamic_cast< const SfxStringItem*>(pItem);
      88             :     }
      89             : 
      90           0 :     if (SID_INSERT_DRAW == nSlotId && pEItem)
      91           0 :         switch ( pEItem->GetValue() )
      92             :         {
      93           0 :             case SVX_SNAP_DRAW_SELECT:              nSlotId = SID_OBJECT_SELECT;            break;
      94           0 :             case SVX_SNAP_DRAW_LINE:                nSlotId = SID_DRAW_LINE;                break;
      95           0 :             case SVX_SNAP_DRAW_RECT:                nSlotId = SID_DRAW_RECT;                break;
      96           0 :             case SVX_SNAP_DRAW_ELLIPSE:             nSlotId = SID_DRAW_ELLIPSE;             break;
      97           0 :             case SVX_SNAP_DRAW_POLYGON_NOFILL:      nSlotId = SID_DRAW_POLYGON_NOFILL;      break;
      98           0 :             case SVX_SNAP_DRAW_BEZIER_NOFILL:       nSlotId = SID_DRAW_BEZIER_NOFILL;       break;
      99           0 :             case SVX_SNAP_DRAW_FREELINE_NOFILL:     nSlotId = SID_DRAW_FREELINE_NOFILL;     break;
     100           0 :             case SVX_SNAP_DRAW_ARC:                 nSlotId = SID_DRAW_ARC;                 break;
     101           0 :             case SVX_SNAP_DRAW_PIE:                 nSlotId = SID_DRAW_PIE;                 break;
     102           0 :             case SVX_SNAP_DRAW_CIRCLECUT:           nSlotId = SID_DRAW_CIRCLECUT;           break;
     103           0 :             case SVX_SNAP_DRAW_TEXT:                nSlotId = SID_DRAW_TEXT;                break;
     104           0 :             case SVX_SNAP_DRAW_TEXT_VERTICAL:       nSlotId = SID_DRAW_TEXT_VERTICAL;       break;
     105           0 :             case SVX_SNAP_DRAW_TEXT_MARQUEE:        nSlotId = SID_DRAW_TEXT_MARQUEE;        break;
     106           0 :             case SVX_SNAP_DRAW_CAPTION:             nSlotId = SID_DRAW_CAPTION;             break;
     107           0 :             case SVX_SNAP_DRAW_CAPTION_VERTICAL:    nSlotId = SID_DRAW_CAPTION_VERTICAL;    break;
     108             :         }
     109             : 
     110           0 :     if (nSlotId == SID_OBJECT_SELECT && m_nFormSfxId == nSlotId)
     111             :     {
     112           0 :         bDeselect = sal_True;
     113             :     }
     114           0 :     else if (nSlotId == SID_FM_CREATE_CONTROL)
     115             :     {
     116           0 :         SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, false );
     117           0 :         if( pIdentifierItem )
     118             :         {
     119           0 :             sal_uInt16 nNewId = pIdentifierItem->GetValue();
     120           0 :             if (nNewId == m_nFormSfxId)
     121             :             {
     122           0 :                 bDeselect = sal_True;
     123           0 :                 GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE);  // Button should popping out
     124             :             }
     125             :         }
     126             :     }
     127           0 :     else if( nSlotId == SID_FM_CREATE_FIELDCONTROL)
     128             :     {
     129           0 :         FmFormView* pFormView = PTR_CAST( FmFormView, pSdrView );
     130           0 :         if ( pFormView )
     131             :         {
     132           0 :             SFX_REQUEST_ARG( rReq, pDescriptorItem, SfxUnoAnyItem, SID_FM_DATACCESS_DESCRIPTOR, false );
     133             :             OSL_ENSURE( pDescriptorItem, "SwView::ExecDraw(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
     134           0 :             if( pDescriptorItem )
     135             :             {
     136           0 :                 ::svx::ODataAccessDescriptor aDescriptor( pDescriptorItem->GetValue() );
     137           0 :                 SdrObject* pObj = pFormView->CreateFieldControl( aDescriptor );
     138             : 
     139           0 :                 if ( pObj )
     140             :                 {
     141           0 :                     Size aDocSize(m_pWrtShell->GetDocSize());
     142           0 :                     const SwRect& rVisArea = m_pWrtShell->VisArea();
     143           0 :                     Point aStartPos = rVisArea.Center();
     144           0 :                     if(rVisArea.Width() > aDocSize.Width())
     145           0 :                         aStartPos.X() = aDocSize.Width() / 2 + rVisArea.Left();
     146           0 :                     if(rVisArea.Height() > aDocSize.Height())
     147           0 :                         aStartPos.Y() = aDocSize.Height() / 2 + rVisArea.Top();
     148             : 
     149             :                     //determine the size of the object
     150           0 :                     if(pObj->IsGroupObject())
     151             :                     {
     152           0 :                         const Rectangle& rBoundRect = ((SdrObjGroup*)pObj)->GetCurrentBoundRect();
     153           0 :                         aStartPos.X() -= rBoundRect.GetWidth()/2;
     154           0 :                         aStartPos.Y() -= rBoundRect.GetHeight()/2;
     155             :                     }
     156             : 
     157             :                     // TODO: unmark all other
     158           0 :                     m_pWrtShell->EnterStdMode();
     159           0 :                     m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aStartPos );
     160           0 :                 }
     161             :             }
     162             :         }
     163             :     }
     164           0 :     else if ( nSlotId == SID_FONTWORK_GALLERY_FLOATER )
     165             :     {
     166           0 :         Window*  pWin = &( m_pWrtShell->GetView().GetViewFrame()->GetWindow() );
     167             : 
     168           0 :         if ( pWin )
     169           0 :             pWin->EnterWait();
     170             : 
     171           0 :         if( !m_pWrtShell->HasDrawView() )
     172           0 :             m_pWrtShell->MakeDrawView();
     173             : 
     174           0 :         pSdrView = m_pWrtShell->GetDrawView();
     175           0 :         if ( pSdrView )
     176             :         {
     177           0 :             SdrObject* pObj = NULL;
     178           0 :             svx::FontWorkGalleryDialog aDlg( pSdrView, pWin, nSlotId );
     179           0 :             aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() );
     180           0 :             aDlg.Execute();
     181           0 :             if ( pObj )
     182             :             {
     183           0 :                 Size            aDocSize( m_pWrtShell->GetDocSize() );
     184           0 :                 const SwRect&   rVisArea = m_pWrtShell->VisArea();
     185           0 :                 Point           aPos( rVisArea.Center() );
     186           0 :                 Size            aSize;
     187           0 :                 Size            aPrefSize( pObj->GetSnapRect().GetSize() );
     188             : 
     189           0 :                 if( rVisArea.Width() > aDocSize.Width())
     190           0 :                     aPos.X() = aDocSize.Width() / 2 + rVisArea.Left();
     191             : 
     192           0 :                 if(rVisArea.Height() > aDocSize.Height())
     193           0 :                     aPos.Y() = aDocSize.Height() / 2 + rVisArea.Top();
     194             : 
     195           0 :                 if( aPrefSize.Width() && aPrefSize.Height() )
     196             :                 {
     197           0 :                     if( pWin )
     198           0 :                         aSize = pWin->PixelToLogic( aPrefSize, MAP_TWIP );
     199             :                     else
     200           0 :                         aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_TWIP );
     201             :                 }
     202             :                 else
     203           0 :                     aSize = Size( 2835, 2835 );
     204             : 
     205           0 :                 m_pWrtShell->EnterStdMode();
     206           0 :                 m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos );
     207           0 :                 rReq.Ignore ();
     208           0 :             }
     209             :         }
     210           0 :         if( pWin )
     211           0 :             pWin->LeaveWait();
     212             :     }
     213             : 
     214           0 :     if( nSlotId == SID_DRAW_CS_ID )
     215             :     {
     216             :         //deselect if same custom shape is selected again
     217           0 :         SwDrawBase* pFuncPtr = GetDrawFuncPtr();
     218           0 :         if( pFuncPtr && pFuncPtr->GetSlotId() == SID_DRAW_CS_ID )
     219             :         {
     220           0 :             ConstCustomShape* pConstCustomShape = (ConstCustomShape*)(pFuncPtr);
     221           0 :             OUString aNew = ConstCustomShape::GetShapeTypeFromRequest( rReq );
     222           0 :             OUString aOld = pConstCustomShape->GetShapeType();
     223           0 :             if( aNew == aOld )
     224             :             {
     225           0 :                 bDeselect = true;
     226           0 :             }
     227             :         }
     228             :     }
     229             : 
     230             :     //deselect if same shape is selected again (but different custom shapes do have same slot id)
     231           0 :     if ( bDeselect || (nSlotId == m_nDrawSfxId &&
     232           0 :             (!pStringItem || (pStringItem->GetValue() == m_sDrawCustom))
     233           0 :                 && (nSlotId != SID_DRAW_CS_ID) ) )
     234             :     {
     235           0 :         if (GetDrawFuncPtr())
     236             :         {
     237           0 :             GetDrawFuncPtr()->Deactivate();
     238           0 :             SetDrawFuncPtr(NULL);
     239             :         }
     240             : 
     241           0 :         if (m_pWrtShell->IsObjSelected() && !m_pWrtShell->IsSelFrmMode())
     242           0 :             m_pWrtShell->EnterSelFrmMode(NULL);
     243           0 :         LeaveDrawCreate();
     244             : 
     245           0 :         GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
     246             : 
     247           0 :         AttrChangedNotify(m_pWrtShell);
     248           0 :         return;
     249             :     }
     250             : 
     251           0 :     LeaveDrawCreate();
     252             : 
     253           0 :     if (m_pWrtShell->IsFrmSelected())
     254           0 :         m_pWrtShell->EnterStdMode();  // because bug #45639
     255             : 
     256           0 :     SwDrawBase* pFuncPtr = NULL;
     257             : 
     258           0 :     switch (nSlotId)
     259             :     {
     260             :         case SID_OBJECT_SELECT:
     261             :         case SID_DRAW_SELECT:
     262           0 :             pFuncPtr = new DrawSelection(m_pWrtShell, m_pEditWin, this);
     263           0 :             m_nDrawSfxId = m_nFormSfxId = SID_OBJECT_SELECT;
     264           0 :             m_sDrawCustom = "";
     265           0 :             break;
     266             : 
     267             :         case SID_DRAW_LINE:
     268             :         case SID_DRAW_RECT:
     269             :         case SID_DRAW_ELLIPSE:
     270             :         case SID_DRAW_TEXT:
     271             :         case SID_DRAW_TEXT_VERTICAL:
     272             :         case SID_DRAW_TEXT_MARQUEE:
     273             :         case SID_DRAW_CAPTION:
     274             :         case SID_DRAW_CAPTION_VERTICAL:
     275           0 :             pFuncPtr = new ConstRectangle(m_pWrtShell, m_pEditWin, this);
     276           0 :             m_nDrawSfxId = nSlotId;
     277           0 :             m_sDrawCustom = "";
     278           0 :             break;
     279             : 
     280             :         case SID_DRAW_POLYGON_NOFILL:
     281             :         case SID_DRAW_BEZIER_NOFILL:
     282             :         case SID_DRAW_FREELINE_NOFILL:
     283           0 :             pFuncPtr = new ConstPolygon(m_pWrtShell, m_pEditWin, this);
     284           0 :             m_nDrawSfxId = nSlotId;
     285           0 :             m_sDrawCustom = "";
     286           0 :             break;
     287             : 
     288             :         case SID_DRAW_ARC:
     289             :         case SID_DRAW_PIE:
     290             :         case SID_DRAW_CIRCLECUT:
     291           0 :             pFuncPtr = new ConstArc(m_pWrtShell, m_pEditWin, this);
     292           0 :             m_nDrawSfxId = nSlotId;
     293           0 :             m_sDrawCustom = "";
     294           0 :             break;
     295             : 
     296             :         case SID_FM_CREATE_CONTROL:
     297             :         {
     298           0 :             SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, false );
     299           0 :             if( pIdentifierItem )
     300           0 :                 nSlotId = pIdentifierItem->GetValue();
     301           0 :             pFuncPtr = new ConstFormControl(m_pWrtShell, m_pEditWin, this);
     302           0 :             m_nFormSfxId = nSlotId;
     303             :         }
     304           0 :         break;
     305             : 
     306             :         case SID_DRAWTBX_CS_BASIC :
     307             :         case SID_DRAWTBX_CS_SYMBOL :
     308             :         case SID_DRAWTBX_CS_ARROW :
     309             :         case SID_DRAWTBX_CS_FLOWCHART :
     310             :         case SID_DRAWTBX_CS_CALLOUT :
     311             :         case SID_DRAWTBX_CS_STAR :
     312             :         case SID_DRAW_CS_ID :
     313             :         {
     314           0 :             pFuncPtr = new ConstCustomShape(m_pWrtShell, m_pEditWin, this, rReq );
     315           0 :             m_nDrawSfxId = nSlotId;
     316           0 :             if ( nSlotId != SID_DRAW_CS_ID )
     317             :             {
     318           0 :                 if ( pStringItem )
     319             :                 {
     320           0 :                     m_sDrawCustom = pStringItem->GetValue();
     321           0 :                     m_aCurrShapeEnumCommand[ nSlotId - SID_DRAWTBX_CS_BASIC ] = m_sDrawCustom;
     322           0 :                     SfxBindings& rBind = GetViewFrame()->GetBindings();
     323           0 :                     rBind.Invalidate( nSlotId );
     324           0 :                     rBind.Update( nSlotId );
     325             :                 }
     326             :             }
     327             :         }
     328           0 :         break;
     329             : 
     330             :         default:
     331           0 :             break;
     332             :     }
     333             : 
     334             :     static sal_uInt16 const aInval[] =
     335             :     {
     336             :         // Slot IDs must be sorted when calling Invalidate!
     337             :         SID_ATTRIBUTES_AREA,
     338             :         SID_INSERT_DRAW,
     339             :         0
     340             :     };
     341           0 :     GetViewFrame()->GetBindings().Invalidate(aInval);
     342             : 
     343           0 :     sal_Bool bEndTextEdit = sal_True;
     344           0 :     if (pFuncPtr)
     345             :     {
     346           0 :         if (GetDrawFuncPtr())
     347             :         {
     348           0 :             GetDrawFuncPtr()->Deactivate();
     349           0 :             SetDrawFuncPtr(NULL);
     350             :         }
     351             : 
     352           0 :         SetDrawFuncPtr(pFuncPtr);
     353           0 :         AttrChangedNotify(m_pWrtShell);
     354             : 
     355           0 :         pFuncPtr->Activate(nSlotId);
     356           0 :         NoRotate();
     357           0 :         if(rReq.GetModifier() == KEY_MOD1)
     358             :         {
     359           0 :             if(SID_OBJECT_SELECT == m_nDrawSfxId )
     360             :             {
     361           0 :                 m_pWrtShell->GotoObj(sal_True);
     362             :             }
     363             :             else
     364             :             {
     365           0 :                 pFuncPtr->CreateDefaultObject();
     366           0 :                 pFuncPtr->Deactivate();
     367           0 :                 SetDrawFuncPtr(NULL);
     368           0 :                 LeaveDrawCreate();
     369           0 :                 m_pWrtShell->EnterStdMode();
     370           0 :                 SdrView *pTmpSdrView = m_pWrtShell->GetDrawView();
     371           0 :                 const SdrMarkList& rMarkList = pTmpSdrView->GetMarkedObjectList();
     372           0 :                 if(rMarkList.GetMarkCount() == 1 &&
     373           0 :                         (SID_DRAW_TEXT == nSlotId || SID_DRAW_TEXT_VERTICAL == nSlotId ||
     374             :                             SID_DRAW_TEXT_MARQUEE == nSlotId ))
     375             :                 {
     376           0 :                     SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     377           0 :                     BeginTextEdit(pObj);
     378           0 :                     bEndTextEdit = sal_False;
     379             :                 }
     380             :             }
     381             :         }
     382             :     }
     383             :     else
     384             :     {
     385           0 :         if (m_pWrtShell->IsObjSelected() && !m_pWrtShell->IsSelFrmMode())
     386           0 :             m_pWrtShell->EnterSelFrmMode(NULL);
     387             :     }
     388             : 
     389           0 :     if(bEndTextEdit && pSdrView && pSdrView->IsTextEdit())
     390           0 :         pSdrView->SdrEndTextEdit( true );
     391             : 
     392           0 :     AttrChangedNotify(m_pWrtShell);
     393             : }
     394             : 
     395             : // End drawing
     396             : 
     397           0 : void SwView::ExitDraw()
     398             : {
     399           0 :     NoRotate();
     400             : 
     401           0 :     if(m_pShell)
     402             :     {
     403             :         // the shell may be invalid at close/reload/SwitchToViewShell
     404           0 :         SfxDispatcher* pDispatch = GetViewFrame()->GetDispatcher();
     405           0 :         sal_uInt16 nIdx = 0;
     406           0 :         SfxShell* pTest = 0;
     407           0 :         do
     408             :         {
     409           0 :             pTest = pDispatch->GetShell(nIdx++);
     410             :         }
     411           0 :         while( pTest && pTest != this && pTest != m_pShell);
     412           0 :         if(pTest == m_pShell &&
     413             :             // don't call LeaveSelFrmMode() etc. for the below,
     414             :             // because objects may still be selected:
     415           0 :             !m_pShell->ISA(SwDrawBaseShell) &&
     416           0 :             !m_pShell->ISA(SwBezierShell) &&
     417           0 :             !m_pShell->ISA(svx::ExtrusionBar) &&
     418           0 :             !m_pShell->ISA(svx::FontworkBar))
     419             :         {
     420           0 :             SdrView *pSdrView = m_pWrtShell->GetDrawView();
     421             : 
     422           0 :             if (pSdrView && pSdrView->IsGroupEntered())
     423             :             {
     424           0 :                 pSdrView->LeaveOneGroup();
     425           0 :                 pSdrView->UnmarkAll();
     426           0 :                 GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP);
     427             :             }
     428             : 
     429           0 :             if (GetDrawFuncPtr())
     430             :             {
     431           0 :                 if (m_pWrtShell->IsSelFrmMode())
     432           0 :                     m_pWrtShell->LeaveSelFrmMode();
     433           0 :                 GetDrawFuncPtr()->Deactivate();
     434             : 
     435           0 :                 SetDrawFuncPtr(NULL);
     436           0 :                 LeaveDrawCreate();
     437             : 
     438           0 :                 GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
     439             :             }
     440           0 :             GetEditWin().SetPointer(Pointer(POINTER_TEXT));
     441             :         }
     442             :     }
     443           0 : }
     444             : 
     445             : // Disable rotate mode
     446             : 
     447           0 : void SwView::NoRotate()
     448             : {
     449           0 :     if (IsDrawRotate())
     450             :     {
     451           0 :         m_pWrtShell->SetDragMode(SDRDRAG_MOVE);
     452           0 :         FlipDrawRotate();
     453             : 
     454           0 :         const SfxBoolItem aTmp( SID_OBJECT_ROTATE, false );
     455           0 :         GetViewFrame()->GetBindings().SetState( aTmp );
     456             :     }
     457           0 : }
     458             : 
     459             : // Enable DrawTextEditMode
     460             : 
     461           0 : sal_Bool SwView::EnterDrawTextMode(const Point& aDocPos)
     462             : {
     463             :     SdrObject* pObj;
     464             :     SdrPageView* pPV;
     465           0 :     SwWrtShell *pSh = &GetWrtShell();
     466           0 :     SdrView *pSdrView = pSh->GetDrawView();
     467             :     OSL_ENSURE( pSdrView, "EnterDrawTextMode without DrawView?" );
     468             : 
     469           0 :     sal_Bool bReturn = sal_False;
     470             : 
     471           0 :     sal_uInt16 nOld = pSdrView->GetHitTolerancePixel();
     472           0 :     pSdrView->SetHitTolerancePixel( 2 );
     473             : 
     474           0 :     if( pSdrView->IsMarkedHit( aDocPos ) &&
     475           0 :         !pSdrView->PickHandle( aDocPos ) && IsTextTool() &&
     476           0 :         pSdrView->PickObj( aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT ) &&
     477             : 
     478             :         // To allow SwDrawVirtObj text objects to be activated, allow their type, too.
     479           0 :         ( pObj->ISA( SdrTextObj ) ||
     480           0 :           ( pObj->ISA(SwDrawVirtObj) &&
     481           0 :             ((SwDrawVirtObj*)pObj)->GetReferencedObj().ISA(SdrTextObj) ) ) &&
     482             : 
     483           0 :         !m_pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT))
     484             :     {
     485           0 :         bReturn = BeginTextEdit( pObj, pPV, m_pEditWin, false );
     486             :     }
     487             : 
     488           0 :     pSdrView->SetHitTolerancePixel( nOld );
     489             : 
     490           0 :     return bReturn;
     491             : }
     492             : 
     493             : // Enable DrawTextEditMode
     494             : 
     495           0 : sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin,
     496             :         bool bIsNewObj, bool bSetSelectionToStart)
     497             : {
     498           0 :     SwWrtShell *pSh = &GetWrtShell();
     499           0 :     SdrView *pSdrView = pSh->GetDrawView();
     500           0 :     SdrOutliner* pOutliner = ::SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrView->GetModel());
     501           0 :     uno::Reference< linguistic2::XSpellChecker1 >  xSpell( ::GetSpellChecker() );
     502           0 :     if (pOutliner)
     503             :     {
     504           0 :         pOutliner->SetRefDevice(pSh->getIDocumentDeviceAccess()->getReferenceDevice(false));
     505           0 :         pOutliner->SetSpeller(xSpell);
     506           0 :         uno::Reference<linguistic2::XHyphenator> xHyphenator( ::GetHyphenator() );
     507           0 :         pOutliner->SetHyphenator( xHyphenator );
     508           0 :         pSh->SetCalcFieldValueHdl(pOutliner);
     509             : 
     510           0 :         sal_uInt32 nCntrl = pOutliner->GetControlWord();
     511           0 :         nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
     512           0 :         nCntrl |= EE_CNTRL_URLSFXEXECUTE;
     513             : 
     514           0 :         const SwViewOption *pOpt = pSh->GetViewOptions();
     515             : 
     516           0 :         if (SwViewOption::IsFieldShadings())
     517           0 :             nCntrl |= EE_CNTRL_MARKFIELDS;
     518             :         else
     519           0 :             nCntrl &= ~EE_CNTRL_MARKFIELDS;
     520             : 
     521           0 :         if (pOpt->IsOnlineSpell())
     522           0 :             nCntrl |= EE_CNTRL_ONLINESPELLING;
     523             :         else
     524           0 :             nCntrl &= ~EE_CNTRL_ONLINESPELLING;
     525             : 
     526           0 :         pOutliner->SetControlWord(nCntrl);
     527           0 :         const SfxPoolItem& rItem = pSh->GetDoc()->GetDefault(RES_CHRATR_LANGUAGE);
     528           0 :         pOutliner->SetDefaultLanguage(((const SvxLanguageItem&)rItem).GetLanguage());
     529             : 
     530           0 :         if( bIsNewObj )
     531           0 :             pOutliner->SetVertical( SID_DRAW_TEXT_VERTICAL == m_nDrawSfxId ||
     532           0 :                                     SID_DRAW_CAPTION_VERTICAL == m_nDrawSfxId );
     533             : 
     534             :         // set default horizontal text direction at outliner
     535             :         EEHorizontalTextDirection aDefHoriTextDir =
     536           0 :             pSh->IsShapeDefaultHoriTextDirR2L() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
     537           0 :         pOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
     538             :     }
     539             : 
     540             :     // To allow editing the referenced object from a SwDrawVirtObj here
     541             :     // the original needs to be fetched evenually. This ATM activates the
     542             :     // text edit mode for the original object.
     543           0 :     SdrObject* pToBeActivated = pObj;
     544             : 
     545             :     // Always the original object is edited. To allow the TextEdit to happen
     546             :     // where the VirtObj is positioned, on demand a occurring offset is set at
     547             :     // the TextEdit object. That offset is used for creating and managing the
     548             :     // OutlinerView.
     549           0 :     Point aNewTextEditOffset(0, 0);
     550             : 
     551           0 :     if(pObj->ISA(SwDrawVirtObj))
     552             :     {
     553           0 :         SwDrawVirtObj* pVirtObj = (SwDrawVirtObj*)pObj;
     554           0 :         pToBeActivated = &((SdrObject&)pVirtObj->GetReferencedObj());
     555           0 :         aNewTextEditOffset = pVirtObj->GetOffset();
     556             :     }
     557             : 
     558             :     // set in each case, thus it will be correct for all objects
     559           0 :     ((SdrTextObj*)pToBeActivated)->SetTextEditOffset(aNewTextEditOffset);
     560             : 
     561           0 :     bool bRet(pSdrView->SdrBeginTextEdit( pToBeActivated, pPV, pWin, true, pOutliner, 0, false, false, false ));
     562             : 
     563             :     // #i7672#
     564             :     // Since SdrBeginTextEdit actually creates the OutlinerView and thus also
     565             :     // sets the background color, an own background color needs to be set
     566             :     // after TextEditing was started. This is now done here.
     567           0 :     if(bRet)
     568             :     {
     569           0 :         OutlinerView* pView = pSdrView->GetTextEditOutlinerView();
     570             : 
     571           0 :         if(pView)
     572             :         {
     573           0 :             Color aBackground(pSh->GetShapeBackgrd());
     574           0 :             pView->SetBackgroundColor(aBackground);
     575             :         }
     576             : 
     577             :         // editing should start at the end of text, spell checking at the beginning ...
     578           0 :         ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
     579           0 :         if (bSetSelectionToStart)
     580           0 :             aNewSelection = ESelection();
     581           0 :         if (pView)
     582             :         {
     583           0 :             pView->SetSelection(aNewSelection);
     584             :         }
     585             :     }
     586             : 
     587           0 :     return bRet;
     588             : }
     589             : 
     590             : // Is a DrawTextObjekt selected?
     591             : 
     592           0 : bool SwView::IsTextTool() const
     593             : {
     594             :     sal_uInt16 nId;
     595             :     sal_uInt32 nInvent;
     596           0 :     SdrView *pSdrView = GetWrtShell().GetDrawView();
     597             :     OSL_ENSURE( pSdrView, "IsTextTool without DrawView?" );
     598             : 
     599           0 :     if (pSdrView->IsCreateMode())
     600           0 :         pSdrView->SetCreateMode(false);
     601             : 
     602           0 :     pSdrView->TakeCurrentObj(nId,nInvent);
     603           0 :     return (nInvent==SdrInventor);
     604             : }
     605             : 
     606           0 : SdrView* SwView::GetDrawView() const
     607             : {
     608           0 :     return GetWrtShell().GetDrawView();
     609             : }
     610             : 
     611           0 : bool SwView::IsBezierEditMode()
     612             : {
     613           0 :     return (!IsDrawSelMode() && GetWrtShell().GetDrawView()->HasMarkablePoints());
     614             : }
     615             : 
     616           0 : bool SwView::IsFormMode() const
     617             : {
     618           0 :     if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
     619             :     {
     620           0 :         return (GetDrawFuncPtr()->IsInsertForm());
     621             :     }
     622             : 
     623           0 :     return AreOnlyFormsSelected();
     624             : }
     625             : 
     626           0 : void SwView::SetDrawFuncPtr(SwDrawBase* pFuncPtr)
     627             : {
     628           0 :     delete m_pDrawActual;
     629           0 :     m_pDrawActual = pFuncPtr;
     630           0 : }
     631             : 
     632           0 : void SwView::SetSelDrawSlot()
     633             : {
     634           0 :     m_nDrawSfxId = SID_OBJECT_SELECT;
     635           0 :     m_sDrawCustom = "";
     636           0 : }
     637             : 
     638           0 : bool SwView::AreOnlyFormsSelected() const
     639             : {
     640           0 :     if ( GetWrtShell().IsFrmSelected() )
     641           0 :         return false;
     642             : 
     643           0 :     bool bForm = true;
     644             : 
     645           0 :     SdrView* pSdrView = GetWrtShell().GetDrawView();
     646             : 
     647           0 :     const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
     648           0 :     sal_uInt32 nCount = rMarkList.GetMarkCount();
     649             : 
     650           0 :     if (nCount)
     651             :     {
     652           0 :         for (sal_uInt32 i = 0; i < nCount; i++)
     653             :         {
     654             :             // Except controls, are still normal draw objects selected?
     655           0 :             SdrObject *pSdrObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
     656             : 
     657           0 :             if (!HasOnlyObj(pSdrObj, FmFormInventor))
     658             :             {
     659           0 :                 bForm = false;
     660           0 :                 break;
     661             :             }
     662             :         }
     663             :     }
     664             :     else
     665           0 :         bForm = false;
     666             : 
     667           0 :     return bForm;
     668             : }
     669             : 
     670           0 : sal_Bool SwView::HasDrwObj(SdrObject *pSdrObj) const
     671             : {
     672           0 :     sal_Bool bRet = sal_False;
     673             : 
     674           0 :     if (pSdrObj->IsGroupObject())
     675             :     {
     676           0 :         SdrObjList* pList = pSdrObj->GetSubList();
     677           0 :         sal_uInt32 nCnt = pList->GetObjCount();
     678             : 
     679           0 :         for (sal_uInt32 i = 0; i < nCnt; i++)
     680           0 :             if ((bRet = HasDrwObj(pList->GetObj(i))) == sal_True)
     681           0 :                 break;
     682             :     }
     683           0 :     else if (SdrInventor == pSdrObj->GetObjInventor() || pSdrObj->Is3DObj())
     684           0 :         return sal_True;
     685             : 
     686           0 :     return bRet;
     687             : }
     688             : 
     689           0 : sal_Bool SwView::HasOnlyObj(SdrObject *pSdrObj, sal_uInt32 eObjInventor) const
     690             : {
     691           0 :     sal_Bool bRet = sal_False;
     692             : 
     693           0 :     if (pSdrObj->IsGroupObject())
     694             :     {
     695           0 :         SdrObjList* pList = pSdrObj->GetSubList();
     696           0 :         sal_uInt32 nCnt = pList->GetObjCount();
     697             : 
     698           0 :         for (sal_uInt32 i = 0; i < nCnt; i++)
     699           0 :             if ((bRet = HasOnlyObj(pList->GetObj(i), eObjInventor)) == sal_False)
     700           0 :                 break;
     701             :     }
     702           0 :     else if (eObjInventor == pSdrObj->GetObjInventor())
     703           0 :         return sal_True;
     704             : 
     705           0 :     return bRet;
     706             : }
     707             : 
     708             : //#i87414# mod
     709           0 : IMPL_LINK(SwView, OnlineSpellCallback, SpellCallbackInfo*, pInfo)
     710             : {
     711           0 :     if (pInfo->nCommand == SPELLCMD_STARTSPELLDLG)
     712           0 :         GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
     713           0 :     return 0;
     714             : }
     715             : 
     716           0 : sal_Bool SwView::ExecDrwTxtSpellPopup(const Point& rPt)
     717             : {
     718           0 :     sal_Bool bRet = sal_False;
     719           0 :     SdrView *pSdrView = m_pWrtShell->GetDrawView();
     720           0 :     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
     721           0 :     Point aPos( GetEditWin().LogicToPixel( rPt ) );
     722             : 
     723           0 :     if (pOLV->IsWrongSpelledWordAtPos( aPos ))
     724             :     {
     725           0 :         bRet = sal_True;
     726           0 :         Link aLink = LINK(this, SwView, OnlineSpellCallback);
     727           0 :         pOLV->ExecuteSpellPopup( aPos,&aLink );
     728             :     }
     729           0 :     return bRet;
     730             : }
     731             : 
     732           0 : sal_Bool SwView::IsDrawTextHyphenate()
     733             : {
     734           0 :     SdrView *pSdrView = m_pWrtShell->GetDrawView();
     735           0 :     sal_Bool bHyphenate = sal_False;
     736             : 
     737           0 :     SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool(),
     738           0 :                             EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
     739           0 :     if( pSdrView->GetAttributes( aNewAttr ) &&
     740           0 :         aNewAttr.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
     741           0 :         bHyphenate = ((const SfxBoolItem&)aNewAttr.Get( EE_PARA_HYPHENATE )).
     742           0 :                         GetValue();
     743             : 
     744           0 :     return bHyphenate;
     745             : }
     746             : 
     747           0 : void SwView::HyphenateDrawText()
     748             : {
     749           0 :     SdrView *pSdrView = m_pWrtShell->GetDrawView();
     750           0 :     sal_Bool bHyphenate = IsDrawTextHyphenate();
     751             : 
     752           0 :     SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
     753           0 :     aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, !bHyphenate ) );
     754           0 :     pSdrView->SetAttributes( aSet );
     755           0 :     GetViewFrame()->GetBindings().Invalidate(FN_HYPHENATE_OPT_DLG);
     756           0 : }
     757             : 
     758             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10