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

Generated by: LCOV version 1.10