LCOV - code coverage report
Current view: top level - svx/source/sdr/properties - textproperties.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 179 263 68.1 %
Date: 2012-08-25 Functions: 11 14 78.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 180 384 46.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <svx/sdr/properties/textproperties.hxx>
      30                 :            : #include <svl/itemset.hxx>
      31                 :            : #include <svl/style.hxx>
      32                 :            : #include <svl/itemiter.hxx>
      33                 :            : #include <svl/smplhint.hxx>
      34                 :            : #include <svx/svddef.hxx>
      35                 :            : #include <svx/svdotext.hxx>
      36                 :            : #include <svx/svdoutl.hxx>
      37                 :            : #include <editeng/writingmodeitem.hxx>
      38                 :            : #include <svx/svdmodel.hxx>
      39                 :            : #include <editeng/outlobj.hxx>
      40                 :            : #include <svx/xflclit.hxx>
      41                 :            : #include <editeng/adjitem.hxx>
      42                 :            : #include <svx/svdetc.hxx>
      43                 :            : #include <editeng/editeng.hxx>
      44                 :            : #include <editeng/flditem.hxx>
      45                 :            : #include <svx/xlnwtit.hxx>
      46                 :            : #include <svx/svdpool.hxx>
      47                 :            : 
      48                 :            : //////////////////////////////////////////////////////////////////////////////
      49                 :            : 
      50                 :            : namespace sdr
      51                 :            : {
      52                 :            :     namespace properties
      53                 :            :     {
      54                 :      56552 :         SfxItemSet& TextProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
      55                 :            :         {
      56                 :            :             return *(new SfxItemSet(rPool,
      57                 :            : 
      58                 :            :                 // range from SdrAttrObj
      59                 :            :                 SDRATTR_START, SDRATTR_SHADOW_LAST,
      60                 :            :                 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
      61                 :            :                 SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
      62                 :            : 
      63                 :            :                 // range from SdrTextObj
      64                 :            :                 EE_ITEMS_START, EE_ITEMS_END,
      65                 :            : 
      66                 :            :                 // end
      67         [ +  - ]:      56552 :                 0, 0));
      68                 :            :         }
      69                 :            : 
      70                 :      57446 :         TextProperties::TextProperties(SdrObject& rObj)
      71                 :            :         :   AttributeProperties(rObj),
      72                 :      57446 :             maVersion(0)
      73                 :            :         {
      74                 :      57446 :         }
      75                 :            : 
      76                 :          6 :         TextProperties::TextProperties(const TextProperties& rProps, SdrObject& rObj)
      77                 :            :         :   AttributeProperties(rProps, rObj),
      78         [ +  - ]:          6 :             maVersion(rProps.getVersion())
      79                 :            :         {
      80                 :          6 :         }
      81                 :            : 
      82                 :      57355 :         TextProperties::~TextProperties()
      83                 :            :         {
      84         [ -  + ]:      76891 :         }
      85                 :            : 
      86                 :          0 :         BaseProperties& TextProperties::Clone(SdrObject& rObj) const
      87                 :            :         {
      88         [ #  # ]:          0 :             return *(new TextProperties(*this, rObj));
      89                 :            :         }
      90                 :            : 
      91                 :     145053 :         void TextProperties::ItemSetChanged(const SfxItemSet& rSet)
      92                 :            :         {
      93                 :     145053 :             SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
      94                 :     145053 :             sal_Int32 nText = rObj.getTextCount();
      95                 :            : 
      96                 :            :             // #i101556# ItemSet has changed -> new version
      97                 :     145053 :             maVersion++;
      98                 :            : 
      99         [ +  + ]:     290106 :             while( --nText >= 0 )
     100                 :            :             {
     101                 :     145053 :                 SdrText* pText = rObj.getText( nText );
     102                 :            : 
     103         [ +  - ]:     145053 :                 OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0;
     104                 :            : 
     105         [ +  + ]:     145053 :                 if(pParaObj)
     106                 :            :                 {
     107 [ -  + ][ #  # ]:      27512 :                     const bool bTextEdit = rObj.IsTextEditActive() && (rObj.getActiveText() == pText);
     108                 :            : 
     109                 :            :                     // handle outliner attributes
     110                 :      27512 :                     GetObjectItemSet();
     111                 :      27512 :                     Outliner* pOutliner = rObj.GetTextEditOutliner();
     112                 :            : 
     113         [ +  - ]:      27512 :                     if(!bTextEdit)
     114                 :            :                     {
     115                 :      27512 :                         pOutliner = &rObj.ImpGetDrawOutliner();
     116                 :      27512 :                         pOutliner->SetText(*pParaObj);
     117                 :            :                     }
     118                 :            : 
     119                 :      27512 :                     sal_uInt32 nParaCount(pOutliner->GetParagraphCount());
     120                 :            : 
     121         [ +  + ]:      56077 :                     for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++)
     122                 :            :                     {
     123         [ +  - ]:      28565 :                         SfxItemSet aSet(pOutliner->GetParaAttribs(nPara));
     124         [ +  - ]:      28565 :                         aSet.Put(rSet);
     125         [ +  - ]:      28565 :                         pOutliner->SetParaAttribs(nPara, aSet);
     126         [ +  - ]:      28565 :                     }
     127                 :            : 
     128         [ +  - ]:      27512 :                     if(!bTextEdit)
     129                 :            :                     {
     130         [ +  - ]:      27512 :                         if(nParaCount)
     131                 :            :                         {
     132                 :            :                             // force ItemSet
     133         [ +  - ]:      27512 :                             GetObjectItemSet();
     134                 :            : 
     135         [ +  - ]:      27512 :                             SfxItemSet aNewSet(pOutliner->GetParaAttribs(0L));
     136 [ +  - ][ +  - ]:      27512 :                             mpItemSet->Put(aNewSet);
     137                 :            :                         }
     138                 :            : 
     139                 :      27512 :                         OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount);
     140                 :      27512 :                         pOutliner->Clear();
     141                 :            : 
     142                 :      27512 :                         rObj.NbcSetOutlinerParaObjectForText(pTemp,pText);
     143                 :            :                     }
     144                 :            :                 }
     145                 :            :             }
     146                 :            : 
     147                 :            :             // Extra-Repaint for radical layout changes (#43139#)
     148         [ +  + ]:     145053 :             if(SFX_ITEM_SET == rSet.GetItemState(SDRATTR_TEXT_CONTOURFRAME))
     149                 :            :             {
     150                 :            :                 // Here only repaint wanted
     151                 :          3 :                 rObj.ActionChanged();
     152                 :            :                 //rObj.BroadcastObjectChange();
     153                 :            :             }
     154                 :            : 
     155                 :            :             // call parent
     156                 :     145053 :             AttributeProperties::ItemSetChanged(rSet);
     157                 :     145053 :         }
     158                 :            : 
     159                 :    1383536 :         void TextProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
     160                 :            :         {
     161                 :    1383536 :             SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
     162                 :            : 
     163                 :            :             // #i25616#
     164                 :    1383536 :             sal_Int32 nOldLineWidth(0L);
     165                 :            : 
     166 [ +  + ][ +  + ]:    1383536 :             if(XATTR_LINEWIDTH == nWhich && rObj.DoesSupportTextIndentingOnLineWidthChange())
                 [ +  + ]
     167                 :            :             {
     168                 :      27321 :                 nOldLineWidth = ((const XLineWidthItem&)GetItem(XATTR_LINEWIDTH)).GetValue();
     169                 :            :             }
     170                 :            : 
     171 [ +  + ][ +  + ]:    1383536 :             if(pNewItem && (SDRATTR_TEXTDIRECTION == nWhich))
     172                 :            :             {
     173                 :      75950 :                 sal_Bool bVertical(com::sun::star::text::WritingMode_TB_RL == ((SvxWritingModeItem*)pNewItem)->GetValue());
     174                 :      75950 :                 rObj.SetVerticalWriting(bVertical);
     175                 :            :             }
     176                 :            : 
     177                 :            :             // #95501# reset to default
     178 [ +  + ][ +  + ]:    1383536 :             if(!pNewItem && !nWhich && rObj.HasText() )
         [ +  + ][ +  + ]
     179                 :            :             {
     180                 :         64 :                 SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner();
     181                 :            : 
     182                 :         64 :                 sal_Int32 nCount = rObj.getTextCount();
     183         [ +  + ]:        128 :                 while( nCount-- )
     184                 :            :                 {
     185                 :         64 :                     SdrText* pText = rObj.getText( nCount );
     186                 :         64 :                     OutlinerParaObject* pParaObj = pText->GetOutlinerParaObject();
     187         [ +  - ]:         64 :                     if( pParaObj )
     188                 :            :                     {
     189                 :         64 :                         rOutliner.SetText(*pParaObj);
     190                 :         64 :                         sal_uInt32 nParaCount(rOutliner.GetParagraphCount());
     191                 :            : 
     192         [ +  - ]:         64 :                         if(nParaCount)
     193                 :            :                         {
     194                 :         64 :                             ESelection aSelection( 0, 0, EE_PARA_ALL, EE_PARA_ALL);
     195         [ +  - ]:         64 :                             rOutliner.RemoveAttribs(aSelection, sal_True, 0);
     196                 :            : 
     197         [ +  - ]:         64 :                             OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount);
     198         [ +  - ]:         64 :                             rOutliner.Clear();
     199                 :            : 
     200         [ +  - ]:         64 :                             rObj.NbcSetOutlinerParaObjectForText( pTemp, pText );
     201                 :            :                         }
     202                 :            :                     }
     203                 :            :                 }
     204                 :            :             }
     205                 :            : 
     206                 :            :             // call parent
     207                 :    1383536 :             AttributeProperties::ItemChange( nWhich, pNewItem );
     208                 :            : 
     209                 :            :             // #i25616#
     210 [ +  + ][ +  + ]:    1383536 :             if(XATTR_LINEWIDTH == nWhich && rObj.DoesSupportTextIndentingOnLineWidthChange())
                 [ +  + ]
     211                 :            :             {
     212                 :      27321 :                 const sal_Int32 nNewLineWidth(((const XLineWidthItem&)GetItem(XATTR_LINEWIDTH)).GetValue());
     213                 :      27321 :                 const sal_Int32 nDifference((nNewLineWidth - nOldLineWidth) / 2);
     214                 :            : 
     215         [ +  + ]:      27321 :                 if(nDifference)
     216                 :            :                 {
     217                 :       2770 :                     const sal_Bool bLineVisible(XLINE_NONE != ((const XLineStyleItem&)(GetItem(XATTR_LINESTYLE))).GetValue());
     218                 :            : 
     219         [ +  + ]:       2770 :                     if(bLineVisible)
     220                 :            :                     {
     221                 :       2323 :                         const sal_Int32 nLeftDist(((const SdrTextLeftDistItem&)GetItem(SDRATTR_TEXT_LEFTDIST)).GetValue());
     222                 :       2323 :                         const sal_Int32 nRightDist(((const SdrTextRightDistItem&)GetItem(SDRATTR_TEXT_RIGHTDIST)).GetValue());
     223                 :       2323 :                         const sal_Int32 nUpperDist(((const SdrTextUpperDistItem&)GetItem(SDRATTR_TEXT_UPPERDIST)).GetValue());
     224                 :       2323 :                         const sal_Int32 nLowerDist(((const SdrTextLowerDistItem&)GetItem(SDRATTR_TEXT_LOWERDIST)).GetValue());
     225                 :            : 
     226         [ +  - ]:       2323 :                         SetObjectItemDirect(SdrTextLeftDistItem(nLeftDist + nDifference));
     227         [ +  - ]:       2323 :                         SetObjectItemDirect(SdrTextRightDistItem(nRightDist + nDifference));
     228         [ +  - ]:       2323 :                         SetObjectItemDirect(SdrTextUpperDistItem(nUpperDist + nDifference));
     229         [ +  - ]:       2323 :                         SetObjectItemDirect(SdrTextLowerDistItem(nLowerDist + nDifference));
     230                 :            :                     }
     231                 :            :                 }
     232                 :            :             }
     233                 :    1383536 :         }
     234                 :            : 
     235                 :      58869 :         void TextProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
     236                 :            :         {
     237                 :      58869 :             SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
     238                 :            : 
     239                 :            :             // call parent
     240                 :      58869 :             AttributeProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
     241                 :            : 
     242                 :            :             // #i101556# StyleSheet has changed -> new version
     243                 :      58869 :             maVersion++;
     244                 :            : 
     245 [ +  - ][ +  + ]:      58869 :             if( rObj.GetModel() /*&& !rObj.IsTextEditActive()*/ && !rObj.IsLinkedText() )
                 [ +  + ]
     246                 :            :             {
     247                 :      58709 :                 SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner();
     248                 :            : 
     249                 :      58709 :                 sal_Int32 nText = rObj.getTextCount();
     250                 :            : 
     251         [ +  + ]:     117718 :                 while( --nText >= 0 )
     252                 :            :                 {
     253                 :      59009 :                     SdrText* pText = rObj.getText( nText );
     254                 :            : 
     255         [ +  - ]:      59009 :                     OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0;
     256         [ +  + ]:      59009 :                     if( !pParaObj )
     257                 :      57693 :                         continue;
     258                 :            : 
     259                 :            :                     // apply StyleSheet to all paragraphs
     260                 :       1316 :                     rOutliner.SetText(*pParaObj);
     261                 :       1316 :                     sal_uInt32 nParaCount(rOutliner.GetParagraphCount());
     262                 :            : 
     263         [ +  - ]:       1316 :                     if(nParaCount)
     264                 :            :                     {
     265         [ +  + ]:       3028 :                         for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++)
     266                 :            :                         {
     267                 :       1712 :                             SfxItemSet* pTempSet = 0L;
     268                 :            : 
     269                 :            :                             // since setting the stylesheet removes all para attributes
     270         [ +  + ]:       1712 :                             if(bDontRemoveHardAttr)
     271                 :            :                             {
     272                 :            :                                 // we need to remember them if we want to keep them
     273         [ +  - ]:        354 :                                 pTempSet = new SfxItemSet(rOutliner.GetParaAttribs(nPara));
     274                 :            :                             }
     275                 :            : 
     276         [ +  - ]:       1712 :                             if(GetStyleSheet())
     277                 :            :                             {
     278 [ +  + ][ +  - ]:       1712 :                                 if((OBJ_OUTLINETEXT == rObj.GetTextKind()) && (SdrInventor == rObj.GetObjInventor()))
                 [ +  + ]
     279                 :            :                                 {
     280 [ +  - ][ +  - ]:        489 :                                     String aNewStyleSheetName(GetStyleSheet()->GetName());
                 [ +  - ]
     281         [ +  - ]:        489 :                                     aNewStyleSheetName.Erase(aNewStyleSheetName.Len() - 1, 1);
     282         [ +  - ]:        489 :                                     sal_Int16 nDepth = rOutliner.GetDepth((sal_uInt16)nPara);
     283 [ +  + ][ +  - ]:        489 :                                     aNewStyleSheetName += String::CreateFromInt32( nDepth <= 0 ? 1 : nDepth + 1);
         [ +  - ][ +  - ]
     284                 :            : 
     285         [ +  - ]:        489 :                                     SdrModel* pModel = rObj.GetModel();
     286 [ +  - ][ +  - ]:        489 :                                     SfxStyleSheetBasePool* pStylePool = (pModel != NULL) ? pModel->GetStyleSheetPool() : 0L;
     287 [ +  - ][ +  - ]:        489 :                                     SfxStyleSheet* pNewStyle = (SfxStyleSheet*)pStylePool->Find(aNewStyleSheetName, GetStyleSheet()->GetFamily());
     288                 :            :                                     DBG_ASSERT( pNewStyle, "AutoStyleSheetName - Style not found!" );
     289                 :            : 
     290         [ +  - ]:        489 :                                     if(pNewStyle)
     291                 :            :                                     {
     292         [ +  - ]:        489 :                                         rOutliner.SetStyleSheet(nPara, pNewStyle);
     293         [ +  - ]:        489 :                                     }
     294                 :            :                                 }
     295                 :            :                                 else
     296                 :            :                                 {
     297                 :       1223 :                                     rOutliner.SetStyleSheet(nPara, GetStyleSheet());
     298                 :            :                                 }
     299                 :            :                             }
     300                 :            :                             else
     301                 :            :                             {
     302                 :            :                                 // remove StyleSheet
     303                 :          0 :                                 rOutliner.SetStyleSheet(nPara, 0L);
     304                 :            :                             }
     305                 :            : 
     306         [ +  + ]:       1712 :                             if(bDontRemoveHardAttr)
     307                 :            :                             {
     308         [ +  - ]:        354 :                                 if(pTempSet)
     309                 :            :                                 {
     310                 :            :                                     // restore para attributes
     311                 :        354 :                                     rOutliner.SetParaAttribs(nPara, *pTempSet);
     312                 :            :                                 }
     313                 :            :                             }
     314                 :            :                             else
     315                 :            :                             {
     316         [ +  - ]:       1358 :                                 if(pNewStyleSheet)
     317                 :            :                                 {
     318                 :            :                                     // remove all hard paragraph attributes
     319                 :            :                                     // which occur in StyleSheet, take care of
     320                 :            :                                     // parents (!)
     321 [ +  - ][ +  - ]:       1358 :                                     SfxItemIter aIter(pNewStyleSheet->GetItemSet());
     322                 :       1358 :                                     const SfxPoolItem* pItem = aIter.FirstItem();
     323                 :            : 
     324         [ +  + ]:      32801 :                                     while(pItem)
     325                 :            :                                     {
     326         [ +  - ]:      31443 :                                         if(!IsInvalidItem(pItem))
     327                 :            :                                         {
     328                 :      31443 :                                             sal_uInt16 nW(pItem->Which());
     329                 :            : 
     330 [ +  - ][ +  + ]:      31443 :                                             if(nW >= EE_ITEMS_START && nW <= EE_ITEMS_END)
     331                 :            :                                             {
     332         [ +  - ]:      25478 :                                                 rOutliner.QuickRemoveCharAttribs((sal_uInt16)nPara, nW);
     333                 :            :                                             }
     334                 :            :                                         }
     335         [ +  - ]:      31443 :                                         pItem = aIter.NextItem();
     336         [ +  - ]:       1358 :                                     }
     337                 :            :                                 }
     338                 :            :                             }
     339                 :            : 
     340         [ +  + ]:       1712 :                             if(pTempSet)
     341                 :            :                             {
     342         [ +  - ]:        354 :                                 delete pTempSet;
     343                 :            :                             }
     344                 :            :                         }
     345                 :            : 
     346                 :       1316 :                         OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount);
     347                 :       1316 :                         rOutliner.Clear();
     348                 :       1316 :                         rObj.NbcSetOutlinerParaObjectForText(pTemp, pText);
     349                 :            :                     }
     350                 :            :                 }
     351                 :            :             }
     352                 :            : 
     353         [ +  + ]:      58869 :             if(rObj.IsTextFrame())
     354                 :            :             {
     355                 :      25720 :                 rObj.NbcAdjustTextFrameWidthAndHeight();
     356                 :            :             }
     357                 :      58869 :         }
     358                 :            : 
     359                 :      56756 :         void TextProperties::ForceDefaultAttributes()
     360                 :            :         {
     361                 :      56756 :             SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
     362                 :            : 
     363         [ +  + ]:      56756 :             if( rObj.GetObjInventor() == SdrInventor )
     364                 :            :             {
     365                 :      56223 :                 const sal_uInt16 nSdrObjKind = rObj.GetObjIdentifier();
     366                 :            : 
     367 [ +  + ][ +  + ]:      56223 :                 if( nSdrObjKind == OBJ_TITLETEXT || nSdrObjKind == OBJ_OUTLINETEXT )
     368                 :      56756 :                     return; // no defaults for presentation objects
     369                 :            :             }
     370                 :            : 
     371                 :      56447 :             bool bTextFrame(rObj.IsTextFrame());
     372                 :            : 
     373                 :            :             // force ItemSet
     374                 :      56447 :             GetObjectItemSet();
     375                 :            : 
     376         [ +  + ]:      56447 :             if(bTextFrame)
     377                 :            :             {
     378         [ +  - ]:      23513 :                 mpItemSet->Put(XLineStyleItem(XLINE_NONE));
     379 [ +  - ][ +  - ]:      23513 :                 mpItemSet->Put(XFillColorItem(String(), Color(COL_WHITE)));
         [ +  - ][ +  - ]
                 [ +  - ]
     380         [ +  - ]:      23513 :                 mpItemSet->Put(XFillStyleItem(XFILL_NONE));
     381                 :            :             }
     382                 :            :             else
     383                 :            :             {
     384         [ +  - ]:      32934 :                 mpItemSet->Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST));
     385         [ +  - ]:      32934 :                 mpItemSet->Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER));
     386         [ +  - ]:      32934 :                 mpItemSet->Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER));
     387                 :            :             }
     388                 :            :         }
     389                 :            : 
     390                 :          0 :         void TextProperties::ForceStyleToHardAttributes()
     391                 :            :         {
     392                 :            :             // #i61284# call parent first to get the hard ObjectItemSet
     393                 :          0 :             AttributeProperties::ForceStyleToHardAttributes();
     394                 :            : 
     395                 :            :             // #i61284# push hard ObjectItemSet to OutlinerParaObject attributes
     396                 :            :             // using existing functionality
     397                 :          0 :             GetObjectItemSet(); // force ItemSet
     398                 :          0 :             ItemSetChanged(*mpItemSet);
     399                 :            : 
     400                 :            :             // now the standard TextProperties stuff
     401                 :          0 :             SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
     402                 :            : 
     403 [ #  # ][ #  #  :          0 :             if(rObj.GetModel()
             #  #  #  # ]
     404                 :          0 :                 && !rObj.IsTextEditActive()
     405                 :          0 :                 && !rObj.IsLinkedText())
     406                 :            :             {
     407                 :          0 :                 Outliner* pOutliner = SdrMakeOutliner(OUTLINERMODE_OUTLINEOBJECT, rObj.GetModel());
     408                 :          0 :                 sal_Int32 nText = rObj.getTextCount();
     409                 :            : 
     410         [ #  # ]:          0 :                 while( --nText >= 0 )
     411                 :            :                 {
     412                 :          0 :                     SdrText* pText = rObj.getText( nText );
     413                 :            : 
     414         [ #  # ]:          0 :                     OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0;
     415         [ #  # ]:          0 :                     if( !pParaObj )
     416                 :          0 :                         continue;
     417                 :            : 
     418                 :          0 :                     pOutliner->SetText(*pParaObj);
     419                 :            : 
     420                 :          0 :                     sal_uInt32 nParaCount(pOutliner->GetParagraphCount());
     421                 :            : 
     422         [ #  # ]:          0 :                     if(nParaCount)
     423                 :            :                     {
     424                 :          0 :                         sal_Bool bBurnIn(sal_False);
     425                 :            : 
     426         [ #  # ]:          0 :                         for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++)
     427                 :            :                         {
     428                 :          0 :                             SfxStyleSheet* pSheet = pOutliner->GetStyleSheet(nPara);
     429                 :            : 
     430         [ #  # ]:          0 :                             if(pSheet)
     431                 :            :                             {
     432         [ #  # ]:          0 :                                 SfxItemSet aParaSet(pOutliner->GetParaAttribs(nPara));
     433         [ #  # ]:          0 :                                 SfxItemSet aSet(*aParaSet.GetPool());
     434 [ #  # ][ #  # ]:          0 :                                 aSet.Put(pSheet->GetItemSet());
     435                 :            : 
     436                 :            :                                 /** the next code handles a special case for paragraphs that contain a
     437                 :            :                                     url field. The color for URL fields is either the system color for
     438                 :            :                                     urls or the char color attribute that formats the portion in which the
     439                 :            :                                     url field is contained.
     440                 :            :                                     When we set a char color attribute to the paragraphs item set from the
     441                 :            :                                     styles item set, we would have this char color attribute as an attribute
     442                 :            :                                     that is spanned over the complete paragraph after xml import due to some
     443                 :            :                                     problems in the xml import (using a XCursor on import so it does not know
     444                 :            :                                     the paragraphs and can't set char attributes to paragraphs ).
     445                 :            : 
     446                 :            :                                     To avoid this, as soon as we try to set a char color attribute from the style
     447                 :            :                                     we
     448                 :            :                                     1. check if we have at least one url field in this paragraph
     449                 :            :                                     2. if we found at least one url field, we span the char color attribute over
     450                 :            :                                     all portions that are not url fields and remove the char color attribute
     451                 :            :                                     from the paragraphs item set
     452                 :            :                                 */
     453                 :            : 
     454                 :          0 :                                 sal_Bool bHasURL(sal_False);
     455                 :            : 
     456 [ #  # ][ #  # ]:          0 :                                 if(aSet.GetItemState(EE_CHAR_COLOR) == SFX_ITEM_SET)
     457                 :            :                                 {
     458                 :          0 :                                     EditEngine* pEditEngine = const_cast<EditEngine*>(&(pOutliner->GetEditEngine()));
     459         [ #  # ]:          0 :                                     std::vector<EECharAttrib> aAttribs;
     460         [ #  # ]:          0 :                                     pEditEngine->GetCharAttribs((sal_uInt16)nPara, aAttribs);
     461                 :            : 
     462 [ #  # ][ #  # ]:          0 :                                     for(std::vector<EECharAttrib>::iterator i = aAttribs.begin(); i < aAttribs.end(); ++i)
     463                 :            :                                     {
     464         [ #  # ]:          0 :                                         if(EE_FEATURE_FIELD == i->pAttr->Which())
     465                 :            :                                         {
     466         [ #  # ]:          0 :                                             if(i->pAttr)
     467                 :            :                                             {
     468                 :          0 :                                                 SvxFieldItem* pFieldItem = (SvxFieldItem*)(i->pAttr);
     469                 :            : 
     470         [ #  # ]:          0 :                                                 if(pFieldItem)
     471                 :            :                                                 {
     472                 :          0 :                                                     const SvxFieldData* pData = pFieldItem->GetField();
     473                 :            : 
     474 [ #  # ][ #  # ]:          0 :                                                     if(pData && pData->ISA(SvxURLField))
         [ #  # ][ #  # ]
                 [ #  # ]
     475                 :            :                                                     {
     476                 :          0 :                                                         bHasURL = sal_True;
     477                 :          0 :                                                         break;
     478                 :            :                                                     }
     479                 :            :                                                 }
     480                 :            :                                             }
     481                 :            :                                         }
     482                 :            :                                     }
     483                 :            : 
     484         [ #  # ]:          0 :                                     if(bHasURL)
     485                 :            :                                     {
     486         [ #  # ]:          0 :                                         SfxItemSet aColorSet(*aSet.GetPool(), EE_CHAR_COLOR, EE_CHAR_COLOR );
     487         [ #  # ]:          0 :                                         aColorSet.Put(aSet, sal_False);
     488                 :            : 
     489                 :          0 :                                         ESelection aSel((sal_uInt16)nPara, 0);
     490                 :            : 
     491 [ #  # ][ #  # ]:          0 :                                         for(std::vector<EECharAttrib>::iterator i = aAttribs.begin(); i < aAttribs.end(); ++i)
     492                 :            :                                         {
     493         [ #  # ]:          0 :                                             if(EE_FEATURE_FIELD == i->pAttr->Which())
     494                 :            :                                             {
     495                 :          0 :                                                 aSel.nEndPos = i->nStart;
     496                 :            : 
     497         [ #  # ]:          0 :                                                 if(aSel.nStartPos != aSel.nEndPos)
     498         [ #  # ]:          0 :                                                     pEditEngine->QuickSetAttribs(aColorSet, aSel);
     499                 :            : 
     500                 :          0 :                                                 aSel.nStartPos = i->nEnd;
     501                 :            :                                             }
     502                 :            :                                         }
     503                 :            : 
     504         [ #  # ]:          0 :                                         aSel.nEndPos = pEditEngine->GetTextLen((sal_uInt16)nPara);
     505                 :            : 
     506         [ #  # ]:          0 :                                         if(aSel.nStartPos != aSel.nEndPos)
     507                 :            :                                         {
     508         [ #  # ]:          0 :                                             pEditEngine->QuickSetAttribs( aColorSet, aSel );
     509         [ #  # ]:          0 :                                         }
     510                 :          0 :                                     }
     511                 :            : 
     512                 :            :                                 }
     513                 :            : 
     514         [ #  # ]:          0 :                                 aSet.Put(aParaSet, sal_False);
     515                 :            : 
     516         [ #  # ]:          0 :                                 if(bHasURL)
     517                 :            :                                 {
     518         [ #  # ]:          0 :                                     aSet.ClearItem(EE_CHAR_COLOR);
     519                 :            :                                 }
     520                 :            : 
     521         [ #  # ]:          0 :                                 pOutliner->SetParaAttribs(nPara, aSet);
     522 [ #  # ][ #  # ]:          0 :                                 bBurnIn = sal_True; // #i51163# Flag was set wrong
     523                 :            :                             }
     524                 :            :                         }
     525                 :            : 
     526         [ #  # ]:          0 :                         if(bBurnIn)
     527                 :            :                         {
     528                 :          0 :                             OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount);
     529                 :          0 :                             rObj.NbcSetOutlinerParaObjectForText(pTemp,pText);
     530                 :            :                         }
     531                 :            :                     }
     532                 :            : 
     533                 :          0 :                     pOutliner->Clear();
     534                 :            :                 }
     535         [ #  # ]:          0 :                 delete pOutliner;
     536                 :            :             }
     537                 :          0 :         }
     538                 :            : 
     539                 :          0 :         void TextProperties::SetObjectItemNoBroadcast(const SfxPoolItem& rItem)
     540                 :            :         {
     541                 :          0 :             GetObjectItemSet();
     542                 :          0 :             mpItemSet->Put(rItem);
     543                 :          0 :         }
     544                 :            : 
     545                 :            : 
     546                 :      17243 :         void TextProperties::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
     547                 :            :         {
     548                 :            :             // call parent
     549                 :      17243 :             AttributeProperties::Notify(rBC, rHint);
     550                 :            : 
     551                 :      17243 :             SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
     552         [ +  + ]:      17243 :             if(rObj.HasText())
     553                 :            :             {
     554 [ +  - ][ +  + ]:      11648 :                 if(HAS_BASE(SfxStyleSheet, &rBC))
                 [ +  + ]
     555                 :            :                 {
     556 [ +  - ][ +  - ]:       7972 :                     SfxSimpleHint* pSimple = PTR_CAST(SfxSimpleHint, &rHint);
     557         [ +  - ]:       7972 :                     sal_uInt32 nId(pSimple ? pSimple->GetId() : 0L);
     558                 :            : 
     559         [ +  - ]:       7972 :                     if(SFX_HINT_DATACHANGED == nId)
     560                 :            :                     {
     561                 :       7972 :                         rObj.SetPortionInfoChecked(sal_False);
     562                 :            : 
     563                 :       7972 :                         sal_Int32 nText = rObj.getTextCount();
     564         [ -  + ]:       7972 :                         while( --nText > 0 )
     565                 :            :                         {
     566                 :          0 :                             OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject();
     567         [ #  # ]:          0 :                             if( pParaObj )
     568                 :          0 :                                 pParaObj->ClearPortionInfo();
     569                 :            :                         }
     570                 :       7972 :                         rObj.SetTextSizeDirty();
     571                 :            : 
     572 [ +  + ][ +  + ]:       7972 :                         if(rObj.IsTextFrame() && rObj.NbcAdjustTextFrameWidthAndHeight())
                 [ +  - ]
     573                 :            :                         {
     574                 :            :                             // here only repaint wanted
     575                 :          4 :                             rObj.ActionChanged();
     576                 :            :                             //rObj.BroadcastObjectChange();
     577                 :            :                         }
     578                 :            : 
     579                 :            :                         // #i101556# content of StyleSheet has changed -> new version
     580                 :       7972 :                         maVersion++;
     581                 :            :                     }
     582                 :            : 
     583         [ -  + ]:       7972 :                     if(SFX_HINT_DYING == nId)
     584                 :            :                     {
     585                 :          0 :                         rObj.SetPortionInfoChecked(sal_False);
     586                 :          0 :                         sal_Int32 nText = rObj.getTextCount();
     587         [ #  # ]:          0 :                         while( --nText > 0 )
     588                 :            :                         {
     589                 :          0 :                             OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject();
     590         [ #  # ]:          0 :                             if( pParaObj )
     591                 :          0 :                                 pParaObj->ClearPortionInfo();
     592                 :            :                         }
     593                 :            :                     }
     594                 :            :                 }
     595 [ +  - ][ +  - ]:       3676 :                 else if(HAS_BASE(SfxStyleSheetBasePool, &rBC))
                 [ +  - ]
     596                 :            :                 {
     597 [ +  - ][ +  + ]:       3676 :                     SfxStyleSheetHintExtended* pExtendedHint = PTR_CAST(SfxStyleSheetHintExtended, &rHint);
     598                 :            : 
     599   [ +  +  +  - ]:       5370 :                     if(pExtendedHint
                 [ +  + ]
     600                 :       1694 :                         && SFX_STYLESHEET_MODIFIED == pExtendedHint->GetHint())
     601                 :            :                     {
     602         [ +  - ]:       1694 :                         String aOldName(pExtendedHint->GetOldName());
     603 [ +  - ][ +  - ]:       1694 :                         String aNewName(pExtendedHint->GetStyleSheet()->GetName());
     604                 :       1694 :                         SfxStyleFamily eFamily = pExtendedHint->GetStyleSheet()->GetFamily();
     605                 :            : 
     606 [ +  - ][ +  - ]:       1694 :                         if(!aOldName.Equals(aNewName))
     607                 :            :                         {
     608         [ +  - ]:       1694 :                             sal_Int32 nText = rObj.getTextCount();
     609         [ -  + ]:       1694 :                             while( --nText > 0 )
     610                 :            :                             {
     611 [ #  # ][ #  # ]:          0 :                                 OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject();
     612         [ #  # ]:          0 :                                 if( pParaObj )
     613         [ #  # ]:          0 :                                     pParaObj->ChangeStyleSheetName(eFamily, aOldName, aNewName);
     614                 :            :                             }
     615 [ +  - ][ +  - ]:       1694 :                         }
     616                 :            :                     }
     617                 :            :                 }
     618                 :            :             }
     619                 :      17243 :         }
     620                 :            : 
     621                 :            :         // #i101556# Handout version information
     622                 :      28373 :         sal_uInt32 TextProperties::getVersion() const
     623                 :            :         {
     624                 :      28373 :             return maVersion;
     625                 :            :         }
     626                 :            :     } // end of namespace properties
     627                 :            : } // end of namespace sdr
     628                 :            : 
     629                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10