LCOV - code coverage report
Current view: top level - sw/source/core/attr - format.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 316 363 87.1 %
Date: 2015-06-13 12:38:46 Functions: 33 40 82.5 %
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 <doc.hxx>
      21             : #include <DocumentSettingManager.hxx> //For SwFmt::getIDocumentSettingAccess()
      22             : #include <IDocumentTimerAccess.hxx>
      23             : #include <fmtcolfunc.hxx>
      24             : #include <frame.hxx>
      25             : #include <format.hxx>
      26             : #include <hintids.hxx>
      27             : #include <hints.hxx>
      28             : #include <paratr.hxx>
      29             : #include <swcache.hxx>
      30             : #include <swtblfmt.hxx>
      31             : #include <svl/grabbagitem.hxx>
      32             : #include <com/sun/star/beans/PropertyValues.hpp>
      33             : 
      34             : //UUUU
      35             : #include <svx/sdr/attribute/sdrallfillattributeshelper.hxx>
      36             : #include <svx/unobrushitemhelper.hxx>
      37             : #include <svx/xdef.hxx>
      38             : 
      39             : using namespace com::sun::star;
      40             : 
      41      152451 : TYPEINIT1( SwFormat, SwClient );
      42             : 
      43       23612 : SwFormat::SwFormat( SwAttrPool& rPool, const sal_Char* pFormatNm,
      44             :               const sal_uInt16* pWhichRanges, SwFormat *pDrvdFrm,
      45             :               sal_uInt16 nFormatWhich )
      46             :     : SwModify( pDrvdFrm ),
      47             :     m_aFormatName( OUString::createFromAscii(pFormatNm) ),
      48             :     m_aSet( rPool, pWhichRanges ),
      49             :     m_nWhichId( nFormatWhich ),
      50             :     m_nPoolFormatId( USHRT_MAX ),
      51             :     m_nPoolHelpId( USHRT_MAX ),
      52       23612 :     m_nPoolHlpFileId( UCHAR_MAX )
      53             : {
      54       23612 :     m_bAutoUpdateFormat = false; // LAYER_IMPL
      55       23612 :     m_bAutoFormat = true;
      56       23612 :     m_bWritten = m_bFormatInDTOR = m_bHidden = false;
      57             : 
      58       23612 :     if( pDrvdFrm )
      59       11780 :         m_aSet.SetParent( &pDrvdFrm->m_aSet );
      60       23612 : }
      61             : 
      62      355669 : SwFormat::SwFormat( SwAttrPool& rPool, const OUString& rFormatNm,
      63             :               const sal_uInt16* pWhichRanges, SwFormat* pDrvdFrm,
      64             :               sal_uInt16 nFormatWhich )
      65             :     : SwModify( pDrvdFrm ),
      66             :     m_aFormatName( rFormatNm ),
      67             :     m_aSet( rPool, pWhichRanges ),
      68             :     m_nWhichId( nFormatWhich ),
      69             :     m_nPoolFormatId( USHRT_MAX ),
      70             :     m_nPoolHelpId( USHRT_MAX ),
      71      355669 :     m_nPoolHlpFileId( UCHAR_MAX )
      72             : {
      73      355669 :     m_bAutoUpdateFormat = false; // LAYER_IMPL
      74      355669 :     m_bAutoFormat = true;
      75      355669 :     m_bWritten = m_bFormatInDTOR = m_bHidden = false;
      76             : 
      77      355669 :     if( pDrvdFrm )
      78      355668 :         m_aSet.SetParent( &pDrvdFrm->m_aSet );
      79      355669 : }
      80             : 
      81       31132 : SwFormat::SwFormat( const SwFormat& rFormat )
      82       31132 :     : SwModify( rFormat.DerivedFrom() ),
      83             :     m_aFormatName( rFormat.m_aFormatName ),
      84             :     m_aSet( rFormat.m_aSet ),
      85             :     m_nWhichId( rFormat.m_nWhichId ),
      86       31132 :     m_nPoolFormatId( rFormat.GetPoolFormatId() ),
      87       31132 :     m_nPoolHelpId( rFormat.GetPoolHelpId() ),
      88       93396 :     m_nPoolHlpFileId( rFormat.GetPoolHlpFileId() )
      89             : {
      90       31132 :     m_bWritten = m_bFormatInDTOR = false; // LAYER_IMPL
      91       31132 :     m_bAutoFormat = rFormat.m_bAutoFormat;
      92       31132 :     m_bHidden = rFormat.m_bHidden;
      93       31132 :     m_bAutoUpdateFormat = rFormat.m_bAutoUpdateFormat;
      94             : 
      95       31132 :     if( rFormat.DerivedFrom() )
      96       31132 :         m_aSet.SetParent( &rFormat.DerivedFrom()->m_aSet );
      97             :     // a few special treatments for attributes
      98       31132 :     m_aSet.SetModifyAtAttr( this );
      99       31132 : }
     100             : 
     101       13203 : SwFormat &SwFormat::operator=(const SwFormat& rFormat)
     102             : {
     103       13203 :     m_nWhichId = rFormat.m_nWhichId;
     104       13203 :     m_nPoolFormatId = rFormat.GetPoolFormatId();
     105       13203 :     m_nPoolHelpId = rFormat.GetPoolHelpId();
     106       13203 :     m_nPoolHlpFileId = rFormat.GetPoolHlpFileId();
     107             : 
     108       13203 :     if ( IsInCache() )
     109             :     {
     110           0 :         SwFrm::GetCache().Delete( this );
     111           0 :         SetInCache( false );
     112             :     }
     113       13203 :     SetInSwFntCache( false );
     114             : 
     115             :     // copy only array with attributes delta
     116       13203 :     SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
     117       26406 :               aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
     118       13203 :     m_aSet.Intersect_BC( rFormat.m_aSet, &aOld, &aNew );
     119       13203 :     (void)m_aSet.Put_BC( rFormat.m_aSet, &aOld, &aNew );
     120             : 
     121             :     // a few special treatments for attributes
     122       13203 :     m_aSet.SetModifyAtAttr( this );
     123             : 
     124             :     // create PoolItem attribute for Modify
     125       13203 :     if( aOld.Count() )
     126             :     {
     127       11803 :         SwAttrSetChg aChgOld( m_aSet, aOld );
     128       23606 :         SwAttrSetChg aChgNew( m_aSet, aNew );
     129       23606 :         ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
     130             :     }
     131             : 
     132       13203 :     if( GetRegisteredIn() != rFormat.GetRegisteredIn() )
     133             :     {
     134           0 :         if( GetRegisteredIn() )
     135           0 :             GetRegisteredInNonConst()->Remove(this);
     136           0 :         if( rFormat.GetRegisteredIn() )
     137             :         {
     138           0 :             const_cast<SwFormat&>(rFormat).GetRegisteredInNonConst()->Add(this);
     139           0 :             m_aSet.SetParent( &rFormat.m_aSet );
     140             :         }
     141             :         else
     142             :         {
     143           0 :             m_aSet.SetParent( 0 );
     144             :         }
     145             :     }
     146       13203 :     m_bAutoFormat = rFormat.m_bAutoFormat;
     147       13203 :     m_bHidden = rFormat.m_bHidden;
     148       13203 :     m_bAutoUpdateFormat = rFormat.m_bAutoUpdateFormat;
     149       26406 :     return *this;
     150             : }
     151             : 
     152        2190 : void SwFormat::SetName( const OUString& rNewName, bool bBroadcast )
     153             : {
     154             :     OSL_ENSURE( !IsDefault(), "SetName: Defaultformat" );
     155        2190 :     if( bBroadcast )
     156             :     {
     157        1175 :         SwStringMsgPoolItem aOld( RES_NAME_CHANGED, m_aFormatName );
     158        2350 :         SwStringMsgPoolItem aNew( RES_NAME_CHANGED, rNewName );
     159        1175 :         m_aFormatName = rNewName;
     160        2350 :         ModifyNotification( &aOld, &aNew );
     161             :     }
     162             :     else
     163             :     {
     164        1015 :         m_aFormatName = rNewName;
     165             :     }
     166        2190 : }
     167             : 
     168             : /** Copy attributes
     169             : 
     170             :     This function is called in every Copy-Ctor for copying the attributes.
     171             :     The latter can be only copied as soon as the derived class exists since
     172             :     for setting them the Which() function is called and that has the default
     173             :     value of 0 in the base class and is then overridden by the derived class.
     174             : 
     175             :     If we copy over multiple documents then the new document has to be provided
     176             :     in which <this> is defined. Currently this is important for DropCaps
     177             :     because that contains data that needs to be copied deeply.
     178             : */
     179        6713 : void SwFormat::CopyAttrs( const SwFormat& rFormat, bool bReplace )
     180             : {
     181             :     // copy only array with attributes delta
     182        6713 :     if ( IsInCache() )
     183             :     {
     184           0 :         SwFrm::GetCache().Delete( this );
     185           0 :         SetInCache( false );
     186             :     }
     187        6713 :     SetInSwFntCache( false );
     188             : 
     189             :     // special treatments for some attributes
     190        6713 :     SwAttrSet* pChgSet = const_cast<SwAttrSet*>(&rFormat.m_aSet);
     191             : 
     192        6713 :     if( !bReplace )     // refresh only those that are not set?
     193             :     {
     194           0 :         if( pChgSet == &rFormat.m_aSet )
     195           0 :             pChgSet = new SwAttrSet( rFormat.m_aSet );
     196           0 :         pChgSet->Differentiate( m_aSet );
     197             :     }
     198             : 
     199             :     // copy only array with attributes delta
     200        6713 :     if( pChgSet->GetPool() != m_aSet.GetPool() )
     201          64 :         pChgSet->CopyToModify( *this );
     202             :     else
     203             :     {
     204        6649 :         SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
     205       13298 :                   aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
     206             : 
     207        6649 :         if ( m_aSet.Put_BC( *pChgSet, &aOld, &aNew ) )
     208             :         {
     209             :             // a few special treatments for attributes
     210        6649 :             m_aSet.SetModifyAtAttr( this );
     211             : 
     212        6649 :             SwAttrSetChg aChgOld( m_aSet, aOld );
     213       13298 :             SwAttrSetChg aChgNew( m_aSet, aNew );
     214       13298 :             ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
     215        6649 :         }
     216             :     }
     217             : 
     218        6713 :     if( pChgSet != &rFormat.m_aSet ) // was a Set created?
     219           0 :         delete pChgSet;
     220        6713 : }
     221             : 
     222      820510 : SwFormat::~SwFormat()
     223             : {
     224             :     // This happens at a ObjectDying message. Thus put all dependent
     225             :     // ones on DerivedFrom.
     226      410255 :     if( HasWriterListeners() )
     227             :     {
     228             :         OSL_ENSURE( DerivedFrom(), "SwFormat::~SwFormat: Def dependents!" );
     229             : 
     230       13323 :         m_bFormatInDTOR = true;
     231             : 
     232       13323 :         SwFormat* pParentFormat = DerivedFrom();
     233       13323 :         if( !pParentFormat )
     234             :         {
     235             :             SAL_WARN(
     236             :                 "sw.core",
     237             :                 "~SwFormat: parent format missing from: " << GetName() );
     238             :         }
     239             :         else
     240             :         {
     241       13299 :             SwFormatChg aOldFormat( this );
     242       26598 :             SwFormatChg aNewFormat( pParentFormat );
     243       26598 :             SwIterator<SwClient,SwFormat> aIter(*this);
     244       70589 :             for(SwClient* pClient = aIter.First(); pClient && pParentFormat; pClient = aIter.Next())
     245             :             {
     246             :                 SAL_INFO("sw.core", "reparenting " << typeid(*pClient).name() << " at " << pClient << " from " << typeid(*this).name() << " at " << this << " to "  << typeid(*pParentFormat).name() << " at " << pParentFormat);
     247       57290 :                 pParentFormat->Add( pClient );
     248       57290 :                 pClient->ModifyNotification( &aOldFormat, &aNewFormat );
     249       13299 :             }
     250             :         }
     251             :     }
     252      410255 : }
     253             : 
     254     2100252 : void SwFormat::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
     255             : {
     256     2100252 :     bool bContinue = true; // true = pass on to dependent ones
     257             : 
     258             :     sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
     259     2100252 :                     pNewValue ? pNewValue->Which() : 0 ;
     260     2100252 :     switch( nWhich )
     261             :     {
     262           0 :     case 0:     break;          // Which-Id of 0?
     263             : 
     264             :     case RES_OBJECTDYING:
     265           0 :         if (pNewValue)
     266             :         {
     267             :             // If the dying object is the parent format of this format so
     268             :             // attach this to the parent of the parent
     269           0 :             SwFormat* pFormat = static_cast<SwFormat*>(static_cast<const SwPtrMsgPoolItem*>(pNewValue)->pObject);
     270             : 
     271             :             // do not move if this is the topmost format
     272           0 :             if( GetRegisteredIn() && GetRegisteredIn() == pFormat )
     273             :             {
     274           0 :                 if( pFormat->GetRegisteredIn() )
     275             :                 {
     276             :                     // if parent so register in new parent
     277           0 :                     pFormat->DerivedFrom()->Add( this );
     278           0 :                     m_aSet.SetParent( &DerivedFrom()->m_aSet );
     279             :                 }
     280             :                 else
     281             :                 {
     282             :                     // otherwise de-register at least from dying one
     283           0 :                     DerivedFrom()->Remove( this );
     284           0 :                     m_aSet.SetParent( 0 );
     285             :                 }
     286             :             }
     287             :         }
     288           0 :         break;
     289             :     case RES_ATTRSET_CHG:
     290     2009073 :         if (pOldValue && pNewValue && static_cast<const SwAttrSetChg*>(pOldValue)->GetTheChgdSet() != &m_aSet)
     291             :         {
     292             :             // pass only those that are not set
     293      474460 :             SwAttrSetChg aOld( *static_cast<const SwAttrSetChg*>(pOldValue) );
     294      948920 :             SwAttrSetChg aNew( *static_cast<const SwAttrSetChg*>(pNewValue) );
     295             : 
     296      474460 :             aOld.GetChgSet()->Differentiate( m_aSet );
     297      474460 :             aNew.GetChgSet()->Differentiate( m_aSet );
     298             : 
     299      474460 :             if( aNew.Count() )
     300      456803 :                 NotifyClients( &aOld, &aNew );
     301      948920 :             bContinue = false;
     302             :         }
     303     2009073 :         break;
     304             :     case RES_FMT_CHG:
     305             :         // if the format parent will be moved so register my attribute set at
     306             :         // the new one
     307             : 
     308             :         // skip my own Modify
     309      264531 :         if ( pOldValue && pNewValue &&
     310      236810 :             static_cast<const SwFormatChg*>(pOldValue)->pChangedFormat != this &&
     311       60456 :             static_cast<const SwFormatChg*>(pNewValue)->pChangedFormat == GetRegisteredIn() )
     312             :         {
     313             :             // attach Set to new parent
     314       37112 :             m_aSet.SetParent( DerivedFrom() ? &DerivedFrom()->m_aSet : 0 );
     315             :         }
     316       88177 :         break;
     317             :     case RES_RESET_FMTWRITTEN:
     318             :         {
     319           0 :             ResetWritten();
     320             : 
     321             :             // mba: here we don't use the additional stuff from NotifyClients().
     322             :             // should we?!
     323             :             // mba: move the code that ignores this event to the clients
     324             : 
     325             :             // pass Hint only to dependent formats (no Frames)
     326             :             //ModifyBroadcast( pOldValue, pNewValue, TYPE(SwFormat) );
     327             :             //bContinue = false;
     328             :         }
     329           0 :         break;
     330             :     default:
     331             :         {
     332             :             // attribute is defined in this format
     333        3002 :             if( SfxItemState::SET == m_aSet.GetItemState( nWhich, false ))
     334             :             {
     335             :                 // DropCaps might come into this block
     336             :                 OSL_ENSURE( RES_PARATR_DROP == nWhich, "Modify was sent without sender" );
     337           0 :                 bContinue = false;
     338             :             }
     339             :         }
     340             :     }
     341             : 
     342     2100252 :     if( bContinue )
     343             :     {
     344             :         // walk over all dependent formats
     345     1625792 :         NotifyClients( pOldValue, pNewValue );
     346             :     }
     347     2100252 : }
     348             : 
     349       25512 : bool SwFormat::SetDerivedFrom(SwFormat *pDerFrom)
     350             : {
     351       25512 :     if ( pDerFrom )
     352             :     {
     353       22408 :         const SwFormat* pFormat = pDerFrom;
     354       96050 :         while ( pFormat != 0 )
     355             :         {
     356       51234 :             if ( pFormat == this )
     357           0 :                 return false;
     358             : 
     359       51234 :             pFormat=pFormat->DerivedFrom();
     360             :         }
     361             :     }
     362             :     else
     363             :     {
     364             :         // nothing provided, search for Dflt format
     365        3104 :         pDerFrom = this;
     366       12189 :         while ( pDerFrom->DerivedFrom() )
     367        5981 :             pDerFrom = pDerFrom->DerivedFrom();
     368             :     }
     369       25512 :     if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) )
     370        1223 :         return false;
     371             : 
     372             :     OSL_ENSURE( Which()==pDerFrom->Which()
     373             :             || ( Which()==RES_CONDTXTFMTCOLL && pDerFrom->Which()==RES_TXTFMTCOLL)
     374             :             || ( Which()==RES_TXTFMTCOLL && pDerFrom->Which()==RES_CONDTXTFMTCOLL)
     375             :             || ( Which()==RES_FLYFRMFMT && pDerFrom->Which()==RES_FRMFMT ),
     376             :             "SetDerivedFrom: derive apples from oranges?");
     377             : 
     378       24289 :     if ( IsInCache() )
     379             :     {
     380           0 :         SwFrm::GetCache().Delete( this );
     381           0 :         SetInCache( false );
     382             :     }
     383       24289 :     SetInSwFntCache( false );
     384             : 
     385       24289 :     pDerFrom->Add( this );
     386       24289 :     m_aSet.SetParent( &pDerFrom->m_aSet );
     387             : 
     388       24289 :     SwFormatChg aOldFormat( this );
     389       48578 :     SwFormatChg aNewFormat( this );
     390       24289 :     ModifyNotification( &aOldFormat, &aNewFormat );
     391             : 
     392       48578 :     return true;
     393             : }
     394             : 
     395      186498 : bool SwFormat::supportsFullDrawingLayerFillAttributeSet() const
     396             : {
     397      186498 :     return false;
     398             : }
     399             : 
     400      159617 : const SfxPoolItem& SwFormat::GetFormatAttr( sal_uInt16 nWhich, bool bInParents ) const
     401             : {
     402      159617 :     if (RES_BACKGROUND == nWhich && supportsFullDrawingLayerFillAttributeSet())
     403             :     {
     404             :         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
     405             :         SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes or makeBackgroundBrushItem (simple fallback is in place and used)");
     406          17 :         static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
     407             : 
     408             :         // fill the local static SvxBrushItem from the current ItemSet so that
     409             :         // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
     410             :         // as good as possible to create a fallback representation and return that
     411          17 :         aSvxBrushItem = getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bInParents);
     412             : 
     413          17 :         return aSvxBrushItem;
     414             :     }
     415             : 
     416      159600 :     return m_aSet.Get( nWhich, bInParents );
     417             : }
     418             : 
     419     2108391 : SfxItemState SwFormat::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, const SfxPoolItem **ppItem ) const
     420             : {
     421     2108391 :     if (RES_BACKGROUND == nWhich && supportsFullDrawingLayerFillAttributeSet())
     422             :     {
     423             :         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
     424             :         SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes or SwFormat::GetBackgroundStat (simple fallback is in place and used)");
     425         714 :         const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFill = getSdrAllFillAttributesHelper();
     426             : 
     427             :         // check if the new fill attributes are used
     428         714 :         if(aFill.get() && aFill->isUsed())
     429             :         {
     430             :             // if yes, fill the local SvxBrushItem using the new fill attributes
     431             :             // as good as possible to have an instance for the pointer to point
     432             :             // to and return as state that it is set
     433             : 
     434           7 :             static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
     435             : 
     436           7 :             aSvxBrushItem = getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bSrchInParent);
     437           7 :             if( ppItem )
     438           5 :                 *ppItem = &aSvxBrushItem;
     439             : 
     440           7 :             return SfxItemState::SET;
     441             :         }
     442             : 
     443             :         // if not, reset pointer and return SfxItemState::DEFAULT to signal that
     444             :         // the item is not set
     445         707 :         if( ppItem )
     446         677 :             *ppItem = NULL;
     447             : 
     448         707 :         return SfxItemState::DEFAULT;
     449             :     }
     450             : 
     451     2107677 :     return m_aSet.GetItemState( nWhich, bSrchInParent, ppItem );
     452             : }
     453             : 
     454         964 : SfxItemState SwFormat::GetBackgroundState(SvxBrushItem &rItem, bool bSrchInParent) const
     455             : {
     456         964 :     if (supportsFullDrawingLayerFillAttributeSet())
     457             :     {
     458             :         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
     459         964 :         const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFill = getSdrAllFillAttributesHelper();
     460             : 
     461             :         // check if the new fill attributes are used
     462         964 :         if(aFill.get() && aFill->isUsed())
     463             :         {
     464             :             // if yes, fill the local SvxBrushItem using the new fill attributes
     465             :             // as good as possible to have an instance for the pointer to point
     466             :             // to and return as state that it is set
     467          14 :             rItem = getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bSrchInParent);
     468          14 :             return SfxItemState::SET;
     469             :         }
     470             : 
     471             :         // if not return SfxItemState::DEFAULT to signal that the item is not set
     472         950 :         return SfxItemState::DEFAULT;
     473             :     }
     474             : 
     475           0 :     const SfxPoolItem* pItem = 0;
     476           0 :     SfxItemState eRet = m_aSet.GetItemState(RES_BACKGROUND, bSrchInParent, &pItem);
     477           0 :     if (pItem)
     478           0 :         rItem = *static_cast<const SvxBrushItem*>(pItem);
     479           0 :     return eRet;
     480             : }
     481             : 
     482     1801545 : bool SwFormat::SetFormatAttr( const SfxPoolItem& rAttr )
     483             : {
     484     1801545 :     if ( IsInCache() || IsInSwFntCache() )
     485             :     {
     486        2478 :         const sal_uInt16 nWhich = rAttr.Which();
     487        2478 :         CheckCaching( nWhich );
     488             :     }
     489             : 
     490     1801545 :     bool bRet = false;
     491             : 
     492             :     //UUUU
     493     1801545 :     if (RES_BACKGROUND == rAttr.Which() && supportsFullDrawingLayerFillAttributeSet())
     494             :     {
     495             :         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
     496             :         SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
     497          26 :         SfxItemSet aTempSet(*m_aSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
     498          26 :         const SvxBrushItem& rSource = static_cast< const SvxBrushItem& >(rAttr);
     499             : 
     500             :         // fill a local ItemSet with the attributes corresponding as good as possible
     501             :         // to the new fill properties [XATTR_FILL_FIRST .. XATTR_FILL_LAST] and set these
     502             :         // as ItemSet
     503          26 :         setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
     504             : 
     505          26 :         if(IsModifyLocked())
     506             :         {
     507           0 :             if( ( bRet = m_aSet.Put( aTempSet ) ) )
     508             :             {
     509           0 :                 m_aSet.SetModifyAtAttr( this );
     510             :             }
     511             :         }
     512             :         else
     513             :         {
     514          52 :             SwAttrSet aOld(*m_aSet.GetPool(), m_aSet.GetRanges()), aNew(*m_aSet.GetPool(), m_aSet.GetRanges());
     515             : 
     516          26 :             bRet = m_aSet.Put_BC(aTempSet, &aOld, &aNew);
     517             : 
     518          26 :             if(bRet)
     519             :             {
     520          26 :                 m_aSet.SetModifyAtAttr(this);
     521             : 
     522          26 :                 SwAttrSetChg aChgOld(m_aSet, aOld);
     523          52 :                 SwAttrSetChg aChgNew(m_aSet, aNew);
     524             : 
     525          52 :                 ModifyNotification(&aChgOld, &aChgNew);
     526          26 :             }
     527             :         }
     528             : 
     529          26 :         return bRet;
     530             :     }
     531             : 
     532             :     // if Modify is locked then no modifications will be sent;
     533             :     // but call Modify always for FrameFormats
     534     1801519 :     const sal_uInt16 nFormatWhich = Which();
     535     3653788 :     if( IsModifyLocked() ||
     536     3545726 :         ( !HasWriterListeners() &&
     537     1754824 :           (RES_GRFFMTCOLL == nFormatWhich  ||
     538             :            RES_TXTFMTCOLL == nFormatWhich ) ) )
     539             :     {
     540       61367 :         if( ( bRet = (0 != m_aSet.Put( rAttr ))) )
     541       59600 :             m_aSet.SetModifyAtAttr( this );
     542             :         // #i71574#
     543       61367 :         if ( nFormatWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
     544             :         {
     545        1758 :             TextFormatCollFunc::CheckTextFormatCollForDeletionOfAssignmentToOutlineStyle( this );
     546             :         }
     547             :     }
     548             :     else
     549             :     {
     550             :         // copy only array with attributes delta
     551     1740152 :         SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
     552     3480304 :                   aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
     553             : 
     554     1740152 :         bRet = m_aSet.Put_BC( rAttr, &aOld, &aNew );
     555     1740152 :         if( bRet )
     556             :         {
     557             :             // some special treatments for attributes
     558     1316541 :             m_aSet.SetModifyAtAttr( this );
     559             : 
     560     1316541 :             SwAttrSetChg aChgOld( m_aSet, aOld );
     561     2633082 :             SwAttrSetChg aChgNew( m_aSet, aNew );
     562     2633082 :             ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
     563     1740152 :         }
     564             :     }
     565     1801519 :     return bRet;
     566             : }
     567             : 
     568      374476 : bool SwFormat::SetFormatAttr( const SfxItemSet& rSet )
     569             : {
     570      374476 :     if( !rSet.Count() )
     571         130 :         return false;
     572             : 
     573      374346 :     if ( IsInCache() )
     574             :     {
     575         113 :         SwFrm::GetCache().Delete( this );
     576         113 :         SetInCache( false );
     577             :     }
     578      374346 :     SetInSwFntCache( false );
     579             : 
     580      374346 :     bool bRet = false;
     581             : 
     582             :     //UUUU Use local copy to be able to apply needed changes, e.g. call
     583             :     // CheckForUniqueItemForLineFillNameOrIndex which is needed for NameOrIndex stuff
     584      374346 :     SfxItemSet aTempSet(rSet);
     585             : 
     586             :     //UUUU Need to check for unique item for DrawingLayer items of type NameOrIndex
     587             :     // and evtl. correct that item to ensure unique names for that type. This call may
     588             :     // modify/correct entries inside of the given SfxItemSet
     589      374346 :     if(GetDoc())
     590             :     {
     591      374346 :         GetDoc()->CheckForUniqueItemForLineFillNameOrIndex(aTempSet);
     592             :     }
     593             : 
     594      374346 :     if (supportsFullDrawingLayerFillAttributeSet())
     595             :     {
     596       96052 :         const SfxPoolItem* pSource = 0;
     597             : 
     598       96052 :         if(SfxItemState::SET == aTempSet.GetItemState(RES_BACKGROUND, false, &pSource))
     599             :         {
     600             :             //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
     601             :             SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
     602             : 
     603             :             // copy all items to be set anyways to a local ItemSet with is also prepared for the new
     604             :             // fill attribute ranges [XATTR_FILL_FIRST .. XATTR_FILL_LAST]. Add the attributes
     605             :             // corresponding as good as possible to the new fill properties and set the whole ItemSet
     606         242 :             const SvxBrushItem& rSource(static_cast< const SvxBrushItem& >(*pSource));
     607         242 :             setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
     608             : 
     609         242 :             if(IsModifyLocked())
     610             :             {
     611           0 :                 if( ( bRet = m_aSet.Put( aTempSet ) ) )
     612             :                 {
     613           0 :                     m_aSet.SetModifyAtAttr( this );
     614             :                 }
     615             :             }
     616             :             else
     617             :             {
     618         484 :                 SwAttrSet aOld(*m_aSet.GetPool(), m_aSet.GetRanges()), aNew(*m_aSet.GetPool(), m_aSet.GetRanges());
     619             : 
     620         242 :                 bRet = m_aSet.Put_BC(aTempSet, &aOld, &aNew);
     621             : 
     622         242 :                 if(bRet)
     623             :                 {
     624         242 :                     m_aSet.SetModifyAtAttr(this);
     625             : 
     626         242 :                     SwAttrSetChg aChgOld(m_aSet, aOld);
     627         484 :                     SwAttrSetChg aChgNew(m_aSet, aNew);
     628             : 
     629         484 :                     ModifyNotification(&aChgOld, &aChgNew);
     630         242 :                 }
     631             :             }
     632             : 
     633         242 :             return bRet;
     634             :         }
     635             :     }
     636             : 
     637             :     // if Modify is locked then no modifications will be sent;
     638             :     // but call Modify always for FrameFormats
     639      374104 :     const sal_uInt16 nFormatWhich = Which();
     640      866416 :     if ( IsModifyLocked() ||
     641      608629 :          ( !HasWriterListeners() &&
     642      235042 :            ( RES_GRFFMTCOLL == nFormatWhich ||
     643             :              RES_TXTFMTCOLL == nFormatWhich ) ) )
     644             :     {
     645      118725 :         if( ( bRet = m_aSet.Put( aTempSet )) )
     646       82221 :             m_aSet.SetModifyAtAttr( this );
     647             :         // #i71574#
     648      118725 :         if ( nFormatWhich == RES_TXTFMTCOLL )
     649             :         {
     650      118208 :             TextFormatCollFunc::CheckTextFormatCollForDeletionOfAssignmentToOutlineStyle( this );
     651             :         }
     652             :     }
     653             :     else
     654             :     {
     655      255379 :         SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
     656      510758 :                   aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
     657      255379 :         bRet = m_aSet.Put_BC( aTempSet, &aOld, &aNew );
     658      255379 :         if( bRet )
     659             :         {
     660             :             // some special treatments for attributes
     661      156002 :             m_aSet.SetModifyAtAttr( this );
     662      156002 :             SwAttrSetChg aChgOld( m_aSet, aOld );
     663      312004 :             SwAttrSetChg aChgNew( m_aSet, aNew );
     664      312004 :             ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
     665      255379 :         }
     666             :     }
     667      374104 :     return bRet;
     668             : }
     669             : 
     670             : // remove Hint using nWhich from array with delta
     671     1389552 : bool SwFormat::ResetFormatAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
     672             : {
     673     1389552 :     if( !m_aSet.Count() )
     674       49750 :         return false;
     675             : 
     676     1339802 :     if( !nWhich2 || nWhich2 < nWhich1 )
     677     1330617 :         nWhich2 = nWhich1; // then set to 1st ID, only this item
     678             : 
     679     1339802 :     if ( IsInCache() || IsInSwFntCache() )
     680             :     {
     681         492 :         for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
     682          40 :             CheckCaching( n );
     683             :     }
     684             : 
     685             :     // if Modify is locked then no modifications will be sent
     686     1339802 :     if( IsModifyLocked() )
     687       19774 :         return 0 != (( nWhich2 == nWhich1 )
     688         763 :                      ? m_aSet.ClearItem( nWhich1 )
     689       19011 :                      : m_aSet.ClearItem_BC( nWhich1, nWhich2 ));
     690             : 
     691     1329915 :     SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
     692     2659830 :               aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
     693     1329915 :     bool bRet = 0 != m_aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew );
     694     1329915 :     if( bRet )
     695             :     {
     696       19822 :         SwAttrSetChg aChgOld( m_aSet, aOld );
     697       39644 :         SwAttrSetChg aChgNew( m_aSet, aNew );
     698       39644 :         ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
     699             :     }
     700     2659830 :     return bRet;
     701             : }
     702             : 
     703             : // #i73790#
     704        7124 : sal_uInt16 SwFormat::ResetAllFormatAttr()
     705             : {
     706        7124 :     if( !m_aSet.Count() )
     707        2573 :         return 0;
     708             : 
     709        4551 :     if ( IsInCache() )
     710             :     {
     711          15 :         SwFrm::GetCache().Delete( this );
     712          15 :         SetInCache( false );
     713             :     }
     714        4551 :     SetInSwFntCache( false );
     715             : 
     716             :     // if Modify is locked then no modifications will be sent
     717        4551 :     if( IsModifyLocked() )
     718           0 :         return m_aSet.ClearItem( 0 );
     719             : 
     720        4551 :     SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
     721        9102 :               aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
     722        4551 :     bool bRet = 0 != m_aSet.ClearItem_BC( 0, &aOld, &aNew );
     723        4551 :     if( bRet )
     724             :     {
     725        4551 :         SwAttrSetChg aChgOld( m_aSet, aOld );
     726        9102 :         SwAttrSetChg aChgNew( m_aSet, aNew );
     727        9102 :         ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
     728             :     }
     729        9102 :     return aNew.Count();
     730             : }
     731             : 
     732     1206492 : bool SwFormat::GetInfo( SfxPoolItem& rInfo ) const
     733             : {
     734     1206492 :     return SwModify::GetInfo( rInfo );
     735             : }
     736             : 
     737       30400 : void SwFormat::DelDiffs( const SfxItemSet& rSet )
     738             : {
     739       30400 :     if( !m_aSet.Count() )
     740         458 :         return;
     741             : 
     742       30171 :     if ( IsInCache() )
     743             :     {
     744           5 :         SwFrm::GetCache().Delete( this );
     745           5 :         SetInCache( false );
     746             :     }
     747       30171 :     SetInSwFntCache( false );
     748             : 
     749             :     // if Modify is locked then no modifications will be sent
     750       30171 :     if( IsModifyLocked() )
     751             :     {
     752           0 :         m_aSet.Intersect( rSet );
     753           0 :         return;
     754             :     }
     755             : 
     756       30171 :     SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
     757       60342 :               aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
     758       30171 :     bool bRet = 0 != m_aSet.Intersect_BC( rSet, &aOld, &aNew );
     759       30171 :     if( bRet )
     760             :     {
     761       19789 :         SwAttrSetChg aChgOld( m_aSet, aOld );
     762       39578 :         SwAttrSetChg aChgNew( m_aSet, aNew );
     763       39578 :         ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
     764       30171 :     }
     765             : }
     766             : 
     767             : /** SwFormat::IsBackgroundTransparent
     768             : 
     769             :     Virtual method to determine, if background of format is transparent.
     770             :     Default implementation returns false. Thus, subclasses have to override
     771             :     method, if the specific subclass can have a transparent background.
     772             : 
     773             :     @return false, default implementation
     774             : */
     775           0 : bool SwFormat::IsBackgroundTransparent() const
     776             : {
     777           0 :     return false;
     778             : }
     779             : 
     780             : /*
     781             :  * Document Interface Access
     782             :  */
     783      776346 : const IDocumentSettingAccess* SwFormat::getIDocumentSettingAccess() const { return & GetDoc()->GetDocumentSettingManager(); }
     784       14517 : const IDocumentDrawModelAccess* SwFormat::getIDocumentDrawModelAccess() const { return & GetDoc()->getIDocumentDrawModelAccess(); }
     785      170084 : IDocumentDrawModelAccess* SwFormat::getIDocumentDrawModelAccess() { return & GetDoc()->getIDocumentDrawModelAccess(); }
     786         297 : const IDocumentLayoutAccess* SwFormat::getIDocumentLayoutAccess() const { return &GetDoc()->getIDocumentLayoutAccess(); }
     787    26821554 : IDocumentLayoutAccess* SwFormat::getIDocumentLayoutAccess() { return &GetDoc()->getIDocumentLayoutAccess(); }
     788        5773 : IDocumentTimerAccess* SwFormat::getIDocumentTimerAccess() { return & GetDoc()->getIDocumentTimerAccess(); }
     789        3042 : IDocumentFieldsAccess* SwFormat::getIDocumentFieldsAccess() { return &GetDoc()->getIDocumentFieldsAccess(); }
     790           0 : IDocumentChartDataProviderAccess* SwFormat::getIDocumentChartDataProviderAccess() { return & GetDoc()->getIDocumentChartDataProviderAccess(); }
     791             : 
     792       10735 : void SwFormat::GetGrabBagItem(uno::Any& rVal) const
     793             : {
     794       10735 :     if (m_pGrabBagItem.get())
     795        6889 :         m_pGrabBagItem->QueryValue(rVal);
     796             :     else
     797             :     {
     798        3846 :         uno::Sequence<beans::PropertyValue> aValue(0);
     799        3846 :         rVal = uno::makeAny(aValue);
     800             :     }
     801       10735 : }
     802             : 
     803       25866 : void SwFormat::SetGrabBagItem(const uno::Any& rVal)
     804             : {
     805       25866 :     if (!m_pGrabBagItem.get())
     806       25840 :         m_pGrabBagItem.reset(new SfxGrabBagItem);
     807             : 
     808       25866 :     m_pGrabBagItem->PutValue(rVal);
     809       25866 : }
     810             : 
     811             : //UUUU
     812       32725 : SvxBrushItem SwFormat::makeBackgroundBrushItem(bool bInP) const
     813             : {
     814       32725 :     if (supportsFullDrawingLayerFillAttributeSet())
     815             :     {
     816             :         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
     817             :         SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
     818             : 
     819             :         // fill the local static SvxBrushItem from the current ItemSet so that
     820             :         // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
     821             :         // as good as possible to create a fallback representation and return that
     822        3257 :         return getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bInP);
     823             :     }
     824             : 
     825       29468 :     return m_aSet.GetBackground(bInP);
     826             : }
     827             : 
     828             : //UUUU
     829           0 : drawinglayer::attribute::SdrAllFillAttributesHelperPtr SwFormat::getSdrAllFillAttributesHelper() const
     830             : {
     831           0 :     return drawinglayer::attribute::SdrAllFillAttributesHelperPtr();
     832         177 : }
     833             : 
     834             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11