LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuoltext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 89 0.0 %
Date: 2014-04-14 Functions: 0 18 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 "fuoltext.hxx"
      21             : 
      22             : #include <sfx2/viewfrm.hxx>
      23             : #include <editeng/outliner.hxx>
      24             : #include <editeng/eeitem.hxx>
      25             : #include <editeng/flditem.hxx>
      26             : #include <sfx2/bindings.hxx>
      27             : #include <sfx2/docfile.hxx>
      28             : #include <sfx2/dispatch.hxx>
      29             : 
      30             : #include <svx/svxids.hrc>
      31             : #include "app.hrc"
      32             : #include "OutlineView.hxx"
      33             : #include "Window.hxx"
      34             : #include "DrawDocShell.hxx"
      35             : #include "ViewShell.hxx"
      36             : #include "OutlineViewShell.hxx"
      37             : 
      38             : #include <stdio.h>
      39             : 
      40             : namespace sd {
      41             : 
      42             : static sal_uInt16 SidArray[] = {
      43             :                 SID_STYLE_FAMILY2,
      44             :                 SID_STYLE_FAMILY3,
      45             :                 SID_STYLE_FAMILY5,
      46             :                 SID_STYLE_UPDATE_BY_EXAMPLE,
      47             :                 SID_CUT,
      48             :                 SID_COPY,
      49             :                 SID_PASTE,
      50             :                 SID_SELECTALL,
      51             :                 SID_ATTR_CHAR_FONT,
      52             :                 SID_ATTR_CHAR_POSTURE,
      53             :                 SID_ATTR_CHAR_WEIGHT,
      54             :                 SID_ATTR_CHAR_SHADOWED,
      55             :                 SID_ATTR_CHAR_STRIKEOUT,
      56             :                 SID_ATTR_CHAR_UNDERLINE,
      57             :                 SID_ATTR_CHAR_FONTHEIGHT,
      58             :                 SID_ATTR_CHAR_COLOR,
      59             :                 SID_ATTR_CHAR_KERNING,
      60             :                 SID_OUTLINE_UP,
      61             :                 SID_OUTLINE_DOWN,
      62             :                 SID_OUTLINE_LEFT,
      63             :                 SID_OUTLINE_RIGHT,
      64             :                 //SID_OUTLINE_FORMAT,
      65             :                 SID_OUTLINE_COLLAPSE_ALL,
      66             :                 //SID_OUTLINE_BULLET,
      67             :                 SID_OUTLINE_COLLAPSE,
      68             :                 SID_OUTLINE_EXPAND_ALL,
      69             :                 SID_OUTLINE_EXPAND,
      70             :                 SID_SET_SUPER_SCRIPT,
      71             :                 SID_SET_SUB_SCRIPT,
      72             :                 SID_HYPERLINK_GETLINK,
      73             :                 SID_PRESENTATION_TEMPLATES,
      74             :                 SID_STATUS_PAGE,
      75             :                 SID_STATUS_LAYOUT,
      76             :                 SID_EXPAND_PAGE,
      77             :                 SID_SUMMARY_PAGE,
      78             :                 SID_PARASPACE_INCREASE,
      79             :                 SID_PARASPACE_DECREASE,
      80             :                 0 };
      81             : 
      82           0 : TYPEINIT1( FuOutlineText, FuOutline );
      83             : 
      84             : 
      85           0 : FuOutlineText::FuOutlineText(ViewShell* pViewShell, ::sd::Window* pWindow,
      86             :                              ::sd::View* pView, SdDrawDocument* pDoc,
      87             :                              SfxRequest& rReq)
      88           0 :        : FuOutline(pViewShell, pWindow, pView, pDoc, rReq)
      89             : {
      90           0 : }
      91             : 
      92           0 : rtl::Reference<FuPoor> FuOutlineText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      93             : {
      94           0 :     rtl::Reference<FuPoor> xFunc( new FuOutlineText( pViewSh, pWin, pView, pDoc, rReq ) );
      95           0 :     xFunc->DoExecute( rReq );
      96           0 :     return xFunc;
      97             : }
      98             : 
      99             : 
     100           0 : sal_Bool FuOutlineText::MouseButtonDown(const MouseEvent& rMEvt)
     101             : {
     102           0 :     mpWindow->GrabFocus();
     103             : 
     104           0 :     sal_Bool bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseButtonDown(rMEvt);
     105             : 
     106           0 :     if (bReturn)
     107             :     {
     108             :         // Now the attributs of the current text position can be different
     109           0 :         mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
     110             :     }
     111             :     else
     112             :     {
     113           0 :         bReturn = FuOutline::MouseButtonDown(rMEvt);
     114             :     }
     115             : 
     116           0 :     return (bReturn);
     117             : }
     118             : 
     119             : 
     120           0 : sal_Bool FuOutlineText::MouseMove(const MouseEvent& rMEvt)
     121             : {
     122           0 :     sal_Bool bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseMove(rMEvt);
     123             : 
     124           0 :     if (!bReturn)
     125             :     {
     126           0 :         bReturn = FuOutline::MouseMove(rMEvt);
     127             :     }
     128             : 
     129           0 :     return (bReturn);
     130             : }
     131             : 
     132             : 
     133           0 : sal_Bool FuOutlineText::MouseButtonUp(const MouseEvent& rMEvt)
     134             : {
     135           0 :     sal_Bool bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseButtonUp(rMEvt);
     136             : 
     137           0 :     if (bReturn)
     138             :     {
     139             :         // Now the attributs of the current text position can be different
     140           0 :         mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
     141             :     }
     142             :     else
     143             :     {
     144           0 :         const SvxFieldItem* pFieldItem = pOutlineView->GetViewByWindow( mpWindow )->GetFieldUnderMousePointer();
     145           0 :         if( pFieldItem )
     146             :         {
     147           0 :             const SvxFieldData* pField = pFieldItem->GetField();
     148             : 
     149           0 :             if( pField && pField->ISA( SvxURLField ) )
     150             :             {
     151           0 :                 bReturn = sal_True;
     152           0 :                 mpWindow->ReleaseMouse();
     153           0 :                 SfxStringItem aStrItem( SID_FILE_NAME, ( (SvxURLField*) pField)->GetURL() );
     154           0 :                 SfxStringItem aReferer( SID_REFERER, mpDocSh->GetMedium()->GetName() );
     155           0 :                 SfxBoolItem aBrowseItem( SID_BROWSE, true );
     156           0 :                 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
     157             : 
     158           0 :                 if ( rMEvt.IsMod1() )
     159             :                 {
     160             :                     // open in new frame
     161             :                     pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
     162           0 :                                 &aStrItem, &aBrowseItem, &aReferer, 0L);
     163             :                 }
     164             :                 else
     165             :                 {
     166             :                     // open in current frame
     167           0 :                     SfxFrameItem aFrameItem( SID_DOCFRAME, pFrame );
     168             :                     pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
     169           0 :                                 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
     170           0 :                 }
     171             :             }
     172             :         }
     173             :     }
     174             : 
     175           0 :     if( !bReturn )
     176           0 :         bReturn = FuOutline::MouseButtonUp(rMEvt);
     177             : 
     178           0 :     return (bReturn);
     179             : }
     180             : 
     181             : /**
     182             :  * Process keyboard input
     183             :  * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
     184             :  */
     185           0 : sal_Bool FuOutlineText::KeyInput(const KeyEvent& rKEvt)
     186             : {
     187           0 :     sal_Bool bReturn = sal_False;
     188             : 
     189           0 :     sal_uInt16 nKeyGroup = rKEvt.GetKeyCode().GetGroup();
     190           0 :     if( !mpDocSh->IsReadOnly() || nKeyGroup == KEYGROUP_CURSOR )
     191             :     {
     192           0 :         mpWindow->GrabFocus();
     193             : 
     194           0 :         boost::scoped_ptr< OutlineViewModelChangeGuard > aGuard;
     195           0 :         if( (nKeyGroup != KEYGROUP_CURSOR) && (nKeyGroup != KEYGROUP_FKEYS) )
     196           0 :             aGuard.reset( new OutlineViewModelChangeGuard( *pOutlineView ) );
     197             : 
     198           0 :         bReturn = pOutlineView->GetViewByWindow(mpWindow)->PostKeyEvent(rKEvt);
     199             : 
     200           0 :         if (bReturn)
     201             :         {
     202           0 :             UpdateForKeyPress (rKEvt);
     203             :         }
     204             :         else
     205             :         {
     206           0 :             bReturn = FuOutline::KeyInput(rKEvt);
     207           0 :         }
     208             :     }
     209             : 
     210           0 :     return (bReturn);
     211             : }
     212             : 
     213           0 : void FuOutlineText::UpdateForKeyPress (const KeyEvent& rEvent)
     214             : {
     215             :     // Attributes at the current text position may have changed.
     216           0 :     mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
     217             : 
     218           0 :     bool bUpdatePreview = true;
     219           0 :     switch (rEvent.GetKeyCode().GetCode())
     220             :     {
     221             :         // When just the cursor has been moved the preview only changes when
     222             :         // it moved to entries of another page.  To prevent unnecessary
     223             :         // updates we check this here.  This is an early rejection test, so
     224             :         // missing a key is not a problem.
     225             :         case KEY_UP:
     226             :         case KEY_DOWN:
     227             :         case KEY_LEFT:
     228             :         case KEY_RIGHT:
     229             :         case KEY_HOME:
     230             :         case KEY_END:
     231             :         case KEY_PAGEUP:
     232             :         case KEY_PAGEDOWN:
     233             :         {
     234           0 :             SdPage* pCurrentPage = pOutlineViewShell->GetActualPage();
     235           0 :             bUpdatePreview = (pCurrentPage != pOutlineViewShell->GetActualPage());
     236             :         }
     237           0 :         break;
     238             :     }
     239           0 :     if (bUpdatePreview)
     240           0 :         pOutlineViewShell->UpdatePreview (pOutlineViewShell->GetActualPage());
     241           0 : }
     242             : 
     243             : 
     244             : 
     245             : 
     246           0 : void FuOutlineText::Activate()
     247             : {
     248           0 :     FuOutline::Activate();
     249           0 : }
     250             : 
     251             : 
     252           0 : void FuOutlineText::Deactivate()
     253             : {
     254           0 :     FuOutline::Deactivate();
     255           0 : }
     256             : 
     257             : /**
     258             :  * Cut object to clipboard
     259             :  */
     260           0 : void FuOutlineText::DoCut()
     261             : {
     262           0 :     pOutlineView->GetViewByWindow(mpWindow)->Cut();
     263           0 : }
     264             : 
     265             : /**
     266             :  * Copy object to clipboard
     267             :  */
     268           0 : void FuOutlineText::DoCopy()
     269             : {
     270           0 :     pOutlineView->GetViewByWindow(mpWindow)->Copy();
     271           0 : }
     272             : 
     273             : /**
     274             :  * Paste object from clipboard
     275             :  */
     276           0 : void FuOutlineText::DoPaste()
     277             : {
     278           0 :     pOutlineView->GetViewByWindow(mpWindow)->PasteSpecial();
     279           0 : }
     280             : 
     281             : /**
     282             :  * Paste object as unformatted text from clipboard
     283             :  */
     284           0 : void FuOutlineText::DoPasteUnformatted()
     285             : {
     286           0 :    TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpViewShell->GetActiveWindow() ) );
     287           0 :    if (aDataHelper.GetTransferable().is())
     288             :    {
     289           0 :        OUString aText;
     290           0 :        if (aDataHelper.GetString(FORMAT_STRING, aText))
     291           0 :            pOutlineView->GetViewByWindow(mpWindow)->InsertText(aText);
     292           0 :    }
     293           0 : }
     294             : 
     295             : 
     296             : 
     297             : } // end of namespace sd
     298             : 
     299             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10