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

Generated by: LCOV version 1.10