LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - editsrc.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 117 0.0 %
Date: 2014-04-14 Functions: 0 41 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             : 
      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           0 : ScHeaderFooterEditSource::ScHeaderFooterEditSource(ScHeaderFooterTextData& rData) :
      45           0 :     mrTextData(rData) {}
      46             : 
      47           0 : ScHeaderFooterEditSource::~ScHeaderFooterEditSource() {}
      48             : 
      49           0 : ScEditEngineDefaulter* ScHeaderFooterEditSource::GetEditEngine()
      50             : {
      51           0 :     return mrTextData.GetEditEngine();
      52             : }
      53             : 
      54           0 : SvxEditSource* ScHeaderFooterEditSource::Clone() const
      55             : {
      56           0 :     return new ScHeaderFooterEditSource(mrTextData);
      57             : }
      58             : 
      59           0 : SvxTextForwarder* ScHeaderFooterEditSource::GetTextForwarder()
      60             : {
      61           0 :     return mrTextData.GetTextForwarder();
      62             : }
      63             : 
      64           0 : void ScHeaderFooterEditSource::UpdateData()
      65             : {
      66           0 :     mrTextData.UpdateData();
      67           0 : }
      68             : 
      69           0 : ScCellEditSource::ScCellEditSource(ScDocShell* pDocSh, const ScAddress& rP) :
      70           0 :     pCellTextData(new ScCellTextData(pDocSh, rP)) {}
      71             : 
      72           0 : ScCellEditSource::~ScCellEditSource()
      73             : {
      74           0 :     delete pCellTextData;
      75           0 : }
      76             : 
      77           0 : SvxEditSource* ScCellEditSource::Clone() const
      78             : {
      79           0 :     return new ScCellEditSource(pCellTextData->GetDocShell(), pCellTextData->GetCellPos());
      80             : }
      81             : 
      82           0 : SvxTextForwarder* ScCellEditSource::GetTextForwarder()
      83             : {
      84           0 :     return pCellTextData->GetTextForwarder();
      85             : }
      86             : 
      87           0 : void ScCellEditSource::UpdateData()
      88             : {
      89           0 :     pCellTextData->UpdateData();
      90           0 : }
      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           0 : ScEditEngineDefaulter* ScCellEditSource::GetEditEngine()
     103             : {
     104           0 :     return pCellTextData->GetEditEngine();
     105             : }
     106             : 
     107           0 : ScAnnotationEditSource::ScAnnotationEditSource(ScDocShell* pDocSh, const ScAddress& rP) :
     108             :     pDocShell( pDocSh ),
     109             :     aCellPos( rP ),
     110             :     pEditEngine( NULL ),
     111             :     pForwarder( NULL ),
     112           0 :     bDataValid( false )
     113             : {
     114           0 :     if (pDocShell)
     115           0 :         pDocShell->GetDocument()->AddUnoObject(*this);
     116           0 : }
     117             : 
     118           0 : ScAnnotationEditSource::~ScAnnotationEditSource()
     119             : {
     120           0 :     SolarMutexGuard aGuard;     //  needed for EditEngine dtor
     121             : 
     122           0 :     if (pDocShell)
     123           0 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
     124             : 
     125           0 :     delete pForwarder;
     126           0 :     delete pEditEngine;
     127           0 : }
     128             : 
     129           0 : SvxEditSource* ScAnnotationEditSource::Clone() const
     130             : {
     131           0 :     return new ScAnnotationEditSource( pDocShell, aCellPos );
     132             : }
     133             : 
     134           0 : SdrObject* ScAnnotationEditSource::GetCaptionObj()
     135             : {
     136           0 :     ScPostIt* pNote = pDocShell->GetDocument()->GetNote(aCellPos);
     137           0 :     return pNote ? pNote->GetOrCreateCaption( aCellPos ) : 0;
     138             : }
     139             : 
     140           0 : SvxTextForwarder* ScAnnotationEditSource::GetTextForwarder()
     141             : {
     142           0 :     if (!pEditEngine)
     143             :     {
     144             :         // Notizen haben keine Felder
     145           0 :         if ( pDocShell )
     146             :         {
     147           0 :             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           0 :         pForwarder = new SvxEditEngineForwarder(*pEditEngine);
     156             :     }
     157             : 
     158           0 :     if (bDataValid)
     159           0 :         return pForwarder;
     160             : 
     161           0 :     if ( pDocShell )
     162           0 :         if ( ScPostIt* pNote = pDocShell->GetDocument()->GetNote(aCellPos) )
     163           0 :             if ( const EditTextObject* pEditObj = pNote->GetEditTextObject() )
     164           0 :                 pEditEngine->SetText( *pEditObj );      // incl. Umbrueche
     165             : 
     166           0 :     bDataValid = true;
     167           0 :     return pForwarder;
     168             : }
     169             : 
     170           0 : void ScAnnotationEditSource::UpdateData()
     171             : {
     172           0 :     if ( pDocShell && pEditEngine )
     173             :     {
     174           0 :         ScDocShellModificator aModificator( *pDocShell );
     175             : 
     176           0 :         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           0 :         aModificator.SetDocumentModified();
     189             : 
     190             :         // bDataValid wird bei SetDocumentModified zurueckgesetzt
     191             :     }
     192           0 : }
     193             : 
     194           0 : void ScAnnotationEditSource::Notify( SfxBroadcaster&, const SfxHint& rHint )
     195             : {
     196           0 :     if ( rHint.ISA( ScUpdateRefHint ) )
     197             :     {
     198             :         //! Ref-Update
     199             :     }
     200           0 :     else if ( rHint.ISA( SfxSimpleHint ) )
     201             :     {
     202           0 :         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
     203           0 :         if ( nId == SFX_HINT_DYING )
     204             :         {
     205           0 :             pDocShell = NULL;                       // ungueltig geworden
     206             : 
     207           0 :             DELETEZ( pForwarder );
     208           0 :             DELETEZ( pEditEngine );     // EditEngine uses document's pool
     209             :         }
     210           0 :         else if ( nId == SFX_HINT_DATACHANGED )
     211           0 :             bDataValid = false;                     // Text muss neu geholt werden
     212             :     }
     213           0 : }
     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           0 : ScAccessibilityEditSource::ScAccessibilityEditSource( ::std::auto_ptr < ScAccessibleTextData > pAccessibleCellTextData )
     244           0 :     : mpAccessibleTextData(pAccessibleCellTextData)
     245             : {
     246           0 : }
     247             : SAL_WNODEPRECATED_DECLARATIONS_POP
     248             : 
     249           0 : ScAccessibilityEditSource::~ScAccessibilityEditSource()
     250             : {
     251           0 : }
     252             : 
     253             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
     254           0 : SvxEditSource* ScAccessibilityEditSource::Clone() const
     255             : {
     256           0 :     return new ScAccessibilityEditSource(::std::auto_ptr < ScAccessibleTextData > (mpAccessibleTextData->Clone()));
     257             : }
     258             : SAL_WNODEPRECATED_DECLARATIONS_POP
     259             : 
     260           0 : SvxTextForwarder* ScAccessibilityEditSource::GetTextForwarder()
     261             : {
     262           0 :     return mpAccessibleTextData->GetTextForwarder();
     263             : }
     264             : 
     265           0 : SvxViewForwarder* ScAccessibilityEditSource::GetViewForwarder()
     266             : {
     267           0 :     return mpAccessibleTextData->GetViewForwarder();
     268             : }
     269             : 
     270           0 : SvxEditViewForwarder* ScAccessibilityEditSource::GetEditViewForwarder( bool bCreate )
     271             : {
     272           0 :     return mpAccessibleTextData->GetEditViewForwarder(bCreate);
     273             : }
     274             : 
     275           0 : void ScAccessibilityEditSource::UpdateData()
     276             : {
     277           0 :     mpAccessibleTextData->UpdateData();
     278           0 : }
     279             : 
     280           0 : SfxBroadcaster& ScAccessibilityEditSource::GetBroadcaster() const
     281             : {
     282           0 :     return mpAccessibleTextData->GetBroadcaster();
     283           0 : }
     284             : 
     285             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10