LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdtext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 90 0.0 %
Date: 2014-04-14 Functions: 0 14 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             : #include "svx/svdotext.hxx"
      21             : #include "svx/svdetc.hxx"
      22             : #include "editeng/outlobj.hxx"
      23             : #include "svx/svdoutl.hxx"
      24             : #include "svx/svdmodel.hxx"
      25             : #include "editeng/fhgtitem.hxx"
      26             : #include <editeng/eeitem.hxx>
      27             : #include <svl/itemset.hxx>
      28             : 
      29           0 : SdrText::SdrText( SdrTextObj& rObject, OutlinerParaObject* pOutlinerParaObject /* = 0 */ )
      30             : : mpOutlinerParaObject( pOutlinerParaObject )
      31             : , mrObject( rObject )
      32           0 : , mpModel( rObject.GetModel() )
      33           0 : , mbPortionInfoChecked( false )
      34             : {
      35             :     OSL_ENSURE(&mrObject, "SdrText created without SdrTextObj (!)");
      36           0 : }
      37             : 
      38           0 : SdrText::~SdrText()
      39             : {
      40           0 :     clearWeak();
      41           0 :     delete mpOutlinerParaObject;
      42           0 : }
      43             : 
      44           0 : void SdrText::CheckPortionInfo( SdrOutliner& rOutliner )
      45             : {
      46           0 :     if(!mbPortionInfoChecked)
      47             :     {
      48             :         // #i102062# no action when the Outliner is the HitTestOutliner,
      49             :         // this will remove WrongList info at the OPO
      50           0 :         if(mpModel && &rOutliner == &mpModel->GetHitTestOutliner())
      51           0 :             return;
      52             : 
      53             :         // TODO: optimization: we could create a BigTextObject
      54           0 :         mbPortionInfoChecked=true;
      55           0 :         if(mpOutlinerParaObject!=NULL && rOutliner.ShouldCreateBigTextObject())
      56             :         {
      57             :             // #i102062# MemoryLeak closed
      58           0 :             delete mpOutlinerParaObject;
      59           0 :             mpOutlinerParaObject = rOutliner.CreateParaObject();
      60             :         }
      61             :     }
      62             : }
      63             : 
      64           0 : void SdrText::ReformatText()
      65             : {
      66           0 :     mbPortionInfoChecked=false;
      67           0 :     mpOutlinerParaObject->ClearPortionInfo();
      68           0 : }
      69             : 
      70           0 : const SfxItemSet& SdrText::GetItemSet() const
      71             : {
      72           0 :     return const_cast< SdrText* >(this)->GetObjectItemSet();
      73             : }
      74             : 
      75           0 : void SdrText::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
      76             : {
      77           0 :     if( mpOutlinerParaObject != pTextObject )
      78             :     {
      79           0 :         if( mpModel )
      80             :         {
      81             :             // Update HitTestOutliner
      82           0 :             const SdrTextObj* pTestObj = mpModel->GetHitTestOutliner().GetTextObj();
      83           0 :             if( pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject )
      84           0 :                 mpModel->GetHitTestOutliner().SetTextObj( 0 );
      85             :         }
      86             : 
      87           0 :         delete mpOutlinerParaObject;
      88             : 
      89           0 :         mpOutlinerParaObject = pTextObject;
      90             : 
      91           0 :         mbPortionInfoChecked = false;
      92             :     }
      93           0 : }
      94             : 
      95           0 : OutlinerParaObject* SdrText::GetOutlinerParaObject() const
      96             : {
      97           0 :     return mpOutlinerParaObject;
      98             : }
      99             : 
     100             : /** returns the current OutlinerParaObject and removes it from this instance */
     101           0 : OutlinerParaObject* SdrText::RemoveOutlinerParaObject()
     102             : {
     103           0 :     if( mpModel )
     104             :     {
     105             :         // Update HitTestOutliner
     106           0 :         const SdrTextObj* pTestObj = mpModel->GetHitTestOutliner().GetTextObj();
     107           0 :         if( pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject )
     108           0 :             mpModel->GetHitTestOutliner().SetTextObj( 0 );
     109             :     }
     110             : 
     111           0 :     OutlinerParaObject* pOPO = mpOutlinerParaObject;
     112             : 
     113           0 :     mpOutlinerParaObject = 0;
     114           0 :     mbPortionInfoChecked = false;
     115             : 
     116           0 :     return pOPO;
     117             : }
     118             : 
     119           0 : void SdrText::SetModel( SdrModel* pNewModel )
     120             : {
     121           0 :     if( pNewModel == mpModel )
     122           0 :         return;
     123             : 
     124           0 :     SdrModel* pOldModel = mpModel;
     125           0 :     mpModel = pNewModel;
     126             : 
     127           0 :     if( mpOutlinerParaObject && pOldModel!=NULL && pNewModel!=NULL)
     128             :     {
     129           0 :         bool bHgtSet = GetObjectItemSet().GetItemState(EE_CHAR_FONTHEIGHT, true) == SFX_ITEM_SET;
     130             : 
     131           0 :         MapUnit aOldUnit(pOldModel->GetScaleUnit());
     132           0 :         MapUnit aNewUnit(pNewModel->GetScaleUnit());
     133           0 :         bool bScaleUnitChanged=aNewUnit!=aOldUnit;
     134             :         // Now move the OutlinerParaObject into a new Pool.
     135             :         // TODO: We should compare the DefTab and RefDevice of both Models to
     136             :         // see whether we need to use AutoGrow!
     137           0 :         sal_uIntPtr nOldFontHgt=pOldModel->GetDefaultFontHeight();
     138           0 :         sal_uIntPtr nNewFontHgt=pNewModel->GetDefaultFontHeight();
     139           0 :         bool bDefHgtChanged=nNewFontHgt!=nOldFontHgt;
     140           0 :         bool bSetHgtItem=bDefHgtChanged && !bHgtSet;
     141           0 :         if (bSetHgtItem)
     142             :         {
     143             :             // fix the value of HeightItem, so
     144             :             // 1. it remains and
     145             :             // 2. DoStretchChars gets the right value
     146           0 :             SetObjectItem(SvxFontHeightItem(nOldFontHgt, 100, EE_CHAR_FONTHEIGHT));
     147             :         }
     148             :         // now use the Outliner, etc. so the above SetAttr can work at all
     149           0 :         SdrOutliner& rOutliner = mrObject.ImpGetDrawOutliner();
     150           0 :         rOutliner.SetText(*mpOutlinerParaObject);
     151           0 :         delete mpOutlinerParaObject;
     152           0 :         mpOutlinerParaObject=0;
     153           0 :         if (bScaleUnitChanged)
     154             :         {
     155           0 :             Fraction aMetricFactor=GetMapFactor(aOldUnit,aNewUnit).X();
     156             : 
     157           0 :             if (bSetHgtItem)
     158             :             {
     159             :                 // Now correct the frame attribute
     160           0 :                 nOldFontHgt=BigMulDiv(nOldFontHgt,aMetricFactor.GetNumerator(),aMetricFactor.GetDenominator());
     161           0 :                 SetObjectItem(SvxFontHeightItem(nOldFontHgt, 100, EE_CHAR_FONTHEIGHT));
     162             :             }
     163             :         }
     164           0 :         SetOutlinerParaObject(rOutliner.CreateParaObject());
     165           0 :         mpOutlinerParaObject->ClearPortionInfo();
     166           0 :         mbPortionInfoChecked=false;
     167           0 :         rOutliner.Clear();
     168             :     }
     169             : }
     170             : 
     171           0 : void SdrText::ForceOutlinerParaObject( sal_uInt16 nOutlMode )
     172             : {
     173           0 :     if( mpModel && !mpOutlinerParaObject )
     174             :     {
     175           0 :         Outliner* pOutliner = SdrMakeOutliner( nOutlMode, mpModel );
     176           0 :         if( pOutliner )
     177             :         {
     178           0 :             Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
     179           0 :             pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
     180             : 
     181           0 :             pOutliner->SetStyleSheet( 0, GetStyleSheet());
     182           0 :             OutlinerParaObject* pOutlinerParaObject = pOutliner->CreateParaObject();
     183           0 :             SetOutlinerParaObject( pOutlinerParaObject );
     184             : 
     185           0 :             delete pOutliner;
     186             :         }
     187             :     }
     188           0 : }
     189             : 
     190           0 : const SfxItemSet& SdrText::GetObjectItemSet()
     191             : {
     192           0 :     return mrObject.GetObjectItemSet();
     193             : }
     194             : 
     195           0 : void SdrText::SetObjectItem(const SfxPoolItem& rItem)
     196             : {
     197           0 :     mrObject.SetObjectItem( rItem );
     198           0 : }
     199             : 
     200           0 : SfxStyleSheet* SdrText::GetStyleSheet() const
     201             : {
     202           0 :     return mrObject.GetStyleSheet();
     203             : }
     204             : 
     205             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10