LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuoltext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 90 1.1 %
Date: 2015-06-13 12:38:46 Functions: 2 20 10.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           0 : FuOutlineText::FuOutlineText(ViewShell* pViewShell, ::sd::Window* pWindow,
      85             :                              ::sd::View* pView, SdDrawDocument* pDoc,
      86             :                              SfxRequest& rReq)
      87           0 :        : FuOutline(pViewShell, pWindow, pView, pDoc, rReq)
      88             : {
      89           0 : }
      90             : 
      91           0 : rtl::Reference<FuPoor> FuOutlineText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      92             : {
      93           0 :     rtl::Reference<FuPoor> xFunc( new FuOutlineText( pViewSh, pWin, pView, pDoc, rReq ) );
      94           0 :     xFunc->DoExecute( rReq );
      95           0 :     return xFunc;
      96             : }
      97             : 
      98           0 : bool FuOutlineText::MouseButtonDown(const MouseEvent& rMEvt)
      99             : {
     100           0 :     mpWindow->GrabFocus();
     101             : 
     102           0 :     bool bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseButtonDown(rMEvt);
     103             : 
     104           0 :     if (bReturn)
     105             :     {
     106             :         // Now the attributes of the current text position can be different
     107           0 :         mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
     108             :     }
     109             :     else
     110             :     {
     111           0 :         bReturn = FuOutline::MouseButtonDown(rMEvt);
     112             :     }
     113             : 
     114           0 :     return bReturn;
     115             : }
     116             : 
     117           0 : bool FuOutlineText::MouseMove(const MouseEvent& rMEvt)
     118             : {
     119           0 :     bool bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseMove(rMEvt);
     120             : 
     121           0 :     if (!bReturn)
     122             :     {
     123           0 :         bReturn = FuOutline::MouseMove(rMEvt);
     124             :     }
     125             : 
     126           0 :     return bReturn;
     127             : }
     128             : 
     129           0 : bool FuOutlineText::MouseButtonUp(const MouseEvent& rMEvt)
     130             : {
     131           0 :     bool bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseButtonUp(rMEvt);
     132             : 
     133           0 :     if (bReturn)
     134             :     {
     135             :         // Now the attributes of the current text position can be different
     136           0 :         mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
     137             :     }
     138             :     else
     139             :     {
     140           0 :         const SvxFieldItem* pFieldItem = pOutlineView->GetViewByWindow( mpWindow )->GetFieldUnderMousePointer();
     141           0 :         if( pFieldItem )
     142             :         {
     143           0 :             const SvxFieldData* pField = pFieldItem->GetField();
     144             : 
     145           0 :             if( pField && pField->ISA( SvxURLField ) )
     146             :             {
     147           0 :                 bReturn = true;
     148           0 :                 mpWindow->ReleaseMouse();
     149           0 :                 SfxStringItem aStrItem( SID_FILE_NAME, static_cast<const SvxURLField*>(pField)->GetURL() );
     150           0 :                 SfxStringItem aReferer( SID_REFERER, mpDocSh->GetMedium()->GetName() );
     151           0 :                 SfxBoolItem aBrowseItem( SID_BROWSE, true );
     152           0 :                 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
     153             : 
     154           0 :                 if ( rMEvt.IsMod1() )
     155             :                 {
     156             :                     // open in new frame
     157             :                     pFrame->GetDispatcher()->Execute(SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
     158           0 :                                 &aStrItem, &aBrowseItem, &aReferer, 0L);
     159             :                 }
     160             :                 else
     161             :                 {
     162             :                     // open in current frame
     163           0 :                     SfxFrameItem aFrameItem( SID_DOCFRAME, pFrame );
     164             :                     pFrame->GetDispatcher()->Execute(SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
     165           0 :                                 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
     166           0 :                 }
     167             :             }
     168             :         }
     169             :     }
     170             : 
     171           0 :     if( !bReturn )
     172           0 :         bReturn = FuOutline::MouseButtonUp(rMEvt);
     173             : 
     174           0 :     return bReturn;
     175             : }
     176             : 
     177             : /**
     178             :  * Process keyboard input
     179             :  * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
     180             :  */
     181           0 : bool FuOutlineText::KeyInput(const KeyEvent& rKEvt)
     182             : {
     183           0 :     bool bReturn = false;
     184             : 
     185           0 :     sal_uInt16 nKeyGroup = rKEvt.GetKeyCode().GetGroup();
     186           0 :     if( !mpDocSh->IsReadOnly() || nKeyGroup == KEYGROUP_CURSOR )
     187             :     {
     188           0 :         mpWindow->GrabFocus();
     189             : 
     190           0 :         boost::scoped_ptr< OutlineViewModelChangeGuard > aGuard;
     191           0 :         if( (nKeyGroup != KEYGROUP_CURSOR) && (nKeyGroup != KEYGROUP_FKEYS) )
     192           0 :             aGuard.reset( new OutlineViewModelChangeGuard( *pOutlineView ) );
     193             : 
     194           0 :         bReturn = pOutlineView->GetViewByWindow(mpWindow)->PostKeyEvent(rKEvt);
     195             : 
     196           0 :         if (bReturn)
     197             :         {
     198           0 :             UpdateForKeyPress (rKEvt);
     199             :         }
     200             :         else
     201             :         {
     202           0 :             bReturn = FuOutline::KeyInput(rKEvt);
     203           0 :         }
     204             :     }
     205             : 
     206           0 :     return bReturn;
     207             : }
     208             : 
     209           0 : void FuOutlineText::UpdateForKeyPress (const KeyEvent& rEvent)
     210             : {
     211             :     // Attributes at the current text position may have changed.
     212           0 :     mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
     213             : 
     214           0 :     bool bUpdatePreview = true;
     215           0 :     switch (rEvent.GetKeyCode().GetCode())
     216             :     {
     217             :         // When just the cursor has been moved the preview only changes when
     218             :         // it moved to entries of another page.  To prevent unnecessary
     219             :         // updates we check this here.  This is an early rejection test, so
     220             :         // missing a key is not a problem.
     221             :         case KEY_UP:
     222             :         case KEY_DOWN:
     223             :         case KEY_LEFT:
     224             :         case KEY_RIGHT:
     225             :         case KEY_HOME:
     226             :         case KEY_END:
     227             :         case KEY_PAGEUP:
     228             :         case KEY_PAGEDOWN:
     229             :         {
     230           0 :             SdPage* pCurrentPage = pOutlineViewShell->GetActualPage();
     231           0 :             bUpdatePreview = (pCurrentPage != pOutlineViewShell->GetActualPage());
     232             :         }
     233           0 :         break;
     234             :     }
     235           0 :     if (bUpdatePreview)
     236           0 :         pOutlineViewShell->UpdatePreview (pOutlineViewShell->GetActualPage());
     237           0 : }
     238             : 
     239           0 : void FuOutlineText::Activate()
     240             : {
     241           0 :     FuOutline::Activate();
     242           0 : }
     243             : 
     244           0 : void FuOutlineText::Deactivate()
     245             : {
     246           0 :     FuOutline::Deactivate();
     247           0 : }
     248             : 
     249             : /**
     250             :  * Cut object to clipboard
     251             :  */
     252           0 : void FuOutlineText::DoCut()
     253             : {
     254           0 :     pOutlineView->GetViewByWindow(mpWindow)->Cut();
     255           0 : }
     256             : 
     257             : /**
     258             :  * Copy object to clipboard
     259             :  */
     260           0 : void FuOutlineText::DoCopy()
     261             : {
     262           0 :     pOutlineView->GetViewByWindow(mpWindow)->Copy();
     263           0 : }
     264             : 
     265             : /**
     266             :  * Paste object from clipboard
     267             :  */
     268           0 : void FuOutlineText::DoPaste()
     269             : {
     270           0 :     pOutlineView->GetViewByWindow(mpWindow)->PasteSpecial();
     271           0 : }
     272             : 
     273             : /**
     274             :  * Paste object as unformatted text from clipboard
     275             :  */
     276           0 : void FuOutlineText::DoPasteUnformatted()
     277             : {
     278           0 :    TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpViewShell->GetActiveWindow() ) );
     279           0 :    if (aDataHelper.GetTransferable().is())
     280             :    {
     281           0 :        OUString aText;
     282           0 :        if (aDataHelper.GetString(SotClipboardFormatId::STRING, aText))
     283           0 :            pOutlineView->GetViewByWindow(mpWindow)->InsertText(aText);
     284           0 :    }
     285           0 : }
     286             : 
     287          66 : } // end of namespace sd
     288             : 
     289             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11