LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - editsrc.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 89 117 76.1 %
Date: 2014-04-11 Functions: 32 41 78.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             : 
      21             : #include "editsrc.hxx"
      22             : 
      23             : #include "scitems.hxx"
      24             : #include <editeng/eeitem.hxx>
      25             : #include <editeng/unofored.hxx>
      26             : #include <vcl/svapp.hxx>
      27             : #include <svx/svdpage.hxx>
      28             : #include <svx/svditer.hxx>
      29             : #include <svx/svdocapt.hxx>
      30             : #include <editeng/outlobj.hxx>
      31             : #include <editeng/editobj.hxx>
      32             : #include <editeng/outliner.hxx>
      33             : #include "textuno.hxx"
      34             : #include "editutil.hxx"
      35             : #include "docsh.hxx"
      36             : #include "docfunc.hxx"
      37             : #include "hints.hxx"
      38             : #include "patattr.hxx"
      39             : #include "drwlayer.hxx"
      40             : #include "userdat.hxx"
      41             : #include "postit.hxx"
      42             : #include "AccessibleText.hxx"
      43             : 
      44        8915 : ScHeaderFooterEditSource::ScHeaderFooterEditSource(ScHeaderFooterTextData& rData) :
      45        8915 :     mrTextData(rData) {}
      46             : 
      47       16527 : ScHeaderFooterEditSource::~ScHeaderFooterEditSource() {}
      48             : 
      49          37 : ScEditEngineDefaulter* ScHeaderFooterEditSource::GetEditEngine()
      50             : {
      51          37 :     return mrTextData.GetEditEngine();
      52             : }
      53             : 
      54        6666 : SvxEditSource* ScHeaderFooterEditSource::Clone() const
      55             : {
      56        6666 :     return new ScHeaderFooterEditSource(mrTextData);
      57             : }
      58             : 
      59       53936 : SvxTextForwarder* ScHeaderFooterEditSource::GetTextForwarder()
      60             : {
      61       53936 :     return mrTextData.GetTextForwarder();
      62             : }
      63             : 
      64        3798 : void ScHeaderFooterEditSource::UpdateData()
      65             : {
      66        3798 :     mrTextData.UpdateData();
      67        3798 : }
      68             : 
      69          51 : ScCellEditSource::ScCellEditSource(ScDocShell* pDocSh, const ScAddress& rP) :
      70          51 :     pCellTextData(new ScCellTextData(pDocSh, rP)) {}
      71             : 
      72         153 : ScCellEditSource::~ScCellEditSource()
      73             : {
      74          51 :     delete pCellTextData;
      75         102 : }
      76             : 
      77          29 : SvxEditSource* ScCellEditSource::Clone() const
      78             : {
      79          29 :     return new ScCellEditSource(pCellTextData->GetDocShell(), pCellTextData->GetCellPos());
      80             : }
      81             : 
      82        1543 : SvxTextForwarder* ScCellEditSource::GetTextForwarder()
      83             : {
      84        1543 :     return pCellTextData->GetTextForwarder();
      85             : }
      86             : 
      87         214 : void ScCellEditSource::UpdateData()
      88             : {
      89         214 :     pCellTextData->UpdateData();
      90         214 : }
      91             : 
      92           0 : void ScCellEditSource::SetDoUpdateData(bool bValue)
      93             : {
      94           0 :     pCellTextData->SetDoUpdate(bValue);
      95           0 : }
      96             : 
      97           0 : bool ScCellEditSource::IsDirty() const
      98             : {
      99           0 :     return pCellTextData->IsDirty();
     100             : }
     101             : 
     102          49 : ScEditEngineDefaulter* ScCellEditSource::GetEditEngine()
     103             : {
     104          49 :     return pCellTextData->GetEditEngine();
     105             : }
     106             : 
     107           8 : ScAnnotationEditSource::ScAnnotationEditSource(ScDocShell* pDocSh, const ScAddress& rP) :
     108             :     pDocShell( pDocSh ),
     109             :     aCellPos( rP ),
     110             :     pEditEngine( NULL ),
     111             :     pForwarder( NULL ),
     112           8 :     bDataValid( false )
     113             : {
     114           8 :     if (pDocShell)
     115           8 :         pDocShell->GetDocument()->AddUnoObject(*this);
     116           8 : }
     117             : 
     118          20 : ScAnnotationEditSource::~ScAnnotationEditSource()
     119             : {
     120           8 :     SolarMutexGuard aGuard;     //  needed for EditEngine dtor
     121             : 
     122           8 :     if (pDocShell)
     123           7 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
     124             : 
     125           8 :     delete pForwarder;
     126           8 :     delete pEditEngine;
     127          12 : }
     128             : 
     129           4 : SvxEditSource* ScAnnotationEditSource::Clone() const
     130             : {
     131           4 :     return new ScAnnotationEditSource( pDocShell, aCellPos );
     132             : }
     133             : 
     134           1 : SdrObject* ScAnnotationEditSource::GetCaptionObj()
     135             : {
     136           1 :     ScPostIt* pNote = pDocShell->GetDocument()->GetNote(aCellPos);
     137           1 :     return pNote ? pNote->GetOrCreateCaption( aCellPos ) : 0;
     138             : }
     139             : 
     140          22 : SvxTextForwarder* ScAnnotationEditSource::GetTextForwarder()
     141             : {
     142          22 :     if (!pEditEngine)
     143             :     {
     144             :         // Notizen haben keine Felder
     145           4 :         if ( pDocShell )
     146             :         {
     147           4 :             pEditEngine = new ScNoteEditEngine( pDocShell->GetDocument()->GetNoteEngine() );
     148             :         }
     149             :         else
     150             :         {
     151           0 :             SfxItemPool* pEnginePool = EditEngine::CreatePool();
     152           0 :             pEnginePool->FreezeIdRanges();
     153           0 :             pEditEngine = new ScEditEngineDefaulter( pEnginePool, true );
     154             :         }
     155           4 :         pForwarder = new SvxEditEngineForwarder(*pEditEngine);
     156             :     }
     157             : 
     158          22 :     if (bDataValid)
     159          17 :         return pForwarder;
     160             : 
     161           5 :     if ( pDocShell )
     162           5 :         if ( ScPostIt* pNote = pDocShell->GetDocument()->GetNote(aCellPos) )
     163           3 :             if ( const EditTextObject* pEditObj = pNote->GetEditTextObject() )
     164           3 :                 pEditEngine->SetText( *pEditObj );      // incl. Umbrueche
     165             : 
     166           5 :     bDataValid = true;
     167           5 :     return pForwarder;
     168             : }
     169             : 
     170           1 : void ScAnnotationEditSource::UpdateData()
     171             : {
     172           1 :     if ( pDocShell && pEditEngine )
     173             :     {
     174           1 :         ScDocShellModificator aModificator( *pDocShell );
     175             : 
     176           1 :         if( SdrObject* pObj = GetCaptionObj() )
     177             :         {
     178           0 :             EditTextObject* pEditObj = pEditEngine->CreateTextObject();
     179           0 :             OutlinerParaObject* pOPO = new OutlinerParaObject( *pEditObj );
     180           0 :             delete pEditObj;
     181           0 :             pOPO->SetOutlinerMode( OUTLINERMODE_TEXTOBJECT );
     182           0 :             pObj->NbcSetOutlinerParaObject( pOPO );
     183           0 :             pObj->ActionChanged();
     184             :         }
     185             : 
     186             :         //! Undo !!!
     187             : 
     188           1 :         aModificator.SetDocumentModified();
     189             : 
     190             :         // bDataValid wird bei SetDocumentModified zurueckgesetzt
     191             :     }
     192           1 : }
     193             : 
     194           5 : void ScAnnotationEditSource::Notify( SfxBroadcaster&, const SfxHint& rHint )
     195             : {
     196           5 :     if ( rHint.ISA( ScUpdateRefHint ) )
     197             :     {
     198             :         //! Ref-Update
     199             :     }
     200           5 :     else if ( rHint.ISA( SfxSimpleHint ) )
     201             :     {
     202           5 :         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
     203           5 :         if ( nId == SFX_HINT_DYING )
     204             :         {
     205           1 :             pDocShell = NULL;                       // ungueltig geworden
     206             : 
     207           1 :             DELETEZ( pForwarder );
     208           1 :             DELETEZ( pEditEngine );     // EditEngine uses document's pool
     209             :         }
     210           4 :         else if ( nId == SFX_HINT_DATACHANGED )
     211           4 :             bDataValid = false;                     // Text muss neu geholt werden
     212             :     }
     213           5 : }
     214             : 
     215           0 : ScSimpleEditSource::ScSimpleEditSource( SvxTextForwarder* pForw ) :
     216           0 :     pForwarder( pForw )
     217             : {
     218             :     //  The same forwarder (and EditEngine) is shared by all children of the same Text object.
     219             :     //  Text range and cursor keep a reference to their parent text, so the text object is
     220             :     //  always alive and the forwarder is valid as long as there are children.
     221           0 : }
     222             : 
     223           0 : ScSimpleEditSource::~ScSimpleEditSource()
     224             : {
     225           0 : }
     226             : 
     227           0 : SvxEditSource* ScSimpleEditSource::Clone() const
     228             : {
     229           0 :     return new ScSimpleEditSource( pForwarder );
     230             : }
     231             : 
     232           0 : SvxTextForwarder* ScSimpleEditSource::GetTextForwarder()
     233             : {
     234           0 :     return pForwarder;
     235             : }
     236             : 
     237           0 : void ScSimpleEditSource::UpdateData()
     238             : {
     239             :     //  nothing
     240           0 : }
     241             : 
     242             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
     243          32 : ScAccessibilityEditSource::ScAccessibilityEditSource( ::std::auto_ptr < ScAccessibleTextData > pAccessibleCellTextData )
     244          32 :     : mpAccessibleTextData(pAccessibleCellTextData)
     245             : {
     246          32 : }
     247             : SAL_WNODEPRECATED_DECLARATIONS_POP
     248             : 
     249          48 : ScAccessibilityEditSource::~ScAccessibilityEditSource()
     250             : {
     251          48 : }
     252             : 
     253             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
     254           2 : SvxEditSource* ScAccessibilityEditSource::Clone() const
     255             : {
     256           2 :     return new ScAccessibilityEditSource(::std::auto_ptr < ScAccessibleTextData > (mpAccessibleTextData->Clone()));
     257             : }
     258             : SAL_WNODEPRECATED_DECLARATIONS_POP
     259             : 
     260         519 : SvxTextForwarder* ScAccessibilityEditSource::GetTextForwarder()
     261             : {
     262         519 :     return mpAccessibleTextData->GetTextForwarder();
     263             : }
     264             : 
     265         139 : SvxViewForwarder* ScAccessibilityEditSource::GetViewForwarder()
     266             : {
     267         139 :     return mpAccessibleTextData->GetViewForwarder();
     268             : }
     269             : 
     270          60 : SvxEditViewForwarder* ScAccessibilityEditSource::GetEditViewForwarder( bool bCreate )
     271             : {
     272          60 :     return mpAccessibleTextData->GetEditViewForwarder(bCreate);
     273             : }
     274             : 
     275           0 : void ScAccessibilityEditSource::UpdateData()
     276             : {
     277           0 :     mpAccessibleTextData->UpdateData();
     278           0 : }
     279             : 
     280          42 : SfxBroadcaster& ScAccessibilityEditSource::GetBroadcaster() const
     281             : {
     282          42 :     return mpAccessibleTextData->GetBroadcaster();
     283         102 : }
     284             : 
     285             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10